import{a as h,b as v,c as w,d as D,e as O}from"./chunk-IBTTRWMZ.js";import{b as l}from"./chunk-MXERDDBQ.js";import{n as d,o as f,p as g,q as m}from"./chunk-ZYAGUDC2.js";import{a as C}from"./chunk-2M7Q7RS4.js";import{ja as I,l as i,na as S,s as n}from"./chunk-EJ5TQG27.js";import{a as u,b as P,g as p}from"./chunk-NZN5XTIE.js";var j,b={projects:{}},o,s=(o=class{static projects(e){return Object.values(e.projects)}static getProjectById(e){return g([j],t=>t.projects[e])}constructor(e){this.apiService=e}listProjects(e,t){return p(this,null,function*(){let r=(yield n(this.apiService.listProjectsInOrganisation({organisationId:t.payload.organisationId}))).reduce((c,y)=>P(u({},c),{[y.id]:y}),{});e.patchState({projects:r})})}createProject(e,t){return p(this,null,function*(){let a=yield n(this.apiService.createProjectInOrganisation(t.payload.organisationId,t.payload)),r=l(e.getState(),c=>{c.projects[a.id]=a});e.setState(r)})}updateProject(e,t){return p(this,null,function*(){let a=yield n(this.apiService.updateProjectInOrganisation(t.payload.organisationId,{id:t.payload.id,name:t.payload.name,description:t.payload.description,code:t.payload.code,fileIds:t.payload.fileIds})),r=l(e.getState(),c=>{c.projects[a.id]=a});e.setState(r)})}deleteProject(e,t){return p(this,null,function*(){let a=yield n(this.apiService.deleteProjectInOrganisation(t.payload.organisationId,t.payload.projectId)),r=l(e.getState(),c=>{delete c.projects[t.payload.projectId]});e.setState(r)})}createProjectDesign(e,t){return p(this,null,function*(){let a=yield n(this.apiService.createProjectDesign({organisationId:t.payload.organisationId,projectId:t.payload.projectId,featureCollection:t.payload.featureCollection})),r=l(e.getState(),c=>{c.projects[t.payload.projectId]=a});e.setState(r)})}},j=o,o.\u0275fac=function(t){return new(t||o)(S(C))},o.\u0275prov=I({token:o,factory:o.\u0275fac}),o);i([d(h)],s.prototype,"listProjects",null);i([d(v)],s.prototype,"createProject",null);i([d(D)],s.prototype,"updateProject",null);i([d(w)],s.prototype,"deleteProject",null);i([d(O)],s.prototype,"createProjectDesign",null);i([m([s])],s,"projects",null);s=j=i([f({name:"projects",defaults:b})],s);export{s as a};
//# sourceMappingURL=chunk-A3UV6SBR.js.map