import{c as S,d as D,e as C,f as k}from"./chunk-YQFKMBOB.js";import{E as y,i as g}from"./chunk-TCUK52QT.js";import{a as f,b as B}from"./chunk-JU5LF7AN.js";import{Ab as u,Ac as p,Fb as o,Gc as c,Ia as a,Qb as r,Rd as h,Ta as s,jc as l,wc as m,xc as b,zc as d}from"./chunk-4HFZZ7HS.js";import{e as v}from"./chunk-SZAW6ZBW.js";var V,w=v(()=>{h();D();B();h();y();k();V=(()=>{class e{constructor(t,i){this.isNew=!0,this.disabled=!1,this.type="button",this.onSubmit=new s,this.onClick=new s,this.isSubmitDisabled=!0,this.submitButtonDisabled=!1,t&&(this.parent=t),this.loadingService=i,this.isLoading=!1}ngAfterViewInit(){this.loadingSubscription=this.loadingService.isWorking().subscribe(t=>{t.mode===S.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}static{this.\u0275fac=function(i){return new(i||e)(o(g,9),o(C))}}static{this.\u0275cmp=r({type:e,selectors:[["sd-submit-button"]],inputs:{isNew:"isNew",disabled:"disabled",parent:"parent",type:"type",label:"label"},outputs:{onSubmit:"onSubmit",onClick:"onClick"},features:[a],decls:2,vars:2,consts:[["type","button","variant","primary",3,"onClick","label","disabled"]],template:function(i,n){i&1&&(d(0),m(1,"dvl-button",0),c("onClick",function(){return n.submit()}),b(),p()),i&2&&(u(),l("label",n.label)("disabled",n.isSubmitDisabled))},dependencies:[f],encapsulation:2})}}return e})()});export{V as a,w as b};
