import{a as p}from"./chunk-J4MLQVIK.js";import{a as d}from"./chunk-SFW4HL5C.js";import{h as f,y as V}from"./chunk-WEQN5LYX.js";import{s,t as k,w as u,x as L}from"./chunk-EAEGBVDW.js";import{c as m,d as v}from"./chunk-FD5DZJ6H.js";import{k as a}from"./chunk-AVXTYPYF.js";import{f as h,i as g}from"./chunk-YKFX4MVT.js";import{T as c,ka as n,la as S,od as b,qa as l,v as i,va as o}from"./chunk-HEIW4SFT.js";V();S();v();k();b();g();L();var C=(()=>{class r extends d{get model$(){return this._model$}get attachments$(){return this._attachments$}get connections$(){return this._connections$}get chatLog$(){return this._chatLog$}get isEditMode(){return m.isSet(this.model?.id)}constructor(t,e,w){super(),this.http=t,this.apiService=e,this.router=w,this.model=null,this.modelS=new i(1),this._model$=this.modelS.asObservable(),this.attachmentsS=new i(1),this._attachments$=this.attachmentsS.asObservable(),this.connectionsS=new i(1),this._connections$=this.connectionsS.asObservable(),this.chatLogS=new i(1),this._chatLog$=this.chatLogS.asObservable(),this.selectedDocuments=[]}unset(){this.formGroup=void 0}unsetModel(){this.model=null,this.modelS.next(null),this.attachmentsS.next(null),this.connectionsS.next(null),this.chatLogS.next(null)}fetch(t){return this.apiService.get(s.tasks.fetch(t)).pipe(n(e=>{this.shouldRedirectToTravelOrder(e)||this.shouldRedirectToLocation(e)||(this.unsetModel(),this.formGroup=new f([]),this.model=e,this.modelS.next(e))}),c(e=>{throw console.error("Error fetching task",e),e}))}fetchAttachmentsList(t){this.apiService.get(s.attachments.fetchAttachmentsList(t)).subscribe(e=>{this.attachmentsS.next(e)})}fetchConnectionsList(t){return this.apiService.get(s.documents.fetchConnectionsList(t)).pipe(n(e=>{this.connectionsS.next(e)}))}shouldRedirectToTravelOrder(t){return t&&t.workflowVariables!=null&&t.workflowVariables.documentKey&&t.workflowVariables.documentKey.trim()!==""&&t.docTypeSetOf===p.TravelOrder?(this.router.navigate(["/human-resources/travel-order/positions"],{queryParams:{id:t.workflowVariables.documentKey,taskId:t.id}}),!0):!1}shouldRedirectToLocation(t){return t&&t.workflowVariables&&t.workflowVariables.acType==="L"&&(!t.workflowVariables.location||t.workflowVariables.location.trim()==="")&&t.workflowVariables.address&&t.workflowVariables.address.trim()!==""&&t.actions&&t.actions.length===1?(this.router.navigate(["/code-lists/locations"],{queryParams:{mode:"create",address:t.workflowVariables.address,taskId:t.id}}),!0):!1}static{this.\u0275fac=function(e){return new(e||r)(o(h),o(u),o(a))}}static{this.\u0275prov=l({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})();export{C as a};
