@maestro_io/maestro-web-sdk 3.3.1 → 4.0.0-beta.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 (269) hide show
  1. package/dist/f8820fca3a2a7957f753167da0884f9d.png +0 -0
  2. package/dist/maestro-web-sdk.esm.js +12 -12
  3. package/dist/maestro-web-sdk.esm.js.map +1 -1
  4. package/dist/maestro-web-sdk.umd.js +12 -12
  5. package/dist/maestro-web-sdk.umd.js.map +1 -1
  6. package/dist/package.json +87 -0
  7. package/dist/src/__mocks__/sentry.d.ts +4 -0
  8. package/dist/src/components/atoms/BaseButton/BaseButton.js +11 -0
  9. package/dist/src/components/atoms/BaseButton/index.js +2 -0
  10. package/dist/src/components/atoms/Image/index.js +34 -0
  11. package/dist/src/components/atoms/Rive/index.js +53 -0
  12. package/dist/src/components/atoms/SvgIcon/BetGeneralIcon.js +9 -0
  13. package/dist/src/components/atoms/SvgIcon/BetsIcon.js +11 -0
  14. package/dist/src/components/atoms/SvgIcon/BetsWarningIcon.js +11 -0
  15. package/dist/src/components/atoms/SvgIcon/CheckmarkIcon.js +6 -0
  16. package/dist/src/components/atoms/SvgIcon/CollapseIcon.js +6 -0
  17. package/dist/src/components/atoms/SvgIcon/ExpandIcon.js +6 -0
  18. package/dist/src/components/atoms/SvgIcon/FantasyIcon.js +15 -0
  19. package/dist/src/components/atoms/SvgIcon/FlameIcon.js +11 -0
  20. package/dist/src/components/atoms/SvgIcon/Icon.js +44 -0
  21. package/dist/src/components/atoms/SvgIcon/KeyPlaysIcon.js +10 -0
  22. package/dist/src/components/atoms/SvgIcon/MobilePhoneIcon.js +11 -0
  23. package/dist/src/components/atoms/SvgIcon/PlayIcon.js +8 -0
  24. package/dist/src/components/atoms/SvgIcon/ShopIcon.js +7 -0
  25. package/dist/src/components/atoms/SvgIcon/StatsIcon.js +12 -0
  26. package/dist/src/components/atoms/SvgIcon/TimesIcon.js +6 -0
  27. package/dist/src/components/atoms/SvgIcon/WarningIcon.js +8 -0
  28. package/dist/src/components/atoms/SvgIcon/index.js +2 -0
  29. package/dist/src/components/core/App/App.js +35 -0
  30. package/dist/src/components/core/App/index.js +2 -0
  31. package/dist/src/components/core/OverlayContainer.js +58 -0
  32. package/dist/src/components/core/PanelManager/PanelManager.js +86 -0
  33. package/dist/src/components/core/PanelManager/index.js +2 -0
  34. package/dist/src/components/core/ScrollableContainer/FocusableItem.js +38 -0
  35. package/dist/src/components/core/ScrollableContainer/ScrollableContainer.js +168 -0
  36. package/dist/src/components/core/ScrollableContainer/index.js +2 -0
  37. package/dist/src/components/molecules/ActionButton/ActionButton.js +10 -0
  38. package/dist/src/components/molecules/ActionButton/index.js +2 -0
  39. package/dist/src/components/molecules/HeadshotImage/HeadshotImage.js +50 -0
  40. package/dist/src/components/molecules/HeadshotImage/index.js +2 -0
  41. package/dist/src/components/molecules/Overlay/Overlay.js +139 -0
  42. package/dist/src/components/molecules/Overlay/index.js +2 -0
  43. package/dist/src/components/molecules/PanelNavButton/PanelNavButton.js +27 -0
  44. package/dist/src/components/molecules/PanelNavButton/index.js +2 -0
  45. package/dist/src/components/molecules/SegmentButton/SegmentButton.js +10 -0
  46. package/dist/src/components/molecules/SegmentButton/index.js +2 -0
  47. package/dist/src/components/molecules/TabLoadError/TabLoadError.js +14 -0
  48. package/dist/src/components/molecules/TabLoadError/index.js +2 -0
  49. package/dist/src/components/molecules/WatchButton/WatchButton.js +15 -0
  50. package/dist/src/components/molecules/WatchButton/index.js +2 -0
  51. package/dist/src/components/organisms/PanelNavigation/PanelNavigation.js +60 -0
  52. package/dist/src/components/organisms/PanelNavigation/index.js +2 -0
  53. package/dist/src/components/organisms/SegmentController/SegmentController.js +76 -0
  54. package/dist/src/components/organisms/SegmentController/index.js +2 -0
  55. package/dist/src/development/MaestroEventDelegate.js +109 -0
  56. package/dist/src/development/TimeSeek.js +218 -0
  57. package/dist/src/development/development.js +33 -0
  58. package/dist/src/external/AxiosNetworkClient.js +110 -0
  59. package/dist/src/external/LocalStorageCacheManager.js +213 -0
  60. package/dist/src/external/ReactRenderer.js +53 -0
  61. package/dist/src/external/mocks/MockExternalNetworkClient.js +187 -0
  62. package/dist/src/external/ports/cacheManager.js +1 -0
  63. package/dist/src/external/ports/networkClient.js +1 -0
  64. package/dist/src/external/ports/renderer.d.ts +1 -2
  65. package/dist/src/external/ports/renderer.js +1 -0
  66. package/dist/src/external/spatial-navigation/__mocks__/withFocusable.d.ts +8 -0
  67. package/dist/src/external/spatial-navigation/__mocks__/withFocusable.js +7 -0
  68. package/dist/src/external/spatial-navigation/index.js +3 -0
  69. package/dist/src/external/spatial-navigation/measureLayout.js +30 -0
  70. package/dist/src/external/spatial-navigation/spatialNavigation.js +876 -0
  71. package/dist/src/external/spatial-navigation/utils.js +6 -0
  72. package/dist/src/external/spatial-navigation/visualDebugger.js +76 -0
  73. package/dist/src/external/spatial-navigation/withFocusable.js +245 -0
  74. package/dist/src/helpers/Observable.js +37 -0
  75. package/dist/src/helpers/strings.js +14 -0
  76. package/dist/src/helpers/url.js +12 -0
  77. package/dist/src/index.d.ts +5 -5
  78. package/dist/src/index.js +165 -0
  79. package/dist/src/interfaces/IMaestroEvent.d.ts +12 -0
  80. package/dist/src/interfaces/IMaestroEvent.js +18 -0
  81. package/dist/src/interfaces/IMaestroEventDelegate.js +1 -0
  82. package/dist/src/interfaces/IMaestroManager.js +1 -0
  83. package/dist/src/interfaces/IUserSettings.js +20 -0
  84. package/dist/src/models/IModel.js +1 -0
  85. package/dist/src/models/IPanel.js +40 -0
  86. package/dist/src/models/ITheme.js +20 -0
  87. package/dist/src/models/IWinningBet.js +1 -0
  88. package/dist/src/modules/bets/interfaces/IBets.js +1 -0
  89. package/dist/src/modules/bets/mocks.js +573 -0
  90. package/dist/src/modules/bets/types/BetsAnalyticsTypes.js +1 -0
  91. package/dist/src/modules/bets/view/BetsView.js +143 -0
  92. package/dist/src/modules/bets/view/HotProps/HotPropsView.js +150 -0
  93. package/dist/src/modules/bets/view/SixPack/SixPackView.js +110 -0
  94. package/dist/src/modules/bets/view/UserBets/BetResult/BetResult.js +6 -0
  95. package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCard.js +149 -0
  96. package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +34 -0
  97. package/dist/src/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +18 -0
  98. package/dist/src/modules/bets/view/UserBets/Boost/Boost.js +6 -0
  99. package/dist/src/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +9 -0
  100. package/dist/src/modules/bets/view/UserBets/Parlay/Parlay.js +13 -0
  101. package/dist/src/modules/bets/view/UserBets/Straight/Straight.js +6 -0
  102. package/dist/src/modules/bets/view/UserBets/Teaser/Teaser.js +13 -0
  103. package/dist/src/modules/bets/view/UserBets/UserBetsView.js +107 -0
  104. package/dist/src/modules/bets/view/components/Bet/Bet.js +32 -0
  105. package/dist/src/modules/bets/view/components/BetPill/BetPill.js +6 -0
  106. package/dist/src/modules/bets/view/components/BetsCard/BetsCard.js +15 -0
  107. package/dist/src/modules/bets/view/components/BetsCard/BetsCardHeader.js +20 -0
  108. package/dist/src/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +14 -0
  109. package/dist/src/modules/bets/view/components/LocationWarning/LocationWarning.js +16 -0
  110. package/dist/src/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +78 -0
  111. package/dist/src/modules/bets/view/components/PromoCodeBanner/index.js +1 -0
  112. package/dist/src/modules/bets/view-model/BetsViewModel.js +974 -0
  113. package/dist/src/modules/fantasy/components/ExpandedAthleteList/ExpandedAthletesList.js +107 -0
  114. package/dist/src/modules/fantasy/components/ExpandedAthleteList/index.js +1 -0
  115. package/dist/src/modules/fantasy/components/LeagueCard/LeagueCard.js +20 -0
  116. package/dist/src/modules/fantasy/components/LeagueCard/index.js +2 -0
  117. package/dist/src/modules/fantasy/components/TopPlayerCard/TopPlayerCard.js +29 -0
  118. package/dist/src/modules/fantasy/components/TopPlayerCard/index.js +2 -0
  119. package/dist/src/modules/fantasy/mocks.js +3682 -0
  120. package/dist/src/modules/fantasy/types.js +6 -0
  121. package/dist/src/modules/fantasy/view/ActiveAthletesMarquee/ActiveAthletesMarquee.js +74 -0
  122. package/dist/src/modules/fantasy/view/ActiveAthletesMarquee/index.js +2 -0
  123. package/dist/src/modules/fantasy/view/ErrorBoundary.d.ts +13 -0
  124. package/dist/src/modules/fantasy/view/FantasyItemView.js +74 -0
  125. package/dist/src/modules/fantasy/view/FantasyView.js +133 -0
  126. package/dist/src/modules/fantasy/view/InactiveLeague/DraftDateCountdown.js +95 -0
  127. package/dist/src/modules/fantasy/view/InactiveLeague/InactiveLeague.js +13 -0
  128. package/dist/src/modules/fantasy/view/InactiveLeague/index.js +2 -0
  129. package/dist/src/modules/fantasy/view/LoginView/LoginView.js +27 -0
  130. package/dist/src/modules/fantasy/view/LoginView/index.js +2 -0
  131. package/dist/src/modules/fantasy/view/MatchupPair/DoubleAthleteCard/DoubleAthleteCard.js +25 -0
  132. package/dist/src/modules/fantasy/view/MatchupPair/DoubleAthleteCard/index.js +2 -0
  133. package/dist/src/modules/fantasy/view/MatchupPair/ExpandedDoubleAthleteCards.js +9 -0
  134. package/dist/src/modules/fantasy/view/MatchupPair/MatchupPair.js +118 -0
  135. package/dist/src/modules/fantasy/view/MatchupPair/index.js +2 -0
  136. package/dist/src/modules/fantasy/view/MatchupSingle/ExpandedSingleAthleteCards.js +9 -0
  137. package/dist/src/modules/fantasy/view/MatchupSingle/MatchupSingle.js +108 -0
  138. package/dist/src/modules/fantasy/view/MatchupSingle/SingleAthleteCard/SingleAthleteCard.js +18 -0
  139. package/dist/src/modules/fantasy/view/MatchupSingle/SingleAthleteCard/index.js +2 -0
  140. package/dist/src/modules/fantasy/view/MatchupSingle/index.js +2 -0
  141. package/dist/src/modules/fantasy/view/PromoView/PromoView.js +12 -0
  142. package/dist/src/modules/fantasy/view/PromoView/index.js +2 -0
  143. package/dist/src/modules/fantasy/view/index.js +2 -0
  144. package/dist/src/modules/fantasy/view-model/FantasyViewModel.FantasyPolling.js +132 -0
  145. package/dist/src/modules/fantasy/view-model/FantasyViewModel.LeagueManagerPolling.js +141 -0
  146. package/dist/src/modules/fantasy/view-model/FantasyViewModel.js +534 -0
  147. package/dist/src/modules/key-plays/constants.js +292 -0
  148. package/dist/src/modules/key-plays/interfaces/IKeyPlays.js +14 -0
  149. package/dist/src/modules/key-plays/interfaces/IKeyPlaysResponse.js +1 -0
  150. package/dist/src/modules/key-plays/view/KeyPlayCardScoreTagView.js +16 -0
  151. package/dist/src/modules/key-plays/view/KeyPlayCardView.js +144 -0
  152. package/dist/src/modules/key-plays/view/KeyPlayErrorStateView.js +65 -0
  153. package/dist/src/modules/key-plays/view/KeyPlaysView.js +151 -0
  154. package/dist/src/modules/key-plays/view-model/KeyPlaysViewModel.js +246 -0
  155. package/dist/src/modules/shop/mocks.js +390 -0
  156. package/dist/src/modules/shop/types.js +7 -0
  157. package/dist/src/modules/shop/view/ProductDetailView/ProductDetailView.js +56 -0
  158. package/dist/src/modules/shop/view/ProductDetailView/index.js +2 -0
  159. package/dist/src/modules/shop/view/ShopView.js +182 -0
  160. package/dist/src/modules/shop/view/components/BrowseCard/BrowseCard.js +23 -0
  161. package/dist/src/modules/shop/view/components/BrowseCard/index.js +2 -0
  162. package/dist/src/modules/shop/view/components/ProductSummaryCard/ProductSummaryCard.js +26 -0
  163. package/dist/src/modules/shop/view/components/ProductSummaryCard/index.js +1 -0
  164. package/dist/src/modules/shop/view/components/ShopPromoView/ShopPromoView.js +19 -0
  165. package/dist/src/modules/shop/view/components/ShopPromoView/index.js +1 -0
  166. package/dist/src/modules/shop/view/components/ShopSection/ShopSection.d.ts +1 -0
  167. package/dist/src/modules/shop/view/components/ShopSection/ShopSection.js +61 -0
  168. package/dist/src/modules/shop/view/components/ShopSection/ShopSectionItem.d.ts +18 -0
  169. package/dist/src/modules/shop/view/components/ShopSection/ShopSectionItem.js +22 -0
  170. package/dist/src/modules/shop/view/components/ShopSection/index.js +1 -0
  171. package/dist/src/modules/shop/view/index.js +2 -0
  172. package/dist/src/modules/shop/view-model/ShopViewModel.ShopPolling.js +111 -0
  173. package/dist/src/modules/shop/view-model/ShopViewModel.js +353 -0
  174. package/dist/src/modules/stats/interfaces/IStats.js +1 -0
  175. package/dist/src/modules/stats/mocks.js +746 -0
  176. package/dist/src/modules/stats/utils/driveSummaryUtils.js +48 -0
  177. package/dist/src/modules/stats/utils/renderTeamStatistic.js +16 -0
  178. package/dist/src/modules/stats/utils.js +62 -0
  179. package/dist/src/modules/stats/view/ActiveAthletes/ActiveAthletes.js +98 -0
  180. package/dist/src/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.js +27 -0
  181. package/dist/src/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.js +89 -0
  182. package/dist/src/modules/stats/view/ActiveAthletes/index.js +2 -0
  183. package/dist/src/modules/stats/view/DriveSummary/DrivePlayCard.js +70 -0
  184. package/dist/src/modules/stats/view/DriveSummary/DriveSummary.js +87 -0
  185. package/dist/src/modules/stats/view/DriveSummary/ExpandedItems/DriveSummaryExpanded.js +129 -0
  186. package/dist/src/modules/stats/view/DriveSummary/Header/DriveSummaryHeader.js +26 -0
  187. package/dist/src/modules/stats/view/DriveSummary/MainStat/MainStat.js +24 -0
  188. package/dist/src/modules/stats/view/DriveSummary/index.js +2 -0
  189. package/dist/src/modules/stats/view/GameLeaders/GameLeaders.js +48 -0
  190. package/dist/src/modules/stats/view/GameLeaders/index.js +2 -0
  191. package/dist/src/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +55 -0
  192. package/dist/src/modules/stats/view/MatchPredictor/DonutChart/index.js +1 -0
  193. package/dist/src/modules/stats/view/MatchPredictor/MatchPredictorView.js +60 -0
  194. package/dist/src/modules/stats/view/MatchPredictor/index.js +2 -0
  195. package/dist/src/modules/stats/view/Penalties/Penalties.js +6 -0
  196. package/dist/src/modules/stats/view/Penalties/index.js +2 -0
  197. package/dist/src/modules/stats/view/RecentGames/RecentGames.js +23 -0
  198. package/dist/src/modules/stats/view/RecentGames/index.js +2 -0
  199. package/dist/src/modules/stats/view/ScoringSummary/ExpandedScores/ExpandedScores.js +121 -0
  200. package/dist/src/modules/stats/view/ScoringSummary/ExpandedScores/index.js +2 -0
  201. package/dist/src/modules/stats/view/ScoringSummary/ScoreItem/ScoreItem.js +62 -0
  202. package/dist/src/modules/stats/view/ScoringSummary/ScoreItem/index.js +2 -0
  203. package/dist/src/modules/stats/view/ScoringSummary/ScoresSection/ScoresSection.js +23 -0
  204. package/dist/src/modules/stats/view/ScoringSummary/ScoresSection/index.js +2 -0
  205. package/dist/src/modules/stats/view/ScoringSummary/ScoringSummary.js +106 -0
  206. package/dist/src/modules/stats/view/ScoringSummary/index.js +2 -0
  207. package/dist/src/modules/stats/view/StatsItemView.js +92 -0
  208. package/dist/src/modules/stats/view/StatsQRCode/StatsQRCodeView.js +36 -0
  209. package/dist/src/modules/stats/view/StatsQRCode/index.js +1 -0
  210. package/dist/src/modules/stats/view/StatsView.js +137 -0
  211. package/dist/src/modules/stats/view/TeamStats/TeamStatsView.js +43 -0
  212. package/dist/src/modules/stats/view/TeamStats/index.js +1 -0
  213. package/dist/src/modules/stats/view/Teams/StatsCarousel.js +83 -0
  214. package/dist/src/modules/stats/view/Teams/StatsProgressBar.js +19 -0
  215. package/dist/src/modules/stats/view/Teams/Teams.js +27 -0
  216. package/dist/src/modules/stats/view/Teams/index.js +2 -0
  217. package/dist/src/modules/stats/view/WinProbability/WinProbability.js +28 -0
  218. package/dist/src/modules/stats/view/WinProbability/index.js +2 -0
  219. package/dist/src/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +89 -0
  220. package/dist/src/modules/stats/view/components/AthletesStatistics/StatisticTable.js +12 -0
  221. package/dist/src/modules/stats/view/components/AthletesStatistics/index.js +2 -0
  222. package/dist/src/modules/stats/view/index.js +2 -0
  223. package/dist/src/modules/stats/view-model/StatsViewModel.d.ts +5 -0
  224. package/dist/src/modules/stats/view-model/StatsViewModel.js +989 -0
  225. package/dist/src/sentry.js +31 -0
  226. package/dist/src/services/AnalyticsService/AnalyticsService.d.ts +12 -7
  227. package/dist/src/services/AnalyticsService/AnalyticsService.js +402 -0
  228. package/dist/src/services/AnalyticsService/types.js +1 -0
  229. package/dist/src/services/BetsService.js +122 -0
  230. package/dist/src/services/FantasyService.js +92 -0
  231. package/dist/src/services/GlobalService/GlobalService.d.ts +9 -0
  232. package/dist/src/services/GlobalService/PageService.d.ts +9 -0
  233. package/dist/src/services/GlobalService/index.d.ts +2 -0
  234. package/dist/src/services/GlobalService/mocks.d.ts +2 -0
  235. package/dist/src/services/GlobalService/types.d.ts +11 -0
  236. package/dist/src/services/InsightsService/InsightsPayloadBuilder.d.ts +1 -2
  237. package/dist/src/services/InsightsService/InsightsPayloadBuilder.js +386 -0
  238. package/dist/src/services/InsightsService/InsightsService.js +74 -0
  239. package/dist/src/services/NetworkManager/NetworkManager.js +457 -0
  240. package/dist/src/services/NetworkManager/NetworkManagerFactory.js +101 -0
  241. package/dist/src/services/NetworkManager/errors.js +45 -0
  242. package/dist/src/services/NetworkManager/types.js +10 -0
  243. package/dist/src/services/PageService/PageService.d.ts +9 -0
  244. package/dist/src/services/PageService/PageService.js +39 -0
  245. package/dist/src/services/PageService/index.d.ts +2 -0
  246. package/dist/src/services/PageService/index.js +2 -0
  247. package/dist/src/services/PageService/mocks.d.ts +2 -0
  248. package/dist/src/services/PageService/mocks.js +104 -0
  249. package/dist/src/services/PageService/types.d.ts +76 -0
  250. package/dist/src/services/PageService/types.js +1 -0
  251. package/dist/src/services/ShopService.js +46 -0
  252. package/dist/src/services/StaticService/PageService.d.ts +9 -0
  253. package/dist/src/services/StaticService/StaticService.d.ts +3 -1
  254. package/dist/src/services/StaticService/StaticService.js +59 -0
  255. package/dist/src/services/StaticService/index.js +2 -0
  256. package/dist/src/services/StaticService/mocks.js +104 -0
  257. package/dist/src/services/StaticService/types.js +1 -0
  258. package/dist/src/services/StatsService.d.ts +1 -0
  259. package/dist/src/services/StatsService.js +147 -0
  260. package/dist/src/services/ThemeManager/constants.js +47 -0
  261. package/dist/src/services/UserSettingsManager.js +155 -0
  262. package/dist/src/test-polyfills.js +15 -0
  263. package/dist/src/types/OverlayTypes.js +4 -0
  264. package/dist/src/view-models/MaestroEventViewModel.d.ts +1 -2
  265. package/dist/src/view-models/MaestroEventViewModel.js +307 -0
  266. package/dist/src/view-models/OverlayViewModel.js +222 -0
  267. package/dist/src/view-models/PanelManagerViewModel.js +212 -0
  268. package/dist/src/view-models/ViewModel.js +32 -0
  269. package/package.json +1 -1
