function initPhoneValidator(){$.validator.addMethod("phone",function(n,t){if(this.optional(t))return!0;var r=$.trim(n).split("").reverse().join(""),u=new RegExp("^(\\d+\\s?(x|\\.txe?)\\s?)?((\\)(\\d+[\\s\\-\\.]?)?\\d+\\(|\\d+)[\\s\\-\\.]?)*(\\)([\\s\\-\\.]?\\d+)?\\d+\\+?\\((?!\\+.*)|\\d+)(\\s?\\+)?$","i"),i=u.exec(r);return i&&i.index===0&&i[0].length===n.length});$.validator.unobtrusive.adapters.addBool("phone")}function InitializeAccountMigration(){var n=document.querySelectorAll(".btnAccountMigration");Array.prototype.forEach.call(n,function(n){n.onclick=function(n){var i,r,t,u,f;n.preventDefault();$.validator.unobtrusive.parse("AccountMigrationForm");i=$("#AccountMigrationForm").valid();i&&($(".btnAccountMigration .save").addClass("hidden"),$(".btnAccountMigration .saving").removeClass("hidden"),$(".btnAccountMigration").attr("disabled","disabled"),r=document.getElementById("txtEmailAddress"),t={},t.EmailAddress=r.value,u="/api/accounts/securityapi/beginaccountprovision",f=fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),f.then(n=>n.json()).then(n=>{var i,t;console.log(n);n.HasErrors&&(i=document.getElementById("divErrorMessage"),i.innerHTML=n.Errors[0],i.classList.remove("hidden"),$(".btnAccountMigration .save").removeClass("hidden"),$(".btnAccountMigration .saving").addClass("hidden"),$(".btnAccountMigration").removeAttr("disabled"));n.IsSuccess&&(t=n.Result.ReturnUrl,(t===null||t===undefined)&&(t=$("#divBeginAccountProvision").attr("data-return-url")),t!==null&&t!==undefined?window.location.href=t:window.location.reload())}))}})}function InitializeEditAddressForm(){var f=document.querySelectorAll(".btnEditAddressSaveChanges"),n,t,i,r,u;Array.prototype.forEach.call(f,function(n){var t=n.getAttribute("aid"),i=document.getElementById("divAddressList"),r=i.getAttribute("data-qas-enabled"),u=i.getAttribute("data-qas-token");n.onclick=function(n){var r,f,e;n.preventDefault();console.log("aid: "+t);r=document.getElementById("divEditAddressErrorMessage_"+t);console.log(r);r.innerHTML="";r.classList.add("hidden");$(".btnEditAddressSaveChanges .save").addClass("hidden");$(".btnEditAddressSaveChanges .saving").removeClass("hidden");$(".btnEditAddressSaveChanges").attr("disabled","disabled");var o=document.getElementById("txtFirstName_"+t),s=document.getElementById("txtLastName_"+t),h=document.getElementById("txtAddressLine1_"+t),c=document.getElementById("txtAddressLine2_"+t),l=document.getElementById("txtCity_"+t),a=document.getElementById("txtState_"+t),v=document.getElementById("txtPostalCode_"+t),u=document.getElementById("ddlCountries_"+t),i={};i.AddressId=t;i.FirstName=o.value;i.LastName=s.value;i.AddressLine1=h.value;i.AddressLine2=c.value;i.City=l.value;i.State=a.value;i.PostalCode=v.value;i.Country=u.options[u.selectedIndex].text;i.CountryCode=u.value;f="/api/accounts/addressapi/saveaddress";console.log(f);e=fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});e.then(n=>n.json()).then(n=>{if(console.log(n),n.HasErrors){var i=document.getElementById("divEditAddressErrorMessage_"+t);i.innerHTML=n.Errors[0];i.classList.remove("hidden");$(".btnEditAddressSaveChanges .save").removeClass("hidden");$(".btnEditAddressSaveChanges .saving").addClass("hidden");$(".btnEditAddressSaveChanges").removeAttr("disabled")}n.IsSuccess&&window.location.reload()})}});n=document.querySelectorAll(".btnEditOpen");Array.prototype.forEach.call(n,function(n){var t=n.getAttribute("aid"),i=document.getElementById("divAddressList"),r=i.getAttribute("data-qas-enabled"),u=i.getAttribute("data-qas-token");n.onclick=function(n){n.preventDefault();console.log("This is test");var f=$("select[id='ddlCountries_"+t+"']").val(),i=[],e=GetStates(f,t).done(function(n){var e,o,s,f,h;console.log(n);e=n.States;for(o in e)e.hasOwnProperty(o)&&(s={},s.StateCode=o,s.State=e[o],i.push(s));f="#ddlStates_"+t;h="#txtState_"+t;i.length>0?(PopluateStates(i,f),$(f).removeClass("hidden"),$(h).addClass("hidden"),$(f).val($(h).val()),InitializeQaSForEdit(u,r,t)):($(h).removeClass("hidden"),$(f).addClass("hidden"),$(f).empty(),InitializeQaSForEditState(u,r,t))})}});t=document.querySelectorAll(".btnNewAddress");Array.prototype.forEach.call(t,function(n){var t=document.getElementById("divAddressList"),i=t.getAttribute("data-qas-enabled"),r=t.getAttribute("data-qas-token");InitializeQaSForNew(r,i);n.onclick=function(n){var i,u,f;n.preventDefault();i=document.getElementById("divNewAddressErrorMessage");console.log(i);i.innerHTML="";i.classList.add("hidden");$(".btnNewAddress .save").addClass("hidden");$(".btnNewAddress .saving").removeClass("hidden");$(".btnNewAddress").attr("disabled","disabled");var e=document.getElementById("txtFirstName"),o=document.getElementById("txtLastName"),s=document.getElementById("txtAddressLine1"),h=document.getElementById("txtAddressLine2"),c=document.getElementById("txtCity"),l=document.getElementById("txtState"),a=document.getElementById("txtPostalCode"),r=document.getElementById("ddlCountries"),t={};t.FirstName=e.value;t.LastName=o.value;t.AddressLine1=s.value;t.AddressLine2=h.value;t.City=c.value;t.State=l.value;t.PostalCode=a.value;t.Country=r.options[r.selectedIndex].text;t.CountryCode=r.value;t.AddressType="Mailing";u="/api/accounts/addressapi/saveaddress";console.log(u);f=fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});f.then(n=>n.json()).then(n=>{if(console.log(n),n.HasErrors){var t=document.getElementById("divNewAddressErrorMessage");t.innerHTML=n.Errors[0];t.classList.remove("hidden");$(".btnNewAddress .save").removeClass("hidden");$(".btnNewAddress .saving").addClass("hidden");$(".btnNewAddress").removeAttr("disabled")}n.IsSuccess&&window.location.reload()})}});i=document.querySelectorAll(".btnNewOpen");Array.prototype.forEach.call(i,function(n){var t=document.getElementById("divAddressList"),i=t.getAttribute("data-qas-enabled"),r=t.getAttribute("data-qas-token");n.onclick=function(n){n.preventDefault();var i=$("#ddlCountries").val(),t=[],r=GetStates(i,null).done(function(n){var r,u,f,i,e;console.log(n);r=n.States;for(u in r)r.hasOwnProperty(u)&&(f={},f.StateCode=u,f.State=r[u],t.push(f));i="#ddlStates";e="#txtState";console.log(t.length);t.length>0?(PopluateStates(t,i),$(i).removeClass("hidden"),$(e).addClass("hidden"),$(i).val($(e).val())):($(e).removeClass("hidden"),$(i).addClass("hidden"),$(i).empty())})}});r=document.querySelectorAll(".btnRemoveAddress");Array.prototype.forEach.call(r,function(n){n.onclick=function(t){var i,r,u,f,e;t.preventDefault();i=n.getAttribute("aid");console.log("aid: "+i);r=document.getElementById("divRemoveAddressErrorMessage_"+i);console.log(r);r.innerHTML="";r.classList.add("hidden");$(".btnRemoveAddress .save").addClass("hidden");$(".btnRemoveAddress .saving").removeClass("hidden");$(".btnRemoveAddress").attr("disabled","disabled");u={};u.AddressId=i;f="/api/accounts/addressapi/removeaddress";console.log(f);e=fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});e.then(n=>n.json()).then(n=>{if(console.log(n),n.HasErrors){var t=document.getElementById("divRemoveAddressErrorMessage_"+i);t.innerHTML=n.Errors[0];t.classList.remove("hidden");$(".btnRemoveAddress .save").removeClass("hidden");$(".btnRemoveAddress .saving").addClass("hidden");$(".btnRemoveAddress").removeAttr("disabled")}n.IsSuccess&&window.location.reload()})}});u=document.querySelectorAll(".btnDefaultAddress");Array.prototype.forEach.call(u,function(n){n.onclick=function(t){var i,r,u,f,e;t.preventDefault();i=n.getAttribute("aid");console.log("aid: "+i);r=document.getElementById("divDefaultAddressErrorMessage_"+i);console.log(r);r.innerHTML="";r.classList.add("hidden");$(".btnDefaultAddress .save").addClass("hidden");$(".btnDefaultAddress .saving").removeClass("hidden");$(".btnDefaultAddress").attr("disabled","disabled");u={};u.AddressId=i;f="/api/accounts/addressapi/defaultaddress";console.log(f);e=fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});e.then(n=>n.json()).then(n=>{if(console.log(n),n.HasErrors){var t=document.getElementById("divDefaultAddressErrorMessage_"+i);t.innerHTML=n.Errors[0];t.classList.remove("hidden");$(".btnDefaultAddress .save").removeClass("hidden");$(".btnDefaultAddress .saving").addClass("hidden");$(".btnDefaultAddress").removeAttr("disabled")}n.IsSuccess&&window.location.reload()})}});$(".ddlCountries").each(function(){$(this).change(function(){var n=$(this).attr("aid"),f=$(this).val(),i=document.getElementById("divAddressList"),r=i.getAttribute("data-qas-enabled"),u=i.getAttribute("data-qas-token"),t=[],e=GetStates(f,n).done(function(i){var s=i.States,e,o,f,h;for(e in s)s.hasOwnProperty(e)&&(o={},o.StateCode=e,o.State=s[e],t.push(o));f="#ddlStates_"+n;h="#txtState_"+n;console.log(t.length);t.length>0?(PopluateStates(t,f),$(f).removeClass("hidden"),$(h).addClass("hidden"),InitializeQaSForEdit(u,r,n)):($(h).removeClass("hidden"),$(f).addClass("hidden"),$(f).empty(),InitializeQaSForEditState(u,r,n))})})});$("#ddlCountries").change(function(){var u=$(this).val(),t=document.getElementById("divAddressList"),i=t.getAttribute("data-qas-enabled"),r=t.getAttribute("data-qas-token"),n=[],f=GetStates(u,null).done(function(t){var o=t.States,f,e,u,s;for(f in o)o.hasOwnProperty(f)&&(e={},e.StateCode=f,e.State=o[f],n.push(e));u="#ddlStates";s="#txtState";console.log(n.length);n.length>0?(PopluateStates(n,u),$(u).removeClass("hidden"),$(s).addClass("hidden"),InitializeQaSForNew(r,i)):($(s).removeClass("hidden"),$(u).addClass("hidden"),$(u).empty(),InitializeQaSForNewState(r,i))})});$(".ddlStates").change(function(){var n=$(this).attr("aid"),t=$(this).val(),r,i;console.log("State Changes");console.log(t);r="#ddlStates_"+n;i="#txtState_"+n;$(i).val(t)});$("#ddlStates").change(function(){var n=$(this).val();$("#txtState").val(n)})}function InitializeQaSForEdit(n,t,i){if(t==="True"){var r={token:n,elements:{input:document.querySelector("input[id='txtAddressLine1_"+i+"']"),countryList:document.querySelector("select[id='ddlCountries_"+i+"']"),countryCodeMapping:{AF:"AFG",AX:"ALA",AL:"ALB",DZ:"DZA",AS:"ASM",AD:"AND",AO:"AGO",AI:"AIA",AQ:"ATA",AG:"ATG",AR:"ARG",AM:"ARM",AW:"ABW",AU:"AUS",AT:"AUT",AZ:"AZE",BS:"BHS",BH:"BHR",BD:"BGD",BB:"BRB",BY:"BLR",BE:"BEL",BZ:"BLZ",BJ:"BEN",BM:"BMU",BT:"BTN",BO:"BOL",BA:"BIH",BW:"BWA",BV:"BVT",BR:"BRA",VG:"VGB",IO:"IOT",BN:"BRN",BG:"BGR",BF:"BFA",BI:"BDI",KH:"KHM",CM:"CMR",CA:"CAN",CV:"CPV",KY:"CYM",CF:"CAF",TD:"TCD",CL:"CHL",CN:"CHN",HK:"HKG",MO:"MAC",CX:"CXR",CC:"CCK",CO:"COL",KM:"COM",CG:"COG",CD:"COD",CK:"COK",CR:"CRI",CI:"CIV",HR:"HRV",CU:"CUB",CY:"CYP",CZ:"CZE",DK:"DNK",DJ:"DJI",DM:"DMA",DO:"DOM",EC:"ECU",EG:"EGY",SV:"SLV",GQ:"GNQ",ER:"ERI",EE:"EST",ET:"ETH",FK:"FLK",FO:"FRO",FJ:"FJI",FI:"FIN",FR:"FRA",GF:"GUF",PF:"PYF",TF:"ATF",GA:"GAB",GM:"GMB",GE:"GEO",DE:"DEU",GH:"GHA",GI:"GIB",GR:"GRC",GL:"GRL",GD:"GRD",GP:"GLP",GU:"GUM",GT:"GTM",GG:"GGY",GN:"GIN",GW:"GNB",GY:"GUY",HT:"HTI",HM:"HMD",VA:"VAT",HN:"HND",HU:"HUN",IS:"ISL",IN:"IND",ID:"IDN",IR:"IRN",IQ:"IRQ",IE:"IRL",IM:"IMN",IL:"ISR",IT:"ITA",JM:"JAM",JP:"JPN",JE:"JEY",JO:"JOR",KZ:"KAZ",KE:"KEN",KI:"KIR",KP:"PRK",KR:"KOR",KW:"KWT",KG:"KGZ",LA:"LAO",LV:"LVA",LB:"LBN",LS:"LSO",LR:"LBR",LY:"LBY",LI:"LIE",LT:"LTU",LU:"LUX",MK:"MKD",MG:"MDG",MW:"MWI",MY:"MYS",MV:"MDV",ML:"MLI",MT:"MLT",MH:"MHL",MQ:"MTQ",MR:"MRT",MU:"MUS",YT:"MYT",MX:"MEX",FM:"FSM",MD:"MDA",MC:"MCO",MN:"MNG",ME:"MNE",MS:"MSR",MA:"MAR",MZ:"MOZ",MM:"MMR",NA:"NAM",NR:"NRU",NP:"NPL",NL:"NLD",AN:"ANT",NC:"NCL",NZ:"NZL",NI:"NIC",NE:"NER",NG:"NGA",NU:"NIU",NF:"NFK",MP:"MNP",NO:"NOR",OM:"OMN",PK:"PAK",PW:"PLW",PS:"PSE",PA:"PAN",PG:"PNG",PY:"PRY",PE:"PER",PH:"PHL",PN:"PCN",PL:"POL",PT:"PRT",PR:"PRI",QA:"QAT",RE:"REU",RO:"ROU",RU:"RUS",RW:"RWA",BL:"BLM",SH:"SHN",KN:"KNA",LC:"LCA",MF:"MAF",PM:"SPM",VC:"VCT",WS:"WSM",SM:"SMR",ST:"STP",SA:"SAU",SN:"SEN",RS:"SRB",SC:"SYC",SL:"SLE",SG:"SGP",SK:"SVK",SI:"SVN",SB:"SLB",SO:"SOM",ZA:"ZAF",GS:"SGS",SS:"SSD",ES:"ESP",LK:"LKA",SD:"SDN",SR:"SUR",SJ:"SJM",SZ:"SWZ",SE:"SWE",CH:"CHE",SY:"SYR",TW:"TWN",TJ:"TJK",TZ:"TZA",TH:"THA",TL:"TLS",TG:"TGO",TK:"TKL",TO:"TON",TT:"TTO",TN:"TUN",TR:"TUR",TM:"TKM",TC:"TCA",TV:"TUV",UG:"UGA",UA:"UKR",AE:"ARE",GB:"GBR",US:"USA",UM:"UMI",UY:"URY",UZ:"UZB",VU:"VUT",VE:"VEN",VN:"VNM",VI:"VIR",WF:"WLF",EH:"ESH",YE:"YEM",ZM:"ZMB",ZW:"ZWE",XK:"XKX"},addressLine1:document.querySelector("input[id='txtAddressLine1_"+i+"']"),addressLine2:document.querySelector("input[id='txtAddressLine2_"+i+"']"),addressLine3:document.querySelector("input[id='txtAddressLine3_"+i+"']"),locality:document.querySelector("input[id='txtCity_"+i+"']"),province:document.querySelector("select[id='ddlStates_"+i+"']"),postalCode:document.querySelector("input[id='txtPostalCode_"+i+"']")},applyFocus:!1,formattedAddressContainer:{showHeading:!1}},u=new ContactDataServices.address(r);u.events.on("post-picklist-selection",function(){setTimeout(function(){$("select[id='ddlStates_"+i+"']").change()},400)})}}function InitializeQaSForEditState(n,t,i){if(t==="True")var r={token:n,elements:{input:document.querySelector("input[id='txtAddressLine1_"+i+"']"),countryList:document.querySelector("select[id='ddlCountries_"+i+"']"),countryCodeMapping:{AF:"AFG",AX:"ALA",AL:"ALB",DZ:"DZA",AS:"ASM",AD:"AND",AO:"AGO",AI:"AIA",AQ:"ATA",AG:"ATG",AR:"ARG",AM:"ARM",AW:"ABW",AU:"AUS",AT:"AUT",AZ:"AZE",BS:"BHS",BH:"BHR",BD:"BGD",BB:"BRB",BY:"BLR",BE:"BEL",BZ:"BLZ",BJ:"BEN",BM:"BMU",BT:"BTN",BO:"BOL",BA:"BIH",BW:"BWA",BV:"BVT",BR:"BRA",VG:"VGB",IO:"IOT",BN:"BRN",BG:"BGR",BF:"BFA",BI:"BDI",KH:"KHM",CM:"CMR",CA:"CAN",CV:"CPV",KY:"CYM",CF:"CAF",TD:"TCD",CL:"CHL",CN:"CHN",HK:"HKG",MO:"MAC",CX:"CXR",CC:"CCK",CO:"COL",KM:"COM",CG:"COG",CD:"COD",CK:"COK",CR:"CRI",CI:"CIV",HR:"HRV",CU:"CUB",CY:"CYP",CZ:"CZE",DK:"DNK",DJ:"DJI",DM:"DMA",DO:"DOM",EC:"ECU",EG:"EGY",SV:"SLV",GQ:"GNQ",ER:"ERI",EE:"EST",ET:"ETH",FK:"FLK",FO:"FRO",FJ:"FJI",FI:"FIN",FR:"FRA",GF:"GUF",PF:"PYF",TF:"ATF",GA:"GAB",GM:"GMB",GE:"GEO",DE:"DEU",GH:"GHA",GI:"GIB",GR:"GRC",GL:"GRL",GD:"GRD",GP:"GLP",GU:"GUM",GT:"GTM",GG:"GGY",GN:"GIN",GW:"GNB",GY:"GUY",HT:"HTI",HM:"HMD",VA:"VAT",HN:"HND",HU:"HUN",IS:"ISL",IN:"IND",ID:"IDN",IR:"IRN",IQ:"IRQ",IE:"IRL",IM:"IMN",IL:"ISR",IT:"ITA",JM:"JAM",JP:"JPN",JE:"JEY",JO:"JOR",KZ:"KAZ",KE:"KEN",KI:"KIR",KP:"PRK",KR:"KOR",KW:"KWT",KG:"KGZ",LA:"LAO",LV:"LVA",LB:"LBN",LS:"LSO",LR:"LBR",LY:"LBY",LI:"LIE",LT:"LTU",LU:"LUX",MK:"MKD",MG:"MDG",MW:"MWI",MY:"MYS",MV:"MDV",ML:"MLI",MT:"MLT",MH:"MHL",MQ:"MTQ",MR:"MRT",MU:"MUS",YT:"MYT",MX:"MEX",FM:"FSM",MD:"MDA",MC:"MCO",MN:"MNG",ME:"MNE",MS:"MSR",MA:"MAR",MZ:"MOZ",MM:"MMR",NA:"NAM",NR:"NRU",NP:"NPL",NL:"NLD",AN:"ANT",NC:"NCL",NZ:"NZL",NI:"NIC",NE:"NER",NG:"NGA",NU:"NIU",NF:"NFK",MP:"MNP",NO:"NOR",OM:"OMN",PK:"PAK",PW:"PLW",PS:"PSE",PA:"PAN",PG:"PNG",PY:"PRY",PE:"PER",PH:"PHL",PN:"PCN",PL:"POL",PT:"PRT",PR:"PRI",QA:"QAT",RE:"REU",RO:"ROU",RU:"RUS",RW:"RWA",BL:"BLM",SH:"SHN",KN:"KNA",LC:"LCA",MF:"MAF",PM:"SPM",VC:"VCT",WS:"WSM",SM:"SMR",ST:"STP",SA:"SAU",SN:"SEN",RS:"SRB",SC:"SYC",SL:"SLE",SG:"SGP",SK:"SVK",SI:"SVN",SB:"SLB",SO:"SOM",ZA:"ZAF",GS:"SGS",SS:"SSD",ES:"ESP",LK:"LKA",SD:"SDN",SR:"SUR",SJ:"SJM",SZ:"SWZ",SE:"SWE",CH:"CHE",SY:"SYR",TW:"TWN",TJ:"TJK",TZ:"TZA",TH:"THA",TL:"TLS",TG:"TGO",TK:"TKL",TO:"TON",TT:"TTO",TN:"TUN",TR:"TUR",TM:"TKM",TC:"TCA",TV:"TUV",UG:"UGA",UA:"UKR",AE:"ARE",GB:"GBR",US:"USA",UM:"UMI",UY:"URY",UZ:"UZB",VU:"VUT",VE:"VEN",VN:"VNM",VI:"VIR",WF:"WLF",EH:"ESH",YE:"YEM",ZM:"ZMB",ZW:"ZWE",XK:"XKX"},addressLine1:document.querySelector("input[id='txtAddressLine1_"+i+"']"),addressLine2:document.querySelector("input[id='txtAddressLine2_"+i+"']"),addressLine3:document.querySelector("input[id='txtAddressLine3_"+i+"']"),locality:document.querySelector("input[id='txtCity_"+i+"']"),province:document.querySelector("input[id='txtState_"+i+"']"),postalCode:document.querySelector("input[id='txtPostalCode_"+i+"']")},applyFocus:!1,formattedAddressContainer:{showHeading:!1}},u=new ContactDataServices.address(r)}function InitializeQaSForNew(n,t){if(t==="True"){var i={token:n,elements:{input:document.querySelector("input[id='txtAddressLine1']"),countryList:document.querySelector("select[id='ddlCountries']"),countryCodeMapping:{AF:"AFG",AX:"ALA",AL:"ALB",DZ:"DZA",AS:"ASM",AD:"AND",AO:"AGO",AI:"AIA",AQ:"ATA",AG:"ATG",AR:"ARG",AM:"ARM",AW:"ABW",AU:"AUS",AT:"AUT",AZ:"AZE",BS:"BHS",BH:"BHR",BD:"BGD",BB:"BRB",BY:"BLR",BE:"BEL",BZ:"BLZ",BJ:"BEN",BM:"BMU",BT:"BTN",BO:"BOL",BA:"BIH",BW:"BWA",BV:"BVT",BR:"BRA",VG:"VGB",IO:"IOT",BN:"BRN",BG:"BGR",BF:"BFA",BI:"BDI",KH:"KHM",CM:"CMR",CA:"CAN",CV:"CPV",KY:"CYM",CF:"CAF",TD:"TCD",CL:"CHL",CN:"CHN",HK:"HKG",MO:"MAC",CX:"CXR",CC:"CCK",CO:"COL",KM:"COM",CG:"COG",CD:"COD",CK:"COK",CR:"CRI",CI:"CIV",HR:"HRV",CU:"CUB",CY:"CYP",CZ:"CZE",DK:"DNK",DJ:"DJI",DM:"DMA",DO:"DOM",EC:"ECU",EG:"EGY",SV:"SLV",GQ:"GNQ",ER:"ERI",EE:"EST",ET:"ETH",FK:"FLK",FO:"FRO",FJ:"FJI",FI:"FIN",FR:"FRA",GF:"GUF",PF:"PYF",TF:"ATF",GA:"GAB",GM:"GMB",GE:"GEO",DE:"DEU",GH:"GHA",GI:"GIB",GR:"GRC",GL:"GRL",GD:"GRD",GP:"GLP",GU:"GUM",GT:"GTM",GG:"GGY",GN:"GIN",GW:"GNB",GY:"GUY",HT:"HTI",HM:"HMD",VA:"VAT",HN:"HND",HU:"HUN",IS:"ISL",IN:"IND",ID:"IDN",IR:"IRN",IQ:"IRQ",IE:"IRL",IM:"IMN",IL:"ISR",IT:"ITA",JM:"JAM",JP:"JPN",JE:"JEY",JO:"JOR",KZ:"KAZ",KE:"KEN",KI:"KIR",KP:"PRK",KR:"KOR",KW:"KWT",KG:"KGZ",LA:"LAO",LV:"LVA",LB:"LBN",LS:"LSO",LR:"LBR",LY:"LBY",LI:"LIE",LT:"LTU",LU:"LUX",MK:"MKD",MG:"MDG",MW:"MWI",MY:"MYS",MV:"MDV",ML:"MLI",MT:"MLT",MH:"MHL",MQ:"MTQ",MR:"MRT",MU:"MUS",YT:"MYT",MX:"MEX",FM:"FSM",MD:"MDA",MC:"MCO",MN:"MNG",ME:"MNE",MS:"MSR",MA:"MAR",MZ:"MOZ",MM:"MMR",NA:"NAM",NR:"NRU",NP:"NPL",NL:"NLD",AN:"ANT",NC:"NCL",NZ:"NZL",NI:"NIC",NE:"NER",NG:"NGA",NU:"NIU",NF:"NFK",MP:"MNP",NO:"NOR",OM:"OMN",PK:"PAK",PW:"PLW",PS:"PSE",PA:"PAN",PG:"PNG",PY:"PRY",PE:"PER",PH:"PHL",PN:"PCN",PL:"POL",PT:"PRT",PR:"PRI",QA:"QAT",RE:"REU",RO:"ROU",RU:"RUS",RW:"RWA",BL:"BLM",SH:"SHN",KN:"KNA",LC:"LCA",MF:"MAF",PM:"SPM",VC:"VCT",WS:"WSM",SM:"SMR",ST:"STP",SA:"SAU",SN:"SEN",RS:"SRB",SC:"SYC",SL:"SLE",SG:"SGP",SK:"SVK",SI:"SVN",SB:"SLB",SO:"SOM",ZA:"ZAF",GS:"SGS",SS:"SSD",ES:"ESP",LK:"LKA",SD:"SDN",SR:"SUR",SJ:"SJM",SZ:"SWZ",SE:"SWE",CH:"CHE",SY:"SYR",TW:"TWN",TJ:"TJK",TZ:"TZA",TH:"THA",TL:"TLS",TG:"TGO",TK:"TKL",TO:"TON",TT:"TTO",TN:"TUN",TR:"TUR",TM:"TKM",TC:"TCA",TV:"TUV",UG:"UGA",UA:"UKR",AE:"ARE",GB:"GBR",US:"USA",UM:"UMI",UY:"URY",UZ:"UZB",VU:"VUT",VE:"VEN",VN:"VNM",VI:"VIR",WF:"WLF",EH:"ESH",YE:"YEM",ZM:"ZMB",ZW:"ZWE",XK:"XKX"},addressLine1:document.querySelector("input[id='txtAddressLine1']"),addressLine2:document.querySelector("input[id='txtAddressLine2']"),addressLine3:document.querySelector("input[id='txtAddressLine3']"),locality:document.querySelector("input[id='txtCity']"),province:document.querySelector("select[id='ddlStates']"),postalCode:document.querySelector("input[id='txtPostalCode']")},applyFocus:!1,formattedAddressContainer:{showHeading:!1}},r=new ContactDataServices.address(i);r.events.on("post-picklist-selection",function(){setTimeout(function(){$("#ddlStates").change()},400)})}}function InitializeQaSForNewState(n,t){if(t==="True")var i={token:n,elements:{input:document.querySelector("input[id='txtAddressLine1']"),countryList:document.querySelector("select[id='ddlCountries']"),countryCodeMapping:{AF:"AFG",AX:"ALA",AL:"ALB",DZ:"DZA",AS:"ASM",AD:"AND",AO:"AGO",AI:"AIA",AQ:"ATA",AG:"ATG",AR:"ARG",AM:"ARM",AW:"ABW",AU:"AUS",AT:"AUT",AZ:"AZE",BS:"BHS",BH:"BHR",BD:"BGD",BB:"BRB",BY:"BLR",BE:"BEL",BZ:"BLZ",BJ:"BEN",BM:"BMU",BT:"BTN",BO:"BOL",BA:"BIH",BW:"BWA",BV:"BVT",BR:"BRA",VG:"VGB",IO:"IOT",BN:"BRN",BG:"BGR",BF:"BFA",BI:"BDI",KH:"KHM",CM:"CMR",CA:"CAN",CV:"CPV",KY:"CYM",CF:"CAF",TD:"TCD",CL:"CHL",CN:"CHN",HK:"HKG",MO:"MAC",CX:"CXR",CC:"CCK",CO:"COL",KM:"COM",CG:"COG",CD:"COD",CK:"COK",CR:"CRI",CI:"CIV",HR:"HRV",CU:"CUB",CY:"CYP",CZ:"CZE",DK:"DNK",DJ:"DJI",DM:"DMA",DO:"DOM",EC:"ECU",EG:"EGY",SV:"SLV",GQ:"GNQ",ER:"ERI",EE:"EST",ET:"ETH",FK:"FLK",FO:"FRO",FJ:"FJI",FI:"FIN",FR:"FRA",GF:"GUF",PF:"PYF",TF:"ATF",GA:"GAB",GM:"GMB",GE:"GEO",DE:"DEU",GH:"GHA",GI:"GIB",GR:"GRC",GL:"GRL",GD:"GRD",GP:"GLP",GU:"GUM",GT:"GTM",GG:"GGY",GN:"GIN",GW:"GNB",GY:"GUY",HT:"HTI",HM:"HMD",VA:"VAT",HN:"HND",HU:"HUN",IS:"ISL",IN:"IND",ID:"IDN",IR:"IRN",IQ:"IRQ",IE:"IRL",IM:"IMN",IL:"ISR",IT:"ITA",JM:"JAM",JP:"JPN",JE:"JEY",JO:"JOR",KZ:"KAZ",KE:"KEN",KI:"KIR",KP:"PRK",KR:"KOR",KW:"KWT",KG:"KGZ",LA:"LAO",LV:"LVA",LB:"LBN",LS:"LSO",LR:"LBR",LY:"LBY",LI:"LIE",LT:"LTU",LU:"LUX",MK:"MKD",MG:"MDG",MW:"MWI",MY:"MYS",MV:"MDV",ML:"MLI",MT:"MLT",MH:"MHL",MQ:"MTQ",MR:"MRT",MU:"MUS",YT:"MYT",MX:"MEX",FM:"FSM",MD:"MDA",MC:"MCO",MN:"MNG",ME:"MNE",MS:"MSR",MA:"MAR",MZ:"MOZ",MM:"MMR",NA:"NAM",NR:"NRU",NP:"NPL",NL:"NLD",AN:"ANT",NC:"NCL",NZ:"NZL",NI:"NIC",NE:"NER",NG:"NGA",NU:"NIU",NF:"NFK",MP:"MNP",NO:"NOR",OM:"OMN",PK:"PAK",PW:"PLW",PS:"PSE",PA:"PAN",PG:"PNG",PY:"PRY",PE:"PER",PH:"PHL",PN:"PCN",PL:"POL",PT:"PRT",PR:"PRI",QA:"QAT",RE:"REU",RO:"ROU",RU:"RUS",RW:"RWA",BL:"BLM",SH:"SHN",KN:"KNA",LC:"LCA",MF:"MAF",PM:"SPM",VC:"VCT",WS:"WSM",SM:"SMR",ST:"STP",SA:"SAU",SN:"SEN",RS:"SRB",SC:"SYC",SL:"SLE",SG:"SGP",SK:"SVK",SI:"SVN",SB:"SLB",SO:"SOM",ZA:"ZAF",GS:"SGS",SS:"SSD",ES:"ESP",LK:"LKA",SD:"SDN",SR:"SUR",SJ:"SJM",SZ:"SWZ",SE:"SWE",CH:"CHE",SY:"SYR",TW:"TWN",TJ:"TJK",TZ:"TZA",TH:"THA",TL:"TLS",TG:"TGO",TK:"TKL",TO:"TON",TT:"TTO",TN:"TUN",TR:"TUR",TM:"TKM",TC:"TCA",TV:"TUV",UG:"UGA",UA:"UKR",AE:"ARE",GB:"GBR",US:"USA",UM:"UMI",UY:"URY",UZ:"UZB",VU:"VUT",VE:"VEN",VN:"VNM",VI:"VIR",WF:"WLF",EH:"ESH",YE:"YEM",ZM:"ZMB",ZW:"ZWE",XK:"XKX"},addressLine1:document.querySelector("input[id='txtAddressLine1']"),addressLine2:document.querySelector("input[id='txtAddressLine2']"),addressLine3:document.querySelector("input[id='txtAddressLine3']"),locality:document.querySelector("input[id='txtCity']"),province:document.querySelector("input[id='txtState']"),postalCode:document.querySelector("input[id='txtPostalCode']")},applyFocus:!1,formattedAddressContainer:{showHeading:!1}},r=new ContactDataServices.address(i)}function GetStates(n){var t={};t.countryCode=n;var i=JSON.stringify(t);return $.ajax({type:"POST",contentType:"application/json;charset=utf-8",url:"/api/cxa/JmmSxaAccount/GetStates",data:i,success:function(){},error:function(){}})}function PopluateStates(n,t){$(t).empty();for(var i=0;i<n.length;i++)$(t).append("<option value="+n[i].StateCode+">"+n[i].State+"<\/option>")}function InitializeChangePassword(){var n=document.querySelectorAll(".btnChangePassword");Array.prototype.forEach.call(n,function(n){n.onclick=function(n){var i,r,u;if(n.preventDefault(),$.validator.unobtrusive.parse("ChangePasswordForm"),i=$("#ChangePasswordForm").valid(),i){$(".btnChangePassword .save").addClass("hidden");$(".btnChangePassword .saving").removeClass("hidden");$(".btnChangePassword").attr("disabled","disabled");var f=document.getElementById("txtPassword"),e=document.getElementById("txtConfirmPassword"),t={};t.NewPassword=f.value;t.ConfirmNewPassword=e.value;r="/api/accounts/accountsapi/ChangePassword";u=fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});u.then(n=>n.json()).then(n=>{var i,t;n.HasErrors&&(i=document.getElementById("divChangePasswordErrorMessage"),i.innerHTML=n.Errors[0],i.classList.remove("hidden"),$.modalNoConflict.close(),$(".btnChangePassword .save").removeClass("hidden"),$(".btnChangePassword .saving").addClass("hidden"),$(".btnChangePassword").removeAttr("disabled"));n.IsSuccess&&(t=n.Result.ReturnUrl,t===null||t===undefined,t!==null&&t!==undefined?window.location.href=t:window.location.reload())})}}})}function InitializeEditAccountForm(){var n=document.querySelectorAll(".btnEditProfileSaveChanges");Array.prototype.forEach.call(n,function(n){n.onclick=function(n){var i,r,u;if(n.preventDefault(),$.validator.unobtrusive.parse("PersonalInfoForm"),i=$("#PersonalInfoForm").valid(),console.log("isValid: "+i),i){r=document.getElementById("divEditAccountErrorMessage");r.innerHTML="";r.classList.add("hidden");$(".btnEditProfileSaveChanges .save").addClass("hidden");$(".btnEditProfileSaveChanges .saving").removeClass("hidden");$(".btnEditProfileSaveChanges").attr("disabled","disabled");var s=document.getElementById("txtFirstName"),h=document.getElementById("txtLastName"),c=document.getElementById("txtEmailAddress"),l=document.getElementById("txtPhone"),a=document.getElementById("txtMobilePhone"),f=document.getElementById("txtBirthDate"),e=document.getElementById("ddlWhereIWatchJoyce"),o=document.getElementById("ddlGiftAid"),t={};t.FirstName=s.value;t.LastName=h.value;t.EmailAddress=c.value;t.Phone=l.value;f!=null&&(t.BirthDate=f.value);e!==null&&(t.WhereIWatchJoyce=e.value);t.GivingAid=o!==null?o.value:"none";u="/api/accounts/accountsapi/updateaccount";console.log(u);const n=fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});n.then(n=>n.json()).then(n=>{if(console.log(n),n.HasErrors){var t=document.getElementById("divEditAccountErrorMessage");t.innerHTML=n.Errors[0];t.classList.remove("hidden");$(".btnEditProfileSaveChanges .save").removeClass("hidden");$(".btnEditProfileSaveChanges .saving").addClass("hidden");$(".btnEditProfileSaveChanges").removeAttr("disabled")}n.IsSuccess&&window.location.reload()})}}})}function InitializeForgotPassword(){var n=document.querySelectorAll(".btnForgotPassword");Array.prototype.forEach.call(n,function(n){n.onclick=function(n){var i,r,t,u,f;n.preventDefault();$.validator.unobtrusive.parse("ForgotPasswordForm");i=$("#ForgotPasswordForm").valid();i&&($(".btnForgotPassword .save").addClass("hidden"),$(".btnForgotPassword .saving").removeClass("hidden"),$(".btnForgotPassword").attr("disabled","disabled"),r=document.getElementById("txtEmailAddress"),t={},t.EmailAddress=r.value,u="/api/accounts/securityapi/forgotpassword",f=fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),f.then(n=>n.json()).then(n=>{var i,t;n.HasErrors&&(i=document.getElementById("divErrorMessage"),i.innerHTML=n.Errors[0],i.classList.remove("hidden"),$(".btnForgotPassword .save").removeClass("hidden"),$(".btnForgotPassword .saving").addClass("hidden"),$(".btnForgotPassword").removeAttr("disabled"));n.IsSuccess&&(t=n.Result.ReturnUrl,(t===null||t===undefined)&&(t=$("#divForgotPassword").attr("data-return-url")),t!==null&&t!==undefined?window.location.href=t:window.location.reload())}))}})}function InitializeGivingSummary(){console.log("InitializeGivingSummary");var n=document.getElementById("ddlGivingSummary");n!==null&&n.addEventListener("change",function(){var i=document.getElementById("hrefGivingSummaryView"),r=n.value,t=i.getAttribute("data-url");t=t+r;console.log(t);i.setAttribute("href",t)})}function InitializeLoginForm(){var n=document.querySelectorAll(".btnLogin");Array.prototype.forEach.call(n,function(n){n.onclick=function(n){n.preventDefault();ProcessAccountLogin()}})}function AccountLogin_OnInit(){}function AccountLogin_OnBegin(){}function ProcessAccountLogin(){var r=$("#LoginForm").valid(),t,i;if(r){$("#loadingModal").modalNoConflict({closeExisting:!1,escapeClose:!1,clickClose:!1,showClose:!1});var u=document.getElementById("userNameLoginCommerce"),f=document.getElementById("passwordLoginCommerce"),n={};n.Username=u.value;n.Password=f.value;t="/api/accounts/securityapi/login";console.log(t);i=fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});i.then(n=>n.json()).then(n=>{var i,r,t;console.log(n);n.HasErrors&&(i=document.getElementById("divLoginErrorMessage"),i.innerHTML=n.Errors[0],n.Result!==null?n.Result.MustProvision?(r=n.Result.ReturnUrl,r!==null&&r!==undefined&&(window.location.href=r)):(i.classList.remove("hidden"),$.modalNoConflict.close()):(i.classList.remove("hidden"),$.modalNoConflict.close()));n.IsSuccess&&(t=n.Result.ReturnUrl,console.log(t),(t===null||t===undefined)&&(t=$("#loginCommerce").attr("data-return-url")),t!==null&&t!==undefined?window.location.href=t:window.location.reload())})}}function InitializeLoginFormActiveEvents(){$("#passwordLoginCommerce").keydown(function(n){n.which==13&&(n.preventDefault(),ProcessAccountLogin())})}function InitializePasswordRecovery(){var n=document.querySelectorAll(".btnPasswordRecovery");Array.prototype.forEach.call(n,function(n){n.onclick=function(n){var i,r,u;if(n.preventDefault(),$.validator.unobtrusive.parse("PasswordRecoveryForm"),i=$("#PasswordRecoveryForm").valid(),i){$(".btnPasswordRecovery .save").addClass("hidden");$(".btnPasswordRecovery .saving").removeClass("hidden");$(".btnPasswordRecovery").attr("disabled","disabled");var f=document.getElementById("txtPassword"),e=document.getElementById("txtConfirmPassword"),o=document.getElementById("hfToken"),t={};t.Password=f.value;t.ConfirmPassword=e.value;t.Token=o.value;r="/api/accounts/securityapi/PasswordRecovery";u=fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});u.then(n=>n.json()).then(n=>{var i,t;n.HasErrors&&(i=document.getElementById("divErrorMessage"),i.innerHTML=n.Errors[0],i.classList.remove("hidden"),$.modalNoConflict.close(),$(".btnPasswordRecovery .save").removeClass("hidden"),$(".btnPasswordRecovery .saving").addClass("hidden"),$(".btnPasswordRecovery").removeAttr("disabled"));n.IsSuccess&&(t=n.Result.ReturnUrl,(t===null||t===undefined)&&(t=$("#divPasswordRecovery").attr("data-return-url")),t!==null&&t!==undefined?window.location.href=t:window.location.reload())})}}})}initPhoneValidator();InitializeAccountMigration();InitializeEditAddressForm();InitializeChangePassword();InitializeEditAccountForm();InitializeForgotPassword();InitializeGivingSummary();InitializeLoginForm();InitializeLoginFormActiveEvents();InitializePasswordRecovery()