@telus-uds/components-web 1.7.0 → 1.9.0

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 (220) hide show
  1. package/.eslintignore +2 -0
  2. package/.vscode/settings.json +7 -0
  3. package/CHANGELOG.md +39 -2
  4. package/lib/Autocomplete/Autocomplete.js +393 -0
  5. package/lib/Autocomplete/Loading.js +51 -0
  6. package/lib/Autocomplete/Suggestions.js +81 -0
  7. package/lib/Autocomplete/constants.js +19 -0
  8. package/lib/Autocomplete/dictionary.js +19 -0
  9. package/lib/Autocomplete/index.js +13 -0
  10. package/lib/BlockQuote/BlockQuote.js +173 -0
  11. package/lib/BlockQuote/index.js +13 -0
  12. package/lib/Callout/Callout.js +3 -0
  13. package/lib/Card/Card.js +180 -0
  14. package/lib/Card/CardContent.js +110 -0
  15. package/lib/Card/CardFooter.js +98 -0
  16. package/lib/Card/index.js +13 -0
  17. package/lib/Countdown/Countdown.js +189 -0
  18. package/lib/Countdown/Segment.js +111 -0
  19. package/lib/Countdown/constants.js +14 -0
  20. package/lib/Countdown/dictionary.js +29 -0
  21. package/lib/Countdown/index.js +13 -0
  22. package/lib/Countdown/types.js +39 -0
  23. package/lib/Countdown/useCountdown.js +40 -0
  24. package/lib/IconButton/IconButton.js +70 -0
  25. package/lib/IconButton/index.js +13 -0
  26. package/lib/Listbox/GroupControl.js +94 -0
  27. package/lib/Listbox/Listbox.js +164 -0
  28. package/lib/Listbox/ListboxGroup.js +129 -0
  29. package/lib/Listbox/ListboxItem.js +137 -0
  30. package/lib/Listbox/ListboxOverlay.js +89 -0
  31. package/lib/Listbox/PressableItem.js +149 -0
  32. package/lib/Listbox/index.js +13 -0
  33. package/lib/Modal/ModalContent.js +11 -4
  34. package/lib/NavigationBar/resolveItemSelection.js +24 -0
  35. package/lib/OptimizeImage/OptimizeImage.js +127 -0
  36. package/lib/OptimizeImage/index.js +13 -0
  37. package/lib/OptimizeImage/utils/getFallbackUrl.js +18 -0
  38. package/lib/OptimizeImage/utils/getOptimizedUrl.js +32 -0
  39. package/lib/OptimizeImage/utils/hasWebpSupport.js +38 -0
  40. package/lib/OptimizeImage/utils/index.js +31 -0
  41. package/lib/OptimizeImage/utils/isSvgUrl.js +10 -0
  42. package/lib/QuantitySelector/QuantitySelector.js +253 -0
  43. package/lib/QuantitySelector/dictionary.js +33 -0
  44. package/lib/QuantitySelector/index.js +13 -0
  45. package/lib/QuantitySelector/styles.js +40 -0
  46. package/lib/StoryCard/StoryCard.js +244 -0
  47. package/lib/StoryCard/index.js +13 -0
  48. package/lib/TermsAndConditions/ExpandCollapse.js +141 -0
  49. package/lib/TermsAndConditions/TermsAndConditions.js +221 -0
  50. package/lib/TermsAndConditions/dictionary.js +19 -0
  51. package/lib/TermsAndConditions/index.js +15 -0
  52. package/lib/Testimonial/Testimonial.js +226 -0
  53. package/lib/Testimonial/index.js +13 -0
  54. package/lib/Video/ControlBar/ControlBar.js +315 -0
  55. package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +91 -0
  56. package/lib/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +186 -0
  57. package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +221 -0
  58. package/lib/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +213 -0
  59. package/lib/Video/MiddleControlButton/MiddleControlButton.js +89 -0
  60. package/lib/Video/Video.js +1072 -0
  61. package/lib/Video/index.js +13 -0
  62. package/lib/Video/videoText.js +62 -0
  63. package/lib/WebVideo/WebVideo.js +170 -0
  64. package/lib/WebVideo/index.js +13 -0
  65. package/lib/baseExports.js +0 -12
  66. package/lib/index.js +118 -1
  67. package/lib/shared/VideoSplash/SplashButton/SplashButton.js +102 -0
  68. package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +234 -0
  69. package/lib/shared/VideoSplash/VideoSplash.js +86 -0
  70. package/lib/shared/VideoSplash/helpers.js +38 -0
  71. package/lib/utils/index.js +8 -0
  72. package/lib/utils/useOverlaidPosition.js +246 -0
  73. package/lib-module/Autocomplete/Autocomplete.js +369 -0
  74. package/lib-module/Autocomplete/Loading.js +38 -0
  75. package/lib-module/Autocomplete/Suggestions.js +64 -0
  76. package/lib-module/Autocomplete/constants.js +5 -0
  77. package/lib-module/Autocomplete/dictionary.js +12 -0
  78. package/lib-module/Autocomplete/index.js +2 -0
  79. package/lib-module/BlockQuote/BlockQuote.js +156 -0
  80. package/lib-module/BlockQuote/index.js +2 -0
  81. package/lib-module/Callout/Callout.js +3 -0
  82. package/lib-module/Card/Card.js +158 -0
  83. package/lib-module/Card/CardContent.js +92 -0
  84. package/lib-module/Card/CardFooter.js +80 -0
  85. package/lib-module/Card/index.js +2 -0
  86. package/lib-module/Countdown/Countdown.js +165 -0
  87. package/lib-module/Countdown/Segment.js +94 -0
  88. package/lib-module/Countdown/constants.js +4 -0
  89. package/lib-module/Countdown/dictionary.js +22 -0
  90. package/lib-module/Countdown/index.js +2 -0
  91. package/lib-module/Countdown/types.js +23 -0
  92. package/lib-module/Countdown/useCountdown.js +32 -0
  93. package/lib-module/IconButton/IconButton.js +52 -0
  94. package/lib-module/IconButton/index.js +2 -0
  95. package/lib-module/Listbox/GroupControl.js +80 -0
  96. package/lib-module/Listbox/Listbox.js +142 -0
  97. package/lib-module/Listbox/ListboxGroup.js +106 -0
  98. package/lib-module/Listbox/ListboxItem.js +112 -0
  99. package/lib-module/Listbox/ListboxOverlay.js +68 -0
  100. package/lib-module/Listbox/PressableItem.js +128 -0
  101. package/lib-module/Listbox/index.js +2 -0
  102. package/lib-module/Modal/ModalContent.js +10 -4
  103. package/lib-module/NavigationBar/resolveItemSelection.js +16 -0
  104. package/lib-module/OptimizeImage/OptimizeImage.js +106 -0
  105. package/lib-module/OptimizeImage/index.js +2 -0
  106. package/lib-module/OptimizeImage/utils/getFallbackUrl.js +8 -0
  107. package/lib-module/OptimizeImage/utils/getOptimizedUrl.js +22 -0
  108. package/lib-module/OptimizeImage/utils/hasWebpSupport.js +32 -0
  109. package/lib-module/OptimizeImage/utils/index.js +4 -0
  110. package/lib-module/OptimizeImage/utils/isSvgUrl.js +3 -0
  111. package/lib-module/QuantitySelector/QuantitySelector.js +232 -0
  112. package/lib-module/QuantitySelector/dictionary.js +26 -0
  113. package/lib-module/QuantitySelector/index.js +2 -0
  114. package/lib-module/QuantitySelector/styles.js +21 -0
  115. package/lib-module/StoryCard/StoryCard.js +220 -0
  116. package/lib-module/StoryCard/index.js +2 -0
  117. package/lib-module/TermsAndConditions/ExpandCollapse.js +120 -0
  118. package/lib-module/TermsAndConditions/TermsAndConditions.js +193 -0
  119. package/lib-module/TermsAndConditions/dictionary.js +12 -0
  120. package/lib-module/TermsAndConditions/index.js +1 -0
  121. package/lib-module/Testimonial/Testimonial.js +204 -0
  122. package/lib-module/Testimonial/index.js +2 -0
  123. package/lib-module/Video/ControlBar/ControlBar.js +292 -0
  124. package/lib-module/Video/ControlBar/Controls/VideoButton/VideoButton.js +74 -0
  125. package/lib-module/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +167 -0
  126. package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +201 -0
  127. package/lib-module/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +193 -0
  128. package/lib-module/Video/MiddleControlButton/MiddleControlButton.js +72 -0
  129. package/lib-module/Video/Video.js +1042 -0
  130. package/lib-module/Video/index.js +2 -0
  131. package/lib-module/Video/videoText.js +55 -0
  132. package/lib-module/WebVideo/WebVideo.js +144 -0
  133. package/lib-module/WebVideo/index.js +2 -0
  134. package/lib-module/baseExports.js +1 -1
  135. package/lib-module/index.js +13 -0
  136. package/lib-module/shared/VideoSplash/SplashButton/SplashButton.js +85 -0
  137. package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +216 -0
  138. package/lib-module/shared/VideoSplash/VideoSplash.js +65 -0
  139. package/lib-module/shared/VideoSplash/helpers.js +23 -0
  140. package/lib-module/utils/index.js +2 -1
  141. package/lib-module/utils/useOverlaidPosition.js +235 -0
  142. package/package.json +7 -5
  143. package/src/Autocomplete/Autocomplete.jsx +354 -0
  144. package/src/Autocomplete/Loading.jsx +18 -0
  145. package/src/Autocomplete/Suggestions.jsx +52 -0
  146. package/src/Autocomplete/constants.js +6 -0
  147. package/src/Autocomplete/dictionary.js +12 -0
  148. package/src/Autocomplete/index.js +3 -0
  149. package/src/BlockQuote/BlockQuote.jsx +130 -0
  150. package/src/BlockQuote/index.js +3 -0
  151. package/src/Callout/Callout.jsx +1 -1
  152. package/src/Card/Card.jsx +170 -0
  153. package/src/Card/CardContent.jsx +88 -0
  154. package/src/Card/CardFooter.jsx +70 -0
  155. package/src/Card/index.js +3 -0
  156. package/src/Countdown/Countdown.jsx +144 -0
  157. package/src/Countdown/Segment.jsx +69 -0
  158. package/src/Countdown/constants.js +4 -0
  159. package/src/Countdown/dictionary.js +22 -0
  160. package/src/Countdown/index.js +3 -0
  161. package/src/Countdown/types.js +23 -0
  162. package/src/Countdown/useCountdown.js +34 -0
  163. package/src/IconButton/IconButton.jsx +46 -0
  164. package/src/IconButton/index.js +3 -0
  165. package/src/Listbox/GroupControl.jsx +65 -0
  166. package/src/Listbox/Listbox.jsx +148 -0
  167. package/src/Listbox/ListboxGroup.jsx +110 -0
  168. package/src/Listbox/ListboxItem.jsx +101 -0
  169. package/src/Listbox/ListboxOverlay.jsx +71 -0
  170. package/src/Listbox/PressableItem.jsx +121 -0
  171. package/src/Listbox/index.js +3 -0
  172. package/src/Modal/ModalContent.jsx +8 -4
  173. package/src/NavigationBar/resolveItemSelection.js +11 -0
  174. package/src/OptimizeImage/OptimizeImage.jsx +131 -0
  175. package/src/OptimizeImage/index.js +3 -0
  176. package/src/OptimizeImage/utils/getFallbackUrl.js +9 -0
  177. package/src/OptimizeImage/utils/getOptimizedUrl.js +30 -0
  178. package/src/OptimizeImage/utils/hasWebpSupport.js +33 -0
  179. package/src/OptimizeImage/utils/index.js +5 -0
  180. package/src/OptimizeImage/utils/isSvgUrl.js +3 -0
  181. package/src/QuantitySelector/QuantitySelector.jsx +245 -0
  182. package/src/QuantitySelector/dictionary.js +27 -0
  183. package/src/QuantitySelector/index.js +3 -0
  184. package/src/QuantitySelector/styles.js +83 -0
  185. package/src/StoryCard/StoryCard.jsx +198 -0
  186. package/src/StoryCard/index.js +3 -0
  187. package/src/TermsAndConditions/ExpandCollapse.jsx +106 -0
  188. package/src/TermsAndConditions/TermsAndConditions.jsx +161 -0
  189. package/src/TermsAndConditions/dictionary.js +12 -0
  190. package/src/TermsAndConditions/index.js +1 -0
  191. package/src/Testimonial/Testimonial.jsx +169 -0
  192. package/src/Testimonial/index.js +3 -0
  193. package/src/Video/ControlBar/ControlBar.jsx +261 -0
  194. package/src/Video/ControlBar/Controls/VideoButton/VideoButton.jsx +61 -0
  195. package/src/Video/ControlBar/Controls/VideoMenu/VideoMenu.jsx +159 -0
  196. package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +185 -0
  197. package/src/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.jsx +184 -0
  198. package/src/Video/MiddleControlButton/MiddleControlButton.jsx +64 -0
  199. package/src/Video/Video.jsx +988 -0
  200. package/src/Video/index.js +3 -0
  201. package/src/Video/videoText.js +58 -0
  202. package/src/WebVideo/WebVideo.jsx +131 -0
  203. package/src/WebVideo/index.js +3 -0
  204. package/src/baseExports.js +0 -2
  205. package/src/index.js +13 -0
  206. package/src/shared/VideoSplash/SplashButton/SplashButton.jsx +64 -0
  207. package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +128 -0
  208. package/src/shared/VideoSplash/VideoSplash.jsx +50 -0
  209. package/src/shared/VideoSplash/helpers.js +27 -0
  210. package/src/utils/index.js +10 -1
  211. package/src/utils/useOverlaidPosition.js +226 -0
  212. package/types/Autocomplete.d.ts +32 -0
  213. package/types/Card.d.ts +45 -0
  214. package/types/ControlBar.d.ts +59 -0
  215. package/types/MiddleControlButton.d.ts +15 -0
  216. package/types/Video.d.ts +39 -0
  217. package/types/VideoButton.d.ts +14 -0
  218. package/types/VideoMenu.d.ts +16 -0
  219. package/types/VideoProgressBar.d.ts +17 -0
  220. package/types/VolumeSlider.d.ts +20 -0
