From 028d3aeeb899d37e04aabc6933b8e87afedcb624 Mon Sep 17 00:00:00 2001 From: Fernando Santos Date: Fri, 22 Nov 2024 18:13:23 -0500 Subject: [PATCH] ENgrid Update --- dist/engrid.css | 6 +- dist/engrid.js | 448 +++++++++++++++++------------------- dist/engrid.min.css | 6 +- dist/engrid.min.js | 8 +- package-lock.json | 12 +- src/index.ts | 2 +- src/scripts/optin-ladder.ts | 243 ------------------- 7 files changed, 225 insertions(+), 500 deletions(-) delete mode 100644 src/scripts/optin-ladder.ts diff --git a/dist/engrid.css b/dist/engrid.css index f68ed2d..9829d17 100644 --- a/dist/engrid.css +++ b/dist/engrid.css @@ -19,10 +19,10 @@ * * ENGRID PAGE TEMPLATE ASSETS * - * Date: Sunday, November 17, 2024 @ 22:04:49 ET + * Date: Friday, November 22, 2024 @ 18:07:17 ET * By: fernando - * ENGrid styles: v0.19.20 - * ENGrid scripts: v0.19.21 + * ENGrid styles: v0.20.0 + * ENGrid scripts: v0.20.1 * * Created by 4Site Studios * Come work with us or join our team, we would love to hear from you diff --git a/dist/engrid.js b/dist/engrid.js index 7ad9564..0042c6a 100644 --- a/dist/engrid.js +++ b/dist/engrid.js @@ -17,10 +17,10 @@ * * ENGRID PAGE TEMPLATE ASSETS * - * Date: Sunday, November 17, 2024 @ 22:04:49 ET + * Date: Friday, November 22, 2024 @ 18:07:17 ET * By: fernando - * ENGrid styles: v0.19.20 - * ENGrid scripts: v0.19.21 + * ENGrid styles: v0.20.0 + * ENGrid scripts: v0.20.1 * * Created by 4Site Studios * Come work with us or join our team, we would love to hear from you @@ -13431,10 +13431,10 @@ class InputPlaceholders { "input#en__field_supporter_emailAddress": "Email Address", "input#en__field_supporter_phoneNumber": "Phone Number (Optional)", ".en__mandatory input#en__field_supporter_phoneNumber": "Phone Number", - ".required-if-visible input#en__field_supporter_phoneNumber": "Phone Number", + ".i-required input#en__field_supporter_phoneNumber": "Phone Number", "input#en__field_supporter_phoneNumber2": "000-000-0000 (Optional)", ".en__mandatory input#en__field_supporter_phoneNumber2": "000-000-0000", - ".required-if-visible input#en__field_supporter_phoneNumber2": "000-000-0000", + ".i-required input#en__field_supporter_phoneNumber2": "000-000-0000", "input#en__field_supporter_country": "Country", "input#en__field_supporter_address1": "Street Address", "input#en__field_supporter_address2": "Apt., Ste., Bldg.", @@ -21823,8 +21823,209 @@ class CheckboxLabel { } } +;// CONCATENATED MODULE: ./node_modules/@4site/engrid-scripts/dist/optin-ladder.js +// This component is responsible for showing a ladder of checkboxes, one at a time, to the user. +// If the page is not embedded in an iframe, and there are EN's Opt-In fields on the page, we will store the values to sessionStorage upon Form Submit. +// If the page is embedded in an iframe and on a Thank You Page, we will look for .optin-ladder elements, compare the values to sessionStorage, and show the next checkbox in the ladder, removing all but the first match. +// If the page is embedded in an iframe and on a Thank You Page, and the child iFrame is also a Thank You Page, we will look for a sessionStorage that has the current ladder step and the total number of steps. +// If the current step is less than the total number of steps, we will redirect to the first page. If the current step is equal to the total number of steps, we will show the Thank You Page. + +class OptInLadder { + constructor() { + this.logger = new EngridLogger("OptInLadder", "lightgreen", "darkgreen", "✔"); + this._form = EnForm.getInstance(); + if (!this.inIframe()) { + this.runAsParent(); + } + else if (engrid_ENGrid.getPageNumber() === 1) { + this.runAsChildRegular(); + } + else { + this.runAsChildThankYou(); + } + } + runAsParent() { + // Grab all the checkboxes with the name starting with "supporter.questions" + const checkboxes = document.querySelectorAll('input[name^="supporter.questions"]'); + if (checkboxes.length === 0) { + this.logger.log("No checkboxes found"); + return; + } + this._form.onSubmit.subscribe(() => { + // Save the checkbox values to sessionStorage + this.saveOptInsToSessionStorage(); + }); + this.logger.log("Running as Parent"); + if (engrid_ENGrid.getPageNumber() === 1) { + // Delete supporter.questions from sessionStorage + sessionStorage.removeItem("engrid.supporter.questions"); + } + } + runAsChildRegular() { + if (!this.isEmbeddedThankYouPage()) { + this.logger.log("Not Embedded on a Thank You Page"); + return; + } + const optInHeaders = document.querySelectorAll(".en__component--copyblock.optin-ladder"); + const optInFormBlocks = document.querySelectorAll(".en__component--formblock.optin-ladder"); + if (optInHeaders.length === 0 && optInFormBlocks.length === 0) { + this.logger.log("No optin-ladder elements found"); + return; + } + // Check if the e-mail field exist and is not empty + const emailField = engrid_ENGrid.getField("supporter.emailAddress"); + if (!emailField || !emailField.value) { + this.logger.log("Email field is empty"); + // Since this is a OptInLadder page with no e-mail address, hide the page + this.hidePage(); + return; + } + const sessionStorageCheckboxValues = JSON.parse(sessionStorage.getItem("engrid.supporter.questions") || "{}"); + let currentStep = 0; + let totalSteps = optInHeaders.length; + let currentHeader = null; + let currentFormBlock = null; + for (let i = 0; i < optInHeaders.length; i++) { + const header = optInHeaders[i]; + // Get the optin number from the .optin-ladder-XXXX class + const optInNumber = header.className.match(/optin-ladder-(\d+)/); + if (!optInNumber) { + this.logger.error(`No optin number found in ${header.innerText.trim()}`); + return; + } + const optInIndex = optInNumber[1]; + // Get the checkbox FormBlock + const formBlock = document.querySelector(`.en__component--formblock.optin-ladder:has(.en__field--${optInIndex})`); + if (!formBlock) { + this.logger.log(`No form block found for ${header.innerText.trim()}`); + // Remove the header if there is no form block + header.remove(); + // Increment the current step + currentStep++; + continue; + } + // Check if the optInIndex is in sessionStorage + if (sessionStorageCheckboxValues[optInIndex] === "Y") { + // If the checkbox is checked, remove the header and form block + header.remove(); + formBlock.remove(); + // Increment the current step + currentStep++; + continue; + } + // If there's a header and a form block, end the loop + currentHeader = header; + currentFormBlock = formBlock; + currentStep++; + break; + } + if (!currentHeader || !currentFormBlock) { + this.logger.log("No optin-ladder elements found"); + // Set the current step to the total steps to avoid redirecting to the first page + currentStep = totalSteps; + this.saveStepToSessionStorage(currentStep, totalSteps); + // hide the page + this.hidePage(); + return; + } + // Show the current header and form block, while removing the rest + optInHeaders.forEach((header) => { + if (header !== currentHeader) { + header.remove(); + } + else { + header.style.display = "block"; + } + }); + optInFormBlocks.forEach((formBlock) => { + if (formBlock !== currentFormBlock) { + formBlock.remove(); + } + else { + formBlock.style.display = "block"; + } + }); + // Save the current step to sessionStorage + this.saveStepToSessionStorage(currentStep, totalSteps); + // On form submit, save the checkbox values to sessionStorage + this._form.onSubmit.subscribe(() => { + this.saveOptInsToSessionStorage(); + // Save the current step to sessionStorage + currentStep++; + this.saveStepToSessionStorage(currentStep, totalSteps); + }); + } + runAsChildThankYou() { + if (!this.isEmbeddedThankYouPage()) { + this.logger.log("Not Embedded on a Thank You Page"); + return; + } + const sessionStorageOptInLadder = JSON.parse(sessionStorage.getItem("engrid.optin-ladder") || "{}"); + const currentStep = sessionStorageOptInLadder.step || 0; + const totalSteps = sessionStorageOptInLadder.totalSteps || 0; + if (currentStep < totalSteps) { + this.logger.log(`Current step ${currentStep} is less than total steps ${totalSteps}`); + // Redirect to the first page + window.location.href = this.getFirstPageUrl(); + return; + } + else { + this.logger.log(`Current step ${currentStep} is equal to total steps ${totalSteps}`); + // Remove the session storage + sessionStorage.removeItem("engrid.optin-ladder"); + } + } + inIframe() { + try { + return window.self !== window.top; + } + catch (e) { + return true; + } + } + saveStepToSessionStorage(step, totalSteps) { + sessionStorage.setItem("engrid.optin-ladder", JSON.stringify({ step, totalSteps })); + this.logger.log(`Saved step ${step} of ${totalSteps} to sessionStorage`); + } + getFirstPageUrl() { + // Get the current URL and replace the last path with 1?chain + const url = new URL(window.location.href); + const path = url.pathname.split("/"); + path.pop(); + path.push("1"); + return url.origin + path.join("/") + "?chain"; + } + saveOptInsToSessionStorage() { + // Grab all the checkboxes with the name starting with "supporter.questions" + const checkboxes = document.querySelectorAll('input[name^="supporter.questions"]'); + if (checkboxes.length === 0) { + this.logger.log("No checkboxes found"); + return; + } + const sessionStorageCheckboxValues = JSON.parse(sessionStorage.getItem("engrid.supporter.questions") || "{}"); + // Loop through all the checkboxes and store the value in sessionStorage + checkboxes.forEach((checkbox) => { + if (checkbox.checked) { + const index = checkbox.name.split(".")[2]; + sessionStorageCheckboxValues[index] = "Y"; + } + }); + sessionStorage.setItem("engrid.supporter.questions", JSON.stringify(sessionStorageCheckboxValues)); + this.logger.log(`Saved checkbox values to sessionStorage: ${JSON.stringify(sessionStorageCheckboxValues)}`); + } + isEmbeddedThankYouPage() { + return engrid_ENGrid.getBodyData("embedded") === "thank-you-page-donation"; + } + hidePage() { + const engridPage = document.querySelector("#engrid"); + if (engridPage) { + engridPage.classList.add("hide"); + } + } +} + ;// CONCATENATED MODULE: ./node_modules/@4site/engrid-scripts/dist/version.js -const AppVersion = "0.19.21"; +const AppVersion = "0.20.1"; ;// CONCATENATED MODULE: ./node_modules/@4site/engrid-scripts/dist/index.js // Runs first so it can change the DOM markup before any markup dependent code fires @@ -21907,6 +22108,7 @@ const AppVersion = "0.19.21"; + // Events @@ -23033,239 +23235,6 @@ class AddDAF { }); } -} -;// CONCATENATED MODULE: ./src/scripts/optin-ladder.ts - -// This component is responsible for showing a ladder of checkboxes, one at a time, to the user. -// If the page is not embedded in an iframe, and there are checkboxes on the page, we will store the checkbox value to sessionStorage upon Form Submit. -// If the page is embedded in an iframe and on a Thank You Page, we will look for .optin-ladder elements, compare the values to sessionStorage, and show the next checkbox in the ladder, removing all but the first. -// If the page is embedded in an iframe and on a Thank You Page, and the child iFrame is also a Thank You Page, we will look for a sessionStorage that has the current ladder step and the total number of steps. -// If the current step is less than the total number of steps, we will redirect to the first page. If the current step is equal to the total number of steps, we will show the Thank You Page. - -class OptInLadder { - constructor() { - _defineProperty(this, "logger", new EngridLogger("OptInLadder", "lightgreen", "darkgreen", "✔")); - - _defineProperty(this, "_form", EnForm.getInstance()); - - if (!this.inIframe()) { - this.runAsParent(); - } else if (engrid_ENGrid.getPageNumber() === 1) { - this.runAsChildRegular(); - } else { - this.runAsChildThankYou(); - } - } - - runAsParent() { - // Grab all the checkboxes with the name starting with "supporter.questions" - const checkboxes = document.querySelectorAll('input[name^="supporter.questions"]'); - - if (checkboxes.length === 0) { - this.logger.log("No checkboxes found"); - return; - } - - this._form.onSubmit.subscribe(() => { - // Save the checkbox values to sessionStorage - this.saveOptInsToSessionStorage(); - }); - - this.logger.log("Running as Parent"); - - if (engrid_ENGrid.getPageNumber() === 1) { - // Delete supporter.questions from sessionStorage - sessionStorage.removeItem("engrid.supporter.questions"); - } - } - - runAsChildRegular() { - if (!this.isEmbeddedThankYouPage()) { - this.logger.log("Not Embedded on a Thank You Page"); - return; - } - - const optInHeaders = document.querySelectorAll(".en__component--copyblock.optin-ladder"); - const optInFormBlocks = document.querySelectorAll(".en__component--formblock.optin-ladder"); - - if (optInHeaders.length === 0 && optInFormBlocks.length === 0) { - this.logger.log("No optin-ladder elements found"); - return; - } // Check if the e-mail field exist and is not empty - - - const emailField = engrid_ENGrid.getField("supporter.emailAddress"); - - if (!emailField || !emailField.value) { - this.logger.log("Email field is empty"); // Since this is a OptInLadder page with no e-mail address, hide the page - - this.hidePage(); - return; - } - - const sessionStorageCheckboxValues = JSON.parse(sessionStorage.getItem("engrid.supporter.questions") || "{}"); - let currentStep = 0; - let totalSteps = optInHeaders.length; - let currentHeader = null; - let currentFormBlock = null; - - for (let i = 0; i < optInHeaders.length; i++) { - const header = optInHeaders[i]; // Get the optin number from the .optin-ladder-XXXX class - - const optInNumber = header.className.match(/optin-ladder-(\d+)/); - - if (!optInNumber) { - this.logger.error(`No optin number found in ${header.innerText.trim()}`); - return; - } - - const optInIndex = optInNumber[1]; // Get the checkbox FormBlock - - const formBlock = document.querySelector(`.en__component--formblock.optin-ladder:has(.en__field--${optInIndex})`); - - if (!formBlock) { - this.logger.log(`No form block found for ${header.innerText.trim()}`); // Remove the header if there is no form block - - header.remove(); // Increment the current step - - currentStep++; - continue; - } // Check if the optInIndex is in sessionStorage - - - if (sessionStorageCheckboxValues[optInIndex] === "Y") { - // If the checkbox is checked, remove the header and form block - header.remove(); - formBlock.remove(); // Increment the current step - - currentStep++; - continue; - } // If there's a header and a form block, end the loop - - - currentHeader = header; - currentFormBlock = formBlock; - currentStep++; - break; - } - - if (!currentHeader || !currentFormBlock) { - this.logger.log("No optin-ladder elements found"); // Set the current step to the total steps to avoid redirecting to the first page - - currentStep = totalSteps; - this.saveStepToSessionStorage(currentStep, totalSteps); // hide the page - - this.hidePage(); - return; - } // Show the current header and form block, while removing the rest - - - optInHeaders.forEach(header => { - if (header !== currentHeader) { - header.remove(); - } else { - header.style.display = "block"; - } - }); - optInFormBlocks.forEach(formBlock => { - if (formBlock !== currentFormBlock) { - formBlock.remove(); - } else { - formBlock.style.display = "block"; - } - }); // Save the current step to sessionStorage - - this.saveStepToSessionStorage(currentStep, totalSteps); // On form submit, save the checkbox values to sessionStorage - - this._form.onSubmit.subscribe(() => { - this.saveOptInsToSessionStorage(); // Save the current step to sessionStorage - - currentStep++; - this.saveStepToSessionStorage(currentStep, totalSteps); - }); - } - - runAsChildThankYou() { - if (!this.isEmbeddedThankYouPage()) { - this.logger.log("Not Embedded on a Thank You Page"); - return; - } - - const sessionStorageOptInLadder = JSON.parse(sessionStorage.getItem("engrid.optin-ladder") || "{}"); - const currentStep = sessionStorageOptInLadder.step || 0; - const totalSteps = sessionStorageOptInLadder.totalSteps || 0; - - if (currentStep < totalSteps) { - this.logger.log(`Current step ${currentStep} is less than total steps ${totalSteps}`); // Redirect to the first page - - window.location.href = this.getFirstPageUrl(); - return; - } else { - this.logger.log(`Current step ${currentStep} is equal to total steps ${totalSteps}`); // Remove the session storage - - sessionStorage.removeItem("engrid.optin-ladder"); - } - } - - inIframe() { - try { - return window.self !== window.top; - } catch (e) { - return true; - } - } - - saveStepToSessionStorage(step, totalSteps) { - sessionStorage.setItem("engrid.optin-ladder", JSON.stringify({ - step, - totalSteps - })); - this.logger.log(`Saved step ${step} of ${totalSteps} to sessionStorage`); - } - - getFirstPageUrl() { - // URL Example: https://act.ran.org/page/75744/{alpha}/2 - // We want to change the URL to https://act.ran.org/page/75744/{alpha}/1 - const url = new URL(window.location.href); - const path = url.pathname.split("/"); - path.pop(); - path.push("1"); - return url.origin + path.join("/") + "?chain"; - } - - saveOptInsToSessionStorage() { - // Grab all the checkboxes with the name starting with "supporter.questions" - const checkboxes = document.querySelectorAll('input[name^="supporter.questions"]'); - - if (checkboxes.length === 0) { - this.logger.log("No checkboxes found"); - return; - } - - const sessionStorageCheckboxValues = JSON.parse(sessionStorage.getItem("engrid.supporter.questions") || "{}"); // Loop through all the checkboxes and store the value in sessionStorage - - checkboxes.forEach(checkbox => { - if (checkbox.checked) { - const index = checkbox.name.split(".")[2]; - sessionStorageCheckboxValues[index] = "Y"; - } - }); - sessionStorage.setItem("engrid.supporter.questions", JSON.stringify(sessionStorageCheckboxValues)); - this.logger.log(`Saved checkbox values to sessionStorage: ${JSON.stringify(sessionStorageCheckboxValues)}`); - } - - isEmbeddedThankYouPage() { - return engrid_ENGrid.getBodyData("embedded") === "thank-you-page-donation"; - } - - hidePage() { - const engridPage = document.querySelector("#engrid"); - - if (engridPage) { - engridPage.classList.add("hide"); - } - } - } ;// CONCATENATED MODULE: ./src/index.ts // Uses ENGrid via NPM @@ -23281,7 +23250,6 @@ class OptInLadder { - const options = { applePay: false, AutoYear: true, diff --git a/dist/engrid.min.css b/dist/engrid.min.css index d0e6803..6a5b504 100644 --- a/dist/engrid.min.css +++ b/dist/engrid.min.css @@ -18,10 +18,10 @@ * * ENGRID PAGE TEMPLATE ASSETS * - * Date: Sunday, November 17, 2024 @ 22:04:49 ET + * Date: Friday, November 22, 2024 @ 18:07:17 ET * By: fernando - * ENGrid styles: v0.19.20 - * ENGrid scripts: v0.19.21 + * ENGrid styles: v0.20.0 + * ENGrid scripts: v0.20.1 * * Created by 4Site Studios * Come work with us or join our team, we would love to hear from you diff --git a/dist/engrid.min.js b/dist/engrid.min.js index a576953..d28b1f7 100644 --- a/dist/engrid.min.js +++ b/dist/engrid.min.js @@ -17,10 +17,10 @@ * * ENGRID PAGE TEMPLATE ASSETS * - * Date: Sunday, November 17, 2024 @ 22:04:49 ET + * Date: Friday, November 22, 2024 @ 18:07:17 ET * By: fernando - * ENGrid styles: v0.19.20 - * ENGrid scripts: v0.19.21 + * ENGrid styles: v0.20.0 + * ENGrid scripts: v0.20.1 * * Created by 4Site Studios * Come work with us or join our team, we would love to hear from you @@ -107,4 +107,4 @@ t.nz=t.FK=void 0;var i=n(782);var s=n(8756);var o=n(7959);Object.defineProperty( * * Copyright Kees C. Bakker / KeesTalksTech * Released under the MIT license - */Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionChangeEventDispatcher=t.HandlingBase=t.PromiseDispatcherBase=t.PromiseSubscription=t.DispatchError=t.EventManagement=t.EventListBase=t.DispatcherWrapper=t.DispatcherBase=t.Subscription=void 0;const i=n(3040);Object.defineProperty(t,"DispatcherBase",{enumerable:!0,get:function(){return i.DispatcherBase}});const s=n(8181);Object.defineProperty(t,"DispatchError",{enumerable:!0,get:function(){return s.DispatchError}});const o=n(3122);Object.defineProperty(t,"DispatcherWrapper",{enumerable:!0,get:function(){return o.DispatcherWrapper}});const r=n(7955);Object.defineProperty(t,"EventListBase",{enumerable:!0,get:function(){return r.EventListBase}});const a=n(2234);Object.defineProperty(t,"EventManagement",{enumerable:!0,get:function(){return a.EventManagement}});const l=n(1605);Object.defineProperty(t,"HandlingBase",{enumerable:!0,get:function(){return l.HandlingBase}});const c=n(2490);Object.defineProperty(t,"PromiseDispatcherBase",{enumerable:!0,get:function(){return c.PromiseDispatcherBase}});const d=n(9347);Object.defineProperty(t,"PromiseSubscription",{enumerable:!0,get:function(){return d.PromiseSubscription}});const u=n(2229);Object.defineProperty(t,"Subscription",{enumerable:!0,get:function(){return u.Subscription}});const h=n(1002);Object.defineProperty(t,"SubscriptionChangeEventDispatcher",{enumerable:!0,get:function(){return h.SubscriptionChangeEventDispatcher}})},2234:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventManagement=void 0;t.EventManagement=class{constructor(e){this.unsub=e,this.propagationStopped=!1}stopPropagation(){this.propagationStopped=!0}}},3861:(e,t,n)=>{"use strict";function i(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function s(e){return e instanceof i(e).Element||e instanceof Element}function o(e){return e instanceof i(e).HTMLElement||e instanceof HTMLElement}function r(e){return"undefined"!=typeof ShadowRoot&&(e instanceof i(e).ShadowRoot||e instanceof ShadowRoot)}n.d(t,{ZP:()=>rt});var a=Math.max,l=Math.min,c=Math.round;function d(e,t){void 0===t&&(t=!1);var n=e.getBoundingClientRect(),i=1,s=1;if(o(e)&&t){var r=e.offsetHeight,a=e.offsetWidth;a>0&&(i=c(n.width)/a||1),r>0&&(s=c(n.height)/r||1)}return{width:n.width/i,height:n.height/s,top:n.top/s,right:n.right/i,bottom:n.bottom/s,left:n.left/i,x:n.left/i,y:n.top/s}}function u(e){var t=i(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function h(e){return e?(e.nodeName||"").toLowerCase():null}function p(e){return((s(e)?e.ownerDocument:e.document)||window.document).documentElement}function g(e){return d(p(e)).left+u(e).scrollLeft}function m(e){return i(e).getComputedStyle(e)}function f(e){var t=m(e),n=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+s+i)}function b(e,t,n){void 0===n&&(n=!1);var s,r,a=o(t),l=o(t)&&function(e){var t=e.getBoundingClientRect(),n=c(t.width)/e.offsetWidth||1,i=c(t.height)/e.offsetHeight||1;return 1!==n||1!==i}(t),m=p(t),b=d(e,l),v={scrollLeft:0,scrollTop:0},y={x:0,y:0};return(a||!a&&!n)&&(("body"!==h(t)||f(m))&&(v=(s=t)!==i(s)&&o(s)?{scrollLeft:(r=s).scrollLeft,scrollTop:r.scrollTop}:u(s)),o(t)?((y=d(t,!0)).x+=t.clientLeft,y.y+=t.clientTop):m&&(y.x=g(m))),{x:b.left+v.scrollLeft-y.x,y:b.top+v.scrollTop-y.y,width:b.width,height:b.height}}function v(e){var t=d(e),n=e.offsetWidth,i=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:i}}function y(e){return"html"===h(e)?e:e.assignedSlot||e.parentNode||(r(e)?e.host:null)||p(e)}function _(e){return["html","body","#document"].indexOf(h(e))>=0?e.ownerDocument.body:o(e)&&f(e)?e:_(y(e))}function S(e,t){var n;void 0===t&&(t=[]);var s=_(e),o=s===(null==(n=e.ownerDocument)?void 0:n.body),r=i(s),a=o?[r].concat(r.visualViewport||[],f(s)?s:[]):s,l=t.concat(a);return o?l:l.concat(S(y(a)))}function w(e){return["table","td","th"].indexOf(h(e))>=0}function E(e){return o(e)&&"fixed"!==m(e).position?e.offsetParent:null}function A(e){for(var t=i(e),n=E(e);n&&w(n)&&"static"===m(n).position;)n=E(n);return n&&("html"===h(n)||"body"===h(n)&&"static"===m(n).position)?t:n||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&o(e)&&"fixed"===m(e).position)return null;for(var n=y(e);o(n)&&["html","body"].indexOf(h(n))<0;){var i=m(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||t}var L="top",C="bottom",k="right",x="left",D="auto",F=[L,C,k,x],P="start",N="end",T="viewport",O="popper",q=F.reduce((function(e,t){return e.concat([t+"-"+P,t+"-"+N])}),[]),M=[].concat(F,[D]).reduce((function(e,t){return e.concat([t,t+"-"+P,t+"-"+N])}),[]),I=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function B(e){var t=new Map,n=new Set,i=[];function s(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var i=t.get(e);i&&s(i)}})),i.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||s(e)})),i}var R={placement:"bottom",modifiers:[],strategy:"absolute"};function j(){for(var e=arguments.length,t=new Array(e),n=0;n=0?"x":"y"}function G(e){var t,n=e.reference,i=e.element,s=e.placement,o=s?V(s):null,r=s?$(s):null,a=n.x+n.width/2-i.width/2,l=n.y+n.height/2-i.height/2;switch(o){case L:t={x:a,y:n.y-i.height};break;case C:t={x:a,y:n.y+n.height};break;case k:t={x:n.x+n.width,y:l};break;case x:t={x:n.x-i.width,y:l};break;default:t={x:n.x,y:n.y}}var c=o?W(o):null;if(null!=c){var d="y"===c?"height":"width";switch(r){case P:t[c]=t[c]-(n[d]/2-i[d]/2);break;case N:t[c]=t[c]+(n[d]/2-i[d]/2)}}return t}var Y={top:"auto",right:"auto",bottom:"auto",left:"auto"};function J(e){var t,n=e.popper,s=e.popperRect,o=e.placement,r=e.variation,a=e.offsets,l=e.position,d=e.gpuAcceleration,u=e.adaptive,h=e.roundOffsets,g=e.isFixed,f=a.x,b=void 0===f?0:f,v=a.y,y=void 0===v?0:v,_="function"==typeof h?h({x:b,y}):{x:b,y};b=_.x,y=_.y;var S=a.hasOwnProperty("x"),w=a.hasOwnProperty("y"),E=x,D=L,F=window;if(u){var P=A(n),T="clientHeight",O="clientWidth";if(P===i(n)&&"static"!==m(P=p(n)).position&&"absolute"===l&&(T="scrollHeight",O="scrollWidth"),P=P,o===L||(o===x||o===k)&&r===N)D=C,y-=(g&&F.visualViewport?F.visualViewport.height:P[T])-s.height,y*=d?1:-1;if(o===x||(o===L||o===C)&&r===N)E=k,b-=(g&&F.visualViewport?F.visualViewport.width:P[O])-s.width,b*=d?1:-1}var q,M=Object.assign({position:l},u&&Y),I=!0===h?function(e){var t=e.x,n=e.y,i=window.devicePixelRatio||1;return{x:c(t*i)/i||0,y:c(n*i)/i||0}}({x:b,y}):{x:b,y};return b=I.x,y=I.y,d?Object.assign({},M,((q={})[D]=w?"0":"",q[E]=S?"0":"",q.transform=(F.devicePixelRatio||1)<=1?"translate("+b+"px, "+y+"px)":"translate3d("+b+"px, "+y+"px, 0)",q)):Object.assign({},M,((t={})[D]=w?y+"px":"",t[E]=S?b+"px":"",t.transform="",t))}const z={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},i=t.attributes[e]||{},s=t.elements[e];o(s)&&h(s)&&(Object.assign(s.style,n),Object.keys(i).forEach((function(e){var t=i[e];!1===t?s.removeAttribute(e):s.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var i=t.elements[e],s=t.attributes[e]||{},r=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});o(i)&&h(i)&&(Object.assign(i.style,r),Object.keys(s).forEach((function(e){i.removeAttribute(e)})))}))}},requires:["computeStyles"]};const K={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,i=e.name,s=n.offset,o=void 0===s?[0,0]:s,r=M.reduce((function(e,n){return e[n]=function(e,t,n){var i=V(e),s=[x,L].indexOf(i)>=0?-1:1,o="function"==typeof n?n(Object.assign({},t,{placement:e})):n,r=o[0],a=o[1];return r=r||0,a=(a||0)*s,[x,k].indexOf(i)>=0?{x:a,y:r}:{x:r,y:a}}(n,t.rects,o),e}),{}),a=r[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[i]=r}};var X={left:"right",right:"left",bottom:"top",top:"bottom"};function Q(e){return e.replace(/left|right|bottom|top/g,(function(e){return X[e]}))}var Z={start:"end",end:"start"};function ee(e){return e.replace(/start|end/g,(function(e){return Z[e]}))}function te(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&r(n)){var i=t;do{if(i&&e.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function ne(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function ie(e,t){return t===T?ne(function(e){var t=i(e),n=p(e),s=t.visualViewport,o=n.clientWidth,r=n.clientHeight,a=0,l=0;return s&&(o=s.width,r=s.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(a=s.offsetLeft,l=s.offsetTop)),{width:o,height:r,x:a+g(e),y:l}}(e)):s(t)?function(e){var t=d(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(t):ne(function(e){var t,n=p(e),i=u(e),s=null==(t=e.ownerDocument)?void 0:t.body,o=a(n.scrollWidth,n.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),r=a(n.scrollHeight,n.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),l=-i.scrollLeft+g(e),c=-i.scrollTop;return"rtl"===m(s||n).direction&&(l+=a(n.clientWidth,s?s.clientWidth:0)-o),{width:o,height:r,x:l,y:c}}(p(e)))}function se(e,t,n){var i="clippingParents"===t?function(e){var t=S(y(e)),n=["absolute","fixed"].indexOf(m(e).position)>=0&&o(e)?A(e):e;return s(n)?t.filter((function(e){return s(e)&&te(e,n)&&"body"!==h(e)})):[]}(e):[].concat(t),r=[].concat(i,[n]),c=r[0],d=r.reduce((function(t,n){var i=ie(e,n);return t.top=a(i.top,t.top),t.right=l(i.right,t.right),t.bottom=l(i.bottom,t.bottom),t.left=a(i.left,t.left),t}),ie(e,c));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function oe(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function re(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function ae(e,t){void 0===t&&(t={});var n=t,i=n.placement,o=void 0===i?e.placement:i,r=n.boundary,a=void 0===r?"clippingParents":r,l=n.rootBoundary,c=void 0===l?T:l,u=n.elementContext,h=void 0===u?O:u,g=n.altBoundary,m=void 0!==g&&g,f=n.padding,b=void 0===f?0:f,v=oe("number"!=typeof b?b:re(b,F)),y=h===O?"reference":O,_=e.rects.popper,S=e.elements[m?y:h],w=se(s(S)?S:S.contextElement||p(e.elements.popper),a,c),E=d(e.elements.reference),A=G({reference:E,element:_,strategy:"absolute",placement:o}),x=ne(Object.assign({},_,A)),D=h===O?x:E,P={top:w.top-D.top+v.top,bottom:D.bottom-w.bottom+v.bottom,left:w.left-D.left+v.left,right:D.right-w.right+v.right},N=e.modifiersData.offset;if(h===O&&N){var q=N[o];Object.keys(P).forEach((function(e){var t=[k,C].indexOf(e)>=0?1:-1,n=[L,C].indexOf(e)>=0?"y":"x";P[e]+=q[n]*t}))}return P}function le(e,t,n){return a(e,l(t,n))}const ce={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name,s=n.mainAxis,o=void 0===s||s,r=n.altAxis,c=void 0!==r&&r,d=n.boundary,u=n.rootBoundary,h=n.altBoundary,p=n.padding,g=n.tether,m=void 0===g||g,f=n.tetherOffset,b=void 0===f?0:f,y=ae(t,{boundary:d,rootBoundary:u,padding:p,altBoundary:h}),_=V(t.placement),S=$(t.placement),w=!S,E=W(_),D="x"===E?"y":"x",F=t.modifiersData.popperOffsets,N=t.rects.reference,T=t.rects.popper,O="function"==typeof b?b(Object.assign({},t.rects,{placement:t.placement})):b,q="number"==typeof O?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),M=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,I={x:0,y:0};if(F){if(o){var B,R="y"===E?L:x,j="y"===E?C:k,H="y"===E?"height":"width",U=F[E],G=U+y[R],Y=U-y[j],J=m?-T[H]/2:0,z=S===P?N[H]:T[H],K=S===P?-T[H]:-N[H],X=t.elements.arrow,Q=m&&X?v(X):{width:0,height:0},Z=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},ee=Z[R],te=Z[j],ne=le(0,N[H],Q[H]),ie=w?N[H]/2-J-ne-ee-q.mainAxis:z-ne-ee-q.mainAxis,se=w?-N[H]/2+J+ne+te+q.mainAxis:K+ne+te+q.mainAxis,oe=t.elements.arrow&&A(t.elements.arrow),re=oe?"y"===E?oe.clientTop||0:oe.clientLeft||0:0,ce=null!=(B=null==M?void 0:M[E])?B:0,de=U+se-ce,ue=le(m?l(G,U+ie-ce-re):G,U,m?a(Y,de):Y);F[E]=ue,I[E]=ue-U}if(c){var he,pe="x"===E?L:x,ge="x"===E?C:k,me=F[D],fe="y"===D?"height":"width",be=me+y[pe],ve=me-y[ge],ye=-1!==[L,x].indexOf(_),_e=null!=(he=null==M?void 0:M[D])?he:0,Se=ye?be:me-N[fe]-T[fe]-_e+q.altAxis,we=ye?me+N[fe]+T[fe]-_e-q.altAxis:ve,Ee=m&&ye?function(e,t,n){var i=le(e,t,n);return i>n?n:i}(Se,me,we):le(m?Se:be,me,m?we:ve);F[D]=Ee,I[D]=Ee-me}t.modifiersData[i]=I}},requiresIfExists:["offset"]};const de={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,i=e.name,s=e.options,o=n.elements.arrow,r=n.modifiersData.popperOffsets,a=V(n.placement),l=W(a),c=[x,k].indexOf(a)>=0?"height":"width";if(o&&r){var d=function(e,t){return oe("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:re(e,F))}(s.padding,n),u=v(o),h="y"===l?L:x,p="y"===l?C:k,g=n.rects.reference[c]+n.rects.reference[l]-r[l]-n.rects.popper[c],m=r[l]-n.rects.reference[l],f=A(o),b=f?"y"===l?f.clientHeight||0:f.clientWidth||0:0,y=g/2-m/2,_=d[h],S=b-u[c]-d[p],w=b/2-u[c]/2+y,E=le(_,w,S),D=l;n.modifiersData[i]=((t={})[D]=E,t.centerOffset=E-w,t)}},effect:function(e){var t=e.state,n=e.options.element,i=void 0===n?"[data-popper-arrow]":n;null!=i&&("string"!=typeof i||(i=t.elements.popper.querySelector(i)))&&te(t.elements.popper,i)&&(t.elements.arrow=i)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function ue(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function he(e){return[L,k,C,x].some((function(t){return e[t]>=0}))}var pe=H({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,s=e.options,o=s.scroll,r=void 0===o||o,a=s.resize,l=void 0===a||a,c=i(t.elements.popper),d=[].concat(t.scrollParents.reference,t.scrollParents.popper);return r&&d.forEach((function(e){e.addEventListener("scroll",n.update,U)})),l&&c.addEventListener("resize",n.update,U),function(){r&&d.forEach((function(e){e.removeEventListener("scroll",n.update,U)})),l&&c.removeEventListener("resize",n.update,U)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=G({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,i=n.gpuAcceleration,s=void 0===i||i,o=n.adaptive,r=void 0===o||o,a=n.roundOffsets,l=void 0===a||a,c={placement:V(t.placement),variation:$(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,J(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:r,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,J(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},z,K,{name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name;if(!t.modifiersData[i]._skip){for(var s=n.mainAxis,o=void 0===s||s,r=n.altAxis,a=void 0===r||r,l=n.fallbackPlacements,c=n.padding,d=n.boundary,u=n.rootBoundary,h=n.altBoundary,p=n.flipVariations,g=void 0===p||p,m=n.allowedAutoPlacements,f=t.options.placement,b=V(f),v=l||(b===f||!g?[Q(f)]:function(e){if(V(e)===D)return[];var t=Q(e);return[ee(e),t,ee(t)]}(f)),y=[f].concat(v).reduce((function(e,n){return e.concat(V(n)===D?function(e,t){void 0===t&&(t={});var n=t,i=n.placement,s=n.boundary,o=n.rootBoundary,r=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?M:l,d=$(i),u=d?a?q:q.filter((function(e){return $(e)===d})):F,h=u.filter((function(e){return c.indexOf(e)>=0}));0===h.length&&(h=u);var p=h.reduce((function(t,n){return t[n]=ae(e,{placement:n,boundary:s,rootBoundary:o,padding:r})[V(n)],t}),{});return Object.keys(p).sort((function(e,t){return p[e]-p[t]}))}(t,{placement:n,boundary:d,rootBoundary:u,padding:c,flipVariations:g,allowedAutoPlacements:m}):n)}),[]),_=t.rects.reference,S=t.rects.popper,w=new Map,E=!0,A=y[0],N=0;N=0,R=B?"width":"height",j=ae(t,{placement:T,boundary:d,rootBoundary:u,altBoundary:h,padding:c}),H=B?I?k:x:I?C:L;_[R]>S[R]&&(H=Q(H));var U=Q(H),W=[];if(o&&W.push(j[O]<=0),a&&W.push(j[H]<=0,j[U]<=0),W.every((function(e){return e}))){A=T,E=!1;break}w.set(T,W)}if(E)for(var G=function(e){var t=y.find((function(t){var n=w.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return A=t,"break"},Y=g?3:1;Y>0;Y--){if("break"===G(Y))break}t.placement!==A&&(t.modifiersData[i]._skip=!0,t.placement=A,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},ce,de,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,i=t.rects.reference,s=t.rects.popper,o=t.modifiersData.preventOverflow,r=ae(t,{elementContext:"reference"}),a=ae(t,{altBoundary:!0}),l=ue(r,i),c=ue(a,s,o),d=he(l),u=he(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:d,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":u})}}]}),ge="tippy-content",me="tippy-backdrop",fe="tippy-arrow",be="tippy-svg-arrow",ve={passive:!0,capture:!0},ye=function(){return document.body};function _e(e,t,n){if(Array.isArray(e)){var i=e[t];return null==i?Array.isArray(n)?n[t]:n:i}return e}function Se(e,t){var n={}.toString.call(e);return 0===n.indexOf("[object")&&n.indexOf(t+"]")>-1}function we(e,t){return"function"==typeof e?e.apply(void 0,t):e}function Ee(e,t){return 0===t?e:function(i){clearTimeout(n),n=setTimeout((function(){e(i)}),t)};var n}function Ae(e){return[].concat(e)}function Le(e,t){-1===e.indexOf(t)&&e.push(t)}function Ce(e){return e.split("-")[0]}function ke(e){return[].slice.call(e)}function xe(e){return Object.keys(e).reduce((function(t,n){return void 0!==e[n]&&(t[n]=e[n]),t}),{})}function De(){return document.createElement("div")}function Fe(e){return["Element","Fragment"].some((function(t){return Se(e,t)}))}function Pe(e){return Se(e,"MouseEvent")}function Ne(e){return!(!e||!e._tippy||e._tippy.reference!==e)}function Te(e){return Fe(e)?[e]:function(e){return Se(e,"NodeList")}(e)?ke(e):Array.isArray(e)?e:ke(document.querySelectorAll(e))}function Oe(e,t){e.forEach((function(e){e&&(e.style.transitionDuration=t+"ms")}))}function qe(e,t){e.forEach((function(e){e&&e.setAttribute("data-state",t)}))}function Me(e){var t,n=Ae(e)[0];return null!=n&&null!=(t=n.ownerDocument)&&t.body?n.ownerDocument:document}function Ie(e,t,n){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach((function(t){e[i](t,n)}))}function Be(e,t){for(var n=t;n;){var i;if(e.contains(n))return!0;n=null==n.getRootNode||null==(i=n.getRootNode())?void 0:i.host}return!1}var Re={isTouch:!1},je=0;function He(){Re.isTouch||(Re.isTouch=!0,window.performance&&document.addEventListener("mousemove",Ue))}function Ue(){var e=performance.now();e-je<20&&(Re.isTouch=!1,document.removeEventListener("mousemove",Ue)),je=e}function Ve(){var e=document.activeElement;if(Ne(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}var $e=!!("undefined"!=typeof window&&"undefined"!=typeof document)&&!!window.msCrypto;var We={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Ge=Object.assign({appendTo:ye,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},We,{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),Ye=Object.keys(Ge);function Je(e){var t=(e.plugins||[]).reduce((function(t,n){var i,s=n.name,o=n.defaultValue;s&&(t[s]=void 0!==e[s]?e[s]:null!=(i=Ge[s])?i:o);return t}),{});return Object.assign({},e,t)}function ze(e,t){var n=Object.assign({},t,{content:we(t.content,[e])},t.ignoreAttributes?{}:function(e,t){return(t?Object.keys(Je(Object.assign({},Ge,{plugins:t}))):Ye).reduce((function(t,n){var i=(e.getAttribute("data-tippy-"+n)||"").trim();if(!i)return t;if("content"===n)t[n]=i;else try{t[n]=JSON.parse(i)}catch(e){t[n]=i}return t}),{})}(e,t.plugins));return n.aria=Object.assign({},Ge.aria,n.aria),n.aria={expanded:"auto"===n.aria.expanded?t.interactive:n.aria.expanded,content:"auto"===n.aria.content?t.interactive?null:"describedby":n.aria.content},n}function Ke(e,t){e.innerHTML=t}function Xe(e){var t=De();return!0===e?t.className=fe:(t.className=be,Fe(e)?t.appendChild(e):Ke(t,e)),t}function Qe(e,t){Fe(t.content)?(Ke(e,""),e.appendChild(t.content)):"function"!=typeof t.content&&(t.allowHTML?Ke(e,t.content):e.textContent=t.content)}function Ze(e){var t=e.firstElementChild,n=ke(t.children);return{box:t,content:n.find((function(e){return e.classList.contains(ge)})),arrow:n.find((function(e){return e.classList.contains(fe)||e.classList.contains(be)})),backdrop:n.find((function(e){return e.classList.contains(me)}))}}function et(e){var t=De(),n=De();n.className="tippy-box",n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var i=De();function s(n,i){var s=Ze(t),o=s.box,r=s.content,a=s.arrow;i.theme?o.setAttribute("data-theme",i.theme):o.removeAttribute("data-theme"),"string"==typeof i.animation?o.setAttribute("data-animation",i.animation):o.removeAttribute("data-animation"),i.inertia?o.setAttribute("data-inertia",""):o.removeAttribute("data-inertia"),o.style.maxWidth="number"==typeof i.maxWidth?i.maxWidth+"px":i.maxWidth,i.role?o.setAttribute("role",i.role):o.removeAttribute("role"),n.content===i.content&&n.allowHTML===i.allowHTML||Qe(r,e.props),i.arrow?a?n.arrow!==i.arrow&&(o.removeChild(a),o.appendChild(Xe(i.arrow))):o.appendChild(Xe(i.arrow)):a&&o.removeChild(a)}return i.className=ge,i.setAttribute("data-state","hidden"),Qe(i,e.props),t.appendChild(n),n.appendChild(i),s(e.props,e.props),{popper:t,onUpdate:s}}et.$$tippy=!0;var tt=1,nt=[],it=[];function st(e,t){var n,i,s,o,r,a,l,c,d=ze(e,Object.assign({},Ge,Je(xe(t)))),u=!1,h=!1,p=!1,g=!1,m=[],f=Ee(Y,d.interactiveDebounce),b=tt++,v=(c=d.plugins).filter((function(e,t){return c.indexOf(e)===t})),y={id:b,reference:e,popper:De(),popperInstance:null,props:d,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:v,clearDelayTimeouts:function(){clearTimeout(n),clearTimeout(i),cancelAnimationFrame(s)},setProps:function(t){0;if(y.state.isDestroyed)return;T("onBeforeUpdate",[y,t]),W();var n=y.props,i=ze(e,Object.assign({},n,xe(t),{ignoreAttributes:!0}));y.props=i,$(),n.interactiveDebounce!==i.interactiveDebounce&&(M(),f=Ee(Y,i.interactiveDebounce));n.triggerTarget&&!i.triggerTarget?Ae(n.triggerTarget).forEach((function(e){e.removeAttribute("aria-expanded")})):i.triggerTarget&&e.removeAttribute("aria-expanded");q(),N(),w&&w(n,i);y.popperInstance&&(X(),Z().forEach((function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})));T("onAfterUpdate",[y,t])},setContent:function(e){y.setProps({content:e})},show:function(){0;var e=y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,i=Re.isTouch&&!y.props.touch,s=_e(y.props.duration,0,Ge.duration);if(e||t||n||i)return;if(x().hasAttribute("disabled"))return;if(T("onShow",[y],!1),!1===y.props.onShow(y))return;y.state.isVisible=!0,k()&&(S.style.visibility="visible");N(),j(),y.state.isMounted||(S.style.transition="none");if(k()){var o=F(),r=o.box,l=o.content;Oe([r,l],0)}a=function(){var e;if(y.state.isVisible&&!g){if(g=!0,S.offsetHeight,S.style.transition=y.props.moveTransition,k()&&y.props.animation){var t=F(),n=t.box,i=t.content;Oe([n,i],s),qe([n,i],"visible")}O(),q(),Le(it,y),null==(e=y.popperInstance)||e.forceUpdate(),T("onMount",[y]),y.props.animation&&k()&&function(e,t){U(e,t)}(s,(function(){y.state.isShown=!0,T("onShown",[y])}))}},function(){var e,t=y.props.appendTo,n=x();e=y.props.interactive&&t===ye||"parent"===t?n.parentNode:we(t,[n]);e.contains(S)||e.appendChild(S);y.state.isMounted=!0,X(),!1}()},hide:function(){0;var e=!y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,i=_e(y.props.duration,1,Ge.duration);if(e||t||n)return;if(T("onHide",[y],!1),!1===y.props.onHide(y))return;y.state.isVisible=!1,y.state.isShown=!1,g=!1,u=!1,k()&&(S.style.visibility="hidden");if(M(),H(),N(!0),k()){var s=F(),o=s.box,r=s.content;y.props.animation&&(Oe([o,r],i),qe([o,r],"hidden"))}O(),q(),y.props.animation?k()&&function(e,t){U(e,(function(){!y.state.isVisible&&S.parentNode&&S.parentNode.contains(S)&&t()}))}(i,y.unmount):y.unmount()},hideWithInteractivity:function(e){0;D().addEventListener("mousemove",f),Le(nt,f),f(e)},enable:function(){y.state.isEnabled=!0},disable:function(){y.hide(),y.state.isEnabled=!1},unmount:function(){0;y.state.isVisible&&y.hide();if(!y.state.isMounted)return;Q(),Z().forEach((function(e){e._tippy.unmount()})),S.parentNode&&S.parentNode.removeChild(S);it=it.filter((function(e){return e!==y})),y.state.isMounted=!1,T("onHidden",[y])},destroy:function(){0;if(y.state.isDestroyed)return;y.clearDelayTimeouts(),y.unmount(),W(),delete e._tippy,y.state.isDestroyed=!0,T("onDestroy",[y])}};if(!d.render)return y;var _=d.render(y),S=_.popper,w=_.onUpdate;S.setAttribute("data-tippy-root",""),S.id="tippy-"+y.id,y.popper=S,e._tippy=y,S._tippy=y;var E=v.map((function(e){return e.fn(y)})),A=e.hasAttribute("aria-expanded");return $(),q(),N(),T("onCreate",[y]),d.showOnCreate&&ee(),S.addEventListener("mouseenter",(function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()})),S.addEventListener("mouseleave",(function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&D().addEventListener("mousemove",f)})),y;function L(){var e=y.props.touch;return Array.isArray(e)?e:[e,0]}function C(){return"hold"===L()[0]}function k(){var e;return!(null==(e=y.props.render)||!e.$$tippy)}function x(){return l||e}function D(){var e=x().parentNode;return e?Me(e):document}function F(){return Ze(S)}function P(e){return y.state.isMounted&&!y.state.isVisible||Re.isTouch||o&&"focus"===o.type?0:_e(y.props.delay,e?0:1,Ge.delay)}function N(e){void 0===e&&(e=!1),S.style.pointerEvents=y.props.interactive&&!e?"":"none",S.style.zIndex=""+y.props.zIndex}function T(e,t,n){var i;(void 0===n&&(n=!0),E.forEach((function(n){n[e]&&n[e].apply(n,t)})),n)&&(i=y.props)[e].apply(i,t)}function O(){var t=y.props.aria;if(t.content){var n="aria-"+t.content,i=S.id;Ae(y.props.triggerTarget||e).forEach((function(e){var t=e.getAttribute(n);if(y.state.isVisible)e.setAttribute(n,t?t+" "+i:i);else{var s=t&&t.replace(i,"").trim();s?e.setAttribute(n,s):e.removeAttribute(n)}}))}}function q(){!A&&y.props.aria.expanded&&Ae(y.props.triggerTarget||e).forEach((function(e){y.props.interactive?e.setAttribute("aria-expanded",y.state.isVisible&&e===x()?"true":"false"):e.removeAttribute("aria-expanded")}))}function M(){D().removeEventListener("mousemove",f),nt=nt.filter((function(e){return e!==f}))}function I(t){if(!Re.isTouch||!p&&"mousedown"!==t.type){var n=t.composedPath&&t.composedPath()[0]||t.target;if(!y.props.interactive||!Be(S,n)){if(Ae(y.props.triggerTarget||e).some((function(e){return Be(e,n)}))){if(Re.isTouch)return;if(y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else T("onClickOutside",[y,t]);!0===y.props.hideOnClick&&(y.clearDelayTimeouts(),y.hide(),h=!0,setTimeout((function(){h=!1})),y.state.isMounted||H())}}}function B(){p=!0}function R(){p=!1}function j(){var e=D();e.addEventListener("mousedown",I,!0),e.addEventListener("touchend",I,ve),e.addEventListener("touchstart",R,ve),e.addEventListener("touchmove",B,ve)}function H(){var e=D();e.removeEventListener("mousedown",I,!0),e.removeEventListener("touchend",I,ve),e.removeEventListener("touchstart",R,ve),e.removeEventListener("touchmove",B,ve)}function U(e,t){var n=F().box;function i(e){e.target===n&&(Ie(n,"remove",i),t())}if(0===e)return t();Ie(n,"remove",r),Ie(n,"add",i),r=i}function V(t,n,i){void 0===i&&(i=!1),Ae(y.props.triggerTarget||e).forEach((function(e){e.addEventListener(t,n,i),m.push({node:e,eventType:t,handler:n,options:i})}))}function $(){var e;C()&&(V("touchstart",G,{passive:!0}),V("touchend",J,{passive:!0})),(e=y.props.trigger,e.split(/\s+/).filter(Boolean)).forEach((function(e){if("manual"!==e)switch(V(e,G),e){case"mouseenter":V("mouseleave",J);break;case"focus":V($e?"focusout":"blur",z);break;case"focusin":V("focusout",z)}}))}function W(){m.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,s=e.options;t.removeEventListener(n,i,s)})),m=[]}function G(e){var t,n=!1;if(y.state.isEnabled&&!K(e)&&!h){var i="focus"===(null==(t=o)?void 0:t.type);o=e,l=e.currentTarget,q(),!y.state.isVisible&&Pe(e)&&nt.forEach((function(t){return t(e)})),"click"===e.type&&(y.props.trigger.indexOf("mouseenter")<0||u)&&!1!==y.props.hideOnClick&&y.state.isVisible?n=!0:ee(e),"click"===e.type&&(u=!n),n&&!i&&te(e)}}function Y(e){var t=e.target,n=x().contains(t)||S.contains(t);if("mousemove"!==e.type||!n){var i=Z().concat(S).map((function(e){var t,n=null==(t=e._tippy.popperInstance)?void 0:t.state;return n?{popperRect:e.getBoundingClientRect(),popperState:n,props:d}:null})).filter(Boolean);(function(e,t){var n=t.clientX,i=t.clientY;return e.every((function(e){var t=e.popperRect,s=e.popperState,o=e.props.interactiveBorder,r=Ce(s.placement),a=s.modifiersData.offset;if(!a)return!0;var l="bottom"===r?a.top.y:0,c="top"===r?a.bottom.y:0,d="right"===r?a.left.x:0,u="left"===r?a.right.x:0,h=t.top-i+l>o,p=i-t.bottom-c>o,g=t.left-n+d>o,m=n-t.right-u>o;return h||p||g||m}))})(i,e)&&(M(),te(e))}}function J(e){K(e)||y.props.trigger.indexOf("click")>=0&&u||(y.props.interactive?y.hideWithInteractivity(e):te(e))}function z(e){y.props.trigger.indexOf("focusin")<0&&e.target!==x()||y.props.interactive&&e.relatedTarget&&S.contains(e.relatedTarget)||te(e)}function K(e){return!!Re.isTouch&&C()!==e.type.indexOf("touch")>=0}function X(){Q();var t=y.props,n=t.popperOptions,i=t.placement,s=t.offset,o=t.getReferenceClientRect,r=t.moveTransition,l=k()?Ze(S).arrow:null,c=o?{getBoundingClientRect:o,contextElement:o.contextElement||x()}:e,d={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var t=e.state;if(k()){var n=F().box;["placement","reference-hidden","escaped"].forEach((function(e){"placement"===e?n.setAttribute("data-placement",t.placement):t.attributes.popper["data-popper-"+e]?n.setAttribute("data-"+e,""):n.removeAttribute("data-"+e)})),t.attributes.popper={}}}},u=[{name:"offset",options:{offset:s}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!r}},d];k()&&l&&u.push({name:"arrow",options:{element:l,padding:3}}),u.push.apply(u,(null==n?void 0:n.modifiers)||[]),y.popperInstance=pe(c,S,Object.assign({},n,{placement:i,onFirstUpdate:a,modifiers:u}))}function Q(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function Z(){return ke(S.querySelectorAll("[data-tippy-root]"))}function ee(e){y.clearDelayTimeouts(),e&&T("onTrigger",[y,e]),j();var t=P(!0),i=L(),s=i[0],o=i[1];Re.isTouch&&"hold"===s&&o&&(t=o),t?n=setTimeout((function(){y.show()}),t):y.show()}function te(e){if(y.clearDelayTimeouts(),T("onUntrigger",[y,e]),y.state.isVisible){if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(e.type)>=0&&u)){var t=P(!1);t?i=setTimeout((function(){y.state.isVisible&&y.hide()}),t):s=requestAnimationFrame((function(){y.hide()}))}}else H()}}function ot(e,t){void 0===t&&(t={});var n=Ge.plugins.concat(t.plugins||[]);document.addEventListener("touchstart",He,ve),window.addEventListener("blur",Ve);var i=Object.assign({},t,{plugins:n}),s=Te(e).reduce((function(e,t){var n=t&&st(t,i);return n&&e.push(n),e}),[]);return Fe(e)?s[0]:s}ot.defaultProps=Ge,ot.setDefaultProps=function(e){Object.keys(e).forEach((function(t){Ge[t]=e[t]}))},ot.currentInput=Re;Object.assign({},z,{effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow)}});ot.setDefaultProps({render:et});const rt=ot},5042:()=>{}},t={};function n(i){var s=t[i];if(void 0!==s)return s.exports;var o=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";const e={backgroundImage:"",MediaAttribution:!0,applePay:!1,CapitalizeFields:!1,ClickToExpand:!0,CurrencySymbol:"$",CurrencyCode:"USD",AddCurrencySymbol:!0,ThousandsSeparator:"",DecimalSeparator:".",DecimalPlaces:2,MinAmount:1,MaxAmount:1e5,MinAmountMessage:"Amount must be at least $1",MaxAmountMessage:"Amount must be less than $100,000",SkipToMainContentLink:!0,SrcDefer:!0,NeverBounceAPI:null,NeverBounceDateField:null,NeverBounceStatusField:null,NeverBounceDateFormat:"MM/DD/YYYY",FreshAddress:!1,ProgressBar:!1,AutoYear:!1,TranslateFields:!0,Debug:!1,RememberMe:!1,TidyContact:!1,RegionLongFormat:"",CountryDisable:[],Plaid:!1,Placeholders:!1,ENValidators:!1,MobileCTA:!1,CustomCurrency:!1,VGS:!1,PostalCodeValidator:!1,CountryRedirect:!1,WelcomeBack:!1,PageLayouts:["leftleft1col","centerleft1col","centercenter1col","centercenter2col","centerright1col","rightright1col","none"]},t={image:"https://picsum.photos/480/650",imagePosition:"left",title:"Will you change your gift to just {new-amount} a month to boost your impact?",paragraph:"Make a monthly pledge today to support us with consistent, reliable resources during emergency moments.",yesLabel:"Yes! Process My
{new-amount} monthly gift",noLabel:"No, thanks. Continue with my
{old-amount} one-time gift",otherAmount:!0,otherLabel:"Or enter a different monthly amount:",upsellOriginalGiftAmountFieldName:"",amountRange:[{max:10,suggestion:5},{max:15,suggestion:7},{max:20,suggestion:8},{max:25,suggestion:9},{max:30,suggestion:10},{max:35,suggestion:11},{max:40,suggestion:12},{max:50,suggestion:14},{max:100,suggestion:15},{max:200,suggestion:19},{max:300,suggestion:29},{max:500,suggestion:"Math.ceil((amount / 12)/5)*5"}],minAmount:0,canClose:!0,submitOnClose:!1,oneTime:!0,annual:!1,disablePaymentMethods:[],skipUpsell:!1,conversionField:"",upsellCheckbox:!1},i=[{field:"supporter.firstName",translation:"Nome"},{field:"supporter.lastName",translation:"Sobrenome"},{field:"supporter.phoneNumber",translation:"Celular"},{field:"supporter.address1",translation:"Endereço"},{field:"supporter.address2",translation:"Complemento"},{field:"supporter.postcode",translation:"CEP"},{field:"supporter.city",translation:"Cidade"},{field:"supporter.region",translation:"Estado"},{field:"supporter.country",translation:"País"}],s=[{field:"supporter.address1",translation:"Straße, Hausnummer"},{field:"supporter.postcode",translation:"Postleitzahl"},{field:"supporter.city",translation:"Ort"},{field:"supporter.region",translation:"Bundesland"},{field:"supporter.country",translation:"Land"}],o=[{field:"supporter.address1",translation:"Adresse"},{field:"supporter.postcode",translation:"Code Postal"},{field:"supporter.city",translation:"Ville"},{field:"supporter.region",translation:"Région"},{field:"supporter.country",translation:"Country"}],r=[{field:"supporter.address1",translation:"Adres"},{field:"supporter.postcode",translation:"Postcode"},{field:"supporter.city",translation:"Woonplaats"},{field:"supporter.region",translation:"Provincie"},{field:"supporter.country",translation:"Country"}],a={BR:i,BRA:i,DE:s,DEU:s,FR:o,FRA:o,NL:r,NLD:r},l={enabled:!1,title:"We are sad that you are leaving",text:"Would you mind telling us why you are leaving this page?",buttonText:"Send us your comments",buttonLink:"https://www.4sitestudios.com/",cookieName:"engrid-exit-intent-lightbox",cookieDuration:30,triggers:{visibilityState:!0,mousePosition:!0}};class c{constructor(){this.logger=new fe("Loader","gold","black","🔁"),this.cssElement=document.querySelector('link[href*="engrid."][rel="stylesheet"]'),this.jsElement=document.querySelector('script[src*="engrid."]')}reload(){var e,t,n;const i=this.getOption("assets"),s=p.getBodyData("loaded");let o="false"===this.getOption("engridcss"),r="false"===this.getOption("engridjs");if(s||!i)return o&&this.cssElement&&(this.logger.log("engridcss=false | Removing original stylesheet:",this.cssElement),this.cssElement.remove()),r&&this.jsElement&&(this.logger.log("engridjs=false | Removing original script:",this.jsElement),this.jsElement.remove()),o&&(this.logger.log("engridcss=false | adding top banner CSS"),this.addENgridCSSUnloadedCSS()),r?(this.logger.log("engridjs=false | Skipping JS load."),this.logger.success("LOADED"),!0):(this.logger.success("LOADED"),!1);this.logger.log("RELOADING"),p.setBodyData("loaded","true");const a=p.getBodyData("theme"),l=null!==(e=this.getOption("repo-name"))&&void 0!==e?e:`engrid-${a}`;let c="",d="";switch(i){case"local":this.logger.log("LOADING LOCAL"),p.setBodyData("assets","local"),c=`https://${l}.test/dist/engrid.js`,d=`https://${l}.test/dist/engrid.css`;break;case"flush":this.logger.log("FLUSHING CACHE");const e=Date.now(),s=new URL((null===(t=this.jsElement)||void 0===t?void 0:t.getAttribute("src"))||"");s.searchParams.set("v",e.toString()),c=s.toString();const o=new URL((null===(n=this.cssElement)||void 0===n?void 0:n.getAttribute("href"))||"");o.searchParams.set("v",e.toString()),d=o.toString();break;default:this.logger.log("LOADING EXTERNAL"),c=`https://s3.amazonaws.com/engrid-dev.4sitestudios.com/${l}/${i}/engrid.js`,d=`https://s3.amazonaws.com/engrid-dev.4sitestudios.com/${l}/${i}/engrid.css`}return o&&this.cssElement&&(this.logger.log("engridcss=false | Removing original stylesheet:",this.cssElement),this.cssElement.remove()),o&&d&&""!==d&&this.logger.log("engridcss=false | Skipping injection of stylesheet:",d),o?(this.logger.log("engridcss=false | adding top banner CSS"),this.addENgridCSSUnloadedCSS()):this.setCssFile(d),r&&this.jsElement&&(this.logger.log("engridjs=false | Removing original script:",this.jsElement),this.jsElement.remove()),r&&c&&""!==c&&this.logger.log("engridjs=false | Skipping injection of script:",c),r||this.setJsFile(c),!!i}getOption(e){const t=p.getUrlParameter(e);return t&&["assets","engridcss","engridjs"].includes(e)?t:window.EngridLoader&&window.EngridLoader.hasOwnProperty(e)?window.EngridLoader[e]:this.jsElement&&this.jsElement.hasAttribute("data-"+e)?this.jsElement.getAttribute("data-"+e):null}setCssFile(e){if(""!==e)if(this.cssElement)this.logger.log("Replacing stylesheet:",e),this.cssElement.setAttribute("href",e);else{this.logger.log("Injecting stylesheet:",e);const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("type","text/css"),t.setAttribute("media","all"),t.setAttribute("href",e),document.head.appendChild(t)}}setJsFile(e){if(""===e)return;this.logger.log("Injecting script:",e);const t=document.createElement("script");t.setAttribute("src",e),document.head.appendChild(t)}addENgridCSSUnloadedCSS(){document.body.insertAdjacentHTML("beforeend",'')}}var d=n(291);class u{constructor(){this.logger=new fe("EnForm"),this._onSubmit=new d.nz,this._onValidate=new d.nz,this._onError=new d.nz,this.submit=!0,this.submitPromise=!1,this.validate=!0,this.validatePromise=!1}static getInstance(){return u.instance||(u.instance=new u),u.instance}dispatchSubmit(){this._onSubmit.dispatch(),this.logger.log("dispatchSubmit")}dispatchValidate(){this._onValidate.dispatch(),this.logger.log("dispatchValidate")}dispatchError(){this._onError.dispatch(),this.logger.log("dispatchError")}submitForm(){const e=document.querySelector("form .en__submit button");if(e){const t=document.getElementById("enModal");t&&t.classList.add("is-submitting"),e.click(),this.logger.log("submitForm")}}get onSubmit(){return this._onSubmit.asEvent()}get onError(){return this._onError.asEvent()}get onValidate(){return this._onValidate.asEvent()}}class h{constructor(e="transaction.donationAmt",t="transaction.donationAmt.other"){this._onAmountChange=new d.FK,this._amount=0,this._radios="",this._other="",this._dispatch=!0,this._other=t,this._radios=e,document.addEventListener("change",(n=>{const i=n.target;if(i)if(i.name==e)this.amount=parseFloat(i.value);else if(i.name==t){const e=p.cleanAmount(i.value);i.value=e%1!=0?e.toFixed(2):e.toString(),this.amount=e}}));const n=document.querySelector(`[name='${this._other}']`);n&&n.addEventListener("keyup",(e=>{this.amount=p.cleanAmount(n.value)}))}static getInstance(e="transaction.donationAmt",t="transaction.donationAmt.other"){return h.instance||(h.instance=new h(e,t)),h.instance}get amount(){return this._amount}set amount(e){this._amount=e||0,this._dispatch&&this._onAmountChange.dispatch(this._amount)}get onAmountChange(){return this._onAmountChange.asEvent()}load(){const e=document.querySelector('input[name="'+this._radios+'"]:checked');if(e){let t=parseFloat(e.value||"");if(t>0)this.amount=parseFloat(e.value);else{const e=document.querySelector('input[name="'+this._other+'"]');t=p.cleanAmount(e.value),this.amount=t}}else if(p.checkNested(window.EngagingNetworks,"require","_defined","enjs","getDonationTotal")&&p.checkNested(window.EngagingNetworks,"require","_defined","enjs","getDonationFee")){const e=window.EngagingNetworks.require._defined.enjs.getDonationTotal()-window.EngagingNetworks.require._defined.enjs.getDonationFee();e&&(this.amount=e)}}setAmount(e,t=!0){if(!document.getElementsByName(this._radios).length)return;this._dispatch=t;let n=Array.from(document.querySelectorAll('input[name="'+this._radios+'"]')).filter((t=>t instanceof HTMLInputElement&&parseInt(t.value)==e));if(n.length){const e=n[0];e.checked=!0;const t=new Event("change",{bubbles:!0,cancelable:!0});e.dispatchEvent(t),this.clearOther()}else{const t=document.querySelector('input[name="'+this._other+'"]');if(t){const n=document.querySelector(`.en__field--donationAmt.en__field--withOther .en__field__item:nth-last-child(2) input[name="${this._radios}"]`);n&&(n.checked=!0),t.value=parseFloat(e.toString()).toFixed(2);const i=new Event("change",{bubbles:!0,cancelable:!0});t.dispatchEvent(i);t.parentNode.classList.remove("en__field__item--hidden")}}this.amount=e,this._dispatch=!0}clearOther(){const e=document.querySelector('input[name="'+this._other+'"]');e.value="";e.parentNode.classList.add("en__field__item--hidden")}}class p{constructor(){if(!p.enForm)throw new Error("Engaging Networks Form Not Found!")}static get enForm(){return document.querySelector("form.en__component")}static get debug(){return!!this.getOption("Debug")}static get demo(){return"DEMO"===this.getUrlParameter("mode")}static getUrlParameter(e){const t=new URLSearchParams(window.location.search);if(e.endsWith("[]")){let n=[];return t.forEach(((t,i)=>{i.startsWith(e.replace("[]",""))&&n.push(new Object({[i]:t}))})),n.length>0?n:null}return t.has(e)?t.get(e)||!0:null}static getField(e){return document.querySelector(`[name="${e}"]`)}static getFieldValue(e){return new FormData(this.enForm).getAll(e).join(",")}static setFieldValue(e,t,n=!0,i=!1){t!==p.getFieldValue(e)&&(document.getElementsByName(e).forEach((e=>{if("type"in e){switch(e.type){case"select-one":case"select-multiple":for(const n of e.options)n.value==t&&(n.selected=!0,i&&e.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":case"radio":e.value==t&&(e.checked=!0,i&&e.dispatchEvent(new Event("change",{bubbles:!0})));break;default:e.value=t,i&&(e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new Event("blur",{bubbles:!0})))}e.setAttribute("engrid-value-changed","")}})),n&&this.enParseDependencies())}static createHiddenInput(e,t=""){var n;const i=document.createElement("div");i.classList.add("en__component","en__component--formblock","hide");const s=document.createElement("div");s.classList.add("en__field","en__field--text");const o=document.createElement("div");o.classList.add("en__field__element","en__field__element--text");const r=document.createElement("input");r.classList.add("en__field__input","en__field__input--text","engrid-added-input"),r.setAttribute("name",e),r.setAttribute("type","hidden"),r.setAttribute("value",t),o.appendChild(r),s.appendChild(o),i.appendChild(s);const a=document.querySelector(".en__submit");if(a){const e=a.closest(".en__component");e&&(null===(n=e.parentNode)||void 0===n||n.insertBefore(i,e.nextSibling))}else p.enForm.appendChild(i);return r}static enParseDependencies(){var e,t,n,i,s,o;if(window.EngagingNetworks&&"function"==typeof(null===(s=null===(i=null===(n=null===(t=null===(e=window.EngagingNetworks)||void 0===e?void 0:e.require)||void 0===t?void 0:t._defined)||void 0===n?void 0:n.enDependencies)||void 0===i?void 0:i.dependencies)||void 0===s?void 0:s.parseDependencies)){const e=[];if("dependencies"in window.EngagingNetworks){const t=document.querySelector(".en__field--donationAmt");if(t){let n=(null===(o=[...t.classList.values()].filter((e=>e.startsWith("en__field--")&&Number(e.substring(11))>0)).toString().match(/\d/g))||void 0===o?void 0:o.join(""))||"";n&&(window.EngagingNetworks.dependencies.forEach((t=>{if("actions"in t&&t.actions.length>0){let i=!1;t.actions.forEach((e=>{"target"in e&&e.target==n&&(i=!0)})),i||e.push(t)}})),e.length>0&&(window.EngagingNetworks.require._defined.enDependencies.dependencies.parseDependencies(e),p.getOption("Debug")&&console.log("EN Dependencies Triggered",e)))}}}}static getGiftProcess(){return"pageJson"in window?window.pageJson.giftProcess:null}static getPageCount(){return"pageJson"in window?window.pageJson.pageCount:null}static getPageNumber(){return"pageJson"in window?window.pageJson.pageNumber:null}static getPageID(){return"pageJson"in window?window.pageJson.campaignPageId:0}static getClientID(){return"pageJson"in window?window.pageJson.clientId:0}static getDataCenter(){return p.getClientID()>=1e4?"us":"ca"}static getPageType(){if(!("pageJson"in window)||!("pageType"in window.pageJson))return"UNKNOWN";switch(window.pageJson.pageType){case"donation":case"premiumgift":return"DONATION";case"e-card":return"ECARD";case"otherdatacapture":case"survey":return"SURVEY";case"emailtotarget":return"EMAILTOTARGET";case"advocacypetition":return"ADVOCACY";case"emailsubscribeform":return"SUBSCRIBEFORM";case"supporterhub":return"SUPPORTERHUB";case"unsubscribe":return"UNSUBSCRIBE";case"tweetpage":return"TWEETPAGE";default:return"UNKNOWN"}}static setBodyData(e,t){const n=document.querySelector("body");"boolean"!=typeof t||!1!==t?n.setAttribute(`data-engrid-${e}`,t.toString()):n.removeAttribute(`data-engrid-${e}`)}static getBodyData(e){return document.querySelector("body").getAttribute(`data-engrid-${e}`)}static hasBodyData(e){return document.querySelector("body").hasAttribute(`data-engrid-${e}`)}static getOption(e){return window.EngridOptions[e]||null}static loadJS(e,t=null,n=!0){const i=document.createElement("script");i.src=e,i.onload=t,n?document.head.appendChild(i):document.body.appendChild(i)}static formatNumber(e,t=2,n=".",i=","){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");const s=isFinite(+e)?+e:0,o=isFinite(+t)?Math.abs(t):0,r=void 0===i?",":i,a=void 0===n?".":n;let l=[];return l=(o?function(e,t){const n=Math.pow(10,t);return""+Math.round(e*n)/n}(s,o):""+Math.round(s)).split("."),l[0].length>3&&(l[0]=l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,r)),(l[1]||"").lengthn>0&&n+1!==t.length&&3!==e.length)).includes(!0))return 0;if(n.length>1&&!n.includes("."))return 0;if([...new Set(n.slice(0,-1))].length>1)return 0;if(t[t.length-1].length<=2){const e=t.pop()||"00";return parseInt(e)>0?parseFloat(Number(parseInt(t.join(""))+"."+e).toFixed(2)):parseInt(t.join(""))}return parseInt(t.join(""))}static disableSubmit(e=""){const t=document.querySelector(".en__submit button");if(!t)return!1;t.dataset.originalText=t.innerHTML;let n=""+e+"";return t.disabled=!0,t.innerHTML=n,!0}static enableSubmit(){const e=document.querySelector(".en__submit button");return!!e&&(!!e.dataset.originalText&&(e.disabled=!1,e.innerHTML=e.dataset.originalText,delete e.dataset.originalText,!0))}static formatDate(e,t="MM/DD/YYYY"){const n=e.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}).split("/");return t.replace(/YYYY/g,n[2]).replace(/MM/g,n[0]).replace(/DD/g,n[1]).replace(/YY/g,n[2].substr(2,2))}static checkNested(e,...t){for(let n=0;n0&&(n=n.substring(0,n.indexOf("("))),n=n.replace(/[^a-zA-Z0-9]/g,""),n=n.substring(0,20),n="engrid"+((i=n).charAt(0).toUpperCase()+i.slice(1)),t&&!t.dataset[n]){t.dataset[n]="true";new MutationObserver((function(t){t.forEach((function(t){"childList"===t.type&&t.addedNodes.length>0&&e()}))})).observe(t,{childList:!0})}}static getPaymentType(){return p.getFieldValue("transaction.paymenttype")}static setPaymentType(e){const t=p.getField("transaction.paymenttype");if(t){const n=Array.from(t.options).find((t=>"card"===e.toLowerCase()?["card","visa","vi"].includes(t.value.toLowerCase()):e.toLowerCase()===t.value.toLowerCase()));n?(n.selected=!0,t.value=n.value):t.value=e;const i=new Event("change",{bubbles:!0,cancelable:!0});t.dispatchEvent(i)}}static isInViewport(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}}class g{constructor(){this._onFrequencyChange=new d.FK,this._frequency="onetime",this._recurring="n",this._dispatch=!0,document.addEventListener("change",(e=>{const t=e.target;t&&"transaction.recurrpay"==t.name&&(this.recurring=t.value,"radio"==t.type&&(this.frequency="n"==t.value.toLowerCase()?"onetime":"monthly",p.setFieldValue("transaction.recurrfreq",this.frequency.toUpperCase()))),t&&"transaction.recurrfreq"==t.name&&(this.frequency=t.value)})),p.getGiftProcess()&&(p.setBodyData("transaction-recurring-frequency",sessionStorage.getItem("engrid-transaction-recurring-frequency")||"onetime"),p.setBodyData("transaction-recurring",window.pageJson.recurring?"y":"n"))}static getInstance(){return g.instance||(g.instance=new g),g.instance}get frequency(){return this._frequency}set frequency(e){this._frequency=e.toLowerCase()||"onetime",this._dispatch&&this._onFrequencyChange.dispatch(this._frequency),p.setBodyData("transaction-recurring-frequency",this._frequency),sessionStorage.setItem("engrid-transaction-recurring-frequency",this._frequency)}get recurring(){return this._recurring}set recurring(e){this._recurring=e.toLowerCase()||"n",p.setBodyData("transaction-recurring",this._recurring)}get onFrequencyChange(){return this._onFrequencyChange.asEvent()}load(){var e;this.frequency=p.getFieldValue("transaction.recurrfreq")||sessionStorage.getItem("engrid-transaction-recurring-frequency")||"onetime";p.getField("transaction.recurrpay")?this.recurring=p.getFieldValue("transaction.recurrpay"):p.checkNested(window.EngagingNetworks,"require","_defined","enjs","getSupporterData")&&(this.recurring=(null===(e=window.EngagingNetworks.require._defined.enjs.getSupporterData("recurrpay"))||void 0===e?void 0:e.toLowerCase())||"n")}setRecurrency(e,t=!0){document.getElementsByName("transaction.recurrpay").length&&(this._dispatch=t,p.setFieldValue("transaction.recurrpay",e.toUpperCase()),this._dispatch=!0)}setFrequency(e,t=!0){if(!document.getElementsByName("transaction.recurrfreq").length)return;this._dispatch=t;let n=Array.from(document.querySelectorAll('input[name="transaction.recurrfreq"]')).filter((t=>t instanceof HTMLInputElement&&t.value==e.toUpperCase()));if(n.length){n[0].checked=!0,this.frequency=e.toLowerCase(),"onetime"===this.frequency?this.setRecurrency("N",t):this.setRecurrency("Y",t)}this._dispatch=!0}}class m{constructor(){this._onFeeChange=new d.FK,this._amount=h.getInstance(),this._form=u.getInstance(),this._fee=0,this._field=null,document.getElementsByName("transaction.donationAmt").length&&(this._field=this.isENfeeCover()?document.querySelector("#en__field_transaction_feeCover"):document.querySelector('input[name="supporter.processing_fees"]'),this._field instanceof HTMLInputElement&&this._field.addEventListener("change",(e=>{this._field instanceof HTMLInputElement&&this._field.checked&&!this._subscribe&&(this._subscribe=this._form.onSubmit.subscribe((()=>this.addFees()))),this._onFeeChange.dispatch(this.fee)})))}static getInstance(){return m.instance||(m.instance=new m),m.instance}get onFeeChange(){return this._onFeeChange.asEvent()}get fee(){return this.calculateFees()}set fee(e){this._fee=e,this._onFeeChange.dispatch(this._fee)}calculateFees(e=0){var t;if(this._field instanceof HTMLInputElement&&this._field.checked){if(this.isENfeeCover())return e>0?window.EngagingNetworks.require._defined.enjs.feeCover.fee(e):window.EngagingNetworks.require._defined.enjs.getDonationFee();const n=Object.assign({processingfeepercentadded:"0",processingfeefixedamountadded:"0"},null===(t=this._field)||void 0===t?void 0:t.dataset),i=e>0?e:this._amount.amount,s=parseFloat(n.processingfeepercentadded)/100*i+parseFloat(n.processingfeefixedamountadded);return Math.round(100*s)/100}return 0}addFees(){this._form.submit&&!this.isENfeeCover()&&this._amount.setAmount(this._amount.amount+this.fee,!1)}removeFees(){this.isENfeeCover()||this._amount.setAmount(this._amount.amount-this.fee)}isENfeeCover(){if("feeCover"in window.EngagingNetworks)for(const e in window.EngagingNetworks.feeCover)if(window.EngagingNetworks.feeCover.hasOwnProperty(e))return!0;return!1}}class f{constructor(){this.logger=new fe("RememberMeEvents"),this._onLoad=new d.FK,this._onClear=new d.nz,this.hasData=!1}static getInstance(){return f.instance||(f.instance=new f),f.instance}dispatchLoad(e){this.hasData=e,this._onLoad.dispatch(e),this.logger.log(`dispatchLoad: ${e}`)}dispatchClear(){this._onClear.dispatch(),this.logger.log("dispatchClear")}get onLoad(){return this._onLoad.asEvent()}get onClear(){return this._onClear.asEvent()}}class b{constructor(){this._onCountryChange=new d.FK,this._country="",this._field=null,this._field=document.getElementById("en__field_supporter_country"),this._field&&(document.addEventListener("change",(e=>{const t=e.target;t&&"supporter.country"==t.name&&(this.country=t.value)})),this.country=p.getFieldValue("supporter.country"))}static getInstance(){return b.instance||(b.instance=new b),b.instance}get countryField(){return this._field}get onCountryChange(){return this._onCountryChange.asEvent()}get country(){return this._country}set country(e){this._country=e,this._onCountryChange.dispatch(this._country)}}class v extends p{constructor(t){super(),this._form=u.getInstance(),this._fees=m.getInstance(),this._amount=h.getInstance("transaction.donationAmt","transaction.donationAmt.other"),this._frequency=g.getInstance(),this._country=b.getInstance(),this.logger=new fe("App","black","white","🍏");const n=new c;this.options=Object.assign(Object.assign({},e),t),window.EngridOptions=this.options,this._dataLayer=ye.getInstance(),!0!==p.getUrlParameter("pbedit")&&"true"!==p.getUrlParameter("pbedit")?n.reload()||("local"===p.getBodyData("assets")&&"false"!==p.getUrlParameter("debug")&&"log"!==p.getUrlParameter("debug")&&(window.EngridOptions.Debug=!0),"loading"!==document.readyState?this.run():document.addEventListener("DOMContentLoaded",(()=>{this.run()})),window.onresize=()=>{this.onResize()}):window.location.href=`https://${p.getDataCenter()}.engagingnetworks.app/index.html#pages/${p.getPageID()}/edit`}run(){if(!p.checkNested(window.EngagingNetworks,"require","_defined","enjs"))return this.logger.danger("Engaging Networks JS Framework NOT FOUND"),void setTimeout((()=>{this.run()}),100);window.hasOwnProperty("EngridPageOptions")&&(this.options=Object.assign(Object.assign({},this.options),window.EngridPageOptions),window.EngridOptions=this.options),p.checkNested(window,"pageJson","pageType")||window.setTimeout((()=>{console.log("%c ⛔️ pageJson.pageType NOT FOUND - Go to the Account Settings and Expose the Transaction Details %s","background-color: red; color: white; font-size: 22px; font-weight: bold;","https://knowledge.engagingnetworks.net/datareports/expose-transaction-details-pagejson")}),2e3),(this.options.Debug||"true"==v.getUrlParameter("debug"))&&v.setBodyData("debug",""),new H,new W,new $,new $e,new X("transaction.giveBySelect","giveBySelect-"),new X("transaction.inmem","inmem-"),new X("transaction.recurrpay","recurrpay-");let e=[];document.querySelectorAll("input[type=radio]").forEach((t=>{"name"in t&&!1===e.includes(t.name)&&e.push(t.name)})),e.forEach((e=>{new X(e,"engrid__"+e.replace(/\./g,"")+"-")}));document.querySelectorAll("input[type=checkbox]").forEach((e=>{"name"in e&&new X(e.name,"engrid__"+e.name.replace(/\./g,"")+"-")})),this._form.onSubmit.subscribe((()=>this.onSubmit())),this._form.onError.subscribe((()=>this.onError())),this._form.onValidate.subscribe((()=>this.onValidate())),this._amount.onAmountChange.subscribe((e=>this.logger.success(`Live Amount: ${e}`))),this._frequency.onFrequencyChange.subscribe((e=>{this.logger.success(`Live Frequency: ${e}`),setTimeout((()=>{this._amount.load()}),150)})),this._form.onSubmit.subscribe((e=>this.logger.success("Submit: "+JSON.stringify(e)))),this._form.onError.subscribe((e=>this.logger.danger("Error: "+JSON.stringify(e)))),this._country.onCountryChange.subscribe((e=>this.logger.success(`Country: ${e}`))),window.enOnSubmit=()=>(this._form.submit=!0,this._form.submitPromise=!1,this._form.dispatchSubmit(),p.watchForError(p.enableSubmit),!!this._form.submit&&(this._form.submitPromise?this._form.submitPromise:(this.logger.success("enOnSubmit Success"),!0))),window.enOnError=()=>{this._form.dispatchError()},window.enOnValidate=()=>(this._form.validate=!0,this._form.validatePromise=!1,this._form.dispatchValidate(),!!this._form.validate&&(this._form.validatePromise?this._form.validatePromise:(this.logger.success("Validation Passed"),!0))),new U,new et,new V,new J(this.options),new ae,new K,new z,new y,new _e,new Se,new Fe,new Pe,new Ne,window.setTimeout((()=>{this._frequency.load()}),1e3),new Je,new xe,new De,new se,this.options.MediaAttribution&&new Y,this.options.applePay&&new O,this.options.CapitalizeFields&&new M,this.options.AutoYear&&new I,new B,new R,this.options.ClickToExpand&&new j,this.options.SkipToMainContentLink&&new oe,this.options.SrcDefer&&new re,this.options.ProgressBar&&new ue;try{this.options.RememberMe&&"object"==typeof this.options.RememberMe&&window.localStorage&&new pe(this.options.RememberMe)}catch(e){}this.options.NeverBounceAPI&&new ce(this.options.NeverBounceAPI,this.options.NeverBounceDateField,this.options.NeverBounceStatusField,this.options.NeverBounceDateFormat),this.options.FreshAddress&&new de,new ge,new me,new be,new ve,new q,new we,new Ee,new le,new Ae,new Le,new Xe,this.options.Debug&&new Oe,this.options.TidyContact&&new ke,this.options.TranslateFields&&new ie,new Ie,new Be,new Ye,"DONATION"===p.getPageType()&&new Re,new je,new He,new Ue,this.options.Plaid&&new Ve,new Ge,new We,new ze,new Ke,new Qe,new Ze,new tt,new it,new rt,new at,new ot,new lt;let t=this.options.Debug;try{!t&&window.sessionStorage.hasOwnProperty(Te.debugSessionStorageKey)&&(t=!0)}catch(e){}t&&new Te(this.options.PageLayouts),"branding"===p.getUrlParameter("development")&&(new Me).show(),p.setBodyData("js-loading","finished"),window.EngridVersion=ct,this.logger.success(`VERSION: ${ct}`);let n="function"==typeof window.onload?window.onload:null;"loading"!==document.readyState?this.onLoad():window.onload=e=>{this.onLoad(),n&&n.bind(window,e)}}onLoad(){this.options.onLoad&&this.options.onLoad()}onResize(){this.options.onResize&&this.options.onResize()}onValidate(){this.options.onValidate&&(this.logger.log("Client onValidate Triggered"),this.options.onValidate())}onSubmit(){this.options.onSubmit&&(this.logger.log("Client onSubmit Triggered"),this.options.onSubmit())}onError(){this.options.onError&&(this.logger.danger("Client onError Triggered"),this.options.onError())}static log(e){new fe("Client","brown","aliceblue","🍪").log(e)}}class y{constructor(){this._frequency=g.getInstance(),this.shouldRun()&&(this._frequency.onFrequencyChange.subscribe((e=>window.setTimeout(this.fixAmountLabels.bind(this),100))),window.setTimeout(this.fixAmountLabels.bind(this),300))}shouldRun(){return!("DONATION"!==p.getPageType()||!p.getOption("AddCurrencySymbol"))}fixAmountLabels(){let e=document.querySelectorAll(".en__field--donationAmt label");const t=p.getCurrencySymbol()||"";e.forEach((e=>{isNaN(e.innerText)||(e.innerText=t+e.innerText)}))}}var _=function(e,t,n,i){return new(n||(n=Promise))((function(s,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))};const S=window.ApplePaySession,w=window.merchantIdentifier,E=window.merchantDomainName,A=window.merchantDisplayName,L=window.merchantSessionIdentifier,C=window.merchantNonce,k=window.merchantEpochTimestamp,x=window.merchantSignature,D=window.merchantCountryCode,F=window.merchantCurrencyCode,P=window.merchantSupportedNetworks,N=window.merchantCapabilities,T=window.merchantTotalLabel;class O{constructor(){this.applePay=document.querySelector('.en__field__input.en__field__input--radio[value="applepay"]'),this._amount=h.getInstance(),this._fees=m.getInstance(),this._form=u.getInstance(),this.checkApplePay()}checkApplePay(){return _(this,void 0,void 0,(function*(){const e=document.querySelector("form.en__component--page");if(!this.applePay||!window.hasOwnProperty("ApplePaySession")){const e=document.querySelector(".en__field__item.applepay");return e&&e.remove(),p.debug&&console.log("Apple Pay DISABLED"),!1}const t=S.canMakePaymentsWithActiveCard(w);let n=!1;yield t.then((t=>{if(n=t,t){let t=document.createElement("input");t.setAttribute("type","hidden"),t.setAttribute("name","PkPaymentToken"),t.setAttribute("id","applePayToken"),e.appendChild(t),this._form.onSubmit.subscribe((()=>this.onPayClicked()))}})),p.debug&&console.log("applePayEnabled",n);let i=this.applePay.closest(".en__field__item");return n?null==i||i.classList.add("applePayWrapper"):i&&(i.style.display="none"),n}))}performValidation(e){return new Promise((function(t,n){var i={};i.merchantIdentifier=w,i.merchantSessionIdentifier=L,i.nonce=C,i.domainName=E,i.epochTimestamp=k,i.signature=x;var s="/ea-dataservice/rest/applepay/validateurl?url="+e+("&merchantIdentifier="+w+"&merchantDomain="+E+"&displayName="+A),o=new XMLHttpRequest;o.onload=function(){var e=JSON.parse(this.responseText);p.debug&&console.log("Apple Pay Validation",e),t(e)},o.onerror=n,o.open("GET",s),o.send()}))}log(e,t){var n=new XMLHttpRequest;n.open("GET","/ea-dataservice/rest/applepay/log?name="+e+"&msg="+t),n.send()}sendPaymentToken(e){return new Promise((function(e,t){e(!0)}))}onPayClicked(){if(!this._form.submit)return;const e=document.querySelector("#en__field_transaction_paymenttype"),t=document.getElementById("applePayToken"),n=this._form;if("applepay"==e.value&&""==t.value)try{let e=this._amount.amount+this._fees.fee;var i=new S(1,{supportedNetworks:P,merchantCapabilities:N,countryCode:D,currencyCode:F,total:{label:T,amount:e}}),s=this;return i.onvalidatemerchant=function(e){s.performValidation(e.validationURL).then((function(e){p.debug&&console.log("Apple Pay merchantSession",e),i.completeMerchantValidation(e)}))},i.onpaymentauthorized=function(e){s.sendPaymentToken(e.payment.token).then((function(t){p.debug&&console.log("Apple Pay Token",e.payment.token),document.getElementById("applePayToken").value=JSON.stringify(e.payment.token),n.submitForm()}))},i.oncancel=function(e){p.debug&&console.log("Cancelled",e),alert("You cancelled. Sorry it didn't work out."),n.dispatchError()},i.begin(),this._form.submit=!1,!1}catch(e){alert("Developer mistake: '"+e.message+"'"),n.dispatchError()}return this._form.submit=!0,!0}}class q{constructor(){this.addRequired(),this.addLabel(),this.addGroupRole()}addGroupRole(){document.querySelectorAll(".en__field--radio").forEach((e=>{e.setAttribute("role","group");const t=e.querySelector("label");t&&(t.setAttribute("id",`en__field__label--${Math.random().toString(36).slice(2,7)}`),e.setAttribute("aria-labelledby",t.id))}))}addRequired(){document.querySelectorAll(".en__mandatory .en__field__input").forEach((e=>{e.setAttribute("aria-required","true")}))}addLabel(){const e=document.querySelector(".en__field__input--otheramount");e&&e.setAttribute("aria-label","Enter your custom donation amount");document.querySelectorAll(".en__field__input--splitselect").forEach((e=>{var t,n,i,s;const o=e.querySelector("option");!o||""!==o.value||(null===(n=null===(t=o.textContent)||void 0===t?void 0:t.toLowerCase())||void 0===n?void 0:n.includes("select"))||(null===(s=null===(i=o.textContent)||void 0===i?void 0:i.toLowerCase())||void 0===s?void 0:s.includes("choose"))||e.setAttribute("aria-label",o.textContent||"")}))}}class M{constructor(){this._form=u.getInstance(),this._form.onSubmit.subscribe((()=>this.capitalizeFields("en__field_supporter_firstName","en__field_supporter_lastName","en__field_supporter_address1","en__field_supporter_city")))}capitalizeFields(...e){e.forEach((e=>this.capitalize(e)))}capitalize(e){let t=document.getElementById(e);return t&&(t.value=t.value.replace(/\w\S*/g,(e=>e.replace(/^\w/,(e=>e.toUpperCase())))),p.debug&&console.log("Capitalized",t.value)),!0}}class I{constructor(){if(this.yearField=document.querySelector("select[name='transaction.ccexpire']:not(#en__field_transaction_ccexpire)"),this.years=20,this.yearLength=2,this.yearField){this.clearFieldOptions();for(let e=0;e{var t;if(""!==e.value&&!isNaN(Number(e.value))){const n=[...this.yearField.options].findIndex((t=>t.value===e.value));null===(t=this.yearField)||void 0===t||t.remove(n)}})))}}class B{constructor(){this.logger=new fe("Autocomplete","#330033","#f0f0f0","📇"),this.autoCompleteField('[name="supporter.firstName"]',"given-name"),this.autoCompleteField('[name="supporter.lastName"]',"family-name"),this.autoCompleteField("#en__field_transaction_ccexpire","cc-exp-month"),this.autoCompleteField('[name="transaction.ccexpire"]:not(#en__field_transaction_ccexpire)',"cc-exp-year"),this.autoCompleteField('[name="supporter.emailAddress"]',"email"),this.autoCompleteField('[name="supporter.phoneNumber"]',"tel"),this.autoCompleteField('[name="supporter.country"]',"country"),this.autoCompleteField('[name="supporter.address1"]',"address-line1"),this.autoCompleteField('[name="supporter.address2"]',"address-line2"),this.autoCompleteField('[name="supporter.city"]',"address-level2"),this.autoCompleteField('[name="supporter.region"]',"address-level1"),this.autoCompleteField('[name="supporter.postcode"]',"postal-code"),this.autoCompleteField('[name="transaction.honname"]',"none"),this.autoCompleteField('[name="transaction.infemail"]',"none"),this.autoCompleteField('[name="transaction.infname"]',"none"),this.autoCompleteField('[name="transaction.infadd1"]',"none"),this.autoCompleteField('[name="transaction.infadd2"]',"none"),this.autoCompleteField('[name="transaction.infcity"]',"none"),this.autoCompleteField('[name="transaction.infpostcd"]',"none")}autoCompleteField(e,t){let n=document.querySelector(e);return n?(n.autocomplete=t,!0):("none"!==t&&this.logger.log("Field Not Found",e),!1)}}class R{constructor(){if(this._form=u.getInstance(),this.logger=new fe("Ecard","red","#f5f5f5","🪪"),!this.shouldRun())return;this._form.onValidate.subscribe((()=>this.checkRecipientFields()));const e=p.getUrlParameter("engrid_ecard.schedule"),t=p.getField("ecard.schedule"),n=p.getUrlParameter("engrid_ecard.name"),i=document.querySelector(".en__ecardrecipients__name input"),s=p.getUrlParameter("engrid_ecard.email"),o=document.querySelector(".en__ecardrecipients__email input");if(e&&t){const n=new Date(e.toString()),i=new Date;n.setHours(0,0,0,0){const t='
'+e.innerHTML+"
";e.innerHTML=t,e.addEventListener("click",(t=>{t&&(p.debug&&console.log("A click-to-expand div was clicked"),e.classList.add("expanded"))})),e.addEventListener("keydown",(t=>{"Enter"===t.key?(p.debug&&console.log("A click-to-expand div had the 'Enter' key pressed on it"),e.classList.add("expanded")):" "===t.key&&(p.debug&&console.log("A click-to-expand div had the 'Spacebar' key pressed on it"),e.classList.add("expanded"),t.preventDefault(),t.stopPropagation())}))}))}}class H{constructor(){this.logger=new fe("Advocacy","#232323","#f7b500","👨‍⚖️"),this.shoudRun()&&this.setClickableLabels()}shoudRun(){return["ADVOCACY","EMAILTOTARGET"].includes(p.getPageType())}setClickableLabels(){const e=document.querySelectorAll(".en__contactDetails__rows");e&&e.forEach((e=>{e.addEventListener("click",(t=>{this.toggleCheckbox(e)}))}))}toggleCheckbox(e){const t=e.closest(".en__contactDetails");if(!t)return;const n=t.querySelector("input[type='checkbox']");n&&(this.logger.log("toggleCheckbox",n.checked),n.checked=!n.checked)}}class U{constructor(){this._country=b.getInstance(),this.setDataAttributes()}setDataAttributes(){p.checkNested(window,"pageJson","pageType")&&p.setBodyData("page-type",window.pageJson.pageType),p.setBodyData("currency-code",p.getCurrencyCode()),document.querySelector(".body-banner img, .body-banner video")||p.setBodyData("body-banner","empty"),document.querySelector(".page-alert *")||p.setBodyData("no-page-alert",""),document.querySelector(".content-header *")||p.setBodyData("no-content-header",""),document.querySelector(".body-headerOutside *")||p.setBodyData("no-body-headerOutside",""),document.querySelector(".body-header *")||p.setBodyData("no-body-header",""),document.querySelector(".body-title *")||p.setBodyData("no-body-title",""),document.querySelector(".body-banner *")||p.setBodyData("no-body-banner",""),document.querySelector(".body-bannerOverlay *")||p.setBodyData("no-body-bannerOverlay",""),document.querySelector(".body-top *")||p.setBodyData("no-body-top",""),document.querySelector(".body-main *")||p.setBodyData("no-body-main",""),document.querySelector(".body-bottom *")||p.setBodyData("no-body-bottom",""),document.querySelector(".body-footer *")||p.setBodyData("no-body-footer",""),document.querySelector(".body-footerOutside *")||p.setBodyData("no-body-footerOutside",""),document.querySelector(".content-footerSpacer *")||p.setBodyData("no-content-footerSpacer",""),document.querySelector(".content-preFooter *")||p.setBodyData("no-content-preFooter",""),document.querySelector(".content-footer *")||p.setBodyData("no-content-footer",""),document.querySelector(".page-backgroundImage img, .page-backgroundImage video")||p.setBodyData("no-page-backgroundImage",""),document.querySelector(".page-backgroundImageOverlay *")||p.setBodyData("no-page-backgroundImageOverlay",""),document.querySelector(".page-customCode *")||p.setBodyData("no-page-customCode",""),this._country.country&&(p.setBodyData("country",this._country.country),this._country.onCountryChange.subscribe((e=>{p.setBodyData("country",e)})));const e=document.querySelector(".en__field--donationAmt .en__field__item--other");e&&e.setAttribute("data-currency-symbol",p.getCurrencySymbol());const t=p.getField("transaction.paymenttype");t&&(p.setBodyData("payment-type",t.value),t.addEventListener("change",(()=>{p.setBodyData("payment-type",t.value)})));const n=document.querySelector(".content-footer");n&&p.isInViewport(n)?p.setBodyData("footer-above-fold",""):p.setBodyData("footer-below-fold",""),p.demo&&p.setBodyData("demo",""),1===p.getPageNumber()&&p.setBodyData("first-page",""),p.getPageNumber()===p.getPageCount()&&p.setBodyData("last-page",""),CSS.supports("selector(:has(*))")||p.setBodyData("css-has-selector","false"),"DONATION"===p.getPageType()&&this.addFrequencyDataAttribute()}addFrequencyDataAttribute(){const e=document.querySelectorAll(".en__field--recurrfreq .en__field__item label.en__field__label");let t=0;e.forEach((e=>{p.isVisible(e)&&t++})),p.setBodyData("visible-frequency",t.toString())}}class V{constructor(){if(this._form=u.getInstance(),this.logger=new fe("iFrame","brown","gray","📡"),this.inIframe()){p.setBodyData("embedded","");const e=/\/page\/\d+\/[^\/]+\/(\d+)(\?|$)/,t=(()=>{try{return window.parent.location.href}catch(e){return document.referrer}})().match(e);if(t){parseInt(t[1],10)>1&&(p.setBodyData("embedded","thank-you-page-donation"),this.hideFormComponents(),this.logger.log("iFrame Event - Set embedded attribute to thank-you-page-donation"))}this.logger.log("iFrame Event - Begin Resizing"),console.log("document.readyState",document.readyState),"loading"!==document.readyState?this.onLoaded():document.addEventListener("DOMContentLoaded",(()=>{this.onLoaded()})),window.setTimeout((()=>{this.sendIframeHeight()}),300),window.addEventListener("resize",this.debounceWithImmediate((()=>{this.logger.log("iFrame Event - window resized"),this.sendIframeHeight()}))),this._form.onSubmit.subscribe((e=>{this.logger.log("iFrame Event - onSubmit"),this.sendIframeFormStatus("submit")})),this.isChained()&&p.getPaymentType()&&(this.logger.log("iFrame Event - Chained iFrame"),this.sendIframeFormStatus("chained"));const n=document.querySelector(".skip-link");n&&n.remove(),this._form.onError.subscribe((()=>{const e=document.querySelector(".en__field--validationFailed"),t=e?e.getBoundingClientRect().top:0;this.logger.log(`iFrame Event 'scrollTo' - Position of top of first error ${t} px`),window.parent.postMessage({scrollTo:t},"*"),window.setTimeout((()=>{this.sendIframeHeight()}),100)}))}else this._form.onError.subscribe((()=>{const e=document.querySelector(".en__field--validationFailed");e&&e.scrollIntoView({behavior:"smooth"})})),window.addEventListener("message",(e=>{const t=this.getIFrameByEvent(e);if(t)if(e.data.hasOwnProperty("frameHeight"))t.style.height=e.data.frameHeight+"px",e.data.frameHeight>0?t.classList.add("loaded"):t.classList.remove("loaded");else if(e.data.hasOwnProperty("scroll")&&e.data.scroll>0){let n=window.pageYOffset+t.getBoundingClientRect().top+e.data.scroll;window.scrollTo({top:n,left:0,behavior:"smooth"}),this.logger.log("iFrame Event - Scrolling Window to "+n)}else if(e.data.hasOwnProperty("scrollTo")){const n=e.data.scrollTo+window.scrollY+t.getBoundingClientRect().top;window.scrollTo({top:n,left:0,behavior:"smooth"}),this.logger.log("iFrame Event - Scrolling Window to "+n)}}))}onLoaded(){this.logger.log("iFrame Event - window.onload"),this.sendIframeHeight(),window.parent.postMessage({scroll:this.shouldScroll()},"*"),document.addEventListener("click",(e=>{this.logger.log("iFrame Event - click"),setTimeout((()=>{this.sendIframeHeight()}),100)})),p.watchForError(this.sendIframeHeight.bind(this))}sendIframeHeight(){let e=document.body.offsetHeight;this.logger.log("iFrame Event - Sending iFrame height of: "+e+"px"),window.parent.postMessage({frameHeight:e,pageNumber:p.getPageNumber(),pageCount:p.getPageCount(),giftProcess:p.getGiftProcess()},"*")}sendIframeFormStatus(e){window.parent.postMessage({status:e,pageNumber:p.getPageNumber(),pageCount:p.getPageCount(),giftProcess:p.getGiftProcess()},"*")}getIFrameByEvent(e){return[].slice.call(document.getElementsByTagName("iframe")).filter((t=>t.contentWindow===e.source))[0]}shouldScroll(){if(document.querySelector(".en__errorHeader"))return!0;if(this.isChained())return!1;let e=document.referrer;return new RegExp(/^(.*)\/(page)\/(\d+.*)/).test(e)}inIframe(){try{return window.self!==window.top}catch(e){return!0}}isChained(){return!!p.getUrlParameter("chain")}hideFormComponents(){this.logger.log("iFrame Event - Hiding Form Components");const e=["giveBySelect-Card","en__field--ccnumber","en__field--survey","give-by-select","give-by-select-header","en__submit","en__captcha","force-visibility","hide","hide-iframe","radio-to-buttons_donationAmt"],t=["en__digitalWallet"];Array.from(document.querySelectorAll(".body-main > div:not(:last-child)")).forEach((n=>{e.some((e=>n.classList.contains(e)||n.querySelector(`:scope > .${e}`)))||t.some((e=>n.querySelector(`#${e}`)))||n.classList.add("hide-iframe","hide-chained")})),this.sendIframeHeight()}showFormComponents(){this.logger.log("iFrame Event - Showing Form Components");document.querySelectorAll(".body-main > div.hide-chained").forEach((e=>{e.classList.remove("hide-iframe"),e.classList.remove("hide-chained")})),this.sendIframeHeight()}debounceWithImmediate(e,t=1e3){let n,i=!0;return(...s)=>{clearTimeout(n),i&&(e.apply(this,s),i=!1),n=setTimeout((()=>{e.apply(this,s),i=!0}),t)}}}class ${constructor(){this.logger=new fe("InputHasValueAndFocus","yellow","#333","🌈"),this.formInputs=document.querySelectorAll(".en__field--text, .en__field--email:not(.en__field--checkbox), .en__field--telephone, .en__field--number, .en__field--textarea, .en__field--select, .en__field--checkbox"),this.shouldRun()&&this.run()}shouldRun(){return this.formInputs.length>0}run(){this.formInputs.forEach((e=>{const t=e.querySelector("input, textarea, select");t&&t.value&&e.classList.add("has-value"),this.bindEvents(e)}))}bindEvents(e){const t=e.querySelector("input, textarea, select");t&&(t.addEventListener("focus",(()=>{this.log("Focus added",t),e.classList.add("has-focus")})),t.addEventListener("blur",(()=>{this.log("Focus removed",t),e.classList.remove("has-focus")})),t.addEventListener("input",(()=>{t.value?(this.log("Value added",t),e.classList.add("has-value")):(this.log("Value removed",t),e.classList.remove("has-value"))})))}log(e,t){this.logger.log(`${e} on ${t.name}: ${t.value}`)}}class W{constructor(){if(this.defaultPlaceholders={"input#en__field_supporter_firstName":"First Name","input#en__field_supporter_lastName":"Last Name","input#en__field_supporter_emailAddress":"Email Address","input#en__field_supporter_phoneNumber":"Phone Number (Optional)",".en__mandatory input#en__field_supporter_phoneNumber":"Phone Number",".required-if-visible input#en__field_supporter_phoneNumber":"Phone Number","input#en__field_supporter_phoneNumber2":"000-000-0000 (Optional)",".en__mandatory input#en__field_supporter_phoneNumber2":"000-000-0000",".required-if-visible input#en__field_supporter_phoneNumber2":"000-000-0000","input#en__field_supporter_country":"Country","input#en__field_supporter_address1":"Street Address","input#en__field_supporter_address2":"Apt., Ste., Bldg.","input#en__field_supporter_city":"City","input#en__field_supporter_region":"Region","input#en__field_supporter_postcode":"ZIP Code",".en__field--donationAmt.en__field--withOther .en__field__input--other":"Other","input#en__field_transaction_ccexpire":"MM / YY","input#en__field_supporter_bankAccountNumber":"Bank Account Number","input#en__field_supporter_bankRoutingNumber":"Bank Routing Number","input#en__field_transaction_honname":"Honoree Name","input#en__field_transaction_infname":"Recipient Name","input#en__field_transaction_infemail":"Recipient Email Address","input#en__field_transaction_infcountry":"Country","input#en__field_transaction_infadd1":"Recipient Street Address","input#en__field_transaction_infadd2":"Recipient Apt., Ste., Bldg.","input#en__field_transaction_infcity":"Recipient City","input#en__field_transaction_infpostcd":"Recipient Postal Code","input#en__field_transaction_gftrsn":"Reason for your gift","input#en__field_transaction_shipfname":"Shipping First Name","input#en__field_transaction_shiplname":"Shipping Last Name","input#en__field_transaction_shipemail":"Shipping Email Address","input#en__field_transaction_shipcountry":"Shipping Country","input#en__field_transaction_shipadd1":"Shipping Street Address","input#en__field_transaction_shipadd2":"Shipping Apt., Ste., Bldg.","input#en__field_transaction_shipcity":"Shipping City","input#en__field_transaction_shipregion":"Shipping Region","input#en__field_transaction_shippostcode":"Shipping Postal Code","input#en__field_supporter_billingCountry":"Billing Country","input#en__field_supporter_billingAddress1":"Billing Street Address","input#en__field_supporter_billingAddress2":"Billing Apt., Ste., Bldg.","input#en__field_supporter_billingCity":"Billing City","input#en__field_supporter_billingRegion":"Billing Region","input#en__field_supporter_billingPostcode":"Billing Postal Code"},this.shouldRun()){const e=p.getOption("Placeholders");e&&(this.defaultPlaceholders=Object.assign(Object.assign({},this.defaultPlaceholders),e)),this.run()}}shouldRun(){return p.hasBodyData("add-input-placeholders")}run(){Object.keys(this.defaultPlaceholders).forEach((e=>{e in this.defaultPlaceholders&&this.addPlaceholder(e,this.defaultPlaceholders[e])}))}addPlaceholder(e,t){const n=document.querySelector(e);n&&(n.placeholder=t)}}const G=n(3861).ZP;class Y{constructor(){this.mediaWithAttribution=document.querySelectorAll("img[data-attribution-source]:not([data-attribution-hide-overlay]), video[data-attribution-source]:not([data-attribution-hide-overlay])"),this.mediaWithAttribution.forEach((e=>{p.debug&&console.log("The following image was found with data attribution fields on it. It's markup will be changed to add caption support.",e);let t=document.createElement("figure");t.classList.add("media-with-attribution");let n=e.parentNode;if(n){n.insertBefore(t,e),t.appendChild(e);let i=e,s=i.dataset.attributionSource;if(s){let e=i.dataset.attributionSourceLink;e?i.insertAdjacentHTML("afterend",''+s+""):i.insertAdjacentHTML("afterend",""+s+"");const t="attributionSourceTooltip"in i.dataset&&i.dataset.attributionSourceTooltip;t&&G(i.nextSibling,{content:t,arrow:!0,arrowType:"default",placement:"left",trigger:"click mouseenter focus",interactive:!0})}}}))}}class J{constructor(t){var n;this._amount=h.getInstance(),this._fees=m.getInstance(),this._frequency=g.getInstance(),this._form=u.getInstance(),this.multiplier=1/12,this.options=Object.assign(Object.assign({},e),t),this.submitLabel=(null===(n=document.querySelector(".en__submit button"))||void 0===n?void 0:n.innerHTML)||"Donate",this._amount.onAmountChange.subscribe((()=>this.changeSubmitButton())),this._amount.onAmountChange.subscribe((()=>this.changeLiveAmount())),this._amount.onAmountChange.subscribe((()=>this.changeLiveUpsellAmount())),this._fees.onFeeChange.subscribe((()=>this.changeLiveAmount())),this._fees.onFeeChange.subscribe((()=>this.changeLiveUpsellAmount())),this._fees.onFeeChange.subscribe((()=>this.changeSubmitButton())),this._frequency.onFrequencyChange.subscribe((()=>this.changeLiveFrequency())),this._frequency.onFrequencyChange.subscribe((()=>this.changeRecurrency())),this._frequency.onFrequencyChange.subscribe((()=>this.changeSubmitButton())),this._form.onSubmit.subscribe((()=>{"SUPPORTERHUB"!==p.getPageType()&&p.disableSubmit("Processing...")})),this._form.onError.subscribe((()=>p.enableSubmit())),document.addEventListener("click",(e=>{const t=e.target;t&&(t.classList.contains("monthly-upsell")?this.upsold(e):t.classList.contains("form-submit")&&(e.preventDefault(),this._form.submitForm()))}))}getAmountTxt(e=0){var t,n,i,s;const o=null!==(t=p.getCurrencySymbol())&&void 0!==t?t:"$",r=null!==(n=this.options.DecimalSeparator)&&void 0!==n?n:".",a=null!==(i=this.options.ThousandsSeparator)&&void 0!==i?i:"",l=e%1==0?0:null!==(s=this.options.DecimalPlaces)&&void 0!==s?s:2,c=p.formatNumber(e,l,r,a);return e>0?`${o}${c}`:""}getUpsellAmountTxt(e=0){var t,n,i,s;const o=null!==(t=p.getCurrencySymbol())&&void 0!==t?t:"$",r=null!==(n=this.options.DecimalSeparator)&&void 0!==n?n:".",a=null!==(i=this.options.ThousandsSeparator)&&void 0!==i?i:"",l=e%1==0?0:null!==(s=this.options.DecimalPlaces)&&void 0!==s?s:2,c=p.formatNumber(5*Math.ceil(e/5),l,r,a);return e>0?o+c:""}getUpsellAmountRaw(e=0){const t=5*Math.ceil(e/5);return e>0?t.toString():""}changeSubmitButton(){const e=document.querySelector(".en__submit button"),t=this.getAmountTxt(this._amount.amount+this._fees.fee),n="onetime"==this._frequency.frequency?"":"annual"==this._frequency.frequency?"annually":this._frequency.frequency;let i=this.submitLabel;t?(i=i.replace("$AMOUNT",t),i=i.replace("$FREQUENCY",`${n}`)):(i=i.replace("$AMOUNT",""),i=i.replace("$FREQUENCY","")),e&&i&&(e.innerHTML=i)}changeLiveAmount(){const e=this._amount.amount+this._fees.fee;document.querySelectorAll(".live-giving-amount").forEach((t=>t.innerHTML=this.getAmountTxt(e)))}changeLiveUpsellAmount(){const e=(this._amount.amount+this._fees.fee)*this.multiplier;document.querySelectorAll(".live-giving-upsell-amount").forEach((t=>t.innerHTML=this.getUpsellAmountTxt(e)));document.querySelectorAll(".live-giving-upsell-amount-raw").forEach((t=>t.innerHTML=this.getUpsellAmountRaw(e)))}changeLiveFrequency(){document.querySelectorAll(".live-giving-frequency").forEach((e=>e.innerHTML="onetime"==this._frequency.frequency?"":this._frequency.frequency))}changeRecurrency(){const e=document.querySelector("[name='transaction.recurrpay']");if(e&&"radio"!=e.type){e.value="onetime"==this._frequency.frequency?"N":"Y",this._frequency.recurring=e.value,p.getOption("Debug")&&console.log("Recurpay Changed!");const t=new Event("change",{bubbles:!0});e.dispatchEvent(t)}}upsold(e){const t=document.querySelector(".en__field--recurrpay input[value='Y']");t&&(t.checked=!0);const n=document.querySelector(".en__field--donationAmt input[value='other']");n&&(n.checked=!0);const i=document.querySelector("input[name='transaction.donationAmt.other']");i&&(i.value=this.getUpsellAmountRaw(this._amount.amount*this.multiplier),this._amount.load(),this._frequency.load(),i.parentElement&&i.parentElement.classList.remove("en__field__item--hidden"));const s=e.target;s&&s.classList.contains("form-submit")&&(e.preventDefault(),this._form.submitForm())}}class z{constructor(){this.overlay=document.createElement("div"),this._form=u.getInstance(),this._amount=h.getInstance(),this._fees=m.getInstance(),this._frequency=g.getInstance(),this._dataLayer=ye.getInstance(),this._suggestAmount=0,this.logger=new fe("UpsellLightbox","black","pink","🪟");let e="EngridUpsell"in window?window.EngridUpsell:{};this.options=Object.assign(Object.assign({},t),e),this.options.disablePaymentMethods.push("applepay"),this.shouldRun()?(this.overlay.id="enModal",this.overlay.classList.add("is-hidden"),this.overlay.classList.add("image-"+this.options.imagePosition),this.renderLightbox(),this._form.onSubmit.subscribe((()=>this.open()))):this.logger.log("Upsell script should NOT run")}renderLightbox(){const e=this.options.title.replace("{new-amount}","").replace("{old-amount}","").replace("{old-frequency}",""),t=this.options.paragraph.replace("{new-amount}","").replace("{old-amount}","").replace("{old-frequency}",""),n=this.options.yesLabel.replace("{new-amount}","").replace("{old-amount}","").replace("{old-frequency}",""),i=this.options.noLabel.replace("{new-amount}","").replace("{old-amount}","").replace("{old-frequency}",""),s=`\n
\n \x3c!-- ideal image size is 480x650 pixels --\x3e\n
\n
\n ${this.options.canClose?'':""}\n

\n ${e}\n

\n ${this.options.otherAmount?`\n
\n
\n

\n ${this.options.otherLabel}\n

\n
\n
\n \n Minimum ${this.getAmountTxt(this.options.minAmount)}\n
\n
\n `:""}\n\n

\n ${t}\n

\n \x3c!-- YES BUTTON --\x3e\n \n \x3c!-- NO BUTTON --\x3e\n
\n \n
\n
\n
\n `;this.overlay.innerHTML=s;const o=this.overlay.querySelector("#goMonthlyClose"),r=this.overlay.querySelector("#upsellYesButton a"),a=this.overlay.querySelector("#upsellNoButton button");r.addEventListener("click",this.continue.bind(this)),a.addEventListener("click",this.continue.bind(this)),o&&o.addEventListener("click",this.close.bind(this)),this.overlay.addEventListener("click",(e=>{e.target instanceof Element&&e.target.id==this.overlay.id&&this.options.canClose&&this.close(e)})),document.addEventListener("keyup",(e=>{"Escape"===e.key&&o&&o.click()})),document.body.appendChild(this.overlay);const l=document.querySelector("#secondOtherField");l&&l.addEventListener("keyup",this.popupOtherField.bind(this)),this.logger.log("Upsell script rendered")}shouldRun(){return!this.shouldSkip()&&"EngridUpsell"in window&&!!window.pageJson&&1==window.pageJson.pageNumber&&["donation","premiumgift"].includes(window.pageJson.pageType)}shouldSkip(){return!(!("EngridUpsell"in window)||!window.EngridUpsell.skipUpsell)||this.options.skipUpsell}popupOtherField(){var e,t;const n=parseFloat(null!==(t=null===(e=this.overlay.querySelector("#secondOtherField"))||void 0===e?void 0:e.value)&&void 0!==t?t:""),i=document.querySelectorAll("#upsellYesButton .upsell_suggestion"),s=this.getUpsellAmount();!isNaN(n)&&n>0?this.checkOtherAmount(n):this.checkOtherAmount(s),i.forEach((e=>e.innerHTML=this.getAmountTxt(s+this._fees.calculateFees(s))))}liveAmounts(){const e=document.querySelectorAll(".upsell_suggestion"),t=document.querySelectorAll(".upsell_amount"),n=this.getUpsellAmount(),i=n+this._fees.calculateFees(n);e.forEach((e=>e.innerHTML=this.getAmountTxt(i))),t.forEach((e=>e.innerHTML=this.getAmountTxt(this._amount.amount+this._fees.fee)))}liveFrequency(){document.querySelectorAll(".upsell_frequency").forEach((e=>e.innerHTML=this.getFrequencyTxt()))}getUpsellAmount(){var e,t;const n=this._amount.amount,i=parseFloat(null!==(t=null===(e=this.overlay.querySelector("#secondOtherField"))||void 0===e?void 0:e.value)&&void 0!==t?t:"");if(i>0)return i>this.options.minAmount?i:this.options.minAmount;let s=0;for(let e=0;ethis.options.minAmount?s:this.options.minAmount}shouldOpen(){const e=this.getUpsellAmount(),t=p.getFieldValue("transaction.paymenttype")||"";return this._suggestAmount=e,!(!this.freqAllowed()||this.shouldSkip()||this.options.disablePaymentMethods.includes(t.toLowerCase())||this.overlay.classList.contains("is-submitting")||!(e>0))&&(this.logger.log("Upsell Frequency "+this._frequency.frequency),this.logger.log("Upsell Amount "+this._amount.amount),this.logger.log("Upsell Suggested Amount "+e),!0)}freqAllowed(){const e=this._frequency.frequency,t=[];return this.options.oneTime&&t.push("onetime"),this.options.annual&&t.push("annual"),t.includes(e)}open(){if(this.logger.log("Upsell script opened"),!this.shouldOpen()){let e=window.sessionStorage.getItem("original");return e&&document.querySelectorAll(".en__errorList .en__error").length>0&&this.setOriginalAmount(e),this._form.submit=!0,!0}return this.liveAmounts(),this.liveFrequency(),this.overlay.classList.remove("is-hidden"),this._form.submit=!1,p.setBodyData("has-lightbox",""),!1}setOriginalAmount(e){if(this.options.upsellOriginalGiftAmountFieldName){let t=document.querySelector(".en__field__input.en__field__input--hidden[name='"+this.options.upsellOriginalGiftAmountFieldName+"']");if(!t){let e=document.querySelector("form.en__component--page");if(e){let n=document.createElement("input");n.setAttribute("type","hidden"),n.setAttribute("name",this.options.upsellOriginalGiftAmountFieldName),n.classList.add("en__field__input","en__field__input--hidden"),e.appendChild(n),t=document.querySelector('.en__field__input.en__field__input--hidden[name="'+this.options.upsellOriginalGiftAmountFieldName+'"]')}}t&&(window.sessionStorage.setItem("original",e),t.setAttribute("value",e))}}continue(e){var t;if(e.preventDefault(),e.target instanceof Element&&(null===(t=document.querySelector("#upsellYesButton"))||void 0===t?void 0:t.contains(e.target))){this.logger.success("Upsold"),this.setOriginalAmount(this._amount.amount.toString());const e=this.getUpsellAmount(),t=this._amount.amount;this._frequency.setFrequency("monthly"),this._amount.setAmount(e),this._dataLayer.addEndOfGiftProcessEvent("ENGRID_UPSELL",{eventValue:!0,originalAmount:t,upsoldAmount:e,frequency:"monthly"}),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL",!0),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_ORIGINAL_AMOUNT",t),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY","MONTHLY"),this.renderConversionField("upsellSuccess","onetime",t,"monthly",this._suggestAmount,"monthly",e)}else this.setOriginalAmount(""),window.sessionStorage.removeItem("original"),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL",!1),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY","ONE-TIME"),this.renderConversionField("upsellFail",this._frequency.frequency,this._amount.amount,"monthly",this._suggestAmount,this._frequency.frequency,this._amount.amount);this._form.submitForm()}close(e){e.preventDefault(),this.overlay.classList.add("is-hidden"),p.setBodyData("has-lightbox",!1),this.options.submitOnClose?(this.renderConversionField("upsellFail",this._frequency.frequency,this._amount.amount,"monthly",this._suggestAmount,this._frequency.frequency,this._amount.amount),this._form.submitForm()):this._form.dispatchError()}getAmountTxt(e=0){var t,n,i,s;const o=null!==(t=p.getCurrencySymbol())&&void 0!==t?t:"$",r=null!==(n=p.getOption("DecimalSeparator"))&&void 0!==n?n:".",a=null!==(i=p.getOption("ThousandsSeparator"))&&void 0!==i?i:"",l=e%1==0?0:null!==(s=p.getOption("DecimalPlaces"))&&void 0!==s?s:2,c=p.formatNumber(e,l,r,a);return e>0?o+c:""}getFrequencyTxt(){const e={onetime:"one-time",monthly:"monthly",annual:"annual"},t=this._frequency.frequency;return t in e?e[t]:t}checkOtherAmount(e){const t=document.querySelector(".upsellOtherAmountInput");t&&(e>=this.options.minAmount?t.classList.remove("is-invalid"):t.classList.add("is-invalid"))}renderConversionField(e,t,n,i,s,o,r){if(""===this.options.conversionField)return;const a=document.querySelector("input[name='"+this.options.conversionField+"']")||p.createHiddenInput(this.options.conversionField);if(!a)return void this.logger.error("Could not find or create the conversion field");const l=`event:${e},freq:${t},amt:${n},sugFreq:${i},sugAmt:${s},subFreq:${o},subAmt:${r}`;a.value=l,this.logger.log(`Conversion Field ${e}`,l)}}class K{constructor(){this.checkboxOptions=!1,this.checkboxOptionsDefaults={label:"Make my gift a monthly gift of {new-amount}/mo",location:"before .en__component .en__submit",cssClass:""},this._amount=h.getInstance(),this._fees=m.getInstance(),this._frequency=g.getInstance(),this._dataLayer=ye.getInstance(),this.checkboxContainer=null,this.oldAmount=0,this.oldFrequency="one-time",this.resetCheckbox=!1,this.logger=new fe("UpsellCheckbox","black","LemonChiffon","✅");let e="EngridUpsell"in window?window.EngridUpsell:{};this.options=Object.assign(Object.assign({},t),e),!1!==this.options.upsellCheckbox?("upsellCheckbox"in e&&!1!==e.upsellCheckbox&&(window.EngridUpsell.skipUpsell=!0),this.checkboxOptions=Object.assign(Object.assign({},this.checkboxOptionsDefaults),this.options.upsellCheckbox),this.shouldRun()?(this.renderCheckbox(),this.updateLiveData(),this._frequency.onFrequencyChange.subscribe((()=>this.updateLiveData())),this._frequency.onFrequencyChange.subscribe((()=>this.resetUpsellCheckbox())),this._amount.onAmountChange.subscribe((()=>this.updateLiveData())),this._amount.onAmountChange.subscribe((()=>this.resetUpsellCheckbox())),this._fees.onFeeChange.subscribe((()=>this.updateLiveData()))):this.logger.log("should NOT run")):this.logger.log("Skipped")}updateLiveData(){this.liveAmounts(),this.liveFrequency()}resetUpsellCheckbox(){var e,t;if(!this.resetCheckbox)return;this.logger.log("Reset");const n=null===(e=this.checkboxContainer)||void 0===e?void 0:e.querySelector("#upsellCheckbox");n&&(n.checked=!1),null===(t=this.checkboxContainer)||void 0===t||t.classList.add("recurring-frequency-y-hide"),this.oldAmount=0,this.oldFrequency="one-time",this.resetCheckbox=!1}renderCheckbox(){if(!1===this.checkboxOptions)return;const e=this.checkboxOptions.label.replace("{new-amount}"," ").replace("{old-amount}"," ").replace("{old-frequency}"," "),t=document.createElement("div");t.classList.add("en__component","en__component--formblock","recurring-frequency-y-hide","engrid-upsell-checkbox"),this.checkboxOptions.cssClass&&t.classList.add(this.checkboxOptions.cssClass),t.innerHTML=`\n
\n
\n
\n \n \n
\n
\n
`;const n=t.querySelector("#upsellCheckbox");n&&n.addEventListener("change",this.toggleCheck.bind(this));const i=this.checkboxOptions.location.split(" ")[0],s=this.checkboxOptions.location.split(" ").slice(1).join(" ").trim(),o=document.querySelector(s);this.checkboxContainer=t,o?"before"===i?(this.logger.log("rendered before"),o.before(t)):(this.logger.log("rendered after"),o.after(t)):this.logger.error("could not render - target not found")}shouldRun(){return 1===p.getPageNumber()&&"DONATION"===p.getPageType()}showCheckbox(){this.checkboxContainer&&this.checkboxContainer.classList.remove("hide")}hideCheckbox(){this.checkboxContainer&&this.checkboxContainer.classList.add("hide")}liveAmounts(){if("onetime"!==this._frequency.frequency)return;const e=document.querySelectorAll(".upsell_suggestion"),t=document.querySelectorAll(".upsell_amount"),n=this.getUpsellAmount(),i=n+this._fees.calculateFees(n);i>0?this.showCheckbox():this.hideCheckbox(),e.forEach((e=>e.innerHTML=this.getAmountTxt(i))),t.forEach((e=>e.innerHTML=this.getAmountTxt(this._amount.amount+this._fees.fee)))}liveFrequency(){document.querySelectorAll(".upsell_frequency").forEach((e=>e.innerHTML=this.getFrequencyTxt()))}getUpsellAmount(){const e=this._amount.amount;let t=0;for(let n=0;nthis.options.minAmount?t:this.options.minAmount}toggleCheck(e){var t,n;if(e.preventDefault(),e.target.checked){this.logger.success("Upsold");const e=this.getUpsellAmount(),n=this._amount.amount;this.oldAmount=n,this.oldFrequency=this._frequency.frequency,null===(t=this.checkboxContainer)||void 0===t||t.classList.remove("recurring-frequency-y-hide"),this._frequency.setFrequency("monthly"),this._amount.setAmount(e),this._dataLayer.addEndOfGiftProcessEvent("ENGRID_UPSELL_CHECKBOX",{eventValue:!0,originalAmount:n,upsoldAmount:e,frequency:"monthly"}),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_CHECKBOX",!0),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_ORIGINAL_AMOUNT",n),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY","MONTHLY"),this.renderConversionField("upsellSuccess","onetime",n,"monthly",e,"monthly",e),window.setTimeout((()=>{this.resetCheckbox=!0}),500)}else this.resetCheckbox=!1,this.logger.success("Not Upsold"),this._amount.setAmount(this.oldAmount),this._frequency.setFrequency(this.oldFrequency),null===(n=this.checkboxContainer)||void 0===n||n.classList.add("recurring-frequency-y-hide"),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_CHECKBOX",!1),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY","ONE-TIME"),this.renderConversionField("upsellFail",this._frequency.frequency,this._amount.amount,"monthly",this._amount.amount,this._frequency.frequency,this._amount.amount)}getAmountTxt(e=0){var t,n,i,s;const o=null!==(t=p.getCurrencySymbol())&&void 0!==t?t:"$",r=null!==(n=p.getOption("DecimalSeparator"))&&void 0!==n?n:".",a=null!==(i=p.getOption("ThousandsSeparator"))&&void 0!==i?i:"",l=e%1==0?0:null!==(s=p.getOption("DecimalPlaces"))&&void 0!==s?s:2,c=p.formatNumber(e,l,r,a);return e>0?o+c:""}getFrequencyTxt(){const e={onetime:"one-time",monthly:"monthly",annual:"annual"},t=this._frequency.frequency;return t in e?e[t]:t}renderConversionField(e,t,n,i,s,o,r){if(""===this.options.conversionField)return;const a=document.querySelector("input[name='"+this.options.conversionField+"']")||p.createHiddenInput(this.options.conversionField);if(!a)return void this.logger.error("Could not find or create the conversion field");const l=`event:${e},freq:${t},amt:${n},sugFreq:${i},sugAmt:${s},subFreq:${o},subAmt:${r}`;a.value=l,this.logger.log(`Conversion Field ${e}`,l)}}class X{createDataAttributes(){this.elements.forEach((e=>{if(e instanceof HTMLInputElement){let t=e.value.replace(/\W/g,"");document.querySelectorAll("."+this.classes+t).forEach((e=>{if(e instanceof HTMLElement){const t=e.querySelectorAll("input[type='text'], input[type='number'], input[type='email'], select, textarea");t.length>0&&t.forEach((e=>{(e instanceof HTMLInputElement||e instanceof HTMLSelectElement)&&(e.hasAttribute("data-original-value")||e.setAttribute("data-original-value",e.value),e.hasAttribute("data-value")||e.setAttribute("data-value",e.value))}))}}))}}))}hideAll(){this.elements.forEach(((e,t)=>{e instanceof HTMLInputElement&&this.hide(e)}))}hide(e){let t=e.value.replace(/\W/g,"");document.querySelectorAll("."+this.classes+t).forEach((e=>{e instanceof HTMLElement&&(this.toggleValue(e,"hide"),e.style.display="none",this.logger.log("Hiding",e))}))}show(e){let t=e.value.replace(/\W/g,"");document.querySelectorAll("."+this.classes+t).forEach((e=>{e instanceof HTMLElement&&(this.toggleValue(e,"show"),e.style.display="",this.logger.log("Showing",e))})),"checkbox"!=e.type||e.checked||this.hide(e)}toggleValue(e,t){if("hide"==t&&!p.isVisible(e))return;this.logger.log(`toggleValue: ${t}`);const n=e.querySelectorAll("input[type='text'], input[type='number'], input[type='email'], select, textarea");n.length>0&&n.forEach((e=>{var n;if((e instanceof HTMLInputElement||e instanceof HTMLSelectElement)&&e.name){const i=p.getFieldValue(e.name),s=e.getAttribute("data-original-value"),o=null!==(n=e.getAttribute("data-value"))&&void 0!==n?n:"";"hide"===t?(e.setAttribute("data-value",i),p.setFieldValue(e.name,s)):p.setFieldValue(e.name,o)}}))}getSessionState(){var e;try{const t=null!==(e=window.sessionStorage.getItem("engrid_ShowHideRadioCheckboxesState"))&&void 0!==e?e:"";return JSON.parse(t)}catch(e){return[]}}storeSessionState(){const e=this.getSessionState();[...this.elements].forEach((t=>{var n,i;t instanceof HTMLInputElement&&("radio"==t.type&&t.checked&&(e.forEach(((t,n)=>{t.class==this.classes&&e.splice(n,1)})),e.push({page:p.getPageID(),class:this.classes,value:t.value}),this.logger.log("storing radio state",e[e.length-1])),"checkbox"==t.type&&(e.forEach(((t,n)=>{t.class==this.classes&&e.splice(n,1)})),e.push({page:p.getPageID(),class:this.classes,value:null!==(i=null===(n=[...this.elements].find((e=>e.checked)))||void 0===n?void 0:n.value)&&void 0!==i?i:"N"}),this.logger.log("storing checkbox state",e[e.length-1])))})),window.sessionStorage.setItem("engrid_ShowHideRadioCheckboxesState",JSON.stringify(e))}constructor(e,t){this.logger=new fe("ShowHideRadioCheckboxes","black","lightblue","👁"),this.elements=document.getElementsByName(e),this.classes=t,this.createDataAttributes(),this.hideAll(),this.storeSessionState();for(let e=0;e{this.hideAll(),this.show(t),this.storeSessionState()}))}}}function Q(e,t){if(!t)return"";let n="; "+e;return!0===t?n:n+"="+t}function Z(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if("number"==typeof e.expires){let t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t}return Q("Expires",e.expires?e.expires.toUTCString():"")+Q("Domain",e.domain)+Q("Path",e.path)+Q("Secure",e.secure)+Q("SameSite",e.sameSite)}(n)}function ee(){return function(e){let t={},n=e?e.split("; "):[],i=/(%[\dA-F]{2})+/gi;for(let e=0;e{e.addEventListener("change",this.translateFields.bind(this,e.name)),e.value&&(t[e.name]=e.value);const n=document.querySelector(`select[name="${this.countryToStateFields[e.name]}"]`);n&&(n.addEventListener("change",this.rememberState.bind(this,e.name)),n.value&&(t[n.name]=n.value))})),this.translateFields("supporter.country");if(!!(!p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")||!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()))for(let e in t)p.setFieldValue(e,t[e],!1)}}translateFields(e="supporter.country"){this.resetTranslatedFields();const t=p.getFieldValue(e);if(this.setStateField(t,this.countryToStateFields[e]),"supporter.country"===e){t in this.options&&this.options[t].forEach((e=>{this.translateField(e.field,e.translation)}));const e=document.querySelectorAll(".recipient-block");if(e.length)switch(t){case"FR":case"FRA":case"France":e.forEach((e=>e.innerHTML="À:"));break;case"DE":case"DEU":case"Germany":e.forEach((e=>e.innerHTML="Zu:"));break;case"NL":case"NLD":case"Netherlands":e.forEach((e=>e.innerHTML="Aan:"))}}}translateField(e,t){const n=document.querySelector(`[name="${e}"]`);if(n){const e=n.closest(".en__field");if(e){const i=e.querySelector(".en__field__label"),s=i.querySelector(".engrid-simple-country");let o=s?s.cloneNode(!0):null;n instanceof HTMLInputElement&&""!=n.placeholder&&(i&&i.innerHTML!=n.placeholder||(n.dataset.original=n.placeholder,n.placeholder=t)),i&&(i.dataset.original=i.innerHTML,i.innerHTML=t,o&&i.appendChild(o))}}}resetTranslatedFields(){document.querySelectorAll("[data-original]").forEach((e=>{if(e instanceof HTMLInputElement&&e.dataset.original)e.placeholder=e.dataset.original;else{const t=e.querySelector(".engrid-simple-country");let n=t?t.cloneNode(!0):null;e.innerHTML=e.dataset.original,n&&e.appendChild(n)}e.removeAttribute("data-original")}))}setStateField(e,t){switch(e){case"ES":case"ESP":case"Spain":this.setStateValues(t,"Provincia",null);break;case"BR":case"BRA":case"Brazil":this.setStateValues(t,"Estado",null);break;case"FR":case"FRA":case"France":this.setStateValues(t,"Région",null);break;case"GB":case"GBR":case"United Kingdom":this.setStateValues(t,"State/Region",null);break;case"DE":case"DEU":case"Germany":this.setStateValues(t,"Bundesland",null);break;case"NL":case"NLD":case"Netherlands":this.setStateValues(t,"Provincie",null);break;case"AU":case"AUS":this.setStateValues(t,"Province / State",[{label:"Select",value:""},{label:"New South Wales",value:"NSW"},{label:"Victoria",value:"VIC"},{label:"Queensland",value:"QLD"},{label:"South Australia",value:"SA"},{label:"Western Australia",value:"WA"},{label:"Tasmania",value:"TAS"},{label:"Northern Territory",value:"NT"},{label:"Australian Capital Territory",value:"ACT"}]);break;case"Australia":this.setStateValues(t,"Province / State",[{label:"Select",value:""},{label:"New South Wales",value:"New South Wales"},{label:"Victoria",value:"Victoria"},{label:"Queensland",value:"Queensland"},{label:"South Australia",value:"South Australia"},{label:"Western Australia",value:"Western Australia"},{label:"Tasmania",value:"Tasmania"},{label:"Northern Territory",value:"Northern Territory"},{label:"Australian Capital Territory",value:"Australian Capital Territory"}]);break;case"US":case"USA":this.setStateValues(t,"State",[{label:"Select State",value:""},{label:"Alabama",value:"AL"},{label:"Alaska",value:"AK"},{label:"Arizona",value:"AZ"},{label:"Arkansas",value:"AR"},{label:"California",value:"CA"},{label:"Colorado",value:"CO"},{label:"Connecticut",value:"CT"},{label:"Delaware",value:"DE"},{label:"District of Columbia",value:"DC"},{label:"Florida",value:"FL"},{label:"Georgia",value:"GA"},{label:"Hawaii",value:"HI"},{label:"Idaho",value:"ID"},{label:"Illinois",value:"IL"},{label:"Indiana",value:"IN"},{label:"Iowa",value:"IA"},{label:"Kansas",value:"KS"},{label:"Kentucky",value:"KY"},{label:"Louisiana",value:"LA"},{label:"Maine",value:"ME"},{label:"Maryland",value:"MD"},{label:"Massachusetts",value:"MA"},{label:"Michigan",value:"MI"},{label:"Minnesota",value:"MN"},{label:"Mississippi",value:"MS"},{label:"Missouri",value:"MO"},{label:"Montana",value:"MT"},{label:"Nebraska",value:"NE"},{label:"Nevada",value:"NV"},{label:"New Hampshire",value:"NH"},{label:"New Jersey",value:"NJ"},{label:"New Mexico",value:"NM"},{label:"New York",value:"NY"},{label:"North Carolina",value:"NC"},{label:"North Dakota",value:"ND"},{label:"Ohio",value:"OH"},{label:"Oklahoma",value:"OK"},{label:"Oregon",value:"OR"},{label:"Pennsylvania",value:"PA"},{label:"Rhode Island",value:"RI"},{label:"South Carolina",value:"SC"},{label:"South Dakota",value:"SD"},{label:"Tennessee",value:"TN"},{label:"Texas",value:"TX"},{label:"Utah",value:"UT"},{label:"Vermont",value:"VT"},{label:"Virginia",value:"VA"},{label:"Washington",value:"WA"},{label:"West Virginia",value:"WV"},{label:"Wisconsin",value:"WI"},{label:"Wyoming",value:"WY"},{label:"── US Territories ──",value:"",disabled:!0},{label:"American Samoa",value:"AS"},{label:"Guam",value:"GU"},{label:"Northern Mariana Islands",value:"MP"},{label:"Puerto Rico",value:"PR"},{label:"US Minor Outlying Islands",value:"UM"},{label:"Virgin Islands",value:"VI"},{label:"── Armed Forces ──",value:"",disabled:!0},{label:"Armed Forces Americas",value:"AA"},{label:"Armed Forces Africa",value:"AE"},{label:"Armed Forces Canada",value:"AE"},{label:"Armed Forces Europe",value:"AE"},{label:"Armed Forces Middle East",value:"AE"},{label:"Armed Forces Pacific",value:"AP"}]);break;case"United States":this.setStateValues(t,"State",[{label:"Select State",value:""},{label:"Alabama",value:"Alabama"},{label:"Alaska",value:"Alaska"},{label:"Arizona",value:"Arizona"},{label:"Arkansas",value:"Arkansas"},{label:"California",value:"California"},{label:"Colorado",value:"Colorado"},{label:"Connecticut",value:"Connecticut"},{label:"Delaware",value:"Delaware"},{label:"District of Columbia",value:"District of Columbia"},{label:"Florida",value:"Florida"},{label:"Georgia",value:"Georgia"},{label:"Hawaii",value:"Hawaii"},{label:"Idaho",value:"Idaho"},{label:"Illinois",value:"Illinois"},{label:"Indiana",value:"Indiana"},{label:"Iowa",value:"Iowa"},{label:"Kansas",value:"Kansas"},{label:"Kentucky",value:"Kentucky"},{label:"Louisiana",value:"Louisiana"},{label:"Maine",value:"Maine"},{label:"Maryland",value:"Maryland"},{label:"Massachusetts",value:"Massachusetts"},{label:"Michigan",value:"Michigan"},{label:"Minnesota",value:"Minnesota"},{label:"Mississippi",value:"Mississippi"},{label:"Missouri",value:"Missouri"},{label:"Montana",value:"Montana"},{label:"Nebraska",value:"Nebraska"},{label:"Nevada",value:"Nevada"},{label:"New Hampshire",value:"New Hampshire"},{label:"New Jersey",value:"New Jersey"},{label:"New Mexico",value:"New Mexico"},{label:"New York",value:"New York"},{label:"North Carolina",value:"North Carolina"},{label:"North Dakota",value:"North Dakota"},{label:"Ohio",value:"Ohio"},{label:"Oklahoma",value:"Oklahoma"},{label:"Oregon",value:"Oregon"},{label:"Pennsylvania",value:"Pennsylvania"},{label:"Rhode Island",value:"Rhode Island"},{label:"South Carolina",value:"South Carolina"},{label:"South Dakota",value:"South Dakota"},{label:"Tennessee",value:"Tennessee"},{label:"Texas",value:"Texas"},{label:"Utah",value:"Utah"},{label:"Vermont",value:"Vermont"},{label:"Virginia",value:"Virginia"},{label:"Washington",value:"Washington"},{label:"West Virginia",value:"West Virginia"},{label:"Wisconsin",value:"Wisconsin"},{label:"Wyoming",value:"Wyoming"},{label:"── US Territories ──",value:"",disabled:!0},{label:"American Samoa",value:"American Samoa"},{label:"Guam",value:"Guam"},{label:"Northern Mariana Islands",value:"Northern Mariana Islands"},{label:"Puerto Rico",value:"Puerto Rico"},{label:"US Minor Outlying Islands",value:"US Minor Outlying Islands"},{label:"Virgin Islands",value:"Virgin Islands"},{label:"── Armed Forces ──",value:"",disabled:!0},{label:"Armed Forces Americas",value:"Armed Forces Americas"},{label:"Armed Forces Africa",value:"Armed Forces Africa"},{label:"Armed Forces Canada",value:"Armed Forces Canada"},{label:"Armed Forces Europe",value:"Armed Forces Europe"},{label:"Armed Forces Middle East",value:"Armed Forces Middle East"},{label:"Armed Forces Pacific",value:"Armed Forces Pacific"}]);break;case"CA":case"CAN":this.setStateValues(t,"Province / Territory",[{label:"Select",value:""},{label:"Alberta",value:"AB"},{label:"British Columbia",value:"BC"},{label:"Manitoba",value:"MB"},{label:"New Brunswick",value:"NB"},{label:"Newfoundland and Labrador",value:"NL"},{label:"Northwest Territories",value:"NT"},{label:"Nova Scotia",value:"NS"},{label:"Nunavut",value:"NU"},{label:"Ontario",value:"ON"},{label:"Prince Edward Island",value:"PE"},{label:"Quebec",value:"QC"},{label:"Saskatchewan",value:"SK"},{label:"Yukon",value:"YT"}]);break;case"Canada":this.setStateValues(t,"Province / Territory",[{label:"Select",value:""},{label:"Alberta",value:"Alberta"},{label:"British Columbia",value:"British Columbia"},{label:"Manitoba",value:"Manitoba"},{label:"New Brunswick",value:"New Brunswick"},{label:"Newfoundland and Labrador",value:"Newfoundland and Labrador"},{label:"Northwest Territories",value:"Northwest Territories"},{label:"Nova Scotia",value:"Nova Scotia"},{label:"Nunavut",value:"Nunavut"},{label:"Ontario",value:"Ontario"},{label:"Prince Edward Island",value:"Prince Edward Island"},{label:"Quebec",value:"Quebec"},{label:"Saskatchewan",value:"Saskatchewan"},{label:"Yukon",value:"Yukon"}]);break;case"MX":case"MEX":this.setStateValues(t,"Estado",[{label:"Seleccione Estado",value:""},{label:"Aguascalientes",value:"AGU"},{label:"Baja California",value:"BCN"},{label:"Baja California Sur",value:"BCS"},{label:"Campeche",value:"CAM"},{label:"Chiapas",value:"CHP"},{label:"Ciudad de Mexico",value:"CMX"},{label:"Chihuahua",value:"CHH"},{label:"Coahuila",value:"COA"},{label:"Colima",value:"COL"},{label:"Durango",value:"DUR"},{label:"Guanajuato",value:"GUA"},{label:"Guerrero",value:"GRO"},{label:"Hidalgo",value:"HID"},{label:"Jalisco",value:"JAL"},{label:"Michoacan",value:"MIC"},{label:"Morelos",value:"MOR"},{label:"Nayarit",value:"NAY"},{label:"Nuevo Leon",value:"NLE"},{label:"Oaxaca",value:"OAX"},{label:"Puebla",value:"PUE"},{label:"Queretaro",value:"QUE"},{label:"Quintana Roo",value:"ROO"},{label:"San Luis Potosi",value:"SLP"},{label:"Sinaloa",value:"SIN"},{label:"Sonora",value:"SON"},{label:"Tabasco",value:"TAB"},{label:"Tamaulipas",value:"TAM"},{label:"Tlaxcala",value:"TLA"},{label:"Veracruz",value:"VER"},{label:"Yucatan",value:"YUC"},{label:"Zacatecas",value:"ZAC"}]);break;case"Mexico":this.setStateValues(t,"Estado",[{label:"Seleccione Estado",value:""},{label:"Aguascalientes",value:"Aguascalientes"},{label:"Baja California",value:"Baja California"},{label:"Baja California Sur",value:"Baja California Sur"},{label:"Campeche",value:"Campeche"},{label:"Chiapas",value:"Chiapas"},{label:"Ciudad de Mexico",value:"Ciudad de Mexico"},{label:"Chihuahua",value:"Chihuahua"},{label:"Coahuila",value:"Coahuila"},{label:"Colima",value:"Colima"},{label:"Durango",value:"Durango"},{label:"Guanajuato",value:"Guanajuato"},{label:"Guerrero",value:"Guerrero"},{label:"Hidalgo",value:"Hidalgo"},{label:"Jalisco",value:"Jalisco"},{label:"Michoacan",value:"Michoacan"},{label:"Morelos",value:"Morelos"},{label:"Nayarit",value:"Nayarit"},{label:"Nuevo Leon",value:"Nuevo Leon"},{label:"Oaxaca",value:"Oaxaca"},{label:"Puebla",value:"Puebla"},{label:"Queretaro",value:"Queretaro"},{label:"Quintana Roo",value:"Quintana Roo"},{label:"San Luis Potosi",value:"San Luis Potosi"},{label:"Sinaloa",value:"Sinaloa"},{label:"Sonora",value:"Sonora"},{label:"Tabasco",value:"Tabasco"},{label:"Tamaulipas",value:"Tamaulipas"},{label:"Tlaxcala",value:"Tlaxcala"},{label:"Veracruz",value:"Veracruz"},{label:"Yucatan",value:"Yucatan"},{label:"Zacatecas",value:"Zacatecas"}]);break;default:this.setStateValues(t,"Province / State",null)}}setStateValues(e,t,n){const i=p.getField(e),s=i?i.closest(".en__field"):null;if(s){const i=s.querySelector(".en__field__label"),o=s.querySelector(".en__field__element");if(i&&(i.innerHTML=t),o){const i=te(`engrid-state-${e}`);if(null==n?void 0:n.length){const t=document.createElement("select");t.name=e,t.id="en__field_"+e.toLowerCase().replace(".","_"),t.classList.add("en__field__input"),t.classList.add("en__field__input--select"),t.autocomplete="address-level1";let s=!1;n.forEach((e=>{const n=document.createElement("option");n.value=e.value,n.innerHTML=e.label,i!==e.value||s||(n.selected=!0,s=!0),e.disabled&&(n.disabled=!0),t.appendChild(n)})),o.innerHTML="",o.appendChild(t),t.addEventListener("change",this.rememberState.bind(this,e)),t.dispatchEvent(new Event("change",{bubbles:!0}))}else{o.innerHTML="";const n=document.createElement("input");n.type="text",n.name=e,n.placeholder=t,n.id="en__field_"+e.toLowerCase().replace(".","_"),n.classList.add("en__field__input"),n.classList.add("en__field__input--text"),n.autocomplete="address-level1",i&&(n.value=i),o.appendChild(n),n.addEventListener("change",this.rememberState.bind(this,e))}}}}rememberState(e){const t=p.getField(e);t&&ne(`engrid-state-${t.name}`,t.value,{expires:1,sameSite:"none",secure:!0})}}class se{constructor(){this._countryEvent=b.getInstance(),this.countryWrapper=document.querySelector(".simple_country_select"),this.countrySelect=this._countryEvent.countryField,this.country=null;const e=te("engrid-autofill"),t=!(!p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")||!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()),n=!!p.checkNested(window.Intl,"DisplayNames"),i=p.getUrlParameter("supporter.country")||p.getUrlParameter("supporter.region")||p.getUrlParameter("ea.url.id")&&!p.getUrlParameter("forwarded");e||t||!n||i?this.init():fetch(`https://${window.location.hostname}/cdn-cgi/trace`).then((e=>e.text())).then((e=>{let t=e.replace(/[\r\n]+/g,'","').replace(/\=+/g,'":"');t='{"'+t.slice(0,t.lastIndexOf('","'))+'"}';const n=JSON.parse(t);this.country=n.loc,this.init()}))}init(){if(this.countrySelect&&this.country){const e=new Intl.DisplayNames(["en"],{type:"region"});this.setCountryByName(e.of(this.country),this.country)}}setCountryByName(e,t){if(this.countrySelect){let n=this.countrySelect.options;for(let i=0;i'),this.insertSkipLinkSpan()):t&&t.parentElement?(t.parentElement.insertAdjacentHTML("beforebegin",''),this.insertSkipLinkSpan()):n&&n.parentElement?(n.parentElement.insertAdjacentHTML("beforebegin",''),this.insertSkipLinkSpan()):i&&i.parentElement?(i.parentElement.insertAdjacentHTML("beforebegin",''),this.insertSkipLinkSpan()):p.debug&&console.log("This page contains no or <h1> and a 'Skip to main content' link was not added")}insertSkipLinkSpan(){document.body.insertAdjacentHTML("afterbegin",'<a class="skip-link" href="#skip-link">Skip to main content</a>')}}class re{constructor(){this.imgSrcDefer=document.querySelectorAll("img[data-src]"),this.videoBackground=document.querySelectorAll("video"),this.videoBackgroundSource=document.querySelectorAll("video source");for(let e=0;e<this.imgSrcDefer.length;e++){let t=this.imgSrcDefer[e];if(t){t.setAttribute("decoding","async"),t.setAttribute("loading","lazy");let e=t.getAttribute("data-src");e&&t.setAttribute("src",e),t.setAttribute("data-engrid-data-src-processed","true"),t.removeAttribute("data-src")}}for(let e=0;e<this.videoBackground.length;e++){let t=this.videoBackground[e];if(this.videoBackgroundSource=t.querySelectorAll("source"),this.videoBackgroundSource){for(let e=0;e<this.videoBackgroundSource.length;e++){let t=this.videoBackgroundSource[e];if(t){let e=t.getAttribute("data-src");e&&(t.setAttribute("src",e),t.setAttribute("data-engrid-data-src-processed","true"),t.removeAttribute("data-src"))}}let e=t.parentNode,n=t;e&&n&&(e.replaceChild(n,t),t.muted=!0,t.controls=!1,t.loop=!0,t.playsInline=!0,t.play())}}}}class ae{constructor(){this._frequency=g.getInstance(),this._amount=h.getInstance(),this.linkClass="setRecurrFreq-",this.checkboxName="engrid.recurrfreq",document.querySelectorAll(`a[class^="${this.linkClass}"]`).forEach((e=>{e.addEventListener("click",(t=>{const n=e.className.split(" ").filter((e=>e.startsWith(this.linkClass)));p.debug&&console.log(n),n.length&&(t.preventDefault(),p.setFieldValue("transaction.recurrfreq",n[0].substring(this.linkClass.length).toUpperCase()),this._frequency.load())}))}));const e=p.getFieldValue("transaction.recurrfreq").toUpperCase();document.getElementsByName(this.checkboxName).forEach((t=>{const n=t.value.toUpperCase();t.checked=n===e,t.addEventListener("change",(()=>{const e=t.value.toUpperCase();t.checked?(p.setFieldValue("transaction.recurrfreq",e),p.setFieldValue("transaction.recurrpay","Y"),this._frequency.load(),this._amount.setAmount(this._amount.amount,!1)):"ONETIME"!==e&&(p.setFieldValue("transaction.recurrfreq","ONETIME"),p.setFieldValue("transaction.recurrpay","N"),this._frequency.load(),this._amount.setAmount(this._amount.amount,!1))}))})),this._frequency.onFrequencyChange.subscribe((()=>{const e=this._frequency.frequency.toUpperCase();document.getElementsByName(this.checkboxName).forEach((t=>{const n=t.value.toUpperCase();t.checked&&n!==e?t.checked=!1:t.checked||n!==e||(t.checked=!0)}))}))}}class le{constructor(){if(this.pageBackground=document.querySelector(".page-backgroundImage"),this.pageBackground){const e=this.pageBackground.querySelector("img");let t=null==e?void 0:e.getAttribute("data-src"),n=null==e?void 0:e.src;this.pageBackground&&t?(p.debug&&console.log("A background image set in the page was found with a data-src value, setting it as --engrid__page-backgroundImage_url",t),t="url('"+t+"')",this.pageBackground.style.setProperty("--engrid__page-backgroundImage_url",t)):this.pageBackground&&n?(p.debug&&console.log("A background image set in the page was found with a src value, setting it as --engrid__page-backgroundImage_url",n),n="url('"+n+"')",this.pageBackground.style.setProperty("--engrid__page-backgroundImage_url",n)):e?p.debug&&console.log("A background image set in the page was found but without a data-src or src value, no action taken",e):p.debug&&console.log("A background image set in the page was not found, any default image set in the theme on --engrid__page-backgroundImage_url will be used")}else p.debug&&console.log("A background image set in the page was not found, any default image set in the theme on --engrid__page-backgroundImage_url will be used");this.setDataAttributes()}setDataAttributes(){return this.hasVideoBackground()?p.setBodyData("page-background","video"):this.hasImageBackground()?p.setBodyData("page-background","image"):p.setBodyData("page-background","empty")}hasVideoBackground(){if(this.pageBackground)return!!this.pageBackground.querySelector("video")}hasImageBackground(){if(this.pageBackground)return!this.hasVideoBackground()&&!!this.pageBackground.querySelector("img")}}class ce{constructor(e,t=null,n=null,i){this.apiKey=e,this.dateField=t,this.statusField=n,this.dateFormat=i,this.form=u.getInstance(),this.emailField=null,this.emailWrapper=document.querySelector(".en__field--emailAddress"),this.nbDate=null,this.nbStatus=null,this.logger=new fe("NeverBounce","#039bc4","#dfdfdf","📧"),this.shouldRun=!0,this.nbLoaded=!1,this.emailField=document.getElementById("en__field_supporter_emailAddress"),window._NBSettings={apiKey:this.apiKey,autoFieldHookup:!1,inputLatency:1500,displayPoweredBy:!1,loadingMessage:"Validating...",softRejectMessage:"Invalid email",acceptedMessage:"Email validated!",feedback:!1},p.loadJS("https://cdn.neverbounce.com/widget/dist/NeverBounce.js"),this.emailField&&(this.emailField.value&&(this.logger.log("E-mail Field Found"),this.shouldRun=!1),this.emailField.addEventListener("change",(e=>{var t;this.nbLoaded||(this.shouldRun=!0,this.init(),(null===(t=this.emailField)||void 0===t?void 0:t.value)&&setTimeout((function(){window._nb.fields.get(document.querySelector("[data-nb-id]"))[0].forceUpdate()}),100))})),window.setTimeout((()=>{this.emailField&&this.emailField.value&&(this.logger.log("E-mail Filled Programatically"),this.shouldRun=!1),this.init()}),1e3)),this.form.onValidate.subscribe(this.validate.bind(this))}init(){if(!this.shouldRun)return void this.logger.log("Should Not Run");if(this.nbLoaded)return void this.logger.log("Already Loaded");if(this.logger.log("Init Function"),this.dateField&&document.getElementsByName(this.dateField).length&&(this.nbDate=document.querySelector("[name='"+this.dateField+"']")),this.statusField&&document.getElementsByName(this.statusField).length&&(this.nbStatus=document.querySelector("[name='"+this.statusField+"']")),!this.emailField)return void this.logger.log("E-mail Field Not Found");this.wrap(this.emailField,document.createElement("div"));this.emailField.parentNode.id="nb-wrapper";const e=document.createElement("div");e.innerHTML='<div id="nb-feedback" class="en__field__error nb-hidden">Enter a valid email.</div>',this.insertAfter(e,this.emailField);const t=this;document.body.addEventListener("nb:registered",(function(e){const n=document.querySelector('[data-nb-id="'+e.detail.id+'"]');n.addEventListener("nb:loading",(function(e){p.disableSubmit("Validating Your Email")})),n.addEventListener("nb:clear",(function(e){t.setEmailStatus("clear"),p.enableSubmit(),t.nbDate&&(t.nbDate.value=""),t.nbStatus&&(t.nbStatus.value="")})),n.addEventListener("nb:soft-result",(function(e){t.setEmailStatus("soft-result"),t.nbDate&&(t.nbDate.value=""),t.nbStatus&&(t.nbStatus.value=""),p.enableSubmit()})),n.addEventListener("nb:result",(function(e){e.detail.result.is(window._nb.settings.getAcceptedStatusCodes())?(t.setEmailStatus("valid"),t.nbDate&&(t.nbDate.value=p.formatDate(new Date,t.dateFormat)),t.nbStatus&&(t.nbStatus.value=e.detail.result.response.result)):(t.setEmailStatus("invalid"),t.nbDate&&(t.nbDate.value=""),t.nbStatus&&(t.nbStatus.value="")),p.enableSubmit()}))})),window._nb.fields.registerListener(t.emailField,!0),this.nbLoaded=!0}clearStatus(){if(!this.emailField)return void this.logger.log("E-mail Field Not Found");this.emailField.classList.remove("rm-error");const e=document.getElementById("nb-wrapper"),t=document.getElementById("nb-feedback");e.className="",t.className="en__field__error nb-hidden",t.innerHTML="",this.emailWrapper.classList.remove("en__field--validationFailed")}deleteENFieldError(){const e=document.querySelector(".en__field--emailAddress>div.en__field__error");e&&e.remove()}setEmailStatus(e){if(this.logger.log("Status:",e),!this.emailField)return void this.logger.log("E-mail Field Not Found");const t=document.getElementById("nb-wrapper");let n=document.getElementById("nb-feedback");const i="nb-hidden",s="nb-loading",o="rm-error";if(!n){const e=t.querySelector("div");e&&(e.innerHTML='<div id="nb-feedback" class="en__field__error nb-hidden">Enter a valid email.</div>'),n=document.getElementById("nb-feedback")}if("valid"==e)this.clearStatus();else switch(t.classList.remove("nb-success"),t.classList.add("nb-error"),e){case"required":this.deleteENFieldError(),n.innerHTML="A valid email is required",n.classList.remove(s),n.classList.remove(i),this.emailField.classList.add(o);break;case"soft-result":this.emailField.value?(this.deleteENFieldError(),n.innerHTML="Invalid email",n.classList.remove(i),this.emailField.classList.add(o)):this.clearStatus();break;case"invalid":this.deleteENFieldError(),n.innerHTML="Invalid email",n.classList.remove(s),n.classList.remove(i),this.emailField.classList.add(o);break;default:this.clearStatus()}}insertAfter(e,t){var n;null===(n=null==t?void 0:t.parentNode)||void 0===n||n.insertBefore(e,t.nextSibling)}wrap(e,t){var n;null===(n=e.parentNode)||void 0===n||n.insertBefore(t,e),t.appendChild(e)}validate(){var e;if(!this.form.validate)return;const t=p.getFieldValue("nb-result");this.emailField&&this.shouldRun&&this.nbLoaded&&t?(this.nbStatus&&(this.nbStatus.value=t),["catchall","unknown","valid"].includes(t)||(this.setEmailStatus("required"),null===(e=this.emailField)||void 0===e||e.focus(),this.logger.log("NB-Result:",p.getFieldValue("nb-result")),this.form.validate=!1)):this.logger.log("validate(): Should Not Run. Returning true.")}}class de{constructor(){this.form=u.getInstance(),this.emailField=null,this.emailWrapper=document.querySelector(".en__field--emailAddress"),this.faDate=null,this.faStatus=null,this.faMessage=null,this.logger=new fe("FreshAddress","#039bc4","#dfdfdf","📧"),this.shouldRun=!0,this.options=p.getOption("FreshAddress"),!1!==this.options&&window.FreshAddress&&(this.emailField=document.getElementById("en__field_supporter_emailAddress"),this.emailField?(this.createFields(),this.addEventListeners(),window.FreshAddressStatus="idle",this.emailField.value&&(this.logger.log("E-mail Field Found"),this.shouldRun=!1),window.setTimeout((()=>{this.emailField&&this.emailField.value&&(this.logger.log("E-mail Filled Programatically"),this.shouldRun=!1)}),1e3)):this.logger.log("E-mail Field Not Found"))}createFields(){this.options&&(this.options.dateField=this.options.dateField||"fa_date",this.faDate=p.getField(this.options.dateField),this.faDate||(this.logger.log("Date Field Not Found. Creating..."),p.createHiddenInput(this.options.dateField,""),this.faDate=p.getField(this.options.dateField)),this.options.statusField=this.options.statusField||"fa_status",this.faStatus=p.getField(this.options.statusField),this.faStatus||(this.logger.log("Status Field Not Found. Creating..."),p.createHiddenInput(this.options.statusField,""),this.faStatus=p.getField(this.options.statusField)),this.options.messageField=this.options.messageField||"fa_message",this.faMessage=p.getField(this.options.messageField),this.faMessage||(this.logger.log("Message Field Not Found. Creating..."),p.createHiddenInput(this.options.messageField,""),this.faMessage=p.getField(this.options.messageField)))}writeToFields(e,t){this.options&&(this.faDate.value=p.formatDate(new Date,this.options.dateFieldFormat||"yyyy-MM-dd"),this.faStatus.value=e,this.faMessage.value=t,this.emailWrapper.dataset.freshaddressSafetosendstatus=e.toLowerCase())}addEventListeners(){var e;this.options&&(null===(e=this.emailField)||void 0===e||e.addEventListener("change",(()=>{var e,t;if(!this.shouldRun||(null===(e=this.emailField)||void 0===e?void 0:e.value.includes("@4sitestudios.com")))return p.removeError(this.emailWrapper),this.writeToFields("Valid","Skipped"),void this.logger.log("Skipping E-mail Validation");this.logger.log("Validating "+(null===(t=this.emailField)||void 0===t?void 0:t.value)),this.callAPI()})),this.form.onValidate.subscribe(this.validate.bind(this)))}callAPI(){var e;if(!this.options||!window.FreshAddress)return;if(!this.shouldRun)return;window.FreshAddressStatus="validating";const t=null===(e=this.emailField)||void 0===e?void 0:e.value;window.FreshAddress.validateEmail(t,{emps:!1,rtc_timeout:1200}).then((e=>(this.logger.log("Validate API Response",JSON.parse(JSON.stringify(e))),this.validateResponse(e))))}validateResponse(e){var t;if(e.isServiceError())return this.logger.log("Service Error"),this.writeToFields("Service Error",e.getErrorResponse()),!0;e.isValid()?(this.writeToFields("Valid",e.getComment()),p.removeError(this.emailWrapper),e.hasSuggest()&&(p.setError(this.emailWrapper,`Did you mean ${e.getSuggEmail()}?`),this.emailField.value=e.getSuggEmail())):e.isError()?(this.writeToFields("Invalid",e.getErrorResponse()),p.setError(this.emailWrapper,e.getErrorResponse()),null===(t=this.emailField)||void 0===t||t.focus(),e.hasSuggest()&&(p.setError(this.emailWrapper,`Did you mean ${e.getSuggEmail()}?`),this.emailField.value=e.getSuggEmail(),this.writeToFields("Error",e.getErrorResponse()))):e.isWarning()?(this.writeToFields("Invalid",e.getErrorResponse()),p.setError(this.emailWrapper,e.getErrorResponse()),e.hasSuggest()&&(p.setError(this.emailWrapper,`Did you mean ${e.getSuggEmail()}?`),this.emailField.value=e.getSuggEmail(),this.writeToFields("Warning",e.getErrorResponse()))):this.writeToFields("API Error","Unknown Error"),window.FreshAddressStatus="idle",p.enableSubmit()}validate(){var e;if(p.removeError(this.emailWrapper),this.form.validate)if(this.options)if(this.shouldRun){if("validating"!==window.FreshAddressStatus)return"Invalid"===this.faStatus.value?(this.form.validate=!1,window.setTimeout((()=>{p.setError(this.emailWrapper,this.faMessage.value)}),100),null===(e=this.emailField)||void 0===e||e.focus(),p.enableSubmit(),!1):(this.form.validate=!0,!0);{this.logger.log("Waiting for API Response");const e=new Promise(((e,t)=>{setTimeout((()=>{var n;const i=this.faStatus.value;if(""===i||"Invalid"===i)return this.logger.log("Promise Rejected"),null===(n=this.emailField)||void 0===n||n.focus(),void t(!1);this.logger.log("Promise Resolved"),e(!0)}),700)}));this.form.validatePromise=e}}else this.form.validate=!0;else this.form.validate=!0}}class ue{constructor(){var e,t;const n=document.querySelector("span[data-engrid-progress-indicator]"),i=p.getPageCount(),s=p.getPageNumber();if(!n||!i||!s)return;let o=null!==(e=n.getAttribute("max"))&&void 0!==e?e:100;"string"==typeof o&&(o=parseInt(o));let r=null!==(t=n.getAttribute("amount"))&&void 0!==t?t:0;"string"==typeof r&&(r=parseInt(r));const a=1===s?0:Math.ceil((s-1)/i*o);let l=1===s?0:Math.ceil(s/i*o);const c=a/100;let d=l/100;if(r&&(l=Math.ceil(r)>Math.ceil(o)?o:r,d=l/100),n.innerHTML=`\n\t\t\t<div class="indicator__wrap">\n\t\t\t\t<span class="indicator__progress" style="transform: scaleX(${c});"></span>\n\t\t\t\t<span class="indicator__percentage">${l}<span class="indicator__percentage-sign">%</span></span>\n\t\t\t</div>`,l!==a){const e=document.querySelector(".indicator__progress");requestAnimationFrame((function(){e.style.transform=`scaleX(${d})`}))}}}const he=n(3861).ZP;class pe{constructor(e){if(this._form=u.getInstance(),this._events=f.getInstance(),this.iframe=null,this.remoteUrl=e.remoteUrl?e.remoteUrl:null,this.cookieName=e.cookieName?e.cookieName:"engrid-autofill",this.cookieExpirationDays=e.cookieExpirationDays?e.cookieExpirationDays:365,this.rememberMeOptIn=!!e.checked&&e.checked,this.fieldNames=e.fieldNames?e.fieldNames:[],this.fieldDonationAmountRadioName=e.fieldDonationAmountRadioName?e.fieldDonationAmountRadioName:"transaction.donationAmt",this.fieldDonationAmountOtherName=e.fieldDonationAmountOtherName?e.fieldDonationAmountOtherName:"transaction.donationAmt.other",this.fieldDonationRecurrPayRadioName=e.fieldDonationRecurrPayRadioName?e.fieldDonationRecurrPayRadioName:"transaction.recurrpay",this.fieldDonationAmountOtherCheckboxID=e.fieldDonationAmountOtherCheckboxID?e.fieldDonationAmountOtherCheckboxID:"#en__field_transaction_donationAmt4",this.fieldOptInSelectorTarget=e.fieldOptInSelectorTarget?e.fieldOptInSelectorTarget:".en__field--emailAddress.en__field",this.fieldOptInSelectorTargetLocation=e.fieldOptInSelectorTargetLocation?e.fieldOptInSelectorTargetLocation:"after",this.fieldClearSelectorTarget=e.fieldClearSelectorTarget?e.fieldClearSelectorTarget:'label[for="en__field_supporter_firstName"]',this.fieldClearSelectorTargetLocation=e.fieldClearSelectorTargetLocation?e.fieldClearSelectorTargetLocation:"before",this.fieldData={},this.useRemote())this.createIframe((()=>{this.iframe&&this.iframe.contentWindow&&(this.iframe.contentWindow.postMessage(JSON.stringify({key:this.cookieName,operation:"read"}),"*"),this._form.onSubmit.subscribe((()=>{this.rememberMeOptIn&&(this.readFields(),this.saveCookieToRemote())})))}),(e=>{let t;if(e.data&&"string"==typeof e.data&&this.isJson(e.data)&&(t=JSON.parse(e.data)),t&&t.key&&void 0!==t.value&&t.key===this.cookieName){this.updateFieldData(t.value),this.writeFields(),Object.keys(this.fieldData).length>0?this.insertClearRememberMeLink():this.insertRememberMeOptin()}}));else{this.readCookie(),Object.keys(this.fieldData).length>0?(this.insertClearRememberMeLink(),this.rememberMeOptIn=!0):(this.insertRememberMeOptin(),this.rememberMeOptIn=!1),this.writeFields(),this._form.onSubmit.subscribe((()=>{this.rememberMeOptIn&&(this.readFields(),this.saveCookie())}))}}updateFieldData(e){if(e){let t=JSON.parse(e);for(let e=0;e<this.fieldNames.length;e++)void 0!==t[this.fieldNames[e]]&&(this.fieldData[this.fieldNames[e]]=decodeURIComponent(t[this.fieldNames[e]]))}}insertClearRememberMeLink(){let e=document.getElementById("clear-autofill-data");if(!e){const t="clear autofill";e=document.createElement("a"),e.setAttribute("id","clear-autofill-data"),e.classList.add("label-tooltip"),e.setAttribute("style","cursor: pointer;"),e.innerHTML=`(${t})`;const n=this.getElementByFirstSelector(this.fieldClearSelectorTarget);n&&("after"===this.fieldClearSelectorTargetLocation?n.appendChild(e):n.prepend(e))}e.addEventListener("click",(e=>{e.preventDefault(),this.clearFields(["supporter.country"]),this.useRemote()?this.clearCookieOnRemote():this.clearCookie();let t=document.getElementById("clear-autofill-data");t&&(t.style.display="none"),this.rememberMeOptIn=!1,this._events.dispatchClear(),window.dispatchEvent(new CustomEvent("RememberMe_Cleared"))})),this._events.dispatchLoad(!0),window.dispatchEvent(new CustomEvent("RememberMe_Loaded",{detail:{withData:!0}}))}getElementByFirstSelector(e){let t=null;const n=e.split(",");for(let e=0;e<n.length&&(t=document.querySelector(n[e]),!t);e++);return t}insertRememberMeOptin(){let e=document.getElementById("remember-me-opt-in");if(e)this.rememberMeOptIn&&(e.checked=!0);else{const e="Remember Me",t="\n\t\t\t\tCheck “Remember me” to complete forms on this device faster. \n\t\t\t\tWhile your financial information won’t be stored, you should only check this box from a personal device. \n\t\t\t\tClick “Clear autofill” to remove the information from your device at any time.\n\t\t\t",n=this.rememberMeOptIn?"checked":"",i=document.createElement("div");i.classList.add("en__field","en__field--checkbox","en__field--question","rememberme-wrapper"),i.setAttribute("id","remember-me-opt-in"),i.setAttribute("style","overflow-x: hidden;"),i.innerHTML=`\n <div class="en__field__element en__field__element--checkbox">\n <div class="en__field__item">\n <input id="remember-me-checkbox" type="checkbox" class="en__field__input en__field__input--checkbox" ${n} />\n <label for="remember-me-checkbox" class="en__field__label en__field__label--item" style="white-space: nowrap;">\n <div class="rememberme-content" style="display: inline-flex; align-items: center;">\n ${e}\n <a id="rememberme-learn-more-toggle" style="display: inline-block; display: inline-flex; align-items: center; cursor: pointer; margin-left: 10px; margin-top: var(--rememberme-learn-more-toggle_margin-top)">\n <svg style="height: 14px; width: auto; z-index: 1;" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11 7H9V5H11V7ZM11 9H9V15H11V9ZM10 2C5.59 2 2 5.59 2 10C2 14.41 5.59 18 10 18C14.41 18 18 14.41 18 10C18 5.59 14.41 2 10 2ZM10 0C15.523 0 20 4.477 20 10C20 15.523 15.523 20 10 20C4.477 20 0 15.523 0 10C0 4.477 4.477 0 10 0Z" fill="currentColor"/></svg>\n </a>\n </div>\n </label>\n </div>\n </div>\n\t\t\t`;const s=this.getElementByFirstSelector(this.fieldOptInSelectorTarget);if(s&&s.parentNode){s.parentNode.insertBefore(i,"before"==this.fieldOptInSelectorTargetLocation?s:s.nextSibling);const e=document.getElementById("remember-me-checkbox");e&&e.addEventListener("change",(()=>{e.checked?this.rememberMeOptIn=!0:this.rememberMeOptIn=!1})),he("#rememberme-learn-more-toggle",{content:t})}}this._events.dispatchLoad(!1),window.dispatchEvent(new CustomEvent("RememberMe_Loaded",{detail:{withData:!1}}))}useRemote(){return!!this.remoteUrl&&"function"==typeof window.postMessage&&window.JSON&&window.localStorage}createIframe(e,t){if(this.remoteUrl){let n=document.createElement("iframe");n.style.cssText="position:absolute;width:1px;height:1px;left:-9999px;",n.src=this.remoteUrl,n.setAttribute("sandbox","allow-same-origin allow-scripts"),this.iframe=n,document.body.appendChild(this.iframe),this.iframe.addEventListener("load",(()=>e()),!1),window.addEventListener("message",(e=>{var n;(null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)===e.source&&t(e)}),!1)}}clearCookie(){this.fieldData={},this.saveCookie()}clearCookieOnRemote(){this.fieldData={},this.saveCookieToRemote()}saveCookieToRemote(){this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage(JSON.stringify({key:this.cookieName,value:this.fieldData,operation:"write",expires:this.cookieExpirationDays}),"*")}readCookie(){this.updateFieldData(te(this.cookieName)||"")}saveCookie(){ne(this.cookieName,JSON.stringify(this.fieldData),{expires:this.cookieExpirationDays})}readFields(){for(let e=0;e<this.fieldNames.length;e++){let t="[name='"+this.fieldNames[e]+"']",n=document.querySelector(t);if(n)if("INPUT"===n.tagName){let i=n.getAttribute("type");"radio"!==i&&"checkbox"!==i||(n=document.querySelector(t+":checked")),this.fieldData[this.fieldNames[e]]=encodeURIComponent(n.value)}else"SELECT"===n.tagName&&(this.fieldData[this.fieldNames[e]]=encodeURIComponent(n.value))}}setFieldValue(e,t,n=!1){e&&void 0!==t&&(e.value&&n||!e.value)&&(e.value=t)}clearFields(e){for(let t in this.fieldData)e.includes(t)||""===this.fieldData[t]?delete this.fieldData[t]:this.fieldData[t]="";this.writeFields(!0)}writeFields(e=!1){for(let t=0;t<this.fieldNames.length;t++){let n="[name='"+this.fieldNames[t]+"']",i=document.querySelector(n);i&&("INPUT"===i.tagName?this.fieldNames[t]===this.fieldDonationRecurrPayRadioName?"Y"===this.fieldData[this.fieldNames[t]]&&i.click():this.fieldDonationAmountRadioName===this.fieldNames[t]?(i=document.querySelector(n+"[value='"+this.fieldData[this.fieldNames[t]]+"']"),i?i.click():(i=document.querySelector("input[name='"+this.fieldDonationAmountOtherName+"']"),this.setFieldValue(i,this.fieldData[this.fieldNames[t]],!0))):this.setFieldValue(i,this.fieldData[this.fieldNames[t]],e):"SELECT"===i.tagName&&this.setFieldValue(i,this.fieldData[this.fieldNames[t]],!0))}}isJson(e){try{JSON.parse(e)}catch(e){return!1}return!0}}class ge{constructor(){if(this._amount=h.getInstance(),this.logger=new fe("ShowIfAmount","yellow","black","👀"),this._elements=document.querySelectorAll('[class*="showifamount"]'),this._elements.length>0)return this._amount.onAmountChange.subscribe((()=>this.init())),void this.init();this.logger.log("Show If Amount: NO ELEMENTS FOUND")}init(){const e=p.getGiftProcess()?window.pageJson.amount:this._amount.amount;this._elements.forEach((t=>{this.lessthan(e,t),this.lessthanorequalto(e,t),this.equalto(e,t),this.greaterthanorequalto(e,t),this.greaterthan(e,t),this.between(e,t)}))}getClassNameByOperand(e,t){let n=null;return e.forEach((e=>{e.includes(`showifamount-${t}-`)&&(n=e)})),n}lessthan(e,t){const n=this.getClassNameByOperand(t.classList,"lessthan");if(n){let i=n.split("-").slice(-1)[0];e<Number(i)?(this.logger.log("(lessthan):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}lessthanorequalto(e,t){const n=this.getClassNameByOperand(t.classList,"lessthanorequalto");if(n){let i=n.split("-").slice(-1)[0];e<=Number(i)?(this.logger.log("(lessthanorequalto):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}equalto(e,t){const n=this.getClassNameByOperand(t.classList,"equalto");if(n){let i=n.split("-").slice(-1)[0];e==Number(i)?(this.logger.log("(equalto):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}greaterthanorequalto(e,t){const n=this.getClassNameByOperand(t.classList,"greaterthanorequalto");if(n){let i=n.split("-").slice(-1)[0];e>=Number(i)?(this.logger.log("(greaterthanorequalto):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}greaterthan(e,t){const n=this.getClassNameByOperand(t.classList,"greaterthan");if(n){let i=n.split("-").slice(-1)[0];e>Number(i)?(this.logger.log("(greaterthan):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}between(e,t){const n=this.getClassNameByOperand(t.classList,"between");if(n){let i=n.split("-").slice(-2,-1)[0],s=n.split("-").slice(-1)[0];e>Number(i)&&e<Number(s)?(this.logger.log("(between):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}}class me{constructor(){this.logger=new fe("OtherAmount","green","black","💰"),this._amount=h.getInstance(),"focusin input".split(" ").forEach((e=>{var t;null===(t=document.querySelector("body"))||void 0===t||t.addEventListener(e,(e=>{e.target.classList.contains("en__field__input--other")&&(this.logger.log("Other Amount Field Focused"),this.setRadioInput())}))}));const e=document.querySelector("[name='transaction.donationAmt.other'");e&&(e.setAttribute("inputmode","decimal"),e.setAttribute("aria-label","Enter your custom donation amount"),e.setAttribute("autocomplete","off"),e.setAttribute("data-lpignore","true"),e.addEventListener("change",(e=>{const t=e.target,n=t.value,i=p.cleanAmount(n);n!==i.toString()&&(this.logger.log(`Other Amount Field Changed: ${n} => ${i}`),"dataLayer"in window&&window.dataLayer.push({event:"otherAmountTransformed",otherAmountTransformation:`${n} => ${i}`}),t.value=i%1!=0?i.toFixed(2):i.toString())})),e.addEventListener("blur",(e=>{const t=e.target.value;if(0===p.cleanAmount(t)){this.logger.log("Other Amount Field Blurred with 0 amount");const e=this._amount.amount;e>0&&this._amount.setAmount(e,!1)}})))}setRadioInput(){const e=document.querySelector(".en__field--donationAmt .en__field__input--other");if(e&&e.parentNode&&e.parentNode.parentNode){const t=e.parentNode;if(t.classList.remove("en__field__item--hidden"),t.parentNode){t.parentNode.querySelector(".en__field__item:nth-last-child(2) input").checked=!0}}}}class fe{constructor(e,t,n,i){if(this.prefix="",this.color="black",this.background="white",this.emoji="",i)this.emoji=i;else switch(t){case"red":this.emoji="🔴";break;case"green":this.emoji="🟢";break;case"blue":this.emoji="🔵";break;case"yellow":this.emoji="🟡",this.background="black";break;case"purple":this.emoji="🟣";break;default:this.emoji="⚫"}e&&(this.prefix=`[ENgrid ${e}]`),t&&(this.color=t),n&&(this.background=n)}get log(){return p.debug||"log"===p.getUrlParameter("debug")?console.log.bind(window.console,"%c"+this.emoji+" "+this.prefix+" %s",`color: ${this.color}; background-color: ${this.background}; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;`):()=>{}}get success(){return p.debug?console.log.bind(window.console,"%c ✅ "+this.prefix+" %s","color: green; background-color: white; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;"):()=>{}}get danger(){return p.debug?console.log.bind(window.console,"%c ⛔️ "+this.prefix+" %s","color: red; background-color: white; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;"):()=>{}}get warn(){return p.debug?console.warn.bind(window.console,"%c"+this.emoji+" "+this.prefix+" %s",`color: ${this.color}; background-color: ${this.background}; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;`):()=>{}}get dir(){return p.debug?console.dir.bind(window.console,"%c"+this.emoji+" "+this.prefix+" %s",`color: ${this.color}; background-color: ${this.background}; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;`):()=>{}}get error(){return p.debug?console.error.bind(window.console,"%c"+this.emoji+" "+this.prefix+" %s",`color: ${this.color}; background-color: ${this.background}; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;`):()=>{}}}class be{constructor(){var e,t;this._form=u.getInstance(),this._amount=h.getInstance(),this.minAmount=null!==(e=p.getOption("MinAmount"))&&void 0!==e?e:1,this.maxAmount=null!==(t=p.getOption("MaxAmount"))&&void 0!==t?t:1e5,this.minAmountMessage=p.getOption("MinAmountMessage"),this.maxAmountMessage=p.getOption("MaxAmountMessage"),this.logger=new fe("MinMaxAmount","white","purple","🔢"),this.shouldRun()&&(this._amount.onAmountChange.subscribe((e=>window.setTimeout(this.liveValidate.bind(this),1e3))),this._form.onValidate.subscribe(this.enOnValidate.bind(this)))}shouldRun(){return"DONATION"===p.getPageType()}enOnValidate(){if(!this._form.validate)return;const e=document.querySelector("[name='transaction.donationAmt.other']");this._amount.amount<this.minAmount?(this.logger.log("Amount is less than min amount: "+this.minAmount),e&&e.focus(),this._form.validate=!1):this._amount.amount>this.maxAmount&&(this.logger.log("Amount is greater than max amount: "+this.maxAmount),e&&e.focus(),this._form.validate=!1),window.setTimeout(this.liveValidate.bind(this),300)}liveValidate(){const e=p.cleanAmount(this._amount.amount.toString()),t=document.activeElement;t&&"INPUT"===t.tagName&&"name"in t&&"transaction.donationAmt.other"===t.name&&0===e||(this.logger.log(`Amount: ${e}`),e<this.minAmount?(this.logger.log("Amount is less than min amount: "+this.minAmount),p.setError(".en__field--withOther",this.minAmountMessage||"Invalid Amount")):e>this.maxAmount?(this.logger.log("Amount is greater than max amount: "+this.maxAmount),p.setError(".en__field--withOther",this.maxAmountMessage||"Invalid Amount")):p.removeError(".en__field--withOther"))}}class ve{constructor(){if(this.shuffleSeed=n(7650),this.items=[],this.tickerElement=document.querySelector(".engrid-ticker"),this.logger=new fe("Ticker","black","beige","🔁"),!this.shouldRun())return void this.logger.log("Not running");const e=document.querySelectorAll(".engrid-ticker li");if(e.length>0)for(let t=0;t<e.length;t++)this.items.push(e[t].innerText);this.render()}shouldRun(){return null!==this.tickerElement}getSeed(){return(new Date).getDate()+p.getPageID()}getItems(){const e=this.tickerElement.getAttribute("data-total")||"50";this.logger.log("Getting "+e+" items");const t=this.getSeed(),n=this.shuffleSeed.shuffle(this.items,t),i=new Date,s=i.getHours(),o=i.getMinutes();let r=Math.round((60*s+o)/5);r>=n.length&&(r=0);return n.slice(r,r+e).reverse()}render(){var e,t,n;this.logger.log("Rendering");const i=this.getItems();let s=document.createElement("div");s.classList.add("en__component"),s.classList.add("en__component--ticker");let o='<div class="ticker">';for(let e=0;e<i.length;e++)o+='<div class="ticker__item">'+i[e]+"</div>";o='<div id="engrid-ticker">'+o+"</div></div>",s.innerHTML=o,null===(t=null===(e=this.tickerElement)||void 0===e?void 0:e.parentElement)||void 0===t||t.insertBefore(s,this.tickerElement),null===(n=this.tickerElement)||void 0===n||n.remove();const r=document.querySelector(".ticker").offsetWidth.toString();s.style.setProperty("--ticker-size",r),this.logger.log("Ticker Size: "+s.style.getPropertyValue("--ticker-size")),this.logger.log("Ticker Width: "+r)}}class ye{constructor(){this.logger=new fe("DataLayer","#f1e5bc","#009cdc","📊"),this.dataLayer=window.dataLayer||[],this._form=u.getInstance(),this.endOfGiftProcessStorageKey="ENGRID_END_OF_GIFT_PROCESS_EVENTS",this.excludedFields=["transaction.ccnumber","transaction.ccexpire.delimiter","transaction.ccexpire","transaction.ccvv","supporter.creditCardHolderName","supporter.bankAccountNumber","supporter.bankAccountType","transaction.bankname","supporter.bankRoutingNumber"],this.hashedFields=["supporter.emailAddress","supporter.phoneNumber","supporter.phoneNumber2","supporter.address1","supporter.address2","supporter.address3","transaction.infemail","transaction.infadd1","transaction.infadd2","transaction.infadd3","supporter.billingAddress1","supporter.billingAddress2","supporter.billingAddress3"],p.getOption("RememberMe")?f.getInstance().onLoad.subscribe((e=>{this.logger.log("Remember me - onLoad",e),this.onLoad()})):this.onLoad(),this._form.onSubmit.subscribe((()=>this.onSubmit()))}static getInstance(){return ye.instance||(ye.instance=new ye,window._dataLayer=ye.instance),ye.instance}transformJSON(e){return"string"==typeof e?e.toUpperCase().split(" ").join("-").replace(":-","-"):"boolean"==typeof e?e=e?"TRUE":"FALSE":""}onLoad(){if(p.getGiftProcess()?(this.logger.log("EN_SUCCESSFUL_DONATION"),this.dataLayer.push({event:"EN_SUCCESSFUL_DONATION"}),this.addEndOfGiftProcessEventsToDataLayer()):(this.logger.log("EN_PAGE_VIEW"),this.dataLayer.push({event:"EN_PAGE_VIEW"})),window.pageJson){const e=window.pageJson;for(const t in e)Number.isNaN(e[t])?(this.dataLayer.push({event:`EN_PAGEJSON_${t.toUpperCase()}-${this.transformJSON(e[t])}`}),this.dataLayer.push({[`'EN_PAGEJSON_${t.toUpperCase()}'`]:this.transformJSON(e[t])})):(this.dataLayer.push({event:`EN_PAGEJSON_${t.toUpperCase()}-${e[t]}`}),this.dataLayer.push({[`'EN_PAGEJSON_${t.toUpperCase()}'`]:e[t]})),this.dataLayer.push({event:"EN_PAGEJSON_"+t.toUpperCase(),eventValue:e[t]});p.getPageCount()===p.getPageNumber()&&(this.dataLayer.push({event:"EN_SUBMISSION_SUCCESS_"+e.pageType.toUpperCase()}),this.dataLayer.push({[`'EN_SUBMISSION_SUCCESS_${e.pageType.toUpperCase()}'`]:"TRUE"}))}if(new URLSearchParams(window.location.search).forEach(((e,t)=>{this.dataLayer.push({event:`EN_URLPARAM_${t.toUpperCase()}-${this.transformJSON(e)}`}),this.dataLayer.push({[`'EN_URLPARAM_${t.toUpperCase()}'`]:this.transformJSON(e)})})),"DONATION"===p.getPageType()){const e=[...document.querySelectorAll('[name="transaction.recurrfreq"]')].map((e=>e.value));this.dataLayer.push({event:"EN_RECURRING_FREQUENCIES","'EN_RECURRING_FREQEUENCIES'":e})}let e=!1;const t=document.querySelector(".en__component--formblock.fast-personal-details");if(t){const n=Je.allMandatoryInputsAreFilled(t),i=Je.someMandatoryInputsAreFilled(t);n?(this.dataLayer.push({event:"EN_FASTFORMFILL_PERSONALINFO_SUCCESS"}),e=!0):i?this.dataLayer.push({event:"EN_FASTFORMFILL_PERSONALINFO_PARTIALSUCCESS"}):this.dataLayer.push({event:"EN_FASTFORMFILL_PERSONALINFO_FAILURE"})}const n=document.querySelector(".en__component--formblock.fast-address-details");if(n){const t=Je.allMandatoryInputsAreFilled(n),i=Je.someMandatoryInputsAreFilled(n);t?(this.dataLayer.push({event:"EN_FASTFORMFILL_ADDRESS_SUCCESS"}),e=!!e):i?this.dataLayer.push({event:"EN_FASTFORMFILL_ADDRESS_PARTIALSUCCESS"}):this.dataLayer.push({event:"EN_FASTFORMFILL_ADDRESS_FAILURE"})}e?this.dataLayer.push({event:"EN_FASTFORMFILL_ALL_SUCCESS"}):this.dataLayer.push({event:"EN_FASTFORMFILL_ALL_FAILURE"}),this.attachEventListeners()}onSubmit(){document.querySelector(".en__field__item:not(.en__field--question) input[name^='supporter.questions'][type='checkbox']:checked")?(this.logger.log("EN_SUBMISSION_WITH_EMAIL_OPTIN"),this.dataLayer.push({event:"EN_SUBMISSION_WITH_EMAIL_OPTIN"})):(this.logger.log("EN_SUBMISSION_WITHOUT_EMAIL_OPTIN"),this.dataLayer.push({event:"EN_SUBMISSION_WITHOUT_EMAIL_OPTIN"}))}attachEventListeners(){document.querySelectorAll(".en__component--advrow input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=hidden]):not([unhidden]), .en__component--advrow textarea").forEach((e=>{e.addEventListener("blur",(e=>{this.handleFieldValueChange(e.target)}))}));document.querySelectorAll(".en__component--advrow input[type=checkbox], .en__component--advrow input[type=radio]").forEach((e=>{e.addEventListener("change",(e=>{this.handleFieldValueChange(e.target)}))}));document.querySelectorAll(".en__component--advrow select").forEach((e=>{e.addEventListener("change",(e=>{this.handleFieldValueChange(e.target)}))}))}handleFieldValueChange(e){var t,n,i;if(""===e.value||this.excludedFields.includes(e.name))return;const s=this.hashedFields.includes(e.name)?this.hash(e.value):e.value;["checkbox","radio"].includes(e.type)?e.checked&&("en__pg"===e.name?this.dataLayer.push({event:"EN_FORM_VALUE_UPDATED",enFieldName:e.name,enFieldLabel:"Premium Gift",enFieldValue:null===(n=null===(t=e.closest(".en__pg__body"))||void 0===t?void 0:t.querySelector(".en__pg__name"))||void 0===n?void 0:n.textContent,enProductId:null===(i=document.querySelector('[name="transaction.selprodvariantid"]'))||void 0===i?void 0:i.value}):this.dataLayer.push({event:"EN_FORM_VALUE_UPDATED",enFieldName:e.name,enFieldLabel:this.getFieldLabel(e),enFieldValue:s})):this.dataLayer.push({event:"EN_FORM_VALUE_UPDATED",enFieldName:e.name,enFieldLabel:this.getFieldLabel(e),enFieldValue:s})}hash(e){return btoa(e)}getFieldLabel(e){var t,n;return(null===(n=null===(t=e.closest(".en__field"))||void 0===t?void 0:t.querySelector("label"))||void 0===n?void 0:n.textContent)||""}addEndOfGiftProcessEvent(e,t={}){this.storeEndOfGiftProcessData(Object.assign({event:e},t))}addEndOfGiftProcessVariable(e,t=""){this.storeEndOfGiftProcessData({[`'${e.toUpperCase()}'`]:t})}storeEndOfGiftProcessData(e){const t=this.getEndOfGiftProcessData();t.push(e),window.sessionStorage.setItem(this.endOfGiftProcessStorageKey,JSON.stringify(t))}addEndOfGiftProcessEventsToDataLayer(){this.getEndOfGiftProcessData().forEach((e=>{this.dataLayer.push(e)})),window.sessionStorage.removeItem(this.endOfGiftProcessStorageKey)}getEndOfGiftProcessData(){let e=window.sessionStorage.getItem(this.endOfGiftProcessStorageKey);return e?JSON.parse(e):[]}}class _e{constructor(){this.logger=new fe("DataReplace","#333333","#00f3ff","⤵️"),this.enElements=new Array,this.searchElements(),this.shouldRun()&&(this.logger.log("Elements Found:",this.enElements),this.replaceAll())}searchElements(){const e=document.querySelectorAll("\n .en__component--copyblock,\n .en__component--codeblock,\n .en__field\n ");e.length>0&&e.forEach((e=>{e instanceof HTMLElement&&e.innerHTML.includes("{engrid_data~")&&this.enElements.push(e)}))}shouldRun(){return this.enElements.length>0}replaceAll(){const e=/{engrid_data~\[([\w-]+)\]~?\[?(.+?)?\]?}/g;this.enElements.forEach((t=>{const n=t.innerHTML.matchAll(e);for(const e of n)this.replaceItem(t,e)})),p.setBodyData("merge-tags-processed","")}replaceItem(e,[t,n,i]){var s;let o=null!==(s=p.getUrlParameter(`engrid_data[${n}]`))&&void 0!==s?s:i;o="string"==typeof o?o.replace(/\r?\\n|\n|\r/g,"<br>"):"",this.logger.log("Replacing",n,o),e.innerHTML=e.innerHTML.replace(t,o)}}class Se{constructor(){this.logger=new fe("DataHide","#333333","#f0f0f0","🙈"),this.enElements=new Array,this.logger.log("Constructor"),this.enElements=p.getUrlParameter("engrid_hide[]"),this.enElements&&0!==this.enElements.length?(this.logger.log("Elements Found:",this.enElements),this.hideAll()):this.logger.log("No Elements Found")}hideAll(){this.enElements.forEach((e=>{const t=Object.keys(e)[0],n=Object.values(e)[0];this.hideItem(t,n)}))}hideItem(e,t){const n=[...e.matchAll(/engrid_hide\[([\w-]+)\]/g)].map((e=>e[1]))[0];if("id"===t){const e=document.getElementById(n);e?(this.logger.log("Hiding By ID",n,e),e.setAttribute("hidden-via-url-argument","")):this.logger.error("Element Not Found By ID",n)}else{const e=document.getElementsByClassName(n);if(e.length>0)for(let t=0;t<e.length;t++)this.logger.log("Hiding By Class",n,e[t]),e[t].setAttribute("hidden-via-url-argument","");else this.logger.log("No Elements Found By Class",n)}}}class we{constructor(){this.shouldRun()&&this.replaceNameShortcode("#en__field_supporter_firstName","#en__field_supporter_lastName")}shouldRun(){return"EMAILTOTARGET"===p.getPageType()}replaceNameShortcode(e,t){const n=document.querySelector(e),i=document.querySelector(t);let s=document.querySelector('[name="contact.message"]'),o=!1,r=!1;if(s){if(s.value.includes("{user_data~First Name")||s.value.includes("{user_data~Last Name"))return;!s.value.includes("{user_data~First Name")&&n&&n.addEventListener("blur",(e=>{const t=e.target;s&&!o&&(o=!0,s.value=s.value.concat("\n"+t.value))})),!s.value.includes("{user_data~Last Name")&&i&&i.addEventListener("blur",(e=>{const t=e.target;s&&!r&&(r=!0,s.value=s.value.concat(" "+t.value))}))}}}class Ee{constructor(){if(this._form=u.getInstance(),this.logger=new fe("ExpandRegionName","#333333","#00eb65","🌍"),this.shouldRun()){const e=p.getOption("RegionLongFormat");console.log("expandedRegionField",e);document.querySelector(`[name="${e}"]`)||(this.logger.log(`CREATED field ${e}`),p.createHiddenInput(e)),this._form.onValidate.subscribe((()=>this.expandRegion()))}}shouldRun(){return!!p.getOption("RegionLongFormat")}expandRegion(){if(!this._form.validate)return;const e=document.querySelector('[name="supporter.region"]'),t=p.getOption("RegionLongFormat"),n=document.querySelector(`[name="${t}"]`);if(e){if("SELECT"===e.tagName&&"options"in e){const t=e.options[e.selectedIndex].innerText;n.value=t,this.logger.log("Populated field",n.value)}else if("INPUT"===e.tagName){const t=e.value;n.value=t,this.logger.log("Populated field",n.value)}return!0}this.logger.log("No region field to populate the hidden region field with")}}class Ae{constructor(){this.logger=new fe("UrlToForm","white","magenta","🔗"),this.urlParams=new URLSearchParams(document.location.search),this.shouldRun()&&this.urlParams.forEach(((e,t)=>{const n=document.getElementsByName(t)[0];n&&(["text","textarea","email"].includes(n.type)&&n.value||(p.setFieldValue(t,e),this.logger.log(`Set: ${t} to ${e}`)))}))}shouldRun(){return!!document.location.search&&this.hasFields()}hasFields(){return[...this.urlParams.keys()].map((e=>document.getElementsByName(e).length>0)).includes(!0)}}class Le{constructor(){this.logger=new fe("RequiredIfVisible","#FFFFFF","#811212","🚥"),this._form=u.getInstance(),this.requiredIfVisibleElements=document.querySelectorAll("\n .i-required .en__field,\n .i1-required .en__field:nth-of-type(1),\n .i2-required .en__field:nth-of-type(2),\n .i3-required .en__field:nth-of-type(3),\n .i4-required .en__field:nth-of-type(4),\n .i5-required .en__field:nth-of-type(5),\n .i6-required .en__field:nth-of-type(6),\n .i7-required .en__field:nth-of-type(7),\n .i8-required .en__field:nth-of-type(8),\n .i9-required .en__field:nth-of-type(9),\n .i10-required .en__field:nth-of-type(10),\n .i11-required .en__field:nth-of-type(11)\n "),this.shouldRun()&&this._form.onValidate.subscribe(this.validate.bind(this))}shouldRun(){return this.requiredIfVisibleElements.length>0}validate(){Array.from(this.requiredIfVisibleElements).reverse().forEach((e=>{if(p.removeError(e),p.isVisible(e)){this.logger.log(`${e.getAttribute("class")} is visible`);const t=e.querySelector("input:not([type=hidden]) , select, textarea");if(t&&null===t.closest("[data-unhidden]")&&!p.getFieldValue(t.getAttribute("name"))){const n=e.querySelector(".en__field__label");n?(this.logger.log(`${n.innerText} is required`),window.setTimeout((()=>{p.setError(e,`${n.innerText} is required`)}),100)):(this.logger.log(`${t.getAttribute("name")} is required`),window.setTimeout((()=>{p.setError(e,"This field is required")}),100)),t.focus(),this._form.validate=!1}}}))}}var Ce=function(e,t,n,i){return new(n||(n=Promise))((function(s,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))};class ke{constructor(){var e,t,n,i,s;if(this.logger=new fe("TidyContact","#FFFFFF","#4d9068","📧"),this.endpoint="https://api.tidycontact.io",this.wasCalled=!1,this.httpStatus=0,this.timeout=5,this.isDirty=!1,this._form=u.getInstance(),this.countries_list=[["Afghanistan","af","93","070 123 4567"],["Albania","al","355","067 212 3456"],["Algeria","dz","213","0551 23 45 67"],["American Samoa","as","1","(684) 733-1234"],["Andorra","ad","376","312 345"],["Angola","ao","244","923 123 456"],["Anguilla","ai","1","(264) 235-1234"],["Antigua and Barbuda","ag","1","(268) 464-1234"],["Argentina","ar","54","011 15-2345-6789"],["Armenia","am","374","077 123456"],["Aruba","aw","297","560 1234"],["Australia","au","61","0412 345 678"],["Austria","at","43","0664 123456"],["Azerbaijan","az","994","040 123 45 67"],["Bahamas","bs","1","(242) 359-1234"],["Bahrain","bh","973","3600 1234"],["Bangladesh","bd","880","01812-345678"],["Barbados","bb","1","(246) 250-1234"],["Belarus","by","375","8 029 491-19-11"],["Belgium","be","32","0470 12 34 56"],["Belize","bz","501","622-1234"],["Benin","bj","229","90 01 12 34"],["Bermuda","bm","1","(441) 370-1234"],["Bhutan","bt","975","17 12 34 56"],["Bolivia","bo","591","71234567"],["Bosnia and Herzegovina","ba","387","061 123 456"],["Botswana","bw","267","71 123 456"],["Brazil","br","55","(11) 96123-4567"],["British Indian Ocean Territory","io","246","380 1234"],["British Virgin Islands","vg","1","(284) 300-1234"],["Brunei","bn","673","712 3456"],["Bulgaria","bg","359","048 123 456"],["Burkina Faso","bf","226","70 12 34 56"],["Burundi","bi","257","79 56 12 34"],["Cambodia","kh","855","091 234 567"],["Cameroon","cm","237","6 71 23 45 67"],["Canada","ca","1","(506) 234-5678"],["Cape Verde","cv","238","991 12 34"],["Caribbean Netherlands","bq","599","318 1234"],["Cayman Islands","ky","1","(345) 323-1234"],["Central African Republic","cf","236","70 01 23 45"],["Chad","td","235","63 01 23 45"],["Chile","cl","56","(2) 2123 4567"],["China","cn","86","131 2345 6789"],["Christmas Island","cx","61","0412 345 678"],["Cocos Islands","cc","61","0412 345 678"],["Colombia","co","57","321 1234567"],["Comoros","km","269","321 23 45"],["Congo","cd","243","0991 234 567"],["Congo","cg","242","06 123 4567"],["Cook Islands","ck","682","71 234"],["Costa Rica","cr","506","8312 3456"],["Côte d’Ivoire","ci","225","01 23 45 6789"],["Croatia","hr","385","092 123 4567"],["Cuba","cu","53","05 1234567"],["Curaçao","cw","599","9 518 1234"],["Cyprus","cy","357","96 123456"],["Czech Republic","cz","420","601 123 456"],["Denmark","dk","45","32 12 34 56"],["Djibouti","dj","253","77 83 10 01"],["Dominica","dm","1","(767) 225-1234"],["Dominican Republic","do","1","(809) 234-5678"],["Ecuador","ec","593","099 123 4567"],["Egypt","eg","20","0100 123 4567"],["El Salvador","sv","503","7012 3456"],["Equatorial Guinea","gq","240","222 123 456"],["Eritrea","er","291","07 123 456"],["Estonia","ee","372","5123 4567"],["Eswatini","sz","268","7612 3456"],["Ethiopia","et","251","091 123 4567"],["Falkland Islands","fk","500","51234"],["Faroe Islands","fo","298","211234"],["Fiji","fj","679","701 2345"],["Finland","fi","358","041 2345678"],["France","fr","33","06 12 34 56 78"],["French Guiana","gf","594","0694 20 12 34"],["French Polynesia","pf","689","87 12 34 56"],["Gabon","ga","241","06 03 12 34"],["Gambia","gm","220","301 2345"],["Georgia","ge","995","555 12 34 56"],["Germany","de","49","01512 3456789"],["Ghana","gh","233","023 123 4567"],["Gibraltar","gi","350","57123456"],["Greece","gr","30","691 234 5678"],["Greenland","gl","299","22 12 34"],["Grenada","gd","1","(473) 403-1234"],["Guadeloupe","gp","590","0690 00 12 34"],["Guam","gu","1","(671) 300-1234"],["Guatemala","gt","502","5123 4567"],["Guernsey","gg","44","07781 123456"],["Guinea","gn","224","601 12 34 56"],["Guinea-Bissau","gw","245","955 012 345"],["Guyana","gy","592","609 1234"],["Haiti","ht","509","34 10 1234"],["Honduras","hn","504","9123-4567"],["Hong Kong","hk","852","5123 4567"],["Hungary","hu","36","06 20 123 4567"],["Iceland","is","354","611 1234"],["India","in","91","081234 56789"],["Indonesia","id","62","0812-345-678"],["Iran","ir","98","0912 345 6789"],["Iraq","iq","964","0791 234 5678"],["Ireland","ie","353","085 012 3456"],["Isle of Man","im","44","07924 123456"],["Israel","il","972","050-234-5678"],["Italy","it","39","312 345 6789"],["Jamaica","jm","1","(876) 210-1234"],["Japan","jp","81","090-1234-5678"],["Jersey","je","44","07797 712345"],["Jordan","jo","962","07 9012 3456"],["Kazakhstan","kz","7","8 (771) 000 9998"],["Kenya","ke","254","0712 123456"],["Kiribati","ki","686","72001234"],["Kosovo","xk","383","043 201 234"],["Kuwait","kw","965","500 12345"],["Kyrgyzstan","kg","996","0700 123 456"],["Laos","la","856","020 23 123 456"],["Latvia","lv","371","21 234 567"],["Lebanon","lb","961","71 123 456"],["Lesotho","ls","266","5012 3456"],["Liberia","lr","231","077 012 3456"],["Libya","ly","218","091-2345678"],["Liechtenstein","li","423","660 234 567"],["Lithuania","lt","370","(8-612) 34567"],["Luxembourg","lu","352","628 123 456"],["Macau","mo","853","6612 3456"],["North Macedonia","mk","389","072 345 678"],["Madagascar","mg","261","032 12 345 67"],["Malawi","mw","265","0991 23 45 67"],["Malaysia","my","60","012-345 6789"],["Maldives","mv","960","771-2345"],["Mali","ml","223","65 01 23 45"],["Malta","mt","356","9696 1234"],["Marshall Islands","mh","692","235-1234"],["Martinique","mq","596","0696 20 12 34"],["Mauritania","mr","222","22 12 34 56"],["Mauritius","mu","230","5251 2345"],["Mayotte","yt","262","0639 01 23 45"],["Mexico","mx","52","222 123 4567"],["Micronesia","fm","691","350 1234"],["Moldova","md","373","0621 12 345"],["Monaco","mc","377","06 12 34 56 78"],["Mongolia","mn","976","8812 3456"],["Montenegro","me","382","067 622 901"],["Montserrat","ms","1","(664) 492-3456"],["Morocco","ma","212","0650-123456"],["Mozambique","mz","258","82 123 4567"],["Myanmar","mm","95","09 212 3456"],["Namibia","na","264","081 123 4567"],["Nauru","nr","674","555 1234"],["Nepal","np","977","984-1234567"],["Netherlands","nl","31","06 12345678"],["New Caledonia","nc","687","75.12.34"],["New Zealand","nz","64","021 123 4567"],["Nicaragua","ni","505","8123 4567"],["Niger","ne","227","93 12 34 56"],["Nigeria","ng","234","0802 123 4567"],["Niue","nu","683","888 4012"],["Norfolk Island","nf","672","3 81234"],["North Korea","kp","850","0192 123 4567"],["Northern Mariana Islands","mp","1","(670) 234-5678"],["Norway","no","47","406 12 345"],["Oman","om","968","9212 3456"],["Pakistan","pk","92","0301 2345678"],["Palau","pw","680","620 1234"],["Palestine","ps","970","0599 123 456"],["Panama","pa","507","6123-4567"],["Papua New Guinea","pg","675","7012 3456"],["Paraguay","py","595","0961 456789"],["Peru","pe","51","912 345 678"],["Philippines","ph","63","0905 123 4567"],["Poland","pl","48","512 345 678"],["Portugal","pt","351","912 345 678"],["Puerto Rico","pr","1","(787) 234-5678"],["Qatar","qa","974","3312 3456"],["Réunion","re","262","0692 12 34 56"],["Romania","ro","40","0712 034 567"],["Russia","ru","7","8 (912) 345-67-89"],["Rwanda","rw","250","0720 123 456"],["Saint Barthélemy","bl","590","0690 00 12 34"],["Saint Helena","sh","290","51234"],["Saint Kitts and Nevis","kn","1","(869) 765-2917"],["Saint Lucia","lc","1","(758) 284-5678"],["Saint Martin","mf","590","0690 00 12 34"],["Saint Pierre and Miquelon","pm","508","055 12 34"],["Saint Vincent and the Grenadines","vc","1","(784) 430-1234"],["Samoa","ws","685","72 12345"],["San Marino","sm","378","66 66 12 12"],["São Tomé and Príncipe","st","239","981 2345"],["Saudi Arabia","sa","966","051 234 5678"],["Senegal","sn","221","70 123 45 67"],["Serbia","rs","381","060 1234567"],["Seychelles","sc","248","2 510 123"],["Sierra Leone","sl","232","(025) 123456"],["Singapore","sg","65","8123 4567"],["Sint Maarten","sx","1","(721) 520-5678"],["Slovakia","sk","421","0912 123 456"],["Slovenia","si","386","031 234 567"],["Solomon Islands","sb","677","74 21234"],["Somalia","so","252","7 1123456"],["South Africa","za","27","071 123 4567"],["South Korea","kr","82","010-2000-0000"],["South Sudan","ss","211","0977 123 456"],["Spain","es","34","612 34 56 78"],["Sri Lanka","lk","94","071 234 5678"],["Sudan","sd","249","091 123 1234"],["Suriname","sr","597","741-2345"],["Svalbard and Jan Mayen","sj","47","412 34 567"],["Sweden","se","46","070-123 45 67"],["Switzerland","ch","41","078 123 45 67"],["Syria","sy","963","0944 567 890"],["Taiwan","tw","886","0912 345 678"],["Tajikistan","tj","992","917 12 3456"],["Tanzania","tz","255","0621 234 567"],["Thailand","th","66","081 234 5678"],["Timor-Leste","tl","670","7721 2345"],["Togo","tg","228","90 11 23 45"],["Tokelau","tk","690","7290"],["Tonga","to","676","771 5123"],["Trinidad and Tobago","tt","1","(868) 291-1234"],["Tunisia","tn","216","20 123 456"],["Turkey","tr","90","0501 234 56 78"],["Turkmenistan","tm","993","8 66 123456"],["Turks and Caicos Islands","tc","1","(649) 231-1234"],["Tuvalu","tv","688","90 1234"],["U.S. Virgin Islands","vi","1","(340) 642-1234"],["Uganda","ug","256","0712 345678"],["Ukraine","ua","380","050 123 4567"],["United Arab Emirates","ae","971","050 123 4567"],["United Kingdom","gb","44","07400 123456"],["United States","us","1","(201) 555-0123"],["Uruguay","uy","598","094 231 234"],["Uzbekistan","uz","998","8 91 234 56 78"],["Vanuatu","vu","678","591 2345"],["Vatican City","va","39","312 345 6789"],["Venezuela","ve","58","0412-1234567"],["Vietnam","vn","84","091 234 56 78"],["Wallis and Futuna","wf","681","82 12 34"],["Western Sahara","eh","212","0650-123456"],["Yemen","ye","967","0712 345 678"],["Zambia","zm","260","095 5123456"],["Zimbabwe","zw","263","071 234 5678"],["Åland Islands","ax","358","041 2345678"]],this.countries_dropdown=null,this.country_ip=null,this.options=p.getOption("TidyContact"),!1!==this.options&&(null===(e=this.options)||void 0===e?void 0:e.cid))if(this.loadOptions(),this.hasAddressFields()||this.phoneEnabled()){if(this.createFields(),this.addEventListeners(),p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")&&!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()&&""!=p.getFieldValue(null===(n=null===(t=this.options)||void 0===t?void 0:t.address_fields)||void 0===n?void 0:n.address1)&&(this.logger.log("Address Field is not empty"),this.isDirty=!0),this.phoneEnabled()){this.createPhoneFields(),this.createPhoneMarginVariable(),this.logger.log("Phone Standardization is enabled"),this.countryDropDownEnabled()&&this.renderFlagsDropDown();const e=p.getField(null===(s=null===(i=this.options)||void 0===i?void 0:i.address_fields)||void 0===s?void 0:s.phone);e&&(e.addEventListener("keyup",(e=>{this.handlePhoneInputKeydown(e)})),this.setDefaultPhoneCountry())}}else this.logger.log("No address fields found")}loadOptions(){var e,t,n,i;this.options&&(this.options.address_fields||(this.options.address_fields={address1:"supporter.address1",address2:"supporter.address2",address3:"supporter.address3",city:"supporter.city",region:"supporter.region",postalCode:"supporter.postcode",country:"supporter.country",phone:"supporter.phoneNumber2"}),this.options.address_enable=null===(e=this.options.address_enable)||void 0===e||e,this.options.phone_enable&&(this.options.phone_flags=null===(t=this.options.phone_flags)||void 0===t||t,this.options.phone_country_from_ip=null===(n=this.options.phone_country_from_ip)||void 0===n||n,this.options.phone_preferred_countries=null!==(i=this.options.phone_preferred_countries)&&void 0!==i?i:[]))}createFields(){var e,t,n,i,s,o;if(!this.options||!this.hasAddressFields())return;const r=p.getField("supporter.geo.latitude"),a=p.getField("supporter.geo.longitude");if(r||(p.createHiddenInput("supporter.geo.latitude",""),this.logger.log("Creating Hidden Field: supporter.geo.latitude")),a||(p.createHiddenInput("supporter.geo.longitude",""),this.logger.log("Creating Hidden Field: supporter.geo.longitude")),this.options.record_field){p.getField(this.options.record_field)||(p.createHiddenInput(this.options.record_field,""),this.logger.log("Creating Hidden Field: "+this.options.record_field))}if(this.options.date_field){p.getField(this.options.date_field)||(p.createHiddenInput(this.options.date_field,""),this.logger.log("Creating Hidden Field: "+this.options.date_field))}if(this.options.status_field){p.getField(this.options.status_field)||(p.createHiddenInput(this.options.status_field,""),this.logger.log("Creating Hidden Field: "+this.options.status_field))}p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.address2)||(p.createHiddenInput(null===(t=this.options.address_fields)||void 0===t?void 0:t.address2,""),this.logger.log("Creating Hidden Field: "+(null===(n=this.options.address_fields)||void 0===n?void 0:n.address2))),p.getField(null===(i=this.options.address_fields)||void 0===i?void 0:i.address3)||(p.createHiddenInput(null===(s=this.options.address_fields)||void 0===s?void 0:s.address3,""),this.logger.log("Creating Hidden Field: "+(null===(o=this.options.address_fields)||void 0===o?void 0:o.address3)))}createPhoneFields(){if(this.options){if(p.createHiddenInput("tc.phone.country",""),this.logger.log("Creating hidden field: tc.phone.country"),this.options.phone_record_field){p.getField(this.options.phone_record_field)||(p.createHiddenInput(this.options.phone_record_field,""),this.logger.log("Creating hidden field: "+this.options.phone_record_field))}if(this.options.phone_date_field){p.getField(this.options.phone_date_field)||(p.createHiddenInput(this.options.phone_date_field,""),this.logger.log("Creating hidden field: "+this.options.phone_date_field))}if(this.options.phone_status_field){p.getField(this.options.phone_status_field)||(p.createHiddenInput(this.options.phone_status_field,""),this.logger.log("Creating hidden field: "+this.options.phone_status_field))}}}createPhoneMarginVariable(){var e;if(!this.options)return;const t=p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.phone);if(t){const e=window.getComputedStyle(t),n=e.marginTop,i=e.marginBottom;document.documentElement.style.setProperty("--tc-phone-margin-top",n),document.documentElement.style.setProperty("--tc-phone-margin-bottom",i)}}addEventListeners(){if(!this.options)return;if(this.options.address_fields)for(const[e,t]of Object.entries(this.options.address_fields)){const e=p.getField(t);e&&e.addEventListener("change",(()=>{this.logger.log("Changed "+e.name,!0),this.isDirty=!0}))}this._form.onSubmit.subscribe(this.callAPI.bind(this));const e=document.getElementsByName("transaction.giveBySelect");e&&e.forEach((e=>{e.addEventListener("change",(()=>{["stripedigitalwallet","paypaltouch"].includes(e.value.toLowerCase())&&(this.logger.log("Clicked Digital Wallet Button"),window.setTimeout((()=>{this.callAPI()}),500))}))}))}checkSum(e){return Ce(this,void 0,void 0,(function*(){const t=(new TextEncoder).encode(e),n=yield crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>("00"+e.toString(16)).slice(-2))).join("")}))}todaysDate(){return(new Date).toLocaleString("en-ZA",{year:"numeric",month:"2-digit",day:"2-digit"}).replace(/\/+/g,"")}countryAllowed(e){var t;return!!this.options&&(!this.options.countries||0===this.options.countries.length||!!(null===(t=this.options.countries)||void 0===t?void 0:t.includes(e.toLowerCase())))}fetchTimeOut(e,t){const n=new AbortController,i=n.signal;t=Object.assign(Object.assign({},t),{signal:i});const s=fetch(e,t);i&&i.addEventListener("abort",(()=>n.abort()));const o=setTimeout((()=>n.abort()),1e3*this.timeout);return s.finally((()=>clearTimeout(o)))}writeError(e){if(!this.options)return;const t=p.getField(this.options.record_field),n=p.getField(this.options.date_field),i=p.getField(this.options.status_field);if(t){let n="";switch(this.httpStatus){case 400:n="Bad Request";break;case 401:n="Unauthorized";break;case 403:n="Forbidden";break;case 404:n="Not Found";break;case 408:n="API Request Timeout";break;case 500:n="Internal Server Error";break;case 503:n="Service Unavailable";break;default:n="Unknown Error"}const i={status:this.httpStatus,error:"string"==typeof e?e:n.toUpperCase()};t.value=JSON.stringify(i)}n&&(n.value=this.todaysDate()),i&&(i.value="ERROR-API")}setFields(e){var t,n,i,s,o;if(!this.options||!this.options.address_enable)return{};let r={};const a=this.getCountry(),l=p.getFieldValue(null===(t=this.options.address_fields)||void 0===t?void 0:t.postalCode),c=null!==(n=this.options.us_zip_divider)&&void 0!==n?n:"+",d=p.getField(null===(i=this.options.address_fields)||void 0===i?void 0:i.address2);if("address2"in e&&!d){p.getFieldValue(null===(s=this.options.address_fields)||void 0===s?void 0:s.address1)==e.address1+" "+e.address2?(delete e.address1,delete e.address2):(e.address1=e.address1+" "+e.address2,delete e.address2)}"postalCode"in e&&l.replace("+",c)===e.postalCode.replace("+",c)&&delete e.postalCode;for(const t in e){const n=this.options.address_fields&&Object.keys(this.options.address_fields).includes(t)?this.options.address_fields[t]:t,i=p.getField(n);if(i){let s=e[t];"postalCode"===t&&["US","USA","United States"].includes(a)&&(s=null!==(o=s.replace("+",c))&&void 0!==o?o:""),r[t]={from:i.value,to:s},this.logger.log(`Set ${i.name} to ${s} (${i.value})`),p.setFieldValue(n,s,!1)}else this.logger.log(`Field ${t} not found`)}return r}hasAddressFields(){var e,t,n,i,s,o;if(!this.options||!this.options.address_enable)return!1;const r=p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.address1),a=p.getField(null===(t=this.options.address_fields)||void 0===t?void 0:t.address2),l=p.getField(null===(n=this.options.address_fields)||void 0===n?void 0:n.city),c=p.getField(null===(i=this.options.address_fields)||void 0===i?void 0:i.region),d=p.getField(null===(s=this.options.address_fields)||void 0===s?void 0:s.postalCode),u=p.getField(null===(o=this.options.address_fields)||void 0===o?void 0:o.country);return!!(r||a||l||c||d||u)}canUseAPI(){var e,t,n,i;if(!this.options||!this.hasAddressFields())return!1;const s=!!this.getCountry(),o=!!p.getFieldValue(null===(e=this.options.address_fields)||void 0===e?void 0:e.address1),r=!!p.getFieldValue(null===(t=this.options.address_fields)||void 0===t?void 0:t.city),a=!!p.getFieldValue(null===(n=this.options.address_fields)||void 0===n?void 0:n.region),l=!!p.getFieldValue(null===(i=this.options.address_fields)||void 0===i?void 0:i.postalCode);return s&&o?r&&a||l:(this.logger.log("API cannot be used"),!1)}canUsePhoneAPI(){var e;if(!this.options)return!1;if(this.phoneEnabled()){const t=!!p.getFieldValue(null===(e=this.options.address_fields)||void 0===e?void 0:e.phone),n=!!p.getFieldValue("tc.phone.country");return t&&n}return this.logger.log("Phone API is not enabled"),!1}getCountry(){var e,t;if(!this.options)return"";const n=null!==(e=this.options.country_fallback)&&void 0!==e?e:"";return p.getFieldValue(null===(t=this.options.address_fields)||void 0===t?void 0:t.country)||n.toUpperCase()}getCountryByCode(e){var t;const n=null!==(t=this.countries_list.find((t=>t.includes(e))))&&void 0!==t?t:"";return n?{name:n[0],code:n[1],dialCode:n[2],placeholder:n[3]}:null}phoneEnabled(){return!(!this.options||!this.options.phone_enable)}countryDropDownEnabled(){return!(!this.options||!this.options.phone_flags)}getCountryFromIP(){return Ce(this,void 0,void 0,(function*(){return fetch(`https://${window.location.hostname}/cdn-cgi/trace`).then((e=>e.text())).then((e=>{let t=e.replace(/[\r\n]+/g,'","').replace(/\=+/g,'":"');t='{"'+t.slice(0,t.lastIndexOf('","'))+'"}';const n=JSON.parse(t);return this.country_ip=n.loc,this.country_ip}))}))}renderFlagsDropDown(){var e;if(!this.options)return;const t=p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.phone);if(!t)return;this.countries_dropdown=document.createElement("div"),this.countries_dropdown.classList.add("tc-flags-container");const n=document.createElement("div");n.classList.add("tc-selected-flag"),n.setAttribute("role","combobox"),n.setAttribute("aria-haspopup","listbox"),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-owns","tc-flags-list"),n.setAttribute("aria-label","Select Country"),n.setAttribute("tabindex","0");const i=document.createElement("div");i.classList.add("tc-flag");const s=document.createElement("div");s.classList.add("tc-flag-arrow"),n.appendChild(i),n.appendChild(s),n.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation(),n.classList.contains("tc-open")?this.closeCountryDropDown():this.openCountryDropDown()}));const o=document.createElement("ul");if(o.classList.add("tc-country-list"),o.classList.add("tc-hide"),o.setAttribute("id","tc-country-list"),o.setAttribute("role","listbox"),o.setAttribute("aria-label","List of Countries"),o.setAttribute("aria-hidden","true"),this.options.phone_preferred_countries.length>0){const e=[];this.options.phone_preferred_countries.forEach((t=>{const n=this.getCountryByCode(t);n&&e.push(n)})),this.appendCountryItems(o,e,"tc-country-list-item",!0);const t=document.createElement("li");t.classList.add("tc-divider"),t.setAttribute("role","separator"),t.setAttribute("aria-disabled","true"),o.appendChild(t),this.logger.log("Rendering preferred countries",JSON.stringify(e))}const r=[];this.countries_list.forEach((e=>{r.push({name:e[0],code:e[1],dialCode:e[2],placeholder:e[3]})})),this.appendCountryItems(o,r,"tc-country-list-item"),o.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation();const t=e.target.closest("li");if(t.classList.contains("tc-country-list-item")){const e=this.getCountryByCode(t.getAttribute("data-country-code"));e&&this.setPhoneCountry(e)}})),o.addEventListener("mouseover",(e=>{e.preventDefault(),e.stopPropagation();const t=e.target.closest("li.tc-country-list-item");t&&this.highlightCountry(t.getAttribute("data-country-code"))})),this.countries_dropdown.appendChild(n),this.countries_dropdown.appendChild(o),t.parentNode.insertBefore(this.countries_dropdown,t),t.parentNode.classList.add("tc-has-country-flags"),this.countries_dropdown.addEventListener("keydown",(e=>{var t,n;(null===(n=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-country-list"))||void 0===n?void 0:n.classList.contains("tc-hide"))&&-1!==["ArrowUp","Up","ArrowDown","Down"," ","Enter"].indexOf(e.key)&&(e.preventDefault(),e.stopPropagation(),this.openCountryDropDown()),"Tab"===e.key&&this.closeCountryDropDown()})),document.addEventListener("keydown",(e=>{var t,n;(null===(n=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-country-list"))||void 0===n?void 0:n.classList.contains("tc-hide"))||(e.preventDefault(),"ArrowUp"===e.key||"Up"===e.key||"ArrowDown"===e.key||"Down"===e.key?this.handleUpDownKey(e.key):"Enter"===e.key?this.handleEnterKey():"Escape"===e.key&&this.closeCountryDropDown())})),document.addEventListener("click",(e=>{var t,n;(null===(n=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-country-list"))||void 0===n?void 0:n.classList.contains("tc-hide"))||e.target.closest(".tc-country-list")||this.closeCountryDropDown()}))}handleUpDownKey(e){var t;const n=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-highlight");if(n){let t="ArrowUp"===e||"Up"===e?n.previousElementSibling:n.nextElementSibling;t&&(t.classList.contains("tc-divider")&&(t="ArrowUp"===e||"Up"===e?t.previousElementSibling:t.nextElementSibling),this.highlightCountry(null==t?void 0:t.getAttribute("data-country-code")))}}handleEnterKey(){var e;const t=null===(e=this.countries_dropdown)||void 0===e?void 0:e.querySelector(".tc-highlight");if(t){const e=this.getCountryByCode(null==t?void 0:t.getAttribute("data-country-code"));this.setPhoneCountry(e)}}handlePhoneInputKeydown(e){const t=e.target.value;if("+"===t.charAt(0)&&t.length>2){const e=this.getCountryByCode(t.substring(1,3));e?this.setPhoneCountry(e):this.setDefaultPhoneCountry()}}openCountryDropDown(){if(!this.countries_dropdown)return;const e=this.countries_dropdown.querySelector(".tc-country-list"),t=this.countries_dropdown.querySelector(".tc-selected-flag");e&&t&&(e.classList.remove("tc-hide"),t.setAttribute("aria-expanded","true"),t.classList.add("tc-open"))}closeCountryDropDown(){var e;if(!this.options)return;if(!this.countries_dropdown)return;const t=this.countries_dropdown.querySelector(".tc-country-list"),n=this.countries_dropdown.querySelector(".tc-selected-flag");t&&n&&(t.classList.add("tc-hide"),n.setAttribute("aria-expanded","false"),n.classList.remove("tc-open"));p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.phone).focus()}getFlagImage(e,t){return`<picture>\n <source\n loading="lazy"\n type="image/webp"\n srcset="https://flagcdn.com/h20/${e}.webp,\n https://flagcdn.com/h40/${e}.webp 2x,\n https://flagcdn.com/h60/${e}.webp 3x">\n <source\n loading="lazy"\n type="image/png"\n srcset="https://flagcdn.com/h20/${e}.png,\n https://flagcdn.com/h40/${e}.png 2x,\n https://flagcdn.com/h60/${e}.png 3x">\n <img\n loading="lazy"\n src="https://flagcdn.com/h20/${e}.png"\n height="20"\n alt="${t}">\n </picture>`}appendCountryItems(e,t,n,i=!1){let s="";for(let e=0;e<t.length;e++){const o=t[e],r=i?"-preferred":"";s+=`<li class='tc-country ${n}' tabIndex='-1' id='tc-item-${o.code}${r}' role='option' data-dial-code='${o.dialCode}' data-country-code='${o.code}' aria-selected='false'>`,s+=`<div class='tc-flag-box'><div class='tc-flag tc-${o.code}'>${this.getFlagImage(o.code,o.name)}</div></div>`,s+=`<span class='tc-country-name'>${o.name}</span>`,s+=`<span class='tc-dial-code'>+${o.dialCode}</span>`,s+="</li>"}e.insertAdjacentHTML("beforeend",s)}setDefaultPhoneCountry(){var e;if(!this.options)return;if(this.options.phone_country_from_ip)return void this.getCountryFromIP().then((e=>{this.logger.log("Country from IP:",e),this.setPhoneCountry(this.getCountryByCode((null!=e?e:"us").toLowerCase()))})).catch((e=>{this.setPhoneCountry(this.getCountryByCode("us"))}));const t=p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.country);if(t){const e=t.options[t.selectedIndex].text,n=this.getCountryByCode(e);if(n)return void this.setPhoneCountry(n);if(this.options.phone_preferred_countries.length>0)return void this.setPhoneCountry(this.getCountryByCode(this.options.phone_preferred_countries[0]))}this.setPhoneCountry(this.getCountryByCode("us"))}setPhoneCountry(e){var t,n,i,s,o,r;if(!this.options||!e)return;const a=p.getField("tc.phone.country");if(a.value===e.code)return;const l=p.getField(null===(t=this.options.address_fields)||void 0===t?void 0:t.phone);if(this.countryDropDownEnabled()){const t=null===(n=this.countries_dropdown)||void 0===n?void 0:n.querySelector(".tc-selected-flag"),a=null===(i=this.countries_dropdown)||void 0===i?void 0:i.querySelector(".tc-flag");t&&a&&(a.innerHTML=this.getFlagImage(e.code,e.name),t.setAttribute("data-country",e.code));const l=null===(s=this.countries_dropdown)||void 0===s?void 0:s.querySelector(".tc-country-list-item[aria-selected='true']");l&&(l.classList.remove("tc-selected"),l.setAttribute("aria-selected","false"));const c=null===(o=this.countries_dropdown)||void 0===o?void 0:o.querySelector(".tc-highlight");c&&c.classList.remove("tc-highlight");const d=null===(r=this.countries_dropdown)||void 0===r?void 0:r.querySelector(`.tc-country-list-item[data-country-code='${e.code}']`);d&&(d.classList.add("tc-selected"),d.setAttribute("aria-selected","true"),d.classList.add("tc-highlight")),(null==t?void 0:t.classList.contains("tc-open"))&&this.closeCountryDropDown()}l.setAttribute("placeholder",e.placeholder),a.value=e.code,this.logger.log(`Setting phone country to ${e.code} - ${e.name}`)}highlightCountry(e){var t,n;if(!e)return;const i=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-highlight");i&&i.classList.remove("tc-highlight");const s=null===(n=this.countries_dropdown)||void 0===n?void 0:n.querySelector(".tc-country-list");if(s){const t=s.querySelector(`.tc-country[data-country-code='${e}']`);t&&(t.classList.add("tc-highlight"),t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}))}}setPhoneDataFromAPI(e,t){var n;return Ce(this,void 0,void 0,(function*(){if(!this.options)return;const i=p.getField(null===(n=this.options.address_fields)||void 0===n?void 0:n.phone),s=p.getField(this.options.phone_record_field),o=p.getField(this.options.phone_date_field),r=p.getField(this.options.phone_status_field);let a={};a.formData={[i.name]:i.value},a.formatted=e.formatted,a.number_type=e.number_type,!0===e.valid?(i.value!==e.formatted.e164&&(a.phone={from:i.value,to:e.formatted.e164},i.value=e.formatted.e164),yield this.checkSum(JSON.stringify(a)).then((e=>{this.logger.log("Phone Checksum",e),a.requestId=t,a.checksum=e})),s&&(a=Object.assign({date:this.todaysDate(),status:"SUCCESS"},a),s.value=JSON.stringify(a)),o&&(o.value=this.todaysDate()),r&&(r.value="SUCCESS")):(yield this.checkSum(JSON.stringify(a)).then((e=>{this.logger.log("Phone Checksum",e),a.requestId=t,a.checksum=e})),s&&(a=Object.assign({date:this.todaysDate(),status:"ERROR"},a),s.value=JSON.stringify(a)),o&&(o.value=this.todaysDate()),r&&(r.value="error"in e?"ERROR: "+e.error:"INVALIDPHONE"))}))}callAPI(){var e,t,n,i,s,o;if(!this.options)return;if(!this.isDirty||this.wasCalled)return;if(!this._form.submit)return void this.logger.log("Form Submission Interrupted by Other Component");const r=p.getField(this.options.record_field),a=p.getField(this.options.date_field),l=p.getField(this.options.status_field),c=p.getField("supporter.geo.latitude"),d=p.getField("supporter.geo.longitude");if(!this.canUseAPI()&&!this.canUsePhoneAPI())return this.logger.log("Not Enough Data to Call API"),a&&(a.value=this.todaysDate()),l&&(l.value="PARTIALADDRESS"),!0;const u=p.getFieldValue(null===(e=this.options.address_fields)||void 0===e?void 0:e.address1),h=p.getFieldValue(null===(t=this.options.address_fields)||void 0===t?void 0:t.address2),g=p.getFieldValue(null===(n=this.options.address_fields)||void 0===n?void 0:n.city),m=p.getFieldValue(null===(i=this.options.address_fields)||void 0===i?void 0:i.region),f=p.getFieldValue(null===(s=this.options.address_fields)||void 0===s?void 0:s.postalCode),b=this.getCountry();if(!this.countryAllowed(b)){if(this.logger.log("Country not allowed: "+b),r){let e={};e=Object.assign({date:this.todaysDate(),status:"DISALLOWED"},e),r.value=JSON.stringify(e)}return a&&(a.value=this.todaysDate()),l&&(l.value="DISALLOWED"),!0}let v={url:window.location.href,cid:this.options.cid};this.canUseAPI()&&(v=Object.assign(v,{address1:u,address2:h,city:g,region:m,postalCode:f,country:b})),this.canUsePhoneAPI()&&(v.phone=p.getFieldValue(null===(o=this.options.address_fields)||void 0===o?void 0:o.phone),v.phoneCountry=p.getFieldValue("tc.phone.country")),this.wasCalled=!0,this.logger.log("FormData",JSON.parse(JSON.stringify(v)));const y=this.fetchTimeOut(this.endpoint,{headers:{"Content-Type":"application/json; charset=utf-8"},method:"POST",body:JSON.stringify(v)}).then((e=>(this.httpStatus=e.status,e.json()))).then((e=>Ce(this,void 0,void 0,(function*(){if(this.logger.log("callAPI response",JSON.parse(JSON.stringify(e))),!0===e.valid){let t={};"changed"in e&&(t=this.setFields(e.changed)),t.formData=v,yield this.checkSum(JSON.stringify(t)).then((n=>{this.logger.log("Checksum",n),t.requestId=e.requestId,t.checksum=n})),"latitude"in e&&(c.value=e.latitude,t.latitude=e.latitude),"longitude"in e&&(d.value=e.longitude,t.longitude=e.longitude),r&&(t=Object.assign({date:this.todaysDate(),status:"SUCCESS"},t),r.value=JSON.stringify(t)),a&&(a.value=this.todaysDate()),l&&(l.value="SUCCESS")}else{let t={};t.formData=v,yield this.checkSum(JSON.stringify(t)).then((n=>{this.logger.log("Checksum",n),t.requestId=e.requestId,t.checksum=n})),r&&(t=Object.assign({date:this.todaysDate(),status:"ERROR"},t),r.value=JSON.stringify(t)),a&&(a.value=this.todaysDate()),l&&(l.value="error"in e?"ERROR: "+e.error:"INVALIDADDRESS")}this.phoneEnabled()&&"phone"in e&&(yield this.setPhoneDataFromAPI(e.phone,e.requestId))})))).catch((e=>{e.toString().includes("AbortError")&&(this.logger.log("Fetch aborted"),this.httpStatus=408),this.writeError(e)}));return this._form.submitPromise=y,y}}class xe{constructor(){this.logger=new fe("LiveCurrency","#1901b1","#feb47a","💲"),this.elementsFound=!1,this.isUpdating=!1,this._amount=h.getInstance(),this._frequency=g.getInstance(),this._fees=m.getInstance(),this.searchElements(),this.shouldRun()&&(p.setBodyData("live-currency","active"),this.updateCurrency(),this.addEventListeners(),document.querySelectorAll(".en__field--donationAmt .en__field__element--radio .en__field__item").forEach((e=>{e.setAttribute("data-engrid-currency-symbol-updated","true")})))}searchElements(){const e=document.querySelectorAll("\n .en__component--copyblock,\n .en__component--codeblock,\n .en__field label,\n .en__submit\n ");if(e.length>0){this.elementsFound=!0;const t=p.getCurrencySymbol(),n=p.getCurrencyCode(),i=`<span class="engrid-currency-symbol">${t}</span>`,s=`<span class="engrid-currency-code">${n}</span>`;e.forEach((e=>{if(!(e instanceof HTMLElement&&e.innerHTML.startsWith("<script"))&&e instanceof HTMLElement&&(e.innerHTML.includes("[$]")||e.innerHTML.includes("[$$$]"))){this.logger.log("Old Value:",e.innerHTML);const t=/\[\$\]/g,n=/\[\$\$\$\]/g;e.innerHTML=e.innerHTML.replace(n,s),e.innerHTML=e.innerHTML.replace(t,i),this.logger.log("New Value:",e.innerHTML)}}))}}shouldRun(){return this.elementsFound}addMutationObserver(){const e=document.querySelector(".en__field--donationAmt .en__field__element--radio");if(!e)return;new MutationObserver((t=>{t.forEach((t=>{if("childList"===t.type){if(this.isUpdating)return;this.isUpdating=!0,setTimeout((()=>{this.searchElements(),this.updateCurrency(),e.querySelectorAll(".en__field__item").forEach((e=>{e.setAttribute("data-engrid-currency-symbol-updated","true")})),this.isUpdating=!1}),20)}}))})).observe(e,{childList:!0})}addEventListeners(){this._fees.onFeeChange.subscribe((()=>{setTimeout((()=>{this.updateCurrency()}),10)})),this._amount.onAmountChange.subscribe((()=>{setTimeout((()=>{this.updateCurrency()}),10)})),this._frequency.onFrequencyChange.subscribe((()=>{this.isUpdating||(this.isUpdating=!0,setTimeout((()=>{this.searchElements(),this.updateCurrency(),document.querySelectorAll(".en__field--donationAmt .en__field__element--radio .en__field__item").forEach((e=>{e.setAttribute("data-engrid-currency-symbol-updated","true")})),this.isUpdating=!1}),10))}));const e=p.getField("transaction.paycurrency");e&&e.addEventListener("change",(()=>{setTimeout((()=>{this.updateCurrency(),this._amount.load();const e=document.querySelector(".en__field--donationAmt .en__field__item--other");e&&e.setAttribute("data-currency-symbol",p.getCurrencySymbol()),p.setBodyData("currency-code",p.getCurrencyCode())}),10)})),this.addMutationObserver()}updateCurrency(){const e=document.querySelectorAll(".engrid-currency-symbol"),t=document.querySelectorAll(".engrid-currency-code");e.length>0&&e.forEach((e=>{e.innerHTML=p.getCurrencySymbol()})),t.length>0&&t.forEach((e=>{e.innerHTML=p.getCurrencyCode()})),this.logger.log(`Currency updated for ${e.length+t.length} elements`)}}class De{constructor(){this.logger=new fe("CustomCurrency","#1901b1","#00cc95","🤑"),this.currencyElement=document.querySelector("[name='transaction.paycurrency']"),this._country=b.getInstance(),this.shouldRun()&&(this.addEventListeners(),this.loadCurrencies())}shouldRun(){return!(!this.currencyElement||!p.getOption("CustomCurrency"))}addEventListeners(){this._country.countryField&&this._country.onCountryChange.subscribe((e=>{this.loadCurrencies(e)}))}loadCurrencies(e="default"){const t=p.getOption("CustomCurrency");if(!t)return;const n=t.label||"Give with [$$$]";let i=t.default;if(t.countries&&t.countries[e]&&(i=t.countries[e]),!i)return void this.logger.log(`No currencies found for ${e}`);this.logger.log(`Loading currencies for ${e}`),this.currencyElement.innerHTML="";for(const e in i){const t=document.createElement("option");t.value=e,t.text=n.replace("[$$$]",e).replace("[$]",i[e]),t.setAttribute("data-currency-code",e),t.setAttribute("data-currency-symbol",i[e]),this.currencyElement.appendChild(t)}this.currencyElement.selectedIndex=0;const s=new Event("change",{bubbles:!0});this.currencyElement.dispatchEvent(s)}}class Fe{constructor(){this.logger=new fe("Autosubmit","#f0f0f0","#ff0000","🚀"),this._form=u.getInstance(),p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")&&!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()&&"Y"===p.getUrlParameter("autosubmit")&&(this.logger.log("Autosubmitting Form"),p.setFieldValue("supporter.emailAddress",p.getFieldValue("supporter.emailAddress").replace(/\s/g,"+")),this._form.submitForm())}}class Pe{constructor(){const e=document.getElementsByClassName("en__ticket__field--cost"),t=document.getElementsByClassName("en__ticket__currency");for(const e of t)e.classList.add("en__ticket__currency__hidden");for(const t of e){const e=t.getElementsByClassName("en__ticket__price")[0],n={style:"currency",currency:t.getElementsByClassName("en__ticket__currency")[0].innerText};let i=Intl.NumberFormat(void 0,n).format(Number(e.innerText));".00"===i.slice(-3)&&(i=i.slice(0,-3)),e.innerText=i}}}class Ne{constructor(){this.logger=new fe("SwapAmounts","purple","white","💰"),this._amount=h.getInstance(),this._frequency=g.getInstance(),this.defaultChange=!1,this.swapped=!1,this.shouldRun()&&(this._frequency.onFrequencyChange.subscribe((()=>this.swapAmounts())),this._amount.onAmountChange.subscribe((()=>{this._frequency.frequency in window.EngridAmounts!=!1&&(this.defaultChange=!1,this.swapped&&this._amount.amount!=window.EngridAmounts[this._frequency.frequency].default&&(this.defaultChange=!0))})))}swapAmounts(){this._frequency.frequency in window.EngridAmounts&&(window.EngagingNetworks.require._defined.enjs.swapList("donationAmt",this.loadEnAmounts(window.EngridAmounts[this._frequency.frequency]),{ignoreCurrentValue:this.ignoreCurrentValue()}),this._amount.load(),this.logger.log("Amounts Swapped To",window.EngridAmounts[this._frequency.frequency]),this.swapped=!0)}loadEnAmounts(e){let t=[];for(let n in e.amounts)t.push({selected:e.amounts[n]===e.default,label:n,value:e.amounts[n].toString()});return t}shouldRun(){return"EngridAmounts"in window}ignoreCurrentValue(){return!(window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()||null!==p.getUrlParameter("transaction.donationAmt")||this.defaultChange)}}class Te{constructor(e){var t,n;this.logger=new fe("Debug Panel","#f0f0f0","#ff0000","💥"),this.brandingHtml=new Me,this.element=null,this.currentTimestamp=this.getCurrentTimestamp(),this.quickFills={"pi-general":[{name:"supporter.title",value:"Ms"},{name:"supporter.firstName",value:"4Site"},{name:"supporter.lastName",value:"Studio"},{name:"supporter.emailAddress",value:"en-test@4sitestudios.com"},{name:"supporter.phoneNumber",value:"555-555-5555"}],"pi-unique":[{name:"supporter.title",value:"Ms"},{name:"supporter.firstName",value:`4Site ${this.currentTimestamp}`},{name:"supporter.lastName",value:"Studio"},{name:"supporter.emailAddress",value:`en-test+${this.currentTimestamp}@4sitestudios.com`},{name:"supporter.phoneNumber",value:"555-555-5555"}],"us-address":[{name:"supporter.address1",value:"3431 14th St NW"},{name:"supporter.address2",value:"Suite 1"},{name:"supporter.city",value:"Washington"},{name:"supporter.region",value:"DC"},{name:"supporter.postcode",value:"20010"},{name:"supporter.country",value:"US"}],"us-address-senate-rep":[{name:"supporter.address1",value:"20 W 34th Street"},{name:"supporter.address2",value:""},{name:"supporter.city",value:"New York"},{name:"supporter.region",value:"NY"},{name:"supporter.postcode",value:"10001"},{name:"supporter.country",value:"US"}],"us-address-nonexistent":[{name:"supporter.address1",value:"12345 Main Street"},{name:"supporter.address2",value:""},{name:"supporter.city",value:"New York"},{name:"supporter.region",value:"TX"},{name:"supporter.postcode",value:"90210"},{name:"supporter.country",value:"US"}],"cc-paysafe-visa":[{name:"transaction.ccnumber",value:"4530910000012345"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}],"cc-paysafe-visa-invalid":[{name:"transaction.ccnumber",value:"411111"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}],"cc-paysafe-mastercard":[{name:"transaction.ccnumber",value:"5036150000001115"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}],"cc-stripe-visa":[{name:"transaction.ccnumber",value:"4242424242424242"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}],"quick-fill-pi-unique-us-address-senate-rep-cc-stripe-visa":[{name:"supporter.title",value:"Ms"},{name:"supporter.firstName",value:`4Site ${this.currentTimestamp}`},{name:"supporter.lastName",value:"Studio"},{name:"supporter.emailAddress",value:`en-test+${this.currentTimestamp}@4sitestudios.com`},{name:"supporter.phoneNumber",value:"555-555-5555"},{name:"supporter.address1",value:"20 W 34th Street"},{name:"supporter.address2",value:""},{name:"supporter.city",value:"New York"},{name:"supporter.region",value:"NY"},{name:"supporter.postcode",value:"10001"},{name:"supporter.country",value:"US"},{name:"transaction.ccnumber",value:"4242424242424242"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}]},this.logger.log("Adding debug panel and starting a debug session"),this.pageLayouts=e,this.loadDebugPanel(),this.element=document.querySelector(".debug-panel"),null===(t=this.element)||void 0===t||t.addEventListener("click",(()=>{var e;null===(e=this.element)||void 0===e||e.classList.add("debug-panel--open")}));const i=document.querySelector(".debug-panel__close");null==i||i.addEventListener("click",(e=>{var t;e.stopPropagation(),null===(t=this.element)||void 0===t||t.classList.remove("debug-panel--open")})),"local"===p.getUrlParameter("assets")&&(null===(n=this.element)||void 0===n||n.classList.add("debug-panel--local")),window.sessionStorage.setItem(Te.debugSessionStorageKey,"active")}loadDebugPanel(){document.body.insertAdjacentHTML("beforeend",'<div class="debug-panel">\n <div class="debug-panel__container">\n <div class="debug-panel__closed-title">Debug</div>\n <div class="debug-panel__title">\n <h2>Debug</h2>\n <div class="debug-panel__close">X</div>\n </div>\n <div class="debug-panel__options">\n <div class="debug-panel__option">\n <label class="debug-panel__link-label link-left">\n <a class="debug-panel__edit-link">Edit page</a>\n </label>\n </div>\n <div class="debug-panel__option">\n <label for="engrid-form-quickfill">Quick-fill</label>\n <select name="engrid-form-quickfill" id="engrid-form-quickfill">\n <option disabled selected>Choose an option</option>\n <option value="quick-fill-pi-unique-us-address-senate-rep-cc-stripe-visa">Quick-fill - Unique w/ Senate Address - Stripe Visa</option>\n <option value="pi-general">Personal Info - General</option>\n <option value="pi-unique">Personal Info - Unique</option>\n <option value="us-address-senate-rep">US Address - w/ Senate Rep</option>\n <option value="us-address">US Address - w/o Senate Rep</option>\n <option value="us-address-nonexistent">US Address - Nonexistent</option>\n <option value="cc-paysafe-visa">CC - Paysafe - Visa</option>\n <option value="cc-paysafe-visa-invalid">CC - Paysafe - Visa (Invalid)</option>\n <option value="cc-paysafe-mastercard">CC - Paysafe - Mastercard</option>\n <option value="cc-stripe-visa">CC - Stripe - Visa</option>\n </select>\n </div>\n <div class="debug-panel__option">\n <label for="engrid-layout-switch">Layout</label>\n <select name="engrid-layout" id="engrid-layout-switch">\n </select>\n </div>\n <div class="debug-panel__option debug-panel__option--local">\n <div class="debug-panel__checkbox">\n <input type="checkbox" name="engrid-embedded-layout" id="engrid-embedded-layout">\n <label for="engrid-embedded-layout">Embedded layout</label> \n </div>\n </div>\n <div class="debug-panel__option debug-panel__option--local">\n <div class="debug-panel__checkbox">\n <input type="checkbox" name="engrid-debug-layout" id="engrid-debug-layout">\n <label for="engrid-debug-layout">Debug layout</label> \n </div>\n </div>\n <div class="debug-panel__option debug-panel__option--local">\n <div class="debug-panel__checkbox">\n <input type="checkbox" name="engrid-branding" id="engrid-branding">\n <label for="engrid-branding">Branding HTML</label> \n </div>\n </div>\n <div class="debug-panel__option">\n <label for="engrid-theme">Theme</label>\n <input type="text" id="engrid-theme">\n </div>\n <div class="debug-panel__option debug-panel__option--local">\n <label for="engrid-theme">Sub-theme</label>\n <input type="text" id="engrid-subtheme">\n </div>\n <div class="debug-panel__option">\n <button class="btn debug-panel__btn debug-panel__btn--submit" type="button">Submit form</button>\n </div>\n <div class="debug-panel__option">\n <label class="debug-panel__link-label">\n <a class="debug-panel__force-submit-link">Force submit form</a>\n </label>\n </div>\n <div class="debug-panel__option">\n <label class="debug-panel__link-label">\n <a class="debug-panel__end-debug-link">End debug</a>\n </label>\n </div>\n </div>\n </div>\n </div>'),this.setupLayoutSwitcher(),this.setupThemeSwitcher(),this.setupSubThemeSwitcher(),this.setupFormQuickfill(),this.createDebugSessionEndHandler(),this.setupEmbeddedLayoutSwitcher(),this.setupDebugLayoutSwitcher(),this.setupBrandingHtmlHandler(),this.setupEditBtnHandler(),this.setupForceSubmitLinkHandler(),this.setupSubmitBtnHandler()}switchENGridLayout(e){p.setBodyData("layout",e)}setupLayoutSwitcher(){var e,t;const n=document.getElementById("engrid-layout-switch");n&&(null===(e=this.pageLayouts)||void 0===e||e.forEach((e=>{n.insertAdjacentHTML("beforeend",`<option value="${e}">${e}</option>`)})),n.value=null!==(t=p.getBodyData("layout"))&&void 0!==t?t:"",n.addEventListener("change",(e=>{const t=e.target;this.switchENGridLayout(t.value)})))}setupThemeSwitcher(){var e;const t=document.getElementById("engrid-theme");t&&(t.value=null!==(e=p.getBodyData("theme"))&&void 0!==e?e:"",["keyup","blur"].forEach((e=>{t.addEventListener(e,(e=>{const t=e.target;this.switchENGridTheme(t.value)}))})))}switchENGridTheme(e){p.setBodyData("theme",e)}setupSubThemeSwitcher(){var e;const t=document.getElementById("engrid-subtheme");t&&(t.value=null!==(e=p.getBodyData("subtheme"))&&void 0!==e?e:"",["keyup","blur"].forEach((e=>{t.addEventListener(e,(e=>{const t=e.target;this.switchENGridSubtheme(t.value)}))})))}switchENGridSubtheme(e){p.setBodyData("subtheme",e)}setupFormQuickfill(){const e=document.getElementById("engrid-form-quickfill");null==e||e.addEventListener("change",(e=>{const t=e.target;this.quickFills[t.value].forEach((e=>{this.setFieldValue(e)}))}))}setFieldValue(e){if("transaction.ccexpire"!==e.name)p.setFieldValue(e.name,e.value,!0,!0);else{const t=document.getElementsByName("transaction.ccexpire");if(t.length>0){const n=e.value.split("/");t[0].value=n[0],t[1].value=n[1],t[0].dispatchEvent(new Event("change",{bubbles:!0})),t[1].dispatchEvent(new Event("change",{bubbles:!0}))}else t[0].value=e.value,t[0].dispatchEvent(new Event("change",{bubbles:!0}))}}getCurrentTimestamp(){const e=new Date;return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}-${String(e.getHours()).padStart(2,"0")}${String(e.getMinutes()).padStart(2,"0")}`}createDebugSessionEndHandler(){const e=document.querySelector(".debug-panel__end-debug-link");null==e||e.addEventListener("click",(()=>{var e;this.logger.log("Removing panel and ending debug session"),null===(e=this.element)||void 0===e||e.remove(),window.sessionStorage.removeItem(Te.debugSessionStorageKey)}))}setupEmbeddedLayoutSwitcher(){const e=document.getElementById("engrid-embedded-layout");e&&(e.checked=!!p.getBodyData("embedded"),e.addEventListener("change",(e=>{const t=e.target;p.setBodyData("embedded",t.checked)})))}setupDebugLayoutSwitcher(){const e=document.getElementById("engrid-debug-layout");e&&(e.checked="layout"===p.getBodyData("debug"),e.addEventListener("change",(e=>{e.target.checked?p.setBodyData("debug","layout"):p.setBodyData("debug","")})))}setupBrandingHtmlHandler(){const e=document.getElementById("engrid-branding");e.checked="branding"===p.getUrlParameter("development"),e.addEventListener("change",(t=>{e.checked?this.brandingHtml.show():this.brandingHtml.hide()}))}setupEditBtnHandler(){const e=document.querySelector(".debug-panel__edit-link");null==e||e.addEventListener("click",(()=>{window.open(`https://${p.getDataCenter()}.engagingnetworks.app/index.html#pages/${p.getPageID()}/edit`,"_blank")}))}setupForceSubmitLinkHandler(){const e=document.querySelector(".debug-panel__force-submit-link");null==e||e.addEventListener("click",(()=>{const e=document.querySelector("form.en__component");null==e||e.submit()}))}setupSubmitBtnHandler(){const e=document.querySelector(".debug-panel__btn--submit");null==e||e.addEventListener("click",(()=>{const e=document.querySelector(".en__submit button");null==e||e.click()}))}}Te.debugSessionStorageKey="engrid_debug_panel";class Oe{constructor(){this.logger=new fe("Debug hidden fields","#f0f0f0","#ff0000","🫣");const e=document.querySelectorAll(".en__component--row [type='hidden'][class*='en_'], .engrid-added-input[type='hidden']");e.length>0&&(this.logger.log(`Switching the following type 'hidden' fields to type 'text': ${[...e].map((e=>e.name)).join(", ")}`),e.forEach((e=>{e.type="text",e.classList.add("en__field__input","en__field__input--text");const t=document.createElement("label");t.textContent="Hidden field: "+e.name,t.classList.add("en__field__label");const n=document.createElement("div");n.classList.add("en__field__element","en__field__element--text");const i=document.createElement("div");i.classList.add("en__field","en__field--text","hide"),i.dataset.unhidden="",i.appendChild(t),i.appendChild(n),e.parentNode&&(e.parentNode.insertBefore(i,e),n.appendChild(e))})))}}var qe=function(e,t,n,i){return new(n||(n=Promise))((function(s,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))};class Me{constructor(){this.assetBaseUrl="https://cdn.jsdelivr.net/gh/4site-interactive-studios/engrid@main/reference-materials/html/brand-guide-markup/",this.brandingHtmlFiles=["html5-tags.html","en-common-fields.html","survey.html","donation-page.html","premium-donation.html","ecards.html","email-to-target.html","tweet-to-target.html","petition.html","event.html","styles.html"],this.bodyMain=document.querySelector(".body-main"),this.htmlFetched=!1}fetchHtml(){return qe(this,void 0,void 0,(function*(){const e=this.brandingHtmlFiles.map((e=>qe(this,void 0,void 0,(function*(){return(yield fetch(this.assetBaseUrl+e)).text()}))));return yield Promise.all(e)}))}appendHtml(){this.fetchHtml().then((e=>e.forEach((e=>{var t;const n=document.createElement("div");n.classList.add("brand-guide-section"),n.innerHTML=e,null===(t=this.bodyMain)||void 0===t||t.insertAdjacentElement("beforeend",n)})))),this.htmlFetched=!0}show(){if(!this.htmlFetched)return void this.appendHtml();const e=document.querySelectorAll(".brand-guide-section");null==e||e.forEach((e=>e.style.display="block"))}hide(){const e=document.querySelectorAll(".brand-guide-section");null==e||e.forEach((e=>e.style.display="none"))}}class Ie{constructor(){this.logger=new fe("CountryDisable","#f0f0f0","#333333","🌎");const e=document.querySelectorAll('select[name="supporter.country"], select[name="transaction.shipcountry"], select[name="supporter.billingCountry"], select[name="transaction.infcountry"]'),t=p.getOption("CountryDisable");if(e.length>0&&t.length>0){const n=t.map((e=>e.toLowerCase()));e.forEach((e=>{e.querySelectorAll("option").forEach((t=>{(n.includes(t.value.toLowerCase())||n.includes(t.text.toLowerCase()))&&(this.logger.log(`Removing ${t.text} from ${e.getAttribute("name")}`),t.remove())}))}))}}}class Be{constructor(){this.logger=new fe("PremiumGift","#232323","#f7b500","🎁"),this.enElements=new Array,this.shoudRun()&&(this.searchElements(),this.addEventListeners(),this.checkPremiumGift())}shoudRun(){return"pageJson"in window&&"pageType"in window.pageJson&&"premiumgift"===window.pageJson.pageType}addEventListeners(){["click","change"].forEach((e=>{document.addEventListener(e,(e=>{const t=e.target,n=t.closest(".en__pg__body");if(n){const e=n.querySelector('[name="en__pg"]');if("type"in t==!1){const t=e.value;window.setTimeout((()=>{const e=document.querySelector('[name="en__pg"][value="'+t+'"]');e&&(e.checked=!0,e.dispatchEvent(new Event("change")))}),100)}window.setTimeout((()=>{this.checkPremiumGift()}),110)}}))}));const e=document.querySelector(".en__component--premiumgiftblock");if(e){new MutationObserver((t=>{for(const n of t)"attributes"===n.type&&"style"===n.attributeName&&"none"===e.style.display&&(this.logger.log("Premium Gift Section hidden - removing premium gift body data attributes and premium title."),p.setBodyData("premium-gift-maximize",!1),p.setBodyData("premium-gift-name",!1),this.setPremiumTitle(""))})).observe(e,{attributes:!0})}}checkPremiumGift(){const e=document.querySelector('[name="en__pg"]:checked');if(e){const t=e.value;this.logger.log("Premium Gift Value: "+t);const n=e.closest(".en__pg");if("0"!==t){const e=n.querySelector(".en__pg__name");p.setBodyData("premium-gift-maximize","false"),p.setBodyData("premium-gift-name",p.slugify(e.innerText)),this.setPremiumTitle(e.innerText)}else p.setBodyData("premium-gift-maximize","true"),p.setBodyData("premium-gift-name",!1),this.setPremiumTitle("");if(!n.classList.contains("en__pg--selected")){const e=document.querySelector(".en__pg--selected");e&&e.classList.remove("en__pg--selected"),n.classList.add("en__pg--selected")}}}searchElements(){const e=document.querySelectorAll("\n .en__component--copyblock,\n .en__component--codeblock,\n .en__field\n ");e.length>0&&e.forEach((e=>{e instanceof HTMLElement&&e.innerHTML.includes("{$PREMIUMTITLE}")&&(e.innerHTML=e.innerHTML.replace("{$PREMIUMTITLE}",'<span class="engrid_premium_title"></span>'),this.enElements.push(e))}))}setPremiumTitle(e){this.enElements.forEach((t=>{const n=t.querySelector(".engrid_premium_title");n&&(n.innerHTML=e)}))}}class Re{constructor(){if(!document.getElementById("en__digitalWallet"))return p.setBodyData("payment-type-option-apple-pay","false"),p.setBodyData("payment-type-option-google-pay","false"),p.setBodyData("payment-type-option-paypal-one-touch","false"),p.setBodyData("payment-type-option-venmo","false"),void p.setBodyData("payment-type-option-daf","false");const e=document.getElementById("en__digitalWallet__stripeButtons__container");e&&(e.classList.add("giveBySelect-stripedigitalwallet"),e.classList.add("showif-stripedigitalwallet-selected"));const t=document.getElementById("en__digitalWallet__paypalTouch__container");t&&(t.classList.add("giveBySelect-paypaltouch"),t.classList.add("showif-paypaltouch-selected"));const n=document.getElementById("en__digitalWallet__chariot__container");if(n&&(n.classList.add("giveBySelect-daf"),n.classList.add("showif-daf-selected")),document.querySelector("#en__digitalWallet__stripeButtons__container > *"))this.addStripeDigitalWallets();else{p.setBodyData("payment-type-option-apple-pay","false"),p.setBodyData("payment-type-option-google-pay","false");const e=document.getElementById("en__digitalWallet__stripeButtons__container");e&&this.checkForWalletsBeingAdded(e,"stripe");"stripedigitalwallet"===p.getPaymentType().toLowerCase()&&p.setPaymentType("card")}if(document.querySelector("#en__digitalWallet__paypalTouch__container > *"))this.addPaypalTouchDigitalWallets();else{p.setBodyData("payment-type-option-paypal-one-touch","false"),p.setBodyData("payment-type-option-venmo","false");const e=document.getElementById("en__digitalWallet__paypalTouch__container");e&&this.checkForWalletsBeingAdded(e,"paypalTouch")}if(document.querySelector("#en__digitalWallet__chariot__container > *"))this.addDAF();else{p.setBodyData("payment-type-option-daf","false");const e=document.getElementById("en__digitalWallet__chariot__container");e&&this.checkForWalletsBeingAdded(e,"daf")}}addStripeDigitalWallets(){this.addOptionToPaymentTypeField("stripedigitalwallet","GooglePay / ApplePay"),p.setBodyData("payment-type-option-apple-pay","true"),p.setBodyData("payment-type-option-google-pay","true")}addPaypalTouchDigitalWallets(){this.addOptionToPaymentTypeField("paypaltouch","Paypal / Venmo"),p.setBodyData("payment-type-option-paypal-one-touch","true"),p.setBodyData("payment-type-option-venmo","true")}addDAF(){this.addOptionToPaymentTypeField("daf","Donor Advised Fund"),p.setBodyData("payment-type-option-daf","true")}addOptionToPaymentTypeField(e,t){const n=document.querySelector('[name="transaction.paymenttype"]');if(n&&!n.querySelector(`[value=${e}]`)){const i=document.createElement("option");i.value=e,i.innerText=t,n.appendChild(i)}const i=document.querySelector('input[name="transaction.giveBySelect"][value="'+e+'"]');if(i&&"true"===i.dataset.default){i.checked=!0;const e=new Event("change",{bubbles:!0,cancelable:!0});i.dispatchEvent(e)}}checkForWalletsBeingAdded(e,t){new MutationObserver(((e,n)=>{for(const i of e)"childList"===i.type&&i.addedNodes.length&&("stripe"===t?this.addStripeDigitalWallets():"paypalTouch"===t?this.addPaypalTouchDigitalWallets():"daf"===t&&this.addDAF(),n.disconnect())})).observe(e,{childList:!0,subtree:!0})}}class je{constructor(){var e,t,n;this.options=null!==(e=p.getOption("MobileCTA"))&&void 0!==e&&e,this.buttonLabel="",this.options&&(null===(t=this.options.pages)||void 0===t?void 0:t.includes(p.getPageType()))&&1===p.getPageNumber()&&(this.buttonLabel=null!==(n=this.options.label)&&void 0!==n?n:"Take Action",this.renderButton(),this.addEventListeners())}renderButton(){const e=document.querySelector("#engrid"),t=document.querySelector(".body-main .en__component--widgetblock:first-child, .en__component--formblock");if(!e||!t)return;const n=document.createElement("div"),i=document.createElement("button");n.classList.add("engrid-mobile-cta-container"),n.style.display="none",i.classList.add("primary"),i.innerHTML=this.buttonLabel,i.addEventListener("click",(()=>{t.scrollIntoView({behavior:"smooth"})})),n.appendChild(i),e.appendChild(n)}addEventListeners(){const e=document.querySelector(".body-main");if(!e)return;const t=()=>{e.getBoundingClientRect().top<=window.innerHeight-100?this.hideButton():this.showButton()};window.addEventListener("load",t),window.addEventListener("resize",t),window.addEventListener("scroll",t)}hideButton(){const e=document.querySelector(".engrid-mobile-cta-container");e&&(e.style.display="none")}showButton(){const e=document.querySelector(".engrid-mobile-cta-container");e&&(e.style.display="block")}}class He{constructor(){this.logger=new fe("LiveFrequency","#00ff00","#000000","🧾"),this.elementsFound=!1,this._amount=h.getInstance(),this._frequency=g.getInstance(),this.searchElements(),this.shouldRun()&&(this.updateFrequency(),this.addEventListeners())}searchElements(){const e=document.querySelectorAll("\n .en__component--copyblock,\n .en__component--codeblock,\n .en__field label,\n .en__submit\n ");if(e.length>0){const t=/\[\[(frequency)\]\]/gi;let n=0;e.forEach((e=>{const i=e.innerHTML.match(t);e instanceof HTMLElement&&i&&(this.elementsFound=!0,i.forEach((t=>{n++,this.replaceMergeTags(t,e)})))})),n>0&&this.logger.log(`Found ${n} merge tag${n>1?"s":""} in the page.`)}}shouldRun(){return!!this.elementsFound||(this.logger.log("No merge tags found. Skipping."),!1)}addEventListeners(){this._amount.onAmountChange.subscribe((()=>{setTimeout((()=>{this.updateFrequency()}),10)})),this._frequency.onFrequencyChange.subscribe((()=>{setTimeout((()=>{this.searchElements(),this.updateFrequency()}),10)}))}updateFrequency(){const e="onetime"===this._frequency.frequency?"one-time":this._frequency.frequency;document.querySelectorAll(".engrid-frequency").forEach((t=>{t.classList.contains("engrid-frequency--lowercase")?t.innerHTML=e.toLowerCase():t.classList.contains("engrid-frequency--capitalized")?t.innerHTML=e.charAt(0).toUpperCase()+e.slice(1):t.classList.contains("engrid-frequency--uppercase")?t.innerHTML=e.toUpperCase():t.innerHTML=e}))}replaceMergeTags(e,t){const n="onetime"===this._frequency.frequency?"one-time":this._frequency.frequency,i=document.createElement("span");switch(i.classList.add("engrid-frequency"),i.innerHTML=n,e){case"[[frequency]]":i.classList.add("engrid-frequency--lowercase"),i.innerHTML=i.innerHTML.toLowerCase(),t.innerHTML=t.innerHTML.replace(e,i.outerHTML);break;case"[[Frequency]]":i.classList.add("engrid-frequency--capitalized"),i.innerHTML=i.innerHTML.charAt(0).toUpperCase()+i.innerHTML.slice(1),t.innerHTML=t.innerHTML.replace(e,i.outerHTML);break;case"[[FREQUENCY]]":i.classList.add("engrid-frequency--uppercase"),i.innerHTML=i.innerHTML.toUpperCase(),t.innerHTML=t.innerHTML.replace(e,i.outerHTML)}}}class Ue{constructor(){this.logger=new fe("UniversalOptIn","#f0f0f0","#d2691e","🪞"),this._elements=document.querySelectorAll(".universal-opt-in, .universal-opt-in_null"),this.shouldRun()&&this.addEventListeners()}shouldRun(){return 0===this._elements.length?(this.logger.log("No universal opt-in elements found. Skipping."),!1):(this.logger.log(`Found ${this._elements.length} universal opt-in elements.`),!0)}addEventListeners(){this._elements.forEach((e=>{const t=e.querySelectorAll(".en__field__input--radio, .en__field__input--checkbox");t.length>0&&t.forEach((n=>{n.addEventListener("click",(()=>{if(n instanceof HTMLInputElement&&"checkbox"===n.getAttribute("type")){return void(n.checked?(this.logger.log("Yes/No "+n.getAttribute("type")+" is checked"),t.forEach((e=>{n!==e&&e instanceof HTMLInputElement&&"checkbox"===e.getAttribute("type")&&(e.checked=!0)}))):(this.logger.log("Yes/No "+n.getAttribute("type")+" is unchecked"),t.forEach((e=>{n!==e&&e instanceof HTMLInputElement&&"checkbox"===e.getAttribute("type")&&(e.checked=!1)}))))}"Y"===n.getAttribute("value")?(this.logger.log("Yes/No "+n.getAttribute("type")+" is checked"),t.forEach((e=>{const t=e.getAttribute("name"),i=n.getAttribute("name");t&&t!==i&&p.setFieldValue(t,"Y")}))):(this.logger.log("Yes/No "+n.getAttribute("type")+" is unchecked"),t.forEach((t=>{const i=t.getAttribute("name"),s=n.getAttribute("name");i&&i!==s&&(e.classList.contains("universal-opt-in")?p.setFieldValue(i,"N"):t.checked=!1)})))}))}))}))}}class Ve{constructor(){this.logger=new fe("Plaid","peru","yellow","🔗"),this._form=u.getInstance(),this.logger.log("Enabled"),this._form.onSubmit.subscribe((()=>this.submit()))}submit(){const e=document.querySelector("#plaid-link-button");if(e&&"Link Account"===e.textContent){this.logger.log("Clicking Link"),e.click(),this._form.submit=!1;new MutationObserver((e=>{e.forEach((e=>{"childList"===e.type&&e.addedNodes.forEach((e=>{e.nodeType===Node.TEXT_NODE&&("Account Linked"===e.nodeValue?(this.logger.log("Plaid Linked"),this._form.submit=!0,this._form.submitForm()):this._form.submit=!0)}))}))})).observe(e,{childList:!0,subtree:!0}),window.setTimeout((()=>{this.logger.log("Enabling Submit"),p.enableSubmit()}),1e3)}}}class $e{constructor(){if(this.logger=new fe("GiveBySelect","#FFF","#333","🐇"),this.transactionGiveBySelect=document.getElementsByName("transaction.giveBySelect"),this._frequency=g.getInstance(),!this.transactionGiveBySelect)return;this._frequency.onFrequencyChange.subscribe((()=>this.checkPaymentTypeVisibility())),this.transactionGiveBySelect.forEach((e=>{e.addEventListener("change",(()=>{this.logger.log("Changed to "+e.value),p.setPaymentType(e.value)}))}));const e=p.getPaymentType();if(e){this.logger.log("Setting giveBySelect to "+e);const t=["card","visa","mastercard","amex","discover","diners","jcb","vi","mc","ax","dc","di","jc"].includes(e.toLowerCase());this.transactionGiveBySelect.forEach((n=>{(t&&"card"===n.value.toLowerCase()||n.value.toLowerCase()===e.toLowerCase())&&(n.checked=!0)}))}}isSelectedPaymentVisible(){let e=!0;return this.transactionGiveBySelect.forEach((t=>{const n=t.parentElement;t.checked&&!p.isVisible(n)&&(this.logger.log(`Selected Payment Type is not visible: ${t.value}`),e=!1)})),e}checkPaymentTypeVisibility(){window.setTimeout((()=>{var e;if(this.isSelectedPaymentVisible())this.logger.log("Selected Payment Type is visible");else{this.logger.log("Setting payment type to first visible option");const t=Array.from(this.transactionGiveBySelect).find((e=>{const t=e.parentElement;return p.isVisible(t)}));if(t){this.logger.log("Setting payment type to ",t.value);null===(e=t.parentElement.querySelector("label"))||void 0===e||e.click(),p.setPaymentType(t.value)}}}),300)}}class We{constructor(){this.logger=new fe("UrlParamsToBodyAttrs","white","magenta","📌"),this.urlParams=new URLSearchParams(document.location.search),this.urlParams.forEach(((e,t)=>{t.startsWith("data-engrid-")&&(p.setBodyData(t.split("data-engrid-")[1],e),this.logger.log(`Set "${t}" on body to "${e}" from URL params`))}))}}class Ge{constructor(){this.opened=!1,this.dataLayer=window.dataLayer||[],this.logger=new fe("ExitIntentLightbox","yellow","black","🚪"),this.triggerDelay=1e3,this.triggerTimeout=null;let e="EngridExitIntent"in window?window.EngridExitIntent:{};if(this.options=Object.assign(Object.assign({},l),e),!this.options.enabled)return void this.logger.log("Not enabled");if(te(this.options.cookieName))return void this.logger.log("Not showing - cookie found.");const t=Object.keys(this.options.triggers).filter((e=>this.options.triggers[e])).join(", ");this.logger.log("Enabled, waiting for trigger. Active triggers: "+t),this.watchForTriggers()}watchForTriggers(){window.addEventListener("load",(()=>{setTimeout((()=>{this.options.triggers.mousePosition&&this.watchMouse(),this.options.triggers.visibilityState&&this.watchDocumentVisibility()}),this.triggerDelay)}))}watchMouse(){document.addEventListener("mouseout",(e=>{if("input"==e.target.tagName.toLowerCase())return;const t=Math.max(document.documentElement.clientWidth,window.innerWidth||0);if(e.clientX>=t-50)return;if(e.clientY>=50)return;const n=e.relatedTarget;n||(this.logger.log("Triggered by mouse position"),this.open()),this.triggerTimeout||(this.triggerTimeout=window.setTimeout((()=>{n||(this.logger.log("Triggered by mouse position"),this.open()),this.triggerTimeout=null}),this.triggerDelay))}))}watchDocumentVisibility(){const e=()=>{"hidden"===document.visibilityState&&(this.triggerTimeout||(this.triggerTimeout=window.setTimeout((()=>{this.logger.log("Triggered by visibilityState is hidden"),this.open(),document.removeEventListener("visibilitychange",e),this.triggerTimeout=null}),this.triggerDelay)))};document.addEventListener("visibilitychange",e)}open(){var e,t,n;this.opened||(p.setBodyData("exit-intent-lightbox","open"),ne(this.options.cookieName,"1",{expires:this.options.cookieDuration}),document.body.insertAdjacentHTML("beforeend",`\n <div class="ExitIntent">\n <div class="ExitIntent__overlay">\n <div class="ExitIntent__container">\n <div class="ExitIntent__close">X</div>\n <div class="ExitIntent__body">\n <h2>${this.options.title}</h2>\n <p>${this.options.text}</p>\n <button type="button" class="ExitIntent__button">\n ${this.options.buttonText}\n </button>\n </div>\n </div>\n </div>\n </div>\n `),this.opened=!0,this.dataLayer.push({event:"exit_intent_lightbox_shown"}),null===(e=document.querySelector(".ExitIntent__close"))||void 0===e||e.addEventListener("click",(()=>{this.dataLayer.push({event:"exit_intent_lightbox_closed"}),this.close()})),null===(t=document.querySelector(".ExitIntent__overlay"))||void 0===t||t.addEventListener("click",(e=>{e.target===e.currentTarget&&(this.dataLayer.push({event:"exit_intent_lightbox_closed"}),this.close())})),null===(n=document.querySelector(".ExitIntent__button"))||void 0===n||n.addEventListener("click",(()=>{this.dataLayer.push({event:"exit_intent_lightbox_cta_clicked"}),this.close();const e=this.options.buttonLink;if(e.startsWith(".")||e.startsWith("#")){const t=document.querySelector(e);t&&t.scrollIntoView({behavior:"smooth"})}else window.open(e,"_blank")})))}close(){var e;null===(e=document.querySelector(".ExitIntent"))||void 0===e||e.remove(),p.setBodyData("exit-intent-lightbox","closed")}}class Ye{constructor(){this.logger=new fe("SupporterHub","black","pink","🛖"),this._form=u.getInstance(),this.shoudRun()&&(this.logger.log("Enabled"),this.watch())}shoudRun(){return"pageJson"in window&&"pageType"in window.pageJson&&"supporterhub"===window.pageJson.pageType}watch(){const e=p.enForm;new MutationObserver((e=>{e.forEach((e=>{"childList"===e.type&&e.addedNodes.forEach((e=>{if("DIV"===e.nodeName){const t=e;(t.classList.contains("en__hubOverlay")||t.classList.contains("en__hubPledge__panels"))&&(this.logger.log("Overlay found"),this.creditCardUpdate(e),this.amountLabelUpdate(e))}}))}))})).observe(e,{childList:!0,subtree:!0});const t=document.querySelector(".en__hubOverlay");t&&(this.creditCardUpdate(t),this.amountLabelUpdate(t))}creditCardUpdate(e){window.setTimeout((()=>{const t=e.querySelector("#en__hubPledge__field--ccnumber"),n=e.querySelector(".en__hubUpdateCC__toggle");t&&n&&t.addEventListener("focus",(()=>{this.logger.log("Credit Card field focused"),n.click()}))}),300)}amountLabelUpdate(e){window.setTimeout((()=>{const t=e.querySelector(".en__field--donationAmt");t&&t.querySelectorAll(".en__field__element--radio .en__field__item").forEach((e=>{e.setAttribute("data-engrid-currency-symbol-updated","true")}))}),300)}}class Je{constructor(){this.logger=new fe("FastFormFill","white","magenta","📌"),this.rememberMeEvents=f.getInstance(),p.getOption("RememberMe")?(this.rememberMeEvents.onLoad.subscribe((e=>{this.logger.log("Remember me - onLoad",e),this.run()})),this.rememberMeEvents.onClear.subscribe((()=>{this.logger.log("Remember me - onClear")}))):this.run()}run(){const e=document.querySelectorAll(".en__component--formblock.fast-personal-details");e.length>0&&([...e].every((e=>Je.allMandatoryInputsAreFilled(e)))?(this.logger.log("Personal details - All mandatory inputs are filled"),p.setBodyData("hide-fast-personal-details","true")):(this.logger.log("Personal details - Not all mandatory inputs are filled"),p.setBodyData("hide-fast-personal-details","false")));const t=document.querySelectorAll(".en__component--formblock.fast-address-details");t.length>0&&([...t].every((e=>Je.allMandatoryInputsAreFilled(e)))?(this.logger.log("Address details - All mandatory inputs are filled"),p.setBodyData("hide-fast-address-details","true")):(this.logger.log("Address details - Not all mandatory inputs are filled"),p.setBodyData("hide-fast-address-details","false")))}static allMandatoryInputsAreFilled(e){return[...e.querySelectorAll(".en__mandatory input, .en__mandatory select, .en__mandatory textarea")].every((e=>{if("radio"===e.type||"checkbox"===e.type){return[...document.querySelectorAll('[name="'+e.name+'"]')].some((e=>e.checked))}return null!==e.value&&""!==e.value.trim()}))}static someMandatoryInputsAreFilled(e){return[...e.querySelectorAll(".en__mandatory input, .en__mandatory select, .en__mandatory textarea")].some((e=>{if("radio"===e.type||"checkbox"===e.type){return[...document.querySelectorAll('[name="'+e.name+'"]')].some((e=>e.checked))}return null!==e.value&&""!==e.value.trim()}))}}class ze{constructor(){this.logger=new fe("SetAttr","black","yellow","📌");const e=document.getElementById("engrid");e&&e.addEventListener("click",(e=>{const t=e.target;if("string"!=typeof t.className)return;t.className.split(" ").some((e=>e.startsWith("setattr--")))&&t.classList.forEach((e=>{const t=e.match(/^setattr--(.+)--(.+)$/i);t&&t[1]&&t[2]&&(this.logger.log(`Clicked element with class "${e}". Setting body attribute "${t[1]}" to "${t[2]}"`),p.setBodyData(t[1].replace("data-engrid-",""),t[2]))}))}))}}class Ke{constructor(){this.logger=new fe("ShowIfPresent","yellow","black","👀"),this.elements=[],this.shouldRun()&&this.run()}shouldRun(){return this.elements=[...document.querySelectorAll('[class*="engrid__supporterquestions"]')].filter((e=>e.className.split(" ").some((e=>/^engrid__supporterquestions\d+(__supporterquestions\d+)*-(present|absent)$/.test(e))))),this.elements.length>0}run(){const e=[];this.elements.forEach((t=>{const n=t.className.split(" ").find((e=>/^engrid__supporterquestions\d+(__supporterquestions\d+)*-(present|absent)$/.test(e)));if(!n)return null;const i=n.lastIndexOf("-"),s=n.substring(i+1),o=n.substring(8,i).split("__").map((e=>`supporter.questions.${e.substring(18)}`));e.push({class:n,fieldNames:o,type:s})})),e.forEach((e=>{const t=e.fieldNames.map((e=>document.getElementsByName(e)[0])),n=document.querySelectorAll(`.${e.class}`),i=t.every((e=>!!e)),s=t.every((e=>!e));("present"===e.type&&s||"absent"===e.type&&i)&&(this.logger.log(`Conditions not met, hiding elements with class ${e.class}`),n.forEach((e=>{e.style.display="none"})))}))}}class Xe{constructor(){this._form=u.getInstance(),this._enElements=null,this.logger=new fe("ENValidators","white","darkolivegreen","🧐"),this.loadValidators()?this.shouldRun()?this._form.onValidate.subscribe(this.enOnValidate.bind(this)):this.logger.log("Not Needed"):this.logger.error("Not Loaded")}loadValidators(){if(!p.checkNested(window.EngagingNetworks,"require","_defined","enValidation","validation","validators"))return!1;const e=window.EngagingNetworks.require._defined.enValidation.validation.validators;return this._enElements=e.reduce(((e,t)=>{if("type"in t&&"CUST"===t.type){const n=document.querySelector(".en__field--"+t.field),i=n?n.querySelector("input, select, textarea"):null;i&&(i.addEventListener("input",this.liveValidate.bind(this,n,i,t.regex,t.message)),e.push({container:n,field:i,regex:t.regex,message:t.message}))}return e}),[]),!0}shouldRun(){return p.getOption("ENValidators")&&this._enElements&&this._enElements.length>0}enOnValidate(){this._enElements&&!1!==this._form.validate&&(this._enElements.forEach((e=>{if(!this.liveValidate(e.container,e.field,e.regex,e.message))return this._form.validate=!1,void e.field.focus()})),this._form.validate=!0)}liveValidate(e,t,n,i){const s=p.getFieldValue(t.getAttribute("name")||"");return""===s||(this.logger.log(`Live Validate ${t.getAttribute("name")} with ${n}`),s.match(n)?(p.removeError(e),!0):(p.setError(e,i),!1))}}class Qe{constructor(){var e,t;this.postalCodeField=p.getField("supporter.postcode"),this._form=u.getInstance(),this.logger=new fe("Postal Code Validator","white","red","📬"),this.supportedSeparators=["+","-"," "],this.separator=this.getSeparator(),this.regexSeparator=this.getRegexSeparator(this.separator),this.shouldRun()&&(null===(e=this.postalCodeField)||void 0===e||e.addEventListener("blur",(()=>this.validate())),null===(t=this.postalCodeField)||void 0===t||t.addEventListener("input",(()=>this.liveValidate())),this._form.onValidate.subscribe((()=>{if(!this._form.validate)return;this.liveValidate(),setTimeout((()=>{this.validate()}),100);const e=!this.shouldValidateUSZipCode()||this.isValidUSZipCode();return this._form.validate=e,e||(this.logger.log(`Invalid Zip Code ${this.postalCodeField.value}`),this.postalCodeField.scrollIntoView({behavior:"smooth"})),e})))}shouldRun(){return!(!p.getOption("PostalCodeValidator")||!this.postalCodeField)}validate(){this.shouldValidateUSZipCode()&&!this.isValidUSZipCode()?p.setError(".en__field--postcode",`Please enter a valid ZIP Code of ##### or #####${this.separator}####`):p.removeError(".en__field--postcode")}isValidUSZipCode(){var e,t;if(!!!document.querySelector(".en__field--postcode.en__mandatory")&&""===(null===(e=this.postalCodeField)||void 0===e?void 0:e.value))return!0;const n=new RegExp(`^\\d{5}(${this.regexSeparator}\\d{4})?$`);return!!(null===(t=this.postalCodeField)||void 0===t?void 0:t.value.match(n))}liveValidate(){var e;if(!this.shouldValidateUSZipCode())return;let t=null===(e=this.postalCodeField)||void 0===e?void 0:e.value;t.length<=5?t=t.replace(/\D/g,""):6===t.length&&this.supportedSeparators.includes(t[5])?t=t.replace(/\D/g,"")+this.separator:(t=t.replace(/\D/g,""),t=t.replace(/(\d{5})(\d)/,`$1${this.separator}$2`)),this.postalCodeField.value=t.slice(0,10)}shouldValidateUSZipCode(){const e=p.getField("supporter.country")?p.getFieldValue("supporter.country"):"US";return["us","united states","usa",""].includes(e.toLowerCase())}getSeparator(){const e=p.getOption("TidyContact");return e&&e.us_zip_divider&&this.supportedSeparators.includes(e.us_zip_divider)?e.us_zip_divider:"-"}getRegexSeparator(e){switch(e){case"+":return"\\+";case"-":return"-";case" ":return"\\s";default:return this.logger.log(`Invalid separator "${e}" provided to PostalCodeValidator, falling back to "-".`),"-"}}}class Ze{constructor(){if(this.logger=new fe("VGS","black","pink","💳"),this.vgsField=document.querySelector(".en__field--vgs"),this.options=p.getOption("VGS"),this.paymentTypeField=document.querySelector("#en__field_transaction_paymenttype"),this._form=u.getInstance(),this.field_expiration_month=null,this.field_expiration_year=null,this.handleExpUpdate=e=>{if(!this.field_expiration_month||!this.field_expiration_year)return;const t=new Date,n=t.getMonth()+1,i=parseInt(this.field_expiration_year[this.field_expiration_year.length-1].value)>2e3?t.getFullYear():t.getFullYear()-2e3;if("month"==e){let e=parseInt(this.field_expiration_month.value),t=e<n;this.logger.log(`month disable ${t}`),this.logger.log(`selected_month ${e}`);for(let e=0;e<this.field_expiration_year.options.length;e++)parseInt(this.field_expiration_year.options[e].value)<=i&&(t?this.field_expiration_year.options[e].setAttribute("disabled","disabled"):this.field_expiration_year.options[e].disabled=!1)}else if("year"==e){let e=parseInt(this.field_expiration_year.value),t=e==i;this.logger.log(`year disable ${t}`),this.logger.log(`selected_year ${e}`);for(let e=0;e<this.field_expiration_month.options.length;e++)parseInt(this.field_expiration_month.options[e].value)<n&&(t?this.field_expiration_month.options[e].setAttribute("disabled","disabled"):this.field_expiration_month.options[e].disabled=!1)}},!this.shouldRun())return;this.setPaymentType(),this.setDefaults(),this.dumpGlobalVar();const e=document.getElementsByName("transaction.ccexpire");e&&(this.field_expiration_month=e[0],this.field_expiration_year=e[1]),this.field_expiration_month&&this.field_expiration_year&&["change"].forEach((e=>{var t,n;null===(t=this.field_expiration_month)||void 0===t||t.addEventListener(e,(()=>{this.handleExpUpdate("month")})),null===(n=this.field_expiration_year)||void 0===n||n.addEventListener(e,(()=>{this.handleExpUpdate("year")}))})),this._form.onValidate.subscribe((()=>{if(this._form.validate){const e=this.validate();this.logger.log(`Form Validation: ${e}`),this._form.validate=e}}))}shouldRun(){return!!this.vgsField}setDefaults(){const e=getComputedStyle(document.body),t={fontFamily:e.getPropertyValue("--input_font-family")||"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'",fontSize:e.getPropertyValue("--input_font-size")||"16px",color:e.getPropertyValue("--input_color")||"#000",padding:e.getPropertyValue("--input_padding")||"10px","&::placeholder":{color:e.getPropertyValue("--input_placeholder-color")||"#a9a9a9",opacity:e.getPropertyValue("--input_placeholder-opacity")||"1",fontWeight:e.getPropertyValue("--input_placeholder-font-weight")||"normal"}},n=this.options,i={"transaction.ccnumber":{showCardIcon:!0,placeholder:"•••• •••• •••• ••••",icons:{cardPlaceholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEwAAABMCAYAAADHl1ErAAAACXBIWXMAABYlAAAWJQFJUiTwAAAB8ElEQVR4nO2c4W3CMBBGz1H/NyNkAzoCo2SDrkI3YJSOABt0g9IJXBnOqUkMyifUqkrek04RlvMjT2c7sc6EGKPBfBpcaSBMBGEiCBNBmAjCRBAmgjARhIkgTARhIggTQZhK2q0Yh5l1ZrYzs0PqsrI4+LN3VTeThkvntUm6Fbuxn2E/LITQmtm7mW08Sb/MbO9tpxhjui6WEMLWzJKDdO3N7Nmf9ZjaYoyn8y8X1o6GXxLV1lJyDeE+9oWPQ/ZRG4b9WkVVpqe+8LLLo7ErM6t248qllZnWBc+uV5+zumGsQjm3f/ic9tb4JGeeXcga4U723rptilVx0avgg2Q3m/JNn+y6zeAm+GSWUi/c7L5yfB77RJhACOHs6WnuLfmGpTI3YditEEGYCMJEECaCMJHZqySvHRfIMBGEiSBMBGEiCBNBmAjCRBAmgjARhIkgTGT2t+R/59EdYXZcfwmEiSBMBGEiCBNZzCr5VzvCZJjIIMxrPKFC6abMsHbaFcZuGq8StqKwDqZkN8emKBbrvawHCtxJ7y1nVxQF34lxUXBupOy8EtWy88jBhknUDjbkPhyd+Xn2l9lHZ8rgcNZVTA5nTYRFjv/dPf7HvzuJ8C0pgjARhIkgTARhIggTQZgIwkQQJoIwEYSJIEwEYQpm9g2Ro5zhLcuLBwAAAABJRU5ErkJggg=="},css:t,autoComplete:"cc-number",validations:["required","validCardNumber"]},"transaction.ccvv":{showCardIcon:!1,placeholder:"CVV",hideValue:!1,autoComplete:"cc-csc",validations:["required","validCardSecurityCode"],css:t},"transaction.ccexpire":{placeholder:"MM/YY",autoComplete:"cc-exp",validations:["required","validCardExpirationDate"],css:t,yearLength:2}};this.options=p.deepMerge(i,n),this.logger.log("Options",this.options)}setPaymentType(){""===p.getPaymentType()&&p.setPaymentType("card")}dumpGlobalVar(){window.enVGSFields=this.options,window.setTimeout((()=>{const e=document.querySelectorAll(".en__field__input--vgs");if(e.length>0){const t=new MutationObserver((e=>{e.forEach((e=>{var t;if("childList"===e.type&&e.addedNodes.length>0&&e.addedNodes.forEach((t=>{"IFRAME"===t.nodeName&&e.previousSibling&&"IFRAME"===e.previousSibling.nodeName&&e.previousSibling.remove()})),"attributes"===e.type&&"class"===e.attributeName){const n=e.target;if(n.classList.contains("vgs-collect-container__valid")){const e=n.closest(".en__field--vgs");null==e||e.classList.remove("en__field--validationFailed"),null===(t=null==e?void 0:e.querySelector(".en__field__error"))||void 0===t||t.remove()}}}))}));e.forEach((e=>{t.observe(e,{childList:!0,attributeFilter:["class"]})})),p.checkNested(window.EngagingNetworks,"require","_defined","enjs","vgs")?window.EngagingNetworks.require._defined.enjs.vgs.init():this.logger.log("VGS is not defined")}}),1e3)}validate(){if("card"===this.paymentTypeField.value.toLowerCase()||"visa"===this.paymentTypeField.value.toLowerCase()||"vi"===this.paymentTypeField.value.toLowerCase()){const e=document.querySelector(".en__field--vgs.en__field--ccnumber"),t=e.querySelector(".vgs-collect-container__empty"),n=document.querySelector(".en__field--vgs.en__field--ccvv"),i=n.querySelector(".vgs-collect-container__empty");if(e&&t)return window.setTimeout((()=>{p.setError(e,"Please enter a valid card number"),e.scrollIntoView({behavior:"smooth"})}),100),!1;if(n&&i)return window.setTimeout((()=>{p.setError(n,"Please enter a valid CVV"),n.scrollIntoView({behavior:"smooth"})}),100),!1}return!0}}class et{constructor(){this.logger=new fe("CountryRedirect","white","brown","🛫"),this._country=b.getInstance(),this.shouldRun()&&(this._country.onCountryChange.subscribe((e=>{this.checkRedirect(e)})),this.checkRedirect(this._country.country))}shouldRun(){return!(!p.getOption("CountryRedirect")||!this._country.countryField)}checkRedirect(e){const t=p.getOption("CountryRedirect");if(t&&e in t&&!1===window.location.href.includes(t[e])){this.logger.log(`${e}: Redirecting to ${t[e]}`);let n=new URL(t[e]);n.search.includes("chain")||(n.search+=(n.search?"&":"?")+"chain"),window.location.href=n.href}}}class tt{constructor(){var e;this.supporterDetails={},this.options=null!==(e=p.getOption("WelcomeBack"))&&void 0!==e&&e,this.rememberMeEvents=f.getInstance(),this.hasRun=!1,this.shouldRun()&&(p.getOption("RememberMe")?(this.rememberMeEvents.onLoad.subscribe((()=>{this.run()})),this.rememberMeEvents.onClear.subscribe((()=>{this.resetWelcomeBack()}))):this.run())}run(){this.hasRun||(this.hasRun=!0,this.supporterDetails={firstName:p.getFieldValue("supporter.firstName"),lastName:p.getFieldValue("supporter.lastName"),emailAddress:p.getFieldValue("supporter.emailAddress"),address1:p.getFieldValue("supporter.address1"),address2:p.getFieldValue("supporter.address2"),city:p.getFieldValue("supporter.city"),region:p.getFieldValue("supporter.region"),postcode:p.getFieldValue("supporter.postcode"),country:p.getFieldValue("supporter.country")},this.addWelcomeBack(),this.addPersonalDetailsSummary(),this.addEventListeners())}shouldRun(){return!!document.querySelector(".fast-personal-details")&&"thank-you-page-donation"!==p.getBodyData("embedded")&&!1!==this.options}addWelcomeBack(){var e;if("object"!=typeof this.options||!this.options.welcomeBackMessage.display)return;const t=this.options.welcomeBackMessage,n=document.createElement("div");n.classList.add("engrid-welcome-back","showif-fast-personal-details");const i=t.title.replace("{firstName}",this.supporterDetails.firstName);n.innerHTML=`<p>\n ${i}\n <span class="engrid-reset-welcome-back">${t.editText}</span>\n </p>`,null===(e=document.querySelector(t.anchor))||void 0===e||e.insertAdjacentElement(t.placement,n)}resetWelcomeBack(){var e;document.querySelectorAll(".fast-personal-details .en__field__input").forEach((e=>{"checkbox"===e.type||"radio"===e.type?e.checked=!1:e.value=""})),this.supporterDetails={},p.setBodyData("hide-fast-personal-details",!1),ne("engrid-autofill","",Object.assign(Object.assign({},e),{expires:-1}))}addPersonalDetailsSummary(){var e;if("object"!=typeof this.options||!this.options.personalDetailsSummary.display)return;let t=this.options.personalDetailsSummary;const n=document.createElement("div");n.classList.add("engrid-personal-details-summary","showif-fast-personal-details"),n.innerHTML=`<h3>${t.title}</h3>`,n.insertAdjacentHTML("beforeend",`\n <p>\n ${this.supporterDetails.firstName} ${this.supporterDetails.lastName}\n <br>\n ${this.supporterDetails.emailAddress}\n </p>\n `),this.supporterDetails.address1&&this.supporterDetails.city&&this.supporterDetails.region&&this.supporterDetails.postcode&&n.insertAdjacentHTML("beforeend",`\n <p>\n ${this.supporterDetails.address1} ${this.supporterDetails.address2}\n <br>\n ${this.supporterDetails.city}, ${this.supporterDetails.region} \n ${this.supporterDetails.postcode}\n </p>\n `),n.insertAdjacentHTML("beforeend",`\n <p class="engrid-welcome-back-clear setattr--data-engrid-hide-fast-personal-details--false">${t.editText}<svg viewbox="0 0 528.899 528.899" xmlns="http://www.w3.org/2000/svg"> <g> <path d="M328.883,89.125l107.59,107.589l-272.34,272.34L56.604,361.465L328.883,89.125z M518.113,63.177l-47.981-47.981 c-18.543-18.543-48.653-18.543-67.259,0l-45.961,45.961l107.59,107.59l53.611-53.611 C532.495,100.753,532.495,77.559,518.113,63.177z M0.3,512.69c-1.958,8.812,5.998,16.708,14.811,14.565l119.891-29.069 L27.473,390.597L0.3,512.69z"></path></g></svg></p>\n `),null===(e=document.querySelector(t.anchor))||void 0===e||e.insertAdjacentElement(t.placement,n)}addEventListeners(){document.querySelectorAll(".engrid-reset-welcome-back").forEach((e=>{e.addEventListener("click",(()=>{this.resetWelcomeBack()}))}))}}const nt={targetName:"",targetEmail:"",hideSendDate:!0,hideTarget:!0,hideMessage:!0,addSupporterNameToMessage:!1};class it{constructor(){this.options=nt,this.logger=new fe("EcardToTarget","DarkBlue","Azure","📧"),this._form=u.getInstance(),this.supporterNameAddedToMessage=!1,this.shouldRun()&&(this.options=Object.assign(Object.assign({},this.options),window.EngridEcardToTarget),this.logger.log("EcardToTarget running. Options:",this.options),this.setTarget(),this.hideElements(),this.addSupporterNameToMessage())}shouldRun(){return window.hasOwnProperty("EngridEcardToTarget")&&"object"==typeof window.EngridEcardToTarget&&window.EngridEcardToTarget.hasOwnProperty("targetName")&&window.EngridEcardToTarget.hasOwnProperty("targetEmail")}setTarget(){const e=document.querySelector(".en__ecardrecipients__name input"),t=document.querySelector(".en__ecardrecipients__email input"),n=document.querySelector(".en__ecarditems__addrecipient");e&&t&&n?(e.value=this.options.targetName,t.value=this.options.targetEmail,null==n||n.click(),this.logger.log("Added recipient",this.options.targetName,this.options.targetEmail)):this.logger.error("Could not add recipient. Required elements not found.")}hideElements(){const e=document.querySelector(".en__ecardmessage"),t=document.querySelector(".en__ecardrecipients__futureDelivery"),n=document.querySelector(".en__ecardrecipients");this.options.hideMessage&&e&&e.classList.add("hide"),this.options.hideSendDate&&t&&t.classList.add("hide"),this.options.hideTarget&&n&&n.classList.add("hide")}addSupporterNameToMessage(){this.options.addSupporterNameToMessage&&this._form.onSubmit.subscribe((()=>{if(this._form.submit&&!this.supporterNameAddedToMessage){this.supporterNameAddedToMessage=!0;const e=`${p.getFieldValue("supporter.firstName")} ${p.getFieldValue("supporter.lastName")}`,t=document.querySelector("[name='transaction.comments']");if(!t)return;t.value=`${t.value}\n${e}`,this.logger.log("Added supporter name to personalized message",e)}}))}}const st={pageUrl:"",headerText:"Send an Ecard notification of your gift",checkboxText:"Yes, I would like to send an ecard to announce my gift.",anchor:".en__field--donationAmt",placement:"afterend"};class ot{constructor(){if(this.logger=new fe("Embedded Ecard","#D95D39","#0E1428","📧"),this.options=st,this._form=u.getInstance(),this.isSubmitting=!1,this.onHostPage()){!(!p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")||!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed())||(sessionStorage.removeItem("engrid-embedded-ecard"),sessionStorage.removeItem("engrid-send-embedded-ecard")),this.options=Object.assign(Object.assign({},st),window.EngridEmbeddedEcard);const e=new URL(this.options.pageUrl);e.searchParams.append("data-engrid-embedded-ecard","true"),this.options.pageUrl=e.href,this.logger.log("Running Embedded Ecard component",this.options),this.embedEcard(),this.addEventListeners()}this.onPostActionPage()&&(p.setBodyData("embedded-ecard-sent","true"),this.submitEcard()),this.onEmbeddedEcardPage()&&this.setupEmbeddedPage()}onHostPage(){return window.hasOwnProperty("EngridEmbeddedEcard")&&"object"==typeof window.EngridEmbeddedEcard&&window.EngridEmbeddedEcard.hasOwnProperty("pageUrl")&&""!==window.EngridEmbeddedEcard.pageUrl}onEmbeddedEcardPage(){return"ECARD"===p.getPageType()&&p.hasBodyData("embedded")}onPostActionPage(){return null!==sessionStorage.getItem("engrid-embedded-ecard")&&null!==sessionStorage.getItem("engrid-send-embedded-ecard")&&!this.onHostPage()&&!this.onEmbeddedEcardPage()}embedEcard(){var e;const t=document.createElement("div");t.classList.add("engrid--embedded-ecard");const n=document.createElement("h3");n.textContent=this.options.headerText,n.classList.add("engrid--embedded-ecard-heading"),t.appendChild(n);const i=document.createElement("div");i.classList.add("pseudo-en-field","en__field","en__field--checkbox","en__field--000000","en__field--embedded-ecard"),i.innerHTML=`\n <div class="en__field__element en__field__element--checkbox">\n <div class="en__field__item">\n <input class="en__field__input en__field__input--checkbox" id="en__field_embedded-ecard" name="engrid.embedded-ecard" type="checkbox" value="Y">\n <label class="en__field__label en__field__label--item" for="en__field_embedded-ecard">${this.options.checkboxText}</label>\n </div>\n </div>`,t.appendChild(i),t.appendChild(this.createIframe(this.options.pageUrl)),null===(e=document.querySelector(this.options.anchor))||void 0===e||e.insertAdjacentElement(this.options.placement,t)}createIframe(e){const t=document.createElement("iframe");return t.src=e,t.setAttribute("src",e),t.setAttribute("width","100%"),t.setAttribute("scrolling","no"),t.setAttribute("frameborder","0"),t.classList.add("engrid-iframe","engrid-iframe--embedded-ecard"),t.style.display="none",t}addEventListeners(){const e=document.querySelector(".engrid-iframe--embedded-ecard"),t=document.getElementById("en__field_embedded-ecard");(null==t?void 0:t.checked)?(null==e||e.setAttribute("style","display: block"),sessionStorage.setItem("engrid-send-embedded-ecard","true")):(null==e||e.setAttribute("style","display: none"),sessionStorage.removeItem("engrid-send-embedded-ecard")),null==t||t.addEventListener("change",(t=>{const n=t.target;(null==n?void 0:n.checked)?(null==e||e.setAttribute("style","display: block"),sessionStorage.setItem("engrid-send-embedded-ecard","true")):(null==e||e.setAttribute("style","display: none"),sessionStorage.removeItem("engrid-send-embedded-ecard"))}))}setEmbeddedEcardSessionData(){let e=document.querySelector("[name='friend.ecard']"),t=document.querySelector("[name='ecard.schedule']"),n=document.querySelector("[name='transaction.comments']");const i=new URL(window.location.href);i.searchParams.has("chain")||i.searchParams.append("chain","");const s={pageUrl:i.href,formData:{ecardVariant:(null==e?void 0:e.value)||"",ecardSendDate:(null==t?void 0:t.value)||"",ecardMessage:(null==n?void 0:n.value)||"",recipients:this.getEcardRecipients()}};sessionStorage.setItem("engrid-embedded-ecard",JSON.stringify(s))}getEcardRecipients(){const e=[],t=document.querySelector(".en__ecarditems__addrecipient");if(!t||0===t.offsetHeight){let t=document.querySelector(".en__ecardrecipients__name > input"),n=document.querySelector(".en__ecardrecipients__email > input");return t&&n&&e.push({name:t.value,email:n.value}),e}const n=document.querySelector(".en__ecardrecipients__list");return null==n||n.querySelectorAll(".en__ecardrecipients__recipient").forEach((t=>{const n=t.querySelector(".ecardrecipient__name"),i=t.querySelector(".ecardrecipient__email");n&&i&&e.push({name:n.value,email:i.value})})),e}setupEmbeddedPage(){let e=document.querySelector("[name='friend.ecard']"),t=document.querySelector("[name='ecard.schedule']"),n=document.querySelector("[name='transaction.comments']"),i=document.querySelector(".en__ecardrecipients__name > input"),s=document.querySelector(".en__ecardrecipients__email > input");[e,t,n,i,s].forEach((e=>{e.addEventListener("input",(()=>{this.isSubmitting||this.setEmbeddedEcardSessionData()}))}));const o=new MutationObserver((e=>{for(let t of e)if("childList"===t.type){if(this.isSubmitting)return;this.setEmbeddedEcardSessionData()}})),r=document.querySelector(".en__ecardrecipients__list");r&&o.observe(r,{childList:!0}),document.querySelectorAll(".en__ecarditems__thumb").forEach((t=>{t.addEventListener("click",(()=>{e.dispatchEvent(new Event("input"))}))})),window.addEventListener("message",(o=>{if(o.origin===location.origin&&o.data.action)switch(this.logger.log("Received post message",o.data),o.data.action){case"submit_form":this.isSubmitting=!0;let r=JSON.parse(sessionStorage.getItem("engrid-embedded-ecard")||"{}");e&&(e.value=r.formData.ecardVariant),t&&(t.value=r.formData.ecardSendDate),n&&(n.value=r.formData.ecardMessage);const a=document.querySelector(".en__ecarditems__addrecipient");r.formData.recipients.forEach((e=>{i.value=e.name,s.value=e.email,null==a||a.click()}));u.getInstance().submitForm(),sessionStorage.removeItem("engrid-embedded-ecard"),sessionStorage.removeItem("engrid-send-embedded-ecard");break;case"set_recipient":i.value=o.data.name,s.value=o.data.email,i.dispatchEvent(new Event("input")),s.dispatchEvent(new Event("input"))}})),this.sendPostMessage("parent","ecard_form_ready")}submitEcard(){var e;const t=JSON.parse(sessionStorage.getItem("engrid-embedded-ecard")||"{}");this.logger.log("Submitting ecard",t);const n=this.createIframe(t.pageUrl);null===(e=document.querySelector(".body-main"))||void 0===e||e.appendChild(n),window.addEventListener("message",(e=>{e.origin===location.origin&&e.data.action&&"ecard_form_ready"===e.data.action&&this.sendPostMessage(n,"submit_form")}))}sendPostMessage(e,t,n={}){var i;const s=Object.assign({action:t},n);"parent"===e?window.parent.postMessage(s,location.origin):null===(i=e.contentWindow)||void 0===i||i.postMessage(s,location.origin)}}class rt{constructor(){if(!this.shouldRun())return;document.querySelector(".en__field--country .en__field__notice")||p.addHtml('<div class="en__field__notice"><em>Note: This action is limited to U.S. addresses.</em></div>',".us-only-form .en__field--country .en__field__element","after");const e=p.getField("supporter.country");e.setAttribute("disabled","disabled");let t="United States";[...e.options].some((e=>"US"===e.value))?t="US":[...e.options].some((e=>"USA"===e.value))&&(t="USA"),p.setFieldValue("supporter.country",t),p.createHiddenInput("supporter.country",t),e.addEventListener("change",(()=>{e.value=t}))}shouldRun(){return!!document.querySelector(".en__component--formblock.us-only-form .en__field--country")}}class at{constructor(){this.logger=new fe("ThankYouPageConditionalContent"),this.shouldRun()&&this.applyShowHideRadioCheckboxesState()}getShowHideRadioCheckboxesState(){var e;try{const t=null!==(e=window.sessionStorage.getItem("engrid_ShowHideRadioCheckboxesState"))&&void 0!==e?e:"";return JSON.parse(t)}catch(e){return[]}}applyShowHideRadioCheckboxesState(){const e=this.getShowHideRadioCheckboxesState();e&&e.forEach((e=>{this.logger.log("Processing TY page conditional content item:",e),p.getPageID()===e.page&&(document.querySelectorAll(`[class*="${e.class}"]`).forEach((e=>{e.classList.add("hide")})),document.querySelectorAll(`.${e.class}${e.value}`).forEach((e=>{e.classList.remove("hide")})))})),this.deleteShowHideRadioCheckboxesState()}deleteShowHideRadioCheckboxesState(){window.sessionStorage.removeItem("engrid_ShowHideRadioCheckboxesState")}shouldRun(){return p.getGiftProcess()}}class lt{constructor(){this.logger=new fe("CheckboxLabel","#00CC95","#2C3E50","✅"),this.checkBoxesLabels=document.querySelectorAll(".checkbox-label"),this.shoudRun()&&(this.logger.log(`Found ${this.checkBoxesLabels.length} custom labels`),this.run())}shoudRun(){return this.checkBoxesLabels.length>0}run(){this.checkBoxesLabels.forEach((e=>{var t;const n=null===(t=e.textContent)||void 0===t?void 0:t.trim(),i=e.nextElementSibling.querySelector("label");i&&n&&(i.textContent=n,e.remove(),this.logger.log(`Set checkbox label to "${n}"`))}))}}const ct="0.19.21";var dt=n(523),ut=n.n(dt);/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&(window.__forceSmoothScrollPolyfill__=!0),ut().polyfill();class ht{constructor(e,t,n){if(!this.isIframe())return;if(this.amount=t,this.frequency=n,this.ipCountry="",this.isDonation=["donation","premiumgift"].includes(window.pageJson.pageType),console.log("DonationLightboxForm: constructor"),this.sections=document.querySelectorAll("form.en__component > .en__component"),pageJson.pageNumber===pageJson.pageCount){this.sendMessage("status","loaded"),this.isDonation&&this.sendMessage("status","celebrate"),this.sendMessage("class","thank-you"),document.querySelector("body").dataset.thankYou="true";const e=new URLSearchParams(window.location.search);if(e.get("name")){let t=document.querySelector("#engrid");if(t){let n=t.innerHTML;n=n.replace("{user_data~First Name}",e.get("name")),n=n.replace("{receipt_data~recurringFrequency}",e.get("frequency")),n=n.replace("{receipt_data~amount}","$"+e.get("amount")),t.innerHTML=n,this.sendMessage("firstname",e.get("name"))}}else{const e=this,t=location.protocol+"//"+location.host+location.pathname+"/pagedata";fetch(t).then((function(e){return e.json()})).then((function(t){t.hasOwnProperty("firstName")&&null!==t.firstName?e.sendMessage("firstname",t.firstName):e.sendMessage("firstname","Friend")})).catch((e=>{console.error("PageData Error:",e)}))}return!1}if(!this.sections.length)return this.sendMessage("error","No sections found"),!1;if(console.log(this.sections),this.isIframe()){if(this.buildSectionNavigation(),this.checkNested(EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")&&EngagingNetworks.require._defined.enjs.checkSubmissionFailed()&&(console.log("DonationLightboxForm: Submission Failed"),this.validateForm())){const e=document.querySelector("li.en__error");e&&(e.innerHTML.toLowerCase().indexOf("processing")>-1?(this.sendMessage("error","Sorry! There's a problem processing your donation."),this.scrollToElement(document.querySelector(".en__field--ccnumber"))):this.sendMessage("error",e.textContent),(e.innerHTML.toLowerCase().indexOf("payment")>-1||e.innerHTML.toLowerCase().indexOf("account")>-1||e.innerHTML.toLowerCase().indexOf("card")>-1)&&this.scrollToElement(document.querySelector(".en__field--ccnumber")))}document.querySelectorAll("form.en__component input.en__field__input").forEach((e=>{e.addEventListener("focus",(t=>{const n=this.getSectionId(e);setTimeout((()=>{n>0&&this.validateForm(n-1)&&this.scrollToElement(e)}),50)}))}))}let i=document.querySelector(".payment-options");i&&this.clickPaymentOptions(i),this.addTabIndexToLabels(),n.getInstance().onFrequencyChange.subscribe((()=>this.changeSubmitButton())),t.getInstance().onAmountChange.subscribe((()=>this.changeSubmitButton())),this.changeSubmitButton(),this.sendMessage("status","loaded");const s=new URLSearchParams(window.location.search);s.get("color")&&document.body.style.setProperty("--color_primary",s.get("color")),fetch("https://www.cloudflare.com/cdn-cgi/trace").then((e=>e.text())).then((e=>{let t=e.replace(/[\r\n]+/g,'","').replace(/\=+/g,'":"');t='{"'+t.slice(0,t.lastIndexOf('","'))+'"}';const n=JSON.parse(t);this.ipCountry=n.loc,this.canadaOnly(),console.log("Country:",this.ipCountry)}));const o=document.querySelector("#en__field_supporter_country");o&&o.addEventListener("change",(e=>{this.canadaOnly()})),e.watchForError((()=>{if(this.sendMessage("status","loaded"),this.validateForm(!1,!1)){const e=document.querySelector("li.en__error");e&&(e.innerHTML.toLowerCase().indexOf("processing")>-1?(this.sendMessage("error","Sorry! There's a problem processing your donation."),this.scrollToElement(document.querySelector(".en__field--ccnumber"))):this.sendMessage("error",e.textContent),(e.innerHTML.toLowerCase().indexOf("payment")>-1||e.innerHTML.toLowerCase().indexOf("account")>-1||e.innerHTML.toLowerCase().indexOf("card")>-1)&&this.scrollToElement(document.querySelector(".en__field--ccnumber")))}}))}sendMessage(e,t){const n={key:e,value:t};window.parent.postMessage(n,"*")}isIframe(){return window.self!==window.top}buildSectionNavigation(){console.log("DonationLightboxForm: buildSectionNavigation"),this.sections.forEach(((e,t)=>{e.dataset.sectionId=t;const n=document.createElement("div");n.classList.add("section-navigation");const i=document.createElement("div");i.classList.add("section-count");const s=this.sections.length;if(s>1)0==t?n.innerHTML=`\n <button class="section-navigation__next" data-section-id="${t}">\n <span>Let’s Do It!</span>\n <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="none" viewBox="0 0 14 14">\n <path fill="currentColor" d="M7.687 13.313c-.38.38-.995.38-1.374 0-.38-.38-.38-.996 0-1.375L10 8.25H1.1c-.608 0-1.1-.493-1.1-1.1 0-.608.492-1.1 1.1-1.1h9.2L6.313 2.062c-.38-.38-.38-.995 0-1.375s.995-.38 1.374 0L14 7l-6.313 6.313z"/>\n </svg>\n </button>\n `:t==this.sections.length-1?n.innerHTML=`\n <button class="section-navigation__previous" data-section-id="${t}">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">\n <path fill="currentColor" d="M7.214.786c.434-.434 1.138-.434 1.572 0 .433.434.433 1.137 0 1.571L4.57 6.572h10.172c.694 0 1.257.563 1.257 1.257s-.563 1.257-1.257 1.257H4.229l4.557 4.557c.433.434.433 1.137 0 1.571-.434.434-1.138.434-1.572 0L0 8 7.214.786z"/>\n </svg>\n </button>\n <button class="section-navigation__submit" data-section-id="${t}" type="submit" data-label="Give $AMOUNT$FREQUENCY">\n <span>Give Now</span>\n </button>\n `:n.innerHTML=`\n <button class="section-navigation__previous" data-section-id="${t}">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">\n <path fill="currentColor" d="M7.214.786c.434-.434 1.138-.434 1.572 0 .433.434.433 1.137 0 1.571L4.57 6.572h10.172c.694 0 1.257.563 1.257 1.257s-.563 1.257-1.257 1.257H4.229l4.557 4.557c.433.434.433 1.137 0 1.571-.434.434-1.138.434-1.572 0L0 8 7.214.786z"/>\n </svg>\n </button>\n <button class="section-navigation__next" data-section-id="${t}">\n <span>Continue</span>\n <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="none" viewBox="0 0 14 14">\n <path fill="currentColor" d="M7.687 13.313c-.38.38-.995.38-1.374 0-.38-.38-.38-.996 0-1.375L10 8.25H1.1c-.608 0-1.1-.493-1.1-1.1 0-.608.492-1.1 1.1-1.1h9.2L6.313 2.062c-.38-.38-.38-.995 0-1.375s.995-.38 1.374 0L14 7l-6.313 6.313z"/>\n </svg>\n </button>\n `,i.innerHTML=`\n <span class="section-count__current">${t+1}</span> of\n <span class="section-count__total">${s}</span>\n `;else{const e=document.querySelector(".en__submit button")?.innerText||"Submit";n.innerHTML=`\n <button class="section-navigation__submit" data-section-id="${t}" type="submit" data-label="${e}">\n <span>${e}</span>\n </button>\n `}n.querySelector(".section-navigation__previous")?.addEventListener("click",(e=>{e.preventDefault(),this.scrollToSection(t-1)})),n.querySelector(".section-navigation__next")?.addEventListener("click",(e=>{e.preventDefault(),this.validateForm(t)&&this.scrollToSection(t+1)})),n.querySelector(".section-navigation__submit")?.addEventListener("click",(e=>{if(e.preventDefault(),this.validateForm(!1,this.isDonation))if(this.isDonation){this.sendMessage("donationinfo",JSON.stringify({name:document.querySelector("#en__field_supporter_firstName").value,amount:EngagingNetworks.require._defined.enjs.getDonationTotal(),frequency:this.frequency.getInstance().frequency}));if("paypal"!=document.querySelector("#en__field_transaction_paymenttype").value)this.sendMessage("status","loading");else{const e=this;document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?e.sendMessage("status","submitted"):e.sendMessage("status","loading")})),document.querySelector("form.en__component").target="_blank"}this.checkNested(window.EngagingNetworks,"require","_defined","enDefaults","validation","_getSubmitPromise")?window.EngagingNetworks.require._defined.enDefaults.validation._getSubmitPromise().then((function(){document.querySelector("form.en__component").submit()})):document.querySelector("form.en__component").requestSubmit()}else this.sendMessage("status","loading"),document.querySelector("form.en__component").requestSubmit()})),e.querySelector(".en__component").append(n),e.querySelector(".en__component").append(i)}))}scrollToSection(e){console.log("DonationLightboxForm: scrollToSection",e);const t=document.querySelector(`[data-section-id="${e}"]`);this.sections[e]&&(console.log(t),this.sections[e].scrollIntoView({behavior:"smooth"}))}scrollToElement(e){if(e){const t=this.getSectionId(e);t&&this.scrollToSection(t)}}getSectionId(e){return e&&parseInt(e.closest("[data-section-id]").dataset.sectionId)||!1}validateForm(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=document.querySelector("form.en__component"),i=n.querySelector("[name='transaction.recurrfreq']:checked"),s=n.querySelector(".en__field--recurrfreq"),o=this.getSectionId(s);if(!1===e||e==o){if(!i||!i.value)return this.scrollToElement(n.querySelector("[name='transaction.recurrfreq']:checked")),this.sendMessage("error","Please select a frequency"),s&&s.classList.add("has-error"),!1;s&&s.classList.remove("has-error")}const r=EngagingNetworks.require._defined.enjs.getDonationTotal(),a=n.querySelector(".en__field--donationAmt"),l=this.getSectionId(a);if(!1===e||e==l){if(!r||r<=0)return this.scrollToElement(a),this.sendMessage("error","Please enter a valid amount"),a&&a.classList.add("has-error"),!1;if(r<5)return this.sendMessage("error","Amount must be at least $5 - Contact us for assistance"),a&&a.classList.add("has-error"),!1;a&&a.classList.remove("has-error")}const c=n.querySelector("#en__field_transaction_paymenttype"),d=n.querySelector("#en__field_transaction_ccnumber"),u=n.querySelector(".en__field--ccnumber"),h=this.getSectionId(u),p=["paypal","paypaltouch","stripedigitalwallet"].includes(c.value);if(console.log("DonationLightboxForm: validateForm",u,h),!p&&(!1===e||e==h)&&t){if(!c||!c.value)return this.scrollToElement(c),this.sendMessage("error","Please add your credit card information"),u&&u.classList.add("has-error"),!1;if(!(d instanceof HTMLInputElement?!!d.value:d.classList.contains("vgs-collect-container__valid")))return this.scrollToElement(d),this.sendMessage("error","Please enter a valid credit card number"),u&&u.classList.add("has-error"),!1;u&&u.classList.remove("has-error");const e=n.querySelectorAll("[name='transaction.ccexpire']"),t=n.querySelector(".en__field--ccexpire");let i=!0;if(e.forEach((e=>{if(!e.value)return this.scrollToElement(t),this.sendMessage("error","Please enter a valid expiration date"),t&&t.classList.add("has-error"),i=!1,!1})),!i&&t)return!1;t&&t.classList.remove("has-error");const s=n.querySelector("#en__field_transaction_ccvv"),o=n.querySelector(".en__field--ccvv");if(!(s instanceof HTMLInputElement?!!s.value:s.classList.contains("vgs-collect-container__valid")))return this.scrollToElement(s),this.sendMessage("error","Please enter a valid CVV"),o&&o.classList.add("has-error"),!1;o&&o.classList.remove("has-error")}const g=n.querySelectorAll(".en__mandatory:not(.en__hidden)");let m=!1;if(g.forEach((t=>{if(m)return;const n=t.querySelector(".en__field__input"),i=t.querySelector(".en__field__label"),s=this.getSectionId(n);if(!1===e||e==s){if(!n.value)return this.scrollToElement(n),this.sendMessage("error","Please enter "+i.textContent.toLowerCase()),t.classList.add("has-error"),m=!0,!1;if(t.classList.remove("has-error"),"supporter.emailAddress"===n.name&&!1===/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n.value))return this.scrollToElement(n),this.sendMessage("error","Please enter a valid email address"),t.classList.add("has-error"),m=!0,!1}})),m)return!1;const f=n.querySelector("#en__field_supporter_city"),b=n.querySelector(".en__field--city");if(!this.checkCharsLimit("#en__field_supporter_city",100))return this.scrollToElement(f),this.sendMessage("error","This field only allows up to 100 characters"),b&&b.classList.add("has-error"),!1;b&&b.classList.remove("has-error");const v=n.querySelector("#en__field_supporter_address1"),y=n.querySelector(".en__field--address1");if(!this.checkCharsLimit("#en__field_supporter_address1",35))return this.scrollToElement(v),this.sendMessage("error","This field only allows up to 35 characters. Longer street addresses can be broken up between Lines 1 and 2."),y&&y.classList.add("has-error"),!1;y&&y.classList.remove("has-error");const _=n.querySelector("#en__field_supporter_address2"),S=n.querySelector(".en__field--address2");if(!this.checkCharsLimit("#en__field_supporter_address2",35))return this.scrollToElement(_),this.sendMessage("error","This field only allows up to 35 characters. Longer street addresses can be broken up between Lines 1 and 2."),S&&S.classList.add("has-error"),!1;S&&S.classList.remove("has-error");const w=n.querySelector("#en__field_supporter_postcode"),E=n.querySelector(".en__field--postcode");if(!this.checkCharsLimit("#en__field_supporter_postcode",20))return this.scrollToElement(w),this.sendMessage("error","This field only allows up to 20 characters"),E&&E.classList.add("has-error"),!1;E&&E.classList.remove("has-error");const A=n.querySelector("#en__field_supporter_firstName"),L=n.querySelector(".en__field--firstName");if(!this.checkCharsLimit("#en__field_supporter_firstName",100))return this.scrollToElement(A),this.sendMessage("error","This field only allows up to 100 characters"),L&&L.classList.add("has-error"),!1;L&&L.classList.remove("has-error");const C=n.querySelector("#en__field_supporter_lastName"),k=n.querySelector(".en__field--lastName");return this.checkCharsLimit("#en__field_supporter_lastName",100)?(k&&k.classList.remove("has-error"),console.log("DonationLightboxForm: validateForm PASSED"),!0):(this.scrollToElement(C),this.sendMessage("error","This field only allows up to 100 characters"),k&&k.classList.add("has-error"),!1)}checkCharsLimit(e,t){const n=document.querySelector(e);return!(n&&n.value.length>t)}changeSubmitButton(){const e=document.querySelector(".section-navigation__submit"),t=this.checkNested(window.EngagingNetworks,"require","_defined","enjs","getDonationTotal")?"$"+window.EngagingNetworks.require._defined.enjs.getDonationTotal():null;let n=this.frequency.getInstance().frequency,i=e?e.dataset.label:"";n="onetime"===n?"":"<small>/mo</small>",t?(i=i.replace("$AMOUNT",t),i=i.replace("$FREQUENCY",n)):(i=i.replace("$AMOUNT",""),i=i.replace("$FREQUENCY","")),e&&i&&(e.innerHTML=`<span>${i}</span>`)}clickPaymentOptions(e){e.querySelectorAll("button").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault();const n=document.querySelector("#en__field_transaction_paymenttype");n&&(n.value=e.className.substr(15),this.scrollToSection(parseInt(e.closest("[data-section-id]").dataset.sectionId)+1))}))}))}isCanada(){const e=document.querySelector("#en__field_supporter_country");if(e&&"CA"===e.value)return!0;return"en-CA"===(window.navigator.userLanguage||window.navigator.language)||"CA"===this.ipCountry}canadaOnly(){const e=document.querySelectorAll(".canada-only");e.length&&(this.isCanada()?e.forEach((e=>{e.style.display="";const t=e.querySelectorAll("input[type='checkbox']");t.length&&t.forEach((e=>{e.checked=!1}))})):e.forEach((e=>{e.style.display="none";const t=e.querySelectorAll("input[type='checkbox']");t.length&&t.forEach((e=>{e.checked=!0}))})))}checkNested(e,t){if(void 0===e)return!1;for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return!(0!=i.length||!e.hasOwnProperty(t))||this.checkNested(e[t],...i)}addTabIndexToLabels(){document.querySelectorAll(".en__field__label.en__field__label--item").forEach((e=>{e.tabIndex=0}))}}var pt=n(3861);function gt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class mt{constructor(){gt(this,"logger",new fe("AddDAF","lightgray","darkblue","🪙")),gt(this,"donorAdvisedFundButtonContainer",document.getElementById("en__digitalWallet__chariot__container")),this.shouldRun()&&(this.donorAdvisedFundButtonContainer?.querySelector("*")?this.addDAF():this.checkForDafBeingAdded())}shouldRun(){return!!this.donorAdvisedFundButtonContainer}checkForDafBeingAdded(){const e=document.getElementById("en__digitalWallet__chariot__container");if(!e)return void this.logger.log("No DAF container found");new MutationObserver(((e,t)=>{for(const n of e)"childList"===n.type&&n.addedNodes.length&&(this.addDAF(),t.disconnect())})).observe(e,{childList:!0,subtree:!0})}addDAF(){if(document.querySelector("input[name='transaction.giveBySelect'][value='daf']"))return void this.logger.log("DAF already added");this.logger.log("Adding DAF");const e=document.querySelector(".give-by-select .en__field__element--radio");if(!e)return void this.logger.log("No giveBySelectWrapper found");const t='\n \x3c!-- DAF (added dynamically) --\x3e\n <div class="en__field__item en__field--giveBySelect give-by-select pseudo-en-field showif-daf-available recurring-frequency-y-hide daf">\n <input class="en__field__input en__field__input--radio" id="en__field_transaction_giveBySelectDAF" name="transaction.giveBySelect" type="radio" value="daf">\n <label class="en__field__label en__field__label--item" for="en__field_transaction_giveBySelectDAF">\n <img alt="DAF Logo" class="daf-logo" src="https://acb0a5d73b67fccd4bbe-c2d8138f0ea10a18dd4c43ec3aa4240a.ssl.cf5.rackcdn.com/10042/daf-logo.png">\n </label>\n </div>\n ',n=document.querySelector(".en__field__item.card");n?n.insertAdjacentHTML("beforebegin",t):e.insertAdjacentHTML("beforeend",t);const i=document.querySelector(".en__component--premiumgiftblock");i&&i.classList.add("hideif-daf-selected"),new X("transaction.giveBySelect","giveBySelect-"),this.logger.log("DAF added");const s=document.querySelector("input[name='transaction.giveBySelect'][value='daf']");s?s.addEventListener("change",(()=>{this.logger.log("Payment DAF selected"),p.setPaymentType("daf")})):this.logger.log("Somehow DAF was not added")}}class ft{constructor(){gt(this,"logger",new fe("OptInLadder","lightgreen","darkgreen","✔")),gt(this,"_form",u.getInstance()),this.inIframe()?1===p.getPageNumber()?this.runAsChildRegular():this.runAsChildThankYou():this.runAsParent()}runAsParent(){0!==document.querySelectorAll('input[name^="supporter.questions"]').length?(this._form.onSubmit.subscribe((()=>{this.saveOptInsToSessionStorage()})),this.logger.log("Running as Parent"),1===p.getPageNumber()&&sessionStorage.removeItem("engrid.supporter.questions")):this.logger.log("No checkboxes found")}runAsChildRegular(){if(!this.isEmbeddedThankYouPage())return void this.logger.log("Not Embedded on a Thank You Page");const e=document.querySelectorAll(".en__component--copyblock.optin-ladder"),t=document.querySelectorAll(".en__component--formblock.optin-ladder");if(0===e.length&&0===t.length)return void this.logger.log("No optin-ladder elements found");const n=p.getField("supporter.emailAddress");if(!n||!n.value)return this.logger.log("Email field is empty"),void this.hidePage();const i=JSON.parse(sessionStorage.getItem("engrid.supporter.questions")||"{}");let s=0,o=e.length,r=null,a=null;for(let t=0;t<e.length;t++){const n=e[t],o=n.className.match(/optin-ladder-(\d+)/);if(!o)return void this.logger.error(`No optin number found in ${n.innerText.trim()}`);const l=o[1],c=document.querySelector(`.en__component--formblock.optin-ladder:has(.en__field--${l})`);if(c){if("Y"!==i[l]){r=n,a=c,s++;break}n.remove(),c.remove(),s++}else this.logger.log(`No form block found for ${n.innerText.trim()}`),n.remove(),s++}if(!r||!a)return this.logger.log("No optin-ladder elements found"),s=o,this.saveStepToSessionStorage(s,o),void this.hidePage();e.forEach((e=>{e!==r?e.remove():e.style.display="block"})),t.forEach((e=>{e!==a?e.remove():e.style.display="block"})),this.saveStepToSessionStorage(s,o),this._form.onSubmit.subscribe((()=>{this.saveOptInsToSessionStorage(),s++,this.saveStepToSessionStorage(s,o)}))}runAsChildThankYou(){if(!this.isEmbeddedThankYouPage())return void this.logger.log("Not Embedded on a Thank You Page");const e=JSON.parse(sessionStorage.getItem("engrid.optin-ladder")||"{}"),t=e.step||0,n=e.totalSteps||0;if(t<n)return this.logger.log(`Current step ${t} is less than total steps ${n}`),void(window.location.href=this.getFirstPageUrl());this.logger.log(`Current step ${t} is equal to total steps ${n}`),sessionStorage.removeItem("engrid.optin-ladder")}inIframe(){try{return window.self!==window.top}catch(e){return!0}}saveStepToSessionStorage(e,t){sessionStorage.setItem("engrid.optin-ladder",JSON.stringify({step:e,totalSteps:t})),this.logger.log(`Saved step ${e} of ${t} to sessionStorage`)}getFirstPageUrl(){const e=new URL(window.location.href),t=e.pathname.split("/");return t.pop(),t.push("1"),e.origin+t.join("/")+"?chain"}saveOptInsToSessionStorage(){const e=document.querySelectorAll('input[name^="supporter.questions"]');if(0===e.length)return void this.logger.log("No checkboxes found");const t=JSON.parse(sessionStorage.getItem("engrid.supporter.questions")||"{}");e.forEach((e=>{if(e.checked){const n=e.name.split(".")[2];t[n]="Y"}})),sessionStorage.setItem("engrid.supporter.questions",JSON.stringify(t)),this.logger.log(`Saved checkbox values to sessionStorage: ${JSON.stringify(t)}`)}isEmbeddedThankYouPage(){return"thank-you-page-donation"===p.getBodyData("embedded")}hidePage(){const e=document.querySelector("#engrid");e&&e.classList.add("hide")}}const bt={applePay:!1,AutoYear:!0,CapitalizeFields:!0,ClickToExpand:!0,CurrencySymbol:"$",CurrencyCode:"USD",DecimalSeparator:".",ThousandsSeparator:",",MinAmount:5,MaxAmount:1e5,MinAmountMessage:"Amount must be at least $5 - Contact us for assistance",MaxAmountMessage:"Amount must be less than $100,000 - Contact us for assistance",MediaAttribution:!0,SkipToMainContentLink:!0,SrcDefer:!0,ProgressBar:!0,TidyContact:{cid:"659b7129-73d0-4601-af4c-8942c4730f65",us_zip_divider:"+",record_field:"supporter.NOT_TAGGED_41",date_field:"supporter.NOT_TAGGED_39",status_field:"supporter.NOT_TAGGED_40",countries:["us"],phone_enable:!0,phone_preferred_countries:["us","ca","gb","jp","au"],phone_record_field:"supporter.NOT_TAGGED_45",phone_date_field:"supporter.NOT_TAGGED_44",phone_status_field:"supporter.NOT_TAGGED_43"},RememberMe:{checked:!0,remoteUrl:"https://www.ran.org/wp-content/themes/ran-2020/data-remember.html",fieldOptInSelectorTarget:"div.en__field--postcode, div.en__field--telephone, div.en__field--email, div.en__field--lastName",fieldOptInSelectorTargetLocation:"after",fieldClearSelectorTarget:"div.en__field--firstName div, div.en__field--email div",fieldClearSelectorTargetLocation:"after",fieldNames:["supporter.firstName","supporter.lastName","supporter.address1","supporter.address2","supporter.city","supporter.country","supporter.region","supporter.postcode","supporter.emailAddress"]},Plaid:!0,Debug:"true"==v.getUrlParameter("debug"),WelcomeBack:{welcomeBackMessage:{display:!0,title:"Welcome back, {firstName}!",editText:"Not you?",anchor:".body-main",placement:"afterbegin"},personalDetailsSummary:{display:!0,title:"Personal Information",editText:"Change",anchor:".fast-personal-details",placement:"beforebegin"}},VGS:{"transaction.ccnumber":{css:{"@font-face":{"font-family":"HarmoniaSansPro","font-style":"normal","font-weight":"400","font-display":"swap",src:'local("HarmoniaSansPro"), local("HarmoniaSansPro-Regular"), url("https://acb0a5d73b67fccd4bbe-c2d8138f0ea10a18dd4c43ec3aa4240a.ssl.cf5.rackcdn.com/10042/HarmoniaSansProRegular.woff2") format("woff2");'}}},"transaction.ccvv":{css:{"@font-face":{"font-family":"HarmoniaSansPro","font-style":"normal","font-weight":"400","font-display":"swap",src:'local("HarmoniaSansPro"), local("HarmoniaSansPro-Regular"), url("https://acb0a5d73b67fccd4bbe-c2d8138f0ea10a18dd4c43ec3aa4240a.ssl.cf5.rackcdn.com/10042/HarmoniaSansProRegular.woff2") format("woff2");'}}}},onLoad:()=>{window.DonationLightboxForm=ht,new ht(v,h,g),function(e,t){if(e.log("ENGrid client scripts are executing"),e.getPageNumber()===e.getPageCount()||document.referrer.includes("act.ran.org")){const e=document.createElement("iframe");e.src="https://act.ran.org/page/51899/data/1?chain",e.style.width="0",e.style.height="0",e.style.visibility="hidden",e.style.display="none",e.width="0",e.height="0",e.name="cohortIframe",e.visibility="hidden";const t=document.querySelector("#endgrid, form");t&&t.appendChild(e)}let n=document.querySelectorAll(".radio-to-buttons_donationAmt .en__field--radio.en__field--donationAmt .en__field__input--other")[0];n&&(n.placeholder="Custom Amount");let i=document.querySelectorAll("input#en__field_supporter_phoneNumber")[0];i&&(i.placeholder="000-000-0000 (optional)");const s=document.querySelector(".media-with-attribution figattribution");if(s){const e=s._tippy;e&&e.setProps({allowHTML:!0,theme:"RAN",placement:"right-end"})}document.body.removeAttribute("data-engrid-errors");const o=document.querySelector('[name="transaction.paymenttype"] [value="ACH"]');o&&(o.value="ach");const r=document.querySelector(".en__submit");if(r&&r.classList.add("hideif-stripedigitalwallet-selected","hideif-paypaltouch-selected"),"UNSUBSCRIBE"===e.getPageType()){const n=document.querySelector(".en__submit button"),i=e.getField("supporter.questions.341509"),s=e.getField("supporter.questions.102600"),o=e.getFieldValue("supporter.emailAddress");if(o){e.getField("supporter.emailAddress").setAttribute("readonly","true");const t=document.createElement("a");t.href=window.location.href.split("?")[0]+"?redirect=cold",t.innerText=`Not ${o}?`,e.addHtml(t,".en__field--emailAddress","beforeend")}const r=document.querySelector(".fewer-emails-block");i&&i.checked&&r&&(r.style.display="none");const a=document.querySelector(".fewer-emails-block button");a&&a.addEventListener("click",(()=>{i.checked=!0,s.checked=!1,e.enParseDependencies(),n.click()}));const l=document.querySelector(".sub-emails-block button");l&&l.addEventListener("click",(()=>{i.checked=!1,s.checked=!0,e.enParseDependencies(),n.click()}));const c=document.querySelector(".unsub-emails-block button");if(c&&c.addEventListener("click",(()=>{i.checked=!1,s.checked=!1,e.enParseDependencies(),n.click()})),t.getInstance().onSubmit.subscribe((()=>{s.checked||sessionStorage.setItem("unsub_details",JSON.stringify({email:e.getFieldValue("supporter.emailAddress")}))})),2===e.getPageNumber()&&JSON.parse(sessionStorage.getItem("unsub_details"))){e.setBodyData("recent-unsubscribe","true");const t=document.querySelector(".resubscribe-block a.button");t&&(t.href=t.href+"?chain&autosubmit=Y&engrid_hide[engrid]=id"),sessionStorage.removeItem("unsub_details")}}const a=document.querySelector("button.en__ecarditems__button.en__ecarditems__addrecipient");a&&(a.innerHTML="Add Recipient");const l=t.getInstance();l.onValidate.subscribe((()=>{if(l.validate)return"DONATION"===e.getPageType()&&["paypaltouch","paypal"].includes(e.getPaymentType())&&"USD"!==e.getCurrencyCode()?(e.addHtml('<div class="en__field__error en__field__error--paypal">PayPal is only available for payments in USD. Please select another payment method or USD.</div>',".dynamic-giving-button"),l.validate=!1,!1):void 0})),function(){const e=document.querySelector(".transaction-fee-opt-in .en__field__element--checkbox");if(!e)return;const t=document.createElement("div");t.classList.add("transaction-fee-tooltip"),t.innerHTML="i",e.appendChild(t),(0,pt.ZP)(t,{content:"By checking this box, you agree to cover the transaction fee for your donation. This small additional amount helps us ensure that 100% of you donation goes directly to RAN.",allowHTML:!0,theme:"white",placement:"top",trigger:"mouseenter click",interactive:!0,arrow:"<div class='custom-tooltip-arrow'></div>",offset:[0,20]})}()}(v,u),new mt,new ft},onResize:()=>console.log("Starter Theme Window Resized"),onValidate:()=>{const e=v.getFieldValue("supporter.country");["us","usa","united states","ca","canada"].includes(e.toLowerCase())||(v.setFieldValue("supporter.region",""),v.log("Region field cleared"))}};new v(bt)})()})(); \ No newline at end of file + */Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionChangeEventDispatcher=t.HandlingBase=t.PromiseDispatcherBase=t.PromiseSubscription=t.DispatchError=t.EventManagement=t.EventListBase=t.DispatcherWrapper=t.DispatcherBase=t.Subscription=void 0;const i=n(3040);Object.defineProperty(t,"DispatcherBase",{enumerable:!0,get:function(){return i.DispatcherBase}});const s=n(8181);Object.defineProperty(t,"DispatchError",{enumerable:!0,get:function(){return s.DispatchError}});const o=n(3122);Object.defineProperty(t,"DispatcherWrapper",{enumerable:!0,get:function(){return o.DispatcherWrapper}});const r=n(7955);Object.defineProperty(t,"EventListBase",{enumerable:!0,get:function(){return r.EventListBase}});const a=n(2234);Object.defineProperty(t,"EventManagement",{enumerable:!0,get:function(){return a.EventManagement}});const l=n(1605);Object.defineProperty(t,"HandlingBase",{enumerable:!0,get:function(){return l.HandlingBase}});const c=n(2490);Object.defineProperty(t,"PromiseDispatcherBase",{enumerable:!0,get:function(){return c.PromiseDispatcherBase}});const d=n(9347);Object.defineProperty(t,"PromiseSubscription",{enumerable:!0,get:function(){return d.PromiseSubscription}});const u=n(2229);Object.defineProperty(t,"Subscription",{enumerable:!0,get:function(){return u.Subscription}});const h=n(1002);Object.defineProperty(t,"SubscriptionChangeEventDispatcher",{enumerable:!0,get:function(){return h.SubscriptionChangeEventDispatcher}})},2234:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventManagement=void 0;t.EventManagement=class{constructor(e){this.unsub=e,this.propagationStopped=!1}stopPropagation(){this.propagationStopped=!0}}},3861:(e,t,n)=>{"use strict";function i(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function s(e){return e instanceof i(e).Element||e instanceof Element}function o(e){return e instanceof i(e).HTMLElement||e instanceof HTMLElement}function r(e){return"undefined"!=typeof ShadowRoot&&(e instanceof i(e).ShadowRoot||e instanceof ShadowRoot)}n.d(t,{ZP:()=>rt});var a=Math.max,l=Math.min,c=Math.round;function d(e,t){void 0===t&&(t=!1);var n=e.getBoundingClientRect(),i=1,s=1;if(o(e)&&t){var r=e.offsetHeight,a=e.offsetWidth;a>0&&(i=c(n.width)/a||1),r>0&&(s=c(n.height)/r||1)}return{width:n.width/i,height:n.height/s,top:n.top/s,right:n.right/i,bottom:n.bottom/s,left:n.left/i,x:n.left/i,y:n.top/s}}function u(e){var t=i(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function h(e){return e?(e.nodeName||"").toLowerCase():null}function p(e){return((s(e)?e.ownerDocument:e.document)||window.document).documentElement}function g(e){return d(p(e)).left+u(e).scrollLeft}function m(e){return i(e).getComputedStyle(e)}function f(e){var t=m(e),n=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+s+i)}function b(e,t,n){void 0===n&&(n=!1);var s,r,a=o(t),l=o(t)&&function(e){var t=e.getBoundingClientRect(),n=c(t.width)/e.offsetWidth||1,i=c(t.height)/e.offsetHeight||1;return 1!==n||1!==i}(t),m=p(t),b=d(e,l),v={scrollLeft:0,scrollTop:0},y={x:0,y:0};return(a||!a&&!n)&&(("body"!==h(t)||f(m))&&(v=(s=t)!==i(s)&&o(s)?{scrollLeft:(r=s).scrollLeft,scrollTop:r.scrollTop}:u(s)),o(t)?((y=d(t,!0)).x+=t.clientLeft,y.y+=t.clientTop):m&&(y.x=g(m))),{x:b.left+v.scrollLeft-y.x,y:b.top+v.scrollTop-y.y,width:b.width,height:b.height}}function v(e){var t=d(e),n=e.offsetWidth,i=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:i}}function y(e){return"html"===h(e)?e:e.assignedSlot||e.parentNode||(r(e)?e.host:null)||p(e)}function _(e){return["html","body","#document"].indexOf(h(e))>=0?e.ownerDocument.body:o(e)&&f(e)?e:_(y(e))}function S(e,t){var n;void 0===t&&(t=[]);var s=_(e),o=s===(null==(n=e.ownerDocument)?void 0:n.body),r=i(s),a=o?[r].concat(r.visualViewport||[],f(s)?s:[]):s,l=t.concat(a);return o?l:l.concat(S(y(a)))}function w(e){return["table","td","th"].indexOf(h(e))>=0}function E(e){return o(e)&&"fixed"!==m(e).position?e.offsetParent:null}function A(e){for(var t=i(e),n=E(e);n&&w(n)&&"static"===m(n).position;)n=E(n);return n&&("html"===h(n)||"body"===h(n)&&"static"===m(n).position)?t:n||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&o(e)&&"fixed"===m(e).position)return null;for(var n=y(e);o(n)&&["html","body"].indexOf(h(n))<0;){var i=m(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||t}var L="top",C="bottom",k="right",x="left",D="auto",F=[L,C,k,x],P="start",N="end",T="viewport",O="popper",q=F.reduce((function(e,t){return e.concat([t+"-"+P,t+"-"+N])}),[]),M=[].concat(F,[D]).reduce((function(e,t){return e.concat([t,t+"-"+P,t+"-"+N])}),[]),I=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function B(e){var t=new Map,n=new Set,i=[];function s(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var i=t.get(e);i&&s(i)}})),i.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||s(e)})),i}var R={placement:"bottom",modifiers:[],strategy:"absolute"};function j(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function H(e){void 0===e&&(e={});var t=e,n=t.defaultModifiers,i=void 0===n?[]:n,o=t.defaultOptions,r=void 0===o?R:o;return function(e,t,n){void 0===n&&(n=r);var o,a,l={placement:"bottom",orderedModifiers:[],options:Object.assign({},R,r),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},c=[],d=!1,u={state:l,setOptions:function(n){var o="function"==typeof n?n(l.options):n;h(),l.options=Object.assign({},r,l.options,o),l.scrollParents={reference:s(e)?S(e):e.contextElement?S(e.contextElement):[],popper:S(t)};var a=function(e){var t=B(e);return I.reduce((function(e,n){return e.concat(t.filter((function(e){return e.phase===n})))}),[])}(function(e){var t=e.reduce((function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e}),{});return Object.keys(t).map((function(e){return t[e]}))}([].concat(i,l.options.modifiers)));return l.orderedModifiers=a.filter((function(e){return e.enabled})),l.orderedModifiers.forEach((function(e){var t=e.name,n=e.options,i=void 0===n?{}:n,s=e.effect;if("function"==typeof s){var o=s({state:l,name:t,instance:u,options:i}),r=function(){};c.push(o||r)}})),u.update()},forceUpdate:function(){if(!d){var e=l.elements,t=e.reference,n=e.popper;if(j(t,n)){l.rects={reference:b(t,A(n),"fixed"===l.options.strategy),popper:v(n)},l.reset=!1,l.placement=l.options.placement,l.orderedModifiers.forEach((function(e){return l.modifiersData[e.name]=Object.assign({},e.data)}));for(var i=0;i<l.orderedModifiers.length;i++)if(!0!==l.reset){var s=l.orderedModifiers[i],o=s.fn,r=s.options,a=void 0===r?{}:r,c=s.name;"function"==typeof o&&(l=o({state:l,options:a,name:c,instance:u})||l)}else l.reset=!1,i=-1}}},update:(o=function(){return new Promise((function(e){u.forceUpdate(),e(l)}))},function(){return a||(a=new Promise((function(e){Promise.resolve().then((function(){a=void 0,e(o())}))}))),a}),destroy:function(){h(),d=!0}};if(!j(e,t))return u;function h(){c.forEach((function(e){return e()})),c=[]}return u.setOptions(n).then((function(e){!d&&n.onFirstUpdate&&n.onFirstUpdate(e)})),u}}var U={passive:!0};function V(e){return e.split("-")[0]}function $(e){return e.split("-")[1]}function W(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function G(e){var t,n=e.reference,i=e.element,s=e.placement,o=s?V(s):null,r=s?$(s):null,a=n.x+n.width/2-i.width/2,l=n.y+n.height/2-i.height/2;switch(o){case L:t={x:a,y:n.y-i.height};break;case C:t={x:a,y:n.y+n.height};break;case k:t={x:n.x+n.width,y:l};break;case x:t={x:n.x-i.width,y:l};break;default:t={x:n.x,y:n.y}}var c=o?W(o):null;if(null!=c){var d="y"===c?"height":"width";switch(r){case P:t[c]=t[c]-(n[d]/2-i[d]/2);break;case N:t[c]=t[c]+(n[d]/2-i[d]/2)}}return t}var Y={top:"auto",right:"auto",bottom:"auto",left:"auto"};function J(e){var t,n=e.popper,s=e.popperRect,o=e.placement,r=e.variation,a=e.offsets,l=e.position,d=e.gpuAcceleration,u=e.adaptive,h=e.roundOffsets,g=e.isFixed,f=a.x,b=void 0===f?0:f,v=a.y,y=void 0===v?0:v,_="function"==typeof h?h({x:b,y}):{x:b,y};b=_.x,y=_.y;var S=a.hasOwnProperty("x"),w=a.hasOwnProperty("y"),E=x,D=L,F=window;if(u){var P=A(n),T="clientHeight",O="clientWidth";if(P===i(n)&&"static"!==m(P=p(n)).position&&"absolute"===l&&(T="scrollHeight",O="scrollWidth"),P=P,o===L||(o===x||o===k)&&r===N)D=C,y-=(g&&F.visualViewport?F.visualViewport.height:P[T])-s.height,y*=d?1:-1;if(o===x||(o===L||o===C)&&r===N)E=k,b-=(g&&F.visualViewport?F.visualViewport.width:P[O])-s.width,b*=d?1:-1}var q,M=Object.assign({position:l},u&&Y),I=!0===h?function(e){var t=e.x,n=e.y,i=window.devicePixelRatio||1;return{x:c(t*i)/i||0,y:c(n*i)/i||0}}({x:b,y}):{x:b,y};return b=I.x,y=I.y,d?Object.assign({},M,((q={})[D]=w?"0":"",q[E]=S?"0":"",q.transform=(F.devicePixelRatio||1)<=1?"translate("+b+"px, "+y+"px)":"translate3d("+b+"px, "+y+"px, 0)",q)):Object.assign({},M,((t={})[D]=w?y+"px":"",t[E]=S?b+"px":"",t.transform="",t))}const z={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},i=t.attributes[e]||{},s=t.elements[e];o(s)&&h(s)&&(Object.assign(s.style,n),Object.keys(i).forEach((function(e){var t=i[e];!1===t?s.removeAttribute(e):s.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var i=t.elements[e],s=t.attributes[e]||{},r=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});o(i)&&h(i)&&(Object.assign(i.style,r),Object.keys(s).forEach((function(e){i.removeAttribute(e)})))}))}},requires:["computeStyles"]};const K={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,i=e.name,s=n.offset,o=void 0===s?[0,0]:s,r=M.reduce((function(e,n){return e[n]=function(e,t,n){var i=V(e),s=[x,L].indexOf(i)>=0?-1:1,o="function"==typeof n?n(Object.assign({},t,{placement:e})):n,r=o[0],a=o[1];return r=r||0,a=(a||0)*s,[x,k].indexOf(i)>=0?{x:a,y:r}:{x:r,y:a}}(n,t.rects,o),e}),{}),a=r[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[i]=r}};var X={left:"right",right:"left",bottom:"top",top:"bottom"};function Q(e){return e.replace(/left|right|bottom|top/g,(function(e){return X[e]}))}var Z={start:"end",end:"start"};function ee(e){return e.replace(/start|end/g,(function(e){return Z[e]}))}function te(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&r(n)){var i=t;do{if(i&&e.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function ne(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function ie(e,t){return t===T?ne(function(e){var t=i(e),n=p(e),s=t.visualViewport,o=n.clientWidth,r=n.clientHeight,a=0,l=0;return s&&(o=s.width,r=s.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(a=s.offsetLeft,l=s.offsetTop)),{width:o,height:r,x:a+g(e),y:l}}(e)):s(t)?function(e){var t=d(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(t):ne(function(e){var t,n=p(e),i=u(e),s=null==(t=e.ownerDocument)?void 0:t.body,o=a(n.scrollWidth,n.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),r=a(n.scrollHeight,n.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),l=-i.scrollLeft+g(e),c=-i.scrollTop;return"rtl"===m(s||n).direction&&(l+=a(n.clientWidth,s?s.clientWidth:0)-o),{width:o,height:r,x:l,y:c}}(p(e)))}function se(e,t,n){var i="clippingParents"===t?function(e){var t=S(y(e)),n=["absolute","fixed"].indexOf(m(e).position)>=0&&o(e)?A(e):e;return s(n)?t.filter((function(e){return s(e)&&te(e,n)&&"body"!==h(e)})):[]}(e):[].concat(t),r=[].concat(i,[n]),c=r[0],d=r.reduce((function(t,n){var i=ie(e,n);return t.top=a(i.top,t.top),t.right=l(i.right,t.right),t.bottom=l(i.bottom,t.bottom),t.left=a(i.left,t.left),t}),ie(e,c));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function oe(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function re(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function ae(e,t){void 0===t&&(t={});var n=t,i=n.placement,o=void 0===i?e.placement:i,r=n.boundary,a=void 0===r?"clippingParents":r,l=n.rootBoundary,c=void 0===l?T:l,u=n.elementContext,h=void 0===u?O:u,g=n.altBoundary,m=void 0!==g&&g,f=n.padding,b=void 0===f?0:f,v=oe("number"!=typeof b?b:re(b,F)),y=h===O?"reference":O,_=e.rects.popper,S=e.elements[m?y:h],w=se(s(S)?S:S.contextElement||p(e.elements.popper),a,c),E=d(e.elements.reference),A=G({reference:E,element:_,strategy:"absolute",placement:o}),x=ne(Object.assign({},_,A)),D=h===O?x:E,P={top:w.top-D.top+v.top,bottom:D.bottom-w.bottom+v.bottom,left:w.left-D.left+v.left,right:D.right-w.right+v.right},N=e.modifiersData.offset;if(h===O&&N){var q=N[o];Object.keys(P).forEach((function(e){var t=[k,C].indexOf(e)>=0?1:-1,n=[L,C].indexOf(e)>=0?"y":"x";P[e]+=q[n]*t}))}return P}function le(e,t,n){return a(e,l(t,n))}const ce={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name,s=n.mainAxis,o=void 0===s||s,r=n.altAxis,c=void 0!==r&&r,d=n.boundary,u=n.rootBoundary,h=n.altBoundary,p=n.padding,g=n.tether,m=void 0===g||g,f=n.tetherOffset,b=void 0===f?0:f,y=ae(t,{boundary:d,rootBoundary:u,padding:p,altBoundary:h}),_=V(t.placement),S=$(t.placement),w=!S,E=W(_),D="x"===E?"y":"x",F=t.modifiersData.popperOffsets,N=t.rects.reference,T=t.rects.popper,O="function"==typeof b?b(Object.assign({},t.rects,{placement:t.placement})):b,q="number"==typeof O?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),M=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,I={x:0,y:0};if(F){if(o){var B,R="y"===E?L:x,j="y"===E?C:k,H="y"===E?"height":"width",U=F[E],G=U+y[R],Y=U-y[j],J=m?-T[H]/2:0,z=S===P?N[H]:T[H],K=S===P?-T[H]:-N[H],X=t.elements.arrow,Q=m&&X?v(X):{width:0,height:0},Z=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},ee=Z[R],te=Z[j],ne=le(0,N[H],Q[H]),ie=w?N[H]/2-J-ne-ee-q.mainAxis:z-ne-ee-q.mainAxis,se=w?-N[H]/2+J+ne+te+q.mainAxis:K+ne+te+q.mainAxis,oe=t.elements.arrow&&A(t.elements.arrow),re=oe?"y"===E?oe.clientTop||0:oe.clientLeft||0:0,ce=null!=(B=null==M?void 0:M[E])?B:0,de=U+se-ce,ue=le(m?l(G,U+ie-ce-re):G,U,m?a(Y,de):Y);F[E]=ue,I[E]=ue-U}if(c){var he,pe="x"===E?L:x,ge="x"===E?C:k,me=F[D],fe="y"===D?"height":"width",be=me+y[pe],ve=me-y[ge],ye=-1!==[L,x].indexOf(_),_e=null!=(he=null==M?void 0:M[D])?he:0,Se=ye?be:me-N[fe]-T[fe]-_e+q.altAxis,we=ye?me+N[fe]+T[fe]-_e-q.altAxis:ve,Ee=m&&ye?function(e,t,n){var i=le(e,t,n);return i>n?n:i}(Se,me,we):le(m?Se:be,me,m?we:ve);F[D]=Ee,I[D]=Ee-me}t.modifiersData[i]=I}},requiresIfExists:["offset"]};const de={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,i=e.name,s=e.options,o=n.elements.arrow,r=n.modifiersData.popperOffsets,a=V(n.placement),l=W(a),c=[x,k].indexOf(a)>=0?"height":"width";if(o&&r){var d=function(e,t){return oe("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:re(e,F))}(s.padding,n),u=v(o),h="y"===l?L:x,p="y"===l?C:k,g=n.rects.reference[c]+n.rects.reference[l]-r[l]-n.rects.popper[c],m=r[l]-n.rects.reference[l],f=A(o),b=f?"y"===l?f.clientHeight||0:f.clientWidth||0:0,y=g/2-m/2,_=d[h],S=b-u[c]-d[p],w=b/2-u[c]/2+y,E=le(_,w,S),D=l;n.modifiersData[i]=((t={})[D]=E,t.centerOffset=E-w,t)}},effect:function(e){var t=e.state,n=e.options.element,i=void 0===n?"[data-popper-arrow]":n;null!=i&&("string"!=typeof i||(i=t.elements.popper.querySelector(i)))&&te(t.elements.popper,i)&&(t.elements.arrow=i)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function ue(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function he(e){return[L,k,C,x].some((function(t){return e[t]>=0}))}var pe=H({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,s=e.options,o=s.scroll,r=void 0===o||o,a=s.resize,l=void 0===a||a,c=i(t.elements.popper),d=[].concat(t.scrollParents.reference,t.scrollParents.popper);return r&&d.forEach((function(e){e.addEventListener("scroll",n.update,U)})),l&&c.addEventListener("resize",n.update,U),function(){r&&d.forEach((function(e){e.removeEventListener("scroll",n.update,U)})),l&&c.removeEventListener("resize",n.update,U)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=G({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,i=n.gpuAcceleration,s=void 0===i||i,o=n.adaptive,r=void 0===o||o,a=n.roundOffsets,l=void 0===a||a,c={placement:V(t.placement),variation:$(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,J(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:r,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,J(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},z,K,{name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,i=e.name;if(!t.modifiersData[i]._skip){for(var s=n.mainAxis,o=void 0===s||s,r=n.altAxis,a=void 0===r||r,l=n.fallbackPlacements,c=n.padding,d=n.boundary,u=n.rootBoundary,h=n.altBoundary,p=n.flipVariations,g=void 0===p||p,m=n.allowedAutoPlacements,f=t.options.placement,b=V(f),v=l||(b===f||!g?[Q(f)]:function(e){if(V(e)===D)return[];var t=Q(e);return[ee(e),t,ee(t)]}(f)),y=[f].concat(v).reduce((function(e,n){return e.concat(V(n)===D?function(e,t){void 0===t&&(t={});var n=t,i=n.placement,s=n.boundary,o=n.rootBoundary,r=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?M:l,d=$(i),u=d?a?q:q.filter((function(e){return $(e)===d})):F,h=u.filter((function(e){return c.indexOf(e)>=0}));0===h.length&&(h=u);var p=h.reduce((function(t,n){return t[n]=ae(e,{placement:n,boundary:s,rootBoundary:o,padding:r})[V(n)],t}),{});return Object.keys(p).sort((function(e,t){return p[e]-p[t]}))}(t,{placement:n,boundary:d,rootBoundary:u,padding:c,flipVariations:g,allowedAutoPlacements:m}):n)}),[]),_=t.rects.reference,S=t.rects.popper,w=new Map,E=!0,A=y[0],N=0;N<y.length;N++){var T=y[N],O=V(T),I=$(T)===P,B=[L,C].indexOf(O)>=0,R=B?"width":"height",j=ae(t,{placement:T,boundary:d,rootBoundary:u,altBoundary:h,padding:c}),H=B?I?k:x:I?C:L;_[R]>S[R]&&(H=Q(H));var U=Q(H),W=[];if(o&&W.push(j[O]<=0),a&&W.push(j[H]<=0,j[U]<=0),W.every((function(e){return e}))){A=T,E=!1;break}w.set(T,W)}if(E)for(var G=function(e){var t=y.find((function(t){var n=w.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return A=t,"break"},Y=g?3:1;Y>0;Y--){if("break"===G(Y))break}t.placement!==A&&(t.modifiersData[i]._skip=!0,t.placement=A,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},ce,de,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,i=t.rects.reference,s=t.rects.popper,o=t.modifiersData.preventOverflow,r=ae(t,{elementContext:"reference"}),a=ae(t,{altBoundary:!0}),l=ue(r,i),c=ue(a,s,o),d=he(l),u=he(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:d,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":u})}}]}),ge="tippy-content",me="tippy-backdrop",fe="tippy-arrow",be="tippy-svg-arrow",ve={passive:!0,capture:!0},ye=function(){return document.body};function _e(e,t,n){if(Array.isArray(e)){var i=e[t];return null==i?Array.isArray(n)?n[t]:n:i}return e}function Se(e,t){var n={}.toString.call(e);return 0===n.indexOf("[object")&&n.indexOf(t+"]")>-1}function we(e,t){return"function"==typeof e?e.apply(void 0,t):e}function Ee(e,t){return 0===t?e:function(i){clearTimeout(n),n=setTimeout((function(){e(i)}),t)};var n}function Ae(e){return[].concat(e)}function Le(e,t){-1===e.indexOf(t)&&e.push(t)}function Ce(e){return e.split("-")[0]}function ke(e){return[].slice.call(e)}function xe(e){return Object.keys(e).reduce((function(t,n){return void 0!==e[n]&&(t[n]=e[n]),t}),{})}function De(){return document.createElement("div")}function Fe(e){return["Element","Fragment"].some((function(t){return Se(e,t)}))}function Pe(e){return Se(e,"MouseEvent")}function Ne(e){return!(!e||!e._tippy||e._tippy.reference!==e)}function Te(e){return Fe(e)?[e]:function(e){return Se(e,"NodeList")}(e)?ke(e):Array.isArray(e)?e:ke(document.querySelectorAll(e))}function Oe(e,t){e.forEach((function(e){e&&(e.style.transitionDuration=t+"ms")}))}function qe(e,t){e.forEach((function(e){e&&e.setAttribute("data-state",t)}))}function Me(e){var t,n=Ae(e)[0];return null!=n&&null!=(t=n.ownerDocument)&&t.body?n.ownerDocument:document}function Ie(e,t,n){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach((function(t){e[i](t,n)}))}function Be(e,t){for(var n=t;n;){var i;if(e.contains(n))return!0;n=null==n.getRootNode||null==(i=n.getRootNode())?void 0:i.host}return!1}var Re={isTouch:!1},je=0;function He(){Re.isTouch||(Re.isTouch=!0,window.performance&&document.addEventListener("mousemove",Ue))}function Ue(){var e=performance.now();e-je<20&&(Re.isTouch=!1,document.removeEventListener("mousemove",Ue)),je=e}function Ve(){var e=document.activeElement;if(Ne(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}var $e=!!("undefined"!=typeof window&&"undefined"!=typeof document)&&!!window.msCrypto;var We={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Ge=Object.assign({appendTo:ye,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},We,{allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999}),Ye=Object.keys(Ge);function Je(e){var t=(e.plugins||[]).reduce((function(t,n){var i,s=n.name,o=n.defaultValue;s&&(t[s]=void 0!==e[s]?e[s]:null!=(i=Ge[s])?i:o);return t}),{});return Object.assign({},e,t)}function ze(e,t){var n=Object.assign({},t,{content:we(t.content,[e])},t.ignoreAttributes?{}:function(e,t){return(t?Object.keys(Je(Object.assign({},Ge,{plugins:t}))):Ye).reduce((function(t,n){var i=(e.getAttribute("data-tippy-"+n)||"").trim();if(!i)return t;if("content"===n)t[n]=i;else try{t[n]=JSON.parse(i)}catch(e){t[n]=i}return t}),{})}(e,t.plugins));return n.aria=Object.assign({},Ge.aria,n.aria),n.aria={expanded:"auto"===n.aria.expanded?t.interactive:n.aria.expanded,content:"auto"===n.aria.content?t.interactive?null:"describedby":n.aria.content},n}function Ke(e,t){e.innerHTML=t}function Xe(e){var t=De();return!0===e?t.className=fe:(t.className=be,Fe(e)?t.appendChild(e):Ke(t,e)),t}function Qe(e,t){Fe(t.content)?(Ke(e,""),e.appendChild(t.content)):"function"!=typeof t.content&&(t.allowHTML?Ke(e,t.content):e.textContent=t.content)}function Ze(e){var t=e.firstElementChild,n=ke(t.children);return{box:t,content:n.find((function(e){return e.classList.contains(ge)})),arrow:n.find((function(e){return e.classList.contains(fe)||e.classList.contains(be)})),backdrop:n.find((function(e){return e.classList.contains(me)}))}}function et(e){var t=De(),n=De();n.className="tippy-box",n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var i=De();function s(n,i){var s=Ze(t),o=s.box,r=s.content,a=s.arrow;i.theme?o.setAttribute("data-theme",i.theme):o.removeAttribute("data-theme"),"string"==typeof i.animation?o.setAttribute("data-animation",i.animation):o.removeAttribute("data-animation"),i.inertia?o.setAttribute("data-inertia",""):o.removeAttribute("data-inertia"),o.style.maxWidth="number"==typeof i.maxWidth?i.maxWidth+"px":i.maxWidth,i.role?o.setAttribute("role",i.role):o.removeAttribute("role"),n.content===i.content&&n.allowHTML===i.allowHTML||Qe(r,e.props),i.arrow?a?n.arrow!==i.arrow&&(o.removeChild(a),o.appendChild(Xe(i.arrow))):o.appendChild(Xe(i.arrow)):a&&o.removeChild(a)}return i.className=ge,i.setAttribute("data-state","hidden"),Qe(i,e.props),t.appendChild(n),n.appendChild(i),s(e.props,e.props),{popper:t,onUpdate:s}}et.$$tippy=!0;var tt=1,nt=[],it=[];function st(e,t){var n,i,s,o,r,a,l,c,d=ze(e,Object.assign({},Ge,Je(xe(t)))),u=!1,h=!1,p=!1,g=!1,m=[],f=Ee(Y,d.interactiveDebounce),b=tt++,v=(c=d.plugins).filter((function(e,t){return c.indexOf(e)===t})),y={id:b,reference:e,popper:De(),popperInstance:null,props:d,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:v,clearDelayTimeouts:function(){clearTimeout(n),clearTimeout(i),cancelAnimationFrame(s)},setProps:function(t){0;if(y.state.isDestroyed)return;T("onBeforeUpdate",[y,t]),W();var n=y.props,i=ze(e,Object.assign({},n,xe(t),{ignoreAttributes:!0}));y.props=i,$(),n.interactiveDebounce!==i.interactiveDebounce&&(M(),f=Ee(Y,i.interactiveDebounce));n.triggerTarget&&!i.triggerTarget?Ae(n.triggerTarget).forEach((function(e){e.removeAttribute("aria-expanded")})):i.triggerTarget&&e.removeAttribute("aria-expanded");q(),N(),w&&w(n,i);y.popperInstance&&(X(),Z().forEach((function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})));T("onAfterUpdate",[y,t])},setContent:function(e){y.setProps({content:e})},show:function(){0;var e=y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,i=Re.isTouch&&!y.props.touch,s=_e(y.props.duration,0,Ge.duration);if(e||t||n||i)return;if(x().hasAttribute("disabled"))return;if(T("onShow",[y],!1),!1===y.props.onShow(y))return;y.state.isVisible=!0,k()&&(S.style.visibility="visible");N(),j(),y.state.isMounted||(S.style.transition="none");if(k()){var o=F(),r=o.box,l=o.content;Oe([r,l],0)}a=function(){var e;if(y.state.isVisible&&!g){if(g=!0,S.offsetHeight,S.style.transition=y.props.moveTransition,k()&&y.props.animation){var t=F(),n=t.box,i=t.content;Oe([n,i],s),qe([n,i],"visible")}O(),q(),Le(it,y),null==(e=y.popperInstance)||e.forceUpdate(),T("onMount",[y]),y.props.animation&&k()&&function(e,t){U(e,t)}(s,(function(){y.state.isShown=!0,T("onShown",[y])}))}},function(){var e,t=y.props.appendTo,n=x();e=y.props.interactive&&t===ye||"parent"===t?n.parentNode:we(t,[n]);e.contains(S)||e.appendChild(S);y.state.isMounted=!0,X(),!1}()},hide:function(){0;var e=!y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,i=_e(y.props.duration,1,Ge.duration);if(e||t||n)return;if(T("onHide",[y],!1),!1===y.props.onHide(y))return;y.state.isVisible=!1,y.state.isShown=!1,g=!1,u=!1,k()&&(S.style.visibility="hidden");if(M(),H(),N(!0),k()){var s=F(),o=s.box,r=s.content;y.props.animation&&(Oe([o,r],i),qe([o,r],"hidden"))}O(),q(),y.props.animation?k()&&function(e,t){U(e,(function(){!y.state.isVisible&&S.parentNode&&S.parentNode.contains(S)&&t()}))}(i,y.unmount):y.unmount()},hideWithInteractivity:function(e){0;D().addEventListener("mousemove",f),Le(nt,f),f(e)},enable:function(){y.state.isEnabled=!0},disable:function(){y.hide(),y.state.isEnabled=!1},unmount:function(){0;y.state.isVisible&&y.hide();if(!y.state.isMounted)return;Q(),Z().forEach((function(e){e._tippy.unmount()})),S.parentNode&&S.parentNode.removeChild(S);it=it.filter((function(e){return e!==y})),y.state.isMounted=!1,T("onHidden",[y])},destroy:function(){0;if(y.state.isDestroyed)return;y.clearDelayTimeouts(),y.unmount(),W(),delete e._tippy,y.state.isDestroyed=!0,T("onDestroy",[y])}};if(!d.render)return y;var _=d.render(y),S=_.popper,w=_.onUpdate;S.setAttribute("data-tippy-root",""),S.id="tippy-"+y.id,y.popper=S,e._tippy=y,S._tippy=y;var E=v.map((function(e){return e.fn(y)})),A=e.hasAttribute("aria-expanded");return $(),q(),N(),T("onCreate",[y]),d.showOnCreate&&ee(),S.addEventListener("mouseenter",(function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()})),S.addEventListener("mouseleave",(function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&D().addEventListener("mousemove",f)})),y;function L(){var e=y.props.touch;return Array.isArray(e)?e:[e,0]}function C(){return"hold"===L()[0]}function k(){var e;return!(null==(e=y.props.render)||!e.$$tippy)}function x(){return l||e}function D(){var e=x().parentNode;return e?Me(e):document}function F(){return Ze(S)}function P(e){return y.state.isMounted&&!y.state.isVisible||Re.isTouch||o&&"focus"===o.type?0:_e(y.props.delay,e?0:1,Ge.delay)}function N(e){void 0===e&&(e=!1),S.style.pointerEvents=y.props.interactive&&!e?"":"none",S.style.zIndex=""+y.props.zIndex}function T(e,t,n){var i;(void 0===n&&(n=!0),E.forEach((function(n){n[e]&&n[e].apply(n,t)})),n)&&(i=y.props)[e].apply(i,t)}function O(){var t=y.props.aria;if(t.content){var n="aria-"+t.content,i=S.id;Ae(y.props.triggerTarget||e).forEach((function(e){var t=e.getAttribute(n);if(y.state.isVisible)e.setAttribute(n,t?t+" "+i:i);else{var s=t&&t.replace(i,"").trim();s?e.setAttribute(n,s):e.removeAttribute(n)}}))}}function q(){!A&&y.props.aria.expanded&&Ae(y.props.triggerTarget||e).forEach((function(e){y.props.interactive?e.setAttribute("aria-expanded",y.state.isVisible&&e===x()?"true":"false"):e.removeAttribute("aria-expanded")}))}function M(){D().removeEventListener("mousemove",f),nt=nt.filter((function(e){return e!==f}))}function I(t){if(!Re.isTouch||!p&&"mousedown"!==t.type){var n=t.composedPath&&t.composedPath()[0]||t.target;if(!y.props.interactive||!Be(S,n)){if(Ae(y.props.triggerTarget||e).some((function(e){return Be(e,n)}))){if(Re.isTouch)return;if(y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else T("onClickOutside",[y,t]);!0===y.props.hideOnClick&&(y.clearDelayTimeouts(),y.hide(),h=!0,setTimeout((function(){h=!1})),y.state.isMounted||H())}}}function B(){p=!0}function R(){p=!1}function j(){var e=D();e.addEventListener("mousedown",I,!0),e.addEventListener("touchend",I,ve),e.addEventListener("touchstart",R,ve),e.addEventListener("touchmove",B,ve)}function H(){var e=D();e.removeEventListener("mousedown",I,!0),e.removeEventListener("touchend",I,ve),e.removeEventListener("touchstart",R,ve),e.removeEventListener("touchmove",B,ve)}function U(e,t){var n=F().box;function i(e){e.target===n&&(Ie(n,"remove",i),t())}if(0===e)return t();Ie(n,"remove",r),Ie(n,"add",i),r=i}function V(t,n,i){void 0===i&&(i=!1),Ae(y.props.triggerTarget||e).forEach((function(e){e.addEventListener(t,n,i),m.push({node:e,eventType:t,handler:n,options:i})}))}function $(){var e;C()&&(V("touchstart",G,{passive:!0}),V("touchend",J,{passive:!0})),(e=y.props.trigger,e.split(/\s+/).filter(Boolean)).forEach((function(e){if("manual"!==e)switch(V(e,G),e){case"mouseenter":V("mouseleave",J);break;case"focus":V($e?"focusout":"blur",z);break;case"focusin":V("focusout",z)}}))}function W(){m.forEach((function(e){var t=e.node,n=e.eventType,i=e.handler,s=e.options;t.removeEventListener(n,i,s)})),m=[]}function G(e){var t,n=!1;if(y.state.isEnabled&&!K(e)&&!h){var i="focus"===(null==(t=o)?void 0:t.type);o=e,l=e.currentTarget,q(),!y.state.isVisible&&Pe(e)&&nt.forEach((function(t){return t(e)})),"click"===e.type&&(y.props.trigger.indexOf("mouseenter")<0||u)&&!1!==y.props.hideOnClick&&y.state.isVisible?n=!0:ee(e),"click"===e.type&&(u=!n),n&&!i&&te(e)}}function Y(e){var t=e.target,n=x().contains(t)||S.contains(t);if("mousemove"!==e.type||!n){var i=Z().concat(S).map((function(e){var t,n=null==(t=e._tippy.popperInstance)?void 0:t.state;return n?{popperRect:e.getBoundingClientRect(),popperState:n,props:d}:null})).filter(Boolean);(function(e,t){var n=t.clientX,i=t.clientY;return e.every((function(e){var t=e.popperRect,s=e.popperState,o=e.props.interactiveBorder,r=Ce(s.placement),a=s.modifiersData.offset;if(!a)return!0;var l="bottom"===r?a.top.y:0,c="top"===r?a.bottom.y:0,d="right"===r?a.left.x:0,u="left"===r?a.right.x:0,h=t.top-i+l>o,p=i-t.bottom-c>o,g=t.left-n+d>o,m=n-t.right-u>o;return h||p||g||m}))})(i,e)&&(M(),te(e))}}function J(e){K(e)||y.props.trigger.indexOf("click")>=0&&u||(y.props.interactive?y.hideWithInteractivity(e):te(e))}function z(e){y.props.trigger.indexOf("focusin")<0&&e.target!==x()||y.props.interactive&&e.relatedTarget&&S.contains(e.relatedTarget)||te(e)}function K(e){return!!Re.isTouch&&C()!==e.type.indexOf("touch")>=0}function X(){Q();var t=y.props,n=t.popperOptions,i=t.placement,s=t.offset,o=t.getReferenceClientRect,r=t.moveTransition,l=k()?Ze(S).arrow:null,c=o?{getBoundingClientRect:o,contextElement:o.contextElement||x()}:e,d={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var t=e.state;if(k()){var n=F().box;["placement","reference-hidden","escaped"].forEach((function(e){"placement"===e?n.setAttribute("data-placement",t.placement):t.attributes.popper["data-popper-"+e]?n.setAttribute("data-"+e,""):n.removeAttribute("data-"+e)})),t.attributes.popper={}}}},u=[{name:"offset",options:{offset:s}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!r}},d];k()&&l&&u.push({name:"arrow",options:{element:l,padding:3}}),u.push.apply(u,(null==n?void 0:n.modifiers)||[]),y.popperInstance=pe(c,S,Object.assign({},n,{placement:i,onFirstUpdate:a,modifiers:u}))}function Q(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function Z(){return ke(S.querySelectorAll("[data-tippy-root]"))}function ee(e){y.clearDelayTimeouts(),e&&T("onTrigger",[y,e]),j();var t=P(!0),i=L(),s=i[0],o=i[1];Re.isTouch&&"hold"===s&&o&&(t=o),t?n=setTimeout((function(){y.show()}),t):y.show()}function te(e){if(y.clearDelayTimeouts(),T("onUntrigger",[y,e]),y.state.isVisible){if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(e.type)>=0&&u)){var t=P(!1);t?i=setTimeout((function(){y.state.isVisible&&y.hide()}),t):s=requestAnimationFrame((function(){y.hide()}))}}else H()}}function ot(e,t){void 0===t&&(t={});var n=Ge.plugins.concat(t.plugins||[]);document.addEventListener("touchstart",He,ve),window.addEventListener("blur",Ve);var i=Object.assign({},t,{plugins:n}),s=Te(e).reduce((function(e,t){var n=t&&st(t,i);return n&&e.push(n),e}),[]);return Fe(e)?s[0]:s}ot.defaultProps=Ge,ot.setDefaultProps=function(e){Object.keys(e).forEach((function(t){Ge[t]=e[t]}))},ot.currentInput=Re;Object.assign({},z,{effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow)}});ot.setDefaultProps({render:et});const rt=ot},5042:()=>{}},t={};function n(i){var s=t[i];if(void 0!==s)return s.exports;var o=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.amdD=function(){throw new Error("define cannot be used indirect")},n.amdO={},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";const e={backgroundImage:"",MediaAttribution:!0,applePay:!1,CapitalizeFields:!1,ClickToExpand:!0,CurrencySymbol:"$",CurrencyCode:"USD",AddCurrencySymbol:!0,ThousandsSeparator:"",DecimalSeparator:".",DecimalPlaces:2,MinAmount:1,MaxAmount:1e5,MinAmountMessage:"Amount must be at least $1",MaxAmountMessage:"Amount must be less than $100,000",SkipToMainContentLink:!0,SrcDefer:!0,NeverBounceAPI:null,NeverBounceDateField:null,NeverBounceStatusField:null,NeverBounceDateFormat:"MM/DD/YYYY",FreshAddress:!1,ProgressBar:!1,AutoYear:!1,TranslateFields:!0,Debug:!1,RememberMe:!1,TidyContact:!1,RegionLongFormat:"",CountryDisable:[],Plaid:!1,Placeholders:!1,ENValidators:!1,MobileCTA:!1,CustomCurrency:!1,VGS:!1,PostalCodeValidator:!1,CountryRedirect:!1,WelcomeBack:!1,PageLayouts:["leftleft1col","centerleft1col","centercenter1col","centercenter2col","centerright1col","rightright1col","none"]},t={image:"https://picsum.photos/480/650",imagePosition:"left",title:"Will you change your gift to just {new-amount} a month to boost your impact?",paragraph:"Make a monthly pledge today to support us with consistent, reliable resources during emergency moments.",yesLabel:"Yes! Process My <br> {new-amount} monthly gift",noLabel:"No, thanks. Continue with my <br> {old-amount} one-time gift",otherAmount:!0,otherLabel:"Or enter a different monthly amount:",upsellOriginalGiftAmountFieldName:"",amountRange:[{max:10,suggestion:5},{max:15,suggestion:7},{max:20,suggestion:8},{max:25,suggestion:9},{max:30,suggestion:10},{max:35,suggestion:11},{max:40,suggestion:12},{max:50,suggestion:14},{max:100,suggestion:15},{max:200,suggestion:19},{max:300,suggestion:29},{max:500,suggestion:"Math.ceil((amount / 12)/5)*5"}],minAmount:0,canClose:!0,submitOnClose:!1,oneTime:!0,annual:!1,disablePaymentMethods:[],skipUpsell:!1,conversionField:"",upsellCheckbox:!1},i=[{field:"supporter.firstName",translation:"Nome"},{field:"supporter.lastName",translation:"Sobrenome"},{field:"supporter.phoneNumber",translation:"Celular"},{field:"supporter.address1",translation:"Endereço"},{field:"supporter.address2",translation:"Complemento"},{field:"supporter.postcode",translation:"CEP"},{field:"supporter.city",translation:"Cidade"},{field:"supporter.region",translation:"Estado"},{field:"supporter.country",translation:"País"}],s=[{field:"supporter.address1",translation:"Straße, Hausnummer"},{field:"supporter.postcode",translation:"Postleitzahl"},{field:"supporter.city",translation:"Ort"},{field:"supporter.region",translation:"Bundesland"},{field:"supporter.country",translation:"Land"}],o=[{field:"supporter.address1",translation:"Adresse"},{field:"supporter.postcode",translation:"Code Postal"},{field:"supporter.city",translation:"Ville"},{field:"supporter.region",translation:"Région"},{field:"supporter.country",translation:"Country"}],r=[{field:"supporter.address1",translation:"Adres"},{field:"supporter.postcode",translation:"Postcode"},{field:"supporter.city",translation:"Woonplaats"},{field:"supporter.region",translation:"Provincie"},{field:"supporter.country",translation:"Country"}],a={BR:i,BRA:i,DE:s,DEU:s,FR:o,FRA:o,NL:r,NLD:r},l={enabled:!1,title:"We are sad that you are leaving",text:"Would you mind telling us why you are leaving this page?",buttonText:"Send us your comments",buttonLink:"https://www.4sitestudios.com/",cookieName:"engrid-exit-intent-lightbox",cookieDuration:30,triggers:{visibilityState:!0,mousePosition:!0}};class c{constructor(){this.logger=new fe("Loader","gold","black","🔁"),this.cssElement=document.querySelector('link[href*="engrid."][rel="stylesheet"]'),this.jsElement=document.querySelector('script[src*="engrid."]')}reload(){var e,t,n;const i=this.getOption("assets"),s=p.getBodyData("loaded");let o="false"===this.getOption("engridcss"),r="false"===this.getOption("engridjs");if(s||!i)return o&&this.cssElement&&(this.logger.log("engridcss=false | Removing original stylesheet:",this.cssElement),this.cssElement.remove()),r&&this.jsElement&&(this.logger.log("engridjs=false | Removing original script:",this.jsElement),this.jsElement.remove()),o&&(this.logger.log("engridcss=false | adding top banner CSS"),this.addENgridCSSUnloadedCSS()),r?(this.logger.log("engridjs=false | Skipping JS load."),this.logger.success("LOADED"),!0):(this.logger.success("LOADED"),!1);this.logger.log("RELOADING"),p.setBodyData("loaded","true");const a=p.getBodyData("theme"),l=null!==(e=this.getOption("repo-name"))&&void 0!==e?e:`engrid-${a}`;let c="",d="";switch(i){case"local":this.logger.log("LOADING LOCAL"),p.setBodyData("assets","local"),c=`https://${l}.test/dist/engrid.js`,d=`https://${l}.test/dist/engrid.css`;break;case"flush":this.logger.log("FLUSHING CACHE");const e=Date.now(),s=new URL((null===(t=this.jsElement)||void 0===t?void 0:t.getAttribute("src"))||"");s.searchParams.set("v",e.toString()),c=s.toString();const o=new URL((null===(n=this.cssElement)||void 0===n?void 0:n.getAttribute("href"))||"");o.searchParams.set("v",e.toString()),d=o.toString();break;default:this.logger.log("LOADING EXTERNAL"),c=`https://s3.amazonaws.com/engrid-dev.4sitestudios.com/${l}/${i}/engrid.js`,d=`https://s3.amazonaws.com/engrid-dev.4sitestudios.com/${l}/${i}/engrid.css`}return o&&this.cssElement&&(this.logger.log("engridcss=false | Removing original stylesheet:",this.cssElement),this.cssElement.remove()),o&&d&&""!==d&&this.logger.log("engridcss=false | Skipping injection of stylesheet:",d),o?(this.logger.log("engridcss=false | adding top banner CSS"),this.addENgridCSSUnloadedCSS()):this.setCssFile(d),r&&this.jsElement&&(this.logger.log("engridjs=false | Removing original script:",this.jsElement),this.jsElement.remove()),r&&c&&""!==c&&this.logger.log("engridjs=false | Skipping injection of script:",c),r||this.setJsFile(c),!!i}getOption(e){const t=p.getUrlParameter(e);return t&&["assets","engridcss","engridjs"].includes(e)?t:window.EngridLoader&&window.EngridLoader.hasOwnProperty(e)?window.EngridLoader[e]:this.jsElement&&this.jsElement.hasAttribute("data-"+e)?this.jsElement.getAttribute("data-"+e):null}setCssFile(e){if(""!==e)if(this.cssElement)this.logger.log("Replacing stylesheet:",e),this.cssElement.setAttribute("href",e);else{this.logger.log("Injecting stylesheet:",e);const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("type","text/css"),t.setAttribute("media","all"),t.setAttribute("href",e),document.head.appendChild(t)}}setJsFile(e){if(""===e)return;this.logger.log("Injecting script:",e);const t=document.createElement("script");t.setAttribute("src",e),document.head.appendChild(t)}addENgridCSSUnloadedCSS(){document.body.insertAdjacentHTML("beforeend",'<style>\n html,\n body {\n background-color: #ffffff;\n }\n\n body {\n opacity: 1;\n margin: 0;\n }\n\n body:before {\n content: "ENGRID CSS UNLOADED";\n display: flex;\n justify-content: center;\n align-items: center;\n width: 100%;\n background-color: #ffff00;\n padding: 1rem;\n margin-bottom: 1rem;\n font-family: sans-serif;\n font-weight: 600;\n }\n\n .en__component--advrow {\n flex-direction: column;\n max-width: 600px;\n margin: 0 auto;\n }\n\n .en__component--advrow * {\n max-width: 100%;\n height: auto;\n }\n </style>')}}var d=n(291);class u{constructor(){this.logger=new fe("EnForm"),this._onSubmit=new d.nz,this._onValidate=new d.nz,this._onError=new d.nz,this.submit=!0,this.submitPromise=!1,this.validate=!0,this.validatePromise=!1}static getInstance(){return u.instance||(u.instance=new u),u.instance}dispatchSubmit(){this._onSubmit.dispatch(),this.logger.log("dispatchSubmit")}dispatchValidate(){this._onValidate.dispatch(),this.logger.log("dispatchValidate")}dispatchError(){this._onError.dispatch(),this.logger.log("dispatchError")}submitForm(){const e=document.querySelector("form .en__submit button");if(e){const t=document.getElementById("enModal");t&&t.classList.add("is-submitting"),e.click(),this.logger.log("submitForm")}}get onSubmit(){return this._onSubmit.asEvent()}get onError(){return this._onError.asEvent()}get onValidate(){return this._onValidate.asEvent()}}class h{constructor(e="transaction.donationAmt",t="transaction.donationAmt.other"){this._onAmountChange=new d.FK,this._amount=0,this._radios="",this._other="",this._dispatch=!0,this._other=t,this._radios=e,document.addEventListener("change",(n=>{const i=n.target;if(i)if(i.name==e)this.amount=parseFloat(i.value);else if(i.name==t){const e=p.cleanAmount(i.value);i.value=e%1!=0?e.toFixed(2):e.toString(),this.amount=e}}));const n=document.querySelector(`[name='${this._other}']`);n&&n.addEventListener("keyup",(e=>{this.amount=p.cleanAmount(n.value)}))}static getInstance(e="transaction.donationAmt",t="transaction.donationAmt.other"){return h.instance||(h.instance=new h(e,t)),h.instance}get amount(){return this._amount}set amount(e){this._amount=e||0,this._dispatch&&this._onAmountChange.dispatch(this._amount)}get onAmountChange(){return this._onAmountChange.asEvent()}load(){const e=document.querySelector('input[name="'+this._radios+'"]:checked');if(e){let t=parseFloat(e.value||"");if(t>0)this.amount=parseFloat(e.value);else{const e=document.querySelector('input[name="'+this._other+'"]');t=p.cleanAmount(e.value),this.amount=t}}else if(p.checkNested(window.EngagingNetworks,"require","_defined","enjs","getDonationTotal")&&p.checkNested(window.EngagingNetworks,"require","_defined","enjs","getDonationFee")){const e=window.EngagingNetworks.require._defined.enjs.getDonationTotal()-window.EngagingNetworks.require._defined.enjs.getDonationFee();e&&(this.amount=e)}}setAmount(e,t=!0){if(!document.getElementsByName(this._radios).length)return;this._dispatch=t;let n=Array.from(document.querySelectorAll('input[name="'+this._radios+'"]')).filter((t=>t instanceof HTMLInputElement&&parseInt(t.value)==e));if(n.length){const e=n[0];e.checked=!0;const t=new Event("change",{bubbles:!0,cancelable:!0});e.dispatchEvent(t),this.clearOther()}else{const t=document.querySelector('input[name="'+this._other+'"]');if(t){const n=document.querySelector(`.en__field--donationAmt.en__field--withOther .en__field__item:nth-last-child(2) input[name="${this._radios}"]`);n&&(n.checked=!0),t.value=parseFloat(e.toString()).toFixed(2);const i=new Event("change",{bubbles:!0,cancelable:!0});t.dispatchEvent(i);t.parentNode.classList.remove("en__field__item--hidden")}}this.amount=e,this._dispatch=!0}clearOther(){const e=document.querySelector('input[name="'+this._other+'"]');e.value="";e.parentNode.classList.add("en__field__item--hidden")}}class p{constructor(){if(!p.enForm)throw new Error("Engaging Networks Form Not Found!")}static get enForm(){return document.querySelector("form.en__component")}static get debug(){return!!this.getOption("Debug")}static get demo(){return"DEMO"===this.getUrlParameter("mode")}static getUrlParameter(e){const t=new URLSearchParams(window.location.search);if(e.endsWith("[]")){let n=[];return t.forEach(((t,i)=>{i.startsWith(e.replace("[]",""))&&n.push(new Object({[i]:t}))})),n.length>0?n:null}return t.has(e)?t.get(e)||!0:null}static getField(e){return document.querySelector(`[name="${e}"]`)}static getFieldValue(e){return new FormData(this.enForm).getAll(e).join(",")}static setFieldValue(e,t,n=!0,i=!1){t!==p.getFieldValue(e)&&(document.getElementsByName(e).forEach((e=>{if("type"in e){switch(e.type){case"select-one":case"select-multiple":for(const n of e.options)n.value==t&&(n.selected=!0,i&&e.dispatchEvent(new Event("change",{bubbles:!0})));break;case"checkbox":case"radio":e.value==t&&(e.checked=!0,i&&e.dispatchEvent(new Event("change",{bubbles:!0})));break;default:e.value=t,i&&(e.dispatchEvent(new Event("change",{bubbles:!0})),e.dispatchEvent(new Event("blur",{bubbles:!0})))}e.setAttribute("engrid-value-changed","")}})),n&&this.enParseDependencies())}static createHiddenInput(e,t=""){var n;const i=document.createElement("div");i.classList.add("en__component","en__component--formblock","hide");const s=document.createElement("div");s.classList.add("en__field","en__field--text");const o=document.createElement("div");o.classList.add("en__field__element","en__field__element--text");const r=document.createElement("input");r.classList.add("en__field__input","en__field__input--text","engrid-added-input"),r.setAttribute("name",e),r.setAttribute("type","hidden"),r.setAttribute("value",t),o.appendChild(r),s.appendChild(o),i.appendChild(s);const a=document.querySelector(".en__submit");if(a){const e=a.closest(".en__component");e&&(null===(n=e.parentNode)||void 0===n||n.insertBefore(i,e.nextSibling))}else p.enForm.appendChild(i);return r}static enParseDependencies(){var e,t,n,i,s,o;if(window.EngagingNetworks&&"function"==typeof(null===(s=null===(i=null===(n=null===(t=null===(e=window.EngagingNetworks)||void 0===e?void 0:e.require)||void 0===t?void 0:t._defined)||void 0===n?void 0:n.enDependencies)||void 0===i?void 0:i.dependencies)||void 0===s?void 0:s.parseDependencies)){const e=[];if("dependencies"in window.EngagingNetworks){const t=document.querySelector(".en__field--donationAmt");if(t){let n=(null===(o=[...t.classList.values()].filter((e=>e.startsWith("en__field--")&&Number(e.substring(11))>0)).toString().match(/\d/g))||void 0===o?void 0:o.join(""))||"";n&&(window.EngagingNetworks.dependencies.forEach((t=>{if("actions"in t&&t.actions.length>0){let i=!1;t.actions.forEach((e=>{"target"in e&&e.target==n&&(i=!0)})),i||e.push(t)}})),e.length>0&&(window.EngagingNetworks.require._defined.enDependencies.dependencies.parseDependencies(e),p.getOption("Debug")&&console.log("EN Dependencies Triggered",e)))}}}}static getGiftProcess(){return"pageJson"in window?window.pageJson.giftProcess:null}static getPageCount(){return"pageJson"in window?window.pageJson.pageCount:null}static getPageNumber(){return"pageJson"in window?window.pageJson.pageNumber:null}static getPageID(){return"pageJson"in window?window.pageJson.campaignPageId:0}static getClientID(){return"pageJson"in window?window.pageJson.clientId:0}static getDataCenter(){return p.getClientID()>=1e4?"us":"ca"}static getPageType(){if(!("pageJson"in window)||!("pageType"in window.pageJson))return"UNKNOWN";switch(window.pageJson.pageType){case"donation":case"premiumgift":return"DONATION";case"e-card":return"ECARD";case"otherdatacapture":case"survey":return"SURVEY";case"emailtotarget":return"EMAILTOTARGET";case"advocacypetition":return"ADVOCACY";case"emailsubscribeform":return"SUBSCRIBEFORM";case"supporterhub":return"SUPPORTERHUB";case"unsubscribe":return"UNSUBSCRIBE";case"tweetpage":return"TWEETPAGE";default:return"UNKNOWN"}}static setBodyData(e,t){const n=document.querySelector("body");"boolean"!=typeof t||!1!==t?n.setAttribute(`data-engrid-${e}`,t.toString()):n.removeAttribute(`data-engrid-${e}`)}static getBodyData(e){return document.querySelector("body").getAttribute(`data-engrid-${e}`)}static hasBodyData(e){return document.querySelector("body").hasAttribute(`data-engrid-${e}`)}static getOption(e){return window.EngridOptions[e]||null}static loadJS(e,t=null,n=!0){const i=document.createElement("script");i.src=e,i.onload=t,n?document.head.appendChild(i):document.body.appendChild(i)}static formatNumber(e,t=2,n=".",i=","){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");const s=isFinite(+e)?+e:0,o=isFinite(+t)?Math.abs(t):0,r=void 0===i?",":i,a=void 0===n?".":n;let l=[];return l=(o?function(e,t){const n=Math.pow(10,t);return""+Math.round(e*n)/n}(s,o):""+Math.round(s)).split("."),l[0].length>3&&(l[0]=l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,r)),(l[1]||"").length<o&&(l[1]=l[1]||"",l[1]+=new Array(o-l[1].length+1).join("0")),l.join(a)}static cleanAmount(e){const t=e.replace(/[^0-9,\.]/g,"").split(/[,.]+/),n=e.replace(/[^.,]/g,"").split("");if(1===t.length)return parseInt(t[0])||0;if(t.map(((e,n)=>n>0&&n+1!==t.length&&3!==e.length)).includes(!0))return 0;if(n.length>1&&!n.includes("."))return 0;if([...new Set(n.slice(0,-1))].length>1)return 0;if(t[t.length-1].length<=2){const e=t.pop()||"00";return parseInt(e)>0?parseFloat(Number(parseInt(t.join(""))+"."+e).toFixed(2)):parseInt(t.join(""))}return parseInt(t.join(""))}static disableSubmit(e=""){const t=document.querySelector(".en__submit button");if(!t)return!1;t.dataset.originalText=t.innerHTML;let n="<span class='loader-wrapper'><span class='loader loader-quart'></span><span class='submit-button-text-wrapper'>"+e+"</span></span>";return t.disabled=!0,t.innerHTML=n,!0}static enableSubmit(){const e=document.querySelector(".en__submit button");return!!e&&(!!e.dataset.originalText&&(e.disabled=!1,e.innerHTML=e.dataset.originalText,delete e.dataset.originalText,!0))}static formatDate(e,t="MM/DD/YYYY"){const n=e.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}).split("/");return t.replace(/YYYY/g,n[2]).replace(/MM/g,n[0]).replace(/DD/g,n[1]).replace(/YY/g,n[2].substr(2,2))}static checkNested(e,...t){for(let n=0;n<t.length;n++){if(!e||!e.hasOwnProperty(t[n]))return!1;e=e[t[n]]}return!0}static deepMerge(e,t){for(const n in t)t[n]instanceof Object&&Object.assign(t[n],p.deepMerge(e[n],t[n]));return Object.assign(e||{},t),e}static setError(e,t){const n="string"==typeof e?document.querySelector(e):e;if(n){n.classList.add("en__field--validationFailed");let e=n.querySelector(".en__field__error");e?e.innerHTML=t:(e=document.createElement("div"),e.classList.add("en__field__error"),e.innerHTML=t,n.insertBefore(e,n.firstChild))}}static removeError(e){const t="string"==typeof e?document.querySelector(e):e;if(t){t.classList.remove("en__field--validationFailed");const e=t.querySelector(".en__field__error");e&&t.removeChild(e)}}static isVisible(e){return!!e&&!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}static getCurrencySymbol(){const e=p.getField("transaction.paycurrency");if(e){const t="SELECT"===e.tagName?e.options[e.selectedIndex]:e;if(t.dataset.currencySymbol)return t.dataset.currencySymbol;return{USD:"$",EUR:"€",GBP:"£",AUD:"$",CAD:"$",JPY:"¥"}[e.value]||"$"}return p.getOption("CurrencySymbol")||"$"}static getCurrencyCode(){const e=p.getField("transaction.paycurrency");return e?e.value||"USD":p.getOption("CurrencyCode")||"USD"}static addHtml(e,t="body",n="before"){var i,s;const o=document.querySelector(t);if("object"==typeof e&&(e=e.outerHTML),o){const t=document.createRange().createContextualFragment(e);"before"===n?null===(i=o.parentNode)||void 0===i||i.insertBefore(t,o):null===(s=o.parentNode)||void 0===s||s.insertBefore(t,o.nextSibling)}}static removeHtml(e){const t=document.querySelector(e);t&&t.remove()}static slugify(e){return e.toString().toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}static watchForError(e){const t=document.querySelector(".en__errorList");let n=e.toString();var i;if(0===n.indexOf("function")&&(n=n.replace("function ","")),n.indexOf("(")>0&&(n=n.substring(0,n.indexOf("("))),n=n.replace(/[^a-zA-Z0-9]/g,""),n=n.substring(0,20),n="engrid"+((i=n).charAt(0).toUpperCase()+i.slice(1)),t&&!t.dataset[n]){t.dataset[n]="true";new MutationObserver((function(t){t.forEach((function(t){"childList"===t.type&&t.addedNodes.length>0&&e()}))})).observe(t,{childList:!0})}}static getPaymentType(){return p.getFieldValue("transaction.paymenttype")}static setPaymentType(e){const t=p.getField("transaction.paymenttype");if(t){const n=Array.from(t.options).find((t=>"card"===e.toLowerCase()?["card","visa","vi"].includes(t.value.toLowerCase()):e.toLowerCase()===t.value.toLowerCase()));n?(n.selected=!0,t.value=n.value):t.value=e;const i=new Event("change",{bubbles:!0,cancelable:!0});t.dispatchEvent(i)}}static isInViewport(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}}class g{constructor(){this._onFrequencyChange=new d.FK,this._frequency="onetime",this._recurring="n",this._dispatch=!0,document.addEventListener("change",(e=>{const t=e.target;t&&"transaction.recurrpay"==t.name&&(this.recurring=t.value,"radio"==t.type&&(this.frequency="n"==t.value.toLowerCase()?"onetime":"monthly",p.setFieldValue("transaction.recurrfreq",this.frequency.toUpperCase()))),t&&"transaction.recurrfreq"==t.name&&(this.frequency=t.value)})),p.getGiftProcess()&&(p.setBodyData("transaction-recurring-frequency",sessionStorage.getItem("engrid-transaction-recurring-frequency")||"onetime"),p.setBodyData("transaction-recurring",window.pageJson.recurring?"y":"n"))}static getInstance(){return g.instance||(g.instance=new g),g.instance}get frequency(){return this._frequency}set frequency(e){this._frequency=e.toLowerCase()||"onetime",this._dispatch&&this._onFrequencyChange.dispatch(this._frequency),p.setBodyData("transaction-recurring-frequency",this._frequency),sessionStorage.setItem("engrid-transaction-recurring-frequency",this._frequency)}get recurring(){return this._recurring}set recurring(e){this._recurring=e.toLowerCase()||"n",p.setBodyData("transaction-recurring",this._recurring)}get onFrequencyChange(){return this._onFrequencyChange.asEvent()}load(){var e;this.frequency=p.getFieldValue("transaction.recurrfreq")||sessionStorage.getItem("engrid-transaction-recurring-frequency")||"onetime";p.getField("transaction.recurrpay")?this.recurring=p.getFieldValue("transaction.recurrpay"):p.checkNested(window.EngagingNetworks,"require","_defined","enjs","getSupporterData")&&(this.recurring=(null===(e=window.EngagingNetworks.require._defined.enjs.getSupporterData("recurrpay"))||void 0===e?void 0:e.toLowerCase())||"n")}setRecurrency(e,t=!0){document.getElementsByName("transaction.recurrpay").length&&(this._dispatch=t,p.setFieldValue("transaction.recurrpay",e.toUpperCase()),this._dispatch=!0)}setFrequency(e,t=!0){if(!document.getElementsByName("transaction.recurrfreq").length)return;this._dispatch=t;let n=Array.from(document.querySelectorAll('input[name="transaction.recurrfreq"]')).filter((t=>t instanceof HTMLInputElement&&t.value==e.toUpperCase()));if(n.length){n[0].checked=!0,this.frequency=e.toLowerCase(),"onetime"===this.frequency?this.setRecurrency("N",t):this.setRecurrency("Y",t)}this._dispatch=!0}}class m{constructor(){this._onFeeChange=new d.FK,this._amount=h.getInstance(),this._form=u.getInstance(),this._fee=0,this._field=null,document.getElementsByName("transaction.donationAmt").length&&(this._field=this.isENfeeCover()?document.querySelector("#en__field_transaction_feeCover"):document.querySelector('input[name="supporter.processing_fees"]'),this._field instanceof HTMLInputElement&&this._field.addEventListener("change",(e=>{this._field instanceof HTMLInputElement&&this._field.checked&&!this._subscribe&&(this._subscribe=this._form.onSubmit.subscribe((()=>this.addFees()))),this._onFeeChange.dispatch(this.fee)})))}static getInstance(){return m.instance||(m.instance=new m),m.instance}get onFeeChange(){return this._onFeeChange.asEvent()}get fee(){return this.calculateFees()}set fee(e){this._fee=e,this._onFeeChange.dispatch(this._fee)}calculateFees(e=0){var t;if(this._field instanceof HTMLInputElement&&this._field.checked){if(this.isENfeeCover())return e>0?window.EngagingNetworks.require._defined.enjs.feeCover.fee(e):window.EngagingNetworks.require._defined.enjs.getDonationFee();const n=Object.assign({processingfeepercentadded:"0",processingfeefixedamountadded:"0"},null===(t=this._field)||void 0===t?void 0:t.dataset),i=e>0?e:this._amount.amount,s=parseFloat(n.processingfeepercentadded)/100*i+parseFloat(n.processingfeefixedamountadded);return Math.round(100*s)/100}return 0}addFees(){this._form.submit&&!this.isENfeeCover()&&this._amount.setAmount(this._amount.amount+this.fee,!1)}removeFees(){this.isENfeeCover()||this._amount.setAmount(this._amount.amount-this.fee)}isENfeeCover(){if("feeCover"in window.EngagingNetworks)for(const e in window.EngagingNetworks.feeCover)if(window.EngagingNetworks.feeCover.hasOwnProperty(e))return!0;return!1}}class f{constructor(){this.logger=new fe("RememberMeEvents"),this._onLoad=new d.FK,this._onClear=new d.nz,this.hasData=!1}static getInstance(){return f.instance||(f.instance=new f),f.instance}dispatchLoad(e){this.hasData=e,this._onLoad.dispatch(e),this.logger.log(`dispatchLoad: ${e}`)}dispatchClear(){this._onClear.dispatch(),this.logger.log("dispatchClear")}get onLoad(){return this._onLoad.asEvent()}get onClear(){return this._onClear.asEvent()}}class b{constructor(){this._onCountryChange=new d.FK,this._country="",this._field=null,this._field=document.getElementById("en__field_supporter_country"),this._field&&(document.addEventListener("change",(e=>{const t=e.target;t&&"supporter.country"==t.name&&(this.country=t.value)})),this.country=p.getFieldValue("supporter.country"))}static getInstance(){return b.instance||(b.instance=new b),b.instance}get countryField(){return this._field}get onCountryChange(){return this._onCountryChange.asEvent()}get country(){return this._country}set country(e){this._country=e,this._onCountryChange.dispatch(this._country)}}class v extends p{constructor(t){super(),this._form=u.getInstance(),this._fees=m.getInstance(),this._amount=h.getInstance("transaction.donationAmt","transaction.donationAmt.other"),this._frequency=g.getInstance(),this._country=b.getInstance(),this.logger=new fe("App","black","white","🍏");const n=new c;this.options=Object.assign(Object.assign({},e),t),window.EngridOptions=this.options,this._dataLayer=ye.getInstance(),!0!==p.getUrlParameter("pbedit")&&"true"!==p.getUrlParameter("pbedit")?n.reload()||("local"===p.getBodyData("assets")&&"false"!==p.getUrlParameter("debug")&&"log"!==p.getUrlParameter("debug")&&(window.EngridOptions.Debug=!0),"loading"!==document.readyState?this.run():document.addEventListener("DOMContentLoaded",(()=>{this.run()})),window.onresize=()=>{this.onResize()}):window.location.href=`https://${p.getDataCenter()}.engagingnetworks.app/index.html#pages/${p.getPageID()}/edit`}run(){if(!p.checkNested(window.EngagingNetworks,"require","_defined","enjs"))return this.logger.danger("Engaging Networks JS Framework NOT FOUND"),void setTimeout((()=>{this.run()}),100);window.hasOwnProperty("EngridPageOptions")&&(this.options=Object.assign(Object.assign({},this.options),window.EngridPageOptions),window.EngridOptions=this.options),p.checkNested(window,"pageJson","pageType")||window.setTimeout((()=>{console.log("%c ⛔️ pageJson.pageType NOT FOUND - Go to the Account Settings and Expose the Transaction Details %s","background-color: red; color: white; font-size: 22px; font-weight: bold;","https://knowledge.engagingnetworks.net/datareports/expose-transaction-details-pagejson")}),2e3),(this.options.Debug||"true"==v.getUrlParameter("debug"))&&v.setBodyData("debug",""),new H,new W,new $,new $e,new X("transaction.giveBySelect","giveBySelect-"),new X("transaction.inmem","inmem-"),new X("transaction.recurrpay","recurrpay-");let e=[];document.querySelectorAll("input[type=radio]").forEach((t=>{"name"in t&&!1===e.includes(t.name)&&e.push(t.name)})),e.forEach((e=>{new X(e,"engrid__"+e.replace(/\./g,"")+"-")}));document.querySelectorAll("input[type=checkbox]").forEach((e=>{"name"in e&&new X(e.name,"engrid__"+e.name.replace(/\./g,"")+"-")})),this._form.onSubmit.subscribe((()=>this.onSubmit())),this._form.onError.subscribe((()=>this.onError())),this._form.onValidate.subscribe((()=>this.onValidate())),this._amount.onAmountChange.subscribe((e=>this.logger.success(`Live Amount: ${e}`))),this._frequency.onFrequencyChange.subscribe((e=>{this.logger.success(`Live Frequency: ${e}`),setTimeout((()=>{this._amount.load()}),150)})),this._form.onSubmit.subscribe((e=>this.logger.success("Submit: "+JSON.stringify(e)))),this._form.onError.subscribe((e=>this.logger.danger("Error: "+JSON.stringify(e)))),this._country.onCountryChange.subscribe((e=>this.logger.success(`Country: ${e}`))),window.enOnSubmit=()=>(this._form.submit=!0,this._form.submitPromise=!1,this._form.dispatchSubmit(),p.watchForError(p.enableSubmit),!!this._form.submit&&(this._form.submitPromise?this._form.submitPromise:(this.logger.success("enOnSubmit Success"),!0))),window.enOnError=()=>{this._form.dispatchError()},window.enOnValidate=()=>(this._form.validate=!0,this._form.validatePromise=!1,this._form.dispatchValidate(),!!this._form.validate&&(this._form.validatePromise?this._form.validatePromise:(this.logger.success("Validation Passed"),!0))),new U,new et,new V,new J(this.options),new ae,new K,new z,new y,new _e,new Se,new Fe,new Pe,new Ne,window.setTimeout((()=>{this._frequency.load()}),1e3),new Je,new xe,new De,new se,this.options.MediaAttribution&&new Y,this.options.applePay&&new O,this.options.CapitalizeFields&&new M,this.options.AutoYear&&new I,new B,new R,this.options.ClickToExpand&&new j,this.options.SkipToMainContentLink&&new oe,this.options.SrcDefer&&new re,this.options.ProgressBar&&new ue;try{this.options.RememberMe&&"object"==typeof this.options.RememberMe&&window.localStorage&&new pe(this.options.RememberMe)}catch(e){}this.options.NeverBounceAPI&&new ce(this.options.NeverBounceAPI,this.options.NeverBounceDateField,this.options.NeverBounceStatusField,this.options.NeverBounceDateFormat),this.options.FreshAddress&&new de,new ge,new me,new be,new ve,new q,new we,new Ee,new le,new Ae,new Le,new Xe,this.options.Debug&&new Oe,this.options.TidyContact&&new ke,this.options.TranslateFields&&new ie,new Ie,new Be,new Ye,"DONATION"===p.getPageType()&&new Re,new je,new He,new Ue,this.options.Plaid&&new Ve,new Ge,new We,new ze,new Ke,new Qe,new Ze,new tt,new it,new rt,new at,new ot,new lt;let t=this.options.Debug;try{!t&&window.sessionStorage.hasOwnProperty(Te.debugSessionStorageKey)&&(t=!0)}catch(e){}t&&new Te(this.options.PageLayouts),"branding"===p.getUrlParameter("development")&&(new Me).show(),p.setBodyData("js-loading","finished"),window.EngridVersion=dt,this.logger.success(`VERSION: ${dt}`);let n="function"==typeof window.onload?window.onload:null;"loading"!==document.readyState?this.onLoad():window.onload=e=>{this.onLoad(),n&&n.bind(window,e)}}onLoad(){this.options.onLoad&&this.options.onLoad()}onResize(){this.options.onResize&&this.options.onResize()}onValidate(){this.options.onValidate&&(this.logger.log("Client onValidate Triggered"),this.options.onValidate())}onSubmit(){this.options.onSubmit&&(this.logger.log("Client onSubmit Triggered"),this.options.onSubmit())}onError(){this.options.onError&&(this.logger.danger("Client onError Triggered"),this.options.onError())}static log(e){new fe("Client","brown","aliceblue","🍪").log(e)}}class y{constructor(){this._frequency=g.getInstance(),this.shouldRun()&&(this._frequency.onFrequencyChange.subscribe((e=>window.setTimeout(this.fixAmountLabels.bind(this),100))),window.setTimeout(this.fixAmountLabels.bind(this),300))}shouldRun(){return!("DONATION"!==p.getPageType()||!p.getOption("AddCurrencySymbol"))}fixAmountLabels(){let e=document.querySelectorAll(".en__field--donationAmt label");const t=p.getCurrencySymbol()||"";e.forEach((e=>{isNaN(e.innerText)||(e.innerText=t+e.innerText)}))}}var _=function(e,t,n,i){return new(n||(n=Promise))((function(s,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))};const S=window.ApplePaySession,w=window.merchantIdentifier,E=window.merchantDomainName,A=window.merchantDisplayName,L=window.merchantSessionIdentifier,C=window.merchantNonce,k=window.merchantEpochTimestamp,x=window.merchantSignature,D=window.merchantCountryCode,F=window.merchantCurrencyCode,P=window.merchantSupportedNetworks,N=window.merchantCapabilities,T=window.merchantTotalLabel;class O{constructor(){this.applePay=document.querySelector('.en__field__input.en__field__input--radio[value="applepay"]'),this._amount=h.getInstance(),this._fees=m.getInstance(),this._form=u.getInstance(),this.checkApplePay()}checkApplePay(){return _(this,void 0,void 0,(function*(){const e=document.querySelector("form.en__component--page");if(!this.applePay||!window.hasOwnProperty("ApplePaySession")){const e=document.querySelector(".en__field__item.applepay");return e&&e.remove(),p.debug&&console.log("Apple Pay DISABLED"),!1}const t=S.canMakePaymentsWithActiveCard(w);let n=!1;yield t.then((t=>{if(n=t,t){let t=document.createElement("input");t.setAttribute("type","hidden"),t.setAttribute("name","PkPaymentToken"),t.setAttribute("id","applePayToken"),e.appendChild(t),this._form.onSubmit.subscribe((()=>this.onPayClicked()))}})),p.debug&&console.log("applePayEnabled",n);let i=this.applePay.closest(".en__field__item");return n?null==i||i.classList.add("applePayWrapper"):i&&(i.style.display="none"),n}))}performValidation(e){return new Promise((function(t,n){var i={};i.merchantIdentifier=w,i.merchantSessionIdentifier=L,i.nonce=C,i.domainName=E,i.epochTimestamp=k,i.signature=x;var s="/ea-dataservice/rest/applepay/validateurl?url="+e+("&merchantIdentifier="+w+"&merchantDomain="+E+"&displayName="+A),o=new XMLHttpRequest;o.onload=function(){var e=JSON.parse(this.responseText);p.debug&&console.log("Apple Pay Validation",e),t(e)},o.onerror=n,o.open("GET",s),o.send()}))}log(e,t){var n=new XMLHttpRequest;n.open("GET","/ea-dataservice/rest/applepay/log?name="+e+"&msg="+t),n.send()}sendPaymentToken(e){return new Promise((function(e,t){e(!0)}))}onPayClicked(){if(!this._form.submit)return;const e=document.querySelector("#en__field_transaction_paymenttype"),t=document.getElementById("applePayToken"),n=this._form;if("applepay"==e.value&&""==t.value)try{let e=this._amount.amount+this._fees.fee;var i=new S(1,{supportedNetworks:P,merchantCapabilities:N,countryCode:D,currencyCode:F,total:{label:T,amount:e}}),s=this;return i.onvalidatemerchant=function(e){s.performValidation(e.validationURL).then((function(e){p.debug&&console.log("Apple Pay merchantSession",e),i.completeMerchantValidation(e)}))},i.onpaymentauthorized=function(e){s.sendPaymentToken(e.payment.token).then((function(t){p.debug&&console.log("Apple Pay Token",e.payment.token),document.getElementById("applePayToken").value=JSON.stringify(e.payment.token),n.submitForm()}))},i.oncancel=function(e){p.debug&&console.log("Cancelled",e),alert("You cancelled. Sorry it didn't work out."),n.dispatchError()},i.begin(),this._form.submit=!1,!1}catch(e){alert("Developer mistake: '"+e.message+"'"),n.dispatchError()}return this._form.submit=!0,!0}}class q{constructor(){this.addRequired(),this.addLabel(),this.addGroupRole()}addGroupRole(){document.querySelectorAll(".en__field--radio").forEach((e=>{e.setAttribute("role","group");const t=e.querySelector("label");t&&(t.setAttribute("id",`en__field__label--${Math.random().toString(36).slice(2,7)}`),e.setAttribute("aria-labelledby",t.id))}))}addRequired(){document.querySelectorAll(".en__mandatory .en__field__input").forEach((e=>{e.setAttribute("aria-required","true")}))}addLabel(){const e=document.querySelector(".en__field__input--otheramount");e&&e.setAttribute("aria-label","Enter your custom donation amount");document.querySelectorAll(".en__field__input--splitselect").forEach((e=>{var t,n,i,s;const o=e.querySelector("option");!o||""!==o.value||(null===(n=null===(t=o.textContent)||void 0===t?void 0:t.toLowerCase())||void 0===n?void 0:n.includes("select"))||(null===(s=null===(i=o.textContent)||void 0===i?void 0:i.toLowerCase())||void 0===s?void 0:s.includes("choose"))||e.setAttribute("aria-label",o.textContent||"")}))}}class M{constructor(){this._form=u.getInstance(),this._form.onSubmit.subscribe((()=>this.capitalizeFields("en__field_supporter_firstName","en__field_supporter_lastName","en__field_supporter_address1","en__field_supporter_city")))}capitalizeFields(...e){e.forEach((e=>this.capitalize(e)))}capitalize(e){let t=document.getElementById(e);return t&&(t.value=t.value.replace(/\w\S*/g,(e=>e.replace(/^\w/,(e=>e.toUpperCase())))),p.debug&&console.log("Capitalized",t.value)),!0}}class I{constructor(){if(this.yearField=document.querySelector("select[name='transaction.ccexpire']:not(#en__field_transaction_ccexpire)"),this.years=20,this.yearLength=2,this.yearField){this.clearFieldOptions();for(let e=0;e<this.years;e++){const t=(new Date).getFullYear()+e,n=document.createElement("option"),i=document.createTextNode(t.toString());n.appendChild(i),n.value=2==this.yearLength?t.toString().substr(-2):t.toString(),this.yearField.appendChild(n)}}}clearFieldOptions(){this.yearField&&(this.yearLength=this.yearField.options[this.yearField.options.length-1].value.length,[...this.yearField.options].forEach((e=>{var t;if(""!==e.value&&!isNaN(Number(e.value))){const n=[...this.yearField.options].findIndex((t=>t.value===e.value));null===(t=this.yearField)||void 0===t||t.remove(n)}})))}}class B{constructor(){this.logger=new fe("Autocomplete","#330033","#f0f0f0","📇"),this.autoCompleteField('[name="supporter.firstName"]',"given-name"),this.autoCompleteField('[name="supporter.lastName"]',"family-name"),this.autoCompleteField("#en__field_transaction_ccexpire","cc-exp-month"),this.autoCompleteField('[name="transaction.ccexpire"]:not(#en__field_transaction_ccexpire)',"cc-exp-year"),this.autoCompleteField('[name="supporter.emailAddress"]',"email"),this.autoCompleteField('[name="supporter.phoneNumber"]',"tel"),this.autoCompleteField('[name="supporter.country"]',"country"),this.autoCompleteField('[name="supporter.address1"]',"address-line1"),this.autoCompleteField('[name="supporter.address2"]',"address-line2"),this.autoCompleteField('[name="supporter.city"]',"address-level2"),this.autoCompleteField('[name="supporter.region"]',"address-level1"),this.autoCompleteField('[name="supporter.postcode"]',"postal-code"),this.autoCompleteField('[name="transaction.honname"]',"none"),this.autoCompleteField('[name="transaction.infemail"]',"none"),this.autoCompleteField('[name="transaction.infname"]',"none"),this.autoCompleteField('[name="transaction.infadd1"]',"none"),this.autoCompleteField('[name="transaction.infadd2"]',"none"),this.autoCompleteField('[name="transaction.infcity"]',"none"),this.autoCompleteField('[name="transaction.infpostcd"]',"none")}autoCompleteField(e,t){let n=document.querySelector(e);return n?(n.autocomplete=t,!0):("none"!==t&&this.logger.log("Field Not Found",e),!1)}}class R{constructor(){if(this._form=u.getInstance(),this.logger=new fe("Ecard","red","#f5f5f5","🪪"),!this.shouldRun())return;this._form.onValidate.subscribe((()=>this.checkRecipientFields()));const e=p.getUrlParameter("engrid_ecard.schedule"),t=p.getField("ecard.schedule"),n=p.getUrlParameter("engrid_ecard.name"),i=document.querySelector(".en__ecardrecipients__name input"),s=p.getUrlParameter("engrid_ecard.email"),o=document.querySelector(".en__ecardrecipients__email input");if(e&&t){const n=new Date(e.toString()),i=new Date;n.setHours(0,0,0,0)<i.setHours(0,0,0,0)?t.value=p.formatDate(i,"YYYY-MM-DD"):t.value=e.toString(),this.logger.log("Schedule set to "+t.value)}n&&i&&(i.value=n.toString(),this.logger.log("Name set to "+i.value)),s&&o&&(o.value=s.toString(),this.logger.log("Email set to "+o.value));const r=document.querySelector(".en__ecardrecipients__futureDelivery label");if(r){const e=document.createElement("h2");e.innerText=r.innerText,r.replaceWith(e)}o&&(o.setAttribute("type","email"),o.setAttribute("autocomplete","off"))}shouldRun(){return"ECARD"===p.getPageType()}checkRecipientFields(){const e=document.querySelector(".en__ecarditems__addrecipient");return e&&!document.querySelector(".ecardrecipient__email")&&e.click(),!0}}class j{constructor(){this.clickToExpandWrapper=document.querySelectorAll("div.click-to-expand"),this.clickToExpandWrapper.length&&this.clickToExpandWrapper.forEach((e=>{const t='<div class="click-to-expand-cta"></div><div class="click-to-expand-text-wrapper" tabindex="0">'+e.innerHTML+"</div>";e.innerHTML=t,e.addEventListener("click",(t=>{t&&(p.debug&&console.log("A click-to-expand div was clicked"),e.classList.add("expanded"))})),e.addEventListener("keydown",(t=>{"Enter"===t.key?(p.debug&&console.log("A click-to-expand div had the 'Enter' key pressed on it"),e.classList.add("expanded")):" "===t.key&&(p.debug&&console.log("A click-to-expand div had the 'Spacebar' key pressed on it"),e.classList.add("expanded"),t.preventDefault(),t.stopPropagation())}))}))}}class H{constructor(){this.logger=new fe("Advocacy","#232323","#f7b500","👨‍⚖️"),this.shoudRun()&&this.setClickableLabels()}shoudRun(){return["ADVOCACY","EMAILTOTARGET"].includes(p.getPageType())}setClickableLabels(){const e=document.querySelectorAll(".en__contactDetails__rows");e&&e.forEach((e=>{e.addEventListener("click",(t=>{this.toggleCheckbox(e)}))}))}toggleCheckbox(e){const t=e.closest(".en__contactDetails");if(!t)return;const n=t.querySelector("input[type='checkbox']");n&&(this.logger.log("toggleCheckbox",n.checked),n.checked=!n.checked)}}class U{constructor(){this._country=b.getInstance(),this.setDataAttributes()}setDataAttributes(){p.checkNested(window,"pageJson","pageType")&&p.setBodyData("page-type",window.pageJson.pageType),p.setBodyData("currency-code",p.getCurrencyCode()),document.querySelector(".body-banner img, .body-banner video")||p.setBodyData("body-banner","empty"),document.querySelector(".page-alert *")||p.setBodyData("no-page-alert",""),document.querySelector(".content-header *")||p.setBodyData("no-content-header",""),document.querySelector(".body-headerOutside *")||p.setBodyData("no-body-headerOutside",""),document.querySelector(".body-header *")||p.setBodyData("no-body-header",""),document.querySelector(".body-title *")||p.setBodyData("no-body-title",""),document.querySelector(".body-banner *")||p.setBodyData("no-body-banner",""),document.querySelector(".body-bannerOverlay *")||p.setBodyData("no-body-bannerOverlay",""),document.querySelector(".body-top *")||p.setBodyData("no-body-top",""),document.querySelector(".body-main *")||p.setBodyData("no-body-main",""),document.querySelector(".body-bottom *")||p.setBodyData("no-body-bottom",""),document.querySelector(".body-footer *")||p.setBodyData("no-body-footer",""),document.querySelector(".body-footerOutside *")||p.setBodyData("no-body-footerOutside",""),document.querySelector(".content-footerSpacer *")||p.setBodyData("no-content-footerSpacer",""),document.querySelector(".content-preFooter *")||p.setBodyData("no-content-preFooter",""),document.querySelector(".content-footer *")||p.setBodyData("no-content-footer",""),document.querySelector(".page-backgroundImage img, .page-backgroundImage video")||p.setBodyData("no-page-backgroundImage",""),document.querySelector(".page-backgroundImageOverlay *")||p.setBodyData("no-page-backgroundImageOverlay",""),document.querySelector(".page-customCode *")||p.setBodyData("no-page-customCode",""),this._country.country&&(p.setBodyData("country",this._country.country),this._country.onCountryChange.subscribe((e=>{p.setBodyData("country",e)})));const e=document.querySelector(".en__field--donationAmt .en__field__item--other");e&&e.setAttribute("data-currency-symbol",p.getCurrencySymbol());const t=p.getField("transaction.paymenttype");t&&(p.setBodyData("payment-type",t.value),t.addEventListener("change",(()=>{p.setBodyData("payment-type",t.value)})));const n=document.querySelector(".content-footer");n&&p.isInViewport(n)?p.setBodyData("footer-above-fold",""):p.setBodyData("footer-below-fold",""),p.demo&&p.setBodyData("demo",""),1===p.getPageNumber()&&p.setBodyData("first-page",""),p.getPageNumber()===p.getPageCount()&&p.setBodyData("last-page",""),CSS.supports("selector(:has(*))")||p.setBodyData("css-has-selector","false"),"DONATION"===p.getPageType()&&this.addFrequencyDataAttribute()}addFrequencyDataAttribute(){const e=document.querySelectorAll(".en__field--recurrfreq .en__field__item label.en__field__label");let t=0;e.forEach((e=>{p.isVisible(e)&&t++})),p.setBodyData("visible-frequency",t.toString())}}class V{constructor(){if(this._form=u.getInstance(),this.logger=new fe("iFrame","brown","gray","📡"),this.inIframe()){p.setBodyData("embedded","");const e=/\/page\/\d+\/[^\/]+\/(\d+)(\?|$)/,t=(()=>{try{return window.parent.location.href}catch(e){return document.referrer}})().match(e);if(t){parseInt(t[1],10)>1&&(p.setBodyData("embedded","thank-you-page-donation"),this.hideFormComponents(),this.logger.log("iFrame Event - Set embedded attribute to thank-you-page-donation"))}this.logger.log("iFrame Event - Begin Resizing"),console.log("document.readyState",document.readyState),"loading"!==document.readyState?this.onLoaded():document.addEventListener("DOMContentLoaded",(()=>{this.onLoaded()})),window.setTimeout((()=>{this.sendIframeHeight()}),300),window.addEventListener("resize",this.debounceWithImmediate((()=>{this.logger.log("iFrame Event - window resized"),this.sendIframeHeight()}))),this._form.onSubmit.subscribe((e=>{this.logger.log("iFrame Event - onSubmit"),this.sendIframeFormStatus("submit")})),this.isChained()&&p.getPaymentType()&&(this.logger.log("iFrame Event - Chained iFrame"),this.sendIframeFormStatus("chained"));const n=document.querySelector(".skip-link");n&&n.remove(),this._form.onError.subscribe((()=>{const e=document.querySelector(".en__field--validationFailed"),t=e?e.getBoundingClientRect().top:0;this.logger.log(`iFrame Event 'scrollTo' - Position of top of first error ${t} px`),window.parent.postMessage({scrollTo:t},"*"),window.setTimeout((()=>{this.sendIframeHeight()}),100)}))}else this._form.onError.subscribe((()=>{const e=document.querySelector(".en__field--validationFailed");e&&e.scrollIntoView({behavior:"smooth"})})),window.addEventListener("message",(e=>{const t=this.getIFrameByEvent(e);if(t)if(e.data.hasOwnProperty("frameHeight"))t.style.height=e.data.frameHeight+"px",e.data.frameHeight>0?t.classList.add("loaded"):t.classList.remove("loaded");else if(e.data.hasOwnProperty("scroll")&&e.data.scroll>0){let n=window.pageYOffset+t.getBoundingClientRect().top+e.data.scroll;window.scrollTo({top:n,left:0,behavior:"smooth"}),this.logger.log("iFrame Event - Scrolling Window to "+n)}else if(e.data.hasOwnProperty("scrollTo")){const n=e.data.scrollTo+window.scrollY+t.getBoundingClientRect().top;window.scrollTo({top:n,left:0,behavior:"smooth"}),this.logger.log("iFrame Event - Scrolling Window to "+n)}}))}onLoaded(){this.logger.log("iFrame Event - window.onload"),this.sendIframeHeight(),window.parent.postMessage({scroll:this.shouldScroll()},"*"),document.addEventListener("click",(e=>{this.logger.log("iFrame Event - click"),setTimeout((()=>{this.sendIframeHeight()}),100)})),p.watchForError(this.sendIframeHeight.bind(this))}sendIframeHeight(){let e=document.body.offsetHeight;this.logger.log("iFrame Event - Sending iFrame height of: "+e+"px"),window.parent.postMessage({frameHeight:e,pageNumber:p.getPageNumber(),pageCount:p.getPageCount(),giftProcess:p.getGiftProcess()},"*")}sendIframeFormStatus(e){window.parent.postMessage({status:e,pageNumber:p.getPageNumber(),pageCount:p.getPageCount(),giftProcess:p.getGiftProcess()},"*")}getIFrameByEvent(e){return[].slice.call(document.getElementsByTagName("iframe")).filter((t=>t.contentWindow===e.source))[0]}shouldScroll(){if(document.querySelector(".en__errorHeader"))return!0;if(this.isChained())return!1;let e=document.referrer;return new RegExp(/^(.*)\/(page)\/(\d+.*)/).test(e)}inIframe(){try{return window.self!==window.top}catch(e){return!0}}isChained(){return!!p.getUrlParameter("chain")}hideFormComponents(){this.logger.log("iFrame Event - Hiding Form Components");const e=["giveBySelect-Card","en__field--ccnumber","en__field--survey","give-by-select","give-by-select-header","en__submit","en__captcha","force-visibility","hide","hide-iframe","radio-to-buttons_donationAmt"],t=["en__digitalWallet"];Array.from(document.querySelectorAll(".body-main > div:not(:last-child)")).forEach((n=>{e.some((e=>n.classList.contains(e)||n.querySelector(`:scope > .${e}`)))||t.some((e=>n.querySelector(`#${e}`)))||n.classList.add("hide-iframe","hide-chained")})),this.sendIframeHeight()}showFormComponents(){this.logger.log("iFrame Event - Showing Form Components");document.querySelectorAll(".body-main > div.hide-chained").forEach((e=>{e.classList.remove("hide-iframe"),e.classList.remove("hide-chained")})),this.sendIframeHeight()}debounceWithImmediate(e,t=1e3){let n,i=!0;return(...s)=>{clearTimeout(n),i&&(e.apply(this,s),i=!1),n=setTimeout((()=>{e.apply(this,s),i=!0}),t)}}}class ${constructor(){this.logger=new fe("InputHasValueAndFocus","yellow","#333","🌈"),this.formInputs=document.querySelectorAll(".en__field--text, .en__field--email:not(.en__field--checkbox), .en__field--telephone, .en__field--number, .en__field--textarea, .en__field--select, .en__field--checkbox"),this.shouldRun()&&this.run()}shouldRun(){return this.formInputs.length>0}run(){this.formInputs.forEach((e=>{const t=e.querySelector("input, textarea, select");t&&t.value&&e.classList.add("has-value"),this.bindEvents(e)}))}bindEvents(e){const t=e.querySelector("input, textarea, select");t&&(t.addEventListener("focus",(()=>{this.log("Focus added",t),e.classList.add("has-focus")})),t.addEventListener("blur",(()=>{this.log("Focus removed",t),e.classList.remove("has-focus")})),t.addEventListener("input",(()=>{t.value?(this.log("Value added",t),e.classList.add("has-value")):(this.log("Value removed",t),e.classList.remove("has-value"))})))}log(e,t){this.logger.log(`${e} on ${t.name}: ${t.value}`)}}class W{constructor(){if(this.defaultPlaceholders={"input#en__field_supporter_firstName":"First Name","input#en__field_supporter_lastName":"Last Name","input#en__field_supporter_emailAddress":"Email Address","input#en__field_supporter_phoneNumber":"Phone Number (Optional)",".en__mandatory input#en__field_supporter_phoneNumber":"Phone Number",".i-required input#en__field_supporter_phoneNumber":"Phone Number","input#en__field_supporter_phoneNumber2":"000-000-0000 (Optional)",".en__mandatory input#en__field_supporter_phoneNumber2":"000-000-0000",".i-required input#en__field_supporter_phoneNumber2":"000-000-0000","input#en__field_supporter_country":"Country","input#en__field_supporter_address1":"Street Address","input#en__field_supporter_address2":"Apt., Ste., Bldg.","input#en__field_supporter_city":"City","input#en__field_supporter_region":"Region","input#en__field_supporter_postcode":"ZIP Code",".en__field--donationAmt.en__field--withOther .en__field__input--other":"Other","input#en__field_transaction_ccexpire":"MM / YY","input#en__field_supporter_bankAccountNumber":"Bank Account Number","input#en__field_supporter_bankRoutingNumber":"Bank Routing Number","input#en__field_transaction_honname":"Honoree Name","input#en__field_transaction_infname":"Recipient Name","input#en__field_transaction_infemail":"Recipient Email Address","input#en__field_transaction_infcountry":"Country","input#en__field_transaction_infadd1":"Recipient Street Address","input#en__field_transaction_infadd2":"Recipient Apt., Ste., Bldg.","input#en__field_transaction_infcity":"Recipient City","input#en__field_transaction_infpostcd":"Recipient Postal Code","input#en__field_transaction_gftrsn":"Reason for your gift","input#en__field_transaction_shipfname":"Shipping First Name","input#en__field_transaction_shiplname":"Shipping Last Name","input#en__field_transaction_shipemail":"Shipping Email Address","input#en__field_transaction_shipcountry":"Shipping Country","input#en__field_transaction_shipadd1":"Shipping Street Address","input#en__field_transaction_shipadd2":"Shipping Apt., Ste., Bldg.","input#en__field_transaction_shipcity":"Shipping City","input#en__field_transaction_shipregion":"Shipping Region","input#en__field_transaction_shippostcode":"Shipping Postal Code","input#en__field_supporter_billingCountry":"Billing Country","input#en__field_supporter_billingAddress1":"Billing Street Address","input#en__field_supporter_billingAddress2":"Billing Apt., Ste., Bldg.","input#en__field_supporter_billingCity":"Billing City","input#en__field_supporter_billingRegion":"Billing Region","input#en__field_supporter_billingPostcode":"Billing Postal Code"},this.shouldRun()){const e=p.getOption("Placeholders");e&&(this.defaultPlaceholders=Object.assign(Object.assign({},this.defaultPlaceholders),e)),this.run()}}shouldRun(){return p.hasBodyData("add-input-placeholders")}run(){Object.keys(this.defaultPlaceholders).forEach((e=>{e in this.defaultPlaceholders&&this.addPlaceholder(e,this.defaultPlaceholders[e])}))}addPlaceholder(e,t){const n=document.querySelector(e);n&&(n.placeholder=t)}}const G=n(3861).ZP;class Y{constructor(){this.mediaWithAttribution=document.querySelectorAll("img[data-attribution-source]:not([data-attribution-hide-overlay]), video[data-attribution-source]:not([data-attribution-hide-overlay])"),this.mediaWithAttribution.forEach((e=>{p.debug&&console.log("The following image was found with data attribution fields on it. It's markup will be changed to add caption support.",e);let t=document.createElement("figure");t.classList.add("media-with-attribution");let n=e.parentNode;if(n){n.insertBefore(t,e),t.appendChild(e);let i=e,s=i.dataset.attributionSource;if(s){let e=i.dataset.attributionSourceLink;e?i.insertAdjacentHTML("afterend",'<figattribution><a href="'+decodeURIComponent(e)+'" target="_blank" tabindex="-1">'+s+"</a></figure>"):i.insertAdjacentHTML("afterend","<figattribution>"+s+"</figure>");const t="attributionSourceTooltip"in i.dataset&&i.dataset.attributionSourceTooltip;t&&G(i.nextSibling,{content:t,arrow:!0,arrowType:"default",placement:"left",trigger:"click mouseenter focus",interactive:!0})}}}))}}class J{constructor(t){var n;this._amount=h.getInstance(),this._fees=m.getInstance(),this._frequency=g.getInstance(),this._form=u.getInstance(),this.multiplier=1/12,this.options=Object.assign(Object.assign({},e),t),this.submitLabel=(null===(n=document.querySelector(".en__submit button"))||void 0===n?void 0:n.innerHTML)||"Donate",this._amount.onAmountChange.subscribe((()=>this.changeSubmitButton())),this._amount.onAmountChange.subscribe((()=>this.changeLiveAmount())),this._amount.onAmountChange.subscribe((()=>this.changeLiveUpsellAmount())),this._fees.onFeeChange.subscribe((()=>this.changeLiveAmount())),this._fees.onFeeChange.subscribe((()=>this.changeLiveUpsellAmount())),this._fees.onFeeChange.subscribe((()=>this.changeSubmitButton())),this._frequency.onFrequencyChange.subscribe((()=>this.changeLiveFrequency())),this._frequency.onFrequencyChange.subscribe((()=>this.changeRecurrency())),this._frequency.onFrequencyChange.subscribe((()=>this.changeSubmitButton())),this._form.onSubmit.subscribe((()=>{"SUPPORTERHUB"!==p.getPageType()&&p.disableSubmit("Processing...")})),this._form.onError.subscribe((()=>p.enableSubmit())),document.addEventListener("click",(e=>{const t=e.target;t&&(t.classList.contains("monthly-upsell")?this.upsold(e):t.classList.contains("form-submit")&&(e.preventDefault(),this._form.submitForm()))}))}getAmountTxt(e=0){var t,n,i,s;const o=null!==(t=p.getCurrencySymbol())&&void 0!==t?t:"$",r=null!==(n=this.options.DecimalSeparator)&&void 0!==n?n:".",a=null!==(i=this.options.ThousandsSeparator)&&void 0!==i?i:"",l=e%1==0?0:null!==(s=this.options.DecimalPlaces)&&void 0!==s?s:2,c=p.formatNumber(e,l,r,a);return e>0?`<span class="live-variable-currency">${o}</span><span class="live-variable-amount">${c}</span>`:""}getUpsellAmountTxt(e=0){var t,n,i,s;const o=null!==(t=p.getCurrencySymbol())&&void 0!==t?t:"$",r=null!==(n=this.options.DecimalSeparator)&&void 0!==n?n:".",a=null!==(i=this.options.ThousandsSeparator)&&void 0!==i?i:"",l=e%1==0?0:null!==(s=this.options.DecimalPlaces)&&void 0!==s?s:2,c=p.formatNumber(5*Math.ceil(e/5),l,r,a);return e>0?o+c:""}getUpsellAmountRaw(e=0){const t=5*Math.ceil(e/5);return e>0?t.toString():""}changeSubmitButton(){const e=document.querySelector(".en__submit button"),t=this.getAmountTxt(this._amount.amount+this._fees.fee),n="onetime"==this._frequency.frequency?"":"annual"==this._frequency.frequency?"annually":this._frequency.frequency;let i=this.submitLabel;t?(i=i.replace("$AMOUNT",t),i=i.replace("$FREQUENCY",`<span class="live-variable-frequency">${n}</span>`)):(i=i.replace("$AMOUNT",""),i=i.replace("$FREQUENCY","")),e&&i&&(e.innerHTML=i)}changeLiveAmount(){const e=this._amount.amount+this._fees.fee;document.querySelectorAll(".live-giving-amount").forEach((t=>t.innerHTML=this.getAmountTxt(e)))}changeLiveUpsellAmount(){const e=(this._amount.amount+this._fees.fee)*this.multiplier;document.querySelectorAll(".live-giving-upsell-amount").forEach((t=>t.innerHTML=this.getUpsellAmountTxt(e)));document.querySelectorAll(".live-giving-upsell-amount-raw").forEach((t=>t.innerHTML=this.getUpsellAmountRaw(e)))}changeLiveFrequency(){document.querySelectorAll(".live-giving-frequency").forEach((e=>e.innerHTML="onetime"==this._frequency.frequency?"":this._frequency.frequency))}changeRecurrency(){const e=document.querySelector("[name='transaction.recurrpay']");if(e&&"radio"!=e.type){e.value="onetime"==this._frequency.frequency?"N":"Y",this._frequency.recurring=e.value,p.getOption("Debug")&&console.log("Recurpay Changed!");const t=new Event("change",{bubbles:!0});e.dispatchEvent(t)}}upsold(e){const t=document.querySelector(".en__field--recurrpay input[value='Y']");t&&(t.checked=!0);const n=document.querySelector(".en__field--donationAmt input[value='other']");n&&(n.checked=!0);const i=document.querySelector("input[name='transaction.donationAmt.other']");i&&(i.value=this.getUpsellAmountRaw(this._amount.amount*this.multiplier),this._amount.load(),this._frequency.load(),i.parentElement&&i.parentElement.classList.remove("en__field__item--hidden"));const s=e.target;s&&s.classList.contains("form-submit")&&(e.preventDefault(),this._form.submitForm())}}class z{constructor(){this.overlay=document.createElement("div"),this._form=u.getInstance(),this._amount=h.getInstance(),this._fees=m.getInstance(),this._frequency=g.getInstance(),this._dataLayer=ye.getInstance(),this._suggestAmount=0,this.logger=new fe("UpsellLightbox","black","pink","🪟");let e="EngridUpsell"in window?window.EngridUpsell:{};this.options=Object.assign(Object.assign({},t),e),this.options.disablePaymentMethods.push("applepay"),this.shouldRun()?(this.overlay.id="enModal",this.overlay.classList.add("is-hidden"),this.overlay.classList.add("image-"+this.options.imagePosition),this.renderLightbox(),this._form.onSubmit.subscribe((()=>this.open()))):this.logger.log("Upsell script should NOT run")}renderLightbox(){const e=this.options.title.replace("{new-amount}","<span class='upsell_suggestion'></span>").replace("{old-amount}","<span class='upsell_amount'></span>").replace("{old-frequency}","<span class='upsell_frequency'></span>"),t=this.options.paragraph.replace("{new-amount}","<span class='upsell_suggestion'></span>").replace("{old-amount}","<span class='upsell_amount'></span>").replace("{old-frequency}","<span class='upsell_frequency'></span>"),n=this.options.yesLabel.replace("{new-amount}","<span class='upsell_suggestion'></span>").replace("{old-amount}","<span class='upsell_amount'></span>").replace("{old-frequency}","<span class='upsell_frequency'></span>"),i=this.options.noLabel.replace("{new-amount}","<span class='upsell_suggestion'></span>").replace("{old-amount}","<span class='upsell_amount'></span>").replace("{old-frequency}","<span class='upsell_frequency'></span>"),s=`\n <div class="upsellLightboxContainer" id="goMonthly">\n \x3c!-- ideal image size is 480x650 pixels --\x3e\n <div class="background" style="background-image: url('${this.options.image}');"></div>\n <div class="upsellLightboxContent">\n ${this.options.canClose?'<span id="goMonthlyClose"></span>':""}\n <h1>\n ${e}\n </h1>\n ${this.options.otherAmount?`\n <div class="upsellOtherAmount">\n <div class="upsellOtherAmountLabel">\n <p>\n ${this.options.otherLabel}\n </p>\n </div>\n <div class="upsellOtherAmountInput">\n <input href="#" id="secondOtherField" name="secondOtherField" type="text" value="" inputmode="decimal" aria-label="Enter your custom donation amount" autocomplete="off" data-lpignore="true" aria-required="true" size="12">\n <small>Minimum ${this.getAmountTxt(this.options.minAmount)}</small>\n </div>\n </div>\n `:""}\n\n <p>\n ${t}\n </p>\n \x3c!-- YES BUTTON --\x3e\n <div id="upsellYesButton">\n <a class="pseduo__en__submit_button" href="#">\n <div>\n <span class='loader-wrapper'><span class='loader loader-quart'></span></span>\n <span class='label'>${n}</span>\n </div>\n </a>\n </div>\n \x3c!-- NO BUTTON --\x3e\n <div id="upsellNoButton">\n <button title="Close (Esc)" type="button">\n <div>\n <span class='loader-wrapper'><span class='loader loader-quart'></span></span>\n <span class='label'>${i}</span>\n </div>\n </button>\n </div>\n </div>\n </div>\n `;this.overlay.innerHTML=s;const o=this.overlay.querySelector("#goMonthlyClose"),r=this.overlay.querySelector("#upsellYesButton a"),a=this.overlay.querySelector("#upsellNoButton button");r.addEventListener("click",this.continue.bind(this)),a.addEventListener("click",this.continue.bind(this)),o&&o.addEventListener("click",this.close.bind(this)),this.overlay.addEventListener("click",(e=>{e.target instanceof Element&&e.target.id==this.overlay.id&&this.options.canClose&&this.close(e)})),document.addEventListener("keyup",(e=>{"Escape"===e.key&&o&&o.click()})),document.body.appendChild(this.overlay);const l=document.querySelector("#secondOtherField");l&&l.addEventListener("keyup",this.popupOtherField.bind(this)),this.logger.log("Upsell script rendered")}shouldRun(){return!this.shouldSkip()&&"EngridUpsell"in window&&!!window.pageJson&&1==window.pageJson.pageNumber&&["donation","premiumgift"].includes(window.pageJson.pageType)}shouldSkip(){return!(!("EngridUpsell"in window)||!window.EngridUpsell.skipUpsell)||this.options.skipUpsell}popupOtherField(){var e,t;const n=parseFloat(null!==(t=null===(e=this.overlay.querySelector("#secondOtherField"))||void 0===e?void 0:e.value)&&void 0!==t?t:""),i=document.querySelectorAll("#upsellYesButton .upsell_suggestion"),s=this.getUpsellAmount();!isNaN(n)&&n>0?this.checkOtherAmount(n):this.checkOtherAmount(s),i.forEach((e=>e.innerHTML=this.getAmountTxt(s+this._fees.calculateFees(s))))}liveAmounts(){const e=document.querySelectorAll(".upsell_suggestion"),t=document.querySelectorAll(".upsell_amount"),n=this.getUpsellAmount(),i=n+this._fees.calculateFees(n);e.forEach((e=>e.innerHTML=this.getAmountTxt(i))),t.forEach((e=>e.innerHTML=this.getAmountTxt(this._amount.amount+this._fees.fee)))}liveFrequency(){document.querySelectorAll(".upsell_frequency").forEach((e=>e.innerHTML=this.getFrequencyTxt()))}getUpsellAmount(){var e,t;const n=this._amount.amount,i=parseFloat(null!==(t=null===(e=this.overlay.querySelector("#secondOtherField"))||void 0===e?void 0:e.value)&&void 0!==t?t:"");if(i>0)return i>this.options.minAmount?i:this.options.minAmount;let s=0;for(let e=0;e<this.options.amountRange.length;e++){let t=this.options.amountRange[e];if(0==s&&n<=t.max){if(s=t.suggestion,0===s)return 0;if("number"!=typeof s){const e=s.replace("amount",n.toFixed(2));s=parseFloat(Function('"use strict";return ('+e+")")())}break}}return s>this.options.minAmount?s:this.options.minAmount}shouldOpen(){const e=this.getUpsellAmount(),t=p.getFieldValue("transaction.paymenttype")||"";return this._suggestAmount=e,!(!this.freqAllowed()||this.shouldSkip()||this.options.disablePaymentMethods.includes(t.toLowerCase())||this.overlay.classList.contains("is-submitting")||!(e>0))&&(this.logger.log("Upsell Frequency "+this._frequency.frequency),this.logger.log("Upsell Amount "+this._amount.amount),this.logger.log("Upsell Suggested Amount "+e),!0)}freqAllowed(){const e=this._frequency.frequency,t=[];return this.options.oneTime&&t.push("onetime"),this.options.annual&&t.push("annual"),t.includes(e)}open(){if(this.logger.log("Upsell script opened"),!this.shouldOpen()){let e=window.sessionStorage.getItem("original");return e&&document.querySelectorAll(".en__errorList .en__error").length>0&&this.setOriginalAmount(e),this._form.submit=!0,!0}return this.liveAmounts(),this.liveFrequency(),this.overlay.classList.remove("is-hidden"),this._form.submit=!1,p.setBodyData("has-lightbox",""),!1}setOriginalAmount(e){if(this.options.upsellOriginalGiftAmountFieldName){let t=document.querySelector(".en__field__input.en__field__input--hidden[name='"+this.options.upsellOriginalGiftAmountFieldName+"']");if(!t){let e=document.querySelector("form.en__component--page");if(e){let n=document.createElement("input");n.setAttribute("type","hidden"),n.setAttribute("name",this.options.upsellOriginalGiftAmountFieldName),n.classList.add("en__field__input","en__field__input--hidden"),e.appendChild(n),t=document.querySelector('.en__field__input.en__field__input--hidden[name="'+this.options.upsellOriginalGiftAmountFieldName+'"]')}}t&&(window.sessionStorage.setItem("original",e),t.setAttribute("value",e))}}continue(e){var t;if(e.preventDefault(),e.target instanceof Element&&(null===(t=document.querySelector("#upsellYesButton"))||void 0===t?void 0:t.contains(e.target))){this.logger.success("Upsold"),this.setOriginalAmount(this._amount.amount.toString());const e=this.getUpsellAmount(),t=this._amount.amount;this._frequency.setFrequency("monthly"),this._amount.setAmount(e),this._dataLayer.addEndOfGiftProcessEvent("ENGRID_UPSELL",{eventValue:!0,originalAmount:t,upsoldAmount:e,frequency:"monthly"}),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL",!0),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_ORIGINAL_AMOUNT",t),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY","MONTHLY"),this.renderConversionField("upsellSuccess","onetime",t,"monthly",this._suggestAmount,"monthly",e)}else this.setOriginalAmount(""),window.sessionStorage.removeItem("original"),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL",!1),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY","ONE-TIME"),this.renderConversionField("upsellFail",this._frequency.frequency,this._amount.amount,"monthly",this._suggestAmount,this._frequency.frequency,this._amount.amount);this._form.submitForm()}close(e){e.preventDefault(),this.overlay.classList.add("is-hidden"),p.setBodyData("has-lightbox",!1),this.options.submitOnClose?(this.renderConversionField("upsellFail",this._frequency.frequency,this._amount.amount,"monthly",this._suggestAmount,this._frequency.frequency,this._amount.amount),this._form.submitForm()):this._form.dispatchError()}getAmountTxt(e=0){var t,n,i,s;const o=null!==(t=p.getCurrencySymbol())&&void 0!==t?t:"$",r=null!==(n=p.getOption("DecimalSeparator"))&&void 0!==n?n:".",a=null!==(i=p.getOption("ThousandsSeparator"))&&void 0!==i?i:"",l=e%1==0?0:null!==(s=p.getOption("DecimalPlaces"))&&void 0!==s?s:2,c=p.formatNumber(e,l,r,a);return e>0?o+c:""}getFrequencyTxt(){const e={onetime:"one-time",monthly:"monthly",annual:"annual"},t=this._frequency.frequency;return t in e?e[t]:t}checkOtherAmount(e){const t=document.querySelector(".upsellOtherAmountInput");t&&(e>=this.options.minAmount?t.classList.remove("is-invalid"):t.classList.add("is-invalid"))}renderConversionField(e,t,n,i,s,o,r){if(""===this.options.conversionField)return;const a=document.querySelector("input[name='"+this.options.conversionField+"']")||p.createHiddenInput(this.options.conversionField);if(!a)return void this.logger.error("Could not find or create the conversion field");const l=`event:${e},freq:${t},amt:${n},sugFreq:${i},sugAmt:${s},subFreq:${o},subAmt:${r}`;a.value=l,this.logger.log(`Conversion Field ${e}`,l)}}class K{constructor(){this.checkboxOptions=!1,this.checkboxOptionsDefaults={label:"Make my gift a monthly gift of <strong>{new-amount}/mo</strong>",location:"before .en__component .en__submit",cssClass:""},this._amount=h.getInstance(),this._fees=m.getInstance(),this._frequency=g.getInstance(),this._dataLayer=ye.getInstance(),this.checkboxContainer=null,this.oldAmount=0,this.oldFrequency="one-time",this.resetCheckbox=!1,this.logger=new fe("UpsellCheckbox","black","LemonChiffon","✅");let e="EngridUpsell"in window?window.EngridUpsell:{};this.options=Object.assign(Object.assign({},t),e),!1!==this.options.upsellCheckbox?("upsellCheckbox"in e&&!1!==e.upsellCheckbox&&(window.EngridUpsell.skipUpsell=!0),this.checkboxOptions=Object.assign(Object.assign({},this.checkboxOptionsDefaults),this.options.upsellCheckbox),this.shouldRun()?(this.renderCheckbox(),this.updateLiveData(),this._frequency.onFrequencyChange.subscribe((()=>this.updateLiveData())),this._frequency.onFrequencyChange.subscribe((()=>this.resetUpsellCheckbox())),this._amount.onAmountChange.subscribe((()=>this.updateLiveData())),this._amount.onAmountChange.subscribe((()=>this.resetUpsellCheckbox())),this._fees.onFeeChange.subscribe((()=>this.updateLiveData()))):this.logger.log("should NOT run")):this.logger.log("Skipped")}updateLiveData(){this.liveAmounts(),this.liveFrequency()}resetUpsellCheckbox(){var e,t;if(!this.resetCheckbox)return;this.logger.log("Reset");const n=null===(e=this.checkboxContainer)||void 0===e?void 0:e.querySelector("#upsellCheckbox");n&&(n.checked=!1),null===(t=this.checkboxContainer)||void 0===t||t.classList.add("recurring-frequency-y-hide"),this.oldAmount=0,this.oldFrequency="one-time",this.resetCheckbox=!1}renderCheckbox(){if(!1===this.checkboxOptions)return;const e=this.checkboxOptions.label.replace("{new-amount}"," <span class='upsell_suggestion'></span>").replace("{old-amount}"," <span class='upsell_amount'></span>").replace("{old-frequency}"," <span class='upsell_frequency'></span>"),t=document.createElement("div");t.classList.add("en__component","en__component--formblock","recurring-frequency-y-hide","engrid-upsell-checkbox"),this.checkboxOptions.cssClass&&t.classList.add(this.checkboxOptions.cssClass),t.innerHTML=`\n <div class="en__field en__field--checkbox">\n <div class="en__field__element en__field__element--checkbox">\n <div class="en__field__item">\n <input type="checkbox" class="en__field__input en__field__input--checkbox" name="upsellCheckbox" id="upsellCheckbox" value="Y">\n <label class="en__field__label en__field__label--item" for="upsellCheckbox" style="gap: 0.5ch">${e}</label>\n </div>\n </div>\n </div>`;const n=t.querySelector("#upsellCheckbox");n&&n.addEventListener("change",this.toggleCheck.bind(this));const i=this.checkboxOptions.location.split(" ")[0],s=this.checkboxOptions.location.split(" ").slice(1).join(" ").trim(),o=document.querySelector(s);this.checkboxContainer=t,o?"before"===i?(this.logger.log("rendered before"),o.before(t)):(this.logger.log("rendered after"),o.after(t)):this.logger.error("could not render - target not found")}shouldRun(){return 1===p.getPageNumber()&&"DONATION"===p.getPageType()}showCheckbox(){this.checkboxContainer&&this.checkboxContainer.classList.remove("hide")}hideCheckbox(){this.checkboxContainer&&this.checkboxContainer.classList.add("hide")}liveAmounts(){if("onetime"!==this._frequency.frequency)return;const e=document.querySelectorAll(".upsell_suggestion"),t=document.querySelectorAll(".upsell_amount"),n=this.getUpsellAmount(),i=n+this._fees.calculateFees(n);i>0?this.showCheckbox():this.hideCheckbox(),e.forEach((e=>e.innerHTML=this.getAmountTxt(i))),t.forEach((e=>e.innerHTML=this.getAmountTxt(this._amount.amount+this._fees.fee)))}liveFrequency(){document.querySelectorAll(".upsell_frequency").forEach((e=>e.innerHTML=this.getFrequencyTxt()))}getUpsellAmount(){const e=this._amount.amount;let t=0;for(let n=0;n<this.options.amountRange.length;n++){let i=this.options.amountRange[n];if(0==t&&e<=i.max){if(t=i.suggestion,0===t)return 0;if("number"!=typeof t){const n=t.replace("amount",e.toFixed(2));t=parseFloat(Function('"use strict";return ('+n+")")())}break}}return t>this.options.minAmount?t:this.options.minAmount}toggleCheck(e){var t,n;if(e.preventDefault(),e.target.checked){this.logger.success("Upsold");const e=this.getUpsellAmount(),n=this._amount.amount;this.oldAmount=n,this.oldFrequency=this._frequency.frequency,null===(t=this.checkboxContainer)||void 0===t||t.classList.remove("recurring-frequency-y-hide"),this._frequency.setFrequency("monthly"),this._amount.setAmount(e),this._dataLayer.addEndOfGiftProcessEvent("ENGRID_UPSELL_CHECKBOX",{eventValue:!0,originalAmount:n,upsoldAmount:e,frequency:"monthly"}),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_CHECKBOX",!0),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_ORIGINAL_AMOUNT",n),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY","MONTHLY"),this.renderConversionField("upsellSuccess","onetime",n,"monthly",e,"monthly",e),window.setTimeout((()=>{this.resetCheckbox=!0}),500)}else this.resetCheckbox=!1,this.logger.success("Not Upsold"),this._amount.setAmount(this.oldAmount),this._frequency.setFrequency(this.oldFrequency),null===(n=this.checkboxContainer)||void 0===n||n.classList.add("recurring-frequency-y-hide"),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_CHECKBOX",!1),this._dataLayer.addEndOfGiftProcessVariable("ENGRID_UPSELL_DONATION_FREQUENCY","ONE-TIME"),this.renderConversionField("upsellFail",this._frequency.frequency,this._amount.amount,"monthly",this._amount.amount,this._frequency.frequency,this._amount.amount)}getAmountTxt(e=0){var t,n,i,s;const o=null!==(t=p.getCurrencySymbol())&&void 0!==t?t:"$",r=null!==(n=p.getOption("DecimalSeparator"))&&void 0!==n?n:".",a=null!==(i=p.getOption("ThousandsSeparator"))&&void 0!==i?i:"",l=e%1==0?0:null!==(s=p.getOption("DecimalPlaces"))&&void 0!==s?s:2,c=p.formatNumber(e,l,r,a);return e>0?o+c:""}getFrequencyTxt(){const e={onetime:"one-time",monthly:"monthly",annual:"annual"},t=this._frequency.frequency;return t in e?e[t]:t}renderConversionField(e,t,n,i,s,o,r){if(""===this.options.conversionField)return;const a=document.querySelector("input[name='"+this.options.conversionField+"']")||p.createHiddenInput(this.options.conversionField);if(!a)return void this.logger.error("Could not find or create the conversion field");const l=`event:${e},freq:${t},amt:${n},sugFreq:${i},sugAmt:${s},subFreq:${o},subAmt:${r}`;a.value=l,this.logger.log(`Conversion Field ${e}`,l)}}class X{createDataAttributes(){this.elements.forEach((e=>{if(e instanceof HTMLInputElement){let t=e.value.replace(/\W/g,"");document.querySelectorAll("."+this.classes+t).forEach((e=>{if(e instanceof HTMLElement){const t=e.querySelectorAll("input[type='text'], input[type='number'], input[type='email'], select, textarea");t.length>0&&t.forEach((e=>{(e instanceof HTMLInputElement||e instanceof HTMLSelectElement)&&(e.hasAttribute("data-original-value")||e.setAttribute("data-original-value",e.value),e.hasAttribute("data-value")||e.setAttribute("data-value",e.value))}))}}))}}))}hideAll(){this.elements.forEach(((e,t)=>{e instanceof HTMLInputElement&&this.hide(e)}))}hide(e){let t=e.value.replace(/\W/g,"");document.querySelectorAll("."+this.classes+t).forEach((e=>{e instanceof HTMLElement&&(this.toggleValue(e,"hide"),e.style.display="none",this.logger.log("Hiding",e))}))}show(e){let t=e.value.replace(/\W/g,"");document.querySelectorAll("."+this.classes+t).forEach((e=>{e instanceof HTMLElement&&(this.toggleValue(e,"show"),e.style.display="",this.logger.log("Showing",e))})),"checkbox"!=e.type||e.checked||this.hide(e)}toggleValue(e,t){if("hide"==t&&!p.isVisible(e))return;this.logger.log(`toggleValue: ${t}`);const n=e.querySelectorAll("input[type='text'], input[type='number'], input[type='email'], select, textarea");n.length>0&&n.forEach((e=>{var n;if((e instanceof HTMLInputElement||e instanceof HTMLSelectElement)&&e.name){const i=p.getFieldValue(e.name),s=e.getAttribute("data-original-value"),o=null!==(n=e.getAttribute("data-value"))&&void 0!==n?n:"";"hide"===t?(e.setAttribute("data-value",i),p.setFieldValue(e.name,s)):p.setFieldValue(e.name,o)}}))}getSessionState(){var e;try{const t=null!==(e=window.sessionStorage.getItem("engrid_ShowHideRadioCheckboxesState"))&&void 0!==e?e:"";return JSON.parse(t)}catch(e){return[]}}storeSessionState(){const e=this.getSessionState();[...this.elements].forEach((t=>{var n,i;t instanceof HTMLInputElement&&("radio"==t.type&&t.checked&&(e.forEach(((t,n)=>{t.class==this.classes&&e.splice(n,1)})),e.push({page:p.getPageID(),class:this.classes,value:t.value}),this.logger.log("storing radio state",e[e.length-1])),"checkbox"==t.type&&(e.forEach(((t,n)=>{t.class==this.classes&&e.splice(n,1)})),e.push({page:p.getPageID(),class:this.classes,value:null!==(i=null===(n=[...this.elements].find((e=>e.checked)))||void 0===n?void 0:n.value)&&void 0!==i?i:"N"}),this.logger.log("storing checkbox state",e[e.length-1])))})),window.sessionStorage.setItem("engrid_ShowHideRadioCheckboxesState",JSON.stringify(e))}constructor(e,t){this.logger=new fe("ShowHideRadioCheckboxes","black","lightblue","👁"),this.elements=document.getElementsByName(e),this.classes=t,this.createDataAttributes(),this.hideAll(),this.storeSessionState();for(let e=0;e<this.elements.length;e++){let t=this.elements[e];t.checked&&this.show(t),t.addEventListener("change",(e=>{this.hideAll(),this.show(t),this.storeSessionState()}))}}}function Q(e,t){if(!t)return"";let n="; "+e;return!0===t?n:n+"="+t}function Z(e,t,n){return encodeURIComponent(e).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(t).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)+function(e){if("number"==typeof e.expires){let t=new Date;t.setMilliseconds(t.getMilliseconds()+864e5*e.expires),e.expires=t}return Q("Expires",e.expires?e.expires.toUTCString():"")+Q("Domain",e.domain)+Q("Path",e.path)+Q("Secure",e.secure)+Q("SameSite",e.sameSite)}(n)}function ee(){return function(e){let t={},n=e?e.split("; "):[],i=/(%[\dA-F]{2})+/gi;for(let e=0;e<n.length;e++){let s=n[e].split("="),o=s.slice(1).join("=");'"'===o.charAt(0)&&(o=o.slice(1,-1));try{t[s[0].replace(i,decodeURIComponent)]=o.replace(i,decodeURIComponent)}catch(e){}}return t}(document.cookie)}function te(e){return ee()[e]}function ne(e,t,n){document.cookie=Z(e,t,Object.assign({path:"/"},n))}class ie{constructor(){this.countryToStateFields={"supporter.country":"supporter.region","transaction.shipcountry":"transaction.shipregion","supporter.billingCountry":"supporter.billingRegion","transaction.infcountry":"transaction.infreg"},this.countriesSelect=document.querySelectorAll('select[name="supporter.country"], select[name="transaction.shipcountry"], select[name="supporter.billingCountry"], select[name="transaction.infcountry"]');let e="EngridTranslate"in window?window.EngridTranslate:{};if(this.options=a,document.querySelector(".en__component--formblock.us-only-form .en__field--country"))return;if(e)for(let t in e)this.options[t]=this.options[t]?[...this.options[t],...e[t]]:e[t];let t={};if(this.countriesSelect){this.countriesSelect.forEach((e=>{e.addEventListener("change",this.translateFields.bind(this,e.name)),e.value&&(t[e.name]=e.value);const n=document.querySelector(`select[name="${this.countryToStateFields[e.name]}"]`);n&&(n.addEventListener("change",this.rememberState.bind(this,e.name)),n.value&&(t[n.name]=n.value))})),this.translateFields("supporter.country");if(!!(!p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")||!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()))for(let e in t)p.setFieldValue(e,t[e],!1)}}translateFields(e="supporter.country"){this.resetTranslatedFields();const t=p.getFieldValue(e);if(this.setStateField(t,this.countryToStateFields[e]),"supporter.country"===e){t in this.options&&this.options[t].forEach((e=>{this.translateField(e.field,e.translation)}));const e=document.querySelectorAll(".recipient-block");if(e.length)switch(t){case"FR":case"FRA":case"France":e.forEach((e=>e.innerHTML="À:"));break;case"DE":case"DEU":case"Germany":e.forEach((e=>e.innerHTML="Zu:"));break;case"NL":case"NLD":case"Netherlands":e.forEach((e=>e.innerHTML="Aan:"))}}}translateField(e,t){const n=document.querySelector(`[name="${e}"]`);if(n){const e=n.closest(".en__field");if(e){const i=e.querySelector(".en__field__label"),s=i.querySelector(".engrid-simple-country");let o=s?s.cloneNode(!0):null;n instanceof HTMLInputElement&&""!=n.placeholder&&(i&&i.innerHTML!=n.placeholder||(n.dataset.original=n.placeholder,n.placeholder=t)),i&&(i.dataset.original=i.innerHTML,i.innerHTML=t,o&&i.appendChild(o))}}}resetTranslatedFields(){document.querySelectorAll("[data-original]").forEach((e=>{if(e instanceof HTMLInputElement&&e.dataset.original)e.placeholder=e.dataset.original;else{const t=e.querySelector(".engrid-simple-country");let n=t?t.cloneNode(!0):null;e.innerHTML=e.dataset.original,n&&e.appendChild(n)}e.removeAttribute("data-original")}))}setStateField(e,t){switch(e){case"ES":case"ESP":case"Spain":this.setStateValues(t,"Provincia",null);break;case"BR":case"BRA":case"Brazil":this.setStateValues(t,"Estado",null);break;case"FR":case"FRA":case"France":this.setStateValues(t,"Région",null);break;case"GB":case"GBR":case"United Kingdom":this.setStateValues(t,"State/Region",null);break;case"DE":case"DEU":case"Germany":this.setStateValues(t,"Bundesland",null);break;case"NL":case"NLD":case"Netherlands":this.setStateValues(t,"Provincie",null);break;case"AU":case"AUS":this.setStateValues(t,"Province / State",[{label:"Select",value:""},{label:"New South Wales",value:"NSW"},{label:"Victoria",value:"VIC"},{label:"Queensland",value:"QLD"},{label:"South Australia",value:"SA"},{label:"Western Australia",value:"WA"},{label:"Tasmania",value:"TAS"},{label:"Northern Territory",value:"NT"},{label:"Australian Capital Territory",value:"ACT"}]);break;case"Australia":this.setStateValues(t,"Province / State",[{label:"Select",value:""},{label:"New South Wales",value:"New South Wales"},{label:"Victoria",value:"Victoria"},{label:"Queensland",value:"Queensland"},{label:"South Australia",value:"South Australia"},{label:"Western Australia",value:"Western Australia"},{label:"Tasmania",value:"Tasmania"},{label:"Northern Territory",value:"Northern Territory"},{label:"Australian Capital Territory",value:"Australian Capital Territory"}]);break;case"US":case"USA":this.setStateValues(t,"State",[{label:"Select State",value:""},{label:"Alabama",value:"AL"},{label:"Alaska",value:"AK"},{label:"Arizona",value:"AZ"},{label:"Arkansas",value:"AR"},{label:"California",value:"CA"},{label:"Colorado",value:"CO"},{label:"Connecticut",value:"CT"},{label:"Delaware",value:"DE"},{label:"District of Columbia",value:"DC"},{label:"Florida",value:"FL"},{label:"Georgia",value:"GA"},{label:"Hawaii",value:"HI"},{label:"Idaho",value:"ID"},{label:"Illinois",value:"IL"},{label:"Indiana",value:"IN"},{label:"Iowa",value:"IA"},{label:"Kansas",value:"KS"},{label:"Kentucky",value:"KY"},{label:"Louisiana",value:"LA"},{label:"Maine",value:"ME"},{label:"Maryland",value:"MD"},{label:"Massachusetts",value:"MA"},{label:"Michigan",value:"MI"},{label:"Minnesota",value:"MN"},{label:"Mississippi",value:"MS"},{label:"Missouri",value:"MO"},{label:"Montana",value:"MT"},{label:"Nebraska",value:"NE"},{label:"Nevada",value:"NV"},{label:"New Hampshire",value:"NH"},{label:"New Jersey",value:"NJ"},{label:"New Mexico",value:"NM"},{label:"New York",value:"NY"},{label:"North Carolina",value:"NC"},{label:"North Dakota",value:"ND"},{label:"Ohio",value:"OH"},{label:"Oklahoma",value:"OK"},{label:"Oregon",value:"OR"},{label:"Pennsylvania",value:"PA"},{label:"Rhode Island",value:"RI"},{label:"South Carolina",value:"SC"},{label:"South Dakota",value:"SD"},{label:"Tennessee",value:"TN"},{label:"Texas",value:"TX"},{label:"Utah",value:"UT"},{label:"Vermont",value:"VT"},{label:"Virginia",value:"VA"},{label:"Washington",value:"WA"},{label:"West Virginia",value:"WV"},{label:"Wisconsin",value:"WI"},{label:"Wyoming",value:"WY"},{label:"── US Territories ──",value:"",disabled:!0},{label:"American Samoa",value:"AS"},{label:"Guam",value:"GU"},{label:"Northern Mariana Islands",value:"MP"},{label:"Puerto Rico",value:"PR"},{label:"US Minor Outlying Islands",value:"UM"},{label:"Virgin Islands",value:"VI"},{label:"── Armed Forces ──",value:"",disabled:!0},{label:"Armed Forces Americas",value:"AA"},{label:"Armed Forces Africa",value:"AE"},{label:"Armed Forces Canada",value:"AE"},{label:"Armed Forces Europe",value:"AE"},{label:"Armed Forces Middle East",value:"AE"},{label:"Armed Forces Pacific",value:"AP"}]);break;case"United States":this.setStateValues(t,"State",[{label:"Select State",value:""},{label:"Alabama",value:"Alabama"},{label:"Alaska",value:"Alaska"},{label:"Arizona",value:"Arizona"},{label:"Arkansas",value:"Arkansas"},{label:"California",value:"California"},{label:"Colorado",value:"Colorado"},{label:"Connecticut",value:"Connecticut"},{label:"Delaware",value:"Delaware"},{label:"District of Columbia",value:"District of Columbia"},{label:"Florida",value:"Florida"},{label:"Georgia",value:"Georgia"},{label:"Hawaii",value:"Hawaii"},{label:"Idaho",value:"Idaho"},{label:"Illinois",value:"Illinois"},{label:"Indiana",value:"Indiana"},{label:"Iowa",value:"Iowa"},{label:"Kansas",value:"Kansas"},{label:"Kentucky",value:"Kentucky"},{label:"Louisiana",value:"Louisiana"},{label:"Maine",value:"Maine"},{label:"Maryland",value:"Maryland"},{label:"Massachusetts",value:"Massachusetts"},{label:"Michigan",value:"Michigan"},{label:"Minnesota",value:"Minnesota"},{label:"Mississippi",value:"Mississippi"},{label:"Missouri",value:"Missouri"},{label:"Montana",value:"Montana"},{label:"Nebraska",value:"Nebraska"},{label:"Nevada",value:"Nevada"},{label:"New Hampshire",value:"New Hampshire"},{label:"New Jersey",value:"New Jersey"},{label:"New Mexico",value:"New Mexico"},{label:"New York",value:"New York"},{label:"North Carolina",value:"North Carolina"},{label:"North Dakota",value:"North Dakota"},{label:"Ohio",value:"Ohio"},{label:"Oklahoma",value:"Oklahoma"},{label:"Oregon",value:"Oregon"},{label:"Pennsylvania",value:"Pennsylvania"},{label:"Rhode Island",value:"Rhode Island"},{label:"South Carolina",value:"South Carolina"},{label:"South Dakota",value:"South Dakota"},{label:"Tennessee",value:"Tennessee"},{label:"Texas",value:"Texas"},{label:"Utah",value:"Utah"},{label:"Vermont",value:"Vermont"},{label:"Virginia",value:"Virginia"},{label:"Washington",value:"Washington"},{label:"West Virginia",value:"West Virginia"},{label:"Wisconsin",value:"Wisconsin"},{label:"Wyoming",value:"Wyoming"},{label:"── US Territories ──",value:"",disabled:!0},{label:"American Samoa",value:"American Samoa"},{label:"Guam",value:"Guam"},{label:"Northern Mariana Islands",value:"Northern Mariana Islands"},{label:"Puerto Rico",value:"Puerto Rico"},{label:"US Minor Outlying Islands",value:"US Minor Outlying Islands"},{label:"Virgin Islands",value:"Virgin Islands"},{label:"── Armed Forces ──",value:"",disabled:!0},{label:"Armed Forces Americas",value:"Armed Forces Americas"},{label:"Armed Forces Africa",value:"Armed Forces Africa"},{label:"Armed Forces Canada",value:"Armed Forces Canada"},{label:"Armed Forces Europe",value:"Armed Forces Europe"},{label:"Armed Forces Middle East",value:"Armed Forces Middle East"},{label:"Armed Forces Pacific",value:"Armed Forces Pacific"}]);break;case"CA":case"CAN":this.setStateValues(t,"Province / Territory",[{label:"Select",value:""},{label:"Alberta",value:"AB"},{label:"British Columbia",value:"BC"},{label:"Manitoba",value:"MB"},{label:"New Brunswick",value:"NB"},{label:"Newfoundland and Labrador",value:"NL"},{label:"Northwest Territories",value:"NT"},{label:"Nova Scotia",value:"NS"},{label:"Nunavut",value:"NU"},{label:"Ontario",value:"ON"},{label:"Prince Edward Island",value:"PE"},{label:"Quebec",value:"QC"},{label:"Saskatchewan",value:"SK"},{label:"Yukon",value:"YT"}]);break;case"Canada":this.setStateValues(t,"Province / Territory",[{label:"Select",value:""},{label:"Alberta",value:"Alberta"},{label:"British Columbia",value:"British Columbia"},{label:"Manitoba",value:"Manitoba"},{label:"New Brunswick",value:"New Brunswick"},{label:"Newfoundland and Labrador",value:"Newfoundland and Labrador"},{label:"Northwest Territories",value:"Northwest Territories"},{label:"Nova Scotia",value:"Nova Scotia"},{label:"Nunavut",value:"Nunavut"},{label:"Ontario",value:"Ontario"},{label:"Prince Edward Island",value:"Prince Edward Island"},{label:"Quebec",value:"Quebec"},{label:"Saskatchewan",value:"Saskatchewan"},{label:"Yukon",value:"Yukon"}]);break;case"MX":case"MEX":this.setStateValues(t,"Estado",[{label:"Seleccione Estado",value:""},{label:"Aguascalientes",value:"AGU"},{label:"Baja California",value:"BCN"},{label:"Baja California Sur",value:"BCS"},{label:"Campeche",value:"CAM"},{label:"Chiapas",value:"CHP"},{label:"Ciudad de Mexico",value:"CMX"},{label:"Chihuahua",value:"CHH"},{label:"Coahuila",value:"COA"},{label:"Colima",value:"COL"},{label:"Durango",value:"DUR"},{label:"Guanajuato",value:"GUA"},{label:"Guerrero",value:"GRO"},{label:"Hidalgo",value:"HID"},{label:"Jalisco",value:"JAL"},{label:"Michoacan",value:"MIC"},{label:"Morelos",value:"MOR"},{label:"Nayarit",value:"NAY"},{label:"Nuevo Leon",value:"NLE"},{label:"Oaxaca",value:"OAX"},{label:"Puebla",value:"PUE"},{label:"Queretaro",value:"QUE"},{label:"Quintana Roo",value:"ROO"},{label:"San Luis Potosi",value:"SLP"},{label:"Sinaloa",value:"SIN"},{label:"Sonora",value:"SON"},{label:"Tabasco",value:"TAB"},{label:"Tamaulipas",value:"TAM"},{label:"Tlaxcala",value:"TLA"},{label:"Veracruz",value:"VER"},{label:"Yucatan",value:"YUC"},{label:"Zacatecas",value:"ZAC"}]);break;case"Mexico":this.setStateValues(t,"Estado",[{label:"Seleccione Estado",value:""},{label:"Aguascalientes",value:"Aguascalientes"},{label:"Baja California",value:"Baja California"},{label:"Baja California Sur",value:"Baja California Sur"},{label:"Campeche",value:"Campeche"},{label:"Chiapas",value:"Chiapas"},{label:"Ciudad de Mexico",value:"Ciudad de Mexico"},{label:"Chihuahua",value:"Chihuahua"},{label:"Coahuila",value:"Coahuila"},{label:"Colima",value:"Colima"},{label:"Durango",value:"Durango"},{label:"Guanajuato",value:"Guanajuato"},{label:"Guerrero",value:"Guerrero"},{label:"Hidalgo",value:"Hidalgo"},{label:"Jalisco",value:"Jalisco"},{label:"Michoacan",value:"Michoacan"},{label:"Morelos",value:"Morelos"},{label:"Nayarit",value:"Nayarit"},{label:"Nuevo Leon",value:"Nuevo Leon"},{label:"Oaxaca",value:"Oaxaca"},{label:"Puebla",value:"Puebla"},{label:"Queretaro",value:"Queretaro"},{label:"Quintana Roo",value:"Quintana Roo"},{label:"San Luis Potosi",value:"San Luis Potosi"},{label:"Sinaloa",value:"Sinaloa"},{label:"Sonora",value:"Sonora"},{label:"Tabasco",value:"Tabasco"},{label:"Tamaulipas",value:"Tamaulipas"},{label:"Tlaxcala",value:"Tlaxcala"},{label:"Veracruz",value:"Veracruz"},{label:"Yucatan",value:"Yucatan"},{label:"Zacatecas",value:"Zacatecas"}]);break;default:this.setStateValues(t,"Province / State",null)}}setStateValues(e,t,n){const i=p.getField(e),s=i?i.closest(".en__field"):null;if(s){const i=s.querySelector(".en__field__label"),o=s.querySelector(".en__field__element");if(i&&(i.innerHTML=t),o){const i=te(`engrid-state-${e}`);if(null==n?void 0:n.length){const t=document.createElement("select");t.name=e,t.id="en__field_"+e.toLowerCase().replace(".","_"),t.classList.add("en__field__input"),t.classList.add("en__field__input--select"),t.autocomplete="address-level1";let s=!1;n.forEach((e=>{const n=document.createElement("option");n.value=e.value,n.innerHTML=e.label,i!==e.value||s||(n.selected=!0,s=!0),e.disabled&&(n.disabled=!0),t.appendChild(n)})),o.innerHTML="",o.appendChild(t),t.addEventListener("change",this.rememberState.bind(this,e)),t.dispatchEvent(new Event("change",{bubbles:!0}))}else{o.innerHTML="";const n=document.createElement("input");n.type="text",n.name=e,n.placeholder=t,n.id="en__field_"+e.toLowerCase().replace(".","_"),n.classList.add("en__field__input"),n.classList.add("en__field__input--text"),n.autocomplete="address-level1",i&&(n.value=i),o.appendChild(n),n.addEventListener("change",this.rememberState.bind(this,e))}}}}rememberState(e){const t=p.getField(e);t&&ne(`engrid-state-${t.name}`,t.value,{expires:1,sameSite:"none",secure:!0})}}class se{constructor(){this._countryEvent=b.getInstance(),this.countryWrapper=document.querySelector(".simple_country_select"),this.countrySelect=this._countryEvent.countryField,this.country=null;const e=te("engrid-autofill"),t=!(!p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")||!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()),n=!!p.checkNested(window.Intl,"DisplayNames"),i=p.getUrlParameter("supporter.country")||p.getUrlParameter("supporter.region")||p.getUrlParameter("ea.url.id")&&!p.getUrlParameter("forwarded");e||t||!n||i?this.init():fetch(`https://${window.location.hostname}/cdn-cgi/trace`).then((e=>e.text())).then((e=>{let t=e.replace(/[\r\n]+/g,'","').replace(/\=+/g,'":"');t='{"'+t.slice(0,t.lastIndexOf('","'))+'"}';const n=JSON.parse(t);this.country=n.loc,this.init()}))}init(){if(this.countrySelect&&this.country){const e=new Intl.DisplayNames(["en"],{type:"region"});this.setCountryByName(e.of(this.country),this.country)}}setCountryByName(e,t){if(this.countrySelect){let n=this.countrySelect.options;for(let i=0;i<n.length;i++)if(n[i].innerHTML.toLowerCase()==e.toLowerCase()||n[i].value.toLowerCase()==t.toLowerCase()){this.countrySelect.selectedIndex=i;break}const i=new Event("change",{bubbles:!0});this.countrySelect.dispatchEvent(i)}}}class oe{constructor(){const e=document.querySelector("div[class*='body-'] title"),t=document.querySelector("div[class*='body-'] h1"),n=document.querySelector("title"),i=document.querySelector("h1");e&&e.parentElement?(e.parentElement.insertAdjacentHTML("beforebegin",'<span id="skip-link"></span>'),this.insertSkipLinkSpan()):t&&t.parentElement?(t.parentElement.insertAdjacentHTML("beforebegin",'<span id="skip-link"></span>'),this.insertSkipLinkSpan()):n&&n.parentElement?(n.parentElement.insertAdjacentHTML("beforebegin",'<span id="skip-link"></span>'),this.insertSkipLinkSpan()):i&&i.parentElement?(i.parentElement.insertAdjacentHTML("beforebegin",'<span id="skip-link"></span>'),this.insertSkipLinkSpan()):p.debug&&console.log("This page contains no <title> or <h1> and a 'Skip to main content' link was not added")}insertSkipLinkSpan(){document.body.insertAdjacentHTML("afterbegin",'<a class="skip-link" href="#skip-link">Skip to main content</a>')}}class re{constructor(){this.imgSrcDefer=document.querySelectorAll("img[data-src]"),this.videoBackground=document.querySelectorAll("video"),this.videoBackgroundSource=document.querySelectorAll("video source");for(let e=0;e<this.imgSrcDefer.length;e++){let t=this.imgSrcDefer[e];if(t){t.setAttribute("decoding","async"),t.setAttribute("loading","lazy");let e=t.getAttribute("data-src");e&&t.setAttribute("src",e),t.setAttribute("data-engrid-data-src-processed","true"),t.removeAttribute("data-src")}}for(let e=0;e<this.videoBackground.length;e++){let t=this.videoBackground[e];if(this.videoBackgroundSource=t.querySelectorAll("source"),this.videoBackgroundSource){for(let e=0;e<this.videoBackgroundSource.length;e++){let t=this.videoBackgroundSource[e];if(t){let e=t.getAttribute("data-src");e&&(t.setAttribute("src",e),t.setAttribute("data-engrid-data-src-processed","true"),t.removeAttribute("data-src"))}}let e=t.parentNode,n=t;e&&n&&(e.replaceChild(n,t),t.muted=!0,t.controls=!1,t.loop=!0,t.playsInline=!0,t.play())}}}}class ae{constructor(){this._frequency=g.getInstance(),this._amount=h.getInstance(),this.linkClass="setRecurrFreq-",this.checkboxName="engrid.recurrfreq",document.querySelectorAll(`a[class^="${this.linkClass}"]`).forEach((e=>{e.addEventListener("click",(t=>{const n=e.className.split(" ").filter((e=>e.startsWith(this.linkClass)));p.debug&&console.log(n),n.length&&(t.preventDefault(),p.setFieldValue("transaction.recurrfreq",n[0].substring(this.linkClass.length).toUpperCase()),this._frequency.load())}))}));const e=p.getFieldValue("transaction.recurrfreq").toUpperCase();document.getElementsByName(this.checkboxName).forEach((t=>{const n=t.value.toUpperCase();t.checked=n===e,t.addEventListener("change",(()=>{const e=t.value.toUpperCase();t.checked?(p.setFieldValue("transaction.recurrfreq",e),p.setFieldValue("transaction.recurrpay","Y"),this._frequency.load(),this._amount.setAmount(this._amount.amount,!1)):"ONETIME"!==e&&(p.setFieldValue("transaction.recurrfreq","ONETIME"),p.setFieldValue("transaction.recurrpay","N"),this._frequency.load(),this._amount.setAmount(this._amount.amount,!1))}))})),this._frequency.onFrequencyChange.subscribe((()=>{const e=this._frequency.frequency.toUpperCase();document.getElementsByName(this.checkboxName).forEach((t=>{const n=t.value.toUpperCase();t.checked&&n!==e?t.checked=!1:t.checked||n!==e||(t.checked=!0)}))}))}}class le{constructor(){if(this.pageBackground=document.querySelector(".page-backgroundImage"),this.pageBackground){const e=this.pageBackground.querySelector("img");let t=null==e?void 0:e.getAttribute("data-src"),n=null==e?void 0:e.src;this.pageBackground&&t?(p.debug&&console.log("A background image set in the page was found with a data-src value, setting it as --engrid__page-backgroundImage_url",t),t="url('"+t+"')",this.pageBackground.style.setProperty("--engrid__page-backgroundImage_url",t)):this.pageBackground&&n?(p.debug&&console.log("A background image set in the page was found with a src value, setting it as --engrid__page-backgroundImage_url",n),n="url('"+n+"')",this.pageBackground.style.setProperty("--engrid__page-backgroundImage_url",n)):e?p.debug&&console.log("A background image set in the page was found but without a data-src or src value, no action taken",e):p.debug&&console.log("A background image set in the page was not found, any default image set in the theme on --engrid__page-backgroundImage_url will be used")}else p.debug&&console.log("A background image set in the page was not found, any default image set in the theme on --engrid__page-backgroundImage_url will be used");this.setDataAttributes()}setDataAttributes(){return this.hasVideoBackground()?p.setBodyData("page-background","video"):this.hasImageBackground()?p.setBodyData("page-background","image"):p.setBodyData("page-background","empty")}hasVideoBackground(){if(this.pageBackground)return!!this.pageBackground.querySelector("video")}hasImageBackground(){if(this.pageBackground)return!this.hasVideoBackground()&&!!this.pageBackground.querySelector("img")}}class ce{constructor(e,t=null,n=null,i){this.apiKey=e,this.dateField=t,this.statusField=n,this.dateFormat=i,this.form=u.getInstance(),this.emailField=null,this.emailWrapper=document.querySelector(".en__field--emailAddress"),this.nbDate=null,this.nbStatus=null,this.logger=new fe("NeverBounce","#039bc4","#dfdfdf","📧"),this.shouldRun=!0,this.nbLoaded=!1,this.emailField=document.getElementById("en__field_supporter_emailAddress"),window._NBSettings={apiKey:this.apiKey,autoFieldHookup:!1,inputLatency:1500,displayPoweredBy:!1,loadingMessage:"Validating...",softRejectMessage:"Invalid email",acceptedMessage:"Email validated!",feedback:!1},p.loadJS("https://cdn.neverbounce.com/widget/dist/NeverBounce.js"),this.emailField&&(this.emailField.value&&(this.logger.log("E-mail Field Found"),this.shouldRun=!1),this.emailField.addEventListener("change",(e=>{var t;this.nbLoaded||(this.shouldRun=!0,this.init(),(null===(t=this.emailField)||void 0===t?void 0:t.value)&&setTimeout((function(){window._nb.fields.get(document.querySelector("[data-nb-id]"))[0].forceUpdate()}),100))})),window.setTimeout((()=>{this.emailField&&this.emailField.value&&(this.logger.log("E-mail Filled Programatically"),this.shouldRun=!1),this.init()}),1e3)),this.form.onValidate.subscribe(this.validate.bind(this))}init(){if(!this.shouldRun)return void this.logger.log("Should Not Run");if(this.nbLoaded)return void this.logger.log("Already Loaded");if(this.logger.log("Init Function"),this.dateField&&document.getElementsByName(this.dateField).length&&(this.nbDate=document.querySelector("[name='"+this.dateField+"']")),this.statusField&&document.getElementsByName(this.statusField).length&&(this.nbStatus=document.querySelector("[name='"+this.statusField+"']")),!this.emailField)return void this.logger.log("E-mail Field Not Found");this.wrap(this.emailField,document.createElement("div"));this.emailField.parentNode.id="nb-wrapper";const e=document.createElement("div");e.innerHTML='<div id="nb-feedback" class="en__field__error nb-hidden">Enter a valid email.</div>',this.insertAfter(e,this.emailField);const t=this;document.body.addEventListener("nb:registered",(function(e){const n=document.querySelector('[data-nb-id="'+e.detail.id+'"]');n.addEventListener("nb:loading",(function(e){p.disableSubmit("Validating Your Email")})),n.addEventListener("nb:clear",(function(e){t.setEmailStatus("clear"),p.enableSubmit(),t.nbDate&&(t.nbDate.value=""),t.nbStatus&&(t.nbStatus.value="")})),n.addEventListener("nb:soft-result",(function(e){t.setEmailStatus("soft-result"),t.nbDate&&(t.nbDate.value=""),t.nbStatus&&(t.nbStatus.value=""),p.enableSubmit()})),n.addEventListener("nb:result",(function(e){e.detail.result.is(window._nb.settings.getAcceptedStatusCodes())?(t.setEmailStatus("valid"),t.nbDate&&(t.nbDate.value=p.formatDate(new Date,t.dateFormat)),t.nbStatus&&(t.nbStatus.value=e.detail.result.response.result)):(t.setEmailStatus("invalid"),t.nbDate&&(t.nbDate.value=""),t.nbStatus&&(t.nbStatus.value="")),p.enableSubmit()}))})),window._nb.fields.registerListener(t.emailField,!0),this.nbLoaded=!0}clearStatus(){if(!this.emailField)return void this.logger.log("E-mail Field Not Found");this.emailField.classList.remove("rm-error");const e=document.getElementById("nb-wrapper"),t=document.getElementById("nb-feedback");e.className="",t.className="en__field__error nb-hidden",t.innerHTML="",this.emailWrapper.classList.remove("en__field--validationFailed")}deleteENFieldError(){const e=document.querySelector(".en__field--emailAddress>div.en__field__error");e&&e.remove()}setEmailStatus(e){if(this.logger.log("Status:",e),!this.emailField)return void this.logger.log("E-mail Field Not Found");const t=document.getElementById("nb-wrapper");let n=document.getElementById("nb-feedback");const i="nb-hidden",s="nb-loading",o="rm-error";if(!n){const e=t.querySelector("div");e&&(e.innerHTML='<div id="nb-feedback" class="en__field__error nb-hidden">Enter a valid email.</div>'),n=document.getElementById("nb-feedback")}if("valid"==e)this.clearStatus();else switch(t.classList.remove("nb-success"),t.classList.add("nb-error"),e){case"required":this.deleteENFieldError(),n.innerHTML="A valid email is required",n.classList.remove(s),n.classList.remove(i),this.emailField.classList.add(o);break;case"soft-result":this.emailField.value?(this.deleteENFieldError(),n.innerHTML="Invalid email",n.classList.remove(i),this.emailField.classList.add(o)):this.clearStatus();break;case"invalid":this.deleteENFieldError(),n.innerHTML="Invalid email",n.classList.remove(s),n.classList.remove(i),this.emailField.classList.add(o);break;default:this.clearStatus()}}insertAfter(e,t){var n;null===(n=null==t?void 0:t.parentNode)||void 0===n||n.insertBefore(e,t.nextSibling)}wrap(e,t){var n;null===(n=e.parentNode)||void 0===n||n.insertBefore(t,e),t.appendChild(e)}validate(){var e;if(!this.form.validate)return;const t=p.getFieldValue("nb-result");this.emailField&&this.shouldRun&&this.nbLoaded&&t?(this.nbStatus&&(this.nbStatus.value=t),["catchall","unknown","valid"].includes(t)||(this.setEmailStatus("required"),null===(e=this.emailField)||void 0===e||e.focus(),this.logger.log("NB-Result:",p.getFieldValue("nb-result")),this.form.validate=!1)):this.logger.log("validate(): Should Not Run. Returning true.")}}class de{constructor(){this.form=u.getInstance(),this.emailField=null,this.emailWrapper=document.querySelector(".en__field--emailAddress"),this.faDate=null,this.faStatus=null,this.faMessage=null,this.logger=new fe("FreshAddress","#039bc4","#dfdfdf","📧"),this.shouldRun=!0,this.options=p.getOption("FreshAddress"),!1!==this.options&&window.FreshAddress&&(this.emailField=document.getElementById("en__field_supporter_emailAddress"),this.emailField?(this.createFields(),this.addEventListeners(),window.FreshAddressStatus="idle",this.emailField.value&&(this.logger.log("E-mail Field Found"),this.shouldRun=!1),window.setTimeout((()=>{this.emailField&&this.emailField.value&&(this.logger.log("E-mail Filled Programatically"),this.shouldRun=!1)}),1e3)):this.logger.log("E-mail Field Not Found"))}createFields(){this.options&&(this.options.dateField=this.options.dateField||"fa_date",this.faDate=p.getField(this.options.dateField),this.faDate||(this.logger.log("Date Field Not Found. Creating..."),p.createHiddenInput(this.options.dateField,""),this.faDate=p.getField(this.options.dateField)),this.options.statusField=this.options.statusField||"fa_status",this.faStatus=p.getField(this.options.statusField),this.faStatus||(this.logger.log("Status Field Not Found. Creating..."),p.createHiddenInput(this.options.statusField,""),this.faStatus=p.getField(this.options.statusField)),this.options.messageField=this.options.messageField||"fa_message",this.faMessage=p.getField(this.options.messageField),this.faMessage||(this.logger.log("Message Field Not Found. Creating..."),p.createHiddenInput(this.options.messageField,""),this.faMessage=p.getField(this.options.messageField)))}writeToFields(e,t){this.options&&(this.faDate.value=p.formatDate(new Date,this.options.dateFieldFormat||"yyyy-MM-dd"),this.faStatus.value=e,this.faMessage.value=t,this.emailWrapper.dataset.freshaddressSafetosendstatus=e.toLowerCase())}addEventListeners(){var e;this.options&&(null===(e=this.emailField)||void 0===e||e.addEventListener("change",(()=>{var e,t;if(!this.shouldRun||(null===(e=this.emailField)||void 0===e?void 0:e.value.includes("@4sitestudios.com")))return p.removeError(this.emailWrapper),this.writeToFields("Valid","Skipped"),void this.logger.log("Skipping E-mail Validation");this.logger.log("Validating "+(null===(t=this.emailField)||void 0===t?void 0:t.value)),this.callAPI()})),this.form.onValidate.subscribe(this.validate.bind(this)))}callAPI(){var e;if(!this.options||!window.FreshAddress)return;if(!this.shouldRun)return;window.FreshAddressStatus="validating";const t=null===(e=this.emailField)||void 0===e?void 0:e.value;window.FreshAddress.validateEmail(t,{emps:!1,rtc_timeout:1200}).then((e=>(this.logger.log("Validate API Response",JSON.parse(JSON.stringify(e))),this.validateResponse(e))))}validateResponse(e){var t;if(e.isServiceError())return this.logger.log("Service Error"),this.writeToFields("Service Error",e.getErrorResponse()),!0;e.isValid()?(this.writeToFields("Valid",e.getComment()),p.removeError(this.emailWrapper),e.hasSuggest()&&(p.setError(this.emailWrapper,`Did you mean ${e.getSuggEmail()}?`),this.emailField.value=e.getSuggEmail())):e.isError()?(this.writeToFields("Invalid",e.getErrorResponse()),p.setError(this.emailWrapper,e.getErrorResponse()),null===(t=this.emailField)||void 0===t||t.focus(),e.hasSuggest()&&(p.setError(this.emailWrapper,`Did you mean ${e.getSuggEmail()}?`),this.emailField.value=e.getSuggEmail(),this.writeToFields("Error",e.getErrorResponse()))):e.isWarning()?(this.writeToFields("Invalid",e.getErrorResponse()),p.setError(this.emailWrapper,e.getErrorResponse()),e.hasSuggest()&&(p.setError(this.emailWrapper,`Did you mean ${e.getSuggEmail()}?`),this.emailField.value=e.getSuggEmail(),this.writeToFields("Warning",e.getErrorResponse()))):this.writeToFields("API Error","Unknown Error"),window.FreshAddressStatus="idle",p.enableSubmit()}validate(){var e;if(p.removeError(this.emailWrapper),this.form.validate)if(this.options)if(this.shouldRun){if("validating"!==window.FreshAddressStatus)return"Invalid"===this.faStatus.value?(this.form.validate=!1,window.setTimeout((()=>{p.setError(this.emailWrapper,this.faMessage.value)}),100),null===(e=this.emailField)||void 0===e||e.focus(),p.enableSubmit(),!1):(this.form.validate=!0,!0);{this.logger.log("Waiting for API Response");const e=new Promise(((e,t)=>{setTimeout((()=>{var n;const i=this.faStatus.value;if(""===i||"Invalid"===i)return this.logger.log("Promise Rejected"),null===(n=this.emailField)||void 0===n||n.focus(),void t(!1);this.logger.log("Promise Resolved"),e(!0)}),700)}));this.form.validatePromise=e}}else this.form.validate=!0;else this.form.validate=!0}}class ue{constructor(){var e,t;const n=document.querySelector("span[data-engrid-progress-indicator]"),i=p.getPageCount(),s=p.getPageNumber();if(!n||!i||!s)return;let o=null!==(e=n.getAttribute("max"))&&void 0!==e?e:100;"string"==typeof o&&(o=parseInt(o));let r=null!==(t=n.getAttribute("amount"))&&void 0!==t?t:0;"string"==typeof r&&(r=parseInt(r));const a=1===s?0:Math.ceil((s-1)/i*o);let l=1===s?0:Math.ceil(s/i*o);const c=a/100;let d=l/100;if(r&&(l=Math.ceil(r)>Math.ceil(o)?o:r,d=l/100),n.innerHTML=`\n\t\t\t<div class="indicator__wrap">\n\t\t\t\t<span class="indicator__progress" style="transform: scaleX(${c});"></span>\n\t\t\t\t<span class="indicator__percentage">${l}<span class="indicator__percentage-sign">%</span></span>\n\t\t\t</div>`,l!==a){const e=document.querySelector(".indicator__progress");requestAnimationFrame((function(){e.style.transform=`scaleX(${d})`}))}}}const he=n(3861).ZP;class pe{constructor(e){if(this._form=u.getInstance(),this._events=f.getInstance(),this.iframe=null,this.remoteUrl=e.remoteUrl?e.remoteUrl:null,this.cookieName=e.cookieName?e.cookieName:"engrid-autofill",this.cookieExpirationDays=e.cookieExpirationDays?e.cookieExpirationDays:365,this.rememberMeOptIn=!!e.checked&&e.checked,this.fieldNames=e.fieldNames?e.fieldNames:[],this.fieldDonationAmountRadioName=e.fieldDonationAmountRadioName?e.fieldDonationAmountRadioName:"transaction.donationAmt",this.fieldDonationAmountOtherName=e.fieldDonationAmountOtherName?e.fieldDonationAmountOtherName:"transaction.donationAmt.other",this.fieldDonationRecurrPayRadioName=e.fieldDonationRecurrPayRadioName?e.fieldDonationRecurrPayRadioName:"transaction.recurrpay",this.fieldDonationAmountOtherCheckboxID=e.fieldDonationAmountOtherCheckboxID?e.fieldDonationAmountOtherCheckboxID:"#en__field_transaction_donationAmt4",this.fieldOptInSelectorTarget=e.fieldOptInSelectorTarget?e.fieldOptInSelectorTarget:".en__field--emailAddress.en__field",this.fieldOptInSelectorTargetLocation=e.fieldOptInSelectorTargetLocation?e.fieldOptInSelectorTargetLocation:"after",this.fieldClearSelectorTarget=e.fieldClearSelectorTarget?e.fieldClearSelectorTarget:'label[for="en__field_supporter_firstName"]',this.fieldClearSelectorTargetLocation=e.fieldClearSelectorTargetLocation?e.fieldClearSelectorTargetLocation:"before",this.fieldData={},this.useRemote())this.createIframe((()=>{this.iframe&&this.iframe.contentWindow&&(this.iframe.contentWindow.postMessage(JSON.stringify({key:this.cookieName,operation:"read"}),"*"),this._form.onSubmit.subscribe((()=>{this.rememberMeOptIn&&(this.readFields(),this.saveCookieToRemote())})))}),(e=>{let t;if(e.data&&"string"==typeof e.data&&this.isJson(e.data)&&(t=JSON.parse(e.data)),t&&t.key&&void 0!==t.value&&t.key===this.cookieName){this.updateFieldData(t.value),this.writeFields(),Object.keys(this.fieldData).length>0?this.insertClearRememberMeLink():this.insertRememberMeOptin()}}));else{this.readCookie(),Object.keys(this.fieldData).length>0?(this.insertClearRememberMeLink(),this.rememberMeOptIn=!0):(this.insertRememberMeOptin(),this.rememberMeOptIn=!1),this.writeFields(),this._form.onSubmit.subscribe((()=>{this.rememberMeOptIn&&(this.readFields(),this.saveCookie())}))}}updateFieldData(e){if(e){let t=JSON.parse(e);for(let e=0;e<this.fieldNames.length;e++)void 0!==t[this.fieldNames[e]]&&(this.fieldData[this.fieldNames[e]]=decodeURIComponent(t[this.fieldNames[e]]))}}insertClearRememberMeLink(){let e=document.getElementById("clear-autofill-data");if(!e){const t="clear autofill";e=document.createElement("a"),e.setAttribute("id","clear-autofill-data"),e.classList.add("label-tooltip"),e.setAttribute("style","cursor: pointer;"),e.innerHTML=`(${t})`;const n=this.getElementByFirstSelector(this.fieldClearSelectorTarget);n&&("after"===this.fieldClearSelectorTargetLocation?n.appendChild(e):n.prepend(e))}e.addEventListener("click",(e=>{e.preventDefault(),this.clearFields(["supporter.country"]),this.useRemote()?this.clearCookieOnRemote():this.clearCookie();let t=document.getElementById("clear-autofill-data");t&&(t.style.display="none"),this.rememberMeOptIn=!1,this._events.dispatchClear(),window.dispatchEvent(new CustomEvent("RememberMe_Cleared"))})),this._events.dispatchLoad(!0),window.dispatchEvent(new CustomEvent("RememberMe_Loaded",{detail:{withData:!0}}))}getElementByFirstSelector(e){let t=null;const n=e.split(",");for(let e=0;e<n.length&&(t=document.querySelector(n[e]),!t);e++);return t}insertRememberMeOptin(){let e=document.getElementById("remember-me-opt-in");if(e)this.rememberMeOptIn&&(e.checked=!0);else{const e="Remember Me",t="\n\t\t\t\tCheck “Remember me” to complete forms on this device faster. \n\t\t\t\tWhile your financial information won’t be stored, you should only check this box from a personal device. \n\t\t\t\tClick “Clear autofill” to remove the information from your device at any time.\n\t\t\t",n=this.rememberMeOptIn?"checked":"",i=document.createElement("div");i.classList.add("en__field","en__field--checkbox","en__field--question","rememberme-wrapper"),i.setAttribute("id","remember-me-opt-in"),i.setAttribute("style","overflow-x: hidden;"),i.innerHTML=`\n <div class="en__field__element en__field__element--checkbox">\n <div class="en__field__item">\n <input id="remember-me-checkbox" type="checkbox" class="en__field__input en__field__input--checkbox" ${n} />\n <label for="remember-me-checkbox" class="en__field__label en__field__label--item" style="white-space: nowrap;">\n <div class="rememberme-content" style="display: inline-flex; align-items: center;">\n ${e}\n <a id="rememberme-learn-more-toggle" style="display: inline-block; display: inline-flex; align-items: center; cursor: pointer; margin-left: 10px; margin-top: var(--rememberme-learn-more-toggle_margin-top)">\n <svg style="height: 14px; width: auto; z-index: 1;" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11 7H9V5H11V7ZM11 9H9V15H11V9ZM10 2C5.59 2 2 5.59 2 10C2 14.41 5.59 18 10 18C14.41 18 18 14.41 18 10C18 5.59 14.41 2 10 2ZM10 0C15.523 0 20 4.477 20 10C20 15.523 15.523 20 10 20C4.477 20 0 15.523 0 10C0 4.477 4.477 0 10 0Z" fill="currentColor"/></svg>\n </a>\n </div>\n </label>\n </div>\n </div>\n\t\t\t`;const s=this.getElementByFirstSelector(this.fieldOptInSelectorTarget);if(s&&s.parentNode){s.parentNode.insertBefore(i,"before"==this.fieldOptInSelectorTargetLocation?s:s.nextSibling);const e=document.getElementById("remember-me-checkbox");e&&e.addEventListener("change",(()=>{e.checked?this.rememberMeOptIn=!0:this.rememberMeOptIn=!1})),he("#rememberme-learn-more-toggle",{content:t})}}this._events.dispatchLoad(!1),window.dispatchEvent(new CustomEvent("RememberMe_Loaded",{detail:{withData:!1}}))}useRemote(){return!!this.remoteUrl&&"function"==typeof window.postMessage&&window.JSON&&window.localStorage}createIframe(e,t){if(this.remoteUrl){let n=document.createElement("iframe");n.style.cssText="position:absolute;width:1px;height:1px;left:-9999px;",n.src=this.remoteUrl,n.setAttribute("sandbox","allow-same-origin allow-scripts"),this.iframe=n,document.body.appendChild(this.iframe),this.iframe.addEventListener("load",(()=>e()),!1),window.addEventListener("message",(e=>{var n;(null===(n=this.iframe)||void 0===n?void 0:n.contentWindow)===e.source&&t(e)}),!1)}}clearCookie(){this.fieldData={},this.saveCookie()}clearCookieOnRemote(){this.fieldData={},this.saveCookieToRemote()}saveCookieToRemote(){this.iframe&&this.iframe.contentWindow&&this.iframe.contentWindow.postMessage(JSON.stringify({key:this.cookieName,value:this.fieldData,operation:"write",expires:this.cookieExpirationDays}),"*")}readCookie(){this.updateFieldData(te(this.cookieName)||"")}saveCookie(){ne(this.cookieName,JSON.stringify(this.fieldData),{expires:this.cookieExpirationDays})}readFields(){for(let e=0;e<this.fieldNames.length;e++){let t="[name='"+this.fieldNames[e]+"']",n=document.querySelector(t);if(n)if("INPUT"===n.tagName){let i=n.getAttribute("type");"radio"!==i&&"checkbox"!==i||(n=document.querySelector(t+":checked")),this.fieldData[this.fieldNames[e]]=encodeURIComponent(n.value)}else"SELECT"===n.tagName&&(this.fieldData[this.fieldNames[e]]=encodeURIComponent(n.value))}}setFieldValue(e,t,n=!1){e&&void 0!==t&&(e.value&&n||!e.value)&&(e.value=t)}clearFields(e){for(let t in this.fieldData)e.includes(t)||""===this.fieldData[t]?delete this.fieldData[t]:this.fieldData[t]="";this.writeFields(!0)}writeFields(e=!1){for(let t=0;t<this.fieldNames.length;t++){let n="[name='"+this.fieldNames[t]+"']",i=document.querySelector(n);i&&("INPUT"===i.tagName?this.fieldNames[t]===this.fieldDonationRecurrPayRadioName?"Y"===this.fieldData[this.fieldNames[t]]&&i.click():this.fieldDonationAmountRadioName===this.fieldNames[t]?(i=document.querySelector(n+"[value='"+this.fieldData[this.fieldNames[t]]+"']"),i?i.click():(i=document.querySelector("input[name='"+this.fieldDonationAmountOtherName+"']"),this.setFieldValue(i,this.fieldData[this.fieldNames[t]],!0))):this.setFieldValue(i,this.fieldData[this.fieldNames[t]],e):"SELECT"===i.tagName&&this.setFieldValue(i,this.fieldData[this.fieldNames[t]],!0))}}isJson(e){try{JSON.parse(e)}catch(e){return!1}return!0}}class ge{constructor(){if(this._amount=h.getInstance(),this.logger=new fe("ShowIfAmount","yellow","black","👀"),this._elements=document.querySelectorAll('[class*="showifamount"]'),this._elements.length>0)return this._amount.onAmountChange.subscribe((()=>this.init())),void this.init();this.logger.log("Show If Amount: NO ELEMENTS FOUND")}init(){const e=p.getGiftProcess()?window.pageJson.amount:this._amount.amount;this._elements.forEach((t=>{this.lessthan(e,t),this.lessthanorequalto(e,t),this.equalto(e,t),this.greaterthanorequalto(e,t),this.greaterthan(e,t),this.between(e,t)}))}getClassNameByOperand(e,t){let n=null;return e.forEach((e=>{e.includes(`showifamount-${t}-`)&&(n=e)})),n}lessthan(e,t){const n=this.getClassNameByOperand(t.classList,"lessthan");if(n){let i=n.split("-").slice(-1)[0];e<Number(i)?(this.logger.log("(lessthan):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}lessthanorequalto(e,t){const n=this.getClassNameByOperand(t.classList,"lessthanorequalto");if(n){let i=n.split("-").slice(-1)[0];e<=Number(i)?(this.logger.log("(lessthanorequalto):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}equalto(e,t){const n=this.getClassNameByOperand(t.classList,"equalto");if(n){let i=n.split("-").slice(-1)[0];e==Number(i)?(this.logger.log("(equalto):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}greaterthanorequalto(e,t){const n=this.getClassNameByOperand(t.classList,"greaterthanorequalto");if(n){let i=n.split("-").slice(-1)[0];e>=Number(i)?(this.logger.log("(greaterthanorequalto):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}greaterthan(e,t){const n=this.getClassNameByOperand(t.classList,"greaterthan");if(n){let i=n.split("-").slice(-1)[0];e>Number(i)?(this.logger.log("(greaterthan):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}between(e,t){const n=this.getClassNameByOperand(t.classList,"between");if(n){let i=n.split("-").slice(-2,-1)[0],s=n.split("-").slice(-1)[0];e>Number(i)&&e<Number(s)?(this.logger.log("(between):",t),t.classList.add("engrid-open")):t.classList.remove("engrid-open")}}}class me{constructor(){this.logger=new fe("OtherAmount","green","black","💰"),this._amount=h.getInstance(),"focusin input".split(" ").forEach((e=>{var t;null===(t=document.querySelector("body"))||void 0===t||t.addEventListener(e,(e=>{e.target.classList.contains("en__field__input--other")&&(this.logger.log("Other Amount Field Focused"),this.setRadioInput())}))}));const e=document.querySelector("[name='transaction.donationAmt.other'");e&&(e.setAttribute("inputmode","decimal"),e.setAttribute("aria-label","Enter your custom donation amount"),e.setAttribute("autocomplete","off"),e.setAttribute("data-lpignore","true"),e.addEventListener("change",(e=>{const t=e.target,n=t.value,i=p.cleanAmount(n);n!==i.toString()&&(this.logger.log(`Other Amount Field Changed: ${n} => ${i}`),"dataLayer"in window&&window.dataLayer.push({event:"otherAmountTransformed",otherAmountTransformation:`${n} => ${i}`}),t.value=i%1!=0?i.toFixed(2):i.toString())})),e.addEventListener("blur",(e=>{const t=e.target.value;if(0===p.cleanAmount(t)){this.logger.log("Other Amount Field Blurred with 0 amount");const e=this._amount.amount;e>0&&this._amount.setAmount(e,!1)}})))}setRadioInput(){const e=document.querySelector(".en__field--donationAmt .en__field__input--other");if(e&&e.parentNode&&e.parentNode.parentNode){const t=e.parentNode;if(t.classList.remove("en__field__item--hidden"),t.parentNode){t.parentNode.querySelector(".en__field__item:nth-last-child(2) input").checked=!0}}}}class fe{constructor(e,t,n,i){if(this.prefix="",this.color="black",this.background="white",this.emoji="",i)this.emoji=i;else switch(t){case"red":this.emoji="🔴";break;case"green":this.emoji="🟢";break;case"blue":this.emoji="🔵";break;case"yellow":this.emoji="🟡",this.background="black";break;case"purple":this.emoji="🟣";break;default:this.emoji="⚫"}e&&(this.prefix=`[ENgrid ${e}]`),t&&(this.color=t),n&&(this.background=n)}get log(){return p.debug||"log"===p.getUrlParameter("debug")?console.log.bind(window.console,"%c"+this.emoji+" "+this.prefix+" %s",`color: ${this.color}; background-color: ${this.background}; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;`):()=>{}}get success(){return p.debug?console.log.bind(window.console,"%c ✅ "+this.prefix+" %s","color: green; background-color: white; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;"):()=>{}}get danger(){return p.debug?console.log.bind(window.console,"%c ⛔️ "+this.prefix+" %s","color: red; background-color: white; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;"):()=>{}}get warn(){return p.debug?console.warn.bind(window.console,"%c"+this.emoji+" "+this.prefix+" %s",`color: ${this.color}; background-color: ${this.background}; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;`):()=>{}}get dir(){return p.debug?console.dir.bind(window.console,"%c"+this.emoji+" "+this.prefix+" %s",`color: ${this.color}; background-color: ${this.background}; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;`):()=>{}}get error(){return p.debug?console.error.bind(window.console,"%c"+this.emoji+" "+this.prefix+" %s",`color: ${this.color}; background-color: ${this.background}; font-size: 1.2em; padding: 4px; border-radius: 2px; font-family: monospace;`):()=>{}}}class be{constructor(){var e,t;this._form=u.getInstance(),this._amount=h.getInstance(),this.minAmount=null!==(e=p.getOption("MinAmount"))&&void 0!==e?e:1,this.maxAmount=null!==(t=p.getOption("MaxAmount"))&&void 0!==t?t:1e5,this.minAmountMessage=p.getOption("MinAmountMessage"),this.maxAmountMessage=p.getOption("MaxAmountMessage"),this.logger=new fe("MinMaxAmount","white","purple","🔢"),this.shouldRun()&&(this._amount.onAmountChange.subscribe((e=>window.setTimeout(this.liveValidate.bind(this),1e3))),this._form.onValidate.subscribe(this.enOnValidate.bind(this)))}shouldRun(){return"DONATION"===p.getPageType()}enOnValidate(){if(!this._form.validate)return;const e=document.querySelector("[name='transaction.donationAmt.other']");this._amount.amount<this.minAmount?(this.logger.log("Amount is less than min amount: "+this.minAmount),e&&e.focus(),this._form.validate=!1):this._amount.amount>this.maxAmount&&(this.logger.log("Amount is greater than max amount: "+this.maxAmount),e&&e.focus(),this._form.validate=!1),window.setTimeout(this.liveValidate.bind(this),300)}liveValidate(){const e=p.cleanAmount(this._amount.amount.toString()),t=document.activeElement;t&&"INPUT"===t.tagName&&"name"in t&&"transaction.donationAmt.other"===t.name&&0===e||(this.logger.log(`Amount: ${e}`),e<this.minAmount?(this.logger.log("Amount is less than min amount: "+this.minAmount),p.setError(".en__field--withOther",this.minAmountMessage||"Invalid Amount")):e>this.maxAmount?(this.logger.log("Amount is greater than max amount: "+this.maxAmount),p.setError(".en__field--withOther",this.maxAmountMessage||"Invalid Amount")):p.removeError(".en__field--withOther"))}}class ve{constructor(){if(this.shuffleSeed=n(7650),this.items=[],this.tickerElement=document.querySelector(".engrid-ticker"),this.logger=new fe("Ticker","black","beige","🔁"),!this.shouldRun())return void this.logger.log("Not running");const e=document.querySelectorAll(".engrid-ticker li");if(e.length>0)for(let t=0;t<e.length;t++)this.items.push(e[t].innerText);this.render()}shouldRun(){return null!==this.tickerElement}getSeed(){return(new Date).getDate()+p.getPageID()}getItems(){const e=this.tickerElement.getAttribute("data-total")||"50";this.logger.log("Getting "+e+" items");const t=this.getSeed(),n=this.shuffleSeed.shuffle(this.items,t),i=new Date,s=i.getHours(),o=i.getMinutes();let r=Math.round((60*s+o)/5);r>=n.length&&(r=0);return n.slice(r,r+e).reverse()}render(){var e,t,n;this.logger.log("Rendering");const i=this.getItems();let s=document.createElement("div");s.classList.add("en__component"),s.classList.add("en__component--ticker");let o='<div class="ticker">';for(let e=0;e<i.length;e++)o+='<div class="ticker__item">'+i[e]+"</div>";o='<div id="engrid-ticker">'+o+"</div></div>",s.innerHTML=o,null===(t=null===(e=this.tickerElement)||void 0===e?void 0:e.parentElement)||void 0===t||t.insertBefore(s,this.tickerElement),null===(n=this.tickerElement)||void 0===n||n.remove();const r=document.querySelector(".ticker").offsetWidth.toString();s.style.setProperty("--ticker-size",r),this.logger.log("Ticker Size: "+s.style.getPropertyValue("--ticker-size")),this.logger.log("Ticker Width: "+r)}}class ye{constructor(){this.logger=new fe("DataLayer","#f1e5bc","#009cdc","📊"),this.dataLayer=window.dataLayer||[],this._form=u.getInstance(),this.endOfGiftProcessStorageKey="ENGRID_END_OF_GIFT_PROCESS_EVENTS",this.excludedFields=["transaction.ccnumber","transaction.ccexpire.delimiter","transaction.ccexpire","transaction.ccvv","supporter.creditCardHolderName","supporter.bankAccountNumber","supporter.bankAccountType","transaction.bankname","supporter.bankRoutingNumber"],this.hashedFields=["supporter.emailAddress","supporter.phoneNumber","supporter.phoneNumber2","supporter.address1","supporter.address2","supporter.address3","transaction.infemail","transaction.infadd1","transaction.infadd2","transaction.infadd3","supporter.billingAddress1","supporter.billingAddress2","supporter.billingAddress3"],p.getOption("RememberMe")?f.getInstance().onLoad.subscribe((e=>{this.logger.log("Remember me - onLoad",e),this.onLoad()})):this.onLoad(),this._form.onSubmit.subscribe((()=>this.onSubmit()))}static getInstance(){return ye.instance||(ye.instance=new ye,window._dataLayer=ye.instance),ye.instance}transformJSON(e){return"string"==typeof e?e.toUpperCase().split(" ").join("-").replace(":-","-"):"boolean"==typeof e?e=e?"TRUE":"FALSE":""}onLoad(){if(p.getGiftProcess()?(this.logger.log("EN_SUCCESSFUL_DONATION"),this.dataLayer.push({event:"EN_SUCCESSFUL_DONATION"}),this.addEndOfGiftProcessEventsToDataLayer()):(this.logger.log("EN_PAGE_VIEW"),this.dataLayer.push({event:"EN_PAGE_VIEW"})),window.pageJson){const e=window.pageJson;for(const t in e)Number.isNaN(e[t])?(this.dataLayer.push({event:`EN_PAGEJSON_${t.toUpperCase()}-${this.transformJSON(e[t])}`}),this.dataLayer.push({[`'EN_PAGEJSON_${t.toUpperCase()}'`]:this.transformJSON(e[t])})):(this.dataLayer.push({event:`EN_PAGEJSON_${t.toUpperCase()}-${e[t]}`}),this.dataLayer.push({[`'EN_PAGEJSON_${t.toUpperCase()}'`]:e[t]})),this.dataLayer.push({event:"EN_PAGEJSON_"+t.toUpperCase(),eventValue:e[t]});p.getPageCount()===p.getPageNumber()&&(this.dataLayer.push({event:"EN_SUBMISSION_SUCCESS_"+e.pageType.toUpperCase()}),this.dataLayer.push({[`'EN_SUBMISSION_SUCCESS_${e.pageType.toUpperCase()}'`]:"TRUE"}))}if(new URLSearchParams(window.location.search).forEach(((e,t)=>{this.dataLayer.push({event:`EN_URLPARAM_${t.toUpperCase()}-${this.transformJSON(e)}`}),this.dataLayer.push({[`'EN_URLPARAM_${t.toUpperCase()}'`]:this.transformJSON(e)})})),"DONATION"===p.getPageType()){const e=[...document.querySelectorAll('[name="transaction.recurrfreq"]')].map((e=>e.value));this.dataLayer.push({event:"EN_RECURRING_FREQUENCIES","'EN_RECURRING_FREQEUENCIES'":e})}let e=!1;const t=document.querySelector(".en__component--formblock.fast-personal-details");if(t){const n=Je.allMandatoryInputsAreFilled(t),i=Je.someMandatoryInputsAreFilled(t);n?(this.dataLayer.push({event:"EN_FASTFORMFILL_PERSONALINFO_SUCCESS"}),e=!0):i?this.dataLayer.push({event:"EN_FASTFORMFILL_PERSONALINFO_PARTIALSUCCESS"}):this.dataLayer.push({event:"EN_FASTFORMFILL_PERSONALINFO_FAILURE"})}const n=document.querySelector(".en__component--formblock.fast-address-details");if(n){const t=Je.allMandatoryInputsAreFilled(n),i=Je.someMandatoryInputsAreFilled(n);t?(this.dataLayer.push({event:"EN_FASTFORMFILL_ADDRESS_SUCCESS"}),e=!!e):i?this.dataLayer.push({event:"EN_FASTFORMFILL_ADDRESS_PARTIALSUCCESS"}):this.dataLayer.push({event:"EN_FASTFORMFILL_ADDRESS_FAILURE"})}e?this.dataLayer.push({event:"EN_FASTFORMFILL_ALL_SUCCESS"}):this.dataLayer.push({event:"EN_FASTFORMFILL_ALL_FAILURE"}),this.attachEventListeners()}onSubmit(){document.querySelector(".en__field__item:not(.en__field--question) input[name^='supporter.questions'][type='checkbox']:checked")?(this.logger.log("EN_SUBMISSION_WITH_EMAIL_OPTIN"),this.dataLayer.push({event:"EN_SUBMISSION_WITH_EMAIL_OPTIN"})):(this.logger.log("EN_SUBMISSION_WITHOUT_EMAIL_OPTIN"),this.dataLayer.push({event:"EN_SUBMISSION_WITHOUT_EMAIL_OPTIN"}))}attachEventListeners(){document.querySelectorAll(".en__component--advrow input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=hidden]):not([unhidden]), .en__component--advrow textarea").forEach((e=>{e.addEventListener("blur",(e=>{this.handleFieldValueChange(e.target)}))}));document.querySelectorAll(".en__component--advrow input[type=checkbox], .en__component--advrow input[type=radio]").forEach((e=>{e.addEventListener("change",(e=>{this.handleFieldValueChange(e.target)}))}));document.querySelectorAll(".en__component--advrow select").forEach((e=>{e.addEventListener("change",(e=>{this.handleFieldValueChange(e.target)}))}))}handleFieldValueChange(e){var t,n,i;if(""===e.value||this.excludedFields.includes(e.name))return;const s=this.hashedFields.includes(e.name)?this.hash(e.value):e.value;["checkbox","radio"].includes(e.type)?e.checked&&("en__pg"===e.name?this.dataLayer.push({event:"EN_FORM_VALUE_UPDATED",enFieldName:e.name,enFieldLabel:"Premium Gift",enFieldValue:null===(n=null===(t=e.closest(".en__pg__body"))||void 0===t?void 0:t.querySelector(".en__pg__name"))||void 0===n?void 0:n.textContent,enProductId:null===(i=document.querySelector('[name="transaction.selprodvariantid"]'))||void 0===i?void 0:i.value}):this.dataLayer.push({event:"EN_FORM_VALUE_UPDATED",enFieldName:e.name,enFieldLabel:this.getFieldLabel(e),enFieldValue:s})):this.dataLayer.push({event:"EN_FORM_VALUE_UPDATED",enFieldName:e.name,enFieldLabel:this.getFieldLabel(e),enFieldValue:s})}hash(e){return btoa(e)}getFieldLabel(e){var t,n;return(null===(n=null===(t=e.closest(".en__field"))||void 0===t?void 0:t.querySelector("label"))||void 0===n?void 0:n.textContent)||""}addEndOfGiftProcessEvent(e,t={}){this.storeEndOfGiftProcessData(Object.assign({event:e},t))}addEndOfGiftProcessVariable(e,t=""){this.storeEndOfGiftProcessData({[`'${e.toUpperCase()}'`]:t})}storeEndOfGiftProcessData(e){const t=this.getEndOfGiftProcessData();t.push(e),window.sessionStorage.setItem(this.endOfGiftProcessStorageKey,JSON.stringify(t))}addEndOfGiftProcessEventsToDataLayer(){this.getEndOfGiftProcessData().forEach((e=>{this.dataLayer.push(e)})),window.sessionStorage.removeItem(this.endOfGiftProcessStorageKey)}getEndOfGiftProcessData(){let e=window.sessionStorage.getItem(this.endOfGiftProcessStorageKey);return e?JSON.parse(e):[]}}class _e{constructor(){this.logger=new fe("DataReplace","#333333","#00f3ff","⤵️"),this.enElements=new Array,this.searchElements(),this.shouldRun()&&(this.logger.log("Elements Found:",this.enElements),this.replaceAll())}searchElements(){const e=document.querySelectorAll("\n .en__component--copyblock,\n .en__component--codeblock,\n .en__field\n ");e.length>0&&e.forEach((e=>{e instanceof HTMLElement&&e.innerHTML.includes("{engrid_data~")&&this.enElements.push(e)}))}shouldRun(){return this.enElements.length>0}replaceAll(){const e=/{engrid_data~\[([\w-]+)\]~?\[?(.+?)?\]?}/g;this.enElements.forEach((t=>{const n=t.innerHTML.matchAll(e);for(const e of n)this.replaceItem(t,e)})),p.setBodyData("merge-tags-processed","")}replaceItem(e,[t,n,i]){var s;let o=null!==(s=p.getUrlParameter(`engrid_data[${n}]`))&&void 0!==s?s:i;o="string"==typeof o?o.replace(/\r?\\n|\n|\r/g,"<br>"):"",this.logger.log("Replacing",n,o),e.innerHTML=e.innerHTML.replace(t,o)}}class Se{constructor(){this.logger=new fe("DataHide","#333333","#f0f0f0","🙈"),this.enElements=new Array,this.logger.log("Constructor"),this.enElements=p.getUrlParameter("engrid_hide[]"),this.enElements&&0!==this.enElements.length?(this.logger.log("Elements Found:",this.enElements),this.hideAll()):this.logger.log("No Elements Found")}hideAll(){this.enElements.forEach((e=>{const t=Object.keys(e)[0],n=Object.values(e)[0];this.hideItem(t,n)}))}hideItem(e,t){const n=[...e.matchAll(/engrid_hide\[([\w-]+)\]/g)].map((e=>e[1]))[0];if("id"===t){const e=document.getElementById(n);e?(this.logger.log("Hiding By ID",n,e),e.setAttribute("hidden-via-url-argument","")):this.logger.error("Element Not Found By ID",n)}else{const e=document.getElementsByClassName(n);if(e.length>0)for(let t=0;t<e.length;t++)this.logger.log("Hiding By Class",n,e[t]),e[t].setAttribute("hidden-via-url-argument","");else this.logger.log("No Elements Found By Class",n)}}}class we{constructor(){this.shouldRun()&&this.replaceNameShortcode("#en__field_supporter_firstName","#en__field_supporter_lastName")}shouldRun(){return"EMAILTOTARGET"===p.getPageType()}replaceNameShortcode(e,t){const n=document.querySelector(e),i=document.querySelector(t);let s=document.querySelector('[name="contact.message"]'),o=!1,r=!1;if(s){if(s.value.includes("{user_data~First Name")||s.value.includes("{user_data~Last Name"))return;!s.value.includes("{user_data~First Name")&&n&&n.addEventListener("blur",(e=>{const t=e.target;s&&!o&&(o=!0,s.value=s.value.concat("\n"+t.value))})),!s.value.includes("{user_data~Last Name")&&i&&i.addEventListener("blur",(e=>{const t=e.target;s&&!r&&(r=!0,s.value=s.value.concat(" "+t.value))}))}}}class Ee{constructor(){if(this._form=u.getInstance(),this.logger=new fe("ExpandRegionName","#333333","#00eb65","🌍"),this.shouldRun()){const e=p.getOption("RegionLongFormat");console.log("expandedRegionField",e);document.querySelector(`[name="${e}"]`)||(this.logger.log(`CREATED field ${e}`),p.createHiddenInput(e)),this._form.onValidate.subscribe((()=>this.expandRegion()))}}shouldRun(){return!!p.getOption("RegionLongFormat")}expandRegion(){if(!this._form.validate)return;const e=document.querySelector('[name="supporter.region"]'),t=p.getOption("RegionLongFormat"),n=document.querySelector(`[name="${t}"]`);if(e){if("SELECT"===e.tagName&&"options"in e){const t=e.options[e.selectedIndex].innerText;n.value=t,this.logger.log("Populated field",n.value)}else if("INPUT"===e.tagName){const t=e.value;n.value=t,this.logger.log("Populated field",n.value)}return!0}this.logger.log("No region field to populate the hidden region field with")}}class Ae{constructor(){this.logger=new fe("UrlToForm","white","magenta","🔗"),this.urlParams=new URLSearchParams(document.location.search),this.shouldRun()&&this.urlParams.forEach(((e,t)=>{const n=document.getElementsByName(t)[0];n&&(["text","textarea","email"].includes(n.type)&&n.value||(p.setFieldValue(t,e),this.logger.log(`Set: ${t} to ${e}`)))}))}shouldRun(){return!!document.location.search&&this.hasFields()}hasFields(){return[...this.urlParams.keys()].map((e=>document.getElementsByName(e).length>0)).includes(!0)}}class Le{constructor(){this.logger=new fe("RequiredIfVisible","#FFFFFF","#811212","🚥"),this._form=u.getInstance(),this.requiredIfVisibleElements=document.querySelectorAll("\n .i-required .en__field,\n .i1-required .en__field:nth-of-type(1),\n .i2-required .en__field:nth-of-type(2),\n .i3-required .en__field:nth-of-type(3),\n .i4-required .en__field:nth-of-type(4),\n .i5-required .en__field:nth-of-type(5),\n .i6-required .en__field:nth-of-type(6),\n .i7-required .en__field:nth-of-type(7),\n .i8-required .en__field:nth-of-type(8),\n .i9-required .en__field:nth-of-type(9),\n .i10-required .en__field:nth-of-type(10),\n .i11-required .en__field:nth-of-type(11)\n "),this.shouldRun()&&this._form.onValidate.subscribe(this.validate.bind(this))}shouldRun(){return this.requiredIfVisibleElements.length>0}validate(){Array.from(this.requiredIfVisibleElements).reverse().forEach((e=>{if(p.removeError(e),p.isVisible(e)){this.logger.log(`${e.getAttribute("class")} is visible`);const t=e.querySelector("input:not([type=hidden]) , select, textarea");if(t&&null===t.closest("[data-unhidden]")&&!p.getFieldValue(t.getAttribute("name"))){const n=e.querySelector(".en__field__label");n?(this.logger.log(`${n.innerText} is required`),window.setTimeout((()=>{p.setError(e,`${n.innerText} is required`)}),100)):(this.logger.log(`${t.getAttribute("name")} is required`),window.setTimeout((()=>{p.setError(e,"This field is required")}),100)),t.focus(),this._form.validate=!1}}}))}}var Ce=function(e,t,n,i){return new(n||(n=Promise))((function(s,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))};class ke{constructor(){var e,t,n,i,s;if(this.logger=new fe("TidyContact","#FFFFFF","#4d9068","📧"),this.endpoint="https://api.tidycontact.io",this.wasCalled=!1,this.httpStatus=0,this.timeout=5,this.isDirty=!1,this._form=u.getInstance(),this.countries_list=[["Afghanistan","af","93","070 123 4567"],["Albania","al","355","067 212 3456"],["Algeria","dz","213","0551 23 45 67"],["American Samoa","as","1","(684) 733-1234"],["Andorra","ad","376","312 345"],["Angola","ao","244","923 123 456"],["Anguilla","ai","1","(264) 235-1234"],["Antigua and Barbuda","ag","1","(268) 464-1234"],["Argentina","ar","54","011 15-2345-6789"],["Armenia","am","374","077 123456"],["Aruba","aw","297","560 1234"],["Australia","au","61","0412 345 678"],["Austria","at","43","0664 123456"],["Azerbaijan","az","994","040 123 45 67"],["Bahamas","bs","1","(242) 359-1234"],["Bahrain","bh","973","3600 1234"],["Bangladesh","bd","880","01812-345678"],["Barbados","bb","1","(246) 250-1234"],["Belarus","by","375","8 029 491-19-11"],["Belgium","be","32","0470 12 34 56"],["Belize","bz","501","622-1234"],["Benin","bj","229","90 01 12 34"],["Bermuda","bm","1","(441) 370-1234"],["Bhutan","bt","975","17 12 34 56"],["Bolivia","bo","591","71234567"],["Bosnia and Herzegovina","ba","387","061 123 456"],["Botswana","bw","267","71 123 456"],["Brazil","br","55","(11) 96123-4567"],["British Indian Ocean Territory","io","246","380 1234"],["British Virgin Islands","vg","1","(284) 300-1234"],["Brunei","bn","673","712 3456"],["Bulgaria","bg","359","048 123 456"],["Burkina Faso","bf","226","70 12 34 56"],["Burundi","bi","257","79 56 12 34"],["Cambodia","kh","855","091 234 567"],["Cameroon","cm","237","6 71 23 45 67"],["Canada","ca","1","(506) 234-5678"],["Cape Verde","cv","238","991 12 34"],["Caribbean Netherlands","bq","599","318 1234"],["Cayman Islands","ky","1","(345) 323-1234"],["Central African Republic","cf","236","70 01 23 45"],["Chad","td","235","63 01 23 45"],["Chile","cl","56","(2) 2123 4567"],["China","cn","86","131 2345 6789"],["Christmas Island","cx","61","0412 345 678"],["Cocos Islands","cc","61","0412 345 678"],["Colombia","co","57","321 1234567"],["Comoros","km","269","321 23 45"],["Congo","cd","243","0991 234 567"],["Congo","cg","242","06 123 4567"],["Cook Islands","ck","682","71 234"],["Costa Rica","cr","506","8312 3456"],["Côte d’Ivoire","ci","225","01 23 45 6789"],["Croatia","hr","385","092 123 4567"],["Cuba","cu","53","05 1234567"],["Curaçao","cw","599","9 518 1234"],["Cyprus","cy","357","96 123456"],["Czech Republic","cz","420","601 123 456"],["Denmark","dk","45","32 12 34 56"],["Djibouti","dj","253","77 83 10 01"],["Dominica","dm","1","(767) 225-1234"],["Dominican Republic","do","1","(809) 234-5678"],["Ecuador","ec","593","099 123 4567"],["Egypt","eg","20","0100 123 4567"],["El Salvador","sv","503","7012 3456"],["Equatorial Guinea","gq","240","222 123 456"],["Eritrea","er","291","07 123 456"],["Estonia","ee","372","5123 4567"],["Eswatini","sz","268","7612 3456"],["Ethiopia","et","251","091 123 4567"],["Falkland Islands","fk","500","51234"],["Faroe Islands","fo","298","211234"],["Fiji","fj","679","701 2345"],["Finland","fi","358","041 2345678"],["France","fr","33","06 12 34 56 78"],["French Guiana","gf","594","0694 20 12 34"],["French Polynesia","pf","689","87 12 34 56"],["Gabon","ga","241","06 03 12 34"],["Gambia","gm","220","301 2345"],["Georgia","ge","995","555 12 34 56"],["Germany","de","49","01512 3456789"],["Ghana","gh","233","023 123 4567"],["Gibraltar","gi","350","57123456"],["Greece","gr","30","691 234 5678"],["Greenland","gl","299","22 12 34"],["Grenada","gd","1","(473) 403-1234"],["Guadeloupe","gp","590","0690 00 12 34"],["Guam","gu","1","(671) 300-1234"],["Guatemala","gt","502","5123 4567"],["Guernsey","gg","44","07781 123456"],["Guinea","gn","224","601 12 34 56"],["Guinea-Bissau","gw","245","955 012 345"],["Guyana","gy","592","609 1234"],["Haiti","ht","509","34 10 1234"],["Honduras","hn","504","9123-4567"],["Hong Kong","hk","852","5123 4567"],["Hungary","hu","36","06 20 123 4567"],["Iceland","is","354","611 1234"],["India","in","91","081234 56789"],["Indonesia","id","62","0812-345-678"],["Iran","ir","98","0912 345 6789"],["Iraq","iq","964","0791 234 5678"],["Ireland","ie","353","085 012 3456"],["Isle of Man","im","44","07924 123456"],["Israel","il","972","050-234-5678"],["Italy","it","39","312 345 6789"],["Jamaica","jm","1","(876) 210-1234"],["Japan","jp","81","090-1234-5678"],["Jersey","je","44","07797 712345"],["Jordan","jo","962","07 9012 3456"],["Kazakhstan","kz","7","8 (771) 000 9998"],["Kenya","ke","254","0712 123456"],["Kiribati","ki","686","72001234"],["Kosovo","xk","383","043 201 234"],["Kuwait","kw","965","500 12345"],["Kyrgyzstan","kg","996","0700 123 456"],["Laos","la","856","020 23 123 456"],["Latvia","lv","371","21 234 567"],["Lebanon","lb","961","71 123 456"],["Lesotho","ls","266","5012 3456"],["Liberia","lr","231","077 012 3456"],["Libya","ly","218","091-2345678"],["Liechtenstein","li","423","660 234 567"],["Lithuania","lt","370","(8-612) 34567"],["Luxembourg","lu","352","628 123 456"],["Macau","mo","853","6612 3456"],["North Macedonia","mk","389","072 345 678"],["Madagascar","mg","261","032 12 345 67"],["Malawi","mw","265","0991 23 45 67"],["Malaysia","my","60","012-345 6789"],["Maldives","mv","960","771-2345"],["Mali","ml","223","65 01 23 45"],["Malta","mt","356","9696 1234"],["Marshall Islands","mh","692","235-1234"],["Martinique","mq","596","0696 20 12 34"],["Mauritania","mr","222","22 12 34 56"],["Mauritius","mu","230","5251 2345"],["Mayotte","yt","262","0639 01 23 45"],["Mexico","mx","52","222 123 4567"],["Micronesia","fm","691","350 1234"],["Moldova","md","373","0621 12 345"],["Monaco","mc","377","06 12 34 56 78"],["Mongolia","mn","976","8812 3456"],["Montenegro","me","382","067 622 901"],["Montserrat","ms","1","(664) 492-3456"],["Morocco","ma","212","0650-123456"],["Mozambique","mz","258","82 123 4567"],["Myanmar","mm","95","09 212 3456"],["Namibia","na","264","081 123 4567"],["Nauru","nr","674","555 1234"],["Nepal","np","977","984-1234567"],["Netherlands","nl","31","06 12345678"],["New Caledonia","nc","687","75.12.34"],["New Zealand","nz","64","021 123 4567"],["Nicaragua","ni","505","8123 4567"],["Niger","ne","227","93 12 34 56"],["Nigeria","ng","234","0802 123 4567"],["Niue","nu","683","888 4012"],["Norfolk Island","nf","672","3 81234"],["North Korea","kp","850","0192 123 4567"],["Northern Mariana Islands","mp","1","(670) 234-5678"],["Norway","no","47","406 12 345"],["Oman","om","968","9212 3456"],["Pakistan","pk","92","0301 2345678"],["Palau","pw","680","620 1234"],["Palestine","ps","970","0599 123 456"],["Panama","pa","507","6123-4567"],["Papua New Guinea","pg","675","7012 3456"],["Paraguay","py","595","0961 456789"],["Peru","pe","51","912 345 678"],["Philippines","ph","63","0905 123 4567"],["Poland","pl","48","512 345 678"],["Portugal","pt","351","912 345 678"],["Puerto Rico","pr","1","(787) 234-5678"],["Qatar","qa","974","3312 3456"],["Réunion","re","262","0692 12 34 56"],["Romania","ro","40","0712 034 567"],["Russia","ru","7","8 (912) 345-67-89"],["Rwanda","rw","250","0720 123 456"],["Saint Barthélemy","bl","590","0690 00 12 34"],["Saint Helena","sh","290","51234"],["Saint Kitts and Nevis","kn","1","(869) 765-2917"],["Saint Lucia","lc","1","(758) 284-5678"],["Saint Martin","mf","590","0690 00 12 34"],["Saint Pierre and Miquelon","pm","508","055 12 34"],["Saint Vincent and the Grenadines","vc","1","(784) 430-1234"],["Samoa","ws","685","72 12345"],["San Marino","sm","378","66 66 12 12"],["São Tomé and Príncipe","st","239","981 2345"],["Saudi Arabia","sa","966","051 234 5678"],["Senegal","sn","221","70 123 45 67"],["Serbia","rs","381","060 1234567"],["Seychelles","sc","248","2 510 123"],["Sierra Leone","sl","232","(025) 123456"],["Singapore","sg","65","8123 4567"],["Sint Maarten","sx","1","(721) 520-5678"],["Slovakia","sk","421","0912 123 456"],["Slovenia","si","386","031 234 567"],["Solomon Islands","sb","677","74 21234"],["Somalia","so","252","7 1123456"],["South Africa","za","27","071 123 4567"],["South Korea","kr","82","010-2000-0000"],["South Sudan","ss","211","0977 123 456"],["Spain","es","34","612 34 56 78"],["Sri Lanka","lk","94","071 234 5678"],["Sudan","sd","249","091 123 1234"],["Suriname","sr","597","741-2345"],["Svalbard and Jan Mayen","sj","47","412 34 567"],["Sweden","se","46","070-123 45 67"],["Switzerland","ch","41","078 123 45 67"],["Syria","sy","963","0944 567 890"],["Taiwan","tw","886","0912 345 678"],["Tajikistan","tj","992","917 12 3456"],["Tanzania","tz","255","0621 234 567"],["Thailand","th","66","081 234 5678"],["Timor-Leste","tl","670","7721 2345"],["Togo","tg","228","90 11 23 45"],["Tokelau","tk","690","7290"],["Tonga","to","676","771 5123"],["Trinidad and Tobago","tt","1","(868) 291-1234"],["Tunisia","tn","216","20 123 456"],["Turkey","tr","90","0501 234 56 78"],["Turkmenistan","tm","993","8 66 123456"],["Turks and Caicos Islands","tc","1","(649) 231-1234"],["Tuvalu","tv","688","90 1234"],["U.S. Virgin Islands","vi","1","(340) 642-1234"],["Uganda","ug","256","0712 345678"],["Ukraine","ua","380","050 123 4567"],["United Arab Emirates","ae","971","050 123 4567"],["United Kingdom","gb","44","07400 123456"],["United States","us","1","(201) 555-0123"],["Uruguay","uy","598","094 231 234"],["Uzbekistan","uz","998","8 91 234 56 78"],["Vanuatu","vu","678","591 2345"],["Vatican City","va","39","312 345 6789"],["Venezuela","ve","58","0412-1234567"],["Vietnam","vn","84","091 234 56 78"],["Wallis and Futuna","wf","681","82 12 34"],["Western Sahara","eh","212","0650-123456"],["Yemen","ye","967","0712 345 678"],["Zambia","zm","260","095 5123456"],["Zimbabwe","zw","263","071 234 5678"],["Åland Islands","ax","358","041 2345678"]],this.countries_dropdown=null,this.country_ip=null,this.options=p.getOption("TidyContact"),!1!==this.options&&(null===(e=this.options)||void 0===e?void 0:e.cid))if(this.loadOptions(),this.hasAddressFields()||this.phoneEnabled()){if(this.createFields(),this.addEventListeners(),p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")&&!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()&&""!=p.getFieldValue(null===(n=null===(t=this.options)||void 0===t?void 0:t.address_fields)||void 0===n?void 0:n.address1)&&(this.logger.log("Address Field is not empty"),this.isDirty=!0),this.phoneEnabled()){this.createPhoneFields(),this.createPhoneMarginVariable(),this.logger.log("Phone Standardization is enabled"),this.countryDropDownEnabled()&&this.renderFlagsDropDown();const e=p.getField(null===(s=null===(i=this.options)||void 0===i?void 0:i.address_fields)||void 0===s?void 0:s.phone);e&&(e.addEventListener("keyup",(e=>{this.handlePhoneInputKeydown(e)})),this.setDefaultPhoneCountry())}}else this.logger.log("No address fields found")}loadOptions(){var e,t,n,i;this.options&&(this.options.address_fields||(this.options.address_fields={address1:"supporter.address1",address2:"supporter.address2",address3:"supporter.address3",city:"supporter.city",region:"supporter.region",postalCode:"supporter.postcode",country:"supporter.country",phone:"supporter.phoneNumber2"}),this.options.address_enable=null===(e=this.options.address_enable)||void 0===e||e,this.options.phone_enable&&(this.options.phone_flags=null===(t=this.options.phone_flags)||void 0===t||t,this.options.phone_country_from_ip=null===(n=this.options.phone_country_from_ip)||void 0===n||n,this.options.phone_preferred_countries=null!==(i=this.options.phone_preferred_countries)&&void 0!==i?i:[]))}createFields(){var e,t,n,i,s,o;if(!this.options||!this.hasAddressFields())return;const r=p.getField("supporter.geo.latitude"),a=p.getField("supporter.geo.longitude");if(r||(p.createHiddenInput("supporter.geo.latitude",""),this.logger.log("Creating Hidden Field: supporter.geo.latitude")),a||(p.createHiddenInput("supporter.geo.longitude",""),this.logger.log("Creating Hidden Field: supporter.geo.longitude")),this.options.record_field){p.getField(this.options.record_field)||(p.createHiddenInput(this.options.record_field,""),this.logger.log("Creating Hidden Field: "+this.options.record_field))}if(this.options.date_field){p.getField(this.options.date_field)||(p.createHiddenInput(this.options.date_field,""),this.logger.log("Creating Hidden Field: "+this.options.date_field))}if(this.options.status_field){p.getField(this.options.status_field)||(p.createHiddenInput(this.options.status_field,""),this.logger.log("Creating Hidden Field: "+this.options.status_field))}p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.address2)||(p.createHiddenInput(null===(t=this.options.address_fields)||void 0===t?void 0:t.address2,""),this.logger.log("Creating Hidden Field: "+(null===(n=this.options.address_fields)||void 0===n?void 0:n.address2))),p.getField(null===(i=this.options.address_fields)||void 0===i?void 0:i.address3)||(p.createHiddenInput(null===(s=this.options.address_fields)||void 0===s?void 0:s.address3,""),this.logger.log("Creating Hidden Field: "+(null===(o=this.options.address_fields)||void 0===o?void 0:o.address3)))}createPhoneFields(){if(this.options){if(p.createHiddenInput("tc.phone.country",""),this.logger.log("Creating hidden field: tc.phone.country"),this.options.phone_record_field){p.getField(this.options.phone_record_field)||(p.createHiddenInput(this.options.phone_record_field,""),this.logger.log("Creating hidden field: "+this.options.phone_record_field))}if(this.options.phone_date_field){p.getField(this.options.phone_date_field)||(p.createHiddenInput(this.options.phone_date_field,""),this.logger.log("Creating hidden field: "+this.options.phone_date_field))}if(this.options.phone_status_field){p.getField(this.options.phone_status_field)||(p.createHiddenInput(this.options.phone_status_field,""),this.logger.log("Creating hidden field: "+this.options.phone_status_field))}}}createPhoneMarginVariable(){var e;if(!this.options)return;const t=p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.phone);if(t){const e=window.getComputedStyle(t),n=e.marginTop,i=e.marginBottom;document.documentElement.style.setProperty("--tc-phone-margin-top",n),document.documentElement.style.setProperty("--tc-phone-margin-bottom",i)}}addEventListeners(){if(!this.options)return;if(this.options.address_fields)for(const[e,t]of Object.entries(this.options.address_fields)){const e=p.getField(t);e&&e.addEventListener("change",(()=>{this.logger.log("Changed "+e.name,!0),this.isDirty=!0}))}this._form.onSubmit.subscribe(this.callAPI.bind(this));const e=document.getElementsByName("transaction.giveBySelect");e&&e.forEach((e=>{e.addEventListener("change",(()=>{["stripedigitalwallet","paypaltouch"].includes(e.value.toLowerCase())&&(this.logger.log("Clicked Digital Wallet Button"),window.setTimeout((()=>{this.callAPI()}),500))}))}))}checkSum(e){return Ce(this,void 0,void 0,(function*(){const t=(new TextEncoder).encode(e),n=yield crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>("00"+e.toString(16)).slice(-2))).join("")}))}todaysDate(){return(new Date).toLocaleString("en-ZA",{year:"numeric",month:"2-digit",day:"2-digit"}).replace(/\/+/g,"")}countryAllowed(e){var t;return!!this.options&&(!this.options.countries||0===this.options.countries.length||!!(null===(t=this.options.countries)||void 0===t?void 0:t.includes(e.toLowerCase())))}fetchTimeOut(e,t){const n=new AbortController,i=n.signal;t=Object.assign(Object.assign({},t),{signal:i});const s=fetch(e,t);i&&i.addEventListener("abort",(()=>n.abort()));const o=setTimeout((()=>n.abort()),1e3*this.timeout);return s.finally((()=>clearTimeout(o)))}writeError(e){if(!this.options)return;const t=p.getField(this.options.record_field),n=p.getField(this.options.date_field),i=p.getField(this.options.status_field);if(t){let n="";switch(this.httpStatus){case 400:n="Bad Request";break;case 401:n="Unauthorized";break;case 403:n="Forbidden";break;case 404:n="Not Found";break;case 408:n="API Request Timeout";break;case 500:n="Internal Server Error";break;case 503:n="Service Unavailable";break;default:n="Unknown Error"}const i={status:this.httpStatus,error:"string"==typeof e?e:n.toUpperCase()};t.value=JSON.stringify(i)}n&&(n.value=this.todaysDate()),i&&(i.value="ERROR-API")}setFields(e){var t,n,i,s,o;if(!this.options||!this.options.address_enable)return{};let r={};const a=this.getCountry(),l=p.getFieldValue(null===(t=this.options.address_fields)||void 0===t?void 0:t.postalCode),c=null!==(n=this.options.us_zip_divider)&&void 0!==n?n:"+",d=p.getField(null===(i=this.options.address_fields)||void 0===i?void 0:i.address2);if("address2"in e&&!d){p.getFieldValue(null===(s=this.options.address_fields)||void 0===s?void 0:s.address1)==e.address1+" "+e.address2?(delete e.address1,delete e.address2):(e.address1=e.address1+" "+e.address2,delete e.address2)}"postalCode"in e&&l.replace("+",c)===e.postalCode.replace("+",c)&&delete e.postalCode;for(const t in e){const n=this.options.address_fields&&Object.keys(this.options.address_fields).includes(t)?this.options.address_fields[t]:t,i=p.getField(n);if(i){let s=e[t];"postalCode"===t&&["US","USA","United States"].includes(a)&&(s=null!==(o=s.replace("+",c))&&void 0!==o?o:""),r[t]={from:i.value,to:s},this.logger.log(`Set ${i.name} to ${s} (${i.value})`),p.setFieldValue(n,s,!1)}else this.logger.log(`Field ${t} not found`)}return r}hasAddressFields(){var e,t,n,i,s,o;if(!this.options||!this.options.address_enable)return!1;const r=p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.address1),a=p.getField(null===(t=this.options.address_fields)||void 0===t?void 0:t.address2),l=p.getField(null===(n=this.options.address_fields)||void 0===n?void 0:n.city),c=p.getField(null===(i=this.options.address_fields)||void 0===i?void 0:i.region),d=p.getField(null===(s=this.options.address_fields)||void 0===s?void 0:s.postalCode),u=p.getField(null===(o=this.options.address_fields)||void 0===o?void 0:o.country);return!!(r||a||l||c||d||u)}canUseAPI(){var e,t,n,i;if(!this.options||!this.hasAddressFields())return!1;const s=!!this.getCountry(),o=!!p.getFieldValue(null===(e=this.options.address_fields)||void 0===e?void 0:e.address1),r=!!p.getFieldValue(null===(t=this.options.address_fields)||void 0===t?void 0:t.city),a=!!p.getFieldValue(null===(n=this.options.address_fields)||void 0===n?void 0:n.region),l=!!p.getFieldValue(null===(i=this.options.address_fields)||void 0===i?void 0:i.postalCode);return s&&o?r&&a||l:(this.logger.log("API cannot be used"),!1)}canUsePhoneAPI(){var e;if(!this.options)return!1;if(this.phoneEnabled()){const t=!!p.getFieldValue(null===(e=this.options.address_fields)||void 0===e?void 0:e.phone),n=!!p.getFieldValue("tc.phone.country");return t&&n}return this.logger.log("Phone API is not enabled"),!1}getCountry(){var e,t;if(!this.options)return"";const n=null!==(e=this.options.country_fallback)&&void 0!==e?e:"";return p.getFieldValue(null===(t=this.options.address_fields)||void 0===t?void 0:t.country)||n.toUpperCase()}getCountryByCode(e){var t;const n=null!==(t=this.countries_list.find((t=>t.includes(e))))&&void 0!==t?t:"";return n?{name:n[0],code:n[1],dialCode:n[2],placeholder:n[3]}:null}phoneEnabled(){return!(!this.options||!this.options.phone_enable)}countryDropDownEnabled(){return!(!this.options||!this.options.phone_flags)}getCountryFromIP(){return Ce(this,void 0,void 0,(function*(){return fetch(`https://${window.location.hostname}/cdn-cgi/trace`).then((e=>e.text())).then((e=>{let t=e.replace(/[\r\n]+/g,'","').replace(/\=+/g,'":"');t='{"'+t.slice(0,t.lastIndexOf('","'))+'"}';const n=JSON.parse(t);return this.country_ip=n.loc,this.country_ip}))}))}renderFlagsDropDown(){var e;if(!this.options)return;const t=p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.phone);if(!t)return;this.countries_dropdown=document.createElement("div"),this.countries_dropdown.classList.add("tc-flags-container");const n=document.createElement("div");n.classList.add("tc-selected-flag"),n.setAttribute("role","combobox"),n.setAttribute("aria-haspopup","listbox"),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-owns","tc-flags-list"),n.setAttribute("aria-label","Select Country"),n.setAttribute("tabindex","0");const i=document.createElement("div");i.classList.add("tc-flag");const s=document.createElement("div");s.classList.add("tc-flag-arrow"),n.appendChild(i),n.appendChild(s),n.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation(),n.classList.contains("tc-open")?this.closeCountryDropDown():this.openCountryDropDown()}));const o=document.createElement("ul");if(o.classList.add("tc-country-list"),o.classList.add("tc-hide"),o.setAttribute("id","tc-country-list"),o.setAttribute("role","listbox"),o.setAttribute("aria-label","List of Countries"),o.setAttribute("aria-hidden","true"),this.options.phone_preferred_countries.length>0){const e=[];this.options.phone_preferred_countries.forEach((t=>{const n=this.getCountryByCode(t);n&&e.push(n)})),this.appendCountryItems(o,e,"tc-country-list-item",!0);const t=document.createElement("li");t.classList.add("tc-divider"),t.setAttribute("role","separator"),t.setAttribute("aria-disabled","true"),o.appendChild(t),this.logger.log("Rendering preferred countries",JSON.stringify(e))}const r=[];this.countries_list.forEach((e=>{r.push({name:e[0],code:e[1],dialCode:e[2],placeholder:e[3]})})),this.appendCountryItems(o,r,"tc-country-list-item"),o.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation();const t=e.target.closest("li");if(t.classList.contains("tc-country-list-item")){const e=this.getCountryByCode(t.getAttribute("data-country-code"));e&&this.setPhoneCountry(e)}})),o.addEventListener("mouseover",(e=>{e.preventDefault(),e.stopPropagation();const t=e.target.closest("li.tc-country-list-item");t&&this.highlightCountry(t.getAttribute("data-country-code"))})),this.countries_dropdown.appendChild(n),this.countries_dropdown.appendChild(o),t.parentNode.insertBefore(this.countries_dropdown,t),t.parentNode.classList.add("tc-has-country-flags"),this.countries_dropdown.addEventListener("keydown",(e=>{var t,n;(null===(n=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-country-list"))||void 0===n?void 0:n.classList.contains("tc-hide"))&&-1!==["ArrowUp","Up","ArrowDown","Down"," ","Enter"].indexOf(e.key)&&(e.preventDefault(),e.stopPropagation(),this.openCountryDropDown()),"Tab"===e.key&&this.closeCountryDropDown()})),document.addEventListener("keydown",(e=>{var t,n;(null===(n=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-country-list"))||void 0===n?void 0:n.classList.contains("tc-hide"))||(e.preventDefault(),"ArrowUp"===e.key||"Up"===e.key||"ArrowDown"===e.key||"Down"===e.key?this.handleUpDownKey(e.key):"Enter"===e.key?this.handleEnterKey():"Escape"===e.key&&this.closeCountryDropDown())})),document.addEventListener("click",(e=>{var t,n;(null===(n=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-country-list"))||void 0===n?void 0:n.classList.contains("tc-hide"))||e.target.closest(".tc-country-list")||this.closeCountryDropDown()}))}handleUpDownKey(e){var t;const n=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-highlight");if(n){let t="ArrowUp"===e||"Up"===e?n.previousElementSibling:n.nextElementSibling;t&&(t.classList.contains("tc-divider")&&(t="ArrowUp"===e||"Up"===e?t.previousElementSibling:t.nextElementSibling),this.highlightCountry(null==t?void 0:t.getAttribute("data-country-code")))}}handleEnterKey(){var e;const t=null===(e=this.countries_dropdown)||void 0===e?void 0:e.querySelector(".tc-highlight");if(t){const e=this.getCountryByCode(null==t?void 0:t.getAttribute("data-country-code"));this.setPhoneCountry(e)}}handlePhoneInputKeydown(e){const t=e.target.value;if("+"===t.charAt(0)&&t.length>2){const e=this.getCountryByCode(t.substring(1,3));e?this.setPhoneCountry(e):this.setDefaultPhoneCountry()}}openCountryDropDown(){if(!this.countries_dropdown)return;const e=this.countries_dropdown.querySelector(".tc-country-list"),t=this.countries_dropdown.querySelector(".tc-selected-flag");e&&t&&(e.classList.remove("tc-hide"),t.setAttribute("aria-expanded","true"),t.classList.add("tc-open"))}closeCountryDropDown(){var e;if(!this.options)return;if(!this.countries_dropdown)return;const t=this.countries_dropdown.querySelector(".tc-country-list"),n=this.countries_dropdown.querySelector(".tc-selected-flag");t&&n&&(t.classList.add("tc-hide"),n.setAttribute("aria-expanded","false"),n.classList.remove("tc-open"));p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.phone).focus()}getFlagImage(e,t){return`<picture>\n <source\n loading="lazy"\n type="image/webp"\n srcset="https://flagcdn.com/h20/${e}.webp,\n https://flagcdn.com/h40/${e}.webp 2x,\n https://flagcdn.com/h60/${e}.webp 3x">\n <source\n loading="lazy"\n type="image/png"\n srcset="https://flagcdn.com/h20/${e}.png,\n https://flagcdn.com/h40/${e}.png 2x,\n https://flagcdn.com/h60/${e}.png 3x">\n <img\n loading="lazy"\n src="https://flagcdn.com/h20/${e}.png"\n height="20"\n alt="${t}">\n </picture>`}appendCountryItems(e,t,n,i=!1){let s="";for(let e=0;e<t.length;e++){const o=t[e],r=i?"-preferred":"";s+=`<li class='tc-country ${n}' tabIndex='-1' id='tc-item-${o.code}${r}' role='option' data-dial-code='${o.dialCode}' data-country-code='${o.code}' aria-selected='false'>`,s+=`<div class='tc-flag-box'><div class='tc-flag tc-${o.code}'>${this.getFlagImage(o.code,o.name)}</div></div>`,s+=`<span class='tc-country-name'>${o.name}</span>`,s+=`<span class='tc-dial-code'>+${o.dialCode}</span>`,s+="</li>"}e.insertAdjacentHTML("beforeend",s)}setDefaultPhoneCountry(){var e;if(!this.options)return;if(this.options.phone_country_from_ip)return void this.getCountryFromIP().then((e=>{this.logger.log("Country from IP:",e),this.setPhoneCountry(this.getCountryByCode((null!=e?e:"us").toLowerCase()))})).catch((e=>{this.setPhoneCountry(this.getCountryByCode("us"))}));const t=p.getField(null===(e=this.options.address_fields)||void 0===e?void 0:e.country);if(t){const e=t.options[t.selectedIndex].text,n=this.getCountryByCode(e);if(n)return void this.setPhoneCountry(n);if(this.options.phone_preferred_countries.length>0)return void this.setPhoneCountry(this.getCountryByCode(this.options.phone_preferred_countries[0]))}this.setPhoneCountry(this.getCountryByCode("us"))}setPhoneCountry(e){var t,n,i,s,o,r;if(!this.options||!e)return;const a=p.getField("tc.phone.country");if(a.value===e.code)return;const l=p.getField(null===(t=this.options.address_fields)||void 0===t?void 0:t.phone);if(this.countryDropDownEnabled()){const t=null===(n=this.countries_dropdown)||void 0===n?void 0:n.querySelector(".tc-selected-flag"),a=null===(i=this.countries_dropdown)||void 0===i?void 0:i.querySelector(".tc-flag");t&&a&&(a.innerHTML=this.getFlagImage(e.code,e.name),t.setAttribute("data-country",e.code));const l=null===(s=this.countries_dropdown)||void 0===s?void 0:s.querySelector(".tc-country-list-item[aria-selected='true']");l&&(l.classList.remove("tc-selected"),l.setAttribute("aria-selected","false"));const c=null===(o=this.countries_dropdown)||void 0===o?void 0:o.querySelector(".tc-highlight");c&&c.classList.remove("tc-highlight");const d=null===(r=this.countries_dropdown)||void 0===r?void 0:r.querySelector(`.tc-country-list-item[data-country-code='${e.code}']`);d&&(d.classList.add("tc-selected"),d.setAttribute("aria-selected","true"),d.classList.add("tc-highlight")),(null==t?void 0:t.classList.contains("tc-open"))&&this.closeCountryDropDown()}l.setAttribute("placeholder",e.placeholder),a.value=e.code,this.logger.log(`Setting phone country to ${e.code} - ${e.name}`)}highlightCountry(e){var t,n;if(!e)return;const i=null===(t=this.countries_dropdown)||void 0===t?void 0:t.querySelector(".tc-highlight");i&&i.classList.remove("tc-highlight");const s=null===(n=this.countries_dropdown)||void 0===n?void 0:n.querySelector(".tc-country-list");if(s){const t=s.querySelector(`.tc-country[data-country-code='${e}']`);t&&(t.classList.add("tc-highlight"),t.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"}))}}setPhoneDataFromAPI(e,t){var n;return Ce(this,void 0,void 0,(function*(){if(!this.options)return;const i=p.getField(null===(n=this.options.address_fields)||void 0===n?void 0:n.phone),s=p.getField(this.options.phone_record_field),o=p.getField(this.options.phone_date_field),r=p.getField(this.options.phone_status_field);let a={};a.formData={[i.name]:i.value},a.formatted=e.formatted,a.number_type=e.number_type,!0===e.valid?(i.value!==e.formatted.e164&&(a.phone={from:i.value,to:e.formatted.e164},i.value=e.formatted.e164),yield this.checkSum(JSON.stringify(a)).then((e=>{this.logger.log("Phone Checksum",e),a.requestId=t,a.checksum=e})),s&&(a=Object.assign({date:this.todaysDate(),status:"SUCCESS"},a),s.value=JSON.stringify(a)),o&&(o.value=this.todaysDate()),r&&(r.value="SUCCESS")):(yield this.checkSum(JSON.stringify(a)).then((e=>{this.logger.log("Phone Checksum",e),a.requestId=t,a.checksum=e})),s&&(a=Object.assign({date:this.todaysDate(),status:"ERROR"},a),s.value=JSON.stringify(a)),o&&(o.value=this.todaysDate()),r&&(r.value="error"in e?"ERROR: "+e.error:"INVALIDPHONE"))}))}callAPI(){var e,t,n,i,s,o;if(!this.options)return;if(!this.isDirty||this.wasCalled)return;if(!this._form.submit)return void this.logger.log("Form Submission Interrupted by Other Component");const r=p.getField(this.options.record_field),a=p.getField(this.options.date_field),l=p.getField(this.options.status_field),c=p.getField("supporter.geo.latitude"),d=p.getField("supporter.geo.longitude");if(!this.canUseAPI()&&!this.canUsePhoneAPI())return this.logger.log("Not Enough Data to Call API"),a&&(a.value=this.todaysDate()),l&&(l.value="PARTIALADDRESS"),!0;const u=p.getFieldValue(null===(e=this.options.address_fields)||void 0===e?void 0:e.address1),h=p.getFieldValue(null===(t=this.options.address_fields)||void 0===t?void 0:t.address2),g=p.getFieldValue(null===(n=this.options.address_fields)||void 0===n?void 0:n.city),m=p.getFieldValue(null===(i=this.options.address_fields)||void 0===i?void 0:i.region),f=p.getFieldValue(null===(s=this.options.address_fields)||void 0===s?void 0:s.postalCode),b=this.getCountry();if(!this.countryAllowed(b)){if(this.logger.log("Country not allowed: "+b),r){let e={};e=Object.assign({date:this.todaysDate(),status:"DISALLOWED"},e),r.value=JSON.stringify(e)}return a&&(a.value=this.todaysDate()),l&&(l.value="DISALLOWED"),!0}let v={url:window.location.href,cid:this.options.cid};this.canUseAPI()&&(v=Object.assign(v,{address1:u,address2:h,city:g,region:m,postalCode:f,country:b})),this.canUsePhoneAPI()&&(v.phone=p.getFieldValue(null===(o=this.options.address_fields)||void 0===o?void 0:o.phone),v.phoneCountry=p.getFieldValue("tc.phone.country")),this.wasCalled=!0,this.logger.log("FormData",JSON.parse(JSON.stringify(v)));const y=this.fetchTimeOut(this.endpoint,{headers:{"Content-Type":"application/json; charset=utf-8"},method:"POST",body:JSON.stringify(v)}).then((e=>(this.httpStatus=e.status,e.json()))).then((e=>Ce(this,void 0,void 0,(function*(){if(this.logger.log("callAPI response",JSON.parse(JSON.stringify(e))),!0===e.valid){let t={};"changed"in e&&(t=this.setFields(e.changed)),t.formData=v,yield this.checkSum(JSON.stringify(t)).then((n=>{this.logger.log("Checksum",n),t.requestId=e.requestId,t.checksum=n})),"latitude"in e&&(c.value=e.latitude,t.latitude=e.latitude),"longitude"in e&&(d.value=e.longitude,t.longitude=e.longitude),r&&(t=Object.assign({date:this.todaysDate(),status:"SUCCESS"},t),r.value=JSON.stringify(t)),a&&(a.value=this.todaysDate()),l&&(l.value="SUCCESS")}else{let t={};t.formData=v,yield this.checkSum(JSON.stringify(t)).then((n=>{this.logger.log("Checksum",n),t.requestId=e.requestId,t.checksum=n})),r&&(t=Object.assign({date:this.todaysDate(),status:"ERROR"},t),r.value=JSON.stringify(t)),a&&(a.value=this.todaysDate()),l&&(l.value="error"in e?"ERROR: "+e.error:"INVALIDADDRESS")}this.phoneEnabled()&&"phone"in e&&(yield this.setPhoneDataFromAPI(e.phone,e.requestId))})))).catch((e=>{e.toString().includes("AbortError")&&(this.logger.log("Fetch aborted"),this.httpStatus=408),this.writeError(e)}));return this._form.submitPromise=y,y}}class xe{constructor(){this.logger=new fe("LiveCurrency","#1901b1","#feb47a","💲"),this.elementsFound=!1,this.isUpdating=!1,this._amount=h.getInstance(),this._frequency=g.getInstance(),this._fees=m.getInstance(),this.searchElements(),this.shouldRun()&&(p.setBodyData("live-currency","active"),this.updateCurrency(),this.addEventListeners(),document.querySelectorAll(".en__field--donationAmt .en__field__element--radio .en__field__item").forEach((e=>{e.setAttribute("data-engrid-currency-symbol-updated","true")})))}searchElements(){const e=document.querySelectorAll("\n .en__component--copyblock,\n .en__component--codeblock,\n .en__field label,\n .en__submit\n ");if(e.length>0){this.elementsFound=!0;const t=p.getCurrencySymbol(),n=p.getCurrencyCode(),i=`<span class="engrid-currency-symbol">${t}</span>`,s=`<span class="engrid-currency-code">${n}</span>`;e.forEach((e=>{if(!(e instanceof HTMLElement&&e.innerHTML.startsWith("<script"))&&e instanceof HTMLElement&&(e.innerHTML.includes("[$]")||e.innerHTML.includes("[$$$]"))){this.logger.log("Old Value:",e.innerHTML);const t=/\[\$\]/g,n=/\[\$\$\$\]/g;e.innerHTML=e.innerHTML.replace(n,s),e.innerHTML=e.innerHTML.replace(t,i),this.logger.log("New Value:",e.innerHTML)}}))}}shouldRun(){return this.elementsFound}addMutationObserver(){const e=document.querySelector(".en__field--donationAmt .en__field__element--radio");if(!e)return;new MutationObserver((t=>{t.forEach((t=>{if("childList"===t.type){if(this.isUpdating)return;this.isUpdating=!0,setTimeout((()=>{this.searchElements(),this.updateCurrency(),e.querySelectorAll(".en__field__item").forEach((e=>{e.setAttribute("data-engrid-currency-symbol-updated","true")})),this.isUpdating=!1}),20)}}))})).observe(e,{childList:!0})}addEventListeners(){this._fees.onFeeChange.subscribe((()=>{setTimeout((()=>{this.updateCurrency()}),10)})),this._amount.onAmountChange.subscribe((()=>{setTimeout((()=>{this.updateCurrency()}),10)})),this._frequency.onFrequencyChange.subscribe((()=>{this.isUpdating||(this.isUpdating=!0,setTimeout((()=>{this.searchElements(),this.updateCurrency(),document.querySelectorAll(".en__field--donationAmt .en__field__element--radio .en__field__item").forEach((e=>{e.setAttribute("data-engrid-currency-symbol-updated","true")})),this.isUpdating=!1}),10))}));const e=p.getField("transaction.paycurrency");e&&e.addEventListener("change",(()=>{setTimeout((()=>{this.updateCurrency(),this._amount.load();const e=document.querySelector(".en__field--donationAmt .en__field__item--other");e&&e.setAttribute("data-currency-symbol",p.getCurrencySymbol()),p.setBodyData("currency-code",p.getCurrencyCode())}),10)})),this.addMutationObserver()}updateCurrency(){const e=document.querySelectorAll(".engrid-currency-symbol"),t=document.querySelectorAll(".engrid-currency-code");e.length>0&&e.forEach((e=>{e.innerHTML=p.getCurrencySymbol()})),t.length>0&&t.forEach((e=>{e.innerHTML=p.getCurrencyCode()})),this.logger.log(`Currency updated for ${e.length+t.length} elements`)}}class De{constructor(){this.logger=new fe("CustomCurrency","#1901b1","#00cc95","🤑"),this.currencyElement=document.querySelector("[name='transaction.paycurrency']"),this._country=b.getInstance(),this.shouldRun()&&(this.addEventListeners(),this.loadCurrencies())}shouldRun(){return!(!this.currencyElement||!p.getOption("CustomCurrency"))}addEventListeners(){this._country.countryField&&this._country.onCountryChange.subscribe((e=>{this.loadCurrencies(e)}))}loadCurrencies(e="default"){const t=p.getOption("CustomCurrency");if(!t)return;const n=t.label||"Give with [$$$]";let i=t.default;if(t.countries&&t.countries[e]&&(i=t.countries[e]),!i)return void this.logger.log(`No currencies found for ${e}`);this.logger.log(`Loading currencies for ${e}`),this.currencyElement.innerHTML="";for(const e in i){const t=document.createElement("option");t.value=e,t.text=n.replace("[$$$]",e).replace("[$]",i[e]),t.setAttribute("data-currency-code",e),t.setAttribute("data-currency-symbol",i[e]),this.currencyElement.appendChild(t)}this.currencyElement.selectedIndex=0;const s=new Event("change",{bubbles:!0});this.currencyElement.dispatchEvent(s)}}class Fe{constructor(){this.logger=new fe("Autosubmit","#f0f0f0","#ff0000","🚀"),this._form=u.getInstance(),p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")&&!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()&&"Y"===p.getUrlParameter("autosubmit")&&(this.logger.log("Autosubmitting Form"),p.setFieldValue("supporter.emailAddress",p.getFieldValue("supporter.emailAddress").replace(/\s/g,"+")),this._form.submitForm())}}class Pe{constructor(){const e=document.getElementsByClassName("en__ticket__field--cost"),t=document.getElementsByClassName("en__ticket__currency");for(const e of t)e.classList.add("en__ticket__currency__hidden");for(const t of e){const e=t.getElementsByClassName("en__ticket__price")[0],n={style:"currency",currency:t.getElementsByClassName("en__ticket__currency")[0].innerText};let i=Intl.NumberFormat(void 0,n).format(Number(e.innerText));".00"===i.slice(-3)&&(i=i.slice(0,-3)),e.innerText=i}}}class Ne{constructor(){this.logger=new fe("SwapAmounts","purple","white","💰"),this._amount=h.getInstance(),this._frequency=g.getInstance(),this.defaultChange=!1,this.swapped=!1,this.shouldRun()&&(this._frequency.onFrequencyChange.subscribe((()=>this.swapAmounts())),this._amount.onAmountChange.subscribe((()=>{this._frequency.frequency in window.EngridAmounts!=!1&&(this.defaultChange=!1,this.swapped&&this._amount.amount!=window.EngridAmounts[this._frequency.frequency].default&&(this.defaultChange=!0))})))}swapAmounts(){this._frequency.frequency in window.EngridAmounts&&(window.EngagingNetworks.require._defined.enjs.swapList("donationAmt",this.loadEnAmounts(window.EngridAmounts[this._frequency.frequency]),{ignoreCurrentValue:this.ignoreCurrentValue()}),this._amount.load(),this.logger.log("Amounts Swapped To",window.EngridAmounts[this._frequency.frequency]),this.swapped=!0)}loadEnAmounts(e){let t=[];for(let n in e.amounts)t.push({selected:e.amounts[n]===e.default,label:n,value:e.amounts[n].toString()});return t}shouldRun(){return"EngridAmounts"in window}ignoreCurrentValue(){return!(window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed()||null!==p.getUrlParameter("transaction.donationAmt")||this.defaultChange)}}class Te{constructor(e){var t,n;this.logger=new fe("Debug Panel","#f0f0f0","#ff0000","💥"),this.brandingHtml=new Me,this.element=null,this.currentTimestamp=this.getCurrentTimestamp(),this.quickFills={"pi-general":[{name:"supporter.title",value:"Ms"},{name:"supporter.firstName",value:"4Site"},{name:"supporter.lastName",value:"Studio"},{name:"supporter.emailAddress",value:"en-test@4sitestudios.com"},{name:"supporter.phoneNumber",value:"555-555-5555"}],"pi-unique":[{name:"supporter.title",value:"Ms"},{name:"supporter.firstName",value:`4Site ${this.currentTimestamp}`},{name:"supporter.lastName",value:"Studio"},{name:"supporter.emailAddress",value:`en-test+${this.currentTimestamp}@4sitestudios.com`},{name:"supporter.phoneNumber",value:"555-555-5555"}],"us-address":[{name:"supporter.address1",value:"3431 14th St NW"},{name:"supporter.address2",value:"Suite 1"},{name:"supporter.city",value:"Washington"},{name:"supporter.region",value:"DC"},{name:"supporter.postcode",value:"20010"},{name:"supporter.country",value:"US"}],"us-address-senate-rep":[{name:"supporter.address1",value:"20 W 34th Street"},{name:"supporter.address2",value:""},{name:"supporter.city",value:"New York"},{name:"supporter.region",value:"NY"},{name:"supporter.postcode",value:"10001"},{name:"supporter.country",value:"US"}],"us-address-nonexistent":[{name:"supporter.address1",value:"12345 Main Street"},{name:"supporter.address2",value:""},{name:"supporter.city",value:"New York"},{name:"supporter.region",value:"TX"},{name:"supporter.postcode",value:"90210"},{name:"supporter.country",value:"US"}],"cc-paysafe-visa":[{name:"transaction.ccnumber",value:"4530910000012345"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}],"cc-paysafe-visa-invalid":[{name:"transaction.ccnumber",value:"411111"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}],"cc-paysafe-mastercard":[{name:"transaction.ccnumber",value:"5036150000001115"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}],"cc-stripe-visa":[{name:"transaction.ccnumber",value:"4242424242424242"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}],"quick-fill-pi-unique-us-address-senate-rep-cc-stripe-visa":[{name:"supporter.title",value:"Ms"},{name:"supporter.firstName",value:`4Site ${this.currentTimestamp}`},{name:"supporter.lastName",value:"Studio"},{name:"supporter.emailAddress",value:`en-test+${this.currentTimestamp}@4sitestudios.com`},{name:"supporter.phoneNumber",value:"555-555-5555"},{name:"supporter.address1",value:"20 W 34th Street"},{name:"supporter.address2",value:""},{name:"supporter.city",value:"New York"},{name:"supporter.region",value:"NY"},{name:"supporter.postcode",value:"10001"},{name:"supporter.country",value:"US"},{name:"transaction.ccnumber",value:"4242424242424242"},{name:"transaction.ccexpire",value:"12/27"},{name:"transaction.ccvv",value:"111"}]},this.logger.log("Adding debug panel and starting a debug session"),this.pageLayouts=e,this.loadDebugPanel(),this.element=document.querySelector(".debug-panel"),null===(t=this.element)||void 0===t||t.addEventListener("click",(()=>{var e;null===(e=this.element)||void 0===e||e.classList.add("debug-panel--open")}));const i=document.querySelector(".debug-panel__close");null==i||i.addEventListener("click",(e=>{var t;e.stopPropagation(),null===(t=this.element)||void 0===t||t.classList.remove("debug-panel--open")})),"local"===p.getUrlParameter("assets")&&(null===(n=this.element)||void 0===n||n.classList.add("debug-panel--local")),window.sessionStorage.setItem(Te.debugSessionStorageKey,"active")}loadDebugPanel(){document.body.insertAdjacentHTML("beforeend",'<div class="debug-panel">\n <div class="debug-panel__container">\n <div class="debug-panel__closed-title">Debug</div>\n <div class="debug-panel__title">\n <h2>Debug</h2>\n <div class="debug-panel__close">X</div>\n </div>\n <div class="debug-panel__options">\n <div class="debug-panel__option">\n <label class="debug-panel__link-label link-left">\n <a class="debug-panel__edit-link">Edit page</a>\n </label>\n </div>\n <div class="debug-panel__option">\n <label for="engrid-form-quickfill">Quick-fill</label>\n <select name="engrid-form-quickfill" id="engrid-form-quickfill">\n <option disabled selected>Choose an option</option>\n <option value="quick-fill-pi-unique-us-address-senate-rep-cc-stripe-visa">Quick-fill - Unique w/ Senate Address - Stripe Visa</option>\n <option value="pi-general">Personal Info - General</option>\n <option value="pi-unique">Personal Info - Unique</option>\n <option value="us-address-senate-rep">US Address - w/ Senate Rep</option>\n <option value="us-address">US Address - w/o Senate Rep</option>\n <option value="us-address-nonexistent">US Address - Nonexistent</option>\n <option value="cc-paysafe-visa">CC - Paysafe - Visa</option>\n <option value="cc-paysafe-visa-invalid">CC - Paysafe - Visa (Invalid)</option>\n <option value="cc-paysafe-mastercard">CC - Paysafe - Mastercard</option>\n <option value="cc-stripe-visa">CC - Stripe - Visa</option>\n </select>\n </div>\n <div class="debug-panel__option">\n <label for="engrid-layout-switch">Layout</label>\n <select name="engrid-layout" id="engrid-layout-switch">\n </select>\n </div>\n <div class="debug-panel__option debug-panel__option--local">\n <div class="debug-panel__checkbox">\n <input type="checkbox" name="engrid-embedded-layout" id="engrid-embedded-layout">\n <label for="engrid-embedded-layout">Embedded layout</label> \n </div>\n </div>\n <div class="debug-panel__option debug-panel__option--local">\n <div class="debug-panel__checkbox">\n <input type="checkbox" name="engrid-debug-layout" id="engrid-debug-layout">\n <label for="engrid-debug-layout">Debug layout</label> \n </div>\n </div>\n <div class="debug-panel__option debug-panel__option--local">\n <div class="debug-panel__checkbox">\n <input type="checkbox" name="engrid-branding" id="engrid-branding">\n <label for="engrid-branding">Branding HTML</label> \n </div>\n </div>\n <div class="debug-panel__option">\n <label for="engrid-theme">Theme</label>\n <input type="text" id="engrid-theme">\n </div>\n <div class="debug-panel__option debug-panel__option--local">\n <label for="engrid-theme">Sub-theme</label>\n <input type="text" id="engrid-subtheme">\n </div>\n <div class="debug-panel__option">\n <button class="btn debug-panel__btn debug-panel__btn--submit" type="button">Submit form</button>\n </div>\n <div class="debug-panel__option">\n <label class="debug-panel__link-label">\n <a class="debug-panel__force-submit-link">Force submit form</a>\n </label>\n </div>\n <div class="debug-panel__option">\n <label class="debug-panel__link-label">\n <a class="debug-panel__end-debug-link">End debug</a>\n </label>\n </div>\n </div>\n </div>\n </div>'),this.setupLayoutSwitcher(),this.setupThemeSwitcher(),this.setupSubThemeSwitcher(),this.setupFormQuickfill(),this.createDebugSessionEndHandler(),this.setupEmbeddedLayoutSwitcher(),this.setupDebugLayoutSwitcher(),this.setupBrandingHtmlHandler(),this.setupEditBtnHandler(),this.setupForceSubmitLinkHandler(),this.setupSubmitBtnHandler()}switchENGridLayout(e){p.setBodyData("layout",e)}setupLayoutSwitcher(){var e,t;const n=document.getElementById("engrid-layout-switch");n&&(null===(e=this.pageLayouts)||void 0===e||e.forEach((e=>{n.insertAdjacentHTML("beforeend",`<option value="${e}">${e}</option>`)})),n.value=null!==(t=p.getBodyData("layout"))&&void 0!==t?t:"",n.addEventListener("change",(e=>{const t=e.target;this.switchENGridLayout(t.value)})))}setupThemeSwitcher(){var e;const t=document.getElementById("engrid-theme");t&&(t.value=null!==(e=p.getBodyData("theme"))&&void 0!==e?e:"",["keyup","blur"].forEach((e=>{t.addEventListener(e,(e=>{const t=e.target;this.switchENGridTheme(t.value)}))})))}switchENGridTheme(e){p.setBodyData("theme",e)}setupSubThemeSwitcher(){var e;const t=document.getElementById("engrid-subtheme");t&&(t.value=null!==(e=p.getBodyData("subtheme"))&&void 0!==e?e:"",["keyup","blur"].forEach((e=>{t.addEventListener(e,(e=>{const t=e.target;this.switchENGridSubtheme(t.value)}))})))}switchENGridSubtheme(e){p.setBodyData("subtheme",e)}setupFormQuickfill(){const e=document.getElementById("engrid-form-quickfill");null==e||e.addEventListener("change",(e=>{const t=e.target;this.quickFills[t.value].forEach((e=>{this.setFieldValue(e)}))}))}setFieldValue(e){if("transaction.ccexpire"!==e.name)p.setFieldValue(e.name,e.value,!0,!0);else{const t=document.getElementsByName("transaction.ccexpire");if(t.length>0){const n=e.value.split("/");t[0].value=n[0],t[1].value=n[1],t[0].dispatchEvent(new Event("change",{bubbles:!0})),t[1].dispatchEvent(new Event("change",{bubbles:!0}))}else t[0].value=e.value,t[0].dispatchEvent(new Event("change",{bubbles:!0}))}}getCurrentTimestamp(){const e=new Date;return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}-${String(e.getHours()).padStart(2,"0")}${String(e.getMinutes()).padStart(2,"0")}`}createDebugSessionEndHandler(){const e=document.querySelector(".debug-panel__end-debug-link");null==e||e.addEventListener("click",(()=>{var e;this.logger.log("Removing panel and ending debug session"),null===(e=this.element)||void 0===e||e.remove(),window.sessionStorage.removeItem(Te.debugSessionStorageKey)}))}setupEmbeddedLayoutSwitcher(){const e=document.getElementById("engrid-embedded-layout");e&&(e.checked=!!p.getBodyData("embedded"),e.addEventListener("change",(e=>{const t=e.target;p.setBodyData("embedded",t.checked)})))}setupDebugLayoutSwitcher(){const e=document.getElementById("engrid-debug-layout");e&&(e.checked="layout"===p.getBodyData("debug"),e.addEventListener("change",(e=>{e.target.checked?p.setBodyData("debug","layout"):p.setBodyData("debug","")})))}setupBrandingHtmlHandler(){const e=document.getElementById("engrid-branding");e.checked="branding"===p.getUrlParameter("development"),e.addEventListener("change",(t=>{e.checked?this.brandingHtml.show():this.brandingHtml.hide()}))}setupEditBtnHandler(){const e=document.querySelector(".debug-panel__edit-link");null==e||e.addEventListener("click",(()=>{window.open(`https://${p.getDataCenter()}.engagingnetworks.app/index.html#pages/${p.getPageID()}/edit`,"_blank")}))}setupForceSubmitLinkHandler(){const e=document.querySelector(".debug-panel__force-submit-link");null==e||e.addEventListener("click",(()=>{const e=document.querySelector("form.en__component");null==e||e.submit()}))}setupSubmitBtnHandler(){const e=document.querySelector(".debug-panel__btn--submit");null==e||e.addEventListener("click",(()=>{const e=document.querySelector(".en__submit button");null==e||e.click()}))}}Te.debugSessionStorageKey="engrid_debug_panel";class Oe{constructor(){this.logger=new fe("Debug hidden fields","#f0f0f0","#ff0000","🫣");const e=document.querySelectorAll(".en__component--row [type='hidden'][class*='en_'], .engrid-added-input[type='hidden']");e.length>0&&(this.logger.log(`Switching the following type 'hidden' fields to type 'text': ${[...e].map((e=>e.name)).join(", ")}`),e.forEach((e=>{e.type="text",e.classList.add("en__field__input","en__field__input--text");const t=document.createElement("label");t.textContent="Hidden field: "+e.name,t.classList.add("en__field__label");const n=document.createElement("div");n.classList.add("en__field__element","en__field__element--text");const i=document.createElement("div");i.classList.add("en__field","en__field--text","hide"),i.dataset.unhidden="",i.appendChild(t),i.appendChild(n),e.parentNode&&(e.parentNode.insertBefore(i,e),n.appendChild(e))})))}}var qe=function(e,t,n,i){return new(n||(n=Promise))((function(s,o){function r(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}l((i=i.apply(e,t||[])).next())}))};class Me{constructor(){this.assetBaseUrl="https://cdn.jsdelivr.net/gh/4site-interactive-studios/engrid@main/reference-materials/html/brand-guide-markup/",this.brandingHtmlFiles=["html5-tags.html","en-common-fields.html","survey.html","donation-page.html","premium-donation.html","ecards.html","email-to-target.html","tweet-to-target.html","petition.html","event.html","styles.html"],this.bodyMain=document.querySelector(".body-main"),this.htmlFetched=!1}fetchHtml(){return qe(this,void 0,void 0,(function*(){const e=this.brandingHtmlFiles.map((e=>qe(this,void 0,void 0,(function*(){return(yield fetch(this.assetBaseUrl+e)).text()}))));return yield Promise.all(e)}))}appendHtml(){this.fetchHtml().then((e=>e.forEach((e=>{var t;const n=document.createElement("div");n.classList.add("brand-guide-section"),n.innerHTML=e,null===(t=this.bodyMain)||void 0===t||t.insertAdjacentElement("beforeend",n)})))),this.htmlFetched=!0}show(){if(!this.htmlFetched)return void this.appendHtml();const e=document.querySelectorAll(".brand-guide-section");null==e||e.forEach((e=>e.style.display="block"))}hide(){const e=document.querySelectorAll(".brand-guide-section");null==e||e.forEach((e=>e.style.display="none"))}}class Ie{constructor(){this.logger=new fe("CountryDisable","#f0f0f0","#333333","🌎");const e=document.querySelectorAll('select[name="supporter.country"], select[name="transaction.shipcountry"], select[name="supporter.billingCountry"], select[name="transaction.infcountry"]'),t=p.getOption("CountryDisable");if(e.length>0&&t.length>0){const n=t.map((e=>e.toLowerCase()));e.forEach((e=>{e.querySelectorAll("option").forEach((t=>{(n.includes(t.value.toLowerCase())||n.includes(t.text.toLowerCase()))&&(this.logger.log(`Removing ${t.text} from ${e.getAttribute("name")}`),t.remove())}))}))}}}class Be{constructor(){this.logger=new fe("PremiumGift","#232323","#f7b500","🎁"),this.enElements=new Array,this.shoudRun()&&(this.searchElements(),this.addEventListeners(),this.checkPremiumGift())}shoudRun(){return"pageJson"in window&&"pageType"in window.pageJson&&"premiumgift"===window.pageJson.pageType}addEventListeners(){["click","change"].forEach((e=>{document.addEventListener(e,(e=>{const t=e.target,n=t.closest(".en__pg__body");if(n){const e=n.querySelector('[name="en__pg"]');if("type"in t==!1){const t=e.value;window.setTimeout((()=>{const e=document.querySelector('[name="en__pg"][value="'+t+'"]');e&&(e.checked=!0,e.dispatchEvent(new Event("change")))}),100)}window.setTimeout((()=>{this.checkPremiumGift()}),110)}}))}));const e=document.querySelector(".en__component--premiumgiftblock");if(e){new MutationObserver((t=>{for(const n of t)"attributes"===n.type&&"style"===n.attributeName&&"none"===e.style.display&&(this.logger.log("Premium Gift Section hidden - removing premium gift body data attributes and premium title."),p.setBodyData("premium-gift-maximize",!1),p.setBodyData("premium-gift-name",!1),this.setPremiumTitle(""))})).observe(e,{attributes:!0})}}checkPremiumGift(){const e=document.querySelector('[name="en__pg"]:checked');if(e){const t=e.value;this.logger.log("Premium Gift Value: "+t);const n=e.closest(".en__pg");if("0"!==t){const e=n.querySelector(".en__pg__name");p.setBodyData("premium-gift-maximize","false"),p.setBodyData("premium-gift-name",p.slugify(e.innerText)),this.setPremiumTitle(e.innerText)}else p.setBodyData("premium-gift-maximize","true"),p.setBodyData("premium-gift-name",!1),this.setPremiumTitle("");if(!n.classList.contains("en__pg--selected")){const e=document.querySelector(".en__pg--selected");e&&e.classList.remove("en__pg--selected"),n.classList.add("en__pg--selected")}}}searchElements(){const e=document.querySelectorAll("\n .en__component--copyblock,\n .en__component--codeblock,\n .en__field\n ");e.length>0&&e.forEach((e=>{e instanceof HTMLElement&&e.innerHTML.includes("{$PREMIUMTITLE}")&&(e.innerHTML=e.innerHTML.replace("{$PREMIUMTITLE}",'<span class="engrid_premium_title"></span>'),this.enElements.push(e))}))}setPremiumTitle(e){this.enElements.forEach((t=>{const n=t.querySelector(".engrid_premium_title");n&&(n.innerHTML=e)}))}}class Re{constructor(){if(!document.getElementById("en__digitalWallet"))return p.setBodyData("payment-type-option-apple-pay","false"),p.setBodyData("payment-type-option-google-pay","false"),p.setBodyData("payment-type-option-paypal-one-touch","false"),p.setBodyData("payment-type-option-venmo","false"),void p.setBodyData("payment-type-option-daf","false");const e=document.getElementById("en__digitalWallet__stripeButtons__container");e&&(e.classList.add("giveBySelect-stripedigitalwallet"),e.classList.add("showif-stripedigitalwallet-selected"));const t=document.getElementById("en__digitalWallet__paypalTouch__container");t&&(t.classList.add("giveBySelect-paypaltouch"),t.classList.add("showif-paypaltouch-selected"));const n=document.getElementById("en__digitalWallet__chariot__container");if(n&&(n.classList.add("giveBySelect-daf"),n.classList.add("showif-daf-selected")),document.querySelector("#en__digitalWallet__stripeButtons__container > *"))this.addStripeDigitalWallets();else{p.setBodyData("payment-type-option-apple-pay","false"),p.setBodyData("payment-type-option-google-pay","false");const e=document.getElementById("en__digitalWallet__stripeButtons__container");e&&this.checkForWalletsBeingAdded(e,"stripe");"stripedigitalwallet"===p.getPaymentType().toLowerCase()&&p.setPaymentType("card")}if(document.querySelector("#en__digitalWallet__paypalTouch__container > *"))this.addPaypalTouchDigitalWallets();else{p.setBodyData("payment-type-option-paypal-one-touch","false"),p.setBodyData("payment-type-option-venmo","false");const e=document.getElementById("en__digitalWallet__paypalTouch__container");e&&this.checkForWalletsBeingAdded(e,"paypalTouch")}if(document.querySelector("#en__digitalWallet__chariot__container > *"))this.addDAF();else{p.setBodyData("payment-type-option-daf","false");const e=document.getElementById("en__digitalWallet__chariot__container");e&&this.checkForWalletsBeingAdded(e,"daf")}}addStripeDigitalWallets(){this.addOptionToPaymentTypeField("stripedigitalwallet","GooglePay / ApplePay"),p.setBodyData("payment-type-option-apple-pay","true"),p.setBodyData("payment-type-option-google-pay","true")}addPaypalTouchDigitalWallets(){this.addOptionToPaymentTypeField("paypaltouch","Paypal / Venmo"),p.setBodyData("payment-type-option-paypal-one-touch","true"),p.setBodyData("payment-type-option-venmo","true")}addDAF(){this.addOptionToPaymentTypeField("daf","Donor Advised Fund"),p.setBodyData("payment-type-option-daf","true")}addOptionToPaymentTypeField(e,t){const n=document.querySelector('[name="transaction.paymenttype"]');if(n&&!n.querySelector(`[value=${e}]`)){const i=document.createElement("option");i.value=e,i.innerText=t,n.appendChild(i)}const i=document.querySelector('input[name="transaction.giveBySelect"][value="'+e+'"]');if(i&&"true"===i.dataset.default){i.checked=!0;const e=new Event("change",{bubbles:!0,cancelable:!0});i.dispatchEvent(e)}}checkForWalletsBeingAdded(e,t){new MutationObserver(((e,n)=>{for(const i of e)"childList"===i.type&&i.addedNodes.length&&("stripe"===t?this.addStripeDigitalWallets():"paypalTouch"===t?this.addPaypalTouchDigitalWallets():"daf"===t&&this.addDAF(),n.disconnect())})).observe(e,{childList:!0,subtree:!0})}}class je{constructor(){var e,t,n;this.options=null!==(e=p.getOption("MobileCTA"))&&void 0!==e&&e,this.buttonLabel="",this.options&&(null===(t=this.options.pages)||void 0===t?void 0:t.includes(p.getPageType()))&&1===p.getPageNumber()&&(this.buttonLabel=null!==(n=this.options.label)&&void 0!==n?n:"Take Action",this.renderButton(),this.addEventListeners())}renderButton(){const e=document.querySelector("#engrid"),t=document.querySelector(".body-main .en__component--widgetblock:first-child, .en__component--formblock");if(!e||!t)return;const n=document.createElement("div"),i=document.createElement("button");n.classList.add("engrid-mobile-cta-container"),n.style.display="none",i.classList.add("primary"),i.innerHTML=this.buttonLabel,i.addEventListener("click",(()=>{t.scrollIntoView({behavior:"smooth"})})),n.appendChild(i),e.appendChild(n)}addEventListeners(){const e=document.querySelector(".body-main");if(!e)return;const t=()=>{e.getBoundingClientRect().top<=window.innerHeight-100?this.hideButton():this.showButton()};window.addEventListener("load",t),window.addEventListener("resize",t),window.addEventListener("scroll",t)}hideButton(){const e=document.querySelector(".engrid-mobile-cta-container");e&&(e.style.display="none")}showButton(){const e=document.querySelector(".engrid-mobile-cta-container");e&&(e.style.display="block")}}class He{constructor(){this.logger=new fe("LiveFrequency","#00ff00","#000000","🧾"),this.elementsFound=!1,this._amount=h.getInstance(),this._frequency=g.getInstance(),this.searchElements(),this.shouldRun()&&(this.updateFrequency(),this.addEventListeners())}searchElements(){const e=document.querySelectorAll("\n .en__component--copyblock,\n .en__component--codeblock,\n .en__field label,\n .en__submit\n ");if(e.length>0){const t=/\[\[(frequency)\]\]/gi;let n=0;e.forEach((e=>{const i=e.innerHTML.match(t);e instanceof HTMLElement&&i&&(this.elementsFound=!0,i.forEach((t=>{n++,this.replaceMergeTags(t,e)})))})),n>0&&this.logger.log(`Found ${n} merge tag${n>1?"s":""} in the page.`)}}shouldRun(){return!!this.elementsFound||(this.logger.log("No merge tags found. Skipping."),!1)}addEventListeners(){this._amount.onAmountChange.subscribe((()=>{setTimeout((()=>{this.updateFrequency()}),10)})),this._frequency.onFrequencyChange.subscribe((()=>{setTimeout((()=>{this.searchElements(),this.updateFrequency()}),10)}))}updateFrequency(){const e="onetime"===this._frequency.frequency?"one-time":this._frequency.frequency;document.querySelectorAll(".engrid-frequency").forEach((t=>{t.classList.contains("engrid-frequency--lowercase")?t.innerHTML=e.toLowerCase():t.classList.contains("engrid-frequency--capitalized")?t.innerHTML=e.charAt(0).toUpperCase()+e.slice(1):t.classList.contains("engrid-frequency--uppercase")?t.innerHTML=e.toUpperCase():t.innerHTML=e}))}replaceMergeTags(e,t){const n="onetime"===this._frequency.frequency?"one-time":this._frequency.frequency,i=document.createElement("span");switch(i.classList.add("engrid-frequency"),i.innerHTML=n,e){case"[[frequency]]":i.classList.add("engrid-frequency--lowercase"),i.innerHTML=i.innerHTML.toLowerCase(),t.innerHTML=t.innerHTML.replace(e,i.outerHTML);break;case"[[Frequency]]":i.classList.add("engrid-frequency--capitalized"),i.innerHTML=i.innerHTML.charAt(0).toUpperCase()+i.innerHTML.slice(1),t.innerHTML=t.innerHTML.replace(e,i.outerHTML);break;case"[[FREQUENCY]]":i.classList.add("engrid-frequency--uppercase"),i.innerHTML=i.innerHTML.toUpperCase(),t.innerHTML=t.innerHTML.replace(e,i.outerHTML)}}}class Ue{constructor(){this.logger=new fe("UniversalOptIn","#f0f0f0","#d2691e","🪞"),this._elements=document.querySelectorAll(".universal-opt-in, .universal-opt-in_null"),this.shouldRun()&&this.addEventListeners()}shouldRun(){return 0===this._elements.length?(this.logger.log("No universal opt-in elements found. Skipping."),!1):(this.logger.log(`Found ${this._elements.length} universal opt-in elements.`),!0)}addEventListeners(){this._elements.forEach((e=>{const t=e.querySelectorAll(".en__field__input--radio, .en__field__input--checkbox");t.length>0&&t.forEach((n=>{n.addEventListener("click",(()=>{if(n instanceof HTMLInputElement&&"checkbox"===n.getAttribute("type")){return void(n.checked?(this.logger.log("Yes/No "+n.getAttribute("type")+" is checked"),t.forEach((e=>{n!==e&&e instanceof HTMLInputElement&&"checkbox"===e.getAttribute("type")&&(e.checked=!0)}))):(this.logger.log("Yes/No "+n.getAttribute("type")+" is unchecked"),t.forEach((e=>{n!==e&&e instanceof HTMLInputElement&&"checkbox"===e.getAttribute("type")&&(e.checked=!1)}))))}"Y"===n.getAttribute("value")?(this.logger.log("Yes/No "+n.getAttribute("type")+" is checked"),t.forEach((e=>{const t=e.getAttribute("name"),i=n.getAttribute("name");t&&t!==i&&p.setFieldValue(t,"Y")}))):(this.logger.log("Yes/No "+n.getAttribute("type")+" is unchecked"),t.forEach((t=>{const i=t.getAttribute("name"),s=n.getAttribute("name");i&&i!==s&&(e.classList.contains("universal-opt-in")?p.setFieldValue(i,"N"):t.checked=!1)})))}))}))}))}}class Ve{constructor(){this.logger=new fe("Plaid","peru","yellow","🔗"),this._form=u.getInstance(),this.logger.log("Enabled"),this._form.onSubmit.subscribe((()=>this.submit()))}submit(){const e=document.querySelector("#plaid-link-button");if(e&&"Link Account"===e.textContent){this.logger.log("Clicking Link"),e.click(),this._form.submit=!1;new MutationObserver((e=>{e.forEach((e=>{"childList"===e.type&&e.addedNodes.forEach((e=>{e.nodeType===Node.TEXT_NODE&&("Account Linked"===e.nodeValue?(this.logger.log("Plaid Linked"),this._form.submit=!0,this._form.submitForm()):this._form.submit=!0)}))}))})).observe(e,{childList:!0,subtree:!0}),window.setTimeout((()=>{this.logger.log("Enabling Submit"),p.enableSubmit()}),1e3)}}}class $e{constructor(){if(this.logger=new fe("GiveBySelect","#FFF","#333","🐇"),this.transactionGiveBySelect=document.getElementsByName("transaction.giveBySelect"),this._frequency=g.getInstance(),!this.transactionGiveBySelect)return;this._frequency.onFrequencyChange.subscribe((()=>this.checkPaymentTypeVisibility())),this.transactionGiveBySelect.forEach((e=>{e.addEventListener("change",(()=>{this.logger.log("Changed to "+e.value),p.setPaymentType(e.value)}))}));const e=p.getPaymentType();if(e){this.logger.log("Setting giveBySelect to "+e);const t=["card","visa","mastercard","amex","discover","diners","jcb","vi","mc","ax","dc","di","jc"].includes(e.toLowerCase());this.transactionGiveBySelect.forEach((n=>{(t&&"card"===n.value.toLowerCase()||n.value.toLowerCase()===e.toLowerCase())&&(n.checked=!0)}))}}isSelectedPaymentVisible(){let e=!0;return this.transactionGiveBySelect.forEach((t=>{const n=t.parentElement;t.checked&&!p.isVisible(n)&&(this.logger.log(`Selected Payment Type is not visible: ${t.value}`),e=!1)})),e}checkPaymentTypeVisibility(){window.setTimeout((()=>{var e;if(this.isSelectedPaymentVisible())this.logger.log("Selected Payment Type is visible");else{this.logger.log("Setting payment type to first visible option");const t=Array.from(this.transactionGiveBySelect).find((e=>{const t=e.parentElement;return p.isVisible(t)}));if(t){this.logger.log("Setting payment type to ",t.value);null===(e=t.parentElement.querySelector("label"))||void 0===e||e.click(),p.setPaymentType(t.value)}}}),300)}}class We{constructor(){this.logger=new fe("UrlParamsToBodyAttrs","white","magenta","📌"),this.urlParams=new URLSearchParams(document.location.search),this.urlParams.forEach(((e,t)=>{t.startsWith("data-engrid-")&&(p.setBodyData(t.split("data-engrid-")[1],e),this.logger.log(`Set "${t}" on body to "${e}" from URL params`))}))}}class Ge{constructor(){this.opened=!1,this.dataLayer=window.dataLayer||[],this.logger=new fe("ExitIntentLightbox","yellow","black","🚪"),this.triggerDelay=1e3,this.triggerTimeout=null;let e="EngridExitIntent"in window?window.EngridExitIntent:{};if(this.options=Object.assign(Object.assign({},l),e),!this.options.enabled)return void this.logger.log("Not enabled");if(te(this.options.cookieName))return void this.logger.log("Not showing - cookie found.");const t=Object.keys(this.options.triggers).filter((e=>this.options.triggers[e])).join(", ");this.logger.log("Enabled, waiting for trigger. Active triggers: "+t),this.watchForTriggers()}watchForTriggers(){window.addEventListener("load",(()=>{setTimeout((()=>{this.options.triggers.mousePosition&&this.watchMouse(),this.options.triggers.visibilityState&&this.watchDocumentVisibility()}),this.triggerDelay)}))}watchMouse(){document.addEventListener("mouseout",(e=>{if("input"==e.target.tagName.toLowerCase())return;const t=Math.max(document.documentElement.clientWidth,window.innerWidth||0);if(e.clientX>=t-50)return;if(e.clientY>=50)return;const n=e.relatedTarget;n||(this.logger.log("Triggered by mouse position"),this.open()),this.triggerTimeout||(this.triggerTimeout=window.setTimeout((()=>{n||(this.logger.log("Triggered by mouse position"),this.open()),this.triggerTimeout=null}),this.triggerDelay))}))}watchDocumentVisibility(){const e=()=>{"hidden"===document.visibilityState&&(this.triggerTimeout||(this.triggerTimeout=window.setTimeout((()=>{this.logger.log("Triggered by visibilityState is hidden"),this.open(),document.removeEventListener("visibilitychange",e),this.triggerTimeout=null}),this.triggerDelay)))};document.addEventListener("visibilitychange",e)}open(){var e,t,n;this.opened||(p.setBodyData("exit-intent-lightbox","open"),ne(this.options.cookieName,"1",{expires:this.options.cookieDuration}),document.body.insertAdjacentHTML("beforeend",`\n <div class="ExitIntent">\n <div class="ExitIntent__overlay">\n <div class="ExitIntent__container">\n <div class="ExitIntent__close">X</div>\n <div class="ExitIntent__body">\n <h2>${this.options.title}</h2>\n <p>${this.options.text}</p>\n <button type="button" class="ExitIntent__button">\n ${this.options.buttonText}\n </button>\n </div>\n </div>\n </div>\n </div>\n `),this.opened=!0,this.dataLayer.push({event:"exit_intent_lightbox_shown"}),null===(e=document.querySelector(".ExitIntent__close"))||void 0===e||e.addEventListener("click",(()=>{this.dataLayer.push({event:"exit_intent_lightbox_closed"}),this.close()})),null===(t=document.querySelector(".ExitIntent__overlay"))||void 0===t||t.addEventListener("click",(e=>{e.target===e.currentTarget&&(this.dataLayer.push({event:"exit_intent_lightbox_closed"}),this.close())})),null===(n=document.querySelector(".ExitIntent__button"))||void 0===n||n.addEventListener("click",(()=>{this.dataLayer.push({event:"exit_intent_lightbox_cta_clicked"}),this.close();const e=this.options.buttonLink;if(e.startsWith(".")||e.startsWith("#")){const t=document.querySelector(e);t&&t.scrollIntoView({behavior:"smooth"})}else window.open(e,"_blank")})))}close(){var e;null===(e=document.querySelector(".ExitIntent"))||void 0===e||e.remove(),p.setBodyData("exit-intent-lightbox","closed")}}class Ye{constructor(){this.logger=new fe("SupporterHub","black","pink","🛖"),this._form=u.getInstance(),this.shoudRun()&&(this.logger.log("Enabled"),this.watch())}shoudRun(){return"pageJson"in window&&"pageType"in window.pageJson&&"supporterhub"===window.pageJson.pageType}watch(){const e=p.enForm;new MutationObserver((e=>{e.forEach((e=>{"childList"===e.type&&e.addedNodes.forEach((e=>{if("DIV"===e.nodeName){const t=e;(t.classList.contains("en__hubOverlay")||t.classList.contains("en__hubPledge__panels"))&&(this.logger.log("Overlay found"),this.creditCardUpdate(e),this.amountLabelUpdate(e))}}))}))})).observe(e,{childList:!0,subtree:!0});const t=document.querySelector(".en__hubOverlay");t&&(this.creditCardUpdate(t),this.amountLabelUpdate(t))}creditCardUpdate(e){window.setTimeout((()=>{const t=e.querySelector("#en__hubPledge__field--ccnumber"),n=e.querySelector(".en__hubUpdateCC__toggle");t&&n&&t.addEventListener("focus",(()=>{this.logger.log("Credit Card field focused"),n.click()}))}),300)}amountLabelUpdate(e){window.setTimeout((()=>{const t=e.querySelector(".en__field--donationAmt");t&&t.querySelectorAll(".en__field__element--radio .en__field__item").forEach((e=>{e.setAttribute("data-engrid-currency-symbol-updated","true")}))}),300)}}class Je{constructor(){this.logger=new fe("FastFormFill","white","magenta","📌"),this.rememberMeEvents=f.getInstance(),p.getOption("RememberMe")?(this.rememberMeEvents.onLoad.subscribe((e=>{this.logger.log("Remember me - onLoad",e),this.run()})),this.rememberMeEvents.onClear.subscribe((()=>{this.logger.log("Remember me - onClear")}))):this.run()}run(){const e=document.querySelectorAll(".en__component--formblock.fast-personal-details");e.length>0&&([...e].every((e=>Je.allMandatoryInputsAreFilled(e)))?(this.logger.log("Personal details - All mandatory inputs are filled"),p.setBodyData("hide-fast-personal-details","true")):(this.logger.log("Personal details - Not all mandatory inputs are filled"),p.setBodyData("hide-fast-personal-details","false")));const t=document.querySelectorAll(".en__component--formblock.fast-address-details");t.length>0&&([...t].every((e=>Je.allMandatoryInputsAreFilled(e)))?(this.logger.log("Address details - All mandatory inputs are filled"),p.setBodyData("hide-fast-address-details","true")):(this.logger.log("Address details - Not all mandatory inputs are filled"),p.setBodyData("hide-fast-address-details","false")))}static allMandatoryInputsAreFilled(e){return[...e.querySelectorAll(".en__mandatory input, .en__mandatory select, .en__mandatory textarea")].every((e=>{if("radio"===e.type||"checkbox"===e.type){return[...document.querySelectorAll('[name="'+e.name+'"]')].some((e=>e.checked))}return null!==e.value&&""!==e.value.trim()}))}static someMandatoryInputsAreFilled(e){return[...e.querySelectorAll(".en__mandatory input, .en__mandatory select, .en__mandatory textarea")].some((e=>{if("radio"===e.type||"checkbox"===e.type){return[...document.querySelectorAll('[name="'+e.name+'"]')].some((e=>e.checked))}return null!==e.value&&""!==e.value.trim()}))}}class ze{constructor(){this.logger=new fe("SetAttr","black","yellow","📌");const e=document.getElementById("engrid");e&&e.addEventListener("click",(e=>{const t=e.target;if("string"!=typeof t.className)return;t.className.split(" ").some((e=>e.startsWith("setattr--")))&&t.classList.forEach((e=>{const t=e.match(/^setattr--(.+)--(.+)$/i);t&&t[1]&&t[2]&&(this.logger.log(`Clicked element with class "${e}". Setting body attribute "${t[1]}" to "${t[2]}"`),p.setBodyData(t[1].replace("data-engrid-",""),t[2]))}))}))}}class Ke{constructor(){this.logger=new fe("ShowIfPresent","yellow","black","👀"),this.elements=[],this.shouldRun()&&this.run()}shouldRun(){return this.elements=[...document.querySelectorAll('[class*="engrid__supporterquestions"]')].filter((e=>e.className.split(" ").some((e=>/^engrid__supporterquestions\d+(__supporterquestions\d+)*-(present|absent)$/.test(e))))),this.elements.length>0}run(){const e=[];this.elements.forEach((t=>{const n=t.className.split(" ").find((e=>/^engrid__supporterquestions\d+(__supporterquestions\d+)*-(present|absent)$/.test(e)));if(!n)return null;const i=n.lastIndexOf("-"),s=n.substring(i+1),o=n.substring(8,i).split("__").map((e=>`supporter.questions.${e.substring(18)}`));e.push({class:n,fieldNames:o,type:s})})),e.forEach((e=>{const t=e.fieldNames.map((e=>document.getElementsByName(e)[0])),n=document.querySelectorAll(`.${e.class}`),i=t.every((e=>!!e)),s=t.every((e=>!e));("present"===e.type&&s||"absent"===e.type&&i)&&(this.logger.log(`Conditions not met, hiding elements with class ${e.class}`),n.forEach((e=>{e.style.display="none"})))}))}}class Xe{constructor(){this._form=u.getInstance(),this._enElements=null,this.logger=new fe("ENValidators","white","darkolivegreen","🧐"),this.loadValidators()?this.shouldRun()?this._form.onValidate.subscribe(this.enOnValidate.bind(this)):this.logger.log("Not Needed"):this.logger.error("Not Loaded")}loadValidators(){if(!p.checkNested(window.EngagingNetworks,"require","_defined","enValidation","validation","validators"))return!1;const e=window.EngagingNetworks.require._defined.enValidation.validation.validators;return this._enElements=e.reduce(((e,t)=>{if("type"in t&&"CUST"===t.type){const n=document.querySelector(".en__field--"+t.field),i=n?n.querySelector("input, select, textarea"):null;i&&(i.addEventListener("input",this.liveValidate.bind(this,n,i,t.regex,t.message)),e.push({container:n,field:i,regex:t.regex,message:t.message}))}return e}),[]),!0}shouldRun(){return p.getOption("ENValidators")&&this._enElements&&this._enElements.length>0}enOnValidate(){this._enElements&&!1!==this._form.validate&&(this._enElements.forEach((e=>{if(!this.liveValidate(e.container,e.field,e.regex,e.message))return this._form.validate=!1,void e.field.focus()})),this._form.validate=!0)}liveValidate(e,t,n,i){const s=p.getFieldValue(t.getAttribute("name")||"");return""===s||(this.logger.log(`Live Validate ${t.getAttribute("name")} with ${n}`),s.match(n)?(p.removeError(e),!0):(p.setError(e,i),!1))}}class Qe{constructor(){var e,t;this.postalCodeField=p.getField("supporter.postcode"),this._form=u.getInstance(),this.logger=new fe("Postal Code Validator","white","red","📬"),this.supportedSeparators=["+","-"," "],this.separator=this.getSeparator(),this.regexSeparator=this.getRegexSeparator(this.separator),this.shouldRun()&&(null===(e=this.postalCodeField)||void 0===e||e.addEventListener("blur",(()=>this.validate())),null===(t=this.postalCodeField)||void 0===t||t.addEventListener("input",(()=>this.liveValidate())),this._form.onValidate.subscribe((()=>{if(!this._form.validate)return;this.liveValidate(),setTimeout((()=>{this.validate()}),100);const e=!this.shouldValidateUSZipCode()||this.isValidUSZipCode();return this._form.validate=e,e||(this.logger.log(`Invalid Zip Code ${this.postalCodeField.value}`),this.postalCodeField.scrollIntoView({behavior:"smooth"})),e})))}shouldRun(){return!(!p.getOption("PostalCodeValidator")||!this.postalCodeField)}validate(){this.shouldValidateUSZipCode()&&!this.isValidUSZipCode()?p.setError(".en__field--postcode",`Please enter a valid ZIP Code of ##### or #####${this.separator}####`):p.removeError(".en__field--postcode")}isValidUSZipCode(){var e,t;if(!!!document.querySelector(".en__field--postcode.en__mandatory")&&""===(null===(e=this.postalCodeField)||void 0===e?void 0:e.value))return!0;const n=new RegExp(`^\\d{5}(${this.regexSeparator}\\d{4})?$`);return!!(null===(t=this.postalCodeField)||void 0===t?void 0:t.value.match(n))}liveValidate(){var e;if(!this.shouldValidateUSZipCode())return;let t=null===(e=this.postalCodeField)||void 0===e?void 0:e.value;t.length<=5?t=t.replace(/\D/g,""):6===t.length&&this.supportedSeparators.includes(t[5])?t=t.replace(/\D/g,"")+this.separator:(t=t.replace(/\D/g,""),t=t.replace(/(\d{5})(\d)/,`$1${this.separator}$2`)),this.postalCodeField.value=t.slice(0,10)}shouldValidateUSZipCode(){const e=p.getField("supporter.country")?p.getFieldValue("supporter.country"):"US";return["us","united states","usa",""].includes(e.toLowerCase())}getSeparator(){const e=p.getOption("TidyContact");return e&&e.us_zip_divider&&this.supportedSeparators.includes(e.us_zip_divider)?e.us_zip_divider:"-"}getRegexSeparator(e){switch(e){case"+":return"\\+";case"-":return"-";case" ":return"\\s";default:return this.logger.log(`Invalid separator "${e}" provided to PostalCodeValidator, falling back to "-".`),"-"}}}class Ze{constructor(){if(this.logger=new fe("VGS","black","pink","💳"),this.vgsField=document.querySelector(".en__field--vgs"),this.options=p.getOption("VGS"),this.paymentTypeField=document.querySelector("#en__field_transaction_paymenttype"),this._form=u.getInstance(),this.field_expiration_month=null,this.field_expiration_year=null,this.handleExpUpdate=e=>{if(!this.field_expiration_month||!this.field_expiration_year)return;const t=new Date,n=t.getMonth()+1,i=parseInt(this.field_expiration_year[this.field_expiration_year.length-1].value)>2e3?t.getFullYear():t.getFullYear()-2e3;if("month"==e){let e=parseInt(this.field_expiration_month.value),t=e<n;this.logger.log(`month disable ${t}`),this.logger.log(`selected_month ${e}`);for(let e=0;e<this.field_expiration_year.options.length;e++)parseInt(this.field_expiration_year.options[e].value)<=i&&(t?this.field_expiration_year.options[e].setAttribute("disabled","disabled"):this.field_expiration_year.options[e].disabled=!1)}else if("year"==e){let e=parseInt(this.field_expiration_year.value),t=e==i;this.logger.log(`year disable ${t}`),this.logger.log(`selected_year ${e}`);for(let e=0;e<this.field_expiration_month.options.length;e++)parseInt(this.field_expiration_month.options[e].value)<n&&(t?this.field_expiration_month.options[e].setAttribute("disabled","disabled"):this.field_expiration_month.options[e].disabled=!1)}},!this.shouldRun())return;this.setPaymentType(),this.setDefaults(),this.dumpGlobalVar();const e=document.getElementsByName("transaction.ccexpire");e&&(this.field_expiration_month=e[0],this.field_expiration_year=e[1]),this.field_expiration_month&&this.field_expiration_year&&["change"].forEach((e=>{var t,n;null===(t=this.field_expiration_month)||void 0===t||t.addEventListener(e,(()=>{this.handleExpUpdate("month")})),null===(n=this.field_expiration_year)||void 0===n||n.addEventListener(e,(()=>{this.handleExpUpdate("year")}))})),this._form.onValidate.subscribe((()=>{if(this._form.validate){const e=this.validate();this.logger.log(`Form Validation: ${e}`),this._form.validate=e}}))}shouldRun(){return!!this.vgsField}setDefaults(){const e=getComputedStyle(document.body),t={fontFamily:e.getPropertyValue("--input_font-family")||"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'",fontSize:e.getPropertyValue("--input_font-size")||"16px",color:e.getPropertyValue("--input_color")||"#000",padding:e.getPropertyValue("--input_padding")||"10px","&::placeholder":{color:e.getPropertyValue("--input_placeholder-color")||"#a9a9a9",opacity:e.getPropertyValue("--input_placeholder-opacity")||"1",fontWeight:e.getPropertyValue("--input_placeholder-font-weight")||"normal"}},n=this.options,i={"transaction.ccnumber":{showCardIcon:!0,placeholder:"•••• •••• •••• ••••",icons:{cardPlaceholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEwAAABMCAYAAADHl1ErAAAACXBIWXMAABYlAAAWJQFJUiTwAAAB8ElEQVR4nO2c4W3CMBBGz1H/NyNkAzoCo2SDrkI3YJSOABt0g9IJXBnOqUkMyifUqkrek04RlvMjT2c7sc6EGKPBfBpcaSBMBGEiCBNBmAjCRBAmgjARhIkgTARhIggTQZhK2q0Yh5l1ZrYzs0PqsrI4+LN3VTeThkvntUm6Fbuxn2E/LITQmtm7mW08Sb/MbO9tpxhjui6WEMLWzJKDdO3N7Nmf9ZjaYoyn8y8X1o6GXxLV1lJyDeE+9oWPQ/ZRG4b9WkVVpqe+8LLLo7ErM6t248qllZnWBc+uV5+zumGsQjm3f/ic9tb4JGeeXcga4U723rptilVx0avgg2Q3m/JNn+y6zeAm+GSWUi/c7L5yfB77RJhACOHs6WnuLfmGpTI3YditEEGYCMJEECaCMJHZqySvHRfIMBGEiSBMBGEiCBNBmAjCRBAmgjARhIkgTGT2t+R/59EdYXZcfwmEiSBMBGEiCBNZzCr5VzvCZJjIIMxrPKFC6abMsHbaFcZuGq8StqKwDqZkN8emKBbrvawHCtxJ7y1nVxQF34lxUXBupOy8EtWy88jBhknUDjbkPhyd+Xn2l9lHZ8rgcNZVTA5nTYRFjv/dPf7HvzuJ8C0pgjARhIkgTARhIggTQZgIwkQQJoIwEYSJIEwEYQpm9g2Ro5zhLcuLBwAAAABJRU5ErkJggg=="},css:t,autoComplete:"cc-number",validations:["required","validCardNumber"]},"transaction.ccvv":{showCardIcon:!1,placeholder:"CVV",hideValue:!1,autoComplete:"cc-csc",validations:["required","validCardSecurityCode"],css:t},"transaction.ccexpire":{placeholder:"MM/YY",autoComplete:"cc-exp",validations:["required","validCardExpirationDate"],css:t,yearLength:2}};this.options=p.deepMerge(i,n),this.logger.log("Options",this.options)}setPaymentType(){""===p.getPaymentType()&&p.setPaymentType("card")}dumpGlobalVar(){window.enVGSFields=this.options,window.setTimeout((()=>{const e=document.querySelectorAll(".en__field__input--vgs");if(e.length>0){const t=new MutationObserver((e=>{e.forEach((e=>{var t;if("childList"===e.type&&e.addedNodes.length>0&&e.addedNodes.forEach((t=>{"IFRAME"===t.nodeName&&e.previousSibling&&"IFRAME"===e.previousSibling.nodeName&&e.previousSibling.remove()})),"attributes"===e.type&&"class"===e.attributeName){const n=e.target;if(n.classList.contains("vgs-collect-container__valid")){const e=n.closest(".en__field--vgs");null==e||e.classList.remove("en__field--validationFailed"),null===(t=null==e?void 0:e.querySelector(".en__field__error"))||void 0===t||t.remove()}}}))}));e.forEach((e=>{t.observe(e,{childList:!0,attributeFilter:["class"]})})),p.checkNested(window.EngagingNetworks,"require","_defined","enjs","vgs")?window.EngagingNetworks.require._defined.enjs.vgs.init():this.logger.log("VGS is not defined")}}),1e3)}validate(){if("card"===this.paymentTypeField.value.toLowerCase()||"visa"===this.paymentTypeField.value.toLowerCase()||"vi"===this.paymentTypeField.value.toLowerCase()){const e=document.querySelector(".en__field--vgs.en__field--ccnumber"),t=e.querySelector(".vgs-collect-container__empty"),n=document.querySelector(".en__field--vgs.en__field--ccvv"),i=n.querySelector(".vgs-collect-container__empty");if(e&&t)return window.setTimeout((()=>{p.setError(e,"Please enter a valid card number"),e.scrollIntoView({behavior:"smooth"})}),100),!1;if(n&&i)return window.setTimeout((()=>{p.setError(n,"Please enter a valid CVV"),n.scrollIntoView({behavior:"smooth"})}),100),!1}return!0}}class et{constructor(){this.logger=new fe("CountryRedirect","white","brown","🛫"),this._country=b.getInstance(),this.shouldRun()&&(this._country.onCountryChange.subscribe((e=>{this.checkRedirect(e)})),this.checkRedirect(this._country.country))}shouldRun(){return!(!p.getOption("CountryRedirect")||!this._country.countryField)}checkRedirect(e){const t=p.getOption("CountryRedirect");if(t&&e in t&&!1===window.location.href.includes(t[e])){this.logger.log(`${e}: Redirecting to ${t[e]}`);let n=new URL(t[e]);n.search.includes("chain")||(n.search+=(n.search?"&":"?")+"chain"),window.location.href=n.href}}}class tt{constructor(){var e;this.supporterDetails={},this.options=null!==(e=p.getOption("WelcomeBack"))&&void 0!==e&&e,this.rememberMeEvents=f.getInstance(),this.hasRun=!1,this.shouldRun()&&(p.getOption("RememberMe")?(this.rememberMeEvents.onLoad.subscribe((()=>{this.run()})),this.rememberMeEvents.onClear.subscribe((()=>{this.resetWelcomeBack()}))):this.run())}run(){this.hasRun||(this.hasRun=!0,this.supporterDetails={firstName:p.getFieldValue("supporter.firstName"),lastName:p.getFieldValue("supporter.lastName"),emailAddress:p.getFieldValue("supporter.emailAddress"),address1:p.getFieldValue("supporter.address1"),address2:p.getFieldValue("supporter.address2"),city:p.getFieldValue("supporter.city"),region:p.getFieldValue("supporter.region"),postcode:p.getFieldValue("supporter.postcode"),country:p.getFieldValue("supporter.country")},this.addWelcomeBack(),this.addPersonalDetailsSummary(),this.addEventListeners())}shouldRun(){return!!document.querySelector(".fast-personal-details")&&"thank-you-page-donation"!==p.getBodyData("embedded")&&!1!==this.options}addWelcomeBack(){var e;if("object"!=typeof this.options||!this.options.welcomeBackMessage.display)return;const t=this.options.welcomeBackMessage,n=document.createElement("div");n.classList.add("engrid-welcome-back","showif-fast-personal-details");const i=t.title.replace("{firstName}",this.supporterDetails.firstName);n.innerHTML=`<p>\n ${i}\n <span class="engrid-reset-welcome-back">${t.editText}</span>\n </p>`,null===(e=document.querySelector(t.anchor))||void 0===e||e.insertAdjacentElement(t.placement,n)}resetWelcomeBack(){var e;document.querySelectorAll(".fast-personal-details .en__field__input").forEach((e=>{"checkbox"===e.type||"radio"===e.type?e.checked=!1:e.value=""})),this.supporterDetails={},p.setBodyData("hide-fast-personal-details",!1),ne("engrid-autofill","",Object.assign(Object.assign({},e),{expires:-1}))}addPersonalDetailsSummary(){var e;if("object"!=typeof this.options||!this.options.personalDetailsSummary.display)return;let t=this.options.personalDetailsSummary;const n=document.createElement("div");n.classList.add("engrid-personal-details-summary","showif-fast-personal-details"),n.innerHTML=`<h3>${t.title}</h3>`,n.insertAdjacentHTML("beforeend",`\n <p>\n ${this.supporterDetails.firstName} ${this.supporterDetails.lastName}\n <br>\n ${this.supporterDetails.emailAddress}\n </p>\n `),this.supporterDetails.address1&&this.supporterDetails.city&&this.supporterDetails.region&&this.supporterDetails.postcode&&n.insertAdjacentHTML("beforeend",`\n <p>\n ${this.supporterDetails.address1} ${this.supporterDetails.address2}\n <br>\n ${this.supporterDetails.city}, ${this.supporterDetails.region} \n ${this.supporterDetails.postcode}\n </p>\n `),n.insertAdjacentHTML("beforeend",`\n <p class="engrid-welcome-back-clear setattr--data-engrid-hide-fast-personal-details--false">${t.editText}<svg viewbox="0 0 528.899 528.899" xmlns="http://www.w3.org/2000/svg"> <g> <path d="M328.883,89.125l107.59,107.589l-272.34,272.34L56.604,361.465L328.883,89.125z M518.113,63.177l-47.981-47.981 c-18.543-18.543-48.653-18.543-67.259,0l-45.961,45.961l107.59,107.59l53.611-53.611 C532.495,100.753,532.495,77.559,518.113,63.177z M0.3,512.69c-1.958,8.812,5.998,16.708,14.811,14.565l119.891-29.069 L27.473,390.597L0.3,512.69z"></path></g></svg></p>\n `),null===(e=document.querySelector(t.anchor))||void 0===e||e.insertAdjacentElement(t.placement,n)}addEventListeners(){document.querySelectorAll(".engrid-reset-welcome-back").forEach((e=>{e.addEventListener("click",(()=>{this.resetWelcomeBack()}))}))}}const nt={targetName:"",targetEmail:"",hideSendDate:!0,hideTarget:!0,hideMessage:!0,addSupporterNameToMessage:!1};class it{constructor(){this.options=nt,this.logger=new fe("EcardToTarget","DarkBlue","Azure","📧"),this._form=u.getInstance(),this.supporterNameAddedToMessage=!1,this.shouldRun()&&(this.options=Object.assign(Object.assign({},this.options),window.EngridEcardToTarget),this.logger.log("EcardToTarget running. Options:",this.options),this.setTarget(),this.hideElements(),this.addSupporterNameToMessage())}shouldRun(){return window.hasOwnProperty("EngridEcardToTarget")&&"object"==typeof window.EngridEcardToTarget&&window.EngridEcardToTarget.hasOwnProperty("targetName")&&window.EngridEcardToTarget.hasOwnProperty("targetEmail")}setTarget(){const e=document.querySelector(".en__ecardrecipients__name input"),t=document.querySelector(".en__ecardrecipients__email input"),n=document.querySelector(".en__ecarditems__addrecipient");e&&t&&n?(e.value=this.options.targetName,t.value=this.options.targetEmail,null==n||n.click(),this.logger.log("Added recipient",this.options.targetName,this.options.targetEmail)):this.logger.error("Could not add recipient. Required elements not found.")}hideElements(){const e=document.querySelector(".en__ecardmessage"),t=document.querySelector(".en__ecardrecipients__futureDelivery"),n=document.querySelector(".en__ecardrecipients");this.options.hideMessage&&e&&e.classList.add("hide"),this.options.hideSendDate&&t&&t.classList.add("hide"),this.options.hideTarget&&n&&n.classList.add("hide")}addSupporterNameToMessage(){this.options.addSupporterNameToMessage&&this._form.onSubmit.subscribe((()=>{if(this._form.submit&&!this.supporterNameAddedToMessage){this.supporterNameAddedToMessage=!0;const e=`${p.getFieldValue("supporter.firstName")} ${p.getFieldValue("supporter.lastName")}`,t=document.querySelector("[name='transaction.comments']");if(!t)return;t.value=`${t.value}\n${e}`,this.logger.log("Added supporter name to personalized message",e)}}))}}const st={pageUrl:"",headerText:"Send an Ecard notification of your gift",checkboxText:"Yes, I would like to send an ecard to announce my gift.",anchor:".en__field--donationAmt",placement:"afterend"};class ot{constructor(){if(this.logger=new fe("Embedded Ecard","#D95D39","#0E1428","📧"),this.options=st,this._form=u.getInstance(),this.isSubmitting=!1,this.onHostPage()){!(!p.checkNested(window.EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")||!window.EngagingNetworks.require._defined.enjs.checkSubmissionFailed())||(sessionStorage.removeItem("engrid-embedded-ecard"),sessionStorage.removeItem("engrid-send-embedded-ecard")),this.options=Object.assign(Object.assign({},st),window.EngridEmbeddedEcard);const e=new URL(this.options.pageUrl);e.searchParams.append("data-engrid-embedded-ecard","true"),this.options.pageUrl=e.href,this.logger.log("Running Embedded Ecard component",this.options),this.embedEcard(),this.addEventListeners()}this.onPostActionPage()&&(p.setBodyData("embedded-ecard-sent","true"),this.submitEcard()),this.onEmbeddedEcardPage()&&this.setupEmbeddedPage()}onHostPage(){return window.hasOwnProperty("EngridEmbeddedEcard")&&"object"==typeof window.EngridEmbeddedEcard&&window.EngridEmbeddedEcard.hasOwnProperty("pageUrl")&&""!==window.EngridEmbeddedEcard.pageUrl}onEmbeddedEcardPage(){return"ECARD"===p.getPageType()&&p.hasBodyData("embedded")}onPostActionPage(){return null!==sessionStorage.getItem("engrid-embedded-ecard")&&null!==sessionStorage.getItem("engrid-send-embedded-ecard")&&!this.onHostPage()&&!this.onEmbeddedEcardPage()}embedEcard(){var e;const t=document.createElement("div");t.classList.add("engrid--embedded-ecard");const n=document.createElement("h3");n.textContent=this.options.headerText,n.classList.add("engrid--embedded-ecard-heading"),t.appendChild(n);const i=document.createElement("div");i.classList.add("pseudo-en-field","en__field","en__field--checkbox","en__field--000000","en__field--embedded-ecard"),i.innerHTML=`\n <div class="en__field__element en__field__element--checkbox">\n <div class="en__field__item">\n <input class="en__field__input en__field__input--checkbox" id="en__field_embedded-ecard" name="engrid.embedded-ecard" type="checkbox" value="Y">\n <label class="en__field__label en__field__label--item" for="en__field_embedded-ecard">${this.options.checkboxText}</label>\n </div>\n </div>`,t.appendChild(i),t.appendChild(this.createIframe(this.options.pageUrl)),null===(e=document.querySelector(this.options.anchor))||void 0===e||e.insertAdjacentElement(this.options.placement,t)}createIframe(e){const t=document.createElement("iframe");return t.src=e,t.setAttribute("src",e),t.setAttribute("width","100%"),t.setAttribute("scrolling","no"),t.setAttribute("frameborder","0"),t.classList.add("engrid-iframe","engrid-iframe--embedded-ecard"),t.style.display="none",t}addEventListeners(){const e=document.querySelector(".engrid-iframe--embedded-ecard"),t=document.getElementById("en__field_embedded-ecard");(null==t?void 0:t.checked)?(null==e||e.setAttribute("style","display: block"),sessionStorage.setItem("engrid-send-embedded-ecard","true")):(null==e||e.setAttribute("style","display: none"),sessionStorage.removeItem("engrid-send-embedded-ecard")),null==t||t.addEventListener("change",(t=>{const n=t.target;(null==n?void 0:n.checked)?(null==e||e.setAttribute("style","display: block"),sessionStorage.setItem("engrid-send-embedded-ecard","true")):(null==e||e.setAttribute("style","display: none"),sessionStorage.removeItem("engrid-send-embedded-ecard"))}))}setEmbeddedEcardSessionData(){let e=document.querySelector("[name='friend.ecard']"),t=document.querySelector("[name='ecard.schedule']"),n=document.querySelector("[name='transaction.comments']");const i=new URL(window.location.href);i.searchParams.has("chain")||i.searchParams.append("chain","");const s={pageUrl:i.href,formData:{ecardVariant:(null==e?void 0:e.value)||"",ecardSendDate:(null==t?void 0:t.value)||"",ecardMessage:(null==n?void 0:n.value)||"",recipients:this.getEcardRecipients()}};sessionStorage.setItem("engrid-embedded-ecard",JSON.stringify(s))}getEcardRecipients(){const e=[],t=document.querySelector(".en__ecarditems__addrecipient");if(!t||0===t.offsetHeight){let t=document.querySelector(".en__ecardrecipients__name > input"),n=document.querySelector(".en__ecardrecipients__email > input");return t&&n&&e.push({name:t.value,email:n.value}),e}const n=document.querySelector(".en__ecardrecipients__list");return null==n||n.querySelectorAll(".en__ecardrecipients__recipient").forEach((t=>{const n=t.querySelector(".ecardrecipient__name"),i=t.querySelector(".ecardrecipient__email");n&&i&&e.push({name:n.value,email:i.value})})),e}setupEmbeddedPage(){let e=document.querySelector("[name='friend.ecard']"),t=document.querySelector("[name='ecard.schedule']"),n=document.querySelector("[name='transaction.comments']"),i=document.querySelector(".en__ecardrecipients__name > input"),s=document.querySelector(".en__ecardrecipients__email > input");[e,t,n,i,s].forEach((e=>{e.addEventListener("input",(()=>{this.isSubmitting||this.setEmbeddedEcardSessionData()}))}));const o=new MutationObserver((e=>{for(let t of e)if("childList"===t.type){if(this.isSubmitting)return;this.setEmbeddedEcardSessionData()}})),r=document.querySelector(".en__ecardrecipients__list");r&&o.observe(r,{childList:!0}),document.querySelectorAll(".en__ecarditems__thumb").forEach((t=>{t.addEventListener("click",(()=>{e.dispatchEvent(new Event("input"))}))})),window.addEventListener("message",(o=>{if(o.origin===location.origin&&o.data.action)switch(this.logger.log("Received post message",o.data),o.data.action){case"submit_form":this.isSubmitting=!0;let r=JSON.parse(sessionStorage.getItem("engrid-embedded-ecard")||"{}");e&&(e.value=r.formData.ecardVariant),t&&(t.value=r.formData.ecardSendDate),n&&(n.value=r.formData.ecardMessage);const a=document.querySelector(".en__ecarditems__addrecipient");r.formData.recipients.forEach((e=>{i.value=e.name,s.value=e.email,null==a||a.click()}));u.getInstance().submitForm(),sessionStorage.removeItem("engrid-embedded-ecard"),sessionStorage.removeItem("engrid-send-embedded-ecard");break;case"set_recipient":i.value=o.data.name,s.value=o.data.email,i.dispatchEvent(new Event("input")),s.dispatchEvent(new Event("input"))}})),this.sendPostMessage("parent","ecard_form_ready")}submitEcard(){var e;const t=JSON.parse(sessionStorage.getItem("engrid-embedded-ecard")||"{}");this.logger.log("Submitting ecard",t);const n=this.createIframe(t.pageUrl);null===(e=document.querySelector(".body-main"))||void 0===e||e.appendChild(n),window.addEventListener("message",(e=>{e.origin===location.origin&&e.data.action&&"ecard_form_ready"===e.data.action&&this.sendPostMessage(n,"submit_form")}))}sendPostMessage(e,t,n={}){var i;const s=Object.assign({action:t},n);"parent"===e?window.parent.postMessage(s,location.origin):null===(i=e.contentWindow)||void 0===i||i.postMessage(s,location.origin)}}class rt{constructor(){if(!this.shouldRun())return;document.querySelector(".en__field--country .en__field__notice")||p.addHtml('<div class="en__field__notice"><em>Note: This action is limited to U.S. addresses.</em></div>',".us-only-form .en__field--country .en__field__element","after");const e=p.getField("supporter.country");e.setAttribute("disabled","disabled");let t="United States";[...e.options].some((e=>"US"===e.value))?t="US":[...e.options].some((e=>"USA"===e.value))&&(t="USA"),p.setFieldValue("supporter.country",t),p.createHiddenInput("supporter.country",t),e.addEventListener("change",(()=>{e.value=t}))}shouldRun(){return!!document.querySelector(".en__component--formblock.us-only-form .en__field--country")}}class at{constructor(){this.logger=new fe("ThankYouPageConditionalContent"),this.shouldRun()&&this.applyShowHideRadioCheckboxesState()}getShowHideRadioCheckboxesState(){var e;try{const t=null!==(e=window.sessionStorage.getItem("engrid_ShowHideRadioCheckboxesState"))&&void 0!==e?e:"";return JSON.parse(t)}catch(e){return[]}}applyShowHideRadioCheckboxesState(){const e=this.getShowHideRadioCheckboxesState();e&&e.forEach((e=>{this.logger.log("Processing TY page conditional content item:",e),p.getPageID()===e.page&&(document.querySelectorAll(`[class*="${e.class}"]`).forEach((e=>{e.classList.add("hide")})),document.querySelectorAll(`.${e.class}${e.value}`).forEach((e=>{e.classList.remove("hide")})))})),this.deleteShowHideRadioCheckboxesState()}deleteShowHideRadioCheckboxesState(){window.sessionStorage.removeItem("engrid_ShowHideRadioCheckboxesState")}shouldRun(){return p.getGiftProcess()}}class lt{constructor(){this.logger=new fe("CheckboxLabel","#00CC95","#2C3E50","✅"),this.checkBoxesLabels=document.querySelectorAll(".checkbox-label"),this.shoudRun()&&(this.logger.log(`Found ${this.checkBoxesLabels.length} custom labels`),this.run())}shoudRun(){return this.checkBoxesLabels.length>0}run(){this.checkBoxesLabels.forEach((e=>{var t;const n=null===(t=e.textContent)||void 0===t?void 0:t.trim(),i=e.nextElementSibling.querySelector("label");i&&n&&(i.textContent=n,e.remove(),this.logger.log(`Set checkbox label to "${n}"`))}))}}class ct{constructor(){this.logger=new fe("OptInLadder","lightgreen","darkgreen","✔"),this._form=u.getInstance(),this.inIframe()?1===p.getPageNumber()?this.runAsChildRegular():this.runAsChildThankYou():this.runAsParent()}runAsParent(){0!==document.querySelectorAll('input[name^="supporter.questions"]').length?(this._form.onSubmit.subscribe((()=>{this.saveOptInsToSessionStorage()})),this.logger.log("Running as Parent"),1===p.getPageNumber()&&sessionStorage.removeItem("engrid.supporter.questions")):this.logger.log("No checkboxes found")}runAsChildRegular(){if(!this.isEmbeddedThankYouPage())return void this.logger.log("Not Embedded on a Thank You Page");const e=document.querySelectorAll(".en__component--copyblock.optin-ladder"),t=document.querySelectorAll(".en__component--formblock.optin-ladder");if(0===e.length&&0===t.length)return void this.logger.log("No optin-ladder elements found");const n=p.getField("supporter.emailAddress");if(!n||!n.value)return this.logger.log("Email field is empty"),void this.hidePage();const i=JSON.parse(sessionStorage.getItem("engrid.supporter.questions")||"{}");let s=0,o=e.length,r=null,a=null;for(let t=0;t<e.length;t++){const n=e[t],o=n.className.match(/optin-ladder-(\d+)/);if(!o)return void this.logger.error(`No optin number found in ${n.innerText.trim()}`);const l=o[1],c=document.querySelector(`.en__component--formblock.optin-ladder:has(.en__field--${l})`);if(c){if("Y"!==i[l]){r=n,a=c,s++;break}n.remove(),c.remove(),s++}else this.logger.log(`No form block found for ${n.innerText.trim()}`),n.remove(),s++}if(!r||!a)return this.logger.log("No optin-ladder elements found"),s=o,this.saveStepToSessionStorage(s,o),void this.hidePage();e.forEach((e=>{e!==r?e.remove():e.style.display="block"})),t.forEach((e=>{e!==a?e.remove():e.style.display="block"})),this.saveStepToSessionStorage(s,o),this._form.onSubmit.subscribe((()=>{this.saveOptInsToSessionStorage(),s++,this.saveStepToSessionStorage(s,o)}))}runAsChildThankYou(){if(!this.isEmbeddedThankYouPage())return void this.logger.log("Not Embedded on a Thank You Page");const e=JSON.parse(sessionStorage.getItem("engrid.optin-ladder")||"{}"),t=e.step||0,n=e.totalSteps||0;if(t<n)return this.logger.log(`Current step ${t} is less than total steps ${n}`),void(window.location.href=this.getFirstPageUrl());this.logger.log(`Current step ${t} is equal to total steps ${n}`),sessionStorage.removeItem("engrid.optin-ladder")}inIframe(){try{return window.self!==window.top}catch(e){return!0}}saveStepToSessionStorage(e,t){sessionStorage.setItem("engrid.optin-ladder",JSON.stringify({step:e,totalSteps:t})),this.logger.log(`Saved step ${e} of ${t} to sessionStorage`)}getFirstPageUrl(){const e=new URL(window.location.href),t=e.pathname.split("/");return t.pop(),t.push("1"),e.origin+t.join("/")+"?chain"}saveOptInsToSessionStorage(){const e=document.querySelectorAll('input[name^="supporter.questions"]');if(0===e.length)return void this.logger.log("No checkboxes found");const t=JSON.parse(sessionStorage.getItem("engrid.supporter.questions")||"{}");e.forEach((e=>{if(e.checked){const n=e.name.split(".")[2];t[n]="Y"}})),sessionStorage.setItem("engrid.supporter.questions",JSON.stringify(t)),this.logger.log(`Saved checkbox values to sessionStorage: ${JSON.stringify(t)}`)}isEmbeddedThankYouPage(){return"thank-you-page-donation"===p.getBodyData("embedded")}hidePage(){const e=document.querySelector("#engrid");e&&e.classList.add("hide")}}const dt="0.20.1";var ut=n(523),ht=n.n(ut);/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&(window.__forceSmoothScrollPolyfill__=!0),ht().polyfill();class pt{constructor(e,t,n){if(!this.isIframe())return;if(this.amount=t,this.frequency=n,this.ipCountry="",this.isDonation=["donation","premiumgift"].includes(window.pageJson.pageType),console.log("DonationLightboxForm: constructor"),this.sections=document.querySelectorAll("form.en__component > .en__component"),pageJson.pageNumber===pageJson.pageCount){this.sendMessage("status","loaded"),this.isDonation&&this.sendMessage("status","celebrate"),this.sendMessage("class","thank-you"),document.querySelector("body").dataset.thankYou="true";const e=new URLSearchParams(window.location.search);if(e.get("name")){let t=document.querySelector("#engrid");if(t){let n=t.innerHTML;n=n.replace("{user_data~First Name}",e.get("name")),n=n.replace("{receipt_data~recurringFrequency}",e.get("frequency")),n=n.replace("{receipt_data~amount}","$"+e.get("amount")),t.innerHTML=n,this.sendMessage("firstname",e.get("name"))}}else{const e=this,t=location.protocol+"//"+location.host+location.pathname+"/pagedata";fetch(t).then((function(e){return e.json()})).then((function(t){t.hasOwnProperty("firstName")&&null!==t.firstName?e.sendMessage("firstname",t.firstName):e.sendMessage("firstname","Friend")})).catch((e=>{console.error("PageData Error:",e)}))}return!1}if(!this.sections.length)return this.sendMessage("error","No sections found"),!1;if(console.log(this.sections),this.isIframe()){if(this.buildSectionNavigation(),this.checkNested(EngagingNetworks,"require","_defined","enjs","checkSubmissionFailed")&&EngagingNetworks.require._defined.enjs.checkSubmissionFailed()&&(console.log("DonationLightboxForm: Submission Failed"),this.validateForm())){const e=document.querySelector("li.en__error");e&&(e.innerHTML.toLowerCase().indexOf("processing")>-1?(this.sendMessage("error","Sorry! There's a problem processing your donation."),this.scrollToElement(document.querySelector(".en__field--ccnumber"))):this.sendMessage("error",e.textContent),(e.innerHTML.toLowerCase().indexOf("payment")>-1||e.innerHTML.toLowerCase().indexOf("account")>-1||e.innerHTML.toLowerCase().indexOf("card")>-1)&&this.scrollToElement(document.querySelector(".en__field--ccnumber")))}document.querySelectorAll("form.en__component input.en__field__input").forEach((e=>{e.addEventListener("focus",(t=>{const n=this.getSectionId(e);setTimeout((()=>{n>0&&this.validateForm(n-1)&&this.scrollToElement(e)}),50)}))}))}let i=document.querySelector(".payment-options");i&&this.clickPaymentOptions(i),this.addTabIndexToLabels(),n.getInstance().onFrequencyChange.subscribe((()=>this.changeSubmitButton())),t.getInstance().onAmountChange.subscribe((()=>this.changeSubmitButton())),this.changeSubmitButton(),this.sendMessage("status","loaded");const s=new URLSearchParams(window.location.search);s.get("color")&&document.body.style.setProperty("--color_primary",s.get("color")),fetch("https://www.cloudflare.com/cdn-cgi/trace").then((e=>e.text())).then((e=>{let t=e.replace(/[\r\n]+/g,'","').replace(/\=+/g,'":"');t='{"'+t.slice(0,t.lastIndexOf('","'))+'"}';const n=JSON.parse(t);this.ipCountry=n.loc,this.canadaOnly(),console.log("Country:",this.ipCountry)}));const o=document.querySelector("#en__field_supporter_country");o&&o.addEventListener("change",(e=>{this.canadaOnly()})),e.watchForError((()=>{if(this.sendMessage("status","loaded"),this.validateForm(!1,!1)){const e=document.querySelector("li.en__error");e&&(e.innerHTML.toLowerCase().indexOf("processing")>-1?(this.sendMessage("error","Sorry! There's a problem processing your donation."),this.scrollToElement(document.querySelector(".en__field--ccnumber"))):this.sendMessage("error",e.textContent),(e.innerHTML.toLowerCase().indexOf("payment")>-1||e.innerHTML.toLowerCase().indexOf("account")>-1||e.innerHTML.toLowerCase().indexOf("card")>-1)&&this.scrollToElement(document.querySelector(".en__field--ccnumber")))}}))}sendMessage(e,t){const n={key:e,value:t};window.parent.postMessage(n,"*")}isIframe(){return window.self!==window.top}buildSectionNavigation(){console.log("DonationLightboxForm: buildSectionNavigation"),this.sections.forEach(((e,t)=>{e.dataset.sectionId=t;const n=document.createElement("div");n.classList.add("section-navigation");const i=document.createElement("div");i.classList.add("section-count");const s=this.sections.length;if(s>1)0==t?n.innerHTML=`\n <button class="section-navigation__next" data-section-id="${t}">\n <span>Let’s Do It!</span>\n <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="none" viewBox="0 0 14 14">\n <path fill="currentColor" d="M7.687 13.313c-.38.38-.995.38-1.374 0-.38-.38-.38-.996 0-1.375L10 8.25H1.1c-.608 0-1.1-.493-1.1-1.1 0-.608.492-1.1 1.1-1.1h9.2L6.313 2.062c-.38-.38-.38-.995 0-1.375s.995-.38 1.374 0L14 7l-6.313 6.313z"/>\n </svg>\n </button>\n `:t==this.sections.length-1?n.innerHTML=`\n <button class="section-navigation__previous" data-section-id="${t}">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">\n <path fill="currentColor" d="M7.214.786c.434-.434 1.138-.434 1.572 0 .433.434.433 1.137 0 1.571L4.57 6.572h10.172c.694 0 1.257.563 1.257 1.257s-.563 1.257-1.257 1.257H4.229l4.557 4.557c.433.434.433 1.137 0 1.571-.434.434-1.138.434-1.572 0L0 8 7.214.786z"/>\n </svg>\n </button>\n <button class="section-navigation__submit" data-section-id="${t}" type="submit" data-label="Give $AMOUNT$FREQUENCY">\n <span>Give Now</span>\n </button>\n `:n.innerHTML=`\n <button class="section-navigation__previous" data-section-id="${t}">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">\n <path fill="currentColor" d="M7.214.786c.434-.434 1.138-.434 1.572 0 .433.434.433 1.137 0 1.571L4.57 6.572h10.172c.694 0 1.257.563 1.257 1.257s-.563 1.257-1.257 1.257H4.229l4.557 4.557c.433.434.433 1.137 0 1.571-.434.434-1.138.434-1.572 0L0 8 7.214.786z"/>\n </svg>\n </button>\n <button class="section-navigation__next" data-section-id="${t}">\n <span>Continue</span>\n <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="none" viewBox="0 0 14 14">\n <path fill="currentColor" d="M7.687 13.313c-.38.38-.995.38-1.374 0-.38-.38-.38-.996 0-1.375L10 8.25H1.1c-.608 0-1.1-.493-1.1-1.1 0-.608.492-1.1 1.1-1.1h9.2L6.313 2.062c-.38-.38-.38-.995 0-1.375s.995-.38 1.374 0L14 7l-6.313 6.313z"/>\n </svg>\n </button>\n `,i.innerHTML=`\n <span class="section-count__current">${t+1}</span> of\n <span class="section-count__total">${s}</span>\n `;else{const e=document.querySelector(".en__submit button")?.innerText||"Submit";n.innerHTML=`\n <button class="section-navigation__submit" data-section-id="${t}" type="submit" data-label="${e}">\n <span>${e}</span>\n </button>\n `}n.querySelector(".section-navigation__previous")?.addEventListener("click",(e=>{e.preventDefault(),this.scrollToSection(t-1)})),n.querySelector(".section-navigation__next")?.addEventListener("click",(e=>{e.preventDefault(),this.validateForm(t)&&this.scrollToSection(t+1)})),n.querySelector(".section-navigation__submit")?.addEventListener("click",(e=>{if(e.preventDefault(),this.validateForm(!1,this.isDonation))if(this.isDonation){this.sendMessage("donationinfo",JSON.stringify({name:document.querySelector("#en__field_supporter_firstName").value,amount:EngagingNetworks.require._defined.enjs.getDonationTotal(),frequency:this.frequency.getInstance().frequency}));if("paypal"!=document.querySelector("#en__field_transaction_paymenttype").value)this.sendMessage("status","loading");else{const e=this;document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?e.sendMessage("status","submitted"):e.sendMessage("status","loading")})),document.querySelector("form.en__component").target="_blank"}this.checkNested(window.EngagingNetworks,"require","_defined","enDefaults","validation","_getSubmitPromise")?window.EngagingNetworks.require._defined.enDefaults.validation._getSubmitPromise().then((function(){document.querySelector("form.en__component").submit()})):document.querySelector("form.en__component").requestSubmit()}else this.sendMessage("status","loading"),document.querySelector("form.en__component").requestSubmit()})),e.querySelector(".en__component").append(n),e.querySelector(".en__component").append(i)}))}scrollToSection(e){console.log("DonationLightboxForm: scrollToSection",e);const t=document.querySelector(`[data-section-id="${e}"]`);this.sections[e]&&(console.log(t),this.sections[e].scrollIntoView({behavior:"smooth"}))}scrollToElement(e){if(e){const t=this.getSectionId(e);t&&this.scrollToSection(t)}}getSectionId(e){return e&&parseInt(e.closest("[data-section-id]").dataset.sectionId)||!1}validateForm(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=document.querySelector("form.en__component"),i=n.querySelector("[name='transaction.recurrfreq']:checked"),s=n.querySelector(".en__field--recurrfreq"),o=this.getSectionId(s);if(!1===e||e==o){if(!i||!i.value)return this.scrollToElement(n.querySelector("[name='transaction.recurrfreq']:checked")),this.sendMessage("error","Please select a frequency"),s&&s.classList.add("has-error"),!1;s&&s.classList.remove("has-error")}const r=EngagingNetworks.require._defined.enjs.getDonationTotal(),a=n.querySelector(".en__field--donationAmt"),l=this.getSectionId(a);if(!1===e||e==l){if(!r||r<=0)return this.scrollToElement(a),this.sendMessage("error","Please enter a valid amount"),a&&a.classList.add("has-error"),!1;if(r<5)return this.sendMessage("error","Amount must be at least $5 - Contact us for assistance"),a&&a.classList.add("has-error"),!1;a&&a.classList.remove("has-error")}const c=n.querySelector("#en__field_transaction_paymenttype"),d=n.querySelector("#en__field_transaction_ccnumber"),u=n.querySelector(".en__field--ccnumber"),h=this.getSectionId(u),p=["paypal","paypaltouch","stripedigitalwallet"].includes(c.value);if(console.log("DonationLightboxForm: validateForm",u,h),!p&&(!1===e||e==h)&&t){if(!c||!c.value)return this.scrollToElement(c),this.sendMessage("error","Please add your credit card information"),u&&u.classList.add("has-error"),!1;if(!(d instanceof HTMLInputElement?!!d.value:d.classList.contains("vgs-collect-container__valid")))return this.scrollToElement(d),this.sendMessage("error","Please enter a valid credit card number"),u&&u.classList.add("has-error"),!1;u&&u.classList.remove("has-error");const e=n.querySelectorAll("[name='transaction.ccexpire']"),t=n.querySelector(".en__field--ccexpire");let i=!0;if(e.forEach((e=>{if(!e.value)return this.scrollToElement(t),this.sendMessage("error","Please enter a valid expiration date"),t&&t.classList.add("has-error"),i=!1,!1})),!i&&t)return!1;t&&t.classList.remove("has-error");const s=n.querySelector("#en__field_transaction_ccvv"),o=n.querySelector(".en__field--ccvv");if(!(s instanceof HTMLInputElement?!!s.value:s.classList.contains("vgs-collect-container__valid")))return this.scrollToElement(s),this.sendMessage("error","Please enter a valid CVV"),o&&o.classList.add("has-error"),!1;o&&o.classList.remove("has-error")}const g=n.querySelectorAll(".en__mandatory:not(.en__hidden)");let m=!1;if(g.forEach((t=>{if(m)return;const n=t.querySelector(".en__field__input"),i=t.querySelector(".en__field__label"),s=this.getSectionId(n);if(!1===e||e==s){if(!n.value)return this.scrollToElement(n),this.sendMessage("error","Please enter "+i.textContent.toLowerCase()),t.classList.add("has-error"),m=!0,!1;if(t.classList.remove("has-error"),"supporter.emailAddress"===n.name&&!1===/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n.value))return this.scrollToElement(n),this.sendMessage("error","Please enter a valid email address"),t.classList.add("has-error"),m=!0,!1}})),m)return!1;const f=n.querySelector("#en__field_supporter_city"),b=n.querySelector(".en__field--city");if(!this.checkCharsLimit("#en__field_supporter_city",100))return this.scrollToElement(f),this.sendMessage("error","This field only allows up to 100 characters"),b&&b.classList.add("has-error"),!1;b&&b.classList.remove("has-error");const v=n.querySelector("#en__field_supporter_address1"),y=n.querySelector(".en__field--address1");if(!this.checkCharsLimit("#en__field_supporter_address1",35))return this.scrollToElement(v),this.sendMessage("error","This field only allows up to 35 characters. Longer street addresses can be broken up between Lines 1 and 2."),y&&y.classList.add("has-error"),!1;y&&y.classList.remove("has-error");const _=n.querySelector("#en__field_supporter_address2"),S=n.querySelector(".en__field--address2");if(!this.checkCharsLimit("#en__field_supporter_address2",35))return this.scrollToElement(_),this.sendMessage("error","This field only allows up to 35 characters. Longer street addresses can be broken up between Lines 1 and 2."),S&&S.classList.add("has-error"),!1;S&&S.classList.remove("has-error");const w=n.querySelector("#en__field_supporter_postcode"),E=n.querySelector(".en__field--postcode");if(!this.checkCharsLimit("#en__field_supporter_postcode",20))return this.scrollToElement(w),this.sendMessage("error","This field only allows up to 20 characters"),E&&E.classList.add("has-error"),!1;E&&E.classList.remove("has-error");const A=n.querySelector("#en__field_supporter_firstName"),L=n.querySelector(".en__field--firstName");if(!this.checkCharsLimit("#en__field_supporter_firstName",100))return this.scrollToElement(A),this.sendMessage("error","This field only allows up to 100 characters"),L&&L.classList.add("has-error"),!1;L&&L.classList.remove("has-error");const C=n.querySelector("#en__field_supporter_lastName"),k=n.querySelector(".en__field--lastName");return this.checkCharsLimit("#en__field_supporter_lastName",100)?(k&&k.classList.remove("has-error"),console.log("DonationLightboxForm: validateForm PASSED"),!0):(this.scrollToElement(C),this.sendMessage("error","This field only allows up to 100 characters"),k&&k.classList.add("has-error"),!1)}checkCharsLimit(e,t){const n=document.querySelector(e);return!(n&&n.value.length>t)}changeSubmitButton(){const e=document.querySelector(".section-navigation__submit"),t=this.checkNested(window.EngagingNetworks,"require","_defined","enjs","getDonationTotal")?"$"+window.EngagingNetworks.require._defined.enjs.getDonationTotal():null;let n=this.frequency.getInstance().frequency,i=e?e.dataset.label:"";n="onetime"===n?"":"<small>/mo</small>",t?(i=i.replace("$AMOUNT",t),i=i.replace("$FREQUENCY",n)):(i=i.replace("$AMOUNT",""),i=i.replace("$FREQUENCY","")),e&&i&&(e.innerHTML=`<span>${i}</span>`)}clickPaymentOptions(e){e.querySelectorAll("button").forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault();const n=document.querySelector("#en__field_transaction_paymenttype");n&&(n.value=e.className.substr(15),this.scrollToSection(parseInt(e.closest("[data-section-id]").dataset.sectionId)+1))}))}))}isCanada(){const e=document.querySelector("#en__field_supporter_country");if(e&&"CA"===e.value)return!0;return"en-CA"===(window.navigator.userLanguage||window.navigator.language)||"CA"===this.ipCountry}canadaOnly(){const e=document.querySelectorAll(".canada-only");e.length&&(this.isCanada()?e.forEach((e=>{e.style.display="";const t=e.querySelectorAll("input[type='checkbox']");t.length&&t.forEach((e=>{e.checked=!1}))})):e.forEach((e=>{e.style.display="none";const t=e.querySelectorAll("input[type='checkbox']");t.length&&t.forEach((e=>{e.checked=!0}))})))}checkNested(e,t){if(void 0===e)return!1;for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return!(0!=i.length||!e.hasOwnProperty(t))||this.checkNested(e[t],...i)}addTabIndexToLabels(){document.querySelectorAll(".en__field__label.en__field__label--item").forEach((e=>{e.tabIndex=0}))}}var gt=n(3861);function mt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class ft{constructor(){mt(this,"logger",new fe("AddDAF","lightgray","darkblue","🪙")),mt(this,"donorAdvisedFundButtonContainer",document.getElementById("en__digitalWallet__chariot__container")),this.shouldRun()&&(this.donorAdvisedFundButtonContainer?.querySelector("*")?this.addDAF():this.checkForDafBeingAdded())}shouldRun(){return!!this.donorAdvisedFundButtonContainer}checkForDafBeingAdded(){const e=document.getElementById("en__digitalWallet__chariot__container");if(!e)return void this.logger.log("No DAF container found");new MutationObserver(((e,t)=>{for(const n of e)"childList"===n.type&&n.addedNodes.length&&(this.addDAF(),t.disconnect())})).observe(e,{childList:!0,subtree:!0})}addDAF(){if(document.querySelector("input[name='transaction.giveBySelect'][value='daf']"))return void this.logger.log("DAF already added");this.logger.log("Adding DAF");const e=document.querySelector(".give-by-select .en__field__element--radio");if(!e)return void this.logger.log("No giveBySelectWrapper found");const t='\n \x3c!-- DAF (added dynamically) --\x3e\n <div class="en__field__item en__field--giveBySelect give-by-select pseudo-en-field showif-daf-available recurring-frequency-y-hide daf">\n <input class="en__field__input en__field__input--radio" id="en__field_transaction_giveBySelectDAF" name="transaction.giveBySelect" type="radio" value="daf">\n <label class="en__field__label en__field__label--item" for="en__field_transaction_giveBySelectDAF">\n <img alt="DAF Logo" class="daf-logo" src="https://acb0a5d73b67fccd4bbe-c2d8138f0ea10a18dd4c43ec3aa4240a.ssl.cf5.rackcdn.com/10042/daf-logo.png">\n </label>\n </div>\n ',n=document.querySelector(".en__field__item.card");n?n.insertAdjacentHTML("beforebegin",t):e.insertAdjacentHTML("beforeend",t);const i=document.querySelector(".en__component--premiumgiftblock");i&&i.classList.add("hideif-daf-selected"),new X("transaction.giveBySelect","giveBySelect-"),this.logger.log("DAF added");const s=document.querySelector("input[name='transaction.giveBySelect'][value='daf']");s?s.addEventListener("change",(()=>{this.logger.log("Payment DAF selected"),p.setPaymentType("daf")})):this.logger.log("Somehow DAF was not added")}}const bt={applePay:!1,AutoYear:!0,CapitalizeFields:!0,ClickToExpand:!0,CurrencySymbol:"$",CurrencyCode:"USD",DecimalSeparator:".",ThousandsSeparator:",",MinAmount:5,MaxAmount:1e5,MinAmountMessage:"Amount must be at least $5 - Contact us for assistance",MaxAmountMessage:"Amount must be less than $100,000 - Contact us for assistance",MediaAttribution:!0,SkipToMainContentLink:!0,SrcDefer:!0,ProgressBar:!0,TidyContact:{cid:"659b7129-73d0-4601-af4c-8942c4730f65",us_zip_divider:"+",record_field:"supporter.NOT_TAGGED_41",date_field:"supporter.NOT_TAGGED_39",status_field:"supporter.NOT_TAGGED_40",countries:["us"],phone_enable:!0,phone_preferred_countries:["us","ca","gb","jp","au"],phone_record_field:"supporter.NOT_TAGGED_45",phone_date_field:"supporter.NOT_TAGGED_44",phone_status_field:"supporter.NOT_TAGGED_43"},RememberMe:{checked:!0,remoteUrl:"https://www.ran.org/wp-content/themes/ran-2020/data-remember.html",fieldOptInSelectorTarget:"div.en__field--postcode, div.en__field--telephone, div.en__field--email, div.en__field--lastName",fieldOptInSelectorTargetLocation:"after",fieldClearSelectorTarget:"div.en__field--firstName div, div.en__field--email div",fieldClearSelectorTargetLocation:"after",fieldNames:["supporter.firstName","supporter.lastName","supporter.address1","supporter.address2","supporter.city","supporter.country","supporter.region","supporter.postcode","supporter.emailAddress"]},Plaid:!0,Debug:"true"==v.getUrlParameter("debug"),WelcomeBack:{welcomeBackMessage:{display:!0,title:"Welcome back, {firstName}!",editText:"Not you?",anchor:".body-main",placement:"afterbegin"},personalDetailsSummary:{display:!0,title:"Personal Information",editText:"Change",anchor:".fast-personal-details",placement:"beforebegin"}},VGS:{"transaction.ccnumber":{css:{"@font-face":{"font-family":"HarmoniaSansPro","font-style":"normal","font-weight":"400","font-display":"swap",src:'local("HarmoniaSansPro"), local("HarmoniaSansPro-Regular"), url("https://acb0a5d73b67fccd4bbe-c2d8138f0ea10a18dd4c43ec3aa4240a.ssl.cf5.rackcdn.com/10042/HarmoniaSansProRegular.woff2") format("woff2");'}}},"transaction.ccvv":{css:{"@font-face":{"font-family":"HarmoniaSansPro","font-style":"normal","font-weight":"400","font-display":"swap",src:'local("HarmoniaSansPro"), local("HarmoniaSansPro-Regular"), url("https://acb0a5d73b67fccd4bbe-c2d8138f0ea10a18dd4c43ec3aa4240a.ssl.cf5.rackcdn.com/10042/HarmoniaSansProRegular.woff2") format("woff2");'}}}},onLoad:()=>{window.DonationLightboxForm=pt,new pt(v,h,g),function(e,t){if(e.log("ENGrid client scripts are executing"),e.getPageNumber()===e.getPageCount()||document.referrer.includes("act.ran.org")){const e=document.createElement("iframe");e.src="https://act.ran.org/page/51899/data/1?chain",e.style.width="0",e.style.height="0",e.style.visibility="hidden",e.style.display="none",e.width="0",e.height="0",e.name="cohortIframe",e.visibility="hidden";const t=document.querySelector("#endgrid, form");t&&t.appendChild(e)}let n=document.querySelectorAll(".radio-to-buttons_donationAmt .en__field--radio.en__field--donationAmt .en__field__input--other")[0];n&&(n.placeholder="Custom Amount");let i=document.querySelectorAll("input#en__field_supporter_phoneNumber")[0];i&&(i.placeholder="000-000-0000 (optional)");const s=document.querySelector(".media-with-attribution figattribution");if(s){const e=s._tippy;e&&e.setProps({allowHTML:!0,theme:"RAN",placement:"right-end"})}document.body.removeAttribute("data-engrid-errors");const o=document.querySelector('[name="transaction.paymenttype"] [value="ACH"]');o&&(o.value="ach");const r=document.querySelector(".en__submit");if(r&&r.classList.add("hideif-stripedigitalwallet-selected","hideif-paypaltouch-selected"),"UNSUBSCRIBE"===e.getPageType()){const n=document.querySelector(".en__submit button"),i=e.getField("supporter.questions.341509"),s=e.getField("supporter.questions.102600"),o=e.getFieldValue("supporter.emailAddress");if(o){e.getField("supporter.emailAddress").setAttribute("readonly","true");const t=document.createElement("a");t.href=window.location.href.split("?")[0]+"?redirect=cold",t.innerText=`Not ${o}?`,e.addHtml(t,".en__field--emailAddress","beforeend")}const r=document.querySelector(".fewer-emails-block");i&&i.checked&&r&&(r.style.display="none");const a=document.querySelector(".fewer-emails-block button");a&&a.addEventListener("click",(()=>{i.checked=!0,s.checked=!1,e.enParseDependencies(),n.click()}));const l=document.querySelector(".sub-emails-block button");l&&l.addEventListener("click",(()=>{i.checked=!1,s.checked=!0,e.enParseDependencies(),n.click()}));const c=document.querySelector(".unsub-emails-block button");if(c&&c.addEventListener("click",(()=>{i.checked=!1,s.checked=!1,e.enParseDependencies(),n.click()})),t.getInstance().onSubmit.subscribe((()=>{s.checked||sessionStorage.setItem("unsub_details",JSON.stringify({email:e.getFieldValue("supporter.emailAddress")}))})),2===e.getPageNumber()&&JSON.parse(sessionStorage.getItem("unsub_details"))){e.setBodyData("recent-unsubscribe","true");const t=document.querySelector(".resubscribe-block a.button");t&&(t.href=t.href+"?chain&autosubmit=Y&engrid_hide[engrid]=id"),sessionStorage.removeItem("unsub_details")}}const a=document.querySelector("button.en__ecarditems__button.en__ecarditems__addrecipient");a&&(a.innerHTML="Add Recipient");const l=t.getInstance();l.onValidate.subscribe((()=>{if(l.validate)return"DONATION"===e.getPageType()&&["paypaltouch","paypal"].includes(e.getPaymentType())&&"USD"!==e.getCurrencyCode()?(e.addHtml('<div class="en__field__error en__field__error--paypal">PayPal is only available for payments in USD. Please select another payment method or USD.</div>',".dynamic-giving-button"),l.validate=!1,!1):void 0})),function(){const e=document.querySelector(".transaction-fee-opt-in .en__field__element--checkbox");if(!e)return;const t=document.createElement("div");t.classList.add("transaction-fee-tooltip"),t.innerHTML="i",e.appendChild(t),(0,gt.ZP)(t,{content:"By checking this box, you agree to cover the transaction fee for your donation. This small additional amount helps us ensure that 100% of you donation goes directly to RAN.",allowHTML:!0,theme:"white",placement:"top",trigger:"mouseenter click",interactive:!0,arrow:"<div class='custom-tooltip-arrow'></div>",offset:[0,20]})}()}(v,u),new ft,new ct},onResize:()=>console.log("Starter Theme Window Resized"),onValidate:()=>{const e=v.getFieldValue("supporter.country");["us","usa","united states","ca","canada"].includes(e.toLowerCase())||(v.setFieldValue("supporter.region",""),v.log("Region field cleared"))}};new v(bt)})()})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 56cda52..00fb9a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,9 +48,9 @@ } }, "node_modules/@4site/engrid-scripts": { - "version": "0.19.21", - "resolved": "https://registry.npmjs.org/@4site/engrid-scripts/-/engrid-scripts-0.19.21.tgz", - "integrity": "sha512-OdPiWaaS931UEbc9SmUN3F2sa2jpiRvlMjmF1TAjlpKEWSLWkbqzJe21WZHs9O483oCR1jT3cPBP+Pr14KaunQ==", + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@4site/engrid-scripts/-/engrid-scripts-0.20.1.tgz", + "integrity": "sha512-SlDVgv1XfVgSa3OBxQ1WgCWP3qy4Kza6LaFWZeZLolsX+eabZ2NhYJ6GoroY3OQlebZti1ZWv28tpVVA+W1OSQ==", "dev": true, "license": "Unlicense", "dependencies": { @@ -122,9 +122,9 @@ } }, "node_modules/@4site/engrid-styles": { - "version": "0.19.20", - "resolved": "https://registry.npmjs.org/@4site/engrid-styles/-/engrid-styles-0.19.20.tgz", - "integrity": "sha512-r3gjDgv1CZ45X8uxNS5GkmxdtiP0stHAMrhwob/G9rFEl0eHdw9fl2qZbC/bIFcOcQhSWjw6nAk0qIg9j7f2DQ==", + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@4site/engrid-styles/-/engrid-styles-0.20.0.tgz", + "integrity": "sha512-rRR7Naes2bQD5uvI8XgWGDC4Gp4nWhFZZOtlRH///E1alV+BeW8XAH6CkrK/5b6ThZ1amXSgz9ytWRFqaQ0p1g==", "dev": true, "license": "Unlicense", "dependencies": { diff --git a/src/index.ts b/src/index.ts index a3bfb7b..c3b834f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import { DonationAmount, DonationFrequency, EnForm, + OptInLadder, } from "@4site/engrid-scripts"; // Uses ENGrid via NPM // import { // Options, @@ -16,7 +17,6 @@ import "./sass/main.scss"; import DonationLightboxForm from "./scripts/donation-lightbox-form"; import { customScript } from "./scripts/main"; import { AddDAF } from "./scripts/add-daf"; -import { OptInLadder } from "./scripts/optin-ladder"; const options: Options = { applePay: false, diff --git a/src/scripts/optin-ladder.ts b/src/scripts/optin-ladder.ts deleted file mode 100644 index 51a8674..0000000 --- a/src/scripts/optin-ladder.ts +++ /dev/null @@ -1,243 +0,0 @@ -// This component is responsible for showing a ladder of checkboxes, one at a time, to the user. -// If the page is not embedded in an iframe, and there are checkboxes on the page, we will store the checkbox value to sessionStorage upon Form Submit. -// If the page is embedded in an iframe and on a Thank You Page, we will look for .optin-ladder elements, compare the values to sessionStorage, and show the next checkbox in the ladder, removing all but the first. -// If the page is embedded in an iframe and on a Thank You Page, and the child iFrame is also a Thank You Page, we will look for a sessionStorage that has the current ladder step and the total number of steps. -// If the current step is less than the total number of steps, we will redirect to the first page. If the current step is equal to the total number of steps, we will show the Thank You Page. -import { EngridLogger, ENGrid, EnForm } from "@4site/engrid-scripts"; - -export class OptInLadder { - private logger: EngridLogger = new EngridLogger( - "OptInLadder", - "lightgreen", - "darkgreen", - "✔" - ); - private _form: EnForm = EnForm.getInstance(); - - constructor() { - if (!this.inIframe()) { - this.runAsParent(); - } else if (ENGrid.getPageNumber() === 1) { - this.runAsChildRegular(); - } else { - this.runAsChildThankYou(); - } - } - - private runAsParent() { - // Grab all the checkboxes with the name starting with "supporter.questions" - const checkboxes = document.querySelectorAll( - 'input[name^="supporter.questions"]' - ); - if (checkboxes.length === 0) { - this.logger.log("No checkboxes found"); - return; - } - this._form.onSubmit.subscribe(() => { - // Save the checkbox values to sessionStorage - this.saveOptInsToSessionStorage(); - }); - this.logger.log("Running as Parent"); - if (ENGrid.getPageNumber() === 1) { - // Delete supporter.questions from sessionStorage - sessionStorage.removeItem("engrid.supporter.questions"); - } - } - - private runAsChildRegular() { - if (!this.isEmbeddedThankYouPage()) { - this.logger.log("Not Embedded on a Thank You Page"); - return; - } - const optInHeaders = document.querySelectorAll( - ".en__component--copyblock.optin-ladder" - ) as NodeListOf<HTMLElement>; - const optInFormBlocks = document.querySelectorAll( - ".en__component--formblock.optin-ladder" - ) as NodeListOf<HTMLElement>; - if (optInHeaders.length === 0 && optInFormBlocks.length === 0) { - this.logger.log("No optin-ladder elements found"); - return; - } - // Check if the e-mail field exist and is not empty - const emailField = ENGrid.getField( - "supporter.emailAddress" - ) as HTMLInputElement; - if (!emailField || !emailField.value) { - this.logger.log("Email field is empty"); - // Since this is a OptInLadder page with no e-mail address, hide the page - this.hidePage(); - return; - } - const sessionStorageCheckboxValues = JSON.parse( - sessionStorage.getItem("engrid.supporter.questions") || "{}" - ); - let currentStep = 0; - let totalSteps = optInHeaders.length; - let currentHeader: HTMLElement | null = null; - let currentFormBlock: HTMLElement | null = null; - for (let i = 0; i < optInHeaders.length; i++) { - const header = optInHeaders[i] as HTMLElement; - // Get the optin number from the .optin-ladder-XXXX class - const optInNumber = header.className.match(/optin-ladder-(\d+)/); - if (!optInNumber) { - this.logger.error( - `No optin number found in ${header.innerText.trim()}` - ); - return; - } - const optInIndex = optInNumber[1]; - // Get the checkbox FormBlock - const formBlock = document.querySelector( - `.en__component--formblock.optin-ladder:has(.en__field--${optInIndex})` - ); - if (!formBlock) { - this.logger.log(`No form block found for ${header.innerText.trim()}`); - // Remove the header if there is no form block - header.remove(); - // Increment the current step - currentStep++; - continue; - } - // Check if the optInIndex is in sessionStorage - if (sessionStorageCheckboxValues[optInIndex] === "Y") { - // If the checkbox is checked, remove the header and form block - header.remove(); - formBlock.remove(); - // Increment the current step - currentStep++; - continue; - } - // If there's a header and a form block, end the loop - currentHeader = header; - currentFormBlock = formBlock as HTMLElement; - currentStep++; - break; - } - if (!currentHeader || !currentFormBlock) { - this.logger.log("No optin-ladder elements found"); - // Set the current step to the total steps to avoid redirecting to the first page - currentStep = totalSteps; - this.saveStepToSessionStorage(currentStep, totalSteps); - // hide the page - this.hidePage(); - return; - } - // Show the current header and form block, while removing the rest - optInHeaders.forEach((header) => { - if (header !== currentHeader) { - header.remove(); - } else { - header.style.display = "block"; - } - }); - optInFormBlocks.forEach((formBlock) => { - if (formBlock !== currentFormBlock) { - formBlock.remove(); - } else { - formBlock.style.display = "block"; - } - }); - // Save the current step to sessionStorage - this.saveStepToSessionStorage(currentStep, totalSteps); - // On form submit, save the checkbox values to sessionStorage - this._form.onSubmit.subscribe(() => { - this.saveOptInsToSessionStorage(); - - // Save the current step to sessionStorage - currentStep++; - this.saveStepToSessionStorage(currentStep, totalSteps); - }); - } - - private runAsChildThankYou() { - if (!this.isEmbeddedThankYouPage()) { - this.logger.log("Not Embedded on a Thank You Page"); - return; - } - const sessionStorageOptInLadder = JSON.parse( - sessionStorage.getItem("engrid.optin-ladder") || "{}" - ); - const currentStep = sessionStorageOptInLadder.step || 0; - const totalSteps = sessionStorageOptInLadder.totalSteps || 0; - if (currentStep < totalSteps) { - this.logger.log( - `Current step ${currentStep} is less than total steps ${totalSteps}` - ); - // Redirect to the first page - window.location.href = this.getFirstPageUrl(); - return; - } else { - this.logger.log( - `Current step ${currentStep} is equal to total steps ${totalSteps}` - ); - // Remove the session storage - sessionStorage.removeItem("engrid.optin-ladder"); - } - } - - private inIframe() { - try { - return window.self !== window.top; - } catch (e) { - return true; - } - } - - private saveStepToSessionStorage(step: number, totalSteps: number) { - sessionStorage.setItem( - "engrid.optin-ladder", - JSON.stringify({ step, totalSteps }) - ); - this.logger.log(`Saved step ${step} of ${totalSteps} to sessionStorage`); - } - - private getFirstPageUrl() { - // URL Example: https://act.ran.org/page/75744/{alpha}/2 - // We want to change the URL to https://act.ran.org/page/75744/{alpha}/1 - const url = new URL(window.location.href); - const path = url.pathname.split("/"); - path.pop(); - path.push("1"); - return url.origin + path.join("/") + "?chain"; - } - - private saveOptInsToSessionStorage() { - // Grab all the checkboxes with the name starting with "supporter.questions" - const checkboxes = document.querySelectorAll( - 'input[name^="supporter.questions"]' - ); - if (checkboxes.length === 0) { - this.logger.log("No checkboxes found"); - return; - } - const sessionStorageCheckboxValues = JSON.parse( - sessionStorage.getItem("engrid.supporter.questions") || "{}" - ); - // Loop through all the checkboxes and store the value in sessionStorage - (checkboxes as NodeListOf<HTMLInputElement>).forEach((checkbox) => { - if (checkbox.checked) { - const index = checkbox.name.split(".")[2]; - sessionStorageCheckboxValues[index] = "Y"; - } - }); - sessionStorage.setItem( - "engrid.supporter.questions", - JSON.stringify(sessionStorageCheckboxValues) - ); - this.logger.log( - `Saved checkbox values to sessionStorage: ${JSON.stringify( - sessionStorageCheckboxValues - )}` - ); - } - private isEmbeddedThankYouPage() { - return ENGrid.getBodyData("embedded") === "thank-you-page-donation"; - } - private hidePage() { - const engridPage = document.querySelector("#engrid") as HTMLElement; - if (engridPage) { - engridPage.classList.add("hide"); - } - } -}