import{_ as S,R as E,r as o,o as n,b as l,a as d,w as h,p as y,q as a,v as b,T as O,k as j,Y as N,U,l as _,u as k,F as C,e as $,n as V,D as B,B as A,Z as q,X as G,b0 as K,C as J,i as z,G as X}from"./main-DtyiNRRn.js";import{E as I}from"./ErrorMessage-BodFsaDt.js";import{_ as Y}from"./validatorsMixin.vue_vue_type_script_lang-BhpMiNHR.js";import{L as x}from"./LoadingIndicatorWrapper-Cd2Pg2hk.js";import{_ as Z}from"./newsletterMixin-CLD5QbLp.js";import{s as Q}from"./pageScrolling-DKoKIacQ.js";const P={name:"NewsletterRegistrationConfirmation",components:{ErrorMessage:I,RichtextFi:E},inject:["fields"],props:{hasConflicts:{type:Boolean,default:!1},conflictMsg:{type:String,default:""}},async mounted(){await this.$nextTick(),this.triggerWarning()},methods:{triggerWarning(){var e;(e=this.$refs.warningMessage)!=null&&e.trigger&&this.$refs.warningMessage.trigger()}}},ee={ref:"newsletterRegConfirmation",class:"newsletter-registration-confirmation-fi"},te=["innerHTML"],se={key:1,class:"newsletter-registration-confirmation-fi__headline"};function ie(e,t,r,c,s,i){var m,w;const u=o("error-message"),g=o("richtext-fi");return n(),l("div",ee,[r.hasConflicts?(n(),d(u,{key:0,ref:"warningMessage",title:(m=i.fields.warningTitle)==null?void 0:m.value,"hide-initially":""},{default:h(()=>[y("span",{innerHTML:r.conflictMsg},null,8,te)]),_:1},8,["title"])):a("",!0),e.$dict.get("newsletter.Registration.Confirmation-Title")?(n(),l("h2",se,b(e.$dict.get("newsletter.Registration.Confirmation-Title")),1)):a("",!0),e.isEditMode||(w=i.fields.confirmationText)!=null&&w.value?(n(),d(g,{key:2,class:"newsletter-registration-confirmation-fi__content","html-content":i.fields.confirmationText},null,8,["html-content"])):a("",!0)],512)}const ne=S(P,[["render",ie],["__scopeId","data-v-0c17fd9a"]]),re={name:"NewsletterRegistrationSignUp",components:{ErrorMessage:I,LoadingIndicatorWrapper:x,TextInputFi:O,RichtextFi:E},mixins:[j,Z,Y,N],inject:["fields"],emits:["newsletter-data-loaded","signed-up","signed-up-with-conflicts"],data(){return{email:"",customerID:"",newsletterTypes:[],alreadySubscribedNewsletters:[],confirmation:!1,validated:!1,enableEmailValidation:!1,enableCustomerIDValidation:!1,warningMessage:"",isSubmittedLoading:!1,newsletterId:null,subscriberEmail:null,signUpLoading:!1}},computed:{customerIDRequired(){var e;return(e=this.fields)!=null&&e.setCustomerIdInputRequired?!!this.fields.setCustomerIdInputRequired.value:!1},showCustomerIdInput(){var e;return((e=this.fields)==null?void 0:e.enableCustomerIdInput)&&!!this.fields.enableCustomerIdInput.value},isRedirectEnabled(){const e=this.$fischer.query("redirect");return(e==null?void 0:e.toLowerCase())==="true"}},watch:{confirmation(){this.validateOnChange()},email(){this.validateOnChange()}},created(){this.newsletterId=this.$fischer.query("id"),this.subscriberEmail=this.$fischer.hash("email"),this.subscriberEmail&&(this.enableEmailValidation=!0)},mounted(){var e;this.getSubscriptionConfiguration(this.subscriberEmail,(e=this.fields)!=null&&e.limitedNewsletter?this.fields.limitedNewsletter:void 0,async()=>{this.newsletterTypes=this.getSelectedNewsletters(this.newsletterId,!0),(this.hasNewsletterError||!this.hasNewsletters)&&(this.hasNewsletterError&&console.error("Newsletter Error"),this.hasNewsletters||console.error("No Newsletter",this.newsletterConfigurations),this.triggerError(),await this.$nextTick(),Q(document.body)),await this.$nextTick(),this.$emit("newsletter-data-loaded")}),this.setKnownSubscriberDetails()},methods:{async validateOnChange(){await this.$nextTick(),this.validate()},validate(){const e=[this.$refs.email,this.customerIDRequired?this.$refs.customerID:null].map(t=>t?t.validate():!0);return this.validated=!e.some(t=>!t),this.validated&&this.newsletterTypes.length===0&&(this.validated=!1),this.confirmation||(this.validated=!1),this.validated},async submit(){var e;if(this.validate()){this.signUpLoading=!0;try{{if(this.isSubmittedLoading)return;this.isSubmittedLoading=!0;const t=await U.get("/exm/api/sendoptin",{params:{ids:this.newsletterTypes.join("|"),email:this.email,sid:this.$fischer.query("sid"),gp:this.customerID,timestamp:Date.now()}});t.data.HasErrors?(this.isSubmittedLoading=!1,this.triggerError()):t.data.HasConflicts&&!t.data.Successful.length?(this.isSubmittedLoading=!1,this.setWarningMsg(t.data.Conflicts,t.data.Successful),this.triggerWarning()):t.data.HasConflicts&&t.data.Successful.length?(this.isSubmittedLoading=!1,this.setWarningMsg(t.data.Conflicts,t.data.Successful),this.trackSignUpEvent(t.data.Successful),this.$emit("signed-up-with-conflicts",this.warningMessage)):(this.trackSignUpEvent(t.data.Successful),this.isRedirectEnabled?this.redirectToDashboard((e=this.fields.successNoteDashboard)==null?void 0:e.value):(this.isSubmittedLoading=!1,this.$emit("signed-up")))}}catch(t){console.error("Error signing up to newsletter",t),this.isSubmittedLoading=!1,this.triggerError()}}},setWarningMsg(e,t){var r,c,s,i;t.length?e.length===1?this.warningMessage=(s=this.fields.warningTextSingleSuccess)==null?void 0:s.value.replace("{0}",`"${e[0].SubscriptionName}"`):(this.warningMessage=(i=this.fields.warningTextMultiSuccess)==null?void 0:i.value,this.warningMessage+="<ul>",e.forEach(u=>{this.warningMessage+=`<li>${u.SubscriptionName}</li>`}),this.warningMessage+="</ul>"):e.length===1?this.warningMessage=(r=this.fields.warningTextSingle)==null?void 0:r.value:this.warningMessage=(c=this.fields.warningTextMulti)==null?void 0:c.value},triggerError(){var e;(e=this.$refs.errorMessage)!=null&&e.trigger&&this.$refs.errorMessage.trigger()},triggerWarning(){var e;(e=this.$refs.warningMessage)!=null&&e.trigger&&this.$refs.warningMessage.trigger()},setKnownSubscriberDetails(){(this.subscriberEmail||this.newsletterId&&this.subscriberEmail)&&(this.email=this.subscriberEmail)},getSelectedNewsletters(e,t=!1){const r=[];return this.newsletterValues.forEach((c,s)=>{t&&c.id===this.newsletterId&&(this.newsletterValues[s].subscribed=!0),e&&c.id!==this.newsletterId&&c.subscribed&&this.alreadySubscribedNewsletters.push(c.id),c.subscribed&&this.alreadySubscribedNewsletters.indexOf(c.id)===-1&&r.push(c.id)}),r},onNewsletterChanged(){this.newsletterTypes=this.getSelectedNewsletters(),this.validate()},trackSignUpEvent(e){if(e!=null&&e.length){const t=e.map(r=>({newsletterId:r.SubscriptionId,newsletterName:r.SubscriptionName}));this.sendEvent("newsletter_registration",{newsletters:t})}},redirectToDashboard(e){if(this.loading=!0,e)try{window.localStorage.setItem("newsletterNotification",JSON.stringify({message:e,inProgress:!0}))}catch(t){console.debug(t)}setTimeout(()=>{window.location.href=this.$fischer.pages.myAccount().url},2e3)}}},ae={class:"newsletter-registration-sign-up-fi"},le=["innerHTML"],oe={key:0,class:"newsletter-registration-sign-up-fi__headline"},de=["innerHTML"],ce={class:"newsletter-registration-sign-up-fi__mandatory-hint"},ue={key:1,class:"newsletter-registration-sign-up-fi__sub-headline"},fe=["innerHTML"],be=["innerHTML"],he=["innerHTML"];function ge(e,t,r,c,s,i){var T,L,M,H,R;const u=o("error-message"),g=o("text-input-fi"),m=o("checkbox-fi"),w=o("loading-indicator-wrapper"),v=o("richtext-fi"),p=o("button-fi");return n(),l("div",ae,[_(u,{ref:"errorMessage",title:e.$dict.get("online-Shop.Global-Labels.Error-Code-Headline"),"data-test":"newsletter-registration-error-text","hide-initially":""},null,8,["title"]),_(u,{ref:"warningMessage",title:(T=i.fields.warningTitle)==null?void 0:T.value,"data-test":"newsletter-registration-warning-text","hide-initially":""},{default:h(()=>[y("span",{innerHTML:s.warningMessage},null,8,le)]),_:1},8,["title"]),!e.isEditMode&&((L=i.fields.registrationTitle)!=null&&L.value)?(n(),l("h2",oe,b(i.fields.registrationTitle.value),1)):a("",!0),e.isEditMode?(n(),l("h2",{key:1,class:"newsletter-registration-sign-up-fi__headline",innerHTML:i.fields.registrationTitle.editable},null,8,de)):a("",!0),y("span",ce,[k(b(e.$dict.get("newsletter.Registration.Mandatory-Explanation").split("{0}")[0])+" ",1),t[7]||(t[7]=y("span",{class:"newsletter-registration-sign-up-fi__mandatory-hint--asterisk"},"*",-1)),k(" "+b(e.$dict.get("newsletter.Registration.Mandatory-Explanation").split("{0}")[1]),1)]),y("form",null,[_(g,{ref:"email",modelValue:s.email,"onUpdate:modelValue":t[0]||(t[0]=f=>s.email=f),modelModifiers:{trim:!0},label:e.$dict.get("newsletter.Registration.Email"),rules:e.hasInvalidCharacters||s.enableEmailValidation?e.rules.emailTrimmed:[],required:"","error-absolute":"",onKeyup:t[1]||(t[1]=f=>e.validateCharacters(s.email)),onBlur:t[2]||(t[2]=f=>s.enableEmailValidation=!0)},null,8,["modelValue","label","rules"]),i.showCustomerIdInput?(n(),d(g,{key:0,ref:"customerID",modelValue:s.customerID,"onUpdate:modelValue":t[3]||(t[3]=f=>s.customerID=f),modelModifiers:{trim:!0},label:e.$dict.get("newsletter.Registration.Customer-ID"),rules:i.customerIDRequired&&s.enableCustomerIDValidation?e.rules.required:[],required:i.customerIDRequired,class:"fi-mt-72",onKeyup:t[4]||(t[4]=f=>i.customerIDRequired?i.validate():null),onBlur:t[5]||(t[5]=f=>s.enableCustomerIDValidation=!0)},null,8,["modelValue","label","rules","required"])):a("",!0),!e.isEditMode&&((M=i.fields.registrationTitle)!=null&&M.value)?(n(),l("h3",ue,b(i.fields.registrationTypeLabel.value),1)):a("",!0),e.isEditMode?(n(),l("h3",{key:2,class:"newsletter-registration-sign-up-fi__sub-headline",innerHTML:i.fields.registrationTypeLabel.editable},null,8,fe)):a("",!0),_(w,{loading:e.isNewsletterLoading,variant:"spinnerCard",spinoff:"in-relative-centered","enable-min-dimensions":""},{default:h(()=>[(n(!0),l(C,null,$(e.newsletterConfigurations,(f,D)=>(n(),l("div",{key:f.Id,class:"newsletter-registration-sign-up-fi__option"},[e.newsletterValues[D]?(n(),d(m,{key:0,modelValue:e.newsletterValues[D].subscribed,"onUpdate:modelValue":W=>e.newsletterValues[D].subscribed=W,label:f.Titel,disabled:f.Id!==s.newsletterId&&f.Subscribed,class:"newsletter-registration-sign-up-fi__checkbox","data-test":"newsletter-registration-sign-up-option","data-test-2":f.Titel,onChange:i.onNewsletterChanged},null,8,["modelValue","onUpdate:modelValue","label","disabled","data-test-2","onChange"])):a("",!0),f.Description?(n(),l("div",{key:1,class:"newsletter-registration-sign-up-fi__checkbox-description",innerHTML:f.Description},null,8,be)):a("",!0)]))),128))]),_:1},8,["loading"]),t[8]||(t[8]=y("hr",{class:"newsletter-registration-sign-up-fi__separator"},null,-1)),(H=i.fields.termsAndConditionsLabel)!=null&&H.value?(n(),d(m,{key:3,ref:"confirmation",modelValue:s.confirmation,"onUpdate:modelValue":t[6]||(t[6]=f=>s.confirmation=f),label:i.fields.termsAndConditionsLabel.value,class:"newsletter-registration-sign-up-fi__checkbox","data-test":"newsletter-registration-terms-and-conditions","show-asterisk":"",onChange:i.onNewsletterChanged},null,8,["modelValue","label","onChange"])):a("",!0),e.isEditMode||(R=i.fields.termsAndConditionsText)!=null&&R.value?(n(),d(v,{key:4,class:"newsletter-registration-sign-up-fi__checkbox-description","html-content":i.fields.termsAndConditionsText},null,8,["html-content"])):a("",!0),e.isEditMode?(n(),l("span",{key:6,class:V([e.isMD?"button-fi--large":"button-fi--stretched","button-fi__primary button-fi--large newsletter-registration-sign-up-fi__submit"]),innerHTML:i.fields.registrationButtonTitle.editable},null,10,he)):(n(),d(w,{key:5,loading:s.isSubmittedLoading,variant:"spinnerLocal",class:"newsletter-registration-sign-up-fi__loading-wrapper"},{default:h(()=>[_(p,{type:"button",disabled:!(s.validated&&s.enableEmailValidation),class:V([e.isMD?"button-fi--large":"button-fi--stretched","button-fi__primary button-fi--large newsletter-registration-sign-up-fi__submit"]),"data-test":"newsletter-registration-sign-up",onClick:i.submit},{default:h(()=>{var f;return[k(b((f=i.fields.registrationButtonTitle)==null?void 0:f.value),1)]}),_:1},8,["disabled","class","onClick"])]),_:1},8,["loading"]))])])}const me=S(re,[["render",ge],["__scopeId","data-v-fb5e617a"]]),_e={name:"NewsletterRegistrationFi",components:{NewsletterRegistrationSignUpFi:me,NewsletterRegistrationConfirmationFi:ne},emits:["newsletter-data-loaded"],data(){return{signedUp:!1,hasConflicts:!1,conflictMsg:null}},methods:{signedUpWithConflicts(e){this.conflictMsg=e,this.hasConflicts=!0}}},we={class:"newsletter-registration"};function pe(e,t,r,c,s,i){const u=o("newsletter-registration-confirmation-fi"),g=o("newsletter-registration-sign-up-fi");return n(),l("div",we,[_(B,{mode:"out-in","leave-active-class":"animated fadeOut fastest","enter-active-class":"animated fadeIn fastest"},{default:h(()=>[s.signedUp||s.hasConflicts?(n(),d(u,{key:"confirmation","data-test":"newsletter-registration-confirmation","has-conflicts":s.hasConflicts,"conflict-msg":s.conflictMsg},null,8,["has-conflicts","conflict-msg"])):(n(),d(g,{key:"signup","data-test":"newsletter-registration-sign-up",onSignedUp:t[0]||(t[0]=m=>s.signedUp=!0),onSignedUpWithConflicts:i.signedUpWithConflicts,onNewsletterDataLoaded:t[1]||(t[1]=m=>e.$emit("newsletter-data-loaded"))},null,8,["onSignedUpWithConflicts"]))]),_:1})])}const ye=S(_e,[["render",pe]]),ve={name:"NewsletterSubscribeSuccessFi",components:{ErrorMessage:I,LoadingIndicator:A,RichtextFi:E},mixins:[N],inject:["fields"],emits:["newsletter-data-loaded"],data(){return{newsletterType:null,contactId:null,hasSubscriptionDetails:!1,isSubscriptionFailed:!1,isLoading:!0,error:!1,warning:!1}},created(){this.parseSubscriptionDetails(),this.hasSubscriptionDetails&&this.subscribe()},methods:{parseSubscriptionDetails(){this.newsletterType=this.$fischer.query("id"),this.contactId=this.$fischer.query("cid"),this.newsletterType&&this.contactId?this.hasSubscriptionDetails=!0:this.error=!0},subscribe(){U.get(`${window.location.origin}/exm/api/subscribe`,{params:{id:this.newsletterType,cid:this.contactId,sid:this.$fischer.query("sid")}}).then(e=>{e.data.HasErrors?this.error=!0:e.data.HasConflicts?this.warning=!0:e.data.StatusCode===200?this.isSubscriptionFailed=!1:console.error("Unknown status code."),!e.data.HasErrors&&e.data.Successful.length&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"subscribeNewsletter"}),this.sendEvent("newsletter_registration_success",{newsletters:[{newsletterId:e.data.Successful[0].SubscriptionId,newsletterName:e.data.Successful[0].SubscriptionName}]})),this.isLoading=!1,setTimeout(()=>{this.$emit("newsletter-data-loaded")},100)}).catch(e=>{e.response&&(this.isSubscriptionFailed=e.response.status===404),this.error=!1,this.isLoading=!1,setTimeout(()=>{this.$emit("newsletter-data-loaded")},100)})}}},Te={class:"newsletter-subscribe-success-fi"},Le={key:0,class:"newsletter-subscribe-success-fi__headline"},Me=["innerHTML"],ke={key:0,class:"newsletter-subscribe-success-fi__headline"},Se={class:"newsletter-subscribe-success-fi__loading-container"},Ce={key:0,class:"newsletter-subscribe-success-fi__headline"},Ee=["innerHTML"];function Ie(e,t,r,c,s,i){var w,v,p;const u=o("richtext-fi"),g=o("loading-indicator"),m=o("error-message");return n(),l("div",Te,[e.isEditMode||s.hasSubscriptionDetails&&!s.isSubscriptionFailed&&!s.isLoading&&!s.error&&!s.warning?(n(),l(C,{key:0},[!e.isEditMode&&((w=i.fields.title)!=null&&w.value)?(n(),l("h2",Le,b(i.fields.title.value),1)):a("",!0),e.isEditMode?(n(),l("h2",{key:1,class:"newsletter-subscribe-success-fi__headline",innerHTML:i.fields.title.editable},null,8,Me)):a("",!0),_(u,{class:"newsletter-subscribe-success-fi__content","html-content":i.fields.text},null,8,["html-content"])],64)):(n(),l(C,{key:1},[s.hasSubscriptionDetails&&s.isLoading&&!s.error&&!s.warning?(n(),l(C,{key:0},[e.$dict.get("newsletter.Registration-Success.Loading-Text")?(n(),l("h2",ke,b(e.$dict.get("newsletter.Registration-Success.Loading-Text")),1)):a("",!0),y("div",Se,[_(g,{variant:"spinnerLocal"})])],64)):(n(),l(C,{key:1},[s.error||s.warning?(n(),l(C,{key:0},[!e.isEditMode&&((v=i.fields.problemTitle)!=null&&v.value)?(n(),l("h2",Ce,b(i.fields.problemTitle.value),1)):a("",!0),e.isEditMode?(n(),l("h2",{key:1,class:"newsletter-subscribe-success-fi__headline",innerHTML:i.fields.problemTitle.editable},null,8,Ee)):a("",!0)],64)):a("",!0),s.error?(n(),d(m,{key:1,title:e.$dict.get("newsletter.Registration-Success.Error-Headline")},{default:h(()=>[k(b(e.$dict.get("newsletter.Registration-Success.Error-Description")),1)]),_:1},8,["title"])):a("",!0),s.warning?(n(),d(m,{key:2,title:(p=i.fields.warningTitle)==null?void 0:p.value},{default:h(()=>{var T;return[k(b((T=i.fields.warningText)==null?void 0:T.value),1)]}),_:1},8,["title"])):a("",!0)],64))],64))])}const De=S(ve,[["render",Ie],["__scopeId","data-v-c7721a30"]]),Ne={name:"UnsubscribeCanceled",components:{RichtextFi:E},props:{fields:{type:Object,required:!0}}},Ue={class:"newsletter-unsubscribe-canceled-fi"},He={key:0,class:"newsletter-unsubscribe-canceled-fi__headline"};function Re(e,t,r,c,s,i){const u=o("richtext-fi");return n(),l("div",Ue,[e.$dict.get("newsletter.Unsubscribe.Canceled-Headline")?(n(),l("h2",He,b(e.$dict.get("newsletter.Unsubscribe.Canceled-Headline")),1)):a("",!0),_(u,{class:"newsletter-unsubscribe-canceled-fi__content","html-content":r.fields.canceledText},null,8,["html-content"])])}const Ve=S(Ne,[["render",Re],["__scopeId","data-v-83344133"]]),qe={name:"UnsubscribeReasons",components:{LoadingIndicatorWrapper:x},props:{fields:{type:Object,required:!0},submitLoading:{type:Boolean,default:!1},cancelLoading:{type:Boolean,default:!1}},emits:["canceled","unsubscribe"],data(){return{selectedReasons:[]}},methods:{unsubscribe(){this.$emit("unsubscribe",this.selectedReasons)},cancelSubscribe(){this.$emit("canceled")}}},Fe={class:"newsletter-unsubscribe-reasons-fi"},$e={key:0,class:"newsletter-unsubscribe-reasons-fi__headline"},Be=["innerHTML"],xe={key:2,class:"newsletter-unsubscribe-reasons-fi__sub-headline"},We=["innerHTML"],Oe={class:"newsletter-unsubscribe-reasons-fi__form"},je=["innerHTML"],Ae=["innerHTML"];function Ge(e,t,r,c,s,i){var w,v,p,T;const u=o("checkbox-fi"),g=o("button-fi"),m=o("loading-indicator-wrapper");return n(),l("div",Fe,[!e.isEditMode&&((w=r.fields.title)!=null&&w.value)?(n(),l("h2",$e,b(r.fields.title.value),1)):a("",!0),e.isEditMode?(n(),l("h2",{key:1,class:"newsletter-unsubscribe-reasons-fi__headline",innerHTML:r.fields.title.editable},null,8,Be)):a("",!0),!e.isEditMode&&((v=r.fields.subtitle)!=null&&v.value)?(n(),l("h3",xe,b(r.fields.subtitle.value),1)):a("",!0),e.isEditMode?(n(),l("h3",{key:3,class:"newsletter-unsubscribe-reasons-fi__sub-headline",innerHTML:r.fields.subtitle.editable},null,8,We)):a("",!0),y("form",Oe,[(n(!0),l(C,null,$(r.fields.newsletterUnsubscribe,L=>(n(),l("div",{key:L.id,class:"newsletter-unsubscribe-reasons-fi__option"},[_(u,{modelValue:s.selectedReasons,"onUpdate:modelValue":t[0]||(t[0]=M=>s.selectedReasons=M),label:L.fields.Title.value,value:L.id,"data-test":"newsletter-unsubscribe-reason","data-test-2":L.id,class:"newsletter-unsubscribe-reasons-fi__checkbox"},null,8,["modelValue","label","value","data-test-2"])]))),128)),!e.isEditMode&&((p=r.fields.buttonTitle)!=null&&p.value)?(n(),d(m,{key:0,loading:r.submitLoading,variant:"spinnerLocal",class:"newsletter-unsubscribe-reasons-fi__loading-wrapper"},{default:h(()=>[_(g,{type:"button",class:"button-fi__primary button-fi--stretched button-fi--large",disabled:r.submitLoading||r.cancelLoading,"data-test":"newsletter-unsubscribe",onClick:q(i.unsubscribe,["prevent"])},{default:h(()=>[k(b(r.fields.buttonTitle.value),1)]),_:1},8,["disabled","onClick"])]),_:1},8,["loading"])):a("",!0),e.isEditMode?(n(),l("span",{key:1,class:"button-fi__primary button-fi--stretched button-fi--large",innerHTML:r.fields.buttonTitle.editable},null,8,je)):a("",!0),t[1]||(t[1]=y("br",null,null,-1)),!e.isEditMode&&((T=r.fields.cancelLinkTitle)!=null&&T.value)?(n(),d(m,{key:2,loading:r.cancelLoading,variant:"spinnerLocal",class:"newsletter-unsubscribe-reasons-fi__loading-wrapper cancel"},{default:h(()=>[_(g,{type:"button",class:"button-fi__tertiary button-fi--stretched button-fi--large newsletter-unsubscribe-reasons-fi__button--cancel",disabled:r.submitLoading||r.cancelLoading,onClick:q(i.cancelSubscribe,["prevent"])},{default:h(()=>[k(b(r.fields.cancelLinkTitle.value),1)]),_:1},8,["disabled","onClick"])]),_:1},8,["loading"])):a("",!0),e.isEditMode?(n(),l("span",{key:3,class:"button-fi__tertiary button-fi--stretched button-fi--large newsletter-unsubscribe-reasons-fi__button--cancel",innerHTML:r.fields.cancelLinkTitle.editable},null,8,Ae)):a("",!0)])])}const Ke=S(qe,[["render",Ge],["__scopeId","data-v-49ffb253"]]),Je={name:"UnsubscribeSuccess",components:{RichtextFi:E},props:{fields:{type:Object,required:!0}}},ze={class:"newsletter-unsubscribe-success-fi","data-test":"newsletter-unsubscribe-success"},Xe={key:0,class:"newsletter-unsubscribe-success-fi__headline"},Ye={key:1,class:"newsletter-unsubscribe-success-fi__headline"};function Ze(e,t,r,c,s,i){var g;const u=o("richtext-fi");return n(),l("div",ze,[!e.isEditMode&&((g=r.fields.successTitle)!=null&&g.value)?(n(),l("h2",Xe,b(r.fields.successTitle.value),1)):a("",!0),e.isEditMode?(n(),l("h2",Ye,b(r.fields.successTitle.editable),1)):a("",!0),_(u,{class:"newsletter-unsubscribe-success-fi__content","html-content":r.fields.successText},null,8,["html-content"])])}const Qe=S(Je,[["render",Ze],["__scopeId","data-v-d3c8a679"]]),F=e=>{if(!["","undefined","null"].includes(e))return e},Pe={name:"NewsletterUnsubscribeFi",components:{ErrorMessage:I,UnsubscribeReasons:Ke,UnsubscribeSuccess:Qe,UnsubscribeCanceled:Ve},mixins:[N],inject:["fields"],emits:["newsletter-data-loaded"],data(){return{localCustomData:null,isUnsubscribed:!1,isCanceled:!1,newsletterType:null,contactId:null,messageId:null,hasUnSubscriptionDetails:!1,error:!1,warning:!1,unsubscribeLoading:!1,cancelLoading:!1}},computed:{correctedFields(){return this.fields},isRedirectEnabled(){const e=this.$fischer.query("redirect");return(e==null?void 0:e.toLowerCase())==="true"}},watch:{isUnsubscribed(){this.isUnsubscribed&&this.setToastMessage()}},created(){this.parseSubscriptionDetails(),setTimeout(()=>{this.$emit("newsletter-data-loaded")},100)},methods:{setToastMessage(){var e;this.$store.dispatch("notifications/openToastNotification",{name:"newsletter-unsubscribe-success",message:{value:(e=this.fields.successNote)==null?void 0:e.value},type:"success",icon:"check",delayLong:!0})},parseSubscriptionDetails(){this.newsletterType=this.$fischer.query("id"),this.contactId=F(this.$fischer.query("cid"))||"current",this.messageId=F(this.$fischer.query("mid")),this.newsletterType&&this.contactId&&this.contactId!=="anonymous"?this.hasUnSubscriptionDetails=!0:(console.error("missing data in url"),this.error=!0)},async unsubscribe(e){var t;this.unsubscribeLoading=!0;try{const r=await U.get(`${window.location.origin}/exm/api/unsubscribe`,{params:{id:this.newsletterType,cid:this.contactId,mid:this.messageId,reasons:e.length?e.join("|"):null}});if(r.data.HasErrors)this.warning=!1,this.error=!0;else if(r.data.HasConflicts)this.error=!1,this.warning=!0;else{this.error=!1,this.warning=!1,window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"unsubscribeNewsletter"});const c=this.correctedFields.newsletterUnsubscribe.filter(s=>e.includes(s.id)).map(s=>{var i;return{reasonId:s.id,reasonTitle:(i=s.fields.Title)==null?void 0:i.value}});await this.sendEvent("newsletter_unsubscribe",{newsletter:{newsletterId:this.newsletterType},reasons:c,mid:this.messageId,cid:this.contactId}),this.isRedirectEnabled?this.redirectToDashboard((t=this.fields.successNoteDashboard)==null?void 0:t.value):(this.isUnsubscribed=!0,this.unsubscribeLoading=!0)}}catch(r){this.unsubscribeLoading=!0,console.error(r),this.error=!0}},unsubscribeCanceled(){var e;this.isRedirectEnabled?(this.cancelLoading=!0,this.redirectToDashboard((e=this.fields.canceledNoteDashboard)==null?void 0:e.value)):this.isCanceled=!0},redirectToDashboard(e){if(e)try{window.localStorage.setItem("newsletterNotification",JSON.stringify({message:e}))}catch(t){console.debug(t)}setTimeout(()=>{window.location.href=this.$fischer.pages.myAccount().url},2e3)}}},et={class:"newsletter-unsubscribe-fi"};function tt(e,t,r,c,s,i){var v;const u=o("error-message"),g=o("unsubscribe-reasons"),m=o("unsubscribe-success"),w=o("unsubscribe-canceled");return n(),l("div",et,[s.error?(n(),d(u,{key:0,title:e.$dict.get("newsletter.Unsubscribe.Failed-Error-Title")},{default:h(()=>[k(b(e.$dict.get("newsletter.Unsubscribe.Failed-Error-Text")),1)]),_:1},8,["title"])):a("",!0),s.warning?(n(),d(u,{key:1,title:(v=i.fields.warningTitle)==null?void 0:v.value},{default:h(()=>{var p;return[k(b((p=i.fields.warningText)==null?void 0:p.value),1)]}),_:1},8,["title"])):a("",!0),_(G,{mode:"out-in","leave-active-class":"animated fadeOut fastest","enter-active-class":"animated fadeIn fastest"},{default:h(()=>[e.isEditMode||!s.error&&!s.warning&&!s.isUnsubscribed&&!s.isCanceled?(n(),d(g,{key:0,fields:i.correctedFields,"submit-loading":s.unsubscribeLoading,"cancel-loading":s.cancelLoading,onUnsubscribe:i.unsubscribe,onCanceled:i.unsubscribeCanceled,onSignedUp:t[0]||(t[0]=p=>(e.signedUp=!0,i.setToastMessage()))},null,8,["fields","submit-loading","cancel-loading","onUnsubscribe","onCanceled"])):a("",!0),s.isUnsubscribed?(n(),d(m,{key:1,fields:i.fields},null,8,["fields"])):a("",!0),s.isCanceled?(n(),d(w,{key:2,fields:i.fields},null,8,["fields"])):a("",!0)]),_:1})])}const st=S(Pe,[["render",tt]]),it={name:"NewsletterFi",components:{BreadcrumbFi:K,CloudImageFi:J,ComponentWrapper:z,GridContainerFi:X,NewsletterRegistrationFi:ye,NewsletterSubscribeSuccessFi:De,NewsletterUnsubscribeFi:st},inject:["fields"],props:{customData:{type:Object,default:null},type:{type:String,required:!0}},data(){return{localCustomData:null,newsletterDataLoaded:!1}},computed:{cData(){return this.customData},breadcrumbData(){var t;let e=[];return(t=this.cData)!=null&&t.breadcrumb&&(e=this.cData.breadcrumb),e}},async created(){},methods:{async localData(){}}},nt={class:"newsletter-fi__image"},rt=["innerHTML"],at={class:"newsletter-fi__content"},lt={class:"newsletter-fi__breadcrumb"},ot={class:"newsletter-fi__content-module"};function dt(e,t,r,c,s,i){const u=o("cloud-image-fi"),g=o("breadcrumb-fi"),m=o("newsletter-registration-fi"),w=o("newsletter-subscribe-success-fi"),v=o("newsletter-unsubscribe-fi"),p=o("grid-container-fi"),T=o("component-wrapper");return n(),d(T,{class:"newsletter-fi"},{default:h(()=>[_(p,{container:!1},{default:h(()=>{var L;return[y("div",nt,[e.isEditMode?(n(),l("div",{key:0,class:"image-fi__editable-image","full-height":"",innerHTML:(L=i.fields.image)==null?void 0:L.editable},null,8,rt)):(n(),d(B,{key:1,"enter-active-class":"animated fadeIn"},{default:h(()=>{var M;return[s.newsletterDataLoaded&&((M=i.fields.image)!=null&&M.value)?(n(),d(u,{key:0,class:"image-fi__img",src:i.fields.image.value.src,alt:i.fields.image.value.alt?i.fields.image.value.alt:null,title:i.fields.image.value.title?i.fields.image.value.title:null,params:"func=crop","full-height":""},null,8,["src","alt","title"])):a("",!0)]}),_:1}))]),y("div",at,[y("div",lt,[_(g,{"breadcrumb-data":i.breadcrumbData,"force-breadcrumb":""},null,8,["breadcrumb-data"])]),_(p,null,{default:h(()=>[y("div",ot,[r.type==="registration"?(n(),d(m,{key:0,"data-test":"newsletter-registration",onNewsletterDataLoaded:t[0]||(t[0]=M=>s.newsletterDataLoaded=!0)})):a("",!0),r.type==="subscribe-success"?(n(),d(w,{key:1,"data-test":"newsletter-subscribe-success",onNewsletterDataLoaded:t[1]||(t[1]=M=>s.newsletterDataLoaded=!0)})):a("",!0),r.type==="unsubscribe"?(n(),d(v,{key:2,"data-test":"newsletter-unsubscribe",onNewsletterDataLoaded:t[2]||(t[2]=M=>s.newsletterDataLoaded=!0)})):a("",!0)])]),_:1})])]}),_:1})]),_:1})}const mt=S(it,[["render",dt],["__scopeId","data-v-0911f7ba"]]);export{mt as N};