@@ -0,0 +1,1072 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _fscreen = _interopRequireDefault(require("fscreen"));
15
+
16
+ var _componentsBase = require("@telus-uds/components-base");
17
+
18
+ var _Spinner = _interopRequireDefault(require("../Spinner"));
19
+
20
+ var _utils = require("../utils");
21
+
22
+ var _VideoSplash = _interopRequireDefault(require("../shared/VideoSplash/VideoSplash"));
23
+
24
+ var _MiddleControlButton = _interopRequireDefault(require("./MiddleControlButton/MiddleControlButton"));
25
+
26
+ var _ControlBar = _interopRequireDefault(require("./ControlBar/ControlBar"));
27
+
28
+ var _videoText = _interopRequireDefault(require("./videoText"));
29
+
30
+ var _jsxRuntime = require("react/jsx-runtime");
31
+
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
+
34
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
+
36
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
+
38
+ const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]); // TODO: replace with the actual spinner component from UDS
39
+
40
+ const VideoPlayerContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
41
+ displayName: "Video__VideoPlayerContainer",
42
+ componentId: "components-web__sc-12ltnuw-0"
43
+ })(_ref => {
44
+ let {
45
+ videoBorder,
46
+ borderColor
47
+ } = _ref;
48
+ return {
49
+ width: '100%',
50
+ outline: 'none',
51
+ position: 'relative',
52
+ border: videoBorder ? `20px solid ${borderColor}` : undefined
53
+ };
54
+ });
55
+
56
+ const VideoElementContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
57
+ displayName: "Video__VideoElementContainer",
58
+ componentId: "components-web__sc-12ltnuw-1"
59
+ })({
60
+ outline: 'none',
61
+ width: '100%',
62
+ height: '100%',
63
+ fontSize: 0
64
+ });
65
+
66
+ const VideoPlayer = /*#__PURE__*/_styledComponents.default.video.withConfig({
67
+ displayName: "Video__VideoPlayer",
68
+ componentId: "components-web__sc-12ltnuw-2"
69
+ })({
70
+ width: '100%',
71
+ height: '100%'
72
+ });
73
+
74
+ const VideoOverlayContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
75
+ displayName: "Video__VideoOverlayContainer",
76
+ componentId: "components-web__sc-12ltnuw-3"
77
+ })(_ref2 => {
78
+ let {
79
+ mouseInactive
80
+ } = _ref2;
81
+ return {
82
+ width: '100%',
83
+ height: '100%',
84
+ position: 'absolute',
85
+ cursor: mouseInactive ? 'none' : 'pointer'
86
+ };
87
+ });
88
+
89
+ const VideoSplashContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
90
+ displayName: "Video__VideoSplashContainer",
91
+ componentId: "components-web__sc-12ltnuw-4"
92
+ })({
93
+ position: 'absolute',
94
+ width: '100%',
95
+ height: '100%',
96
+ zIndex: 5
97
+ });
98
+
99
+ const VideoOverlayElementContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
100
+ displayName: "Video__VideoOverlayElementContainer",
101
+ componentId: "components-web__sc-12ltnuw-5"
102
+ })({
103
+ position: 'absolute',
104
+ zIndex: 4,
105
+ display: 'flex',
106
+ justifyContent: 'center',
107
+ alignItems: 'center',
108
+ width: '100%',
109
+ height: '100%'
110
+ });
111
+
112
+ const Video = props => {
113
+ const refVideoPlayer = (0, _react.useRef)({});
114
+ const refVideoPlayerContainer = (0, _react.useRef)({});
115
+ const refKeyboardInstructions = (0, _react.useRef)({});
116
+ let inactivityTimer = null;
117
+ const {
118
+ videoBorder,
119
+ simpleMode,
120
+ copy,
121
+ posterSrc,
122
+ crossOrigin,
123
+ defaultVolume,
124
+ sources,
125
+ tracks,
126
+ defaultDesktopQuality,
127
+ tokens,
128
+ variant = {},
129
+ ...rest
130
+ } = props;
131
+ const {
132
+ borderColor,
133
+ pauseIcon,
134
+ playIcon,
135
+ replayIcon
136
+ } = (0, _componentsBase.useThemeTokens)('Video', tokens, variant);
137
+ const playerOptions = {
138
+ mouseTimeout: simpleMode ? 750 : 1500,
139
+ // defined in ms
140
+ keyboardSeekIncrement: 5,
141
+ // defined in s
142
+ keyboardVolumeIncrement: 0.1,
143
+ // from 0 to 1
144
+ compactModeThreshold: 700 // in px
145
+
146
+ };
147
+ const [videoPlayerState, setVideoPlayerState] = (0, _react.useState)({
148
+ loadedSources: null,
149
+ loadedTracks: null,
150
+ videoLength: 0,
151
+ videoCurrentTime: -1,
152
+ videoBufferEnd: 0,
153
+ videoUnplayed: true,
154
+ videoIsBuffering: false,
155
+ videoCurrentVolume: 1,
156
+ videoIsPlaying: false,
157
+ videoIsMuted: false,
158
+ videoIsFullscreen: false,
159
+ mouseInactive: false,
160
+ videoEnded: false,
161
+ videoQuality: defaultDesktopQuality,
162
+ videoQualityChanged: false,
163
+ selectedTextTrack: -1,
164
+ mouseOnControlBar: false,
165
+ qualityMenuOpen: false,
166
+ captionsMenuOpen: false,
167
+ isMobile: false,
168
+ videoPlayerWidth: 0,
169
+ percentageWatched: 'watched 0%'
170
+ });
171
+
172
+ const generateSources = videoQuality => {
173
+ return sources.map(source => {
174
+ if (source.qualityRank === videoQuality) {
175
+ return /*#__PURE__*/_react.default.createElement('source', {
176
+ src: source.source,
177
+ type: source.mediaType,
178
+ key: source.source
179
+ });
180
+ }
181
+
182
+ return undefined;
183
+ });
184
+ };
185
+
186
+ const generateTracks = () => {
187
+ return tracks.map(track => {
188
+ return /*#__PURE__*/_react.default.createElement('track', {
189
+ label: track.label,
190
+ kind: track.kind,
191
+ srcLang: track.language,
192
+ src: track.source,
193
+ default: track.isDefault,
194
+ key: track.source
195
+ });
196
+ });
197
+ };
198
+
199
+ const refreshMedia = () => {
200
+ const {
201
+ defaultMobileQuality
202
+ } = props;
203
+ const {
204
+ videoUnplayed
205
+ } = videoPlayerState; // Handle mobile check
206
+
207
+ const isMobile = navigator && navigator.userAgent.indexOf('Mobi') >= 0;
208
+
209
+ if (videoUnplayed && isMobile) {
210
+ setVideoPlayerState(prevState => ({ ...prevState,
211
+ isMobile,
212
+ videoQuality: isMobile ? defaultMobileQuality : defaultDesktopQuality
213
+ }));
214
+ } // Load media
215
+
216
+
217
+ setVideoPlayerState(prevState => ({ ...prevState,
218
+ loadedSources: generateSources(prevState.videoQuality),
219
+ loadedTracks: tracks && generateTracks()
220
+ }));
221
+ };
222
+
223
+ const percentageBucket = percentValue => {
224
+ if (percentValue < 25) {
225
+ return setVideoPlayerState(prevState => {
226
+ if (prevState !== 'watched 0%') {
227
+ return { ...prevState,
228
+ percentageWatched: 'watched 0%'
229
+ };
230
+ }
231
+
232
+ return false;
233
+ });
234
+ }
235
+
236
+ if (percentValue < 50) {
237
+ return setVideoPlayerState(prevState => {
238
+ if (prevState !== 'watched 25%') {
239
+ return { ...prevState,
240
+ percentageWatched: 'watched 25%'
241
+ };
242
+ }
243
+
244
+ return false;
245
+ });
246
+ }
247
+
248
+ if (percentValue < 75) {
249
+ return setVideoPlayerState(prevState => {
250
+ if (prevState !== 'watched 50%') {
251
+ return { ...prevState,
252
+ percentageWatched: 'watched 50%'
253
+ };
254
+ }
255
+
256
+ return false;
257
+ });
258
+ }
259
+
260
+ if (percentValue < 100) {
261
+ return setVideoPlayerState(prevState => {
262
+ if (prevState !== 'watched 75%') {
263
+ return { ...prevState,
264
+ percentageWatched: 'watched 75%'
265
+ };
266
+ }
267
+
268
+ return false;
269
+ });
270
+ }
271
+
272
+ if (percentValue === 100) {
273
+ return setVideoPlayerState(prevState => {
274
+ if (prevState !== 'watched 100%') {
275
+ return { ...prevState,
276
+ percentageWatched: 'watched 100%'
277
+ };
278
+ }
279
+
280
+ return false;
281
+ });
282
+ }
283
+
284
+ return false;
285
+ }; // required for analytics
286
+
287
+
288
+ const calculatePercentageWatched = () => {
289
+ const {
290
+ videoCurrentTime,
291
+ videoLength,
292
+ percentageWatched
293
+ } = videoPlayerState;
294
+ const {
295
+ videoTitle,
296
+ analyticsTracking
297
+ } = props;
298
+ let percentValue = videoCurrentTime / videoLength * 100;
299
+ percentValue = Math.round(percentValue);
300
+ const previousValue = percentageWatched;
301
+ percentageBucket(percentValue);
302
+
303
+ if (previousValue !== percentageWatched) {
304
+ const analyticsObject = {
305
+ name: 'video tracking',
306
+ details: videoTitle
307
+ };
308
+ analyticsObject.action = percentageWatched;
309
+ analyticsTracking(analyticsObject);
310
+ }
311
+ };
312
+
313
+ const setPlaying = async isPlaying => {
314
+ const videoPlayer = refVideoPlayer.current;
315
+ const {
316
+ analyticsTracking,
317
+ videoTitle
318
+ } = props;
319
+
320
+ if (isPlaying) {
321
+ await videoPlayer.play();
322
+
323
+ if (analyticsTracking !== undefined && videoTitle) {
324
+ const intervalId = setInterval(calculatePercentageWatched, 300);
325
+ setVideoPlayerState(prevState => ({ ...prevState,
326
+ intervalId
327
+ }));
328
+ }
329
+ } else {
330
+ const {
331
+ intervalId
332
+ } = videoPlayerState;
333
+ videoPlayer.pause();
334
+ clearInterval(intervalId);
335
+ }
336
+ };
337
+
338
+ const updateAnalyticsData = () => {
339
+ const {
340
+ videoTitle,
341
+ analyticsTracking
342
+ } = props;
343
+ const {
344
+ videoIsPlaying,
345
+ percentageWatched
346
+ } = videoPlayerState;
347
+ const analyticsObject = {
348
+ name: 'video tracking',
349
+ details: videoTitle
350
+ };
351
+ analyticsObject.action = videoIsPlaying ? 'play' : 'pause';
352
+
353
+ if (percentageWatched !== 'watched 100%') {
354
+ analyticsTracking(analyticsObject);
355
+ }
356
+ };
357
+
358
+ const setSeek = seconds => {
359
+ refVideoPlayer.current.currentTime = seconds;
360
+ };
361
+
362
+ const qualitySwitchSeek = () => {
363
+ const {
364
+ videoCurrentTime
365
+ } = videoPlayerState; // The following setState gets the video length on the splash screen in iOS
366
+
367
+ setVideoPlayerState(prevState => ({ ...prevState,
368
+ videoLength: refVideoPlayer.current.duration
369
+ }));
370
+
371
+ if (videoCurrentTime > -1) {
372
+ setSeek(videoCurrentTime);
373
+ }
374
+ };
375
+
376
+ const updateVideoTimestamp = () => {
377
+ setVideoPlayerState(prevState => ({ ...prevState,
378
+ videoCurrentTime: refVideoPlayer.current.currentTime
379
+ }));
380
+ };
381
+
382
+ const initializeVideoDuration = () => {
383
+ // This will run on every load() call, meaning it will also run when video quality is changed.
384
+ setVideoPlayerState(prevState => {
385
+ return { ...prevState,
386
+ videoLength: refVideoPlayer.current.duration,
387
+ videoBufferEnd: refVideoPlayer.current.buffered.length === 0 ? 0 : refVideoPlayer.current.buffered.end(refVideoPlayer.current.buffered.length - 1),
388
+ videoUnplayed: refVideoPlayer.current.played.length === 0 && !prevState.videoQualityChanged
389
+ };
390
+ });
391
+ const {
392
+ videoQualityChanged,
393
+ videoIsPlaying
394
+ } = videoPlayerState; // Prevents an IE 11 bug where the video will not continue playing after a quality switch
395
+
396
+ if (videoQualityChanged && videoIsPlaying) {
397
+ setPlaying(true);
398
+ }
399
+ };
400
+
401
+ const clearInactivityTimer = () => {
402
+ setVideoPlayerState(prevState => ({ ...prevState,
403
+ mouseInactive: false
404
+ }));
405
+ clearTimeout(inactivityTimer);
406
+ };
407
+
408
+ const setAsBuffering = () => {
409
+ // Prevent IE infinite buffer bug with readyState
410
+ if (refVideoPlayer.current.readyState < 4) {
411
+ clearInactivityTimer();
412
+ setVideoPlayerState(prevState => ({ ...prevState,
413
+ videoIsPlaying: false,
414
+ videoIsBuffering: true,
415
+ mouseInactive: true
416
+ }));
417
+ setPlaying(false);
418
+ }
419
+ };
420
+
421
+ const playAfterBuffer = () => {
422
+ const {
423
+ videoIsBuffering,
424
+ videoCurrentTime,
425
+ videoQualityChanged
426
+ } = videoPlayerState;
427
+
428
+ if (videoIsBuffering && videoCurrentTime !== -1 && !videoQualityChanged) {
429
+ setPlaying(true);
430
+ setVideoPlayerState(prevState => ({ ...prevState,
431
+ videoIsBuffering: false
432
+ }));
433
+ }
434
+ };
435
+
436
+ const resetInactivityTimer = () => {
437
+ clearInactivityTimer();
438
+ const {
439
+ videoQualityChanged,
440
+ videoIsPlaying,
441
+ mouseOnControlBar
442
+ } = videoPlayerState;
443
+
444
+ if (!videoQualityChanged && videoIsPlaying) {
445
+ inactivityTimer = setTimeout(() => {
446
+ if (!mouseOnControlBar) {
447
+ setVideoPlayerState(prevState => ({ ...prevState,
448
+ mouseInactive: true
449
+ }));
450
+ }
451
+ }, playerOptions.mouseTimeout);
452
+ }
453
+ };
454
+
455
+ const setAsPlaying = () => {
456
+ setVideoPlayerState(prevState => ({ ...prevState,
457
+ videoIsPlaying: true,
458
+ videoIsBuffering: false,
459
+ videoEnded: false,
460
+ videoUnplayed: false,
461
+ videoQualityChanged: false
462
+ }));
463
+ const {
464
+ analyticsTracking
465
+ } = props;
466
+
467
+ if (analyticsTracking) {
468
+ updateAnalyticsData();
469
+ }
470
+
471
+ resetInactivityTimer();
472
+ };
473
+
474
+ const setAsPaused = () => {
475
+ clearInactivityTimer();
476
+ setVideoPlayerState(prevState => ({ ...prevState,
477
+ videoIsPlaying: false
478
+ }));
479
+ const {
480
+ analyticsTracking
481
+ } = props;
482
+
483
+ if (analyticsTracking) {
484
+ updateAnalyticsData();
485
+ }
486
+ };
487
+
488
+ const returnFromEndState = () => {
489
+ resetInactivityTimer();
490
+ setVideoPlayerState(prevState => ({ ...prevState,
491
+ videoEnded: false
492
+ }));
493
+ };
494
+
495
+ const setAsEnded = () => {
496
+ setVideoPlayerState(prevState => ({ ...prevState,
497
+ videoIsPlaying: false,
498
+ videoEnded: true
499
+ }));
500
+ clearInactivityTimer();
501
+ };
502
+
503
+ const updateBufferProgress = () => {
504
+ const {
505
+ videoCurrentTime,
506
+ videoQualityChanged
507
+ } = videoPlayerState;
508
+ const videoPlayer = refVideoPlayer.current;
509
+
510
+ if (videoPlayer && videoPlayer.readyState >= 2) {
511
+ const {
512
+ buffered
513
+ } = videoPlayer;
514
+ setVideoPlayerState(prevState => ({ ...prevState,
515
+ videoBufferEnd: buffered.length === 0 ? 0 : buffered.end(buffered.length - 1)
516
+ }));
517
+ } else if (videoCurrentTime !== -1 && !videoQualityChanged && !videoPlayer) {
518
+ setVideoPlayerState(prevState => ({ ...prevState,
519
+ videoIsPlaying: false,
520
+ videoIsBuffering: true
521
+ }));
522
+ }
523
+ };
524
+
525
+ const updateVolumeState = () => {
526
+ resetInactivityTimer();
527
+ const videoPlayer = refVideoPlayer.current;
528
+ setVideoPlayerState(prevState => ({ ...prevState,
529
+ videoCurrentVolume: videoPlayer.volume,
530
+ videoIsMuted: videoPlayer.muted
531
+ }));
532
+ };
533
+
534
+ const getPlayerWidth = () => {
535
+ setVideoPlayerState(prevState => ({ ...prevState,
536
+ videoPlayerWidth: refVideoPlayerContainer.current.offsetWidth
537
+ }));
538
+ };
539
+
540
+ const setMouseOnControlBar = isOver => {
541
+ setVideoPlayerState(prevState => ({ ...prevState,
542
+ mouseOnControlBar: isOver
543
+ }));
544
+ };
545
+
546
+ const togglePlayPause = () => {
547
+ const {
548
+ videoIsPlaying
549
+ } = videoPlayerState;
550
+ setPlaying(!videoIsPlaying);
551
+ };
552
+
553
+ const setTextTracks = trackNumber => {
554
+ const {
555
+ textTracks
556
+ } = refVideoPlayer.current;
557
+
558
+ for (let i = 0; i < textTracks.length; i += 1) {
559
+ textTracks[i].mode = i === trackNumber ? 'showing' : 'hidden';
560
+ }
561
+
562
+ setVideoPlayerState(prevState => ({ ...prevState,
563
+ selectedTextTrack: trackNumber
564
+ }));
565
+ };
566
+
567
+ const beginVideo = () => {
568
+ setTextTracks(-1);
569
+ setPlaying(true);
570
+ refVideoPlayerContainer.current.focus();
571
+ };
572
+
573
+ const closeSubMenus = () => {
574
+ setVideoPlayerState(prevState => ({ ...prevState,
575
+ qualityMenuOpen: false,
576
+ captionsMenuOpen: false
577
+ }));
578
+ };
579
+
580
+ const incrementSeek = seconds => {
581
+ refVideoPlayer.current.currentTime += seconds;
582
+ };
583
+
584
+ const replayVideo = async () => {
585
+ setSeek(0);
586
+ togglePlayPause();
587
+ };
588
+
589
+ const incrementVolume = amount => {
590
+ refVideoPlayer.current.volume += amount;
591
+ };
592
+
593
+ const setVolume = amount => {
594
+ refVideoPlayer.current.volume = amount;
595
+ };
596
+
597
+ const toggleMute = () => {
598
+ refVideoPlayer.current.muted = !refVideoPlayer.current.muted;
599
+ };
600
+
601
+ const setCaptionsMenuOpen = isOpen => {
602
+ setVideoPlayerState(prevState => ({ ...prevState,
603
+ captionsMenuOpen: isOpen
604
+ }));
605
+ };
606
+
607
+ const toggleFullscreen = () => {
608
+ if (_fscreen.default.fullscreenEnabled) {
609
+ if (_fscreen.default.fullscreenElement === null) {
610
+ _fscreen.default.requestFullscreen(refVideoPlayerContainer.current);
611
+ } else {
612
+ _fscreen.default.exitFullscreen();
613
+ }
614
+
615
+ setVideoPlayerState(prevState => {
616
+ return { ...prevState,
617
+ videoIsFullscreen: !prevState.videoIsFullscreen
618
+ };
619
+ });
620
+ }
621
+ };
622
+
623
+ const setVideoQuality = async newVideoQuality => {
624
+ await setPlaying(false);
625
+ setVideoPlayerState(prevState => ({ ...prevState,
626
+ videoLength: 0,
627
+ videoBufferEnd: 0,
628
+ videoQuality: newVideoQuality,
629
+ loadedSources: generateSources(newVideoQuality),
630
+ loadedTracks: tracks && generateTracks(),
631
+ videoQualityChanged: true
632
+ }));
633
+ await refVideoPlayer.current.load();
634
+ resetInactivityTimer();
635
+ setSeek(videoPlayerState.videoCurrentTime);
636
+ };
637
+
638
+ const setQualityMenuOpen = isOpen => {
639
+ setVideoPlayerState(prevState => ({ ...prevState,
640
+ qualityMenuOpen: isOpen
641
+ }));
642
+ };
643
+
644
+ const handleClick = event => {
645
+ resetInactivityTimer(); // This allows playing videos within components that act like
646
+ // links, e.g. `PreviewCard`, `StoryCard`, etc.
647
+
648
+ event === null || event === void 0 ? void 0 : event.preventDefault();
649
+ event === null || event === void 0 ? void 0 : event.stopPropagation();
650
+ };
651
+
652
+ const handleKeyboard = event => {
653
+ const {
654
+ videoLength,
655
+ videoCurrentVolume
656
+ } = videoPlayerState;
657
+ const key = event.key || event.keyCode; // *** Begin Seek & Play Control ****
658
+
659
+ if (key === ' ' || key === 32 || key === 'k' || key === 75) {
660
+ event.preventDefault();
661
+ resetInactivityTimer();
662
+ togglePlayPause();
663
+ } // Disables all keys except for play/pause when in simpleMode
664
+
665
+
666
+ if (!simpleMode) {
667
+ if (key === 'ArrowRight' || key === 39 || key === '.' || key === 190) {
668
+ resetInactivityTimer();
669
+ incrementSeek(playerOptions.keyboardSeekIncrement);
670
+ }
671
+
672
+ if (key === 'ArrowLeft' || key === 37 || key === ',' || key === 188) {
673
+ resetInactivityTimer();
674
+ incrementSeek(-playerOptions.keyboardSeekIncrement);
675
+ }
676
+
677
+ if (key === '0' || key === 48 || key === 'numpad 0' || key === 96) {
678
+ setSeek(0);
679
+ }
680
+
681
+ if (key === '1' || key === 49 || key === 'numpad 1' || key === 97) {
682
+ setSeek(videoLength * 0.1);
683
+ }
684
+
685
+ if (key === '2' || key === 50 || key === 'numpad 2' || key === 98) {
686
+ setSeek(videoLength * 0.2);
687
+ }
688
+
689
+ if (key === '3' || key === 51 || key === 'numpad 3' || key === 99) {
690
+ setSeek(videoLength * 0.3);
691
+ }
692
+
693
+ if (key === '4' || key === 52 || key === 'numpad 4' || key === 100) {
694
+ setSeek(videoLength * 0.4);
695
+ }
696
+
697
+ if (key === '5' || key === 53 || key === 'numpad 5' || key === 101) {
698
+ setSeek(videoLength * 0.5);
699
+ }
700
+
701
+ if (key === '6' || key === 54 || key === 'numpad 6' || key === 102) {
702
+ setSeek(videoLength * 0.6);
703
+ }
704
+
705
+ if (key === '7' || key === 55 || key === 'numpad 7' || key === 103) {
706
+ setSeek(videoLength * 0.7);
707
+ }
708
+
709
+ if (key === '8' || key === 56 || key === 'numpad 8' || key === 104) {
710
+ setSeek(videoLength * 0.8);
711
+ }
712
+
713
+ if (key === '9' || key === 57 || key === 'numpad 9' || key === 105) {
714
+ setSeek(videoLength * 0.9);
715
+ } // **** End Seek & Play Control ****
716
+ // **** Begin Volume Control ****
717
+
718
+
719
+ const {
720
+ keyboardVolumeIncrement
721
+ } = playerOptions;
722
+
723
+ if (key === 'ArrowUp' || key === 38 || key === '=' || key === 187 || key === 'add' || key === 107) {
724
+ resetInactivityTimer();
725
+
726
+ if (videoCurrentVolume + keyboardVolumeIncrement < 1) {
727
+ incrementVolume(keyboardVolumeIncrement);
728
+ } else {
729
+ setVolume(1);
730
+ }
731
+ }
732
+
733
+ if (key === 'ArrowDown' || key === 40 || key === '-' || key === 189 || key === 'subtract' || key === 109) {
734
+ resetInactivityTimer();
735
+
736
+ if (videoCurrentVolume - keyboardVolumeIncrement > 0) {
737
+ incrementVolume(-keyboardVolumeIncrement);
738
+ } else {
739
+ setVolume(0);
740
+ }
741
+ }
742
+
743
+ if (key === 'm' || key === 77) {
744
+ resetInactivityTimer();
745
+ toggleMute();
746
+ }
747
+
748
+ if (key === 'f' || key === 70) {
749
+ resetInactivityTimer();
750
+ toggleFullscreen();
751
+ }
752
+
753
+ if (key === 'Escape' || key === 27) {
754
+ // Resets focus back to container if user is focused on ControlBar button
755
+ refVideoPlayerContainer.current.focus();
756
+ closeSubMenus();
757
+ }
758
+
759
+ if (key === 'q' || key === 81) {
760
+ refKeyboardInstructions.current.focus();
761
+ }
762
+ }
763
+ }; // Prepares video and caption files
764
+
765
+
766
+ (0, _react.useEffect)(() => {
767
+ refreshMedia(); // eslint-disable-next-line react-hooks/exhaustive-deps
768
+ }, []); // Initial Setup after loading sources
769
+
770
+ (0, _react.useEffect)(() => {
771
+ const {
772
+ loadedSources,
773
+ loadedTracks
774
+ } = videoPlayerState;
775
+
776
+ if (loadedSources && loadedTracks) {
777
+ const {
778
+ beginMuted,
779
+ analyticsTracking,
780
+ videoTitle
781
+ } = props;
782
+ const videoPlayer = refVideoPlayer.current; // Initializes Settings
783
+
784
+ videoPlayer.volume = defaultVolume / 100;
785
+ videoPlayer.muted = beginMuted || simpleMode;
786
+ getPlayerWidth(); // Reports when the video has completed loading metadata (used for seeking after quality switch)
787
+
788
+ videoPlayer.onloadedmetadata = qualitySwitchSeek; // Reports the video's duration when the video player is ready to play
789
+
790
+ videoPlayer.oncanplay = initializeVideoDuration; // Reports the video's width on resize
791
+
792
+ window.addEventListener('resize', getPlayerWidth); // Reports the current video timestamp
793
+
794
+ videoPlayer.ontimeupdate = updateVideoTimestamp; // Reports when the video has paused due to buffering
795
+
796
+ videoPlayer.onwaiting = setAsBuffering; // Reports the video's latest buffering progress if video player is properly initialized
797
+
798
+ videoPlayer.onprogress = updateBufferProgress; // Reports when the video has recovered from buffering
799
+
800
+ videoPlayer.oncanplaythrough = playAfterBuffer; // Reports when the video has ended
801
+
802
+ videoPlayer.onended = setAsEnded; // Reports when the video is playing and disables the buffer spinner (even if buffering is still needed)
803
+
804
+ videoPlayer.onplay = setAsPlaying; // Reports when the video has been paused
805
+
806
+ videoPlayer.onpause = setAsPaused; // Reports when the video has been seeked
807
+
808
+ videoPlayer.onseeked = returnFromEndState; // Reports when the video's volume has been changed, or if the video has been muted
809
+
810
+ videoPlayer.onvolumechange = updateVolumeState; // Video Analytics
811
+
812
+ if (analyticsTracking !== undefined && videoTitle === undefined || analyticsTracking === undefined && videoTitle !== undefined) {
813
+ (0, _utils.warn)('Video', 'Both the `analyticsTracking` and `videoTitle` props must be defined in order to return a proper analytics object.');
814
+ }
815
+
816
+ return () => {
817
+ clearInactivityTimer();
818
+ window.removeEventListener('resize', getPlayerWidth);
819
+ clearInterval(videoPlayerState.intervalId);
820
+ };
821
+ }
822
+
823
+ return () => {}; // returning a noop for sake of consistency
824
+ // eslint-disable-next-line react-hooks/exhaustive-deps
825
+ }, [videoPlayerState.loadedSources, videoPlayerState.loadedTracks]);
826
+ const {
827
+ loadedSources,
828
+ loadedTracks,
829
+ isMobile,
830
+ mouseInactive,
831
+ selectedTextTrack,
832
+ qualityMenuOpen,
833
+ captionsMenuOpen,
834
+ videoUnplayed,
835
+ videoEnded,
836
+ videoIsBuffering,
837
+ videoIsPlaying,
838
+ videoIsFullscreen,
839
+ videoIsMuted,
840
+ videoQualityChanged,
841
+ videoLength,
842
+ videoBufferEnd,
843
+ videoCurrentTime,
844
+ videoCurrentVolume,
845
+ videoQuality,
846
+ videoPlayerWidth
847
+ } = videoPlayerState;
848
+ const {
849
+ style,
850
+ className,
851
+ as,
852
+ ...safeRest
853
+ } = rest;
854
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(VideoPlayerContainer, { ...safeRest,
855
+ ref: refVideoPlayerContainer,
856
+ videoBorder: videoBorder,
857
+ borderColor: borderColor,
858
+ onMouseMove: resetInactivityTimer,
859
+ onClick: handleClick,
860
+ onKeyDown: handleKeyboard,
861
+ tabIndex: "0",
862
+ "aria-label": simpleMode ? _videoText.default[copy].videoSelectedSimple : _videoText.default[copy].videoSelected,
863
+ "data-testid": "videoPlayer",
864
+ ...selectProps(rest),
865
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(VideoOverlayContainer, {
866
+ mouseInactive: mouseInactive,
867
+ onClick: () => {
868
+ closeSubMenus();
869
+ togglePlayPause();
870
+ },
871
+ children: [videoUnplayed && !videoQualityChanged && /*#__PURE__*/(0, _jsxRuntime.jsx)(VideoSplashContainer, {
872
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_VideoSplash.default, {
873
+ poster: posterSrc,
874
+ copy: copy,
875
+ videoLength: videoLength,
876
+ simpleMode: simpleMode,
877
+ iconLeftOffsetPx: 2,
878
+ onClick: beginVideo
879
+ })
880
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(VideoOverlayElementContainer, {
881
+ children: [videoEnded && /*#__PURE__*/(0, _jsxRuntime.jsx)(_MiddleControlButton.default, {
882
+ icon: replayIcon,
883
+ onClick: replayVideo
884
+ }), !videoUnplayed && !videoIsBuffering && !videoEnded && !isMobile && /*#__PURE__*/(0, _jsxRuntime.jsx)(_MiddleControlButton.default, {
885
+ icon: videoIsPlaying ? pauseIcon : playIcon,
886
+ isHidden: mouseInactive,
887
+ onClick: togglePlayPause,
888
+ onFocus: resetInactivityTimer
889
+ }), videoIsBuffering && !isMobile && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Spinner.default, {
890
+ show: true
891
+ })]
892
+ })]
893
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(VideoElementContainer, {
894
+ videoIsFullscreen: videoIsFullscreen,
895
+ mouseInactive: mouseInactive,
896
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(VideoPlayer, {
897
+ ref: refVideoPlayer,
898
+ controls: isMobile,
899
+ videoIsFullscreen: videoIsFullscreen,
900
+ crossOrigin: crossOrigin,
901
+ playsinline: true,
902
+ children: [loadedSources, loadedTracks, "Your browser does not support the video tag."]
903
+ })
904
+ }), !simpleMode && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ControlBar.default, {
905
+ videoPlayer: refVideoPlayer,
906
+ videoPlayerContainer: refVideoPlayerContainer,
907
+ sources: sources,
908
+ tracks: tracks,
909
+ videoLength: videoLength,
910
+ videoBufferEnd: videoBufferEnd,
911
+ videoCurrentTime: videoCurrentTime,
912
+ videoPlaying: refVideoPlayer.current !== null ? !refVideoPlayer.current.paused : false,
913
+ videoUnplayed: videoUnplayed,
914
+ videoCurrentVolume: videoCurrentVolume,
915
+ videoIsMuted: videoIsMuted,
916
+ setVolume: setVolume,
917
+ isHidden: (mouseInactive || videoUnplayed) && !videoEnded,
918
+ isMobile: isMobile,
919
+ tracksAvailable: tracks !== undefined,
920
+ togglePlayPause: togglePlayPause,
921
+ setSeek: setSeek,
922
+ toggleMute: toggleMute,
923
+ toggleFullscreen: toggleFullscreen,
924
+ videoIsFullscreen: videoIsFullscreen,
925
+ setTextTracks: setTextTracks,
926
+ selectedTextTrack: selectedTextTrack,
927
+ resetInactivityTimer: resetInactivityTimer,
928
+ videoQuality: videoQuality,
929
+ setVideoQuality: setVideoQuality,
930
+ qualityMenuOpen: qualityMenuOpen,
931
+ setQualityMenuOpen: setQualityMenuOpen,
932
+ captionsMenuOpen: captionsMenuOpen,
933
+ setCaptionsMenuOpen: setCaptionsMenuOpen,
934
+ clearInactivityTimer: clearInactivityTimer,
935
+ copy: copy,
936
+ compactModeThreshold: playerOptions.compactModeThreshold,
937
+ videoPlayerWidth: videoPlayerWidth,
938
+ onMouseOver: () => setMouseOnControlBar(true),
939
+ onMouseOut: () => setMouseOnControlBar(false),
940
+ onFocus: () => {},
941
+ onBlur: () => {}
942
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
943
+ tabIndex: "-1",
944
+ ref: refKeyboardInstructions,
945
+ "aria-label": _videoText.default[copy].videoPlayer,
946
+ role: "note"
947
+ })]
948
+ });
949
+ };
950
+
951
+ Video.propTypes = { ...selectedSystemPropTypes,
952
+
953
+ /**
954
+ * An array of objects that defines each video file. See the "Basic Usage" section for more information.
955
+ */
956
+ sources: _propTypes.default.arrayOf(_propTypes.default.shape({
957
+ /** A path to a video file */
958
+ source: _propTypes.default.string.isRequired,
959
+
960
+ /** The video's MIME type (example: `video/mp4`) */
961
+ mediaType: _propTypes.default.string.isRequired,
962
+
963
+ /** The label to be given to this file in the quality selector (example: `1080p`) */
964
+ qualityName: _propTypes.default.string.isRequired,
965
+
966
+ /** A number indicating the video's quality, with 1 being the best, and the number increasing from there as quality degrades */
967
+ qualityRank: _propTypes.default.number.isRequired,
968
+
969
+ /** A boolean that defines its source as a fallback for another source with the same `qualityRank` */
970
+ isFallback: _propTypes.default.bool
971
+ })).isRequired,
972
+
973
+ /**
974
+ * A path of the image that will be displayed on the video's splash screen.
975
+ */
976
+ posterSrc: _propTypes.default.string.isRequired,
977
+
978
+ /**
979
+ * An array of objects that defines each caption file. See the "Basic Usage" section for more information.
980
+ */
981
+ tracks: _propTypes.default.arrayOf(_propTypes.default.shape({
982
+ /** A path to the track file */
983
+ source: _propTypes.default.string.isRequired,
984
+
985
+ /** The name of the track file as it will appear in the "Captions" dialogue */
986
+ label: _propTypes.default.string.isRequired,
987
+
988
+ /** The track's file type, typically one of "subtitles", "captions", or "descriptions". See [MDN's documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track#Attributes) for more information on these types */
989
+ kind: _propTypes.default.string.isRequired,
990
+
991
+ /** The language of the track file represented as a ISO 639-1 language code */
992
+ language: _propTypes.default.string.isRequired
993
+ })),
994
+
995
+ /**
996
+ * The video's default volume, defined from 1 to 100. Please use the `beginMuted` prop to have the video start silenced.
997
+ */
998
+ defaultVolume: _propTypes.default.number,
999
+
1000
+ /**
1001
+ * Defines if the video should start muted.
1002
+ */
1003
+ beginMuted: _propTypes.default.bool,
1004
+
1005
+ /**
1006
+ * The default quality level if the user is on mobile. See the `sources` prop for available quality levels.
1007
+ */
1008
+ defaultMobileQuality: _propTypes.default.number,
1009
+
1010
+ /**
1011
+ * The default quality level if the user is on desktop. See the `sources` prop for available quality levels.
1012
+ */
1013
+ defaultDesktopQuality: _propTypes.default.number,
1014
+
1015
+ /**
1016
+ * The video player UI's language as an ISO language code. It currently supports English and French.
1017
+ */
1018
+ copy: _propTypes.default.oneOf(['en', 'fr']).isRequired,
1019
+
1020
+ /**
1021
+ * Sets the `video` tag's `crossorigin` mode. Please note that content loaded without CORS approval may be insecure.
1022
+ * @since 1.1.0
1023
+ */
1024
+ crossOrigin: _propTypes.default.oneOf(['anonymous', 'use-credentials']),
1025
+
1026
+ /**
1027
+ * Disables the control bar during playback and reduces the amount of time until the UI hides itself.
1028
+ * For special approved internal uses only.
1029
+ * @since 1.2.0
1030
+ */
1031
+ simpleMode: _propTypes.default.bool,
1032
+
1033
+ /**
1034
+ * Renders a gainsboro coloured border around the video. Used to seperate the video from the rest of the page if the video's background is the same colour as the container's.
1035
+ * @since 1.2.0
1036
+ */
1037
+ videoBorder: _propTypes.default.bool,
1038
+
1039
+ /**
1040
+ * A callback function that fires when a customer interacts with Video.
1041
+ * When using `analyticsTracking`, `videoTitle` must also be defined.
1042
+ *
1043
+ * When invoked, your callback function returns an object containing three keys (see below).
1044
+ * @since 1.3.0
1045
+ *
1046
+ * @param {Object} analyticsObject Contains video data based on customer interactions
1047
+ * @param {string} analyticsObject.name Always 'video tracking'
1048
+ * @param {string} analyticsObject.action Contains the latest customer action
1049
+ * @param {string} analyticsObject.details The name of the video based on the `videoTitle` prop
1050
+ */
1051
+ analyticsTracking: _propTypes.default.func,
1052
+
1053
+ /**
1054
+ * The title of the video being rendered. This is used for analytics purposes in conjunction with `analyticsTracking`.
1055
+ * @since 1.3.0
1056
+ */
1057
+ videoTitle: _propTypes.default.string
1058
+ };
1059
+ Video.defaultProps = {
1060
+ tracks: undefined,
1061
+ defaultVolume: 100,
1062
+ beginMuted: false,
1063
+ defaultMobileQuality: 1,
1064
+ defaultDesktopQuality: 1,
1065
+ crossOrigin: undefined,
1066
+ simpleMode: false,
1067
+ videoBorder: false,
1068
+ analyticsTracking: undefined,
1069
+ videoTitle: undefined
1070
+ };
1071
+ var _default = Video;
1072
+ exports.default = _default;