import{a as t}from"./chunk-6UCSAL3G.js";import{a as O}from"./chunk-WL2OYEJL.js";import{a as e,b as g,e as a,f as n}from"./chunk-KGCVL6CP.js";import{l as d,m as _,u as S,v}from"./chunk-LBZE4AC4.js";import{I as k,La as B}from"./chunk-QHAVDXDG.js";import{X as w,Z as A,ca as M,f as z,g as F,j as P,n as N,o as E,q as I,s as V}from"./chunk-27KSTDMK.js";import{z as p}from"./chunk-GQAU5ACB.js";import{Bb as r,Ea as y,Ib as T,fd as f,gd as u,hc as c,ic as b,jc as D,kc as m,qa as C,sb as h,yd as R}from"./chunk-ISMRT7VU.js";var oi=(()=>{class l{constructor(i,o,s,G,U){this.data=i,this._dialogRef=o,this._fb=s,this._cdr=G,this._localizationService=U,this.destroyRef=C(y),this.form=this._fb.group({changeTo:this._fb.control(null,e(!1,this._localizationService.getSync.bind(this._localizationService))),fieldForEdit:this._fb.control(null,e(!1,this._localizationService.getSync.bind(this._localizationService)))})}ngOnInit(){this._dialogRef.submitData$$.next(this.form),this._dialogRef.instance?.submitted.pipe(p(this.destroyRef)).subscribe(()=>this._cdr.markForCheck()),this._validateChangeToField()}_validateChangeToField(){this.form.controls.fieldForEdit.valueChanges.pipe(p(this.destroyRef)).subscribe(i=>{this.form.controls.changeTo.clearValidators(),this.form.controls.changeTo.updateValueAndValidity(),i===t.PurchasePrice&&this.form.controls.changeTo.setValidators([e(!1,this._localizationService.getSync.bind(this._localizationService)),a(d.max),n(d.min)]),i===t.Quantity&&(this.data.isOnlyWeight?this.form.controls.changeTo.setValidators([e(!1,this._localizationService.getSync.bind(this._localizationService)),a(S.max),n(S.min)]):this.form.controls.changeTo.setValidators([e(!1,this._localizationService.getSync.bind(this._localizationService)),a(v.max),n(v.min)])),i===t.Markup&&this.form.controls.changeTo.setValidators([e(!1,this._localizationService.getSync.bind(this._localizationService)),a(_.max),n(_.min)]),i===t.NewPrice&&this.form.controls.changeTo.setValidators([e(!1,this._localizationService.getSync.bind(this._localizationService)),a(d.max),n(0)]),!this.data.isOnlyWeight&&i!==t.PurchasePrice&&i!==t.NewPrice&&i!==t.Markup&&this.form.controls.changeTo.addValidators(g(/^\d+$/,this._localizationService.getSync("\u0412\u044B\u0431\u0440\u0430\u043D\u044B \u0448\u0442\u0443\u0447\u043D\u044B\u0435 \u0442\u043E\u0432\u0430\u0440\u044B"))),(i==t.PurchasePrice||i==t.NewPrice||i==t.Markup)&&this.form.controls.changeTo.addValidators(g(/^\d+(\.\d{1,2})?$/,this._localizationService.getSync("\u0414\u043E\u043F\u0443\u0441\u0442\u0438\u043C\u0430 \u0446\u0435\u043D\u0430 \u0442\u043E\u043B\u044C\u043A\u043E \u0441 \u0434\u0432\u0443\u043C\u044F \u0437\u043D\u0430\u043A\u0430\u043C\u0438 \u043F\u043E\u0441\u043B\u0435 \u0442\u043E\u0447\u043A\u0438"))),this.form.controls.changeTo.updateValueAndValidity(),this._cdr.detectChanges()})}static{this.\u0275fac=function(o){return new(o||l)(r(A),r(w),r(I),r(R),r(B))}}static{this.\u0275cmp=T({type:l,selectors:[["tis-mass-editing-dialog"]],decls:5,vars:13,consts:[[3,"formGroup"],["formControlName","fieldForEdit",3,"requiredForLabel","options","showClearButton","label"],["formControlName","changeTo","token","changeTo",3,"showControlButtons","precision","isWeight","label"]],template:function(o,s){o&1&&(b(0,"form",0),m(1,"wk-dropdown",1),f(2,"translate"),m(3,"wk-number-input",2),f(4,"translate"),D()),o&2&&(c("formGroup",s.form),h(),c("requiredForLabel",!0)("options",s.data.options)("showClearButton",!1)("label",u(2,9,"\u041F\u043E\u043B\u0435 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F")),h(2),c("showControlButtons",!1)("precision",3)("isWeight",s.data.isOnlyWeight)("label",u(4,11,"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430")))},dependencies:[V,P,z,F,E,N,M,O,k],encapsulation:2,changeDetection:0})}}return l})();export{oi as a};
//# sourceMappingURL=chunk-QDKRXVST.js.map
