import{$ as i,i as x,a_ as v,a$ as _,b0 as R,d as G,p as a,w as u,b1 as w,aj as E,b2 as N}from"./CfjfYOu4.js";class b{async getPastSchedules(t){try{const e=await i(`/api/v2/Schedule/pasts?initialSportId=${t.toString()}&endSportId=${t.toString()}`);return e||null}catch(e){return console.error("[ScheduleRepo] getPastSchedules() Request error caught",e),null}}async getById(t){try{const e=x().bucket,s=`/api/v2/Schedule/${t.toString()}`,o=await i(s,{onResponse:({response:r})=>{r.status===204&&(r._data=null)}});return o?v(o,e):null}catch(e){return console.error("[ScheduleRepo] getById() Request error caught ",e),null}}async getScheduleRecord(t){try{const e=`/api/v2/Schedule/${t.scheduleId}/Record`,s=await i(e,{onResponse:({response:o})=>{o.status===204&&(o._data=null)}});return s||null}catch(e){return console.error("[ScheduleRepo] getScheduleRecord() Request error caught",e),null}}async getGameDetails(t){try{const e=await i(`/api/v2/ScheduleGames/${t.game_id}/results?sportId=${t.sport_id}`);return e?_(e):null}catch(e){return console.error("[ScheduleRepo] getGameDetails() Request error caught",e),null}}async getNextEvents(t){try{const e=`/api/v2/Ticketing/next-events?sportId=${t.id}`,s=await i(e,{onResponse:({response:o})=>{o.status===204&&(o._data=null)}});return s||null}catch(e){return console.error("[ScheduleRepo] getNextEvents() Request error caught",e),null}}async getNextGameEventCountdown(t){try{const e=`/api/v2/Countdown/schedule-page?sportId=${t}`,s=await i(e,{onResponse:({response:o})=>{o.status===204&&(o._data=null)}});return s||null}catch(e){return console.error("[ScheduleRepo] getNextGameEventCountdown() Request error caught",e),null}}async getScheduleSettings(t){try{const e=await i(`/api/v2/Schedule/settings?sportId=${t}`);return e||null}catch(e){return console.error("[ScheduleRepo] getScheduleSettings() Request error caught",e),null}}async getNextSeasonPromotion(t){try{const e=`/api/v2/Ticketing/season-promo?sportId=${t}`,s=await i(e,{timeout:1e4,onResponse:({response:o})=>{o.status===204&&(o._data=null)}});return s||null}catch(e){return console.error("[ScheduleRepo] getNextSeasonPromotion() Request error caught",e),null}}async getNextUpcomingEvents(t){var e;try{const s=await i(`/api/v2/NextEvents?upcoming=true&sportId=${t}&$pageIndex=1&$pageSize=1`);return s&&(e=s==null?void 0:s.items)!=null&&e.length?s.items:null}catch(s){return console.error("[ScheduleRepo] getNextUpcomingEvents() Request error caught",s),null}}async getScheduleGame(t){try{const e=await i(`/api/v2/ScheduleGames/${t}`);return e||null}catch(e){return console.error("[ScheduleRepo] getScheduleGame() Request error caught",e),null}}async getMarriottWidget(){const t="/api/v2/MarriottBookingWidget/data";try{const e=await i(t,{onResponse:({response:s})=>{s.status===204&&(s._data=null)}});return e?R(e):null}catch(e){return console.error("[ScheduleRepo] getMarriottWidget() Request error caught",e),null}}}const y=(n,...t)=>`${n}-${t.join()}`,p=n=>y("schedules",n.globalSportNameSlug,n.seasonTitle??""),f=n=>y("schedules-records",n.scheduleId??""),l=()=>new b,I=n=>{var e;const t=[];if(n!=null&&n.length){const s=n;for(let o=0;o{var h,g,S,m;return d.length&&((h=r==null?void 0:r.tournament)==null?void 0:h.id)&&((S=(g=d[0])==null?void 0:g.tournament)==null?void 0:S.id)===((m=r.tournament)==null?void 0:m.id)});c>=0?(e=t[c])==null||e.push(r):t.push([r])}}}return t},$=G("schedule",{state:()=>({schedules:{},nextEvents:{},scheduleRecords:{},pastSchedules:{},gameDetails:{},nextGameEventCountdown:{},scheduleSettings:{},nextSeasonPromotion:{},nextUpcomingEvents:{},schedulePageDataLoaded:{},scheduleGames:{},marriottWidget:{},isLoading:!1}),actions:{async fetchNextEvents(n){const t=u().getSportByGlobalSlugOrShortname(n.globalSportNameSlug),e=a(n);if(t!=null&&t.global_sport_id&&!(e in this.nextEvents)){const s=await l().getNextEvents(t);this.nextEvents[e]=s}},async fetchSchedule(n){var s;const t=u().getSportByGlobalSlugOrShortname(n.globalSportNameSlug),e=p(n);if(t!=null&&t.scheduleId&&!(e in this.schedules)){this.isLoading=!0;let o=t.scheduleId;if(n.seasonTitle&&n.seasonTitle!==""){const c=this.getPastScheduleByTitle(t.id,n.seasonTitle);c&&(o=c.scheduleId)}const r=await l().getById(o);if(t&&(t!=null&&t.global_sport_id)&&((s=r==null?void 0:r.games)!=null&&s.length)){const c=r.games,d=w(t.global_sport_id);E.info(`${t==null?void 0:t.title} [${t==null?void 0:t.global_sport_id}] --> isStatSport`,d),(!d||N(t.global_sport_id)==="Tennis")&&(r.games=I(c).reduce((h,g)=>[...h,...g],[]))}r&&(this.schedules[e]=r),this.isLoading=!1}},async fetchScheduleById(n){var e,s;const t=a(n);if(!(t in this.schedules)){const o=await l().getById(n);if(o){this.schedules[t]=o;const r=a({globalSportNameSlug:((e=o==null?void 0:o.sport)==null?void 0:e.global_sport_name_slug)||"",scheduleId:o==null?void 0:o.id,seasonTitle:((s=o==null?void 0:o.season)==null?void 0:s.title)||""});this.schedules[r]=o}}},async fetchPastSchedules(n){const t=u().getSportByGlobalSlugOrShortname(n.globalSportNameSlug);if(t&&!(t.id in this.pastSchedules)){const e=await l().getPastSchedules(t.id),s=t.id.toString();e&&(this.pastSchedules[s]=e)}},async fetchScheduleRecord(n){const t=f(n);if(!(t in this.scheduleRecords)){const e=await l().getScheduleRecord(n);e&&(this.scheduleRecords[t]=e)}},async fetchGameDetails(n){const t=a(n);if(!(t in this.gameDetails)){const e=await l().getGameDetails(n);e&&(this.gameDetails[t]=e)}},async fetchNextEventCountdown(n){const t=u().getSportByGlobalSlugOrShortname(n.globalSportNameSlug),e=a(n);if(t&&!(e in this.nextGameEventCountdown)){const s=await l().getNextGameEventCountdown(t.id);s&&(this.nextGameEventCountdown[e]=s)}},async fetchScheduleSettings(n){const t=u().getSportByGlobalSlugOrShortname(n.globalSportNameSlug),e=a(n);if(t&&!(e in this.scheduleSettings)){const s=await l().getScheduleSettings(t.id);this.scheduleSettings[e]=s}},async fetchNextSeasonPromotion(n){const t=u().getSportByGlobalSlugOrShortname(n.globalSportNameSlug),e=a(n);if(t!=null&&t.global_sport_id&&!(e in this.nextSeasonPromotion)){const s=await l().getNextSeasonPromotion(t.id);this.nextSeasonPromotion[e]=s}},async fetchNextUpcomingEvents(n){const t=u().getSportByGlobalSlugOrShortname(n.globalSportNameSlug),e=a(n);if(t!=null&&t.global_sport_id&&!(e in this.nextUpcomingEvents)){const s=await l().getNextUpcomingEvents(t.id);this.nextUpcomingEvents[e]=s}},async fetchScheduleGame(n){const t=a(n);if(!(t in this.scheduleGames)){const e=await l().getScheduleGame(n);this.scheduleGames[t]=e}},async fetchMarriottWidgetData(){const n="_marriottWidget_";if(!(n in this.marriottWidget)){const t=await l().getMarriottWidget();this.marriottWidget[n]=t}}},getters:{getScheduleByKey:n=>t=>{const e=p(t);return e in n.schedules&&n.schedules[e]?n.schedules[e]:null},getScheduleById:n=>t=>{const e=a(t);return e in n.schedules?n.schedules[e]:null},getNextEvents:n=>t=>{const e=a(t);return e in n.nextEvents&&n.nextEvents[e]?n.nextEvents[e]:null},getScheduleRecord:n=>t=>{const e=f(t);return e in n.scheduleRecords?n.scheduleRecords[e]:null},getPastSchedules:n=>t=>{var o;const e=u().getSportByGlobalSlugOrShortname(t.globalSportNameSlug),s=(o=e==null?void 0:e.id)==null?void 0:o.toString();return s&&s in n.pastSchedules&&n.pastSchedules[s]?n.pastSchedules[s]:[]},getPastScheduleByTitle:n=>(t,e)=>{var o;const s=t.toString();if(s in n.pastSchedules){const r=(o=n.pastSchedules[s])==null?void 0:o.filter(c=>c.seasonTitle===e)[0];if(r)return r}return null},getGameDetails:n=>t=>{const e=a(t);return e in n.gameDetails?n.gameDetails[e]:null},getNextEventCountdown:n=>t=>{const e=a(t);return e in n.nextGameEventCountdown?n.nextGameEventCountdown[e]:null},getScheduleSettings:n=>t=>{const e=a(t);return e in n.scheduleSettings&&n.scheduleSettings[e]?n.scheduleSettings[e]:null},getNextSeasonPromotion:n=>t=>{const e=a(t);return e in n.nextSeasonPromotion&&n.nextSeasonPromotion[e]?n.nextSeasonPromotion[e]:null},getNextUpcomingEvents:n=>t=>{const e=a(t);return e in n.nextUpcomingEvents?n.nextUpcomingEvents[e]:null},getFirstNextUpcomingEventGame:n=>t=>{var s,o,r;const e=a(t);return e in n.nextUpcomingEvents?((r=(o=(s=n.nextUpcomingEvents[e])==null?void 0:s.at(0))==null?void 0:o.games)==null?void 0:r.at(0))??null:null},getLoadingFlag:n=>n.isLoading,getScheduleGame:n=>t=>{const e=a(t);return e in n.scheduleGames?n.scheduleGames[e]:null},getMarriottWidget:n=>{const t="_marriottWidget_";return t in n.marriottWidget?n.marriottWidget[t]:null}}});export{$ as u};

AltStyle によって変換されたページ (->オリジナル) /