import{H as t}from"./p-1d4c7c11.js";import{d as a}from"./p-2f569553.js";import{S as e}from"./p-935e7cfc.js";const{state:s,onChange:n}=a({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(a){return await t.http.get(`api/v1/AppData/${a}`)}async createAppData(a){return await t.http.post("api/v1/AppData/",a)}async updateAppData(a){return await t.http.put(`api/v1/AppData/${a.Id}`,a)}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}=a({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 a=await t.http.get("api/v1/Feed/GetAll");return a&&(i.state.posts=a.Data,i.state.postsLoading=!1),a}async createPost(a){i.state.createPostLoading=!0;let e=await t.http.post("api/v1/Feed/PostFeed",a);return e&&(i.state.posts=[e.Data,...i.state.posts],i.state.createPostLoading=!1),e}async createPostComment(a){i.state.postIdLoading=a.PostId;let e=await t.http.post("api/v1/Feed/Comment",a);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}