import{a as f,b as D}from"./chunk-HFFJGLC6.js";import{a as u,b as y}from"./chunk-WMHCILDY.js";import{a as v,b}from"./chunk-6Q7YU3GA.js";import{a as m,b as q}from"./chunk-UIVS6623.js";import{Fb as c,J as s,Rd as S,Sb as l,Ub as p,X as h,ha as d,ia as r,ka as a,na as g,x as n}from"./chunk-4HFZZ7HS.js";import{e as I}from"./chunk-SZAW6ZBW.js";var B,P=I(()=>{g();q();S();D();y();b();B=(()=>{class t extends m{constructor(e,i,o){super(),this.editService=e,this.crudService=i,this.longOperationIndicatorService=o,this.displayDialog=!1,this.editMode=!1}ngOnInit(){this.subscribeToEditRequest(),this.subscribeToCreateRequest()}save(e){this.saveItem(e)}cancel(){this.callActionCancel()}saveItem(e){this.longOperationIndicatorService.showIndicator(),this.crudService.save(this.item).pipe(h(()=>this.longOperationIndicatorService.hideIndicator()),a(()=>this.longOperationIndicatorService.hideIndicator()),s(i=>!!i),r(this.destroyed$)).subscribe(i=>{this.callActionAccept(),e&&e(i)})}callActionAccept(e=!0){this.requestParams&&this.requestParams.accept&&(this.requestParams.accept(),this.requestParams=null),e&&(this.displayDialog=!1)}callActionCancel(e=!0){this.requestParams&&this.requestParams.cancel&&(this.requestParams.cancel(),this.requestParams=null),e&&(this.displayDialog=!1)}subscribeToEditRequest(){let e=i=>this.crudService.get(i.id).pipe(n(o=>({request:i,item:o})),a(()=>this.longOperationIndicatorService.hideIndicator()));this.editService.editRequest.pipe(s(i=>i.key===this.key),a(()=>this.longOperationIndicatorService.showIndicator()),d(i=>e(i)),r(this.destroyed$)).subscribe({next:i=>{this.editMode=!0,this.requestParams=i.request,this.item=this.initItem?this.initItem(i.item):i.item,this.displayDialog=!!this.item},complete:()=>this.longOperationIndicatorService.hideIndicator()})}subscribeToCreateRequest(){this.editService.createRequest.pipe(s(e=>e.key===this.key),r(this.destroyed$)).subscribe(e=>{this.editMode=!1,this.requestParams=e,this.item=this.createEmptyItem(e.data),this.displayDialog=!0})}static{this.\u0275fac=function(i){return new(i||t)(c(f),c(u),c(v))}}static{this.\u0275dir=l({type:t,features:[p]})}}return t})()});export{B as a,P as b};
