import{b as t,H as a}from"./p-6bf07a28.js";import{S as e}from"./p-935e7cfc.js";const{state:s,onChange:n}=t({goals:[],goalsLoading:!1,goalLoading:!1}),r={state:s,onChange:n};class o{constructor(){}static getInstance(){return o.instance||(o.instance=new o),o.instance}async getAllAppData(t){return await a.http.get(`api/v1/AppData/${t}`)}async createAppData(t){return await a.http.post("api/v1/AppData/",t)}async updateAppData(t){return await a.http.put(`api/v1/AppData/${t.Id}`,t)}async getAllGoals(){r.state.goalsLoading=!0;let t=await this.getAllAppData(e.MY_GOALS_APP_ID);return t&&(r.state.goals=t.Data.map((t=>Object.assign(Object.assign({},t),{AppData:JSON.parse(t.AppJsonData)}))),r.state.goalsLoading=!1),t}async createGoal(t){r.state.goalLoading=!0;let a=await this.createAppData(t);return a&&(a.Data.AppData=JSON.parse(a.Data.AppJsonData),r.state.goals=[...r.state.goals,a.Data],r.state.goalLoading=!1),a}async updateGoal(t){r.state.goalLoading=!0;let a=await this.updateAppData(t);return a&&(a.Data.AppData=JSON.parse(a.Data.AppJsonData),r.state.goals=r.state.goals.map((t=>t.Id==a.Data.Id?Object.assign(Object.assign({},a.Data),{AppData:JSON.parse(a.Data.AppJsonData)}):t)),r.state.goalLoading=!1),a}}const{state:c,reset:p}=t({posts:[],postsLoading:!1,createPostLoading:!1,postIdLoading:null}),i={state:c,reset:p};class l{constructor(){}static getInstance(){return l.instance||(l.instance=new l),l.instance}async getAllPosts(){i.state.postsLoading=!0;let t=await a.http.get("api/v1/Feed/GetAll");return t&&(i.state.posts=t.Data,i.state.postsLoading=!1),t}async createPost(t){i.state.createPostLoading=!0;let e=await a.http.post("api/v1/Feed/PostFeed",t);return e&&(i.state.posts=[e.Data,...i.state.posts],i.state.createPostLoading=!1),e}async createPostComment(t){i.state.postIdLoading=t.PostId;let e=await a.http.post("api/v1/Feed/Comment",t);return e&&(i.state.posts=i.state.posts.map((t=>t.Id==e.Data.ClassFeedPostId?Object.assign(Object.assign({},t),{Comments:[...t.Comments,e.Data]}):t)),i.state.postIdLoading=null),e}}export{o as A,l as F,i as f,r as g}