import{a as f,b as D}from"./chunk-BWL33736.js";import{a as m,b as y}from"./chunk-ICWTV5LB.js";import{a as v,b}from"./chunk-LK2BF24O.js";import{a as u,b as q}from"./chunk-TS62PHQY.js";import{Eb as c,Gd as S,J as s,Qb as l,Sb as p,X as h,ha as d,ia as r,ka as a,na as g,x as n}from"./chunk-JSJB5BKT.js";import{e as I}from"./chunk-SZAW6ZBW.js";var B,P=I(()=>{g();q();S();D();y();b();B=(()=>{class t extends u{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=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(m),c(v))}}static{this.\u0275dir=l({type:t,features:[p]})}}return t})()});export{B as a,P as b};
