import{a as t}from"./chunk-2KELYR7M.js";import{a as e,b as g,e as n,f as s}from"./chunk-VFX53AYF.js";import{l as d,m as C,v as T,w as _}from"./chunk-ZVQ5RRLK.js";import{b as G,e as U}from"./chunk-QBYYSEMG.js";import{B as M,D as A,Ia as S,Ja as B,Oa as O,Qa as k,q as R,r as E,u as I,w as V,z as w}from"./chunk-IDENGFF3.js";import{a as N,b as f}from"./chunk-IGFM5CCE.js";import{ua as v}from"./chunk-TDUJNOEU.js";import{Db as b,dc as c,ec as y,fc as F,fd as h,gc as u,gd as p,lb as m,wb as a,zd as P}from"./chunk-I3FGJX2C.js";import{d as D,n as z}from"./chunk-INB5GR2I.js";z();var o,j=(o=class{constructor(i,r,l,x,W){this.data=i,this._dialogRef=r,this._fb=l,this._cdr=x,this._localizationService=W,this.form=this._fb.group({changeTo:this._fb.control(null,e()),fieldForEdit:this._fb.control(null,e())})}ngOnInit(){this._dialogRef.submitData$$.next(this.form),this._dialogRef.instance?.submitted.pipe(f(this)).subscribe(()=>this._cdr.markForCheck()),this._validateChangeToField()}_validateChangeToField(){this.form.controls.fieldForEdit.valueChanges.pipe(f(this)).subscribe(i=>{this.form.controls.changeTo.clearValidators(),this.form.controls.changeTo.updateValueAndValidity(),i===t.PurchasePrice&&this.form.controls.changeTo.setValidators([e(),n(d.max),s(d.min)]),i===t.Quantity&&(this.data.isOnlyWeight?this.form.controls.changeTo.setValidators([e(),n(T.max),s(T.min)]):this.form.controls.changeTo.setValidators([e(),n(_.max),s(_.min)])),i===t.Markup&&this.form.controls.changeTo.setValidators([e(),n(C.max),s(C.min)]),i===t.NewPrice&&this.form.controls.changeTo.setValidators([e(),n(d.max),s(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()})}},o.\u0275fac=function(r){return new(r||o)(a(B),a(S),a(M),a(P),a(U))},o.\u0275cmp=b({type:o,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(r,l){r&1&&(y(0,"form",0),u(1,"wk-dropdown",1),h(2,"translate"),u(3,"wk-number-input",2),h(4,"translate"),F()),r&2&&(c("formGroup",l.form),m(),c("requiredForLabel",!0)("options",l.data.options)("showClearButton",!1)("label",p(2,9,"\u041F\u043E\u043B\u0435 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F")),m(2),c("showControlButtons",!1)("precision",3)("isWeight",l.data.isOnlyWeight)("label",p(4,11,"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430")))},dependencies:[v,A,I,R,E,V,w,O,k,G],encapsulation:2,changeDetection:0}),o);j=D([N()],j);export{j as a};
//# sourceMappingURL=chunk-JPLCIMG4.js.map
