import{_ as S,c5 as N,bT as I,by as m,ak as T,h as w,A as h,o as r,b as _,s as v,d as f,p as d,a as l,t as b,c as n,l as u,F,x as E,y as V,M as B,N as M,O,q as y,f as P,bY as q,b8 as U,bZ as A,Q as z}from"./BDipKYNj.js";const D={props:{buttonText:{type:String,default:"SIGN UP",required:!0},headerText:{type:String,default:"Sign up for our eNewsletters",required:!0},headerTextColor:{type:String,required:!0},bodyTextColor:{type:String,required:!0},bodyBackgroundColor:{type:String},headerBackgroundColor:{type:String},buttonBackgroundColor:{type:String,required:!0},buttonTextColor:{type:String,required:!0},showDescription:{type:Boolean},noAvailableNlText:{default:"No Available Newsletters",type:String},simpleMode:{type:Boolean,default:!0},recaptchaKey:{type:String}},async setup(e){const{localeFields:o,getCurrentCountry:s}=N({inlineLabels:!0}),c=I(e.recaptchaKey);return{localeFields:o,getCurrentCountry:s,recaptcha:c}},data(){return{userInfo:null,availableNewsletters:[],subscribed:[],message:null,processing:!1,showErrors:!1,error:"",fieldValues:{email:""},fieldValuesCompliance:{},fieldErrors:{},complianceNeeded:!1,fieldInfo:{rows:[{fields:{email:{type:"email_input",placeholder:"Email Address",required:!0,showErrors:!1,icon:!1}}},{fields:{countryCode:this.localeFields.countryCode}}]},fieldInfoCompliance:{rows:[{fields:{compliance:this.localeFields.compliance}}]}}},computed:{textStyle(){return{fontFamily:this.$ss.primaryFontFamily}},emailField(){var e;return(e=this.fieldInfo.rows[0])==null?void 0:e.fields.email},countryCodeField(){var e;return(e=this.fieldInfo.rows[1])==null?void 0:e.fields.countryCode},regionsField(){var e;return(e=this.fieldInfo.rows[2])==null?void 0:e.fields.region},complianceField(){var e;return(e=this.fieldInfoCompliance.rows[0])==null?void 0:e.fields.compliance},omedaSite(){var e;return((e=this.$ss.magazine)==null?void 0:e.nlOmedaSite)??""},omedaQuery(){var e;return((e=this.$ss.magazine)==null?void 0:e.nlSignupQuery)??""}},watch:{fieldValues:{deep:!0,handler(){this.updateFieldInfo()}}},async mounted(){var e;this.userInfo=await m.getUserInfo(),this.subscribed=((e=this.userInfo)==null?void 0:e.newsletters)??[],this.availableNewsletters=this.$ss.newsletters.enabledNewsletters.filter(o=>this.userInfo?!this.subscribed.includes(o.omedaProductId)&&o.showInSubscribeBlock:o.showInSubscribeBlock)},methods:{update(e,o,s){this.fieldValues[e]=o,this.fieldErrors[e]={errorObj:s}},updateFieldInfo(){const e=this.getCurrentCountry(this.fieldValues.countryCode);e!=null&&e.regions?(this.localeFields.region.options=e.regions.options,this.localeFields.region.placeholder=e.regions.label,this.fieldInfo.rows[2]={fields:{region:this.localeFields.region}}):(delete this.fieldValues.region,this.fieldInfo.rows.splice(2,1)),e!=null&&e.compliance?this.complianceNeeded=!0:(delete this.fieldValues.compliance,this.update({...this.fieldValues,error:{valid:!0,errors:[]}}),this.complianceNeeded=!1)},canRenderDescription(e){return e.description&&this.showDescription},handleNewsletterClick(e,o){if(this.userInfo){this.toggleUserSubscription(e,o);return}const s=this.subscribed.indexOf(e);s===-1?this.subscribed.push(e):this.subscribed.splice(s,1)},handleSubmitClick(){this.showErrors=T(this.fieldErrors??{})>0,this.checkErrors()},async submit(){var e,o;try{if(this.error="",this.subscribed.length===0)throw new Error("Please select a newsletter before continuing");if(this.showErrors)throw new Error("Please correct issues with this form");this.fieldValues.compliance===""&&(this.fieldValues.compliance=!1),this.processing=!0;const s=await this.recaptcha("newsletterSubscribeSignUp"),c=((o=(e=w())==null?void 0:e.query)==null?void 0:o.pk)??this.$ss.newsletters.subscribeBlockSettings.promoCode,t={email:this.fieldValues.email,omedaProducts:this.subscribed,countryCode:this.fieldValues.countryCode,regionCode:this.fieldValues.region,consent:m.formatConsentObject({country:this.fieldValues.countryCode,region:this.fieldValues.region,compliance:this.fieldValues.compliance}),recaptchaToken:s,promoCode:c},i=await this.$gql.mutate("subscribeAnonymousCustomer",t);if(i.error)throw new Error(i.message);this.message="You're all done! You will now receive updates from the newsletter(s) you selected."}catch(s){this.error=s}finally{this.processing=!1}},checkErrors(){var e,o,s,c;this.emailField.showErrors=!((e=this.fieldErrors.email)!=null&&e.errorObj.valid),this.countryCodeField.showErrors=!((o=this.fieldErrors.countryCode)!=null&&o.errorObj.valid),this.regionsField&&(this.regionsField.showErrors=!((s=this.fieldErrors.region)!=null&&s.errorObj.valid)),this.complianceField&&(this.complianceField.showErrors=!((c=this.fieldErrors.compliance)!=null&&c.errorObj.valid))},async toggleUserSubscription(e,o){var s,c;if(this.subscribed.includes(e))confirm("Are you sure you wish to opt out from this newsletter?")&&((await m.unsubscribeToNewsletter(e)).error?h.error("Newsletter opt out failed. Please try again or contact support for assistance."):(this.subscribed.splice(this.subscribed.indexOf(e),1),h.success("Newsletter opt out successful!")));else{const t=((c=(s=w())==null?void 0:s.query)==null?void 0:c.pk)??this.$ss.newsletters.subscribeBlockSettings.promoCode;(await m.subscribeToNewsletter(e,o,"nl_widget",t)).error?h.error("Newsletter opt in failed. Please try again or contact support for assistance."):(this.subscribed.push(e),h.success("Newsletter opt in successful!"))}}}},L={key:0,class:"user-welcome"},j=["innerHTML"],H={key:1},W={class:"toggle"},Q={key:0,class:"overview"},R={style:{"font-weight":"800"},class:"name"},Y=["innerHTML"],G={key:1,class:"overview"},K={class:"name"},Z={class:"non-compliance-fields"},J={class:"full-button"},X={key:0,class:"compliance-fields"},$={class:"mobile-button"},ee={key:2,class:"web-subscribe-form simple",action:"https://endeavor.dragonforms.com/loading.do",method:"GET"},se=["value"],oe=["value"],te={key:0},ie={key:1};function re(e,o,s,c,t,i){const C=P,g=q,p=U,k=A,x=z;return r(),_(x,null,{default:v(()=>[f(k,{"include-frame":!1,error:t.error,message:t.message,processing:t.processing,style:d({fontFamily:e.$ss.primaryFontFamily,padding:s.simpleMode?"10px 0":0}),padding:"0",class:"ebm-subscribe-wrapper"},{default:v(()=>[l("div",{class:"ebm-subscribe",style:d(i.textStyle)},[l("div",{class:"header",style:d({backgroundColor:s.headerBackgroundColor,color:s.headerTextColor})},[l("h2",null,b(s.headerText),1)],4),l("div",{class:"subscribe-container",style:d({backgroundColor:s.bodyBackgroundColor})},[s.simpleMode?u("",!0):(r(),n("div",{key:0,class:"subscribe-info",style:d({color:s.bodyTextColor})},[t.userInfo?(r(),n("div",L,[t.availableNewsletters.length===0?(r(),n("div",{key:0,innerHTML:s.noAvailableNlText},null,8,j)):(r(),n("div",H," Hello "+b(t.userInfo.firstName)+", would you like to update your newsletter subscription(s)? ",1))])):u("",!0),l("div",{class:"newsletters",style:d({padding:t.availableNewsletters.length===0?"0":"20px 0"})},[(r(!0),n(F,null,E(t.availableNewsletters,a=>(r(),n("div",{key:a.omedaProductId,class:V(["newsletter",t.availableNewsletters.length===1?"single":""])},[l("div",{class:"newsletter-content",style:d({alignItems:i.canRenderDescription(a)?"flex-start":"center"})},[l("div",W,[f(C,{icon:t.subscribed.includes(a.omedaProductId)?"mdi:checkbox-outline":"mdi:checkbox-blank-outline",width:26,"icon-color":s.bodyTextColor,onClick:le=>i.handleNewsletterClick(a.omedaProductId,a.title)},null,8,["icon","icon-color","onClick"])]),i.canRenderDescription(a)?(r(),n("div",Q,[l("div",R,b(a.title),1),l("div",{class:"description",innerHTML:a.description},null,8,Y)])):(r(),n("div",G,[l("div",K,b(a.title),1)]))],4)],2))),128))],4)],4)),!t.userInfo&&!s.simpleMode?(r(),n("form",{key:1,class:"web-subscribe-form",onSubmit:o[0]||(o[0]=B((...a)=>i.submit&&i.submit(...a),["prevent"]))},[l("div",Z,[f(g,{class:"fields","field-info":t.fieldInfo,"field-values":t.fieldValues,onUpdate:i.update},null,8,["field-info","field-values","onUpdate"]),l("div",J,[f(p,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"large",onOnClick:i.handleSubmitClick},null,8,["color","alt-color","label","onOnClick"])])]),t.complianceNeeded?(r(),n("div",X,[t.complianceNeeded?(r(),_(g,{key:0,"field-info":t.fieldInfoCompliance,"field-values":t.fieldValuesCompliance,onUpdate:i.update},null,8,["field-info","field-values","onUpdate"])):u("",!0)])):u("",!0),l("div",$,[f(p,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"large",onOnClick:i.handleSubmitClick},null,8,["color","alt-color","label","onOnClick"])])],32)):u("",!0),s.simpleMode?(r(),n("form",ee,[l("input",{type:"hidden",name:"omedasite",value:i.omedaSite},null,8,se),M(l("input",{"onUpdate:modelValue":o[1]||(o[1]=a=>t.fieldValues.email=a),type:"email",name:"em",placeholder:"Email Address"},null,512),[[O,t.fieldValues.email]]),i.omedaQuery?(r(),n("input",{key:0,type:"hidden",name:"pk",value:i.omedaQuery},null,8,oe)):u("",!0),f(p,{type:"submit",color:s.buttonBackgroundColor,"alt-color":s.buttonTextColor,label:s.buttonText,size:"fullWidth"},null,8,["color","alt-color","label"])])):u("",!0)],4),!s.simpleMode&&t.availableNewsletters.length!==0?(r(),n("div",{key:0,class:"consent",style:d({backgroundColor:s.bodyBackgroundColor,color:s.bodyTextColor})},[t.userInfo?(r(),n("span",te,"Your account is subject")):(r(),n("span",ie,"By submitting your information, you are agreeing")),o[2]||(o[2]=y(" to Endeavor Business Media's ")),o[3]||(o[3]=l("a",{href:"https://www.endeavorbusinessmedia.com/endeavor-terms"},"Terms of Service",-1)),o[4]||(o[4]=y(" and ")),o[5]||(o[5]=l("a",{href:"https://www.endeavorbusinessmedia.com/privacy-policy"},"Privacy Policy",-1)),o[6]||(o[6]=y(". "))],4)):u("",!0)],4)]),_:1},8,["error","message","processing","style"])]),_:1})}const ae=S(D,[["render",re]]);export{ae as default};