import{a as h,b as v,c as w,d as D,e as O}from"./chunk-K5DONN7K.js";import{b as d}from"./chunk-PF3UOPAN.js";import{n,o as f,p as g,q as m}from"./chunk-ZFNKYFYE.js";import{a as C}from"./chunk-UVACHISL.js";import{ka as u,l as s,pa as I,s as p}from"./chunk-N4CITC4N.js";import{a as P,b as S,i}from"./chunk-BAF7YKD7.js";var l,b={projects:{}},c=class j{static{l=this}static projects(e){return Object.values(e.projects)}static getProjectById(e){return g([l],t=>t.projects[e])}constructor(e){this.apiService=e}listProjects(e,t){return i(this,null,function*(){let a=(yield p(this.apiService.listProjectsInOrganisation({organisationId:t.payload.organisationId}))).reduce((r,y)=>S(P({},r),{[y.id]:y}),{});e.patchState({projects:a})})}createProject(e,t){return i(this,null,function*(){let o=yield p(this.apiService.createProjectInOrganisation(t.payload.organisationId,t.payload)),a=d(e.getState(),r=>{r.projects[o.id]=o});e.setState(a)})}updateProject(e,t){return i(this,null,function*(){let o=yield p(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})),a=d(e.getState(),r=>{r.projects[o.id]=o});e.setState(a)})}deleteProject(e,t){return i(this,null,function*(){let o=yield p(this.apiService.deleteProjectInOrganisation(t.payload.organisationId,t.payload.projectId)),a=d(e.getState(),r=>{delete r.projects[t.payload.projectId]});e.setState(a)})}createProjectDesign(e,t){return i(this,null,function*(){let o=yield p(this.apiService.createProjectDesign({organisationId:t.payload.organisationId,projectId:t.payload.projectId,featureCollection:t.payload.featureCollection})),a=d(e.getState(),r=>{r.projects[t.payload.projectId]=o});e.setState(a)})}static{this.\u0275fac=function(t){return new(t||j)(I(C))}}static{this.\u0275prov=u({token:j,factory:j.\u0275fac})}};s([n(h)],c.prototype,"listProjects",null);s([n(v)],c.prototype,"createProject",null);s([n(D)],c.prototype,"updateProject",null);s([n(w)],c.prototype,"deleteProject",null);s([n(O)],c.prototype,"createProjectDesign",null);s([m([c])],c,"projects",null);c=l=s([f({name:"projects",defaults:b})],c);export{c as a};
//# sourceMappingURL=chunk-TEL4DWXS.js.map