import{c as C,d as B,e as v,f as w}from"./chunk-YQYH6YEK.js";import{cb as S,zb as k}from"./chunk-V2ECYACM.js";import{E as D,i as f}from"./chunk-JPHJ3OD7.js";import{Ac as p,Bc as c,Db as o,Hc as h,Jb as a,Qb as u,Wa as r,be as g,tc as b,uc as m,vc as d,yb as l}from"./chunk-WL5U2YIT.js";import{e as y}from"./chunk-ADEKKGI2.js";var W,L=y(()=>{g();B();k();g();D();w();W=(()=>{let i=class i{constructor(t,e){this.isNew=!0,this.disabled=!1,this.type="button",this.onSubmit=new o,this.onClick=new o,this.isSubmitDisabled=!0,this.submitButtonDisabled=!1,t&&(this.parent=t),this.loadingService=e,this.isLoading=!1}ngAfterViewInit(){this.loadingSubscription=this.loadingService.isWorking().subscribe(t=>{t.mode===C.Local&&(this.isLoading=t.isLoading,this.toggleSubmitButton())}),this.parent.form.valueChanges.subscribe(()=>{this.toggleSubmitButton()})}ngAfterContentChecked(){this.isSubmitDisabled=this.submitButtonDisabled}ngOnChanges(t){this.toggleSubmitButton()}submit(){this.type==="button"&&(this.onSubmit.emit(),this.onClick.emit())}ngOnDestroy(){this.loadingSubscription&&this.loadingSubscription.unsubscribe()}toggleSubmitButton(){this.submitButtonDisabled=this.isLoading||!this.isNew&&this.parent.pristine||this.disabled||this.parent.form.invalid}};i.\u0275fac=function(e){return new(e||i)(a(f,9),a(v))},i.\u0275cmp=u({type:i,selectors:[["sd-submit-button"]],inputs:{isNew:"isNew",disabled:"disabled",parent:"parent",type:"type",label:"label"},outputs:{onSubmit:"onSubmit",onClick:"onClick"},features:[r],decls:2,vars:2,consts:[["type","button","variant","primary",3,"onClick","label","disabled"]],template:function(e,s){e&1&&(p(0),m(1,"dvl-button",0),h("onClick",function(){return s.submit()}),d(),c()),e&2&&(l(),b("label",s.label)("disabled",s.isSubmitDisabled))},dependencies:[S],encapsulation:2});let n=i;return n})()});export{W as a,L as b};
