@maestro_io/maestro-web-sdk 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/dist/MaestroEventDelegate.js +60 -0
  2. package/dist/components/atoms/BaseButton/BaseButton.js +11 -0
  3. package/dist/components/atoms/BaseButton/index.js +2 -0
  4. package/dist/components/atoms/Image/index.js +30 -0
  5. package/dist/components/atoms/Rive/index.d.ts +7 -8
  6. package/dist/components/atoms/Rive/index.js +52 -0
  7. package/dist/components/atoms/SvgIcon/BetGeneralIcon.js +9 -0
  8. package/dist/components/atoms/SvgIcon/BetsIcon.js +11 -0
  9. package/dist/components/atoms/SvgIcon/BetsWarningIcon.js +11 -0
  10. package/dist/components/atoms/SvgIcon/CheckmarkIcon.js +6 -0
  11. package/dist/components/atoms/SvgIcon/CollapseIcon.js +6 -0
  12. package/dist/components/atoms/SvgIcon/ExpandIcon.js +6 -0
  13. package/dist/components/atoms/SvgIcon/FantasyIcon.js +8 -0
  14. package/dist/components/atoms/SvgIcon/FlameIcon.js +11 -0
  15. package/dist/components/atoms/SvgIcon/Icon.js +42 -0
  16. package/dist/components/atoms/SvgIcon/KeyPlaysIcon.js +10 -0
  17. package/dist/components/atoms/SvgIcon/MobilePhoneIcon.js +11 -0
  18. package/dist/components/atoms/SvgIcon/PlayIcon.js +8 -0
  19. package/dist/components/atoms/SvgIcon/StatsIcon.js +12 -0
  20. package/dist/components/atoms/SvgIcon/TimesIcon.js +6 -0
  21. package/dist/components/atoms/SvgIcon/WarningIcon.js +8 -0
  22. package/dist/components/atoms/SvgIcon/index.js +2 -0
  23. package/dist/components/core/App/App.js +41 -0
  24. package/dist/components/core/App/index.js +2 -0
  25. package/dist/components/core/OverlayContainer.js +58 -0
  26. package/dist/components/core/PanelManager/PanelManager.js +80 -0
  27. package/dist/components/core/PanelManager/index.js +2 -0
  28. package/dist/components/core/ScrollableContainer/FocusableItem.js +38 -0
  29. package/dist/components/core/ScrollableContainer/ScrollableContainer.js +166 -0
  30. package/dist/components/core/ScrollableContainer/index.js +2 -0
  31. package/dist/components/molecules/ActionButton/ActionButton.js +10 -0
  32. package/dist/components/molecules/ActionButton/index.js +2 -0
  33. package/dist/components/molecules/Overlay/Overlay.d.ts +1 -2
  34. package/dist/components/molecules/Overlay/Overlay.js +139 -0
  35. package/dist/components/molecules/Overlay/index.js +2 -0
  36. package/dist/components/molecules/PanelNavButton/PanelNavButton.js +40 -0
  37. package/dist/components/molecules/PanelNavButton/index.js +2 -0
  38. package/dist/components/molecules/SegmentButton/SegmentButton.js +10 -0
  39. package/dist/components/molecules/SegmentButton/index.js +2 -0
  40. package/dist/components/molecules/WatchButton/WatchButton.js +15 -0
  41. package/dist/components/molecules/WatchButton/index.js +2 -0
  42. package/dist/components/organisms/PanelNavigation/PanelNavigation.js +72 -0
  43. package/dist/components/organisms/PanelNavigation/index.js +2 -0
  44. package/dist/components/organisms/SegmentController/SegmentController.js +69 -0
  45. package/dist/components/organisms/SegmentController/index.d.ts +1 -1
  46. package/dist/components/organisms/SegmentController/index.js +2 -0
  47. package/dist/external/AxiosNetworkClient.js +83 -0
  48. package/dist/external/LocalStorageCacheManager.js +213 -0
  49. package/dist/external/ReactRenderer.d.ts +2 -2
  50. package/dist/external/ReactRenderer.js +86 -0
  51. package/dist/external/mocks/MockExternalNetworkClient.js +161 -0
  52. package/dist/external/ports/cacheManager.js +1 -0
  53. package/dist/external/ports/networkClient.js +1 -0
  54. package/dist/external/ports/renderer.js +1 -0
  55. package/dist/external/spatial-navigation/index.d.ts +1 -1
  56. package/dist/external/spatial-navigation/index.js +4 -0
  57. package/dist/external/spatial-navigation/measureLayout.js +30 -0
  58. package/dist/external/spatial-navigation/spatialNavigation.js +875 -0
  59. package/dist/external/spatial-navigation/utils.js +6 -0
  60. package/dist/external/spatial-navigation/visualDebugger.js +76 -0
  61. package/dist/external/spatial-navigation/withFocusable.js +238 -0
  62. package/dist/helpers/Observable.js +37 -0
  63. package/dist/helpers/deliver-focus.js +12 -0
  64. package/dist/index.d.ts +4 -4
  65. package/dist/index.js +192 -0
  66. package/dist/interfaces/IMaestroEvent.js +6 -0
  67. package/dist/interfaces/IMaestroEventDelegate.js +1 -0
  68. package/dist/interfaces/IMaestroManager.js +1 -0
  69. package/dist/maestro-web-sdk.umd.js +3 -3
  70. package/dist/maestro-web-sdk.umd.js.map +1 -1
  71. package/dist/models/IModel.js +1 -0
  72. package/dist/models/IPanel.js +53 -0
  73. package/dist/models/ITheme.js +20 -0
  74. package/dist/models/IWinningBet.js +1 -0
  75. package/dist/modules/bets/interfaces/IBets.js +1 -0
  76. package/dist/modules/bets/mocks.js +572 -0
  77. package/dist/modules/bets/view/BetsView.js +116 -0
  78. package/dist/modules/bets/view/HotProps/HotPropsView.js +139 -0
  79. package/dist/modules/bets/view/SixPack/SixPackView.js +103 -0
  80. package/dist/modules/bets/view/TabLoadFailureView.js +12 -0
  81. package/dist/modules/bets/view/UserBets/BetResult/BetResult.js +6 -0
  82. package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.js +122 -0
  83. package/dist/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +34 -0
  84. package/dist/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +22 -0
  85. package/dist/modules/bets/view/UserBets/Boost/Boost.js +6 -0
  86. package/dist/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +9 -0
  87. package/dist/modules/bets/view/UserBets/Parlay/Parlay.js +13 -0
  88. package/dist/modules/bets/view/UserBets/Straight/Straight.js +6 -0
  89. package/dist/modules/bets/view/UserBets/Teaser/Teaser.js +13 -0
  90. package/dist/modules/bets/view/UserBets/UserBetsView.js +114 -0
  91. package/dist/modules/bets/view/components/Bet/Bet.js +32 -0
  92. package/dist/modules/bets/view/components/BetPill/BetPill.js +6 -0
  93. package/dist/modules/bets/view/components/BetsCard/BetsCard.js +15 -0
  94. package/dist/modules/bets/view/components/BetsCard/BetsCardHeader.js +20 -0
  95. package/dist/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +14 -0
  96. package/dist/modules/bets/view/components/LocationWarning/LocationWarning.js +16 -0
  97. package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +63 -0
  98. package/dist/modules/bets/view/components/PromoCodeBanner/index.d.ts +1 -1
  99. package/dist/modules/bets/view/components/PromoCodeBanner/index.js +1 -0
  100. package/dist/modules/bets/view-model/BetsViewModel.js +767 -0
  101. package/dist/modules/key-plays/constants.js +292 -0
  102. package/dist/modules/key-plays/interfaces/IKeyPlays.d.ts +4 -4
  103. package/dist/modules/key-plays/interfaces/IKeyPlays.js +14 -0
  104. package/dist/modules/key-plays/interfaces/IKeyPlaysResponse.js +1 -0
  105. package/dist/modules/key-plays/view/KeyPlayCardScoreTagView.js +13 -0
  106. package/dist/modules/key-plays/view/KeyPlayCardView.js +142 -0
  107. package/dist/modules/key-plays/view/KeyPlayErrorStateView.js +58 -0
  108. package/dist/modules/key-plays/view/KeyPlaysView.js +167 -0
  109. package/dist/modules/key-plays/view-model/KeyPlaysViewModel.js +182 -0
  110. package/dist/modules/stats/interfaces/IStats.d.ts +163 -0
  111. package/dist/modules/stats/interfaces/IStats.js +1 -0
  112. package/dist/modules/stats/mocks.d.ts +2 -0
  113. package/dist/modules/stats/mocks.js +546 -0
  114. package/dist/modules/stats/utils.d.ts +39 -0
  115. package/dist/modules/stats/utils.js +62 -0
  116. package/dist/modules/stats/view/GameLeaders/GameLeaders.d.ts +29 -0
  117. package/dist/modules/stats/view/GameLeaders/GameLeaders.js +9 -0
  118. package/dist/modules/stats/view/GameLeaders/index.d.ts +2 -0
  119. package/dist/modules/stats/view/GameLeaders/index.js +2 -0
  120. package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.d.ts +17 -0
  121. package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +55 -0
  122. package/dist/modules/stats/view/MatchPredictor/DonutChart/index.d.ts +2 -0
  123. package/dist/modules/stats/view/MatchPredictor/DonutChart/index.js +1 -0
  124. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.d.ts +52 -0
  125. package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.js +66 -0
  126. package/dist/modules/stats/view/MatchPredictor/index.d.ts +3 -0
  127. package/dist/modules/stats/view/MatchPredictor/index.js +2 -0
  128. package/dist/modules/stats/view/RecentGames/RecentGames.d.ts +62 -0
  129. package/dist/modules/stats/view/RecentGames/RecentGames.js +22 -0
  130. package/dist/modules/stats/view/RecentGames/index.d.ts +2 -0
  131. package/dist/modules/stats/view/RecentGames/index.js +2 -0
  132. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.d.ts +51 -0
  133. package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.js +38 -0
  134. package/dist/modules/stats/view/StatsQRCode/index.d.ts +2 -0
  135. package/dist/modules/stats/view/StatsQRCode/index.js +1 -0
  136. package/dist/modules/stats/view/StatsView.d.ts +20 -0
  137. package/dist/modules/stats/view/StatsView.js +87 -0
  138. package/dist/modules/stats/view/Teams/StatsCarousel.d.ts +8 -0
  139. package/dist/modules/stats/view/Teams/StatsCarousel.js +14 -0
  140. package/dist/modules/stats/view/Teams/StatsProgressBar.d.ts +7 -0
  141. package/dist/modules/stats/view/Teams/StatsProgressBar.js +14 -0
  142. package/dist/modules/stats/view/Teams/Teams.d.ts +67 -0
  143. package/dist/modules/stats/view/Teams/Teams.js +35 -0
  144. package/dist/modules/stats/view/Teams/index.d.ts +2 -0
  145. package/dist/modules/stats/view/Teams/index.js +2 -0
  146. package/dist/modules/stats/view/WinProbability/WinProbability.d.ts +62 -0
  147. package/dist/modules/stats/view/WinProbability/WinProbability.js +27 -0
  148. package/dist/modules/stats/view/WinProbability/index.d.ts +2 -0
  149. package/dist/modules/stats/view/WinProbability/index.js +2 -0
  150. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.d.ts +51 -0
  151. package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +28 -0
  152. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.d.ts +10 -0
  153. package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.js +11 -0
  154. package/dist/modules/stats/view/components/AthletesStatistics/index.d.ts +2 -0
  155. package/dist/modules/stats/view/components/AthletesStatistics/index.js +2 -0
  156. package/dist/modules/stats/view/index.d.ts +1 -0
  157. package/dist/modules/stats/view/index.js +1 -0
  158. package/dist/modules/stats/view-model/StatsViewModel.d.ts +31 -0
  159. package/dist/modules/stats/view-model/StatsViewModel.js +90 -0
  160. package/dist/services/BetsService.js +102 -0
  161. package/dist/services/NetworkManager/NetworkManager.js +410 -0
  162. package/dist/services/NetworkManager/errors.js +45 -0
  163. package/dist/services/ThemeManager/constants.js +47 -0
  164. package/dist/test-polyfills.d.ts +1 -0
  165. package/dist/test-polyfills.js +15 -0
  166. package/dist/types/OverlayTypes.js +4 -0
  167. package/dist/view-models/MaestroEventViewModel.d.ts +2 -0
  168. package/dist/view-models/MaestroEventViewModel.js +156 -0
  169. package/dist/view-models/OverlayViewModel.js +222 -0
  170. package/dist/view-models/PanelManagerViewModel.js +80 -0
  171. package/dist/view-models/ViewModel.js +32 -0
  172. package/dist/view-models/index.js +59 -0
  173. package/package.json +1 -1
