import{a as E}from"./chunk-LDPZ3XS5.js";import{a as k}from"./chunk-LGWYB44Q.js";import{c as p}from"./chunk-IBPO7XYL.js";import{k as m,l as d,u as l,v as h}from"./chunk-QIDUJNWO.js";import{B as w,E as I,G as x,Oa as A,Pa as O,p as t,r as M,s as b,w as R,y as V}from"./chunk-D2E2EQ56.js";import{a as N,b as u}from"./chunk-XVWHZ5TH.js";import{ya as y}from"./chunk-ZZKAL5UM.js";import{Bb as C,Ub as s,dc as T,ec as D,fc as _,gd as P,nb as c,sb as a}from"./chunk-LEOKSAW2.js";import{d as g,n as U}from"./chunk-HE7HQ6LI.js";var i=function(e){return e[e.PurchasePrice=0]="PurchasePrice",e[e.Quantity=1]="Quantity",e[e.Markup=2]="Markup",e[e.NewPrice=3]="NewPrice",e}(i||{});U();var F=class f{constructor(o,r,n,G){this.data=o,this._dialogRef=r,this._fb=n,this._cdr=G,this.form=this._fb.group({changeTo:this._fb.control(null,t.required),fieldForEdit:this._fb.control(null,t.required)})}ngOnInit(){this._dialogRef.submitData$$.next(this.form),this._dialogRef.instance?.submitted.pipe(u(this)).subscribe(()=>this._cdr.markForCheck()),this._validateChangeToField()}_validateChangeToField(){this.form.controls.fieldForEdit.valueChanges.pipe(u(this)).subscribe(o=>{this.form.controls.changeTo.clearValidators(),this.form.controls.changeTo.updateValueAndValidity(),o===i.PurchasePrice&&this.form.controls.changeTo.setValidators([t.required,t.max(m.max),t.min(m.min)]),o===i.Quantity&&(this.data.isOnlyWeight?this.form.controls.changeTo.setValidators([t.required,t.max(l.max),t.min(l.min)]):this.form.controls.changeTo.setValidators([t.required,t.max(h.max),t.min(h.min)])),o===i.Markup&&this.form.controls.changeTo.setValidators([t.required,t.max(d.max),t.min(d.min)]),o===i.NewPrice&&this.form.controls.changeTo.setValidators([t.required,t.max(m.max),t.min(0)]),!this.data.isOnlyWeight&&o!==i.PurchasePrice&&o!==i.NewPrice&&o!==i.Markup&&this.form.controls.changeTo.addValidators(p(t.pattern(/^\d+$/),"\u0412\u044B\u0431\u0440\u0430\u043D\u044B \u0448\u0442\u0443\u0447\u043D\u044B\u0435 \u0442\u043E\u0432\u0430\u0440\u044B")),(o==i.PurchasePrice||o==i.NewPrice||o==i.Markup)&&this.form.controls.changeTo.addValidators(p(t.pattern(/^\d+(\.\d{1,2})?$/),"\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(r){return new(r||f)(a(O),a(A),a(I),a(P))}}static{this.\u0275cmp=C({type:f,selectors:[["tis-mass-editing-dialog"]],decls:3,vars:6,consts:[[3,"formGroup"],["formControlName","fieldForEdit","label","\u041F\u043E\u043B\u0435 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F",3,"options","showClearButton"],["formControlName","changeTo","token","changeTo","label","\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430",3,"showControlButtons","precision","isWeight"]],template:function(r,n){r&1&&(T(0,"form",0),_(1,"tis-dropdown",1)(2,"tis-number-input",2),D()),r&2&&(s("formGroup",n.form),c(),s("options",n.data.options)("showClearButton",!1),c(),s("showControlButtons",!1)("precision",3)("isWeight",n.data.isOnlyWeight))},dependencies:[y,x,R,M,b,V,w,k,E],encapsulation:2,changeDetection:0})}};F=g([N()],F);export{i as a,F as b};
