import{a as q}from"./chunk-KLA2UHCO.js";import{a as xe}from"./chunk-4TS5TSPC.js";import{a as F}from"./chunk-YII4XRFM.js";import{a as ge,d as be}from"./chunk-ZSVIZXE3.js";import{b as ve}from"./chunk-ISDPQX42.js";import{Qo as _e,_d as w,me as fe,pe as he}from"./chunk-RQDYBYBM.js";import{A as pe,H as de,I as ue,c as ne,e as f,f as oe,g as re,m as ae,o as le,q as ce,t as se,w as me}from"./chunk-DX7LHTFF.js";import{$d as W,Aa as I,Ab as s,Ba as T,Bb as u,Cb as v,Db as x,Fb as k,Ge as ee,Kb as N,Lb as g,N as B,Ua as t,Va as b,Vc as Y,Wc as z,Xc as J,Yb as p,_b as d,ae as Z,bd as Q,be as U,c as M,da as D,ea as L,ga as P,gf as te,ib as _,ic as E,la as H,lc as X,oa as O,ob as r,qb as $,rc as n,s as C,sc as o,ta as R,yh as ie,zb as l}from"./chunk-N6B2OJOY.js";import{a as y,b as A,l as K}from"./chunk-GHL4OFBQ.js";var Ie=U(_e,i=>i.contact),ye=U(Ie,i=>({loading:i.loading,loaded:i.loaded,error:i.error}));var Fe=(()=>{let c=class c{constructor(e,m){this._foerchStore=e,this._userIdService=m}send(e){let m=y({},e);delete m.contactType,m.callbackTime===null&&delete m.callbackTime,this._userIdService.getUserId().pipe(B(1)).subscribe(h=>{this._foerchStore.dispatch(new fe({userId:h,contact:m}))})}resetLoadingState(){this._foerchStore.dispatch(new he)}getLoadingState(){return this._foerchStore.pipe(Z(ye))}};c.\u0275fac=function(m){return new(m||c)(O(W),O(ee))},c.\u0275prov=H({token:c,factory:c.\u0275fac,providedIn:"root"});let i=c;return i})();var Be=()=>({loaded:!1,loading:!1}),Pe=(i,c,a)=>({loadingState:i,isUserLoggedIn:c,shouldShowTitle:a}),G=()=>[];function ke(i,c){i&1&&(l(0,"div",4)(1,"h1",5),p(2),n(3,"cxTranslate"),s(),l(4,"div",6),p(5),n(6,"cxTranslate"),s()()),i&2&&(t(2),d(" ",o(3,2,"contactForm.messageSentHeader")," "),t(3),d(" ",o(6,4,"contactForm.messageSentSubheader")," "))}function we(i,c){if(i&1&&(l(0,"div",28),p(1),n(2,"cxTranslate"),s()),i&2){let a=g(3);$("form-helptext_danger",a.form.controls.message.invalid),t(),d(" ",o(2,3,"contactForm.message.tooShortError")," ")}}function Ve(i,c){if(i&1&&(v(0),l(1,"div",17)(2,"ng-select",29),n(3,"cxTranslate"),l(4,"ng-option",23),n(5,"cxTranslate"),p(6),n(7,"cxTranslate"),s(),l(8,"ng-option",23),n(9,"cxTranslate"),p(10),n(11,"cxTranslate"),s(),l(12,"ng-option",23),n(13,"cxTranslate"),p(14),n(15,"cxTranslate"),s()()(),u(16,"foerch-input",30),n(17,"cxTranslate"),x()),i&2){let a=g(3);t(2),r("clearable",!1)("placeholder",o(3,11,"contactForm.callbackTime")+"*")("searchable",!1),t(2),r("value",o(5,13,"contactForm.callbackASAP")),t(2),d("",o(7,15,"contactForm.callbackASAP")," "),t(2),r("value",o(9,17,"contactForm.callbackMorning")),t(2),d("",o(11,19,"contactForm.callbackMorning")," "),t(2),r("value",o(13,21,"contactForm.callbackAfternoon")),t(2),d("",o(15,23,"contactForm.callbackAfternoon")," "),t(2),r("errorMsg",a.form.controls.callbackNumber.invalid&&(a.form.controls.callbackNumber.touched||a.form.controls.callbackNumber.dirty)?"contactForm.missingCallbackNumber":"")("labelAndPlaceholder",o(17,25,"contactForm.callbackNumber")+"*")}}function Me(i,c){if(i&1){let a=k();v(0),l(1,"div",17)(2,"ng-select",47),n(3,"cxTranslate"),N("change",function(m){I(a);let h=g(4);return T(h.salesDivisionChanged(m))}),s()(),x()}if(i&2){let a=c.ngIf;t(2),r("clearable",!1)("items",a||E(6,G))("placeholder",o(3,4,"contactForm.sector")+"*")("searchable",!1)}}function De(i,c){if(i&1&&(v(0),l(1,"div",17),u(2,"ng-select",48),n(3,"cxTranslate"),s(),x()),i&2){let a=c.ngIf;t(2),r("clearable",!1)("items",a||E(6,G))("placeholder",o(3,4,"contactForm.industryName")+"*")("searchable",!1)}}function Le(i,c){if(i&1&&(l(0,"label",52),u(1,"input",53),l(2,"div",54),p(3),s()()),i&2){let a=c.$implicit;t(),r("value",a.code),t(2),d(" ",a.name," ")}}function Oe(i,c){if(i&1&&(v(0),l(1,"label",49),p(2),n(3,"cxTranslate"),s(),l(4,"div",50),_(5,Le,4,2,"label",51),n(6,"async"),s(),x()),i&2){let a=g(4);t(2),d("",o(3,3,"contactForm.titleCode"),"*"),t(3),r("ngForOf",o(6,5,a.titles$))("ngForTrackBy",a.trackByIndex)}}function $e(i,c){if(i&1&&(v(0),l(1,"div",17),u(2,"ng-select",55),n(3,"cxTranslate"),s(),x()),i&2){let a=c.ngIf;t(2),r("clearable",!1)("items",a||E(6,G))("placeholder",o(3,4,"contactForm.customerEmployeeOccupation"))("searchable",!1)}}function Ue(i,c){if(i&1&&(v(0),l(1,"div",11)(2,"div",31),p(3),n(4,"cxTranslate"),s(),l(5,"p",13),p(6),n(7,"cxTranslate"),s()(),l(8,"div",11)(9,"fieldset",32)(10,"legend",15),p(11),n(12,"cxTranslate"),s(),_(13,Me,4,7,"ng-container",24),n(14,"async"),_(15,De,4,7,"ng-container",24),n(16,"async"),u(17,"foerch-input",33),n(18,"cxTranslate"),u(19,"foerch-input",34),n(20,"cxTranslate"),u(21,"foerch-input",35),n(22,"cxTranslate"),u(23,"foerch-input",36),n(24,"cxTranslate"),u(25,"foerch-input",37),n(26,"cxTranslate"),u(27,"foerch-input",38),n(28,"cxTranslate"),u(29,"foerch-input",39),n(30,"cxTranslate"),u(31,"foerch-input",40),n(32,"cxTranslate"),s(),l(33,"fieldset",41)(34,"legend",15),p(35),n(36,"cxTranslate"),s(),l(37,"div"),_(38,Oe,7,7,"ng-container",24),s(),u(39,"foerch-input",42),n(40,"cxTranslate"),u(41,"foerch-input",43),n(42,"cxTranslate"),_(43,$e,4,7,"ng-container",24),n(44,"async"),u(45,"foerch-input",44),n(46,"cxTranslate"),u(47,"foerch-input",45),n(48,"cxTranslate"),u(49,"foerch-input",46),n(50,"cxTranslate"),s()(),x()),i&2){let a=g(2).ngIf,e=g();t(3),d(" ",o(4,30,"contactForm.notUser")," "),t(3),d(" ",o(7,32,"contactForm.requiredFields")," "),t(5),d(" ",o(12,34,"contactForm.companyInfo")," "),t(2),r("ngIf",o(14,36,e.salesDivisions$)),t(2),r("ngIf",o(16,38,e.industryGroups$)),t(2),r("labelAndPlaceholder",o(18,40,"contactForm.companyName")+"*"),t(2),r("labelAndPlaceholder",o(20,42,"contactForm.customerNumber")),t(2),r("labelAndPlaceholder",o(22,44,"contactForm.street")+"*"),t(2),r("labelAndPlaceholder",o(24,46,"contactForm.addressInfo")),t(2),r("errorMsg",e.form.controls.postalCode.invalid&&(e.form.controls.postalCode.touched||e.form.controls.postalCode.dirty)?"common.wrongPostalCodeFormat":"")("labelAndPlaceholder",o(26,48,"contactForm.postalCode")+"*"),t(2),r("labelAndPlaceholder",o(28,50,"contactForm.city")+"*"),t(2),r("labelAndPlaceholder",o(30,52,"register.newCustomer.employLabel"))("max",e.MAX_EMPLOYEE_AMOUNT)("min",1),t(2),r("errorMsg",e.form.controls.ustIdNumber.invalid&&(e.form.controls.ustIdNumber.touched||e.form.controls.ustIdNumber.dirty)?"common.wrongVATNumberFormat":"")("labelAndPlaceholder",o(32,54,"contactForm.vatNumber")),t(4),d(" ",o(36,56,"contactForm.personalInfo")," "),t(2),$("form-group",a.shouldShowTitle),t(),r("ngIf",a.shouldShowTitle),t(),r("labelAndPlaceholder",o(40,58,"contactForm.firstName")+"*"),t(2),r("labelAndPlaceholder",o(42,60,"contactForm.lastName")+"*"),t(2),r("ngIf",o(44,62,e.customerEmployeeOccupations$)),t(2),r("errorMsg",e.form.controls.email.invalid&&(e.form.controls.email.touched||e.form.controls.email.dirty)?"common.wrongEmailFormat":"")("labelAndPlaceholder",o(46,64,"contactForm.email")+"*"),t(2),r("errorMsg",e.form.controls.telephone.invalid&&(e.form.controls.telephone.touched||e.form.controls.telephone.dirty)?"common.wrongPhoneFormat":"")("labelAndPlaceholder",o(48,66,"contactForm.phoneStationary")),t(2),r("errorMsg",e.form.controls.mobile.invalid&&(e.form.controls.mobile.touched||e.form.controls.mobile.dirty)?"common.wrongPhoneFormat":"")("labelAndPlaceholder",o(50,68,"contactForm.phoneMobile"))}}function qe(i,c){if(i&1){let a=k();l(0,"button",56),N("click",function(){I(a);let m=g(3);return T(m.clearForm())}),p(1),n(2,"cxTranslate"),s()}i&2&&(t(),d(" ",o(2,1,"contactForm.clearForm")," "))}function je(i,c){if(i&1){let a=k();l(0,"form",7),N("submit",function(){I(a);let m=g(2);return T(m.sendMessage())}),l(1,"h1",8),p(2),n(3,"cxTranslate"),s(),l(4,"h2",9),p(5),n(6,"cxTranslate"),s(),l(7,"div",10)(8,"div",11)(9,"div",12)(10,"p",13),p(11),n(12,"cxTranslate"),s()()(),l(13,"div",11)(14,"fieldset",14)(15,"legend",15),p(16),n(17,"cxTranslate"),s(),l(18,"div",16)(19,"div",17)(20,"div",18),u(21,"textarea",19),n(22,"cxTranslate"),l(23,"label",20),p(24),n(25,"cxTranslate"),s()(),_(26,we,3,5,"div",21),s(),l(27,"div",17)(28,"ng-select",22),n(29,"cxTranslate"),N("change",function(m){I(a);let h=g(2);return T(h.updateValidation(m))}),l(30,"ng-option",23),p(31),n(32,"cxTranslate"),s(),l(33,"ng-option",23),p(34),n(35,"cxTranslate"),s()()(),_(36,Ve,18,27,"ng-container",24),s()()(),_(37,Ue,51,70,"ng-container",24),s(),l(38,"div",25),_(39,qe,3,3,"button",26),l(40,"button",27),p(41),n(42,"cxTranslate"),s()()()}if(i&2){let a=g().ngIf,e=g();r("formGroup",e.form),t(2),d(" ",o(3,21,"contactForm.header")," "),t(3),d(" ",o(6,23,"contactForm.message.label")," "),t(6),d(" ",o(12,25,"contactForm.subtitle")," "),t(3),r("ngClass",a.isUserLoggedIn?"mb-lg-3":""),t(2),d(" ",o(17,27,"contactForm.message.label"),"* "),t(5),r("placeholder",o(22,29,"contactForm.message.placeholder")),t(3),d(" ",o(25,31,"contactForm.message.placeholder")," "),t(2),r("ngIf",e.form.controls.message.invalid&&(e.form.controls.message.dirty||e.form.controls.message.touched)),t(2),r("clearable",!1)("placeholder",o(29,33,"contactForm.contactType")+"*")("searchable",!1),t(2),r("value",e.contactTypes.EMAIL),t(),d("",o(32,35,"contactForm.contactByEmail")," "),t(2),r("value",e.contactTypes.PHONE),t(),d("",o(35,37,"contactForm.contactByPhone")," "),t(2),r("ngIf",e.form.controls.contactType.value===e.contactTypes.PHONE),t(),r("ngIf",!a.isUserLoggedIn),t(2),r("ngIf",e.form.dirty),t(),r("disabled",a.loadingState.loading||e.form.pristine||e.form.invalid),t(),d(" ",o(42,39,"contactForm.submit")," ")}}function Ge(i,c){if(i&1&&(l(0,"div",1),_(1,ke,7,6,"div",2)(2,je,43,41,"form",3),s()),i&2){let a=c.ngIf;t(),r("ngIf",a.loadingState.loaded),t(),r("ngIf",!a.loadingState.loaded)}}var V=function(i){return i[i.EMAIL=0]="EMAIL",i[i.PHONE=1]="PHONE",i}(V||{});function j(i){return!i?.parent?.controls.contactType||i.parent.controls.contactType.value===V.EMAIL||i.value?null:{required:!0}}var vt=(()=>{let c=class c{constructor(e,m,h,S,Se,Ce){this._fb=e,this._authService=m,this._salesDivisionsService=h,this._contactService=S,this._userProfileService=Se,this._baseSiteService=Ce,this.MAX_EMPLOYEE_AMOUNT=q,this.contactTypes=V,this._salesDivisionChanged$=new M,this._defaultTitleCode="",this._ngDestroy$=new M}ngOnDestroy(){this._contactService.resetLoadingState(),this._ngDestroy$.next(),this._ngDestroy$.complete()}ngOnInit(){this.titles$=this._userProfileService.getTitles().pipe(P(e=>{Object.keys(e).length>0&&(this._defaultTitleCode=e[0].code,this.setDefaultTitleCode(this._defaultTitleCode))})),this.loadingState$=this._contactService.getLoadingState().pipe(L(this._ngDestroy$)),this.salesDivisions$=this._salesDivisionsService.getAllSalesDivisions().pipe(C(e=>w(e,"name")),L(this._ngDestroy$)),this.customerEmployeeOccupations$=this._salesDivisionChanged$.pipe(P(()=>{this.form.setValue(A(y({},this.form.value),{occupation:null}))}),D(e=>this._salesDivisionsService.getCustomerEmployeesOccupations(e.PK)),C(e=>w(e,"name"))),this.industryGroups$=this._salesDivisionChanged$.pipe(P(()=>{this.form.setValue(A(y({},this.form.value),{industryGroup:null}))}),D(e=>{let m=e.PK;return this._salesDivisionsService.getIndustryGroupsById(m)}),C(e=>w(e,"name"))),this.shouldShowTitle$=this._baseSiteService.shouldShowTitleForBaseSite(),this.isUserLoggedIn$=this._authService.isUserLoggedIn(),this.isUserLoggedIn$.pipe(C(e=>this.getFormBasedOnAuthState(e))).subscribe(e=>{this.form=e,this.form.reset()})}trackByIndex(e){return e}getFormBasedOnAuthState(e){let m={message:["",[f.required,f.minLength(10)]],contactType:["",f.required],callbackTime:["",j],callbackNumber:["",j]};return this._fb.group(e?m:A(y({},m),{salesDivision:["",[f.required]],industryGroup:["",[f.required]],companyName:["",f.required],customerNumber:["",[],[F.regexpCustomerNumberAsyncValidator(this._baseSiteService,!0)]],postalCode:["",[f.required],[F.regexpPostalCodeAsyncValidator(this._baseSiteService)]],streetName:["",f.required],addressInfo:[""],town:["",f.required],ustIdNumber:["",F.VATNumberValidator],employees:["",[f.min(1),f.max(q),f.required]],email:["",[f.required],[F.regexpEmailAsyncValidator(this._baseSiteService)]],occupation:[""],titleCode:["",[],[F.titleCodeRequiredAsyncValidator(this._baseSiteService)]],firstName:["",f.required],lastName:["",f.required],telephone:[""],mobile:[""]}))}salesDivisionChanged(e){this._salesDivisionChanged$.next(e)}clearForm(){return K(this,null,function*(){this.form.reset(),Object.keys(this.form.controls).forEach(e=>{this.form.get(e).setErrors(null)}),this.form.markAsPristine(),this._authService.isUserLoggedIn().pipe(B(1)).subscribe(e=>{e||this.setDefaultTitleCode(this._defaultTitleCode)})})}sendMessage(){this.form.markAllAsTouched(),this.form.valid&&this._contactService.send(this.form.value)}updateValidation(e){["callbackTime","callbackNumber"].forEach(h=>{let S=this.form.controls[h];e===V.EMAIL?S.clearValidators():S.setValidators(j),S.updateValueAndValidity()})}setDefaultTitleCode(e){this.form.get("titleCode").setValue(e)}};c.\u0275fac=function(m){return new(m||c)(b(pe),b(te),b(ge),b(Fe),b(xe),b(be))},c.\u0275cmp=R({type:c,selectors:[["foerch-contact-form"]],decls:4,vars:12,consts:[["class","container",4,"ngIf"],[1,"container"],["class","text-center",4,"ngIf"],["class","contactForm",3,"formGroup","submit",4,"ngIf"],[1,"text-center"],[1,"display-1"],[1,"subtitle"],[1,"contactForm",3,"submit","formGroup"],[1,"display-1","pb-md-2"],[1,"mb-3"],[1,"row"],[1,"col-lg-6"],[1,"mb-2"],[1,"contactForm-paragraph"],[1,"contactForm-box","contactForm-box_sm-wide","pb-2",3,"ngClass"],[1,"contactForm-legend"],[1,"clearfix"],[1,"form-group"],[1,"form-floating"],["formControlName","message","id","message","required","","rows","4",1,"form-control",3,"placeholder"],["for","message",1,"form-label"],["class","form-helptext",3,"form-helptext_danger",4,"ngIf"],["formControlName","contactType","labelForId","contactType",3,"change","clearable","placeholder","searchable"],[3,"value"],[4,"ngIf"],[1,"text-end","mb-5"],["class","btn btn-secondary me-2","type","button",3,"click",4,"ngIf"],["type","submit",1,"btn","btn-primary",3,"disabled"],[1,"form-helptext"],["formControlName","callbackTime","labelForId","callbackTime",3,"clearable","placeholder","searchable"],["formControlName","callbackNumber","inputId","callbackNumber","type","tel",3,"errorMsg","labelAndPlaceholder"],[1,"h2","mb-2"],[1,"contactForm-box","contactForm-box_sm-wide","pb-2"],["formControlName","companyName","inputId","companyName","type","text",3,"labelAndPlaceholder"],["formControlName","customerNumber","inputId","customerNumber","type","text",3,"labelAndPlaceholder"],["formControlName","streetName","inputId","streetName","type","text",3,"labelAndPlaceholder"],["formControlName","addressInfo","inputId","addressInfo","type","text",3,"labelAndPlaceholder"],["formControlName","postalCode","inputId","postalCode","type","text",3,"errorMsg","labelAndPlaceholder"],["formControlName","town","inputId","town","type","text",3,"labelAndPlaceholder"],["formControlName","employees","inputId","employees","type","number",3,"labelAndPlaceholder","max","min"],["formControlName","ustIdNumber","inputId","ustIdNumber","type","text",3,"errorMsg","labelAndPlaceholder"],[1,"contactForm-box","contactForm-box_sm-wide","mb-lg-3"],["formControlName","firstName","inputId","firstName","type","text",3,"labelAndPlaceholder"],["formControlName","lastName","inputId","lastName","type","text",3,"labelAndPlaceholder"],["formControlName","email","inputId","email","type","email",3,"errorMsg","labelAndPlaceholder"],["formControlName","telephone","inputId","telephone","type","tel",3,"errorMsg","labelAndPlaceholder"],["formControlName","mobile","inputId","mobile","type","tel",3,"errorMsg","labelAndPlaceholder"],["bindLabel","name","bindValue","PK","formControlName","salesDivision","labelForId","salesDivision",3,"change","clearable","items","placeholder","searchable"],["bindLabel","name","bindValue","PK","formControlName","industryGroup","labelForId","industryGroup",3,"clearable","items","placeholder","searchable"],[1,"contactForm-legend","contactForm-legend_small","mb-1"],[1,"custom-buttonSwitch"],["class","custom-buttonSwitch-label",4,"ngFor","ngForOf","ngForTrackBy"],[1,"custom-buttonSwitch-label"],["formControlName","titleCode","type","radio",1,"form-check-input","btn-check","custom-buttonSwitch-input",3,"value"],[1,"btn","btn-block"],["bindLabel","name","bindValue","PK","formControlName","occupation","labelForId","occupation",3,"clearable","items","placeholder","searchable"],["type","button",1,"btn","btn-secondary","me-2",3,"click"]],template:function(m,h){m&1&&(_(0,Ge,3,2,"div",0),n(1,"async"),n(2,"async"),n(3,"async")),m&2&&r("ngIf",X(8,Pe,o(1,1,h.loadingState$)||E(7,Be),o(2,3,h.isUserLoggedIn$),o(3,5,h.shouldShowTitle$)))},dependencies:[Y,z,J,ae,ne,le,oe,re,me,ce,se,ue,de,ve,Q,ie],encapsulation:2,changeDetection:0});let i=c;return i})();export{vt as a};