@@ -0,0 +1,167 @@
1
+ import React, { Component } from 'react';
2
+ import KeyPlayCardView from './KeyPlayCardView';
3
+ import './KeyPlaysView.styles.css';
4
+ import KeyPlayErrorStateView from './KeyPlayErrorStateView';
5
+ import SDK from '@/index';
6
+ import { setFocus } from '@/external/spatial-navigation';
7
+ import ScrollableContainer from '@/components/core/ScrollableContainer';
8
+ const STICKY_HEADER_HEIGHT = 32;
9
+ export class KeyPlays extends Component {
10
+ constructor(props) {
11
+ super(props);
12
+ Object.defineProperty(this, "container", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: null
17
+ });
18
+ Object.defineProperty(this, "playbackProgressUnsub", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: null
23
+ });
24
+ Object.defineProperty(this, "playbackIndexUnsub", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: null
29
+ });
30
+ Object.defineProperty(this, "itemsUnsub", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: null
35
+ });
36
+ Object.defineProperty(this, "vm", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: void 0
41
+ });
42
+ Object.defineProperty(this, "handlePlayClip", {
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true,
46
+ value: (index) => async () => {
47
+ await this.vm.playKeyPlay(index);
48
+ }
49
+ });
50
+ this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
51
+ const rawSections = this.vm.items.value;
52
+ this.state = {
53
+ scrollableContainer: null,
54
+ playbackProgress: this.vm.currentClipPlaybackProgress.value ?? null,
55
+ playbackIndex: this.vm.currentlyPlayingClipIndex.value ?? null,
56
+ items: rawSections.map((section) => ({
57
+ title: section.title,
58
+ items: section.items.map((item) => ({
59
+ id: item.id,
60
+ clipID: item.clipID,
61
+ awayTeamScore: item.awayTeamScore,
62
+ homeTeamScore: item.homeTeamScore,
63
+ awayTeamName: item.awayTeamName,
64
+ homeTeamName: item.homeTeamName,
65
+ description: item.description,
66
+ playerImageUrl: item.playerImageUrl || '',
67
+ teamImageUrl: item.teamImageUrl || '',
68
+ thumbnailImageUrl: item.thumbnailImageUrl || '',
69
+ })),
70
+ })),
71
+ };
72
+ }
73
+ componentDidMount() {
74
+ this.playbackProgressUnsub = this.vm.currentClipPlaybackProgress.subscribe((value) => {
75
+ this.setState({ playbackProgress: value ?? null });
76
+ });
77
+ this.playbackIndexUnsub = this.vm.currentlyPlayingClipIndex.subscribe((value) => {
78
+ this.setState({ playbackIndex: value ?? null });
79
+ });
80
+ this.itemsUnsub = this.vm.items.subscribe((rawSections) => {
81
+ this.setState({
82
+ items: rawSections.map((section) => ({
83
+ title: section.title,
84
+ items: section.items.map((item) => ({
85
+ id: item.id,
86
+ clipID: item.clipID,
87
+ awayTeamScore: item.awayTeamScore,
88
+ homeTeamScore: item.homeTeamScore,
89
+ awayTeamName: item.awayTeamName,
90
+ homeTeamName: item.homeTeamName,
91
+ description: item.description,
92
+ playerImageUrl: item.playerImageUrl || '',
93
+ teamImageUrl: item.teamImageUrl || '',
94
+ thumbnailImageUrl: item.thumbnailImageUrl || '',
95
+ })),
96
+ })),
97
+ });
98
+ });
99
+ this.setState({
100
+ scrollableContainer: this.container,
101
+ });
102
+ }
103
+ componentWillUnmount() {
104
+ this.playbackProgressUnsub && this.playbackProgressUnsub();
105
+ this.playbackIndexUnsub && this.playbackIndexUnsub();
106
+ this.itemsUnsub && this.itemsUnsub();
107
+ }
108
+ render() {
109
+ const { playbackProgress, playbackIndex, items, scrollableContainer, } = this.state;
110
+ return (React.createElement(ScrollableContainer, { scrollableContainerRef: scrollableContainer, containerTopOffset: STICKY_HEADER_HEIGHT },
111
+ React.createElement("div", { ref: (el) => {
112
+ this.container = el;
113
+ }, className: "key-plays-view" },
114
+ items.map((section, sectionIndex) => (React.createElement("div", { key: `section-${sectionIndex}`, className: "key-plays-section" },
115
+ React.createElement("h3", { className: "key-plays-section-title T10" }, section.title),
116
+ React.createElement("div", { className: "key-plays-section-items" }, section.items.map((item) => {
117
+ const absoluteIndex = this.vm.allItems.findIndex((vmItem) => vmItem.id === item.id);
118
+ return (React.createElement(KeyPlayCardView, { key: item.id, id: item.id, clipID: item.clipID, description: item.description, awayTeamName: item.awayTeamName, homeTeamName: item.homeTeamName, awayTeamScore: item.awayTeamScore, homeTeamScore: item.homeTeamScore, playerImageUrl: item.playerImageUrl, teamImageUrl: item.teamImageUrl, thumbnailImageUrl: item.thumbnailImageUrl, isPlaying: this.vm.isCurrentlyPlaying(absoluteIndex), isScoring: Boolean(item.awayTeamScore && item.homeTeamScore), playbackProgress: absoluteIndex === playbackIndex
119
+ ? playbackProgress
120
+ : null, onEnterPress: this.handlePlayClip(absoluteIndex) }));
121
+ }))))),
122
+ React.createElement("div", { className: "key-plays-bottom-padding" }))));
123
+ }
124
+ }
125
+ export default class KeyPlaysWithErrorState extends Component {
126
+ constructor(props) {
127
+ super(props);
128
+ Object.defineProperty(this, "errorStateUnsub", {
129
+ enumerable: true,
130
+ configurable: true,
131
+ writable: true,
132
+ value: null
133
+ });
134
+ Object.defineProperty(this, "vm", {
135
+ enumerable: true,
136
+ configurable: true,
137
+ writable: true,
138
+ value: void 0
139
+ });
140
+ Object.defineProperty(this, "handleRetry", {
141
+ enumerable: true,
142
+ configurable: true,
143
+ writable: true,
144
+ value: async () => {
145
+ await this.vm.userRequestedNewKeyPlaysData();
146
+ setFocus('PANEL_NAV_BUTTON_0');
147
+ }
148
+ });
149
+ this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
150
+ this.state = { errorState: this.vm.errorState.value };
151
+ }
152
+ componentDidMount() {
153
+ this.errorStateUnsub = this.vm.errorState.subscribe((value) => {
154
+ this.setState({ errorState: value });
155
+ });
156
+ }
157
+ componentWillUnmount() {
158
+ this.errorStateUnsub && this.errorStateUnsub();
159
+ }
160
+ render() {
161
+ const { errorState } = this.state;
162
+ if (errorState) {
163
+ return (React.createElement(KeyPlayErrorStateView, { errorState: errorState, onRetry: this.handleRetry }));
164
+ }
165
+ return React.createElement(KeyPlays, null);
166
+ }
167
+ }
@@ -0,0 +1,182 @@
1
+ import SDK from '@/index';
2
+ import { Observable } from '@/helpers/Observable';
3
+ class KeyPlaysViewModel {
4
+ constructor() {
5
+ Object.defineProperty(this, "currentlyPlayingClipIndex", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: new Observable(null)
10
+ });
11
+ Object.defineProperty(this, "lastPlayedClipIndex", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: new Observable(null)
16
+ });
17
+ Object.defineProperty(this, "currentClipPlaybackProgress", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: new Observable(null)
22
+ });
23
+ Object.defineProperty(this, "errorState", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: new Observable('unpopulatedEvent')
28
+ });
29
+ Object.defineProperty(this, "failedClips", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: new Observable({})
34
+ });
35
+ Object.defineProperty(this, "items", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: new Observable([])
40
+ });
41
+ }
42
+ isCurrentlyPlaying(index) {
43
+ return index === this.currentlyPlayingClipIndex.value;
44
+ }
45
+ async setKeyPlays(items) {
46
+ if (items === null) {
47
+ this.errorState.value = 'tabLoadFailure';
48
+ return;
49
+ }
50
+ this.items.value = this.parseNetworkResponse(items);
51
+ this.cleanErrors();
52
+ }
53
+ cleanErrors() {
54
+ if (this.errorState.value === 'tabLoadFailure') {
55
+ this.errorState.value = null;
56
+ }
57
+ if (this.errorState.value === 'unpopulatedEvent' && this.allItems.length) {
58
+ this.errorState.value = null;
59
+ }
60
+ if (!this.allItems.length) {
61
+ this.errorState.value = 'unpopulatedEvent';
62
+ }
63
+ }
64
+ async playKeyPlay(atIndex) {
65
+ const mevm = SDK.getMaestroEventViewModel();
66
+ mevm.delegate.playClip(atIndex);
67
+ }
68
+ parseNetworkResponse(response) {
69
+ const teams = Object.values(response.entities.team);
70
+ const athletes = Object.values(response.entities.athlete);
71
+ const homeTeam = teams.find((team) => team.homeAway === 'home');
72
+ const awayTeam = teams.find((team) => team.homeAway === 'away');
73
+ if (!homeTeam || !awayTeam) {
74
+ console.warn('Could not find home or away team');
75
+ return [];
76
+ }
77
+ const items = [];
78
+ const result = [];
79
+ for (const section of response.sections) {
80
+ for (const keyPlay of section.items) {
81
+ const playTeam = keyPlay.team
82
+ ? teams.find((team) => team.id === keyPlay.team)
83
+ : undefined;
84
+ const athlete = keyPlay.athlete
85
+ ? athletes.find((a) => a.id === keyPlay.athlete)
86
+ : undefined;
87
+ const teamImageUrl = playTeam ? playTeam.logoRef : undefined;
88
+ const playerImageUrl = athlete ? athlete.headshot : undefined;
89
+ const thumbnailImageUrl = keyPlay.thumbnailType !== 'headshot' ? keyPlay.thumbnail : undefined;
90
+ const homeScore = keyPlay.homeScore ? keyPlay.homeScore : '0';
91
+ const awayScore = keyPlay.awayScore ? keyPlay.awayScore : '0';
92
+ const homeTeamScore = keyPlay.scoringPlay
93
+ ? parseInt(homeScore)
94
+ : undefined;
95
+ const awayTeamScore = keyPlay.scoringPlay
96
+ ? parseInt(awayScore)
97
+ : undefined;
98
+ const randomId = Math.random().toString(36).substring(2, 15);
99
+ const keyPlayData = {
100
+ id: randomId,
101
+ description: keyPlay.description ? keyPlay.description : '',
102
+ homeTeamName: homeTeam ? homeTeam.shortName : '',
103
+ awayTeamName: awayTeam ? awayTeam.shortName : '',
104
+ homeTeamScore,
105
+ awayTeamScore,
106
+ clipID: keyPlay.clipID,
107
+ teamImageUrl,
108
+ playerImageUrl,
109
+ thumbnailImageUrl,
110
+ section: section.title,
111
+ };
112
+ items.push(keyPlayData);
113
+ }
114
+ // Only add the section if it has items
115
+ if (items.length) {
116
+ const sectionTitle = section.title;
117
+ const existingSection = result.find((item) => item.title === sectionTitle);
118
+ if (existingSection) {
119
+ existingSection.items.push(...items);
120
+ }
121
+ else {
122
+ result.push({
123
+ title: sectionTitle,
124
+ items: [...items],
125
+ });
126
+ }
127
+ // Reset items for the next section
128
+ items.length = 0;
129
+ }
130
+ }
131
+ return result;
132
+ }
133
+ get allItems() {
134
+ return this.items.value.reduce((acc, section) => {
135
+ return acc.concat(section.items);
136
+ }, []);
137
+ }
138
+ clipID(forKeyPlayAtIndex) {
139
+ const item = this.allItems[forKeyPlayAtIndex];
140
+ if (!item) {
141
+ return undefined;
142
+ }
143
+ return this.allItems[forKeyPlayAtIndex].clipID;
144
+ }
145
+ handleKeyPlayLoadFailure(forKeyPlayAtIndex) {
146
+ const clipID = this.clipID(forKeyPlayAtIndex);
147
+ if (clipID) {
148
+ const newFailedClips = this.failedClips.value;
149
+ newFailedClips[clipID] = 'recentFailure';
150
+ this.failedClips.value = newFailedClips;
151
+ setTimeout(() => {
152
+ if (this.loadFailureStatus(forKeyPlayAtIndex) === 'recentFailure') {
153
+ const newFailedClips = this.failedClips.value;
154
+ newFailedClips[clipID] = 'nonRecentFailure';
155
+ this.failedClips.value = newFailedClips;
156
+ }
157
+ }, 5000);
158
+ }
159
+ }
160
+ loadFailureStatus(forKeyPlayAtIndex) {
161
+ const clipID = this.clipID(forKeyPlayAtIndex);
162
+ const newFailedClips = this.failedClips.value;
163
+ if (!newFailedClips) {
164
+ return 'noFailure';
165
+ }
166
+ return clipID ? this.failedClips.value[clipID] : 'noFailure';
167
+ }
168
+ clearLoadFailureStatus(forKeyPlayAtIndex) {
169
+ const clipID = this.clipID(forKeyPlayAtIndex);
170
+ if (clipID && this.failedClips) {
171
+ this.failedClips.value = {
172
+ ...this.failedClips.value,
173
+ [clipID]: 'noFailure',
174
+ };
175
+ }
176
+ }
177
+ async userRequestedNewKeyPlaysData() {
178
+ const mevm = SDK.getMaestroEventViewModel();
179
+ await mevm.delegate.userRequestedNewKeyPlaysData();
180
+ }
181
+ }
182
+ export default KeyPlaysViewModel;
@@ -0,0 +1,163 @@
1
+ export interface TeamStatistic {
2
+ $key: string;
3
+ value: number;
4
+ displayValue: string;
5
+ displayName: string;
6
+ }
7
+ export interface Team {
8
+ id: string;
9
+ uid: string;
10
+ slug?: string;
11
+ location?: string;
12
+ name?: string;
13
+ abbreviation: string;
14
+ displayName: string;
15
+ shortDisplayName?: string;
16
+ color?: string;
17
+ alternateColor?: string;
18
+ logo: string;
19
+ statistics?: TeamStatistic[];
20
+ homeAway?: string;
21
+ record?: string;
22
+ displayOrder?: number;
23
+ }
24
+ interface AthleteLink {
25
+ rel: string[];
26
+ href: string;
27
+ text: string;
28
+ }
29
+ interface AthletePosition {
30
+ name?: string;
31
+ displayName?: string;
32
+ abbreviation: string;
33
+ }
34
+ export interface Athlete {
35
+ id: string;
36
+ uid: string;
37
+ guid: string;
38
+ displayName: string;
39
+ shortName: string;
40
+ jersey: string;
41
+ headshot: string;
42
+ links: AthleteLink[];
43
+ position: AthletePosition;
44
+ statistics?: {
45
+ $key: string;
46
+ value?: number;
47
+ displayValue: string;
48
+ }[];
49
+ }
50
+ export interface EntityMap<T> {
51
+ [id: string]: T;
52
+ }
53
+ interface LeaderStatistic {
54
+ displayValue: string;
55
+ abbreviation: string;
56
+ }
57
+ interface LeaderAthlete {
58
+ $key: string;
59
+ statistics?: LeaderStatistic[];
60
+ }
61
+ interface LeaderTeam {
62
+ team: {
63
+ $key: string;
64
+ };
65
+ athlete: LeaderAthlete;
66
+ }
67
+ export interface Leader {
68
+ displayName: string;
69
+ name: string;
70
+ home: LeaderTeam;
71
+ away: LeaderTeam;
72
+ }
73
+ interface LineScore {
74
+ displayValue: string;
75
+ }
76
+ interface HeaderTeam {
77
+ $key: string;
78
+ score?: string;
79
+ linescores: LineScore[];
80
+ }
81
+ export interface Header {
82
+ teams: HeaderTeam[];
83
+ linescoresHeader: string[];
84
+ }
85
+ export interface PredictorTeam {
86
+ team: {
87
+ $key: string;
88
+ };
89
+ gameProjection: string;
90
+ teamChanceLoss: string;
91
+ }
92
+ export interface Predictor {
93
+ header: string;
94
+ imageUrl: string;
95
+ homeTeam: PredictorTeam;
96
+ awayTeam: PredictorTeam;
97
+ }
98
+ export interface WinProbabilityTeam {
99
+ team: {
100
+ $key: string;
101
+ };
102
+ winPercentage: string;
103
+ }
104
+ export interface WinProbability {
105
+ imageUrl: string;
106
+ homeTeam: WinProbabilityTeam;
107
+ awayTeam: WinProbabilityTeam;
108
+ }
109
+ interface ActiveAthletesTeam {
110
+ team: {
111
+ $key: string;
112
+ };
113
+ athletes: unknown[];
114
+ }
115
+ export interface ActiveAthletes {
116
+ displayText: string;
117
+ teams: ActiveAthletesTeam[];
118
+ }
119
+ export interface Meta {
120
+ gp_topic: string;
121
+ picker_topic: string;
122
+ lastUpdatedAt?: string;
123
+ firstPlayWallClock?: string;
124
+ lastPlayWallClock?: string;
125
+ gameState: string;
126
+ syncUrl?: string;
127
+ }
128
+ export interface StatsPromotion {
129
+ title: string;
130
+ description: string;
131
+ logo: string;
132
+ qrCode: string;
133
+ backgroundImage: string;
134
+ }
135
+ export interface StatsApiResponse {
136
+ entities: {
137
+ teams: EntityMap<Team>;
138
+ athletes: EntityMap<Athlete>;
139
+ };
140
+ leaders: Leader[];
141
+ header: Header;
142
+ predictor: Predictor;
143
+ winProbability: WinProbability;
144
+ gameState: string;
145
+ activeAthletes?: ActiveAthletes;
146
+ meta: Meta;
147
+ promotion?: StatsPromotion;
148
+ previousGames?: {
149
+ displayOrder: number;
150
+ team: {
151
+ $key: string;
152
+ };
153
+ events: {
154
+ team: {
155
+ $key: string;
156
+ homeAway: string;
157
+ };
158
+ score: string;
159
+ gameResult: string;
160
+ }[];
161
+ }[];
162
+ }
163
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { StatsApiResponse } from './interfaces/IStats';
2
+ export declare const MOCK_STATS_API_PRE_GAME_RESPONSE: StatsApiResponse;