var m=Object.defineProperty;var G=(e,t,o)=>t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var l=(e,t,o)=>G(e,typeof t!="symbol"?t+"":t,o);import{$ as r,av as g,aw as c,ax as f,ay as p,az as y,aA as L,d as h}from"./DThBoNQI.js";class d{constructor(){l(this,"resource","/api/v2/game-center")}async getLayout(t){try{const o=await r(`${this.resource}/${t}/layout`,{onResponse:({response:n})=>{n.status===204&&(n._data=null)}});return o||null}catch(o){return console.error("[GameCenterRepo] getLayout() Request Failed",o),null}}async getGameHero(t){try{const o=await r(`${this.resource}/${t}/hero`,{onResponse:({response:n})=>{n.status===204&&(n._data=null)}});return o?g(o):null}catch(o){return console.error("[GameCenterRepo] getGameHero() Request Failed",o),null}}async getGameGalleryInfo(t){try{const o=await r(`${this.resource}/${t}/gallery`,{onResponse:({response:n})=>{n.status===204&&(n._data=null)}});return o?c(o):null}catch(o){return console.error("[GameCenterRepo] getGameGalleryInfo() Request Failed",o),null}}async getStories(t){try{const o=await r(`${this.resource}/${t}/stories`,{onResponse:({response:n})=>{n.status===204&&(n._data=null)}});return o||null}catch(o){return console.error("[GameCenterRepo] getStories() Request Failed",o),null}}async getGameInfo(t){try{const o=await r(`${this.resource}/${t}/game-info`,{onResponse:({response:n})=>{n.status===204&&(n._data=null)}});return o?f(o):null}catch(o){return console.error("[GameCenterRepo] getGameInfo() Request Failed",o),null}}async getOpponentHistory(t){try{const o=await r(`${this.resource}/${t}/opponent-history`,{onResponse:({response:n})=>{n.status===204&&(n._data=null)}});return o||null}catch(o){return console.error("[GameCenterRepo] getOpponentHistory() Request Failed",o),null}}async getNextGame(t){try{const o=await r(`${this.resource}/${t}/next-game`,{onResponse:({response:n})=>{n.status===204&&(n._data=null)}});return o?p(o):null}catch(o){return console.error("[GameCenterRepo] getNextGame() Request Failed",o),null}}async getPromoGroups(t){var o;try{const n=await r(`${this.resource}/promo-group/${t}`,{onResponse:({response:i})=>{i.status===204&&(i._data=null)}});return(o=n==null?void 0:n.promoItems)!=null&&o.length?n.promoItems.map(i=>y(i)):null}catch(n){return console.error("[GameCenterRepo] getPromoGroups() Request Failed",n),null}}async getLiveGames(){try{const t=await r(`${this.resource}/games`,{onResponse:({response:o})=>{o.status===204&&(o._data=null)}});return t!=null&&t.length?t.map(o=>L(o)):null}catch(t){return console.error("[GameCenterRepo] getLiveGames() Request Failed",t),null}}}const a=()=>new d,s=()=>"__liveGames__",_=h("game-center",{state:()=>({layout:{},isLoadingLayout:{},stories:{},isLoadingStories:{},gameInfo:{},isLoadingGameInfo:{},opponentHistory:{},isLoadingOpponentHistory:{},nextGame:{},isLoadingNextGame:{},gameHero:{},gameLiveStats:{},promoGroups:{},isLoadingPromoGroups:{},liveGames:{},isLoadingLiveGames:{},gameGalleryInfo:{}}),actions:{clearAllData(){this.layout={},this.isLoadingLayout={},this.stories={},this.isLoadingStories={},this.gameInfo={},this.isLoadingGameInfo={},this.opponentHistory={},this.isLoadingOpponentHistory={},this.nextGame={},this.isLoadingNextGame={},this.gameHero={},this.gameLiveStats={},this.promoGroups={},this.isLoadingPromoGroups={},this.liveGames={},this.isLoadingLiveGames={},this.gameGalleryInfo={},console.log("Cleared all game center store data")},async fetchLayout(e){if(!(e in this.layout)){this.isLoadingLayout[e]=!0;const t=await a().getLayout(e);this.layout[e]=t,this.isLoadingLayout[e]=!1}},async fetchGameGalleryInfo(e){if(!(e in this.gameGalleryInfo)){const t=await a().getGameGalleryInfo(e);this.gameGalleryInfo[e]=t}},async fetchStories(e){if(!(e in this.stories)){this.isLoadingStories[e]=!0;const t=await a().getStories(e);this.stories[e]=t,this.isLoadingStories[e]=!1}},async fetchGameInfo(e){if(!(e in this.gameInfo)){this.isLoadingGameInfo[e]=!0;const t=await a().getGameInfo(e);this.gameInfo[e]=t,this.isLoadingGameInfo[e]=!1}},async fetchGameHero(e){if(!(e in this.gameHero)){const t=await a().getGameHero(e);this.gameHero[e]=t}},async fetchOpponentHistory(e){if(!(e in this.opponentHistory)){this.isLoadingOpponentHistory[e]=!0;const t=await a().getOpponentHistory(e);this.opponentHistory[e]=t,this.isLoadingOpponentHistory[e]=!1}},async fetchNextGame(e){if(!(e in this.nextGame)){this.isLoadingNextGame[e]=!0;const t=await a().getNextGame(e);this.nextGame[e]=t,this.isLoadingNextGame[e]=!1}},async fetchPromoGroups(e){if(!(e in this.promoGroups)){this.isLoadingPromoGroups[e]=!0;const t=await a().getPromoGroups(e);this.promoGroups[e]=t,this.isLoadingPromoGroups[e]=!1}},async fetchLiveGames(){const e=s();e in this.liveGames||(this.isLoadingLiveGames[e]=!0);const t=await a().getLiveGames();this.liveGames[e]=t,e in this.liveGames&&(this.isLoadingLiveGames[e]=!1)}},getters:{getLayout:e=>t=>t in e.layout&&e.layout[t]?e.layout[t]:null,getGameHero:e=>t=>e.gameHero[t]??null,getGameGalleryInfo:e=>t=>e.gameGalleryInfo[t]??null,getStories:e=>t=>t in e.stories&&e.stories[t]?e.stories[t]:null,getLoadingStoriesFlag:e=>t=>t in e.isLoadingStories?e.isLoadingStories[t]??!1:!1,getGameInfo:e=>t=>t in e.gameInfo&&e.gameInfo[t]?e.gameInfo[t]:null,getLoadingGameInfoFlag:e=>t=>t in e.isLoadingGameInfo?e.isLoadingGameInfo[t]??!1:!1,getOpponentHistory:e=>t=>t in e.opponentHistory&&e.opponentHistory[t]?e.opponentHistory[t]:null,getLoadingOpponentHistoryFlag:e=>t=>t in e.isLoadingOpponentHistory?e.isLoadingOpponentHistory[t]??!1:!1,getNextGame:e=>t=>t in e.nextGame&&e.nextGame[t]?e.nextGame[t]:null,getLoadingNextGameFlag:e=>t=>t in e.isLoadingNextGame?e.isLoadingNextGame[t]??!1:!1,getPromoGroups:e=>t=>t in e.promoGroups&&e.promoGroups[t]?e.promoGroups[t]:null,getLoadingPromoGroupsFlag:e=>t=>t in e.isLoadingPromoGroups?e.isLoadingPromoGroups[t]??!1:!1,getLiveGames:e=>{const t=s();return t in e.liveGames&&e.liveGames[t]?e.liveGames[t]:null},liveGamesAvailable(e){var o;const t=s();return!!(t in e.liveGames&&e.liveGames[t]&&((o=e.liveGames[t])!=null&&o.length))},getLiveGameById:e=>t=>{var n,i;const o=s();if(o in e.liveGames&&((n=e.liveGames[o])!=null&&n.length))return(i=e.liveGames[o])==null?void 0:i.find(u=>u.id===t)},getLoadingLiveGamesFlag:e=>{const t=s();return t in e.isLoadingLiveGames?e.isLoadingLiveGames[t]??!1:!1}}});export{_ as u};