@@ -0,0 +1,151 @@
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 ScrollableContainer from '@/components/core/ScrollableContainer';
7
+ const STICKY_HEADER_HEIGHT = 32;
8
+ export class KeyPlays extends Component {
9
+ constructor(props) {
10
+ super(props);
11
+ Object.defineProperty(this, "container", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: null
16
+ });
17
+ Object.defineProperty(this, "playbackProgressUnsub", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: null
22
+ });
23
+ Object.defineProperty(this, "playbackIndexUnsub", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: null
28
+ });
29
+ Object.defineProperty(this, "itemsUnsub", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: null
34
+ });
35
+ Object.defineProperty(this, "vm", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: void 0
40
+ });
41
+ Object.defineProperty(this, "handlePlayClip", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: (index) => async () => {
46
+ await this.viewModel.playKeyPlay(index);
47
+ }
48
+ });
49
+ this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
50
+ this.state = {
51
+ scrollableContainer: null,
52
+ playbackProgress: this.viewModel.currentClipPlaybackProgress.value ?? null,
53
+ playbackIndex: this.viewModel.currentlyPlayingClipIndex.value ?? null,
54
+ items: this.viewModel.filteredItems.value ?? [],
55
+ };
56
+ }
57
+ get viewModel() {
58
+ if (!this.vm) {
59
+ throw new Error('KeyPlaysViewModel is not initialized');
60
+ }
61
+ return this.vm;
62
+ }
63
+ componentDidMount() {
64
+ this.playbackProgressUnsub = this.viewModel.currentClipPlaybackProgress.subscribe((value) => {
65
+ this.setState({ playbackProgress: value ?? null });
66
+ });
67
+ this.playbackIndexUnsub = this.viewModel.currentlyPlayingClipIndex.subscribe((value) => {
68
+ this.setState({ playbackIndex: value ?? null });
69
+ });
70
+ this.itemsUnsub = this.viewModel.filteredItems.subscribe((items) => {
71
+ this.setState({
72
+ items,
73
+ });
74
+ });
75
+ this.setState({
76
+ scrollableContainer: this.container,
77
+ });
78
+ }
79
+ componentWillUnmount() {
80
+ this.playbackProgressUnsub && this.playbackProgressUnsub();
81
+ this.playbackIndexUnsub && this.playbackIndexUnsub();
82
+ this.itemsUnsub && this.itemsUnsub();
83
+ }
84
+ render() {
85
+ const { playbackProgress, playbackIndex, items, scrollableContainer, } = this.state;
86
+ return (React.createElement(ScrollableContainer, { scrollableContainerRef: scrollableContainer, containerTopOffset: STICKY_HEADER_HEIGHT },
87
+ React.createElement("div", { ref: (el) => {
88
+ this.container = el;
89
+ }, className: "key-plays-view" },
90
+ items.map((section, sectionIndex) => (React.createElement("div", { key: `section-${sectionIndex}`, className: "key-plays-section" },
91
+ section.title && (React.createElement("h3", { className: "key-plays-section-title T10" }, section.title)),
92
+ React.createElement("div", { className: "key-plays-section-items" }, section.items.map((item) => {
93
+ const absoluteIndex = this.vm?.allItems.findIndex((vmItem) => vmItem.id === item.id) ?? -1;
94
+ 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.viewModel.isCurrentlyPlaying(absoluteIndex), isScoring: Boolean(item.awayTeamScore && item.homeTeamScore), playbackProgress: absoluteIndex === playbackIndex
95
+ ? playbackProgress
96
+ : null, onEnterPress: this.handlePlayClip(absoluteIndex) }));
97
+ }))))),
98
+ React.createElement("div", { className: "key-plays-bottom-padding" }))));
99
+ }
100
+ }
101
+ export default class KeyPlaysWithErrorState extends Component {
102
+ constructor(props) {
103
+ super(props);
104
+ Object.defineProperty(this, "errorStateUnsub", {
105
+ enumerable: true,
106
+ configurable: true,
107
+ writable: true,
108
+ value: null
109
+ });
110
+ Object.defineProperty(this, "vm", {
111
+ enumerable: true,
112
+ configurable: true,
113
+ writable: true,
114
+ value: void 0
115
+ });
116
+ Object.defineProperty(this, "handleRetry", {
117
+ enumerable: true,
118
+ configurable: true,
119
+ writable: true,
120
+ value: async () => {
121
+ await this.viewModel.userRequestedNewKeyPlaysData();
122
+ }
123
+ });
124
+ this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
125
+ this.state = {
126
+ errorState: this.viewModel.errorState.value,
127
+ };
128
+ }
129
+ get viewModel() {
130
+ if (!this.vm) {
131
+ throw new Error('KeyPlaysViewModel is not initialized');
132
+ }
133
+ return this.vm;
134
+ }
135
+ componentDidMount() {
136
+ this.errorStateUnsub = this.viewModel.errorState.subscribe((value) => {
137
+ this.setState({ errorState: value });
138
+ });
139
+ this.viewModel.init();
140
+ }
141
+ componentWillUnmount() {
142
+ this.errorStateUnsub && this.errorStateUnsub();
143
+ }
144
+ render() {
145
+ const { errorState } = this.state;
146
+ if (errorState) {
147
+ return (React.createElement(KeyPlayErrorStateView, { errorState: errorState, onRetry: this.handleRetry }));
148
+ }
149
+ return React.createElement(KeyPlays, null);
150
+ }
151
+ }
@@ -0,0 +1,246 @@
1
+ import SDK from '@/index';
2
+ import { Observable } from '@/helpers/Observable';
3
+ import { setImageDimensions } from '@/helpers/url';
4
+ import AnalyticsService from '@/services/AnalyticsService/AnalyticsService';
5
+ class KeyPlaysViewModel {
6
+ constructor() {
7
+ Object.defineProperty(this, "currentlyPlayingClipIndex", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: new Observable(null)
12
+ });
13
+ Object.defineProperty(this, "lastPlayedClipIndex", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: new Observable(null)
18
+ });
19
+ Object.defineProperty(this, "currentClipPlaybackProgress", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: new Observable(null)
24
+ });
25
+ Object.defineProperty(this, "errorState", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: new Observable('unpopulatedEvent')
30
+ });
31
+ Object.defineProperty(this, "failedClips", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: new Observable({})
36
+ });
37
+ Object.defineProperty(this, "items", {
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true,
41
+ value: new Observable([])
42
+ });
43
+ Object.defineProperty(this, "filteredItems", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: new Observable([])
48
+ });
49
+ Object.defineProperty(this, "analyticsService", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+ this.analyticsService = new AnalyticsService();
56
+ }
57
+ onUpdatePlayerTimeCode(playerTimeCode) {
58
+ this.filterItemsByPlayerTimeCode(playerTimeCode);
59
+ this.cleanErrors();
60
+ }
61
+ filterItemsByPlayerTimeCode(playerTimeCode) {
62
+ if (!playerTimeCode) {
63
+ this.filteredItems.value = this.items.value;
64
+ return;
65
+ }
66
+ const filteredItems = [];
67
+ for (const item of this.items.value) {
68
+ const filteredKeyPlays = item.items.filter((keyPlay) => this.shouldShowKeyPlay(keyPlay, playerTimeCode));
69
+ if (filteredKeyPlays.length > 0) {
70
+ filteredItems.push({
71
+ title: item.title,
72
+ items: filteredKeyPlays,
73
+ });
74
+ }
75
+ }
76
+ this.filteredItems.value = filteredItems;
77
+ }
78
+ shouldShowKeyPlay(keyPlay, playerTimeCode) {
79
+ if (!keyPlay.wallClock || !playerTimeCode) {
80
+ return true;
81
+ }
82
+ const timestamp = new Date(playerTimeCode);
83
+ const wallClockTimestamp = new Date(keyPlay.wallClock);
84
+ return wallClockTimestamp <= timestamp;
85
+ }
86
+ isCurrentlyPlaying(index) {
87
+ return index === this.currentlyPlayingClipIndex.value;
88
+ }
89
+ async setKeyPlays(items, playerTimeCode) {
90
+ if (items === null) {
91
+ this.errorState.value = 'tabLoadFailure';
92
+ return;
93
+ }
94
+ this.items.value = this.parseNetworkResponse(items);
95
+ this.filterItemsByPlayerTimeCode(playerTimeCode);
96
+ this.cleanErrors();
97
+ }
98
+ cleanErrors() {
99
+ if (this.errorState.value === 'tabLoadFailure') {
100
+ this.errorState.value = null;
101
+ }
102
+ if (this.errorState.value === 'unpopulatedEvent' && this.allItems.length) {
103
+ this.errorState.value = null;
104
+ }
105
+ if (!this.filteredItems.value.length) {
106
+ this.errorState.value = 'unpopulatedEvent';
107
+ }
108
+ }
109
+ async playKeyPlay(atIndex) {
110
+ const keyPlay = this.allItems[atIndex];
111
+ if (!keyPlay) {
112
+ console.warn('Key play not found at index:', atIndex);
113
+ return;
114
+ }
115
+ const mevm = SDK.getMaestroEventViewModel();
116
+ mevm.delegate.playClip(atIndex);
117
+ this.analyticsService.panelClick({
118
+ type: 'espnKeyPlays',
119
+ name: 'key_play_clicked',
120
+ metadata: {
121
+ action: 'play clip',
122
+ clip: keyPlay.clipID,
123
+ key_play: keyPlay.description,
124
+ },
125
+ });
126
+ }
127
+ async init() {
128
+ await this.analyticsService.panelView('espnKeyPlays');
129
+ }
130
+ parseNetworkResponse(response) {
131
+ const teams = Object.values(response.entities?.team || {});
132
+ const athletes = Object.values(response.entities?.athlete || {});
133
+ const homeTeam = teams.find((team) => team.homeAway === 'home');
134
+ const awayTeam = teams.find((team) => team.homeAway === 'away');
135
+ const items = [];
136
+ const result = [];
137
+ for (const section of response.sections) {
138
+ for (const keyPlay of section.items) {
139
+ const playTeam = keyPlay.team
140
+ ? teams.find((team) => team.id === keyPlay.team)
141
+ : undefined;
142
+ const athlete = keyPlay.athlete
143
+ ? athletes.find((a) => a.id === keyPlay.athlete)
144
+ : undefined;
145
+ const teamImageUrl = playTeam?.logoRef
146
+ ? setImageDimensions(playTeam.logoRef, 184, 144)
147
+ : undefined;
148
+ const playerImageUrl = athlete?.headshot
149
+ ? setImageDimensions(athlete.headshot, 184, 144)
150
+ : undefined;
151
+ const thumbnailImageUrl = keyPlay.thumbnailType !== 'headshot' && keyPlay.thumbnail
152
+ ? setImageDimensions(keyPlay.thumbnail, 184, 144)
153
+ : undefined;
154
+ const homeScore = keyPlay.homeScore ? keyPlay.homeScore : '0';
155
+ const awayScore = keyPlay.awayScore ? keyPlay.awayScore : '0';
156
+ const homeTeamScore = keyPlay.scoringPlay
157
+ ? parseInt(homeScore)
158
+ : undefined;
159
+ const awayTeamScore = keyPlay.scoringPlay
160
+ ? parseInt(awayScore)
161
+ : undefined;
162
+ const keyPlayData = {
163
+ id: `${section.title || ''}-${keyPlay.clipID}`,
164
+ description: keyPlay.description ? keyPlay.description : '',
165
+ homeTeamName: homeTeam ? homeTeam.shortName : '',
166
+ awayTeamName: awayTeam ? awayTeam.shortName : '',
167
+ homeTeamScore,
168
+ awayTeamScore,
169
+ clipID: keyPlay.clipID,
170
+ teamImageUrl,
171
+ playerImageUrl,
172
+ thumbnailImageUrl,
173
+ section: section.title,
174
+ wallClock: keyPlay.wallClock,
175
+ };
176
+ items.push(keyPlayData);
177
+ }
178
+ // Only add the section if it has items
179
+ if (items.length) {
180
+ const sectionTitle = section.title;
181
+ const existingSection = result.find((item) => item.title === sectionTitle);
182
+ if (existingSection) {
183
+ existingSection.items.push(...items);
184
+ }
185
+ else {
186
+ result.push({
187
+ title: sectionTitle,
188
+ items: [...items],
189
+ });
190
+ }
191
+ // Reset items for the next section
192
+ items.length = 0;
193
+ }
194
+ }
195
+ return result;
196
+ }
197
+ get allItems() {
198
+ return this.items.value.reduce((acc, section) => {
199
+ return acc.concat(section.items);
200
+ }, []);
201
+ }
202
+ clipID(forKeyPlayAtIndex) {
203
+ const item = this.allItems[forKeyPlayAtIndex];
204
+ if (!item) {
205
+ return undefined;
206
+ }
207
+ return this.allItems[forKeyPlayAtIndex].clipID;
208
+ }
209
+ handleKeyPlayLoadFailure(forKeyPlayAtIndex) {
210
+ const clipID = this.clipID(forKeyPlayAtIndex);
211
+ if (clipID) {
212
+ const newFailedClips = this.failedClips.value;
213
+ newFailedClips[clipID] = 'recentFailure';
214
+ this.failedClips.value = newFailedClips;
215
+ setTimeout(() => {
216
+ if (this.loadFailureStatus(forKeyPlayAtIndex) === 'recentFailure') {
217
+ const newFailedClips = this.failedClips.value;
218
+ newFailedClips[clipID] = 'nonRecentFailure';
219
+ this.failedClips.value = newFailedClips;
220
+ }
221
+ }, 5000);
222
+ }
223
+ }
224
+ loadFailureStatus(forKeyPlayAtIndex) {
225
+ const clipID = this.clipID(forKeyPlayAtIndex);
226
+ const newFailedClips = this.failedClips.value;
227
+ if (!newFailedClips) {
228
+ return 'noFailure';
229
+ }
230
+ return clipID ? this.failedClips.value[clipID] : 'noFailure';
231
+ }
232
+ clearLoadFailureStatus(forKeyPlayAtIndex) {
233
+ const clipID = this.clipID(forKeyPlayAtIndex);
234
+ if (clipID && this.failedClips) {
235
+ this.failedClips.value = {
236
+ ...this.failedClips.value,
237
+ [clipID]: 'noFailure',
238
+ };
239
+ }
240
+ }
241
+ async userRequestedNewKeyPlaysData() {
242
+ const mevm = SDK.getMaestroEventViewModel();
243
+ await mevm.delegate.userRequestedNewKeyPlaysData();
244
+ }
245
+ }
246
+ export default KeyPlaysViewModel;