import{W as u,fa as b,p as R,r as c,s as f,u as l}from"./chunk-LZWDFT64.js";import{M as n,S as p,V as s,bc as N,g as i}from"./chunk-YEIQIJLV.js";import{a as g,b as C}from"./chunk-IA5I2OHH.js";var j=(()=>{class o{static{this.type="[Dashboard] Statistics Count Get"}constructor(t){this.payload=t}}return o})(),w=(()=>{class o{static{this.type="[Dashboard] Revenue Get"}}return o})();var k=(()=>{class o{static{this.type="[Notice] Get"}constructor(t){this.payload=t}}return o})(),G=(()=>{class o{static{this.type="[Notice] Create"}constructor(t){this.payload=t}}return o})(),A=(()=>{class o{static{this.type="[Notice] Edit"}constructor(t){this.id=t}}return o})(),I=(()=>{class o{static{this.type="[Notice] Resent"}constructor(t){this.id=t}}return o})(),U=(()=>{class o{static{this.type="[Notice] Update"}constructor(t,r){this.payload=t,this.id=r}}return o})();var E=(()=>{class o{static{this.type="[Notice] MarkAsRead"}constructor(t){this.id=t}}return o})(),D=(()=>{class o{static{this.type="[Notice] Delete"}constructor(t){this.id=t}}return o})();var $=(()=>{class o{constructor(t){this.http=t}getStatisticsCount(t){return this.http.get(`${u.URL}/count.json`,{params:t})}getRevenueChart(){return this.http.get(`${u.URL}/chart.json`)}static{this.\u0275fac=function(r){return new(r||o)(s(N))}}static{this.\u0275prov=p({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var h=class S{constructor(e){this.dashboardService=e}static statistics(e){return e.statistics}static revenueChart(e){return e.revenueChart}getStatisticsCount(e,t){return this.dashboardService.getStatisticsCount(t.payload).pipe(n({next:r=>{e.patchState({statistics:r})},error:r=>{throw new Error(r?.error?.message)}}))}getRevenueChart(e){return this.dashboardService.getRevenueChart().pipe(n({next:t=>{e.patchState({revenueChart:t})},error:t=>{throw new Error(t?.error?.message)}}))}static{this.\u0275fac=function(t){return new(t||S)(s($))}}static{this.\u0275prov=p({token:S,factory:S.\u0275fac})}};i([c(j)],h.prototype,"getStatisticsCount",null);i([c(w)],h.prototype,"getRevenueChart",null);i([l()],h,"statistics",null);i([l()],h,"revenueChart",null);h=i([f({name:"dashboard",defaults:{statistics:null,revenueChart:null}})],h);var F=(()=>{class o{constructor(t){this.http=t}getNotice(t){return this.http.get(`${u.URL}/notice.json`,{params:t})}markAsRead(t){return this.http.put(`${u.URL}/notice/markAsRead/${t}`,{})}static{this.\u0275fac=function(r){return new(r||o)(s(N))}}static{this.\u0275prov=p({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var a=class y{constructor(e,t,r){this.store=e,this.notificationService=t,this.noticeService=r}static notice(e){return e.notice}static selectedNotice(e){return e.selectedNotice}static recentNotice(e){return e.recentNotice}getNotices(e,t){return this.noticeService.getNotice(t.payload).pipe(n({next:r=>{e.patchState({notice:{data:r.data,total:r?.total?r?.total:r.data?.length}})},error:r=>{throw new Error(r?.error?.message)}}))}create(e,t){}edit(e,{id:t}){return this.noticeService.getNotice().pipe(n({next:r=>{let d=e.getState(),m=r.data.find(v=>v.id==t);e.patchState(C(g({},d),{selectedNotice:m}))},error:r=>{throw new Error(r?.error?.message)}}))}recentNotice(e,{id:t}){return this.noticeService.getNotice().pipe(n({next:r=>{e.patchState({recentNotice:r.data.length?r.data[0]:null})},error:r=>{throw new Error(r?.error?.message)}}))}update(e,{payload:t,id:r}){}markAsRead(e,{id:t}){return this.noticeService.markAsRead(t).pipe(n({next:r=>{if(typeof r=="object"){let d=e.getState(),m=[...d.notice.data],v=m.findIndex(L=>L.id===t);m[v]=r,e.patchState(C(g({},d),{notice:{data:m,total:d.notice.total},recentNotice:null}))}},error:r=>{throw new Error(r?.error?.message)}}))}delete(e,{id:t}){}static{this.\u0275fac=function(t){return new(t||y)(s(R),s(b),s(F))}}static{this.\u0275prov=p({token:y,factory:y.\u0275fac})}};i([c(k)],a.prototype,"getNotices",null);i([c(G)],a.prototype,"create",null);i([c(A)],a.prototype,"edit",null);i([c(I)],a.prototype,"recentNotice",null);i([c(U)],a.prototype,"update",null);i([c(E)],a.prototype,"markAsRead",null);i([c(D)],a.prototype,"delete",null);i([l()],a,"notice",null);i([l()],a,"selectedNotice",null);i([l()],a,"recentNotice",null);a=i([f({name:"notice",defaults:{notice:{data:[],total:0},selectedNotice:null,recentNotice:null}})],a);export{j as a,w as b,I as c,E as d,h as e,a as f};
