import{a as w,b as j,c as b,d as g,e as F}from"./chunk-KULNRCN7.js";import{a as T}from"./chunk-PF3UOPAN.js";import{d as U}from"./chunk-3QA2AJ76.js";import{p as l,q as v,r as p,s as u}from"./chunk-R37RAKSP.js";import{ha as m,l as a,ma as h,s as i}from"./chunk-AYX7PVNL.js";import{a as y,b as f,i as r}from"./chunk-BAF7YKD7.js";var n,O={todos:{},selectedTodoId:null},d=class S{static{n=this}static get(t){return p([n],o=>{let e=o.todos[t];return e||null})}static listByParentId(t){return p([n],o=>Object.values(o.todos).filter(s=>s.parentId===t))}static todos(t){return Object.values(t.todos)}static selectedTodo(t){let o=Object.values(t.todos),e=t.todos[t.selectedTodoId||""];return f(y({},e),{children:o.filter(s=>s.parentId===e?.id)})}static newestTodoId(t){let o=Object.keys(t.todos),e=o[o.length-1];return t.todos[e]?.id}static getType(t){return p([n.todos],o=>o.filter(e=>e.todoType===t))}constructor(t){this.apiService=t}listTodosForUpload(t,o){return r(this,null,function*(){let s=(yield i(this.apiService.listTodosForUpload({uploadId:o.payload.uploadId}))).reduce((c,I)=>f(y({},c),{[I.id]:I}),{});t.patchState({todos:s})})}setSelectedTodoId(t,o){return r(this,null,function*(){t.patchState({selectedTodoId:o.payload.todoId})})}createTodo(t,o){return r(this,null,function*(){let e=yield i(this.apiService.createTodo(o.payload.todo)),s=T(t.getState(),c=>{c.todos[e.id]=e});t.setState(s)})}updateTodo(t,o){return r(this,null,function*(){let e=yield i(this.apiService.updateTodo(o.payload.id,o.payload.todo)),s=T(t.getState(),c=>{c.todos[e.id]=e});t.setState(s)})}deleteTodo(t,o){return r(this,null,function*(){yield i(this.apiService.deleteTodo(o.payload.uploadId,o.payload.todoId));let e=T(t.getState(),s=>{delete s.todos[o.payload.todoId]});t.setState(e)})}static{this.\u0275fac=function(o){return new(o||S)(h(U))}}static{this.\u0275prov=m({token:S,factory:S.\u0275fac})}};a([l(w)],d.prototype,"listTodosForUpload",null);a([l(j)],d.prototype,"setSelectedTodoId",null);a([l(b)],d.prototype,"createTodo",null);a([l(F)],d.prototype,"updateTodo",null);a([l(g)],d.prototype,"deleteTodo",null);a([u([d])],d,"todos",null);a([u([d])],d,"selectedTodo",null);a([u([d])],d,"newestTodoId",null);d=n=a([v({name:"todos",defaults:O})],d);export{d as a}; //# sourceMappingURL=chunk-LHZJCYGG.js.map