import{i as h,k as S,y as g,z as v}from"./chunk-ZIVZTBTN.js";import{Z as y,ba as p,qe as k,wd as E}from"./chunk-OX24XL2F.js";import{i as u,j as d}from"./chunk-FQ4ILEWG.js";var b=(()=>{let a=class a{formBuilder=p(v);buildForm(o,t={}){let r={},n={},i={};for(let s of Object.keys(o)){r[s]="";let c=o[s];if(this.isRecursiveField(c)){let m=this.buildForm(c,t[s]);i[s]=m.form,r[s]=m.formErrors,n[s]=m.validationMessages;continue}c?.MESSAGES&&(n[s]=c.MESSAGES);let f=t[s]??"";c?.VALIDATORS?i[s]=[f,c.VALIDATORS]:i[s]=[f]}return{form:this.formBuilder.group(i),formErrors:r,validationMessages:n}}updateFormGroup(o,t,r,n,i={}){for(let e of k(n)){let s=n[e];if(this.isRecursiveField(s)){t[e]={},this.updateFormGroup(o[e],t[e],r[e],n[e],i[e]);continue}t[e]="",s?.MESSAGES&&(r[e]=s.MESSAGES);let c=i[e]??"";o.addControl(e+"",new S(c,s?.VALIDATORS,s?.ASYNC_VALIDATORS))}}addControlInFormArray(o){let{formArray:t,formErrors:r,validationMessages:n,controlName:i,formToBuild:e,defaultValues:s={}}=o,c=new h({});r[i]||(r[i]=[]),n[i]||(n[i]=[]);let f=r[i],m=n[i],A=t.controls.length;f.push({}),m.push({}),this.updateFormGroup(c,f[A],m[A],e,s),t.push(c)}removeControlFromFormArray(o){let{formArray:t,formErrors:r,validationMessages:n,index:i,controlName:e}=o,s=r[e],c=n[e];s.splice(i,1),c.splice(i,1),t.removeAt(i)}updateTreeValidity(o){for(let t of Object.keys(o.controls)){let r=o.controls[t];r instanceof h||r instanceof g?this.updateTreeValidity(r):r.updateValueAndValidity({emitEvent:!1})}}isRecursiveField(o){return o&&typeof o=="object"&&!o.MESSAGES&&!o.VALIDATORS}};u(a,"\u0275fac",function(t){return new(t||a)}),u(a,"\u0275prov",y({token:a,factory:a.\u0275fac}));let l=a;return l})();var L=(()=>{let a=class a{formValidatorService=p(b);buildForm(o,t={}){let{formErrors:r,validationMessages:n,form:i}=this.formValidatorService.buildForm(o,t);return i.statusChanges.subscribe(()=>d(this,null,function*(){yield this.waitPendingCheck(i),this.onStatusChanged({form:i,formErrors:r,validationMessages:n})})),{form:i,formErrors:r,validationMessages:n}}waitPendingCheck(o){return d(this,null,function*(){if(o.status==="PENDING")do yield E(10);while(o.status==="PENDING")})}markAllAsDirty(o){let t=o;for(let r of Object.keys(t)){let n=t[r];if(n instanceof h){this.markAllAsDirty(n.controls);continue}n.markAsDirty()}}forceCheck(o,t,r){this.onStatusChanged({form:o,formErrors:t,validationMessages:r,onlyDirty:!1})}onStatusChanged(o){let{form:t,formErrors:r,validationMessages:n,onlyDirty:i=!0}=o;for(let e of Object.keys(r)){if(r[e]&&typeof r[e]=="object"){this.onStatusChanged({form:t.controls[e],formErrors:r[e],validationMessages:n[e],onlyDirty:i});continue}r[e]="";let s=t.get(e);if(!s||i&&!s.dirty||!s.enabled||!s.errors)continue;let c=n[e];for(let f of Object.keys(s.errors)){let m=s.errors[f];if(c[f])r[e]+=c[f]+" ";else if(typeof m=="string")r[e]+=s.errors[f];else throw new Error("Form error value of "+e+" is invalid")}}}};u(a,"\u0275fac",function(t){return new(t||a)}),u(a,"\u0275prov",y({token:a,factory:a.\u0275fac}));let l=a;return l})();var F=class{formChanged=!1;form;formErrors;validationMessages;buildForm(a,C={}){let{formErrors:o,validationMessages:t,form:r}=this.formReactiveService.buildForm(a,C);this.form=r,this.formErrors=o,this.validationMessages=t}waitPendingCheck(){return d(this,null,function*(){return this.formReactiveService.waitPendingCheck(this.form)})}markAllAsDirty(){return this.formReactiveService.markAllAsDirty(this.form.controls)}forceCheck(){return this.formReactiveService.forceCheck(this.form,this.formErrors,this.validationMessages)}};export{b as a,L as b,F as c};
/**i18n:93ef1b86561141301263c1f349fa8abb749523958c3a6dfaf46ed36d22b0a506*/
//# sourceMappingURL=chunk-67RJ5AZW.js.map
