rx-player 4.0.0 → 4.1.0-dev.2024031100

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 (2222) hide show
  1. package/.prettierrc +4 -0
  2. package/CHANGELOG.md +1500 -996
  3. package/MAINTAINERS.md +9 -12
  4. package/README.md +107 -122
  5. package/VERSION +1 -1
  6. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  7. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  8. package/dist/commonjs/__GENERATED_CODE/embedded_worker_es5.d.ts +3 -0
  9. package/dist/commonjs/__GENERATED_CODE/embedded_worker_es5.js +6 -0
  10. package/dist/commonjs/__GENERATED_CODE/index.d.ts +1 -0
  11. package/dist/commonjs/__GENERATED_CODE/index.js +3 -1
  12. package/dist/commonjs/compat/add_class_name.js +4 -3
  13. package/dist/commonjs/compat/add_text_track.d.ts +1 -1
  14. package/dist/commonjs/compat/add_text_track.js +3 -2
  15. package/dist/commonjs/compat/browser_compatibility_types.js +13 -7
  16. package/dist/commonjs/compat/browser_detection.d.ts +3 -1
  17. package/dist/commonjs/compat/browser_detection.js +16 -12
  18. package/dist/commonjs/compat/can_seek_directly_after_loaded_metadata.d.ts +7 -0
  19. package/dist/commonjs/compat/can_seek_directly_after_loaded_metadata.js +10 -0
  20. package/dist/commonjs/compat/change_source_buffer_type.d.ts +1 -1
  21. package/dist/commonjs/compat/eme/close_session.d.ts +1 -1
  22. package/dist/commonjs/compat/eme/close_session.js +16 -12
  23. package/dist/commonjs/compat/eme/custom_key_system_access.d.ts +1 -1
  24. package/dist/commonjs/compat/eme/custom_media_keys/ie11_media_keys.d.ts +1 -1
  25. package/dist/commonjs/compat/eme/custom_media_keys/ie11_media_keys.js +14 -9
  26. package/dist/commonjs/compat/eme/custom_media_keys/moz_media_keys_constructor.d.ts +1 -1
  27. package/dist/commonjs/compat/eme/custom_media_keys/old_webkit_media_keys.d.ts +1 -1
  28. package/dist/commonjs/compat/eme/custom_media_keys/old_webkit_media_keys.js +13 -11
  29. package/dist/commonjs/compat/eme/custom_media_keys/types.d.ts +1 -1
  30. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.d.ts +1 -1
  31. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.js +5 -11
  32. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys_constructor.d.ts +1 -1
  33. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys_constructor.js +2 -2
  34. package/dist/commonjs/compat/eme/eme-api-implementation.d.ts +3 -3
  35. package/dist/commonjs/compat/eme/eme-api-implementation.js +13 -9
  36. package/dist/commonjs/compat/eme/generate_key_request.d.ts +1 -1
  37. package/dist/commonjs/compat/eme/generate_key_request.js +16 -19
  38. package/dist/commonjs/compat/eme/get_init_data.js +5 -7
  39. package/dist/commonjs/compat/eme/get_uuid_kid_from_keystatus_kid.js +1 -2
  40. package/dist/commonjs/compat/eme/get_webkit_fairplay_initdata.js +10 -11
  41. package/dist/commonjs/compat/eme/load_session.d.ts +1 -1
  42. package/dist/commonjs/compat/eme/set_media_keys.d.ts +9 -0
  43. package/dist/commonjs/compat/eme/set_media_keys.js +37 -0
  44. package/dist/commonjs/compat/enable_audio_track.d.ts +1 -1
  45. package/dist/commonjs/compat/event_listeners.d.ts +4 -4
  46. package/dist/commonjs/compat/event_listeners.js +42 -33
  47. package/dist/commonjs/compat/has_webassembly.js +1 -2
  48. package/dist/commonjs/compat/has_worker_api.d.ts +9 -0
  49. package/dist/commonjs/compat/has_worker_api.js +17 -0
  50. package/dist/commonjs/compat/is_codec_supported.js +2 -1
  51. package/dist/commonjs/compat/is_vtt_cue.d.ts +1 -1
  52. package/dist/commonjs/compat/make_vtt_cue.d.ts +1 -1
  53. package/dist/commonjs/compat/may_media_element_fail_on_undecipherable_data.d.ts +16 -0
  54. package/dist/commonjs/compat/may_media_element_fail_on_undecipherable_data.js +19 -0
  55. package/dist/commonjs/compat/on_height_width_change.d.ts +2 -2
  56. package/dist/commonjs/compat/patch_webkit_source_buffer.js +29 -29
  57. package/dist/commonjs/compat/should_await_set_media_keys.d.ts +16 -0
  58. package/dist/commonjs/compat/should_await_set_media_keys.js +22 -0
  59. package/dist/commonjs/compat/should_reload_media_source_on_decipherability_update.js +1 -2
  60. package/dist/commonjs/config.d.ts +1 -1
  61. package/dist/commonjs/core/adaptive/adaptive_representation_selector.d.ts +25 -22
  62. package/dist/commonjs/core/adaptive/adaptive_representation_selector.js +47 -25
  63. package/dist/commonjs/core/adaptive/buffer_based_chooser.d.ts +1 -1
  64. package/dist/commonjs/core/adaptive/buffer_based_chooser.js +13 -11
  65. package/dist/commonjs/core/adaptive/guess_based_chooser.d.ts +6 -6
  66. package/dist/commonjs/core/adaptive/guess_based_chooser.js +7 -6
  67. package/dist/commonjs/core/adaptive/index.d.ts +2 -2
  68. package/dist/commonjs/core/adaptive/network_analyzer.d.ts +6 -6
  69. package/dist/commonjs/core/adaptive/network_analyzer.js +44 -40
  70. package/dist/commonjs/core/adaptive/utils/bandwidth_estimator.js +1 -1
  71. package/dist/commonjs/core/adaptive/utils/ewma.js +1 -2
  72. package/dist/commonjs/core/adaptive/utils/filter_by_bitrate.d.ts +2 -2
  73. package/dist/commonjs/core/adaptive/utils/filter_by_resolution.d.ts +2 -2
  74. package/dist/commonjs/core/adaptive/utils/filter_by_resolution.js +2 -4
  75. package/dist/commonjs/core/adaptive/utils/get_buffer_levels.js +7 -4
  76. package/dist/commonjs/core/adaptive/utils/last_estimate_storage.d.ts +3 -3
  77. package/dist/commonjs/core/adaptive/utils/pending_requests_store.d.ts +5 -5
  78. package/dist/commonjs/core/adaptive/utils/pending_requests_store.js +4 -3
  79. package/dist/commonjs/core/adaptive/utils/representation_score_calculator.d.ts +7 -7
  80. package/dist/commonjs/core/adaptive/utils/representation_score_calculator.js +11 -8
  81. package/dist/commonjs/core/adaptive/utils/select_optimal_representation.d.ts +4 -4
  82. package/dist/commonjs/core/adaptive/utils/select_optimal_representation.js +2 -2
  83. package/dist/commonjs/core/fetchers/cdn_prioritizer.d.ts +2 -2
  84. package/dist/commonjs/core/fetchers/cdn_prioritizer.js +5 -6
  85. package/dist/commonjs/core/fetchers/manifest/index.d.ts +1 -1
  86. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +3 -3
  87. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +80 -65
  88. package/dist/commonjs/core/fetchers/segment/index.d.ts +1 -1
  89. package/dist/commonjs/core/fetchers/segment/initialization_segment_cache.d.ts +4 -4
  90. package/dist/commonjs/core/fetchers/segment/prioritized_segment_fetcher.d.ts +4 -3
  91. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +12 -12
  92. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +49 -32
  93. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +5 -5
  94. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.js +4 -2
  95. package/dist/commonjs/core/fetchers/segment/task_prioritizer.d.ts +1 -1
  96. package/dist/commonjs/core/fetchers/segment/task_prioritizer.js +18 -17
  97. package/dist/commonjs/core/fetchers/utils/error_selector.d.ts +1 -2
  98. package/dist/commonjs/core/fetchers/utils/error_selector.js +0 -1
  99. package/dist/commonjs/core/fetchers/utils/schedule_request.d.ts +3 -3
  100. package/dist/commonjs/core/fetchers/utils/schedule_request.js +20 -21
  101. package/dist/commonjs/core/main/common/DecipherabilityFreezeDetector.d.ts +79 -0
  102. package/dist/commonjs/core/main/common/DecipherabilityFreezeDetector.js +127 -0
  103. package/dist/commonjs/core/main/common/content_time_boundaries_observer.d.ts +191 -0
  104. package/dist/commonjs/core/main/common/content_time_boundaries_observer.js +519 -0
  105. package/dist/commonjs/core/main/common/create_content_time_boundaries_observer.d.ts +27 -0
  106. package/dist/commonjs/core/main/common/create_content_time_boundaries_observer.js +48 -0
  107. package/dist/commonjs/core/main/common/get_buffered_data_per_media_buffer.d.ts +14 -0
  108. package/dist/commonjs/core/main/common/get_buffered_data_per_media_buffer.js +37 -0
  109. package/dist/commonjs/core/main/worker/content_preparer.d.ts +93 -0
  110. package/dist/commonjs/core/main/worker/content_preparer.js +273 -0
  111. package/dist/commonjs/core/main/worker/globals.d.ts +13 -0
  112. package/dist/commonjs/core/main/worker/globals.js +26 -0
  113. package/dist/commonjs/core/main/worker/index.d.ts +2 -0
  114. package/dist/commonjs/core/main/worker/index.js +4 -0
  115. package/dist/commonjs/core/main/worker/send_message.d.ts +3 -0
  116. package/dist/commonjs/core/main/worker/send_message.js +25 -0
  117. package/dist/commonjs/core/main/worker/track_choice_setter.d.ts +19 -0
  118. package/dist/commonjs/core/main/worker/track_choice_setter.js +140 -0
  119. package/dist/commonjs/core/main/worker/worker_main.d.ts +1 -0
  120. package/dist/commonjs/core/main/worker/worker_main.js +784 -0
  121. package/dist/commonjs/core/main/worker/worker_text_displayer_interface.d.ts +64 -0
  122. package/dist/commonjs/core/main/worker/worker_text_displayer_interface.js +126 -0
  123. package/dist/commonjs/core/segment_sinks/garbage_collector.d.ts +43 -0
  124. package/dist/commonjs/core/segment_sinks/garbage_collector.js +226 -0
  125. package/dist/commonjs/core/segment_sinks/implementations/audio_video/audio_video_segment_buffer.d.ts +135 -0
  126. package/dist/commonjs/core/segment_sinks/implementations/audio_video/audio_video_segment_buffer.js +358 -0
  127. package/dist/commonjs/core/segment_sinks/implementations/audio_video/index.d.ts +17 -0
  128. package/dist/commonjs/core/segment_sinks/implementations/index.d.ts +19 -0
  129. package/dist/commonjs/core/segment_sinks/implementations/index.js +35 -0
  130. package/dist/commonjs/core/segment_sinks/implementations/text/index.d.ts +3 -0
  131. package/dist/commonjs/core/segment_sinks/implementations/text/text_segment_buffer.d.ts +90 -0
  132. package/dist/commonjs/core/segment_sinks/implementations/text/text_segment_buffer.js +257 -0
  133. package/dist/commonjs/core/segment_sinks/implementations/types.d.ts +307 -0
  134. package/dist/commonjs/core/segment_sinks/implementations/types.js +117 -0
  135. package/dist/commonjs/core/segment_sinks/index.d.ts +21 -0
  136. package/dist/commonjs/core/segment_sinks/index.js +28 -0
  137. package/dist/commonjs/core/segment_sinks/inventory/buffered_history.d.ts +89 -0
  138. package/dist/commonjs/core/segment_sinks/inventory/index.d.ts +21 -0
  139. package/dist/commonjs/core/segment_sinks/inventory/segment_inventory.d.ts +238 -0
  140. package/dist/commonjs/core/segment_sinks/inventory/segment_inventory.js +917 -0
  141. package/dist/commonjs/core/segment_sinks/inventory/types.d.ts +27 -0
  142. package/dist/commonjs/core/segment_sinks/inventory/utils.d.ts +33 -0
  143. package/dist/commonjs/core/segment_sinks/inventory/utils.js +53 -0
  144. package/dist/commonjs/core/segment_sinks/segment_buffers_store.d.ts +171 -0
  145. package/dist/commonjs/core/segment_sinks/segment_buffers_store.js +288 -0
  146. package/dist/commonjs/core/stream/adaptation/adaptation_stream.d.ts +4 -4
  147. package/dist/commonjs/core/stream/adaptation/adaptation_stream.js +52 -24
  148. package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.d.ts +11 -11
  149. package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.js +32 -33
  150. package/dist/commonjs/core/stream/adaptation/types.d.ts +18 -18
  151. package/dist/commonjs/core/stream/index.d.ts +1 -1
  152. package/dist/commonjs/core/stream/orchestrator/get_time_ranges_for_content.d.ts +5 -5
  153. package/dist/commonjs/core/stream/orchestrator/get_time_ranges_for_content.js +5 -5
  154. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.d.ts +20 -19
  155. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +76 -52
  156. package/dist/commonjs/core/stream/period/period_stream.d.ts +5 -5
  157. package/dist/commonjs/core/stream/period/period_stream.js +85 -47
  158. package/dist/commonjs/core/stream/period/types.d.ts +23 -21
  159. package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +13 -13
  160. package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.js +34 -38
  161. package/dist/commonjs/core/stream/representation/representation_stream.d.ts +5 -5
  162. package/dist/commonjs/core/stream/representation/representation_stream.js +58 -32
  163. package/dist/commonjs/core/stream/representation/types.d.ts +24 -24
  164. package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.d.ts +9 -9
  165. package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.js +12 -13
  166. package/dist/commonjs/core/stream/representation/utils/check_for_discontinuity.d.ts +7 -7
  167. package/dist/commonjs/core/stream/representation/utils/check_for_discontinuity.js +16 -18
  168. package/dist/commonjs/core/stream/representation/utils/downloading_queue.d.ts +10 -10
  169. package/dist/commonjs/core/stream/representation/utils/downloading_queue.js +11 -11
  170. package/dist/commonjs/core/stream/representation/utils/get_buffer_status.d.ts +11 -11
  171. package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +50 -29
  172. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.d.ts +6 -7
  173. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +29 -30
  174. package/dist/commonjs/core/stream/representation/utils/push_init_segment.d.ts +13 -13
  175. package/dist/commonjs/core/stream/representation/utils/push_init_segment.js +10 -8
  176. package/dist/commonjs/core/stream/representation/utils/push_media_segment.d.ts +14 -14
  177. package/dist/commonjs/core/stream/representation/utils/push_media_segment.js +16 -13
  178. package/dist/commonjs/core/types.d.ts +8 -0
  179. package/dist/commonjs/default_config.js +21 -18
  180. package/dist/commonjs/errors/encrypted_media_error.d.ts +2 -2
  181. package/dist/commonjs/errors/encrypted_media_error.js +4 -2
  182. package/dist/commonjs/errors/error_codes.d.ts +3 -3
  183. package/dist/commonjs/errors/error_codes.js +1 -0
  184. package/dist/commonjs/errors/format_error.d.ts +2 -2
  185. package/dist/commonjs/errors/format_error.js +1 -2
  186. package/dist/commonjs/errors/is_known_error.d.ts +1 -1
  187. package/dist/commonjs/errors/is_known_error.js +2 -2
  188. package/dist/commonjs/errors/media_error.d.ts +2 -2
  189. package/dist/commonjs/errors/media_error.js +4 -2
  190. package/dist/commonjs/errors/network_error.d.ts +2 -2
  191. package/dist/commonjs/errors/network_error.js +6 -4
  192. package/dist/commonjs/errors/other_error.d.ts +1 -1
  193. package/dist/commonjs/errors/other_error.js +1 -3
  194. package/dist/commonjs/errors/source_buffer_error.js +4 -2
  195. package/dist/commonjs/experimental/features/local.d.ts +1 -1
  196. package/dist/commonjs/experimental/features/local.js +1 -2
  197. package/dist/commonjs/experimental/features/metaplaylist.d.ts +1 -1
  198. package/dist/commonjs/experimental/features/metaplaylist.js +1 -2
  199. package/dist/commonjs/experimental/features/multi_thread.d.ts +1 -1
  200. package/dist/commonjs/experimental/features/multi_thread.js +1 -2
  201. package/dist/commonjs/experimental/index.d.ts +1 -1
  202. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/features/dash.d.ts +1 -1
  203. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/features/metaplaylist.d.ts +1 -1
  204. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/index.d.ts +1 -1
  205. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/load_and_push_segment.d.ts +3 -3
  206. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts +2 -2
  207. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +5 -5
  208. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.d.ts +1 -1
  209. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.js +2 -2
  210. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/types.d.ts +6 -6
  211. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.d.ts +3 -3
  212. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +11 -18
  213. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +13 -23
  214. package/dist/commonjs/experimental/tools/createMetaplaylist/index.d.ts +1 -1
  215. package/dist/commonjs/experimental/tools/createMetaplaylist/index.js +8 -7
  216. package/dist/commonjs/experimental/tools/index.d.ts +1 -1
  217. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/api/index.d.ts +1 -1
  218. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/api/index.js +9 -15
  219. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +4 -3
  220. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +6 -3
  221. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/capabilities.d.ts +1 -1
  222. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/capabilities.js +9 -46
  223. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.d.ts +2 -1
  224. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +8 -5
  225. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.d.ts +2 -1
  226. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +21 -13
  227. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.d.ts +2 -1
  228. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.js +21 -17
  229. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +12 -12
  230. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/index.d.ts +1 -1
  231. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts +2 -1
  232. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +7 -8
  233. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/format.d.ts +1 -1
  234. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/format.js +6 -11
  235. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.d.ts +2 -1
  236. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.js +1 -2
  237. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.d.ts +2 -1
  238. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +3 -3
  239. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/types.d.ts +2 -2
  240. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/utils.d.ts +1 -1
  241. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/utils.js +8 -7
  242. package/dist/commonjs/features/add_features.d.ts +1 -1
  243. package/dist/commonjs/features/features_object.d.ts +1 -1
  244. package/dist/commonjs/features/features_object.js +4 -3
  245. package/dist/commonjs/features/index.d.ts +1 -1
  246. package/dist/commonjs/features/list/dash.d.ts +1 -1
  247. package/dist/commonjs/features/list/dash.js +3 -4
  248. package/dist/commonjs/features/list/dash_wasm.d.ts +2 -2
  249. package/dist/commonjs/features/list/dash_wasm.js +1 -2
  250. package/dist/commonjs/features/list/debug_element.d.ts +1 -1
  251. package/dist/commonjs/features/list/debug_element.js +1 -1
  252. package/dist/commonjs/features/list/directfile.d.ts +1 -1
  253. package/dist/commonjs/features/list/directfile.js +2 -3
  254. package/dist/commonjs/features/list/eme.d.ts +1 -1
  255. package/dist/commonjs/features/list/eme.js +1 -1
  256. package/dist/commonjs/features/list/html_sami_parser.d.ts +1 -1
  257. package/dist/commonjs/features/list/html_sami_parser.js +4 -4
  258. package/dist/commonjs/features/list/html_srt_parser.d.ts +1 -1
  259. package/dist/commonjs/features/list/html_srt_parser.js +4 -4
  260. package/dist/commonjs/features/list/html_text_buffer.d.ts +1 -1
  261. package/dist/commonjs/features/list/html_text_buffer.js +1 -1
  262. package/dist/commonjs/features/list/html_ttml_parser.d.ts +1 -1
  263. package/dist/commonjs/features/list/html_ttml_parser.js +4 -4
  264. package/dist/commonjs/features/list/html_vtt_parser.d.ts +1 -1
  265. package/dist/commonjs/features/list/html_vtt_parser.js +4 -4
  266. package/dist/commonjs/features/list/media_source_main.d.ts +1 -1
  267. package/dist/commonjs/features/list/media_source_main.js +1 -2
  268. package/dist/commonjs/features/list/native_sami_parser.d.ts +1 -1
  269. package/dist/commonjs/features/list/native_sami_parser.js +4 -4
  270. package/dist/commonjs/features/list/native_srt_parser.d.ts +1 -1
  271. package/dist/commonjs/features/list/native_srt_parser.js +4 -4
  272. package/dist/commonjs/features/list/native_text_buffer.d.ts +1 -1
  273. package/dist/commonjs/features/list/native_text_buffer.js +1 -1
  274. package/dist/commonjs/features/list/native_ttml_parser.d.ts +1 -1
  275. package/dist/commonjs/features/list/native_ttml_parser.js +4 -4
  276. package/dist/commonjs/features/list/native_vtt_parser.d.ts +1 -1
  277. package/dist/commonjs/features/list/native_vtt_parser.js +4 -4
  278. package/dist/commonjs/features/list/smooth.d.ts +1 -1
  279. package/dist/commonjs/features/list/smooth.js +1 -2
  280. package/dist/commonjs/features/types.d.ts +28 -23
  281. package/dist/commonjs/index.d.ts +1 -1
  282. package/dist/commonjs/index.js +3 -1
  283. package/dist/commonjs/main_thread/api/debug/buffer_graph.d.ts +28 -0
  284. package/dist/commonjs/main_thread/api/debug/buffer_graph.js +168 -0
  285. package/dist/commonjs/main_thread/api/debug/buffer_size_graph.js +131 -0
  286. package/dist/commonjs/main_thread/api/debug/modules/general_info.d.ts +3 -0
  287. package/dist/commonjs/main_thread/api/debug/modules/general_info.js +236 -0
  288. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.d.ts +4 -0
  289. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +127 -0
  290. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_size.d.ts +3 -0
  291. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_size.js +38 -0
  292. package/dist/commonjs/main_thread/api/debug/render.d.ts +3 -0
  293. package/dist/commonjs/main_thread/api/index.d.ts +17 -0
  294. package/dist/commonjs/main_thread/api/index.js +19 -0
  295. package/dist/commonjs/main_thread/api/option_utils.d.ts +124 -0
  296. package/dist/commonjs/main_thread/api/option_utils.js +335 -0
  297. package/dist/commonjs/main_thread/api/public_api.d.ts +768 -0
  298. package/dist/commonjs/main_thread/api/public_api.js +2557 -0
  299. package/dist/commonjs/main_thread/api/utils.d.ts +66 -0
  300. package/dist/commonjs/main_thread/api/utils.js +178 -0
  301. package/dist/commonjs/main_thread/decrypt/__tests__/__global__/utils.d.ts +184 -0
  302. package/dist/commonjs/main_thread/decrypt/__tests__/__global__/utils.js +439 -0
  303. package/dist/commonjs/main_thread/decrypt/attach_media_keys.d.ts +53 -0
  304. package/dist/commonjs/main_thread/decrypt/attach_media_keys.js +124 -0
  305. package/dist/commonjs/main_thread/decrypt/clear_on_stop.js +43 -0
  306. package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts +185 -0
  307. package/dist/commonjs/main_thread/decrypt/content_decryptor.js +1053 -0
  308. package/dist/commonjs/main_thread/decrypt/create_or_load_session.d.ts +64 -0
  309. package/dist/commonjs/main_thread/decrypt/create_or_load_session.js +135 -0
  310. package/dist/commonjs/main_thread/decrypt/create_session.d.ts +54 -0
  311. package/dist/commonjs/main_thread/decrypt/create_session.js +215 -0
  312. package/dist/commonjs/main_thread/decrypt/dispose_decryption_resources.js +83 -0
  313. package/dist/commonjs/main_thread/decrypt/find_key_system.d.ts +48 -0
  314. package/dist/commonjs/main_thread/decrypt/find_key_system.js +375 -0
  315. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts +44 -0
  316. package/dist/commonjs/main_thread/decrypt/get_media_keys.js +165 -0
  317. package/dist/commonjs/main_thread/decrypt/index.d.ts +26 -0
  318. package/dist/commonjs/main_thread/decrypt/init_media_keys.d.ts +26 -0
  319. package/dist/commonjs/main_thread/decrypt/init_media_keys.js +87 -0
  320. package/dist/commonjs/main_thread/decrypt/session_events_listener.d.ts +75 -0
  321. package/dist/commonjs/main_thread/decrypt/session_events_listener.js +325 -0
  322. package/dist/commonjs/main_thread/decrypt/set_server_certificate.d.ts +51 -0
  323. package/dist/commonjs/main_thread/decrypt/set_server_certificate.js +145 -0
  324. package/dist/commonjs/main_thread/decrypt/types.d.ts +374 -0
  325. package/dist/commonjs/main_thread/decrypt/utils/are_init_values_compatible.js +144 -0
  326. package/dist/commonjs/main_thread/decrypt/utils/check_key_statuses.d.ts +52 -0
  327. package/dist/commonjs/main_thread/decrypt/utils/check_key_statuses.js +211 -0
  328. package/dist/commonjs/main_thread/decrypt/utils/clean_old_loaded_sessions.d.ts +26 -0
  329. package/dist/commonjs/main_thread/decrypt/utils/clean_old_stored_persistent_info.d.ts +32 -0
  330. package/dist/commonjs/main_thread/decrypt/utils/init_data_values_container.d.ts +69 -0
  331. package/dist/commonjs/main_thread/decrypt/utils/init_data_values_container.js +137 -0
  332. package/dist/commonjs/main_thread/decrypt/utils/is_session_usable.d.ts +24 -0
  333. package/dist/commonjs/main_thread/decrypt/utils/is_session_usable.js +51 -0
  334. package/dist/commonjs/main_thread/decrypt/utils/key_session_record.d.ts +104 -0
  335. package/dist/commonjs/main_thread/decrypt/utils/key_session_record.js +189 -0
  336. package/dist/commonjs/main_thread/decrypt/utils/loaded_sessions_store.d.ts +213 -0
  337. package/dist/commonjs/main_thread/decrypt/utils/loaded_sessions_store.js +518 -0
  338. package/dist/commonjs/main_thread/decrypt/utils/media_keys_infos_store.d.ts +56 -0
  339. package/dist/commonjs/main_thread/decrypt/utils/media_keys_infos_store.js +45 -0
  340. package/dist/commonjs/main_thread/decrypt/utils/persistent_sessions_store.d.ts +94 -0
  341. package/dist/commonjs/main_thread/decrypt/utils/persistent_sessions_store.js +356 -0
  342. package/dist/commonjs/main_thread/decrypt/utils/serializable_bytes.d.ts +44 -0
  343. package/dist/commonjs/main_thread/decrypt/utils/serializable_bytes.js +50 -0
  344. package/dist/commonjs/main_thread/decrypt/utils/server_certificate_store.d.ts +64 -0
  345. package/dist/commonjs/main_thread/decrypt/utils/server_certificate_store.js +123 -0
  346. package/dist/commonjs/main_thread/init/directfile_content_initializer.d.ts +97 -0
  347. package/dist/commonjs/main_thread/init/directfile_content_initializer.js +264 -0
  348. package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts +166 -0
  349. package/dist/commonjs/main_thread/init/media_source_content_initializer.js +918 -0
  350. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts +222 -0
  351. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.js +1477 -0
  352. package/dist/commonjs/main_thread/init/send_message.d.ts +2 -0
  353. package/dist/commonjs/main_thread/init/send_message.js +13 -0
  354. package/dist/commonjs/main_thread/init/types.d.ts +221 -0
  355. package/dist/commonjs/main_thread/init/utils/create_core_playback_observer.d.ts +83 -0
  356. package/dist/commonjs/main_thread/init/utils/create_core_playback_observer.js +105 -0
  357. package/dist/commonjs/main_thread/init/utils/create_media_source.d.ts +37 -0
  358. package/dist/commonjs/main_thread/init/utils/create_media_source.js +106 -0
  359. package/dist/commonjs/main_thread/init/utils/get_initial_time.d.ts +76 -0
  360. package/dist/commonjs/main_thread/init/utils/get_initial_time.js +109 -0
  361. package/dist/commonjs/main_thread/init/utils/get_loaded_reference.d.ts +28 -0
  362. package/dist/commonjs/main_thread/init/utils/get_loaded_reference.js +67 -0
  363. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.d.ts +61 -0
  364. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.js +204 -0
  365. package/dist/commonjs/main_thread/init/utils/initialize_content_decryption.d.ts +87 -0
  366. package/dist/commonjs/main_thread/init/utils/initialize_content_decryption.js +119 -0
  367. package/dist/commonjs/main_thread/init/utils/main_thread_text_displayer_interface.d.ts +35 -0
  368. package/dist/commonjs/main_thread/init/utils/rebuffering_controller.d.ts +114 -0
  369. package/dist/commonjs/main_thread/init/utils/rebuffering_controller.js +450 -0
  370. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/are_same_stream_events.js +35 -0
  371. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/index.d.ts +18 -0
  372. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/refresh_scheduled_events_list.d.ts +25 -0
  373. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/refresh_scheduled_events_list.js +98 -0
  374. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts +53 -0
  375. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/stream_events_emitter.js +230 -0
  376. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/types.d.ts +41 -0
  377. package/dist/commonjs/main_thread/init/utils/throw_on_media_error.d.ts +23 -0
  378. package/dist/commonjs/main_thread/init/utils/throw_on_media_error.js +66 -0
  379. package/dist/commonjs/main_thread/text_displayer/html/html_parsers.js +25 -0
  380. package/dist/commonjs/main_thread/text_displayer/html/html_text_displayer.d.ts +100 -0
  381. package/dist/commonjs/main_thread/text_displayer/html/html_text_displayer.js +318 -0
  382. package/dist/commonjs/main_thread/text_displayer/html/text_track_cues_store.d.ts +65 -0
  383. package/dist/commonjs/main_thread/text_displayer/html/text_track_cues_store.js +378 -0
  384. package/dist/commonjs/main_thread/text_displayer/html/update_proportional_elements.js +64 -0
  385. package/dist/commonjs/main_thread/text_displayer/html/utils.js +119 -0
  386. package/dist/commonjs/main_thread/text_displayer/index.d.ts +2 -0
  387. package/dist/commonjs/main_thread/text_displayer/manual_time_ranges.js +52 -0
  388. package/dist/commonjs/main_thread/text_displayer/native/native_parsers.d.ts +11 -0
  389. package/dist/commonjs/main_thread/text_displayer/native/native_parsers.js +25 -0
  390. package/dist/commonjs/main_thread/text_displayer/native/native_text_displayer.d.ts +56 -0
  391. package/dist/commonjs/main_thread/text_displayer/native/native_text_displayer.js +207 -0
  392. package/dist/commonjs/main_thread/text_displayer/types.d.ts +71 -0
  393. package/dist/commonjs/main_thread/text_displayer/types.js +2 -0
  394. package/dist/commonjs/main_thread/tracks_store/index.d.ts +20 -0
  395. package/dist/commonjs/main_thread/tracks_store/media_element_tracks_store.d.ts +197 -0
  396. package/dist/commonjs/main_thread/tracks_store/media_element_tracks_store.js +691 -0
  397. package/dist/commonjs/main_thread/tracks_store/track_dispatcher.d.ts +101 -0
  398. package/dist/commonjs/main_thread/tracks_store/track_dispatcher.js +198 -0
  399. package/dist/commonjs/main_thread/tracks_store/tracks_store.d.ts +448 -0
  400. package/dist/commonjs/main_thread/tracks_store/tracks_store.js +1096 -0
  401. package/dist/commonjs/main_thread/types.d.ts +5 -0
  402. package/dist/commonjs/main_thread/types.js +2 -0
  403. package/dist/commonjs/manifest/classes/adaptation.d.ts +134 -0
  404. package/dist/commonjs/manifest/classes/adaptation.js +237 -0
  405. package/dist/commonjs/manifest/classes/index.d.ts +25 -0
  406. package/dist/commonjs/manifest/classes/index.js +46 -0
  407. package/dist/commonjs/manifest/classes/manifest.d.ts +391 -0
  408. package/dist/commonjs/manifest/classes/manifest.js +494 -0
  409. package/dist/commonjs/manifest/classes/period.d.ts +106 -0
  410. package/dist/commonjs/manifest/classes/period.js +235 -0
  411. package/dist/commonjs/manifest/classes/representation.d.ts +238 -0
  412. package/dist/commonjs/manifest/classes/representation.js +382 -0
  413. package/dist/commonjs/manifest/classes/representation_index/index.d.ts +18 -0
  414. package/dist/commonjs/manifest/classes/representation_index/static.d.ts +101 -0
  415. package/dist/commonjs/manifest/classes/representation_index/static.js +147 -0
  416. package/dist/commonjs/manifest/classes/representation_index/types.d.ts +420 -0
  417. package/dist/commonjs/manifest/classes/types.d.ts +29 -0
  418. package/dist/commonjs/manifest/classes/types.js +33 -0
  419. package/dist/commonjs/manifest/classes/update_period_in_place.d.ts +53 -0
  420. package/dist/commonjs/manifest/classes/update_period_in_place.js +172 -0
  421. package/dist/commonjs/manifest/classes/update_periods.d.ts +50 -0
  422. package/dist/commonjs/manifest/classes/update_periods.js +229 -0
  423. package/dist/commonjs/manifest/classes/utils.d.ts +39 -0
  424. package/dist/commonjs/manifest/classes/utils.js +54 -0
  425. package/dist/commonjs/manifest/index.d.ts +15 -25
  426. package/dist/commonjs/manifest/index.js +5 -46
  427. package/dist/commonjs/manifest/types.d.ts +2 -31
  428. package/dist/commonjs/manifest/types.js +0 -16
  429. package/dist/commonjs/manifest/utils.d.ts +11 -49
  430. package/dist/commonjs/manifest/utils.js +55 -79
  431. package/dist/commonjs/minimal.d.ts +1 -1
  432. package/dist/commonjs/minimal.js +6 -1
  433. package/dist/commonjs/mse/main_codec_support_prober.d.ts +1 -1
  434. package/dist/commonjs/mse/main_media_source_interface.d.ts +2 -2
  435. package/dist/commonjs/mse/main_media_source_interface.js +59 -34
  436. package/dist/commonjs/mse/types.d.ts +3 -3
  437. package/dist/commonjs/mse/utils/end_of_stream.d.ts +33 -0
  438. package/dist/commonjs/mse/utils/end_of_stream.js +114 -0
  439. package/dist/commonjs/mse/utils/media_source_duration_updater.js +272 -0
  440. package/dist/commonjs/mse/worker_codec_support_prober.d.ts +1 -1
  441. package/dist/commonjs/mse/worker_media_source_interface.d.ts +4 -4
  442. package/dist/commonjs/mse/worker_media_source_interface.js +19 -17
  443. package/dist/commonjs/multithread_types.d.ts +15 -18
  444. package/dist/commonjs/parsers/containers/isobmff/create_box.d.ts +1 -1
  445. package/dist/commonjs/parsers/containers/isobmff/create_box.js +4 -3
  446. package/dist/commonjs/parsers/containers/isobmff/drm/playready.js +1 -2
  447. package/dist/commonjs/parsers/containers/isobmff/extract_complete_chunks.js +95 -0
  448. package/dist/commonjs/parsers/containers/isobmff/find_complete_box.js +57 -0
  449. package/dist/commonjs/parsers/containers/isobmff/get_box.js +2 -4
  450. package/dist/commonjs/parsers/containers/isobmff/index.d.ts +5 -3
  451. package/dist/commonjs/parsers/containers/isobmff/index.js +5 -1
  452. package/dist/commonjs/parsers/containers/isobmff/read.d.ts +1 -1
  453. package/dist/commonjs/parsers/containers/isobmff/read.js +7 -7
  454. package/dist/commonjs/parsers/containers/isobmff/take_pssh_out.js +3 -4
  455. package/dist/commonjs/parsers/containers/isobmff/utils.js +64 -40
  456. package/dist/commonjs/parsers/containers/matroska/index.d.ts +1 -1
  457. package/dist/commonjs/parsers/containers/matroska/utils.js +42 -29
  458. package/dist/commonjs/parsers/images/bif.js +17 -4
  459. package/dist/commonjs/parsers/manifest/dash/common/attach_trickmode_track.d.ts +1 -1
  460. package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.js +1 -3
  461. package/dist/commonjs/parsers/manifest/dash/common/flatten_overlapping_periods.d.ts +1 -1
  462. package/dist/commonjs/parsers/manifest/dash/common/flatten_overlapping_periods.js +1 -1
  463. package/dist/commonjs/parsers/manifest/dash/common/get_hdr_information.js +4 -12
  464. package/dist/commonjs/parsers/manifest/dash/common/get_http_utc-timing_url.d.ts +1 -1
  465. package/dist/commonjs/parsers/manifest/dash/common/get_http_utc-timing_url.js +4 -5
  466. package/dist/commonjs/parsers/manifest/dash/common/get_minimum_and_maximum_positions.d.ts +1 -1
  467. package/dist/commonjs/parsers/manifest/dash/common/get_minimum_and_maximum_positions.js +5 -2
  468. package/dist/commonjs/parsers/manifest/dash/common/get_periods_time_infos.d.ts +1 -1
  469. package/dist/commonjs/parsers/manifest/dash/common/get_periods_time_infos.js +14 -10
  470. package/dist/commonjs/parsers/manifest/dash/common/index.d.ts +1 -1
  471. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +5 -5
  472. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +39 -29
  473. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_init_segment.d.ts +2 -2
  474. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_init_segment.js +8 -4
  475. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +4 -4
  476. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +14 -10
  477. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +2 -2
  478. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +33 -20
  479. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +3 -3
  480. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +58 -57
  481. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.d.ts +5 -4
  482. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +13 -10
  483. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.d.ts +3 -2
  484. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.js +23 -18
  485. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/convert_element_to_index_segment.d.ts +1 -1
  486. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/convert_element_to_index_segment.js +16 -9
  487. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.d.ts +4 -3
  488. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.js +47 -26
  489. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/parse_s_element.d.ts +11 -2
  490. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/parse_s_element.js +74 -3
  491. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +9 -8
  492. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +85 -66
  493. package/dist/commonjs/parsers/manifest/dash/common/indexes/tokens.js +2 -4
  494. package/dist/commonjs/parsers/manifest/dash/common/infer_adaptation_type.d.ts +1 -1
  495. package/dist/commonjs/parsers/manifest/dash/common/infer_adaptation_type.js +2 -2
  496. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +9 -10
  497. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.d.ts +5 -5
  498. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +63 -56
  499. package/dist/commonjs/parsers/manifest/dash/common/parse_availability_start_time.d.ts +3 -2
  500. package/dist/commonjs/parsers/manifest/dash/common/parse_availability_start_time.js +5 -3
  501. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.d.ts +6 -6
  502. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +67 -41
  503. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts +5 -5
  504. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +46 -29
  505. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.d.ts +5 -5
  506. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +4 -6
  507. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.d.ts +5 -5
  508. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +66 -64
  509. package/dist/commonjs/parsers/manifest/dash/common/resolve_base_urls.d.ts +1 -1
  510. package/dist/commonjs/parsers/manifest/dash/common/resolve_base_urls.js +4 -2
  511. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/index.d.ts +17 -0
  512. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/index.js +19 -0
  513. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.d.ts +24 -0
  514. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.js +400 -0
  515. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.d.ts +24 -0
  516. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.js +33 -0
  517. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.d.ts +23 -0
  518. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.js +70 -0
  519. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.d.ts +22 -0
  520. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.js +118 -0
  521. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.d.ts +23 -0
  522. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.js +154 -0
  523. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.d.ts +22 -0
  524. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.js +70 -0
  525. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.d.ts +23 -0
  526. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.js +221 -0
  527. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Period.d.ts +23 -0
  528. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Period.js +179 -0
  529. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.d.ts +22 -0
  530. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +256 -0
  531. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.d.ts +23 -0
  532. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.js +152 -0
  533. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.d.ts +22 -0
  534. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.js +60 -0
  535. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.d.ts +24 -0
  536. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.js +125 -0
  537. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.d.ts +22 -0
  538. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.js +36 -0
  539. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.d.ts +24 -0
  540. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.js +82 -0
  541. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts +176 -0
  542. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.js +382 -0
  543. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.d.ts +24 -0
  544. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.js +142 -0
  545. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/AdaptationSet.d.ts +23 -0
  546. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/AdaptationSet.js +374 -0
  547. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/BaseURL.d.ts +23 -0
  548. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/BaseURL.js +32 -0
  549. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/ContentComponent.d.ts +22 -0
  550. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/ContentProtection.d.ts +21 -0
  551. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/EventStream.d.ts +23 -0
  552. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/EventStream.js +119 -0
  553. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Initialization.d.ts +21 -0
  554. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Initialization.js +44 -0
  555. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/MPD.d.ts +21 -0
  556. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/MPD.js +181 -0
  557. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Period.d.ts +21 -0
  558. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Period.js +138 -0
  559. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Representation.d.ts +21 -0
  560. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Representation.js +230 -0
  561. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentBase.d.ts +22 -0
  562. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentBase.js +126 -0
  563. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentList.d.ts +21 -0
  564. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentTemplate.d.ts +23 -0
  565. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentTemplate.js +102 -0
  566. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentTimeline.d.ts +21 -0
  567. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentURL.d.ts +23 -0
  568. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentURL.js +56 -0
  569. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/utils.d.ts +169 -0
  570. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/utils.js +346 -0
  571. package/dist/commonjs/parsers/manifest/dash/native-parser/parse_from_document.d.ts +24 -0
  572. package/dist/commonjs/parsers/manifest/dash/native-parser/parse_from_document.js +136 -0
  573. package/dist/commonjs/parsers/manifest/dash/node_parser_types.d.ts +5 -3
  574. package/dist/commonjs/parsers/manifest/dash/parsers_types.d.ts +1 -1
  575. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.d.ts +1 -1
  576. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +31 -17
  577. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.d.ts +3 -2
  578. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +21 -25
  579. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.d.ts +2 -2
  580. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.d.ts +3 -3
  581. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.js +1 -1
  582. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.d.ts +3 -3
  583. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.js +4 -2
  584. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/EventStream.d.ts +3 -2
  585. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/EventStream.js +2 -4
  586. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/MPD.d.ts +3 -2
  587. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/MPD.js +4 -4
  588. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Period.d.ts +3 -2
  589. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Period.js +9 -6
  590. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Representation.d.ts +3 -2
  591. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +13 -15
  592. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.d.ts +3 -3
  593. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.js +1 -1
  594. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.d.ts +2 -2
  595. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.js +5 -10
  596. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentList.d.ts +3 -2
  597. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.d.ts +2 -2
  598. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.js +11 -18
  599. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentUrl.d.ts +2 -2
  600. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentUrl.js +2 -4
  601. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/XLink.d.ts +3 -2
  602. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/XLink.js +4 -4
  603. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/root.d.ts +2 -2
  604. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/root.js +7 -3
  605. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/parsers_stack.js +5 -2
  606. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/utils.d.ts +1 -1
  607. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/utils.js +7 -3
  608. package/dist/commonjs/parsers/manifest/local/parse_local_manifest.d.ts +2 -2
  609. package/dist/commonjs/parsers/manifest/local/parse_local_manifest.js +25 -16
  610. package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +2 -2
  611. package/dist/commonjs/parsers/manifest/local/representation_index.js +8 -10
  612. package/dist/commonjs/parsers/manifest/metaplaylist/index.d.ts +1 -1
  613. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.d.ts +4 -4
  614. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +48 -43
  615. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +3 -3
  616. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +10 -7
  617. package/dist/commonjs/parsers/manifest/smooth/create_parser.d.ts +2 -2
  618. package/dist/commonjs/parsers/manifest/smooth/create_parser.js +130 -108
  619. package/dist/commonjs/parsers/manifest/smooth/get_codecs.js +3 -3
  620. package/dist/commonjs/parsers/manifest/smooth/index.d.ts +1 -1
  621. package/dist/commonjs/parsers/manifest/smooth/parse_C_nodes.js +9 -9
  622. package/dist/commonjs/parsers/manifest/smooth/parse_protection_node.js +12 -8
  623. package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +3 -3
  624. package/dist/commonjs/parsers/manifest/smooth/representation_index.js +37 -37
  625. package/dist/commonjs/parsers/manifest/smooth/shared_smooth_segment_timeline.d.ts +1 -1
  626. package/dist/commonjs/parsers/manifest/smooth/shared_smooth_segment_timeline.js +8 -9
  627. package/dist/commonjs/parsers/manifest/smooth/utils/add_segment_infos.js +10 -7
  628. package/dist/commonjs/parsers/manifest/smooth/utils/parseBoolean.d.ts +1 -1
  629. package/dist/commonjs/parsers/manifest/smooth/utils/parseBoolean.js +1 -1
  630. package/dist/commonjs/parsers/manifest/smooth/utils/tokens.d.ts +1 -1
  631. package/dist/commonjs/parsers/manifest/smooth/utils/tokens.js +1 -2
  632. package/dist/commonjs/parsers/manifest/types.d.ts +2 -2
  633. package/dist/commonjs/parsers/manifest/utils/check_manifest_ids.d.ts +1 -1
  634. package/dist/commonjs/parsers/manifest/utils/clear_timeline_from_position.d.ts +3 -2
  635. package/dist/commonjs/parsers/manifest/utils/clear_timeline_from_position.js +11 -7
  636. package/dist/commonjs/parsers/manifest/utils/get_first_time_from_adaptation.d.ts +1 -1
  637. package/dist/commonjs/parsers/manifest/utils/get_first_time_from_adaptation.js +5 -4
  638. package/dist/commonjs/parsers/manifest/utils/get_last_time_from_adaptation.d.ts +1 -1
  639. package/dist/commonjs/parsers/manifest/utils/get_last_time_from_adaptation.js +5 -4
  640. package/dist/commonjs/parsers/manifest/utils/get_maximum_positions.d.ts +2 -2
  641. package/dist/commonjs/parsers/manifest/utils/get_maximum_positions.js +11 -17
  642. package/dist/commonjs/parsers/manifest/utils/get_minimum_position.d.ts +2 -2
  643. package/dist/commonjs/parsers/manifest/utils/get_minimum_position.js +5 -11
  644. package/dist/commonjs/parsers/manifest/utils/index_helpers.js +4 -5
  645. package/dist/commonjs/parsers/manifest/utils/update_segment_timeline.d.ts +1 -1
  646. package/dist/commonjs/parsers/manifest/utils/update_segment_timeline.js +17 -17
  647. package/dist/commonjs/parsers/texttracks/index.d.ts +1 -1
  648. package/dist/commonjs/parsers/texttracks/sami/html.d.ts +1 -1
  649. package/dist/commonjs/parsers/texttracks/sami/html.js +17 -16
  650. package/dist/commonjs/parsers/texttracks/sami/native.d.ts +1 -1
  651. package/dist/commonjs/parsers/texttracks/sami/native.js +12 -18
  652. package/dist/commonjs/parsers/texttracks/srt/html.js +12 -10
  653. package/dist/commonjs/parsers/texttracks/srt/native.d.ts +1 -1
  654. package/dist/commonjs/parsers/texttracks/srt/native.js +2 -8
  655. package/dist/commonjs/parsers/texttracks/srt/parse_cue.js +4 -8
  656. package/dist/commonjs/parsers/texttracks/ttml/get_parameters.js +7 -8
  657. package/dist/commonjs/parsers/texttracks/ttml/get_time_delimiters.d.ts +1 -1
  658. package/dist/commonjs/parsers/texttracks/ttml/get_time_delimiters.js +9 -10
  659. package/dist/commonjs/parsers/texttracks/ttml/html/apply_default_ttml_paragraph_style.js +2 -2
  660. package/dist/commonjs/parsers/texttracks/ttml/html/apply_extent.js +5 -9
  661. package/dist/commonjs/parsers/texttracks/ttml/html/apply_font_size.js +6 -7
  662. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +2 -2
  663. package/dist/commonjs/parsers/texttracks/ttml/html/apply_origin.js +5 -9
  664. package/dist/commonjs/parsers/texttracks/ttml/html/apply_padding.js +7 -11
  665. package/dist/commonjs/parsers/texttracks/ttml/html/create_element.d.ts +2 -2
  666. package/dist/commonjs/parsers/texttracks/ttml/html/create_element.js +29 -22
  667. package/dist/commonjs/parsers/texttracks/ttml/html/generate_css_test_outline.js +2 -2
  668. package/dist/commonjs/parsers/texttracks/ttml/html/parse_cue.d.ts +1 -1
  669. package/dist/commonjs/parsers/texttracks/ttml/html/parse_cue.js +5 -3
  670. package/dist/commonjs/parsers/texttracks/ttml/html/parse_ttml_to_div.d.ts +1 -1
  671. package/dist/commonjs/parsers/texttracks/ttml/html/ttml_color_to_css_color.js +39 -23
  672. package/dist/commonjs/parsers/texttracks/ttml/native/parse_cue.d.ts +2 -2
  673. package/dist/commonjs/parsers/texttracks/ttml/native/parse_cue.js +14 -13
  674. package/dist/commonjs/parsers/texttracks/ttml/native/parse_ttml_to_vtt.d.ts +1 -1
  675. package/dist/commonjs/parsers/texttracks/ttml/parse_ttml.d.ts +3 -3
  676. package/dist/commonjs/parsers/texttracks/ttml/parse_ttml.js +27 -15
  677. package/dist/commonjs/parsers/texttracks/ttml/resolve_styles_inheritance.d.ts +1 -1
  678. package/dist/commonjs/parsers/texttracks/ttml/time_parsing.d.ts +1 -1
  679. package/dist/commonjs/parsers/texttracks/ttml/time_parsing.js +2 -2
  680. package/dist/commonjs/parsers/texttracks/ttml/xml_utils.js +2 -1
  681. package/dist/commonjs/parsers/texttracks/types.d.ts +1 -1
  682. package/dist/commonjs/parsers/texttracks/webvtt/get_style_blocks.js +2 -1
  683. package/dist/commonjs/parsers/texttracks/webvtt/html/convert_payload_to_html.d.ts +1 -1
  684. package/dist/commonjs/parsers/texttracks/webvtt/html/create_default_style_elements.d.ts +1 -1
  685. package/dist/commonjs/parsers/texttracks/webvtt/html/create_style_attribute.js +6 -12
  686. package/dist/commonjs/parsers/texttracks/webvtt/html/create_styled_element.d.ts +1 -1
  687. package/dist/commonjs/parsers/texttracks/webvtt/html/create_styled_element.js +7 -8
  688. package/dist/commonjs/parsers/texttracks/webvtt/html/parse_style_block.js +4 -4
  689. package/dist/commonjs/parsers/texttracks/webvtt/html/parse_webvtt_to_div.d.ts +1 -1
  690. package/dist/commonjs/parsers/texttracks/webvtt/html/parse_webvtt_to_div.js +1 -1
  691. package/dist/commonjs/parsers/texttracks/webvtt/html/to_html.d.ts +1 -1
  692. package/dist/commonjs/parsers/texttracks/webvtt/html/to_html.js +4 -10
  693. package/dist/commonjs/parsers/texttracks/webvtt/native/parse_vtt_to_cues.d.ts +1 -1
  694. package/dist/commonjs/parsers/texttracks/webvtt/native/parse_vtt_to_cues.js +5 -9
  695. package/dist/commonjs/parsers/texttracks/webvtt/native/set_settings_on_cue.d.ts +1 -1
  696. package/dist/commonjs/parsers/texttracks/webvtt/native/to_native_cue.d.ts +2 -2
  697. package/dist/commonjs/parsers/texttracks/webvtt/native/to_native_cue.js +3 -3
  698. package/dist/commonjs/parsers/texttracks/webvtt/parse_cue_block.js +9 -5
  699. package/dist/commonjs/parsers/texttracks/webvtt/parse_timestamp.js +1 -2
  700. package/dist/commonjs/parsers/texttracks/webvtt/utils.js +6 -6
  701. package/dist/commonjs/playback_observer/index.d.ts +6 -0
  702. package/dist/commonjs/playback_observer/index.js +5 -0
  703. package/dist/commonjs/playback_observer/media_element_playback_observer.d.ts +203 -0
  704. package/dist/commonjs/playback_observer/media_element_playback_observer.js +685 -0
  705. package/dist/commonjs/playback_observer/types.d.ts +223 -0
  706. package/dist/commonjs/playback_observer/types.js +2 -0
  707. package/dist/commonjs/playback_observer/utils/generate_read_only_observer.d.ts +11 -0
  708. package/dist/commonjs/playback_observer/utils/generate_read_only_observer.js +44 -0
  709. package/dist/commonjs/playback_observer/utils/observation_position.d.ts +87 -0
  710. package/dist/commonjs/playback_observer/utils/observation_position.js +88 -0
  711. package/dist/commonjs/playback_observer/worker_playback_observer.d.ts +72 -0
  712. package/dist/commonjs/playback_observer/worker_playback_observer.js +49 -0
  713. package/dist/commonjs/public_types.d.ts +13 -16
  714. package/dist/commonjs/public_types.js +0 -1
  715. package/dist/commonjs/tools/TextTrackRenderer/text_track_renderer.d.ts +2 -2
  716. package/dist/commonjs/tools/TextTrackRenderer/text_track_renderer.js +10 -7
  717. package/dist/commonjs/tools/index.d.ts +1 -1
  718. package/dist/commonjs/tools/parseBIFThumbnails/index.js +5 -4
  719. package/dist/commonjs/transports/dash/add_segment_integrity_checks_to_loader.d.ts +1 -1
  720. package/dist/commonjs/transports/dash/add_segment_integrity_checks_to_loader.js +2 -3
  721. package/dist/commonjs/transports/dash/construct_segment_url.d.ts +2 -2
  722. package/dist/commonjs/transports/dash/construct_segment_url.js +7 -3
  723. package/dist/commonjs/transports/dash/get_events_out_of_emsgs.d.ts +2 -2
  724. package/dist/commonjs/transports/dash/get_events_out_of_emsgs.js +12 -10
  725. package/dist/commonjs/transports/dash/init_segment_loader.d.ts +3 -3
  726. package/dist/commonjs/transports/dash/init_segment_loader.js +46 -22
  727. package/dist/commonjs/transports/dash/low_latency_segment_loader.d.ts +2 -2
  728. package/dist/commonjs/transports/dash/low_latency_segment_loader.js +18 -11
  729. package/dist/commonjs/transports/dash/manifest_parser.d.ts +2 -2
  730. package/dist/commonjs/transports/dash/manifest_parser.js +69 -28
  731. package/dist/commonjs/transports/dash/pipelines.d.ts +1 -1
  732. package/dist/commonjs/transports/dash/pipelines.js +15 -12
  733. package/dist/commonjs/transports/dash/segment_loader.d.ts +4 -4
  734. package/dist/commonjs/transports/dash/segment_loader.js +35 -21
  735. package/dist/commonjs/transports/dash/segment_parser.d.ts +2 -2
  736. package/dist/commonjs/transports/dash/segment_parser.js +54 -22
  737. package/dist/commonjs/transports/dash/text_loader.d.ts +2 -2
  738. package/dist/commonjs/transports/dash/text_loader.js +21 -18
  739. package/dist/commonjs/transports/dash/text_parser.d.ts +2 -2
  740. package/dist/commonjs/transports/dash/text_parser.js +49 -23
  741. package/dist/commonjs/transports/index.d.ts +1 -1
  742. package/dist/commonjs/transports/index.js +0 -15
  743. package/dist/commonjs/transports/local/pipelines.d.ts +1 -1
  744. package/dist/commonjs/transports/local/pipelines.js +15 -10
  745. package/dist/commonjs/transports/local/segment_loader.d.ts +3 -3
  746. package/dist/commonjs/transports/local/segment_loader.js +14 -6
  747. package/dist/commonjs/transports/local/segment_parser.d.ts +1 -1
  748. package/dist/commonjs/transports/local/segment_parser.js +30 -12
  749. package/dist/commonjs/transports/local/text_parser.d.ts +1 -1
  750. package/dist/commonjs/transports/local/text_parser.js +48 -18
  751. package/dist/commonjs/transports/metaplaylist/manifest_loader.d.ts +4 -4
  752. package/dist/commonjs/transports/metaplaylist/manifest_loader.js +9 -5
  753. package/dist/commonjs/transports/metaplaylist/pipelines.d.ts +1 -1
  754. package/dist/commonjs/transports/metaplaylist/pipelines.js +38 -22
  755. package/dist/commonjs/transports/smooth/extract_timings_infos.d.ts +2 -2
  756. package/dist/commonjs/transports/smooth/extract_timings_infos.js +14 -13
  757. package/dist/commonjs/transports/smooth/is_mp4_embedded_track.d.ts +1 -1
  758. package/dist/commonjs/transports/smooth/is_mp4_embedded_track.js +1 -1
  759. package/dist/commonjs/transports/smooth/isobmff/create_audio_init_segment.d.ts +0 -1
  760. package/dist/commonjs/transports/smooth/isobmff/create_audio_init_segment.js +3 -4
  761. package/dist/commonjs/transports/smooth/isobmff/create_boxes.js +22 -31
  762. package/dist/commonjs/transports/smooth/isobmff/create_init_segment.js +1 -1
  763. package/dist/commonjs/transports/smooth/isobmff/get_aaces_header.js +4 -16
  764. package/dist/commonjs/transports/smooth/isobmff/parse_tfrf.js +1 -1
  765. package/dist/commonjs/transports/smooth/isobmff/parse_tfxd.js +1 -1
  766. package/dist/commonjs/transports/smooth/isobmff/patch_segment.js +12 -11
  767. package/dist/commonjs/transports/smooth/pipelines.d.ts +1 -1
  768. package/dist/commonjs/transports/smooth/pipelines.js +101 -60
  769. package/dist/commonjs/transports/smooth/segment_loader.d.ts +3 -3
  770. package/dist/commonjs/transports/smooth/segment_loader.js +50 -27
  771. package/dist/commonjs/transports/smooth/utils.d.ts +4 -4
  772. package/dist/commonjs/transports/smooth/utils.js +9 -5
  773. package/dist/commonjs/transports/types.d.ts +22 -27
  774. package/dist/commonjs/transports/utils/byte_range.js +1 -2
  775. package/dist/commonjs/transports/utils/call_custom_manifest_loader.d.ts +3 -3
  776. package/dist/commonjs/transports/utils/call_custom_manifest_loader.js +10 -6
  777. package/dist/commonjs/transports/utils/check_isobmff_integrity.js +5 -5
  778. package/dist/commonjs/transports/utils/generate_manifest_loader.d.ts +3 -3
  779. package/dist/commonjs/transports/utils/generate_manifest_loader.js +18 -6
  780. package/dist/commonjs/transports/utils/get_isobmff_timing_infos.d.ts +2 -2
  781. package/dist/commonjs/transports/utils/get_isobmff_timing_infos.js +12 -11
  782. package/dist/commonjs/transports/utils/infer_segment_container.d.ts +1 -1
  783. package/dist/commonjs/transports/utils/infer_segment_container.js +1 -3
  784. package/dist/commonjs/transports/utils/parse_text_track.d.ts +4 -4
  785. package/dist/commonjs/transports/utils/parse_text_track.js +4 -7
  786. package/dist/commonjs/utils/array_includes.js +2 -6
  787. package/dist/commonjs/utils/assert.js +3 -6
  788. package/dist/commonjs/utils/base64.js +87 -29
  789. package/dist/commonjs/utils/byte_parsing.js +64 -56
  790. package/dist/commonjs/utils/cancellable_sleep.d.ts +1 -1
  791. package/dist/commonjs/utils/create_cancellable_promise.d.ts +1 -1
  792. package/dist/commonjs/utils/deep_merge.js +4 -4
  793. package/dist/commonjs/utils/event_emitter.d.ts +1 -1
  794. package/dist/commonjs/utils/event_emitter.js +1 -2
  795. package/dist/commonjs/utils/get_fuzzed_delay.js +1 -1
  796. package/dist/commonjs/utils/global_scope.d.ts +1 -1
  797. package/dist/commonjs/utils/global_scope.js +10 -3
  798. package/dist/commonjs/utils/hash_buffer.js +1 -1
  799. package/dist/commonjs/utils/languages/normalize.js +4 -2
  800. package/dist/commonjs/utils/logger.js +21 -31
  801. package/dist/commonjs/utils/monotonic_timestamp.d.ts +6 -9
  802. package/dist/commonjs/utils/monotonic_timestamp.js +15 -6
  803. package/dist/commonjs/utils/object_assign.d.ts +6 -3
  804. package/dist/commonjs/utils/object_assign.js +5 -7
  805. package/dist/commonjs/utils/object_values.d.ts +1 -1
  806. package/dist/commonjs/utils/object_values.js +2 -3
  807. package/dist/commonjs/utils/queue_microtask.js +3 -3
  808. package/dist/commonjs/utils/ranges.js +22 -29
  809. package/dist/commonjs/utils/reference.d.ts +1 -1
  810. package/dist/commonjs/utils/reference.js +1 -3
  811. package/dist/commonjs/utils/request/fetch.d.ts +1 -1
  812. package/dist/commonjs/utils/request/fetch.js +33 -22
  813. package/dist/commonjs/utils/request/request_error.js +2 -2
  814. package/dist/commonjs/utils/request/xhr.d.ts +1 -1
  815. package/dist/commonjs/utils/request/xhr.js +28 -17
  816. package/dist/commonjs/utils/retry_promise_with_backoff.d.ts +10 -1
  817. package/dist/commonjs/utils/retry_promise_with_backoff.js +18 -4
  818. package/dist/commonjs/utils/slice_uint8array.js +3 -3
  819. package/dist/commonjs/utils/starts_with.js +3 -3
  820. package/dist/commonjs/utils/string_parsing.js +16 -18
  821. package/dist/commonjs/utils/sync_or_async.js +6 -2
  822. package/dist/commonjs/utils/task_canceller.js +1 -2
  823. package/dist/commonjs/utils/wrapInPromise.d.ts +1 -1
  824. package/dist/commonjs/utils/xml-parser.d.ts +70 -0
  825. package/dist/commonjs/utils/xml-parser.js +357 -0
  826. package/dist/commonjs/worker_entry_point.js +1 -1
  827. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  828. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  829. package/dist/es2017/__GENERATED_CODE/embedded_worker_es5.d.ts +3 -0
  830. package/dist/es2017/__GENERATED_CODE/embedded_worker_es5.js +3 -0
  831. package/dist/es2017/__GENERATED_CODE/index.d.ts +1 -0
  832. package/dist/es2017/__GENERATED_CODE/index.js +1 -0
  833. package/dist/es2017/compat/add_class_name.js +4 -3
  834. package/dist/es2017/compat/add_text_track.d.ts +1 -1
  835. package/dist/es2017/compat/add_text_track.js +3 -2
  836. package/dist/es2017/compat/browser_compatibility_types.js +13 -7
  837. package/dist/es2017/compat/browser_detection.d.ts +3 -1
  838. package/dist/es2017/compat/browser_detection.js +15 -12
  839. package/dist/es2017/compat/can_reuse_media_keys.js +1 -1
  840. package/dist/es2017/compat/can_seek_directly_after_loaded_metadata.d.ts +7 -0
  841. package/dist/es2017/compat/can_seek_directly_after_loaded_metadata.js +8 -0
  842. package/dist/es2017/compat/change_source_buffer_type.d.ts +1 -1
  843. package/dist/es2017/compat/eme/close_session.d.ts +1 -1
  844. package/dist/es2017/compat/eme/close_session.js +17 -13
  845. package/dist/es2017/compat/eme/custom_key_system_access.d.ts +1 -1
  846. package/dist/es2017/compat/eme/custom_media_keys/ie11_media_keys.d.ts +1 -1
  847. package/dist/es2017/compat/eme/custom_media_keys/ie11_media_keys.js +14 -7
  848. package/dist/es2017/compat/eme/custom_media_keys/index.js +1 -1
  849. package/dist/es2017/compat/eme/custom_media_keys/moz_media_keys_constructor.d.ts +1 -1
  850. package/dist/es2017/compat/eme/custom_media_keys/old_webkit_media_keys.d.ts +1 -1
  851. package/dist/es2017/compat/eme/custom_media_keys/old_webkit_media_keys.js +10 -10
  852. package/dist/es2017/compat/eme/custom_media_keys/types.d.ts +1 -1
  853. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.d.ts +1 -1
  854. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.js +5 -9
  855. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys_constructor.d.ts +1 -1
  856. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys_constructor.js +3 -3
  857. package/dist/es2017/compat/eme/eme-api-implementation.d.ts +3 -3
  858. package/dist/es2017/compat/eme/eme-api-implementation.js +13 -12
  859. package/dist/es2017/compat/eme/generate_key_request.d.ts +1 -1
  860. package/dist/es2017/compat/eme/generate_key_request.js +17 -20
  861. package/dist/es2017/compat/eme/get_init_data.js +5 -7
  862. package/dist/es2017/compat/eme/get_uuid_kid_from_keystatus_kid.js +2 -3
  863. package/dist/es2017/compat/eme/get_webkit_fairplay_initdata.js +12 -13
  864. package/dist/es2017/compat/eme/load_session.d.ts +1 -1
  865. package/dist/es2017/compat/eme/set_media_keys.d.ts +9 -0
  866. package/dist/es2017/compat/eme/set_media_keys.js +33 -0
  867. package/dist/es2017/compat/enable_audio_track.d.ts +1 -1
  868. package/dist/es2017/compat/event_listeners.d.ts +4 -4
  869. package/dist/es2017/compat/event_listeners.js +39 -36
  870. package/dist/es2017/compat/has_webassembly.js +1 -2
  871. package/dist/es2017/compat/has_worker_api.d.ts +9 -0
  872. package/dist/es2017/compat/has_worker_api.js +14 -0
  873. package/dist/es2017/compat/is_codec_supported.js +2 -1
  874. package/dist/es2017/compat/is_vtt_cue.d.ts +1 -1
  875. package/dist/es2017/compat/make_vtt_cue.d.ts +1 -1
  876. package/dist/es2017/compat/may_media_element_fail_on_undecipherable_data.d.ts +16 -0
  877. package/dist/es2017/compat/may_media_element_fail_on_undecipherable_data.js +17 -0
  878. package/dist/es2017/compat/on_height_width_change.d.ts +2 -2
  879. package/dist/es2017/compat/on_height_width_change.js +1 -1
  880. package/dist/es2017/compat/patch_webkit_source_buffer.js +28 -28
  881. package/dist/es2017/compat/should_await_set_media_keys.d.ts +16 -0
  882. package/dist/es2017/compat/should_await_set_media_keys.js +19 -0
  883. package/dist/es2017/compat/should_favour_custom_safari_EME.js +2 -2
  884. package/dist/es2017/compat/should_reload_media_source_on_decipherability_update.js +1 -2
  885. package/dist/es2017/config.d.ts +1 -1
  886. package/dist/es2017/core/adaptive/adaptive_representation_selector.d.ts +25 -22
  887. package/dist/es2017/core/adaptive/adaptive_representation_selector.js +40 -28
  888. package/dist/es2017/core/adaptive/buffer_based_chooser.d.ts +1 -1
  889. package/dist/es2017/core/adaptive/buffer_based_chooser.js +14 -12
  890. package/dist/es2017/core/adaptive/guess_based_chooser.d.ts +6 -6
  891. package/dist/es2017/core/adaptive/guess_based_chooser.js +8 -7
  892. package/dist/es2017/core/adaptive/index.d.ts +2 -2
  893. package/dist/es2017/core/adaptive/network_analyzer.d.ts +6 -6
  894. package/dist/es2017/core/adaptive/network_analyzer.js +45 -41
  895. package/dist/es2017/core/adaptive/utils/bandwidth_estimator.js +1 -1
  896. package/dist/es2017/core/adaptive/utils/ewma.js +1 -2
  897. package/dist/es2017/core/adaptive/utils/filter_by_bitrate.d.ts +2 -2
  898. package/dist/es2017/core/adaptive/utils/filter_by_resolution.d.ts +2 -2
  899. package/dist/es2017/core/adaptive/utils/filter_by_resolution.js +2 -4
  900. package/dist/es2017/core/adaptive/utils/get_buffer_levels.js +8 -5
  901. package/dist/es2017/core/adaptive/utils/last_estimate_storage.d.ts +3 -3
  902. package/dist/es2017/core/adaptive/utils/pending_requests_store.d.ts +5 -5
  903. package/dist/es2017/core/adaptive/utils/pending_requests_store.js +5 -6
  904. package/dist/es2017/core/adaptive/utils/representation_score_calculator.d.ts +7 -7
  905. package/dist/es2017/core/adaptive/utils/representation_score_calculator.js +10 -8
  906. package/dist/es2017/core/adaptive/utils/select_optimal_representation.d.ts +4 -4
  907. package/dist/es2017/core/adaptive/utils/select_optimal_representation.js +2 -2
  908. package/dist/es2017/core/fetchers/cdn_prioritizer.d.ts +2 -2
  909. package/dist/es2017/core/fetchers/cdn_prioritizer.js +5 -6
  910. package/dist/es2017/core/fetchers/manifest/index.d.ts +1 -1
  911. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +3 -3
  912. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +76 -76
  913. package/dist/es2017/core/fetchers/segment/index.d.ts +1 -1
  914. package/dist/es2017/core/fetchers/segment/initialization_segment_cache.d.ts +4 -4
  915. package/dist/es2017/core/fetchers/segment/initialization_segment_cache.js +1 -1
  916. package/dist/es2017/core/fetchers/segment/prioritized_segment_fetcher.d.ts +4 -3
  917. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +12 -12
  918. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +52 -37
  919. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +5 -5
  920. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.js +5 -3
  921. package/dist/es2017/core/fetchers/segment/task_prioritizer.d.ts +1 -1
  922. package/dist/es2017/core/fetchers/segment/task_prioritizer.js +22 -21
  923. package/dist/es2017/core/fetchers/utils/error_selector.d.ts +1 -2
  924. package/dist/es2017/core/fetchers/utils/error_selector.js +1 -2
  925. package/dist/es2017/core/fetchers/utils/schedule_request.d.ts +3 -3
  926. package/dist/es2017/core/fetchers/utils/schedule_request.js +22 -23
  927. package/dist/es2017/core/main/common/DecipherabilityFreezeDetector.d.ts +79 -0
  928. package/dist/es2017/core/main/common/DecipherabilityFreezeDetector.js +91 -0
  929. package/dist/es2017/core/main/common/content_time_boundaries_observer.d.ts +191 -0
  930. package/dist/es2017/core/main/common/content_time_boundaries_observer.js +467 -0
  931. package/dist/es2017/core/main/common/create_content_time_boundaries_observer.d.ts +27 -0
  932. package/dist/es2017/core/main/common/create_content_time_boundaries_observer.js +41 -0
  933. package/dist/es2017/core/main/common/get_buffered_data_per_media_buffer.d.ts +14 -0
  934. package/dist/es2017/core/main/common/get_buffered_data_per_media_buffer.js +34 -0
  935. package/dist/es2017/core/main/worker/content_preparer.d.ts +93 -0
  936. package/dist/es2017/core/main/worker/content_preparer.js +239 -0
  937. package/dist/es2017/core/main/worker/globals.d.ts +13 -0
  938. package/dist/es2017/core/main/worker/globals.js +18 -0
  939. package/dist/es2017/core/main/worker/index.d.ts +2 -0
  940. package/dist/es2017/core/main/worker/index.js +2 -0
  941. package/dist/es2017/core/main/worker/send_message.d.ts +3 -0
  942. package/dist/es2017/core/main/worker/send_message.js +20 -0
  943. package/dist/es2017/core/main/worker/track_choice_setter.d.ts +19 -0
  944. package/dist/es2017/core/main/worker/track_choice_setter.js +114 -0
  945. package/dist/es2017/core/main/worker/worker_main.d.ts +1 -0
  946. package/dist/es2017/core/main/worker/worker_main.js +699 -0
  947. package/dist/es2017/core/main/worker/worker_text_displayer_interface.d.ts +64 -0
  948. package/dist/es2017/core/main/worker/worker_text_displayer_interface.js +120 -0
  949. package/dist/es2017/core/segment_sinks/garbage_collector.d.ts +43 -0
  950. package/dist/es2017/core/segment_sinks/garbage_collector.js +143 -0
  951. package/dist/es2017/core/segment_sinks/implementations/audio_video/audio_video_segment_buffer.d.ts +135 -0
  952. package/dist/es2017/core/segment_sinks/implementations/audio_video/audio_video_segment_buffer.js +265 -0
  953. package/dist/es2017/core/segment_sinks/implementations/audio_video/index.d.ts +17 -0
  954. package/dist/es2017/core/segment_sinks/implementations/audio_video/index.js +17 -0
  955. package/dist/es2017/core/segment_sinks/implementations/index.d.ts +19 -0
  956. package/dist/es2017/core/segment_sinks/implementations/index.js +18 -0
  957. package/dist/es2017/core/segment_sinks/implementations/text/index.d.ts +3 -0
  958. package/dist/es2017/core/segment_sinks/implementations/text/index.js +2 -0
  959. package/dist/es2017/core/segment_sinks/implementations/text/text_segment_buffer.d.ts +90 -0
  960. package/dist/es2017/core/segment_sinks/implementations/text/text_segment_buffer.js +156 -0
  961. package/dist/es2017/core/segment_sinks/implementations/types.d.ts +307 -0
  962. package/dist/es2017/core/segment_sinks/implementations/types.js +112 -0
  963. package/dist/es2017/core/segment_sinks/implementations/utils/manual_time_ranges.js +63 -0
  964. package/dist/es2017/core/segment_sinks/index.d.ts +21 -0
  965. package/dist/es2017/core/segment_sinks/index.js +21 -0
  966. package/dist/es2017/core/segment_sinks/inventory/buffered_history.d.ts +89 -0
  967. package/dist/es2017/core/segment_sinks/inventory/buffered_history.js +88 -0
  968. package/dist/es2017/core/segment_sinks/inventory/index.d.ts +21 -0
  969. package/dist/es2017/core/segment_sinks/inventory/index.js +18 -0
  970. package/dist/es2017/core/segment_sinks/inventory/segment_inventory.d.ts +238 -0
  971. package/dist/es2017/core/segment_sinks/inventory/segment_inventory.js +868 -0
  972. package/dist/es2017/core/segment_sinks/inventory/types.d.ts +27 -0
  973. package/dist/es2017/core/segment_sinks/inventory/utils.d.ts +33 -0
  974. package/dist/es2017/core/segment_sinks/inventory/utils.js +48 -0
  975. package/dist/es2017/core/segment_sinks/segment_buffers_store.d.ts +171 -0
  976. package/dist/es2017/core/segment_sinks/segment_buffers_store.js +281 -0
  977. package/dist/es2017/core/stream/adaptation/adaptation_stream.d.ts +4 -4
  978. package/dist/es2017/core/stream/adaptation/adaptation_stream.js +43 -32
  979. package/dist/es2017/core/stream/adaptation/get_representations_switch_strategy.d.ts +11 -11
  980. package/dist/es2017/core/stream/adaptation/get_representations_switch_strategy.js +31 -32
  981. package/dist/es2017/core/stream/adaptation/types.d.ts +18 -18
  982. package/dist/es2017/core/stream/index.d.ts +1 -1
  983. package/dist/es2017/core/stream/orchestrator/get_time_ranges_for_content.d.ts +5 -5
  984. package/dist/es2017/core/stream/orchestrator/get_time_ranges_for_content.js +6 -6
  985. package/dist/es2017/core/stream/orchestrator/stream_orchestrator.d.ts +20 -19
  986. package/dist/es2017/core/stream/orchestrator/stream_orchestrator.js +68 -57
  987. package/dist/es2017/core/stream/period/period_stream.d.ts +5 -5
  988. package/dist/es2017/core/stream/period/period_stream.js +78 -58
  989. package/dist/es2017/core/stream/period/types.d.ts +23 -21
  990. package/dist/es2017/core/stream/period/utils/get_adaptation_switch_strategy.d.ts +13 -13
  991. package/dist/es2017/core/stream/period/utils/get_adaptation_switch_strategy.js +34 -38
  992. package/dist/es2017/core/stream/representation/representation_stream.d.ts +5 -5
  993. package/dist/es2017/core/stream/representation/representation_stream.js +48 -35
  994. package/dist/es2017/core/stream/representation/types.d.ts +24 -24
  995. package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.d.ts +9 -9
  996. package/dist/es2017/core/stream/representation/utils/append_segment_to_buffer.js +13 -14
  997. package/dist/es2017/core/stream/representation/utils/check_for_discontinuity.d.ts +7 -7
  998. package/dist/es2017/core/stream/representation/utils/check_for_discontinuity.js +16 -18
  999. package/dist/es2017/core/stream/representation/utils/downloading_queue.d.ts +10 -10
  1000. package/dist/es2017/core/stream/representation/utils/downloading_queue.js +11 -11
  1001. package/dist/es2017/core/stream/representation/utils/get_buffer_status.d.ts +11 -11
  1002. package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +40 -31
  1003. package/dist/es2017/core/stream/representation/utils/get_needed_segments.d.ts +6 -7
  1004. package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +26 -31
  1005. package/dist/es2017/core/stream/representation/utils/push_init_segment.d.ts +13 -13
  1006. package/dist/es2017/core/stream/representation/utils/push_init_segment.js +8 -9
  1007. package/dist/es2017/core/stream/representation/utils/push_media_segment.d.ts +14 -14
  1008. package/dist/es2017/core/stream/representation/utils/push_media_segment.js +14 -15
  1009. package/dist/es2017/core/types.d.ts +8 -0
  1010. package/dist/es2017/default_config.js +21 -18
  1011. package/dist/es2017/errors/encrypted_media_error.d.ts +2 -2
  1012. package/dist/es2017/errors/encrypted_media_error.js +5 -3
  1013. package/dist/es2017/errors/error_codes.d.ts +3 -3
  1014. package/dist/es2017/errors/error_codes.js +2 -1
  1015. package/dist/es2017/errors/format_error.d.ts +2 -2
  1016. package/dist/es2017/errors/format_error.js +2 -3
  1017. package/dist/es2017/errors/is_known_error.d.ts +1 -1
  1018. package/dist/es2017/errors/is_known_error.js +2 -2
  1019. package/dist/es2017/errors/media_error.d.ts +2 -2
  1020. package/dist/es2017/errors/media_error.js +5 -3
  1021. package/dist/es2017/errors/network_error.d.ts +2 -2
  1022. package/dist/es2017/errors/network_error.js +7 -5
  1023. package/dist/es2017/errors/other_error.d.ts +1 -1
  1024. package/dist/es2017/errors/other_error.js +2 -4
  1025. package/dist/es2017/errors/source_buffer_error.js +4 -2
  1026. package/dist/es2017/experimental/features/local.d.ts +1 -1
  1027. package/dist/es2017/experimental/features/local.js +1 -2
  1028. package/dist/es2017/experimental/features/metaplaylist.d.ts +1 -1
  1029. package/dist/es2017/experimental/features/metaplaylist.js +1 -2
  1030. package/dist/es2017/experimental/features/multi_thread.d.ts +1 -1
  1031. package/dist/es2017/experimental/features/multi_thread.js +1 -2
  1032. package/dist/es2017/experimental/index.d.ts +1 -1
  1033. package/dist/es2017/experimental/index.js +1 -1
  1034. package/dist/es2017/experimental/tools/VideoThumbnailLoader/features/dash.d.ts +1 -1
  1035. package/dist/es2017/experimental/tools/VideoThumbnailLoader/features/metaplaylist.d.ts +1 -1
  1036. package/dist/es2017/experimental/tools/VideoThumbnailLoader/index.d.ts +1 -1
  1037. package/dist/es2017/experimental/tools/VideoThumbnailLoader/index.js +2 -2
  1038. package/dist/es2017/experimental/tools/VideoThumbnailLoader/load_and_push_segment.d.ts +3 -3
  1039. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts +2 -2
  1040. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +5 -5
  1041. package/dist/es2017/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.d.ts +1 -1
  1042. package/dist/es2017/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.js +2 -2
  1043. package/dist/es2017/experimental/tools/VideoThumbnailLoader/types.d.ts +6 -6
  1044. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.d.ts +3 -3
  1045. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +14 -22
  1046. package/dist/es2017/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +13 -23
  1047. package/dist/es2017/experimental/tools/createMetaplaylist/index.d.ts +1 -1
  1048. package/dist/es2017/experimental/tools/createMetaplaylist/index.js +8 -14
  1049. package/dist/es2017/experimental/tools/index.d.ts +1 -1
  1050. package/dist/es2017/experimental/tools/index.js +1 -1
  1051. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/api/index.d.ts +1 -1
  1052. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/api/index.js +9 -13
  1053. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.d.ts +4 -3
  1054. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/api/probeMediaConfiguration.js +7 -4
  1055. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/capabilities.d.ts +1 -1
  1056. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/capabilities.js +10 -47
  1057. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.d.ts +2 -1
  1058. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +9 -6
  1059. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.d.ts +2 -1
  1060. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +22 -14
  1061. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.d.ts +2 -1
  1062. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.js +22 -18
  1063. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +10 -10
  1064. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/index.d.ts +1 -1
  1065. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts +2 -1
  1066. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +6 -7
  1067. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/format.d.ts +1 -1
  1068. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/format.js +6 -11
  1069. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.d.ts +2 -1
  1070. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.js +2 -3
  1071. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.d.ts +2 -1
  1072. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +4 -4
  1073. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/types.d.ts +2 -2
  1074. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/utils.d.ts +1 -1
  1075. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/utils.js +8 -7
  1076. package/dist/es2017/features/add_features.d.ts +1 -1
  1077. package/dist/es2017/features/features_object.d.ts +1 -1
  1078. package/dist/es2017/features/features_object.js +4 -3
  1079. package/dist/es2017/features/index.d.ts +1 -1
  1080. package/dist/es2017/features/index.js +1 -1
  1081. package/dist/es2017/features/list/dash.d.ts +1 -1
  1082. package/dist/es2017/features/list/dash.js +3 -4
  1083. package/dist/es2017/features/list/dash_wasm.d.ts +2 -2
  1084. package/dist/es2017/features/list/dash_wasm.js +1 -2
  1085. package/dist/es2017/features/list/debug_element.d.ts +1 -1
  1086. package/dist/es2017/features/list/debug_element.js +1 -1
  1087. package/dist/es2017/features/list/directfile.d.ts +1 -1
  1088. package/dist/es2017/features/list/directfile.js +3 -5
  1089. package/dist/es2017/features/list/eme.d.ts +1 -1
  1090. package/dist/es2017/features/list/eme.js +1 -1
  1091. package/dist/es2017/features/list/html_sami_parser.d.ts +1 -1
  1092. package/dist/es2017/features/list/html_sami_parser.js +1 -1
  1093. package/dist/es2017/features/list/html_srt_parser.d.ts +1 -1
  1094. package/dist/es2017/features/list/html_srt_parser.js +1 -1
  1095. package/dist/es2017/features/list/html_text_buffer.d.ts +1 -1
  1096. package/dist/es2017/features/list/html_text_buffer.js +1 -1
  1097. package/dist/es2017/features/list/html_ttml_parser.d.ts +1 -1
  1098. package/dist/es2017/features/list/html_ttml_parser.js +1 -1
  1099. package/dist/es2017/features/list/html_vtt_parser.d.ts +1 -1
  1100. package/dist/es2017/features/list/html_vtt_parser.js +1 -1
  1101. package/dist/es2017/features/list/media_source_main.d.ts +1 -1
  1102. package/dist/es2017/features/list/media_source_main.js +1 -2
  1103. package/dist/es2017/features/list/native_sami_parser.d.ts +1 -1
  1104. package/dist/es2017/features/list/native_sami_parser.js +1 -1
  1105. package/dist/es2017/features/list/native_srt_parser.d.ts +1 -1
  1106. package/dist/es2017/features/list/native_srt_parser.js +1 -1
  1107. package/dist/es2017/features/list/native_text_buffer.d.ts +1 -1
  1108. package/dist/es2017/features/list/native_text_buffer.js +1 -1
  1109. package/dist/es2017/features/list/native_ttml_parser.d.ts +1 -1
  1110. package/dist/es2017/features/list/native_ttml_parser.js +1 -1
  1111. package/dist/es2017/features/list/native_vtt_parser.d.ts +1 -1
  1112. package/dist/es2017/features/list/native_vtt_parser.js +1 -1
  1113. package/dist/es2017/features/list/smooth.d.ts +1 -1
  1114. package/dist/es2017/features/list/smooth.js +1 -2
  1115. package/dist/es2017/features/types.d.ts +28 -23
  1116. package/dist/es2017/index.d.ts +1 -1
  1117. package/dist/es2017/index.js +3 -1
  1118. package/dist/es2017/main_thread/api/debug/buffer_graph.d.ts +28 -0
  1119. package/dist/es2017/main_thread/api/debug/buffer_graph.js +164 -0
  1120. package/dist/es2017/main_thread/api/debug/buffer_size_graph.js +102 -0
  1121. package/dist/es2017/main_thread/api/debug/modules/general_info.d.ts +3 -0
  1122. package/dist/es2017/main_thread/api/debug/modules/general_info.js +192 -0
  1123. package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.d.ts +4 -0
  1124. package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.js +124 -0
  1125. package/dist/es2017/main_thread/api/debug/modules/segment_buffer_size.d.ts +3 -0
  1126. package/dist/es2017/main_thread/api/debug/modules/segment_buffer_size.js +35 -0
  1127. package/dist/es2017/main_thread/api/debug/render.d.ts +3 -0
  1128. package/dist/es2017/main_thread/api/debug/render.js +32 -0
  1129. package/dist/es2017/main_thread/api/debug/utils.js +54 -0
  1130. package/dist/es2017/main_thread/api/index.d.ts +17 -0
  1131. package/dist/es2017/main_thread/api/index.js +17 -0
  1132. package/dist/es2017/main_thread/api/option_utils.d.ts +124 -0
  1133. package/dist/es2017/main_thread/api/option_utils.js +308 -0
  1134. package/dist/es2017/main_thread/api/public_api.d.ts +768 -0
  1135. package/dist/es2017/main_thread/api/public_api.js +2386 -0
  1136. package/dist/es2017/main_thread/api/utils.d.ts +66 -0
  1137. package/dist/es2017/main_thread/api/utils.js +170 -0
  1138. package/dist/es2017/main_thread/decrypt/__tests__/__global__/utils.d.ts +184 -0
  1139. package/dist/es2017/main_thread/decrypt/__tests__/__global__/utils.js +378 -0
  1140. package/dist/es2017/main_thread/decrypt/attach_media_keys.d.ts +53 -0
  1141. package/dist/es2017/main_thread/decrypt/attach_media_keys.js +72 -0
  1142. package/dist/es2017/main_thread/decrypt/clear_on_stop.js +40 -0
  1143. package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts +185 -0
  1144. package/dist/es2017/main_thread/decrypt/content_decryptor.js +799 -0
  1145. package/dist/es2017/main_thread/decrypt/create_or_load_session.d.ts +64 -0
  1146. package/dist/es2017/main_thread/decrypt/create_or_load_session.js +83 -0
  1147. package/dist/es2017/main_thread/decrypt/create_session.d.ts +54 -0
  1148. package/dist/es2017/main_thread/decrypt/create_session.js +150 -0
  1149. package/dist/es2017/main_thread/decrypt/dispose_decryption_resources.js +34 -0
  1150. package/dist/es2017/main_thread/decrypt/find_key_system.d.ts +48 -0
  1151. package/dist/es2017/main_thread/decrypt/find_key_system.js +287 -0
  1152. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts +44 -0
  1153. package/dist/es2017/main_thread/decrypt/get_media_keys.js +103 -0
  1154. package/dist/es2017/main_thread/decrypt/index.d.ts +26 -0
  1155. package/dist/es2017/main_thread/decrypt/index.js +26 -0
  1156. package/dist/es2017/main_thread/decrypt/init_media_keys.d.ts +26 -0
  1157. package/dist/es2017/main_thread/decrypt/init_media_keys.js +37 -0
  1158. package/dist/es2017/main_thread/decrypt/session_events_listener.d.ts +75 -0
  1159. package/dist/es2017/main_thread/decrypt/session_events_listener.js +246 -0
  1160. package/dist/es2017/main_thread/decrypt/set_server_certificate.d.ts +51 -0
  1161. package/dist/es2017/main_thread/decrypt/set_server_certificate.js +82 -0
  1162. package/dist/es2017/main_thread/decrypt/types.d.ts +374 -0
  1163. package/dist/es2017/main_thread/decrypt/utils/are_init_values_compatible.js +141 -0
  1164. package/dist/es2017/main_thread/decrypt/utils/check_key_statuses.d.ts +52 -0
  1165. package/dist/es2017/main_thread/decrypt/utils/check_key_statuses.js +163 -0
  1166. package/dist/es2017/main_thread/decrypt/utils/clean_old_loaded_sessions.d.ts +26 -0
  1167. package/dist/es2017/main_thread/decrypt/utils/clean_old_stored_persistent_info.d.ts +32 -0
  1168. package/dist/es2017/main_thread/decrypt/utils/init_data_values_container.d.ts +69 -0
  1169. package/dist/es2017/main_thread/decrypt/utils/init_data_values_container.js +105 -0
  1170. package/dist/es2017/main_thread/decrypt/utils/is_session_usable.d.ts +24 -0
  1171. package/dist/es2017/main_thread/decrypt/utils/is_session_usable.js +48 -0
  1172. package/dist/es2017/main_thread/decrypt/utils/key_id_comparison.js +48 -0
  1173. package/dist/es2017/main_thread/decrypt/utils/key_session_record.d.ts +104 -0
  1174. package/dist/es2017/main_thread/decrypt/utils/key_session_record.js +152 -0
  1175. package/dist/es2017/main_thread/decrypt/utils/loaded_sessions_store.d.ts +213 -0
  1176. package/dist/es2017/main_thread/decrypt/utils/loaded_sessions_store.js +365 -0
  1177. package/dist/es2017/main_thread/decrypt/utils/media_keys_infos_store.d.ts +56 -0
  1178. package/dist/es2017/main_thread/decrypt/utils/media_keys_infos_store.js +43 -0
  1179. package/dist/es2017/main_thread/decrypt/utils/persistent_sessions_store.d.ts +94 -0
  1180. package/dist/es2017/main_thread/decrypt/utils/persistent_sessions_store.js +325 -0
  1181. package/dist/es2017/main_thread/decrypt/utils/serializable_bytes.d.ts +44 -0
  1182. package/dist/es2017/main_thread/decrypt/utils/serializable_bytes.js +46 -0
  1183. package/dist/es2017/main_thread/decrypt/utils/server_certificate_store.d.ts +64 -0
  1184. package/dist/es2017/main_thread/decrypt/utils/server_certificate_store.js +121 -0
  1185. package/dist/es2017/main_thread/init/directfile_content_initializer.d.ts +97 -0
  1186. package/dist/es2017/main_thread/init/directfile_content_initializer.js +233 -0
  1187. package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts +166 -0
  1188. package/dist/es2017/main_thread/init/media_source_content_initializer.js +712 -0
  1189. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts +222 -0
  1190. package/dist/es2017/main_thread/init/multi_thread_content_initializer.js +1394 -0
  1191. package/dist/es2017/main_thread/init/send_message.d.ts +2 -0
  1192. package/dist/es2017/main_thread/init/send_message.js +10 -0
  1193. package/dist/es2017/main_thread/init/types.d.ts +221 -0
  1194. package/dist/es2017/main_thread/init/utils/create_core_playback_observer.d.ts +83 -0
  1195. package/dist/es2017/main_thread/init/utils/create_core_playback_observer.js +98 -0
  1196. package/dist/es2017/main_thread/init/utils/create_media_source.d.ts +37 -0
  1197. package/dist/es2017/main_thread/init/utils/create_media_source.js +101 -0
  1198. package/dist/es2017/main_thread/init/utils/get_initial_time.d.ts +76 -0
  1199. package/dist/es2017/main_thread/init/utils/get_initial_time.js +106 -0
  1200. package/dist/es2017/main_thread/init/utils/get_loaded_reference.d.ts +28 -0
  1201. package/dist/es2017/main_thread/init/utils/get_loaded_reference.js +64 -0
  1202. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.d.ts +61 -0
  1203. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.js +200 -0
  1204. package/dist/es2017/main_thread/init/utils/initialize_content_decryption.d.ts +87 -0
  1205. package/dist/es2017/main_thread/init/utils/initialize_content_decryption.js +116 -0
  1206. package/dist/es2017/main_thread/init/utils/main_thread_text_displayer_interface.d.ts +35 -0
  1207. package/dist/es2017/main_thread/init/utils/rebuffering_controller.d.ts +114 -0
  1208. package/dist/es2017/main_thread/init/utils/rebuffering_controller.js +426 -0
  1209. package/dist/es2017/main_thread/init/utils/stream_events_emitter/are_same_stream_events.js +33 -0
  1210. package/dist/es2017/main_thread/init/utils/stream_events_emitter/index.d.ts +18 -0
  1211. package/dist/es2017/main_thread/init/utils/stream_events_emitter/refresh_scheduled_events_list.d.ts +25 -0
  1212. package/dist/es2017/main_thread/init/utils/stream_events_emitter/refresh_scheduled_events_list.js +84 -0
  1213. package/dist/es2017/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts +53 -0
  1214. package/dist/es2017/main_thread/init/utils/stream_events_emitter/stream_events_emitter.js +175 -0
  1215. package/dist/es2017/main_thread/init/utils/stream_events_emitter/types.d.ts +41 -0
  1216. package/dist/es2017/main_thread/init/utils/throw_on_media_error.d.ts +23 -0
  1217. package/dist/es2017/main_thread/init/utils/throw_on_media_error.js +63 -0
  1218. package/dist/es2017/main_thread/text_displayer/html/html_parsers.js +22 -0
  1219. package/dist/es2017/main_thread/text_displayer/html/html_text_displayer.d.ts +100 -0
  1220. package/dist/es2017/main_thread/text_displayer/html/html_text_displayer.js +312 -0
  1221. package/dist/es2017/main_thread/text_displayer/html/text_track_cues_store.d.ts +65 -0
  1222. package/dist/es2017/main_thread/text_displayer/html/text_track_cues_store.js +358 -0
  1223. package/dist/es2017/main_thread/text_displayer/html/update_proportional_elements.js +61 -0
  1224. package/dist/es2017/main_thread/text_displayer/html/utils.js +111 -0
  1225. package/dist/es2017/main_thread/text_displayer/index.d.ts +2 -0
  1226. package/dist/es2017/main_thread/text_displayer/manual_time_ranges.js +48 -0
  1227. package/dist/es2017/main_thread/text_displayer/native/native_parsers.d.ts +11 -0
  1228. package/dist/es2017/main_thread/text_displayer/native/native_parsers.js +22 -0
  1229. package/dist/es2017/main_thread/text_displayer/native/native_text_displayer.d.ts +56 -0
  1230. package/dist/es2017/main_thread/text_displayer/native/native_text_displayer.js +203 -0
  1231. package/dist/es2017/main_thread/text_displayer/types.d.ts +71 -0
  1232. package/dist/es2017/main_thread/text_displayer/types.js +1 -0
  1233. package/dist/es2017/main_thread/tracks_store/index.d.ts +20 -0
  1234. package/dist/es2017/main_thread/tracks_store/media_element_tracks_store.d.ts +197 -0
  1235. package/dist/es2017/main_thread/tracks_store/media_element_tracks_store.js +663 -0
  1236. package/dist/es2017/main_thread/tracks_store/track_dispatcher.d.ts +101 -0
  1237. package/dist/es2017/main_thread/tracks_store/track_dispatcher.js +175 -0
  1238. package/dist/es2017/main_thread/tracks_store/tracks_store.d.ts +448 -0
  1239. package/dist/es2017/main_thread/tracks_store/tracks_store.js +998 -0
  1240. package/dist/es2017/main_thread/types.d.ts +5 -0
  1241. package/dist/es2017/main_thread/types.js +1 -0
  1242. package/dist/es2017/manifest/classes/adaptation.d.ts +134 -0
  1243. package/dist/es2017/manifest/classes/adaptation.js +193 -0
  1244. package/dist/es2017/manifest/classes/index.d.ts +25 -0
  1245. package/dist/es2017/manifest/classes/index.js +28 -0
  1246. package/dist/es2017/manifest/classes/manifest.d.ts +391 -0
  1247. package/dist/es2017/manifest/classes/manifest.js +381 -0
  1248. package/dist/es2017/manifest/classes/period.d.ts +106 -0
  1249. package/dist/es2017/manifest/classes/period.js +194 -0
  1250. package/dist/es2017/manifest/classes/representation.d.ts +238 -0
  1251. package/dist/es2017/manifest/classes/representation.js +346 -0
  1252. package/dist/es2017/manifest/classes/representation_index/index.d.ts +18 -0
  1253. package/dist/es2017/manifest/classes/representation_index/static.d.ts +101 -0
  1254. package/dist/es2017/manifest/classes/representation_index/static.js +143 -0
  1255. package/dist/es2017/manifest/classes/representation_index/types.d.ts +420 -0
  1256. package/dist/es2017/manifest/classes/types.d.ts +29 -0
  1257. package/dist/es2017/manifest/classes/types.js +30 -0
  1258. package/dist/es2017/manifest/classes/update_period_in_place.d.ts +53 -0
  1259. package/dist/es2017/manifest/classes/update_period_in_place.js +109 -0
  1260. package/dist/es2017/manifest/classes/update_periods.d.ts +50 -0
  1261. package/dist/es2017/manifest/classes/update_periods.js +193 -0
  1262. package/dist/es2017/manifest/classes/utils.d.ts +39 -0
  1263. package/dist/es2017/manifest/classes/utils.js +49 -0
  1264. package/dist/es2017/manifest/index.d.ts +15 -25
  1265. package/dist/es2017/manifest/index.js +3 -28
  1266. package/dist/es2017/manifest/types.d.ts +2 -31
  1267. package/dist/es2017/manifest/types.js +1 -15
  1268. package/dist/es2017/manifest/utils.d.ts +11 -49
  1269. package/dist/es2017/manifest/utils.js +46 -88
  1270. package/dist/es2017/minimal.d.ts +1 -1
  1271. package/dist/es2017/minimal.js +6 -1
  1272. package/dist/es2017/mse/main_codec_support_prober.d.ts +1 -1
  1273. package/dist/es2017/mse/main_media_source_interface.d.ts +2 -2
  1274. package/dist/es2017/mse/main_media_source_interface.js +61 -36
  1275. package/dist/es2017/mse/types.d.ts +3 -3
  1276. package/dist/es2017/mse/utils/end_of_stream.d.ts +33 -0
  1277. package/dist/es2017/mse/utils/end_of_stream.js +87 -0
  1278. package/dist/es2017/mse/utils/media_source_duration_updater.js +265 -0
  1279. package/dist/es2017/mse/worker_codec_support_prober.d.ts +1 -1
  1280. package/dist/es2017/mse/worker_media_source_interface.d.ts +4 -4
  1281. package/dist/es2017/mse/worker_media_source_interface.js +21 -19
  1282. package/dist/es2017/multithread_types.d.ts +15 -18
  1283. package/dist/es2017/parsers/containers/isobmff/create_box.d.ts +1 -1
  1284. package/dist/es2017/parsers/containers/isobmff/create_box.js +6 -5
  1285. package/dist/es2017/parsers/containers/isobmff/drm/playready.js +2 -3
  1286. package/dist/es2017/parsers/containers/isobmff/extract_complete_chunks.js +67 -0
  1287. package/dist/es2017/parsers/containers/isobmff/find_complete_box.js +54 -0
  1288. package/dist/es2017/parsers/containers/isobmff/get_box.js +3 -5
  1289. package/dist/es2017/parsers/containers/isobmff/index.d.ts +5 -3
  1290. package/dist/es2017/parsers/containers/isobmff/index.js +6 -4
  1291. package/dist/es2017/parsers/containers/isobmff/read.d.ts +1 -1
  1292. package/dist/es2017/parsers/containers/isobmff/read.js +9 -9
  1293. package/dist/es2017/parsers/containers/isobmff/take_pssh_out.js +4 -5
  1294. package/dist/es2017/parsers/containers/isobmff/utils.js +60 -45
  1295. package/dist/es2017/parsers/containers/matroska/index.d.ts +1 -1
  1296. package/dist/es2017/parsers/containers/matroska/index.js +1 -1
  1297. package/dist/es2017/parsers/containers/matroska/utils.js +42 -29
  1298. package/dist/es2017/parsers/images/bif.js +10 -6
  1299. package/dist/es2017/parsers/manifest/dash/common/attach_trickmode_track.d.ts +1 -1
  1300. package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.js +1 -3
  1301. package/dist/es2017/parsers/manifest/dash/common/flatten_overlapping_periods.d.ts +1 -1
  1302. package/dist/es2017/parsers/manifest/dash/common/flatten_overlapping_periods.js +1 -1
  1303. package/dist/es2017/parsers/manifest/dash/common/get_hdr_information.js +4 -12
  1304. package/dist/es2017/parsers/manifest/dash/common/get_http_utc-timing_url.d.ts +1 -1
  1305. package/dist/es2017/parsers/manifest/dash/common/get_http_utc-timing_url.js +4 -5
  1306. package/dist/es2017/parsers/manifest/dash/common/get_minimum_and_maximum_positions.d.ts +1 -1
  1307. package/dist/es2017/parsers/manifest/dash/common/get_minimum_and_maximum_positions.js +4 -2
  1308. package/dist/es2017/parsers/manifest/dash/common/get_periods_time_infos.d.ts +1 -1
  1309. package/dist/es2017/parsers/manifest/dash/common/get_periods_time_infos.js +15 -13
  1310. package/dist/es2017/parsers/manifest/dash/common/index.d.ts +1 -1
  1311. package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +5 -5
  1312. package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +36 -31
  1313. package/dist/es2017/parsers/manifest/dash/common/indexes/get_init_segment.d.ts +2 -2
  1314. package/dist/es2017/parsers/manifest/dash/common/indexes/get_init_segment.js +6 -4
  1315. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.d.ts +4 -4
  1316. package/dist/es2017/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +10 -10
  1317. package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +2 -2
  1318. package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +23 -20
  1319. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +3 -3
  1320. package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +54 -59
  1321. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.d.ts +5 -4
  1322. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +14 -11
  1323. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.d.ts +3 -2
  1324. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.js +25 -20
  1325. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/convert_element_to_index_segment.d.ts +1 -1
  1326. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/convert_element_to_index_segment.js +15 -10
  1327. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.d.ts +4 -3
  1328. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.js +43 -27
  1329. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/parse_s_element.d.ts +11 -2
  1330. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/parse_s_element.js +49 -2
  1331. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +9 -8
  1332. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +77 -69
  1333. package/dist/es2017/parsers/manifest/dash/common/indexes/tokens.js +2 -4
  1334. package/dist/es2017/parsers/manifest/dash/common/infer_adaptation_type.d.ts +1 -1
  1335. package/dist/es2017/parsers/manifest/dash/common/infer_adaptation_type.js +2 -2
  1336. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +9 -10
  1337. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.d.ts +5 -5
  1338. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +61 -66
  1339. package/dist/es2017/parsers/manifest/dash/common/parse_availability_start_time.d.ts +3 -2
  1340. package/dist/es2017/parsers/manifest/dash/common/parse_availability_start_time.js +5 -3
  1341. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.d.ts +6 -6
  1342. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +54 -42
  1343. package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts +5 -5
  1344. package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +33 -34
  1345. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.d.ts +5 -5
  1346. package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +5 -7
  1347. package/dist/es2017/parsers/manifest/dash/common/parse_representations.d.ts +5 -5
  1348. package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +63 -68
  1349. package/dist/es2017/parsers/manifest/dash/common/resolve_base_urls.d.ts +1 -1
  1350. package/dist/es2017/parsers/manifest/dash/common/resolve_base_urls.js +5 -3
  1351. package/dist/es2017/parsers/manifest/dash/fast-js-parser/index.d.ts +17 -0
  1352. package/dist/es2017/parsers/manifest/dash/fast-js-parser/index.js +17 -0
  1353. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.d.ts +24 -0
  1354. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.js +358 -0
  1355. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.d.ts +24 -0
  1356. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.js +30 -0
  1357. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.d.ts +23 -0
  1358. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.js +45 -0
  1359. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.d.ts +22 -0
  1360. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.js +77 -0
  1361. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.d.ts +23 -0
  1362. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.js +101 -0
  1363. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.d.ts +22 -0
  1364. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.js +45 -0
  1365. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.d.ts +23 -0
  1366. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.js +179 -0
  1367. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Period.d.ts +23 -0
  1368. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Period.js +137 -0
  1369. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.d.ts +22 -0
  1370. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +214 -0
  1371. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.d.ts +23 -0
  1372. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.js +111 -0
  1373. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.d.ts +22 -0
  1374. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.js +41 -0
  1375. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.d.ts +24 -0
  1376. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.js +84 -0
  1377. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.d.ts +22 -0
  1378. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.js +33 -0
  1379. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.d.ts +24 -0
  1380. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.js +57 -0
  1381. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts +176 -0
  1382. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.js +310 -0
  1383. package/dist/es2017/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.d.ts +24 -0
  1384. package/dist/es2017/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.js +114 -0
  1385. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/AdaptationSet.d.ts +23 -0
  1386. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/AdaptationSet.js +354 -0
  1387. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/BaseURL.d.ts +23 -0
  1388. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/BaseURL.js +29 -0
  1389. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/ContentComponent.d.ts +22 -0
  1390. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/ContentProtection.d.ts +21 -0
  1391. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/EventStream.d.ts +23 -0
  1392. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/EventStream.js +100 -0
  1393. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/Initialization.d.ts +21 -0
  1394. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/Initialization.js +41 -0
  1395. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/MPD.d.ts +21 -0
  1396. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/MPD.js +161 -0
  1397. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/Period.d.ts +21 -0
  1398. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/Period.js +118 -0
  1399. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/Representation.d.ts +21 -0
  1400. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/Representation.js +210 -0
  1401. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/SegmentBase.d.ts +22 -0
  1402. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/SegmentBase.js +107 -0
  1403. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/SegmentList.d.ts +21 -0
  1404. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/SegmentTemplate.d.ts +23 -0
  1405. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/SegmentTemplate.js +83 -0
  1406. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/SegmentTimeline.d.ts +21 -0
  1407. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/SegmentURL.d.ts +23 -0
  1408. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/SegmentURL.js +53 -0
  1409. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/utils.d.ts +169 -0
  1410. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/utils.js +297 -0
  1411. package/dist/es2017/parsers/manifest/dash/native-parser/parse_from_document.d.ts +24 -0
  1412. package/dist/es2017/parsers/manifest/dash/native-parser/parse_from_document.js +108 -0
  1413. package/dist/es2017/parsers/manifest/dash/node_parser_types.d.ts +5 -3
  1414. package/dist/es2017/parsers/manifest/dash/parsers_types.d.ts +1 -1
  1415. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.d.ts +1 -1
  1416. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +29 -18
  1417. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.d.ts +3 -2
  1418. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +22 -26
  1419. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.d.ts +2 -2
  1420. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.d.ts +3 -3
  1421. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.js +1 -1
  1422. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.d.ts +3 -3
  1423. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.js +4 -2
  1424. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/EventStream.d.ts +3 -2
  1425. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/EventStream.js +2 -4
  1426. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/MPD.d.ts +3 -2
  1427. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/MPD.js +5 -5
  1428. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Period.d.ts +3 -2
  1429. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Period.js +9 -6
  1430. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Representation.d.ts +3 -2
  1431. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +13 -15
  1432. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.d.ts +3 -3
  1433. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.js +1 -1
  1434. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.d.ts +2 -2
  1435. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.js +5 -10
  1436. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/SegmentList.d.ts +3 -2
  1437. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.d.ts +2 -2
  1438. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.js +11 -18
  1439. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/SegmentUrl.d.ts +2 -2
  1440. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/SegmentUrl.js +2 -4
  1441. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/XLink.d.ts +3 -2
  1442. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/XLink.js +5 -5
  1443. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/root.d.ts +2 -2
  1444. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/root.js +8 -4
  1445. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/parsers_stack.js +4 -2
  1446. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/utils.d.ts +1 -1
  1447. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/utils.js +8 -4
  1448. package/dist/es2017/parsers/manifest/local/parse_local_manifest.d.ts +2 -2
  1449. package/dist/es2017/parsers/manifest/local/parse_local_manifest.js +21 -16
  1450. package/dist/es2017/parsers/manifest/local/representation_index.d.ts +2 -2
  1451. package/dist/es2017/parsers/manifest/local/representation_index.js +7 -7
  1452. package/dist/es2017/parsers/manifest/metaplaylist/index.d.ts +1 -1
  1453. package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.d.ts +4 -4
  1454. package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +41 -43
  1455. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +3 -3
  1456. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +10 -7
  1457. package/dist/es2017/parsers/manifest/smooth/create_parser.d.ts +2 -2
  1458. package/dist/es2017/parsers/manifest/smooth/create_parser.js +120 -121
  1459. package/dist/es2017/parsers/manifest/smooth/get_codecs.js +3 -3
  1460. package/dist/es2017/parsers/manifest/smooth/index.d.ts +1 -1
  1461. package/dist/es2017/parsers/manifest/smooth/index.js +1 -1
  1462. package/dist/es2017/parsers/manifest/smooth/parse_C_nodes.js +9 -9
  1463. package/dist/es2017/parsers/manifest/smooth/parse_protection_node.js +12 -8
  1464. package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +3 -3
  1465. package/dist/es2017/parsers/manifest/smooth/representation_index.js +35 -38
  1466. package/dist/es2017/parsers/manifest/smooth/shared_smooth_segment_timeline.d.ts +1 -1
  1467. package/dist/es2017/parsers/manifest/smooth/shared_smooth_segment_timeline.js +8 -9
  1468. package/dist/es2017/parsers/manifest/smooth/utils/add_segment_infos.js +10 -7
  1469. package/dist/es2017/parsers/manifest/smooth/utils/parseBoolean.d.ts +1 -1
  1470. package/dist/es2017/parsers/manifest/smooth/utils/parseBoolean.js +1 -1
  1471. package/dist/es2017/parsers/manifest/smooth/utils/tokens.d.ts +1 -1
  1472. package/dist/es2017/parsers/manifest/smooth/utils/tokens.js +2 -3
  1473. package/dist/es2017/parsers/manifest/types.d.ts +2 -2
  1474. package/dist/es2017/parsers/manifest/utils/check_manifest_ids.d.ts +1 -1
  1475. package/dist/es2017/parsers/manifest/utils/check_manifest_ids.js +2 -2
  1476. package/dist/es2017/parsers/manifest/utils/clear_timeline_from_position.d.ts +3 -2
  1477. package/dist/es2017/parsers/manifest/utils/clear_timeline_from_position.js +11 -7
  1478. package/dist/es2017/parsers/manifest/utils/get_first_time_from_adaptation.d.ts +1 -1
  1479. package/dist/es2017/parsers/manifest/utils/get_first_time_from_adaptation.js +5 -4
  1480. package/dist/es2017/parsers/manifest/utils/get_last_time_from_adaptation.d.ts +1 -1
  1481. package/dist/es2017/parsers/manifest/utils/get_last_time_from_adaptation.js +5 -4
  1482. package/dist/es2017/parsers/manifest/utils/get_maximum_positions.d.ts +2 -2
  1483. package/dist/es2017/parsers/manifest/utils/get_maximum_positions.js +11 -17
  1484. package/dist/es2017/parsers/manifest/utils/get_minimum_position.d.ts +2 -2
  1485. package/dist/es2017/parsers/manifest/utils/get_minimum_position.js +5 -11
  1486. package/dist/es2017/parsers/manifest/utils/index_helpers.js +4 -5
  1487. package/dist/es2017/parsers/manifest/utils/update_segment_timeline.d.ts +1 -1
  1488. package/dist/es2017/parsers/manifest/utils/update_segment_timeline.js +17 -16
  1489. package/dist/es2017/parsers/texttracks/index.d.ts +1 -1
  1490. package/dist/es2017/parsers/texttracks/sami/html.d.ts +1 -1
  1491. package/dist/es2017/parsers/texttracks/sami/html.js +17 -16
  1492. package/dist/es2017/parsers/texttracks/sami/native.d.ts +1 -1
  1493. package/dist/es2017/parsers/texttracks/sami/native.js +11 -17
  1494. package/dist/es2017/parsers/texttracks/srt/html.js +12 -10
  1495. package/dist/es2017/parsers/texttracks/srt/native.d.ts +1 -1
  1496. package/dist/es2017/parsers/texttracks/srt/native.js +1 -7
  1497. package/dist/es2017/parsers/texttracks/srt/parse_cue.js +4 -9
  1498. package/dist/es2017/parsers/texttracks/ttml/get_parameters.js +8 -13
  1499. package/dist/es2017/parsers/texttracks/ttml/get_time_delimiters.d.ts +1 -1
  1500. package/dist/es2017/parsers/texttracks/ttml/get_time_delimiters.js +9 -10
  1501. package/dist/es2017/parsers/texttracks/ttml/html/apply_default_ttml_paragraph_style.js +2 -2
  1502. package/dist/es2017/parsers/texttracks/ttml/html/apply_extent.js +3 -7
  1503. package/dist/es2017/parsers/texttracks/ttml/html/apply_font_size.js +4 -5
  1504. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +1 -1
  1505. package/dist/es2017/parsers/texttracks/ttml/html/apply_origin.js +3 -7
  1506. package/dist/es2017/parsers/texttracks/ttml/html/apply_padding.js +3 -7
  1507. package/dist/es2017/parsers/texttracks/ttml/html/create_element.d.ts +2 -2
  1508. package/dist/es2017/parsers/texttracks/ttml/html/create_element.js +30 -23
  1509. package/dist/es2017/parsers/texttracks/ttml/html/generate_css_test_outline.js +2 -2
  1510. package/dist/es2017/parsers/texttracks/ttml/html/parse_cue.d.ts +1 -1
  1511. package/dist/es2017/parsers/texttracks/ttml/html/parse_cue.js +5 -4
  1512. package/dist/es2017/parsers/texttracks/ttml/html/parse_ttml_to_div.d.ts +1 -1
  1513. package/dist/es2017/parsers/texttracks/ttml/html/ttml_color_to_css_color.js +39 -23
  1514. package/dist/es2017/parsers/texttracks/ttml/native/parse_cue.d.ts +2 -2
  1515. package/dist/es2017/parsers/texttracks/ttml/native/parse_cue.js +14 -13
  1516. package/dist/es2017/parsers/texttracks/ttml/native/parse_ttml_to_vtt.d.ts +1 -1
  1517. package/dist/es2017/parsers/texttracks/ttml/parse_ttml.d.ts +3 -3
  1518. package/dist/es2017/parsers/texttracks/ttml/parse_ttml.js +22 -19
  1519. package/dist/es2017/parsers/texttracks/ttml/resolve_styles_inheritance.d.ts +1 -1
  1520. package/dist/es2017/parsers/texttracks/ttml/time_parsing.d.ts +1 -1
  1521. package/dist/es2017/parsers/texttracks/ttml/time_parsing.js +2 -2
  1522. package/dist/es2017/parsers/texttracks/ttml/xml_utils.js +2 -1
  1523. package/dist/es2017/parsers/texttracks/types.d.ts +1 -1
  1524. package/dist/es2017/parsers/texttracks/webvtt/get_cue_blocks.js +1 -1
  1525. package/dist/es2017/parsers/texttracks/webvtt/get_style_blocks.js +2 -1
  1526. package/dist/es2017/parsers/texttracks/webvtt/html/convert_payload_to_html.d.ts +1 -1
  1527. package/dist/es2017/parsers/texttracks/webvtt/html/create_default_style_elements.d.ts +1 -1
  1528. package/dist/es2017/parsers/texttracks/webvtt/html/create_style_attribute.js +6 -12
  1529. package/dist/es2017/parsers/texttracks/webvtt/html/create_styled_element.d.ts +1 -1
  1530. package/dist/es2017/parsers/texttracks/webvtt/html/create_styled_element.js +8 -9
  1531. package/dist/es2017/parsers/texttracks/webvtt/html/parse_style_block.js +4 -4
  1532. package/dist/es2017/parsers/texttracks/webvtt/html/parse_webvtt_to_div.d.ts +1 -1
  1533. package/dist/es2017/parsers/texttracks/webvtt/html/parse_webvtt_to_div.js +1 -1
  1534. package/dist/es2017/parsers/texttracks/webvtt/html/to_html.d.ts +1 -1
  1535. package/dist/es2017/parsers/texttracks/webvtt/html/to_html.js +5 -13
  1536. package/dist/es2017/parsers/texttracks/webvtt/native/parse_vtt_to_cues.d.ts +1 -1
  1537. package/dist/es2017/parsers/texttracks/webvtt/native/parse_vtt_to_cues.js +4 -8
  1538. package/dist/es2017/parsers/texttracks/webvtt/native/set_settings_on_cue.d.ts +1 -1
  1539. package/dist/es2017/parsers/texttracks/webvtt/native/to_native_cue.d.ts +2 -2
  1540. package/dist/es2017/parsers/texttracks/webvtt/native/to_native_cue.js +2 -2
  1541. package/dist/es2017/parsers/texttracks/webvtt/parse_cue_block.js +7 -8
  1542. package/dist/es2017/parsers/texttracks/webvtt/parse_timestamp.js +1 -2
  1543. package/dist/es2017/parsers/texttracks/webvtt/utils.js +6 -6
  1544. package/dist/es2017/playback_observer/index.d.ts +6 -0
  1545. package/dist/es2017/playback_observer/index.js +2 -0
  1546. package/dist/es2017/playback_observer/media_element_playback_observer.d.ts +203 -0
  1547. package/dist/es2017/playback_observer/media_element_playback_observer.js +678 -0
  1548. package/dist/es2017/playback_observer/types.d.ts +223 -0
  1549. package/dist/es2017/playback_observer/types.js +1 -0
  1550. package/dist/es2017/playback_observer/utils/generate_read_only_observer.d.ts +11 -0
  1551. package/dist/es2017/playback_observer/utils/generate_read_only_observer.js +41 -0
  1552. package/dist/es2017/playback_observer/utils/observation_position.d.ts +87 -0
  1553. package/dist/es2017/playback_observer/utils/observation_position.js +84 -0
  1554. package/dist/es2017/playback_observer/worker_playback_observer.d.ts +72 -0
  1555. package/dist/es2017/playback_observer/worker_playback_observer.js +45 -0
  1556. package/dist/es2017/public_types.d.ts +13 -16
  1557. package/dist/es2017/public_types.js +0 -1
  1558. package/dist/es2017/tools/TextTrackRenderer/text_track_renderer.d.ts +2 -2
  1559. package/dist/es2017/tools/TextTrackRenderer/text_track_renderer.js +11 -9
  1560. package/dist/es2017/tools/index.d.ts +1 -1
  1561. package/dist/es2017/tools/index.js +1 -1
  1562. package/dist/es2017/tools/parseBIFThumbnails/index.js +6 -5
  1563. package/dist/es2017/transports/dash/add_segment_integrity_checks_to_loader.d.ts +1 -1
  1564. package/dist/es2017/transports/dash/add_segment_integrity_checks_to_loader.js +2 -3
  1565. package/dist/es2017/transports/dash/construct_segment_url.d.ts +2 -2
  1566. package/dist/es2017/transports/dash/construct_segment_url.js +7 -3
  1567. package/dist/es2017/transports/dash/get_events_out_of_emsgs.d.ts +2 -2
  1568. package/dist/es2017/transports/dash/get_events_out_of_emsgs.js +12 -10
  1569. package/dist/es2017/transports/dash/init_segment_loader.d.ts +3 -3
  1570. package/dist/es2017/transports/dash/init_segment_loader.js +29 -23
  1571. package/dist/es2017/transports/dash/low_latency_segment_loader.d.ts +2 -2
  1572. package/dist/es2017/transports/dash/low_latency_segment_loader.js +14 -11
  1573. package/dist/es2017/transports/dash/manifest_parser.d.ts +2 -2
  1574. package/dist/es2017/transports/dash/manifest_parser.js +68 -32
  1575. package/dist/es2017/transports/dash/pipelines.d.ts +1 -1
  1576. package/dist/es2017/transports/dash/pipelines.js +15 -12
  1577. package/dist/es2017/transports/dash/segment_loader.d.ts +4 -4
  1578. package/dist/es2017/transports/dash/segment_loader.js +31 -23
  1579. package/dist/es2017/transports/dash/segment_parser.d.ts +2 -2
  1580. package/dist/es2017/transports/dash/segment_parser.js +40 -25
  1581. package/dist/es2017/transports/dash/text_loader.d.ts +2 -2
  1582. package/dist/es2017/transports/dash/text_loader.js +19 -20
  1583. package/dist/es2017/transports/dash/text_parser.d.ts +2 -2
  1584. package/dist/es2017/transports/dash/text_parser.js +44 -26
  1585. package/dist/es2017/transports/index.d.ts +1 -1
  1586. package/dist/es2017/transports/index.js +1 -1
  1587. package/dist/es2017/transports/local/pipelines.d.ts +1 -1
  1588. package/dist/es2017/transports/local/pipelines.js +14 -9
  1589. package/dist/es2017/transports/local/segment_loader.d.ts +3 -3
  1590. package/dist/es2017/transports/local/segment_loader.js +14 -6
  1591. package/dist/es2017/transports/local/segment_parser.d.ts +1 -1
  1592. package/dist/es2017/transports/local/segment_parser.js +24 -14
  1593. package/dist/es2017/transports/local/text_parser.d.ts +1 -1
  1594. package/dist/es2017/transports/local/text_parser.js +36 -18
  1595. package/dist/es2017/transports/metaplaylist/manifest_loader.d.ts +4 -4
  1596. package/dist/es2017/transports/metaplaylist/manifest_loader.js +8 -6
  1597. package/dist/es2017/transports/metaplaylist/pipelines.d.ts +1 -1
  1598. package/dist/es2017/transports/metaplaylist/pipelines.js +35 -24
  1599. package/dist/es2017/transports/smooth/extract_timings_infos.d.ts +2 -2
  1600. package/dist/es2017/transports/smooth/extract_timings_infos.js +17 -19
  1601. package/dist/es2017/transports/smooth/is_mp4_embedded_track.d.ts +1 -1
  1602. package/dist/es2017/transports/smooth/is_mp4_embedded_track.js +1 -1
  1603. package/dist/es2017/transports/smooth/isobmff/create_audio_init_segment.d.ts +0 -1
  1604. package/dist/es2017/transports/smooth/isobmff/create_audio_init_segment.js +3 -4
  1605. package/dist/es2017/transports/smooth/isobmff/create_boxes.js +23 -32
  1606. package/dist/es2017/transports/smooth/isobmff/create_init_segment.js +2 -2
  1607. package/dist/es2017/transports/smooth/isobmff/create_traf_box.js +2 -2
  1608. package/dist/es2017/transports/smooth/isobmff/get_aaces_header.js +4 -16
  1609. package/dist/es2017/transports/smooth/isobmff/parse_tfrf.js +2 -2
  1610. package/dist/es2017/transports/smooth/isobmff/parse_tfxd.js +1 -1
  1611. package/dist/es2017/transports/smooth/isobmff/patch_segment.js +12 -11
  1612. package/dist/es2017/transports/smooth/pipelines.d.ts +1 -1
  1613. package/dist/es2017/transports/smooth/pipelines.js +84 -61
  1614. package/dist/es2017/transports/smooth/segment_loader.d.ts +3 -3
  1615. package/dist/es2017/transports/smooth/segment_loader.js +44 -29
  1616. package/dist/es2017/transports/smooth/utils.d.ts +4 -4
  1617. package/dist/es2017/transports/smooth/utils.js +10 -6
  1618. package/dist/es2017/transports/types.d.ts +22 -27
  1619. package/dist/es2017/transports/utils/byte_range.js +1 -2
  1620. package/dist/es2017/transports/utils/call_custom_manifest_loader.d.ts +3 -3
  1621. package/dist/es2017/transports/utils/call_custom_manifest_loader.js +10 -8
  1622. package/dist/es2017/transports/utils/check_isobmff_integrity.js +4 -4
  1623. package/dist/es2017/transports/utils/generate_manifest_loader.d.ts +3 -3
  1624. package/dist/es2017/transports/utils/generate_manifest_loader.js +12 -6
  1625. package/dist/es2017/transports/utils/get_isobmff_timing_infos.d.ts +2 -2
  1626. package/dist/es2017/transports/utils/get_isobmff_timing_infos.js +12 -11
  1627. package/dist/es2017/transports/utils/infer_segment_container.d.ts +1 -1
  1628. package/dist/es2017/transports/utils/infer_segment_container.js +1 -3
  1629. package/dist/es2017/transports/utils/parse_text_track.d.ts +4 -4
  1630. package/dist/es2017/transports/utils/parse_text_track.js +6 -16
  1631. package/dist/es2017/utils/array_includes.js +2 -6
  1632. package/dist/es2017/utils/assert.js +3 -6
  1633. package/dist/es2017/utils/base64.js +87 -29
  1634. package/dist/es2017/utils/byte_parsing.js +64 -56
  1635. package/dist/es2017/utils/cancellable_sleep.d.ts +1 -1
  1636. package/dist/es2017/utils/create_cancellable_promise.d.ts +1 -1
  1637. package/dist/es2017/utils/deep_merge.js +4 -4
  1638. package/dist/es2017/utils/event_emitter.d.ts +1 -1
  1639. package/dist/es2017/utils/event_emitter.js +1 -2
  1640. package/dist/es2017/utils/get_fuzzed_delay.js +1 -1
  1641. package/dist/es2017/utils/global_scope.d.ts +1 -1
  1642. package/dist/es2017/utils/global_scope.js +10 -3
  1643. package/dist/es2017/utils/hash_buffer.js +1 -1
  1644. package/dist/es2017/utils/languages/normalize.js +5 -5
  1645. package/dist/es2017/utils/logger.js +12 -22
  1646. package/dist/es2017/utils/monotonic_timestamp.d.ts +6 -9
  1647. package/dist/es2017/utils/monotonic_timestamp.js +13 -5
  1648. package/dist/es2017/utils/object_assign.d.ts +6 -3
  1649. package/dist/es2017/utils/object_assign.js +5 -7
  1650. package/dist/es2017/utils/object_values.d.ts +1 -1
  1651. package/dist/es2017/utils/object_values.js +4 -4
  1652. package/dist/es2017/utils/queue_microtask.js +3 -3
  1653. package/dist/es2017/utils/ranges.js +22 -29
  1654. package/dist/es2017/utils/reference.d.ts +1 -1
  1655. package/dist/es2017/utils/reference.js +1 -3
  1656. package/dist/es2017/utils/request/fetch.d.ts +1 -1
  1657. package/dist/es2017/utils/request/fetch.js +24 -23
  1658. package/dist/es2017/utils/request/request_error.js +2 -2
  1659. package/dist/es2017/utils/request/xhr.d.ts +1 -1
  1660. package/dist/es2017/utils/request/xhr.js +19 -17
  1661. package/dist/es2017/utils/retry_promise_with_backoff.d.ts +10 -1
  1662. package/dist/es2017/utils/retry_promise_with_backoff.js +15 -3
  1663. package/dist/es2017/utils/slice_uint8array.js +3 -3
  1664. package/dist/es2017/utils/starts_with.js +3 -3
  1665. package/dist/es2017/utils/string_parsing.js +16 -18
  1666. package/dist/es2017/utils/sync_or_async.js +6 -2
  1667. package/dist/es2017/utils/task_canceller.js +1 -2
  1668. package/dist/es2017/utils/wrapInPromise.d.ts +1 -1
  1669. package/dist/es2017/utils/xml-parser.d.ts +70 -0
  1670. package/dist/es2017/utils/xml-parser.js +322 -0
  1671. package/dist/es2017/worker_entry_point.js +2 -2
  1672. package/dist/mpd-parser.wasm +0 -0
  1673. package/dist/rx-player.js +46203 -45666
  1674. package/dist/rx-player.min.js +1 -1
  1675. package/dist/worker.es5.js +2 -0
  1676. package/dist/worker.es5.js.LICENSE.txt +1 -0
  1677. package/dist/worker.js +8 -3
  1678. package/package.json +20 -10
  1679. package/dist/commonjs/compat/index.d.ts +0 -36
  1680. package/dist/commonjs/compat/index.js +0 -64
  1681. package/dist/commonjs/core/api/debug/buffer_graph.d.ts +0 -28
  1682. package/dist/commonjs/core/api/debug/buffer_graph.js +0 -173
  1683. package/dist/commonjs/core/api/debug/buffer_size_graph.js +0 -132
  1684. package/dist/commonjs/core/api/debug/modules/general_info.d.ts +0 -3
  1685. package/dist/commonjs/core/api/debug/modules/general_info.js +0 -232
  1686. package/dist/commonjs/core/api/debug/modules/segment_buffer_content.d.ts +0 -4
  1687. package/dist/commonjs/core/api/debug/modules/segment_buffer_content.js +0 -125
  1688. package/dist/commonjs/core/api/debug/modules/segment_buffer_size.d.ts +0 -3
  1689. package/dist/commonjs/core/api/debug/modules/segment_buffer_size.js +0 -38
  1690. package/dist/commonjs/core/api/debug/render.d.ts +0 -3
  1691. package/dist/commonjs/core/api/index.d.ts +0 -20
  1692. package/dist/commonjs/core/api/index.js +0 -22
  1693. package/dist/commonjs/core/api/option_utils.d.ts +0 -124
  1694. package/dist/commonjs/core/api/option_utils.js +0 -318
  1695. package/dist/commonjs/core/api/playback_observer.d.ts +0 -521
  1696. package/dist/commonjs/core/api/playback_observer.js +0 -771
  1697. package/dist/commonjs/core/api/public_api.d.ts +0 -751
  1698. package/dist/commonjs/core/api/public_api.js +0 -2458
  1699. package/dist/commonjs/core/api/track_management/index.d.ts +0 -18
  1700. package/dist/commonjs/core/api/track_management/media_element_tracks_store.d.ts +0 -197
  1701. package/dist/commonjs/core/api/track_management/media_element_tracks_store.js +0 -688
  1702. package/dist/commonjs/core/api/track_management/track_dispatcher.d.ts +0 -100
  1703. package/dist/commonjs/core/api/track_management/track_dispatcher.js +0 -184
  1704. package/dist/commonjs/core/api/track_management/tracks_store.d.ts +0 -441
  1705. package/dist/commonjs/core/api/track_management/tracks_store.js +0 -1066
  1706. package/dist/commonjs/core/api/utils.d.ts +0 -66
  1707. package/dist/commonjs/core/api/utils.js +0 -175
  1708. package/dist/commonjs/core/decrypt/__tests__/__global__/utils.d.ts +0 -178
  1709. package/dist/commonjs/core/decrypt/__tests__/__global__/utils.js +0 -413
  1710. package/dist/commonjs/core/decrypt/attach_media_keys.d.ts +0 -53
  1711. package/dist/commonjs/core/decrypt/attach_media_keys.js +0 -121
  1712. package/dist/commonjs/core/decrypt/clear_on_stop.js +0 -43
  1713. package/dist/commonjs/core/decrypt/content_decryptor.d.ts +0 -184
  1714. package/dist/commonjs/core/decrypt/content_decryptor.js +0 -1035
  1715. package/dist/commonjs/core/decrypt/create_or_load_session.d.ts +0 -63
  1716. package/dist/commonjs/core/decrypt/create_or_load_session.js +0 -127
  1717. package/dist/commonjs/core/decrypt/create_session.d.ts +0 -53
  1718. package/dist/commonjs/core/decrypt/create_session.js +0 -215
  1719. package/dist/commonjs/core/decrypt/dispose_decryption_resources.js +0 -91
  1720. package/dist/commonjs/core/decrypt/find_key_system.d.ts +0 -48
  1721. package/dist/commonjs/core/decrypt/find_key_system.js +0 -369
  1722. package/dist/commonjs/core/decrypt/get_media_keys.d.ts +0 -44
  1723. package/dist/commonjs/core/decrypt/get_media_keys.js +0 -156
  1724. package/dist/commonjs/core/decrypt/index.d.ts +0 -26
  1725. package/dist/commonjs/core/decrypt/init_media_keys.d.ts +0 -26
  1726. package/dist/commonjs/core/decrypt/init_media_keys.js +0 -93
  1727. package/dist/commonjs/core/decrypt/session_events_listener.d.ts +0 -75
  1728. package/dist/commonjs/core/decrypt/session_events_listener.js +0 -330
  1729. package/dist/commonjs/core/decrypt/set_server_certificate.d.ts +0 -51
  1730. package/dist/commonjs/core/decrypt/set_server_certificate.js +0 -146
  1731. package/dist/commonjs/core/decrypt/types.d.ts +0 -374
  1732. package/dist/commonjs/core/decrypt/utils/are_init_values_compatible.js +0 -116
  1733. package/dist/commonjs/core/decrypt/utils/check_key_statuses.d.ts +0 -52
  1734. package/dist/commonjs/core/decrypt/utils/check_key_statuses.js +0 -211
  1735. package/dist/commonjs/core/decrypt/utils/clean_old_loaded_sessions.d.ts +0 -26
  1736. package/dist/commonjs/core/decrypt/utils/clean_old_stored_persistent_info.d.ts +0 -32
  1737. package/dist/commonjs/core/decrypt/utils/init_data_values_container.d.ts +0 -69
  1738. package/dist/commonjs/core/decrypt/utils/init_data_values_container.js +0 -126
  1739. package/dist/commonjs/core/decrypt/utils/is_session_usable.d.ts +0 -24
  1740. package/dist/commonjs/core/decrypt/utils/is_session_usable.js +0 -52
  1741. package/dist/commonjs/core/decrypt/utils/key_session_record.d.ts +0 -104
  1742. package/dist/commonjs/core/decrypt/utils/key_session_record.js +0 -190
  1743. package/dist/commonjs/core/decrypt/utils/loaded_sessions_store.d.ts +0 -215
  1744. package/dist/commonjs/core/decrypt/utils/loaded_sessions_store.js +0 -515
  1745. package/dist/commonjs/core/decrypt/utils/media_keys_infos_store.d.ts +0 -56
  1746. package/dist/commonjs/core/decrypt/utils/media_keys_infos_store.js +0 -46
  1747. package/dist/commonjs/core/decrypt/utils/persistent_sessions_store.d.ts +0 -94
  1748. package/dist/commonjs/core/decrypt/utils/persistent_sessions_store.js +0 -346
  1749. package/dist/commonjs/core/decrypt/utils/serializable_bytes.d.ts +0 -44
  1750. package/dist/commonjs/core/decrypt/utils/serializable_bytes.js +0 -50
  1751. package/dist/commonjs/core/decrypt/utils/server_certificate_store.d.ts +0 -64
  1752. package/dist/commonjs/core/decrypt/utils/server_certificate_store.js +0 -114
  1753. package/dist/commonjs/core/init/directfile_content_initializer.d.ts +0 -97
  1754. package/dist/commonjs/core/init/directfile_content_initializer.js +0 -267
  1755. package/dist/commonjs/core/init/media_source_content_initializer.d.ts +0 -165
  1756. package/dist/commonjs/core/init/media_source_content_initializer.js +0 -865
  1757. package/dist/commonjs/core/init/multithread/main_thread/multi_thread_content_initializer.d.ts +0 -167
  1758. package/dist/commonjs/core/init/multithread/main_thread/multi_thread_content_initializer.js +0 -1393
  1759. package/dist/commonjs/core/init/multithread/main_thread/send_message.d.ts +0 -2
  1760. package/dist/commonjs/core/init/multithread/main_thread/send_message.js +0 -13
  1761. package/dist/commonjs/core/init/multithread/worker/content_preparer.d.ts +0 -92
  1762. package/dist/commonjs/core/init/multithread/worker/content_preparer.js +0 -259
  1763. package/dist/commonjs/core/init/multithread/worker/globals.d.ts +0 -13
  1764. package/dist/commonjs/core/init/multithread/worker/globals.js +0 -26
  1765. package/dist/commonjs/core/init/multithread/worker/index.d.ts +0 -2
  1766. package/dist/commonjs/core/init/multithread/worker/index.js +0 -4
  1767. package/dist/commonjs/core/init/multithread/worker/send_message.d.ts +0 -3
  1768. package/dist/commonjs/core/init/multithread/worker/send_message.js +0 -25
  1769. package/dist/commonjs/core/init/multithread/worker/track_choice_setter.d.ts +0 -19
  1770. package/dist/commonjs/core/init/multithread/worker/track_choice_setter.js +0 -140
  1771. package/dist/commonjs/core/init/multithread/worker/worker_playback_observer.d.ts +0 -21
  1772. package/dist/commonjs/core/init/multithread/worker/worker_playback_observer.js +0 -47
  1773. package/dist/commonjs/core/init/multithread/worker/worker_portal.d.ts +0 -1
  1774. package/dist/commonjs/core/init/multithread/worker/worker_portal.js +0 -727
  1775. package/dist/commonjs/core/init/multithread/worker/worker_text_displayer_interface.d.ts +0 -64
  1776. package/dist/commonjs/core/init/multithread/worker/worker_text_displayer_interface.js +0 -127
  1777. package/dist/commonjs/core/init/types.d.ts +0 -226
  1778. package/dist/commonjs/core/init/utils/DecipherabilityFreezeDetector.d.ts +0 -54
  1779. package/dist/commonjs/core/init/utils/DecipherabilityFreezeDetector.js +0 -129
  1780. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.d.ts +0 -192
  1781. package/dist/commonjs/core/init/utils/content_time_boundaries_observer.js +0 -518
  1782. package/dist/commonjs/core/init/utils/create_content_time_boundaries_observer.d.ts +0 -28
  1783. package/dist/commonjs/core/init/utils/create_content_time_boundaries_observer.js +0 -48
  1784. package/dist/commonjs/core/init/utils/create_core_playback_observer.d.ts +0 -61
  1785. package/dist/commonjs/core/init/utils/create_core_playback_observer.js +0 -130
  1786. package/dist/commonjs/core/init/utils/create_media_source.d.ts +0 -37
  1787. package/dist/commonjs/core/init/utils/create_media_source.js +0 -108
  1788. package/dist/commonjs/core/init/utils/end_of_stream.d.ts +0 -33
  1789. package/dist/commonjs/core/init/utils/end_of_stream.js +0 -115
  1790. package/dist/commonjs/core/init/utils/get_initial_time.d.ts +0 -76
  1791. package/dist/commonjs/core/init/utils/get_initial_time.js +0 -116
  1792. package/dist/commonjs/core/init/utils/get_loaded_reference.d.ts +0 -28
  1793. package/dist/commonjs/core/init/utils/get_loaded_reference.js +0 -61
  1794. package/dist/commonjs/core/init/utils/initial_seek_and_play.d.ts +0 -61
  1795. package/dist/commonjs/core/init/utils/initial_seek_and_play.js +0 -210
  1796. package/dist/commonjs/core/init/utils/initialize_content_decryption.d.ts +0 -86
  1797. package/dist/commonjs/core/init/utils/initialize_content_decryption.js +0 -113
  1798. package/dist/commonjs/core/init/utils/main_thread_text_displayer_interface.d.ts +0 -35
  1799. package/dist/commonjs/core/init/utils/media_source_duration_updater.js +0 -270
  1800. package/dist/commonjs/core/init/utils/rebuffering_controller.d.ts +0 -114
  1801. package/dist/commonjs/core/init/utils/rebuffering_controller.js +0 -445
  1802. package/dist/commonjs/core/init/utils/stream_events_emitter/are_same_stream_events.js +0 -37
  1803. package/dist/commonjs/core/init/utils/stream_events_emitter/index.d.ts +0 -18
  1804. package/dist/commonjs/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.d.ts +0 -25
  1805. package/dist/commonjs/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.js +0 -91
  1806. package/dist/commonjs/core/init/utils/stream_events_emitter/stream_events_emitter.d.ts +0 -53
  1807. package/dist/commonjs/core/init/utils/stream_events_emitter/stream_events_emitter.js +0 -234
  1808. package/dist/commonjs/core/init/utils/stream_events_emitter/types.d.ts +0 -41
  1809. package/dist/commonjs/core/init/utils/throw_on_media_error.d.ts +0 -23
  1810. package/dist/commonjs/core/init/utils/throw_on_media_error.js +0 -61
  1811. package/dist/commonjs/core/segment_buffers/garbage_collector.d.ts +0 -43
  1812. package/dist/commonjs/core/segment_buffers/garbage_collector.js +0 -220
  1813. package/dist/commonjs/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.d.ts +0 -134
  1814. package/dist/commonjs/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +0 -350
  1815. package/dist/commonjs/core/segment_buffers/implementations/audio_video/index.d.ts +0 -17
  1816. package/dist/commonjs/core/segment_buffers/implementations/index.d.ts +0 -19
  1817. package/dist/commonjs/core/segment_buffers/implementations/index.js +0 -35
  1818. package/dist/commonjs/core/segment_buffers/implementations/text/index.d.ts +0 -3
  1819. package/dist/commonjs/core/segment_buffers/implementations/text/text_segment_buffer.d.ts +0 -89
  1820. package/dist/commonjs/core/segment_buffers/implementations/text/text_segment_buffer.js +0 -253
  1821. package/dist/commonjs/core/segment_buffers/implementations/types.d.ts +0 -309
  1822. package/dist/commonjs/core/segment_buffers/implementations/types.js +0 -117
  1823. package/dist/commonjs/core/segment_buffers/index.d.ts +0 -21
  1824. package/dist/commonjs/core/segment_buffers/index.js +0 -28
  1825. package/dist/commonjs/core/segment_buffers/inventory/buffered_history.d.ts +0 -89
  1826. package/dist/commonjs/core/segment_buffers/inventory/index.d.ts +0 -21
  1827. package/dist/commonjs/core/segment_buffers/inventory/segment_inventory.d.ts +0 -238
  1828. package/dist/commonjs/core/segment_buffers/inventory/segment_inventory.js +0 -906
  1829. package/dist/commonjs/core/segment_buffers/inventory/types.d.ts +0 -27
  1830. package/dist/commonjs/core/segment_buffers/inventory/utils.d.ts +0 -33
  1831. package/dist/commonjs/core/segment_buffers/inventory/utils.js +0 -54
  1832. package/dist/commonjs/core/segment_buffers/segment_buffers_store.d.ts +0 -171
  1833. package/dist/commonjs/core/segment_buffers/segment_buffers_store.js +0 -292
  1834. package/dist/commonjs/manifest/adaptation.d.ts +0 -135
  1835. package/dist/commonjs/manifest/adaptation.js +0 -242
  1836. package/dist/commonjs/manifest/manifest.d.ts +0 -388
  1837. package/dist/commonjs/manifest/manifest.js +0 -496
  1838. package/dist/commonjs/manifest/period.d.ts +0 -106
  1839. package/dist/commonjs/manifest/period.js +0 -236
  1840. package/dist/commonjs/manifest/representation.d.ts +0 -238
  1841. package/dist/commonjs/manifest/representation.js +0 -376
  1842. package/dist/commonjs/manifest/representation_index/index.d.ts +0 -18
  1843. package/dist/commonjs/manifest/representation_index/static.d.ts +0 -101
  1844. package/dist/commonjs/manifest/representation_index/static.js +0 -143
  1845. package/dist/commonjs/manifest/representation_index/types.d.ts +0 -420
  1846. package/dist/commonjs/manifest/update_period_in_place.d.ts +0 -52
  1847. package/dist/commonjs/manifest/update_period_in_place.js +0 -172
  1848. package/dist/commonjs/manifest/update_periods.d.ts +0 -50
  1849. package/dist/commonjs/manifest/update_periods.js +0 -228
  1850. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.d.ts +0 -23
  1851. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +0 -331
  1852. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/BaseURL.d.ts +0 -23
  1853. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/BaseURL.js +0 -33
  1854. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/ContentComponent.d.ts +0 -22
  1855. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/ContentProtection.d.ts +0 -21
  1856. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/EventStream.d.ts +0 -23
  1857. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/EventStream.js +0 -113
  1858. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/Initialization.d.ts +0 -21
  1859. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/Initialization.js +0 -42
  1860. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/MPD.d.ts +0 -21
  1861. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/MPD.js +0 -164
  1862. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/Period.d.ts +0 -21
  1863. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/Period.js +0 -132
  1864. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/Representation.d.ts +0 -21
  1865. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/Representation.js +0 -209
  1866. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/SegmentBase.d.ts +0 -22
  1867. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/SegmentBase.js +0 -108
  1868. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/SegmentList.d.ts +0 -21
  1869. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/SegmentTemplate.d.ts +0 -23
  1870. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/SegmentTemplate.js +0 -92
  1871. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/SegmentTimeline.d.ts +0 -21
  1872. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/SegmentURL.d.ts +0 -23
  1873. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/SegmentURL.js +0 -52
  1874. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/utils.d.ts +0 -187
  1875. package/dist/commonjs/parsers/manifest/dash/js-parser/node_parsers/utils.js +0 -354
  1876. package/dist/commonjs/parsers/manifest/dash/js-parser/parse_from_document.d.ts +0 -24
  1877. package/dist/commonjs/parsers/manifest/dash/js-parser/parse_from_document.js +0 -131
  1878. package/dist/commonjs/text_displayer/html/html_parsers.js +0 -25
  1879. package/dist/commonjs/text_displayer/html/html_text_displayer.d.ts +0 -100
  1880. package/dist/commonjs/text_displayer/html/html_text_displayer.js +0 -317
  1881. package/dist/commonjs/text_displayer/html/text_track_cues_store.d.ts +0 -65
  1882. package/dist/commonjs/text_displayer/html/text_track_cues_store.js +0 -378
  1883. package/dist/commonjs/text_displayer/html/update_proportional_elements.js +0 -65
  1884. package/dist/commonjs/text_displayer/html/utils.js +0 -115
  1885. package/dist/commonjs/text_displayer/index.d.ts +0 -2
  1886. package/dist/commonjs/text_displayer/manual_time_ranges.js +0 -52
  1887. package/dist/commonjs/text_displayer/native/native_parsers.d.ts +0 -11
  1888. package/dist/commonjs/text_displayer/native/native_parsers.js +0 -25
  1889. package/dist/commonjs/text_displayer/native/native_text_displayer.d.ts +0 -56
  1890. package/dist/commonjs/text_displayer/native/native_text_displayer.js +0 -207
  1891. package/dist/commonjs/text_displayer/types.d.ts +0 -74
  1892. package/dist/commonjs/transports/dash/extract_complete_chunks.js +0 -91
  1893. package/dist/commonjs/transports/utils/find_complete_box.js +0 -56
  1894. package/dist/es2017/compat/index.d.ts +0 -36
  1895. package/dist/es2017/compat/index.js +0 -42
  1896. package/dist/es2017/core/api/debug/buffer_graph.d.ts +0 -28
  1897. package/dist/es2017/core/api/debug/buffer_graph.js +0 -169
  1898. package/dist/es2017/core/api/debug/buffer_size_graph.js +0 -103
  1899. package/dist/es2017/core/api/debug/modules/general_info.d.ts +0 -3
  1900. package/dist/es2017/core/api/debug/modules/general_info.js +0 -188
  1901. package/dist/es2017/core/api/debug/modules/segment_buffer_content.d.ts +0 -4
  1902. package/dist/es2017/core/api/debug/modules/segment_buffer_content.js +0 -122
  1903. package/dist/es2017/core/api/debug/modules/segment_buffer_size.d.ts +0 -3
  1904. package/dist/es2017/core/api/debug/modules/segment_buffer_size.js +0 -35
  1905. package/dist/es2017/core/api/debug/render.d.ts +0 -3
  1906. package/dist/es2017/core/api/debug/render.js +0 -32
  1907. package/dist/es2017/core/api/debug/utils.js +0 -54
  1908. package/dist/es2017/core/api/index.d.ts +0 -20
  1909. package/dist/es2017/core/api/index.js +0 -19
  1910. package/dist/es2017/core/api/option_utils.d.ts +0 -124
  1911. package/dist/es2017/core/api/option_utils.js +0 -315
  1912. package/dist/es2017/core/api/playback_observer.d.ts +0 -521
  1913. package/dist/es2017/core/api/playback_observer.js +0 -770
  1914. package/dist/es2017/core/api/public_api.d.ts +0 -751
  1915. package/dist/es2017/core/api/public_api.js +0 -2346
  1916. package/dist/es2017/core/api/track_management/index.d.ts +0 -18
  1917. package/dist/es2017/core/api/track_management/media_element_tracks_store.d.ts +0 -197
  1918. package/dist/es2017/core/api/track_management/media_element_tracks_store.js +0 -669
  1919. package/dist/es2017/core/api/track_management/track_dispatcher.d.ts +0 -100
  1920. package/dist/es2017/core/api/track_management/track_dispatcher.js +0 -166
  1921. package/dist/es2017/core/api/track_management/tracks_store.d.ts +0 -441
  1922. package/dist/es2017/core/api/track_management/tracks_store.js +0 -981
  1923. package/dist/es2017/core/api/utils.d.ts +0 -66
  1924. package/dist/es2017/core/api/utils.js +0 -167
  1925. package/dist/es2017/core/decrypt/__tests__/__global__/utils.d.ts +0 -178
  1926. package/dist/es2017/core/decrypt/__tests__/__global__/utils.js +0 -363
  1927. package/dist/es2017/core/decrypt/attach_media_keys.d.ts +0 -53
  1928. package/dist/es2017/core/decrypt/attach_media_keys.js +0 -72
  1929. package/dist/es2017/core/decrypt/clear_on_stop.js +0 -40
  1930. package/dist/es2017/core/decrypt/content_decryptor.d.ts +0 -184
  1931. package/dist/es2017/core/decrypt/content_decryptor.js +0 -792
  1932. package/dist/es2017/core/decrypt/create_or_load_session.d.ts +0 -63
  1933. package/dist/es2017/core/decrypt/create_or_load_session.js +0 -75
  1934. package/dist/es2017/core/decrypt/create_session.d.ts +0 -53
  1935. package/dist/es2017/core/decrypt/create_session.js +0 -150
  1936. package/dist/es2017/core/decrypt/dispose_decryption_resources.js +0 -42
  1937. package/dist/es2017/core/decrypt/find_key_system.d.ts +0 -48
  1938. package/dist/es2017/core/decrypt/find_key_system.js +0 -281
  1939. package/dist/es2017/core/decrypt/get_media_keys.d.ts +0 -44
  1940. package/dist/es2017/core/decrypt/get_media_keys.js +0 -100
  1941. package/dist/es2017/core/decrypt/index.d.ts +0 -26
  1942. package/dist/es2017/core/decrypt/index.js +0 -26
  1943. package/dist/es2017/core/decrypt/init_media_keys.d.ts +0 -26
  1944. package/dist/es2017/core/decrypt/init_media_keys.js +0 -47
  1945. package/dist/es2017/core/decrypt/session_events_listener.d.ts +0 -75
  1946. package/dist/es2017/core/decrypt/session_events_listener.js +0 -249
  1947. package/dist/es2017/core/decrypt/set_server_certificate.d.ts +0 -51
  1948. package/dist/es2017/core/decrypt/set_server_certificate.js +0 -83
  1949. package/dist/es2017/core/decrypt/types.d.ts +0 -374
  1950. package/dist/es2017/core/decrypt/utils/are_init_values_compatible.js +0 -113
  1951. package/dist/es2017/core/decrypt/utils/check_key_statuses.d.ts +0 -52
  1952. package/dist/es2017/core/decrypt/utils/check_key_statuses.js +0 -165
  1953. package/dist/es2017/core/decrypt/utils/clean_old_loaded_sessions.d.ts +0 -26
  1954. package/dist/es2017/core/decrypt/utils/clean_old_stored_persistent_info.d.ts +0 -32
  1955. package/dist/es2017/core/decrypt/utils/init_data_values_container.d.ts +0 -69
  1956. package/dist/es2017/core/decrypt/utils/init_data_values_container.js +0 -96
  1957. package/dist/es2017/core/decrypt/utils/is_session_usable.d.ts +0 -24
  1958. package/dist/es2017/core/decrypt/utils/is_session_usable.js +0 -49
  1959. package/dist/es2017/core/decrypt/utils/key_id_comparison.js +0 -48
  1960. package/dist/es2017/core/decrypt/utils/key_session_record.d.ts +0 -104
  1961. package/dist/es2017/core/decrypt/utils/key_session_record.js +0 -153
  1962. package/dist/es2017/core/decrypt/utils/loaded_sessions_store.d.ts +0 -215
  1963. package/dist/es2017/core/decrypt/utils/loaded_sessions_store.js +0 -365
  1964. package/dist/es2017/core/decrypt/utils/media_keys_infos_store.d.ts +0 -56
  1965. package/dist/es2017/core/decrypt/utils/media_keys_infos_store.js +0 -44
  1966. package/dist/es2017/core/decrypt/utils/persistent_sessions_store.d.ts +0 -94
  1967. package/dist/es2017/core/decrypt/utils/persistent_sessions_store.js +0 -321
  1968. package/dist/es2017/core/decrypt/utils/serializable_bytes.d.ts +0 -44
  1969. package/dist/es2017/core/decrypt/utils/serializable_bytes.js +0 -46
  1970. package/dist/es2017/core/decrypt/utils/server_certificate_store.d.ts +0 -64
  1971. package/dist/es2017/core/decrypt/utils/server_certificate_store.js +0 -112
  1972. package/dist/es2017/core/init/directfile_content_initializer.d.ts +0 -97
  1973. package/dist/es2017/core/init/directfile_content_initializer.js +0 -238
  1974. package/dist/es2017/core/init/media_source_content_initializer.d.ts +0 -165
  1975. package/dist/es2017/core/init/media_source_content_initializer.js +0 -685
  1976. package/dist/es2017/core/init/multithread/main_thread/multi_thread_content_initializer.d.ts +0 -167
  1977. package/dist/es2017/core/init/multithread/main_thread/multi_thread_content_initializer.js +0 -1317
  1978. package/dist/es2017/core/init/multithread/main_thread/send_message.d.ts +0 -2
  1979. package/dist/es2017/core/init/multithread/main_thread/send_message.js +0 -10
  1980. package/dist/es2017/core/init/multithread/worker/content_preparer.d.ts +0 -92
  1981. package/dist/es2017/core/init/multithread/worker/content_preparer.js +0 -236
  1982. package/dist/es2017/core/init/multithread/worker/globals.d.ts +0 -13
  1983. package/dist/es2017/core/init/multithread/worker/globals.js +0 -18
  1984. package/dist/es2017/core/init/multithread/worker/index.d.ts +0 -2
  1985. package/dist/es2017/core/init/multithread/worker/index.js +0 -2
  1986. package/dist/es2017/core/init/multithread/worker/send_message.d.ts +0 -3
  1987. package/dist/es2017/core/init/multithread/worker/send_message.js +0 -20
  1988. package/dist/es2017/core/init/multithread/worker/track_choice_setter.d.ts +0 -19
  1989. package/dist/es2017/core/init/multithread/worker/track_choice_setter.js +0 -114
  1990. package/dist/es2017/core/init/multithread/worker/worker_playback_observer.d.ts +0 -21
  1991. package/dist/es2017/core/init/multithread/worker/worker_playback_observer.js +0 -43
  1992. package/dist/es2017/core/init/multithread/worker/worker_portal.d.ts +0 -1
  1993. package/dist/es2017/core/init/multithread/worker/worker_portal.js +0 -671
  1994. package/dist/es2017/core/init/multithread/worker/worker_text_displayer_interface.d.ts +0 -64
  1995. package/dist/es2017/core/init/multithread/worker/worker_text_displayer_interface.js +0 -121
  1996. package/dist/es2017/core/init/types.d.ts +0 -226
  1997. package/dist/es2017/core/init/utils/DecipherabilityFreezeDetector.d.ts +0 -54
  1998. package/dist/es2017/core/init/utils/DecipherabilityFreezeDetector.js +0 -93
  1999. package/dist/es2017/core/init/utils/content_time_boundaries_observer.d.ts +0 -192
  2000. package/dist/es2017/core/init/utils/content_time_boundaries_observer.js +0 -468
  2001. package/dist/es2017/core/init/utils/create_content_time_boundaries_observer.d.ts +0 -28
  2002. package/dist/es2017/core/init/utils/create_content_time_boundaries_observer.js +0 -41
  2003. package/dist/es2017/core/init/utils/create_core_playback_observer.d.ts +0 -61
  2004. package/dist/es2017/core/init/utils/create_core_playback_observer.js +0 -122
  2005. package/dist/es2017/core/init/utils/create_media_source.d.ts +0 -37
  2006. package/dist/es2017/core/init/utils/create_media_source.js +0 -103
  2007. package/dist/es2017/core/init/utils/end_of_stream.d.ts +0 -33
  2008. package/dist/es2017/core/init/utils/end_of_stream.js +0 -88
  2009. package/dist/es2017/core/init/utils/get_initial_time.d.ts +0 -76
  2010. package/dist/es2017/core/init/utils/get_initial_time.js +0 -113
  2011. package/dist/es2017/core/init/utils/get_loaded_reference.d.ts +0 -28
  2012. package/dist/es2017/core/init/utils/get_loaded_reference.js +0 -58
  2013. package/dist/es2017/core/init/utils/initial_seek_and_play.d.ts +0 -61
  2014. package/dist/es2017/core/init/utils/initial_seek_and_play.js +0 -206
  2015. package/dist/es2017/core/init/utils/initialize_content_decryption.d.ts +0 -86
  2016. package/dist/es2017/core/init/utils/initialize_content_decryption.js +0 -110
  2017. package/dist/es2017/core/init/utils/main_thread_text_displayer_interface.d.ts +0 -35
  2018. package/dist/es2017/core/init/utils/media_source_duration_updater.js +0 -263
  2019. package/dist/es2017/core/init/utils/rebuffering_controller.d.ts +0 -114
  2020. package/dist/es2017/core/init/utils/rebuffering_controller.js +0 -421
  2021. package/dist/es2017/core/init/utils/stream_events_emitter/are_same_stream_events.js +0 -35
  2022. package/dist/es2017/core/init/utils/stream_events_emitter/index.d.ts +0 -18
  2023. package/dist/es2017/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.d.ts +0 -25
  2024. package/dist/es2017/core/init/utils/stream_events_emitter/refresh_scheduled_events_list.js +0 -85
  2025. package/dist/es2017/core/init/utils/stream_events_emitter/stream_events_emitter.d.ts +0 -53
  2026. package/dist/es2017/core/init/utils/stream_events_emitter/stream_events_emitter.js +0 -180
  2027. package/dist/es2017/core/init/utils/stream_events_emitter/types.d.ts +0 -41
  2028. package/dist/es2017/core/init/utils/throw_on_media_error.d.ts +0 -23
  2029. package/dist/es2017/core/init/utils/throw_on_media_error.js +0 -58
  2030. package/dist/es2017/core/segment_buffers/garbage_collector.d.ts +0 -43
  2031. package/dist/es2017/core/segment_buffers/garbage_collector.js +0 -137
  2032. package/dist/es2017/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.d.ts +0 -134
  2033. package/dist/es2017/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +0 -259
  2034. package/dist/es2017/core/segment_buffers/implementations/audio_video/index.d.ts +0 -17
  2035. package/dist/es2017/core/segment_buffers/implementations/audio_video/index.js +0 -17
  2036. package/dist/es2017/core/segment_buffers/implementations/index.d.ts +0 -19
  2037. package/dist/es2017/core/segment_buffers/implementations/index.js +0 -18
  2038. package/dist/es2017/core/segment_buffers/implementations/text/index.d.ts +0 -3
  2039. package/dist/es2017/core/segment_buffers/implementations/text/index.js +0 -2
  2040. package/dist/es2017/core/segment_buffers/implementations/text/text_segment_buffer.d.ts +0 -89
  2041. package/dist/es2017/core/segment_buffers/implementations/text/text_segment_buffer.js +0 -152
  2042. package/dist/es2017/core/segment_buffers/implementations/types.d.ts +0 -309
  2043. package/dist/es2017/core/segment_buffers/implementations/types.js +0 -112
  2044. package/dist/es2017/core/segment_buffers/implementations/utils/manual_time_ranges.js +0 -63
  2045. package/dist/es2017/core/segment_buffers/index.d.ts +0 -21
  2046. package/dist/es2017/core/segment_buffers/index.js +0 -21
  2047. package/dist/es2017/core/segment_buffers/inventory/buffered_history.d.ts +0 -89
  2048. package/dist/es2017/core/segment_buffers/inventory/buffered_history.js +0 -90
  2049. package/dist/es2017/core/segment_buffers/inventory/index.d.ts +0 -21
  2050. package/dist/es2017/core/segment_buffers/inventory/index.js +0 -18
  2051. package/dist/es2017/core/segment_buffers/inventory/segment_inventory.d.ts +0 -238
  2052. package/dist/es2017/core/segment_buffers/inventory/segment_inventory.js +0 -863
  2053. package/dist/es2017/core/segment_buffers/inventory/types.d.ts +0 -27
  2054. package/dist/es2017/core/segment_buffers/inventory/utils.d.ts +0 -33
  2055. package/dist/es2017/core/segment_buffers/inventory/utils.js +0 -49
  2056. package/dist/es2017/core/segment_buffers/segment_buffers_store.d.ts +0 -171
  2057. package/dist/es2017/core/segment_buffers/segment_buffers_store.js +0 -281
  2058. package/dist/es2017/manifest/adaptation.d.ts +0 -135
  2059. package/dist/es2017/manifest/adaptation.js +0 -195
  2060. package/dist/es2017/manifest/manifest.d.ts +0 -388
  2061. package/dist/es2017/manifest/manifest.js +0 -383
  2062. package/dist/es2017/manifest/period.d.ts +0 -106
  2063. package/dist/es2017/manifest/period.js +0 -194
  2064. package/dist/es2017/manifest/representation.d.ts +0 -238
  2065. package/dist/es2017/manifest/representation.js +0 -344
  2066. package/dist/es2017/manifest/representation_index/index.d.ts +0 -18
  2067. package/dist/es2017/manifest/representation_index/static.d.ts +0 -101
  2068. package/dist/es2017/manifest/representation_index/static.js +0 -139
  2069. package/dist/es2017/manifest/representation_index/types.d.ts +0 -420
  2070. package/dist/es2017/manifest/update_period_in_place.d.ts +0 -52
  2071. package/dist/es2017/manifest/update_period_in_place.js +0 -110
  2072. package/dist/es2017/manifest/update_periods.d.ts +0 -50
  2073. package/dist/es2017/manifest/update_periods.js +0 -192
  2074. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.d.ts +0 -23
  2075. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/AdaptationSet.js +0 -311
  2076. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/BaseURL.d.ts +0 -23
  2077. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/BaseURL.js +0 -30
  2078. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/ContentComponent.d.ts +0 -22
  2079. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/ContentProtection.d.ts +0 -21
  2080. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/EventStream.d.ts +0 -23
  2081. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/EventStream.js +0 -94
  2082. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/Initialization.d.ts +0 -21
  2083. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/Initialization.js +0 -39
  2084. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/MPD.d.ts +0 -21
  2085. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/MPD.js +0 -144
  2086. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/Period.d.ts +0 -21
  2087. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/Period.js +0 -112
  2088. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/Representation.d.ts +0 -21
  2089. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/Representation.js +0 -189
  2090. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/SegmentBase.d.ts +0 -22
  2091. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/SegmentBase.js +0 -89
  2092. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/SegmentList.d.ts +0 -21
  2093. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/SegmentTemplate.d.ts +0 -23
  2094. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/SegmentTemplate.js +0 -73
  2095. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/SegmentTimeline.d.ts +0 -21
  2096. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/SegmentURL.d.ts +0 -23
  2097. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/SegmentURL.js +0 -49
  2098. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/utils.d.ts +0 -187
  2099. package/dist/es2017/parsers/manifest/dash/js-parser/node_parsers/utils.js +0 -306
  2100. package/dist/es2017/parsers/manifest/dash/js-parser/parse_from_document.d.ts +0 -24
  2101. package/dist/es2017/parsers/manifest/dash/js-parser/parse_from_document.js +0 -106
  2102. package/dist/es2017/text_displayer/html/html_parsers.js +0 -22
  2103. package/dist/es2017/text_displayer/html/html_text_displayer.d.ts +0 -100
  2104. package/dist/es2017/text_displayer/html/html_text_displayer.js +0 -311
  2105. package/dist/es2017/text_displayer/html/text_track_cues_store.d.ts +0 -65
  2106. package/dist/es2017/text_displayer/html/text_track_cues_store.js +0 -358
  2107. package/dist/es2017/text_displayer/html/update_proportional_elements.js +0 -62
  2108. package/dist/es2017/text_displayer/html/utils.js +0 -107
  2109. package/dist/es2017/text_displayer/index.d.ts +0 -2
  2110. package/dist/es2017/text_displayer/manual_time_ranges.js +0 -48
  2111. package/dist/es2017/text_displayer/native/native_parsers.d.ts +0 -11
  2112. package/dist/es2017/text_displayer/native/native_parsers.js +0 -22
  2113. package/dist/es2017/text_displayer/native/native_text_displayer.d.ts +0 -56
  2114. package/dist/es2017/text_displayer/native/native_text_displayer.js +0 -203
  2115. package/dist/es2017/text_displayer/types.d.ts +0 -74
  2116. package/dist/es2017/transports/dash/extract_complete_chunks.js +0 -63
  2117. package/dist/es2017/transports/utils/find_complete_box.js +0 -53
  2118. /package/dist/commonjs/core/{segment_buffers → segment_sinks}/implementations/audio_video/index.js +0 -0
  2119. /package/dist/commonjs/core/{segment_buffers → segment_sinks}/implementations/text/index.js +0 -0
  2120. /package/dist/commonjs/core/{segment_buffers → segment_sinks}/implementations/utils/manual_time_ranges.d.ts +0 -0
  2121. /package/dist/commonjs/core/{segment_buffers → segment_sinks}/implementations/utils/manual_time_ranges.js +0 -0
  2122. /package/dist/commonjs/core/{segment_buffers → segment_sinks}/inventory/buffered_history.js +0 -0
  2123. /package/dist/commonjs/core/{segment_buffers → segment_sinks}/inventory/index.js +0 -0
  2124. /package/dist/commonjs/core/{init/utils/stream_events_emitter → segment_sinks/inventory}/types.js +0 -0
  2125. /package/dist/commonjs/{text_displayer → core}/types.js +0 -0
  2126. /package/dist/commonjs/{core → main_thread}/api/debug/buffer_size_graph.d.ts +0 -0
  2127. /package/dist/commonjs/{core → main_thread}/api/debug/constants.d.ts +0 -0
  2128. /package/dist/commonjs/{core → main_thread}/api/debug/constants.js +0 -0
  2129. /package/dist/commonjs/{core → main_thread}/api/debug/index.d.ts +0 -0
  2130. /package/dist/commonjs/{core → main_thread}/api/debug/index.js +0 -0
  2131. /package/dist/commonjs/{core → main_thread}/api/debug/render.js +0 -0
  2132. /package/dist/commonjs/{core → main_thread}/api/debug/utils.d.ts +0 -0
  2133. /package/dist/commonjs/{core → main_thread}/api/debug/utils.js +0 -0
  2134. /package/dist/commonjs/{core → main_thread}/decrypt/clear_on_stop.d.ts +0 -0
  2135. /package/dist/commonjs/{core → main_thread}/decrypt/dispose_decryption_resources.d.ts +0 -0
  2136. /package/dist/commonjs/{core → main_thread}/decrypt/get_key_system_configuration.d.ts +0 -0
  2137. /package/dist/commonjs/{core → main_thread}/decrypt/get_key_system_configuration.js +0 -0
  2138. /package/dist/commonjs/{core → main_thread}/decrypt/index.js +0 -0
  2139. /package/dist/commonjs/{core → main_thread}/decrypt/types.js +0 -0
  2140. /package/dist/commonjs/{core → main_thread}/decrypt/utils/are_init_values_compatible.d.ts +0 -0
  2141. /package/dist/commonjs/{core → main_thread}/decrypt/utils/clean_old_loaded_sessions.js +0 -0
  2142. /package/dist/commonjs/{core → main_thread}/decrypt/utils/clean_old_stored_persistent_info.js +0 -0
  2143. /package/dist/commonjs/{core → main_thread}/decrypt/utils/get_drm_system_id.d.ts +0 -0
  2144. /package/dist/commonjs/{core → main_thread}/decrypt/utils/get_drm_system_id.js +0 -0
  2145. /package/dist/commonjs/{core → main_thread}/decrypt/utils/key_id_comparison.d.ts +0 -0
  2146. /package/dist/commonjs/{core → main_thread}/decrypt/utils/key_id_comparison.js +0 -0
  2147. /package/dist/commonjs/{core → main_thread}/init/index.d.ts +0 -0
  2148. /package/dist/commonjs/{core → main_thread}/init/index.js +0 -0
  2149. /package/dist/commonjs/{core → main_thread}/init/types.js +0 -0
  2150. /package/dist/commonjs/{core → main_thread}/init/utils/main_thread_text_displayer_interface.js +0 -0
  2151. /package/dist/commonjs/{core → main_thread}/init/utils/stream_events_emitter/are_same_stream_events.d.ts +0 -0
  2152. /package/dist/commonjs/{core → main_thread}/init/utils/stream_events_emitter/index.js +0 -0
  2153. /package/dist/commonjs/{core/segment_buffers/inventory → main_thread/init/utils/stream_events_emitter}/types.js +0 -0
  2154. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/html/html_parsers.d.ts +0 -0
  2155. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/html/index.d.ts +0 -0
  2156. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/html/index.js +0 -0
  2157. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/html/update_proportional_elements.d.ts +0 -0
  2158. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/html/utils.d.ts +0 -0
  2159. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/index.js +0 -0
  2160. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/manual_time_ranges.d.ts +0 -0
  2161. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/native/index.d.ts +0 -0
  2162. /package/dist/commonjs/{text_displayer → main_thread/text_displayer}/native/index.js +0 -0
  2163. /package/dist/commonjs/{core/api/track_management → main_thread/tracks_store}/index.js +0 -0
  2164. /package/dist/commonjs/manifest/{representation_index → classes/representation_index}/index.js +0 -0
  2165. /package/dist/commonjs/manifest/{representation_index → classes/representation_index}/types.js +0 -0
  2166. /package/dist/commonjs/{core/init → mse}/utils/media_source_duration_updater.d.ts +0 -0
  2167. /package/dist/commonjs/{transports/dash → parsers/containers/isobmff}/extract_complete_chunks.d.ts +0 -0
  2168. /package/dist/commonjs/{transports/utils → parsers/containers/isobmff}/find_complete_box.d.ts +0 -0
  2169. /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/index.d.ts +0 -0
  2170. /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/index.js +0 -0
  2171. /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.js +0 -0
  2172. /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.js +0 -0
  2173. /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.js +0 -0
  2174. /package/dist/commonjs/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.js +0 -0
  2175. /package/dist/es2017/core/{segment_buffers → segment_sinks}/implementations/utils/manual_time_ranges.d.ts +0 -0
  2176. /package/dist/es2017/core/{init/utils/stream_events_emitter → segment_sinks/inventory}/types.js +0 -0
  2177. /package/dist/es2017/{text_displayer → core}/types.js +0 -0
  2178. /package/dist/es2017/{core → main_thread}/api/debug/buffer_size_graph.d.ts +0 -0
  2179. /package/dist/es2017/{core → main_thread}/api/debug/constants.d.ts +0 -0
  2180. /package/dist/es2017/{core → main_thread}/api/debug/constants.js +0 -0
  2181. /package/dist/es2017/{core → main_thread}/api/debug/index.d.ts +0 -0
  2182. /package/dist/es2017/{core → main_thread}/api/debug/index.js +0 -0
  2183. /package/dist/es2017/{core → main_thread}/api/debug/utils.d.ts +0 -0
  2184. /package/dist/es2017/{core → main_thread}/decrypt/clear_on_stop.d.ts +0 -0
  2185. /package/dist/es2017/{core → main_thread}/decrypt/dispose_decryption_resources.d.ts +0 -0
  2186. /package/dist/es2017/{core → main_thread}/decrypt/get_key_system_configuration.d.ts +0 -0
  2187. /package/dist/es2017/{core → main_thread}/decrypt/get_key_system_configuration.js +0 -0
  2188. /package/dist/es2017/{core → main_thread}/decrypt/types.js +0 -0
  2189. /package/dist/es2017/{core → main_thread}/decrypt/utils/are_init_values_compatible.d.ts +0 -0
  2190. /package/dist/es2017/{core → main_thread}/decrypt/utils/clean_old_loaded_sessions.js +0 -0
  2191. /package/dist/es2017/{core → main_thread}/decrypt/utils/clean_old_stored_persistent_info.js +0 -0
  2192. /package/dist/es2017/{core → main_thread}/decrypt/utils/get_drm_system_id.d.ts +0 -0
  2193. /package/dist/es2017/{core → main_thread}/decrypt/utils/get_drm_system_id.js +0 -0
  2194. /package/dist/es2017/{core → main_thread}/decrypt/utils/key_id_comparison.d.ts +0 -0
  2195. /package/dist/es2017/{core → main_thread}/init/index.d.ts +0 -0
  2196. /package/dist/es2017/{core → main_thread}/init/index.js +0 -0
  2197. /package/dist/es2017/{core → main_thread}/init/types.js +0 -0
  2198. /package/dist/es2017/{core → main_thread}/init/utils/main_thread_text_displayer_interface.js +0 -0
  2199. /package/dist/es2017/{core → main_thread}/init/utils/stream_events_emitter/are_same_stream_events.d.ts +0 -0
  2200. /package/dist/es2017/{core → main_thread}/init/utils/stream_events_emitter/index.js +0 -0
  2201. /package/dist/es2017/{core/segment_buffers/inventory → main_thread/init/utils/stream_events_emitter}/types.js +0 -0
  2202. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/html/html_parsers.d.ts +0 -0
  2203. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/html/index.d.ts +0 -0
  2204. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/html/index.js +0 -0
  2205. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/html/update_proportional_elements.d.ts +0 -0
  2206. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/html/utils.d.ts +0 -0
  2207. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/index.js +0 -0
  2208. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/manual_time_ranges.d.ts +0 -0
  2209. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/native/index.d.ts +0 -0
  2210. /package/dist/es2017/{text_displayer → main_thread/text_displayer}/native/index.js +0 -0
  2211. /package/dist/es2017/{core/api/track_management → main_thread/tracks_store}/index.js +0 -0
  2212. /package/dist/es2017/manifest/{representation_index → classes/representation_index}/index.js +0 -0
  2213. /package/dist/es2017/manifest/{representation_index → classes/representation_index}/types.js +0 -0
  2214. /package/dist/es2017/{core/init → mse}/utils/media_source_duration_updater.d.ts +0 -0
  2215. /package/dist/es2017/{transports/dash → parsers/containers/isobmff}/extract_complete_chunks.d.ts +0 -0
  2216. /package/dist/es2017/{transports/utils → parsers/containers/isobmff}/find_complete_box.d.ts +0 -0
  2217. /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/index.d.ts +0 -0
  2218. /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/index.js +0 -0
  2219. /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentComponent.js +0 -0
  2220. /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/ContentProtection.js +0 -0
  2221. /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentList.js +0 -0
  2222. /package/dist/es2017/parsers/manifest/dash/{js-parser → native-parser}/node_parsers/SegmentTimeline.js +0 -0
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see rx-player.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RxPlayer=t():e.RxPlayer=t()}(self,(function(){return function(){var e={61:function(e,t,n){var r=n(698).default;function i(){"use strict";e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},a=Object.prototype,o=a.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},l=u.iterator||"@@iterator",d=u.asyncIterator||"@@asyncIterator",c=u.toStringTag||"@@toStringTag";function f(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,n){return e[t]=n}}function v(e,t,n,r){var i=t&&t.prototype instanceof b?t:b,a=Object.create(i.prototype),o=new D(r||[]);return s(a,"_invoke",{value:x(e,n,o)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=v;var h="suspendedStart",m="suspendedYield",g="executing",y="completed",_={};function b(){}function S(){}function E(){}var T={};f(T,l,(function(){return this}));var k=Object.getPrototypeOf,w=k&&k(k(O([])));w&&w!==a&&o.call(w,l)&&(T=w);var A=E.prototype=b.prototype=Object.create(T);function I(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(i,a,s,u){var l=p(e[i],e,a);if("throw"!==l.type){var d=l.arg,c=d.value;return c&&"object"==r(c)&&o.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(c).then((function(e){d.value=e,s(d)}),(function(e){return n("throw",e,s,u)}))}u(l.arg)}var i;s(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(a,a):a()}})}function x(e,n,r){var i=h;return function(a,o){if(i===g)throw new Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=C(s,r);if(u){if(u===_)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var l=p(e,n,r);if("normal"===l.type){if(i=r.done?y:m,l.arg===_)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i=y,r.method="throw",r.arg=l.arg)}}}function C(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,C(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var a=p(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,_;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,_):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function M(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(M,this),this.reset(!0)}function O(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function n(){for(;++i<e.length;)if(o.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(r(e)+" is not iterable")}return S.prototype=E,s(A,"constructor",{value:E,configurable:!0}),s(E,"constructor",{value:S,configurable:!0}),S.displayName=f(E,c,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===S||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,f(e,c,"GeneratorFunction")),e.prototype=Object.create(A),e},n.awrap=function(e){return{__await:e}},I(R.prototype),f(R.prototype,d,(function(){return this})),n.AsyncIterator=R,n.async=function(e,t,r,i,a){void 0===a&&(a=Promise);var o=new R(v(e,t,r,i),a);return n.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(A),f(A,c,"Generator"),f(A,l,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=O,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var n in this)"t"===n.charAt(0)&&o.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),l=o.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,_):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),P(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:O(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},n}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},698:function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:function(e,t,n){var r=n(61)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var r={};return function(){"use strict";function e(){return"boolean"==typeof __RX_PLAYER_DEBUG_MODE__&&__RX_PLAYER_DEBUG_MODE__}function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function i(e){var n=function(e,n){if("object"!=t(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,n||"default");if("object"!=t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==t(n)?n:String(n)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,i(r.key),r)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},s(e,t)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,s(e,t)}n.d(r,{default:function(){return qv}});var l={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:"native",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:"continue",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MINIMUM_MAX_BUFFER_AHEAD:{text:120},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:"none",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,BITRATE_REBUFFERING_RATIO:1.5,DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:500,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,SEGMENT_SYNCHRONIZATION_DELAY:1500,MISSING_DATA_TRIGGER_SYNC_DELAY:.1,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.005,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs="avc1.4d401e"','video/mp4;codecs="avc1.42e01e"','video/webm;codecs="vp8"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs="mp4a.40.2"',"audio/webm;codecs=opus"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:["HW_SECURE_ALL","HW_SECURE_DECODE","HW_SECURE_CRYPTO","SW_SECURE_DECODE","SW_SECURE_CRYPTO"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:["3000","2000"],EME_KEY_SYSTEMS:{clearkey:["webkit-org.w3.clearkey","org.w3.clearkey"],widevine:["com.widevine.alpha"],playready:["com.microsoft.playready.recommendation","com.microsoft.playready","com.chromecast.playready","com.youtube.playready"],fairplay:["com.apple.fps.1_0"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:"reload",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:"seamless"};var d="function"==typeof Object.assign?Object.assign:function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=0;n<(arguments.length<=1?0:arguments.length-1);n++){var r=n+1<1||arguments.length<=n+1?void 0:arguments[n+1];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};function c(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}function f(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(0===n.length)return e;var i=n.shift();if(c(e)&&c(i))for(var a in i)if(c(i[a])){var o=e[a];void 0===o&&(o={},e[a]=o),f(o,i[a])}else{var s;d(e,((s={})[a]=i[a],s))}return f.apply(void 0,[e].concat(n))}var v=function(){function e(){this._config=l}var t=e.prototype;return t.update=function(e){var t=f(this._config,e);this._config=t},t.getCurrent=function(){return this._config},e}(),p=new v,h="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,m="undefined"==typeof window&&!h,g=h?self:m?n.g:window;function y(e){return"string"==typeof e&&e.length>0}function _(e){return null==e}function b(){}function S(e,t,n){if("function"==typeof Array.prototype.findIndex)return e.findIndex(t,n);for(var r=e.length>>>0,i=0;i<r;i++)if(t.call(n,e[i],i,e))return i;return-1}function E(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return T(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return T(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var k=function(){function e(e,t){var n=this;this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],void 0!==t&&(this._deregisterCancellation=t.register((function(){return n.finish()})))}var t=e.prototype;return t.getValue=function(){return this._value},t.setValue=function(e){if(!this._isFinished&&(this._value=e,0!==this._listeners.length))for(var t,n=E(this._listeners.slice());!(t=n()).done;){var r=t.value;try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(e){}}},t.setValueIfChanged=function(e){e!==this._value&&this.setValue(e)},t.onUpdate=function(e,t){var n=this,r=function e(){if(void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.deregister(e),!i.hasBeenCleared){i.hasBeenCleared=!0;var r=n._listeners.indexOf(i);r>=0&&n._listeners.splice(r,1)}},i={trigger:e,complete:r,hasBeenCleared:!1};this._listeners.push(i),!0===(null==t?void 0:t.emitCurrentValue)&&e(this._value,r),this._isFinished||i.hasBeenCleared?r():void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.register(r)},t.waitUntilDefined=function(e,t){var n=this;this.onUpdate((function(t,r){void 0!==t&&(r(),e(n._value))}),{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:!0})},t._onFinished=function(e,t){var n=this;if(t.isCancelled())return b;var r=function(){var e=S(n._onFinishCbs,(function(e){return e.trigger===i}));e>=0&&(n._onFinishCbs[e].hasBeenCleared=!0,n._onFinishCbs.splice(e,1))},i=function(){r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a},t.finish=function(){void 0!==this._deregisterCancellation&&this._deregisterCancellation(),this._isFinished=!0;for(var e,t=E(this._listeners.slice());!(e=t()).done;){var n=e.value;try{n.hasBeenCleared||(n.complete(),n.hasBeenCleared=!0)}catch(e){}}if(this._listeners.length=0,this._onFinishCbs.length>0){for(var r,i=E(this._onFinishCbs.slice());!(r=i()).done;){var a=r.value;try{a.hasBeenCleared||(a.trigger(),a.hasBeenCleared=!0)}catch(e){}}this._onFinishCbs.length=0}},e}();function w(e,t,n){var r=new k(t(e.getValue()),n);return e.onUpdate((function(e){r.setValue(t(e))}),{clearSignal:n}),e._onFinished((function(){r.finish()}),n),r}var A=k,I=["","webkit","moz","ms"];function R(e,t){return t.filter((function(t){return function(e,t){var n=document.createElement(e.tagName),r="on"+t;return r in n||(n.setAttribute(r,"return;"),"function"==typeof n[r])}(e,t)}))[0]}function x(e,t){var n,r=function(e,t){return e.reduce((function(e,n){return e.concat((void 0===t?I:t).map((function(e){return e+n})))}),[])}(e,t);return function(e,t,i){if(!i.isCancelled()){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement){if(void 0===n&&(n=R(e,r)),!y(n))return void 0;e.addEventListener(n,t),i.register((function(){void 0!==n&&e.removeEventListener(n,t)}))}r.forEach((function(n){var r=!1;"function"==typeof e.addEventListener?e.addEventListener(n,t):(r=!0,e["on"+n]=t),i.register((function(){"function"==typeof e.removeEventListener&&e.removeEventListener(n,t),r&&delete e["on"+n]}))}))}}}x(["loadedmetadata"]),x(["timeupdate"]),x(["addtrack"]),x(["removetrack"]);var C=x(["sourceopen","webkitsourceopen"]),M=x(["sourceclose","webkitsourceclose"]),P=x(["sourceended","webkitsourceended"]),D=x(["update"]),O=x(["removesourcebuffer"]),N=x(["keymessage","message"]),L=x(["keyadded","ready"]),U=x(["keyerror","error"]),B=x(["keystatuseschange"]),F=x(["seeking"]),z=x(["seeked"]),V=x(["ended"]);function K(e,t,n,r){e.addEventListener(t,n),r.register((function(){e.removeEventListener(t,n)}))}function W(e){var t=e;if("function"==typeof t.getStartDate){var n=t.getStartDate();if("object"==typeof n&&null!==n){var r=+n;if(!isNaN(r))return r/1e3}else if("number"==typeof n&&!isNaN(n))return n}}var G,j,H,q=!1,Y=!1,Q=!1,$=!1,X=!1,Z=!1,J=!1,ee=!1,te=!1,ne=!1,re=!1;m||(void 0!==g.MSInputMethodContext&&void 0!==document.documentMode?(Y=!0,Q=!0):"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&/(Trident|Edge)\//.test(navigator.userAgent)?Q=!0:-1!==navigator.userAgent.toLowerCase().indexOf("edg/")?q=!0:-1!==navigator.userAgent.toLowerCase().indexOf("firefox")?$=!0:"string"==typeof navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)?Z=!0:(Object.prototype.toString.call(g.HTMLElement).indexOf("Constructor")>=0||"[object SafariRemoteNotification]"===(null===(j=null===(G=g.safari)||void 0===G?void 0:G.pushNotification)||void 0===j?void 0:j.toString())||/Safari\/(\d+)/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&-1!==(null===(H=navigator.vendor)||void 0===H?void 0:H.indexOf("Apple"))&&!/Chrome\/(\d+)/.test(navigator.userAgent)&&!/Chromium\/(\d+)/.test(navigator.userAgent))&&(X=!0),/SamsungBrowser/.test(navigator.userAgent)&&(J=!0),-1!==navigator.userAgent.indexOf("PlayStation 5")?re=!0:/Tizen/.test(navigator.userAgent)?ee=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(te=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\/87/.test(navigator.userAgent)||(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\/79/.test(navigator.userAgent))):/[Pp]anasonic/.test(navigator.userAgent)?ne=!0:navigator.userAgent.indexOf("Xbox"));var ie=function(){function e(){this._listeners={}}var t=e.prototype;return t.addEventListener=function(e,t,n){var r=this,i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],void 0!==n&&n.register((function(){r.removeEventListener(e,t)}))},t.removeEventListener=function(e,t){if(_(e))this._listeners={};else{var n=this._listeners[e];if(Array.isArray(n))if(_(t))delete this._listeners[e];else{var r=n.indexOf(t);-1!==r&&n.splice(r,1),0===n.length&&delete this._listeners[e]}}},t.trigger=function(e,t){var n=this._listeners[e];Array.isArray(n)&&n.slice().forEach((function(e){try{e(t)}catch(e){0,console.error("RxPlayer: EventEmitter error",e instanceof Error?e:null)}}))},e}(),ae=function(e){function t(){var t;return(t=e.call(this)||this).error=b,t.warn=b,t.info=b,t.debug=b,t._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},t._currentLevel="NONE",t}u(t,e);var n=t.prototype;return n.setLevel=function(e,t){var n,r=this._levels[e];"number"==typeof r?(n=r,this._currentLevel=e):(n=0,this._currentLevel="NONE"),void 0===t?(this.error=n>=this._levels.ERROR?console.error.bind(console):b,this.warn=n>=this._levels.WARNING?console.warn.bind(console):b,this.info=n>=this._levels.INFO?console.info.bind(console):b,this.debug=n>=this._levels.DEBUG?console.log.bind(console):b):(this.error=n>=this._levels.ERROR?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("ERROR",n)}:b,this.warn=n>=this._levels.WARNING?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("WARNING",n)}:b,this.info=n>=this._levels.INFO?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("INFO",n)}:b,this.debug=n>=this._levels.DEBUG?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("DEBUG",n)}:b),this.trigger("onLogLevelChange",this._currentLevel)},n.getLevel=function(){return this._currentLevel},n.hasLevel=function(e){return this._levels[e]>=this._levels[this._currentLevel]},t}(ie),oe=new ae;function se(){if(!$)return!0;var e=function(){if(!$)return oe.warn("Compat: Can't access Firefox version on no firefox browser."),null;var e=navigator.userAgent,t=/Firefox\/([0-9]+)\./.exec(e);if(null===t)return-1;var n=parseInt(t[1],10);return isNaN(n)?-1:n}();if(null===e||e<67)return!0;var t=null===HTMLVideoElement||void 0===HTMLVideoElement?void 0:HTMLVideoElement.prototype;return void 0!==(null==t?void 0:t.requirePictureInPicture)}var ue="function"==typeof MediaSource&&!0===MediaSource.canConstructInDedicatedWorker,le="object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate;function de(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ce(e){return ce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ce(e)}function fe(e,t,n){return fe=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&s(i,n.prototype),i},fe.apply(null,arguments)}function ve(e){var t="function"==typeof Map?new Map:void 0;return ve=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return fe(e,arguments,ce(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,e)},ve(e)}var pe=function(e){function t(n,r,i){var a;switch(a=e.call(this)||this,Object.setPrototypeOf(de(a),t.prototype),a.name="RequestError",a.url=n,a.status=r,a.type=i,i){case"TIMEOUT":a.message="The request timed out";break;case"ERROR_EVENT":a.message="An error prevented the request to be performed successfully";break;case"PARSE_ERROR":a.message="An error happened while formatting the response data";break;case"ERROR_HTTP_CODE":a.message="An HTTP status code indicating failure was received: "+String(a.status)}return a}return u(t,e),t.prototype.serialize=function(){return{url:this.url,status:this.status,type:this.type}},t}(ve(Error)),he={TIMEOUT:"TIMEOUT",ERROR_EVENT:"ERROR_EVENT",ERROR_HTTP_CODE:"ERROR_HTTP_CODE",PARSE_ERROR:"PARSE_ERROR"},me=he,ge={NETWORK_ERROR:"NETWORK_ERROR",MEDIA_ERROR:"MEDIA_ERROR",ENCRYPTED_MEDIA_ERROR:"ENCRYPTED_MEDIA_ERROR",OTHER_ERROR:"OTHER_ERROR"},ye={PIPELINE_LOAD_ERROR:"PIPELINE_LOAD_ERROR",PIPELINE_PARSE_ERROR:"PIPELINE_PARSE_ERROR",INTEGRITY_ERROR:"INTEGRITY_ERROR",MANIFEST_PARSE_ERROR:"MANIFEST_PARSE_ERROR",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"MANIFEST_INCOMPATIBLE_CODECS_ERROR",MANIFEST_UPDATE_ERROR:"MANIFEST_UPDATE_ERROR",MANIFEST_UNSUPPORTED_ADAPTATION_TYPE:"MANIFEST_UNSUPPORTED_ADAPTATION_TYPE",MEDIA_STARTING_TIME_NOT_FOUND:"MEDIA_STARTING_TIME_NOT_FOUND",MEDIA_TIME_BEFORE_MANIFEST:"MEDIA_TIME_BEFORE_MANIFEST",MEDIA_TIME_AFTER_MANIFEST:"MEDIA_TIME_AFTER_MANIFEST",MEDIA_TIME_NOT_FOUND:"MEDIA_TIME_NOT_FOUND",NO_PLAYABLE_REPRESENTATION:"NO_PLAYABLE_REPRESENTATION",MEDIA_IS_ENCRYPTED_ERROR:"MEDIA_IS_ENCRYPTED_ERROR",CREATE_MEDIA_KEYS_ERROR:"CREATE_MEDIA_KEYS_ERROR",KEY_ERROR:"KEY_ERROR",KEY_STATUS_CHANGE_ERROR:"KEY_STATUS_CHANGE_ERROR",KEY_UPDATE_ERROR:"KEY_UPDATE_ERROR",KEY_LOAD_ERROR:"KEY_LOAD_ERROR",KEY_LOAD_TIMEOUT:"KEY_LOAD_TIMEOUT",KEY_GENERATE_REQUEST_ERROR:"KEY_GENERATE_REQUEST_ERROR",INCOMPATIBLE_KEYSYSTEMS:"INCOMPATIBLE_KEYSYSTEMS",INVALID_ENCRYPTED_EVENT:"INVALID_ENCRYPTED_EVENT",INVALID_KEY_SYSTEM:"INVALID_KEY_SYSTEM",LICENSE_SERVER_CERTIFICATE_ERROR:"LICENSE_SERVER_CERTIFICATE_ERROR",MULTIPLE_SESSIONS_SAME_INIT_DATA:"MULTIPLE_SESSIONS_SAME_INIT_DATA",BUFFER_APPEND_ERROR:"BUFFER_APPEND_ERROR",BUFFER_FULL_ERROR:"BUFFER_FULL_ERROR",BUFFER_TYPE_UNKNOWN:"BUFFER_TYPE_UNKNOWN",MEDIA_ERR_BLOCKED_AUTOPLAY:"MEDIA_ERR_BLOCKED_AUTOPLAY",MEDIA_ERR_PLAY_NOT_ALLOWED:"MEDIA_ERR_PLAY_NOT_ALLOWED",MEDIA_ERR_NOT_LOADED_METADATA:"MEDIA_ERR_NOT_LOADED_METADATA",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_UNKNOWN:"MEDIA_ERR_UNKNOWN",MEDIA_SOURCE_NOT_SUPPORTED:"MEDIA_SOURCE_NOT_SUPPORTED",MEDIA_KEYS_NOT_SUPPORTED:"MEDIA_KEYS_NOT_SUPPORTED",DISCONTINUITY_ENCOUNTERED:"DISCONTINUITY_ENCOUNTERED",NONE:"NONE"};function _e(e,t){return e+": "+t}var be=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(de(a),t.prototype),a.name="EncryptedMediaError",a.type=ge.ENCRYPTED_MEDIA_ERROR,a.code=n,a._originalMessage=r,a.message=_e(a.code,r),a.fatal=!1,"string"==typeof(null==i?void 0:i.keyStatuses)&&(a.keyStatuses=i.keyStatuses),a}return u(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}},t}(ve(Error)),Se=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(de(a),t.prototype),a.name="MediaError",a.type=ge.MEDIA_ERROR,a._originalMessage=r,a.code=n,a.message=_e(a.code,r),a.fatal=!1,void 0!==(null==i?void 0:i.tracks)&&(null==i?void 0:i.tracks.length)>0&&(a.tracksInfo=i.tracks),a}return u(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}},t}(ve(Error)),Ee=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(de(i),t.prototype),i.name="NetworkError",i.type=ge.NETWORK_ERROR,i.url=r.url,i.status=r.status,i.errorType=r.type,i._baseError=r,i.code=n,i.message=_e(i.code,r.message),i.fatal=!1,i}u(t,e);var n=t.prototype;return n.isHttpError=function(e){return this.errorType===me.ERROR_HTTP_CODE&&this.status===e},n.serialize=function(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}},t}(ve(Error)),Te=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(de(i),t.prototype),i.name="OtherError",i.type=ge.OTHER_ERROR,i.code=n,i.message=_e(i.code,r),i.fatal=!1,i._originalMessage=r,i}return u(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage}},t}(ve(Error));function ke(e){return(e instanceof be||e instanceof Se||e instanceof Te||e instanceof Ee)&&Object.keys(ge).indexOf(e.type)>=0}function we(e,t){var n=t.defaultCode,r=t.defaultReason;if(ke(e))return e;var i=e instanceof Error?e.toString():r;return new Te(n,i)}var Ae=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(de(i),t.prototype),i.name="WorkerInitializationError",i.type="WORKER_INITIALIZATION_ERROR",i.code=n,i.message=_e(i.code,r),i}return u(t,e),t}(ve(Error)),Ie={dashParsers:{wasm:null,js:null},codecSupportProber:null,createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}};var Re=Ie;function xe(e,t,n){if("function"==typeof Array.prototype.find)return e.find(t,n);for(var r=e.length>>>0,i=0;i<r;i++){var a=e[i];if(t.call(n,a,i,e))return a}}var Ce=new A(0);function Me(){return performance.now()+Ce.getValue()}function Pe(e){return Object.keys(e).map((function(t){return e[t]}))}var De="function"==typeof Object.values?Object.values:Pe;function Oe(e,t){return e.segment.id===t.segment.id&&e.representation.uniqueId===t.representation.uniqueId}function Ne(e){if(_(e))return"";var t=e.period,n=e.adaptation,r=e.representation,i=e.segment;return n.type+" P: "+t.id+" A: "+n.id+" R: "+r.id+" S: "+(i.isInit?"init":i.complete?i.time+"-"+i.duration:""+i.time)}function Le(e){var t,n,r=e.timeBounds;if(null===r.timeshiftDepth)return null!==(t=r.minimumSafePosition)&&void 0!==t?t:0;var i,a=r.maximumTimeData;if(r.maximumTimeData.isLinear){var o=Me()-a.time;i=a.maximumSafePosition+o/1e3}else i=a.maximumSafePosition;var s=i-r.timeshiftDepth;return Math.max(null!==(n=r.minimumSafePosition)&&void 0!==n?n:0,s)}function Ue(e){var t=e.timeBounds.maximumTimeData;if(e.isLive&&void 0!==t.livePosition){if(!t.isLinear)return t.livePosition;var n=Me()-t.time;return t.livePosition+n/1e3}}function Be(e){var t=e.timeBounds.maximumTimeData;if(!t.isLinear)return t.maximumSafePosition;var n=Me()-t.time;return t.maximumSafePosition+n/1e3}function Fe(e,t){if(void 0===t)return Ke(e).filter((function(e){return!0===e.isSupported}));var n=e.adaptations[t];return void 0===n?[]:n.filter((function(e){return!0===e.isSupported}))}function ze(e,t){var n=t.end;if(void 0===n)return null;var r=xe(e.periods,(function(e){return void 0===e.end||n<e.end}));return void 0===r?null:r}function Ve(e,t,n){return t>=e.start&&(void 0===e.end||t<e.end)||t===e.end&&(null===n||n.start>e.end)}function Ke(e){return Pe(e.adaptations).reduce((function(e,t){return null!=t?e.concat(t):e}),[])}function We(e,t){var n,r,i={language:null!==(n=e.language)&&void 0!==n?n:"",normalized:null!==(r=e.normalizedLanguage)&&void 0!==r?r:"",audioDescription:!0===e.isAudioDescription,id:e.id,representations:(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(He),label:e.label};return!0===e.isDub&&(i.dub=!0),i}function Ge(e){var t,n;return{language:null!==(t=e.language)&&void 0!==t?t:"",normalized:null!==(n=e.normalizedLanguage)&&void 0!==n?n:"",closedCaption:!0===e.isClosedCaption,id:e.id,label:e.label,forced:e.isForcedSubtitles}}function je(e,t){var n=void 0!==e.trickModeTracks?e.trickModeTracks.map((function(e){var n=(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(qe),r={id:e.id,representations:n,isTrickModeTrack:!0};return!0===e.isSignInterpreted&&(r.signInterpreted=!0),r})):void 0,r={id:e.id,representations:(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(qe),label:e.label};return!0===e.isSignInterpreted&&(r.signInterpreted=!0),!0===e.isTrickModeTrack&&(r.isTrickModeTrack=!0),void 0!==n&&(r.trickModeTracks=n),r}function He(e){var t=e.id,n=e.bitrate,r=e.codecs,i=e.isSpatialAudio,a=e.isSupported,o=e.decipherable;return{id:t,bitrate:n,codec:null==r?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function qe(e){var t=e.id,n=e.bitrate,r=e.frameRate,i=e.width,a=e.height,o=e.codecs,s=e.hdrInfo,u=e.isSupported,l=e.decipherable;return{id:t,bitrate:n,frameRate:r,width:i,height:a,codec:null==o?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:l}}function Ye(e){switch(e.type){case"audio":return{type:"audio",track:We(e,!1)};case"video":return{type:"video",track:je(e,!1)};case"text":return{type:"text",track:Ge(e)}}}function Qe(e,t,n){if("function"==typeof Array.prototype.includes)return e.includes(t,n);var r=e.length>>>0;if(0===r)return!1;for(var i,a,o=0|n,s=o>=0?Math.min(o,r-1):Math.max(r+o,0);s<r;){if((i=e[s])===(a=t)||"number"==typeof i&&"number"==typeof a&&isNaN(i)&&isNaN(a))return!0;s++}return!1}var $e=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(de(r),t.prototype),r.name="AssertionError",r.message=n,r}return u(t,e),t}(ve(Error));function Xe(e,t){0}function Ze(e){throw new $e("Unreachable path taken")}function Je(){var e="",t=-1;return function(){return++t>=Number.MAX_SAFE_INTEGER&&(e+="0",t=0),e+String(t)}}var et=1/60;function tt(e,t){return Math.abs(e-t)<et}function nt(e,t){return{start:Math.min(e.start,t.start),end:Math.max(e.end,t.end)}}function rt(e,t){return e.end<=t.start}function it(e,t){var n=e.start,r=e.end;return n<=t&&t<r}function at(e,t){return it(e,t.start)||e.start<t.end&&t.end<e.end||it(t,e.start)}function ot(e,t){return tt(t.start,e.end)||tt(t.end,e.start)}function st(e){for(var t=[],n=0;n<e.length;n++)t.push({start:e.start(n),end:e.end(n)});return t}function ut(e,t){for(var n=e.length-1;n>=0;n--){var r=e.start(n);if(t>=r){var i=e.end(n);if(t<i)return{start:r,end:i}}}return null}function lt(e,t){for(var n=e.length-1;n>=0;n--){if(t>=e[n].start)if(t<e[n].end)return e[n]}return null}function dt(e,t){for(var n=null,r=[],i=0;i<e.length;i++){var a=e[i].start,o=e[i].end;t<a||t>=o?r.push({start:a,end:o}):n={start:a,end:o}}return{outerRanges:r,innerRange:n}}function ct(e,t){var n=lt(e,t);return null!==n?n.end-t:1/0}function ft(e,t){if(t.start===t.end)return e;for(var n=t,r=0;r<e.length;r++){var i=e[r],a=at(n,i),o=ot(n,i);if(a||o)n=nt(n,i),e.splice(r--,1);else if(0===r){if(rt(n,e[0]))break}else if(rt(e[r-1],n)&&rt(n,i))break}return e.splice(r,0,n),function(e){for(var t=1;t<e.length;t++){var n=e[t-1],r=e[t];if(ot(n,r)){var i=nt(n,r);e.splice(--t,2,i)}}return e}(function(e){for(var t=0;t<e.length;t++){var n=e[t];n.start===n.end&&e.splice(t--,1)}return e}(e))}function vt(e,t){for(var n=[],r=0;r<t.length;r++)at(e,t[r])&&n.push(t[r]);return n}function pt(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=[],o=vt(i,t);if(o.length>0)for(var s=0;s<o.length;s++){var u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(0===a.length)n.push(i);else{for(var l=i.start,d=0;d<a.length;d++)a[d].start>l&&n.push({start:l,end:a[d].start}),l=a[d].end;l<i.end&&n.push({start:l,end:i.end})}}return n}var ht=function(){function e(){var e,t=(e=b,[function(t){e(t)},function(t){e=t}]),n=t[0],r=t[1];this._isUsed=!1,this._trigger=n,this.signal=new mt(r)}var t=e.prototype;return t.isUsed=function(){return this._isUsed},t.linkToSignal=function(e){var t=this,n=e.register((function(){t.cancel()}));return this.signal.register(n),n},t.cancel=function(e){if(!this._isUsed){this._isUsed=!0;var t=null!=e?e:new gt;this._trigger(t)}},e.isCancellationError=function(e){return e instanceof gt},e}(),mt=function(){function e(e){var t=this;this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e((function(e){for(t.cancellationError=e,t._isCancelled=!0;t._listeners.length>0;)try{var n=t._listeners.pop();null==n||n(e)}catch(e){oe.error("Error while calling clean up listener",e instanceof Error?e.toString():"Unknown error")}}))}var t=e.prototype;return t.isCancelled=function(){return this._isCancelled},t.register=function(e){var t=this;return this._isCancelled?(Xe(this.cancellationError),e(this.cancellationError),b):(this._listeners.push(e),function(){return t.deregister(e)})},t.deregister=function(e){for(var t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)},e}(),gt=function(e){function t(){var n;return n=e.call(this)||this,Object.setPrototypeOf(de(n),t.prototype),n.name="CancellationError",n.message="This task was cancelled.",n}return u(t,e),t}(ve(Error));function yt(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function _t(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){yt(a,r,i,o,s,"next",e)}function s(e){yt(a,r,i,o,s,"throw",e)}o(void 0)}))}}var bt=n(687),St=n.n(bt);function Et(e){return new Promise((function(t){setTimeout(t,e)}))}var Tt=new WeakMap,kt={setState:function(e,t){Tt.set(e,t)},getState:function(e){var t=Tt.get(e);return void 0===t?null:t},clearState:function(e){Tt.set(e,null)}};function wt(e){return At.apply(this,arguments)}function At(){return(At=_t(St().mark((function e(t){var n,r;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==(n=kt.getState(t))){e.next=3;break}return e.abrupt("return",void 0);case 3:return oe.info("DRM: Disposing of the current MediaKeys"),r=n.loadedSessionsStore,kt.clearState(t),e.next=8,r.closeAllSessions();case 8:return e.abrupt("return",Promise.race([n.emeImplementation.setMediaKeys(t,null).catch((function(e){oe.error("DRM: Could not reset MediaKeys",e instanceof Error?e:"Unknown Error")})),Et(1e3)]));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function It(e){var t=kt.getState(e);return null===t?null:[t.mediaKeySystemAccess.keySystem,t.mediaKeySystemAccess.getConfiguration()]}function Rt(e){if(oe.info("DRM: Clearing-up DRM session."),Y)return oe.info("DRM: disposing current MediaKeys."),wt(e);var t=kt.getState(e);return null!==t&&!0===t.keySystemOptions.closeSessionsOnStop?(oe.info("DRM: closing all current sessions."),t.loadedSessionsStore.closeAllSessions()):(oe.info("DRM: Nothing to clear. Returning right away. No state =",null===t),Promise.resolve())}function xt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ct(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ct(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ct(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Mt=ee,Pt=["canplay","ended","play","pause","seeking","seeked","loadedmetadata","ratechange"],Dt=function(){function e(e,t){var n=this;this._internalSeeksIncoming=[],this._mediaElement=e,this._withMediaSource=t.withMediaSource,this._lowLatencyMode=t.lowLatencyMode,this._canceller=new ht,this._observationRef=this._createSharedReference(),this._expectedSeekingPosition=null,this._pendingSeek=null;var r=function(){if(null!==n._pendingSeek){var e=n._pendingSeek;n._pendingSeek=null,n._actuallySetCurrentTime(e)}};e.addEventListener("loadedmetadata",r),this._canceller.signal.register((function(){e.removeEventListener("loadedmetadata",r)}))}var t=e.prototype;return t.stop=function(){this._canceller.cancel()},t.getCurrentTime=function(){return this._mediaElement.currentTime},t.getPlaybackRate=function(){return this._mediaElement.playbackRate},t.getIsPaused=function(){return this._mediaElement.paused},t.setCurrentTime=function(e){this._mediaElement.readyState>=1?this._actuallySetCurrentTime(e):(this._internalSeeksIncoming=[],this._pendingSeek=e,this._generateObservationForEvent("manual"))},t.setPlaybackRate=function(e){this._mediaElement.playbackRate=e},t.getReadyState=function(){return this._mediaElement.readyState},t.getReference=function(){return this._observationRef},t.listen=function(e,t){var n;if(this._canceller.isUsed()||!0===(null===(n=null==t?void 0:t.clearSignal)||void 0===n?void 0:n.isCancelled()))return b;this._observationRef.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},t.deriveReadOnlyObserver=function(e){return Ut(this,e,this._canceller.signal)},t._actuallySetCurrentTime=function(e){oe.info("API: Seeking internally",e),this._internalSeeksIncoming.push(e),this._mediaElement.currentTime=e},t._createSharedReference=function(){var e=this;if(void 0!==this._observationRef)return this._observationRef;var t=p.getCurrent(),n=t.SAMPLING_INTERVAL_MEDIASOURCE,r=t.SAMPLING_INTERVAL_LOW_LATENCY,i=t.SAMPLING_INTERVAL_NO_MEDIASOURCE,a=new A(this._getCurrentObservation("init"),this._canceller.signal),o=this._lowLatencyMode?r:this._withMediaSource?n:i,s=function(){e._generateObservationForEvent("timeupdate")},u=setInterval(s,o),l=Pt.map((function(t){var n=function(){clearInterval(u),u=setInterval(s,o),e._generateObservationForEvent(t)};return e._mediaElement.addEventListener(t,n),function(){e._mediaElement.removeEventListener(t,n)}}));return this._canceller.signal.register((function(){clearInterval(u),l.forEach((function(e){return e()})),a.finish()})),a},t._getCurrentObservation=function(e){var t,n,r=e,i=void 0===this._observationRef?function(e){var t=Lt(e);return d(t,{rebuffering:null,event:"init",seeking:0,position:new Ot(t.position,null),freezing:null,bufferGap:0,currentRange:null})}(this._mediaElement):this._observationRef.getValue(),a=!1,o=this._pendingSeek,s=Lt(this._mediaElement),u=s.buffered,l=s.readyState,c=s.position,f=s.seeking;if("seeking"===r)if(this._internalSeeksIncoming.length>0){a=!0,r="internal-seeking";var v=this._internalSeeksIncoming.shift();this._expectedSeekingPosition=Mt?Math.max(c,null!=v?v:0):c}else this._expectedSeekingPosition=c;else f?this._expectedSeekingPosition=Math.max(c,null!==(t=this._expectedSeekingPosition)&&void 0!==t?t:0):Mt&&null!==this._expectedSeekingPosition&&c<this._expectedSeekingPosition?o=this._expectedSeekingPosition:this._expectedSeekingPosition=null;f&&1===i.seeking&&"seeking"!==e&&(a=!0);var h,m,g=null!==(n=this._expectedSeekingPosition)&&void 0!==n?n:c;!this._withMediaSource&&0===u.length&&l>=3?(h=void 0,m=void 0):m=null!==(h=ut(u,g))?h.end-g:1/0;var y=function(e){var t,n,r=e.previousObservation,i=e.currentObservation,a=e.basePosition,o=e.observationEvent,s=e.withMediaSource,u=e.lowLatencyMode,l=e.bufferGap,d=e.currentRange,c=p.getCurrent().REBUFFERING_GAP,f=i.position,v=i.duration,h=i.paused,m=i.readyState,g=i.ended,y=r.rebuffering,_=r.event,b=r.position,S=function(e,t,n,r,i){var a=p.getCurrent().REBUFFERING_GAP,o=i?"LOW_LATENCY":"DEFAULT";if(void 0===t)return n&&Math.abs(r-e)<=a[o];return null!==t&&r-t.end<=a[o]}(a,d,g,v,u),E=m>=1&&"loadedmetadata"!==o&&null===y&&!(S||g),T=null,k=u?c.LOW_LATENCY:c.DEFAULT;if(s){if(E)l===1/0?(t=!0,T=a):void 0===l?m<3&&(t=!0,T=void 0):l<=k&&(t=!0,T=a+l);else if(null!==y){var w=Nt(y,u);!0!==t&&null!==y&&m>1&&(S||g||void 0!==l&&isFinite(l)&&l>w)||void 0===l&&m>=3?n=!0:void 0===l?T=void 0:l===1/0?T=a:l<=w&&(T=a+l)}}else E&&(!h&&"timeupdate"===o&&"timeupdate"===_&&f===b.getPolled()||"seeking"===o&&(l===1/0||void 0===l&&m<3))?t=!0:null!==y&&("seeking"!==o&&f!==b.getPolled()||"canplay"===o||void 0===l&&m>=3||void 0!==l&&l<1/0&&(l>Nt(y,u)||S||g))&&(n=!0);if(!0===n)return null;var A;if(!0===t||null!==y)return A="seeking"===o||null!==y&&"seeking"===y.reason||i.seeking?"seeking":1===m?"not-ready":"buffering",null!==y&&y.reason===A?{reason:y.reason,timestamp:y.timestamp,position:T}:{reason:A,timestamp:Me(),position:T};return null}({previousObservation:i,currentObservation:s,basePosition:g,observationEvent:r,lowLatencyMode:this._lowLatencyMode,withMediaSource:this._withMediaSource,bufferGap:m,currentRange:h}),_=function(e,t,n,r){var i=p.getCurrent().MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING;if(e.freezing)return t.ended||t.paused||0===t.readyState||0===t.playbackRate||e.position.getPolled()!==t.position?null:e.freezing;return"timeupdate"===n&&void 0!==r&&r>i&&!t.ended&&!t.paused&&t.readyState>=1&&0!==t.playbackRate&&t.position===e.position.getPolled()?{timestamp:Me()}:null}(i,s,r,m),b=a?1:f?2:0,S=d({},s,{position:new Ot(s.position,o),event:r,seeking:b,rebuffering:y,freezing:_,bufferGap:m,currentRange:h});return oe.hasLevel("DEBUG")&&oe.debug("API: current media element state tick","event",S.event,"position",S.position.getPolled(),"seeking",S.seeking,"internalSeek",a,"rebuffering",null!==S.rebuffering,"freezing",null!==S.freezing,"ended",S.ended,"paused",S.paused,"playbackRate",S.playbackRate,"readyState",S.readyState,"pendingPosition",o),S},t._generateObservationForEvent=function(e){var t=this._getCurrentObservation(e);oe.hasLevel("DEBUG")&&oe.debug("API: current playback timeline:\n"+function(e,t){for(var n="",r="",i=0;i<e.length;i++){var a=e.start(i),o=e.end(i),s=a.toFixed(2),u=o.toFixed(2),l=s+"|=="+(o-a).toFixed(2)+"==|"+u;if(n+=l,0===r.length&&o>t){var d=n.length-Math.floor(l.length/2);r=" ".repeat(d)+"^"+t}if(i<e.length-1){var c=e.start(i+1),f=" ~"+(c-o).toFixed(2)+"~ ";if(n+=f,0===r.length&&t<c){var v=n.length-Math.floor(f.length/2);r=" ".repeat(v)+"^"+t}}}0===r.length&&(r=" ".repeat(n.length)+"^"+t);return n+"\n"+r}(t.buffered,t.position.getPolled()),"\n"+e),this._observationRef.setValue(t)},e}(),Ot=function(){function e(e,t){this._last=e,this._wanted=t}var t=e.prototype;return t.serialize=function(){return[this._last,this._wanted]},t.getPolled=function(){return this._last},t.getWanted=function(){var e;return null!==(e=this._wanted)&&void 0!==e?e:this._last},t.forceWantedPosition=function(e){this._wanted=e},t.isAwaitingFuturePosition=function(){return null!==this._wanted},e}();function Nt(e,t){if(null===e)return 0;var n=t?"LOW_LATENCY":"DEFAULT",r=p.getCurrent(),i=r.RESUME_GAP_AFTER_SEEKING,a=r.RESUME_GAP_AFTER_NOT_ENOUGH_DATA,o=r.RESUME_GAP_AFTER_BUFFERING;switch(e.reason){case"seeking":return i[n];case"not-ready":return a[n];case"buffering":return o[n]}}function Lt(e){return{buffered:e.buffered,position:e.currentTime,duration:e.duration,ended:e.ended,paused:e.paused,playbackRate:e.playbackRate,readyState:e.readyState,seeking:e.seeking}}function Ut(e,t,n){var r=t(e.getReference(),n);return{getCurrentTime:function(){return e.getCurrentTime()},getReadyState:function(){return e.getReadyState()},getPlaybackRate:function(){return e.getPlaybackRate()},getIsPaused:function(){return e.getIsPaused()},getReference:function(){return r},listen:function(e,t){var i;n.isCancelled()||!0===(null===(i=null==t?void 0:t.clearSignal)||void 0===i?void 0:i.isCancelled())||r.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},deriveReadOnlyObserver:function(e){return Ut(this,e,n)}}}var Bt=function(e){function t(t){var n;return(n=e.call(this)||this)._canceller=new ht,n._adaptationRef=t,n._updateToken=!1,n.refresh=b,n}u(t,e);var n=t.prototype;return n.start=function(e){if(this._updateToken=!0,null===e)return this._lastEmitted=null,this._updateToken=!1,void this._adaptationRef.setValue(null);var t=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:e.adaptation,switchingMode:e.switchingMode,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:e.adaptation.id,switchingMode:e.switchingMode,representations:t,relativeResumingPosition:void 0}))},n.updateTrack=function(e){if(this._updateToken=!0,null===e){if(null===this._lastEmitted)return;return this._updateToken=!1,this._canceller.cancel(),this._canceller=new ht,this._lastEmitted=null,void this._adaptationRef.setValue(null)}var t=e.adaptation,n=e.switchingMode,r=e.relativeResumingPosition;this._canceller.cancel(),this._canceller=new ht;var i=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:t,switchingMode:n,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:t.id,switchingMode:n,representations:i,relativeResumingPosition:r}))},n._constructLockedRepresentationsReference=function(e){var t=new A({representationIds:[],switchingMode:"lazy"}),n=this;return this.refresh=r,this._canceller.signal.register((function(){n.refresh=b})),e.lockedRepresentations.onUpdate(r,{clearSignal:this._canceller.signal,emitCurrentValue:!1}),r(),t;function r(){var r,i,a=e.lockedRepresentations.getValue();if(null===a)i=e.adaptation.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})),r="lazy";else{var o=a.representationIds;if(r=a.switchingMode,0===(i=e.adaptation.representations.filter((function(e){return Qe(o,e.id)})).filter((function(e){return!0===e.isSupported&&!1!==e.decipherable}))).length)return void n.trigger("noPlayableLockedRepresentation",null)}if(i.length<=0)return e.adaptation.isSupported=!1,void n.trigger("noPlayableRepresentation",null);var s=t.getValue(),u=i.map((function(e){return e.id})).slice().sort();if(u.length===s.representationIds.length){for(var l=0;l<u.length;l++)if(s.representationIds[l]!==u[l])return void t.setValue({representationIds:u,switchingMode:r})}else t.setValue({representationIds:u,switchingMode:r})}},n.dispose=function(){this.removeEventListener(),this._canceller.cancel(),this._adaptationRef.finish()},t}(ie);function Ft(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return zt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function zt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Vt=function(e){function t(t){var n,r;return(n=e.call(this)||this)._storedPeriodInfo=[],n._isDisposed=!1,n._cachedPeriodInfo=new WeakMap,n._isTrickModeTrackEnabled=t.preferTrickModeTracks,n._defaultAudioTrackSwitchingMode=null!==(r=t.defaultAudioTrackSwitchingMode)&&void 0!==r?r:p.getCurrent().DEFAULT_AUDIO_TRACK_SWITCHING_MODE,n}u(t,e);var n=t.prototype;return n.getAvailablePeriods=function(){return this._storedPeriodInfo.reduce((function(e,t){return t.isPeriodAdvertised&&e.push(Ht(t.period)),e}),[])},n.onManifestUpdate=function(e){for(var t,n,r,i,a,o,s,u=this,l=p.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=e.periods,c=[],f=0,v=function(e){var i=u._storedPeriodInfo[e].period,a=d[f];if(void 0===a)for(var o=u._storedPeriodInfo.length-1;o>=e;o--)u._storedPeriodInfo[o].inManifest=!1,Wt(u._storedPeriodInfo[o])&&u._removePeriodObject(o);else if(i===a){f++;var s=u._storedPeriodInfo[e].text.storedSettings;if(null!==s)if(!Fe(a,"text").some((function(e){return e.id===s.adaptation.id}))){oe.warn("TS: Chosen text Adaptation not available anymore");var v=u._storedPeriodInfo[e];if(v.text.storedSettings=null,u.trigger("trackUpdate",{period:Ht(a),trackType:"text",reason:"missing"}),u._isDisposed)return{v:void 0};var p=Kt(u._storedPeriodInfo,v.period.id);void 0!==p&&null===p.text.storedSettings&&(null===(t=p.text.dispatcher)||void 0===t||t.updateTrack(null))}var m=u._storedPeriodInfo[e].video.storedSettings;if(null!==m){var g=Fe(a,"video");if(!g.some((function(e){return e.id===m.adaptation.id}))){oe.warn("TS: Chosen video Adaptation not available anymore");var y,_=u._storedPeriodInfo[e];if(0===g.length)y=null;else{var b=g[0],S=Gt(b,u._isTrickModeTrackEnabled),E=new A(null);y={adaptationBase:b,adaptation:S,switchingMode:l,lockedRepresentations:E}}if(_.video.storedSettings=y,u.trigger("trackUpdate",{period:Ht(a),trackType:"video",reason:"missing"}),u._isDisposed)return{v:void 0};var T=Kt(u._storedPeriodInfo,_.period.id);void 0!==T&&T.video.storedSettings===y&&(null===(n=T.video.dispatcher)||void 0===n||n.updateTrack(y))}}var k=u._storedPeriodInfo[e].audio.storedSettings;if(null!==k){var w=Fe(a,"audio");if(!w.some((function(e){return e.id===k.adaptation.id}))){oe.warn("TS: Chosen audio Adaptation not available anymore");var I=u._storedPeriodInfo[e],R=0===w.length?null:{adaptation:w[0],switchingMode:u._defaultAudioTrackSwitchingMode,lockedRepresentations:new A(null)};if(I.audio.storedSettings=R,u.trigger("trackUpdate",{period:Ht(a),trackType:"audio",reason:"missing"}),u._isDisposed)return{v:void 0};var x=Kt(u._storedPeriodInfo,I.period.id);void 0!==x&&x.audio.storedSettings===R&&(null===(r=x.audio.dispatcher)||void 0===r||r.updateTrack(R))}}}else if(i.start<=a.start)u._storedPeriodInfo[e].inManifest=!1,Wt(u._storedPeriodInfo[e])&&(u._removePeriodObject(e),e--);else{var C=jt(a,!0,u._isTrickModeTrackEnabled,u._defaultAudioTrackSwitchingMode);u._storedPeriodInfo.splice(e,0,C),c.push(C),f++}h=e},h=0;h<this._storedPeriodInfo.length;h++)if(s=v(h))return s.v;if(f<d.length){var m,g=d.slice(f).map((function(e){return jt(e,!0,u._isTrickModeTrackEnabled,u._defaultAudioTrackSwitchingMode)}));(m=this._storedPeriodInfo).push.apply(m,g),c.push.apply(c,g)}for(var y,_=Ft(this._storedPeriodInfo);!(y=_()).done;){var b=y.value;null===(i=b.audio.dispatcher)||void 0===i||i.refresh(),null===(a=b.video.dispatcher)||void 0===a||a.refresh(),null===(o=b.text.dispatcher)||void 0===o||o.refresh()}},n.onDecipherabilityUpdates=function(){for(var e,t,n,r,i=Ft(this._storedPeriodInfo);!(r=i()).done;){var a=r.value;null===(e=a.audio.dispatcher)||void 0===e||e.refresh(),null===(t=a.video.dispatcher)||void 0===t||t.refresh(),null===(n=a.text.dispatcher)||void 0===n||n.refresh()}},n.addTrackReference=function(e,t,n){var r=this,i=Kt(this._storedPeriodInfo,t.id);if(void 0===i){i=jt(t,!1,this._isTrickModeTrackEnabled,this._defaultAudioTrackSwitchingMode);for(var a=!1,o=0;o<this._storedPeriodInfo.length;o++)this._storedPeriodInfo[o].period.start>t.start&&(this._storedPeriodInfo.splice(o,0,i),a=!0);a||this._storedPeriodInfo.push(i)}if(i.isPeriodAdvertised||(i.isPeriodAdvertised=!0,this.trigger("newAvailablePeriods",[{id:t.id,start:t.start,end:t.end}]),!this._isDisposed))if(null===i[e].dispatcher){var s=i[e].storedSettings,u=new Bt(n);i[e].dispatcher=u,u.addEventListener("noPlayableRepresentation",(function(){var n,i,a,o,s=xe(null!==(n=t.adaptations[e])&&void 0!==n?n:[],(function(e){return!1!==e.isSupported&&e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})).length>0}));if(void 0===s){var u=new Se("NO_PLAYABLE_REPRESENTATION","No "+e+" Representation can be played",{tracks:void 0});return r.trigger("error",u),void r.dispose()}var l=null===(i=Kt(r._storedPeriodInfo,t.id))||void 0===i?void 0:i[e];if(!_(l)){var d={adaptation:s,switchingMode:"audio"===e?r._defaultAudioTrackSwitchingMode:"reload",lockedRepresentations:new A(null)};l.storedSettings=d,r.trigger("trackUpdate",{period:Ht(t),trackType:e,reason:"no-playable-representation"}),r._isDisposed||_(l=null===(a=Kt(r._storedPeriodInfo,t.id))||void 0===a?void 0:a[e])||l.storedSettings!==d||null===(o=l.dispatcher)||void 0===o||o.updateTrack(d)}})),u.addEventListener("noPlayableLockedRepresentation",(function(){null==s||s.lockedRepresentations.setValue(null),r.trigger("brokenRepresentationsLock",{period:{id:t.id,start:t.start,end:t.end},trackType:e})})),u.start(s)}else oe.error("TS: Subject already added for "+e+" and Period "+t.start)},n.removeTrackReference=function(e,t){var n=function(e,t){for(var n=0;n<e.length;n++){if(e[n].period.id===t.id)return n}}(this._storedPeriodInfo,t);if(void 0!==n){var r=this._storedPeriodInfo[n],i=r[e];null!==(null==i?void 0:i.dispatcher)?(i.dispatcher.dispose(),i.dispatcher=null,Wt(r)&&this._removePeriodObject(n)):oe.warn("TS: TrackDispatcher already removed for "+e+" and Period "+t.start)}else oe.warn("TS: "+e+" not found for period",t.start)},n.getPeriodObjectFromPeriod=function(e){var t=Kt(this._storedPeriodInfo,e.id);return void 0===t&&void 0!==e?this._cachedPeriodInfo.get(e):t},n.getPeriodObjectFromId=function(e){return Kt(this._storedPeriodInfo,e)},n.disableVideoTrickModeTracks=function(){this._isTrickModeTrackEnabled&&(this._isTrickModeTrackEnabled=!1,this._resetVideoTrackChoices("trickmode-disabled"))},n.enableVideoTrickModeTracks=function(){this._isTrickModeTrackEnabled||(this._isTrickModeTrackEnabled=!0,this._resetVideoTrackChoices("trickmode-enabled"))},n.resetPeriodObjects=function(){for(var e,t,n,r=this._storedPeriodInfo.length-1;r>=0;r--){var i=this._storedPeriodInfo[r];null===(e=i.audio.dispatcher)||void 0===e||e.dispose(),i.audio.dispatcher=null,null===(t=i.video.dispatcher)||void 0===t||t.dispose(),i.video.dispatcher=null,null===(n=i.text.dispatcher)||void 0===n||n.dispose(),i.text.dispatcher=null,i.inManifest||this._removePeriodObject(r)}},n.isTrickModeEnabled=function(){return this._isTrickModeTrackEnabled},n.setAudioTrack=function(e){var t=e.periodRef,n=e.trackId,r=e.switchingMode,i=e.lockedRepresentations,a=e.relativeResumingPosition;return this._setAudioOrTextTrack({bufferType:"audio",periodRef:t,trackId:n,switchingMode:null!=r?r:this._defaultAudioTrackSwitchingMode,reprsToLock:i,relativeResumingPosition:a})},n.setTextTrack=function(e,t){return this._setAudioOrTextTrack({bufferType:"text",periodRef:e,trackId:t,switchingMode:"direct",reprsToLock:null,relativeResumingPosition:void 0})},n._setAudioOrTextTrack=function(e){var t,n,r=e.bufferType,i=e.periodRef,a=e.trackId,o=e.switchingMode,s=e.reprsToLock,u=e.relativeResumingPosition,l=i.period,d=xe(null!==(t=l.adaptations[r])&&void 0!==t?t:[],(function(e){var t=e.id;return!0===e.isSupported&&t===a}));if(void 0===d)throw new Error("Wanted "+r+" track not found.");var c,f=i[r];if(null===s)c=new A(null);else{var v=this._getRepresentationsToLock(d,s),p="audio"===r?this._defaultAudioTrackSwitchingMode:"direct";c=new A({representationIds:v,switchingMode:p})}var h={adaptation:d,switchingMode:o,lockedRepresentations:c,relativeResumingPosition:u};if(f.storedSettings=h,this.trigger("trackUpdate",{period:Ht(l),trackType:r,reason:"manual"}),!this._isDisposed){var m=Kt(this._storedPeriodInfo,l.id);void 0!==m&&m[r].storedSettings===h&&(null===(n=m[r].dispatcher)||void 0===n||n.updateTrack(h))}},n.setVideoTrack=function(e){var t,n,r=e.periodRef,i=e.trackId,a=e.switchingMode,o=e.lockedRepresentations,s=e.relativeResumingPosition,u=r.period,l=xe(null!==(t=u.adaptations.video)&&void 0!==t?t:[],(function(e){var t=e.id;return!0===e.isSupported&&t===i}));if(void 0===l)throw new Error("Wanted video track not found.");var d,c=p.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,f=r.video,v=Gt(l,this._isTrickModeTrackEnabled);if(null===o)d=new A(null);else{var h=this._getRepresentationsToLock(l,o);d=new A({representationIds:h,switchingMode:c})}var m={adaptationBase:l,switchingMode:null!=a?a:c,adaptation:v,relativeResumingPosition:s,lockedRepresentations:d};if(f.storedSettings=m,this.trigger("trackUpdate",{period:Ht(u),trackType:"video",reason:"manual"}),!this._isDisposed){var g=Kt(this._storedPeriodInfo,u.id);void 0!==g&&g.video.storedSettings===m&&(null===(n=g.video.dispatcher)||void 0===n||n.updateTrack(m))}},n.disableTrack=function(e,t){var n,r,i=e[t];if(null!==i.storedSettings&&("text"!==t&&(null===(n=e[t].storedSettings)||void 0===n||n.lockedRepresentations.finish()),i.storedSettings=null,this.trigger("trackUpdate",{period:Ht(e.period),trackType:t,reason:"manual"}),!this._isDisposed)){var a=Kt(this._storedPeriodInfo,e.period.id);void 0!==a&&null===a[t].storedSettings&&(null===(r=a[t].dispatcher)||void 0===r||r.updateTrack(null))}},n.getChosenAudioTrack=function(e){return null===e.audio.storedSettings?null:We(e.audio.storedSettings.adaptation,!0)},n.getChosenTextTrack=function(e){return null===e.text.storedSettings?null:Ge(e.text.storedSettings.adaptation)},n.getChosenVideoTrack=function(e){return null===e.video.storedSettings?null:je(e.video.storedSettings.adaptation,!0)},n.getAvailableAudioTracks=function(e){var t=e.audio.storedSettings,n=null!==t?t.adaptation.id:null;return Fe(e.period,"audio").map((function(e){var t=null!==n&&n===e.id;return d(We(e,!0),{active:t})}))},n.getAvailableTextTracks=function(e){var t=e.text.storedSettings,n=null!==t?t.adaptation.id:null;return Fe(e.period,"text").map((function(e){var t=null!==n&&n===e.id;return d(Ge(e),{active:t})}))},n.getAvailableVideoTracks=function(e){var t=e.video.storedSettings,n=null===t?void 0:t.adaptation.id;return Fe(e.period,"video").map((function(e){var t=null!==n&&n===e.id,r=je(e,!0),i=void 0!==r.trickModeTracks?r.trickModeTracks.map((function(e){var t=null!==n&&n===e.id;return d(e,{active:t})})):[],a=d(r,{active:t});return void 0!==i&&(a.trickModeTracks=i),a}))},n.getLockedAudioRepresentations=function(e){var t=e.audio.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representationIds},n.getLockedVideoRepresentations=function(e){var t=e.video.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representationIds},n.lockAudioRepresentations=function(e,t){var n,r=e.audio.storedSettings;if(null!==r){var i=p.getCurrent().DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representationIds:a,switchingMode:o})}},n.lockVideoRepresentations=function(e,t){var n,r=e.video.storedSettings;if(null!==r){var i=p.getCurrent().DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representationIds:a,switchingMode:o})}},n.unlockAudioRepresentations=function(e){var t=e.audio.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},n.unlockVideoRepresentations=function(e){var t=e.video.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},n.dispose=function(){for(this._isDisposed=!0;;){var e=this._storedPeriodInfo.pop();if(void 0===e)return;e.isRemoved=!0}},n._resetVideoTrackChoices=function(e){for(var t,n=0;n<this._storedPeriodInfo.length;n++){var r=this._storedPeriodInfo[n];if(null!==r.video.storedSettings){var i=r.video.storedSettings.adaptationBase;if(null!==i){var a=Gt(i,this._isTrickModeTrackEnabled);r.video.storedSettings.adaptationBase=i,r.video.storedSettings.adaptation=a}}}for(var o=this._storedPeriodInfo.slice(),s=0;s<o.length;s++){var u=o[s].period,l=o[s].video.storedSettings;if(this.trigger("trackUpdate",{period:Ht(u),trackType:"video",reason:e}),this._isDisposed)return;var d=Kt(this._storedPeriodInfo,u.id);void 0!==d&&d.video.storedSettings===l&&(null===(t=d.video.dispatcher)||void 0===t||t.updateTrack(l))}},n._removePeriodObject=function(e){var t=this._storedPeriodInfo[e];this._storedPeriodInfo[e].isRemoved=!0,this._storedPeriodInfo.splice(e,1),this._cachedPeriodInfo.set(t.period,t)},n._getRepresentationsToLock=function(e,t){var n=t.reduce((function(t,n){var r=xe(e.representations,(function(e){return e.id===n}));return void 0===r?oe.warn("API: Wanted locked Representation not found."):t.push(r.id),t}),[]);if(0===n.length)throw new Error("Cannot lock Representations: None of the given Representation id are found");return n},t}(ie);function Kt(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.period.id===t)return r}}function Wt(e){var t,n,r;return!e.inManifest&&null===(null===(t=e.text)||void 0===t?void 0:t.dispatcher)&&null===(null===(n=e.audio)||void 0===n?void 0:n.dispatcher)&&null===(null===(r=e.video)||void 0===r?void 0:r.dispatcher)}function Gt(e,t){var n;return t&&void 0!==(null===(n=e.trickModeTracks)||void 0===n?void 0:n[0])?e.trickModeTracks[0]:e}function jt(e,t,n,r){var i,a,o=Fe(e,"audio")[0],s=Fe(e,"video")[0],u=Gt(s,n),l=p.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=void 0!==o?{adaptation:o,switchingMode:r,lockedRepresentations:new A(null)}:null,c=void 0!==u?{adaptation:u,adaptationBase:s,switchingMode:l,lockedRepresentations:new A(null)}:null,f=null,v=(null!==(i=e.adaptations.text)&&void 0!==i?i:[]).filter((function(e){return!0===e.isForcedSubtitles}));if(v.length>0){if(null!=o){var h=xe(v,(function(e){return e.normalizedLanguage===o.normalizedLanguage}));void 0!==h&&(f=h)}null===f&&(f=null!==(a=xe(v,(function(e){return void 0===e.normalizedLanguage})))&&void 0!==a?a:null)}var m=null;return null!==f&&(m={adaptation:f,switchingMode:"direct",lockedRepresentations:new A(null)}),{period:e,inManifest:t,isPeriodAdvertised:!1,isRemoved:!1,audio:{storedSettings:d,dispatcher:null},video:{storedSettings:c,dispatcher:null},text:{storedSettings:m,dispatcher:null}}}function Ht(e){return{start:e.start,end:e.end,id:e.id}}function qt(e,t){var n=p.getCurrent().FORCED_ENDED_THRESHOLD;if(e.ended)return"ENDED";if(null!==t){var r=Math.abs(e.duration-e.currentTime);return null!=n&&r<n?"ENDED":"seeking"===t?"SEEKING":"freezing"===t?"FREEZING":"BUFFERING"}return e.paused?"PAUSED":"PLAYING"}function Yt(e){return"LOADING"!==e&&"RELOADING"!==e&&"STOPPED"!==e}function Qt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $t(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $t(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function $t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Xt=Je(),Zt=function(e,t){var n=e;if(!0===n.webkitSupportsPresentationMode&&"function"==typeof n.webkitSetPresentationMode){var r="picture-in-picture"===n.webkitPresentationMode,i=new A({isEnabled:r,pipWindow:null},t);return K(n,"webkitpresentationmodechanged",(function(){var e="picture-in-picture"===n.webkitPresentationMode;i.setValue({isEnabled:e,pipWindow:null})}),t),i}var a=document.pictureInPictureElement===n,o=new A({isEnabled:a,pipWindow:null},t);return K(n,"enterpictureinpicture",(function(e){var t;o.setValue({isEnabled:!0,pipWindow:null!==(t=e.pictureInPictureWindow)&&void 0!==t?t:null})}),t),K(n,"leavepictureinpicture",(function(){o.setValue({isEnabled:!1,pipWindow:null})}),t),o},Jt=function(e,t){var n,r=function(e){var t,n=document;_(n.hidden)?_(n.mozHidden)?_(n.msHidden)?_(n.webkitHidden)||(t="webkit"):t="ms":t="moz":t="";var r=y(t)?t+"Hidden":"hidden",i=y(t)?t+"visibilitychange":"visibilitychange",a=document[r],o=new A(!a,e);return K(document,i,(function(){var e=!document[r];o.setValueIfChanged(e)}),e),o}(t),i=new A(!0,t);return t.register((function(){clearTimeout(n),n=void 0})),r.onUpdate(a,{clearSignal:t}),e.onUpdate(a,{clearSignal:t}),a(),i;function a(){if(clearTimeout(n),n=void 0,e.getValue().isEnabled||r.getValue())i.setValueIfChanged(!0);else{var t=p.getCurrent().INACTIVITY_DELAY;n=setTimeout((function(){i.setValueIfChanged(!1)}),t)}}},en=function(e,t,n){var r=null==g.devicePixelRatio||0===g.devicePixelRatio?1:g.devicePixelRatio,i=new A({width:e.clientWidth,height:e.clientHeight,pixelRatio:r},n),a=b;t.onUpdate(s,{clearSignal:n}),K(g,"resize",s,n),K(e,"enterpictureinpicture",s,n),K(e,"leavepictureinpicture",s,n);var o=setInterval(s,2e4);return s(),n.register((function(){a(),clearInterval(o)})),i;function s(){a();var n=t.getValue(),o=n.pipWindow;if(n.isEnabled)if(_(o)){var s=i.getValue();void 0===s.width&&void 0===s.height&&s.pixelRatio===r||i.setValue({width:void 0,height:void 0,pixelRatio:r})}else{var u=function(){d()};o.addEventListener("resize",u),a=function(){o.removeEventListener("resize",u),a=b},d()}else{var l=i.getValue();l.width===e.clientWidth&&l.height===e.clientHeight&&l.pixelRatio===r||i.setValue({width:e.clientWidth,height:e.clientHeight,pixelRatio:r})}function d(){var e=i.getValue();e.width===(null==o?void 0:o.width)&&e.height===(null==o?void 0:o.height)&&e.pixelRatio===r||i.setValue({width:null==o?void 0:o.width,height:null==o?void 0:o.height,pixelRatio:r})}}},tn=function(e){var t,n,r=null==g.devicePixelRatio||0===g.devicePixelRatio?1:g.devicePixelRatio,i=new A({width:null===(t=g.screen)||void 0===t?void 0:t.width,height:null===(n=g.screen)||void 0===n?void 0:n.height,pixelRatio:r},e),a=setInterval((function(){var e=i.getValue();e.width===screen.width&&e.height===screen.height&&e.pixelRatio===r||i.setValue({width:screen.width,height:screen.height,pixelRatio:r})}),2e4);return e.register((function(){clearInterval(a)})),i},nn=["manifestLoader","segmentLoader"],rn=function(t){function n(e){var n;void 0===e&&(e={}),n=t.call(this)||this;var r=function(e){var t,n,r,i,a,o,s=p.getCurrent(),u=s.DEFAULT_BASE_BANDWIDTH,l=s.DEFAULT_VIDEO_RESOLUTION_LIMIT,d=s.DEFAULT_MAX_BUFFER_AHEAD,c=s.DEFAULT_MAX_BUFFER_BEHIND,f=s.DEFAULT_MAX_VIDEO_BUFFER_SIZE,v=s.DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN,h=s.DEFAULT_WANTED_BUFFER_AHEAD;if(_(e.maxBufferAhead))t=d;else if(t=Number(e.maxBufferAhead),isNaN(t))throw new Error("Invalid maxBufferAhead parameter. Should be a number.");if(_(e.maxBufferBehind))n=c;else if(n=Number(e.maxBufferBehind),isNaN(n))throw new Error("Invalid maxBufferBehind parameter. Should be a number.");if(_(e.wantedBufferAhead))r=h;else if(r=Number(e.wantedBufferAhead),isNaN(r))throw new Error("Invalid wantedBufferAhead parameter. Should be a number.");if(_(e.maxVideoBufferSize))i=f;else if(i=Number(e.maxVideoBufferSize),isNaN(i))throw new Error("Invalid maxVideoBufferSize parameter. Should be a number.");var m=_(e.videoResolutionLimit)?l:e.videoResolutionLimit,g=_(e.throttleVideoBitrateWhenHidden)?v:!!e.throttleVideoBitrateWhenHidden;if(_(e.videoElement))a=document.createElement("video");else{if(!(e.videoElement instanceof HTMLMediaElement))throw new Error("Invalid videoElement parameter. Should be a HTMLMediaElement.");a=e.videoElement}if(_(e.baseBandwidth))o=u;else if(o=Number(e.baseBandwidth),isNaN(o))throw new Error("Invalid baseBandwidth parameter. Should be a number.");return{maxBufferAhead:t,maxBufferBehind:n,videoResolutionLimit:m,videoElement:a,wantedBufferAhead:r,maxVideoBufferSize:i,throttleVideoBitrateWhenHidden:g,baseBandwidth:o}}(e),i=r.baseBandwidth,a=r.videoResolutionLimit,o=r.maxBufferAhead,s=r.maxBufferBehind,u=r.throttleVideoBitrateWhenHidden,l=r.videoElement,d=r.wantedBufferAhead,c=r.maxVideoBufferSize;l.preload="auto",n.version="4.0.0",n.log=oe,n.state="STOPPED",n.videoElement=l;var f=new ht;n._destroyCanceller=f,n._priv_pictureInPictureRef=Zt(l,f.signal),n._priv_speed=new A(l.playbackRate,n._destroyCanceller.signal),n._priv_preferTrickModeTracks=!1,n._priv_contentLock=new A(!1,n._destroyCanceller.signal),n._priv_bufferOptions={wantedBufferAhead:new A(d,n._destroyCanceller.signal),maxBufferAhead:new A(o,n._destroyCanceller.signal),maxBufferBehind:new A(s,n._destroyCanceller.signal),maxVideoBufferSize:new A(c,n._destroyCanceller.signal)},n._priv_bitrateInfos={lastBitrates:{audio:i,video:i}},n._priv_throttleVideoBitrateWhenHidden=u,n._priv_videoResolutionLimit=a,n._priv_currentError=null,n._priv_contentInfos=null,n._priv_contentEventsMemory={},n._priv_reloadingMetadata={},n._priv_lastAutoPlay=!1,n._priv_worker=null;var v=function(){n.trigger("volumeChange",{volume:l.volume,muted:l.muted})};return l.addEventListener("volumechange",v),f.signal.register((function(){l.removeEventListener("volumechange",v)})),n}u(n,t),n.addFeatures=function(e){!function(e){for(var t=0;t<e.length;t++){var n=e[t];if("function"==typeof n)n(Ie);else{if(_(n)||"function"!=typeof n._addFeature)throw new Error("Unrecognized feature");n._addFeature(Ie)}}}(e)};var r=n.prototype;return r.attachWorker=function(t){var n=this;return new Promise((function(r,i){var a;if("function"!=typeof Worker)return oe.warn("API: Cannot rely on a WebWorker: Worker API unavailable"),i(new Ae("INCOMPATIBLE_ERROR","Worker unavailable"));if(!le)return oe.warn("API: Cannot rely on a WebWorker: WebAssembly unavailable"),i(new Ae("INCOMPATIBLE_ERROR","WebAssembly unavailable"));if("string"==typeof t.workerUrl)n._priv_worker=new Worker(t.workerUrl);else{var o=URL.createObjectURL(t.workerUrl);n._priv_worker=new Worker(o),URL.revokeObjectURL(o)}n._priv_worker.onerror=function(e){null!==n._priv_worker&&(n._priv_worker.terminate(),n._priv_worker=null),oe.error("API: Unexpected worker error",e.error instanceof Error?e.error:void 0),i(new Ae("UNKNOWN_ERROR",'Unexpected Worker "error" event'))};n._priv_worker.addEventListener("message",(function e(t){var a=t.data;"init-error"===a.type?(oe.warn("API: Processing InitError worker message: detaching worker"),null!==n._priv_worker&&(n._priv_worker.removeEventListener("message",e),n._priv_worker.terminate(),n._priv_worker=null),i(new Ae("SETUP_ERROR","Worker parser initialization failed: "+a.value.errorMessage))):"init-success"===a.type&&(oe.info("API: InitSuccess received from worker."),null!==n._priv_worker&&n._priv_worker.removeEventListener("message",e),r())})),oe.debug("---\x3e Sending To Worker:","init"),n._priv_worker.postMessage({type:"init",value:{dashWasmUrl:t.dashWasmUrl,logLevel:oe.getLevel(),sendBackLogs:e(),date:Date.now(),timestamp:Me(),hasVideo:"video"===(null===(a=n.videoElement)||void 0===a?void 0:a.nodeName.toLowerCase()),hasMseInWorker:ue}}),oe.addEventListener("onLogLevelChange",(function(t){null!==n._priv_worker&&(oe.debug("---\x3e Sending To Worker:","log-level-update"),n._priv_worker.postMessage({type:"log-level-update",value:{logLevel:t,sendBackLogs:e()}}))}),n._destroyCanceller.signal)}))},r.getCurrentModeInformation=function(){return null===this._priv_contentInfos?null:{isDirectFile:this._priv_contentInfos.isDirectFile,useWorker:this._priv_contentInfos.useWorker}},r.addEventListener=function(e,n){return t.prototype.addEventListener.call(this,e,n)},r.stop=function(){null!==this._priv_contentInfos&&this._priv_contentInfos.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),"STOPPED"!==this.state&&this._priv_setPlayerState("STOPPED")},r.dispose=function(){this.stop(),null!==this.videoElement&&wt(this.videoElement).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";oe.error("API: Could not dispose decryption resources: "+t)})),this._destroyCanceller.cancel(),this._priv_reloadingMetadata={},this.videoElement=null,null!==this._priv_worker&&(this._priv_worker.terminate(),this._priv_worker=null)},r.loadVideo=function(e){var t=function(e){var t,n,r,i,a,o,s,u,l,c,f=p.getCurrent(),v=f.DEFAULT_AUTO_PLAY,h=f.DEFAULT_CODEC_SWITCHING_BEHAVIOR,m=f.DEFAULT_ENABLE_FAST_SWITCHING,g=f.DEFAULT_TEXT_TRACK_MODE;if(_(e))throw new Error("No option set on loadVideo");if(_(e.url)){if(_(e.initialManifest)&&_(e.manifestLoader))throw new Error("Unable to load a content: no url set on loadVideo.\nPlease provide at least either an `url` argument, a `initialManifest` option or a `manifestLoader` option so the RxPlayer can load the content.")}else i=String(e.url);if(_(e.transport))throw new Error("No transport set on loadVideo");a=String(e.transport);var y=_(e.autoPlay)?v:!!e.autoPlay;if(_(e.keySystems))o=[];else for(var b,S=xt(o=Array.isArray(e.keySystems)?e.keySystems:[e.keySystems]);!(b=S()).done;){var E=b.value;if("string"!=typeof E.type||"function"!=typeof E.getLicense)throw new Error("Invalid key system given: Missing type string or getLicense callback")}var T=void 0!==e.lowLatencyMode&&!!e.lowLatencyMode,k=e.initialManifest,w=null!==(t=e.minimumManifestUpdateInterval)&&void 0!==t?t:0,A=null!==(n=e.defaultAudioTrackSwitchingMode)&&void 0!==n?n:void 0;void 0===A||Qe(["seamless","direct","reload"],A)||(oe.warn("The `defaultAudioTrackSwitchingMode` loadVideo option must match one of the following strategy name:\n- `seamless`\n- `direct`\n- `reload`"),A=void 0);var I=_(e.onCodecSwitch)?h:e.onCodecSwitch;if(Qe(["continue","reload"],I)||(oe.warn("The `onCodecSwitch` loadVideo option must match one of the following string:\n- `continue`\n- `reload`\nIf badly set, "+h+" will be used as default"),I=h),_(e.textTrackMode))s=g;else{if("native"!==e.textTrackMode&&"html"!==e.textTrackMode)throw new Error("Invalid textTrackMode.");s=e.textTrackMode}if("html"===s){if(_(e.textTrackElement))throw new Error('You have to provide a textTrackElement in "html" textTrackMode.');if(!(e.textTrackElement instanceof HTMLElement))throw new Error("textTrackElement should be an HTMLElement.");l=e.textTrackElement}else _(e.textTrackElement)||oe.warn('API: You have set a textTrackElement without being in an "html" textTrackMode. It will be ignored.');if(_(e.mode))u="auto";else{if(!Qe(["auto","multithread","main"],e.mode))throw new Error("Invalid `mode` option.");u=e.mode}var R=_(e.enableFastSwitching)?m:e.enableFastSwitching;if(!_(e.startAt))if("wallClockTime"in e.startAt&&e.startAt.wallClockTime instanceof Date){var x=e.startAt.wallClockTime.getTime()/1e3;c=d({},e.startAt,{wallClockTime:x})}else c=e.startAt;var C=null!==(r=e.requestConfig)&&void 0!==r?r:{};return{__priv_patchLastSegmentInSidx:e.__priv_patchLastSegmentInSidx,__priv_manifestUpdateUrl:e.__priv_manifestUpdateUrl,checkMediaSegmentIntegrity:e.checkMediaSegmentIntegrity,autoPlay:y,defaultAudioTrackSwitchingMode:A,enableFastSwitching:R,initialManifest:k,keySystems:o,lowLatencyMode:T,manifestLoader:e.manifestLoader,minimumManifestUpdateInterval:w,requestConfig:C,onCodecSwitch:I,referenceDateTime:e.referenceDateTime,representationFilter:e.representationFilter,segmentLoader:e.segmentLoader,serverSyncInfos:e.serverSyncInfos,startAt:c,textTrackElement:l,textTrackMode:s,transport:a,mode:u,url:i}}(e);oe.info("API: Calling loadvideo",t.url,t.transport),this._priv_reloadingMetadata={options:t},this._priv_initializeContentPlayback(t),this._priv_lastAutoPlay=t.autoPlay},r.reload=function(e){var t,n,r,i,a,o,s=this._priv_reloadingMetadata,u=s.options,l=s.manifest,d=s.reloadPosition,c=s.reloadInPause;if(void 0===u)throw new Error("API: Can't reload without having previously loaded a content.");if(function(e){var t,n,r,i;if(null===e||"object"!=typeof e&&void 0!==e)throw new Error("API: reload - Invalid options format.");if(null===(null==e?void 0:e.reloadAt)||"object"!=typeof(null==e?void 0:e.reloadAt)&&void 0!==(null==e?void 0:e.reloadAt))throw new Error("API: reload - Invalid 'reloadAt' option format.");if("number"!=typeof(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position)&&void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.position))throw new Error("API: reload - Invalid 'reloadAt.position' option format.");if("number"!=typeof(null===(r=null==e?void 0:e.reloadAt)||void 0===r?void 0:r.relative)&&void 0!==(null===(i=null==e?void 0:e.reloadAt)||void 0===i?void 0:i.relative))throw new Error("API: reload - Invalid 'reloadAt.relative' option format.");if(!Array.isArray(null==e?void 0:e.keySystems)&&void 0!==(null==e?void 0:e.keySystems))throw new Error("API: reload - Invalid 'keySystems' option format.");if(void 0!==(null==e?void 0:e.autoPlay)&&"boolean"!=typeof e.autoPlay)throw new Error("API: reload - Invalid 'autoPlay' option format.")}(e),void 0!==(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position))i={position:e.reloadAt.position};else if(void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.relative)){if(void 0===d)throw new Error("Can't reload to a relative position when previous content was not loaded.");i={position:e.reloadAt.relative+d}}else void 0!==d&&(i={position:d});void 0!==(null==e?void 0:e.autoPlay)?a=e.autoPlay:void 0!==c&&(a=!c),void 0!==(null==e?void 0:e.keySystems)?o=e.keySystems:void 0!==(null===(r=this._priv_reloadingMetadata.options)||void 0===r?void 0:r.keySystems)&&(o=this._priv_reloadingMetadata.options.keySystems);var f=Object.assign(Object.assign({},u),{initialManifest:l});void 0!==i&&(f.startAt=i),void 0!==a&&(f.autoPlay=a),void 0!==o&&(f.keySystems=o),this._priv_initializeContentPlayback(f)},r.createDebugElement=function(e){if(null===Re.createDebugElement)throw new Error("Feature `DEBUG_ELEMENT` not added to the RxPlayer");var t=new ht;return Re.createDebugElement(e,this,t.signal),{dispose:function(){t.cancel()}}},r._priv_initializeContentPlayback=function(e){var t,n,r,i,a,o,s=this,u=e.autoPlay,l=e.defaultAudioTrackSwitchingMode,c=e.enableFastSwitching,f=e.initialManifest,v=e.keySystems,p=e.lowLatencyMode,h=e.minimumManifestUpdateInterval,m=e.requestConfig,g=e.onCodecSwitch,y=e.startAt,b=e.transport,S=e.checkMediaSegmentIntegrity,E=e.manifestLoader,T=e.referenceDateTime,k=e.segmentLoader,I=e.serverSyncInfos,R=e.mode,x=e.__priv_manifestUpdateUrl,C=e.__priv_patchLastSegmentInSidx,M=e.url;if(null===this.videoElement)throw new Error("the attached video element is disposed");var P,D,O="directfile"===b,N=new ht,L=this.videoElement,U=!1,B=null;if(O){if(null===Re.directfile)throw this.stop(),this._priv_currentError=null,new Error("DirectFile feature not activated in your build.");if(_(M))throw new Error("No URL for a DirectFile content");if(oe.info("API: Initializing DirectFile mode in the main thread"),B=this._priv_initializeMediaElementTracksStore(N.signal),N.isUsed())return;P=new Re.directfile.initDirectFile({autoPlay:u,keySystems:v,speed:this._priv_speed,startAt:y,url:M})}else{var F={lowLatencyMode:p,maxRetry:null===(t=m.manifest)||void 0===t?void 0:t.maxRetry,requestTimeout:null===(n=m.manifest)||void 0===n?void 0:n.timeout,connectionTimeout:null===(r=m.manifest)||void 0===r?void 0:r.connectionTimeout,minimumManifestUpdateInterval:h,initialManifest:f},z=se(),V={throttleBitrate:{},limitResolution:{}};this._priv_throttleVideoBitrateWhenHidden&&(z?V.throttleBitrate={video:w(Jt(this._priv_pictureInPictureRef,N.signal),(function(e){return e?1/0:0}),N.signal)}:oe.warn("API: Can't apply throttleVideoBitrateWhenHidden because browser can't be trusted for visibility.")),"videoElement"===this._priv_videoResolutionLimit?z?V.limitResolution={video:en(L,this._priv_pictureInPictureRef,N.signal)}:oe.warn("API: Can't apply videoResolutionLimit because browser can't be trusted for video size."):"screen"===this._priv_videoResolutionLimit&&(V.limitResolution={video:tn(N.signal)});var K={initialBitrates:this._priv_bitrateInfos.lastBitrates,lowLatencyMode:p,throttlers:V},W="native"===e.textTrackMode?{textTrackMode:"native"}:{textTrackMode:"html",textTrackElement:e.textTrackElement},G=d({enableFastSwitching:c,onCodecSwitch:g},this._priv_bufferOptions),j={lowLatencyMode:p,maxRetry:null===(i=m.segment)||void 0===i?void 0:i.maxRetry,requestTimeout:null===(a=m.segment)||void 0===a?void 0:a.timeout,connectionTimeout:null===(o=m.segment)||void 0===o?void 0:o.connectionTimeout},H=null!==Re.multithread&&null!==this._priv_worker&&"dash"===b&&nn.every((function(t){return _(e[t])}))&&"function"!=typeof e.representationFilter;if("main"===R||"auto"===R&&!H){if(null===Re.mainThreadMediaSourceInit)throw new Error("Cannot load video, neither in a WebWorker nor with the `MEDIA_SOURCE_MAIN` feature");var q=Re.transports[b];if("function"!=typeof q)throw this.stop(),this._priv_currentError=null,new Error('transport "'+b+'" not supported');var Y="string"==typeof e.representationFilter?(D=e.representationFilter,new Function("return ("+D+"(arguments[0], arguments[1]))")):e.representationFilter;oe.info("API: Initializing MediaSource mode in the main thread");var Q=q({lowLatencyMode:p,checkMediaSegmentIntegrity:S,manifestLoader:E,referenceDateTime:T,representationFilter:Y,segmentLoader:k,serverSyncInfos:I,__priv_manifestUpdateUrl:x,__priv_patchLastSegmentInSidx:C});P=new Re.mainThreadMediaSourceInit({adaptiveOptions:K,autoPlay:u,bufferOptions:G,keySystems:v,lowLatencyMode:p,transport:Q,manifestRequestSettings:F,segmentRequestOptions:j,speed:this._priv_speed,startAt:y,textTrackOptions:W,url:M})}else{if(null===Re.multithread)throw new Error("Cannot load video in multithread mode: `MULTI_THREAD` feature not imported.");if(null===this._priv_worker)throw new Error("Cannot load video in multithread mode: `attachWorker` method not called.");Xe(e.representationFilter),U=!0,oe.info("API: Initializing MediaSource mode in a WebWorker");var $={lowLatencyMode:p,checkMediaSegmentIntegrity:S,referenceDateTime:T,serverSyncInfos:I,manifestLoader:void 0,segmentLoader:void 0,representationFilter:e.representationFilter,__priv_manifestUpdateUrl:x,__priv_patchLastSegmentInSidx:C};P=new Re.multithread.init({adaptiveOptions:K,autoPlay:u,bufferOptions:G,keySystems:v,lowLatencyMode:p,transportOptions:$,manifestRequestSettings:F,segmentRequestOptions:j,speed:this._priv_speed,startAt:y,textTrackOptions:W,worker:this._priv_worker,url:M})}}var X={contentId:Xt(),originalUrl:M,currentContentCanceller:N,defaultAudioTrackSwitchingMode:l,initializer:P,isDirectFile:O,segmentBuffersStore:null,manifest:null,currentPeriod:null,activeAdaptations:null,activeRepresentations:null,tracksStore:null,mediaElementTracksStore:B,useWorker:U};P.addEventListener("error",(function(e){s._priv_onFatalError(e,X)})),P.addEventListener("warning",(function(e){var t=we(e,{defaultCode:"NONE",defaultReason:"An unknown error happened."});oe.warn("API: Sending warning:",t),s.trigger("warning",t)})),P.addEventListener("reloadingMediaSource",(function(e){X.segmentBuffersStore=null,null!==X.tracksStore&&X.tracksStore.resetPeriodObjects(),s._priv_lastAutoPlay=e.autoPlay})),P.addEventListener("inbandEvents",(function(e){return s.trigger("inbandEvents",e)})),P.addEventListener("streamEvent",(function(e){return s.trigger("streamEvent",e)})),P.addEventListener("streamEventSkip",(function(e){return s.trigger("streamEventSkip",e)})),P.addEventListener("activePeriodChanged",(function(e){return s._priv_onActivePeriodChanged(X,e)})),P.addEventListener("periodStreamReady",(function(e){return s._priv_onPeriodStreamReady(X,e)})),P.addEventListener("periodStreamCleared",(function(e){return s._priv_onPeriodStreamCleared(X,e)})),P.addEventListener("representationChange",(function(e){return s._priv_onRepresentationChange(X,e)})),P.addEventListener("adaptationChange",(function(e){return s._priv_onAdaptationChange(X,e)})),P.addEventListener("bitrateEstimateChange",(function(e){return s._priv_onBitrateEstimateChange(e)})),P.addEventListener("manifestReady",(function(e){return s._priv_onManifestReady(X,e)})),P.addEventListener("manifestUpdate",(function(e){return s._priv_onManifestUpdate(X,e)})),P.addEventListener("decipherabilityUpdate",(function(e){return s._priv_onDecipherabilityUpdate(X,e)})),P.addEventListener("loaded",(function(e){X.segmentBuffersStore=e.segmentBuffersStore})),P.prepare(),this.stop();var Z=new Dt(L,{withMediaSource:!O,lowLatencyMode:p});N.signal.register((function(){Z.stop()}));var J=function(e,t,n,r){var i=new A("LOADING",r);e.addEventListener("loaded",(function(){if("LOADING"===i.getValue()){if(i.setValue("LOADED"),!r.isCancelled()){var e=qt(t,null);"PAUSED"!==e&&i.setValue(e)}}else"RELOADING"===i.getValue()?i.setValue(qt(t,null)):o(null)}),r),e.addEventListener("reloadingMediaSource",(function(){Yt(i.getValue())&&i.setValueIfChanged("RELOADING")}),r);var a=null;return e.addEventListener("stalled",(function(e){e!==a&&(o(e),a=e)}),r),e.addEventListener("unstalled",(function(){null!==a&&(o(null),a=null)}),r),n.listen((function(e){Qe(["seeking","ended","play","pause"],e.event)&&o(a)}),{clearSignal:r}),i;function o(e){if(Yt(i.getValue())){var n=qt(t,e);"LOADED"===i.getValue()&&"PAUSED"===n||i.setValueIfChanged(n)}}}(P,L,Z,N.signal);N.signal.register((function(){P.dispose()}));var ee=function(e){switch(e){case"STOPPED":case"RELOADING":case"LOADING":break;case"ENDED":s._priv_reloadingMetadata.reloadInPause=!0,s._priv_reloadingMetadata.reloadPosition=Z.getReference().getValue().position.getPolled();break;default:var t=Z.getReference().getValue();s._priv_reloadingMetadata.reloadInPause=t.paused,s._priv_reloadingMetadata.reloadPosition=t.position.getWanted()}},te=null,ne=function(e){null!==te&&(te.cancel(),te=null),J.onUpdate((function(t,n){var r,i,a,o;Yt(t)&&(n(),null!==te&&te.cancel(),(te=new ht).linkToSignal(N.signal),e!==!L.paused&&(L.paused?s.trigger("pause",null):s.trigger("play",null)),r=L,i=function(){return s.trigger("play",null)},a=function(){return s.trigger("pause",null)},(o=N.signal).isCancelled()||null===r||(r.addEventListener("play",i),r.addEventListener("pause",a),o.register((function(){r.removeEventListener("play",i),r.removeEventListener("pause",a)}))))}),{emitCurrentValue:!1,clearSignal:N.signal})};ne(u),P.addEventListener("reloadingMediaSource",(function(e){ne(e.autoPlay)})),this._priv_currentError=null,this._priv_contentInfos=X;var re=null;J.onUpdate((function(e){ee(e),s._priv_setPlayerState(e),N.isUsed()||(null!==re?Yt(s.state)||(re.cancel(),re=null):Yt(s.state)&&((re=new ht).linkToSignal(N.signal),function(e,t,n,r,i){if(!i.isCancelled()&&null!==e){var a=2===t.getReference().getValue().seeking;a&&(n(),i.isCancelled())||t.listen((function(e){"seeking"===e.event?(a=!0,n()):a&&"seeked"===e.event&&(a=!1,r())}),{includeLastObservation:!0,clearSignal:i})}}(L,Z,(function(){return s.trigger("seeking",null)}),(function(){return s.trigger("seeked",null)}),re.signal)))}),{emitCurrentValue:!0,clearSignal:N.signal}),Z.listen((function(e){ee(s.state),s._priv_triggerPositionUpdate(X,e)}),{clearSignal:N.signal}),N.signal.register((function(){P.removeEventListener()})),this._priv_contentLock.onUpdate((function(e,t){e||(t(),P.start(L,Z))}),{emitCurrentValue:!0,clearSignal:N.signal})},r.getError=function(){return this._priv_currentError},r.getVideoElement=function(){return this.videoElement},r.getPlayerState=function(){return this.state},r.isContentLoaded=function(){return!Qe(["LOADING","RELOADING","STOPPED"],this.state)},r.isBuffering=function(){return Qe(["BUFFERING","SEEKING","LOADING","RELOADING"],this.state)},r.isPaused=function(){return!this.videoElement||(Qe(["LOADING","RELOADING"],this.state)?!this._priv_lastAutoPlay:this.videoElement.paused)},r.isLive=function(){if(null===this._priv_contentInfos)return!1;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return!t&&null!==n&&n.isLive},r.areTrickModeTracksEnabled=function(){return this._priv_preferTrickModeTracks},r.getContentUrls=function(){if(null!==this._priv_contentInfos){var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest,r=e.originalUrl;return t?void 0===r?void 0:[r]:null!==n?n.uris:void 0}},r.updateContentUrls=function(e,t){if(null===this._priv_contentInfos)throw new Error("No content loaded");var n=!0===(null==t?void 0:t.refresh);this._priv_contentInfos.initializer.updateContentUrls(e,n)},r.getMediaDuration=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration},r.getCurrentBufferGap=function(){if(null===this.videoElement)throw new Error("Disposed player");var e,t,n,r=this.videoElement,i=(e=r.buffered,t=r.currentTime,null!==(n=ut(e,t))?n.end-t:1/0);return i===1/0?0:i},r.getWallClockTime=function(){if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)return this.videoElement.currentTime;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){var r=W(this.videoElement);return(null!=r?r:0)+this.videoElement.currentTime}return null!==n?this.videoElement.currentTime+(void 0!==n.availabilityStartTime?n.availabilityStartTime:0):0},r.getPosition=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.currentTime},r.getLastStoredContentPosition=function(){return this._priv_reloadingMetadata.reloadPosition},r.getPlaybackRate=function(){return this._priv_speed.getValue()},r.setPlaybackRate=function(e,t){var n;e!==this._priv_speed.getValue()&&this._priv_speed.setValue(e);var r=null==t?void 0:t.preferTrickModeTracks;if("boolean"==typeof r){this._priv_preferTrickModeTracks=r;var i=null===(n=this._priv_contentInfos)||void 0===n?void 0:n.tracksStore;_(i)||(r&&!i.isTrickModeEnabled()?i.enableVideoTrickModeTracks():!r&&i.isTrickModeEnabled()&&i.disableVideoTrickModeTracks())}},r.getVideoRepresentation=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e)return e.video},r.getAudioRepresentation=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e)return e.audio},r.play=function(){var e=this;if(null===this.videoElement)throw new Error("Disposed player");var t=this.videoElement.play();return _(t)||"function"!=typeof t.catch?Promise.resolve():t.catch((function(t){if("NotAllowedError"===t.name){var n=new Se("MEDIA_ERR_PLAY_NOT_ALLOWED",t.toString());e.trigger("warning",n)}throw t}))},r.pause=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.pause()},r.seekTo=function(e){var t;if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)throw new Error("player: no content loaded");var n,r=this._priv_contentInfos,i=r.isDirectFile,a=r.manifest;if(!i&&null===a)throw new Error("player: the content did not load yet");if("number"==typeof e)n=e;else if("object"==typeof e){var o=e,s=this.videoElement.currentTime;if(_(o.relative))if(_(o.position)){if(_(o.wallClockTime))throw new Error('invalid time object. You must set one of the following properties: "relative", "position" or "wallClockTime"');if(null!==a)n=o.wallClockTime-(null!==(t=a.availabilityStartTime)&&void 0!==t?t:0);else if(i&&null!==this.videoElement){var u=W(this.videoElement);void 0!==u&&(n=o.wallClockTime-u)}void 0===n&&(n=o.wallClockTime)}else n=o.position;else n=s+o.relative}if(void 0===n)throw new Error("invalid time given");return oe.info("API: API Seek to",n),this.videoElement.currentTime=n,n},r.getVolume=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.volume},r.setVolume=function(e){if(null===this.videoElement)throw new Error("Disposed player");var t=this.videoElement;e!==t.volume&&(t.volume=e)},r.isMute=function(){var e;return!0===(null===(e=this.videoElement)||void 0===e?void 0:e.muted)},r.mute=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.muted||(this.videoElement.muted=!0)},r.unMute=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.muted&&(this.videoElement.muted=!1)},r.setMaxBufferBehind=function(e){this._priv_bufferOptions.maxBufferBehind.setValue(e)},r.setMaxBufferAhead=function(e){this._priv_bufferOptions.maxBufferAhead.setValue(e)},r.setWantedBufferAhead=function(e){this._priv_bufferOptions.wantedBufferAhead.setValue(e)},r.setMaxVideoBufferSize=function(e){this._priv_bufferOptions.maxVideoBufferSize.setValue(e)},r.getMaxBufferBehind=function(){return this._priv_bufferOptions.maxBufferBehind.getValue()},r.getMaxBufferAhead=function(){return this._priv_bufferOptions.maxBufferAhead.getValue()},r.getWantedBufferAhead=function(){return this._priv_bufferOptions.wantedBufferAhead.getValue()},r.getMaxVideoBufferSize=function(){return this._priv_bufferOptions.maxVideoBufferSize.getValue()},r.getCurrentPeriod=function(){var e,t=null===(e=this._priv_contentInfos)||void 0===e?void 0:e.currentPeriod;return _(t)?null:{id:t.id,start:t.start,end:t.end}},r.getKeySystemConfiguration=function(){if(null===this.videoElement)throw new Error("Disposed player");var e=It(this.videoElement);return null===e?null:{keySystem:e[0],configuration:e[1]}},r.getAvailablePeriods=function(){if(null===this._priv_contentInfos)return[];var e=this._priv_contentInfos,t=e.isDirectFile,n=e.tracksStore;return t||null===n?[]:n.getAvailablePeriods().slice()},r.getAvailableAudioTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableAudioTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableAudioTracks(t))&&void 0!==n?n:[]}))},r.getAvailableTextTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableTextTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableTextTracks(t))&&void 0!==n?n:[]}))},r.getAvailableVideoTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableVideoTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableVideoTracks(t))&&void 0!==n?n:[]}))},r.getAudioTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenAudioTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenAudioTrack(t)}))}},r.getTextTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenTextTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenTextTrack(t)}))}},r.getVideoTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenVideoTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenVideoTrack(t)}))}},r.setAudioTrack=function(e){var t;if(null===this._priv_contentInfos)throw new Error("No content loaded");var n,r,i,a=this._priv_contentInfos,o=a.isDirectFile,s=a.mediaElementTracksStore;if(o)try{var u="string"==typeof e?e:e.trackId;return void(null==s||s.setAudioTrackById(u))}catch(e){throw new Error("player: unknown audio track")}var l,d=null;return"string"==typeof e?r=e:(r=e.trackId,n=e.periodId,i=e.switchingMode,d=null!==(t=e.lockedRepresentations)&&void 0!==t?t:null,l=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,t){return e.setAudioTrack({periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:d,relativeResumingPosition:l})}))},r.setTextTrack=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r=this._priv_contentInfos,i=r.isDirectFile,a=r.mediaElementTracksStore;if(i)try{var o="string"==typeof e?e:e.trackId;return void(null==a||a.setTextTrackById(o))}catch(e){throw new Error("player: unknown text track")}return"string"==typeof e?n=e:(n=e.trackId,t=e.periodId),this._priv_callTracksStoreGetterSetter(t,void 0,(function(e,t){return e.setTextTrack(t,n)}))},r.disableTextTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(!n)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.disableTrack(t,"text")}));null==r||r.disableTextTrack()}},r.setVideoTrack=function(e){var t;if(null===this._priv_contentInfos)throw new Error("No content loaded");var n,r,i,a=this._priv_contentInfos,o=a.isDirectFile,s=a.mediaElementTracksStore;if(o)try{var u="string"==typeof e?e:e.trackId;return void(null==s||s.setVideoTrackById(u))}catch(e){throw new Error("player: unknown video track")}var l,d=null;return"string"==typeof e?r=e:(r=e.trackId,n=e.periodId,i=e.switchingMode,d=null!==(t=e.lockedRepresentations)&&void 0!==t?t:null,l=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,t){return e.setVideoTrack({periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:d,relativeResumingPosition:l})}))},r.disableVideoTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;return n&&null!==r?r.disableVideoTrack():this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.disableTrack(t,"video")}))}},r.lockVideoRepresentations=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r;if(this._priv_contentInfos.isDirectFile)throw new Error("Cannot lock video Representations in directfile mode.");return Array.isArray(e)?(t=e,n=void 0):(t=e.representations,n=e.periodId,r=e.switchingMode),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,n){return e.lockVideoRepresentations(n,{representations:t,switchingMode:r})}))},r.lockAudioRepresentations=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r;if(this._priv_contentInfos.isDirectFile)throw new Error("Cannot lock audio Representations in directfile mode.");return Array.isArray(e)?(t=e,n=void 0):(t=e.representations,n=e.periodId,r=e.switchingMode),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,n){return e.lockAudioRepresentations(n,{representations:t,switchingMode:r})}))},r.getLockedVideoRepresentations=function(e){return null===this._priv_contentInfos||this._priv_contentInfos.isDirectFile?null:this._priv_callTracksStoreGetterSetter(e,null,(function(e,t){return e.getLockedVideoRepresentations(t)}))},r.getLockedAudioRepresentations=function(e){return null===this._priv_contentInfos||this._priv_contentInfos.isDirectFile?null:this._priv_callTracksStoreGetterSetter(e,null,(function(e,t){return e.getLockedAudioRepresentations(t)}))},r.unlockVideoRepresentations=function(e){if(null!==this._priv_contentInfos&&!this._priv_contentInfos.isDirectFile)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.unlockVideoRepresentations(t)}))},r.unlockAudioRepresentations=function(e){if(null!==this._priv_contentInfos&&!this._priv_contentInfos.isDirectFile)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.unlockAudioRepresentations(t)}))},r.getMinimumPosition=function(){if(null===this._priv_contentInfos)return null;if(this._priv_contentInfos.isDirectFile)return 0;var e=this._priv_contentInfos.manifest;return null!==e?Le(e):null},r.getLivePosition=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return t?void 0:!0!==(null==n?void 0:n.isLive)?null:Ue(n)},r.getMaximumPosition=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration}return null!==n?n.isDynamic||null===this.videoElement?Be(n):this.videoElement.duration:null},r.__priv_getSegmentBufferContent=function(e){if(null===this._priv_contentInfos||null===this._priv_contentInfos.segmentBuffersStore)return null;var t=this._priv_contentInfos.segmentBuffersStore.getStatus(e);return"initialized"===t.type?t.value.getLastKnownInventory():null},r.__priv_getManifest=function(){return null===this._priv_contentInfos?null:this._priv_contentInfos.manifest},r.__priv_getCurrentAdaptation=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.currentPeriod,n=e.activeAdaptations;return null===t||null===n||_(n[t.id])?null:n[t.id]},r.__priv_getCurrentRepresentations=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.currentPeriod,n=e.activeRepresentations;return null===t||null===n||_(n[t.id])?null:n[t.id]},r._priv_cleanUpCurrentContentState=function(){var e,t,n,r,i=this;oe.debug("Locking `contentLock` to clean-up the current content."),this._priv_contentLock.setValue(!0),null===(t=null===(e=this._priv_contentInfos)||void 0===e?void 0:e.tracksStore)||void 0===t||t.dispose(),null===(r=null===(n=this._priv_contentInfos)||void 0===n?void 0:n.mediaElementTracksStore)||void 0===r||r.dispose(),this._priv_contentInfos=null,this._priv_contentEventsMemory={};var a=function(){null!==i.videoElement&&(oe.debug("Unlocking `contentLock`. Next content can begin."),i._priv_contentLock.setValue(!1))};_(this.videoElement)?a():Rt(this.videoElement).then((function(){oe.debug("API: DRM session cleaned-up with success!"),a()}),(function(e){oe.error("API: An error arised when trying to clean-up the DRM session:"+(e instanceof Error?e.toString():"Unknown Error")),a()}))},r._priv_onManifestReady=function(e,t){var n,r=this;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){e.manifest=t,0===t.manifestFormat&&(this._priv_reloadingMetadata.manifest=t);var i=new Vt({preferTrickModeTracks:this._priv_preferTrickModeTracks,defaultAudioTrackSwitchingMode:e.defaultAudioTrackSwitchingMode});e.tracksStore=i,i.addEventListener("newAvailablePeriods",(function(e){r.trigger("newAvailablePeriods",e)})),i.addEventListener("brokenRepresentationsLock",(function(e){r.trigger("brokenRepresentationsLock",e)})),i.addEventListener("trackUpdate",(function(e){var t,n;r.trigger("trackUpdate",e);var i=null!==(n=null===(t=r._priv_contentInfos)||void 0===t?void 0:t.currentPeriod)&&void 0!==n?n:void 0;"no-playable-representation"===e.reason&&e.period.id===(null==i?void 0:i.id)&&r._priv_onAvailableTracksMayHaveChanged(e.trackType)})),e.tracksStore.addEventListener("warning",(function(e){r.trigger("warning",e)})),e.tracksStore.addEventListener("error",(function(t){r._priv_onFatalError(t,e)})),e.tracksStore.onManifestUpdate(t)}},r._priv_onManifestUpdate=function(e,t){var n,r,i;if(null!==this._priv_contentInfos&&null!==this._priv_contentInfos.manifest){_(null==e?void 0:e.tracksStore)||e.tracksStore.onManifestUpdate(this._priv_contentInfos.manifest);var a=null!==(r=null===(n=this._priv_contentInfos)||void 0===n?void 0:n.currentPeriod)&&void 0!==r?r:void 0,o=null===(i=this._priv_contentInfos)||void 0===i?void 0:i.tracksStore;if(void 0!==a&&!_(o))for(var s,u=Qt(t.updatedPeriods);!(s=u()).done;){var l=s.value;if(l.period.id===a.id&&(l.result.addedAdaptations.length>0||l.result.removedAdaptations.length>0)){if(void 0===o.getPeriodObjectFromPeriod(a))return;this._priv_onAvailableTracksMayHaveChanged("audio"),this._priv_onAvailableTracksMayHaveChanged("text"),this._priv_onAvailableTracksMayHaveChanged("video")}}}},r._priv_onDecipherabilityUpdate=function(e,t){if(null!==e&&null!==e.manifest){_(null==e?void 0:e.tracksStore)||e.tracksStore.onDecipherabilityUpdates();for(var n,r=t.reduce((function(t,n){var r,i,a;if(!(void 0!==xe(t,(function(e){return e[0].id===n.period.id&&e[1]===n.adaptation.type})))){var o=e.tracksStore;if(null===o)return t;var s=!1,u=o.getPeriodObjectFromPeriod(n.period);if(void 0===u)return t;switch(n.adaptation.type){case"audio":s=(null===(r=o.getChosenAudioTrack(u))||void 0===r?void 0:r.id)===n.adaptation.id;break;case"video":s=(null===(i=o.getChosenVideoTrack(u))||void 0===i?void 0:i.id)===n.adaptation.id;break;case"text":s=(null===(a=o.getChosenTextTrack(u))||void 0===a?void 0:a.id)===n.adaptation.id}s&&t.push([n.period,n.adaptation.type])}return t}),[]),i=Qt(r);!(n=i()).done;){var a=n.value,o=a[0],s=a[1];this._priv_triggerEventIfNotStopped("representationListUpdate",{period:{start:o.start,end:o.end,id:o.id},trackType:s,reason:"decipherability-update"},e.currentContentCanceller.signal)}}},r._priv_onActivePeriodChanged=function(e,t){var n,r,i,a,o,s,u=t.period;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){e.currentPeriod=u;var l=e.currentContentCanceller.signal;this._priv_contentEventsMemory.periodChange!==u&&(this._priv_contentEventsMemory.periodChange=u,this._priv_triggerEventIfNotStopped("periodChange",{start:u.start,end:u.end,id:u.id},l)),this._priv_triggerEventIfNotStopped("availableAudioTracksChange",this.getAvailableAudioTracks(),l),this._priv_triggerEventIfNotStopped("availableTextTracksChange",this.getAvailableTextTracks(),l),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",this.getAvailableVideoTracks(),l);var d=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.tracksStore;if(_(d))this._priv_triggerEventIfNotStopped("audioTrackChange",null,l),this._priv_triggerEventIfNotStopped("textTrackChange",null,l),this._priv_triggerEventIfNotStopped("videoTrackChange",null,l);else{var c=d.getPeriodObjectFromPeriod(u);if(c){var f=d.getChosenAudioTrack(c);this._priv_triggerEventIfNotStopped("audioTrackChange",f,l);var v=d.getChosenTextTrack(c);this._priv_triggerEventIfNotStopped("textTrackChange",v,l);var p=d.getChosenVideoTrack(c);this._priv_triggerEventIfNotStopped("videoTrackChange",p,l)}}var h=null!==(a=null===(i=this.__priv_getCurrentRepresentations())||void 0===i?void 0:i.audio)&&void 0!==a?a:null;this._priv_triggerEventIfNotStopped("audioRepresentationChange",h,l);var m=null!==(s=null===(o=this.__priv_getCurrentRepresentations())||void 0===o?void 0:o.video)&&void 0!==s?s:null;this._priv_triggerEventIfNotStopped("videoRepresentationChange",m,l)}},r._priv_onPeriodStreamReady=function(e,t){var n;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var r=t.type,i=t.period,a=t.adaptationRef,o=e.tracksStore;switch(r){case"video":case"audio":case"text":_(o)?(oe.error("API: TracksStore not instanciated for a new "+r+" period"),a.setValue(null)):o.addTrackReference(r,i,a);break;default:Ze()}}},r._priv_onPeriodStreamCleared=function(e,t){var n;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var r=t.type,i=t.period,a=e.tracksStore;switch(r){case"audio":case"text":case"video":_(a)||a.removeTrackReference(r,i)}var o=e.activeAdaptations,s=e.activeRepresentations;if(!_(o)&&!_(o[i.id])){var u=o[i.id];delete u[r],0===Object.keys(u).length&&delete o[i.id]}if(!_(s)&&!_(s[i.id])){var l=s[i.id];delete l[r],0===Object.keys(l).length&&delete s[i.id]}}},r._priv_onAdaptationChange=function(e,t){var n,r=t.type,i=t.adaptation,a=t.period;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){null===e.activeAdaptations&&(e.activeAdaptations={});var o,s=e.activeAdaptations,u=e.currentPeriod,l=s[a.id];if(_(l))s[a.id]=((o={})[r]=i,o);else l[r]=i;var d=e.tracksStore,c=e.currentContentCanceller.signal;if(null!==d&&null!==u&&!_(a)&&a.id===u.id){var f=d.getPeriodObjectFromPeriod(a);if(void 0===f)return;switch(r){case"audio":var v=d.getChosenAudioTrack(f);this._priv_triggerEventIfNotStopped("audioTrackChange",v,c);break;case"text":var p=d.getChosenTextTrack(f);this._priv_triggerEventIfNotStopped("textTrackChange",p,c);break;case"video":var h=d.getChosenVideoTrack(f);this._priv_triggerEventIfNotStopped("videoTrackChange",h,c)}}}},r._priv_onRepresentationChange=function(e,t){var n,r=t.type,i=t.period,a=t.representation;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){null===e.activeRepresentations&&(e.activeRepresentations={});var o,s=e.activeRepresentations,u=e.currentPeriod,l=s[i.id];if(_(l))s[i.id]=((o={})[r]=a,o);else l[r]=a;if(!_(i)&&null!==u&&u.id===i.id){var d=this._priv_contentInfos.currentContentCanceller.signal;"video"===r?this._priv_triggerEventIfNotStopped("videoRepresentationChange",a,d):"audio"===r&&this._priv_triggerEventIfNotStopped("audioRepresentationChange",a,d)}}},r._priv_onBitrateEstimateChange=function(e){var t=e.type,n=e.bitrate;void 0!==n&&(this._priv_bitrateInfos.lastBitrates[t]=n),this.trigger("__priv_bitrateEstimateChange",{type:t,bitrate:n})},r._priv_setPlayerState=function(e){this.state!==e&&(this.state=e,oe.info("API: playerStateChange event",e),this.trigger("playerStateChange",e))},r._priv_triggerPositionUpdate=function(e,t){var n,r;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){var i=e.isDirectFile,a=e.manifest;if((i||null!==a)&&!_(t)){var o=null!==a?Be(a):void 0,s={position:t.position.getPolled(),duration:t.duration,playbackRate:t.playbackRate,maximumPosition:o,bufferGap:void 0!==t.bufferGap&&isFinite(t.bufferGap)?t.bufferGap:0};if(null!==a&&a.isLive&&t.position.getPolled()>0){var u=null!==(r=a.availabilityStartTime)&&void 0!==r?r:0;s.wallClockTime=t.position.getPolled()+u;var l=Ue(a);void 0!==l&&(s.liveGap=l-t.position.getPolled())}else if(i&&null!==this.videoElement){var d=W(this.videoElement);void 0!==d&&(s.wallClockTime=d+t.position.getPolled())}this.trigger("positionUpdate",s)}}},r._priv_triggerEventIfNotStopped=function(e,t,n){n.isCancelled()||this.trigger(e,t)},r._priv_initializeMediaElementTracksStore=function(e){var t,n,r,i=this;Xe(Re.directfile),Xe(this.videoElement);var a=new Re.directfile.mediaElementTracksStore(this.videoElement);return this._priv_triggerEventIfNotStopped("availableAudioTracksChange",a.getAvailableAudioTracks(),e),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",a.getAvailableVideoTracks(),e),this._priv_triggerEventIfNotStopped("availableTextTracksChange",a.getAvailableTextTracks(),e),this._priv_triggerEventIfNotStopped("audioTrackChange",null!==(t=a.getChosenAudioTrack())&&void 0!==t?t:null,e),this._priv_triggerEventIfNotStopped("textTrackChange",null!==(n=a.getChosenTextTrack())&&void 0!==n?n:null,e),this._priv_triggerEventIfNotStopped("videoTrackChange",null!==(r=a.getChosenVideoTrack())&&void 0!==r?r:null,e),a.addEventListener("availableVideoTracksChange",(function(e){return i.trigger("availableVideoTracksChange",e)})),a.addEventListener("availableAudioTracksChange",(function(e){return i.trigger("availableAudioTracksChange",e)})),a.addEventListener("availableTextTracksChange",(function(e){return i.trigger("availableTextTracksChange",e)})),a.addEventListener("audioTrackChange",(function(e){return i.trigger("audioTrackChange",e)})),a.addEventListener("videoTrackChange",(function(e){return i.trigger("videoTrackChange",e)})),a.addEventListener("textTrackChange",(function(e){return i.trigger("textTrackChange",e)})),a},r._priv_callTracksStoreGetterSetter=function(e,t,n){var r,i;if(null===this._priv_contentInfos||null===this._priv_contentInfos.tracksStore)return oe.warn("API: Trying to call track API too soon"),t;var a=this._priv_contentInfos.tracksStore,o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,s=null!=e?e:null==o?void 0:o.id;if(void 0===s)return t;var u=s===(null==o?void 0:o.id)?a.getPeriodObjectFromPeriod(o):a.getPeriodObjectFromId(s);return void 0===u?t:n(a,u)},r._priv_onAvailableTracksMayHaveChanged=function(e,t){var n=this._priv_contentInfos;if(null!==n){var r=n.currentPeriod,i=n.tracksStore,a=n.currentContentCanceller.signal;if(!_(r)&&null!==i){var o=null!=t?t:i.getPeriodObjectFromPeriod(r);if(void 0!==o)switch(e){case"video":var s=i.getAvailableVideoTracks(o);this._priv_triggerEventIfNotStopped("availableVideoTracksChange",null!=s?s:[],a);break;case"audio":var u=i.getAvailableAudioTracks(o);this._priv_triggerEventIfNotStopped("availableAudioTracksChange",null!=u?u:[],a);break;case"text":var l=i.getAvailableTextTracks(o);this._priv_triggerEventIfNotStopped("availableTextTracksChange",null!=l?l:[],a);break;default:Ze()}}}},r._priv_onFatalError=function(e,t){var n=we(e,{defaultCode:"NONE",defaultReason:"An unknown error stopped content playback."});n.fatal=!0,t.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this._priv_currentError=n,oe.error("API: The player stopped because of an error",n),this._priv_setPlayerState("STOPPED"),this._priv_currentError===n&&this.trigger("error",n)},o(n,null,[{key:"ErrorTypes",get:function(){return ge}},{key:"ErrorCodes",get:function(){return ye}},{key:"LogLevel",get:function(){return oe.getLevel()},set:function(e){oe.setLevel(e)}}]),n}(ie);rn.version="4.0.0";var an=rn;function on(e,t){if(e.length!==t.length)return!1;if(e===t)return!0;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return!1;return!0}function sn(e,t){var n;return new Promise((function(r,i){if(null!==e.cancellationError)return i(e.cancellationError);var a=!1;function o(e){void 0!==n&&n(),i(e)}n=t((function(t){e.deregister(o),a=!0,r(t)}),(function(t){e.deregister(o),a=!0,i(t)})),a||e.register(o)}))}var un={createSync:function(e){return{syncValue:e,getValueAsAsync:function(){return Promise.resolve(e)}}},createAsync:function(e){var t=null;return e.then((function(e){t=e}),b),{syncValue:t,getValueAsAsync:function(){return e}}}};function ln(e){var t=e.map((function(t){return Math.log(t/e[0])})),n=t.map((function(e){return e-t[0]+1})),r=(n[n.length-1]-1)/(2*e.length+10),i=1/r;return e.map((function(e,t){return a(t)}));function a(t){if(0===t)return 0;var o=Math.min(Math.max(1,t),e.length-1);return e[o]===e[o-1]?a(t-1):i*(r+(e[o]*n[o-1]-e[o-1]*n[o])/(e[o]-e[o-1]))+4}}var dn=function(){function e(e){this._levelsMap=ln(e).map((function(e){return e+4})),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=6e3,oe.debug("ABR: Steps for buffer based chooser.",this._levelsMap.map((function(t,n){return"bufferLevel: "+t+", bitrate: "+e[n]})).join(" ,"))}var t=e.prototype;return t.onAddedSegment=function(e){var t=this._levelsMap,n=this._bitrates,r=e.bufferGap,i=e.currentBitrate,a=e.currentScore,o=e.speed;if(null!=i){for(var s,u=-1,l=0;l<n.length;l++){var d=n[l];if(d===i)u=l;else if(d>i)break}if(u<0||n.length!==t.length)return oe.info("ABR: Current Bitrate not found in the calculated levels"),void(this._currentEstimate=n[0]);void 0!==a&&(s=0===o?a.score:a.score/o);var c=isFinite(r)?r:0,f=Me();if(c<t[u]||void 0!==s&&s<1&&1===(null==a?void 0:a.confidenceLevel)){if((void 0===this._lastUnsuitableQualityTimestamp?-1:f-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+9e3){var v=this._blockRaiseDelay+3e3;this._blockRaiseDelay=Math.min(v,15e3),oe.debug("ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality",this._blockRaiseDelay)}else{var p=this._blockRaiseDelay-1e3;this._blockRaiseDelay=Math.max(6e3,p),oe.debug("ABR: Lowering quality in BufferBasedChooser",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=f;for(var h=S(n,(function(e){return e===i}))-1;h>=0;h--)if(c>=t[h])return void(this._currentEstimate=n[h]);this._currentEstimate=n[0]}else if(void 0!==this._lastUnsuitableQualityTimestamp&&f-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||void 0===s||s<1.15||1!==(null==a?void 0:a.confidenceLevel))this._currentEstimate=i;else{var m=t[u],g=function(){for(var e=u+1;e<t.length;e++)if(t[e]>m)return e}();if(void 0!==g)if(r>=t[g])return oe.debug("ABR: Raising quality in BufferBasedChooser",n[g]),void(this._currentEstimate=n[g]);this._currentEstimate=i}}else this._currentEstimate=n[0]},t.getLastEstimate=function(){return this._currentEstimate},e}(),cn=function(){function e(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}var t=e.prototype;return t.addSample=function(e,t){var n=Math.pow(this._alpha,e),r=t*(1-n)+n*this._lastEstimate;isNaN(r)||(this._lastEstimate=r,this._totalWeight+=e)},t.getEstimate=function(){var e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e},e}();function fn(e){if(!(e.progress.length<5)){for(var t=new cn(2),n=e.progress,r=1;r<n.length;r++){var i=n[r].size-n[r-1].size,a=n[r].timestamp-n[r-1].timestamp,o=8*i/(a/1e3);t.addSample(a/1e3,o)}return t.getEstimate()}}function vn(e,t){var n=8*(e.totalSize-e.size);return Math.max(n/t,0)}var pn=function(){function e(e,t){var n=p.getCurrent(),r=n.ABR_STARVATION_GAP,i=n.OUT_OF_STARVATION_GAP,a=n.ABR_STARVATION_FACTOR,o=n.ABR_REGULAR_FACTOR;this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,this._config=t?{starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:{starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}var t=e.prototype;return t.getBandwidthEstimate=function(e,t,n,r,i){var a,o,s=this._config,u=e.bufferGap,l=e.position,d=e.duration,c=isFinite(u)?u:0,f=p.getCurrent().ABR_STARVATION_DURATION_DELTA;return isNaN(d)||c+l.getWanted()<d-f?!this._inStarvationMode&&c<=s.starvationGap?(oe.info("ABR: enter starvation mode."),this._inStarvationMode=!0):this._inStarvationMode&&c>=s.outOfStarvationGap&&(oe.info("ABR: exit starvation mode."),this._inStarvationMode=!1):this._inStarvationMode&&(oe.info("ABR: exit starvation mode."),this._inStarvationMode=!1),this._inStarvationMode&&(o=function(e,t,n,r,i){if(!r){var a=t.bufferGap,o=t.speed,s=t.position,u=isFinite(a)?a:0,l=function(e,t){for(var n=-1,r=0;r<e.length;r++){var i=e[r].content.segment;if(!(i.duration<=0)){var a=i.time+i.duration;if(!i.complete&&r===e.length-1&&t-i.time>-1.2){n=r;break}if(a>t&&t-i.time>-1.2){n=r;break}}}if(n<0)return[];for(var o=e[n],s=o.content.segment.time,u=[o],l=n+1;l<e.length&&e[l].content.segment.time===s;l++)u.push(e[l]);return u}(e,s.getWanted()+u);if(1===l.length){var d=l[0],c=Me(),f=1.5*d.content.segment.duration;if(f=Math.min(f,3e3),f=Math.max(f,12e3),!(c-d.requestTimestamp<f)){var v=d.progress.length>0?d.progress[d.progress.length-1]:void 0,p=fn(d);if(void 0!==v&&void 0!==p){var h=vn(v,p);if((c-v.timestamp)/1e3<=h&&h-u/o>2500)return p}if(d.content.segment.complete){var m=d.content.segment.duration,g=(c-d.requestTimestamp)/1e3;if(null!=n&&!(g<=(1.5*m+2)/o)){var y=m/g,_=n.bitrate*Math.min(.7,y);return void 0===i||_<i?_:void 0}}}}}}(r,e,n,this._lowLatencyMode,i),void 0!==o&&(oe.info("ABR: starvation mode emergency estimate:",o),t.reset(),a=_(n)?o:Math.min(o,n.bitrate))),null==a&&(a=void 0!==(o=t.getEstimate())?o*(this._inStarvationMode?s.starvationBitrateFactor:s.regularBitrateFactor):void 0!==i?i*(this._inStarvationMode?s.starvationBitrateFactor:s.regularBitrateFactor):this._initialBitrate),e.speed>1&&(a/=e.speed),{bandwidthEstimate:o,bitrateChosen:a}},t.isUrgent=function(e,t,n,r){return null===t||!(e>=t.bitrate)&&function(e,t,n){if(n)return!0;var r=isFinite(e.bufferGap)?e.bufferGap:0,i=e.position.getWanted()+r,a=xe(t,(function(e){var t=e.content;return t.segment.duration>0&&t.segment.time+t.segment.duration>i}));if(void 0===a)return!0;var o=Me(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=fn(a);if(void 0===s||void 0===u)return!0;var l=vn(s,u);return(o-s.timestamp)/1e3>1.2*l||l-r/e.speed>-1.5}(r,n,this._lowLatencyMode)},e}();function hn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function mn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var gn=function(){function e(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}var t=e.prototype;return t.getGuess=function(e,t,n,r,i){var a=t.bufferGap,o=t.speed,s=this._lastAbrEstimate.representation;if(null===s)return null;if(r>s.bitrate)return 2===this._lastAbrEstimate.algorithmType&&(null!==this._lastAbrEstimate.representation&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;var u=this._scoreCalculator.getEstimate(n);if(2!==this._lastAbrEstimate.algorithmType){if(void 0===u)return null;if(this._canGuessHigher(a,o,u)){var l=yn(e,n);if(null!==l)return l}return null}if(this._isLastGuessValidated(s,r,u)&&(oe.debug("ABR: Guessed Representation validated",s.bitrate),this._lastMaintanableBitrate=s.bitrate,this._consecutiveWrongGuesses=0),n.id!==s.id)return s;if(this._shouldStopGuess(n,u,a,i))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=Me()+Math.min(15e3*this._consecutiveWrongGuesses,12e4),function(e,t){var n=S(e,(function(e){return e.id===t.id}));if(n<0)return oe.error("ABR: Current Representation not found."),null;for(;--n>=0;)if(e[n].bitrate<t.bitrate)return e[n];return null}(e,n);if(void 0===u)return n;if(this._canGuessHigher(a,o,u)){var d=yn(e,n);if(null!==d)return d}return n},t._canGuessHigher=function(e,t,n){var r=n.score,i=n.confidenceLevel;return isFinite(e)&&e>=2.5&&Me()>this._blockGuessesUntil&&1===i&&r/t>1.01},t._shouldStopGuess=function(e,t,n,r){if(void 0!==t&&t.score<1.01)return!0;if((void 0===t||t.score<1.2)&&n<.6)return!0;for(var i,a=r.filter((function(t){return t.content.representation.id===e.id})),o=Me(),s=hn(a);!(i=s()).done;){var u=i.value,l=o-u.requestTimestamp;if(u.content.segment.isInit){if(l>1e3)return!0}else{if(l>1e3*u.content.segment.duration+200)return!0;var d=fn(u);if(void 0!==d&&d<.8*e.bitrate)return!0}}return!1},t._isLastGuessValidated=function(e,t,n){return void 0!==n&&1===n.confidenceLevel&&n.score>1.5||t>=e.bitrate&&(null===this._lastMaintanableBitrate||this._lastMaintanableBitrate<e.bitrate)},e}();function yn(e,t){var n=e.length,r=S(e,(function(e){return e.id===t.id}));if(r<0)return oe.error("ABR: Current Representation not found."),null;for(;++r<n;)if(e[r].bitrate>t.bitrate)return e[r];return null}var _n=function(){function e(){var e=p.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new cn(t),this._slowEWMA=new cn(n),this._bytesSampled=0}var t=e.prototype;return t.addSample=function(e,t){if(!(t<p.getCurrent().ABR_MINIMUM_CHUNK_SIZE)){var n=8e3*t/e,r=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(r,n),this._slowEWMA.addSample(r,n)}},t.getEstimate=function(){var e=p.getCurrent().ABR_MINIMUM_TOTAL_BYTES;if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())},t.reset=function(){var e=p.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new cn(t),this._slowEWMA=new cn(n),this._bytesSampled=0},e}();var bn=function(){function e(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}return e.prototype.update=function(e,t,n){this.representation=e,this.bandwidth=t,this.algorithmType=n},e}(),Sn=function(){function e(){this._currentRequests={}}var t=e.prototype;return t.add=function(e){var t=e.id,n=e.requestTimestamp,r=e.content;this._currentRequests[t]={requestTimestamp:n,progress:[],content:r}},t.addProgress=function(e){var t=this._currentRequests[e.id];null!=t?t.progress.push(e):oe.warn("ABR: progress for a request not added")},t.remove=function(e){null==this._currentRequests[e]&&oe.warn("ABR: can't remove unknown request"),delete this._currentRequests[e]},t.getRequests=function(){return De(this._currentRequests).filter((function(e){return null!=e})).sort((function(e,t){return e.content.segment.time-t.content.segment.time}))},e}(),En=function(){function e(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}var t=e.prototype;return t.addSample=function(e,t,n){var r,i=n/t,a=this._currentRepresentationData;null!==a&&a.representation.id===e.id?(r=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=n,a.loadedSegments++):((r=new cn(5)).addSample(t,i),this._currentRepresentationData={representation:e,ewma:r,loadedDuration:n,loadedSegments:0}),r.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(oe.debug("ABR: New last stable representation",e.bitrate),this._lastRepresentationWithGoodScore=e)},t.getEstimate=function(e){if(null!==this._currentRepresentationData&&this._currentRepresentationData.representation.id===e.id){var t=this._currentRepresentationData,n=t.ewma,r=t.loadedSegments,i=t.loadedDuration;return{score:n.getEstimate(),confidenceLevel:r>=5&&i>=10?1:0}}},t.getLastStableRepresentation=function(){return this._lastRepresentationWithGoodScore},e}();function Tn(e,t){var n=S(e,(function(e){return e.bitrate>t}));return-1===n?e[e.length-1]:0===n?e[0]:e[n-1]}var kn=new A(void 0);kn.finish();var wn=new A(1/0);wn.finish();var An=function(e){var t={},n=e.initialBitrates,r=e.throttlers,i=e.lowLatencyMode;return function(e,a,o,s,u){var l,d,c,f=e.adaptation.type,v=function(e){var n=t[e];if(null==n){oe.debug("ABR: Creating new BandwidthEstimator for ",e);var r=new _n;return t[e]=r,r}return n}(f),h=null!==(l=n[f])&&void 0!==l?l:0;return function(e,t){var n=e.bandwidthEstimator,r=e.context,i=e.currentRepresentation,a=e.filters,o=e.initialBitrate,s=e.lowLatencyMode,u=e.playbackObserver,l=e.representations,d=new En,c=new pn(null!=o?o:0,s),f=new Sn,v=b,h={metrics:E,requestBegin:T,requestProgress:k,requestEnd:w,addedSegment:function(e){v(e)}},m=new ht;m.linkToSignal(t);var g=y(l.getValue(),m.signal);return l.onUpdate(_,{clearSignal:t}),{estimates:g,callbacks:h};function y(e,t){if(e.length<=1)return new A({bitrate:void 0,representation:e[0],urgent:!0,knownStableBitrate:void 0});var o=!1,l=e.sort((function(e,t){return e.bitrate-t.bitrate})),h=new dn(l.map((function(e){return e.bitrate}))),m=new bn,g=new gn(d,m),y=u.getReference().getValue(),_=new A(T());return u.listen((function(e){y=e,E()}),{includeLastObservation:!1,clearSignal:t}),v=function(e){if(null!==y){var t=y,n=t.position,r=t.speed,i=ct(e.buffered,n.getWanted()),a=e.content.representation,o=d.getEstimate(a),s={bufferGap:i,currentBitrate:a.bitrate,currentScore:o,speed:r};h.onAddedSegment(s),E()}},t.register((function(){v=b})),a.throttleBitrate.onUpdate(E,{clearSignal:t}),a.limitResolution.onUpdate(E,{clearSignal:t}),_;function E(){_.setValue(T())}function T(){var e=y,t=e.bufferGap,u=e.position,v=e.maximumPosition,_=a.limitResolution.getValue(),b=a.throttleBitrate.getValue(),E=i.getValue(),T=function(e,t,n){var r=e;void 0!==n&&n<1/0&&(r=function(e,t){if(0===e.length)return[];e.sort((function(e,t){return e.bitrate-t.bitrate}));var n=e[0].bitrate,r=Math.max(t,n),i=S(e,(function(e){return e.bitrate>r}));return-1===i?e:e.slice(0,i)}(r,n));void 0!==t&&(r=function(e,t){if(void 0===t.width||void 0===t.height)return e;var n=t.width*t.pixelRatio,r=t.height*t.pixelRatio,i=e.slice().sort((function(e,t){var n,r;return(null!==(n=e.width)&&void 0!==n?n:0)-(null!==(r=t.width)&&void 0!==r?r:0)})),a=xe(i,(function(e){return"number"==typeof e.width&&e.width>=n&&"number"==typeof e.height&&e.height>=r}));if(void 0===a)return e;var o="number"==typeof a.width?a.width:0;return e.filter((function(e){return"number"!=typeof e.width||e.width<=o}))}(r,t));return r}(l,_,b),k=f.getRequests(),w=c.getBandwidthEstimate(y,n,E,k,m.bandwidth),A=w.bandwidthEstimate,I=w.bitrateChosen,R=d.getLastStableRepresentation(),x=null===R?void 0:R.bitrate/(y.speed>0?y.speed:1),C=p.getCurrent(),M=C.ABR_ENTER_BUFFER_BASED_ALGO,P=C.ABR_EXIT_BUFFER_BASED_ALGO;o&&t<=P?o=!1:!o&&isFinite(t)&&t>=M&&(o=!0);var D=Tn(T,I),O=h.getLastEstimate(),N=D.bitrate,L=null;o&&void 0!==O&&O>N&&(N=(L=Tn(T,O)).bitrate);var U=null;return s&&null!==E&&r.manifest.isDynamic&&v-u.getWanted()<40&&(U=g.getGuess(l,y,E,N,k)),null!==U&&U.bitrate>N?(oe.debug("ABR: Choosing representation with guess-based estimation.",U.bitrate,U.id),m.update(U,A,2),{bitrate:A,representation:U,urgent:null===E||U.bitrate<E.bitrate,knownStableBitrate:x}):null!==L?(oe.debug("ABR: Choosing representation with buffer-based estimation.",L.bitrate,L.id),m.update(L,A,0),{bitrate:A,representation:L,urgent:c.isUrgent(L.bitrate,E,k,y),knownStableBitrate:x}):(oe.debug("ABR: Choosing representation with bandwidth estimation.",D.bitrate,D.id),m.update(D,A,1),{bitrate:A,representation:D,urgent:c.isUrgent(D.bitrate,E,k,y),knownStableBitrate:x})}}function _(){var e=l.getValue();m.cancel(),(m=new ht).linkToSignal(t),y(e,m.signal).onUpdate((function(e){g.setValue(e)}),{clearSignal:m.signal,emitCurrentValue:!0})}function E(e){var t=e.requestDuration,r=e.segmentDuration,i=e.size,a=e.content;if(n.addSample(t,i),!a.segment.isInit){var o=a.segment,s=a.representation;if(void 0===r&&!o.complete)return;var u=null!=r?r:o.duration;d.addSample(s,t/1e3,u)}}function T(e){f.add(e)}function k(e){f.addProgress(e)}function w(e){f.remove(e.id)}}({bandwidthEstimator:v,context:e,currentRepresentation:a,filters:{limitResolution:null!==(d=r.limitResolution[f])&&void 0!==d?d:kn,throttleBitrate:null!==(c=r.throttleBitrate[f])&&void 0!==c?c:wn},initialBitrate:h,playbackObserver:s,representations:o,lowLatencyMode:i},u)}},In=[];function Rn(e){Qe(In,e)||(console.warn(e),In.push(e))}var xn={aa:"aar",ab:"abk",ae:"ave",af:"afr",ak:"aka",am:"amh",an:"arg",ar:"ara",as:"asm",av:"ava",ay:"aym",az:"aze",ba:"bak",be:"bel",bg:"bul",bi:"bis",bm:"bam",bn:"ben",bo:"bod",br:"bre",bs:"bos",ca:"cat",ce:"che",ch:"cha",co:"cos",cr:"cre",cs:"ces",cu:"chu",cv:"chv",cy:"cym",da:"dan",de:"deu",dv:"div",dz:"dzo",ee:"ewe",el:"ell",en:"eng",eo:"epo",es:"spa",et:"est",eu:"eus",fa:"fas",ff:"ful",fi:"fin",fj:"fij",fo:"fao",fr:"fra",fy:"fry",ga:"gle",gd:"gla",gl:"glg",gn:"grn",gu:"guj",gv:"glv",ha:"hau",he:"heb",hi:"hin",ho:"hmo",hr:"hrv",ht:"hat",hu:"hun",hy:"hye",hz:"her",ia:"ina",id:"ind",ie:"ile",ig:"ibo",ii:"iii",ik:"ipk",io:"ido",is:"isl",it:"ita",iu:"iku",ja:"jpn",jv:"jav",ka:"kat",kg:"kon",ki:"kik",kj:"kua",kk:"kaz",kl:"kal",km:"khm",kn:"kan",ko:"kor",kr:"kau",ks:"kas",ku:"kur",kv:"kom",kw:"cor",ky:"kir",la:"lat",lb:"ltz",lg:"lug",li:"lim",ln:"lin",lo:"lao",lt:"lit",lu:"lub",lv:"lav",mg:"mlg",mh:"mah",mi:"mri",mk:"mkd",ml:"mal",mn:"mon",mr:"mar",ms:"msa",mt:"mlt",my:"mya",na:"nau",nb:"nob",nd:"nde",ne:"nep",ng:"ndo",nl:"nld",nn:"nno",no:"nor",nr:"nbl",nv:"nav",ny:"nya",oc:"oci",oj:"oji",om:"orm",or:"ori",os:"oss",pa:"pan",pi:"pli",pl:"pol",ps:"pus",pt:"por",qu:"que",rm:"roh",rn:"run",ro:"ron",ru:"rus",rw:"kin",sa:"san",sc:"srd",sd:"snd",se:"sme",sg:"sag",si:"sin",sk:"slk",sl:"slv",sm:"smo",sn:"sna",so:"som",sq:"sqi",sr:"srp",ss:"ssw",st:"sot",su:"sun",sv:"swe",sw:"swa",ta:"tam",te:"tel",tg:"tgk",th:"tha",ti:"tir",tk:"tuk",tl:"tgl",tn:"tsn",to:"ton",tr:"tur",ts:"tso",tt:"tat",tw:"twi",ty:"tah",ug:"uig",uk:"ukr",ur:"urd",uz:"uzb",ve:"ven",vi:"vie",vo:"vol",wa:"wln",wo:"wol",xh:"xho",yi:"yid",yo:"yor",za:"zha",zh:"zho",zu:"zul"},Cn={alb:"sqi",arm:"hye",baq:"eus",bur:"mya",chi:"zho",cze:"ces",dut:"nld",fre:"fra",geo:"kat",ger:"deu",gre:"ell",ice:"isl",mac:"mkd",mao:"mri",may:"msa",per:"fas",slo:"slk",rum:"ron",tib:"bod",wel:"cym"};function Mn(e){if(_(e)||""===e)return"";var t=function(e){var t;switch(e.length){case 2:t=xn[e];break;case 3:t=Cn[e]}return t}((""+e).toLowerCase().split("-")[0]);return y(t)?t:e}var Pn=Mn;function Dn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return On(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return On(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function On(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Nn=Je(),Ln=function(){function e(e,t){var n,r,i,a,o;if(this.id=e.id,this.uniqueId=Nn(),this.bitrate=e.bitrate,this.codecs=[],void 0!==e.isSpatialAudio&&(this.isSpatialAudio=e.isSpatialAudio),void 0!==e.height&&(this.height=e.height),void 0!==e.width&&(this.width=e.width),void 0!==e.mimeType&&(this.mimeType=e.mimeType),void 0!==e.contentProtections&&(this.contentProtections=e.contentProtections),void 0!==e.frameRate&&(this.frameRate=e.frameRate),void 0!==e.hdrInfo&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index,"audio"===t||"video"===t)if(null!==Re.codecSupportProber){if(void 0!==e.supplementalCodecs){var s=Re.codecSupportProber.isSupported(null!==(n=this.mimeType)&&void 0!==n?n:"",null!==(r=e.supplementalCodecs)&&void 0!==r?r:"");!1!==s&&(this.codecs=[e.supplementalCodecs],!0===s&&(this.isSupported=!0))}!0!==this.isSupported&&(this.codecs.length>0?this.codecs.push(null!==(i=e.codecs)&&void 0!==i?i:""):(this.codecs=void 0===e.codecs?[]:[e.codecs],this.isSupported=Re.codecSupportProber.isSupported(null!==(a=this.mimeType)&&void 0!==a?a:"",null!==(o=e.codecs)&&void 0!==o?o:"")))}else void 0!==e.supplementalCodecs&&this.codecs.push(e.supplementalCodecs),void 0!==e.codecs&&this.codecs.push(e.codecs);else void 0!==e.codecs&&this.codecs.push(e.codecs),this.isSupported=!0}var t=e.prototype;return t.refreshCodecSupport=function(e){var t,n=null!==(t=this.mimeType)&&void 0!==t?t:"",r=this.codecs;0===r.length&&(r=[""]);for(var i=0;i<r.length;i++)for(var a,o=Dn(e);!(a=o()).done;){var s=a.value,u=r[i];if(s.codec===u&&s.mimeType===n){if(s.result)return this.isSupported=!0,void(this.codecs=[u]);if(i===r.length)return this.isSupported=!1,void(this.codecs=[u])}}},t.getMimeTypeString=function(){var e,t,n;return(null!==(e=this.mimeType)&&void 0!==e?e:"")+';codecs="'+(null!==(n=null===(t=this.codecs)||void 0===t?void 0:t[0])&&void 0!==n?n:"")+'"'},t.getEncryptionData=function(e){for(var t,n,r=this.getAllEncryptionData(),i=[],a=0;a<r.length;a++)for(var o=!1,s=r[a],u=0;u<s.values.length;u++)if(s.values[u].systemId.toLowerCase()===e.toLowerCase())if(o)i[i.length-1].values.push(s.values[u]);else{var l=null===(n=null===(t=this.contentProtections)||void 0===t?void 0:t.keyIds)||void 0===n?void 0:n.map((function(e){return e.keyId}));i.push({type:s.type,keyIds:l,values:[s.values[u]]}),o=!0}return i},t.getAllEncryptionData=function(){var e,t;if(void 0===this.contentProtections||0===this.contentProtections.initData.length)return[];var n=null===(t=null===(e=this.contentProtections)||void 0===e?void 0:e.keyIds)||void 0===t?void 0:t.map((function(e){return e.keyId}));return this.contentProtections.initData.map((function(e){return{type:e.type,keyIds:n,values:e.values}}))},t.addProtectionData=function(e,t,n){var r=!1;if(void 0===this.contentProtections)return this.contentProtections={keyIds:void 0!==t?[{keyId:t}]:[],initData:[{type:e,values:n}]},!0;if(void 0!==t){var i=this.contentProtections.keyIds;if(void 0===i)this.contentProtections.keyIds=[{keyId:t}];else{for(var a,o=!1,s=Dn(i);!(a=s()).done;){on(a.value.keyId,t)&&(o=!0)}o||(oe.warn("Manifest: found unanounced key id."),i.push({keyId:t}))}}for(var u=this.contentProtections.initData,l=0;l<u.length;l++)if(u[l].type===e){for(var d=u[l].values,c=0;c<n.length;c++){var f=n[c],v=void 0;for(v=0;v<d.length;v++)if(f.systemId===d[v].systemId){if(on(f.data,d[v].data))break;oe.warn("Manifest: different init data for the same system ID")}v===d.length&&(d.push(f),r=!0)}return r}return this.contentProtections.initData.push({type:e,values:n}),!0},t.getMetadataSnapshot=function(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,codecs:this.codecs,mimeType:this.mimeType,width:this.width,height:this.height,frameRate:this.frameRate,isSupported:this.isSupported,hdrInfo:this.hdrInfo,contentProtections:this.contentProtections,decipherable:this.decipherable}},e}(),Un=Ln;function Bn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Fn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Fn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var zn=["audio","video","text"],Vn=function(){function e(t,n){void 0===n&&(n={});var r=t.trickModeTracks,i=n,a=i.representationFilter,o=i.isManuallyAdded;this.id=t.id,this.type=t.type,void 0!==t.isTrickModeTrack&&(this.isTrickModeTrack=t.isTrickModeTrack),void 0!==t.language&&(this.language=t.language,this.normalizedLanguage=Pn(t.language)),void 0!==t.closedCaption&&(this.isClosedCaption=t.closedCaption),void 0!==t.audioDescription&&(this.isAudioDescription=t.audioDescription),void 0!==t.isDub&&(this.isDub=t.isDub),void 0!==t.forcedSubtitles&&(this.isForcedSubtitles=t.forcedSubtitles),void 0!==t.isSignInterpreted&&(this.isSignInterpreted=t.isSignInterpreted),void 0!==t.label&&(this.label=t.label),void 0!==r&&r.length>0&&(this.trickModeTracks=r.map((function(t){return new e(t)})));for(var s,u=t.representations,l=[],d=0;d<u.length;d++){var c=new Un(u[d],this.type),f=!0;if(!_(a)){var v={id:c.id,bitrate:c.bitrate,codecs:c.codecs,height:c.height,width:c.width,frameRate:c.frameRate,hdrInfo:c.hdrInfo};if(void 0!==c.contentProtections&&(v.contentProtections={},void 0!==c.contentProtections.keyIds)){var p=c.contentProtections.keyIds.map((function(e){return e.keyId}));v.contentProtections.keyIds=p}f=a(v,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}f?(l.push(c),void 0===s&&(!0===c.isSupported?s=!0:!1===c.isSupported&&(s=!1))):oe.debug("Filtering Representation due to representationFilter",this.type,"Adaptation: "+this.id,"Representation: "+c.id,"("+c.bitrate+")")}l.sort((function(e,t){return e.bitrate-t.bitrate})),this.representations=l,this.isSupported=s,this.manuallyAdded=!0===o}var t=e.prototype;return t.refreshCodecSupport=function(e){for(var t,n=Bn(this.representations);!(t=n()).done;){var r=t.value;void 0===r.isSupported&&(r.refreshCodecSupport(e),!0!==this.isSupported&&!0===r.isSupported?this.isSupported=!0:void 0===this.isSupported&&!1===r.isSupported&&(this.isSupported=!1))}},t.getRepresentation=function(e){return xe(this.representations,(function(t){var n=t.id;return e===n}))},t.getMetadataSnapshot=function(){for(var e,t=[],n=Bn(this.representations);!(e=n()).done;){var r=e.value;t.push(r.getMetadataSnapshot())}return{id:this.id,type:this.type,isSupported:this.isSupported,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:t,label:this.label,isDub:this.isDub}},e}();function Kn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Wn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Wn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Wn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Gn,jn=function(){function e(e,t,n){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((function(r,i){var a=e.adaptations[i];if(null==a)return r;var o=a.map((function(e){var r=new Vn(e,{representationFilter:n});return r.representations.length>0&&!1===r.isSupported&&t.push(r),r})).filter((function(e){return e.representations.length>0}));if(o.every((function(e){return!1===e.isSupported}))&&a.length>0&&("video"===i||"audio"===i))throw new Se("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+i+" adaptations",{tracks:void 0});return o.length>0&&(r[i]=o),r}),{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new Se("MANIFEST_PARSE_ERROR","No supported audio and video tracks.");this.duration=e.duration,this.start=e.start,null!=this.duration&&null!=this.start&&(this.end=this.start+this.duration),this.streamEvents=void 0===e.streamEvents?[]:e.streamEvents}var t=e.prototype;return t.refreshCodecSupport=function(e,t){var n=this;Object.keys(this.adaptations).forEach((function(r){var i=n.adaptations[r];if(void 0!==i){for(var a,o=!1,s=Kn(i);!(a=s()).done;){var u=a.value,l=u.isSupported;u.refreshCodecSupport(e),!1!==l&&!1===u.isSupported&&t.push(u),!1===o?o=u.isSupported:void 0===o&&!0===u.isSupported&&(o=!0)}if(("video"===r||"audio"===r)&&!1===o)throw new Se("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+r+" adaptations",{tracks:void 0})}}),{})},t.getAdaptations=function(){return Ke(this)},t.getAdaptationsForType=function(e){var t=this.adaptations[e];return null==t?[]:t},t.getAdaptation=function(e){return xe(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},t.getSupportedAdaptations=function(e){return Fe(this,e)},t.containsTime=function(e,t){return Ve(this,e,t)},t.getMetadataSnapshot=function(){for(var e,t={},n=Kn(this.getAdaptations());!(e=n()).done;){var r=e.value,i=t[r.type];void 0===i&&(i=[],t[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:t}},e}();function Hn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return qn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function qn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Yn(e,t,n){var r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};e.start=t.start,e.end=t.end,e.duration=t.duration,e.streamEvents=t.streamEvents;for(var i=e.getAdaptations(),a=t.getAdaptations(),o=function(e){var t=i[e],o=S(a,(function(e){return e.id===t.id}));if(-1===o){oe.warn('Manifest: Adaptation "'+i[e].id+'" not found when merging.');var u=i.splice(e,1)[0];e--,r.removedAdaptations.push({id:u.id,trackType:u.type})}else{var l=a.splice(o,1)[0],d=[],c=[],f=[];r.updatedAdaptations.push({adaptation:t.id,trackType:t.type,updatedRepresentations:d,addedRepresentations:c,removedRepresentations:f});for(var v,p=t.representations,h=l.representations.slice(),m=function(e){var t=p[e],r=S(h,(function(e){return e.id===t.id}));if(-1===r){oe.warn('Manifest: Representation "'+p[e].id+'" not found when merging.');var i=p.splice(e,1)[0];e--,f.push(i.id)}else{var a=h.splice(r,1)[0];d.push(t.getMetadataSnapshot()),t.cdnMetadata=a.cdnMetadata,n===Gn.Full?t.index._replace(a.index):t.index._update(a.index)}g=e},g=0;g<p.length;g++)m(g);if(h.length>0)oe.warn("Manifest: "+h.length+" new Representations found when merging."),(v=t.representations).push.apply(v,h),c.push.apply(c,h.map((function(e){return e.getMetadataSnapshot()})))}s=e},s=0;s<i.length;s++)o(s);if(a.length>0){oe.warn("Manifest: "+a.length+" new Adaptations found when merging.");for(var u,l=Hn(a);!(u=l()).done;){var d=u.value,c=e.adaptations[d.type];void 0===c?e.adaptations[d.type]=[d]:c.push(d),r.addedAdaptations.push(d.getMetadataSnapshot())}}return r}function Qn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $n(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $n(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function $n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}!function(e){e[e.Full=0]="Full",e[e.Partial=1]="Partial"}(Gn||(Gn={}));var Xn=Je(),Zn=function(e){function t(t,n,r){var i,a;i=e.call(this)||this;var o=n.representationFilter,s=n.manifestUpdateUrl;i.manifestFormat=0,i.id=Xn(),i.expired=null!==(a=t.expired)&&void 0!==a?a:null,i.transport=t.transportType,i.clockOffset=t.clockOffset;var u=[];if(i.periods=t.periods.map((function(e){return new jn(e,u,o)})).sort((function(e,t){return e.start-t.start})),u.length>0){var l=new Se("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{tracks:u.map(Ye)});r.push(l)}return i.adaptations=void 0===i.periods[0]?{}:i.periods[0].adaptations,i.timeBounds=t.timeBounds,i.isDynamic=t.isDynamic,i.isLive=t.isLive,i.isLastPeriodKnown=t.isLastPeriodKnown,i.uris=void 0===t.uris?[]:t.uris,i.updateUrl=s,i.lifetime=t.lifetime,i.clockOffset=t.clockOffset,i.suggestedPresentationDelay=t.suggestedPresentationDelay,i.availabilityStartTime=t.availabilityStartTime,i.publishTime=t.publishTime,i}u(t,e);var n=t.prototype;return n.refreshCodecSupport=function(e){for(var t,n=[],r=Qn(this.periods);!(t=r()).done;){t.value.refreshCodecSupport(e,n)}return n.length>0?new Se("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{tracks:n.map(Ye)}):null},n.getPeriod=function(e){return xe(this.periods,(function(t){return e===t.id}))},n.getPeriodForTime=function(e){return function(e,t){for(var n=null,r=e.periods.length-1;r>=0;r--){var i=e.periods[r];if(Ve(i,t,n))return i;n=i}}(this,e)},n.getNextPeriod=function(e){return xe(this.periods,(function(t){return t.start>e}))},n.getPeriodAfter=function(e){return ze(this,e)},n.getUrls=function(){return this.uris},n.replace=function(e){this._performUpdate(e,Gn.Full)},n.update=function(e){this._performUpdate(e,Gn.Partial)},n.getMinimumSafePosition=function(){return Le(this)},n.getLivePosition=function(){return Ue(this)},n.getMaximumSafePosition=function(){return Be(this)},n.updateRepresentationsDeciperability=function(e){var t=function(e,t){for(var n,r=[],i=Qn(e.periods);!(n=i()).done;)for(var a,o=n.value,s=Qn(o.getAdaptations());!(a=s()).done;)for(var u,l=a.value,d=Qn(l.representations);!(u=d()).done;){var c=u.value,f={manifest:e,period:o,adaptation:l,representation:c},v=t(f);v!==c.decipherable&&(r.push(f),c.decipherable=v,oe.debug('Decipherability changed for "'+c.id+'"',"("+c.bitrate+")",String(c.decipherable)))}return r}(this,e);t.length>0&&this.trigger("decipherabilityUpdate",t)},n.getAdaptations=function(){Rn("manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead");var e=this.periods[0];if(void 0===e)return[];var t=e.adaptations,n=[];for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];n.push.apply(n,i)}return n},n.getAdaptationsForType=function(e){Rn("manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead");var t=this.periods[0];if(void 0===t)return[];var n=t.adaptations[e];return void 0===n?[]:n},n.getAdaptation=function(e){return Rn("manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead"),xe(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n.getMetadataSnapshot=function(){for(var e,t=[],n=Qn(this.periods);!(e=n()).done;){var r=e.value;t.push(r.getMetadataSnapshot())}return{manifestFormat:1,id:this.id,periods:t,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}},n._performUpdate=function(e,t){var n;if(this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime,t===Gn.Full)this.timeBounds=e.timeBounds,this.uris=e.uris,n=function(e,t){for(var n={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0,i=0;i<t.length;i++){for(var a=t[i],o=r,s=e[o];null!=s&&s.id!==a.id;)s=e[++o];if(null!=s){var u,l,d=Yn(s,a,Gn.Full);n.updatedPeriods.push({period:{id:s.id,start:s.start,end:s.end,duration:s.duration,streamEvents:s.streamEvents},result:d});var c=t.slice(r,i),f=o-r,v=e.splice.apply(e,[r,f].concat(c));(u=n.removedPeriods).push.apply(u,v.map((function(e){return{id:e.id,start:e.start,end:e.end}}))),(l=n.addedPeriods).push.apply(l,c.map((function(e){return e.getMetadataSnapshot()}))),r=i+1}}if(r>e.length)return oe.error("Manifest: error when updating Periods"),n;if(r<e.length){var p,h=e.splice(r,e.length-r);(p=n.removedPeriods).push.apply(p,h.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}var m,g=t.slice(r,t.length);return g.length>0&&(e.push.apply(e,g),(m=n.addedPeriods).push.apply(m,g.map((function(e){return e.getMetadataSnapshot()})))),n}(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],n=function(e,t){var n,r={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(0===e.length)return e.splice.apply(e,[0,0].concat(t)),(n=r.addedPeriods).push.apply(n,t.map((function(e){return e.getMetadataSnapshot()}))),r;if(0===t.length)return r;var i=e[e.length-1];if(i.start<t[0].start){var a;if(i.end!==t[0].start)throw new Se("MANIFEST_UPDATE_ERROR","Cannot perform partial update: not enough data");return e.push.apply(e,t),(a=r.addedPeriods).push.apply(a,t.map((function(e){return e.getMetadataSnapshot()}))),r}var o=S(e,(function(e){return e.id===t[0].id}));if(o<0)throw new Se("MANIFEST_UPDATE_ERROR","Cannot perform partial update: incoherent data");var s=Yn(e[o],t[0],Gn.Partial);r.updatedPeriods.push({period:d(e[o].getMetadataSnapshot(),{adaptations:void 0}),result:s});for(var u=o+1,l=1;l<t.length;l++){for(var c=t[l],f=-1,v=u;v<e.length;v++)if(c.id===e[v].id){f=v;break}if(f<0){for(var p,h=-1,m=u;m<e.length;m++)if(c.start<e[m].start){h=m;break}var g=h-u,y=e.splice(u,g,c);r.addedPeriods.push(c.getMetadataSnapshot()),(p=r.removedPeriods).push.apply(p,y.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}else{if(f>u){var _;oe.warn("Manifest: old Periods not found in new when updating, removing");var b=e.splice(u,f-u);(_=r.removedPeriods).push.apply(_,b.map((function(e){return{id:e.id,start:e.start,end:e.end}}))),f=u}var E=Yn(e[f],c,Gn.Full);r.updatedPeriods.push({period:d(e[f].getMetadataSnapshot(),{adaptations:void 0}),result:E})}u++}if(u<e.length){var T;oe.warn("Manifest: Ending Periods not found in new when updating, removing");var k=e.splice(u,e.length-u);(T=r.removedPeriods).push.apply(T,k.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}return r}(this.periods,e.periods);for(var r=this.getMinimumSafePosition();this.periods.length>0;){var i=this.periods[0];if(void 0===i.end||i.end>r)break;this.periods.shift()}}this.adaptations=void 0===this.periods[0]?{}:this.periods[0].adaptations,this.trigger("manifestUpdate",n)},t}(ie);var Jn=Zn;function er(e){return e instanceof pe?new Ee("PIPELINE_LOAD_ERROR",e):we(e,{defaultCode:"PIPELINE_LOAD_ERROR",defaultReason:"Unknown error when fetching the Manifest"})}var tr=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(de(a),t.prototype),a.name="CustomLoaderError",a.message=n,a.canRetry=r,a.xhr=i,a}return u(t,e),t}(ve(Error));function nr(e,t){return sn(t,(function(t){var n=setTimeout((function(){return t()}),e);return function(){return clearTimeout(n)}}))}var rr=.3;function ir(e){return e*((2*Math.random()-1)*rr+1)}function ar(e,t,n,r,i){return or.apply(this,arguments)}function or(){return or=_t(St().mark((function e(t,n,r,i,a){var o,s,u,l,d,c,f,v,p,h,m,g,y;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(y=function(e){var t;if(0===d.size)return e[0];var n=Me();return null===(t=e.filter((function(e){var t;return!0!==(null===(t=d.get(e))||void 0===t?void 0:t.isBlacklisted)})).reduce((function(e,t){var r,i=null===(r=d.get(t))||void 0===r?void 0:r.blockedUntil;return void 0!==i&&i<=n&&(i=void 0),void 0===e?[t,i]:void 0===i?void 0===e[1]?e:[t,void 0]:void 0===e[1]?e:i<e[1]?[t,i]:e}),void 0))||void 0===t?void 0:t[0]},g=function(e,t){var r=d.get(e);if(void 0===r||void 0===r.blockedUntil)return v(e);var i=Me(),o=r.blockedUntil-i;if(o<=0)return v(e);var s=new ht,u=s.linkToSignal(a);return new Promise((function(r,i){function l(e){u(),r(e)}function d(e){u(),i(e)}null==n||n.addEventListener("priorityChange",(function(){var n=f();if(a.isCancelled())throw a.cancellationError;if(void 0===n)return d(t);n!==e&&(s.cancel(),g(n,t).then(l,d))}),s.signal),nr(o,s.signal).then((function(){return v(e).then(l,d)}),b)}))},m=function(){return(m=_t(St().mark((function e(t){var n;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=f(),!a.isCancelled()){e.next=3;break}throw a.cancellationError;case 3:if(void 0!==n){e.next=5;break}throw t;case 5:if(l(t),!a.isCancelled()){e.next=8;break}throw a.cancellationError;case 8:return e.abrupt("return",g(n,t));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)},h=function(e){return m.apply(this,arguments)},p=function(){return(p=_t(St().mark((function e(t){var i,l,c,f,v;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r(t,a);case 3:return i=e.sent,e.abrupt("return",i);case 7:if(e.prev=7,e.t0=e.catch(0),!ht.isCancellationError(e.t0)){e.next=11;break}throw e.t0;case 11:if(null!==t&&null!==n&&n.downgradeCdn(t),void 0===(l=d.get(t))?(l={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},d.set(t,l)):l.errorCounter++,(p=e.t0)instanceof pe?p.type===me.ERROR_HTTP_CODE?p.status>=500||404===p.status||415===p.status||412===p.status:p.type===me.TIMEOUT||p.type===me.ERROR_EVENT:p instanceof tr?"boolean"==typeof p.canRetry?p.canRetry:void 0!==p.xhr&&(p.xhr.status>=500||404===p.xhr.status||415===p.xhr.status||412===p.xhr.status):ke(p)&&"INTEGRITY_ERROR"===p.code){e.next=18;break}return l.blockedUntil=void 0,l.isBlacklisted=!0,e.abrupt("return",h(e.t0));case 18:return l.errorCounter>u?(l.blockedUntil=void 0,l.isBlacklisted=!0):(c=l.errorCounter,f=Math.min(o*Math.pow(2,c-1),s),v=ir(f),l.blockedUntil=Me()+v),e.abrupt("return",h(e.t0));case 20:case"end":return e.stop()}var p}),e,null,[[0,7]])})))).apply(this,arguments)},v=function(e){return p.apply(this,arguments)},f=function(){if(null===t){var e=d.get(null);if(void 0!==e&&e.isBlacklisted)return;return null}if(null===n)return y(t);var r=n.getCdnPreferenceForResource(t);return y(r)},null===a.cancellationError){e.next=9;break}return e.abrupt("return",Promise.reject(a.cancellationError));case 9:if(o=i.baseDelay,s=i.maxDelay,u=i.maxRetry,l=i.onRetry,null!==t&&0===t.length&&oe.warn("Fetchers: no CDN given to `scheduleRequestWithCdns`."),d=new Map,void 0!==(c=f())){e.next=15;break}throw new Error("No CDN to request");case 15:return e.abrupt("return",v(c));case 16:case"end":return e.stop()}}),e)}))),or.apply(this,arguments)}function sr(e,t,n){return ar(null,null,e,t,n)}function ur(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return lr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function lr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var dr=function(e){function t(t,n,r){var i;return(i=e.call(this)||this).scheduleManualRefresh=b,i._manifestUrls=t,i._pipelines=n.manifest,i._settings=r,i._canceller=new ht,i._isStarted=!1,i._isRefreshPending=!1,i._consecutiveUnsafeMode=0,i._prioritizedContentUrl=null,i}u(t,e);var n=t.prototype;return n.dispose=function(){this._canceller.cancel(),this.removeEventListener()},n.start=function(){var e=this;if(!this._isStarted){this._isStarted=!0;var t=this._settings.initialManifest;(t instanceof Jn?Promise.resolve({manifest:t}):void 0!==t?this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):this._fetchManifest(void 0).then((function(e){return e.parse({previousManifest:null,unsafeMode:!1})}))).then((function(t){e.trigger("manifestReady",t.manifest),e._canceller.isUsed()||e._recursivelyRefreshManifest(t.manifest,t)})).catch((function(t){return e._onFatalError(t)}))}},n.updateContentUrls=function(e,t){var n;this._prioritizedContentUrl=null!==(n=null==e?void 0:e[0])&&void 0!==n?n:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})},n._fetchManifest=function(){var e=_t(St().mark((function e(t){var n,r,i,a,o,s,u,l,d=this;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=function(e){var t=a.loadManifest,n=void 0===i.requestTimeout?p.getCurrent().DEFAULT_REQUEST_TIMEOUT:i.requestTimeout,o=void 0===i.connectionTimeout?p.getCurrent().DEFAULT_CONNECTION_TIMEOUT:i.connectionTimeout;n<0&&(n=void 0),o<0&&(o=void 0);return sr((function(){return t(e,{timeout:n,connectionTimeout:o},r)}),s,r)},r=this._canceller.signal,i=this._settings,a=this._pipelines,o=null!=t?t:null===(n=this._manifestUrls)||void 0===n?void 0:n[0],s=this._getBackoffSetting((function(e){d.trigger("warning",er(e))})),e.prev=6,e.next=9,l(o);case 9:return u=e.sent,e.abrupt("return",{parse:function(e){return d._parseLoadedManifest(u,e,o)}});case 13:throw e.prev=13,e.t0=e.catch(6),er(e.t0);case 16:case"end":return e.stop()}}),e,this,[[6,13]])})));return function(t){return e.apply(this,arguments)}}(),n.parse=function(e,t,n){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,n)},n._parseLoadedManifest=function(){var e=_t(St().mark((function e(t,n,r){var i,a,o,s,u,l,d,c,f,v,p,h,m,g,y,_,b,S=this;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(b=function(e,t){_(t);var n=Me()-a;return oe.info("MF: Manifest parsed in "+n+"ms"),{manifest:e,sendingTime:u,receivedTime:l,parsingTime:n}},_=function(e){for(var t,n=ur(e);!(t=n()).done;){var r=t.value;if(o.isCancelled())return;var i=we(r,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown error when parsing the Manifest"});s("warning",i)}},y=function(){return(y=_t(St().mark((function e(t){var n;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,sr(t,d,o);case 3:return n=e.sent,e.abrupt("return",n);case 7:throw e.prev=7,e.t0=e.catch(0),er(e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)},g=function(e){return y.apply(this,arguments)},a=Me(),o=this._canceller.signal,s=this.trigger.bind(this),u=t.sendingTime,l=t.receivedTime,d=this._getBackoffSetting((function(e){S.trigger("warning",er(e))})),c=null!=r?r:null===(i=this._manifestUrls)||void 0===i?void 0:i[0],f={externalClockOffset:n.externalClockOffset,unsafeMode:n.unsafeMode,previousManifest:n.previousManifest,originalUrl:c},e.prev=11,v=this._pipelines.parseManifest(t,f,_,o,g),v instanceof Promise){e.next=17;break}return e.abrupt("return",b(v.manifest,v.warnings));case 17:return e.next=19,v;case 19:return p=e.sent,h=p.manifest,m=p.warnings,e.abrupt("return",b(h,m));case 23:e.next=29;break;case 25:throw e.prev=25,e.t0=e.catch(11),we(e.t0,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown error when parsing the Manifest"});case 29:case"end":return e.stop()}}),e,this,[[11,25]])})));return function(t,n,r){return e.apply(this,arguments)}}(),n._getBackoffSetting=function(e){var t=p.getCurrent(),n=t.DEFAULT_MAX_MANIFEST_REQUEST_RETRY,r=t.INITIAL_BACKOFF_DELAY_BASE,i=t.MAX_BACKOFF_DELAY_BASE,a=this._settings,o=a.lowLatencyMode,s=a.maxRetry;return{onRetry:e,baseDelay:o?r.LOW_LATENCY:r.REGULAR,maxDelay:o?i.LOW_LATENCY:i.REGULAR,maxRetry:null!=s?s:n}},n._recursivelyRefreshManifest=function(e,t){var n=this,r=t.sendingTime,i=t.parsingTime,a=t.updatingTime,o=p.getCurrent(),s=o.MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE,u=o.MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE,l=void 0!==i?i+(null!=a?a:0):void 0,d=this._consecutiveUnsafeMode>0?this._consecutiveUnsafeMode<s:void 0!==l&&l>=u,c=void 0===r?0:Me()-r,f=Math.max(this._settings.minimumManifestUpdateInterval-c,0),v=new ht;if(v.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=function(t){var i=t.enablePartialRefresh,a=t.delay,o=t.canUseUnsafeMode&&d,s=void 0===r?0:Me()-r,u=Math.max(n._settings.minimumManifestUpdateInterval-s,0),l=setTimeout((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:i,unsafeMode:o})}),Math.max((null!=a?a:0)-s,u));v.signal.register((function(){clearTimeout(l)}))},null!==e.expired){var h=setTimeout((function(){var t;null===(t=e.expired)||void 0===t||t.then((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})}),b)}),f);v.signal.register((function(){clearTimeout(h)}))}if(void 0!==e.lifetime&&e.lifetime>=0){var m,g=1e3*e.lifetime-c;void 0===l?m=g:e.lifetime<3&&l>=100?(m=Math.min(Math.max(3e3-c,Math.max(g,0)+l),6*g),oe.info("MUS: Manifest update rythm is too frequent. Postponing next request.",g,m)):l>=1e3*e.lifetime/10?(m=Math.min(Math.max(g,0)+l,6*g),oe.info("MUS: Manifest took too long to parse. Postponing next request",m,m)):m=g;var y=setTimeout((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})}),Math.max(m,f));v.signal.register((function(){clearTimeout(y)}))}},n._triggerNextManifestRefresh=function(e,t){var n,r,i=this,a=t.enablePartialRefresh,o=t.unsafeMode,s=e.updateUrl;null!==this._prioritizedContentUrl?(n=!0,r=this._prioritizedContentUrl,this._prioritizedContentUrl=null):r=(n=!a||void 0===s)?e.getUrls()[0]:s;var u=e.clockOffset;o?(this._consecutiveUnsafeMode+=1,oe.info('Init: Refreshing the Manifest in "unsafeMode" for the '+String(this._consecutiveUnsafeMode)+" consecutive time.")):this._consecutiveUnsafeMode>0&&(oe.info('Init: Not parsing the Manifest in "unsafeMode" anymore after '+String(this._consecutiveUnsafeMode)+" consecutive times."),this._consecutiveUnsafeMode=0),this._isRefreshPending||(this._isRefreshPending=!0,this._fetchManifest(r).then((function(t){return t.parse({externalClockOffset:u,previousManifest:e,unsafeMode:o})})).then((function(t){i._isRefreshPending=!1;var r=t.manifest,a=t.sendingTime,o=t.parsingTime,s=Me();if(n)e.replace(r);else try{e.update(r)}catch(t){var u=t instanceof Error?t.message:"unknown error";oe.warn("MUS: Attempt to update Manifest failed: "+u,"Re-downloading the Manifest fully");var l=p.getCurrent().FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY,d=void 0===a?0:Me()-a,c=Math.max(i._settings.minimumManifestUpdateInterval-d,0),f=b,v=setTimeout((function(){f(),i._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})}),Math.max(l-d,c));return void(f=i._canceller.signal.register((function(){clearTimeout(v)})))}var h=Me()-s;i._recursivelyRefreshManifest(e,{sendingTime:a,parsingTime:o,updatingTime:h})})).catch((function(e){i._isRefreshPending=!1,i._onFatalError(e)})))},n._onFatalError=function(e){this._canceller.isUsed()||(this.trigger("error",e),this.dispose())},t}(ie);var cr=dr;function fr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function vr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var pr=function(e){function t(t){var n;return(n=e.call(this)||this)._downgradedCdnList={metadata:[],timeouts:[]},t.register((function(){for(var e,t=fr(n._downgradedCdnList.timeouts);!(e=t()).done;){var r=e.value;clearTimeout(r)}n._downgradedCdnList={metadata:[],timeouts:[]}})),n}u(t,e);var n=t.prototype;return n.getCdnPreferenceForResource=function(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)},n.downgradeCdn=function(e){var t=this,n=hr(this._downgradedCdnList.metadata,e);n>=0&&this._removeIndexFromDowngradeList(n);var r=p.getCurrent().DEFAULT_CDN_DOWNGRADE_TIME;this._downgradedCdnList.metadata.push(e);var i=setTimeout((function(){var n=hr(t._downgradedCdnList.metadata,e);n>=0&&t._removeIndexFromDowngradeList(n),t.trigger("priorityChange",null)}),r);this._downgradedCdnList.timeouts.push(i),this.trigger("priorityChange",null)},n._innerGetCdnPreferenceForResource=function(e){var t=this,n=e.reduce((function(e,n){return t._downgradedCdnList.metadata.some((function(e){return e.id===n.id&&e.baseUrl===n.baseUrl}))?e[1].push(n):e[0].push(n),e}),[[],[]]),r=n[0],i=n[1];return r.concat(i)},n._removeIndexFromDowngradeList=function(e){this._downgradedCdnList.metadata.splice(e,1);var t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])},t}(ie);function hr(e,t){return 0===e.length?-1:void 0!==t.id?S(e,(function(e){return e.id===t.id})):S(e,(function(e){return e.baseUrl===t.baseUrl}))}var mr=function(){function e(){this._cache=new WeakMap}var t=e.prototype;return t.add=function(e,t){var n=e.representation;e.segment.isInit&&this._cache.set(n,t)},t.get=function(e){var t=e.representation;if(e.segment.isInit){var n=this._cache.get(t);if(void 0!==n)return n}return null},e}(),gr=Je();var yr=function(){function e(e){var t=e.prioritySteps;if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=t,this._prioritySteps.high>=this._prioritySteps.low)throw new Error("TP: the max high level priority should be given a lowerpriority number than the min low priority.")}var t=e.prototype;return t.create=function(e,t,n,r){var i,a=this;return sn(r,(function(o,s){return i={hasEnded:!1,priority:t,trigger:function(){if(!i.hasEnded){var e=function(){u(),a._endTask(i)},t=new ht,u=t.linkToSignal(r);i.interrupter=t,t.signal.register((function(){i.interrupter=null,r.isCancelled()||n.beforeInterrupted()})),a._minPendingPriority=null===a._minPendingPriority?i.priority:Math.min(a._minPendingPriority,i.priority),a._pendingTasks.push(i),i.taskFn(t.signal).then((function(t){n.beforeEnded(),e(),o(t)})).catch((function(n){!r.isCancelled()&&t.isUsed()&&n instanceof gt||function(t){e(),s(t)}(n)}))}},taskFn:e,interrupter:null},a._canBeStartedNow(i)?(i.trigger(),a._isRunningHighPriorityTasks()&&a._interruptCancellableTasks()):a._waitingQueue.push(i),function(){return a._endTask(i)}}))},t._endTask=function(e){e.hasEnded=!0;var t=_r(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{var n=_r(e.taskFn,this._pendingTasks);if(n<0)return;this._pendingTasks.splice(n,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}},t.updatePriority=function(e,t){var n=_r(e,this._waitingQueue);if(n>=0){var r=this._waitingQueue[n];if(r.priority===t)return;if(r.priority=t,!this._canBeStartedNow(r))return;return this._findAndRunWaitingQueueTask(n),void(this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks())}var i=_r(e,this._pendingTasks);if(i<0)oe.warn("TP: request to update the priority of a non-existent task");else{var a=this._pendingTasks[i];if(a.priority!==t){var o=a.priority;a.priority=t,null===this._minPendingPriority||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(1===this._pendingTasks.length?this._minPendingPriority=t:this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority}))),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}}},t._loopThroughWaitingQueue=function(){var e=this._waitingQueue.reduce((function(e,t){return null===e||e>t.priority?t.priority:e}),null);if(!(null===e||null!==this._minPendingPriority&&this._minPendingPriority<e))for(var t=0;t<this._waitingQueue.length;t++){var n=null===this._minPendingPriority?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=n&&(this._findAndRunWaitingQueueTask(t),t--)}},t._interruptCancellableTasks=function(){for(var e=0;e<this._pendingTasks.length;e++){var t=this._pendingTasks[e];if(t.priority>=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}},t._findAndRunWaitingQueueTask=function(e){return e>=this._waitingQueue.length||e<0?(oe.warn("TP : Tried to start a non existing task"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)},t._interruptPendingTask=function(e){var t,n=_r(e.taskFn,this._pendingTasks);n<0?oe.warn("TP: Interrupting a non-existent pending task. Aborting..."):(this._pendingTasks.splice(n,1),this._waitingQueue.push(e),0===this._pendingTasks.length?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))),null===(t=e.interrupter)||void 0===t||t.cancel())},t._canBeStartedNow=function(e){return null===this._minPendingPriority||e.priority<=this._minPendingPriority},t._isRunningHighPriorityTasks=function(){return null!==this._minPendingPriority&&this._minPendingPriority<=this._prioritySteps.high},e}();function _r(e,t){return S(t,(function(t){return t.taskFn===e}))}var br=function(){function e(e,t,n){var r=new pr(n),i=p.getCurrent(),a=i.MIN_CANCELABLE_PRIORITY,o=i.MAX_HIGH_PRIORITY_LEVEL;this._transport=e,this._prioritizer=new yr({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=r,this._backoffOptions=t}return e.prototype.createSegmentFetcher=function(e,t){var n,r,i,a,o,s,u,l,c,f,v,h,m,g,y=(n=this._backoffOptions,r=n.maxRetry,i=n.lowLatencyMode,a=n.requestTimeout,o=n.connectionTimeout,s=p.getCurrent(),u=s.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,l=s.DEFAULT_REQUEST_TIMEOUT,c=s.DEFAULT_CONNECTION_TIMEOUT,f=s.INITIAL_BACKOFF_DELAY_BASE,v=s.MAX_BACKOFF_DELAY_BASE,{maxRetry:null!=r?r:u,baseDelay:i?f.LOW_LATENCY:f.REGULAR,maxDelay:i?v.LOW_LATENCY:v.REGULAR,requestTimeout:void 0===a?l:a,connectionTimeout:void 0===o?c:o}),b=function(e,t,n,r,i){var a={timeout:i.requestTimeout<0?void 0:i.requestTimeout,connectionTimeout:void 0===i.connectionTimeout||i.connectionTimeout<0?void 0:i.connectionTimeout},o=Qe(["audio","video"],e)?new mr:void 0,s=t.loadSegment,u=t.parseSegment;return function(){var e=_t(St().mark((function e(t,l,c){var f,v,p,h,m,g,y,b,S,E,T,k,w,A,I,R,x,C,M,P,D,O,N,L;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(L=function(){var e;A||!_(T)&&void 0!==T.size&&void 0!==T.requestDuration&&k.length>0&&k.every((function(e){return e}))&&(A=!0,null===(e=r.onMetrics)||void 0===e||e.call(r,{size:T.size,requestDuration:T.requestDuration,content:t,segmentDuration:w}))},N=function(e){l.onRetry(er(e))},O=function(e,t){k.push(!1);var n=k.length-1;return function(r){var i={data:e,isChunked:t};try{var a=u(i,I,r);return k[n]||(w=void 0!==w&&"media"===a.segmentType&&null!==a.chunkInfos&&void 0!==a.chunkInfos.duration?w+a.chunkInfos.duration:void 0,k[n]=!0,L()),a}catch(e){throw we(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown parsing error"})}}},D=function(e){return s(e,I,a,c,R)},P=function(){var e;void 0===T&&(oe.debug("SF: Segment request cancelled",S),T=null,null===(e=r.onRequestEnd)||void 0===e||e.call(r,{id:E}))},h=t.segment,m=t.adaptation,g=t.representation,y=t.manifest,b=t.period,S=Ne(t),E=gr(),k=[],w=0,A=!1,I={segment:h,type:m.type,language:m.language,isLive:y.isLive,periodStart:b.start,periodEnd:b.end,mimeType:g.mimeType,codecs:g.codecs[0],manifestPublishTime:y.publishTime},R={onProgress:function(e){var t;void 0===T&&void 0!==e.totalSize&&e.size<e.totalSize&&(null===(t=r.onProgress)||void 0===t||t.call(r,{duration:e.duration,size:e.size,totalSize:e.totalSize,timestamp:Me(),id:E}))},onNewChunk:function(e){l.onChunk(O(e,!0))}},null===(x=void 0!==o?o.get(t):null)){e.next=18;break}return oe.debug("SF: Found wanted segment in cache",S),l.onChunk(O(x,!1)),e.abrupt("return",Promise.resolve());case 18:return oe.debug("SF: Beginning request",S),null===(f=r.onRequestBegin)||void 0===f||f.call(r,{requestTimestamp:Me(),id:E,content:t}),c.register(P),e.prev=21,e.next=24,ar(t.representation.cdnMetadata,n,D,d({onRetry:N},i),c);case 24:"segment-loaded"===(C=e.sent).resultType?(M=C.resultData.responseData,void 0!==o&&o.add(t,C.resultData.responseData),l.onChunk(O(M,!1))):"segment-created"===C.resultType&&l.onChunk(O(C.resultData,!1)),oe.debug("SF: Segment request ended with success",S),l.onAllChunksReceived(),"segment-created"!==C.resultType?(T=C.resultData,L()):T=null,c.isCancelled()||null===(v=r.onRequestEnd)||void 0===v||v.call(r,{id:E}),c.deregister(P),e.next=43;break;case 33:if(e.prev=33,e.t0=e.catch(21),c.deregister(P),T=null,!(e.t0 instanceof gt)){e.next=40;break}throw oe.debug("SF: Segment request aborted",S),e.t0;case 40:throw oe.debug("SF: Segment request failed",S),null===(p=r.onRequestEnd)||void 0===p||p.call(r,{id:E}),er(e.t0);case 43:case"end":return e.stop()}}),e,null,[[21,33]])})));return function(t,n,r){return e.apply(this,arguments)}}()}(e,this._transport[e],this._cdnPrioritizer,t,y);return h=this._prioritizer,m=b,g=new WeakMap,{createRequest:function(e,t,n,r){var i=function(t){return m(e,n,t)},a=h.create(i,t,n,r);return g.set(a,i),a},updatePriority:function(e,t){var n=g.get(e);void 0!==n?h.updatePriority(n,t):oe.warn("Fetchers: Cannot update the priority of a request: task not found.")}}},e}(),Sr=br;function Er(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Tr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Tr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Tr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var kr=function(){function e(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}var t=e.prototype;return t.addBufferedSegment=function(e,t){var n=Me();this._history.push({date:n,buffered:t,context:e}),this._cleanHistory(n)},t.getHistoryFor=function(e){return this._history.filter((function(t){return Oe(t.context,e)}))},t._cleanHistory=function(e){for(var t,n=e-this._lifetime,r=0,i=Er(this._history);!(t=i()).done;){if(!(t.value.date<n))break;r++}if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){var a=this._history.length-this._maxHistoryLength;this._history=this._history.splice(a)}},e}();function wr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ar(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ar(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ar(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ir=function(){function e(){var e=p.getCurrent(),t=e.BUFFERED_HISTORY_RETENTION_TIME,n=e.BUFFERED_HISTORY_MAXIMUM_ENTRIES;this._inventory=[],this._bufferedHistory=new kr(t,n)}var t=e.prototype;return t.reset=function(){this._inventory.length=0},t.synchronizeBuffered=function(e){for(var t,n,r,i,a,o,s,u=this._inventory,l=0,d=u[0],c=p.getCurrent().MINIMUM_SEGMENT_SIZE,f=null==d?void 0:d.infos.adaptation.type,v=e.length,h=0;h<v;h++){if(void 0===d)return;var m=e[h].start,g=e[h].end;if(g-m<c)oe.warn("SI: skipped range when synchronizing because it was too small",f,m,g);else{for(var y=l;void 0!==d&&(null!==(t=d.bufferedEnd)&&void 0!==t?t:d.end)-m<c;)d=u[++l];var _=null,b=l-y;if(b>0){var S=u[y+b-1];_={end:null!==(n=S.bufferedEnd)&&void 0!==n?n:S.end,precizeEnd:S.precizeEnd},oe.debug("SI: "+b+" segments GCed.",f);for(var E,T=wr(u.splice(y,b));!(E=T()).done;){var k=E.value;void 0===k.bufferedStart&&void 0===k.bufferedEnd&&2!==k.status&&this._bufferedHistory.addBufferedSegment(k.infos,null)}l=y}if(void 0===d)return;if(g-(null!==(r=d.bufferedStart)&&void 0!==r?r:d.start)>=c){if(Cr(d,m,_,f),l===u.length-1)return void Mr(d,g,f);for(var w=null!==(i=(d=u[++l]).bufferedStart)&&void 0!==i?i:d.start,A=null!==(a=d.bufferedEnd)&&void 0!==a?a:d.end,I=h<v-1?e[h+1].start:void 0;void 0!==d&&g-w>=c&&(void 0===I||g-w>=A-I);){var R=u[l-1];void 0===R.bufferedEnd&&(R.bufferedEnd=d.precizeStart?d.start:R.end,oe.debug("SI: calculating buffered end of contiguous segment",f,R.bufferedEnd,R.end)),d.bufferedStart=R.bufferedEnd,void 0!==(d=u[++l])&&(w=null!==(o=d.bufferedStart)&&void 0!==o?o:d.start,A=null!==(s=d.bufferedEnd)&&void 0!==s?s:d.end)}}var x=u[l-1];void 0!==x&&Mr(x,g,f)}}if(null!=d){oe.debug("SI: last segments have been GCed",f,l,u.length);for(var C,M=wr(u.splice(l,u.length-l));!(C=M()).done;){var P=C.value;void 0===P.bufferedStart&&void 0===P.bufferedEnd&&2!==P.status&&this._bufferedHistory.addBufferedSegment(P.infos,null)}}void 0!==f&&oe.hasLevel("DEBUG")&&oe.debug("SI: current "+f+" inventory timeline:\n"+function(e){var t=1/60,n={},r=[],i=null,a=null;function o(e){var t=String.fromCharCode(r.length+65);return r.push({letter:t,periodId:e.period.id,representationId:e.representation.id,bitrate:e.representation.bitrate}),t}for(var s="",u=0;u<e.length;u++){var l=e[u];if(void 0!==l.bufferedStart&&void 0!==l.bufferedEnd){var d,c=l.infos.period.id,f=l.infos.representation.id,v=n[c],p=void 0;if(void 0===v)p=o(l.infos),n[c]=((d={})[f]=p,d);else void 0===v[f]?(p=o(l.infos),v[f]=p):p=v[f];null===i?s+=l.bufferedStart.toFixed(2)+"|"+p+"|":a===p?i.bufferedEnd+t<l.bufferedStart&&(s+=i.bufferedEnd.toFixed(2)+" ~ "+l.bufferedStart.toFixed(2)+"|"+p+"|"):s+=i.bufferedEnd.toFixed(2)+" ~ "+l.bufferedStart.toFixed(2)+"|"+p+"|",i=l,a=p}}null!==i&&(s+=String(i.end.toFixed(2)));return r.forEach((function(e){var t;s+="\n["+e.letter+"] P: "+e.periodId+" || R: "+e.representationId+"("+(null!==(t=e.bitrate)&&void 0!==t?t:"unknown bitrate")+")"})),s}(this._inventory))},t.insertChunk=function(e,t,n){var r=e.period,i=e.adaptation,a=e.representation,o=e.segment,s=e.chunkSize,u=e.start,l=e.end;if(!o.isInit){var d=i.type;if(u>=l)oe.warn("SI: Invalid chunked inserted: starts before it ends",d,u,l);else{for(var c=this._inventory,f={status:t?0:2,insertionTs:n,chunkSize:s,splitted:!1,start:u,end:l,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:o,period:r,adaptation:i,representation:a}},v=c.length-1;v>=0;v--){var p=c[v];if(p.start<=u){if(p.end<=u){for(oe.debug("SI: Pushing segment strictly after previous one.",d,u,p.end),this._inventory.splice(v+1,0,f),v+=2;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return oe.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);oe.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}if(p.start===u){if(p.end<=l){for(oe.debug("SI: Segment pushed replace another one",d,u,l,p.end),this._inventory.splice(v,1,f),v+=1;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return oe.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);oe.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}return oe.debug("SI: Segment pushed ends before another with the same start",d,u,l,p.end),c.splice(v,0,f),p.start=f.end,p.bufferedStart=void 0,void(p.precizeStart=p.precizeStart&&f.precizeEnd)}if(p.end<=f.end){for(oe.debug("SI: Segment pushed updates end of previous one",d,u,l,p.start,p.end),this._inventory.splice(v+1,0,f),p.end=f.start,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&f.precizeStart,v+=2;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return oe.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);oe.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}oe.warn("SI: Segment pushed is contained in a previous one",d,u,l,p.start,p.end);var h={status:p.status,insertionTs:p.insertionTs,chunkSize:p.chunkSize,splitted:!0,start:f.end,end:p.end,precizeStart:p.precizeStart&&p.precizeEnd&&f.precizeEnd,precizeEnd:p.precizeEnd,bufferedStart:void 0,bufferedEnd:p.end,infos:p.infos};return p.end=f.start,p.splitted=!0,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&f.precizeStart,c.splice(v+1,0,f),void c.splice(v+2,0,h)}}var m=this._inventory[0];if(void 0===m)return oe.debug("SI: first segment pushed",d,u,l),void this._inventory.push(f);if(!(m.start>=l)){if(m.end<=l){for(oe.debug("SI: Segment pushed starts before and completely recovers the previous first one",d,u,l,m.start,m.end),this._inventory.splice(0,1,f);c.length>1&&c[1].start<f.end;){if(c[1].end>f.end)return oe.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[1].start),c[1].start=f.end,c[1].bufferedStart=void 0,void(c[1].precizeStart=f.precizeEnd);oe.debug("SI: Segment pushed removes the next one",d,u,l,c[1].start,c[1].end),c.splice(1,1)}return}return oe.debug("SI: Segment pushed start of the next one",d,u,l,m.start,m.end),m.start=l,m.bufferedStart=void 0,m.precizeStart=f.precizeEnd,void this._inventory.splice(0,0,f)}oe.debug("SI: Segment pushed comes before all previous ones",d,u,l,m.start),this._inventory.splice(0,0,f)}}},t.completeSegment=function(e){if(!e.segment.isInit){for(var t=this._inventory,n=[],r=0;r<t.length;r++)if(Oe(t[r].infos,e)){var i=!1;n.length>0&&(i=!0,1===n.length&&(oe.warn("SI: Completed Segment is splitted.",e.segment.id,e.segment.time,e.segment.end),n[0].splitted=!0));var a=r,o=t[r].chunkSize;for(r+=1;r<t.length&&Oe(t[r].infos,e);){var s=t[r].chunkSize;void 0!==o&&void 0!==s&&(o+=s),r++}var u=r-1,l=u-a,d=t[u].end,c=t[u].bufferedEnd;l>0&&(this._inventory.splice(a+1,l),r-=l),0===this._inventory[a].status&&(this._inventory[a].status=1),this._inventory[a].chunkSize=o,this._inventory[a].end=d,this._inventory[a].bufferedEnd=c,this._inventory[a].splitted=i,n.push(this._inventory[a])}if(0===n.length)oe.warn("SI: Completed Segment not found",e.segment.id,e.segment.time);else for(var f,v=wr(n);!(f=v()).done;){var p=f.value;void 0!==p.bufferedStart&&void 0!==p.bufferedEnd?2!==p.status&&this._bufferedHistory.addBufferedSegment(p.infos,{start:p.bufferedStart,end:p.bufferedEnd}):oe.debug("SI: buffered range not known after sync. Skipping history.",p.start,p.end)}}},t.getInventory=function(){return this._inventory},t.getHistoryFor=function(e){return this._bufferedHistory.getHistoryFor(e)},e}();function Rr(e){if(void 0===e.bufferedStart||1!==e.status)return!1;var t=e.start,n=e.end-t,r=p.getCurrent(),i=r.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,a=r.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(t-e.bufferedStart)<=i&&(void 0===e.bufferedEnd||e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-n)<=Math.min(a,n/3))}function xr(e){if(void 0===e.bufferedEnd||1!==e.status)return!1;var t=e.start,n=e.end,r=n-t,i=p.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(n-e.bufferedEnd)<=a&&null!=e.bufferedStart&&e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-r)<=Math.min(o,r/3)}function Cr(e,t,n,r){var i=p.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MISSING_DATA_TRIGGER_SYNC_DELAY,s=i.SEGMENT_SYNCHRONIZATION_DELAY;if(void 0!==e.bufferedStart)e.bufferedStart<t&&(oe.debug("SI: Segment partially GCed at the start",r,e.bufferedStart,t),e.bufferedStart=t),!e.precizeStart&&Rr(e)&&(e.start=e.bufferedStart,e.precizeStart=!0);else if(e.precizeStart)oe.debug("SI: buffered start is precize start",r,e.start),e.bufferedStart=e.start;else if(null!==n&&n.end>t&&(n.precizeEnd||e.start-n.end<=a))oe.debug("SI: buffered start is end of previous segment",r,t,e.start,n.end),e.bufferedStart=n.end,Rr(e)&&(e.start=n.end,e.precizeStart=!0);else if(e.start-t<=a){var u=Me();if(e.start-t>=o&&u-e.insertionTs<s)return void oe.debug("SI: Ignored bufferedStart synchronization",r,t,e.start,u-e.insertionTs);oe.debug("SI: found true buffered start",r,t,e.start),e.bufferedStart=t,Rr(e)&&(e.start=t,e.precizeStart=!0)}else if(t<e.start)oe.debug("SI: range start too far from expected start",r,t,e.start),e.bufferedStart=e.start;else{var l=Me();if(e.start-t>=o&&l-e.insertionTs<s)return void oe.debug("SI: Ignored bufferedStart synchronization",r,t,e.start,l-e.insertionTs);oe.debug("SI: Segment appears immediately garbage collected at the start",r,t,e.start),e.bufferedStart=t}}function Mr(e,t,n){var r=p.getCurrent(),i=r.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,a=r.MISSING_DATA_TRIGGER_SYNC_DELAY,o=r.SEGMENT_SYNCHRONIZATION_DELAY;if(void 0!==e.bufferedEnd)e.bufferedEnd>t&&(oe.debug("SI: Segment partially GCed at the end",n,e.bufferedEnd,t),e.bufferedEnd=t),!e.precizeEnd&&t-e.end<=i&&xr(e)&&(e.precizeEnd=!0,e.end=t);else if(e.precizeEnd)oe.debug("SI: buffered end is precize end",n,e.end),e.bufferedEnd=e.end;else if(t-e.end<=i){var s=Me();if(t-e.end>=a&&s-e.insertionTs<o)return void oe.debug("SI: Ignored bufferedEnd synchronization",n,t,e.end,s-e.insertionTs);oe.debug("SI: found true buffered end",n,t,e.end),e.bufferedEnd=t,xr(e)&&(e.end=t,e.precizeEnd=!0)}else if(t>e.end)oe.debug("SI: range end too far from expected end",n,t,e.end),e.bufferedEnd=e.end;else{var u=Me();if(t-e.end>=a&&u-e.insertionTs<o)return void oe.debug("SI: Ignored bufferedEnd synchronization",n,t,e.end,u-e.insertionTs);oe.debug("SI: Segment appears immediately garbage collected at the end",n,e.bufferedEnd,t),e.bufferedEnd=t}}var Pr,Dr=Ir,Or=function(){function e(){this._segmentInventory=new Dr}var t=e.prototype;return t.synchronizeInventory=function(e){this._segmentInventory.synchronizeBuffered(e)},t.getLastKnownInventory=function(){return this._segmentInventory.getInventory()},t.getSegmentHistory=function(e){return this._segmentInventory.getHistoryFor(e)},e}();!function(e){e[e.Push=0]="Push",e[e.Remove=1]="Remove",e[e.SignalSegmentComplete=2]="SignalSegmentComplete"}(Pr||(Pr={}));var Nr=function(e){function t(t,n,r){var i;i=e.call(this)||this,oe.info("AVSB: calling `mediaSource.addSourceBuffer`",n);var a=r.addSourceBuffer(t,n);return i.bufferType=t,i._sourceBuffer=a,i._lastInitSegmentUniqueId=null,i.codec=n,i._initSegmentsMap=new Map,i._pendingOperations=[],i}u(t,e);var n=t.prototype;return n.declareInitSegment=function(e,t){Lr(t),this._initSegmentsMap.set(e,t)},n.freeInitSegment=function(e){this._initSegmentsMap.delete(e)},n.pushChunk=function(){var e=_t(St().mark((function e(t){var n,r,i,a,o=this;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Lr(t.data.chunk),oe.debug("AVSB: receiving order to push data to the SourceBuffer",this.bufferType,Ne(t.inventoryInfos)),0===(n=this._getActualDataToPush(t.data)).length&&n.push(new Uint8Array),r=Promise.all(n.map((function(e){var n=t.data,r=n.codec,i=n.timestampOffset,a=n.appendWindow;return oe.debug("AVSB: pushing segment",o.bufferType,Ne(t.inventoryInfos)),o._sourceBuffer.appendBuffer(e,{codec:r,timestampOffset:i,appendWindow:a})}))),this._addToOperationQueue(r,{type:Pr.Push,value:t}),e.prev=6,e.next=9,r;case 9:i=e.sent,e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(6),this._segmentInventory.insertChunk(t.inventoryInfos,!1,Me()),e.t0;case 16:return null!==t.inventoryInfos&&this._segmentInventory.insertChunk(t.inventoryInfos,!0,Me()),a=i[i.length-1],this._segmentInventory.synchronizeBuffered(a),e.abrupt("return",a);case 20:case"end":return e.stop()}}),e,this,[[6,12]])})));return function(t){return e.apply(this,arguments)}}(),n.removeBuffer=function(){var e=_t(St().mark((function e(t,n){var r,i;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe.debug("AVSB: receiving order to remove data from the SourceBuffer",this.bufferType,t,n),r=this._sourceBuffer.remove(t,n),this._addToOperationQueue(r,{type:Pr.Remove,value:{start:t,end:n}}),e.next=5,r;case 5:return i=e.sent,this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.signalSegmentComplete=function(){var e=_t(St().mark((function e(t){var n;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._pendingOperations.length>0)){e.next=10;break}return n=this._pendingOperations[this._pendingOperations.length-1].promise,this._addToOperationQueue(n,{type:Pr.SignalSegmentComplete,value:t}),e.prev=3,e.next=6,n;case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:this._segmentInventory.completeSegment(t);case 11:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(t){return e.apply(this,arguments)}}(),n.getPendingOperations=function(){return this._pendingOperations.map((function(e){return e.operation}))},n.dispose=function(){try{oe.debug("AVSB: Calling `dispose` on the SourceBufferInterface"),this._sourceBuffer.dispose()}catch(e){oe.debug("AVSB: Failed to dispose a "+this.bufferType+" SourceBufferInterface:",e instanceof Error?e:"")}},n._getActualDataToPush=function(e){var t=[];if(null!==e.initSegmentUniqueId&&!this._isLastInitSegment(e.initSegmentUniqueId)){var n=this._initSegmentsMap.get(e.initSegmentUniqueId);if(void 0===n)throw new Error("Invalid initialization segment uniqueId");var r=new ArrayBuffer(n.byteLength),i=new Uint8Array(r);i.set(n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)),n=i,t.push(n),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return null!==e.chunk&&t.push(e.chunk),t},n._isLastInitSegment=function(e){return null!==this._lastInitSegmentUniqueId&&this._lastInitSegmentUniqueId===e},n._addToOperationQueue=function(e,t){var n=this,r={operation:t,promise:e};this._pendingOperations.push(r);var i=function(){var e=n._pendingOperations.indexOf(r);e>=0&&n._pendingOperations.splice(e,1)};e.then(i,i)},t}(Or);function Lr(e){}var Ur=Nr,Br=function(e){function t(t){var n;return oe.debug("HTSB: Creating TextSegmentBuffer"),(n=e.call(this)||this).bufferType="text",n._sender=t,n._pendingOperations=[],n._sender.reset(),n}u(t,e);var n=t.prototype;return n.declareInitSegment=function(e){oe.warn("HTSB: Declaring initialization segment for Text SegmentBuffer",e)},n.freeInitSegment=function(e){oe.warn("HTSB: Freeing initialization segment for Text SegmentBuffer",e)},n.pushChunk=function(){var e=_t(St().mark((function e(t){var n,r,i;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Fr((n=t.data).chunk),r=this._sender.pushTextData(Object.assign(Object.assign({},n),{chunk:n.chunk})),this._addToOperationQueue(r,{type:Pr.Push,value:t}),e.next=6,r;case 6:return i=e.sent,null!==t.inventoryInfos&&this._segmentInventory.insertChunk(t.inventoryInfos,!0,Me()),this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.removeBuffer=function(){var e=_t(St().mark((function e(t,n){var r,i;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._sender.remove(t,n),this._addToOperationQueue(r,{type:Pr.Remove,value:{start:t,end:n}}),e.next=4,r;case 4:return i=e.sent,this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.signalSegmentComplete=function(){var e=_t(St().mark((function e(t){var n;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._pendingOperations.length>0)){e.next=10;break}return n=this._pendingOperations[this._pendingOperations.length-1].promise,this._addToOperationQueue(n,{type:Pr.SignalSegmentComplete,value:t}),e.prev=3,e.next=6,n;case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:this._segmentInventory.completeSegment(t);case 11:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(t){return e.apply(this,arguments)}}(),n.getPendingOperations=function(){return this._pendingOperations.map((function(e){return e.operation}))},n.dispose=function(){oe.debug("HTSB: Disposing TextSegmentBuffer"),this._sender.reset()},n._addToOperationQueue=function(e,t){var n=this,r={operation:t,promise:e};this._pendingOperations.push(r);var i=function(){var e=n._pendingOperations.indexOf(r);e>=0&&n._pendingOperations.splice(e,1)};e.then(i,i)},t}(Or);function Fr(e){}var zr=Br,Vr=["audio","video","text"];function Kr(e){return"audio"===e||"video"===e}var Wr=function(){function e(e,t,n){this._mediaSource=e,this._textInterface=n,this._hasVideo=t,this._initializedSegmentBuffers={},this._onNativeBufferAddedOrDisabled=[]}e.isNative=function(e){return Kr(e)};var t=e.prototype;return t.getBufferTypes=function(){var e=this.getNativeBufferTypes();return null!==this._textInterface&&e.push("text"),e},t.getNativeBufferTypes=function(){return this._hasVideo?["video","audio"]:["audio"]},t.getStatus=function(e){var t=this._initializedSegmentBuffers[e];return void 0===t?{type:"uninitialized"}:null===t?{type:"disabled"}:{type:"initialized",value:t}},t.waitForUsableBuffers=function(e){var t=this;return this._areNativeBuffersUsable()?Promise.resolve():sn(e,(function(e){var n,r=function(){var e=t._onNativeBufferAddedOrDisabled.indexOf(n);e>=0&&t._onNativeBufferAddedOrDisabled.splice(e,1)};return n=function(){t._areNativeBuffersUsable()&&(r(),e())},t._onNativeBufferAddedOrDisabled.push(n),r}))},t.disableSegmentBuffer=function(t){var n=this._initializedSegmentBuffers[t];if(null!==n){if(void 0!==n)throw new Error("Cannot disable an active SegmentBuffer.");this._initializedSegmentBuffers[t]=null,e.isNative(t)&&this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()}))}else oe.warn("SBS: The "+t+" SegmentBuffer was already disabled.")},t.createSegmentBuffer=function(e,t){var n,r=this._initializedSegmentBuffers[e];if(Kr(e)){if(null!=r)return r instanceof Ur&&r.codec!==t?oe.warn("SB: Reusing native SegmentBuffer with codec",r.codec,"for codec",t):oe.info("SB: Reusing native SegmentBuffer with codec",t),r;oe.info("SB: Adding native SegmentBuffer with codec",t);var i=new Ur("audio"===e?"audio":"video",t,this._mediaSource);return this._initializedSegmentBuffers[e]=i,this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()})),i}if(null!=r)return oe.info("SB: Reusing a previous custom SegmentBuffer for the type",e),r;if("text"===e){if(oe.info("SB: Creating a new text SegmentBuffer"),null===this._textInterface)throw new Error("HTML Text track feature not activated");return n=new zr(this._textInterface),this._initializedSegmentBuffers.text=n,n}throw oe.error("SB: Unknown buffer type:",e),new Se("BUFFER_TYPE_UNKNOWN","The player wants to create a SegmentBuffer of an unknown type.")},t.disposeSegmentBuffer=function(e){var t=this._initializedSegmentBuffers[e];null!=t?(oe.info("SB: Aborting SegmentBuffer",e),t.dispose(),delete this._initializedSegmentBuffers[e]):oe.warn("SB: Trying to dispose a SegmentBuffer that does not exist")},t.disposeAll=function(){var e=this;Vr.forEach((function(t){"initialized"===e.getStatus(t).type&&e.disposeSegmentBuffer(t)}))},t._areNativeBuffersUsable=function(){var e=this,t=this.getNativeBufferTypes();return!t.some((function(t){return void 0===e._initializedSegmentBuffers[t]}))&&!t.every((function(t){return null===e._initializedSegmentBuffers[t]}))},e}(),Gr="function"==typeof queueMicrotask?queueMicrotask:function(e){Promise.resolve().then(e,(function(){return e()}))},jr=function(){function e(e){this._array=[],this._sortingFn=e}var t=e.prototype;return t.add=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.sort(this._sortingFn);for(var r=0,i=0;i<t.length;i++){for(var a=t[i],o=!1;!o&&r<this._array.length;)this._sortingFn(a,this._array[r])<0?(this._array.splice(r,0,a),o=!0):r++;o||this._array.push(a)}},t.length=function(){return this._array.length},t.get=function(e){if(e<0||e>=this._array.length)throw new Error("Invalid index.");return this._array[e]},t.toArray=function(){return this._array.slice()},t.findFirst=function(e){return xe(this._array,e)},t.has=function(e){return Qe(this._array,e)},t.removeElement=function(e){var t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t},t.head=function(){return this._array[0]},t.last=function(){return this._array[this._array.length-1]},t.shift=function(){return this._array.shift()},t.pop=function(){return this._array.pop()},e}(),Hr=function(){function e(e){this._weakMap=new WeakMap,this._fn=e}var t=e.prototype;return t.get=function(e){var t=this._weakMap.get(e);if(void 0===t){var n=this._fn(e);return this._weakMap.set(e,n),n}return t},t.destroy=function(e){this._weakMap.delete(e)},e}();function qr(e,t){var n,r=e.segmentBuffer,i=e.playbackObserver,a=e.maxBufferBehind,o=e.maxBufferAhead,s=[];function u(){null!==s&&function(e,t,n,r,i,a){return Yr.apply(this,arguments)}(r,n,s,a.getValue(),o.getValue(),t).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";oe.error("Could not run BufferGarbageCollector:",t)}))}i.listen((function(e){n=e.position.getWanted(),s=e.buffered[r.bufferType],u()}),{includeLastObservation:!0,clearSignal:t}),a.onUpdate(u,{clearSignal:t}),o.onUpdate(u,{clearSignal:t}),u()}function Yr(){return(Yr=_t(St().mark((function e(t,n,r,i,a,o){var s,u,l,d,c,f,v,p;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(isFinite(i)||isFinite(a)){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:s=[],u=dt(r,n),l=u.innerRange,d=u.outerRanges,c=function(){if(isFinite(a)){for(var e=0;e<d.length;e++){var t=d[e];n+a<=t.start?s.push(t):n<=t.start&&n+a<t.end&&n+a>t.start&&s.push({start:n+a,end:t.end})}null!=l&&n+a<l.end&&s.push({start:n+a,end:l.end})}},function(){if(isFinite(i)){for(var e=0;e<d.length;e++){var t=d[e];n-i>=t.end?s.push(t):n>=t.end&&n-i>t.start&&n-i<t.end&&s.push({start:t.start,end:n-i})}null!=l&&n-i>l.start&&s.push({start:l.start,end:n-i})}}(),c(),f=0,v=s;case 9:if(!(f<v.length)){e.next=20;break}if(!((p=v[f]).start<p.end)){e.next=17;break}if(oe.debug("GC: cleaning range from SegmentBuffer",p.start,p.end),null===o.cancellationError){e.next=15;break}throw o.cancellationError;case 15:return e.next=17,t.removeBuffer(p.start,p.end);case 17:f++,e.next=9;break;case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Qr=function(e){function t(t,n,r,i){var a;return(a=e.call(this)||this)._content=t,a._currentCanceller=null,a._downloadQueue=n,a._initSegmentRequest=null,a._mediaSegmentRequest=null,a._segmentFetcher=r,a._initSegmentInfoRef=new A(void 0),a._mediaSegmentAwaitingInitMetadata=null,i||a._initSegmentInfoRef.setValue(null),a}u(t,e);var n=t.prototype;return n.getRequestedInitSegment=function(){return null===this._initSegmentRequest?null:this._initSegmentRequest.segment},n.getRequestedMediaSegment=function(){return null===this._mediaSegmentRequest?null:this._mediaSegmentRequest.segment},n.start=function(){var e=this;null===this._currentCanceller&&(this._currentCanceller=new ht,this._downloadQueue.onUpdate((function(t){var n=t.segmentQueue;if(!(n.length>0&&n[0].segment.id===e._mediaSegmentAwaitingInitMetadata)){var r=e._mediaSegmentRequest;if(0===n.length){if(null===r)return;return oe.debug("Stream: no more media segment to request. Cancelling queue.",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()}if(null===r)return oe.debug("Stream: Media segments now need to be requested. Starting queue.",e._content.adaptation.type,n.length),void e._restartMediaSegmentDownloadingQueue();var i=n[0];return r.segment.id!==i.segment.id?(oe.debug("Stream: Next media segment changed, cancelling previous",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()):void(r.priority!==i.priority&&(oe.debug("Stream: Priority of next media segment changed, updating",e._content.adaptation.type,r.priority,i.priority),e._segmentFetcher.updatePriority(r.request,i.priority)))}}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate((function(t){var n,r=e._initSegmentRequest;null===t.initSegment||null===r?(null===(n=t.initSegment)||void 0===n?void 0:n.segment.id)!==(null==r?void 0:r.segment.id)&&(null===t.initSegment&&oe.debug("Stream: no more init segment to request. Cancelling queue.",e._content.adaptation.type),e._restartInitSegmentDownloadingQueue(t.initSegment)):t.initSegment.priority!==r.priority&&e._segmentFetcher.updatePriority(r.request,t.initSegment.priority)}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))},n.stop=function(){var e;null===(e=this._currentCanceller)||void 0===e||e.cancel(),this._currentCanceller=null},n._restartMediaSegmentDownloadingQueue=function(){var e=this;null!==this._mediaSegmentRequest&&this._mediaSegmentRequest.canceller.cancel();!function t(n){if(null!==e._currentCanceller&&e._currentCanceller.isUsed())e._mediaSegmentRequest=null;else{if(void 0===n)return e._mediaSegmentRequest=null,void e.trigger("emptyQueue",null);var r=new ht,i=null===e._currentCanceller?b:r.linkToSignal(e._currentCanceller.signal),a=n.segment,o=n.priority,s=d({segment:a},e._content),u=!1,l=!1;r.signal.register((function(){e._mediaSegmentRequest=null,u||(e._mediaSegmentAwaitingInitMetadata===a.id&&(e._mediaSegmentAwaitingInitMetadata=null),u=!0,l=!1)}));var c=function(t){Xe(t.segmentType),e.trigger("parsedMediaSegment",d({},t,{segment:a}))},f=function(){var n=e._downloadQueue.getValue().segmentQueue;if(0===n.length)return u=!0,void e.trigger("emptyQueue",null);n[0].segment.id===a.id&&n.shift(),u=!0,t(n[0])},v=e._segmentFetcher.createRequest(s,o,{onRetry:function(t){e.trigger("requestRetry",{segment:a,error:t})},beforeInterrupted:function(){oe.info("Stream: segment request interrupted temporarly.",a.id,a.time)},onChunk:function(t){var n=e._initSegmentInfoRef.getValue();void 0!==n?c(t(null!=n?n:void 0)):(l=!0,e._initSegmentInfoRef.waitUntilDefined((function(e){c(t(null!=e?e:void 0))}),{clearSignal:r.signal}))},onAllChunksReceived:function(){l?(e._mediaSegmentAwaitingInitMetadata=a.id,e._initSegmentInfoRef.waitUntilDefined((function(){e._mediaSegmentAwaitingInitMetadata=null,l=!1,e.trigger("fullyLoadedSegment",a)}),{clearSignal:r.signal})):e.trigger("fullyLoadedSegment",a)},beforeEnded:function(){i(),e._mediaSegmentRequest=null,l?e._initSegmentInfoRef.waitUntilDefined(f,{clearSignal:r.signal}):f()}},r.signal);v.catch((function(t){i(),u||(u=!0,e.stop(),e.trigger("error",t))})),e._mediaSegmentRequest={segment:a,priority:o,request:v,canceller:r}}}(this._downloadQueue.getValue().segmentQueue[0])},n._restartInitSegmentDownloadingQueue=function(e){var t=this;if((null===this._currentCanceller||!this._currentCanceller.isUsed())&&(null!==this._initSegmentRequest&&this._initSegmentRequest.canceller.cancel(),null!==e)){var n=new ht,r=null===this._currentCanceller?b:n.linkToSignal(this._currentCanceller.signal),i=e.segment,a=e.priority,o=d({segment:i},this._content),s=!1,u=this._segmentFetcher.createRequest(o,a,{onRetry:function(e){t.trigger("requestRetry",{segment:i,error:e})},beforeInterrupted:function(){oe.info("Stream: init segment request interrupted temporarly.",i.id)},beforeEnded:function(){r(),t._initSegmentRequest=null,s=!0},onChunk:function(e){var n,r=e(void 0);Xe(r.segmentType),t.trigger("parsedInitSegment",d({},r,{segment:i})),"init"===r.segmentType&&t._initSegmentInfoRef.setValue(null!==(n=r.initTimescale)&&void 0!==n?n:null)},onAllChunksReceived:function(){t.trigger("fullyLoadedSegment",i)}},n.signal);u.catch((function(e){r(),s||(s=!0,t.stop(),t.trigger("error",e))})),n.signal.register((function(){t._initSegmentRequest=null,s||(s=!0)})),this._initSegmentRequest={segment:i,priority:a,request:u,canceller:n}}},t}(ie);function $r(e,t,n,r,i){var a=e.period,o=e.adaptation,s=e.representation,u=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(void 0===r.bufferedStart||void 0===r.bufferedEnd||r.bufferedStart>=t.end)return null;if(r.bufferedEnd>t.start)return n}return null}(i,t);if(null===u){if(null===n){if(r&&void 0!==a.end&&t.end>=a.end)return{start:void 0,end:null};var l=s.index.checkDiscontinuity(t.start);if(null!==l)return{start:void 0,end:l}}return null}var d=i[u];if(void 0!==d.bufferedStart&&d.bufferedStart>t.start&&(null===n||d.infos.segment.end<=n)){var c=d.bufferedStart;return r||!1===s.index.awaitSegmentBetween(t.start,c)?(oe.debug("RS: current discontinuity encountered",o.type,d.bufferedStart),{start:void 0,end:c}):null}var f=function(e,t,n){if(n<=0)return oe.error("RS: Asked to check a discontinuity before the first chunk."),null;for(var r=n;r<e.length;r++){var i=e[r],a=e[r-1];if(void 0===i.bufferedStart||void 0===a.bufferedEnd||i.bufferedStart>=t.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}(i,t,u+1);if(null!==f){var v=i[f-1],p=i[f];if(null===n||p.infos.segment.end<=n){if(!r&&!1!==s.index.awaitSegmentBetween(v.infos.segment.end,p.infos.segment.time))return null;var h=v.bufferedEnd,m=p.bufferedStart;return oe.debug("RS: future discontinuity encountered",o.type,h,m),{start:h,end:m}}}if(null===n){if(r&&void 0!==a.end){if(t.end<a.end)return null;var g=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(void 0===r.bufferedStart)return null;if(r.bufferedStart<t)return n}return null}(i,a.end);if(null!==g){var y=i[g];if(void 0!==y.bufferedEnd&&y.bufferedEnd<a.end)return oe.debug("RS: discontinuity encountered at the end of the current period",o.type,y.bufferedEnd,a.end),{start:y.bufferedEnd,end:null}}}if(void 0!==a.end&&t.end>=a.end)return null;for(var _=i.length-1;_>=0;_--){var b=i[_];if(void 0===b.bufferedStart)break;if(b.bufferedStart<t.end){if(void 0!==b.bufferedEnd&&b.bufferedEnd<t.end){var S=s.index.checkDiscontinuity(t.end);if(null!==S)return{start:b.bufferedEnd,end:S}}return null}}}return null}function Xr(e){var t=e.bufferedSegments,n=e.content,r=e.currentPlaybackTime,i=e.fastSwitchThreshold,a=e.getBufferedHistory,o=e.neededRange,s=e.segmentsBeingPushed,u=e.maxBufferSize,l=n.adaptation,c=n.representation,f=function(e,t,n){var r=8e3*n;return r-=t.reduce((function(e,t){return e+t.representation.bitrate*t.segment.duration}),0),e.reduce((function(e,t){return void 0!==t.chunkSize?e-8*t.chunkSize:e}),r)}(t,s,u),v=c.index.getSegments(o.start,o.end-o.start),h=t.filter((function(e){return!Jr(e.infos,n,r,i)})).filter((function(e,t,n){var r=0===t?null:n[t-1],i=t>=n.length-1?null:n[t+1],s=null;if(function(e,t,n){var r=p.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedStart)return!1;if(null!==t&&void 0!==t.bufferedEnd&&e.bufferedStart-t.bufferedEnd<.1)return!1;if(n<e.bufferedStart&&e.bufferedStart-e.start>r)return oe.info("Stream: The start of the wanted segment has been garbage collected",e.start,e.bufferedStart),!0;return!1}(e,r,o.start)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.start;if(void 0!==t&&void 0!==a&&t-a>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.start;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(s=a(e.infos),e.bufferedStart))return!1;oe.debug("Stream: skipping segment gc-ed at the start",e.start,e.bufferedStart)}if(function(e,t,n){var r=p.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedEnd)return!1;if(null!==t&&void 0!==t.bufferedStart&&t.bufferedStart-e.bufferedEnd<.1)return!1;if(n>e.bufferedEnd&&e.end-e.bufferedEnd>r)return oe.info("Stream: The end of the wanted segment has been garbage collected",e.end,e.bufferedEnd),!0;return!1}(e,i,o.end)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.end;if(void 0!==t&&void 0!==a&&a-t>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.end;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(s=null!=s?s:a(e.infos),e.bufferedEnd))return!1;oe.debug("Stream: skipping segment gc-ed at the end",e.end,e.bufferedEnd)}return!0})),m=p.getCurrent(),g=m.MINIMUM_SEGMENT_SIZE,y=m.MIN_BUFFER_AHEAD,_=!1,b=Math.min(1/60,g),S=!1,E=[],T=v.filter((function(e){var t=d({segment:e},n);if(s.length>0&&s.some((function(e){return Oe(t,e)})))return!1;var u=e.duration,v=e.time,p=e.end;if(e.isInit)return!0;if(_)return E.push(e),!1;if(e.complete&&u<g)return!1;if(s.length>0&&s.some((function(e){if(e.period.id!==n.period.id||e.adaptation.id!==n.adaptation.id)return!1;var a=e.segment;return!(a.time-b>v)&&(!(a.end+b<p)&&!Jr(e,t,r,i))})))return!1;for(var m=0;m<h.length;m++){var T=h[m];if(T.infos.period.id===n.period.id){var k=T.infos.segment;if(v-k.time>-b&&k.end-p>-b)return!1}}var w=u*n.representation.bitrate;if(f-w<0&&(S=!0,v>o.start+y))return _=!0,E.push(e),!1;var A=a(t);if(A.length>1){var I=A[A.length-1],R=A[A.length-2];if(null===I.buffered&&null===R.buffered)return oe.warn("Stream: Segment GCed multiple times in a row, ignoring it.","If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering."+l.type,c.id,e.time),!1}for(var x=0;x<h.length;x++){var C=h[x];if(C.end+b>v){var M=C.start>v+b||Zr(h,x).end<p-b;return M&&(f-=w),M}}return f-=w,!0}));return{segmentsToLoad:T,segmentsOnHold:E,isBufferFull:S}}function Zr(e,t){for(var n=t+1,r=p.getCurrent().MINIMUM_SEGMENT_SIZE,i=Math.min(1/60,r);n<e.length-1&&e[n-1].end+i>e[n].start;)n++;return e[--n]}function Jr(e,t,n,r){var i=p.getCurrent().CONTENT_REPLACEMENT_PADDING;return e.period.id===t.period.id&&(!(e.segment.time<n+i)&&(e.adaptation.id!==t.adaptation.id||function(e,t,n){var r=e.bitrate,i=p.getCurrent().BITRATE_REBUFFERING_RATIO;if(void 0===n){var a=r*i;return t.bitrate>a}return r<n&&t.bitrate>r}(e.representation,t.representation,r)))}function ei(e,t){for(var n=e-t,r=p.getCurrent().SEGMENT_PRIORITIES_STEPS,i=0;i<r.length;i++)if(n<r[i])return i;return r.length}function ti(e,t,n,r,i,a,o){var s,u,l,d=e.representation,c=null!==(u=null!==(s=n.getIsPaused())&&void 0!==s?s:n.getReference().getValue().paused.pending)&&void 0!==u?u:n.getReference().getValue().paused.last,f=null!==(l=n.getPlaybackRate())&&void 0!==l?l:n.getReference().getValue().speed,v=t;(void 0===c||void 0===f||c||f<=0)&&(v-=.1);var h=function(e,t,n){var r,i,a=e.manifest,o=e.period,s=e.representation,u=s.index.getLastAvailablePosition(),l=s.index;i=!_(u)&&Wr.isNative(e.adaptation.type)&&t>=u&&l.isInitialized()&&!l.isStillAwaitingFutureSegments()&&function(e,t,n){var r,i=e.getPeriodAfter(t);return t.containsTime(n,i)&&e.isLastPeriodKnown&&t.id===(null===(r=e.periods[e.periods.length-1])||void 0===r?void 0:r.id)}(a,o,t)?u-1:t-.1;var d,c=i+n;d=!(!s.index.isInitialized()||s.index.isStillAwaitingFutureSegments()||void 0===o.end)&&(void 0===u?c>=o.end:null===u||c>=u);return{start:Math.max(i,o.start),end:Math.min(c,null!==(r=o.end)&&void 0!==r?r:1/0),hasReachedPeriodEnd:d}}(e,v,i),m=d.index.shouldRefresh(h.start,h.end),g=o.getPendingOperations().filter((function(e){return e.type===Pr.SignalSegmentComplete})).map((function(e){return e.value})),y=function(e,t){for(var n=p.getCurrent().MINIMUM_SEGMENT_SIZE,r=Math.max(1/60,n),i=e.start+r,a=e.end-r,o=[],s=t.length-1;s>=0;s--){var u=t[s],l=u.infos.representation;if(1===u.status&&!1!==l.decipherable&&!1!==l.isSupported){var d=u.infos.segment,c=d.time/d.timescale;((d.complete?c+d.duration/d.timescale:u.end)>i&&c<a||u.end>i&&u.start<a)&&o.unshift(u)}}return o}({start:Math.max(h.start-.5,0),end:h.end+.5},o.getLastKnownInventory()),b=n.getCurrentTime();void 0===b&&(b=n.getReference().getValue().position.getWanted());var S=Xr({content:e,bufferedSegments:y,currentPlaybackTime:b,fastSwitchThreshold:r,getBufferedHistory:o.getSegmentHistory.bind(o),neededRange:h,segmentsBeingPushed:g,maxBufferSize:a}),E=S.segmentsToLoad,T=S.segmentsOnHold,k=S.isBufferFull,w=E.map((function(e){return{priority:ei(e.time,v),segment:e}})),A=d.index.isInitialized()&&!d.index.isStillAwaitingFutureSegments()&&h.hasReachedPeriodEnd&&0===w.length&&0===T.length,I=null;return g.length>0&&(I=Math.min.apply(Math,g.map((function(e){return e.segment.time})))),T.length>0&&(I=null!==I?Math.min(I,T[0].time):T[0].time),w.length>0&&(I=null!==I?Math.min(I,w[0].segment.time):w[0].segment.time),{imminentDiscontinuity:$r(e,h,I,A,y),hasFinishedLoading:A,neededSegments:w,isBufferFull:k,shouldRefreshManifest:m}}var ni=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(de(a),t.prototype),a.name="SourceBufferError",a.errorName=n,a.message=r,a.isBufferFull=i,a}u(t,e);var n=t.prototype;return n.serialize=function(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}},n.toString=function(){return this.errorName+": "+this.message},t}(ve(Error));function ri(e,t,n,r,i){return ii.apply(this,arguments)}function ii(){return(ii=_t(St().mark((function e(t,n,r,i,a){var o,s,u,l,d,c,f;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,n.pushChunk(r);case 3:case 31:return e.abrupt("return",e.sent);case 6:if(e.prev=6,e.t0=e.catch(0),!(a.isCancelled()&&e.t0 instanceof gt)){e.next=12;break}throw e.t0;case 12:if(e.t0 instanceof ni&&e.t0.isBufferFull){e.next=15;break}throw o=e.t0 instanceof Error?e.t0.toString():"An unknown error happened when pushing content",new Se("BUFFER_APPEND_ERROR",o,{tracks:[Ye(r.inventoryInfos.adaptation)]});case 15:return s=t.getReference().getValue(),u=s.position,l=u.getWanted(),e.prev=17,oe.warn("Stream: Running garbage collector"),d=Math.max(l-5,0),c=l+i.getValue()+12,e.next=23,n.removeBuffer(0,d);case 23:return e.next=25,n.removeBuffer(c,Number.MAX_VALUE);case 25:return e.next=27,Et(200);case 27:if(null===a.cancellationError){e.next=29;break}throw a.cancellationError;case 29:return e.next=31,n.pushChunk(r);case 34:if(e.prev=34,e.t1=e.catch(17),!(e.t1 instanceof gt)){e.next=38;break}throw e.t1;case 38:throw f=e.t1 instanceof Error?e.t1.toString():"Could not clean the buffer",new Se("BUFFER_FULL_ERROR",f,{tracks:[Ye(r.inventoryInfos.adaptation)]});case 40:case"end":return e.stop()}}),e,null,[[0,6],[17,34]])})))).apply(this,arguments)}function ai(){return ai=_t(St().mark((function e(t,n){var r,i,a,o,s,u,l,c,f,v;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.playbackObserver,i=t.content,a=t.initSegmentUniqueId,o=t.segment,s=t.segmentBuffer,u=t.bufferGoal,null===n.cancellationError){e.next=3;break}throw n.cancellationError;case 3:return l=i.representation.getMimeTypeString(),c={initSegmentUniqueId:a,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:l},f=d({segment:o,chunkSize:void 0,start:0,end:0},i),e.next=8,ri(r,s,{data:c,inventoryInfos:f},u,n);case 8:return v=e.sent,e.abrupt("return",{content:i,segment:o,buffered:v});case 10:case"end":return e.stop()}}),e)}))),ai.apply(this,arguments)}function oi(){return oi=_t(St().mark((function e(t,n){var r,i,a,o,s,u,l,c,f,v,h,m,g,y,_,b,S,E,T,k,w,A,I,R;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.playbackObserver,i=t.bufferGoal,a=t.content,o=t.initSegmentUniqueId,s=t.parsedSegment,u=t.segment,l=t.segmentBuffer,null!==s.chunkData){e.next=3;break}return e.abrupt("return",null);case 3:if(null===n.cancellationError){e.next=5;break}throw n.cancellationError;case 5:return v=s.chunkData,h=s.chunkInfos,m=s.chunkOffset,g=s.chunkSize,y=s.appendWindow,_=a.representation.getMimeTypeString(),b=p.getCurrent(),S=b.APPEND_WINDOW_SECURITIES,E=[void 0!==y[0]?Math.max(0,y[0]-S.START):void 0,void 0!==y[1]?y[1]+S.END:void 0],T={initSegmentUniqueId:o,chunk:v,timestampOffset:m,appendWindow:E,codec:_},k=null!==(c=null==h?void 0:h.time)&&void 0!==c?c:u.time,w=null!==(f=null==h?void 0:h.duration)&&void 0!==f?f:u.duration,A=k+w,void 0!==E[0]&&(k=Math.max(k,E[0])),void 0!==E[1]&&(A=Math.min(A,E[1])),I=d({segment:u,chunkSize:g,start:k,end:A},a),e.next=18,ri(r,l,{data:T,inventoryInfos:I},i,n);case 18:return R=e.sent,e.abrupt("return",{content:a,segment:u,buffered:R});case 20:case"end":return e.stop()}}),e)}))),oi.apply(this,arguments)}function si(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ui(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ui(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ui(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var li=function(e,t,n){var r=e.content,i=e.options,a=e.playbackObserver,o=e.segmentBuffer,s=e.segmentFetcher,u=e.terminate,l=r.period,c=r.adaptation,f=r.representation,v=i.bufferGoal,h=i.maxBufferSize,m=i.drmSystemId,g=i.fastSwitchThreshold,y=c.type,_=new ht;_.linkToSignal(n);var b=new ht;b.linkToSignal(_.signal);var S={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};_.signal.register((function(){null!==S.uniqueId&&o.freeInitSegment(S.uniqueId)}));var E=new A({initSegment:null,segmentQueue:[]},b.signal),T=null!==S.segment;T||(S.isLoaded=!0);var k=!1;if(void 0!==m){var w=f.getEncryptionData(m);if(w.length>0&&w.every((function(e){return void 0!==e.keyIds}))&&(k=!0,t.encryptionDataEncountered(w.map((function(e){return d({content:r},e)}))),_.isUsed()))return}var I=new Qr(r,E,s,T);return I.addEventListener("error",(function(e){b.signal.isCancelled()||(_.cancel(),t.error(e))})),I.addEventListener("parsedInitSegment",x),I.addEventListener("parsedMediaSegment",x),I.addEventListener("emptyQueue",R),I.addEventListener("requestRetry",(function(e){if(t.warning(e.error),!b.signal.isCancelled()){var n=e.segment,r=f.index;!1===r.isSegmentStillAvailable(n)?R():r.canBeOutOfSyncError(e.error,n)&&t.manifestMightBeOufOfSync()}})),I.addEventListener("fullyLoadedSegment",(function(e){o.signalSegmentComplete(d({segment:e},r)).catch(C)})),I.start(),b.signal.register((function(){I.removeEventListener(),I.stop()})),a.listen(R,{includeLastObservation:!1,clearSignal:b.signal}),r.manifest.addEventListener("manifestUpdate",R,b.signal),v.onUpdate(R,{emitCurrentValue:!1,clearSignal:b.signal}),h.onUpdate(R,{emitCurrentValue:!1,clearSignal:b.signal}),u.onUpdate(R,{emitCurrentValue:!1,clearSignal:b.signal}),void R();function R(){if(!b.isUsed()){var e=a.getReference().getValue(),n=e.position.getWanted(),i=ti(r,n,a,g.getValue(),v.getValue(),h.getValue(),o),s=i.neededSegments,d=null;if(f.index.isInitialized()){if(s.length>0&&!S.isLoaded&&null!==S.segment){var c=s[0].priority;d={segment:S.segment,priority:c}}}else if(null===S.segment)oe.warn("Stream: Uninitialized index without an initialization segment");else if(S.isLoaded)oe.warn("Stream: Uninitialized index with an already loaded initialization segment");else{var m=e.position.getWanted();d={segment:S.segment,priority:ei(l.start,m)}}var _=u.getValue();if(null===_)E.setValue({initSegment:d,segmentQueue:s});else{if(_.urgent)return oe.debug("Stream: Urgent switch, terminate now.",y),E.setValue({initSegment:null,segmentQueue:[]}),E.finish(),b.cancel(),void t.terminating();var T=s[0],k=I.getRequestedInitSegment(),w=I.getRequestedMediaSegment(),A=null===w||void 0===T||w.id!==T.segment.id?[]:[T],R=null===k?null:d;if(E.setValue({initSegment:R,segmentQueue:A}),0===A.length&&null===R)return oe.debug("Stream: No request left, terminate",y),E.finish(),b.cancel(),void t.terminating()}if(t.streamStatusUpdate({period:l,position:e.position.getWanted(),bufferType:y,imminentDiscontinuity:i.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:i.hasFinishedLoading,neededSegments:i.neededSegments}),!b.signal.isCancelled()){var x=p.getCurrent().UPTO_CURRENT_POSITION_CLEANUP;if(i.isBufferFull){var M=Math.max(0,n-x);M>0&&o.removeBuffer(0,M).catch(C)}i.shouldRefreshManifest&&t.needsManifestRefresh()}}}function x(e){if(!_.isUsed()){for(var n,i=si(e.protectionData);!(n=i()).done;){var s=n.value;f.addProtectionData(s.initDataType,s.keyId,s.initData)}if(!k){var u=f.getAllEncryptionData();if(u.length>0&&(t.encryptionDataEncountered(u.map((function(e){return d({content:r},e)}))),k=!0,_.isUsed()))return}if("init"!==e.segmentType){var l=e.inbandEvents,c=e.predictedSegments,p=e.needsManifestRefresh;if(!(void 0!==c&&f.index.addPredictedSegments(c,e.segment),!0===p&&(t.needsManifestRefresh(),_.isUsed())||void 0!==l&&l.length>0&&(t.inbandEvent(l),_.isUsed()))){var h=S.uniqueId;(function(e,t){return oi.apply(this,arguments)})({playbackObserver:a,bufferGoal:v,content:r,initSegmentUniqueId:h,parsedSegment:e,segment:e.segment,segmentBuffer:o},_.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(C)}}else{if(f.index.isInitialized()||void 0===e.segmentList||f.index.initialize(e.segmentList),S.isLoaded=!0,null!==e.initializationData){var m=f.uniqueId;S.uniqueId=m,o.declareInitSegment(m,e.initializationData),function(e,t){return ai.apply(this,arguments)}({playbackObserver:a,bufferGoal:v,content:r,initSegmentUniqueId:m,segment:e.segment,segmentData:e.initializationData,segmentBuffer:o},_.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(C)}R()}}}function C(e){_.isUsed()&&e instanceof gt||(_.cancel(),t.error(e))}};function di(e,t){for(var n=0;n<e.length;n++)if(e[n].infos.period.start>=t.start)return n>0?e[n-1]:null;return e.length>0?e[e.length-1]:null}function ci(e,t){for(var n=0;n<e.length;n++)if(e[n].infos.period.start>t.start)return e[n];return null}function fi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return vi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return vi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function vi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function pi(e,t,n,r,i){var a,o;if("lazy"===n.switchingMode)return{type:"continue",value:void 0};for(var s,u=r.getLastKnownInventory(),l=[],d=fi(u);!(s=d()).done;){var c=s.value;c.infos.period.id!==e.id||c.infos.adaptation.id===t.id&&Qe(n.representationIds,c.infos.representation.id)||ft(l,{start:null!==(a=c.bufferedStart)&&void 0!==a?a:c.start,end:null!==(o=c.bufferedEnd)&&void 0!==o?o:c.end})}for(var f,v=fi(r.getPendingOperations());!(f=v()).done;){var h=f.value;if(h.type===Pr.Push){var m=h.value.inventoryInfos;if(m.period.id===e.id&&(m.adaptation.id!==t.id||!Qe(n.representationIds,m.representation.id))){var g=m.segment.time;ft(l,{start:g,end:g+m.segment.duration})}}}if(0===l.length)return{type:"continue",value:void 0};if("reload"===n.switchingMode){var y=i.getReadyState();if(void 0===y||y>1)return{type:"needs-reload",value:void 0}}var _="direct"===n.switchingMode,b=[],S=di(u,e);if(null!==S&&(void 0===S.bufferedEnd||e.start-S.bufferedEnd<1)&&b.push({start:0,end:e.start+1}),!_){var E=p.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,T=t.type,k=E[T].before;null==k&&(k=0);var w=E[T].after;null==w&&(w=0);var A=i.getCurrentTime();if(void 0===A)A=i.getReference().getValue().position.getPolled();b.push({start:A-k,end:A+w})}if(void 0!==e.end){var I=ci(u,e);null!==I&&(void 0===I.bufferedStart||I.bufferedStart-e.end<1)&&b.push({start:e.end-1,end:Number.MAX_VALUE})}var R=pt(l,b);return 0===R.length?{type:"continue",value:void 0}:_?{type:"flush-buffer",value:R}:{type:"clean-buffer",value:R}}function hi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function mi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var gi=function(e,t,n){var r=e.playbackObserver,i=e.content,a=e.options,o=e.representationEstimator,s=e.segmentBuffer,u=e.segmentFetcherCreator,l=e.wantedBufferAhead,c=e.maxVideoBufferSize,f=i.manifest,v=i.period,h=i.adaptation,m=new ht;m.linkToSignal(n);var g,y,_=new Map,S=new A(null,m.signal),E=i.representations.getValue().representationIds,T=i.adaptation.representations.filter((function(e){return Qe(E,e.id)&&!1!==e.decipherable&&!1!==e.isSupported})),k=new A(T,m.signal),I=o({manifest:f,period:v,adaptation:h},S,k,r,m.signal),R=I.estimates,x=I.callbacks,C=u.createSegmentFetcher(h.type,{onRequestBegin:x.requestBegin,onRequestEnd:x.requestEnd,onProgress:x.requestProgress,onMetrics:x.metrics}),M=new A(0);return R.onUpdate((function(e){var n=e.bitrate,r=e.knownStableBitrate;a.enableFastSwitching&&M.setValueIfChanged(r),void 0!==n&&n!==g&&(g=n,oe.debug("Stream: new "+h.type+" bitrate estimate",n),t.bitrateEstimateChange({type:h.type,bitrate:n}))}),{emitCurrentValue:!0,clearSignal:m.signal}),void i.representations.onUpdate((function(e){void 0!==y&&y.cancel();var n=i.representations.getValue().representationIds,r=i.adaptation.representations.filter((function(e){return Qe(n,e.id)}));k.setValueIfChanged(r),(y=new ht).linkToSignal(m.signal),function(e,t){return P.apply(this,arguments)}(e,y.signal).catch((function(e){!0===(null==y?void 0:y.isUsed())&&ht.isCancellationError(e)||(m.cancel(),t.error(e))}))}),{clearSignal:m.signal,emitCurrentValue:!0});function P(){return(P=_t(St().mark((function e(n,i){var a,o,u,l;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=pi(v,h,n,s,r),e.t0=a.type,e.next="continue"===e.t0?4:"needs-reload"===e.t0?5:"flush-buffer"===e.t0||"clean-buffer"===e.t0?6:20;break;case 4:return e.abrupt("break",21);case 5:return e.abrupt("return",Gr((function(){r.listen((function(){if(!i.isCancelled()){var e=p.getCurrent().DELTA_POSITION_AFTER_RELOAD.bitrateSwitch;return t.waitingMediaSourceReload({bufferType:h.type,period:v,timeOffset:e,stayInPeriod:!0})}}),{includeLastObservation:!0,clearSignal:i})})));case 6:o=hi(a.value);case 7:if((u=o()).done){e.next=15;break}return l=u.value,e.next=11,s.removeBuffer(l.start,l.end);case 11:if(!i.isCancelled()){e.next=13;break}return e.abrupt("return");case 13:e.next=7;break;case 15:if("flush-buffer"!==a.type){e.next=19;break}if(t.needsBufferFlush(),!i.isCancelled()){e.next=19;break}return e.abrupt("return");case 19:return e.abrupt("break",21);case 20:Ze();case 21:D(i);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function D(e){var n=new ht;n.linkToSignal(e);var r=R.getValue().representation;if(null!==r){var i=new A(null,n.signal);R.onUpdate((function(e){if(null!==e.representation&&e.representation.id!==r.id)return e.urgent?(oe.info("Stream: urgent Representation switch",h.type),i.setValue({urgent:!0})):(oe.info("Stream: slow Representation switch",h.type),i.setValue({urgent:!1}))}),{clearSignal:n.signal,emitCurrentValue:!0});var a={type:h.type,adaptation:h,period:v,representation:r};if(S.setValue(r),!m.isUsed()&&(t.representationChange(a),!m.isUsed())){var o={streamStatusUpdate:t.streamStatusUpdate,encryptionDataEncountered:t.encryptionDataEncountered,manifestMightBeOufOfSync:t.manifestMightBeOufOfSync,needsManifestRefresh:t.needsManifestRefresh,inbandEvent:t.inbandEvent,warning:t.warning,error:function(e){m.cancel(),t.error(e)},addedSegment:function(e){x.addedSegment(e)},terminating:function(){if(!n.isUsed())return n.cancel(),D(e)}};O(r,i,o,e)}}}function O(e,n,i,o){var u=new ht;u.linkToSignal(o);var p=w(l,(function(t){return t*function(e){var t=_.get(e.id),n=void 0!==t?t:1;void 0===t&&_.set(e.id,n);return n}(e)}),u.signal),g="video"===h.type?c:new A(1/0);oe.info("Stream: changing representation",h.type,e.id,e.bitrate);var y=d({},i,{error:function(t){var r,a=we(t,{defaultCode:"NONE",defaultReason:"Unknown `RepresentationStream` error"});if("BUFFER_FULL_ERROR"!==a.code)i.error(t);else{var s=l.getValue(),u=.7*(null!==(r=_.get(e.id))&&void 0!==r?r:1);if(u<=.05||s*u<=2)throw a;_.set(e.id,u),nr(4e3,m.signal).then((function(){return O(e,n,i,o)})).catch(b)}},terminating:function(){u.cancel(),i.terminating()}});li({playbackObserver:r,content:{representation:e,adaptation:h,period:v,manifest:f},segmentBuffer:s,segmentFetcher:C,terminate:n,options:{bufferGoal:p,maxBufferSize:g,drmSystemId:a.drmSystemId,fastSwitchThreshold:M}},y,o),f.addEventListener("manifestUpdate",(function(n){for(var r,i=hi(n.updatedPeriods);!(r=i()).done;){var a=r.value;if(a.period.id===v.id)for(var s,u=hi(a.result.updatedAdaptations);!(s=u()).done;){var l=s.value;if(l.adaptation===h.id)for(var d,c=hi(l.removedRepresentations);!(d=c()).done;){if(d.value===e.id){if(o.isCancelled())return;return t.waitingMediaSourceReload({bufferType:h.type,period:v,timeOffset:0,stayInPeriod:!0})}}}else if(a.period.start>v.start)break}}),o)}};function yi(e,t,n){if("function"==typeof String.prototype.startsWith)return e.startsWith(t,n);var r="number"==typeof n?Math.max(n,0):0;return e.substring(r,r+t.length)===t}var _i=function(e,t){var n=e.split(";"),r=n[0],i=n.slice(1),a=t.split(";"),o=a[0],s=a.slice(1);if(r!==o)return!1;var u=xe(i,(function(e){return yi(e,"codecs=")})),l=xe(s,(function(e){return yi(e,"codecs=")}));if(void 0===u||void 0===l)return!1;var d=u.substring(7),c=l.substring(7);return d.split(".")[0]===c.split(".")[0]};function bi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Si(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Si(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Si(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ei(e,t,n,r,i,a){var o,s;if(void 0!==e.codec&&"reload"===a.onCodecSwitch&&!function(e,t){return e.representations.some((function(e){return!0===e.isSupported&&!1!==e.decipherable&&_i(e.getMimeTypeString(),t)}))}(n,e.codec))return{type:"needs-reload",value:void 0};for(var u,l=e.getLastKnownInventory(),d=[],c=bi(l);!(u=c()).done;){var f=u.value;f.infos.period.id===t.id&&f.infos.adaptation.id!==n.id&&ft(d,{start:null!==(o=f.bufferedStart)&&void 0!==o?o:f.start,end:null!==(s=f.bufferedEnd)&&void 0!==s?s:f.end})}for(var v,h=bi(e.getPendingOperations());!(v=h()).done;){var m=v.value;if(m.type===Pr.Push){var g=m.value.inventoryInfos;if(g.period.id===t.id&&g.adaptation.id!==n.id){var y=g.segment.time;ft(d,{start:y,end:y+g.segment.duration})}}}if(0===d.length)return{type:"continue",value:void 0};if("reload"===r){var _=i.getReadyState();if(void 0===_||_>1)return{type:"needs-reload",value:void 0}}var b="direct"===r,S=[],E=di(l,t);if(null!==E&&(void 0===E.bufferedEnd||t.start-E.bufferedEnd<1)&&S.push({start:0,end:t.start+1}),!b){var T=n.type,k=p.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,w=k[T].before;null==w&&(w=0);var A=k[T].after;null==A&&(A=0);var I=i.getCurrentTime();if(void 0===I)I=i.getReference().getValue().position.getPolled();S.push({start:I-w,end:I+A})}if(void 0!==t.end){var R=ci(l,t);null!==R&&(void 0===R.bufferedStart||R.bufferedStart-t.end<1)&&S.push({start:t.end-1,end:Number.MAX_VALUE})}var x=pt(d,S);return 0===x.length?{type:"continue",value:void 0}:b&&"text"!==n.type?{type:"flush-buffer",value:x}:{type:"clean-buffer",value:x}}function Ti(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ki(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ki(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ki(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function wi(e,t,n){var r=e.getStatus(t);if("initialized"===r.type)return oe.info("Stream: Reusing a previous SegmentBuffer for the type",t),r.value;var i=function(e){var t=e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable}));if(0===t.length){throw new Se("NO_PLAYABLE_REPRESENTATION","No Representation in the chosen "+e.type+" Adaptation can be played",{tracks:[Ye(e)]})}return t[0].getMimeTypeString()}(n);return e.createSegmentBuffer(t,i)}function Ai(e,t,n,r,i,a){var o=r.period,s=!1;function u(){var r=e.getReference().getValue(),a=t.getValue(),u=r.position.getWanted();void 0!==o.end&&u+a>=o.end&&(oe.debug('Stream: full "empty" AdaptationStream',n),s=!0),i.streamStatusUpdate({period:o,bufferType:n,imminentDiscontinuity:null,position:u,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}t.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),e.listen(u,{includeLastObservation:!1,clearSignal:a}),u()}var Ii=function(e,t,n){var r=e.bufferType,i=e.content,a=e.garbageCollectors,o=e.playbackObserver,s=e.representationEstimator,u=e.segmentFetcherCreator,l=e.segmentBuffersStore,c=e.options,f=e.wantedBufferAhead,v=e.maxVideoBufferSize,h=i.manifest,m=i.period,g=new A(void 0,n);if(t.periodStreamReady({type:r,manifest:h,period:m,adaptationRef:g}),!n.isCancelled()){var y,_=!0;g.onUpdate((function(e){_t(St().mark((function i(){var s,u,d,v,g,E,T,k,w,A,I,R,x,C,M,P,D,O;return St().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==e){i.next=2;break}return i.abrupt("return");case 2:if((u=new ht).linkToSignal(n),null==y||y.cancel(),y=u,null!==e){i.next=34;break}if(oe.info("Stream: Set no "+r+" Adaptation. P:",m.start),"initialized"!==(d=l.getStatus(r)).type){i.next=26;break}if(oe.info("Stream: Clearing previous "+r+" SegmentBuffer"),!Wr.isNative(r)){i.next=15;break}return i.abrupt("return",S(0,!0,u.signal));case 15:if(v=null!==(s=m.end)&&void 0!==s?s:1/0,!(m.start>v)){i.next=20;break}oe.warn("Stream: Can't free buffer: period's start is after its end"),i.next=24;break;case 20:return i.next=22,d.value.removeBuffer(m.start,v);case 22:if(!u.isUsed()){i.next=24;break}return i.abrupt("return");case 24:i.next=30;break;case 26:if("uninitialized"!==d.type){i.next=30;break}if(l.disableSegmentBuffer(r),!u.isUsed()){i.next=30;break}return i.abrupt("return");case 30:if(t.adaptationChange({type:r,adaptation:null,period:m}),!u.isUsed()){i.next=33;break}return i.abrupt("return");case 33:return i.abrupt("return",Ai(o,f,r,{period:m},t,u.signal));case 34:if(g=m.adaptations[r],void 0!==(E=xe(null!=g?g:[],(function(t){return t.id===e.adaptationId})))){i.next=40;break}return y.cancel(),oe.warn("Stream: Unfound chosen Adaptation choice",e.adaptationId),i.abrupt("return");case 40:if(T=p.getCurrent(),k=T.DELTA_POSITION_AFTER_RELOAD,w=!1,!_){i.next=46;break}A=0,i.next=60;break;case 46:if(void 0===e.relativeResumingPosition){i.next=50;break}A=e.relativeResumingPosition,i.next=60;break;case 50:w=!0,i.t0=r,i.next="audio"===i.t0?54:"video"===i.t0?56:58;break;case 54:return A=k.trackSwitch.audio,i.abrupt("break",60);case 56:return A=k.trackSwitch.video,i.abrupt("break",60);case 58:return A=k.trackSwitch.other,i.abrupt("break",60);case 60:if(_=!1,!Wr.isNative(r)||"disabled"!==l.getStatus(r).type){i.next=63;break}return i.abrupt("return",S(A,!0,u.signal));case 63:if(h.addEventListener("manifestUpdate",(function(e){for(var t,n=Ti(e.updatedPeriods);!(t=n()).done;){var r=t.value;if(r.period.id===m.id)for(var i,a=Ti(r.result.removedAdaptations);!(i=a()).done;){if(i.value.id===E.id)return S(A,!0,u.signal)}else if(r.period.start>m.start)break}}),y.signal),I=e.representations,oe.info("Stream: Updating "+r+" adaptation","A: "+E.id,"P: "+m.start),t.adaptationChange({type:r,adaptation:E,period:m}),!u.isUsed()){i.next=69;break}return i.abrupt("return");case 69:if(R=wi(l,r,E),"needs-reload"!==(x=Ei(R,m,E,e.switchingMode,o,c)).type){i.next=73;break}return i.abrupt("return",S(A,!0,u.signal));case 73:return i.next=75,l.waitForUsableBuffers(u.signal);case 75:if(!u.isUsed()){i.next=77;break}return i.abrupt("return");case 77:if("flush-buffer"!==x.type&&"clean-buffer"!==x.type){i.next=91;break}C=Ti(x.value);case 79:if((M=C()).done){i.next=87;break}return P=M.value,D=P.start,O=P.end,i.next=83,R.removeBuffer(D,O);case 83:if(!u.isUsed()){i.next=85;break}return i.abrupt("return");case 85:i.next=79;break;case 87:if("flush-buffer"!==x.type){i.next=91;break}if(t.needsBufferFlush({relativeResumingPosition:A,relativePosHasBeenDefaulted:w}),!u.isUsed()){i.next=91;break}return i.abrupt("return");case 91:a.get(R)(u.signal),b(E,I,R,u.signal);case 93:case"end":return i.stop()}}),i)})))().catch((function(e){e instanceof gt||(null==y||y.cancel(),t.error(e))}))}),{clearSignal:n,emitCurrentValue:!0})}function b(e,n,i,a){var p,g,y=(p=o,g=e.type,p.deriveReadOnlyObserver((function(e,t){var n=new A(r(),t);return e.onUpdate(i,{clearSignal:t,emitCurrentValue:!1}),n;function r(){var t=e.getValue(),n=t.buffered[g],r=null!==n?ct(n,t.position.getWanted()):0;return d({},t,{bufferGap:r,buffered:n})}function i(){n.setValue(r())}})));gi({content:{manifest:h,period:m,adaptation:e,representations:n},options:c,playbackObserver:y,representationEstimator:s,segmentBuffer:i,segmentFetcherCreator:u,wantedBufferAhead:f,maxVideoBufferSize:v},Object.assign(Object.assign({},t),{error:function(e){if(!Wr.isNative(r)){oe.error("Stream: "+r+" Stream crashed. Aborting it.",e instanceof Error?e:""),l.disposeSegmentBuffer(r);var n=we(e,{defaultCode:"NONE",defaultReason:"Unknown `AdaptationStream` error"});if(t.warning(n),a.isCancelled())return;return Ai(o,f,r,{period:m},t,a)}oe.error("Stream: "+r+" Stream crashed. Stopping playback.",e instanceof Error?e:""),t.error(e)}}),a)}function S(e,n,i){Gr((function(){o.listen((function(){i.isCancelled()||t.waitingMediaSourceReload({bufferType:r,period:m,timeOffset:e,stayInPeriod:n})}),{includeLastObservation:!0,clearSignal:i})}))}};function Ri(e,t){if(0===t.length)return[];for(var n,r=[],i=e.getLastKnownInventory(),a=function(){var e=i[o];if(t.some((function(t){return e.infos.period.id===t.period.id&&e.infos.adaptation.id===t.adaptation.id&&e.infos.representation.id===t.representation.id}))){var n=e.bufferedStart,a=e.bufferedEnd;if(void 0===n||void 0===a)return oe.warn("SO: No buffered start or end found from a segment."),{v:[{start:0,end:Number.MAX_VALUE}]};var s=r[r.length-1];void 0!==s&&s.end===n?s.end=a:r.push({start:n,end:a})}},o=0;o<i.length;o++)if(n=a())return n.v;return r}function xi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ci(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ci(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ci(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Mi(e,t){if(0===t.length)return!1;var n=e.position.getPolled();return e.speed>=0?t[t.length-1].end>=n-5:t[0].start<=n+5}var Pi=function(e,t,n,r,i,a,o,s){for(var u,l=e.manifest,d=e.initialPeriod,c=a.maxBufferAhead,f=a.maxBufferBehind,v=a.wantedBufferAhead,h=a.maxVideoBufferSize,m=p.getCurrent(),g=m.MINIMUM_MAX_BUFFER_AHEAD,y=m.MAXIMUM_MAX_BUFFER_AHEAD,_=m.MAXIMUM_MAX_BUFFER_BEHIND,b=new Hr((function(e){var n,r,i=e.bufferType,a=null!==(n=_[i])&&void 0!==n?n:1/0,o=null!==(r=y[i])&&void 0!==r?r:1/0;return function(n){qr({segmentBuffer:e,playbackObserver:t,maxBufferBehind:w(f,(function(e){return Math.min(e,a)}),n),maxBufferAhead:w(c,(function(e){var t,n=Math.max(e,null!==(t=g[i])&&void 0!==t?t:0);return Math.min(n,o)}),n)},n)}})),S=xi(r.getBufferTypes());!(u=S()).done;){E(u.value,d)}function E(e,n){var i=new jr((function(e,t){return e.start-t.start})),a=!1,u=new ht;return u.linkToSignal(s),t.listen((function(t){var n,r=t.position.getWanted();if(a&&function(e){var t=i.head(),n=i.last();if(null==t||null==n)return!0;return t.start>e||(null==n.end?1/0:n.end)<e}(r)){for(oe.info("Stream: Destroying all PeriodStreams due to out of bounds situation",e,r),a=!1;i.length()>0;){var c=i.get(i.length()-1);i.removeElement(c),o.periodStreamCleared({type:e,manifest:l,period:c})}u.cancel(),(u=new ht).linkToSignal(s);var f=null!==(n=l.getPeriodForTime(r))&&void 0!==n?n:l.getNextPeriod(r);if(void 0===f)return oe.warn("Stream: The wanted position is not found in the Manifest."),void(a=!0);d(f)}}),{clearSignal:s,includeLastObservation:!0}),l.addEventListener("decipherabilityUpdate",(function(e){s.isCancelled()||function(e){return c.apply(this,arguments)}(e).catch((function(e){s.isCancelled()||(u.cancel(),o.error(e))}))}),s),d(n);function d(t){var n=Object.assign(Object.assign({},o),{waitingMediaSourceReload:function(e){var t=i.head();void 0===t||t.id!==e.period.id?o.lockedStream({bufferType:e.bufferType,period:e.period}):o.needsMediaSourceReload({timeOffset:e.timeOffset,minimumPosition:e.stayInPeriod?e.period.start:void 0,maximumPosition:e.stayInPeriod?e.period.end:void 0})},periodStreamReady:function(e){a=!0,i.add(e.period),o.periodStreamReady(e)},periodStreamCleared:function(e){i.removeElement(e.period),o.periodStreamCleared(e)},error:function(e){u.cancel(),o.error(e)}});T(e,t,n,u.signal)}function c(){return c=_t(St().mark((function n(c){var f,v,p,h,m,g,y,_,b,S,E,T,k;return St().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(f=r.getStatus(e),0!==(v=c.filter((function(t){return t.adaptation.type===e}))).length&&"initialized"===f.type&&!v.every((function(e){return!0===e.representation.decipherable}))){n.next=4;break}return n.abrupt("return");case 4:for(p=f.value,h=v.filter((function(e){return void 0===e.representation.decipherable})),m=v.filter((function(e){return!1===e.representation.decipherable})),g=Ri(p,m),y=Ri(p,h),a=!1,oe.info("Stream: Destroying all PeriodStreams for decipherability matters",e);i.length()>0;)_=i.get(i.length()-1),i.removeElement(_),o.periodStreamCleared({type:e,manifest:l,period:_});u.cancel(),(u=new ht).linkToSignal(s),b=0,S=[].concat(g,y);case 16:if(!(b<S.length)){n.next=28;break}if(E=S[b],T=E.start,k=E.end,!s.isCancelled()){n.next=20;break}return n.abrupt("return");case 20:if(!(T<k)){n.next=25;break}if(!s.isCancelled()){n.next=23;break}return n.abrupt("return");case 23:return n.next=25,p.removeBuffer(T,k);case 25:b++,n.next=16;break;case 28:Gr((function(){if(!s.isCancelled()){var e=t.getReference().getValue();if(Mi(e,g)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(Mi(e,y)&&(o.needsBufferFlush(),s.isCancelled()))return;var n=e.position.getWanted(),r=l.getPeriodForTime(n);null!=r?d(r):o.error(new Se("MEDIA_TIME_NOT_FOUND","The wanted position is not found in the Manifest."))}}));case 29:case"end":return n.stop()}}),n)}))),c.apply(this,arguments)}}function T(e,s,u,d){oe.info("Stream: Creating new Stream for",e,s.start);var c=null,f=new ht;f.linkToSignal(d),t.listen((function(t,n){var r=t.position;if(void 0!==s.end&&r.getWanted()>=s.end){var i=l.getPeriodAfter(s);if(s.containsTime(r.getWanted(),i))return;oe.info("Stream: Destroying PeriodStream as the current playhead moved above it",e,s.start,r.getWanted(),s.end),n(),u.periodStreamCleared({type:e,manifest:l,period:s}),f.cancel()}}),{clearSignal:d,includeLastObservation:!0});var p,m={bufferType:e,content:{manifest:l,period:s},garbageCollectors:b,maxVideoBufferSize:h,segmentFetcherCreator:i,segmentBuffersStore:r,options:a,playbackObserver:t,representationEstimator:n,wantedBufferAhead:v},g=Object.assign(Object.assign({},u),{streamStatusUpdate:function(t){if(t.hasFinishedLoading){var n=l.getPeriodAfter(s);null!==n&&function(t){if(null!==c){if(c.period.id===t.id)return;oe.warn("Stream: Creating next `PeriodStream` while one was already created.",e,t.id,c.period.id),u.periodStreamCleared({type:e,manifest:l,period:c.period}),c.canceller.cancel()}var n=new ht;n.linkToSignal(d),c={canceller:n,period:t},T(e,t,u,c.canceller.signal)}(n)}else null!==c&&(oe.info("Stream: Destroying next PeriodStream due to current one being active",e,c.period.start),u.periodStreamCleared({type:e,manifest:l,period:c.period}),c.canceller.cancel(),c=null);u.streamStatusUpdate(t)},error:function(e){null!==c&&(c.canceller.cancel(),c=null),f.cancel(),u.error(e)}});Ii(m,g,f.signal),p=f.signal,l.addEventListener("manifestUpdate",(function(t){for(var n,r=xi(t.removedPeriods);!(n=r()).done;){var i=n.value;if(i.id===s.id){if(l.periods.length>0&&l.periods[0].start<=i.start)return Gr((function(){if(!p.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})}))}else if(i.start>s.start)break}if(t.addedPeriods.length>0&&null!==c){var a=l.getPeriodAfter(s);null!==a&&c.period.id===a.id||(oe.warn("Stream: Destroying next PeriodStream due to new one being added",e,c.period.start),u.periodStreamCleared({type:e,manifest:l,period:c.period}),c.canceller.cancel(),c=null)}}),p)}},Di=Pi,Oi=function(e){function t(){return e.apply(this,arguments)||this}return u(t,e),t}(ie);function Ni(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Li(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Li(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Li(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ui=function(e){function t(t,n,r){var i;(i=e.call(this)||this)._canceller=new ht,i._manifest=t,i._activeStreams=new Map,i._allBufferTypes=r,i._lastCurrentPeriodId=null;var a=new Bi(t);i._maximumPositionCalculator=a;var o=i._canceller.signal;return n.listen((function(e){var n=e.position.getWanted();if(n<t.getMinimumSafePosition()){var r=new Se("MEDIA_TIME_BEFORE_MANIFEST","The current position is behind the earliest time announced in the Manifest.");i.trigger("warning",r)}else if(n>a.getMaximumAvailablePosition()){var o=new Se("MEDIA_TIME_AFTER_MANIFEST","The current position is after the latest time announced in the Manifest.");i.trigger("warning",o)}}),{includeLastObservation:!0,clearSignal:o}),t.addEventListener("manifestUpdate",(function(){i.trigger("endingPositionChange",i._getManifestEndTime()),o.isCancelled()||i._checkEndOfStream()}),o),i}u(t,e);var n=t.prototype;return n.getCurrentEndingTime=function(){return this._getManifestEndTime()},n.onAdaptationChange=function(e,t,n){if(this._manifest.isLastPeriodKnown){var r=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(null==r?void 0:r.id)&&("audio"===e||"video"===e)){"audio"===e?this._maximumPositionCalculator.updateLastAudioAdaptation(n):this._maximumPositionCalculator.updateLastVideoAdaptation(n);var i=this._maximumPositionCalculator.getEndingPosition(),a=void 0!==i?{isEnd:!0,endingPosition:i}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger("endingPositionChange",a)}}this._canceller.isUsed()||null===n&&this._addActivelyLoadedPeriod(t,e)},n.onRepresentationChange=function(e,t){this._addActivelyLoadedPeriod(t,e)},n.onPeriodCleared=function(e,t){this._removeActivelyLoadedPeriod(t,e)},n.onLastSegmentFinishedLoading=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())},n.onLastSegmentLoadingResume=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())},n.dispose=function(){this.removeEventListener(),this._canceller.cancel()},n._addActivelyLoadedPeriod=function(e,t){var n=this._lazilyCreateActiveStreamInfo(t);n.activePeriods.has(e)||(n.activePeriods.add(e),this._checkCurrentPeriod())},n._removeActivelyLoadedPeriod=function(e,t){var n=this._activeStreams.get(t);void 0!==n&&n.activePeriods.has(e)&&(n.activePeriods.removeElement(e),this._checkCurrentPeriod())},n._checkCurrentPeriod=function(){var e=this;if(0!==this._allBufferTypes.length){var t=this._activeStreams.get(this._allBufferTypes[0]);if(void 0!==t)for(var n,r,i=function(){for(var t=r.value,n=!0,i=1;i<e._allBufferTypes.length;i++){var a=e._activeStreams.get(e._allBufferTypes[i]);if(void 0===a)return{v:void 0};if(!a.activePeriods.toArray().some((function(e){return e.id===t.id}))){n=!1;break}}if(n)return e._lastCurrentPeriodId!==t.id&&(e._lastCurrentPeriodId=t.id,e.trigger("periodChange",t)),{v:void 0}},a=Ni(t.activePeriods.toArray());!(r=a()).done;)if(n=i())return n.v}},n._getManifestEndTime=function(){var e=this._maximumPositionCalculator.getEndingPosition();return void 0!==e?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}},n._lazilyCreateActiveStreamInfo=function(e){var t=this._activeStreams.get(e);return void 0===t&&(t={activePeriods:new jr((function(e,t){return e.start-t.start})),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t},n._checkEndOfStream=function(){var e=this;this._manifest.isLastPeriodKnown&&(this._allBufferTypes.every((function(t){var n=e._activeStreams.get(t);return void 0!==n&&n.hasFinishedLoadingLastPeriod}))?this.trigger("endOfStream",null):this.trigger("resumeStream",null))},t}(ie),Bi=function(){function e(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}var t=e.prototype;return t.updateLastAudioAdaptation=function(e){this._lastAudioAdaptation=e},t.updateLastVideoAdaptation=function(e){this._lastVideoAdaptation=e},t.getMaximumAvailablePosition=function(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(void 0===this._lastVideoAdaptation||void 0===this._lastAudioAdaptation)return this._manifest.getMaximumSafePosition();if(null===this._lastAudioAdaptation){if(null===this._lastVideoAdaptation)return this._manifest.getMaximumSafePosition();var e=Fi(this._lastVideoAdaptation);return"number"!=typeof e?this._manifest.getMaximumSafePosition():e}if(null===this._lastVideoAdaptation){var t=Fi(this._lastAudioAdaptation);return"number"!=typeof t?this._manifest.getMaximumSafePosition():t}var n=Fi(this._lastAudioAdaptation),r=Fi(this._lastVideoAdaptation);return"number"!=typeof n||"number"!=typeof r?this._manifest.getMaximumSafePosition():Math.min(n,r)},t.getEndingPosition=function(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(void 0!==this._lastVideoAdaptation&&void 0!==this._lastAudioAdaptation){if(null===this._lastAudioAdaptation)return null===this._lastVideoAdaptation?void 0:null!==(e=zi(this._lastVideoAdaptation))&&void 0!==e?e:void 0;if(null===this._lastVideoAdaptation)return null!==(t=zi(this._lastAudioAdaptation))&&void 0!==t?t:void 0;var n=zi(this._lastAudioAdaptation),r=zi(this._lastVideoAdaptation);return"number"!=typeof n||"number"!=typeof r?void 0:Math.min(n,r)}},e}();function Fi(e){for(var t,n=e.representations,r=null,i=0;i<n.length;i++)if(n[i].index!==t){t=n[i].index;var a=n[i].index.getLastAvailablePosition();if(void 0===a)return;null!==a&&(r=_(r)?a:Math.min(r,a))}return r}function zi(e){for(var t,n=e.representations,r=null,i=0;i<n.length;i++)if(n[i].index!==t){t=n[i].index;var a=n[i].index.getEnd();if(void 0===a)return;null!==a&&(r=_(r)?a:Math.min(r,a))}return r}function Vi(e,t,n){var r=t.autoPlay,i=t.initialPlayPerformed,a=t.manifest,o=t.mediaSource,s=t.speed,u=t.textDisplayer;return e.deriveReadOnlyObserver((function(e,t){var l=new ht;l.linkToSignal(t),l.linkToSignal(n);var d=new A(c(),l.signal);return s.onUpdate(f,{clearSignal:l.signal,emitCurrentValue:!1}),e.onUpdate(f,{clearSignal:l.signal,emitCurrentValue:!1}),d;function c(){var t=e.getValue(),n=s.getValue();return function(e,t){if(!t.isDynamic||t.isLastPeriodKnown){var n=t.periods[t.periods.length-1];if(void 0!==n&&void 0!==n.end){var r=e.position.getWanted();if(r>=n.start&&r>=n.end-1){var i=e.buffered;(0===i.length||i.end(i.length-1)<e.duration-1)&&e.position.forceWantedPosition(n.end-1)}}}}(t,a),{maximumPosition:Be(a),bufferGap:t.bufferGap,position:t.position,buffered:Wi(o,u),duration:t.duration,rebuffering:t.rebuffering,freezing:t.freezing,paused:{last:t.paused,pending:Ki(i,r)},readyState:t.readyState,speed:n}}function f(){d.setValue(c())}}))}function Ki(e,t){return e.getValue()?void 0:!t}function Wi(e,t){var n={audio:null,video:null,text:null};if(null!==t&&(n.text=t.getBufferedRanges()),null===e)return n;var r=xe(e.sourceBuffers,(function(e){return"audio"===e.type})),i=xe(e.sourceBuffers,(function(e){return"video"===e.type})),a=null==r?void 0:r.getBuffered();void 0!==a&&(n.audio=a);var o=null==i?void 0:i.getBuffered();return void 0!==o&&(n.video=o),n}function Gi(e){var t=e.textTracks;if(!_(t)){for(var n=0;n<t.length;n++)t[n].mode="disabled";if(e.hasChildNodes())for(var r=e.childNodes,i=r.length-1;i>=0;i--)if("track"===r[i].nodeName)try{e.removeChild(r[i])}catch(e){oe.warn("Compat: Could not remove text track child from element.")}}e.src="",e.removeAttribute("src")}var ji=g,Hi=void 0===ji?void 0:_(ji.MediaSource)?_(ji.MozMediaSource)?_(ji.WebKitMediaSource)?ji.MSMediaSource:ji.WebKitMediaSource:ji.MozMediaSource:ji.MediaSource;function qi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Yi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Yi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Yi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Qi=O,$i=C,Xi=D;function Zi(e,t){if(oe.debug("Init: Trying to call endOfStream"),"open"===e.readyState){var n=e.sourceBuffers,r=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];r.updating&&t.push(r)}return t}(n);if(0===r.length)return oe.info("Init: Triggering end of stream"),void e.endOfStream();oe.debug("Init: Waiting SourceBuffers to be updated before calling endOfStream.");var i=new ht;i.linkToSignal(t);for(var a,o=qi(r);!(a=o()).done;){var s=a.value;Xi(s,(function(){i.cancel(),Zi(e,t)}),i.signal)}Qi(n,(function(){i.cancel(),Zi(e,t)}),i.signal)}else oe.debug("Init: MediaSource not open, cancel endOfStream")}var Ji=31536e3,ea=function(){function e(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}var t=e.prototype;return t.updateDuration=function(e,t){null!==this._currentMediaSourceDurationUpdateCanceller&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new ht;var n=this._mediaSource,r=this._currentMediaSourceDurationUpdateCanceller.signal,i=function(e,t){var n=new A("open"===e.readyState,t);return C(e,(function(){oe.debug("Init: Reacting to MediaSource open in duration updater"),n.setValueIfChanged(!0)}),t),P(e,(function(){oe.debug("Init: Reacting to MediaSource ended in duration updater"),n.setValueIfChanged(!1)}),t),M(e,(function(){oe.debug("Init: Reacting to MediaSource close in duration updater"),n.setValueIfChanged(!1)}),t),n}(n,r),a=new ht;a.linkToSignal(r),i.onUpdate((function(){if(a.cancel(),!i.getValue())return;(a=new ht).linkToSignal(r);var o=function(e,t){if(0===e.length){var n=new A(!1);return n.finish(),n}var r=new A(!1,t);o();for(var i=function(){var n=e[a];n.addEventListener("updatestart",o),n.addEventListener("update",o),t.register((function(){n.removeEventListener("updatestart",o),n.removeEventListener("update",o)}))},a=0;a<e.length;a++)i();return r;function o(){for(var t=0;t<e.length;t++){if(e[t].updating)return void r.setValueIfChanged(!0)}r.setValueIfChanged(!1)}}(n.sourceBuffers,a.signal),s=new ht;return s.linkToSignal(a.signal),o.onUpdate((function(r){s.cancel(),(s=new ht).linkToSignal(a.signal),r||na(n,e,t,s.signal)}),{clearSignal:a.signal,emitCurrentValue:!0})}),{emitCurrentValue:!0,clearSignal:r})},t.stopUpdating=function(){null!==this._currentMediaSourceDurationUpdateCanceller&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)},e}();function ta(e,t,n){var r=t;n||(r=re?1/0:ra(t));for(var i=0,a=0;a<e.sourceBuffers.length;a++){var o=e.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===e.duration)return"success";if(i>r){if(i<e.duration)try{oe.info("Init: Updating duration to what is currently buffered",i),e.duration=i}catch(e){return oe.warn("Duration Updater: Can't update duration on the MediaSource.",e instanceof Error?e:""),"failed"}return"partial"}var u=e.duration;try{if(oe.info("Init: Updating duration",r),e.duration=r,"open"===e.readyState&&!isFinite(r)){var l=ra(t);oe.info("Init: calling `mediaSource.setLiveSeekableRange`",l),e.setLiveSeekableRange(0,l)}}catch(e){return oe.warn("Duration Updater: Can't update duration on the MediaSource.",e instanceof Error?e:""),"failed"}var d=Math.abs(e.duration-r);return d>=.1?d<Math.abs(e.duration-u)?"partial":"failed":"success"}function na(e,t,n,r){if("success"!==ta(e,t,n))var i=setTimeout((function(){a(),na(e,t,n,r)}),2e3),a=r.register((function(){clearTimeout(i)}))}function ra(e){return Math.max(Math.pow(2,32),e+Ji)}function ia(){for(var e,t=arguments.length,n=-1,r=0;++n<t;)r+="number"==typeof(e=n<0||arguments.length<=n?void 0:arguments[n])?e:e.length;var i=new Uint8Array(r),a=0;for(n=-1;++n<t;)"number"==typeof(e=n<0||arguments.length<=n?void 0:arguments[n])?a+=e:e.length>0&&(i.set(e,a),a+=e.length);return i}function aa(e,t){return(e[t+0]<<8)+(e[t+1]<<0)}function oa(e,t){return 65536*e[t+0]+256*e[t+1]+e[t+2]}function sa(e,t){return 16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3]}function ua(e,t){return 4294967296*(16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3])+16777216*e[t+4]+65536*e[t+5]+256*e[t+6]+e[t+7]}function la(e){return new Uint8Array([e>>>8&255,255&e])}function da(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}function ca(e){var t=e%4294967296,n=(e-t)/4294967296;return new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n,t>>>24&255,t>>>16&255,t>>>8&255,255&t])}function fa(e){return new Uint8Array([255&e,e>>>8&255,e>>>16&255,e>>>24&255])}function va(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return pa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pa(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ha=function(e){function t(t){var n;if((n=e.call(this)||this).id=t,n.sourceBuffers=[],n._canceller=new ht,_(Hi))throw new Se("MEDIA_SOURCE_NOT_SUPPORTED","No MediaSource Object was found in the current browser.");oe.info("Init: Creating MediaSource");var r=new Hi;n.readyState=r.readyState;var i=r.handle;return n.handle=_(i)?{type:"media-source",value:r}:{type:"handle",value:i},n._mediaSource=r,n._durationUpdater=new ea(r),n._endOfStreamCanceller=null,C(r,(function(){n.readyState=r.readyState,n.trigger("mediaSourceOpen",null)}),n._canceller.signal),P(r,(function(){n.readyState=r.readyState,n.trigger("mediaSourceEnded",null)}),n._canceller.signal),M(r,(function(){n.readyState=r.readyState,n.trigger("mediaSourceClose",null)}),n._canceller.signal),n}u(t,e);var n=t.prototype;return n.addSourceBuffer=function(e,t){var n=this._mediaSource.addSourceBuffer(t),r=new ma(e,t,n);return this.sourceBuffers.push(r),r},n.setDuration=function(e,t){this._durationUpdater.updateDuration(e,t)},n.interruptDurationSetting=function(){this._durationUpdater.stopUpdating()},n.maintainEndOfStream=function(){var e,t,n;null===this._endOfStreamCanceller&&(this._endOfStreamCanceller=new ht,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),oe.debug("Init: end-of-stream order received."),e=this._mediaSource,t=this._endOfStreamCanceller.signal,(n=new ht).linkToSignal(t),$i(e,(function(){oe.debug("Init: MediaSource re-opened while end-of-stream is active"),n.cancel(),(n=new ht).linkToSignal(t),Zi(e,n.signal)}),t),Zi(e,n.signal))},n.stopEndOfStream=function(){null!==this._endOfStreamCanceller&&(oe.debug("Init: resume-stream order received."),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)},n.dispose=function(){this.sourceBuffers.forEach((function(e){return e.dispose()})),this._canceller.cancel(),function(e){if("closed"!==e.readyState){for(var t=e.readyState,n=e.sourceBuffers,r=n.length-1;r>=0;r--){var i=n[r];try{if("open"===t){oe.info("Init: Aborting SourceBuffer before removing");try{i.abort()}catch(e){}}oe.info("Init: Removing SourceBuffer from mediaSource"),e.removeSourceBuffer(i)}catch(e){}}n.length>0&&oe.info("Init: Not all SourceBuffers could have been removed.")}}(this._mediaSource)},t}(ie),ma=function(){function e(e,t,n){var r=this;this.type=e,this.codec=t,this._canceller=new ht,this._sourceBuffer=n,this._operationQueue=[],this._currentOperations=[];var i=function(e){var t;t=e instanceof Error?e:e.error instanceof Error?e.error:new Error("Unknown SourceBuffer Error");var n=r._currentOperations;if(r._currentOperations=[],0===n.length)oe.error("SBI: error for an unknown operation",t);else for(var i,a=new ni(t.name,t.message,"QuotaExceededError"===t.name),o=va(n);!(i=o()).done;){i.value.reject(a)}},a=function(){var e=r._currentOperations;r._currentOperations=[];try{for(var t,n=va(e);!(t=n()).done;){t.value.resolve(st(r._sourceBuffer.buffered))}}catch(t){for(var i,a=va(e);!(i=a()).done;){var o=i.value;t instanceof Error&&"InvalidStateError"===t.name?o.resolve([]):o.reject(t)}}r._performNextOperation()};n.addEventListener("error",i),n.addEventListener("updateend",a),this._canceller.signal.register((function(){n.removeEventListener("error",i),n.removeEventListener("updateend",a)}))}var t=e.prototype;return t.appendBuffer=function(){oe.debug("SBI: receiving order to push data to the SourceBuffer",this.type);for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._addToQueue({operationName:0,params:t})},t.remove=function(e,t){return oe.debug("SBI: receiving order to remove data from the SourceBuffer",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})},t.getBuffered=function(){try{return st(this._sourceBuffer.buffered)}catch(e){return oe.error("Failed to get buffered time range of SourceBuffer",this.type,e instanceof Error?e:null),[]}},t.abort=function(){try{this._sourceBuffer.abort()}catch(e){oe.debug("Init: Failed to abort SourceBuffer:",e instanceof Error?e:null)}this._emptyCurrentQueue()},t.dispose=function(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()},t._emptyCurrentQueue=function(){var e=new gt;this._currentOperations.length>0&&(this._currentOperations.forEach((function(t){t.reject(e)})),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach((function(t){t.reject(e)})),this._operationQueue=[])},t._addToQueue=function(e){var t=this;return new Promise((function(n,r){var i=0===t._operationQueue.length&&0===t._currentOperations.length,a=d({resolve:n,reject:r},e);t._operationQueue.push(a),i&&t._performNextOperation()}))},t._performNextOperation=function(){var e,t,n,r,i;if(0===this._currentOperations.length&&!this._sourceBuffer.updating){var a=this._operationQueue.shift();if(void 0!==a)if(0===a.operationName){this._currentOperations=[{operationName:0,resolve:a.resolve,reject:a.reject}];var o=a.params[0],s=a.params[1],u=o;if(this._operationQueue.length>0&&0===this._operationQueue[0].operationName){for(var l=[o instanceof ArrayBuffer?new Uint8Array(o):o instanceof Uint8Array?o:new Uint8Array(o.buffer)];0===(null===(e=this._operationQueue[0])||void 0===e?void 0:e.operationName);){var d=this._operationQueue[0],c=null!==(t=s.appendWindow)&&void 0!==t?t:[void 0,void 0],f=null!==(n=d.params[1].appendWindow)&&void 0!==n?n:[void 0,void 0],v=null!==(r=s.timestampOffset)&&void 0!==r?r:0,p=null!==(i=d.params[1].timestampOffset)&&void 0!==i?i:0;if(c[0]!==f[0]||c[1]!==f[1]||s.codec!==d.params[1].codec||v!==p)break;var h=d.params[0];l.push(h instanceof ArrayBuffer?new Uint8Array(h):h instanceof Uint8Array?h:new Uint8Array(h.buffer)),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:d.resolve,reject:d.reject})}l.length>1&&(oe.info("MMSI: Merging "+l.length+" segments together for perf",this.type),u=ia.apply(void 0,l))}try{this._appendBufferNow(u,s)}catch(e){var m=e instanceof Error?new ni(e.name,e.message,"QuotaExceededError"===e.name):new ni("Error","Unknown SourceBuffer Error during appendBuffer",!1);this._currentOperations.forEach((function(e){e.reject(m)})),this._currentOperations=[]}}else{this._currentOperations=[a];var g=a.params,y=g[0],_=g[1];oe.debug("SBI: removing data from SourceBuffer",this.type,y,_);try{this._sourceBuffer.remove(y,_)}catch(e){var b=e instanceof Error?new ni(e.name,e.message,!1):new ni("Error","Unknown SourceBuffer Error during remove",!1);a.reject(b),this._currentOperations=[]}}}},t._appendBufferNow=function(e,t){var n=this._sourceBuffer,r=t.codec,i=t.timestampOffset,a=t.appendWindow,o=void 0===a?[]:a;if(void 0!==r&&r!==this.codec){oe.debug("SBI: updating codec",r);var s=function(e,t){if("function"==typeof e.changeType){try{e.changeType(t)}catch(e){return oe.warn("Could not call 'changeType' on the given SourceBuffer:",e instanceof Error?e:""),!1}return!0}return!1}(n,r);s?this.codec=r:oe.debug("SBI: could not update codec",r,this.codec)}if(void 0!==i&&n.timestampOffset!==i){var u=i;oe.debug("SBI: updating timestampOffset",r,n.timestampOffset,u),n.timestampOffset=u}if(void 0===o[0])n.appendWindowStart>0&&(oe.debug("SBI: re-setting `appendWindowStart` to `0`"),n.appendWindowStart=0);else if(o[0]!==n.appendWindowStart){if(o[0]>=n.appendWindowEnd){var l=o[0]+1;oe.debug("SBI: pre-updating `appendWindowEnd`",l),n.appendWindowEnd=l}oe.debug("SBI: setting `appendWindowStart`",o[0]),n.appendWindowStart=o[0]}void 0===o[1]?n.appendWindowEnd!==1/0&&(oe.debug("SBI: re-setting `appendWindowEnd` to `Infinity`"),n.appendWindowEnd=1/0):o[1]!==n.appendWindowEnd&&(oe.debug("SBI: setting `appendWindowEnd`",o[1]),n.appendWindowEnd=o[1]),oe.debug("SBI: pushing segment",this.type),n.appendBuffer(e)},e}();var ga=Je();function ya(e,t){if(null!==t&&e.src===t&&(oe.info("Init: Clearing HTMLMediaElement's src"),Gi(e)),null!==t)try{oe.debug("Init: Revoking previous URL"),URL.revokeObjectURL(t)}catch(e){oe.warn("Init: Error while revoking the media source URL",e instanceof Error?e:"")}}function _a(e,t){return sn(t,(function(n){var r=function(e,t){ya(e,y(e.src)?e.src:null);var n=new ha(ga());return t.register((function(){n.dispose()})),n}(e,t);if(r.addEventListener("mediaSourceOpen",(function(){oe.info("Init: MediaSource opened"),n(r)}),t),oe.info("MTCI: Attaching MediaSource URL to the media element"),"handle"===r.handle.type)e.srcObject=r.handle.value,t.register((function(){ya(e,null)}));else{var i=URL.createObjectURL(r.handle.value);e.src=i,t.register((function(){ya(e,i)}))}}))}function ba(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Sa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Sa(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Sa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ea,Ta=function(){function e(e){this._segmentBuffersStore=e,this._currentFreezeTimestamp=null}return e.prototype.needToReload=function(e){var t=e.readyState,n=e.rebuffering,r=e.freezing;if((void 0!==e.bufferGap&&isFinite(e.bufferGap)?e.bufferGap:0)<6||null===n&&null===r||t>1)return this._currentFreezeTimestamp=null,!1;var i=Me();null===this._currentFreezeTimestamp&&(this._currentFreezeTimestamp=i);var a=null!==n&&i-n.timestamp>4e3,o=null!==r&&i-r.timestamp>4e3;if((a||o)&&Me()-this._currentFreezeTimestamp>4e3){for(var s=!0,u=!0,l=0,d=[this._segmentBuffersStore.getStatus("audio"),this._segmentBuffersStore.getStatus("video")];l<d.length;l++){var c=d[l];if("initialized"===c.type)for(var f,v=ba(c.value.getLastKnownInventory());!(f=v()).done;){var p=f.value.infos.representation;if(!1===p.decipherable)return oe.warn("Init: we have undecipherable segments left in the buffer, reloading"),this._currentFreezeTimestamp=null,!0;void 0!==p.contentProtections&&(u=!1,!0!==p.decipherable&&(s=!1))}}if(!u&&s)return oe.warn("Init: we are frozen despite only having decipherable segments left in the buffer, reloading"),this._currentFreezeTimestamp=null,!0}return!1},e}();function ka(e,t,n){var r;if(!_(n)){var i=Le(e),a=Be(e);if(!_(n.position))return oe.debug("Init: using startAt.minimumPosition"),Math.max(Math.min(n.position,a),i);if(!_(n.wallClockTime)){oe.debug("Init: using startAt.wallClockTime");var o=void 0===e.availabilityStartTime?0:e.availabilityStartTime,s=n.wallClockTime-o;return Math.max(Math.min(s,a),i)}if(!_(n.fromFirstPosition)){oe.debug("Init: using startAt.fromFirstPosition");var u=n.fromFirstPosition;return u<=0?i:Math.min(a,i+u)}if(!_(n.fromLastPosition)){oe.debug("Init: using startAt.fromLastPosition");var l=n.fromLastPosition;return l>=0?a:Math.max(i,a+l)}if(!_(n.fromLivePosition)){oe.debug("Init: using startAt.fromLivePosition");var d=null!==(r=Ue(e))&&void 0!==r?r:a,c=n.fromLivePosition;return c>=0?d:Math.max(i,d+c)}if(!_(n.percentage)){oe.debug("Init: using startAt.percentage");var f=n.percentage;return f>100?a:f<0?i:i+(a-i)*(+f/100)}}var v=Le(e);if(e.isLive){var h,m=e.suggestedPresentationDelay,g=e.clockOffset,y=Be(e),b=p.getCurrent().DEFAULT_LIVE_GAP;if(void 0===g)oe.info("Init: no clock offset found for a live content, starting close to maximum available position"),h=y;else{oe.info("Init: clock offset found for a live content, checking if we can start close to it");var S=void 0===e.availabilityStartTime?0:e.availabilityStartTime,E=(Me()+g)/1e3-S;h=Math.min(y,E)}var T=void 0!==m?m:t?b.LOW_LATENCY:b.DEFAULT;return oe.debug("Init: "+h+" defined as the live time, applying a live gap of "+T),Math.max(h-T,v)}return oe.info("Init: starting at the minimum available position:",v),v}function wa(){return J}function Aa(e,t,n,r){var i=new ht;i.linkToSignal(r);var a=new A(!1,i.signal);return e.listen((function(e){if(null===e.rebuffering&&null===e.freezing&&0!==e.readyState){if(!function(e,t){return!e||!Z||t}(n,t.hasAttribute("playsinline"))&&t.duration>0)return a.setValue(!0),void i.cancel();var r=re?4:3;return e.readyState>=r&&(null!==e.currentRange||e.ended)&&(!wa()||t.duration>0)?(a.setValue(!0),void i.cancel()):void 0}}),{includeLastObservation:!0,clearSignal:i.signal}),a}function Ia(e,t){var n=e.mediaElement,r=e.playbackObserver,i=e.startTime,a=e.mustAutoPlay,o=e.isDirectfile,s=e.onWarning,u=new A(!1,t),l=new Promise((function(e,l){var d=t.register((function(e){l(e)}));if(!t.isCancelled()){var c=!1,f=function(e){r.setCurrentTime(e),c=!0};if(o&&"number"!=typeof i)r.listen((function(e,t){if(e.readyState>=1){t();var n="number"==typeof i?i:i();0!==n&&(Z?setTimeout((function(){f(n)}),0):f(n)),p()}}),{includeLastObservation:!0,clearSignal:t});else{var v="number"==typeof i?i:i();0!==v&&f(v),p()}}function p(){var i=!1;r.listen((function(o,f){if(i||0===o.seeking||(i=!0),(!c||i)&&0!==o.readyState){if(f(),wa()&&0===n.duration){var v=new Se("MEDIA_ERR_NOT_LOADED_METADATA","Cannot load automatically: your browser falsely announced having loaded the content.");s(v)}t.isCancelled()||r.listen((function(r,i){0===r.seeking&&null===r.rebuffering&&r.readyState>=1&&(i(),function(){var r,i;if(oe.info("Init: Can begin to play content"),!a)return n.autoplay&&oe.warn("Init: autoplay is enabled on HTML media element. Media will play as soon as possible."),u.setValue(!0),u.finish(),d(),e({type:"skipped"});if(n.ended)return oe.warn("Init: autoplay is enabled but the video is ended. Skipping autoplay to prevent video to start again"),u.setValue(!0),u.finish(),d(),e({type:"skipped"});try{i=null!==(r=n.play())&&void 0!==r?r:Promise.resolve()}catch(e){return d(),l(e)}i.then((function(){if(!t.isCancelled())return u.setValue(!0),u.finish(),d(),e({type:"autoplay"})})).catch((function(n){if(d(),!t.isCancelled()){if(n instanceof Error&&"NotAllowedError"===n.name){oe.warn("Init: Media element can't play. It may be due to browser auto-play policies.");var r=new Se("MEDIA_ERR_BLOCKED_AUTOPLAY","Cannot trigger auto-play automatically: your browser does not allow it.");if(s(r),t.isCancelled())return;return e({type:"autoplay-blocked"})}l(n)}}))}())}),{includeLastObservation:!0,clearSignal:t})}}),{includeLastObservation:!0,clearSignal:t})}}));return{autoPlayResult:l,initialPlayPerformed:u}}function Ra(e,t,n,r,i){if(0===t.length)return l("No `keySystems` option given.");if(null===Re.decrypt)return l("EME feature not activated.");var a=new ht;a.linkToSignal(i);var o=new A({initializationState:{type:"uninitialized",value:null},drmSystemId:void 0},i),s=Re.decrypt;if(!s.hasEmeApis())return l("EME API not available on the current page.");oe.debug("Init: Creating ContentDecryptor");var u=new s(e,t);return u.addEventListener("stateChange",(function(e){if(e===Ea.WaitingForAttachment){var t=new A(!1);t.onUpdate((function(t,n){t&&(n(),e===Ea.WaitingForAttachment&&u.attach())}),{clearSignal:a.signal}),o.setValue({initializationState:{type:"awaiting-media-link",value:{isMediaLinked:t}},drmSystemId:u.systemId})}else e===Ea.ReadyForContent&&(o.setValue({initializationState:{type:"initialized",value:null},drmSystemId:u.systemId}),u.removeEventListener("stateChange"))})),u.addEventListener("error",(function(e){a.cancel(),r.onError(e)})),u.addEventListener("warning",(function(e){r.onWarning(e)})),u.addEventListener("blackListProtectionData",(function(e){r.onBlackListProtectionData(e)})),u.addEventListener("keyIdsCompatibilityUpdate",(function(e){r.onKeyIdsCompatibilityUpdate(e)})),n.onUpdate((function(e){null!==e&&u.onInitializationData(e)}),{clearSignal:a.signal}),a.signal.register((function(){u.dispose()})),o;function l(e){n.onUpdate((function(t,n){if(null!==t){n();var i=new be("MEDIA_IS_ENCRYPTED_ERROR",e);r.onError(i)}}),{clearSignal:i});var t=new A({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return t.finish(),t}}!function(e){e[e.Initializing=0]="Initializing",e[e.WaitingForAttachment=1]="WaitingForAttachment",e[e.ReadyForContent=2]="ReadyForContent",e[e.Error=3]="Error",e[e.Disposed=4]="Disposed"}(Ea||(Ea={}));var xa=function(){function e(e){this._displayer=e}var t=e.prototype;return t.pushTextData=function(e){try{return Promise.resolve(this._displayer.pushTextData(e))}catch(e){return Promise.reject(e)}},t.remove=function(e,t){try{return Promise.resolve(this._displayer.removeBuffer(e,t))}catch(e){return Promise.reject(e)}},t.reset=function(){this._displayer.reset()},t.stop=function(){this._displayer.stop()},e}(),Ca=1/60,Ma=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._playbackObserver=t,i._manifest=n,i._speed=r,i._discontinuitiesStore=[],i._isStarted=!1,i._canceller=new ht,i}u(t,e);var n=t.prototype;return n.start=function(){var e=this;if(!this._isStarted){this._isStarted=!0;var t=new Oa(this._playbackObserver,this._speed);this._canceller.signal.register((function(){t.dispose()}));var n=null;this._playbackObserver.listen((function(r){var i,a=e._discontinuitiesStore,o=r.buffered,s=r.position,u=r.readyState,l=r.rebuffering,d=r.freezing,c=p.getCurrent(),f=c.BUFFER_DISCONTINUITY_THRESHOLD,v=c.FREEZING_STALLED_DELAY,h=c.UNFREEZING_SEEK_DELAY,m=c.UNFREEZING_DELTA_POSITION;if(null!==d){var g=Me(),y=null===n?d.timestamp:n.attemptTimestamp;if(!s.isAwaitingFuturePosition()&&g-y>h&&(oe.warn("Init: trying to seek to un-freeze player"),e._playbackObserver.setCurrentTime(e._playbackObserver.getCurrentTime()+m),n={attemptTimestamp:g}),g-d.timestamp>v)return null===l?t.stopRebuffering():t.startRebuffering(),void e.trigger("stalled","freezing")}else n=null;if(null===l)return t.stopRebuffering(),1===u?(i=0!==r.seeking?1===r.seeking?"internal-seek":"seeking":"not-ready",void e.trigger("stalled",i)):void e.trigger("unstalled",null);var _="seeking"===l.reason&&1===r.seeking?"internal-seek":l.reason;if(s.isAwaitingFuturePosition())return t.stopRebuffering(),oe.debug("Init: let rebuffering happen as we're awaiting a future position"),void e.trigger("stalled",_);if(t.startRebuffering(),null!==e._manifest){var b=l.position;if(null!=b&&e._speed.getValue()>0){var S=function(e,t,n){if(0===e.length)return null;for(var r=null,i=0;i<e.length;i++){var a=e[i].period;if(a.start>n)return r;var o=void 0;if(void 0===a.end||a.end>n){var s=e[i],u=s.discontinuity,l=s.position,d=u.start,c=u.end;if(n>=(null!=d?d:l)-Ca)if(null===c){var f=ze(t,a);null!==f?o=f.start+Ca:oe.warn("Init: discontinuity at Period's end but no next Period")}else n<c+Ca&&(o=c+Ca);void 0!==o&&(oe.info("Init: discontinuity found",n,o),r=null!==r&&r>o?r:o)}}return r}(a,e._manifest,b);if(null!==S){var E=S+.001;if(!(E<=e._playbackObserver.getCurrentTime()))return oe.warn("SA: skippable discontinuity found in the stream",s.getPolled(),E),e._playbackObserver.setCurrentTime(E),void e.trigger("warning",Da(b,E));oe.info("Init: position to seek already reached, no seeking",e._playbackObserver.getCurrentTime(),E)}}var T=null!=b?b:s.getPolled(),k=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e.start(r);if(t<i)return i-t}return 1/0}(o,T);if(e._speed.getValue()>0&&k<f){var w=T+k+Ca;if(e._playbackObserver.getCurrentTime()<w)return oe.warn("Init: discontinuity encountered inferior to the threshold",T,w,f),e._playbackObserver.setCurrentTime(w),void e.trigger("warning",Da(T,w))}for(var A=e._manifest.periods.length-2;A>=0;A--){var I=e._manifest.periods[A];if(void 0!==I.end&&I.end<=T){if(e._manifest.periods[A+1].start>T&&e._manifest.periods[A+1].start>e._playbackObserver.getCurrentTime()){var R=e._manifest.periods[A+1];return e._playbackObserver.setCurrentTime(R.start),void e.trigger("warning",Da(T,R.start))}break}}e.trigger("stalled",_)}else e.trigger("stalled",_)}),{includeLastObservation:!0,clearSignal:this._canceller.signal})}},n.updateDiscontinuityInfo=function(e){this._isStarted||this.start();var t=this._playbackObserver.getReference().getValue();!function(e,t,n){var r=Math.min(n.position.getPolled(),n.position.getWanted());for(;e.length>0&&void 0!==e[0].period.end&&e[0].period.end+10<r;)e.shift();var i=t.period,a=t.bufferType;if("audio"!==a&&"video"!==a)return;for(var o=0;o<e.length;o++)if(e[o].period.id===i.id){if(e[o].bufferType===a)return void(Pa(t)?e[o]=t:e.splice(o,1))}else if(e[o].period.start>i.start)return void(Pa(t)&&e.splice(o,0,t));Pa(t)&&e.push(t)}(this._discontinuitiesStore,e,t)},n.onLockedStream=function(e,t){var n;this._isStarted||this.start();var r=this._playbackObserver.getReference().getValue();if(!(!r.rebuffering||r.paused||this._speed.getValue()<=0||"audio"!==e&&"video"!==e)){var i=r.position.getWanted(),a=null!==(n=r.rebuffering.position)&&void 0!==n?n:i,o=t.start;i<o&&Math.abs(a-o)<1&&(oe.warn("Init: rebuffering because of a future locked stream.\nTrying to unlock by seeking to the next Period"),this._playbackObserver.setCurrentTime(o+.001))}},n.destroy=function(){this._canceller.cancel()},t}(ie);function Pa(e){return null!==e.discontinuity}function Da(e,t){return new Se("DISCONTINUITY_ENCOUNTERED","A discontinuity has been encountered at position "+String(e)+", seeked at position "+String(t))}var Oa=function(){function e(e,t){this._speedUpdateCanceller=new ht,this._isRebuffering=!1,this._playbackObserver=e,this._isDisposed=!1,this._speed=t,this._updateSpeed()}var t=e.prototype;return t.startRebuffering=function(){this._isRebuffering||this._isDisposed||(this._isRebuffering=!0,this._speedUpdateCanceller.cancel(),oe.info("Init: Pause playback to build buffer"),this._playbackObserver.setPlaybackRate(0))},t.stopRebuffering=function(){this._isRebuffering&&!this._isDisposed&&(this._isRebuffering=!1,this._speedUpdateCanceller=new ht,this._updateSpeed())},t.dispose=function(){this._speedUpdateCanceller.cancel(),this._isDisposed=!0},t._updateSpeed=function(){var e=this;this._speed.onUpdate((function(t){oe.info("Init: Resume playback speed",t),e._playbackObserver.setPlaybackRate(t)}),{clearSignal:this._speedUpdateCanceller.signal,emitCurrentValue:!0})},e}();var Na=function(e,t){return e.id===t.id&&e.start===t.start&&e.end===t.end};var La=function(e,t){for(var n=[],r=t.periods,i=0;i<r.length;i++){r[i].streamEvents.forEach((function(t){for(var r,i=t.start,a=t.end,o=t.id,s=t.data,u=0;u<e.length;u++){var l=e[u];if(Na(l,{id:o,start:i,end:a}))return void n.push(l)}if(void 0!==s.value.element)r=s.value.element;else{if(void 0===s.value.xmlData)return;var d=s.value.xmlData.namespaces.reduce((function(e,t){return e+"xmlns:"+t.key+'="'+t.value+'" '}),"<toremove ");d+=">";var c=(new DOMParser).parseFromString(d+s.value.xmlData.data+"</toremove>","application/xml").documentElement;r=c.children.length>0?c.children[0]:c.childNodes[0]}var f={type:s.type,value:Object.assign(Object.assign({},s.value),{element:r})};if(void 0===a){var v={start:i,id:o,data:f,publicEvent:{start:i,data:f}};n.push(v)}else{var p={start:i,end:a,id:o,data:f,publicEvent:{start:i,end:a,data:f}};n.push(p)}}))}return n};function Ua(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ba(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ba(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ba(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Fa=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._manifest=t,i._mediaElement=n,i._playbackObserver=r,i._canceller=null,i._scheduledEventsRef=new A([]),i._eventsBeingPlayed=new WeakMap,i}u(t,e);var n=t.prototype;return n.start=function(){var e=this;if(null===this._canceller){this._canceller=new ht;var t=this._canceller.signal,n=this._playbackObserver,r=this._mediaElement,i=!1,a=new ht;a.linkToSignal(t),this._scheduledEventsRef.setValue(La([],this._manifest)),this._scheduledEventsRef.onUpdate((function(o){if(0!==o.length){if(!i){i=!0;var s=c(),u=function(){var t=c();e._emitStreamEvents(e._scheduledEventsRef.getValue(),s,t,a.signal),s=t},l=p.getCurrent().STREAM_EVENT_EMITTER_POLL_INTERVAL,d=setInterval(u,l);n.listen(u,{includeLastObservation:!1,clearSignal:a.signal}),a.signal.register((function(){clearInterval(d)}))}}else i&&(a.cancel(),(a=new ht).linkToSignal(t),i=!1);function c(){var e=n.getReference().getValue();return{currentTime:r.currentTime,isSeeking:0!==e.seeking}}}),{emitCurrentValue:!0,clearSignal:t})}},n.onManifestUpdate=function(e){var t=this._scheduledEventsRef.getValue();this._scheduledEventsRef.setValue(La(t,e))},n.stop=function(){null!==this._canceller&&(this._canceller.cancel(),this._canceller=null)},n._emitStreamEvents=function(e,t,n,r){for(var i=t.currentTime,a=n.isSeeking,o=n.currentTime,s=[],u=[],l=0;l<e.length;l++){var d=e[l],c=d.start,f=za(d)?d.end:void 0;this._eventsBeingPlayed.has(d)?(c>o||void 0!==f&&o>=f)&&(za(d)&&u.push(d.publicEvent),this._eventsBeingPlayed.delete(d)):c<=o&&void 0!==f&&o<f?(s.push({type:"stream-event",value:d.publicEvent}),this._eventsBeingPlayed.set(d,!0)):i<c&&o>=(null!=f?f:c)&&(a?s.push({type:"stream-event-skip",value:d.publicEvent}):(s.push({type:"stream-event",value:d.publicEvent}),za(d)&&u.push(d.publicEvent)))}if(s.length>0)for(var v,p=Ua(s);!(v=p()).done;){var h=v.value;if("stream-event"===h.type?this.trigger("event",h.value):this.trigger("eventSkip",h.value),r.isCancelled())return}if(u.length>0)for(var m,g=Ua(u);!(m=g()).done;){var y=m.value;if("function"==typeof y.onExit&&y.onExit(),r.isCancelled())return}},t}(ie);function za(e){return void 0!==e.end}var Va=Fa;function Ka(e,t,n){function r(){var n,r,i=e.error;switch(_(i)||(n=i.code,r=i.message),n){case 1:return t(new Se("MEDIA_ERR_ABORTED",r=null!=r?r:"The fetching of the associated resource was aborted by the user's request."));case 2:return t(new Se("MEDIA_ERR_NETWORK",r=null!=r?r:"A network error occurred which prevented the media from being successfully fetched"));case 3:return t(new Se("MEDIA_ERR_DECODE",r=null!=r?r:"An error occurred while trying to decode the media resource"));case 4:return t(new Se("MEDIA_ERR_SRC_NOT_SUPPORTED",r=null!=r?r:"The media resource has been found to be unsuitable."));default:return t(new Se("MEDIA_ERR_UNKNOWN",r=null!=r?r:"The HTMLMediaElement errored due to an unknown reason."))}}n.isCancelled()||(e.addEventListener("error",r),n.register((function(){e.removeEventListener("error",r)})))}function Wa(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ga(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ga(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ga(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ja=function(e){function t(t){var n;(n=e.call(this)||this)._settings=t,n._initCanceller=new ht,n._manifest=null;var r=void 0===t.url?void 0:[t.url];return n._manifestFetcher=new cr(r,t.transport,t.manifestRequestSettings),n}u(t,e);var n=t.prototype;return n.prepare=function(){var e=this;null===this._manifest&&(this._manifest=un.createAsync(sn(this._initCanceller.signal,(function(t,n){e._manifestFetcher.addEventListener("warning",(function(t){return e.trigger("warning",t)})),e._manifestFetcher.addEventListener("error",(function(t){e.trigger("error",t),n(t)})),e._manifestFetcher.addEventListener("manifestReady",(function(e){t(e)}))}))),this._manifestFetcher.start(),this._initCanceller.signal.register((function(){e._manifestFetcher.dispose()})))},n.start=function(e,t){var n=this;this.prepare(),Ka(e,(function(e){return n._onFatalError(e)}),this._initCanceller.signal);var r=new A(null,this._initCanceller.signal);this._initializeMediaSourceAndDecryption(e,r).then((function(i){return n._onInitialMediaSourceReady(e,i.mediaSource,t,i.drmSystemId,r,i.unlinkMediaSource)})).catch((function(e){n._onFatalError(e)}))},n.updateContentUrls=function(e,t){this._manifestFetcher.updateContentUrls(e,t)},n.dispose=function(){this._initCanceller.cancel()},n._onFatalError=function(e){this._initCanceller.isUsed()||(this._initCanceller.cancel(),this.trigger("error",e))},n._initializeMediaSourceAndDecryption=function(e,t){var n=this,r=this._initCanceller;return sn(r.signal,(function(i){var a=n._settings.keySystems,o=Ra(e,a,t,{onWarning:function(e){return n.trigger("warning",e)},onError:function(e){return n._onFatalError(e)},onBlackListProtectionData:function(e){_t(St().mark((function t(){var r;return St().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==n._manifest){t.next=2;break}return t.abrupt("return");case 2:if(null===(r=n._manifest.syncValue)||void 0===r){t.next=6;break}t.t0=r,t.next=9;break;case 6:return t.next=8,n._manifest.getValueAsAsync();case 8:t.t0=t.sent;case 9:qa(t.t0,e);case 11:case"end":return t.stop()}}),t)})))().catch(b)},onKeyIdsCompatibilityUpdate:function(e){_t(St().mark((function t(){var r;return St().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==n._manifest){t.next=2;break}return t.abrupt("return");case 2:if(null===(r=n._manifest.syncValue)||void 0===r){t.next=6;break}t.t0=r,t.next=9;break;case 6:return t.next=8,n._manifest.getValueAsAsync();case 8:t.t0=t.sent;case 9:Ha(t.t0,e.whitelistedKeyIds,e.blacklistedKeyIds,e.delistedKeyIds);case 11:case"end":return t.stop()}}),t)})))().catch(b)}},r.signal);o.onUpdate((function(t,a){if("uninitialized"!==t.initializationState.type){a();var s=new ht;s.linkToSignal(r.signal),_a(e,s.signal).then((function(e){var n=o.getValue();if("awaiting-media-link"===n.initializationState.type)n.initializationState.value.isMediaLinked.setValue(!0),o.onUpdate((function(t,n){if("initialized"===t.initializationState.type)return n(),void i({mediaSource:e,drmSystemId:t.drmSystemId,unlinkMediaSource:s})}),{emitCurrentValue:!0,clearSignal:r.signal});else if("initialized"===t.initializationState.type)return void i({mediaSource:e,drmSystemId:t.drmSystemId,unlinkMediaSource:s})})).catch((function(e){s.isUsed()||n._onFatalError(e)}))}}),{emitCurrentValue:!0,clearSignal:r.signal})}))},n._onInitialMediaSourceReady=function(){var e=_t(St().mark((function e(t,n,r,i,a,o){var s,u,l,c,f,v,p,h,m,g,y,_,b,S,E,T,k,w,A,I,R,x=this;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(R=function(e,n,i,o){w({mediaElement:t,playbackObserver:r,mediaSource:e,initialTime:n,autoPlay:i,manifest:b,representationEstimator:E,segmentFetcherCreator:k,speed:h,protectionRef:a,bufferOptions:T},(function(e){if(o.cancel(),_.isUsed())return;if(A("reloadingMediaSource",e),_.isUsed())return;var n=new ht;n.linkToSignal(_.signal),_a(t,n.signal).then((function(t){R(t,e.position,e.autoPlay,n)})).catch((function(e){n.isUsed()||I(e)}))}),o.signal)},u=this._settings,l=u.adaptiveOptions,c=u.autoPlay,f=u.bufferOptions,v=u.lowLatencyMode,p=u.segmentRequestOptions,h=u.speed,m=u.startAt,g=u.textTrackOptions,y=u.transport,_=this._initCanceller,Xe(this._manifest),e.prev=4,null===(s=this._manifest.syncValue)||void 0===s){e.next=9;break}e.t0=s,e.next=12;break;case 9:return e.next=11,this._manifest.getValueAsAsync();case 11:e.t0=e.sent;case 12:b=e.t0,e.next=18;break;case 15:return e.prev=15,e.t1=e.catch(4),e.abrupt("return");case 18:if(b.addEventListener("manifestUpdate",(function(e){x.trigger("manifestUpdate",e)}),_.signal),b.addEventListener("decipherabilityUpdate",(function(e){x.trigger("decipherabilityUpdate",e)}),_.signal),oe.debug("Init: Calculating initial time"),S=ka(b,v,m),oe.debug("Init: Initial time calculated:",S),E=An(l),T=d({textTrackOptions:g,drmSystemId:i},f),k=new Sr(y,p,_.signal),this.trigger("manifestReady",b),!_.isUsed()){e.next=29;break}return e.abrupt("return");case 29:w=this._startBufferingOnMediaSource.bind(this),A=this.trigger.bind(this),I=this._onFatalError.bind(this),R(n,S,c,o);case 33:case"end":return e.stop()}}),e,this,[[4,15]])})));return function(t,n,r,i,a,o){return e.apply(this,arguments)}}(),n._startBufferingOnMediaSource=function(e,t,n){var r,i=this,a=e.autoPlay,o=e.bufferOptions,s=e.initialTime,u=e.manifest,l=e.mediaElement,d=e.mediaSource,c=e.playbackObserver,f=e.protectionRef,v=e.representationEstimator,h=e.segmentFetcherCreator,m=e.speed,g=null!==(r=u.getPeriodForTime(s))&&void 0!==r?r:u.getNextPeriod(s);if(void 0===g){var y=new Se("MEDIA_STARTING_TIME_NOT_FOUND","Wanted starting time not found in the Manifest.");return this._onFatalError(y)}var _=null,b=null;if("html"===this._settings.textTrackOptions.textTrackMode&&null!==Re.htmlTextDisplayer?b=new Re.htmlTextDisplayer(l,this._settings.textTrackOptions.textTrackElement):null!==Re.nativeTextDisplayer&&(b=new Re.nativeTextDisplayer(l)),null!==b){var S=new xa(b);_=S,n.register((function(){S.stop(),null==b||b.stop()}))}var E=new Wr(d,"VIDEO"===l.nodeName,_);n.register((function(){E.disposeAll()}));var T=Ia({mediaElement:l,playbackObserver:c,startTime:s,mustAutoPlay:a,onWarning:function(e){i.trigger("warning",e)},isDirectfile:!1},n),k=T.autoPlayResult,w=T.initialPlayPerformed;if(!n.isCancelled()){w.onUpdate((function(e,t){if(e){t();var r=new Va(u,l,c);u.addEventListener("manifestUpdate",(function(){r.onManifestUpdate(u)}),n),r.addEventListener("event",(function(e){i.trigger("streamEvent",e)}),n),r.addEventListener("eventSkip",(function(e){i.trigger("streamEventSkip",e)}),n),r.start(),n.register((function(){r.stop()}))}}),{clearSignal:n,emitCurrentValue:!0});var A=Vi(c,{autoPlay:a,manifest:u,mediaSource:d,textDisplayer:b,initialPlayPerformed:w,speed:m},n),I=this._createRebufferingController(c,u,m,n),R=new Ta(E);c.listen((function(e){if(R.needToReload(e)){var n,r=c.getReference().getValue();n=r.position.isAwaitingFuturePosition()?r.position.getWanted():c.getCurrentTime();var i=w.getValue()?!c.getIsPaused():a;t({position:n,autoPlay:i})}}),{clearSignal:n}),A.listen((function(e){["video","audio","text"].forEach((function(t){var n,r=E.getStatus(t);"initialized"===r.type&&r.value.synchronizeInventory(null!==(n=e.buffered[t])&&void 0!==n?n:[])}))}),{clearSignal:n});var x=function(e,t,n,r,i,a){a.register((function(){t.interruptDurationSetting()}));var o=new Ui(e,n,r.getBufferTypes());a.register((function(){o.dispose()})),o.addEventListener("warning",(function(e){return i.onWarning(e)})),o.addEventListener("periodChange",(function(e){return i.onPeriodChanged(e)})),o.addEventListener("endingPositionChange",(function(e){t.setDuration(e.endingPosition,e.isEnd)})),o.addEventListener("endOfStream",(function(){oe.debug("Init: end-of-stream order received."),t.maintainEndOfStream()})),o.addEventListener("resumeStream",(function(){t.stopEndOfStream()}));var s=o.getCurrentEndingTime();return t.setDuration(s.endingPosition,s.isEnd),o}(u,d,A,E,{onWarning:function(e){return i.trigger("warning",e)},onPeriodChanged:function(e){return i.trigger("activePeriodChanged",{period:e})}},n);k.then((function(){Aa(c,l,!1,n).onUpdate((function(e,t){e&&(t(),i.trigger("loaded",{segmentBuffersStore:E}))}),{emitCurrentValue:!0,clearSignal:n})})).catch((function(e){n.isCancelled()||i._onFatalError(e)}));var C=this;Di({manifest:u,initialPeriod:g},A,v,E,h,o,{needsBufferFlush:function(e){var t,r,i=c.getCurrentTime(),a=null!==(t=null==e?void 0:e.relativeResumingPosition)&&void 0!==t?t:0,o=Boolean(null==e?void 0:e.relativePosHasBeenDefaulted);r=0===a&&o?i+.001:i+a,c.setCurrentTime(r),c.listen((function(e,t){(null!==e.currentRange||e.position.getPolled()>r+.1)&&(t(),c.setCurrentTime(e.position.getWanted()+.001))}),{includeLastObservation:!1,clearSignal:n})},streamStatusUpdate:function(e){var t=e.period,r=e.bufferType,i=e.imminentDiscontinuity,a=e.position;I.updateDiscontinuityInfo({period:t,bufferType:r,discontinuity:i,position:a}),n.isCancelled()||u.isLastPeriodKnown&&e.period.id===u.periods[u.periods.length-1].id&&(e.hasFinishedLoading||e.isEmptyStream?x.onLastSegmentFinishedLoading(e.bufferType):x.onLastSegmentLoadingResume(e.bufferType))},needsManifestRefresh:function(){return C._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync:function(){var e=p.getCurrent().OUT_OF_SYNC_MANIFEST_REFRESH_DELAY;C._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:e})},lockedStream:function(e){return I.onLockedStream(e.bufferType,e.period)},adaptationChange:function(e){C.trigger("adaptationChange",e),n.isCancelled()||x.onAdaptationChange(e.type,e.period,e.adaptation)},representationChange:function(e){C.trigger("representationChange",e),n.isCancelled()||x.onRepresentationChange(e.type,e.period)},inbandEvent:function(e){return C.trigger("inbandEvents",e)},warning:function(e){return C.trigger("warning",e)},periodStreamReady:function(e){return C.trigger("periodStreamReady",e)},periodStreamCleared:function(e){x.onPeriodCleared(e.type,e.period),n.isCancelled()||C.trigger("periodStreamCleared",e)},bitrateEstimateChange:function(e){return C.trigger("bitrateEstimateChange",e)},needsMediaSourceReload:function(e){var n,r,i,a=A.getReference().getValue(),o=a.position.isAwaitingFuturePosition()?a.position.getWanted():null!==(n=A.getCurrentTime())&&void 0!==n?n:a.position.getPolled(),s=null!==(i=null!==(r=a.paused.pending)&&void 0!==r?r:A.getIsPaused())&&void 0!==i?i:a.paused.last,u=o+e.timeOffset;void 0!==e.minimumPosition&&(u=Math.max(e.minimumPosition,u)),void 0!==e.maximumPosition&&(u=Math.min(e.maximumPosition,u)),t({position:u,autoPlay:!s})},needsDecipherabilityFlush:function(){var e,n,r,i,a,o=It(l);if(void 0===(a=null==o?void 0:o[0])||a.indexOf("widevine")<0){var s=A.getReference().getValue(),u=s.position.isAwaitingFuturePosition()?s.position.getWanted():null!==(e=A.getCurrentTime())&&void 0!==e?e:s.position.getPolled(),d=null!==(r=null!==(n=s.paused.pending)&&void 0!==n?n:A.getIsPaused())&&void 0!==r?r:s.paused.last;t({position:u,autoPlay:!d})}else{var f=A.getReference().getValue(),v=f.position.isAwaitingFuturePosition()?f.position.getWanted():null!==(i=A.getCurrentTime())&&void 0!==i?i:f.position.getPolled();v+.001<f.duration?c.setCurrentTime(l.currentTime+.001):c.setCurrentTime(v)}},encryptionDataEncountered:function(e){for(var t,r=Wa(e);!(t=r()).done;){var i=t.value;if(f.setValue(i),n.isCancelled())return}},error:function(e){return C._onFatalError(e)}},n)}},n._createRebufferingController=function(e,t,n,r){var i=this,a=new Ma(e,t,n);return a.addEventListener("stalled",(function(e){return i.trigger("stalled",e)})),a.addEventListener("unstalled",(function(){return i.trigger("unstalled",null)})),a.addEventListener("warning",(function(e){return i.trigger("warning",e)})),r.register((function(){return a.destroy()})),a.start(),a},t}(Oi);function Ha(e,t,n,r){e.updateRepresentationsDeciperability((function(e){var i=e.representation;if(void 0===i.contentProtections)return i.decipherable;var a=i.contentProtections.keyIds;if(void 0!==a)for(var o,s=Wa(a);!(o=s()).done;){for(var u,l=o.value,d=Wa(n);!(u=d()).done;){if(on(u.value,l.keyId))return!1}for(var c,f=Wa(t);!(c=f()).done;){if(on(c.value,l.keyId))return!0}for(var v,p=Wa(r);!(v=p()).done;){if(on(v.value,l.keyId))return}}return i.decipherable}))}function qa(e,t){e.updateRepresentationsDeciperability((function(e){var n,r,i=e.representation;if(!1===i.decipherable)return!1;for(var a,o,s=function(){var e=o.value;if((void 0===t.type||e.type===t.type)&&t.values.getFormattedValues().every((function(t){return e.values.some((function(e){return(void 0===t.systemId||e.systemId===t.systemId)&&on(e.data,t.data)}))})))return{v:!1}},u=Wa(null!==(r=null===(n=i.contentProtections)||void 0===n?void 0:n.initData)&&void 0!==r?r:[]);!(o=u()).done;)if(a=s())return a.v;return i.decipherable}))}var Ya=new Map;var Qa=new(function(){function e(){this._cachedCodecSupport=new Map}return e.prototype.isSupported=function(e,t){var n=(null!=e?e:"")+';codecs="'+(null!=t?t:"")+'"',r=this._cachedCodecSupport.get(n);if(void 0!==r)return r;this._cachedCodecSupport.size>=50&&this._cachedCodecSupport.clear();var i=function(e){if(null==Hi)return h&&oe.error("Compat: Cannot request codec support in a worker without MSE."),!1;if("function"==typeof Hi.isTypeSupported){var t=Ya.get(e);if(void 0!==t)return t;var n=Hi.isTypeSupported(e);return Ya.size>=200&&Ya.clear(),Ya.set(e,n),n}return!0}(n);return this._cachedCodecSupport.set(n,i),i},e}());function $a(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xa(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Xa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Za(e,t){for(var n,r=e,i=$a(t);!(n=i()).done;){var a=Ja(r,n.value);if(null===a)return null;r=a}return r}function Ja(e,t){var n=eo(e,t);return null!==n?e.subarray(n[1],n[2]):null}function eo(e,t){for(var n,r,i=e.length,a=0,o=0;a+8<=i;){if(o=sa(e,r=a),n=sa(e,r+=4),r+=4,0===o)o=i-a;else if(1===o){if(r+8>i)return null;o=ua(e,r),r+=8}if(o<0)throw new Error("ISOBMFF: Size out of range");if(n===t)return 1970628964===t&&(r+=16),[a,r,a+o];a+=o}return null}function to(e,t,n,r,i){for(var a,o=e.length,s=0;s<o;s+=a){var u=s;a=sa(e,u);var l=sa(e,u+=4);if(u+=4,0===a)a=o-s;else if(1===a){if(u+8>o)return;a=ua(e,u),u+=8}if(1970628964===l&&u+16<=o&&sa(e,u)===t&&sa(e,u+4)===n&&sa(e,u+8)===r&&sa(e,u+12)===i)return u+=16,e.subarray(u,s+a)}}function no(e){var t=e.length;if(t<8)return oe.warn("ISOBMFF: box inferior to 8 bytes, cannot find offsets"),null;var n=0,r=sa(e,n),i=sa(e,n+=4);if(n+=4,0===r)r=t;else if(1===r){if(n+8>t)return oe.warn("ISOBMFF: box too short, cannot find offsets"),null;r=ua(e,n),n+=8}if(r<0)throw new Error("ISOBMFF: Size out of range");return 1970628964===i&&(n+=16),[0,n,r]}function ro(e){var t=Ja(e,1836019558);return null===t?null:Ja(t,1953653094)}function io(e){var t=function(e,t){for(var n=[],r=e;;){var i=eo(r,t);if(null===i)return n;Xe(0!==i[2]&&r.length),n.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}(e,1836019558);return t.reduce((function(e,t){var n=Ja(t,1953653094);return null!==n&&e.push(n),e}),[])}function ao(e){return Ja(e,1835295092)}function oo(e,t){return void 0===t&&(t=0),Ja(e.subarray(t),1701671783)}var so=/^(?:[a-z]+:)?\/\//i,uo=/\/\.{1,2}\//;function lo(){var e=arguments.length;if(0===e)return"";for(var t="",n=0;n<e;n++){var r=n<0||arguments.length<=n?void 0:arguments[n];"string"==typeof r&&""!==r&&(so.test(r)?t=r:("/"===r[0]&&(r=r.substring(1)),"/"===t[t.length-1]&&(t=t.substring(0,t.length-1)),t=t+"/"+r))}return function(e){if(!uo.test(e))return e;for(var t=[],n=e.split("/"),r=0,i=n.length;r<i;r++)if(".."===n[r])t.pop();else{if("."===n[r])continue;t.push(n[r])}return t.join("/")}(t)}function co(e){var t=e.lastIndexOf("/");if(t<0)return e.length;if(so.test(e)){var n=e.indexOf("/");if(n>=0&&t===n+1)return e.length}var r=e.indexOf("?");return r>=0&&r<t?co(e.substring(0,r)):t+1}var fo="object"==typeof g&&"function"==typeof g.TextDecoder,vo="object"==typeof g&&"function"==typeof g.TextEncoder;function po(e){if(fo)try{return new TextDecoder("utf-16le").decode(e)}catch(e){var t=e instanceof Error?e:"";oe.warn("Utils: could not use TextDecoder to parse UTF-16LE, fallbacking to another implementation",t)}for(var n="",r=0;r<e.length;r+=2)n+=String.fromCharCode((e[r+1]<<8)+e[r]);return n}function ho(e){if(vo)try{return(new TextEncoder).encode(e)}catch(e){var t=e instanceof Error?e:"";oe.warn("Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation",t)}var n,r=encodeURIComponent(e);if("function"==typeof unescape)n=unescape(r);else{var i=/[0-9a-fA-F]/,a=r.length;n="";for(var o=0;o<r.length;o++){var s=!1;if("%"===r[o])if(o<=a-6&&"u"===r[o+1]&&i.test(r[o+2])&&i.test(r[o+3])&&i.test(r[o+4])&&i.test(r[o+5])){var u=parseInt(r.substring(o+1,o+6),16);n+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(r[o+1])&&i.test(r[o+2])){var l=parseInt(r.substring(o+1,o+3),16);n+=String.fromCharCode(l),s=!0,o+=2}s||(n+=r[o])}}for(var d=new Uint8Array(n.length),c=0;c<n.length;c++)d[c]=255&n.charCodeAt(c);return d}function mo(e,t){var n=e.toString(16);return n.length>=t?n:new Array(t-n.length+1).join("0")+n}function go(e){if(fo)try{return(new TextDecoder).decode(e)}catch(e){var t=e instanceof Error?e:"";oe.warn("Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation",t)}var n=e;239===n[0]&&187===n[1]&&191===n[2]&&(n=n.subarray(3));var r,i=function(e){for(var t="",n=0;n<e.length;n+=16e3){var r=e.subarray(n,n+16e3);t+=String.fromCharCode.apply(null,r)}return t}(n);if("function"==typeof escape)r=escape(i);else{var a=/[A-Za-z0-9*_\+-\.\/]/;r="";for(var o=0;o<i.length;o++)if(a.test(i[o]))r+=i[o];else{var s=i.charCodeAt(o);r+=s>=256?"%u"+mo(s,4):"%"+mo(s,2)}}return decodeURIComponent(r)}function yo(e){for(var t=e.length,n=new Uint8Array(t/2),r=0,i=0;r<t;r+=2,i++)n[i]=255&parseInt(e.substring(r,r+2),16);return n}function _o(e,t){void 0===t&&(t="");for(var n="",r=0;r<e.byteLength;r++)n+=(e[r]>>>4).toString(16),n+=(15&e[r]).toString(16),t.length>0&&r<e.byteLength-1&&(n+=t);return n}function bo(e){Xe(e.length);var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=new Uint8Array(16);return l[0]=i,l[1]=r,l[2]=n,l[3]=t,l[4]=o,l[5]=a,l[6]=u,l[7]=s,l.set(e.subarray(8,16),8),l}function So(e,t){for(var n=t;n<e.length;){if(0===e[n])break;n+=1}return{end:n+1,string:go(e.subarray(t,n))}}var Eo=Math.pow(2,32)-1,To={};function ko(e){if(null!=To[e])return To[e];var t=ho(e);return To[e]=t,t}function wo(e,t){var n=t.length+8;return n<=Eo?ia(da(n),ko(e),t):ia(da(1),ko(e),ca(n+8),t)}function Ao(e,t){return wo(e,ia.apply(void 0,t))}function Io(e){var t=[];e.periods.forEach((function(n){var r=n.id;if(Qe(t,r)){oe.warn("Two periods with the same ID found. Updating.");var i=r+"-dup";n.id=i,Io(e),t.push(i)}else t.push(r);var a=n.adaptations,o=[];Object.keys(a).forEach((function(t){var n=a[t];void 0!==n&&n.forEach((function(t){var n=t.id;if(Qe(o,n)){oe.warn("Two adaptations with the same ID found. Updating.",n);var r=n+"-dup";t.id=r,Io(e),o.push(r)}else o.push(n);var i=[];t.representations.forEach((function(t){var n=t.id;if(Qe(i,n)){oe.warn("Two representations with the same ID found. Updating.",n);var r=n+"-dup";t.id=r,Io(e),i.push(r)}else i.push(n)}))}))}))}))}var Ro=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],xo=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function Co(e){if(e>=xo.length)throw new Error("Unable to parse base64 string.");var t=xo[e];if(255===t)throw new Error("Unable to parse base64 string.");return t}function Mo(e){var t,n="",r=e.length;for(t=2;t<r;t+=3)n+=Ro[e[t-2]>>2],n+=Ro[(3&e[t-2])<<4|e[t-1]>>4],n+=Ro[(15&e[t-1])<<2|e[t]>>6],n+=Ro[63&e[t]];return t===r+1&&(n+=Ro[e[t-2]>>2],n+=Ro[(3&e[t-2])<<4],n+="=="),t===r&&(n+=Ro[e[t-2]>>2],n+=Ro[(3&e[t-2])<<4|e[t-1]>>4],n+=Ro[(15&e[t-1])<<2],n+="="),n}function Po(e){var t=e.length%4,n=e;0!==t&&(oe.warn("base64ToBytes: base64 given miss padding"),n+=3===t?"=":2===t?"==":"===");var r=n.indexOf("=");if(-1!==r&&r<n.length-2)throw new Error("Unable to parse base64 string.");for(var i,a=n.endsWith("==")?2:n.endsWith("=")?1:0,o=n.length,s=new Uint8Array(o/4*3),u=0,l=0;u<o;u+=4,l+=3)i=Co(n.charCodeAt(u))<<18|Co(n.charCodeAt(u+1))<<12|Co(n.charCodeAt(u+2))<<6|Co(n.charCodeAt(u+3)),s[l]=i>>16,s[l+1]=i>>8&255,s[l+2]=255&i;return s.subarray(0,s.length-a)}function Do(e){return[{systemId:"edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",privateData:ia([8,1,18,16],e)}]}function Oo(e,t){if(void 0===t&&(t=Do),null===e.firstElementChild||"ProtectionHeader"!==e.firstElementChild.nodeName)throw new Error("Protection should have ProtectionHeader child");var n=e.firstElementChild,r=Po(null===n.textContent?"":n.textContent),i=yo(function(e){var t,n,r=((t=e)[0+(n=8)]<<0)+(t[n+1]<<8),i=po(e.subarray(10,r+10)),a=(new DOMParser).parseFromString(i,"application/xml").querySelector("KID");if(null===a)throw new Error("Cannot parse PlayReady private data: invalid XML");return _o(bo(Po(null===a.textContent?"":a.textContent))).toLowerCase()}(r)),a=n.getAttribute("SystemID");return{keyId:i,keySystems:[{systemId:(null!==a?a:"").toLowerCase().replace(/\{|\}/g,""),privateData:r}].concat(t(i))}}function No(e,t,n){var r,i=e.repeatCount;return i>=0?i:(r=_(t)?void 0!==n?n:Number.MAX_VALUE:t.start,Math.ceil((r-e.start)/e.duration)-1)}function Lo(e,t,n){var r=e.start,i=e.duration;return i<=0?r:r+(No(e,t,n)+1)*i}function Uo(e,t){var n;return e*t.timescale+(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0)}function Bo(e,t){var n;return(e-(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0))/t.timescale}function Fo(e,t,n){var r=e.timeline,i=Uo(t,e);if(i<0)return null;var a=function(e,t){for(var n=0,r=e.length;n<r;){var i=n+r>>>1;e[i].start<=t?n=i+1:r=i}return n-1}(r,i);if(a<0||a>=r.length-1)return null;var o=r[a];if(o.duration<=0)return null;var s=r[a+1];if(void 0===s)return null;var u=s.start;return i>=Lo(o,s,n)&&i<u?Bo(u,e):null}function zo(e,t){return e.replace(/\{start time\}/g,String(t))}function Vo(e,t,n){var r=t-e;return r>0?Math.floor(r/n):0}function Ko(e,t){var n=e.repeatCount;if(void 0!==e.duration&&n<0){var r=void 0!==t?t.start:1/0;n=Math.ceil((r-e.start)/e.duration)-1}return n}var Wo=function(){function e(e){var t=e.isLive,n=e.segmentPrivateInfos,r=e.media,i=e.sharedSmoothTimeline;if(this._sharedSmoothTimeline=i,this._initSegmentInfos={bitsPerSample:n.bitsPerSample,channels:n.channels,codecPrivateData:n.codecPrivateData,packetSize:n.packetSize,samplingRate:n.samplingRate,timescale:i.timescale,height:n.height,width:n.width,protection:n.protection},this._isLive=t,this._media=r,0!==i.timeline.length&&t){var a=i.timeline,o=i.validityTime,s=Lo(a[a.length-1],null),u=o/1e3*i.timescale;this._scaledLiveGap=u-s}}var t=e.prototype;return t.getInitSegment=function(){return{id:"init",isInit:!0,privateInfos:{smoothInitSegment:this._initSegmentInfos},url:null,time:0,end:0,duration:0,timescale:1,complete:!0}},t.getSegments=function(e,t){this._refreshTimeline();for(var n,r=this._sharedSmoothTimeline,i=r.timescale,a=r.timeline,o=function(e,t,n){var r=void 0===e||0===e?1:e;return{up:t*r,to:(t+n)*r}}(i,e,t),s=o.up,u=o.to,l=this._media,d=[],c=a.length,f=void 0===this._scaledLiveGap?void 0:Me()/1e3*i-this._scaledLiveGap,v=0;v<c;v++){for(var p=a[v],h=p.duration,m=p.start,g=Ko(p,a[v+1]),y=Vo(m,s,h),_=m+y*h,b=h;_<u&&y<=g&&(void 0===f||_+b<=f);){var S=_,E=void 0!==n?n+y:void 0,T={id:String(_),isInit:!1,time:S/i,end:(S+h)/i,duration:h/i,timescale:1,number:E,url:zo(l,S),complete:!0,privateInfos:{smoothMediaSegment:{time:S,duration:h}}};d.push(T),_=m+ ++y*h}if(_>=u)return d;void 0!==n&&(n+=g+1)}return d},t.shouldRefresh=function(e,t){if(this._refreshTimeline(),!this._isLive)return!1;var n=this._sharedSmoothTimeline,r=n.timeline,i=n.timescale,a=r[r.length-1];if(void 0===a)return!1;var o=a.repeatCount,s=a.start+(o+1)*a.duration;return!(t*i<s)&&(e*i>=s||e*i>a.start+o*a.duration)},t.getFirstAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;return 0===t.length?null:t[0].start/n},t.getLastAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;if(void 0===this._scaledLiveGap)return Lo(t[t.length-1],null)/n;for(var r=t.length-1;r>=0;r--)for(var i=t[r],a=Me()/1e3*n,o=i.start,s=i.duration,u=i.repeatCount;u>=0;u--){var l=o+s*(u+1);if(l<=a-this._scaledLiveGap)return l/n}},t.getEnd=function(){if(!this._isLive)return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(e,t){var n;if(Xe(),this.isStillAwaitingFutureSegments())return!1;var r=this.getLastAvailablePosition();return!(void 0!==r&&t<r)&&(t>(null!==(n=this.getFirstAvailablePosition())&&void 0!==n?n:0)&&void 0)},t.checkDiscontinuity=function(e){return this._refreshTimeline(),Fo(this._sharedSmoothTimeline,e,void 0)},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline();for(var t=this._sharedSmoothTimeline,n=t.timeline,r=t.timescale,i=0;i<n.length;i++){var a=n[i],o=a.start/r;if(o>e.time)return!1;if(o===e.time)return!0;if(a.repeatCount>=0&&void 0!==a.duration){var s=(o-a.start)/a.duration-1;return s%1==0&&s<=a.repeatCount}}return!1},t.canBeOutOfSyncError=function(e){return!!this._isLive&&(e instanceof Ee&&(e.isHttpError(404)||e.isHttpError(412)))},t._replace=function(e){this._initialScaledLastPosition=e._initialScaledLastPosition,this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.replace(e._sharedSmoothTimeline)},t._update=function(e){this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.update(e._sharedSmoothTimeline)},t.isStillAwaitingFutureSegments=function(){return this._isLive},t.isInitialized=function(){return!0},t.initialize=function(){oe.error("A `SmoothRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(e,t){this._sharedSmoothTimeline.addPredictedSegments(e,t)},t._refreshTimeline=function(){this._sharedSmoothTimeline.refresh()},e}();function Go(e,t){for(var n=0;e.length>0;){var r=e[0];if(r.start>=t)return n;if(-1===r.repeatCount)return n;if(0===r.repeatCount)e.shift(),n+=1;else{var i=e[1];if(void 0!==i&&i.start<=t)e.shift(),n+=1;else{if(r.duration<=0)return n;for(var a=r.start+r.duration,o=1;a<t&&o<=r.repeatCount;)a+=r.duration,o++;if(!(o>r.repeatCount)){var s=r.repeatCount-o;return r.start=a,r.repeatCount=s,n+=o}e.shift(),n=r.repeatCount+1}}}return n}function jo(e,t){if(0===e.length)return e.push.apply(e,t),!0;if(0===t.length)return!1;var n=e.length,r=t[0].start;if(Lo(e[n-1],t[0])<r)throw new Se("MANIFEST_UPDATE_ERROR","Cannot perform partial update: not enough data");for(var i=n-1;i>=0;i--){var a=e[i].start;if(a===r){var o=n-i;return e.splice.apply(e,[i,o].concat(t)),!1}if(a<r){var s=e[i];if(s.start+s.duration>r)return oe.warn("RepresentationIndex: Manifest update removed all previous segments"),e.splice.apply(e,[0,n].concat(t)),!0;if(void 0===s.repeatCount||s.repeatCount<=0)return s.repeatCount<0&&(s.repeatCount=Math.floor((r-s.start)/s.duration)-1),e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1;if(s.start+s.duration*(s.repeatCount+1)<=r)return e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1;var u=(r-s.start)/s.duration-1;if(u%1==0&&s.duration===t[0].duration){var l=t[0].repeatCount<0?-1:t[0].repeatCount+u+1;return e.splice.apply(e,[i,n-i].concat(t)),e[i].start=s.start,e[i].repeatCount=l,!1}return oe.warn("RepresentationIndex: Manifest update removed previous segments"),e[i].repeatCount=Math.floor(u),e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1}}var d=e[e.length-1],c=t[t.length-1];return void 0!==d.repeatCount&&d.repeatCount<0?d.start>c.start?(oe.warn("RepresentationIndex: The new index is older than the previous one"),!1):(oe.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0):d.start+d.duration*(d.repeatCount+1)>=c.start+c.duration*(c.repeatCount+1)?(oe.warn("RepresentationIndex: The new index is older than the previous one"),!1):(oe.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0)}function Ho(e,t,n,r){var i=e[e.length-1],a=n.timescale===t?{time:n.time,duration:n.duration}:{time:n.time/n.timescale*t,duration:n.duration/n.timescale*t};return!(r.time===a.time)&&(a.time>=Lo(i,null)&&(i.duration===a.duration?i.repeatCount++:e.push({duration:a.duration,start:a.time,repeatCount:0}),!0))}var qo=function(){function e(e){var t=e.timeline,n=e.timescale,r=e.timeShiftBufferDepth,i=e.manifestReceivedTime;this.timeline=t,this.timescale=n;var a=null!=i?i:Me();if(this.validityTime=a,this._timeShiftBufferDepth=r,0!==t.length){var o=Lo(t[t.length-1],null);this._initialScaledLastPosition=o}}var t=e.prototype;return t.refresh=function(){if(void 0!==this._initialScaledLastPosition){var e=this._timeShiftBufferDepth,t=(Me()-this.validityTime)/1e3+this._initialScaledLastPosition/this.timescale;if(void 0!==e){var n=(t-e)*this.timescale;Go(this.timeline,n)}}},t.replace=function(e){var t=this.timeline,n=e.timeline,r=this.timescale,i=e.timescale;if(this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime,0!==t.length&&0!==n.length&&r===i){var a=t[t.length-1],o=n[n.length-1],s=Lo(o,null);if(!(Lo(a,null)<=s))for(var u=0;u<t.length;u++){var l=t[u],d=Lo(l,null);if(d===s)return void(this.timeline=this.timeline.concat(t.slice(u+1)));if(d>s){if(l.duration!==o.duration)return;var c=s-l.start;if(0===c)return oe.warn("Smooth Parser: a discontinuity detected in the previous manifest has been resolved."),void(this.timeline=this.timeline.concat(t.slice(u)));if(c<0||c%l.duration!=0)return;var f=c/l.duration-1,v=l.repeatCount-f;if(v<0)return;o.repeatCount+=v;var p=t.slice(u+1);return void(this.timeline=this.timeline.concat(p))}}}},t.update=function(e){jo(this.timeline,e.timeline),this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime},t.addPredictedSegments=function(e,t){var n;if(void 0!==(null===(n=t.privateInfos)||void 0===n?void 0:n.smoothMediaSegment)){this.refresh();for(var r=0;r<e.length;r++)Ho(this.timeline,this.timescale,e[r],t.privateInfos.smoothMediaSegment)}else oe.warn("Smooth Parser: should only encounter SmoothRepresentationIndex")},e}();function Yo(e,t,n){for(var r=e.firstElementChild,i=n;null!==r;)i=t(i,r.nodeName,r),r=r.nextElementSibling;return i}var Qo={audio:"audio/mp4",video:"video/mp4",text:"application/ttml+xml"},$o={AACL:"audio/mp4",AVC1:"video/mp4",H264:"video/mp4",TTML:"application/ttml+xml+mp4",DFXP:"application/ttml+xml+mp4"};var Xo=function(e){void 0===e&&(e={});var t=void 0===e.referenceDateTime?Date.UTC(1970,0,1,0,0,0,0)/1e3:e.referenceDateTime,n=void 0===e.minRepresentationBitrate?0:e.minRepresentationBitrate,r=e.serverSyncInfos,i=void 0!==r?r.serverTimestamp-r.clientTime:void 0;function a(e,t){var n=Yo(e,(function(e,t,n){return"CustomAttributes"===t&&e.push.apply(e,Yo(n,(function(e,t,n){if("Attribute"===t){var r=n.getAttribute("Name"),i=n.getAttribute("Value");null!==r&&null!==i&&e.push(r+"="+i)}return e}),[])),e}),[]);function r(t){var n=e.getAttribute(t);return null==n?void 0:n}switch(t){case"audio":var i=r("AudioTag"),a=r("BitsPerSample"),o=r("Channels"),s=r("CodecPrivateData"),u=r("FourCC"),l=r("PacketSize"),d=r("SamplingRate"),c=r("Bitrate"),f=void 0===c||isNaN(parseInt(c,10))?0:parseInt(c,10);if(void 0!==u&&void 0===$o[u]||void 0===s)return oe.warn("Smooth parser: Unsupported audio codec. Ignoring quality level."),null;var v=function(e,t){var n;return 0==(n="AACH"===t?5:y(e)?(248&parseInt(e.substring(0,2),16))>>3:2)?"mp4a.40.2":"mp4a.40."+n}(s,u);return{audiotag:void 0!==i?parseInt(i,10):i,bitrate:f,bitsPerSample:void 0!==a?parseInt(a,10):a,channels:void 0!==o?parseInt(o,10):o,codecPrivateData:s,codecs:v,customAttributes:n,mimeType:void 0!==u?$o[u]:u,packetSize:void 0!==l?parseInt(l,10):l,samplingRate:void 0!==d?parseInt(d,10):d};case"video":var p=r("CodecPrivateData"),h=r("FourCC"),m=r("MaxWidth"),g=r("MaxHeight"),_=r("Bitrate"),b=void 0===_||isNaN(parseInt(_,10))?0:parseInt(_,10);if(void 0!==h&&void 0===$o[h]||void 0===p)return oe.warn("Smooth parser: Unsupported video codec. Ignoring quality level."),null;var S=function(e){var t=/00000001\d7([0-9a-fA-F]{6})/.exec(e);return null!==t&&y(t[1])?"avc1."+t[1]:"avc1.4D401E"}(p);return{bitrate:b,customAttributes:n,mimeType:void 0!==h?$o[h]:h,codecPrivateData:p,codecs:S,width:void 0!==m?parseInt(m,10):void 0,height:void 0!==g?parseInt(g,10):void 0};case"text":var E=r("CodecPrivateData"),T=r("FourCC"),k=r("Bitrate");return{bitrate:void 0===k||isNaN(parseInt(k,10))?0:parseInt(k,10),customAttributes:n,mimeType:void 0!==T?$o[T]:T,codecPrivateData:null!=E?E:""};default:return oe.error("Smooth Parser: Unrecognized StreamIndex type: "+t),null}}function o(e){var t=e.root,r=e.timescale,i=e.baseUrl,o=e.protections,s=e.timeShiftBufferDepth,u=e.manifestReceivedTime,l=e.isLive,c=t.getAttribute("Timescale"),f=null===c||isNaN(+c)?r:+c,v=t.getAttribute("Type");if(null===v)throw new Error("StreamIndex without type.");Qe(zn,v)||oe.warn("Smooth Parser: Unrecognized adaptation type:",v);var p=v,h=t.getAttribute("Subtype"),m=t.getAttribute("Language"),g=t.getAttribute("Url"),_=null===g?"":g;var b,S=Yo(t,(function(e,t,r){switch(t){case"QualityLevel":var i=a(r,p);if(null===i)return e;("video"!==p||i.bitrate>n)&&e.qualityLevels.push(i);break;case"c":e.cNodes.push(r)}return e}),{qualityLevels:[],cNodes:[]}),E=S.qualityLevels,T=S.cNodes,k=new qo({timeline:(b=T,b.reduce((function(e,t,n){var r=t.getAttribute("d"),i=t.getAttribute("t"),a=t.getAttribute("r"),o=null!==a?+a-1:0,s=null!==i?+i:void 0,u=null!==r?+r:void 0;if(0===n)s=void 0===s||isNaN(s)?0:s;else{var l=e[n-1];if(null==s||isNaN(s)){if(null==l.duration||isNaN(l.duration))throw new Error("Smooth: Invalid CNodes. Missing timestamp.");s=l.start+l.duration*(l.repeatCount+1)}}if(null==u||isNaN(u)){var d=b[n+1];if(void 0===d)return e;var c=d.getAttribute("t"),f=y(c)?+c:null;if(null===f)throw new Error("Can't build index timeline from Smooth Manifest.");u=f-s}return e.push({duration:u,start:s,repeatCount:o}),e}),[])),timescale:f,timeShiftBufferDepth:s,manifestReceivedTime:u});Xe(E.length);var w=p+(y(m)?"_"+m:""),A=E.map((function(e){var t,n,r,a,s=(t=_,n=e.bitrate,r=e.customAttributes,t.replace(/\{bitrate\}/g,String(n)).replace(/{CustomAttributes}/g,r.length>0?r[0]:"")),u=y(e.mimeType)?e.mimeType:Qo[p],c=e.codecs,f=w+"_"+(null!=p?p+"-":"")+(null!=u?u+"-":"")+(null!=c?c+"-":"")+String(e.bitrate),v=[];o.length>0&&(a=o[0],o.forEach((function(e){var t=e.keyId;e.keySystems.forEach((function(e){v.push({keyId:t,systemId:e.systemId})}))})));var h={bitsPerSample:e.bitsPerSample,channels:e.channels,codecPrivateData:e.codecPrivateData,packetSize:e.packetSize,samplingRate:e.samplingRate,height:e.height,width:e.width,protection:null!=a?{keyId:a.keyId}:void 0},m=new Wo({isLive:l,sharedSmoothTimeline:k,media:s,segmentPrivateInfos:h}),g=d({},e,{index:m,cdnMetadata:[{baseUrl:i}],mimeType:u,codecs:c,id:f});if(v.length>0||void 0!==a){var b=void 0===a?[]:a.keySystems.map((function(e){var t=e.systemId,n=e.privateData,r=t.replace(/-/g,""),i=function(e,t){if(32!==e.length)throw new Error("HSS: wrong system id length");return wo("pssh",ia([0,0,0,0],yo(e),da(t.length),t))}(r,n);return{systemId:r,data:i}}));if(b.length>0){var S=[{type:"cenc",values:b}];g.contentProtections={keyIds:v,initData:S}}else g.contentProtections={keyIds:v,initData:[]}}return g}));if("ADVT"===h)return null;var I={id:w,type:p,representations:A,language:null==m?void 0:m};return"text"===p&&"DESC"===h&&(I.closedCaption=!0),I}return function(n,r,a){var s="";if(void 0!==r){var u=co(r);s=r.substring(0,u)}var l=n.documentElement;if(null==l||"SmoothStreamingMedia"!==l.nodeName)throw new Error("document root should be SmoothStreamingMedia");var d=l.getAttribute("MajorVersion"),c=l.getAttribute("MinorVersion");if(null===d||null===c||!/^[2]-[0-2]$/.test(d+"-"+c))throw new Error("Version should be 2.0, 2.1 or 2.2");var f,v,p=l.getAttribute("Timescale"),h=y(p)?isNaN(+p)?1e7:+p:1e7,m=Yo(l,(function(t,n,r){switch(n){case"Protection":t.protections.push(Oo(r,e.keySystems));break;case"StreamIndex":t.adaptationNodes.push(r)}return t}),{adaptationNodes:[],protections:[]}),g=m.protections,_=m.adaptationNodes,b="boolean"==typeof(f=l.getAttribute("IsLive"))?f:"string"==typeof f&&"TRUE"===f.toUpperCase();if(b){var S=l.getAttribute("DVRWindowLength");null==S||isNaN(+S)||0==+S||(v=+S/h)}var E,T,k,w,A,I,R,x=_.reduce((function(e,t){var n=o({root:t,baseUrl:s,timescale:h,protections:g,isLive:b,timeShiftBufferDepth:v,manifestReceivedTime:a});if(null===n)return e;var r=n.type,i=e[r];return void 0===i?e[r]=[n]:i.push(n),e}),{}),C=null,M=void 0!==x.video?x.video[0]:void 0,P=void 0!==x.audio?x.audio[0]:void 0;if(void 0!==M||void 0!==P){var D=[],O=[];if(void 0!==M){var N=M.representations[0];if(void 0!==N){var L=N.index.getFirstAvailablePosition(),U=N.index.getLastAvailablePosition();null!=L&&D.push(L),null!=U&&O.push(U)}}if(void 0!==P){var B=P.representations[0];if(void 0!==B){var F=B.index.getFirstAvailablePosition(),z=B.index.getLastAvailablePosition();null!=F&&D.push(F),null!=z&&O.push(z)}}D.length>0&&(A=Math.max.apply(Math,D)),O.length>0&&(I=Math.min.apply(Math,O),R=Math.max.apply(Math,O))}var V=l.getAttribute("Duration"),K=null!==V&&0!=+V?+V/h:void 0;if(b){E=e.suggestedPresentationDelay,T=t,k=null!=A?A:T;var W=R;void 0===W&&(W=Date.now()/1e3-T);var G=I;void 0===G&&(G=W),w={isLinear:!0,maximumSafePosition:G,livePosition:W,time:Me()},C=null!=v?v:null}else{k=null!=A?A:0,w={isLinear:!1,maximumSafePosition:void 0!==I?I:void 0!==K?k+K:1/0,livePosition:void 0,time:Me()}}var j=b?0:k,H=b?void 0:w.maximumSafePosition,q={availabilityStartTime:void 0===T?0:T,clockOffset:i,isLive:b,isDynamic:b,isLastPeriodKnown:!0,timeBounds:{minimumSafePosition:k,timeshiftDepth:C,maximumTimeData:w},periods:[{adaptations:x,duration:void 0!==H?H-j:K,end:H,id:"gen-smooth-period-0",start:j}],suggestedPresentationDelay:E,transportType:"smooth",uris:null==r?[]:[r]};return Io(q),q}},Zo=Xo;var Jo=function(e){var t={url:e.url,headers:e.headers,responseType:_(e.responseType)?"json":e.responseType,timeout:e.timeout,connectionTimeout:e.connectionTimeout};return new Promise((function(n,r){var i,a,o=e.onProgress,s=e.cancelSignal,u=t.url,l=t.headers,d=t.responseType,c=t.timeout,f=t.connectionTimeout,v=new XMLHttpRequest;if(v.open("GET",u,!0),void 0!==c&&(v.timeout=c,i=setTimeout((function(){b(),r(new pe(u,v.status,he.TIMEOUT))}),c+3e3)),void 0!==f&&(a=setTimeout((function(){b(),v.readyState!==XMLHttpRequest.DONE&&v.abort(),r(new pe(u,v.status,he.TIMEOUT))}),f)),v.responseType=d,"document"===v.responseType&&v.overrideMimeType("text/xml"),!_(l)){var p=l;for(var h in p)p.hasOwnProperty(h)&&v.setRequestHeader(h,p[h])}var m=Me(),g=null;function b(){void 0!==i&&clearTimeout(i),void 0!==a&&clearTimeout(a),null!==g&&g()}void 0!==s&&(g=s.register((function(e){b(),v.readyState!==XMLHttpRequest.DONE&&v.abort(),r(e)})),s.isCancelled())||(v.onerror=function(){b(),r(new pe(u,v.status,he.ERROR_EVENT))},v.ontimeout=function(){b(),r(new pe(u,v.status,he.TIMEOUT))},void 0!==f&&(v.onreadystatechange=function(){v.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(a)}),void 0!==o&&(v.onprogress=function(e){var t=Me();o({url:u,duration:t-m,sendingTime:m,currentTime:t,size:e.loaded,totalSize:e.total})}),v.onload=function(e){if(v.readyState===XMLHttpRequest.DONE)if(b(),v.status>=200&&v.status<300){var t,i=Me(),a=v.response instanceof ArrayBuffer?v.response.byteLength:e.total,o=v.status,s=v.responseType,l=y(v.responseURL)?v.responseURL:u;if(_(t="json"===s?"object"==typeof v.response?v.response:function(e){try{return JSON.parse(e)}catch(e){return null}}(v.responseText):v.response))return void r(new pe(u,v.status,he.PARSE_ERROR));n({status:o,url:l,responseType:s,sendingTime:m,receivedTime:i,requestDuration:i-m,size:a,responseData:t})}else r(new pe(u,v.status,he.ERROR_HTTP_CODE))},v.send())}))};function es(e,t){for(var n=e.length,r=0;r+8<=n;){var i=sa(e,r);if(0===i)i=n-r;else if(1===i){if(r+16>n)return-1;i=ua(e,r+8)}if(isNaN(i)||i<=0)return-1;if(sa(e,r+4)===t)return r+i<=n?r:-1;r+=i}return-1}function ts(e,t){if(t){if(es(e,1718909296)<0)throw new Te("INTEGRITY_ERROR","Incomplete `ftyp` box");if(es(e,1836019574)<0)throw new Te("INTEGRITY_ERROR","Incomplete `moov` box")}else{if(es(e,1836019558)<0)throw new Te("INTEGRITY_ERROR","Incomplete `moof` box");if(es(e,1835295092)<0)throw new Te("INTEGRITY_ERROR","Incomplete `mdat` box")}}function ns(e,t){var n=e.customManifestLoader,r=function(e){return function(t,n,r){if(void 0===t)throw new Error("Cannot perform HTTP(s) request. URL not known");switch(e){case"arraybuffer":return Jo({url:t,responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});case"text":return Jo({url:t,responseType:"text",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});case"document":return Jo({url:t,responseType:"document",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});default:Ze()}}}(t);return"function"!=typeof n?r:function(e,t){return function(n,r,i){return new Promise((function(a,o){var s=Date.now()-Me(),u=!1,l={reject:function(e){var t,n;if(!u&&!i.isCancelled()){u=!0,i.deregister(c);var r=e,a=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching the Manifest through a custom manifestLoader.",s=new tr(a,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);o(s)}},resolve:function(e){if(!u&&!i.isCancelled()){u=!0,i.deregister(c);var t=void 0!==e.receivingTime?e.receivingTime-s:void 0,n=void 0!==e.sendingTime?e.sendingTime-s:void 0;a({responseData:e.data,size:e.size,requestDuration:e.duration,url:e.url,receivedTime:t,sendingTime:n})}},fallback:function(){u||i.isCancelled()||(u=!0,i.deregister(c),t(n,r,i).then(a,o))}},d=e({url:n,timeout:r.timeout},l);function c(e){u||(u=!0,"function"==typeof d&&d(),o(e))}i.register(c)}))}}(n,r)}function rs(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return is(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return is(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function is(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function as(e,t){var n=eo(e,1936286840);if(null===n)return null;var r,i=t,a=n[2]-n[0],o=n[1],s=e[o],u=sa(e,o+=8);if(o+=4,0===s)r=sa(e,o),i+=sa(e,o+=4)+a,o+=4;else{if(1!==s)return null;r=ua(e,o),i+=ua(e,o+=8)+a,o+=8}var l=[],d=aa(e,o+=2);for(o+=2;--d>=0;){var c=sa(e,o);o+=4;var f=2147483647&c;if(1===(2147483648&c)>>>31)throw new Error("sidx with reference_type `1` not yet implemented");var v=sa(e,o);o+=4,o+=4,l.push({time:r,duration:v,timescale:u,range:[i,i+f-1]}),r+=v,i+=f}return l}function os(e){var t=Ja(e,1952868452);if(null!==t){var n=1,r=oa(t,n);if(n+=3,(8&r)>0)return n+=4,(1&r)>0&&(n+=8),(2&r)>0&&(n+=4),sa(t,n)}}function ss(e){var t=io(e);if(0!==t.length){for(var n,r=0,i=rs(t);!(n=i()).done;){var a=n.value,o=Ja(a,1953658222);if(null===o)return;var s=0;if(o[s]>1)return;var u=oa(o,s+=1);s+=3;var l=(256&u)>0,d=0;if(!l&&void 0===(d=os(a)))return;var c=(1&u)>0,f=(4&u)>0,v=(512&u)>0,p=(1024&u)>0,h=(2048&u)>0,m=sa(o,s);s+=4,c&&(s+=4),f&&(s+=4);for(var g=m,y=0;g-- >0;)l?(y+=sa(o,s),s+=4):y+=d,v&&(s+=4),p&&(s+=4),h&&(s+=4);r+=y}return r}}function us(e){var t=function(e){var t=Ja(e,1836019574);if(null===t)return null;var n=Ja(t,1953653099);return null===n?null:Ja(n,1835297121)}(e);if(null!==t){var n=Ja(t,1835296868);if(null!==n){var r=0,i=n[r];return r+=4,1===i?sa(n,r+16):0===i?sa(n,r+8):void 0}}}function ls(e){var t=e.length;if(t<4)throw new Error("Cannot update box length: box too short");var n=sa(e,0);if(0===n){if(t>Eo){var r=new Uint8Array(t+8);return r.set(da(1),0),r.set(e.subarray(4,8),4),r.set(ca(t+8),8),r.set(e.subarray(8,t),16),r}return e.set(da(t),0),e}if(1===n){if(t<16)throw new Error("Cannot update box length: box too short");return e.set(ca(t),8),e}if(t<=Eo)return e.set(da(t),0),e;var i=new Uint8Array(t+8);return i.set(da(1),0),i.set(e.subarray(4,8),4),i.set(ca(t+8),8),i.set(e.subarray(8,t),16),i}function ds(e,t,n,r,i){var a,o,s,u=[];if(i){var l=ro(e);null!==l?(s=function(e){var t=to(e,3565190898,3392751253,2387879627,2655430559);if(void 0===t)return[];for(var n=[],r=t[0],i=t[4],a=0;a<i;a++){var o=void 0,s=void 0;1===r?(s=ua(t,16*a+5),o=ua(t,16*a+5+8)):(s=sa(t,8*a+5),o=sa(t,8*a+5+4)),n.push({time:s,duration:o})}return n}(l),o=function(e){var t=to(e,1830656773,1121273062,2162299933,2952222642);if(void 0!==t)return{duration:ua(t,12),time:ua(t,4)}}(l)):oe.warn("smooth: could not find traf atom")}if(void 0!==s)for(var d=0;d<s.length;d++)u.push({time:s[d].time,duration:s[d].duration,timescale:n});if(void 0!==o)return{nextSegments:u,chunkInfos:{time:o.time/n,duration:o.duration/n},scaledSegmentTime:o.time};if(t||!r.complete)return{nextSegments:u,chunkInfos:null,scaledSegmentTime:void 0};var c=r.duration*n,f=Math.min(.9*n,c/4),v=ss(e),p=void 0!==(null===(a=r.privateInfos)||void 0===a?void 0:a.smoothMediaSegment)?r.privateInfos.smoothMediaSegment.time:Math.round(r.time*n);return{nextSegments:u,chunkInfos:void 0!==v&&Math.abs(v-c)<=f?{time:r.time,duration:v/n}:{time:r.time,duration:r.duration},scaledSegmentTime:p}}function cs(e){return"string"==typeof e&&e.indexOf("mp4")>=0}function fs(e,t){return wo("schm",ia(4,ho(e),da(t)))}function vs(e){return wo("frma",ho(e))}function ps(e){var t=[7,[e.length]];return wo("stsd",ia.apply(void 0,t.concat(e)))}function hs(e,t,n){return wo("tenc",ia(6,[e,t],n))}function ms(e,t,n,r,i){var a=[e,t,n];return void 0!==i&&a.push(wo("senc",i),function(e){if(0===e.length)return wo("saiz",new Uint8Array(0));var t=sa(e,0),n=sa(e,4),r=new Uint8Array(n+9);r.set(da(n),5);for(var i,a,o=9,s=8;s<e.length;)s+=8,2==(2&t)?(a=2,s+=6*(i=aa(e,s))+2):(i=0,a=0),r[o]=6*i+8+a,o++;return wo("saiz",r)}(i),function(e,t,n,r){return wo("saio",ia(4,[0,0,0,1],da(e.length+t.length+n.length+r.length+8+8+8+8)))}(r,e,t,n)),Ao("traf",a)}function gs(e,t){var n=eo(e,1836019558);if(null===n)throw new Error("Smooth: Invalid ISOBMFF given");var r=e.subarray(n[1],n[2]),i=function(e,t){var n=eo(e,t);return null!==n?e.subarray(n[0],n[2]):null}(r,1835427940),a=Ja(r,1953653094);if(null===a||null===i)throw new Error("Smooth: Invalid ISOBMFF given");var o=eo(a,1952868452),s=eo(a,1953658222);if(null===o||null===s)throw new Error("Smooth: Invalid ISOBMFF given");var u=a.subarray(o[0],o[2]),l=a.subarray(s[0],s[2]);u.set([0,0,0,1],o[1]-o[0]+4);var d=function(e){return wo("tfdt",ia([1,0,0,0],ca(e)))}(t),c=function(e,t){var n=(1&e[t+3])>0;if(n)return e;var r=new Uint8Array(e.length+4);return r.set(e.subarray(0,t+8),0),r[t+3]=1|r[t+3],r.set([0,0,0,0],t+8),r.set(e.subarray(t+8,e.length),t+12),ls(r)}(l,s[1]-s[0]),f=ms(u,d,c,i,to(a,2721664850,1520127764,2722393154,2086964724)),v=Ao("moof",[i,f]),p=eo(v,1836019558),h=eo(f,1953653094),m=eo(c,1953658222);if(null===p||null===h||null===m)throw new Error("Smooth: Invalid moof, trun or traf generation");var g=p[1]-p[0]+i.length+(h[1]-h[0])+u.length+d.length+(m[1]-m[0])+8,y=n[2]-n[0],_=v.length-y,b=eo(e,1835295092);if(null===b)throw new Error("Smooth: Invalid ISOBMFF given");if(!Q&&(0===_||_<=-8)){var S=b[1];return v.set(da(S),g),e.set(v,n[0]),_<=-8&&e.set(wo("free",new Uint8Array(-_-8)),v.length),e}var E=b[1]+_;v.set(da(E),g);var T=new Uint8Array(e.length+_),k=e.subarray(0,n[0]),w=e.subarray(n[2],e.length);return T.set(k,0),T.set(v,k.length),T.set(w,k.length+v.length),T}function ys(e){var t=e[0],n=e[1];return n===1/0?"bytes="+t+"-":"bytes="+t+"-"+n}function _s(e,t,n,r,i,a){var o,s,u=Ao("stbl",[n,wo("stts",new Uint8Array(8)),wo("stsc",new Uint8Array(8)),wo("stsz",new Uint8Array(12)),wo("stco",new Uint8Array(8))]),l=function(e){return wo("dref",ia(7,[1],e))}(wo("url ",new Uint8Array([0,0,0,1]))),d=Ao("dinf",[l]),c=Ao("minf",[r,d,u]),f=function(e){var t,n;switch(e){case"video":t="vide",n="VideoHandler";break;case"audio":t="soun",n="SoundHandler";break;default:t="hint",n=""}return wo("hdlr",ia(8,ho(t),12,ho(n),1))}(t),v=function(e){return wo("mdhd",ia(12,da(e),8))}(e),p=Ao("mdia",[v,f,c]),h=function(e,t,n){return wo("tkhd",ia(da(7),8,da(n),20,[1,0,0,0],[0,1,0,0],12,[0,1,0,0],12,[64,0,0,0],la(e),2,la(t),2))}(i,a,1),m=Ao("trak",[h,p]),g=Ao("mvex",[wo("trex",ia(4,da(1),[0,0,0,1],12))]),y=function(e,t){return wo("mvhd",ia(12,da(e),4,[0,1],2,[1,0],10,[0,1],14,[0,1],14,[64,0,0,0],26,la(t+1)))}(e,1),_=function(e,t,n){return Ao("moov",[e,t,n])}(y,g,m),b=(o="isom",s=["isom","iso2","iso6","avc1","dash"],wo("ftyp",ia.apply(void 0,[ho(o),[0,0,0,1]].concat(s.map(ho)))));return ia(b,_)}function bs(e,t,n,r,i,a,o,s){var u=o.split("00000001"),l=u[1],d=u[2];if(void 0===l||void 0===d)throw new Error("Smooth: unsupported codec private data.");var c,f,v=function(e,t,n){var r=2===n?1:4===n?3:0;return wo("avcC",ia([1,e[1],e[2],e[3],252|r,225],la(e.length),e,[1],la(t.length),t))}(yo(l),yo(d),a);if(void 0===s){var p=function(e,t,n,r,i,a,o){return wo("avc1",ia(6,la(1),16,la(e),la(t),la(n),2,la(r),6,[0,1,i.length],ho(i),31-i.length,la(a),[255,255],o))}(t,n,r,i,"AVC Coding",24,v);c=ps([p])}else{var h=Ao("schi",[hs(1,8,s)]),m=fs("cenc",65536),g=function(e,t,n,r,i,a,o,s){return wo("encv",ia(6,la(1),16,la(e),la(t),la(n),2,la(r),6,[0,1,i.length],ho(i),31-i.length,la(a),[255,255],o,s))}(t,n,r,i,"AVC Coding",24,v,Ao("sinf",[vs("avc1"),m,h]));c=ps([g])}return _s(e,"video",c,((f=new Uint8Array(12))[3]=1,wo("vmhd",f)),t,n)}var Ss=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function Es(e,t,n,r,i,a,o){var s,u,l=function(e,t){return wo("esds",ia(4,[3,25],la(e),[0,4,17,64,21],11,[5,2],yo(t),[6,1,2]))}(1,0===a.length?(s=i,u=t,_o(la((((63&2)<<4|31&Ss.indexOf(s))<<4|31&u)<<3))):a),d=function(){if(void 0===o){var e=function(e,t,n,r,i,a){return wo("mp4a",ia(6,la(e),8,la(t),la(n),2,la(r),la(i),2,a))}(1,t,n,r,i,l);return ps([e])}var a=Ao("schi",[hs(1,8,o)]),s=fs("cenc",65536),u=Ao("sinf",[vs("mp4a"),s,a]),d=function(e,t,n,r,i,a,o){return wo("enca",ia(6,la(e),8,la(t),la(n),2,la(r),la(i),2,a,o))}(1,t,n,r,i,l,u);return ps([d])}();return _s(e,"audio",d,wo("smhd",new Uint8Array(8)),0,0)}function Ts(e,t,n,r,i,a){var o,s=t.segment.range;return Array.isArray(s)&&(o={Range:ys(s)}),Jo({url:e,responseType:"arraybuffer",headers:o,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:n.onProgress}).then((function(e){if(!cs(t.mimeType)||!0!==a)return{resultType:"segment-loaded",resultData:e};var n=new Uint8Array(e.responseData);return ts(n,t.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},e),{responseData:n})}}))}var ks=function(e){var t=e.checkMediaSegmentIntegrity,n=e.segmentLoader;return function(e,r,i,a,o){var s=r.segment;if(s.isInit){if(void 0===s.privateInfos||void 0===s.privateInfos.smoothInitSegment)throw new Error("Smooth: Invalid segment format");var u,l=s.privateInfos.smoothInitSegment,d=l.codecPrivateData,c=l.timescale,f=l.height,v=l.width,p=l.protection,h=void 0===p?{keyId:void 0,keySystems:void 0}:p;if(void 0===d)throw new Error("Smooth: no codec private data.");switch(r.type){case"video":u=bs(c,null!=v?v:0,null!=f?f:0,72,72,4,d,h.keyId);break;case"audio":var m=l.channels,g=void 0===m?0:m,y=l.bitsPerSample,_=void 0===y?0:y,b=l.packetSize,S=void 0===b?0:b,E=l.samplingRate;u=Es(c,g,_,S,void 0===E?0:E,d,h.keyId);break;default:0,u=new Uint8Array(0)}return Promise.resolve({resultType:"segment-created",resultData:u})}return null===e?Promise.resolve({resultType:"segment-created",resultData:null}):"function"!=typeof n?Ts(e,r,o,i,a,t):new Promise((function(s,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a Smooth segment through a custom segmentLoader.",o=new tr(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(e){if(!d&&!a.isCancelled()){d=!0,a.deregister(p),cs(r.mimeType)&&!0===t||s({resultType:"segment-loaded",resultData:{responseData:e.data,size:e.size,requestDuration:e.duration}});var n=e.data instanceof Uint8Array?e.data:new Uint8Array(e.data);ts(n,r.segment.isInit),s({resultType:"segment-loaded",resultData:{responseData:n,size:e.size,requestDuration:e.duration}})}},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),Ts(e,r,o,i,a,t).then(s,u))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:e},v=n(f,c);function p(e){d||((d=!0)||"function"!=typeof v||v(),u(e))}a.register(p)}))}};function ws(e,t){return null===e?null:null===t.url?e.baseUrl:lo(e.baseUrl,t.url)}var As=function(e){var t=Zo(e),n=ks(e),r={loadManifest:ns({customManifestLoader:e.manifestLoader},"text"),parseManifest:function(n,r){var i,a=null!==(i=n.url)&&void 0!==i?i:r.originalUrl,o=n.receivedTime,s=n.responseData,u="string"==typeof s?(new DOMParser).parseFromString(s,"text/xml"):s,l=t(u,a,o),d=[];return{manifest:new Jn(l,{representationFilter:e.representationFilter},d),url:a,warnings:d}}},i={loadSegment:function(e,t,r,i,a){var o=ws(e,t.segment);return n(o,t,r,i,a)},parseSegment:function(e,t,n){var r,i,a=t.segment,o=e.data,s=e.isChunked;if(null===o)return a.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var u=o instanceof Uint8Array?o:new Uint8Array(o);if(a.isInit){var l=null===(i=null===(r=a.privateInfos)||void 0===r?void 0:r.smoothInitSegment)||void 0===i?void 0:i.timescale;return{segmentType:"init",initializationData:o,initializationDataSize:o.byteLength,initTimescale:l,protectionData:[]}}var d=void 0!==n?ds(u,s,n,a,t.isLive):null;if(null===d||null===d.chunkInfos||void 0===d.scaledSegmentTime)throw new Error("Smooth Segment without time information");var c=d.nextSegments,f=d.chunkInfos,v=gs(u,d.scaledSegmentTime),p=c.length>0?c:void 0;return{segmentType:"media",chunkData:v,chunkInfos:f,chunkOffset:0,chunkSize:v.length,protectionData:[],predictedSegments:p,appendWindow:[void 0,void 0]}}},a={loadSegment:function(t,n,r,i,a){var o=n.segment,s=ws(t,o);return o.isInit||null===s?Promise.resolve({resultType:"segment-created",resultData:null}):cs(n.mimeType)?Jo({url:s,responseType:"arraybuffer",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:a.onProgress}).then((function(t){if(!0!==e.checkMediaSegmentIntegrity)return{resultType:"segment-loaded",resultData:t};var r=new Uint8Array(t.responseData);return ts(r,n.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},t),{responseData:r})}})):Jo({url:s,responseType:"text",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:a.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))},parseSegment:function(e,t,n){var r,i,a,o=t.segment,s=t.language,u=t.mimeType,l=void 0===u?"":u,d=t.codecs,c=void 0===d?"":d,f=cs(t.mimeType),v=e.data,p=e.isChunked;if(o.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if(null===v)return{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var h,m,g,y,_=null;if(f){var b;i=(b="string"==typeof v?ho(v):v instanceof Uint8Array?v:new Uint8Array(v)).length;var S=void 0!==n?ds(b,p,n,o,t.isLive):null;a=null==S?void 0:S.nextSegments,null===(_=null!==(r=null==S?void 0:S.chunkInfos)&&void 0!==r?r:null)?p?oe.warn("Smooth: Unavailable time data for current text track."):(h=o.time,m=o.end):(h=_.time,m=void 0!==_.duration?_.time+_.duration:o.end);var E=c.toLowerCase();if("application/ttml+xml+mp4"===l||"stpp"===E||"stpp.ttml.im1t"===E)y="ttml";else{if("wvtt"!==E)throw new Error("could not find a text-track parser for the type "+l);y="vtt"}var T=ao(b);g=null===T?"":go(T)}else{var k;if(h=o.time,m=o.end,"string"!=typeof v){var w=v instanceof Uint8Array?v:new Uint8Array(v);i=w.length,k=go(w)}else k=v;switch(l){case"application/x-sami":case"application/smil":y="sami";break;case"application/ttml+xml":y="ttml";break;case"text/vtt":y="vtt"}if(void 0===y){if("srt"!==c.toLowerCase())throw new Error("could not find a text-track parser for the type "+l);y="srt"}g=k}return{segmentType:"media",chunkData:{type:y,data:g,start:h,end:m,language:s},chunkSize:i,chunkInfos:_,chunkOffset:null!=h?h:0,protectionData:[],predictedSegments:Array.isArray(a)&&a.length>0?a:void 0,appendWindow:[void 0,void 0]}}};return{manifest:r,audio:i,video:i,text:a}};function Is(e){void 0===e.transports.smooth&&(e.transports.smooth=As),e.mainThreadMediaSourceInit=ja,e.codecSupportProber=Qa}function Rs(e){var t=Date.parse(e)-Me();if(!isNaN(t))return t;oe.warn("DASH Parser: Invalid clock received: ",e)}function xs(e){for(var t=e.representations,n=null,r=0;r<t.length;r++){var i=t[r].index.getLastAvailablePosition();if(void 0===i)return;null!==i&&(n=null==n?i:Math.min(n,i))}return null===n?null:n}function Cs(e){for(var t=e.representations,n=null,r=0;r<t.length;r++){var i=t[r].index.getFirstAvailablePosition();if(void 0===i)return;null!==i&&(n=null==n?i:Math.max(n,i))}return null===n?null:n}function Ms(e){if(0===e.length)throw new Error("DASH Parser: no period available for a dynamic content");var t=function(e){for(var t=0;t<=e.length-1;t++){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,o=null;if(void 0!==r){var s=Cs(r);if(void 0===s)return;a=s}if(void 0!==i){var u=Cs(i);if(void 0===u)return;o=u}if(void 0!==r&&null===a||void 0!==i&&null===o)return void oe.info("Parser utils: found Period with no segment. ","Going to next one to calculate first position");if(null!==o)return null!==a?Math.max(a,o):o;if(null!==a)return a}}}(e),n=function(e){for(var t=e.length-1;t>=0;t--){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,o=null;if(void 0!==r){var s=xs(r);if(void 0===s)return{safe:void 0,unsafe:void 0};a=s}if(void 0!==i){var u=xs(i);if(void 0===u)return{safe:void 0,unsafe:void 0};o=u}if(void 0!==r&&null===a||void 0!==i&&null===o)return oe.info("Parser utils: found Period with no segment. ","Going to previous one to calculate last position"),{safe:void 0,unsafe:void 0};if(null!==o)return null!==a?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(null!==a)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}(e);return{minimumSafePosition:t,maximumSafePosition:n.safe,maximumUnsafePosition:n.unsafe}}var Ps=function(){function e(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=e.isDynamic&&void 0!==e.timeShiftBufferDepth?e.timeShiftBufferDepth:null,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}var t=e.prototype;return t.setLastPosition=function(e,t){this._lastPosition=e,this._positionTime=t},t.lastPositionIsKnown=function(){return this._isDynamic?null!=this._positionTime&&null!=this._lastPosition:null!=this._lastPosition},t.getEstimatedMinimumSegmentTime=function(){var e;if(!this._isDynamic||null===this._timeShiftBufferDepth)return 0;var t=null!==(e=this.getEstimatedLiveEdge())&&void 0!==e?e:this.getEstimatedMaximumPosition(0);return void 0!==t?t-this._timeShiftBufferDepth:void 0},t.getEstimatedLiveEdge=function(){if(this._isDynamic&&void 0!==this._serverTimestampOffset)return(Me()+this._serverTimestampOffset)/1e3-this._availabilityStartTime},t.getEstimatedMaximumPosition=function(e){if(!this._isDynamic)return this._lastPosition;var t=this.getEstimatedLiveEdge();return void 0!==t&&e!==1/0?t+e:void 0!==this._positionTime&&void 0!==this._lastPosition?Math.max(this._lastPosition-this._positionTime+Me()/1e3,0):this._lastPosition},e}();function Ds(e,t){return"function"==typeof Array.prototype.flatMap?e.flatMap(t):e.reduce((function(e,n){var r=t(n);return Array.isArray(r)?(e.push.apply(e,r),e):(e.push(r),e)}),[])}function Os(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ns(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ns(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ns(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ls=function(e,t){for(var n,r=Os(t);!(n=r()).done;)for(var i,a=n.value,o=a.adaptation,s=Os(a.trickModeAttachedAdaptationIds);!(i=s()).done;)for(var u,l=i.value,d=Os(zn);!(u=d()).done;){var c=e[u.value];if(void 0!==c)for(var f,v=Os(c);!(f=v()).done;){var p=f.value;p.id===l&&(void 0===p.trickModeTracks&&(p.trickModeTracks=[]),p.trickModeTracks.push(o))}}},Us=["subtitle","caption"];function Bs(e,t,n,r){function i(e,t){var n=e.split("/")[0];return Qe(zn,n)?n:"application/ttml+xml"===e||"application/mp4"===e&&null!=t&&null!=xe(t,(function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri&&Qe(Us,e.value)}))?"text":void 0}function a(e){switch(e.substring(0,3)){case"avc":case"hev":case"hvc":case"vp8":case"vp9":case"av1":return"video";case"vtt":return"text"}switch(e.substring(0,4)){case"mp4a":return"audio";case"wvtt":case"stpp":return"text"}}if(null!==t){var o=i(t,r);if(void 0!==o)return o}if(null!==n){var s=a(n);if(void 0!==s)return s}for(var u=0;u<e.length;u++){var l=e[u].attributes,d=l.mimeType,c=l.codecs;if(void 0!==d){var f=i(d,r);if(void 0!==f)return f}if(void 0!==c){var v=a(c);if(void 0!==v)return v}}}var Fs=/[, ]+/g;function zs(e,t){var n,r=e.initialization,i={};return void 0!==t&&(i.isEMSGWhitelisted=t),{id:"init",isInit:!0,time:0,end:0,duration:0,timescale:1,range:null!=r?r.range:void 0,indexRange:e.indexRange,url:null!==(n=null==r?void 0:r.url)&&void 0!==n?n:null,complete:!0,privateInfos:i,timestampOffset:-e.indexTimeOffset/e.timescale}}function Vs(e){return function(t,n,r){var i,a,o,s=y(r)?parseInt(r,10):1;return i=String(e),a=s,(o=i.toString()).length>=a?o:(new Array(a+1).join("0")+o).slice(-a)}}function Ks(e,t,n){return function(e,t,n){return-1===e.indexOf("$")?e:e.replace(/\$\$/g,"$").replace(/\$RepresentationID\$/g,String(t)).replace(/\$Bandwidth(\%0(\d+)d)?\$/g,Vs(void 0===n?0:n))}(e,t,n)}function Ws(e,t){return function(n){return-1===n.indexOf("$")?n:n.replace(/\$\$/g,"$").replace(/\$Number(\%0(\d+)d)?\$/g,(function(e,n,r){if(void 0===t)throw new Error("Segment number not defined in a $Number$ scheme");return Vs(t)(e,n,r)})).replace(/\$Time(\%0(\d+)d)?\$/g,(function(t,n,r){if(void 0===e)throw new Error("Segment time not defined in a $Time$ scheme");return Vs(e)(t,n,r)}))}}function Gs(e,t,n,r,i,a){for(var o,s,u,l=r.getEstimatedMaximumPosition(null!==(o=e.availabilityTimeOffset)&&void 0!==o?o:0),d=Math.min(t+n,null!=l?l:1/0),c=Uo(t,e),f=Uo(d,e),v=e.timeline,p=e.timescale,h=e.segmentUrlTemplate,m=e.startNumber,g=e.endNumber,y=null!=m?m:1,_=[],b=v.length,S=0;S<b;S++){var E=v[S],T=E.duration,k=E.start,w=E.range,A=void 0;A=void 0===l?i:Math.min(l*p,null!=i?i:1/0);for(var I=No(E,v[S+1],A),R=!1!==e.availabilityTimeComplete||S!==b-1&&0!==I,x=(s=T,u=void 0,(u=c-k)>0?Math.floor(u/s):0),C=k+x*T;C<f&&x<=I;){var M=y+x;if(void 0!==g&&M>g)break;var P=null===h?null:Ws(C,M)(h),D=C-e.indexTimeOffset,O=T;D<0&&(O=T+D,D=0);var N={id:String(C),time:D/p,end:(D+O)/p,duration:O/p,isInit:!1,range:w,timescale:1,url:P,number:M,timestampOffset:-e.indexTimeOffset/p,complete:R,privateInfos:{isEMSGWhitelisted:a}};_.push(N),C=k+ ++x*T}if(C>=f)return _;if(y+=I+1,void 0!==g&&y>g)return _}return _}function js(e,t){if(t.timescale!==e.timescale){var n=e.timescale;e.timeline.push({start:t.time/t.timescale*n,duration:t.duration/t.timescale*n,repeatCount:void 0===t.count?0:t.count,range:t.range})}else e.timeline.push({start:t.time,duration:t.duration,repeatCount:void 0===t.count?0:t.count,range:t.range});return!0}var Hs=function(){function e(e,t){var n,r,i,a=t.periodStart,o=t.periodEnd,s=t.representationId,u=t.representationBitrate,l=t.isEMSGWhitelisted,d=null!==(n=e.timescale)&&void 0!==n?n:1,c=(null!=e.presentationTimeOffset?e.presentationTimeOffset:0)-a*d,f=void 0===(null===(r=e.initialization)||void 0===r?void 0:r.media)?null:Ks(e.initialization.media,s,u),v=void 0===e.media?null:Ks(e.media,s,u),p=void 0!==e.initialization?e.initialization.range:void 0!==e.indexRange?[0,e.indexRange[0]-1]:void 0;this._index={indexRange:e.indexRange,indexTimeOffset:c,initialization:{url:f,range:p},segmentUrlTemplate:v,startNumber:e.startNumber,endNumber:e.endNumber,timeline:null!==(i=e.timeline)&&void 0!==i?i:[],timescale:d},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Uo(a,this._index),this._scaledPeriodEnd=null==o?void 0:Uo(o,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=l}var t=e.prototype;return t.getInitSegment=function(){return zs(this._index,this._isEMSGWhitelisted)},t.getSegments=function(e,t){return Gs(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)},t.shouldRefresh=function(){return!1},t.getFirstAvailablePosition=function(){var e=this._index;return 0===e.timeline.length?null:Bo(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)},t.getLastAvailablePosition=function(){var e,t=this._index.timeline;if(0===t.length)return null;var n=t[t.length-1];return Bo(Math.min(Lo(n,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)},t.getEnd=function(){return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(){return!1},t.isSegmentStillAvailable=function(){return!0},t.checkDiscontinuity=function(){return null},t.canBeOutOfSyncError=function(){return!1},t.isStillAwaitingFutureSegments=function(){return!1},t.isInitialized=function(){return this._isInitialized},t.initialize=function(e){if(!this._isInitialized){for(var t=0;t<e.length;t++)js(this._index,e[t]);this._isInitialized=!0}},t.addPredictedSegments=function(){oe.warn("Cannot add predicted segments to a `BaseRepresentationIndex`")},t._replace=function(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted},t._update=function(){oe.error("Base RepresentationIndex: Cannot update a SegmentList")},e}(),qs=function(){function e(e,t){var n,r;if(void 0===e.duration)throw new Error("Invalid SegmentList: no duration");var i=t.periodStart,a=t.periodEnd,o=t.representationId,s=t.representationBitrate,u=t.isEMSGWhitelisted;this._isEMSGWhitelisted=u,this._periodStart=i,this._periodEnd=a;var l=null!=e.presentationTimeOffset?e.presentationTimeOffset:0,d=null!==(n=e.timescale)&&void 0!==n?n:1,c=l-i*d,f=void 0===(null===(r=e.initialization)||void 0===r?void 0:r.media)?null:Ks(e.initialization.media,o,s),v=e.list.map((function(e){return{url:void 0===e.media?null:Ks(e.media,o,s),mediaRange:e.mediaRange}}));this._index={list:v,timescale:d,duration:e.duration,indexTimeOffset:c,indexRange:e.indexRange,initialization:null==e.initialization?void 0:{url:f,range:e.initialization.range}}}var t=e.prototype;return t.getInitSegment=function(){var e=zs(this._index);return void 0===e.privateInfos&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e},t.getSegments=function(e,t){for(var n=this._index,r=n.duration,i=n.list,a=n.timescale,o=r/a,s=function(e,t,n){return[e*n,(e+t)*n]}(e-this._periodStart,t,a),u=s[0],l=s[1],d=Math.min(i.length-1,Math.floor(l/r)),c=[],f=Math.floor(u/r);f<=d;){var v=i[f].mediaRange,p=i[f].url,h=f*o+this._periodStart,m={id:String(f),time:h,isInit:!1,range:v,duration:o,timescale:1,end:h+o,url:p,timestampOffset:-n.indexTimeOffset/a,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};c.push(m),f++}return c},t.shouldRefresh=function(e,t){return!1},t.getFirstAvailablePosition=function(){return this._periodStart},t.getLastAvailablePosition=function(){var e,t=this._index,n=t.duration,r=t.list;return Math.min(r.length*n/t.timescale+this._periodStart,null!==(e=this._periodEnd)&&void 0!==e?e:1/0)},t.getEnd=function(){return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(){return!1},t.isSegmentStillAvailable=function(){return!0},t.checkDiscontinuity=function(){return null},t.canBeOutOfSyncError=function(){return!1},t.isStillAwaitingFutureSegments=function(){return!1},t.isInitialized=function(){return!0},t.initialize=function(){oe.error("A `ListRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(){oe.warn("Cannot add predicted segments to a `ListRepresentationIndex`")},t._replace=function(e){this._index=e._index},t._update=function(){oe.error("A `ListRepresentationIndex` cannot be updated")},e}();function Ys(e){return p.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*e}function Qs(e,t,n){var r=e.start,i=e.duration,a=e.repeatCount;return void 0===r&&(null===t?r=0:_(t.duration)||(r=t.start+t.duration*(t.repeatCount+1))),void 0!==i&&!isNaN(i)||null===n||void 0===n.start||isNaN(n.start)||void 0===r||isNaN(r)||(i=n.start-r),void 0===r||isNaN(r)||void 0===i||isNaN(i)||void 0!==a&&isNaN(a)?(oe.warn('DASH: A "S" Element could not have been parsed.'),null):{start:r,duration:i,repeatCount:void 0===a?0:a}}function $s(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"t":var i=parseInt(r.value,10);isNaN(i)?oe.warn('DASH: invalid t ("'+r.value+'")'):t.start=i;break;case"d":var a=parseInt(r.value,10);isNaN(a)?oe.warn('DASH: invalid d ("'+r.value+'")'):t.duration=a;break;case"r":var o=parseInt(r.value,10);isNaN(o)?oe.warn('DASH: invalid r ("'+r.value+'")'):t.repeatCount=o}}return t}function Xs(e){for(var t=[],n=0;n<e.length;n++)t.push($s(e[n]));for(var r=[],i=0;i<t.length;i++){var a=Qs(t[i],void 0===r[r.length-1]?null:r[r.length-1],void 0===t[i+1]?null:t[i+1]);null!==a&&r.push(a)}return r}function Zs(e,t){var n,r=function(e,t){if(0===e.length||0===t.length)return null;var n=e[0].start,r=t[0].getAttribute("t"),i=null===r?null:parseInt(r,10);if(null===i||Number.isNaN(i))return null;if(n===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(n<i)for(var a=e[0],o=0;;){if(a.repeatCount>0){var s=i-a.start;if(s%a.duration==0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(++o>=e.length)return null;if((a=e[o]).start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}else for(var u=0,l=t[0],d=i;;){var c=l.getAttribute("d"),f=null===c?null:parseInt(c,10);if(null===f||Number.isNaN(f))return null;var v=l.getAttribute("r"),p=null===v?null:parseInt(v,10);if(null!==p){if(Number.isNaN(p)||p<0)return null;if(p>0){var h=n-d;if(h%f==0&&h/f<=p)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/f,prevSegmentsIdx:0,newElementsIdx:u}}d+=f*(p+1)}else d+=f;if(++u>=t.length)return null;var m=(l=t[u]).getAttribute("t"),g=null===m?null:parseInt(m,10);if(null!==g){if(Number.isNaN(g))return null;d=g}if(d===n)return{newElementsIdx:u,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(d>i)return null}}(t,e);if(null===r)return oe.warn('DASH: Cannot perform "based" update. Common segment not found.'),Xs(e);var i=r.prevSegmentsIdx,a=r.newElementsIdx,o=r.repeatNumberInPrevSegments,s=r.repeatNumberInNewElements,u=t.length-i+a-1;if(u>=e.length)return oe.info('DASH: Cannot perform "based" update. New timeline too short'),Xs(e);var l=t.slice(i);if(o>0){var d=l[0];d.start+=d.duration*o,l[0].repeatCount-=o}if(s>0&&0!==a)return oe.info('DASH: Cannot perform "based" update. The new timeline has a different form.'),Xs(e);var c=l[l.length-1],f=$s(e[u]),v=(null!==(n=f.repeatCount)&&void 0!==n?n:0)-s;if(f.duration!==c.duration||c.repeatCount>v)return oe.info('DASH: Cannot perform "based" update. The new timeline has a different form at the beginning.'),Xs(e);void 0!==f.repeatCount&&f.repeatCount>c.repeatCount&&(c.repeatCount=f.repeatCount);for(var p=[],h=[],m=u+1;m<e.length;m++)h.push($s(e[m]));for(var g=0;g<h.length;g++){var y=Qs(h[g],void 0===p[p.length-1]?c:p[p.length-1],void 0===h[g+1]?null:h[g+1]);null!==y&&p.push(y)}return l.concat(p)}var Js=function(){function e(t,n){var r,i,a;if(!e.isTimelineIndexArgument(t))throw new Error("The given index is not compatible with a TimelineRepresentationIndex.");var o=n.availabilityTimeComplete,s=n.availabilityTimeOffset,u=n.manifestBoundsCalculator,l=n.isDynamic,d=n.isLastPeriod,c=n.representationId,f=n.representationBitrate,v=n.periodStart,p=n.periodEnd,h=n.isEMSGWhitelisted,m=null!==(r=t.timescale)&&void 0!==r?r:1,g=(null!=t.presentationTimeOffset?t.presentationTimeOffset:0)-v*m;this._manifestBoundsCalculator=u,this._isEMSGWhitelisted=h,this._isLastPeriod=d,this._lastUpdate=null==n.receivedTime?Me():n.receivedTime,this._unsafelyBaseOnPreviousIndex=null,null!==n.unsafelyBaseOnPreviousRepresentation&&n.unsafelyBaseOnPreviousRepresentation.index instanceof e&&(n.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=n.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=l,this._parseTimeline=null!==(i=t.timelineParser)&&void 0!==i?i:null;var y,_=void 0===(null===(a=t.initialization)||void 0===a?void 0:a.media)?null:Ks(t.initialization.media,c,f),b=void 0===t.media?null:Ks(t.media,c,f);y=void 0===s&&void 0===o?1/0:null!=s?s:0,this._index={availabilityTimeComplete:null==o||o,availabilityTimeOffset:y,indexRange:t.indexRange,indexTimeOffset:g,initialization:null==t.initialization?void 0:{url:_,range:t.initialization.range},segmentUrlTemplate:b,startNumber:t.startNumber,endNumber:t.endNumber,timeline:void 0===t.timeline?null:eu(t.timeline,t.startNumber,t.endNumber),timescale:m},this._scaledPeriodStart=Uo(v,this._index),this._scaledPeriodEnd=void 0===p?void 0:Uo(p,this._index)}var t=e.prototype;return t.getInitSegment=function(){return zs(this._index,this._isEMSGWhitelisted)},t.getSegments=function(e,t){this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var n=this._index;return Gs({segmentUrlTemplate:n.segmentUrlTemplate,startNumber:n.startNumber,endNumber:n.endNumber,timeline:n.timeline,timescale:n.timescale,indexTimeOffset:n.indexTimeOffset},e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)},t.shouldRefresh=function(){return!1},t.getFirstAvailablePosition=function(){this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var e=this._index.timeline;return 0===e.length?null:Bo(Math.max(this._scaledPeriodStart,e[0].start),this._index)},t.getLastAvailablePosition=function(){var e;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=tu(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);return null===t?null:Bo(Math.min(t.end,null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)},t.getEnd=function(){var e;if(!this._isDynamic||this._isLastPeriod){if(this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;var t=this._index.timeline[this._index.timeline.length-1];return Bo(Math.min(Lo(t,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)}},t.awaitSegmentBetween=function(e,t){var n,r;if(Xe(),!this._isDynamic)return!1;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var i=this._index,a=i.timescale,o=i.timeline,s=Ys(a),u=Uo(t,this._index),l=tu(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(null!==l&&Math.min(l.end,null!==(n=this._scaledPeriodEnd)&&void 0!==n?n:1/0)+s>=Math.min(u,null!==(r=this._scaledPeriodEnd)&&void 0!==r?r:1/0))return!1;var d=Uo(e,this._index);if(o.length>0&&null!==l&&!l.isLastOfTimeline&&d<Lo(o[o.length-1],null,this._scaledPeriodEnd)+s+s)return!0;return!!this._isLastPeriod&&(void 0===this._scaledPeriodEnd?u+s>this._scaledPeriodStart&&void 0:d-s<this._scaledPeriodEnd&&u+s>this._scaledPeriodStart)},t.isSegmentStillAvailable=function(e){return!!e.isInit||(this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline()),function(e,t,n,r){var i=tu(t,n,r);if(null===i)return!1;for(var a=0;a<t.timeline.length;a++){if(i.timelineIdx<a)return!1;var o=t.timeline[a],s=(o.start-t.indexTimeOffset)/t.timescale;if(s>e.time)return!1;if(s===e.time)return void 0===o.range?void 0===e.range:null!=e.range&&o.range[0]===e.range[0]&&o.range[1]===e.range[1];if(o.repeatCount>=0&&void 0!==o.duration){var u=(s-o.start)/o.duration-1;return u%1==0&&u<=i.newRepeatCount}}return!1}(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))},t.checkDiscontinuity=function(e){this._refreshTimeline();var t=this._index.timeline;return null===t&&(t=this._getTimeline(),this._index.timeline=t),Fo({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)},t.canBeOutOfSyncError=function(e){return!!this._isDynamic&&(e instanceof Ee&&e.isHttpError(404))},t._replace=function(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod},t._update=function(e){null===this._index.timeline&&(this._index.timeline=this._getTimeline()),null===e._index.timeline&&(e._index.timeline=e._getTimeline()),jo(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.availabilityTimeOffset=e._index.availabilityTimeOffset,this._index.availabilityTimeComplete=e._index.availabilityTimeComplete,this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod},t.isStillAwaitingFutureSegments=function(){var e;if(!this._isDynamic)return!1;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=this._index.timeline;if(0===t.length){if(void 0!==this._scaledPeriodEnd){var n=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(void 0!==n&&Uo(n,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}var r=Ys(this._index.timescale),i=tu(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(null!==i&&!i.isLastOfTimeline){var a=Math.min(i.end,null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0);return!(void 0!==this._scaledPeriodEnd&&a+r>=this._scaledPeriodEnd)}return!!this._isLastPeriod&&(void 0===this._scaledPeriodEnd||Lo(t[t.length-1],null,this._scaledPeriodEnd)+r<this._scaledPeriodEnd)},t.isInitialized=function(){return!0},t.initialize=function(){oe.error("A `TimelineRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(){oe.warn("Cannot add predicted segments to a `TimelineRepresentationIndex`")},e.isTimelineIndexArgument=function(e){return"function"==typeof e.timelineParser||Array.isArray(e.timeline)},t._refreshTimeline=function(){if(null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._isDynamic){var e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(null!=e){var t=Uo(e,this._index),n=Go(this._index.timeline,t);void 0!==this._index.startNumber?this._index.startNumber+=n:void 0!==this._index.endNumber&&(this._index.startNumber=n+1)}}},t._getTimeline=function(){if(null===this._parseTimeline)return null!==this._index.timeline?this._index.timeline:(oe.error("DASH: Timeline already lazily parsed."),[]);var e=this._parseTimeline();this._parseTimeline=null;var t,n=p.getCurrent().MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY;return null===this._unsafelyBaseOnPreviousIndex||e.length<n?eu(Xs(e),this._index.startNumber,this._index.endNumber):(null===this._unsafelyBaseOnPreviousIndex._index.timeline?(t=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=t):t=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,eu(Zs(e,t),this._index.startNumber,this._index.endNumber))},e}();function eu(e,t,n){if(void 0===n)return e;for(var r=null!=t?t:1,i=0;i<e.length;i++){var a=e[i];if((r+=a.repeatCount+1)>n){if(r===n+1)return e.slice(0,i+1);var o=e.slice(0,i),s=Object.assign({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,n-u),o.push(s),o}}return e}function tu(e,t,n){if(e.timeline.length<=0)return null;if(e.availabilityTimeOffset===1/0){var r=e.timeline.length-1,i=e.timeline[r];return{isLastOfTimeline:!0,timelineIdx:r,newRepeatCount:i.repeatCount,end:Lo(i,null,n)}}var a=t.getEstimatedMaximumPosition(e.availabilityTimeOffset);if(void 0===a){var o=e.timeline.length-1,s=e.timeline[o];return{isLastOfTimeline:!0,timelineIdx:o,newRepeatCount:s.repeatCount,end:Lo(s,null,n)}}for(var u=e.timeline.length-1;u>=e.timeline.length;u--){var l=e.timeline[u],d=l.start+l.duration;if(Bo(d,e)<=a){if(Bo(Lo(l,e.timeline[u+1],n),e)<=a)return{isLastOfTimeline:u===e.timeline.length-1,timelineIdx:u,newRepeatCount:l.repeatCount,end:d};var c=Uo(a,e)-l.start,f=Math.floor(c/l.duration);return Xe(),{isLastOfTimeline:!1,timelineIdx:u,newRepeatCount:f-1,end:l.start+f*l.duration}}}return null}var nu=Js,ru=function(){function e(e,t){var n,r,i=t.availabilityTimeOffset,a=t.manifestBoundsCalculator,o=t.isDynamic,s=t.periodEnd,u=t.periodStart,l=t.representationId,d=t.representationBitrate,c=t.isEMSGWhitelisted,f=null!==(n=e.timescale)&&void 0!==n?n:1;this._availabilityTimeOffset=i,this._manifestBoundsCalculator=a;var v=null!=e.presentationTimeOffset?e.presentationTimeOffset:0,p=v-u*f;if(void 0===e.duration)throw new Error("Invalid SegmentTemplate: no duration");var h=void 0===(null===(r=e.initialization)||void 0===r?void 0:r.media)?null:Ks(e.initialization.media,l,d),m=void 0===e.media?null:Ks(e.media,l,d);this._index={duration:e.duration,timescale:f,indexRange:e.indexRange,indexTimeOffset:p,initialization:null==e.initialization?void 0:{url:h,range:e.initialization.range},url:m,presentationTimeOffset:v,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=o,this._periodStart=u,this._scaledRelativePeriodEnd=void 0===s?void 0:(s-u)*f,this._isEMSGWhitelisted=c}var t=e.prototype;return t.getInitSegment=function(){return zs(this._index,this._isEMSGWhitelisted)},t.getSegments=function(e,t){var n=this._index,r=n.duration,i=n.startNumber,a=n.endNumber,o=n.timescale,s=n.url,u=this._periodStart*o,l=this._scaledRelativePeriodEnd,d=e*o-u,c=(e+t)*o-u,f=this._getFirstSegmentStart(),v=this._getLastSegmentStart();if(null==f||null==v)return[];var p=Math.max(f,d),h=Math.min(v,c);if(h+r<=p)return[];for(var m=[],g=null!=i?i:1,y=Math.floor(p/r),_=y*r;_<=h;_+=r){var b=y+g;if(void 0!==a&&b>a)return m;var S=null!=l&&_+r>l?l-_:r,E=_+u,T=_+this._index.presentationTimeOffset,k=null===s?null:Ws(T,b)(s),w={id:String(b),number:b,time:E/o,end:(E+S)/o,duration:S/o,timescale:1,isInit:!1,scaledDuration:S/o,url:k,timestampOffset:-n.indexTimeOffset/o,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(w),y++}return m},t.getFirstAvailablePosition=function(){var e=this._getFirstSegmentStart();return null==e?e:e/this._index.timescale+this._periodStart},t.getLastAvailablePosition=function(){var e=this._getLastSegmentStart();if(_(e))return e;var t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,null!=t?t:1/0)/this._index.timescale+this._periodStart},t.getEnd=function(){if(!this._isDynamic)return this.getLastAvailablePosition();var e=this._estimateRelativeScaledEnd();if(void 0!==e){var t=this._index.timescale;return(e+this._periodStart*t)/t}},t.awaitSegmentBetween=function(e,t){if(Xe(),!this._isDynamic)return!1;var n=this._index.timescale,r=Ys(n),i=this._periodStart*n,a=e*n-i,o=t*n-i,s=this._getLastSegmentStart();if(_(s)){var u=this._estimateRelativeScaledEnd();return void 0===u?o+r>=0:o+r>=0&&a<u-r}var l=s+this._index.duration,d=this._estimateRelativeScaledEnd();return void 0===d?o>l-r:o>l-r&&a<d-r},t.shouldRefresh=function(){return!1},t.checkDiscontinuity=function(){return null},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;var t=this.getSegments(e.time,.1);return 0!==t.length&&(t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number)},t.canBeOutOfSyncError=function(){return!1},t.isStillAwaitingFutureSegments=function(){if(!this._isDynamic)return!1;var e=this._estimateRelativeScaledEnd();if(void 0===e)return!0;var t=this._index.timescale,n=this._getLastSegmentStart();return!!_(n)||n+this._index.duration+Ys(t)<e},t.isInitialized=function(){return!0},t.initialize=function(){oe.error("A `TemplateRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(){oe.warn("Cannot add predicted segments to a `TemplateRepresentationIndex`")},t._replace=function(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator},t._update=function(e){this._replace(e)},t._getFirstSegmentStart=function(){var e;if(!this._isDynamic)return 0;if(0===this._scaledRelativePeriodEnd||void 0===this._scaledRelativePeriodEnd){var t=this._manifestBoundsCalculator.getEstimatedMaximumPosition(null!==(e=this._availabilityTimeOffset)&&void 0!==e?e:0);if(void 0!==t&&t<this._periodStart)return null}var n=this._index,r=n.duration,i=n.timescale,a=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(void 0!==a){var o=a>this._periodStart?(a-this._periodStart)*i:0;return Math.floor(o/r)*r}},t._getLastSegmentStart=function(){var e,t,n=this._index,r=n.duration,i=n.timescale,a=n.endNumber,o=n.startNumber,s=void 0===o?1:o;if(this._isDynamic){var u=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(void 0!==u&&void 0!==this._scaledRelativePeriodEnd&&this._scaledRelativePeriodEnd<u-this._periodStart*this._index.timescale){var l=Math.ceil(this._scaledRelativePeriodEnd/r);return void 0!==a&&a-s+1<l&&(l=a-s+1),(l-1)*r}var d=this._manifestBoundsCalculator.getEstimatedMaximumPosition(null!==(e=this._availabilityTimeOffset)&&void 0!==e?e:0);if(void 0===d)return;var c=(d-this._periodStart)*i;if(c<0)return null;var f=Math.floor(c/r);return void 0!==a&&a-s+1<f&&(f=a-s+1),f<=0?null:(f-1)*r}var v=null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:0,h=Math.ceil(v/r);void 0!==a&&a-s+1<h&&(h=a-s+1);var m=(h-1)*r,g=p.getCurrent().MINIMUM_SEGMENT_SIZE*i;return void 0!==a||v-m>g||h<2?m:(h-2)*r},t._estimateRelativeScaledEnd=function(){var e,t;if(void 0!==this._index.endNumber){var n=this._index.endNumber-(null!==(e=this._index.startNumber)&&void 0!==e?e:1)+1;return Math.max(Math.min(n*this._index.duration,null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:1/0),0)}if(void 0!==this._scaledRelativePeriodEnd)return Math.max(this._scaledRelativePeriodEnd,0)},e}();function iu(e,t){var n;if(0===t.length)return e;var r=t.map((function(e){return{url:e.value}}));if(0===e.length)return r;for(var i=[],a=0;a<e.length;a++)for(var o=e[a],s=0;s<r.length;s++){var u=r[s],l=lo(o.url,u.url);i.push({url:l,serviceLocation:null!==(n=u.serviceLocation)&&void 0!==n?n:o.serviceLocation})}return i}function au(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ou(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ou(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ou(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function su(e){var t=e.adaptationProfiles,n=e.essentialProperties,r=e.supplementalProperties,i=e.manifestProfiles,a=e.codecs;if(-1!==((null!=t?t:"")+(null!=i?i:"")).indexOf("http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10")&&("hvc1.2.4.L153.B0"===a||"hev1.2.4.L153.B0"===a))return{colorDepth:10,eotf:"pq",colorSpace:"rec2020"};var o=xe([].concat(null!=n?n:[],null!=r?r:[]),(function(e){return"urn:mpeg:mpegB:cicp:TransferCharacteristics"===e.schemeIdUri}));if(void 0!==o)switch(o.value){case"15":return;case"16":return{eotf:"pq"};case"18":return{eotf:"hlg"}}return void 0!==a&&/^vp(08|09|10)/.exec(a)?function(e){var t,n,r,i=e.split("."),a=i[0],o=(i[1],i[2],i[3]),s=(i[4],i[5]),u=i[6],l=i[7];if(("vp08"===a||"vp09"===a||"vp10"===a)&&((void 0!==o&&"10"===o||"12"===o)&&(t=parseInt(o,10)),void 0!==u&&("16"===u?n="pq":"18"===u&&(n="hlg")),void 0!==s&&void 0!==l&&"09"===s&&"09"===l&&(r="rec2020"),void 0!==t&&void 0!==n))return{colorDepth:t,eotf:n,colorSpace:r}}(a):void 0}function uu(e,t,n){for(var r,i,a,o,s,u,l=[],c=function(){for(var e=u.value,c=void 0!==e.attributes.id?e.attributes.id:String(e.attributes.bitrate)+(void 0!==e.attributes.height?"-"+e.attributes.height:"")+(void 0!==e.attributes.width?"-"+e.attributes.width:"")+(void 0!==e.attributes.mimeType?"-"+e.attributes.mimeType:"")+(void 0!==e.attributes.codecs?"-"+e.attributes.codecs:"");l.some((function(e){return e.id===c}));)c+="-dup";var f,v=null!==(i=null===(r=n.unsafelyBaseOnPreviousAdaptation)||void 0===r?void 0:r.getRepresentation(c))&&void 0!==i?i:null,p=function(e,t){var n=[];if(void 0!==e.children.inbandEventStreams&&n.push.apply(n,e.children.inbandEventStreams),void 0!==t.children.inbandEventStreams&&n.push.apply(n,t.children.inbandEventStreams),0!==n.length)return n}(e,t),h=null!==(a=e.attributes.availabilityTimeComplete)&&void 0!==a?a:n.availabilityTimeComplete;void 0===e.attributes.availabilityTimeOffset&&void 0===n.availabilityTimeOffset||(f=(null!==(o=e.attributes.availabilityTimeOffset)&&void 0!==o?o:0)+(null!==(s=n.availabilityTimeOffset)&&void 0!==s?s:0));var m,g=function(e,t){var n,r,i,a=t.availabilityTimeOffset,o=t.manifestBoundsCalculator,s=t.isDynamic,u=t.end,l=t.start,c=t.receivedTime,f=t.unsafelyBaseOnPreviousRepresentation,v=t.inbandEventStreams,p={availabilityTimeComplete:void 0,availabilityTimeOffset:a,unsafelyBaseOnPreviousRepresentation:f,isEMSGWhitelisted:function(e){return void 0!==v&&v.some((function(t){return t.schemeIdUri===e.schemeIdUri}))},isLastPeriod:t.isLastPeriod,manifestBoundsCalculator:o,isDynamic:s,periodEnd:u,periodStart:l,receivedTime:c,representationBitrate:e.attributes.bitrate,representationId:e.attributes.id};if(void 0!==e.children.segmentBase){var h=e.children.segmentBase;i=new Hs(h,p)}else if(void 0!==e.children.segmentList){var m=e.children.segmentList;i=new qs(m,p)}else if(void 0!==e.children.segmentTemplate||t.parentSegmentTemplates.length>0){var g=t.parentSegmentTemplates.slice(),y=e.children.segmentTemplate;void 0!==y&&g.push(y);var _=d.apply(void 0,[{}].concat(g));void 0===_.availabilityTimeOffset&&void 0===t.availabilityTimeOffset||(p.availabilityTimeOffset=(null!==(n=_.availabilityTimeOffset)&&void 0!==n?n:0)+(null!==(r=t.availabilityTimeOffset)&&void 0!==r?r:0)),i=nu.isTimelineIndexArgument(_)?new nu(_,p):new ru(_,p)}else{var b=t.adaptation.children;if(void 0!==b.segmentBase){var S=b.segmentBase;i=new Hs(S,p)}else if(void 0!==b.segmentList){var E=b.segmentList;i=new qs(E,p)}else i=new ru({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:""},p)}return i}(e,d({},n,{availabilityTimeOffset:f,availabilityTimeComplete:h,unsafelyBaseOnPreviousRepresentation:v,adaptation:t,inbandEventStreams:p}));void 0===e.attributes.bitrate?(oe.warn("DASH: No usable bitrate found in the Representation."),m=0):m=e.attributes.bitrate;var _,b,S,E=iu(n.baseURLs,e.children.baseURLs),T={bitrate:m,cdnMetadata:0===E.length?[{baseUrl:"",id:void 0}]:E.map((function(e){return{baseUrl:e.url,id:e.serviceLocation}})),index:g,id:c};void 0!==e.children.supplementalProperties&&xe(e.children.supplementalProperties,(function(e){return"tag:dolby.com,2018:dash:EC3_ExtensionType:2018"===e.schemeIdUri&&"JOC"===e.value}))&&(T.isSpatialAudio=!0),void 0!==e.attributes.codecs?_=e.attributes.codecs:void 0!==t.attributes.codecs&&(_=t.attributes.codecs),void 0!==_&&(_="mp4a.40.02"===_?"mp4a.40.2":_,T.codecs=_),void 0!==e.attributes.supplementalCodecs?b=e.attributes.supplementalCodecs:void 0!==t.attributes.supplementalCodecs&&(b=t.attributes.supplementalCodecs),void 0!==b&&(T.supplementalCodecs=y(S=b)?S.trim().replace(Fs,", "):""),void 0!==e.attributes.frameRate?T.frameRate=e.attributes.frameRate:void 0!==t.attributes.frameRate&&(T.frameRate=t.attributes.frameRate),void 0!==e.attributes.height?T.height=e.attributes.height:void 0!==t.attributes.height&&(T.height=t.attributes.height),void 0!==e.attributes.mimeType?T.mimeType=e.attributes.mimeType:void 0!==t.attributes.mimeType&&(T.mimeType=t.attributes.mimeType),void 0!==e.attributes.width?T.width=e.attributes.width:void 0!==t.attributes.width&&(T.width=t.attributes.width);var k=void 0!==t.children.contentProtections?t.children.contentProtections:[];if(void 0!==e.children.contentProtections&&k.push.apply(k,e.children.contentProtections),k.length>0){var w=k.reduce((function(e,t){var n;if(void 0!==t.attributes.schemeIdUri&&"urn:uuid:"===t.attributes.schemeIdUri.substring(0,9)&&(n=t.attributes.schemeIdUri.substring(9).replace(/-/g,"").toLowerCase()),void 0!==t.attributes.keyId&&t.attributes.keyId.length>0){var r={keyId:t.attributes.keyId,systemId:n};void 0===e.keyIds?e.keyIds=[r]:e.keyIds.push(r)}if(void 0!==n){for(var i,a=[],o=au(t.children.cencPssh);!(i=o()).done;){var s=i.value;a.push({systemId:n,data:s})}if(a.length>0){var u,l=xe(e.initData,(function(e){return"cenc"===e.type}));if(void 0===l)e.initData.push({type:"cenc",values:a});else(u=l.values).push.apply(u,a)}}return e}),{keyIds:void 0,initData:[]});(Object.keys(w.initData).length>0||void 0!==w.keyIds&&w.keyIds.length>0)&&(T.contentProtections=w)}T.hdrInfo=su({adaptationProfiles:t.attributes.profiles,supplementalProperties:t.children.supplementalProperties,essentialProperties:t.children.essentialProperties,manifestProfiles:n.manifestProfiles,codecs:_}),l.push(T)},f=au(e);!(u=f()).done;)c();return l}function lu(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return du(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return du(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function du(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function cu(e){if(void 0===e)return!1;var t="urn:tva:metadata:cs:AudioPurposeCS:2007"===e.schemeIdUri&&"1"===e.value,n="urn:mpeg:dash:role:2011"===e.schemeIdUri&&"description"===e.value;return t||n}function fu(e,t){if(void 0!==e&&e.some((function(e){return"urn:tva:metadata:cs:AudioPurposeCS:2007"===e.schemeIdUri&&"2"===e.value})))return!0;if(void 0!==t&&t.some((function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri&&"caption"===e.value})))return!0;return!1}function vu(e){return void 0!==e&&("urn:mpeg:dash:role:2011"===e.schemeIdUri&&"sign"===e.value)}function pu(e,t){if(y(e.attributes.id))return e.attributes.id;var n=t.isClosedCaption,r=t.isForcedSubtitle,i=t.isAudioDescription,a=t.isSignInterpreted,o=t.isTrickModeTrack,s=t.type;return y(e.attributes.language)&&(s+="-"+e.attributes.language),!0===n&&(s+="-cc"),!0===r&&(s+="-cc"),!0===i&&(s+="-ad"),!0===a&&(s+="-si"),o&&(s+="-trickMode"),y(e.attributes.contentType)&&(s+="-"+e.attributes.contentType),y(e.attributes.codecs)&&(s+="-"+e.attributes.codecs),y(e.attributes.mimeType)&&(s+="-"+e.attributes.mimeType),void 0!==e.attributes.frameRate&&(s+="-"+String(e.attributes.frameRate)),s}function hu(e){if(null!=e.children.supplementalProperties)for(var t,n=lu(e.children.supplementalProperties);!(t=n()).done;){var r=t.value;if("urn:mpeg:dash:adaptation-set-switching:2016"===r.schemeIdUri&&null!=r.value)return r.value.split(",").map((function(e){return e.trim()})).filter((function(e){return e}))}return[]}function mu(e,t){var n=t[1].priority-e[1].priority;return 0!==n?n:e[1].isMainAdaptation!==t[1].isMainAdaptation?e[1].isMainAdaptation?-1:1:e[1].indexInMpd-t[1].indexInMpd}function gu(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return yu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yu(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function yu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var _u=Je();function bu(e,t){var n,r,i,a,o=[],s=function(e,t){var n=[];return e.forEach((function(r,i){var a,o;if(null!=r.attributes.start)a=r.attributes.start;else if(0===i)a=t.isDynamic&&null!=t.availabilityStartTime?t.availabilityStartTime:0;else{var s=n[n.length-1];if(null==s||null==s.periodEnd)throw new Error("Missing start time when parsing periods.");a=s.periodEnd}var u=e[i+1];null!=r.attributes.duration?o=r.attributes.duration:i===e.length-1?o=t.duration:null!=u.attributes.start&&(o=u.attributes.start-a);var l=null!=o?a+o:void 0;n.push({periodStart:a,periodDuration:o,periodEnd:l})})),n}(e,t);if(s.length!==e.length)throw new Error("MPD parsing error: the time information are incoherent.");var u=t.isDynamic,l=t.manifestBoundsCalculator;u||_(t.duration)||l.setLastPosition(t.duration);for(var d=function(){var d,f=c===e.length-1,v=e[c],p=t.xlinkInfos.get(v),m=iu(t.baseURLs,v.children.baseURLs),g=s[c],b=g.periodStart,E=g.periodDuration,T=g.periodEnd;for(_(v.attributes.id)?(oe.warn("DASH: No usable id found in the Period. Generating one."),d="gen-dash-period-"+_u()):d=v.attributes.id;o.some((function(e){return e.id===d}));)d+="-dup";var k=void 0!==p?p.receivedTime:t.receivedTime,w=null!==(r=null===(n=t.unsafelyBaseOnPreviousManifest)||void 0===n?void 0:n.getPeriod(d))&&void 0!==r?r:null,A=v.attributes.availabilityTimeComplete,I=v.attributes.availabilityTimeOffset,R=t.manifestProfiles,x=v.children.segmentTemplate,C={availabilityTimeComplete:A,availabilityTimeOffset:I,baseURLs:m,manifestBoundsCalculator:l,end:T,isDynamic:u,isLastPeriod:f,manifestProfiles:R,receivedTime:k,segmentTemplate:x,start:b,unsafelyBaseOnPreviousPeriod:w},M=function(e,t){for(var n,r,i,a,o,s,u,l={video:[],audio:[],text:[]},d=[],c={},f=[],v=0;v<e.length;v++){var p=e[v],h=p.children,m=h.essentialProperties,g=h.roles,_=h.label,b=Array.isArray(g)&&g.some((function(e){return"main"===e.value}))&&g.some((function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri})),E=p.children.representations,T=null!==(n=p.attributes.availabilityTimeComplete)&&void 0!==n?n:t.availabilityTimeComplete,k=void 0;void 0===p.attributes.availabilityTimeOffset&&void 0===t.availabilityTimeOffset||(k=(null!==(r=p.attributes.availabilityTimeOffset)&&void 0!==r?r:0)+(null!==(i=t.availabilityTimeOffset)&&void 0!==i?i:0));var w=p.attributes.mimeType,A=p.attributes.codecs,I=Bs(E,y(w)?w:null,y(A)?A:null,null!=h.roles?h.roles:null);if(void 0!==I){var R=null!==(a=p.attributes.selectionPriority)&&void 0!==a?a:1,x=p.attributes.id,C=hu(p),M=[];void 0!==t.segmentTemplate&&M.push(t.segmentTemplate),void 0!==p.children.segmentTemplate&&M.push(p.children.segmentTemplate);var P={availabilityTimeComplete:T,availabilityTimeOffset:k,baseURLs:iu(t.baseURLs,h.baseURLs),manifestBoundsCalculator:t.manifestBoundsCalculator,end:t.end,isDynamic:t.isDynamic,isLastPeriod:t.isLastPeriod,manifestProfiles:t.manifestProfiles,parentSegmentTemplates:M,receivedTime:t.receivedTime,start:t.start,unsafelyBaseOnPreviousAdaptation:null},D=Array.isArray(m)?xe(m,(function(e){return"http://dashif.org/guidelines/trickmode"===e.schemeIdUri})):void 0,O=null===(o=null==D?void 0:D.value)||void 0===o?void 0:o.split(" "),N=void 0!==O,L=h.accessibilities,U=void 0;void 0!==g&&g.some((function(e){return"dub"===e.value}))&&(U=!0);var B=void 0;B="text"===I&&fu(L,g);var F=void 0;"text"===I&&void 0!==g&&g.some((function(e){return"forced-subtitle"===e.value||"forced_subtitle"===e.value}))&&(F=!0);var z=void 0;"audio"!==I?z=!1:void 0!==L&&(z=L.some(cu));var V=void 0;"video"!==I?V=!1:void 0!==L&&(V=L.some(vu));for(var K=pu(p,{isAudioDescription:z,isForcedSubtitle:F,isClosedCaption:B,isSignInterpreted:V,isTrickModeTrack:N,type:I});Qe(f,K);)K+="-dup";var W=K;f.push(K),P.unsafelyBaseOnPreviousAdaptation=null!==(u=null===(s=t.unsafelyBaseOnPreviousPeriod)||void 0===s?void 0:s.getAdaptation(K))&&void 0!==u?u:null;var G={id:K,representations:uu(E,p,P),type:I,isTrickModeTrack:N};if(null!=p.attributes.language&&(G.language=p.attributes.language),null!=B&&(G.closedCaption=B),null!=z&&(G.audioDescription=z),!0===U&&(G.isDub=!0),void 0!==F&&(G.forcedSubtitles=F),!0===V&&(G.isSignInterpreted=!0),void 0!==_&&(G.label=_),void 0!==O)d.push({adaptation:G,trickModeAttachedAdaptationIds:O});else{for(var j,H=-1,q=function(){var e=j.value,t=c[e];if(void 0!==t&&t.newID!==W&&Qe(t.adaptationSetSwitchingIDs,x)){H=S(l[I],(function(t){return t[0].id===e}));var n,r=l[I][H];if(void 0!==r&&r[0].audioDescription===G.audioDescription&&r[0].closedCaption===G.closedCaption&&r[0].language===G.language)return oe.info('DASH Parser: merging "switchable" AdaptationSets',x,e),(n=r[0].representations).push.apply(n,G.representations),r[1]={priority:Math.max(R,r[1].priority),isMainAdaptation:b||r[1].isMainAdaptation,indexInMpd:Math.min(v,r[1].indexInMpd)},1}},Y=lu(C);!(j=Y()).done&&!q(););H<0&&l[I].push([G,{priority:R,isMainAdaptation:b,indexInMpd:v}])}null!=x&&null==c[x]&&(c[x]={newID:W,adaptationSetSwitchingIDs:C})}}var Q=zn.reduce((function(e,t){var n=l[t];return n.length>0&&(n.sort(mu),e[t]=n.map((function(e){return e[0]}))),e}),{});return l.video.sort(mu),Ls(Q,d),Q}(v.children.adaptations,C),P=(null!==(i=t.xmlNamespaces)&&void 0!==i?i:[]).concat(null!==(a=v.attributes.namespaces)&&void 0!==a?a:[]),D=function(e,t,n){for(var r,i,a,o=[],s=gu(e);!(a=s()).done;)for(var u,l=a.value,d=l.attributes,c=d.schemeIdUri,f=void 0===c?"":c,v=d.timescale,p=void 0===v?1:v,m=n.concat(null!==(r=l.attributes.namespaces)&&void 0!==r?r:[]),g=gu(l.children.events);!(u=g()).done;){var y=u.value;if(void 0!==y.eventStreamData){var _=(null!==(i=y.presentationTime)&&void 0!==i?i:0)/p+t,b=void 0===y.duration?void 0:_+y.duration/p,S=void 0,E=void 0;if(!h&&y.eventStreamData instanceof Element)S=y.eventStreamData;else try{E={namespaces:m,data:go(new Uint8Array(y.eventStreamData))}}catch(e){oe.error("DASH: Error while parsing event-stream:",e instanceof Error?e.message:"Unknown error")}o.push({start:_,end:b,id:y.id,data:{type:"dash-event-stream",value:{schemeIdUri:f,timescale:p,element:S,xmlData:E}}})}}return o}(v.children.eventStreams,b,P),O={id:d,start:b,end:T,duration:E,adaptations:M,streamEvents:D};if(o.unshift(O),!l.lastPositionIsKnown()){var N=function(e){for(var t,n=null,r=!0,i=gu(Ds(De(e).filter((function(e){return!_(e)})),(function(e){return e})));!(t=i()).done;)for(var a,o=gu(t.value.representations);!(a=o()).done;){var s=a.value.index.getLastAvailablePosition();null!==s&&(r=!1,"number"==typeof s&&(n=_(n)?s:Math.max(n,s)))}if(!_(n))return n;if(r)return null;return}(M);if(u)if("number"==typeof N){var L=Me()/1e3;l.setLastPosition(N,L)}else{var U=Su(t,b);if(void 0!==U){var B=U[0],F=U[1];l.setLastPosition(B,F)}}else"number"==typeof N&&l.setLastPosition(N)}},c=e.length-1;c>=0;c--)d();if(t.isDynamic&&!l.lastPositionIsKnown()){var f=Su(t,0);if(void 0!==f){var v=f[0],p=f[1];l.setLastPosition(v,p)}}return function(e){if(0===e.length)return[];for(var t=[e[0]],n=1;n<e.length;n++){for(var r=e[n],i=t[t.length-1];(void 0===i.duration||i.start+i.duration>r.start)&&(oe.warn("DASH: Updating overlapping Periods.",null==i?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0))&&(t.pop(),0!==t.length);)i=t[t.length-1];t.push(r)}return t}(o)}function Su(e,t){if(_(e.clockOffset)){var n=Date.now()/1e3;if(n>=t)return oe.warn("DASH Parser: no clock synchronization mechanism found. Using the system clock instead."),[n-e.availabilityStartTime,Me()/1e3]}else{var r=e.clockOffset/1e3-e.availabilityStartTime,i=Me()/1e3,a=i+r;if(a>=t)return[a,i]}}function Eu(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Tu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Tu(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Tu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ku=function e(t,n,r,i,a){void 0===a&&(a=new WeakMap);var o=t.children,s=t.attributes;if(null==n.externalClockOffset){var u="dynamic"===s.type,l=xe(o.utcTimings,(function(e){return"urn:mpeg:dash:utc:direct:2014"===e.schemeIdUri&&null!=e.value})),d=null!=l&&null!=l.value?Rs(l.value):void 0,c=null==d||isNaN(d)?void 0:d;if(null!=c&&!0!==i)n.externalClockOffset=c;else if(u&&!0!==i){var f=function(e){var t=e.children.utcTimings.filter((function(e){return("urn:mpeg:dash:utc:http-iso:2014"===e.schemeIdUri||"urn:mpeg:dash:utc:http-xsdate:2014"===e.schemeIdUri)&&void 0!==e.value}));return t.length>0?t[0].value:void 0}(t);if(null!=f&&f.length>0)return{type:"needs-clock",value:{url:f,continue:function(i){return i.success?(n.externalClockOffset=Rs(i.data),e(t,n,r,!0)):(r.push(i.error),oe.warn("DASH Parser: Error on fetching the clock ressource",i.error),e(t,n,r,!0))}}}}}for(var v=[],h=0;h<o.periods.length;h++){var m=o.periods[h].attributes,g=m.xlinkHref,y=m.xlinkActuate;null!=g&&"onLoad"===y&&v.push({index:h,ressource:g})}return 0===v.length?function(e,t,n,r){var i,a,o,s,u,l,d=e.children,c=e.attributes,f="dynamic"===c.type,v=void 0!==t.url?[{url:t.url.substring(0,co(t.url))}]:[],h=iu(v,d.baseURLs),m=function(e,t){return"dynamic"!==e.type?0:null==e.availabilityStartTime?null==t?0:t:e.availabilityStartTime}(c,t.referenceDateTime),g=c.timeShiftBufferDepth,y=t.externalClockOffset,_=t.unsafelyBaseOnPreviousManifest,b=t.externalClockOffset,S=new Ps({availabilityStartTime:m,isDynamic:f,timeShiftBufferDepth:g,serverTimestampOffset:b}),E={availabilityStartTime:m,baseURLs:h,clockOffset:y,duration:c.duration,isDynamic:f,manifestBoundsCalculator:S,manifestProfiles:e.attributes.profiles,receivedTime:t.manifestReceivedTime,timeShiftBufferDepth:g,unsafelyBaseOnPreviousManifest:_,xlinkInfos:r,xmlNamespaces:e.attributes.namespaces},T=bu(d.periods,E),k=c.duration,w=null;void 0!==c.minimumUpdatePeriod&&c.minimumUpdatePeriod>=0&&(s=0===c.minimumUpdatePeriod?p.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:c.minimumUpdatePeriod);var A=Ms(T),I=A.minimumSafePosition,R=A.maximumSafePosition,x=A.maximumUnsafePosition,C=Me();if(f){var M;if(void 0!==R)M=R;else if(void 0===b)oe.warn("DASH Parser: use system clock to define maximum position"),M=Date.now()/1e3-m;else M=(Me()+b)/1e3-m;var P=S.getEstimatedLiveEdge();void 0===P&&(P=void 0!==x?x:M),l={isLinear:!0,maximumSafePosition:M,livePosition:P,time:C},u=I,null!==(w=null!=g?g:null)&&void 0!==u&&P-u>w&&(w=P-u)}else{u=void 0!==I?I:void 0!==(null===(i=T[0])||void 0===i?void 0:i.start)?T[0].start:0;var D=null!=k?k:1/0;if(void 0!==T[T.length-1]){var O=T[T.length-1],N=null!==(a=O.end)&&void 0!==a?a:void 0!==O.duration?O.start+O.duration:void 0;void 0!==N&&N<D&&(D=N)}void 0!==R&&R<D&&(D=R),l={isLinear:!1,maximumSafePosition:D,livePosition:void 0,time:C}}var L=!f||void 0===e.attributes.minimumUpdatePeriod&&(void 0!==(null===(o=T[T.length-1])||void 0===o?void 0:o.end)||void 0!==e.attributes.duration),U={availabilityStartTime:m,clockOffset:t.externalClockOffset,isDynamic:f,isLive:f,isLastPeriodKnown:L,periods:T,publishTime:c.publishTime,suggestedPresentationDelay:c.suggestedPresentationDelay,transportType:"dash",timeBounds:{minimumSafePosition:u,timeshiftDepth:w,maximumTimeData:l},lifetime:s,uris:null==t.url?d.locations:[t.url].concat(d.locations)};return{type:"done",value:{parsed:U,warnings:n}}}(t,n,r,a):{type:"needs-xlinks",value:{xlinksUrls:v.map((function(e){return e.ressource})),continue:function(s){if(s.length!==v.length)throw new Error("DASH parser: wrong number of loaded ressources.");for(var u=s.length-1;u>=0;u--){var l,d=v[u].index,c=s[u],f=c.parsed,p=c.warnings,h=c.receivedTime,m=c.sendingTime,g=c.url;p.length>0&&r.push.apply(r,p);for(var y,_=Eu(f);!(y=_()).done;){var b=y.value;a.set(b,{receivedTime:h,sendingTime:m,url:g})}(l=o.periods).splice.apply(l,[d,1].concat(f))}return e(t,n,r,i,a)}}}};function wu(e){var t=e.textContent,n=[];return null===t||0===t.length?[void 0,n]:[{value:t},n]}function Au(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"id":t.id=r.value;break;case"lang":t.language=r.value;break;case"contentType":t.contentType=r.value;break;case"par":t.par=r.value}}return t}var Iu=/^P(([\d.]*)Y)?(([\d.]*)M)?(([\d.]*)D)?T?(([\d.]*)H)?(([\d.]*)M)?(([\d.]*)S)?/,Ru=/([0-9]+)-([0-9]+)/;function xu(e,t){return"true"===e?[!0,null]:"false"===e?[!1,null]:[!1,new zu("`"+t+'` property is not a boolean value but "'+e+'"')]}function Cu(e,t){var n=parseInt(e,10);return isNaN(n)?[null,new zu("`"+t+'` property is not an integer value but "'+e+'"')]:[n,null]}function Mu(e,t){if("INF"===e)return[1/0,null];var n=parseFloat(e);return isNaN(n)?[null,new zu("`"+t+'` property is invalid: "'+e+'"')]:[n,null]}function Pu(e,t){if("true"===e)return[!0,null];if("false"===e)return[!1,null];var n=parseInt(e,10);return isNaN(n)?[null,new zu("`"+t+'` property is not a boolean nor an integer but "'+e+'"')]:[n,null]}function Du(e,t){var n=Date.parse(e);return isNaN(n)?[null,new zu("`"+t+'` is in an invalid date format: "'+e+'"')]:[new Date(Date.parse(e)).getTime()/1e3,null]}function Ou(e,t){if(!y(e))return[0,new zu("`"+t+"` property is empty")];var n=Iu.exec(e);return null===n?[null,new zu("`"+t+'` property has an unrecognized format "'+e+'"')]:[365*parseFloat(y(n[2])?n[2]:"0")*24*60*60+30*parseFloat(y(n[4])?n[4]:"0")*24*60*60+24*parseFloat(y(n[6])?n[6]:"0")*60*60+60*parseFloat(y(n[8])?n[8]:"0")*60+60*parseFloat(y(n[10])?n[10]:"0")+parseFloat(y(n[12])?n[12]:"0"),null]}function Nu(e,t){var n=Ru.exec(e);return null===n?[null,new zu("`"+t+'` property has an unrecognized format "'+e+'"')]:[[+n[1],+n[2]],null]}function Lu(e,t){try{return[Po(e),null]}catch(n){return[null,new zu("`"+t+'` is not a valid base64 string: "'+e+'"')]}}function Uu(e,t){var n=/^(\d+)\/(\d+)$/.exec(e);return null!==n?[+n[1]/+n[2],null]:Mu(e,t)}function Bu(e){for(var t,n,r=0;r<e.attributes.length;r++){var i=e.attributes[r];switch(i.name){case"schemeIdUri":t=i.value;break;case"value":n=i.value}}return{schemeIdUri:t,value:n}}function Fu(e,t){return function(n,r){var i=r.asKey,a=(0,r.parser)(n,r.dashName),o=a[0],s=a[1];null!==s&&(oe.warn(s.message),t.push(s)),null!==o&&(e[i]=o)}}var zu=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(de(r),t.prototype),r.name="MPDError",r.message=n,r}return u(t,e),t}(ve(Error));function Vu(e){var t=function(e){for(var t=[],n=[],r=0;r<e.length;r++)if(e[r].nodeType===Node.ELEMENT_NODE){var i=e[r];if("cenc:pssh"===i.nodeName){var a=i.textContent;if(null!==a&&a.length>0){var o=Lu(a,"cenc:pssh"),s=o[0],u=o[1];null!==u&&(oe.warn(u.message),t.push(u)),null!==s&&n.push(s)}}}return[{cencPssh:n},t]}(e.childNodes),n=t[0],r=t[1];return[{children:n,attributes:function(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"schemeIdUri":t.schemeIdUri=r.value;break;case"value":t.value=r.value;break;case"cenc:default_KID":t.keyId=yo(r.value.replace(/-/g,""))}}return t}(e)},r]}function Ku(e){for(var t={},n=[],r=Fu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"range":r(a.value,{asKey:"range",parser:Nu,dashName:"range"});break;case"sourceURL":t.media=a.value}}return[t,n]}function Wu(e){for(var t={},n=[],r=Fu(t,n),i=e.childNodes,a=0;a<i.length;a++)if(i[a].nodeType===Node.ELEMENT_NODE){var o=i[a];if("Initialization"===o.nodeName){var s=Ku(o),u=s[0],l=s[1];t.initialization=u,n=n.concat(l)}}for(var d=0;d<e.attributes.length;d++){var c=e.attributes[d];switch(c.name){case"timescale":r(c.value,{asKey:"timescale",parser:Cu,dashName:"timescale"});break;case"presentationTimeOffset":r(c.value,{asKey:"presentationTimeOffset",parser:Mu,dashName:"presentationTimeOffset"});break;case"indexRange":r(c.value,{asKey:"indexRange",parser:Nu,dashName:"indexRange"});break;case"indexRangeExact":r(c.value,{asKey:"indexRangeExact",parser:xu,dashName:"indexRangeExact"});break;case"availabilityTimeOffset":r(c.value,{asKey:"availabilityTimeOffset",parser:Mu,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(c.value,{asKey:"availabilityTimeComplete",parser:xu,dashName:"availabilityTimeComplete"});break;case"duration":r(c.value,{asKey:"duration",parser:Cu,dashName:"duration"});break;case"startNumber":r(c.value,{asKey:"startNumber",parser:Cu,dashName:"startNumber"});break;case"endNumber":r(c.value,{asKey:"endNumber",parser:Cu,dashName:"endNumber"})}}return[t,n]}function Gu(e){for(var t={},n=[],r=Fu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"media":t.media=a.value;break;case"indexRange":r(a.value,{asKey:"indexRange",parser:Nu,dashName:"indexRange"});break;case"index":t.index=a.value;break;case"mediaRange":r(a.value,{asKey:"mediaRange",parser:Nu,dashName:"mediaRange"})}}return[t,n]}function ju(e){for(var t=Wu(e),n=t[0],r=t[1],i=[],a=e.childNodes,o=0;o<a.length;o++)if(a[o].nodeType===Node.ELEMENT_NODE){var s=a[o];if("SegmentURL"===s.nodeName){var u=Gu(s),l=u[0],c=u[1];i.push(l),r=r.concat(c)}}return[d(n,{list:i}),r]}function Hu(e){var t=null;return function(){if(null===t){var n=e.getElementsByTagName("S");return t=n,n}return t}}function qu(e){for(var t,n=Wu(e),r=n[0],i=n[1],a=0;a<e.childNodes.length;a++)if(e.childNodes[a].nodeType===Node.ELEMENT_NODE){var o=e.childNodes[a];"SegmentTimeline"===o.nodeName&&(t=Hu(o))}for(var s=d({},r,{duration:r.duration,timelineParser:t}),u=Fu(s,i),l=0;l<e.attributes.length;l++){var c=e.attributes[l];switch(c.nodeName){case"initialization":null==s.initialization&&(s.initialization={media:c.value});break;case"index":s.index=c.value;break;case"availabilityTimeOffset":u(c.value,{asKey:"availabilityTimeOffset",parser:Mu,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":u(c.value,{asKey:"availabilityTimeComplete",parser:xu,dashName:"availabilityTimeComplete"});break;case"media":s.media=c.value;break;case"bitstreamSwitching":u(c.value,{asKey:"bitstreamSwitching",parser:xu,dashName:"bitstreamSwitching"})}}return[s,i]}function Yu(e){var t=function(e){for(var t={baseURLs:[]},n=[],r=[],i=0;i<e.length;i++)if(e[i].nodeType===Node.ELEMENT_NODE){var a=e[i];switch(a.nodeName){case"BaseURL":var o=wu(a),s=o[0],u=o[1];void 0!==s&&t.baseURLs.push(s),r=r.concat(u);break;case"InbandEventStream":void 0===t.inbandEventStreams&&(t.inbandEventStreams=[]),t.inbandEventStreams.push(Bu(a));break;case"SegmentBase":var l=Wu(a),d=l[0],c=l[1];t.segmentBase=d,c.length>0&&(r=r.concat(c));break;case"SegmentList":var f=ju(a),v=f[0],p=f[1];r=r.concat(p),t.segmentList=v;break;case"SegmentTemplate":var h=qu(a),m=h[0],g=h[1];r=r.concat(g),t.segmentTemplate=m;break;case"ContentProtection":var y=Vu(a),_=y[0],b=y[1];b.length>0&&(r=r.concat(b)),void 0!==_&&n.push(_);break;case"SupplementalProperty":null==t.supplementalProperties?t.supplementalProperties=[Bu(a)]:t.supplementalProperties.push(Bu(a))}}return n.length>0&&(t.contentProtections=n),[t,r]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Fu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"audioSamplingRate":t.audioSamplingRate=a.value;break;case"bandwidth":r(a.value,{asKey:"bitrate",parser:Cu,dashName:"bandwidth"});break;case"codecs":t.codecs=a.value;break;case"codingDependency":r(a.value,{asKey:"codingDependency",parser:xu,dashName:"codingDependency"});break;case"frameRate":r(a.value,{asKey:"frameRate",parser:Uu,dashName:"frameRate"});break;case"height":r(a.value,{asKey:"height",parser:Cu,dashName:"height"});break;case"id":t.id=a.value;break;case"maxPlayoutRate":r(a.value,{asKey:"maxPlayoutRate",parser:Mu,dashName:"maxPlayoutRate"});break;case"maximumSAPPeriod":r(a.value,{asKey:"maximumSAPPeriod",parser:Mu,dashName:"maximumSAPPeriod"});break;case"mimeType":t.mimeType=a.value;break;case"profiles":t.profiles=a.value;break;case"qualityRanking":r(a.value,{asKey:"qualityRanking",parser:Cu,dashName:"qualityRanking"});break;case"scte214:supplementalCodecs":t.supplementalCodecs=a.value;break;case"segmentProfiles":t.segmentProfiles=a.value;break;case"width":r(a.value,{asKey:"width",parser:Cu,dashName:"width"});break;case"availabilityTimeOffset":r(a.value,{asKey:"availabilityTimeOffset",parser:Mu,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(a.value,{asKey:"availabilityTimeComplete",parser:xu,dashName:"availabilityTimeComplete"})}}return void 0===t.bitrate&&n.push(new zu("No bitrate found on a Representation")),[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}function Qu(e){var t=function(e){for(var t={baseURLs:[],representations:[]},n=[],r=[],i=0;i<e.length;i++)if(e[i].nodeType===Node.ELEMENT_NODE){var a=e[i];switch(a.nodeName){case"Accessibility":void 0===t.accessibilities?t.accessibilities=[Bu(a)]:t.accessibilities.push(Bu(a));break;case"BaseURL":var o=wu(a),s=o[0],u=o[1];void 0!==s&&t.baseURLs.push(s),u.length>0&&(r=r.concat(u));break;case"ContentComponent":t.contentComponent=Au(a);break;case"EssentialProperty":null==t.essentialProperties?t.essentialProperties=[Bu(a)]:t.essentialProperties.push(Bu(a));break;case"InbandEventStream":void 0===t.inbandEventStreams&&(t.inbandEventStreams=[]),t.inbandEventStreams.push(Bu(a));break;case"Label":var l=a.textContent;null!=l&&(t.label=l);break;case"Representation":var d=Yu(a),c=d[0],f=d[1];t.representations.push(c),f.length>0&&(r=r.concat(f));break;case"Role":null==t.roles?t.roles=[Bu(a)]:t.roles.push(Bu(a));break;case"SupplementalProperty":null==t.supplementalProperties?t.supplementalProperties=[Bu(a)]:t.supplementalProperties.push(Bu(a));break;case"SegmentBase":var v=Wu(a),p=v[0],h=v[1];t.segmentBase=p,h.length>0&&(r=r.concat(h));break;case"SegmentList":var m=ju(a),g=m[0],y=m[1];t.segmentList=g,y.length>0&&(r=r.concat(y));break;case"SegmentTemplate":var _=qu(a),b=_[0],S=_[1];t.segmentTemplate=b,S.length>0&&(r=r.concat(S));break;case"ContentProtection":var E=Vu(a),T=E[0],k=E[1];k.length>0&&(r=r.concat(k)),void 0!==T&&n.push(T)}}return n.length>0&&(t.contentProtections=n),[t,r]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Fu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"group":r(a.value,{asKey:"group",parser:Cu,dashName:"group"});break;case"lang":t.language=a.value;break;case"contentType":t.contentType=a.value;break;case"par":t.par=a.value;break;case"minBandwidth":r(a.value,{asKey:"minBitrate",parser:Cu,dashName:"minBandwidth"});break;case"maxBandwidth":r(a.value,{asKey:"maxBitrate",parser:Cu,dashName:"maxBandwidth"});break;case"minWidth":r(a.value,{asKey:"minWidth",parser:Cu,dashName:"minWidth"});break;case"maxWidth":r(a.value,{asKey:"maxWidth",parser:Cu,dashName:"maxWidth"});break;case"minHeight":r(a.value,{asKey:"minHeight",parser:Cu,dashName:"minHeight"});break;case"maxHeight":r(a.value,{asKey:"maxHeight",parser:Cu,dashName:"maxHeight"});break;case"minFrameRate":r(a.value,{asKey:"minFrameRate",parser:Uu,dashName:"minFrameRate"});break;case"maxFrameRate":r(a.value,{asKey:"maxFrameRate",parser:Uu,dashName:"maxFrameRate"});break;case"selectionPriority":r(a.value,{asKey:"selectionPriority",parser:Cu,dashName:"selectionPriority"});break;case"segmentAlignment":r(a.value,{asKey:"segmentAlignment",parser:Pu,dashName:"segmentAlignment"});break;case"subsegmentAlignment":r(a.value,{asKey:"subsegmentAlignment",parser:Pu,dashName:"subsegmentAlignment"});break;case"bitstreamSwitching":r(a.value,{asKey:"bitstreamSwitching",parser:xu,dashName:"bitstreamSwitching"});break;case"audioSamplingRate":t.audioSamplingRate=a.value;break;case"codecs":t.codecs=a.value;break;case"scte214:supplementalCodecs":t.supplementalCodecs=a.value;break;case"codingDependency":r(a.value,{asKey:"codingDependency",parser:xu,dashName:"codingDependency"});break;case"frameRate":r(a.value,{asKey:"frameRate",parser:Uu,dashName:"frameRate"});break;case"height":r(a.value,{asKey:"height",parser:Cu,dashName:"height"});break;case"maxPlayoutRate":r(a.value,{asKey:"maxPlayoutRate",parser:Mu,dashName:"maxPlayoutRate"});break;case"maximumSAPPeriod":r(a.value,{asKey:"maximumSAPPeriod",parser:Mu,dashName:"maximumSAPPeriod"});break;case"mimeType":t.mimeType=a.value;break;case"profiles":t.profiles=a.value;break;case"segmentProfiles":t.segmentProfiles=a.value;break;case"width":r(a.value,{asKey:"width",parser:Cu,dashName:"width"});break;case"availabilityTimeOffset":r(a.value,{asKey:"availabilityTimeOffset",parser:Mu,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(a.value,{asKey:"availabilityTimeComplete",parser:xu,dashName:"availabilityTimeComplete"})}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}function $u(e){for(var t={children:{events:[]},attributes:{}},n=[],r=Fu(t.attributes,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"schemeIdUri":t.attributes.schemeIdUri=a.value;break;case"timescale":r(a.value,{asKey:"timescale",parser:Cu,dashName:"timescale"});break;case"value":t.attributes.value=a.value}}for(var o=0;o<e.childNodes.length;o++)if(e.childNodes[o].nodeType===Node.ELEMENT_NODE){var s=e.childNodes[o];if("Event"===s.nodeName){var u=Xu(s),l=u[0],d=u[1];t.children.events.push(l),d.length>0&&(n=n.concat(d))}}return[t,n]}function Xu(e){for(var t={eventStreamData:e},n=[],r=Fu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"presentationTime":r(a.value,{asKey:"presentationTime",parser:Cu,dashName:"presentationTime"});break;case"duration":r(a.value,{asKey:"duration",parser:Cu,dashName:"duration"});break;case"id":t.id=a.value}}return[t,n]}function Zu(e){var t=function(e){for(var t,n=[],r=[],i=[],a=[],o=0;o<e.length;o++)if(e[o].nodeType===Node.ELEMENT_NODE){var s=e[o];switch(s.nodeName){case"BaseURL":var u=wu(s),l=u[0],d=u[1];void 0!==l&&n.push(l),i=i.concat(d);break;case"AdaptationSet":var c=Qu(s),f=c[0],v=c[1];r.push(f),i=i.concat(v);break;case"EventStream":var p=$u(s),h=p[0],m=p[1];a.push(h),i=i.concat(m);break;case"SegmentTemplate":var g=qu(s),y=g[0],_=g[1];t=y,_.length>0&&(i=i.concat(_))}}return[{baseURLs:n,adaptations:r,eventStreams:a,segmentTemplate:t},i]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Fu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"start":r(a.value,{asKey:"start",parser:Ou,dashName:"start"});break;case"duration":r(a.value,{asKey:"duration",parser:Ou,dashName:"duration"});break;case"bitstreamSwitching":r(a.value,{asKey:"bitstreamSwitching",parser:xu,dashName:"bitstreamSwitching"});break;case"xlink:href":t.xlinkHref=a.value;break;case"xlink:actuate":t.xlinkActuate=a.value}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}function Ju(e){var t=function(e){for(var t=[],n=[],r=[],i=[],a=[],o=0;o<e.length;o++)if(e[o].nodeType===Node.ELEMENT_NODE){var s=e[o];switch(s.nodeName){case"BaseURL":var u=wu(s),l=u[0],d=u[1];void 0!==l&&t.push(l),a=a.concat(d);break;case"Location":n.push(null===s.textContent?"":s.textContent);break;case"Period":var c=Zu(s),f=c[0],v=c[1];r.push(f),a=a.concat(v);break;case"UTCTiming":var p=Bu(s);i.push(p)}}return[{baseURLs:t,locations:n,periods:r,utcTimings:i},a]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=Fu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"profiles":t.profiles=a.value;break;case"type":t.type=a.value;break;case"availabilityStartTime":r(a.value,{asKey:"availabilityStartTime",parser:Du,dashName:"availabilityStartTime"});break;case"availabilityEndTime":r(a.value,{asKey:"availabilityEndTime",parser:Du,dashName:"availabilityEndTime"});break;case"publishTime":r(a.value,{asKey:"publishTime",parser:Du,dashName:"publishTime"});break;case"mediaPresentationDuration":r(a.value,{asKey:"duration",parser:Ou,dashName:"mediaPresentationDuration"});break;case"minimumUpdatePeriod":r(a.value,{asKey:"minimumUpdatePeriod",parser:Ou,dashName:"minimumUpdatePeriod"});break;case"minBufferTime":r(a.value,{asKey:"minBufferTime",parser:Ou,dashName:"minBufferTime"});break;case"timeShiftBufferDepth":r(a.value,{asKey:"timeShiftBufferDepth",parser:Ou,dashName:"timeShiftBufferDepth"});break;case"suggestedPresentationDelay":r(a.value,{asKey:"suggestedPresentationDelay",parser:Ou,dashName:"suggestedPresentationDelay"});break;case"maxSegmentDuration":r(a.value,{asKey:"maxSegmentDuration",parser:Ou,dashName:"maxSegmentDuration"});break;case"maxSubsegmentDuration":r(a.value,{asKey:"maxSubsegmentDuration",parser:Ou,dashName:"maxSubsegmentDuration"})}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}var el=function(e,t){var n=e.documentElement;if(_(n)||"MPD"!==n.nodeName)throw new Error("DASH Parser: document root should be MPD");var r=Ju(n),i=r[0],a=r[1];return function e(t){if("done"===t.type)return t;if("needs-clock"===t.type)return{type:"needs-resources",value:{urls:[t.value.url],format:"string",continue:function(n){if(1!==n.length)throw new Error("DASH parser: wrong number of loaded ressources.");var r=t.value.continue(n[0].responseData);return e(r)}}};if("needs-xlinks"===t.type)return{type:"needs-resources",value:{urls:t.value.xlinksUrls,format:"string",continue:function(n){for(var r=[],i=0;i<n.length;i++){var a=n[i],o=a.responseData,s=a.receivedTime,u=a.sendingTime,l=a.url;if(!o.success)throw o.error;var d="<root>"+o.data+"</root>",c=(new DOMParser).parseFromString(d,"text/xml");if(null==c||0===c.children.length)throw new Error("DASH parser: Invalid external ressources");for(var f=c.children[0].children,v=[],p=[],h=0;h<f.length;h++)if(f[h].nodeType===Node.ELEMENT_NODE){var m=Zu(f[h]),g=m[0],y=m[1];p.push.apply(p,y),v.push(g)}r.push({url:l,receivedTime:s,sendingTime:u,parsed:v,warnings:p})}var _=t.value.continue(r);return e(_)}}};Ze()}(ku(i,t,a))};function tl(e){var t=e.referenceDateTime,n=void 0!==e.serverSyncInfos?e.serverSyncInfos.serverTimestamp-e.serverSyncInfos.clientTime:void 0;return function(r,i,a,o,s){var u,l=r.responseData,c=i.externalClockOffset,f=null!==(u=r.url)&&void 0!==u?u:i.originalUrl,v=null!=n?n:c,h={unsafelyBaseOnPreviousManifest:i.unsafeMode?i.previousManifest:null,url:f,referenceDateTime:t,externalClockOffset:v},m=Re.dashParsers;if(null===m.wasm||"uninitialized"===m.wasm.status||"failure"===m.wasm.status)return oe.debug("DASH: WASM MPD Parser not initialized. Running JS one."),y();var g=function(e){if(e instanceof ArrayBuffer)return e;if("string"==typeof e)return ho(e).buffer;if(e instanceof Document)return ho(e.documentElement.innerHTML).buffer;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return function(e){var t=new DataView(e);if(61371===t.getUint16(0)&&191===t.getUint8(2))return!0;if(65279===t.getUint16(0)||65534===t.getUint16(0))return!1;return!0}(g)?"initialized"===m.wasm.status?(oe.debug("DASH: Running WASM MPD Parser."),_(m.wasm.runWasmParser(g,h))):(oe.debug("DASH: Awaiting WASM initialization before parsing the MPD."),m.wasm.waitForInitialization().catch((function(){})).then((function(){return null===m.wasm||"initialized"!==m.wasm.status?(oe.warn("DASH: WASM MPD parser initialization failed. Running JS parser instead"),y()):(oe.debug("DASH: Running WASM MPD Parser."),_(m.wasm.runWasmParser(g,h)))}))):(oe.info("DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one."),y());function y(){if(null===m.js)throw new Error("No MPD parser is imported");var e=function(e){if(e instanceof ArrayBuffer)return(new DOMParser).parseFromString(go(new Uint8Array(e)),"text/xml");if("string"==typeof e)return(new DOMParser).parseFromString(e,"text/xml");if(e instanceof Document)return e;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return _(m.js(e,h))}function _(t){if("done"===t.type){if(t.value.warnings.length>0&&a(t.value.warnings),o.isCancelled())return Promise.reject(o.cancellationError);var n=[];return{manifest:new Jn(t.value.parsed,e,n),url:f,warnings:n}}var r=t.value,i=r.urls.map((function(e){return s((function(){var t=p.getCurrent().DEFAULT_REQUEST_TIMEOUT,n=p.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return"string"===r.format?Jo({url:e,responseType:"text",timeout:t,connectionTimeout:n,cancelSignal:o}):Jo({url:e,responseType:"arraybuffer",timeout:t,connectionTimeout:n,cancelSignal:o})})).then((function(e){if("string"===r.format){if("string"!=typeof e.responseData)throw new Error("External DASH resources should have been a string");return d(e,{responseData:{success:!0,data:e.responseData}})}if(!(e.responseData instanceof ArrayBuffer))throw new Error("External DASH resources should have been ArrayBuffers");return d(e,{responseData:{success:!0,data:e.responseData}})}),(function(e){var t=we(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"An unknown error occured when parsing ressources."});return d({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:t}})}))}));return Promise.all(i).then((function(e){return r.format,_(r.continue(e))}))}}}var nl="function"==typeof Headers?Headers:null,rl="function"==typeof AbortController?AbortController:null;function il(){return"function"==typeof g.fetch&&!_(rl)&&!_(nl)}function al(e,t){return"audio"===e||"video"===e?"video/mp4"===t||"audio/mp4"===t?"mp4":"video/webm"===t||"audio/webm"===t?"webm":void 0:"text"===e&&"application/mp4"===t?"mp4":void 0}function ol(e){return function(t,n,r,i,a){return new Promise((function(s,u){var l=new ht,d=l.linkToSignal(i);function c(){l.signal.deregister(u),d()}l.signal.register(u),e(t,n,r,l.signal,Object.assign(Object.assign({},a),{onNewChunk:function(e){try{o(e),a.onNewChunk(e)}catch(e){c(),l.cancel(),u(e)}}})).then((function(e){if(c(),!l.isUsed()){if("segment-loaded"===e.resultType)try{o(e.resultData.responseData)}catch(e){return void u(e)}s(e)}}),(function(e){c(),u(e)}))}));function o(e){(e instanceof ArrayBuffer||e instanceof Uint8Array)&&"mp4"===al(n.type,n.mimeType)&&ts(new Uint8Array(e),n.segment.isInit)}}}function sl(e,t){return null===e?null:null===t.url?e.baseUrl:lo(e.baseUrl,t.url)}function ul(e,t,n,r,i){if(void 0===t.range)return Jo({url:e,responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(void 0===t.indexRange)return Jo({url:e,headers:{Range:ys(t.range)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(t.range[1]+1===t.indexRange[0])return Jo({url:e,headers:{Range:ys([t.range[0],t.indexRange[1]])},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));var a=Jo({url:e,headers:{Range:ys(t.range)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),o=Jo({url:e,headers:{Range:ys(t.indexRange)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then((function(t){var n=t[0],r=t[1],i=ia(new Uint8Array(n.responseData),new Uint8Array(r.responseData)),a=Math.min(n.sendingTime,r.sendingTime),o=Math.max(n.receivedTime,r.receivedTime);return{resultType:"segment-loaded",resultData:{url:e,responseData:i,size:n.size+r.size,requestDuration:o-a,sendingTime:a,receivedTime:o}}}))}function ll(e,t,n,r,i){var a=t.segment,o=void 0!==a.range?{Range:ys(a.range)}:void 0,s=null;return function(e){var t;if(!_(e.headers))if(_(nl))t=e.headers;else{t=new nl;for(var n=Object.keys(e.headers),r=0;r<n.length;r++){var i=n[r];t.append(i,e.headers[i])}}oe.debug("Fetch: Called with URL",e.url);var a,o,s=null,u=!1,l=!1,d=Me(),c=_(rl)?null:new rl;function f(){_(c)?oe.warn("Fetch: AbortController API not available."):c.abort()}void 0!==e.timeout&&(a=setTimeout((function(){u=!0,void 0!==o&&clearTimeout(o),f()}),e.timeout)),void 0!==e.connectionTimeout&&(o=setTimeout((function(){l=!0,void 0!==a&&clearTimeout(a),f()}),e.connectionTimeout));var v=e.cancelSignal.register((function(e){s=e,f()})),p={method:"GET"};return void 0!==t&&(p.headers=t),p.signal=_(c)?null:c.signal,fetch(e.url,p).then((function(t){if(void 0!==o&&clearTimeout(o),t.status>=300)throw oe.warn("Fetch: Request HTTP Error",t.status,t.url),new pe(t.url,t.status,he.ERROR_HTTP_CODE);if(_(t.body))throw new pe(t.url,t.status,he.PARSE_ERROR);var n=t.headers.get("Content-Length"),r=_(n)||isNaN(+n)?void 0:+n,i=t.body.getReader(),s=0;return u();function u(){return l.apply(this,arguments)}function l(){return(l=_t(St().mark((function n(){var o,l,c,f,p;return St().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,i.read();case 2:if((o=n.sent).done||_(o.value)){n.next=11;break}return s+=o.value.byteLength,l=Me(),c={url:t.url,currentTime:l,duration:l-d,sendingTime:d,chunkSize:o.value.byteLength,chunk:o.value.buffer,size:s,totalSize:r},e.onData(c),n.abrupt("return",u());case 11:if(!o.done){n.next=17;break}return void 0!==a&&clearTimeout(a),v(),f=Me(),p=f-d,n.abrupt("return",{requestDuration:p,receivedTime:f,sendingTime:d,size:s,status:t.status,url:t.url});case 17:return n.abrupt("return",u());case 18:case"end":return n.stop()}}),n)})))).apply(this,arguments)}})).catch((function(t){if(null!==s)throw s;if(v(),u)throw oe.warn("Fetch: Request timed out."),new pe(e.url,0,he.TIMEOUT);if(l)throw oe.warn("Fetch: Request connection timed out."),new pe(e.url,0,he.TIMEOUT);if(t instanceof pe)throw t;throw oe.warn("Fetch: Request Error",t instanceof Error?t.toString():""),new pe(e.url,0,he.ERROR_EVENT)}))}({url:e,headers:o,onData:function(e){var t=new Uint8Array(e.chunk),n=function(e){for(var t=0,n=[],r=null;t<e.length;){var i=es(r=e.subarray(t,1/0),1836019558);if(i<0)break;var a=t+i+sa(e,i+t);if(a>e.length)break;var o=es(r,1835295092);if(o<0)break;var s=t+o+sa(e,o+t);if(s>e.length)break;var u=Math.max(a,s),l=e.subarray(t,u);n.push(l),t=u}return 0===n.length?[null,r]:[ia.apply(void 0,n),r]}(null!==s?ia(s,t):t),a=n[0];s=n[1],null!==a&&(r.onNewChunk(a),i.isCancelled())||(r.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize}),i.isCancelled())},timeout:n.timeout,cancelSignal:i}).then((function(e){return{resultType:"chunk-complete",resultData:e}}))}function dl(e,t,n,r,i,a){if(t.segment.isInit)return ul(e,t.segment,r,a,i);var o=al(t.type,t.mimeType);if(n&&("mp4"===o||void 0===o)){if(il())return ll(e,t,r,i,a);Rn("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}var s=t.segment;return Jo({url:e,responseType:"arraybuffer",headers:void 0!==s.range?{Range:ys(s.range)}:void 0,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}var cl="function"==typeof Uint8Array.prototype.slice?function(e,t,n){return e.slice(t,n)}:function(e,t,n){return new Uint8Array(Array.prototype.slice.call(e,t,n))};function fl(e,t){if(e[t]>1)oe.warn("ISOBMFF: un-handled PSSH version");else{var n=t+4;if(!(n+16>e.length))return _o(cl(e,n,n+16))}}var vl=408125543,pl=357149030,hl=2807729,ml=17545,gl=475249515,yl=187,_l=179,bl=183,Sl=241;function El(e,t,n,r){for(var i=r[0],a=r[1],o=i;o<a;){var s=Al(n,o);if(null==s)return null;var u=s.value,l=o+s.length,d=Il(n,l);if(null==d)return null;var c=l+d.length,f=c+d.value;if(u===e)return[c,f];if(t.length>0)for(var v=0;v<t.length;v++){if(u===t[v])return El(e,t.slice(v+1,t.length),n,[c,f])}o=f}return null}function Tl(e,t){var n=El(hl,[vl,pl],e,[t,e.length]);if(null==n)return null;var r=n[1]-n[0];return 1e9/Rl(e,n[0],r)}function kl(e,t){var n=El(ml,[vl,pl],e,[t,e.length]);if(null==n)return null;var r=n[1]-n[0];return 4===r?function(e,t){return new DataView(e.buffer).getFloat32(t)}(e,n[0]):8===r?function(e,t){return new DataView(e.buffer).getFloat64(t)}(e,n[0]):null}function wl(e,t){for(var n=1;n<=8;n++)if(e[t]>=Math.pow(2,8-n))return n}function Al(e,t){var n=wl(e,t);if(null==n)return oe.warn("webm: unrepresentable length"),null;if(t+n>e.length)return oe.warn("webm: impossible length"),null;for(var r=0,i=0;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return{length:n,value:r}}function Il(e,t){var n=wl(e,t);if(null==n)return oe.warn("webm: unrepresentable length"),null;if(t+n>e.length)return oe.warn("webm: impossible length"),null;for(var r=(e[t]&(1<<8-n)-1)*Math.pow(2,8*(n-1)),i=1;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return{length:n,value:r}}function Rl(e,t,n){for(var r=0,i=0;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return r}function xl(e,t,n,r){var i=function(e){var t=ro(e);if(null!==t){var n=Ja(t,1952867444);if(null!==n){var r=n[0];return 1===r?ua(n,4):0===r?sa(n,4):void 0}}}(e);if(void 0===i||void 0===r)return null;var a,o=void 0!==n.timestampOffset?i+n.timestampOffset*r:i,s=ss(e);if(o<0&&(void 0!==s&&(s+=o),o=0),t||!n.complete)return void 0===s&&oe.warn("DASH: Chunked segments should indicate a duration through their trun boxes"),{time:o/r,duration:void 0!==s?s/r:void 0};var u=n.duration*r,l=Math.min(.9*r,u/4);return void 0!==s&&Math.abs(s-u)<=l&&(a=s),{time:o/r,duration:void 0!==a?a/r:a}}function Cl(e,t){if(0!==e.length){var n=e.reduce((function(e,t){return"urn:mpeg:dash:event:2012"===t.schemeIdUri&&"1"===t.value?(void 0===e.manifestRefreshEventsFromEMSGs&&(e.manifestRefreshEventsFromEMSGs=[]),e.manifestRefreshEventsFromEMSGs.push(t)):(void 0===e.EMSGs&&(e.EMSGs=[]),e.EMSGs.push(t)),e}),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),r=n.manifestRefreshEventsFromEMSGs,i=n.EMSGs,a=null==i?void 0:i.map((function(e){return{type:"emsg",value:e}})),o=void 0!==t&&void 0!==r&&function(e,t){if(e.length<=0)return!1;for(var n=e.length,r=0;r<n;r++){var i=t,a=go(e[r].messageData),o=Date.parse(a);if(void 0===i||void 0===o||isNaN(o)||o>=i)return!0}return!1}(r,t);return{inbandEvents:a,needsManifestRefresh:o}}}function Ml(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a,o=n.segment,s=n.periodStart,u=n.periodEnd,l=e.data,d=e.isChunked,c=[s,u];if(null===l)return o.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:c};var f=l instanceof Uint8Array?l:new Uint8Array(l),v=al(n.type,n.mimeType),p="mp4"===v||void 0===v,h=[];if(p){var m,g=function(e){var t=0,n=Ja(e,1836019574);if(null===n)return[];for(var r=[];t<n.length;){var i=void 0;try{i=eo(n,1886614376)}catch(e){var a=e instanceof Error?e:"";return oe.warn("Error while removing PSSH from ISOBMFF",a),r}if(null==i)return r;var o=cl(n,i[0],i[2]),s=fl(o,i[1]-i[0]);void 0!==s&&r.push({systemId:s,data:o}),n[i[0]+4]=102,n[i[0]+5]=114,n[i[0]+6]=101,n[i[0]+7]=101,t=i[2]}return r}(f);o.isInit&&(m=null!==(i=function(e){var t=Za(e,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(null===t)return null;var n=t.subarray(8),r=Ja(n,1701733238),i=0;if(null===r?(i=28,r=Ja(n,1701733217)):i=78,null===r)return null;var a=Za(r.subarray(i),[1936289382,1935894633,1952804451]);return null===a||a.byteLength<24?null:a.subarray(8,24)}(f))&&void 0!==i?i:void 0),(g.length>0||void 0!==m)&&h.push({initDataType:"cenc",keyId:m,initData:g})}if(!o.isInit){var y=p?xl(f,d,o,r):null,b=null!==(a=o.timestampOffset)&&void 0!==a?a:0;if(p){var S=function(e){for(var t=[],n=0;n<e.length;){var r=oo(e,n);if(null===r)break;var i=r.length;n+=i;var a=r[0];if(0!==a)oe.warn("ISOBMFF: EMSG version "+a.toString()+" not supported.");else{var o=4,s=So(r,o),u=s.end,l=s.string,d=So(r,o=u),c=d.end,f=d.string,v=sa(r,o=c),p=sa(r,o+=4),h=sa(r,o+=4),m=sa(r,o+=4);o+=4;var g={schemeIdUri:l,value:f,timescale:v,presentationTimeDelta:p,eventDuration:h,id:m,messageData:r.subarray(o,i)};t.push(g)}}if(0!==t.length)return t}(f);if(void 0!==S){var E=Cl(S.filter((function(e){return void 0!==o.privateInfos&&void 0!==o.privateInfos.isEMSGWhitelisted&&o.privateInfos.isEMSGWhitelisted(e)})),n.manifestPublishTime);if(void 0!==E){var T=E.needsManifestRefresh,k=E.inbandEvents;return{segmentType:"media",chunkData:f,chunkSize:f.length,chunkInfos:y,chunkOffset:b,appendWindow:c,inbandEvents:k,protectionData:h,needsManifestRefresh:T}}}}return{segmentType:"media",chunkData:f,chunkSize:f.length,chunkInfos:y,chunkOffset:b,protectionData:h,appendWindow:c}}var w,A=o.indexRange;if("webm"===v)w=function(e,t){var n=El(vl,[],e,[t,e.length]);if(null==n)return null;var r=n[0],i=n[1],a=Tl(e,r);if(null==a)return null;var o=kl(e,r);if(null==o)return null;var s=El(gl,[],e,[r,i]);if(null==s)return null;for(var u=[],l=s[0];l<s[1];){var d=El(yl,[],e,[l,s[1]]);if(null==d)break;var c=El(_l,[],e,[d[0],d[1]]);if(null==c)return null;var f=Rl(e,c[0],c[1]-c[0]),v=El(Sl,[bl],e,[d[0],d[1]]);if(null==v)return null;var p=Rl(e,v[0],v[1]-v[0])+r;u.push({time:f,rangeStart:p}),l=d[1]}for(var h=[],m=0;m<u.length;m++){var g=u[m];m===u.length-1?h.push({time:g.time,timescale:a,duration:0===m?o:o-g.time,range:[g.rangeStart,1/0]}):h.push({time:g.time,timescale:a,duration:u[m+1].time-g.time,range:[g.rangeStart,u[m+1].rangeStart-1]})}return h}(f,0);else if(p&&(w=as(f,Array.isArray(A)?A[0]:0),!0===t&&null!==w&&w.length>0)){var I=w[w.length-1];Array.isArray(I.range)&&(I.range[1]=1/0)}var R=p?us(f):"webm"===v?Tl(f,0):void 0,x=_(R)?void 0:R;return{segmentType:"init",initializationData:f,initializationDataSize:f.length,protectionData:h,initTimescale:x,segmentList:null!=w?w:void 0}}}function Pl(e,t,n,r){var i,a,o=e.segment,s=e.language,u=e.codecs;if(o.isInit)return null;null===n?r?(i=o.time,a=o.end):oe.warn("Transport: Unavailable time data for current text track."):(i=n.time,void 0!==n.duration?a=i+n.duration:!r&&o.complete&&(a=i+o.duration));var l=function(e){if(void 0===e)throw new Error("Cannot parse subtitles: unknown format");switch(e.toLowerCase()){case"stpp":case"stpp.ttml.im1t":return"ttml";case"wvtt":return"vtt"}throw new Error('The codec used for the subtitles "'+e+'" is not managed yet.')}(u),d=function(e){var t=ao(e);return null===t?"":go(t)}(t);return{data:d,type:l,language:s,start:i,end:a}}function Dl(e,t,n){var r,i,a=e.segment;return a.isInit?null:(n?oe.warn("Transport: Unavailable time data for current text track."):(r=a.time,a.complete&&(i=a.time+a.duration)),{data:t,type:function(e,t){switch(t){case"application/ttml+xml":return"ttml";case"application/x-sami":case"application/smil":return"sami";case"text/vtt":return"vtt"}if(void 0!==e&&"srt"===e.toLowerCase())return"srt";throw new Error("could not find a text-track parser for the type "+(null!=t?t:""))}(e.codecs,e.mimeType),language:e.language,start:r,end:i})}function Ol(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=e.data,l=e.isChunked;if(null===u)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:null!==(i=s.timestampOffset)&&void 0!==i?i:0,protectionData:[],appendWindow:[a,o]};var d=al(n.type,n.mimeType);if("webm"===d)throw new Error("Text tracks with a WEBM container are not yet handled.");return"mp4"===d?function(e,t,n,r,i){var a,o=n.segment,s=o.isInit,u=o.indexRange,l="string"==typeof e?ho(e):e instanceof Uint8Array?e:new Uint8Array(e);if(s){var d=as(l,Array.isArray(u)?u[0]:0);if(!0===i&&null!==d&&d.length>0){var c=d[d.length-1];Array.isArray(c.range)&&(c.range[1]=1/0)}return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:us(l),segmentList:null!=d?d:void 0}}var f=xl(l,t,o,r),v=Pl(n,l,f,t),p=null!==(a=o.timestampOffset)&&void 0!==a?a:0;return{segmentType:"media",chunkData:v,chunkSize:l.length,chunkInfos:f,chunkOffset:p,protectionData:[],appendWindow:[n.periodStart,n.periodEnd]}}(u,l,n,r,t):function(e,t,n){var r,i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=s.timestampOffset,l=void 0===u?0:u;if(s.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if("string"!=typeof e){var d=e instanceof Uint8Array?e:new Uint8Array(e);r=go(d),i=d.length}else r=e;return{segmentType:"media",chunkData:Dl(n,r,t),chunkSize:i,chunkInfos:null,chunkOffset:l,protectionData:[],appendWindow:[a,o]}}(u,l,n)}}var Nl=function(e){var t=ns({customManifestLoader:e.manifestLoader},null===Re.dashParsers.wasm||"initialized"!==Re.dashParsers.wasm.status&&"initializing"!==Re.dashParsers.wasm.status?"arraybuffer":"text"),n=tl(e),r=function(e){var t=e.lowLatencyMode,n=e.segmentLoader;return!0!==e.checkMediaSegmentIntegrity?r:ol(r);function r(e,r,i,a,o){var s=sl(e,r.segment);return null==s?Promise.resolve({resultType:"segment-created",resultData:null}):t||void 0===n?dl(s,r,t,i,o,a):new Promise((function(e,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a DASH segment through a custom segmentLoader.",o=new tr(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(t){d||a.isCancelled()||(d=!0,a.deregister(p),e({resultType:"segment-loaded",resultData:{responseData:t.data,size:t.size,requestDuration:t.duration}}))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),dl(s,r,t,i,o,a).then(e,u))}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:s},v=n(f,c);function p(e){d||(d=!0,"function"==typeof v&&v(),u(e))}a.register(p)}))}}(e),i=Ml(e),a=function(e){var t=e.lowLatencyMode;return!0!==e.checkMediaSegmentIntegrity?n:ol(n);function n(e,n,r,i,a){var o=n.segment,s=o.range,u=sl(e,o);if(null===u)return Promise.resolve({resultType:"segment-created",resultData:null});if(o.isInit)return ul(u,o,r,i,a);var l=al(n.type,n.mimeType),d="mp4"===l||void 0===l;if(t&&d){if(il())return ll(u,n,r,a,i);Rn("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}return d?Jo({url:u,responseType:"arraybuffer",headers:Array.isArray(s)?{Range:ys(s)}:null,timeout:r.timeout,connectionTimeout:r.connectionTimeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}})):Jo({url:u,responseType:"text",headers:Array.isArray(s)?{Range:ys(s)}:null,timeout:r.timeout,connectionTimeout:r.connectionTimeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}}(e);return{manifest:{loadManifest:t,parseManifest:n},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:Ol(e)}}};function Ll(e){void 0===e.transports.dash&&(e.transports.dash=Nl),e.dashParsers.js=el,e.mainThreadMediaSourceInit=ja,e.codecSupportProber=Qa}function Ul(e,t){var n;if(t.length!==e.length)return!0;for(var r=0;r<t.length;r++)if(t[r].nativeTrack!==(null===(n=e[r])||void 0===n?void 0:n.nativeTrack))return!0;return!1}function Bl(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_audio_"+o+"_"+s.toString();r[o]=s+1;var l={language:a.language,id:u,normalized:Pn(a.language),audioDescription:"descriptions"===a.kind||"description"===a.kind,representations:[]};n.push({track:l,nativeTrack:a})}return n}function Fl(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_text_"+o+"_"+s.toString();r[o]=s+1;var l="forced"===a.kind||void 0,d={language:a.language,forced:l,label:a.label,id:u,normalized:Pn(a.language),closedCaption:"captions"===a.kind};n.push({track:d,nativeTrack:a})}return n}function zl(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_video_"+o+"_"+s.toString();r[o]=s+1,n.push({track:{id:u,representations:[]},nativeTrack:a})}return n}var Vl=function(e){function t(t){var n,r,i,a;return(n=e.call(this)||this)._nativeAudioTracks=t.audioTracks,n._nativeVideoTracks=t.videoTracks,n._nativeTextTracks=t.textTracks,n._audioTracks=void 0!==n._nativeAudioTracks?Bl(n._nativeAudioTracks):[],n._videoTracks=void 0!==n._nativeVideoTracks?zl(n._nativeVideoTracks):[],n._textTracks=void 0!==n._nativeTextTracks?Fl(n._nativeTextTracks):[],n._lastEmittedNativeAudioTrack=null===(r=n._getCurrentAudioTrack())||void 0===r?void 0:r.nativeTrack,n._lastEmittedNativeVideoTrack=null===(i=n._getCurrentVideoTrack())||void 0===i?void 0:i.nativeTrack,n._lastEmittedNativeTextTrack=null===(a=n._getCurrentTextTrack())||void 0===a?void 0:a.nativeTrack,n._handleNativeTracksCallbacks(),n}u(t,e);var n=t.prototype;return n.setAudioTrackById=function(e){for(var t=0;t<this._audioTracks.length;t++){var n=this._audioTracks[t],r=n.track,i=n.nativeTrack;if(r.id===e)return this._enableAudioTrackFromIndex(t),void(this._audioTrackLockedOn=i)}throw new Error("Audio track not found.")},n.disableTextTrack=function(){Kl(this._textTracks),this._textTrackLockedOn=null},n.setTextTrackById=function(e){for(var t=!1,n=0;n<this._textTracks.length;n++){var r=this._textTracks[n],i=r.track,a=r.nativeTrack;i.id===e?(a.mode="showing",t=!0,this._textTrackLockedOn=a):"showing"!==a.mode&&"hidden"!==a.mode||(a.mode="disabled")}if(!t)throw new Error("Text track not found.")},n.disableVideoTrack=function(){Gl(this._videoTracks),this._videoTrackLockedOn=null},n.setVideoTrackById=function(e){for(var t=0;t<this._videoTracks.length;t++){var n=this._videoTracks[t],r=n.track,i=n.nativeTrack;if(r.id===e)return i.selected=!0,void(this._videoTrackLockedOn=i)}throw new Error("Video track not found.")},n.getChosenAudioTrack=function(){var e=this._getCurrentAudioTrack();return _(e)?e:e.track},n.getChosenTextTrack=function(){var e=this._getCurrentTextTrack();return _(e)?e:e.track},n.getChosenVideoTrack=function(){var e=this._getCurrentVideoTrack();return _(e)?e:e.track},n.getAvailableAudioTracks=function(){return this._audioTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,language:t.language,normalized:t.normalized,audioDescription:t.audioDescription,active:n.enabled,representations:t.representations}}))},n.getAvailableTextTracks=function(){return this._textTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,label:t.label,forced:t.forced,language:t.language,normalized:t.normalized,closedCaption:t.closedCaption,active:"showing"===n.mode}}))},n.getAvailableVideoTracks=function(){return this._videoTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,representations:t.representations,active:n.selected}}))},n.dispose=function(){void 0!==this._nativeVideoTracks&&(this._nativeVideoTracks.onchange=null,this._nativeVideoTracks.onaddtrack=null,this._nativeVideoTracks.onremovetrack=null),void 0!==this._nativeAudioTracks&&(this._nativeAudioTracks.onchange=null,this._nativeAudioTracks.onaddtrack=null,this._nativeAudioTracks.onremovetrack=null),void 0!==this._nativeTextTracks&&(this._nativeTextTracks.onchange=null,this._nativeTextTracks.onaddtrack=null,this._nativeTextTracks.onremovetrack=null),this.removeEventListener()},n._getCurrentAudioTrack=function(){if(void 0!==this._nativeAudioTracks){for(var e=0;e<this._audioTracks.length;e++){var t=this._audioTracks[e];if(t.nativeTrack.enabled)return t}return null}},n._getCurrentVideoTrack=function(){if(void 0!==this._nativeVideoTracks){for(var e=0;e<this._videoTracks.length;e++){var t=this._videoTracks[e];if(t.nativeTrack.selected)return t}return null}},n._getCurrentTextTrack=function(){if(void 0!==this._nativeTextTracks){for(var e=0;e<this._textTracks.length;e++){var t=this._textTracks[e];if("showing"===t.nativeTrack.mode)return t}return null}},n._setPreviouslyLockedAudioTrack=function(){if(void 0!==this._audioTrackLockedOn)if(null===this._audioTrackLockedOn)for(var e=0;e<this._audioTracks.length;e++){this._audioTracks[e].nativeTrack.enabled=!1}else for(var t=0;t<this._audioTracks.length;t++){if(this._audioTracks[t].nativeTrack===this._audioTrackLockedOn)return void this._enableAudioTrackFromIndex(t)}},n._setPreviouslyLockedTextTrack=function(){if(void 0!==this._textTrackLockedOn)if(null!==this._textTrackLockedOn)for(var e=0;e<this._textTracks.length;e++){var t=this._textTracks[e].nativeTrack;if(t===this._textTrackLockedOn)return Wl(this._textTracks,t),void("showing"!==t.mode&&(t.mode="showing"))}else Kl(this._textTracks)},n._setPreviouslyLockedVideoTrack=function(){if(void 0!==this._videoTrackLockedOn)if(null!==this._videoTrackLockedOn)for(var e=0;e<this._videoTracks.length;e++){var t=this._videoTracks[e].nativeTrack;if(t===this._videoTrackLockedOn)return void(t.selected=!0)}else Gl(this._videoTracks)},n._handleNativeTracksCallbacks=function(){var e=this;void 0!==this._nativeAudioTracks&&(this._nativeAudioTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeAudioTracks){var r=Bl(e._nativeAudioTracks);if(Ul(e._audioTracks,r)){e._audioTracks=r,e._setPreviouslyLockedAudioTrack(),e.trigger("availableAudioTracksChange",e.getAvailableAudioTracks());var i=e._getCurrentAudioTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeAudioTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeAudioTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeAudioTracks){var r=Bl(e._nativeAudioTracks);if(Ul(e._audioTracks,r)){e._audioTracks=r,e.trigger("availableAudioTracksChange",e.getAvailableAudioTracks());var i=e._getCurrentAudioTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeAudioTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeAudioTracks.onchange=function(){if(void 0!==e._audioTracks)for(var t=0;t<e._audioTracks.length;t++){var n=e._audioTracks[t],r=n.track,i=n.nativeTrack;if(i.enabled)return void(i!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",r),e._lastEmittedNativeAudioTrack=i))}null!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null),e._lastEmittedNativeAudioTrack=null)}),void 0!==this._nativeTextTracks&&(this._nativeTextTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeTextTracks){var r=Fl(e._nativeTextTracks);if(Ul(e._textTracks,r)){e._textTracks=r,e._setPreviouslyLockedTextTrack(),e.trigger("availableTextTracksChange",e.getAvailableTextTracks());var i=e._getCurrentTextTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeTextTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeTextTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeTextTracks){var r=Fl(e._nativeTextTracks);if(Ul(e._textTracks,r)){e._textTracks=r,e._setPreviouslyLockedTextTrack(),e.trigger("availableTextTracksChange",e.getAvailableTextTracks());var i=e._getCurrentTextTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeTextTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeTextTracks.onchange=function(){if(void 0!==e._textTracks)for(var t=0;t<e._textTracks.length;t++){var n=e._textTracks[t],r=n.track,i=n.nativeTrack;if("showing"===i.mode)return void(i!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",r),e._lastEmittedNativeTextTrack=i))}null!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null),e._lastEmittedNativeTextTrack=null)}),void 0!==this._nativeVideoTracks&&(this._nativeVideoTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeVideoTracks){var r=zl(e._nativeVideoTracks);if(Ul(e._videoTracks,r)){e._videoTracks=r,e._setPreviouslyLockedVideoTrack(),e.trigger("availableVideoTracksChange",e.getAvailableVideoTracks());var i=e._getCurrentVideoTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeVideoTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeVideoTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeVideoTracks){var r=zl(e._nativeVideoTracks);if(Ul(e._videoTracks,r)){e._videoTracks=r,e._setPreviouslyLockedVideoTrack(),e.trigger("availableVideoTracksChange",e.getAvailableVideoTracks());var i=e._getCurrentVideoTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeVideoTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeVideoTracks.onchange=function(){if(void 0!==e._videoTracks)for(var t=0;t<e._videoTracks.length;t++){var n=e._videoTracks[t],r=n.track,i=n.nativeTrack;if(i.selected)return void(i!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",r),e._lastEmittedNativeVideoTrack=i))}null!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null),e._lastEmittedNativeVideoTrack=null)})},n._enableAudioTrackFromIndex=function(e){!function(e,t){for(var n=0;n<e.length;n++)ee&&n===t||(e[n].enabled=!1);t<0||t>=e.length||(e[t].enabled=!0)}(this._audioTracks.map((function(e){return e.nativeTrack})),e)},t}(ie);function Kl(e){for(var t=0;t<e.length;t++){e[t].nativeTrack.mode="disabled"}}function Wl(e,t){for(var n=0;n<e.length;n++){var r=e[n].nativeTrack;r===t||"showing"!==r.mode&&"hidden"!==r.mode||(r.mode="disabled")}}function Gl(e){for(var t=0;t<e.length;t++){e[t].nativeTrack.selected=!1}}var jl=function(e){function t(t){var n;return(n=e.call(this)||this)._settings=t,n._initCanceller=new ht,n}u(t,e);var n=t.prototype;return n.prepare=function(){},n.start=function(e,t){var n=this,r=this._initCanceller.signal,i=this._settings,a=i.keySystems,o=i.speed,s=i.url;Gi(e);var u=new A(null);u.finish();var l=Ra(e,a,u,{onError:function(e){return n._onFatalError(e)},onWarning:function(e){return n.trigger("warning",e)},onBlackListProtectionData:b,onKeyIdsCompatibilityUpdate:b},r);Ka(e,(function(e){return n._onFatalError(e)}),r);var d=new Ma(t,null,o);d.addEventListener("stalled",(function(e){return n.trigger("stalled",e)})),d.addEventListener("unstalled",(function(){return n.trigger("unstalled",null)})),d.addEventListener("warning",(function(e){return n.trigger("warning",e)})),r.register((function(){d.destroy()})),d.start(),l.onUpdate((function(i,a){"uninitialized"!==i.initializationState.type&&(a(),oe.info("Setting URL to HTMLMediaElement",s),e.src=s,r.register((function(){oe.info("Init: Removing directfile src from media element",e.src),Gi(e)})),"awaiting-media-link"===i.initializationState.type?(i.initializationState.value.isMediaLinked.setValue(!0),l.onUpdate((function(r,i){"initialized"===r.initializationState.type&&(i(),n._seekAndPlay(e,t))}),{emitCurrentValue:!0,clearSignal:r})):(Xe(i.initializationState.type),n._seekAndPlay(e,t)))}),{emitCurrentValue:!0,clearSignal:r})},n.updateContentUrls=function(e,t){throw new Error("Cannot update content URL of directfile contents")},n.dispose=function(){this._initCanceller.cancel()},n._onFatalError=function(e){this._initCanceller.cancel(),this.trigger("error",e)},n._seekAndPlay=function(e,t){var n=this,r=this._initCanceller.signal,i=this._settings,a=i.autoPlay,o=i.startAt;Ia({mediaElement:e,playbackObserver:t,startTime:function(){oe.debug("Init: Calculating initial time");var t=function(e,t){if(_(t))return 0;if(!_(t.position))return t.position;if(null!=t.wallClockTime)return t.wallClockTime;if(null!=t.fromFirstPosition)return t.fromFirstPosition;var n=e.duration;if("number"==typeof t.fromLastPosition)return _(n)||!isFinite(n)?(oe.warn("startAt.fromLastPosition set but no known duration, beginning at 0."),0):Math.max(0,n+t.fromLastPosition);if("number"==typeof t.fromLivePosition){var r=e.seekable.length>0?e.seekable.end(0):n;return _(r)?(oe.warn("startAt.fromLivePosition set but no known live position, beginning at 0."),0):Math.max(0,r+t.fromLivePosition)}if(null!=t.percentage){if(_(n)||!isFinite(n))return oe.warn("startAt.percentage set but no known duration, beginning at 0."),0;var i=t.percentage;return i>=100?n:i<=0?0:n*(+i/100)}return 0}(e,o);return oe.debug("Init: Initial time calculated:",t),t},mustAutoPlay:a,onWarning:function(e){return n.trigger("warning",e)},isDirectfile:!0},r).autoPlayResult.then((function(){return Aa(t,e,!0,r).onUpdate((function(e,t){e&&(t(),n.trigger("loaded",{segmentBuffersStore:null}))}),{emitCurrentValue:!0,clearSignal:r})})).catch((function(e){r.isCancelled()||n._onFatalError(e)}))},t}(Oi);function Hl(e){e.directfile={initDirectFile:jl,mediaElementTracksStore:Vl}}var ql,Yl=g.WebKitMediaKeys;void 0!==Yl&&"function"==typeof Yl.isTypeSupported&&"function"==typeof Yl.prototype.createSession&&"function"==typeof HTMLMediaElement.prototype.webkitSetMediaKeys&&(ql=Yl);var Ql,$l=function(){function e(e,t,n){this._keyType=e,this._mediaKeys=t,this._configuration=n}var t=e.prototype;return t.createMediaKeys=function(){var e=this;return new Promise((function(t){return t(e._mediaKeys)}))},t.getConfiguration=function(){return this._configuration},o(e,[{key:"keySystem",get:function(){return this._keyType}}]),e}(),Xl=g.MSMediaKeys;function Zl(e){try{var t=e();return"object"==typeof t&&null!==t&&"function"==typeof t.then?t:Promise.resolve(t)}catch(e){return Promise.reject(e)}}void 0!==Xl&&void 0!==Xl.prototype&&"function"==typeof Xl.isTypeSupported&&"function"==typeof Xl.prototype.createSession&&(Ql=Xl);var Jl,ed=function(e){function t(t){var n;return(n=e.call(this)||this).expiration=NaN,n.keyStatuses=new Map,n._mk=t,n._sessionClosingCanceller=new ht,n.closed=new Promise((function(e){n._sessionClosingCanceller.signal.register((function(){return e()}))})),n.update=function(e){return new Promise((function(t,r){if(void 0===n._ss)return r("MediaKeySession not set.");try{t(n._ss.update(e,""))}catch(e){r(e)}}))},n}u(t,e);var n=t.prototype;return n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r=t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer);n._ss=n._mk.createSession("video/mp4",r),N(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"message",e)}),n._sessionClosingCanceller.signal),L(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyadded",e)}),n._sessionClosingCanceller.signal),U(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyerror",e)}),n._sessionClosingCanceller.signal),e()}))},n.close=function(){var e=this;return new Promise((function(t){null!=e._ss&&(e._ss.close(),e._ss=void 0),e._sessionClosingCanceller.cancel(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},o(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._ss)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(ie),td=function(){function e(e){if(void 0===Ql)throw new Error("No MSMediaKeys API.");this._mediaKeys=new Ql(e)}var t=e.prototype;return t._setVideo=function(e){var t=this;return Zl((function(){t._videoElement=e,void 0!==t._videoElement.msSetMediaKeys&&t._videoElement.msSetMediaKeys(t._mediaKeys)}))},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new ed(this._mediaKeys)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();var nd=g.MozMediaKeys;function rd(e){return"function"==typeof(null==e?void 0:e.webkitGenerateKeyRequest)}void 0!==nd&&void 0!==nd.prototype&&"function"==typeof nd.isTypeSupported&&"function"==typeof nd.prototype.createSession&&(Jl=nd);var id=function(e){function t(t,n){var r;(r=e.call(this)||this)._vid=t,r._key=n,r.sessionId="",r._closeSession=b,r.keyStatuses=new Map,r.expiration=NaN;var i=function(e){r.trigger(e.type,e)};return r.closed=new Promise((function(e){r._closeSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.removeEventListener(e,i),t.removeEventListener("webkit"+e,i)})),e()}})),["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.addEventListener(e,i),t.addEventListener("webkit"+e,i)})),r}u(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){try{if(t._key.indexOf("clearkey")>=0){var i=e instanceof ArrayBuffer?new Uint8Array(e):e,a=JSON.parse(go(i)),o=Po(a.keys[0].k),s=Po(a.keys[0].kid);n(t._vid.webkitAddKey(t._key,o,s,""))}else n(t._vid.webkitAddKey(t._key,e,null,""))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){n._vid.webkitGenerateKeyRequest(n._key,t),e()}))},n.close=function(){var e=this;return new Promise((function(t){e._closeSession(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},t}(ie),ad=function(){function e(e){this._keySystem=e}var t=e.prototype;return t._setVideo=function(e){var t=this;return Zl((function(){if(!rd(e))throw new Error("Video not attached to the MediaKeys");t._videoElement=e}))},t.createSession=function(){if(null==this._videoElement)throw new Error("Video not attached to the MediaKeys");return new id(this._videoElement,this._keySystem)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();function od(e,t){var n=e instanceof Uint8Array?e:new Uint8Array(e),r=t instanceof Uint8Array?t:new Uint8Array(t),i=function(e,t){return e[t+0]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]}(n,0);if(i+4!==n.length)throw new Error("Unsupported WebKit initData.");var a=po(n),o=a.indexOf("skd://"),s=function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint8Array(t),r=0;r<n.length;r+=2){var i=e.charCodeAt(r/2);n[r]=255&i,n[r+1]=i>>8&255}return n}(o>-1?a.substring(o+6):a),u=0,l=new Uint8Array(n.byteLength+4+s.byteLength+4+r.byteLength);return l.set(n),u+=n.length,l.set(fa(s.byteLength),u),u+=4,l.set(s,u),u+=s.byteLength,l.set(fa(r.byteLength),u),u+=4,l.set(r,u),l}function sd(e,t){var n=e;return Zl((function(){if(void 0===n.webkitSetMediaKeys)throw new Error("No webKitMediaKeys API.");n.webkitSetMediaKeys(t)}))}var ud=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._serverCertificate=r,i._videoElement=t,i._keyType=n,i._unbindSession=b,i._closeSession=b,i.closed=new Promise((function(e){i._closeSession=e})),i.keyStatuses=new Map,i.expiration=NaN,i}u(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){if(void 0===t._nativeSession||void 0===t._nativeSession.update||"function"!=typeof t._nativeSession.update)return r("Unavailable WebKit key session.");try{var i;i=e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e.buffer),n(t._nativeSession.update(i))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r,i,a=n._videoElement;if(void 0===(null===(r=a.webkitKeys)||void 0===r?void 0:r.createSession))throw new Error("No WebKitMediaKeys API.");if(yi(n._keyType,"com.apple.fps")){if(void 0===n._serverCertificate)throw new Error("A server certificate is needed for creating fairplay session.");i=od(t,n._serverCertificate)}else i=t;var o=a.webkitKeys.createSession("video/mp4",i);if(null==o)throw new Error("Impossible to get the key sessions");n._listenEvent(o),n._nativeSession=o,e()}))},n.close=function(){var e=this;return new Promise((function(t,n){e._unbindSession(),e._closeSession(),void 0!==e._nativeSession?(e._nativeSession.close(),t()):n("No session to close.")}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},n._listenEvent=function(e){var t=this;this._unbindSession();var n=function(e){t.trigger(e.type,e)};["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.addEventListener(t,n),e.addEventListener("webkit"+t,n)})),this._unbindSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.removeEventListener(t,n),e.removeEventListener("webkit"+t,n)}))}},o(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._nativeSession)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(ie),ld=function(){function e(e){if(void 0===ql)throw new Error("No WebKitMediaKeys API.");this._keyType=e,this._mediaKeys=new ql(e)}var t=e.prototype;return t._setVideo=function(e){if(this._videoElement=e,void 0===this._videoElement)throw new Error("Video not attached to the MediaKeys");return sd(this._videoElement,this._mediaKeys)},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new ud(this._videoElement,this._keyType,this._serverCertificate)},t.setServerCertificate=function(e){return this._serverCertificate=e,Promise.resolve()},e}();function dd(){if(void 0===ql)throw new Error("No WebKitMediaKeys API.");return{isTypeSupported:ql.isTypeSupported,createCustomMediaKeys:function(e){return new ld(e)},setMediaKeys:function(e,t){if(null===t)return sd(e,t);if(!(t instanceof ld))throw new Error("Custom setMediaKeys is supposed to be called with webkit custom MediaKeys.");return t._setVideo(e)}}}var cd=function(e){var t,n,r,i,a=fd;if("standard"!==e&&("auto"!==e||(X||Z)&&void 0!==ql)||!m&&_(navigator.requestMediaKeySystemAccess)){var o,s;if("webkit"===e&&void 0!==ql){r=x(["needkey"]);var u=dd();o=u.isTypeSupported,s=u.createCustomMediaKeys,a=u.setMediaKeys,i="webkit"}else if(rd(null===(t=g.HTMLVideoElement)||void 0===t?void 0:t.prototype)){r=x(["needkey"]);var l={isTypeSupported:function(e){var t=document.querySelector("video");return null==t&&(t=document.createElement("video")),null!=t&&"function"==typeof t.canPlayType&&!!t.canPlayType("video/mp4",e)},createCustomMediaKeys:function(e){return new ad(e)},setMediaKeys:function(e,t){if(null===t)return Promise.resolve(void 0);if(!(t instanceof ad))throw new Error("Custom setMediaKeys is supposed to be called with old webkit custom MediaKeys.");return t._setVideo(e)}};o=l.isTypeSupported,s=l.createCustomMediaKeys,a=l.setMediaKeys,i="older-webkit"}else if(void 0!==ql){r=x(["needkey"]);var d=dd();o=d.isTypeSupported,s=d.createCustomMediaKeys,a=d.setMediaKeys,i="webkit"}else if(Y&&void 0!==Ql){r=x(["encrypted","needkey"]);var c={isTypeSupported:function(e,t){if(void 0===Ql)throw new Error("No MSMediaKeys API.");return void 0!==t?Ql.isTypeSupported(e,t):Ql.isTypeSupported(e)},createCustomMediaKeys:function(e){return new td(e)},setMediaKeys:function(e,t){if(null===t)return Promise.resolve(void 0);if(!(t instanceof td))throw new Error("Custom setMediaKeys is supposed to be called with IE11 custom MediaKeys.");return t._setVideo(e)}};o=c.isTypeSupported,s=c.createCustomMediaKeys,a=c.setMediaKeys,i="ms"}else if(void 0!==Jl){r=x(["encrypted","needkey"]);var f={isTypeSupported:function(e,t){if(void 0===Jl)throw new Error("No MozMediaKeys API.");return void 0!==t?Jl.isTypeSupported(e,t):Jl.isTypeSupported(e)},createCustomMediaKeys:function(e){if(void 0===Jl)throw new Error("No MozMediaKeys API.");return new Jl(e)},setMediaKeys:function(e,t){return Zl((function(){var n=e;if(void 0===n.mozSetMediaKeys||"function"!=typeof n.mozSetMediaKeys)throw new Error("Can't set video on MozMediaKeys.");return n.mozSetMediaKeys(t)}))}};o=f.isTypeSupported,s=f.createCustomMediaKeys,a=f.setMediaKeys,i="moz"}else{r=x(["encrypted","needkey"]);var v=g.MediaKeys,p=function(){if(void 0===v)throw new Se("MEDIA_KEYS_NOT_SUPPORTED","No `MediaKeys` implementation found in the current browser.");if(void 0===v.isTypeSupported){throw new Error("This browser seems to be unable to play encrypted contents currently.Note: Some browsers do not allow decryption in some situations, like when not using HTTPS.")}};o=function(e){return p(),Xe(v.isTypeSupported),v.isTypeSupported(e)},s=function(e){return p(),new v(e)},i="unknown"}n=function(e,t){if(!o(e))return Promise.reject(new Error("Unsupported key type"));for(var n=0;n<t.length;n++){var r=t[n],i=r.videoCapabilities,a=r.audioCapabilities,u=r.initDataTypes,l=r.distinctiveIdentifier,d=!0;if(d=(d=d&&(null==u||u.some((function(e){return"cenc"===e}))))&&"required"!==l){var c={initDataTypes:["cenc"],distinctiveIdentifier:"not-allowed",persistentState:"required",sessionTypes:["temporary","persistent-license"]};void 0!==i&&(c.videoCapabilities=i),void 0!==a&&(c.audioCapabilities=a);var f=s(e);return Promise.resolve(new $l(e,f,c))}}return Promise.reject(new Error("Unsupported configuration"))}}else n=function(){var e;return(e=navigator).requestMediaKeySystemAccess.apply(e,arguments)},r=x(["encrypted"]),i="standard";return{requestMediaKeySystemAccess:n,onEncrypted:r,setMediaKeys:a,implementation:i}}("auto");function fd(e,t){try{var n,r=e;return"function"==typeof r.setMediaKeys?n=r.setMediaKeys(t):"function"==typeof r.webkitSetMediaKeys?n=r.webkitSetMediaKeys(t):"function"==typeof r.mozSetMediaKeys?n=r.mozSetMediaKeys(t):"function"==typeof r.msSetMediaKeys&&null!==t&&(n=r.msSetMediaKeys(t)),"object"==typeof n&&null!==n&&"function"==typeof n.then?n:Promise.resolve(n)}catch(e){return Promise.reject(e)}}var vd=cd,pd=sa(ho("pssh"),0);function hd(e,t){for(var n=0;n<e.length;n++){var r=e[n];if((void 0===t.systemId||void 0===r.systemId||t.systemId===r.systemId)&&on(t.data,r.data))return!0}return!1}function md(e){var t=e.initData,n=e.initDataType;if(null==t)return oe.warn("Compat: No init data found on media encrypted event."),null;var r=function(e){for(var t=[],n=0;n<e.length;){if(e.length<n+8||sa(e,n+4)!==pd)return oe.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var r=sa(new Uint8Array(e),n);if(n+r>e.length)return oe.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var i=e.subarray(n,n+r),a={systemId:fl(i,8),data:i};hd(t,a)?oe.warn("Compat: Duplicated PSSH found in initialization data, removing it."):t.push(a),n+=r}return n!==e.length?(oe.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}]):t}(new Uint8Array(t));return{type:n,values:r}}function gd(e){return kt.setState(e,null),vd.setMediaKeys(e,null).then((function(){oe.info("DRM: MediaKeys disabled with success")})).catch((function(e){oe.error("DRM: Could not disable MediaKeys",e instanceof Error?e:"Unknown Error")}))}function yd(){return(yd=_t(St().mark((function e(t,n,r){var i,a,o,s,u,l,d;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.emeImplementation,a=n.keySystemOptions,o=n.loadedSessionsStore,s=n.mediaKeySystemAccess,u=n.mediaKeys,l=kt.getState(t),d=null!==l&&l.loadedSessionsStore!==o?l.loadedSessionsStore.closeAllSessions():Promise.resolve(),e.next=5,d;case 5:if(!r.isCancelled()){e.next=7;break}throw r.cancellationError;case 7:if(kt.setState(t,{emeImplementation:i,keySystemOptions:a,mediaKeySystemAccess:s,mediaKeys:u,loadedSessionsStore:o}),t.mediaKeys!==u){e.next=10;break}return e.abrupt("return");case 10:oe.info("DRM: Attaching MediaKeys to the media element"),i.setMediaKeys(t,u).then((function(){oe.info("DRM: MediaKeys attached with success")})).catch((function(e){oe.error("DRM: Could not set MediaKeys",e instanceof Error?e:"Unknown Error")}));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function _d(e){if(""===e.sessionId)return!1;var t=e.keyStatuses,n=[];return t.forEach((function(e){n.push(e)})),n.length<=0?(oe.debug("DRM: isSessionUsable: MediaKeySession given has an empty keyStatuses",e.sessionId),!1):Qe(n,"expired")?(oe.debug("DRM: isSessionUsable: MediaKeySession given has an expired key",e.sessionId),!1):Qe(n,"internal-error")?(oe.debug("DRM: isSessionUsable: MediaKeySession given has a key with an internal-error",e.sessionId),!1):(oe.debug("DRM: isSessionUsable: MediaKeySession is usable",e.sessionId),!0)}function bd(e,t,n,r){var i=e.loadedSessionsStore,a=e.persistentSessionsStore;return"temporary"===n?Sd(i,t):null===a?(oe.warn("DRM: Cannot create persistent MediaKeySession, PersistentSessionsStore not created."),Sd(i,t)):function(e,t,n,r){return Ed.apply(this,arguments)}(i,a,t,r)}function Sd(e,t){oe.info("DRM: Creating a new temporary session");var n=e.createSession(t,"temporary");return Promise.resolve({type:"created-session",value:n})}function Ed(){return Ed=_t(St().mark((function e(t,n,r,i){var a,o,s,u,l,d;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d=function(){return d=_t(St().mark((function e(){var o,s;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===i.cancellationError){e.next=2;break}throw i.cancellationError;case 2:return oe.info("DRM: Removing previous persistent session."),null!==(o=n.get(r))&&n.delete(o.sessionId),e.prev=5,e.next=8,t.closeSession(a.mediaKeySession);case 8:e.next=15;break;case 10:if(e.prev=10,e.t0=e.catch(5),""===a.mediaKeySession.sessionId){e.next=14;break}throw e.t0;case 14:t.removeSessionWithoutClosingIt(a.mediaKeySession);case 15:if(null===i.cancellationError){e.next=17;break}throw i.cancellationError;case 17:return s=t.createSession(r,"persistent-license"),e.abrupt("return",{type:"created-session",value:s});case 19:case"end":return e.stop()}}),e,null,[[5,10]])}))),d.apply(this,arguments)},l=function(){return d.apply(this,arguments)},null===i.cancellationError){e.next=4;break}throw i.cancellationError;case 4:if(oe.info("DRM: Creating persistent MediaKeySession"),a=t.createSession(r,"persistent-license"),null!==(o=n.getAndReuse(r))){e.next=9;break}return e.abrupt("return",{type:"created-session",value:a});case 9:return e.prev=9,e.next=12,t.loadPersistentSession(a.mediaKeySession,o.sessionId);case 12:if(s=e.sent){e.next=19;break}return oe.warn("DRM: No data stored for the loaded session"),n.delete(o.sessionId),t.removeSessionWithoutClosingIt(a.mediaKeySession),u=t.createSession(r,"persistent-license"),e.abrupt("return",{type:"created-session",value:u});case 19:if(!s||!_d(a.mediaKeySession)){e.next=23;break}return n.add(r,r.keyIds,a.mediaKeySession),oe.info("DRM: Succeeded to load persistent session."),e.abrupt("return",{type:"loaded-persistent-session",value:a});case 23:return oe.warn("DRM: Previous persistent session not usable anymore."),e.abrupt("return",l());case 27:return e.prev=27,e.t0=e.catch(9),oe.warn("DRM: Unable to load persistent session: "+(e.t0 instanceof Error?e.t0.toString():"Unknown Error")),e.abrupt("return",l());case 31:case"end":return e.stop()}}),e,null,[[9,27]])}))),Ed.apply(this,arguments)}function Td(e,t){return kd.apply(this,arguments)}function kd(){return(kd=_t(St().mark((function e(t,n){var r,i,a,o,s;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n<0||n>=t.getLength())){e.next=2;break}return e.abrupt("return");case 2:for(oe.info("DRM: LSS cache limit exceeded",n,t.getLength()),r=[],i=t.getAll().slice(),a=i.length-n,o=0;o<a;o++)s=i[o],r.push(t.closeSession(s.mediaKeySession));return e.next=9,Promise.all(r);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function wd(e,t,n,r,i){return Ad.apply(this,arguments)}function Ad(){return(Ad=_t(St().mark((function e(t,n,r,i,a){var o,s,u,l,d;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null,s=n.loadedSessionsStore,u=n.persistentSessionsStore,null===(l=s.reuse(t))){e.next=11;break}if(!_d(o=l.mediaKeySession)){e.next=10;break}return oe.info("DRM: Reuse loaded session",o.sessionId),e.abrupt("return",{type:"loaded-open-session",value:{mediaKeySession:o,sessionType:l.sessionType,keySessionRecord:l.keySessionRecord}});case 10:null!==u&&""!==l.mediaKeySession.sessionId&&u.delete(l.mediaKeySession.sessionId);case 11:if(null===o){e.next=16;break}return e.next=14,s.closeSession(o);case 14:if(null===a.cancellationError){e.next=16;break}throw a.cancellationError;case 16:return e.next=18,Td(s,i);case 18:if(null===a.cancellationError){e.next=20;break}throw a.cancellationError;case 20:return e.next=22,bd(n,t,r,a);case 22:return d=e.sent,e.abrupt("return",{type:d.type,value:{mediaKeySession:d.value.mediaKeySession,sessionType:d.value.sessionType,keySessionRecord:d.value.keySessionRecord}});case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Id(e,t,n){var r=t.getConfiguration();if(Y||null==r)return null;var i=e.filter((function(e){return e.type===n.type&&(!!(_(e.persistentLicenseConfig)&&"required"!==e.persistentState||"required"===r.persistentState)&&("required"!==e.distinctiveIdentifier||"required"===r.distinctiveIdentifier))}))[0];return null!=i?{keySystemOptions:i,keySystemAccess:t}:null}function Rd(e){var t=e.keyName,n=e.keyType,r=e.keySystemOptions,i=["temporary"],a="optional",o="optional";_(r.persistentLicenseConfig)||(a="required",i.push("persistent-license")),_(r.persistentState)||(a=r.persistentState),_(r.distinctiveIdentifier)||(o=r.distinctiveIdentifier);var s,u,l=p.getCurrent(),d=l.EME_DEFAULT_AUDIO_CODECS,c=l.EME_DEFAULT_VIDEO_CODECS,f=l.EME_DEFAULT_WIDEVINE_ROBUSTNESSES,v=l.EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES,h=r.audioCapabilitiesConfig,m=r.videoCapabilitiesConfig;if("full"===(null==h?void 0:h.type))s=h.value;else{var g;0===(g="robustness"===(null==h?void 0:h.type)?h.value:"widevine"===t?f:"com.microsoft.playready.recommendation"===n?v:[]).length&&g.push(void 0);var y="contentType"===(null==h?void 0:h.type)?h.value:d;s=Ds(g,(function(e){return y.map((function(t){return void 0!==e?{contentType:t,robustness:e}:{contentType:t}}))}))}if("full"===(null==m?void 0:m.type))u=m.value;else{var b;0===(b="robustness"===(null==m?void 0:m.type)?m.value:"widevine"===t?f:"com.microsoft.playready.recommendation"===n?v:[]).length&&b.push(void 0);var S="contentType"===(null==m?void 0:m.type)?m.value:c;u=Ds(b,(function(e){return S.map((function(t){return void 0!==e?{contentType:t,robustness:e}:{contentType:t}}))}))}var E={initDataTypes:["cenc"],videoCapabilities:u,audioCapabilities:s,distinctiveIdentifier:o,persistentState:a,sessionTypes:i};return[E,Object.assign(Object.assign({},E),{audioCapabilities:void 0,videoCapabilities:void 0})]}function xd(e,t,n){oe.info("DRM: Searching for compatible MediaKeySystemAccess");var r=kt.getState(e);if(null!==r&&vd.implementation===r.emeImplementation.implementation){var i=Id(t,r.mediaKeySystemAccess,r.keySystemOptions);if(null!==i)return oe.info("DRM: Found cached compatible keySystem"),Promise.resolve({type:"reuse-media-key-system-access",value:{mediaKeySystemAccess:i.keySystemAccess,options:i.keySystemOptions}})}var a=t.reduce((function(e,t){var n,r=p.getCurrent().EME_KEY_SYSTEMS[t.type];if(null!=r)n=r.map((function(e){return{keyName:t.type,keyType:e,keySystemOptions:t}}));else{var i=function(e){for(var t=p.getCurrent().EME_KEY_SYSTEMS,n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];if(Qe(t[i],e))return i}}(t.type);n=[{keyName:i,keyType:t.type,keySystemOptions:t}]}return e.concat(n)}),[]);return o(0);function o(e){return s.apply(this,arguments)}function s(){return(s=_t(St().mark((function e(t){var r,i,s,u,l;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t>=a.length)){e.next=2;break}throw new be("INCOMPATIBLE_KEYSYSTEMS","No key system compatible with your wanted configuration has been found in the current browser.");case 2:if(null!=vd.requestMediaKeySystemAccess){e.next=4;break}throw new Error("requestMediaKeySystemAccess is not implemented in your browser.");case 4:return r=a[t],i=r.keyType,s=r.keySystemOptions,u=Rd(r),oe.debug("DRM: Request keysystem access "+i+","+(t+1)+" of "+a.length),e.prev=8,e.next=11,vd.requestMediaKeySystemAccess(i,u);case 11:return l=e.sent,oe.info("DRM: Found compatible keysystem",i,t+1),e.abrupt("return",{type:"create-media-key-system-access",value:{options:s,mediaKeySystemAccess:l}});case 16:if(e.prev=16,e.t0=e.catch(8),oe.debug("DRM: Rejected access to keysystem",i,t+1),null===n.cancellationError){e.next=21;break}throw n.cancellationError;case 21:return e.abrupt("return",o(t+1));case 22:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}}function Cd(e,t,n){var r;oe.debug("Compat: Calling generateRequest on the MediaKeySession");try{r=function(e){oe.info("Compat: Trying to move CENC PSSH from init data at the end of it.");for(var t=!1,n=new Uint8Array,r=new Uint8Array,i=0;i<e.length;){if(e.length<i+8||sa(e,i+4)!==pd)throw oe.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var a=sa(new Uint8Array(e),i);if(i+a>e.length)throw oe.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var o=e.subarray(i,i+a);if(16===e[i+12]&&119===e[i+13]&&239===e[i+14]&&236===e[i+15]&&192===e[i+16]&&178===e[i+17]&&77===e[i+18]&&2===e[i+19]&&172===e[i+20]&&227===e[i+21]&&60===e[i+22]&&30===e[i+23]&&82===e[i+24]&&226===e[i+25]&&251===e[i+26]&&75===e[i+27]){var s=no(o),u=null===s?void 0:o[s[1]];oe.info("Compat: CENC PSSH found with version",u),void 0===u?oe.warn("Compat: could not read version of CENC PSSH"):t===(1===u)?n=ia(n,o):1===u?(oe.warn("Compat: cenc version 1 encountered, removing every other cenc pssh box."),n=o,t=!0):oe.warn("Compat: filtering out cenc pssh box with wrong version",u)}else r=ia(r,o);i+=a}if(i!==e.length)throw oe.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");return ia(r,n)}(n)}catch(e){r=n}var i=null!=t?t:"";return e.generateRequest(i,r).catch((function(t){if(""!==i||!(t instanceof TypeError))throw t;return oe.warn('Compat: error while calling `generateRequest` with an empty initialization data type. Retrying with a default "cenc" value.',t),e.generateRequest("cenc",r)}))}var Md=100;function Pd(e,t){return Dd.apply(this,arguments)}function Dd(){return(Dd=_t(St().mark((function e(t,n){var r;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe.info("DRM: Load persisted session",n),e.next=3,t.load(n);case 3:if((r=e.sent)&&!(t.keyStatuses.size>0)){e.next=6;break}return e.abrupt("return",r);case 6:return e.abrupt("return",new Promise((function(e){t.addEventListener("keystatuseschange",i);var n=setTimeout(i,Md);function i(){clearTimeout(n),t.removeEventListener("keystatuseschange",i),e(r)}})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Od(e){var t=new ht;return Promise.race([e.close().then((function(){t.cancel()})),e.closed.then((function(){t.cancel()})),function(){return n.apply(this,arguments)}()]);function n(){return(n=_t(St().mark((function e(){var n;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,nr(1e3,t.signal);case 3:return e.next=5,r();case 5:e.next=13;break;case 7:if(e.prev=7,e.t0=e.catch(0),!(e.t0 instanceof gt)){e.next=11;break}return e.abrupt("return");case 11:n=e.t0 instanceof Error?e.t0.message:"Unknown error made it impossible to close the session",oe.error("DRM: "+n);case 13:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function r(){return i.apply(this,arguments)}function i(){return(i=_t(St().mark((function n(){return St().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.update(new Uint8Array(1));case 3:n.next=13;break;case 5:if(n.prev=5,n.t0=n.catch(0),!t.isUsed()){n.next=9;break}return n.abrupt("return");case 9:if(!(n.t0 instanceof Error&&"The session is already closed."===n.t0.message)){n.next=11;break}return n.abrupt("return");case 11:return n.next=13,nr(1e3,t.signal);case 13:if(!t.isUsed()){n.next=15;break}return n.abrupt("return");case 15:throw new Error("Compat: Couldn't know if session is closed");case 16:case"end":return n.stop()}}),n,null,[[0,5]])})))).apply(this,arguments)}}function Nd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ld(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ld(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ld(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ud(e,t){for(var n,r,i=function(){var e=r.value;if(!t.some((function(t){return on(t,e)})))return{v:!1}},a=Nd(e);!(r=a()).done;)if(n=i())return n.v;return!0}function Bd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Fd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Fd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var zd=function(){function e(e){this._initializationData=e,this._keyIds=null}var t=e.prototype;return t.associateKeyIds=function(e){null===this._keyIds&&(this._keyIds=[]);for(var t=0,n=Array.from(e);t<n.length;t++){var r=n[t];this.isAssociatedWithKeyId(r)||this._keyIds.push(r)}},t.isAssociatedWithKeyId=function(e){if(null===this._keyIds)return!1;for(var t,n=Bd(this._keyIds);!(t=n()).done;){if(on(t.value,e))return!0}return!1},t.getAssociatedKeyIds=function(){return null===this._keyIds?[]:this._keyIds},t.isCompatibleWith=function(e){var t=e.keyIds;if(void 0!==t&&t.length>0){if(null!==this._keyIds&&Ud(t,this._keyIds))return!0;if(void 0!==this._initializationData.keyIds)return Ud(t,this._initializationData.keyIds)}return this._checkInitializationDataCompatibility(e)},t._checkInitializationDataCompatibility=function(e){return void 0!==e.keyIds&&e.keyIds.length>0&&void 0!==this._initializationData.keyIds?Ud(e.keyIds,this._initializationData.keyIds):this._initializationData.type===e.type&&this._initializationData.values.isCompatibleWith(e.values)},e}();function Vd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Kd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Kd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Kd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Wd=function(){function e(e){this._mediaKeys=e,this._storage=[]}var t=e.prototype;return t.createSession=function(e,t){var n=this,r=new zd(e);oe.debug("DRM-LSS: calling `createSession`",t);var i=this._mediaKeys.createSession(t),a={mediaKeySession:i,sessionType:t,keySessionRecord:r,isGeneratingRequest:!1,isLoadingPersistentSession:!1,closingStatus:{type:"none"}};return _(i.closed)||i.closed.then((function(){oe.info("DRM-LSS: session was closed, removing it.",i.sessionId);var e=n.getIndex(r);e>=0&&n._storage[e].mediaKeySession===i&&n._storage.splice(e,1)})).catch((function(e){oe.warn("DRM-LSS: MediaKeySession.closed rejected: "+e)})),this._storage.push(Object.assign({},a)),oe.debug("DRM-LSS: MediaKeySession added",a.sessionType,this._storage.length),a},t.reuse=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.keySessionRecord.isCompatibleWith(e))return this._storage.splice(t,1),this._storage.push(n),oe.debug("DRM-LSS: Reusing session:",n.mediaKeySession.sessionId,n.sessionType),Object.assign({},n)}return null},t.getEntryForSession=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.mediaKeySession===e)return Object.assign({},n)}return null},t.generateLicenseRequest=function(){var e=_t(St().mark((function e(t,n,r){var i,a,o,s;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=Vd(this._storage);case 1:if((o=a()).done){e.next=8;break}if((s=o.value).mediaKeySession!==t){e.next=6;break}return i=s,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==i){e.next=11;break}return oe.error("DRM-LSS: generateRequest error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Cd(t,n,r));case 11:if(i.isGeneratingRequest=!0,"none"===i.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,Cd(t,n,r);case 17:e.next=26;break;case 19:if(e.prev=19,e.t0=e.catch(14),void 0!==i){e.next=23;break}throw e.t0;case 23:throw i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start(),e.t0;case 26:if(void 0!==i){e.next=28;break}return e.abrupt("return",void 0);case 28:i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start();case 30:case"end":return e.stop()}}),e,this,[[14,19]])})));return function(t,n,r){return e.apply(this,arguments)}}(),t.loadPersistentSession=function(){var e=_t(St().mark((function e(t,n){var r,i,a,o,s;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=Vd(this._storage);case 1:if((a=i()).done){e.next=8;break}if((o=a.value).mediaKeySession!==t){e.next=6;break}return r=o,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==r){e.next=11;break}return oe.error("DRM-LSS: loadPersistentSession error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Pd(t,n));case 11:if(r.isLoadingPersistentSession=!0,"none"===r.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,Pd(t,n);case 17:s=e.sent,e.next=27;break;case 20:if(e.prev=20,e.t0=e.catch(14),void 0!==r){e.next=24;break}throw e.t0;case 24:throw r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.t0;case 27:if(void 0!==r){e.next=29;break}return e.abrupt("return",s);case 29:return r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.abrupt("return",s);case 32:case"end":return e.stop()}}),e,this,[[14,20]])})));return function(t,n){return e.apply(this,arguments)}}(),t.closeSession=function(){var e=_t(St().mark((function e(t){var n,r,i,a;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Vd(this._storage);case 1:if((i=r()).done){e.next=8;break}if((a=i.value).mediaKeySession!==t){e.next=6;break}return n=a,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==n){e.next=11;break}return oe.warn("DRM-LSS: No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Promise.resolve(!1));case 11:return e.abrupt("return",this._closeEntry(n));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getLength=function(){return this._storage.length},t.getAll=function(){return this._storage},t.closeAllSessions=function(){var e=_t(St().mark((function e(){var t,n,r=this;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._storage,oe.debug("DRM-LSS: Closing all current MediaKeySessions",t.length),this._storage=[],n=t.map((function(e){return r._closeEntry(e)})),e.next=6,Promise.all(n);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.removeSessionWithoutClosingIt=function(e){Xe(e.sessionId);for(var t=this._storage.length-1;t>=0;t--){if(this._storage[t].mediaKeySession===e)return oe.debug("DRM-LSS: Removing session without closing it",e.sessionId),this._storage.splice(t,1),!0}return!1},t.getIndex=function(e){for(var t=0;t<this._storage.length;t++){if(this._storage[t].keySessionRecord===e)return t}return-1},t._closeEntry=function(){var e=_t(St().mark((function e(t){var n;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.mediaKeySession,e.abrupt("return",new Promise((function(e,r){function i(){void 0!==t&&(t.closingStatus={type:"pending"}),Gd(n).then((function(){void 0!==t&&(t.closingStatus={type:"done"}),e(!0)})).catch((function(e){void 0!==t&&(t.closingStatus={type:"failed"}),r(e)}))}void 0!==t&&(t.isLoadingPersistentSession||t.isGeneratingRequest)?t.closingStatus={type:"awaiting",start:i}:i()})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e}();function Gd(e){return jd.apply(this,arguments)}function jd(){return(jd=_t(St().mark((function e(t){return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe.debug("DRM: Trying to close a MediaKeySession",t.sessionId),e.prev=1,e.next=4,Od(t);case 4:return oe.debug("DRM: Succeeded to close MediaKeySession"),e.abrupt("return");case 8:return e.prev=8,e.t0=e.catch(1),oe.error("DRM: Could not close MediaKeySession: "+(e.t0 instanceof Error?e.t0.toString():"Unknown error")),e.abrupt("return");case 12:case"end":return e.stop()}}),e,null,[[1,8]])})))).apply(this,arguments)}function Hd(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e[n],t&=t;return t}var qd=function(){function e(e){this.initData=e}return e.prototype.toJSON=function(){return Mo(this.initData)},e.decode=function(e){return Po(e)},e}();function Yd(e,t){var n,r;return null!==(r=null!==(n=Qd(e,t))&&void 0!==n?n:Qd(t,e))&&void 0!==r&&r}function Qd(e,t){if(0===e.length)return!1;if(t.length<e.length)return null;for(var n=e[0],r=0,i=0;i<t.length;i++){var a=t[i];if(a.systemId===n.systemId){if(a.hash!==n.hash)return!1;if(!on(n.data instanceof Uint8Array?n.data:"string"==typeof n.data?qd.decode(n.data):n.data.initData,a.data instanceof Uint8Array?a.data:"string"==typeof a.data?qd.decode(a.data):a.data.initData))return!1;if(t.length-i<e.length)return null;for(r=1;r<e.length;r++){var o=e[r];for(i+=1;i<t.length;i++){var s=t[i];if(o.systemId===s.systemId){if(o.hash!==s.hash)return!1;if(!on(o.data instanceof Uint8Array?o.data:"string"==typeof o.data?qd.decode(o.data):o.data.initData,s.data instanceof Uint8Array?s.data:"string"==typeof s.data?qd.decode(s.data):s.data.initData))return!1;break}}if(r===t.length)return null}return!0}}return null}function $d(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Xd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Xd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Xd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Zd(e){!function(e,t,n){for(var r in void 0===n&&(n="object"),Xe(_(e)),t)t.hasOwnProperty(r)&&Xe((e[r],t[r]),t[r])}(e,{save:"function",load:"function"},"persistentLicenseConfig")}var Jd=function(){function e(e){Zd(e),this._entries=[],this._storage=e;try{var t=this._storage.load();Array.isArray(t)||(t=[]),this._entries=t}catch(e){oe.warn("DRM-PSS: Could not get entries from license storage",e instanceof Error?e:""),this.dispose()}}var t=e.prototype;return t.getLength=function(){return this._entries.length},t.getAll=function(){return this._entries},t.get=function(e){var t=this._getIndex(e);return-1===t?null:this._entries[t]},t.getAndReuse=function(e){var t=this._getIndex(e);if(-1===t)return null;var n=this._entries.splice(t,1)[0];return this._entries.push(n),n},t.add=function(e,t,n){var r;if(!_(n)&&y(n.sessionId)){var i=n.sessionId,a=this._getIndex(e);if(a>=0){var o=void 0===t?3:4,s=this._entries[a];if((null!==(r=s.version)&&void 0!==r?r:-1)>=o&&i===s.sessionId)return;oe.info("DRM-PSS: Updating session info.",i),this._entries.splice(a,1)}else oe.info("DRM-PSS: Add new session",i);var u=e.values.getFormattedValues().map((function(e){var t=e.systemId,n=e.data;return{systemId:t,hash:e.hash,data:new qd(n)}}));void 0===t?this._entries.push({version:3,sessionId:i,values:u,initDataType:e.type}):this._entries.push({version:4,sessionId:i,keyIds:t.map((function(e){return new qd(e)})),values:u,initDataType:e.type}),this._save()}else oe.warn("DRM-PSS: Invalid Persisten Session given.")},t.delete=function(e){for(var t=-1,n=0;n<this._entries.length;n++){if(this._entries[n].sessionId===e){t=n;break}}if(-1!==t){var r=this._entries[t];oe.warn("DRM-PSS: Delete session from store",r.sessionId),this._entries.splice(t,1),this._save()}else oe.warn("DRM-PSS: initData to delete not found.")},t.deleteOldSessions=function(e){oe.info("DRM-PSS: Deleting last "+e+" sessions."),e<=0||(e<=this._entries.length?this._entries.splice(0,e):(oe.warn("DRM-PSS: Asked to remove more information that it contains",e,this._entries.length),this._entries=[]),this._save())},t.dispose=function(){this._entries=[],this._save()},t._getIndex=function(e){var t=this,n=null;function r(){if(null===n){var t=e.values.constructRequestData();n={initData:t,initDataHash:Hd(t)}}return n}for(var i,a=function(){var n=t._entries[o];if(n.initDataType===e.type)switch(n.version){case 4:if(void 0!==e.keyIds){if(e.keyIds.every((function(e){for(var t,r=Mo(e),i=$d(n.keyIds);!(t=i()).done;){var a=t.value;if("string"==typeof a){if(r===a)return!0}else if(on(a.initData,e))return!0}return!1})))return{v:o}}else if(Yd(e.values.getFormattedValues(),n.values))return{v:o};break;case 3:if(Yd(e.values.getFormattedValues(),n.values))return{v:o};break;case 2:var i=r(),a=i.initData,s=i.initDataHash;if(n.initDataHash===s)try{if(on("string"==typeof n.initData?qd.decode(n.initData):n.initData.initData,a))return{v:o}}catch(e){oe.warn("DRM-PSS: Could not decode initialization data.",e instanceof Error?e:"")}break;case 1:var u=r(),l=u.initData,d=u.initDataHash;if(n.initDataHash===d){if(void 0===n.initData.length)return{v:o};if(on(n.initData,l))return{v:o}}break;default:var c=r().initDataHash;if(n.initData===c)return{v:o}}},o=0;o<this._entries.length;o++)if(i=a())return i.v;return-1},t._save=function(){try{this._storage.save(this._entries)}catch(t){var e=t instanceof Error?t:void 0;oe.warn("DRM-PSS: Could not save MediaKeySession information",e)}},e}();var ec=new WeakMap,tc={prepare:function(e){ec.set(e,null)},set:function(e,t){var n=t instanceof Uint8Array?t:new Uint8Array(t instanceof ArrayBuffer?t:t.buffer),r=Hd(n);ec.set(e,{hash:r,serverCertificate:n})},hasOne:function(e){var t=ec.get(e);return void 0!==t&&(null!==t||void 0)},has:function(e,t){var n=ec.get(e);if(null==n)return!1;var r=n.hash,i=n.serverCertificate,a=t instanceof Uint8Array?t:new Uint8Array(t instanceof ArrayBuffer?t:t.buffer);if(Hd(a)!==r||i.length!==a.length)return!1;for(var o=0;o<i.length;o++)if(i[o]!==a[o])return!1;return!0}};function nc(e,t,n){return rc.apply(this,arguments)}function rc(){return(rc=_t(St().mark((function e(t,n,r){var i,a,o,s,u,l,d,c,f,v;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,xd(t,n,r);case 2:if(i=e.sent,null===r.cancellationError){e.next=5;break}throw r.cancellationError;case 5:if(a=i.value,o=a.options,s=a.mediaKeySystemAccess,u=kt.getState(t),p=void 0,p=o.persistentLicenseConfig,l=_(p)?null:(oe.debug("DRM: Set the given license storage"),new Jd(p)),te||ne||null===u||"reuse-media-key-system-access"!==i.type){e.next=12;break}if(d=u.mediaKeys,c=u.loadedSessionsStore,!1!==tc.hasOne(d)&&(_(o.serverCertificate)||!tc.has(d,o.serverCertificate))){e.next=12;break}return e.abrupt("return",{mediaKeys:d,mediaKeySystemAccess:s,stores:{loadedSessionsStore:c,persistentSessionsStore:l},options:o});case 12:return e.next=14,ic(s);case 14:return f=e.sent,oe.info("DRM: MediaKeys created with success"),v=new Wd(f),e.abrupt("return",{mediaKeys:f,mediaKeySystemAccess:s,stores:{loadedSessionsStore:v,persistentSessionsStore:l},options:o});case 18:case"end":return e.stop()}var p}),e)})))).apply(this,arguments)}function ic(e){return ac.apply(this,arguments)}function ac(){return(ac=_t(St().mark((function e(t){var n,r;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe.info("DRM: Calling createMediaKeys on the MediaKeySystemAccess"),e.prev=1,e.next=4,t.createMediaKeys();case 4:return n=e.sent,e.abrupt("return",n);case 8:throw e.prev=8,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.message:"Unknown error when creating MediaKeys.",new be("CREATE_MEDIA_KEYS_ERROR",r);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})))).apply(this,arguments)}function oc(){return(oc=_t(St().mark((function e(t,n,r){var i,a;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,nc(t,n,r);case 2:if(i=e.sent,a=i.mediaKeys,!(null!==t.mediaKeys&&void 0!==t.mediaKeys&&a!==t.mediaKeys)){e.next=13;break}if(oe.debug("DRM: Disabling old MediaKeys"),!te){e.next=12;break}return e.next=10,gd(t);case 10:e.next=13;break;case 12:gd(t).catch(b);case 13:return e.abrupt("return",i);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var sc=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(de(r),t.prototype),r.reason=n,r}return u(t,e),t}(ve(Error)),uc={EXPIRED:"expired",INTERNAL_ERROR:"internal-error",OUTPUT_RESTRICTED:"output-restricted"};function lc(e,t,n){var r,i=t.onKeyInternalError,a=t.onKeyOutputRestricted,o=t.onKeyExpiration,s=[],u=[],l=[];return e.keyStatuses.forEach((function(e,t){var r="string"==typeof e?[e,t]:[t,e],d=r[0],c=function(e,t){return-1!==e.indexOf("playready")&&(Q||q)?bo(t):t}(n,new Uint8Array(r[1])),f={keyId:c.buffer,keyStatus:d};switch(oe.hasLevel("DEBUG")&&oe.debug("DRM: key status update ("+_o(c)+"): "+d),d){case uc.EXPIRED:var v=new be("KEY_STATUS_CHANGE_ERROR","A decryption key expired ("+_o(c)+")",{keyStatuses:[f].concat(l)});if("error"===o||void 0===o)throw v;switch(o){case"close-session":throw new sc(v);case"fallback":s.push(c);break;default:"continue"===o||void 0===o?u.push(c):Ze()}l.push(f);break;case uc.INTERNAL_ERROR:var p=new be("KEY_STATUS_CHANGE_ERROR",'A "'+d+'" status has been encountered ('+_o(c)+")",{keyStatuses:[f].concat(l)});switch(i){case void 0:case"error":throw p;case"close-session":throw new sc(p);case"fallback":s.push(c);break;case"continue":u.push(c);break;default:if(void 0===i)throw p;Ze()}l.push(f);break;case uc.OUTPUT_RESTRICTED:var h=new be("KEY_STATUS_CHANGE_ERROR",'A "'+d+'" status has been encountered ('+_o(c)+")",{keyStatuses:[f].concat(l)});switch(a){case void 0:case"error":throw h;case"fallback":s.push(c);break;case"continue":u.push(c);break;default:if(void 0===a)throw h;Ze()}l.push(f);break;default:u.push(c)}})),l.length>0&&(r=new be("KEY_STATUS_CHANGE_ERROR","One or several problematic key statuses have been encountered",{keyStatuses:l})),{warning:r,blacklistedKeyIds:s,whitelistedKeyIds:u}}var dc=U,cc=N,fc=B;function vc(e,t,n,r,i){oe.info("DRM: Binding session events",e.sessionId);var a=t.getLicenseConfig,o=void 0===a?{}:a,s=new ht;return s.linkToSignal(i),_(e.closed)||e.closed.then((function(){return s.cancel()})).catch((function(e){i.isCancelled()||(s.cancel(),r.onError(e))})),dc(e,(function(e){s.cancel(),r.onError(new be("KEY_ERROR",e.type))}),s.signal),fc(e,(function(){try{u()}catch(e){if(i.isCancelled()||s.isUsed()&&e instanceof mt)return;s.cancel(),r.onError(e)}}),s.signal),cc(e,(function(n){var i,a=n,u=new Uint8Array(a.message),l=y(a.messageType)?a.messageType:"license-request";oe.info("DRM: Received message event, type "+l,e.sessionId),function(e,t,n){var r=t.baseDelay,i=t.maxDelay,a=t.totalRetry,o=t.shouldRetry,s=t.onRetry,u=0;return l();function l(){return d.apply(this,arguments)}function d(){return(d=_t(St().mark((function t(){var d,c,f,v;return St().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null===n.cancellationError){t.next=2;break}throw n.cancellationError;case 2:return t.prev=2,t.next=5,e();case 5:return d=t.sent,t.abrupt("return",d);case 9:if(t.prev=9,t.t0=t.catch(2),null===n.cancellationError){t.next=13;break}throw n.cancellationError;case 13:if(!(!_(o)&&!o(t.t0)||u++>=a)){t.next=15;break}throw t.t0;case 15:return"function"==typeof s&&s(t.t0,u),c=Math.min(r*Math.pow(2,u-1),i),f=ir(c),t.next=20,Et(f);case 20:return v=l(),t.abrupt("return",v);case 22:case"end":return t.stop()}}),t,null,[[2,9]])})))).apply(this,arguments)}}((function(){return function(e,n){var r;return new Promise((function(i,a){try{oe.debug("DRM: Calling `getLicense`",n);var s=t.getLicense(e,n),u=_(o.timeout)?1e4:o.timeout;u>=0&&(r=setTimeout((function(){a(new gc('"getLicense" timeout exceeded ('+u+" ms)"))}),u)),Promise.resolve(s).then(l,d)}catch(e){d(e)}function l(e){void 0!==r&&clearTimeout(r),i(e)}function d(e){void 0!==r&&clearTimeout(r),a(e)}}))}(u,l)}),{totalRetry:null!=(i=o.retry)?i:2,baseDelay:200,maxDelay:3e3,shouldRetry:function(e){return e instanceof gc||_(e)||!0!==e.noRetry},onRetry:function(e){return r.onWarning(pc(e))}},s.signal).then((function(t){if(s.isUsed())return Promise.resolve();if(_(t))oe.info("DRM: No license given, skipping session.update");else try{return function(e,t){return hc.apply(this,arguments)}(e,t)}catch(e){s.cancel(),r.onError(e)}})).catch((function(e){if(!s.isUsed()){s.cancel();var t=pc(e);if(!_(e))if(!0===e.fallbackOnLastTry)return oe.warn("DRM: Last `getLicense` attempt failed. Blacklisting the current session."),void r.onError(new mc(t));r.onError(t)}}))}),s.signal),void u();function u(){if(oe.info("DRM: keystatuseschange event received",e.sessionId),!s.isUsed()&&0!==e.keyStatuses.size){var i=lc(e,t,n),a=i.warning,o=i.blacklistedKeyIds,u=i.whitelistedKeyIds;void 0!==a&&(r.onWarning(a),s.isUsed())||r.onKeyUpdate({whitelistedKeyIds:u,blacklistedKeyIds:o})}}}function pc(e){if(e instanceof gc)return new be("KEY_LOAD_TIMEOUT","The license server took too much time to respond.");var t=new be("KEY_LOAD_ERROR","An error occured when calling `getLicense`.");return!_(e)&&y(e.message)&&(t.message=e.message),t}function hc(){return(hc=_t(St().mark((function e(t,n){var r;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return oe.info("DRM: Updating MediaKeySession with message"),e.prev=1,e.next=4,t.update(n);case 4:e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.toString():"`session.update` failed",new be("KEY_UPDATE_ERROR",r);case 10:oe.info("DRM: MediaKeySession update succeeded.");case 11:case"end":return e.stop()}}),e,null,[[1,6]])})))).apply(this,arguments)}var mc=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(de(r),t.prototype),r.sessionError=n,r}return u(t,e),t}(ve(Error)),gc=function(e){function t(t){var n;return n=e.call(this)||this,Object.setPrototypeOf(de(n),mc.prototype),n.message=t,n}return u(t,e),t}(ve(Error));function yc(e,t){return _c.apply(this,arguments)}function _c(){return(_c=_t(St().mark((function e(t,n){var r,i;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.setServerCertificate(n);case 3:return r=e.sent,e.abrupt("return",r);case 7:throw e.prev=7,e.t0=e.catch(0),oe.warn("DRM: mediaKeys.setServerCertificate returned an error",e.t0 instanceof Error?e.t0:""),i=e.t0 instanceof Error?e.t0.toString():"`setServerCertificate` error",new be("LICENSE_SERVER_CERTIFICATE_ERROR",i);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function bc(e,t){return Sc.apply(this,arguments)}function Sc(){return(Sc=_t(St().mark((function e(t,n){var r,i;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!0!==tc.hasOne(t)){e.next=3;break}return oe.info("DRM: The MediaKeys already has a server certificate, skipping..."),e.abrupt("return",{type:"already-has-one"});case 3:if("function"==typeof t.setServerCertificate){e.next=6;break}return oe.warn("DRM: Could not set the server certificate. mediaKeys.setServerCertificate is not a function"),e.abrupt("return",{type:"method-not-implemented"});case 6:return oe.info("DRM: Setting server certificate on the MediaKeys"),tc.prepare(t),e.prev=8,e.next=11,yc(t,n);case 11:return r=e.sent,tc.set(t,n),e.abrupt("return",{type:"success",value:r});case 16:return e.prev=16,e.t0=e.catch(8),i=ke(e.t0)?e.t0:new be("LICENSE_SERVER_CERTIFICATE_ERROR","Unknown error when setting the server certificate."),e.abrupt("return",{type:"error",value:i});case 20:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}function Ec(e,t){if(!(isNaN(t)||t<0||t>=e.getLength())){var n=e.getLength(),r=n-t;oe.info("DRM: Too many stored persistent sessions, removing some.",n,r),e.deleteOldSessions(r)}}var Tc=function(){function e(e){this._innerValues=e,this._lazyFormattedValues=null}var t=e.prototype;return t.constructRequestData=function(){return ia.apply(void 0,this._innerValues.map((function(e){return e.data})))},t.isCompatibleWith=function(t){var n=t instanceof e?t.getFormattedValues():t;return Yd(this.getFormattedValues(),n)},t.getFormattedValues=function(){return null===this._lazyFormattedValues&&(this._lazyFormattedValues=this._innerValues.slice().sort((function(e,t){return e.systemId===t.systemId?0:void 0===e.systemId?1:void 0===t.systemId||e.systemId<t.systemId?-1:1})).map((function(e){var t=e.systemId,n=e.data;return{systemId:t,data:n,hash:Hd(n)}}))),this._lazyFormattedValues},e}();function kc(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return wc(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wc(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function wc(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ac=function(e){function t(t,n){var r;r=e.call(this)||this,oe.debug("DRM: Starting ContentDecryptor logic.");var i=new ht;return r._currentSessions=[],r._canceller=i,r._initDataQueue=[],r._stateData={state:Ea.Initializing,isMediaKeysAttached:0,isInitDataQueueLocked:!0,data:null},r.error=null,vd.onEncrypted(t,(function(e){oe.debug("DRM: Encrypted event received from media element.");var t=md(e);null!==t&&r.onInitializationData(t)}),i.signal),function(e,t,n){return oc.apply(this,arguments)}(t,n,i.signal).then((function(e){var n,i,a=e.options,o=e.mediaKeySystemAccess;(_(a.persistentLicenseConfig)||!0===a.persistentLicenseConfig.disableRetroCompatibility)&&(n=yi(i=o.keySystem,"com.microsoft.playready")||"com.chromecast.playready"===i||"com.youtube.playready"===i?"9a04f07998404286ab92e65be0885f95":"com.widevine.alpha"===i?"edef8ba979d64acea3c827dcd51d21ed":yi(i,"com.apple.fps")?"94ce86fb07ff4f43adb893d2fa968ca2":yi(i,"com.nagra.")?"adb41c242dbf4a6d958b4457c0d27b95":void 0),r.systemId=n,r._stateData.state===Ea.Initializing&&(r._stateData={state:Ea.WaitingForAttachment,isInitDataQueueLocked:!0,isMediaKeysAttached:0,data:{mediaKeysInfo:e,mediaElement:t}},r.trigger("stateChange",r._stateData.state))})).catch((function(e){r._onFatalError(e)})),r}u(t,e),t.hasEmeApis=function(){return!_(vd.requestMediaKeySystemAccess)};var n=t.prototype;return n.getState=function(){return this._stateData.state},n.attach=function(){var e=this;if(this._stateData.state!==Ea.WaitingForAttachment)throw new Error("`attach` should only be called when in the WaitingForAttachment state");if(0===this._stateData.isMediaKeysAttached){var t=this._stateData.data,n=t.mediaElement,r=t.mediaKeysInfo,i=r.options,a=r.mediaKeys,o=r.mediaKeySystemAccess,s=r.stores;if(!(!0===i.disableMediaKeysAttachmentLock)||(this._stateData={state:Ea.ReadyForContent,isInitDataQueueLocked:!0,isMediaKeysAttached:1,data:{mediaKeysInfo:r,mediaElement:n}},this.trigger("stateChange",this._stateData.state),!this._isStopped())){this._stateData.isMediaKeysAttached=1;var u={emeImplementation:vd,loadedSessionsStore:s.loadedSessionsStore,mediaKeySystemAccess:o,mediaKeys:a,keySystemOptions:i};oe.debug("DRM: Attaching current MediaKeys"),function(e,t,n){return yd.apply(this,arguments)}(n,u,this._canceller.signal).then(_t(St().mark((function t(){var n,o,s;return St().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e._stateData.isMediaKeysAttached=2,_(n=i.serverCertificate)){t.next=7;break}return t.next=5,bc(a,n);case 5:"error"===(o=t.sent).type&&e.trigger("warning",o.value);case 7:if(!e._isStopped()){t.next=9;break}return t.abrupt("return");case 9:s=e._stateData.state,e._stateData={state:Ea.ReadyForContent,isMediaKeysAttached:2,isInitDataQueueLocked:!1,data:{mediaKeysData:r}},s!==Ea.ReadyForContent&&e.trigger("stateChange",Ea.ReadyForContent),e._isStopped()||e._processCurrentInitDataQueue();case 13:case"end":return t.stop()}}),t)})))).catch((function(t){e._onFatalError(t)}))}}else oe.warn("DRM: ContentDecryptor's `attach` method called more than once.")},n.dispose=function(){this.removeEventListener(),this._stateData={state:Ea.Disposed,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("stateChange",this._stateData.state)},n.onInitializationData=function(e){var t=this;if(!1===this._stateData.isInitDataQueueLocked){var n=this._stateData.data.mediaKeysData,r=Object.assign(Object.assign({},e),{values:new Tc(e.values)});this._processInitializationData(r,n).catch((function(e){t._onFatalError(e)}))}else{if(this._isStopped())throw new Error("ContentDecryptor either disposed or stopped.");this._initDataQueue.push(e)}},n._processInitializationData=function(){var e=_t(St().mark((function e(t,n){var r,i,a,o,s,u,l,d,c,f,v,h,m,g,y,b,S,E,T,k,w,A,I,R,x,C,M,P,D,O,N,L,U,B=this;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.mediaKeySystemAccess,i=n.stores,a=n.options,!this._tryToUseAlreadyCreatedSession(t,n)&&!this._isStopped()){e.next=3;break}return e.abrupt("return");case 3:if("content"!==a.singleLicensePer){e.next=15;break}if(void 0===(o=xe(this._currentSessions,(function(e){return"created-session"===e.source})))){e.next=13;break}if(void 0!==(s=t.keyIds)){e.next=10;break}return void 0===t.content?oe.warn("DRM: Unable to fallback from a non-decipherable quality."):this.trigger("blackListProtectionData",t),e.abrupt("return");case 10:return o.record.associateKeyIds(s),void 0!==t.content&&(oe.hasLevel("DEBUG")&&(u=s.reduce((function(e,t){return e+", "+_o(t)}),""),oe.debug("DRM: Blacklisting new key ids",u)),this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:s,delistedKeyIds:[]})),e.abrupt("return");case 13:e.next=42;break;case 15:if("periods"!==a.singleLicensePer||void 0===t.content){e.next=42;break}l=t.content.period,d=this._currentSessions.filter((function(e){return"created-session"===e.source})),Cc(c=new Set,l),f=kc(d);case 21:if((v=f()).done){e.next=42;break}h=v.value,m=Array.from(c),g=0,y=m;case 25:if(!(g<y.length)){e.next=40;break}if(b=y[g],!h.record.isAssociatedWithKeyId(b)){e.next=37;break}h.record.associateKeyIds(c.values()),S=St().mark((function e(){var t;return St().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=T.value,h.keyStatuses.whitelisted.some((function(e){return on(e,t)}))||h.keyStatuses.blacklisted.some((function(e){return on(e,t)}))||h.keyStatuses.blacklisted.push(t);case 2:case"end":return e.stop()}}),e)})),E=kc(m);case 31:if((T=E()).done){e.next=35;break}return e.delegateYield(S(),"t0",33);case 33:e.next=31;break;case 35:return this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:h.keyStatuses.whitelisted,blacklistedKeyIds:h.keyStatuses.blacklisted,delistedKeyIds:[]}),e.abrupt("return");case 37:g++,e.next=25;break;case 40:e.next=21;break;case 42:return this._lockInitDataQueue(),_(a.persistentLicenseConfig)?k="temporary":Ic(r)?k="persistent-license":(oe.warn('DRM: Cannot create "persistent-license" session: not supported'),k="temporary"),w=p.getCurrent(),A=w.EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS,I=w.EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION,R="number"==typeof a.maxSessionCacheSize?a.maxSessionCacheSize:A,e.next=48,wd(t,i,k,R,this._canceller.signal);case 48:if(x=e.sent,!this._isStopped()){e.next=51;break}return e.abrupt("return");case 51:if(C={record:x.value.keySessionRecord,source:x.type,keyStatuses:{whitelisted:[],blacklisted:[]},blacklistedSessionError:null},this._currentSessions.push(C),M=x.value,P=M.mediaKeySession,D=M.sessionType,O=!1,vc(P,a,r.keySystem,{onKeyUpdate:function(e){var n=Rc(t,C.record,a.singleLicensePer,"created-session"===C.source,e.whitelistedKeyIds,e.blacklistedKeyIds);if(C.record.associateKeyIds(n.whitelisted),C.record.associateKeyIds(n.blacklisted),C.keyStatuses={whitelisted:n.whitelisted,blacklisted:n.blacklisted},0!==C.record.getAssociatedKeyIds().length&&"persistent-license"===D&&null!==i.persistentSessionsStore&&!O){var r=i.persistentSessionsStore;Ec(r,I-1),r.add(t,C.record.getAssociatedKeyIds(),P),O=!0}void 0!==t.content&&B.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:n.whitelisted,blacklistedKeyIds:n.blacklisted,delistedKeyIds:[]}),B._unlockInitDataQueue()},onWarning:function(e){B.trigger("warning",e)},onError:function(e){var n;if(e instanceof sc){oe.warn("DRM: A session's closing condition has been triggered"),B._lockInitDataQueue();var r=B._currentSessions.indexOf(C);return r>=0&&B._currentSessions.splice(r),void 0!==t.content&&B.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:[],delistedKeyIds:C.record.getAssociatedKeyIds()}),null===(n=i.persistentSessionsStore)||void 0===n||n.delete(P.sessionId),i.loadedSessionsStore.closeSession(P).catch((function(e){var t=e instanceof Error?e:"unknown error";oe.warn("DRM: failed to close expired session",t)})).then((function(){return B._unlockInitDataQueue()})).catch((function(e){return B._onFatalError(e)})),void(B._isStopped()||B.trigger("warning",e.reason))}e instanceof mc?(C.blacklistedSessionError=e,void 0!==t.content&&(oe.info("DRM: blacklisting Representations based on protection data."),B.trigger("blackListProtectionData",t)),B._unlockInitDataQueue()):B._onFatalError(e)}},this._canceller.signal),void 0!==a.singleLicensePer&&"init-data"!==a.singleLicensePer||this._unlockInitDataQueue(),"created-session"!==x.type){e.next=72;break}return N=t.values.constructRequestData(),e.prev=59,e.next=62,i.loadedSessionsStore.generateLicenseRequest(P,t.type,N);case 62:e.next=72;break;case 64:if(e.prev=64,e.t1=e.catch(59),null!==(L=i.loadedSessionsStore.getEntryForSession(P))&&"none"===L.closingStatus.type){e.next=71;break}return(U=this._currentSessions.indexOf(C))>=0&&this._currentSessions.splice(U,1),e.abrupt("return",Promise.resolve());case 71:throw new be("KEY_GENERATE_REQUEST_ERROR",e.t1 instanceof Error?e.t1.toString():"Unknown error");case 72:return e.abrupt("return",Promise.resolve());case 73:case"end":return e.stop()}}),e,this,[[59,64]])})));return function(t,n){return e.apply(this,arguments)}}(),n._tryToUseAlreadyCreatedSession=function(e,t){var n=t.stores,r=t.options,i=xe(this._currentSessions,(function(t){return t.record.isCompatibleWith(e)}));if(void 0===i)return!1;if(!_(i.blacklistedSessionError))return void 0===e.type||void 0===e.content?(oe.error("DRM: This initialization data has already been blacklisted but the current content is not known."),!0):(oe.info("DRM: This initialization data has already been blacklisted. Blacklisting the related content."),this.trigger("blackListProtectionData",e),!0);if(void 0!==e.keyIds){var a;if(void 0===r.singleLicensePer||"init-data"===r.singleLicensePer){var o=i.keyStatuses.blacklisted;a=function(e,t){for(var n,r,i=function(){var e=r.value;if(t.some((function(t){return on(t,e)})))return{v:!0}},a=Nd(e);!(r=a()).done;)if(n=i())return n.v;return!1}(e.keyIds,o)}else{var s=i.keyStatuses.whitelisted;a=!Ud(e.keyIds,s)}if(a)return void 0===e.content?(oe.error("DRM: Cannot forbid key id, the content is unknown."),!0):(oe.info("DRM: Current initialization data is linked to blacklisted keys. Marking Representations as not decipherable"),this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:e.keyIds,delistedKeyIds:[]}),!0)}if(null!==n.loadedSessionsStore.reuse(e))return oe.debug("DRM: Init data already processed. Skipping it."),!0;var u=this._currentSessions.indexOf(i);return-1===u?oe.error("DRM: Unable to remove processed init data: not found."):(oe.debug("DRM: A session from a processed init data is not available anymore. Re-processing it."),this._currentSessions.splice(u,1)),!1},n._onFatalError=function(e){if(!this._canceller.isUsed()){var t=e instanceof Error?e:new Te("NONE","Unknown decryption error");this.error=t,this._initDataQueue.length=0,this._stateData={state:Ea.Error,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("error",t),this._stateData.state===Ea.Error&&this.trigger("stateChange",this._stateData.state)}},n._isStopped=function(){return this._stateData.state===Ea.Disposed||this._stateData.state===Ea.Error},n._processCurrentInitDataQueue=function(){for(;!1===this._stateData.isInitDataQueueLocked;){var e=this._initDataQueue.shift();if(void 0===e)return;this.onInitializationData(e)}},n._lockInitDataQueue=function(){!1===this._stateData.isInitDataQueueLocked&&(this._stateData.isInitDataQueueLocked=!0)},n._unlockInitDataQueue=function(){2===this._stateData.isMediaKeysAttached?(this._stateData.isInitDataQueueLocked=!1,this._processCurrentInitDataQueue()):oe.error("DRM: Trying to unlock in the wrong state")},t}(ie);function Ic(e){var t=e.getConfiguration().sessionTypes;return void 0!==t&&Qe(t,"persistent-license")}function Rc(e,t,n,r,i,a){for(var o,s,u=[].concat(i,a),l=function(){var e=s.value;u.some((function(t){return on(t,e)}))||(oe.hasLevel("DEBUG")&&oe.debug("DRM: KeySessionRecord's key missing in the license, blacklisting it",_o(e)),u.push(e))},d=kc(t.getAssociatedKeyIds());!(s=d()).done;)l();if(void 0!==n&&"init-data"!==n){var c=e.keyIds,f=e.content;if(void 0!==c){var v=c.filter((function(e){return!u.some((function(t){return on(t,e)}))}));v.length>0&&(oe.hasLevel("DEBUG")&&oe.debug("DRM: init data keys missing in the license, blacklisting them",v.map((function(e){return _o(e)})).join(", ")),u.push.apply(u,v))}if(r&&void 0!==f)if("content"===n){for(var p,h=new Set,m=kc(f.manifest.periods);!(p=m()).done;){Cc(h,p.value)}xc(h,u)}else if("periods"===n)for(var g,y=kc(f.manifest.periods);!(g=y()).done;){var _=g.value,b=new Set;if(Cc(b,_),(null===(o=e.content)||void 0===o?void 0:o.period.id)===_.id)xc(b,u);else for(var S=Array.from(b),E=function(){var e=k[T];if(u.some((function(t){return on(t,e)})))return xc(b,u),1},T=0,k=S;T<k.length&&!E();T++);}}return{whitelisted:i,blacklisted:u.slice(i.length)}}function xc(e,t){for(var n=Array.from(e.values()),r=function(){var e=a[i];t.some((function(t){return on(t,e)}))||t.push(e)},i=0,a=n;i<a.length;i++)r()}function Cc(e,t){for(var n,r=kc(Pe(t.adaptations).reduce((function(e,t){return null!=t?e.concat(t):e}),[]));!(n=r()).done;)for(var i,a=kc(n.value.representations);!(i=a()).done;){var o=i.value;if(void 0!==o.contentProtections&&void 0!==o.contentProtections.keyIds)for(var s,u=kc(o.contentProtections.keyIds);!(s=u()).done;){var l=s.value;e.add(l.keyId)}}}var Mc=Ac;function Pc(e){e.decrypt=Mc}var Dc=/(\d+) (\d+)/;function Oc(e,t,n,r){for(var i,a={},o=e.slice(),s=function(){var e=t[u];if(void 0!==e){var i,s;if(e.nodeType===Node.ELEMENT_NODE)for(var l=e,d=0;d<=l.attributes.length-1;d++){var c=l.attributes[d],f=c.name;if("style"===f)i=c.value;else if("region"===f)s=c.value;else{var v=f.substring(4);if(Qe(o,v)&&(a[v]=c.value,o.splice(d,1),0===o.length))return{v:a}}}if(y(i)){var p=xe(n,(function(e){return e.id===i}));if(void 0!==p)for(var h=0;h<=o.length-1;h++){var m=o[h];if(!y(a[m])&&y(p.style[m])){if(a[m]=p.style[m],o.splice(h,1),0===o.length)return{v:a};h--}}}if(y(s)){var g=xe(r,(function(e){return e.id===s}));if(void 0!==g)for(var _=0;_<=o.length-1;_++){var b=o[_];if(!y(a[b])&&y(g.style[b])){if(a[b]=g.style[b],o.splice(_,1),0===o.length)return{v:a};_--}}}}},u=0;u<=t.length-1;u++)if(i=s())return i.v;return a}function Nc(e){if(e.nodeType!==Node.ELEMENT_NODE)return{};for(var t=e,n={},r=0;r<=t.attributes.length-1;r++){var i=t.attributes[r];if(yi(i.name,"tts"))n[i.name.substring(4)]=i.value}return n}function Lc(e,t){if(!(e.parentNode instanceof Element))return[];return function e(n){var r=[];n.tagName.toLowerCase()===t.toLowerCase()&&r.push(n);var i=n.parentNode;return i instanceof Element&&r.push.apply(r,e(i)),r}(e.parentNode)}function Uc(e){var t=Lc(e,"div");if(0===t.length){var n=Lc(e,"tt:div");n.length>0&&(t=n)}return t}function Bc(e){return"br"===e.nodeName||"tt:br"===e.nodeName}function Fc(e){return"span"===e.nodeName||"tt:span"===e.nodeName}var zc=["align","backgroundColor","color","direction","display","displayAlign","extent","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","opacity","origin","overflow","padding","textAlign","textDecoration","textOutline","unicodeBidi","visibility","wrapOption","writingMode"];function Vc(e,t){var n=[],r=(new DOMParser).parseFromString(e,"text/xml");if(null!=r){var i=r.getElementsByTagName("tt")[0];if(void 0===i)if(void 0===(i=r.getElementsByTagNameNS("*","tt")[0]))throw new Error("invalid XML");for(var a=function(e){var t=e.getElementsByTagName("body");if(t.length>0)return t[0];var n=e.getElementsByTagName("tt:body");return n.length>0?n[0]:null}(i),o=function(e){var t=e.getElementsByTagName("style");if(t.length>0)return t;var n=e.getElementsByTagName("tt:style");return n.length>0?n:t}(i),s=function(e){var t=e.getElementsByTagName("region");if(t.length>0)return t;var n=e.getElementsByTagName("tt:region");return n.length>0?n:t}(i),u=function(e){var t=e.getElementsByTagName("p");if(t.length>0)return t;var n=e.getElementsByTagName("tt:p");return n.length>0?n:t}(i),l=function(e){var t=e.getAttribute("ttp:frameRate"),n=e.getAttribute("ttp:subFramRate"),r=e.getAttribute("ttp:tickRate"),i=e.getAttribute("ttp:frameRateMultiplier"),a=e.getAttribute("xml:space"),o=e.getAttribute("ttp:cellResolution"),s={columns:32,rows:15};if(null!==o){var u=Dc.exec(o);if(null===u||u.length<3)oe.warn("TTML Parser: Invalid cellResolution");else{var l=parseInt(u[1],10),d=parseInt(u[2],10);isNaN(l)||isNaN(d)?oe.warn("TTML Parser: Invalid cellResolution"):s={columns:l,rows:d}}}if(y(a)&&"default"!==a&&"preserve"!==a)throw new Error("Invalid spacing style");var c=Number(t);(isNaN(c)||c<=0)&&(c=30);var f=Number(n);(isNaN(f)||f<=0)&&(f=1);var v=Number(r);(isNaN(v)||v<=0)&&(v=void 0);var p=c,h=null!=f?f:1,m=null!==a?a:"default",g=void 0!==v?v:c*f;if(null!==i){var _=/^(\d+) (\d+)$/g.exec(i);null!==_&&(p=c*(Number(_[1])/Number(_[2])))}return{cellResolution:s,tickRate:g,frameRate:p,subFrameRate:h,spaceStyle:m}}(i),c=[],f=0;f<=o.length-1;f++){var v=o[f];if(v instanceof Element){var p=v.getAttribute("xml:id");if(null!==p){var h=v.getAttribute("style"),m=null===h?[]:h.split(" ");c.push({id:p,style:Nc(v),extendsStyles:m})}}}!function(e){var t=[];function n(r,i){t.push(i);for(var a=function(){var i=r.extendsStyles[o],a=S(e,(function(e){return e.id===i}));if(a<0)oe.warn("TTML Parser: unknown style inheritance: "+i);else{var s=e[a];Qe(t,a)?oe.warn("TTML Parser: infinite style inheritance loop avoided"):n(s,a),r.style=d({},s.style,r.style)}},o=0;o<r.extendsStyles.length;o++)a();r.extendsStyles.length=0}for(var r=0;r<e.length;r++)n(e[r],r),t.length=0}(c);for(var g=[],_=function(){var e=s[b];if(e instanceof Element){var t=e.getAttribute("xml:id");if(null!==t){var n=Nc(e),r=e.getAttribute("style");if(y(r)){var i=xe(c,(function(e){return e.id===r}));void 0!==i&&(n=d({},i.style,n))}g.push({id:t,style:n,extendsStyles:[]})}}},b=0;b<=s.length-1;b++)_();for(var E=Oc(zc,null!==a?[a]:[],c,g),T="default"===(null!==a?a.getAttribute("xml:space"):void 0)||"default"===l.spaceStyle,k=0;k<u.length;k++){var w=u[k];if(w instanceof Element){var A=Uc(w),I=d({},E,Oc(zc,[w].concat(A),c,g)),R=w.getAttribute("xml:space"),x=y(R)?"default"===R:T,C={paragraph:w,timeOffset:t,idStyles:c,regionStyles:g,body:a,paragraphStyle:I,ttParams:l,shouldTrimWhiteSpace:x};null!==C&&n.push(C)}}}return n}function Kc(e,t,n){if(e>=t)return oe.warn("Compat: Invalid cue times: "+e+" - "+t),null;if(_(g.VTTCue)){if(_(g.TextTrackCue))throw new Error("VTT cues not supported in your target");return new TextTrackCue(e,t,n)}return new VTTCue(e,t,n)}function Wc(e){return"function"==typeof g.VTTCue&&e instanceof g.VTTCue}var Gc=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,jc=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,Hc=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d{2,})$/,qc=/^(\d*\.?\d*)f$/,Yc=/^(\d*\.?\d*)t$/,Qc=/^(?:(\d*\.?\d*)h)?(?:(\d*\.?\d*)m)?(?:(\d*\.?\d*)s)?(?:(\d*\.?\d*)ms)?$/,$c=/^(\d{1,2}|100)% (\d{1,2}|100)%$/,Xc=/^((?:\+|\-)?\d*(?:\.\d+)?)(px|em|c|%|rh|rw)$/,Zc=/^#([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})$/,Jc=/^#([0-9A-f])([0-9A-f])([0-9A-f])([0-9A-f])$/,ef=/^rgb\( *(\d+) *, *(\d+) *, *(\d+) *\)/,tf=/^rgba\( *(\d+) *, *(\d+) *, *(\d+) *, *(\d+) *\)/;function nf(e,t){var n=e.exec(t);if(null===n||""===n[0])return null;var r=Number(n[1]);isNaN(r)&&(r=0);var i=Number(n[2]);isNaN(i)&&(i=0);var a=Number(n[3]);isNaN(a)&&(a=0);var o=Number(n[4]);return isNaN(o)&&(o=0),o/1e3+a+60*i+3600*r}var rf=function(e,t){return Gc.test(e)?function(e,t){var n=Gc.exec(t),r=Number(n[1]),i=Number(n[2]),a=Number(n[3]),o=Number(n[4]),s=Number(n[5]);isNaN(s)&&(s=0);return o+=s/e.subFrameRate,a+=o/e.frameRate,a+60*i+3600*r}(t,e):jc.test(e)?nf(jc,e):Hc.test(e)?nf(Hc,e):qc.test(e)?function(e,t){var n=qc.exec(t);return Number(n[1])/e.frameRate}(t,e):Yc.test(e)?function(e,t){var n=Yc.exec(t);return Number(n[1])/e.tickRate}(t,e):Qc.test(e)?nf(Qc,e):void 0};function af(e,t){var n=e.getAttribute("begin"),r=e.getAttribute("dur"),i=e.getAttribute("end"),a=y(n)?rf(n,t):null,o=y(r)?rf(r,t):null,s=y(i)?rf(i,t):null;if(null==a||null==s&&null==o)throw new Error("Invalid text cue");return{start:a,end:null==s?a+o:s}}var of={left:"start",center:"center",right:"end",start:"start",end:"end"},sf={left:"line-left",center:"center",right:"line-right"};function uf(e){var t=e.paragraph,n=e.timeOffset,r=e.paragraphStyle,i=e.ttParams,a=e.shouldTrimWhiteSpace;if(!t.hasAttribute("begin")&&!t.hasAttribute("end")&&/^\s*$/.test(null===t.textContent?"":t.textContent))return null;var o=af(t,i),s=o.start,u=o.end,l=function(e,t){function n(e,t){for(var r=e.childNodes,i="",a=0;a<r.length;a++){var o=r[a];if("#text"===o.nodeName){var s=o.textContent;if(null===s&&(s=""),t){var u=s.trim();s=u=u.replace(/\s+/g," ")}i+=s.replace(/&|\u0026/g,"&amp;").replace(/<|\u003C/g,"&lt;").replace(/>|\u2265/g,"&gt;").replace(/\u200E/g,"&lrm;").replace(/\u200F/g,"&rlm;").replace(/\u00A0/g,"&nbsp;")}else if(Bc(o))i+="\n";else if(Fc(o)&&o.nodeType===Node.ELEMENT_NODE&&o.childNodes.length>0){var l=o.getAttribute("xml:space");i+=n(o,y(l)?"default"===l:t)}}return i}return n(e,t)}(t,a),d=Kc(s+n,u+n,l);return null===d?null:(Wc(d)&&function(e,t){var n=t.extent;if(y(n)){var r=$c.exec(n);null!=r&&(e.size=Number(r[1]))}switch(t.writingMode){case"tb":case"tblr":e.vertical="lr";break;case"tbrl":e.vertical="rl"}var i=t.origin;if(y(i))$c.exec(i);var a=t.align;if(y(a)){e.align=a,"center"===a&&("center"!==e.align&&(e.align="middle"),e.position="auto");var o=sf[a];e.positionAlign=void 0===o?"":o;var s=of[a];e.lineAlign=void 0===s?"":s}}(d,r),d)}var lf=function(e,t){for(var n=Vc(e,t),r=[],i=0;i<n.length;i++){var a=uf(n[i]);null!==a&&r.push(a)}return r};function df(e,t){if($&&function(e,t){var n=e.activeCues;if(null===n)return!1;for(var r=0;r<n.length;r++)if(n[r]===t)return!0;return!1}(e,t)){var n=e.mode;e.mode="hidden";try{e.removeCue(t)}catch(e){oe.warn("Compat: Could not remove cue from text track.")}e.mode=n}else try{e.removeCue(t)}catch(e){oe.warn("Compat: Could not remove cue from text track.")}}var cf=function(){function e(){this._ranges=[],this.length=0}var t=e.prototype;return t.insert=function(e,t){ft(this._ranges,{start:e,end:t}),this.length=this._ranges.length},t.remove=function(e,t){var n=[];e>0&&n.push({start:0,end:e}),t<1/0&&n.push({start:t,end:1/0}),this._ranges=function(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=vt(i,t);if(a.length>0)for(var o=0;o<a.length;o++){var s=a[o];n.push({start:Math.max(i.start,s.start),end:Math.min(i.end,s.end)})}}return n}(this._ranges,n),this.length=this._ranges.length},t.start=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].start},t.end=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].end},e}();var ff=function(){function e(e){oe.debug("NTD: Creating NativeTextDisplayer");var t=function(e){var t,n,r,i="subtitles";if(Q){var a=e.textTracks.length;(n=a>0?e.textTracks[a-1]:e.addTextTrack(i)).mode=null!==(t=n.SHOWING)&&void 0!==t?t:"showing"}else r=document.createElement("track"),e.appendChild(r),n=r.track,r.kind=i,n.mode="showing";return{track:n,trackElement:r}}(e),n=t.track,r=t.trackElement;this._buffered=new cf,this._videoElement=e,this._track=n,this._trackElement=r}var t=e.prototype;return t.pushTextData=function(e){var t,n;if(oe.debug("NTD: Appending new native text tracks"),null===e.chunk)return st(this._buffered);var r,i,a=e.timestampOffset,o=e.appendWindow,s=e.chunk,u=s.start,l=s.end,d=s.data,c=s.type,f=s.language,v=null!==(t=o[0])&&void 0!==t?t:0,p=null!==(n=o[1])&&void 0!==n?n:1/0,h=function(e,t,n,r){oe.debug("NTSB: Finding parser for native text tracks:",e);var i=Re.nativeTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");oe.debug("NTSB: Parser found, parsing...");var a=i(t,n,r);return oe.debug("NTSB: Parsed successfully!",a.length),a}(c,d,a,f);if(0!==v&&p!==1/0){for(var m=0;m<h.length&&h[m].endTime<=v;)m++;for(h.splice(0,m),m=0;m<h.length&&h[m].startTime<v;)h[m].startTime=v,m++;for(m=h.length-1;m>=0&&h[m].startTime>=p;)m--;for(h.splice(m,h.length),m=h.length-1;m>=0&&h[m].endTime>p;)h[m].endTime=p,m--}if(void 0!==u)r=Math.max(v,u);else{if(h.length<=0)return oe.warn("NTD: Current text tracks have no cues nor start time. Aborting"),st(this._buffered);oe.warn("NTD: No start time given. Guessing from cues."),r=h[0].startTime}if(void 0!==l)i=Math.min(p,l);else{if(h.length<=0)return oe.warn("NTD: Current text tracks have no cues nor end time. Aborting"),st(this._buffered);oe.warn("NTD: No end time given. Guessing from cues."),i=h[h.length-1].endTime}if(i<=r)return oe.warn("NTD: Invalid text track appended: ","the start time is inferior or equal to the end time."),st(this._buffered);if(h.length>0){var g=h[0],y=this._track.cues;null!==y&&y.length>0&&g.startTime<y[y.length-1].startTime&&this._removeData(g.startTime,1/0);for(var _=0;_<h.length;_++)this._track.addCue(h[_])}return this._buffered.insert(r,i),st(this._buffered)},t.removeBuffer=function(e,t){return this._removeData(e,t),st(this._buffered)},t.getBufferedRanges=function(){return st(this._buffered)},t.reset=function(){oe.debug("NTD: Aborting NativeTextDisplayer"),this._removeData(0,1/0);var e=this._trackElement,t=this._videoElement;if(void 0!==e&&t.hasChildNodes())try{t.removeChild(e)}catch(e){oe.warn("NTD: Can't remove track element from the video")}var n=this._track.mode;this._track.mode="disabled",this._track.mode=n,void 0!==this._trackElement&&(this._trackElement.innerHTML="")},t.stop=function(){oe.debug("NTD: Aborting NativeTextDisplayer"),this._removeData(0,1/0);var e=this._trackElement,t=this._videoElement;if(void 0!==e&&t.hasChildNodes())try{t.removeChild(e)}catch(e){oe.warn("NTD: Can't remove track element from the video")}this._track.mode="disabled",void 0!==this._trackElement&&(this._trackElement.innerHTML="")},t._removeData=function(e,t){oe.debug("NTD: Removing native text track data",e,t);var n=this._track,r=n.cues;if(null!==r)for(var i=r.length-1;i>=0;i--){var a=r[i],o=a.startTime,s=a.endTime;o>=e&&o<=t&&s<=t&&df(n,a)}this._buffered.remove(e,t)},e}(),vf=ff;function pf(e){e.nativeTextTracksParsers.ttml=lf,e.nativeTextDisplayer=vf}var hf=/&#([0-9]+);/g,mf=/<br>/gi,gf=/<style[^>]*>([\s\S]*?)<\/style[^>]*>/i,yf=/\s*<p (?:class=([^>]+))?>(.*)/i,_f=/<sync[^>]+?start="?([0-9]*)"?[^0-9]/i;function bf(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}var Sf=function(e,t,n){var r,i,a=/<sync[ >]/gi,o=/<sync[ >]|<\/body>/gi,s=[],u=gf.exec(e),l=null!==u?u[1]:"";o.exec(e);var d,c=function(e){for(var t=/\.(\S+)\s*{([^}]*)}/gi,n={},r=t.exec(e);Array.isArray(r);){var i=r[1],a=bf(r[2],"lang");null!=i&&null!=a&&(n[a]=i),r=t.exec(e)}return n}(l);if(y(n)&&void 0===(d=c[n]))throw new Error("sami: could not find lang "+n+" in CSS");for(;r=a.exec(e),i=o.exec(e),null!==r||null!==i;){if(null===r||null===i||r.index>=i.index)throw new Error("parse error");var f=e.slice(r.index,i.index),v=_f.exec(f);if(null===v)throw new Error("parse error (sync time attribute)");var p=+v[1];if(isNaN(p))throw new Error("parse error (sync time attribute NaN)");h(f.split("\n"),p/1e3)}return function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n],i=r.start,a=r.end,o=r.text;if(y(o)&&null!=a){var s=Kc(i,a,o);null!=s&&t.push(s)}}return t}(s);function h(e,n){for(var r,i,a=e.length;--a>=0;)if(null!==(r=yf.exec(e[a]))){var o=r,u=o[1],l=o[2];d===u&&("&nbsp;"===l?s[s.length-1].end=n:s.push({text:(i=l,i.replace(mf,"\n").replace(hf,(function(e,t){return String.fromCharCode(Number(t))}))),start:n+t}))}}};function Ef(e){e.nativeTextTracksParsers.sami=Sf,e.nativeTextDisplayer=vf}function Tf(e){for(var t=0;t<e.length;){if(""===e[t])return t+1;t++}return t}function kf(e,t){return"string"==typeof e[t]&&/^STYLE( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}function wf(e,t){var n=e[t];if(void 0===n||""===n||kf(e,t)||function(e,t){return"string"==typeof e[t]&&/^REGION( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}(e,t)||function(e,t){return"string"==typeof e[t]&&/^NOTE( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}(e,t))return!1;if(n.indexOf("--\x3e")>=0)return!0;var r=e[t+1];return void 0!==r&&r.indexOf("--\x3e")>=0}function Af(e,t){for(var n=t+1;y(e[n]);)n++;return n}function If(e,t){for(var n=[],r=t;r<e.length;r++)if(wf(e,r)){var i=Af(e,r);n.push(e.slice(r,i)),r=i}else if(y(e[r]))for(;y(e[r]);)r++;return n}function Rf(e){var t=e.split(":").reverse();if(y(t[2])||y(t[1])){var n=y(t[2])?parseInt(t[2],10):0,r=parseInt(t[1],10),i=parseFloat(t[0].replace(",","."));if(isNaN(n)||isNaN(r)||isNaN(i))return;return 60*n*60+60*r+i}}function xf(e,t){var n,r,i,a=/-->/;if(a.test(e[0]))n=e[0],r=e.slice(1,e.length);else{if(!a.test(e[1]))return null;i=e[0],n=e[1],r=e.slice(2,e.length)}var o=function(e){var t=/^([\d:.]+)[ |\t]+-->[ |\t]+([\d:.]+)[ |\t]*(.*)$/.exec(e);if(null===t)return null;var n=Rf(t[1]),r=Rf(t[2]);return null==n||null==r?null:{start:n,end:r,settings:t[3].split(/ |\t/).reduce((function(e,t){var n=t.split(":");return 2===n.length&&(e[n[0]]=n[1]),e}),{})}}(n);return null===o?null:{start:o.start+t,end:o.end+t,settings:o.settings,payload:r,header:i}}function Cf(e,t){if(!y(e.vertical)||"rl"!==e.vertical&&"lr"!==e.vertical||(t.vertical=e.vertical),y(e.line)){var n=/^(\d+(\.\d+)?)%(,([a-z]+))?/.exec(e.line);if(Array.isArray(n))t.line=Number(n[1]),t.snapToLines=!1,Qe(["start","center","end"],n[4])&&(t.lineAlign=n[4]);else{var r=/^(-?\d+)(,([a-z]+))?/.exec(e.line);Array.isArray(r)&&(t.line=Number(r[1]),t.snapToLines=!0,Qe(["start","center","end"],r[3])&&(t.lineAlign=r[3]))}}if(y(e.position)){var i=/^([\d\.]+)%(?:,(line-left|line-right|center))?$/.exec(e.position);if(Array.isArray(i)&&i.length>=2){var a=parseInt(i[1],10);isNaN(a)||(t.position=a,void 0!==i[2]&&(t.positionAlign=i[2]))}}y(e.size)&&(t.size=e.size),"string"==typeof e.align&&Qe(["start","center","end","left"],e.align)&&(t.align=e.align)}var Mf=function(e,t){var n=e.split(/\r\n|\n|\r/);if(!/^WEBVTT($| |\t)/.test(n[0]))throw new Error("Can't parse WebVTT: Invalid file.");for(var r,i=If(n,Tf(n)),a=[],o=0;o<i.length;o++){var s=xf(i[o],t);if(null!=s){var u=Kc((r=s).start,r.end,r.payload.join("\n"));null!=u&&(Wc(u)&&Cf(s.settings,u),a.push(u))}}return a};function Pf(e){e.nativeTextTracksParsers.vtt=Mf,e.nativeTextDisplayer=vf}function Df(e,t){for(var n=t+1;y(e[n]);)n++;return n}function Of(e){for(var t=[],n=0;n<e.length;n++)if(y(e[n])){var r=Df(e,n),i=e.slice(n,r);i.length>0&&(1===i.length?i[0].indexOf("--\x3e")>=0&&t.push(i):(i[1].indexOf("--\x3e")>=0||i[0].indexOf("--\x3e")>=0)&&t.push(i)),n=r}return t}function Nf(e){var t=e.split(":");if(y(t[2])){var n=parseInt(t[0],10),r=parseInt(t[1],10),i=parseFloat(t[2].replace(",","."));if(isNaN(n)||isNaN(r)||isNaN(i))return;return 60*n*60+60*r+i}}function Lf(e,t){if(0===e.length)return null;var n,r,i=[];if(y(e[1])&&-1!==e[1].indexOf("--\x3e")){var a=e[1].split("--\x3e").map((function(e){return e.trim()}));n=a[0],r=a[1],i=e.slice(2,e.length)}if(!y(n)||!y(r)){var o=e[0].split("--\x3e").map((function(e){return e.trim()}));n=o[0],r=o[1],i=e.slice(1,e.length)}if(!y(n)||!y(r))return null;var s=Nf(n),u=Nf(r);return void 0===s||void 0===u?null:{start:s+t,end:u+t,payload:i}}function Uf(e,t){for(var n,r,i,a,o,s=Of(e.split(/\r\n|\n|\r/)),u=[],l=0;l<s.length;l++){var d=Lf(s[l],t);if(null!==d){var c=(r=void 0,i=void 0,a=void 0,o=void 0,r=(n=d).start,i=n.end,a=n.payload,o=a.join("\n"),Kc(r,i,o));null!==c&&u.push(c)}}return u}function Bf(e){e.nativeTextTracksParsers.srt=Uf,e.nativeTextDisplayer=vf}var Ff;function zf(e){return void 0===e.extent&&void 0===e.origin&&void 0===e.displayAlign&&void 0===e.display&&void 0===e.textAlign&&void 0===e.fontSize}function Vf(e){e.extent="70% 20%",e.fontSize="1c",e.origin="15% 80%",e.displayAlign="before",e.textAlign="center"}function Kf(e,t){(void 0===Ff&&(Ff=void 0!==e.classList&&"function"==typeof e.classList.add),Ff)?e.classList.add(t):(" "+e.className+" ").indexOf(" "+t+" ")<0&&(e.className+=" "+t)}function Wf(e,t){var n=t;return y(t)&&t.trim().endsWith("%")&&(n=t.trim().slice(0,-1),n=(parseInt(n,10)/100).toString()+"em"),"-1px -1px "+n+" "+e+",1px -1px "+n+" "+e+",-1px 1px "+n+" "+e+",1px 1px "+n+" "+e}function Gf(e){var t;return null!=(t=Zc.exec(e))?"rgba("+String(parseInt(t[1],16))+","+String(parseInt(t[2],16))+","+String(parseInt(t[3],16))+","+String(parseInt(t[4],16)/255)+")":null!=(t=Jc.exec(e))?"rgba("+String(parseInt(t[1]+t[1],16))+","+String(parseInt(t[2]+t[2],16))+","+String(parseInt(t[3]+t[3],16))+","+String(parseInt(t[4]+t[4],16)/255)+")":null!=(t=ef.exec(e))?"rgb("+String(+t[1])+","+String(+t[2])+","+String(+t[3])+")":null!=(t=tf.exec(e))?"rgba("+String(+t[1])+","+String(+t[2])+","+String(+t[3])+","+String(+t[4]/255)+")":e}var jf=["color","direction","display","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","textOutline","unicodeBidi","visibility","wrapOption"];function Hf(e,t,n){var r=t.color;y(r)&&(e.style.color=Gf(r));var i=t.backgroundColor;y(i)&&(e.style.backgroundColor=Gf(i));var a=t.textOutline;if(y(a)){var o=a.trim().replace(/\s+/g," ").split(" "),s=o.length;if(3===s){var u=Gf(o[0]),l=o[1];e.style.textShadow=Wf(u,l)}else if(y(r)&&1===s){var d=o[0];e.style.textShadow=Wf(r,d)}else if(2===s){var c=/^[#A-Z]/i.test(o[0]);if(c!==/^[0-9]/.test(o[0]))if(c){var f=Gf(o[0]),v=o[1];e.style.textShadow=Wf(f,v)}else if(y(r)){var p=o[0];e.style.textShadow=Wf(r,p)}}}var h=t.textDecoration;if(y(h))switch(h){case"noUnderline":case"noLineThrough":case"noOverline":e.style.textDecoration="none";break;case"lineThrough":e.style.textDecoration="line-through";break;default:e.style.textDecoration=h}var m=t.fontFamily;if(y(m))switch(m){case"proportionalSansSerif":e.style.fontFamily="Arial, Helvetica, Liberation Sans, sans-serif";break;case"monospaceSansSerif":case"sansSerif":e.style.fontFamily="sans-serif";break;case"monospaceSerif":case"default":e.style.fontFamily="Courier New, Liberation Mono, monospace";break;case"proportionalSerif":e.style.fontFamily="serif";break;default:e.style.fontFamily=m}var g=t.fontStyle;y(g)&&(e.style.fontStyle=g);var _=t.fontWeight;y(_)&&(e.style.fontWeight=_);var b=t.fontSize;y(b)?function(e,t){var n=t.trim().split(" ");if(0!==n.length){var r=Xc.exec(n[0]);if(null!==r)if("px"===r[2]||"em"===r[2])e.style.fontSize=r[1]+r[2];else if("c"===r[2])e.style.position="relative",Kf(e,"proportional-style"),e.setAttribute("data-proportional-font-size",r[1]);else if("%"===r[2]){var i=Number(r[1]);isNaN(i)?oe.warn('TTML Parser: could not parse fontSize value "'+r[1]+'" into a number'):(e.style.position="relative",Kf(e,"proportional-style"),e.setAttribute("data-proportional-font-size",String(i/100)))}else oe.warn("TTML Parser: unhandled fontSize unit:",r[2])}}(e,b):(Kf(e,"proportional-style"),e.setAttribute("data-proportional-font-size","1"));var S=t.direction;y(S)&&(e.style.direction=S);var E=t.unicodeBidi;if(y(E))switch(E){case"bidiOverride":e.style.unicodeBidi="bidi-override";break;case"embed":e.style.unicodeBidi="embed";break;default:e.style.unicodeBidi="normal"}var T=t.visibility;y(T)&&(e.style.visibility=T),"none"===t.display&&(e.style.display="none");var k=t.wrapOption;e.style.whiteSpace="noWrap"===k?n?"nowrap":"pre":n?"normal":"pre-wrap"}function qf(e,t){e.style.color="white",e.style.position="absolute";var n=t.extent;y(n)&&function(e,t){var n=t.trim();if("auto"!==n){var r=n.split(" ");if(2===r.length){var i=Xc.exec(r[0]),a=Xc.exec(r[1]);null!==i&&null!==a&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.width=i[1]+i[2]:"c"===i[2]?(Kf(e,"proportional-style"),e.setAttribute("data-proportional-width",i[1])):oe.warn("TTML Parser: unhandled extent unit:",i[2]),"px"===a[2]||"%"===a[2]||"em"===a[2]?e.style.height=a[1]+a[2]:"c"===a[2]?(Kf(e,"proportional-style"),e.setAttribute("data-proportional-height",a[1])):oe.warn("TTML Parser: unhandled extent unit:",a[2]))}}}(e,n),y(t.writingMode);var r=t.overflow;e.style.overflow=y(r)?r:"hidden";var i=t.padding;y(i)&&function(e,t){var n=t.trim().split(" ");if(!(n.length<1)){var r=Xc.exec(n[0]);if(null!==r){if("px"===r[2]||"%"===r[2]||"em"===r[2]){var i=r[1]+r[2];1===n.length?e.style.padding=i:2===n.length?(e.style.paddingTop=i,e.style.paddingBottom=i):e.style.paddingTop=i}else"c"===r[2]?(Kf(e,"proportional-style"),1===n.length?(e.setAttribute("data-proportional-padding-top",r[1]),e.setAttribute("data-proportional-padding-bottom",r[1]),e.setAttribute("data-proportional-padding-left",r[1]),e.setAttribute("data-proportional-padding-right",r[1])):2===n.length?(e.setAttribute("data-proportional-padding-top",r[1]),e.setAttribute("data-proportional-padding-bottom",r[1])):e.setAttribute("data-proportional-padding-top",r[1])):oe.warn("TTML Parser: unhandled padding unit:",r[2]);if(1!==n.length){var a=Xc.exec(n[1]);if(null!==a){if("px"===a[2]||"%"===a[2]||"em"===a[2]){var o=a[1]+a[2];n.length<4?(e.style.paddingLeft=o,e.style.paddingRight=o):e.style.paddingRight=o}else"c"===a[2]?(Kf(e,"proportional-style"),n.length<4?(e.setAttribute("data-proportional-padding-left",a[1]),e.setAttribute("data-proportional-padding-right",a[1])):e.setAttribute("data-proportional-padding-right",a[1])):oe.warn("TTML Parser: unhandled padding unit:",a[2]);if(2!==n.length){var s=Xc.exec(n[2]);if(null!==s){if("px"===s[2]||"%"===s[2]||"em"===s[2]){var u=s[1]+s[2];e.style.paddingBottom=u}else"c"===s[2]?(Kf(e,"proportional-style"),e.setAttribute("data-proportional-padding-bottom",s[1])):oe.warn("TTML Parser: unhandled padding unit:",s[2]);if(3!==n.length){var l=Xc.exec(n[3]);if(null!==l)if("px"===l[2]||"%"===l[2]||"em"===l[2]){var d=l[1]+l[2];e.style.paddingLeft=d}else"c"===l[2]?(Kf(e,"proportional-style"),e.setAttribute("data-proportional-padding-left",l[1])):oe.warn("TTML Parser: unhandled padding unit:",l[2])}}}}}}}}(e,i);var a=t.origin;y(a)&&function(e,t){var n=t.trim();if("auto"!==n){var r=n.split(" ");if(2===r.length){var i=Xc.exec(r[0]),a=Xc.exec(r[1]);null!==i&&null!==a&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.left=i[1]+i[2]:"c"===i[2]?(Kf(e,"proportional-style"),e.setAttribute("data-proportional-left",i[1])):oe.warn("TTML Parser: unhandled origin unit:",i[2]),"px"===a[2]||"%"===a[2]||"em"===a[2]?e.style.top=a[1]+a[2]:"c"===a[2]?(Kf(e,"proportional-style"),e.setAttribute("data-proportional-top",a[1])):oe.warn("TTML Parser: unhandled origin unit:",a[2]))}}}(e,a);var o=t.displayAlign;if(y(o))switch(e.style.display="flex",e.style.flexDirection="column",o){case"before":e.style.justifyContent="flex-start";break;case"center":e.style.justifyContent="center";break;case"after":e.style.justifyContent="flex-end"}var s=t.opacity;y(s)&&(e.style.opacity=s);var u=t.visibility;y(u)&&(e.style.visibility=u),"none"===t.display&&(e.style.display="none")}function Yf(e,t){e.style.margin="0px",Kf(e,"proportional-style"),e.setAttribute("data-proportional-font-size","1");var n=t.backgroundColor;y(n)&&(e.style.backgroundColor=Gf(n));var r=t.lineHeight;y(r)&&function(e,t){var n=t.trim(),r=n.split(" ");if("auto"!==n){var i=Xc.exec(r[0]);null!==i&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.lineHeight=i[1]+i[2]:"c"===i[2]?(Kf(e,"proportional-style"),e.setAttribute("data-proportional-line-height",i[1])):oe.warn("TTML Parser: unhandled lineHeight unit:",i[2]))}}(e,r);var i=t.textAlign;if(y(i))switch(i){case"center":e.style.textAlign="center";break;case"left":case"start":e.style.textAlign="left";break;case"right":case"end":e.style.textAlign="right"}}function Qf(e,t,n){var r=document.createElement("span"),i=null===e.textContent?"":e.textContent;if(n){var a=i.trim();i=a=a.replace(/\s+/g," ")}var o=document.createTextNode(i);return r.appendChild(o),r.className="rxp-texttrack-span",Hf(r,t,n),r}function $f(e,t,n,r,i,a){var o=a.cellResolution,s=a.shouldTrimWhiteSpace,u=Uc(e),l=document.createElement("DIV");if(l.className="rxp-texttrack-region",l.setAttribute("data-resolution-columns",String(o.columns)),l.setAttribute("data-resolution-rows",String(o.rows)),qf(l,i),null!==t){var c=Oc(["backgroundColor"],[].concat(u,[t]),r,n).bodyBackgroundColor;y(c)&&(l.style.backgroundColor=Gf(c))}var f=document.createElement("p");f.className="rxp-texttrack-p",Yf(f,i);for(var v=function(e,t,n,r,i){return function e(r,i,a,o){for(var s=r.childNodes,u=[],l=0;l<s.length;l++){var c=s[l];if("#text"===c.nodeName){var f=Oc(["backgroundColor"],a,n,t).backgroundColor;y(f)?i.backgroundColor=f:delete i.backgroundColor;var v=Qf(c,i,o);u.push(v)}else if(Bc(c)){var p=document.createElement("BR");u.push(p)}else if(Fc(c)&&c.nodeType===Node.ELEMENT_NODE&&c.childNodes.length>0){var h=c.getAttribute("xml:space"),m=y(h)?"default"===h:o,g=d({},i,Oc(jf,[c],n,t));u.push.apply(u,e(c,g,[c].concat(a),m))}}return u}(e,d({},r),[],i)}(e,n,r,i,s),p=0;p<v.length;p++)f.appendChild(v[p]);return l.appendChild(f),l}function Xf(e){var t=e.paragraph,n=e.ttParams,r=e.body,i=e.regionStyles,a=e.idStyles,o=e.paragraphStyle,s=e.timeOffset,u=e.shouldTrimWhiteSpace;if(!t.hasAttribute("begin")&&!t.hasAttribute("end")&&/^\s*$/.test(null===t.textContent?"":t.textContent))return null;var l=n.cellResolution,d=af(t,n);return{start:d.start+s,end:d.end+s,element:$f(t,r,i,a,o,{cellResolution:l,shouldTrimWhiteSpace:u})}}var Zf=function(e,t){for(var n=Vc(e,t),r=[],i=0;i<n.length;i++){var a=n[i].paragraphStyle;zf(a)&&Vf(a);var o=Xf(n[i]);null!==o&&r.push(o)}return r},Jf=g.ResizeObserver;function ev(e,t,n){return void 0===n&&(n=.2),Math.abs(e-t)<=Math.min(n,.2)}function tv(e,t){for(var n=e.length-1;n>=0;n--){if(e[n].start<t)return e.slice(0,n+1)}return[]}function nv(e,t){for(var n=0;n<e.length;n++){if(e[n].end>t)return e.slice(n,e.length)}return[]}function rv(e,t,n){var r=Math.max(e.start,t),i=tv(e.cues,t),a={start:e.start,end:r,cues:i},o=Math.min(n,e.end),s=nv(e.cues,n);return[a,{start:o,end:e.end,cues:s}]}var iv=function(){function e(){this._cuesBuffer=[]}var t=e.prototype;return t.isEmpty=function(){return 0===this._cuesBuffer.length},t.get=function(e){for(var t=this._cuesBuffer,n=[],r=t.length-1;r>=0;r--){var i=t[r];if(e<i.end&&e>=i.start){for(var a=i.cues,o=0;o<a.length;o++)e>=a[o].start&&e<a[o].end&&n.push(a[o].element);if(0===n.length&&a.length>0)for(var s=0;s<a.length;s++)(ev(e,a[s].start,.001)||ev(e,a[s].end,.001))&&n.push(a[s].element);return n}}return[]},t.remove=function(e,t){for(var n=Math.max(e,t),r=this._cuesBuffer,i=0;i<r.length;i++)if(r[i].end>e){var a=r[i];if(a.start>=n)return;if(a.end>=n){if(e<=a.start)a.cues=nv(a.cues,n),a.start=n;else{var o=rv(a,e,n),s=o[0],u=o[1];this._cuesBuffer[i]=s,r.splice(i+1,0,u)}return}a.start>=e?(r.splice(i,1),i--):(a.cues=tv(a.cues,e),a.end=Math.max(e,a.start))}},t.insert=function(e,t,n){var r=this._cuesBuffer,i={start:t,end:n,cues:e},a=Math.abs(t-n)/5;function o(e){var t=r[e];void 0===t||ev(i.end,t.end,a)?r[e]=i:(t.start>=i.end||(t.cues=nv(t.cues,i.end),t.start=i.end),r.splice(e,0,i))}for(var s=0;s<r.length;s++){var u=r[s];if(t<u.end){if(ev(t,u.start,a)){if(ev(n,u.end,a))return void(r[s]=i);if(n<u.end)return u.cues=nv(u.cues,n),u.start=n,void r.splice(s,0,i);do{r.splice(s,1),u=r[s]}while(void 0!==u&&n>u.end);return void o(s)}if(t<u.start){if(n<u.start)return void r.splice(s,0,i);if(ev(n,u.start,a))return u.start=n,void r.splice(s,0,i);if(ev(n,u.end,a))return void r.splice(s,1,i);if(n<u.end)return u.cues=nv(u.cues,n),u.start=n,void r.splice(s,0,i);do{r.splice(s,1),u=r[s]}while(void 0!==u&&n>u.end);return void o(s)}if(ev(u.end,n,a))return u.cues=tv(u.cues,t),u.end=t,void r.splice(s+1,0,i);if(u.end>n){var l=rv(u,t,n),d=l[0],c=l[1];return this._cuesBuffer[s]=d,r.splice(s+1,0,i),void r.splice(s+2,0,c)}u.cues=tv(u.cues,t),u.end=t;var f=s+1;for(u=r[f];void 0!==u&&n>u.end;)r.splice(f,1),u=r[f];return void o(f)}}if(r.length){var v=r[r.length-1];ev(v.end,t,a)&&(v.end=t)}r.push(i)},e}();function av(e,t,n,r){for(var i=[t/n.columns,e/n.rows],a=r.getElementsByClassName("proportional-style"),o=0;o<a.length;o++){var s=a[o];if(s instanceof HTMLElement){var u=s.getAttribute("data-proportional-font-size");null===u||isNaN(+u)||(s.style.fontSize=String(+u*i[1])+"px");var l=s.getAttribute("data-proportional-width");null===l||isNaN(+l)||(s.style.width=String(+l*i[0])+"px");var d=s.getAttribute("data-proportional-height");null===d||isNaN(+d)||(s.style.height=String(+d*i[1])+"px");var c=s.getAttribute("data-proportional-line-height");null===c||isNaN(+c)||(s.style.lineHeight=String(+c*i[1])+"px");var f=s.getAttribute("data-proportional-left");null===f||isNaN(+f)||(s.style.left=String(+f*i[0])+"px");var v=s.getAttribute("data-proportional-top");null===v||isNaN(+v)||(s.style.top=String(+v*i[1])+"px");var p=s.getAttribute("data-proportional-padding-top");null===p||isNaN(+p)||(s.style.paddingTop=String(+p*i[1])+"px");var h=s.getAttribute("data-proportional-padding-bottom");null===h||isNaN(+h)||(s.style.paddingBottom=String(+h*i[1])+"px");var m=s.getAttribute("data-proportional-padding-left");null===m||isNaN(+m)||(s.style.paddingLeft=String(+m*i[0])+"px");var g=s.getAttribute("data-proportional-padding-right");null===g||isNaN(+g)||(s.style.paddingRight=String(+g*i[0])+"px")}}return a.length>0}var ov=V,sv=z,uv=F;function lv(e,t){try{e.removeChild(t)}catch(e){oe.warn("HTD: Can't remove text track: not in the element.")}}function dv(e){var t=e.getAttribute("data-resolution-rows"),n=e.getAttribute("data-resolution-columns");if(null===t||null===n)return null;var r=parseInt(t,10),i=parseInt(n,10);return null===r||null===i?null:{rows:r,columns:i}}var cv=function(){function e(e,t){oe.debug("HTD: Creating HTMLTextDisplayer"),this._buffered=new cf,this._videoElement=e,this._textTrackElement=t,this._sizeUpdateCanceller=new ht,this._subtitlesIntervalCanceller=new ht,this._buffer=new iv,this._currentCues=[],this._isAutoRefreshing=!1}var t=e.prototype;return t.pushTextData=function(e){var t,n;oe.debug("HTD: Appending new html text tracks");var r=e.timestampOffset,i=e.appendWindow,a=e.chunk;if(null===a)return st(this._buffered);var o,s,u=a.start,l=a.end,d=a.data,c=a.type,f=a.language,v=null!==(t=i[0])&&void 0!==t?t:0,p=null!==(n=i[1])&&void 0!==n?n:1/0,h=function(e,t,n,r){oe.debug("HTSB: Finding parser for html text tracks:",e);var i=Re.htmlTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");oe.debug("HTSB: Parser found, parsing...");var a=i(t,n,r);return oe.debug("HTTB: Parsed successfully!",a.length),a}(c,d,r,f);if(0!==v&&p!==1/0){for(var m=0;m<h.length&&h[m].end<=v;)m++;for(h.splice(0,m),m=0;m<h.length&&h[m].start<v;)h[m].start=v,m++;for(m=h.length-1;m>=0&&h[m].start>=p;)m--;for(h.splice(m,h.length),m=h.length-1;m>=0&&h[m].end>p;)h[m].end=p,m--}if(void 0!==u)o=Math.max(v,u);else{if(h.length<=0)return oe.warn("HTD: Current text tracks have no cues nor start time. Aborting"),st(this._buffered);oe.warn("HTD: No start time given. Guessing from cues."),o=h[0].start}if(void 0!==l)s=Math.min(p,l);else{if(h.length<=0)return oe.warn("HTD: Current text tracks have no cues nor end time. Aborting"),st(this._buffered);oe.warn("HTD: No end time given. Guessing from cues."),s=h[h.length-1].end}return s<=o?(oe.warn("HTD: Invalid text track appended: ","the start time is inferior or equal to the end time."),st(this._buffered)):(this._buffer.insert(h,o,s),this._buffered.insert(o,s),this._isAutoRefreshing||this._buffer.isEmpty()||this.autoRefreshSubtitles(this._subtitlesIntervalCanceller.signal),st(this._buffered))},t.removeBuffer=function(e,t){return oe.debug("HTD: Removing html text track data",e,t),this._buffer.remove(e,t),this._buffered.remove(e,t),this._isAutoRefreshing&&this._buffer.isEmpty()&&(this.refreshSubtitles(),this._isAutoRefreshing=!1,this._subtitlesIntervalCanceller.cancel(),this._subtitlesIntervalCanceller=new ht),st(this._buffered)},t.getBufferedRanges=function(){return st(this._buffered)},t.reset=function(){oe.debug("HTD: Resetting HTMLTextDisplayer"),this.stop(),this._subtitlesIntervalCanceller=new ht},t.stop=function(){this._subtitlesIntervalCanceller.isUsed()||(oe.debug("HTD: Stopping HTMLTextDisplayer"),this._disableCurrentCues(),this._buffer.remove(0,1/0),this._buffered.remove(0,1/0),this._isAutoRefreshing=!1,this._subtitlesIntervalCanceller.cancel())},t._disableCurrentCues=function(){if(this._sizeUpdateCanceller.cancel(),this._currentCues.length>0){for(var e=0;e<this._currentCues.length;e++)lv(this._textTrackElement,this._currentCues[e].element);this._currentCues=[]}},t._displayCues=function(e){if(!(this._currentCues.length===e.length&&this._currentCues.every((function(t,n){return t.element===e[n]})))){this._sizeUpdateCanceller.cancel();for(var t=0;t<this._currentCues.length;t++)lv(this._textTrackElement,this._currentCues[t].element);this._currentCues=[];for(var n=0;n<e.length;n++){var r=e[n],i=dv(r);this._currentCues.push({element:r,resolution:i}),this._textTrackElement.appendChild(r)}var a=this._currentCues.filter((function(e){return null!==e.resolution}));if(a.length>0){this._sizeUpdateCanceller=new ht,this._sizeUpdateCanceller.linkToSignal(this._subtitlesIntervalCanceller.signal);var o=p.getCurrent().TEXT_TRACK_SIZE_CHECKS_INTERVAL,s=function(e,t,n){var r=e.getBoundingClientRect(),i=r.height,a=r.width,o=new A({height:i,width:a},n),s=i,u=a;if(void 0!==Jf){var l=new Jf((function(e){if(0!==e.length){var t=e[0].contentRect,n=t.height,r=t.width;n===s&&r===u||(s=n,u=r,o.setValue({height:n,width:r}))}else oe.error("Compat: Resized but no observed element.")}));l.observe(e),n.register((function(){l.disconnect()}))}else{var d=setInterval((function(){var t=e.getBoundingClientRect(),n=t.height,r=t.width;n===s&&r===u||(s=n,u=r,o.setValue({height:n,width:r}))}),t);n.register((function(){clearInterval(d)}))}return o}(this._textTrackElement,o,this._sizeUpdateCanceller.signal);s.onUpdate((function(e){for(var t=e.height,n=e.width,r=0;r<a.length;r++){var i=a[r];av(t,n,i.resolution,i.element)}}),{clearSignal:this._sizeUpdateCanceller.signal,emitCurrentValue:!0})}}},t.autoRefreshSubtitles=function(e){var t=this;if(!this._isAutoRefreshing&&!e.isCancelled()){var n=null,r=p.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL,i=function(){t._isAutoRefreshing=!1,null!==n&&(n.cancel(),n=null)},a=function(){i(),t._isAutoRefreshing=!0,(n=new ht).linkToSignal(e);var a=setInterval((function(){return t.refreshSubtitles()}),r);n.signal.register((function(){clearInterval(a)})),t.refreshSubtitles()};uv(this._videoElement,(function(){i(),t._disableCurrentCues()}),e),sv(this._videoElement,a,e),ov(this._videoElement,a,e),a()}},t.refreshSubtitles=function(){var e,t=p.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL;e=this._videoElement.paused||this._videoElement.playbackRate<=0?this._videoElement.currentTime:Math.max(this._videoElement.currentTime+t/1e3/2,0);var n=this._buffer.get(e);0===n.length?this._disableCurrentCues():this._displayCues(n)},e}(),fv=cv;function vv(e){e.htmlTextTracksParsers.ttml=Zf,e.htmlTextDisplayer=fv}var pv=/&#([0-9]+);/g,hv=/<br>/gi,mv=/<style[^>]*>([\s\S]*?)<\/style[^>]*>/i,gv=/\s*<p (?:class=([^>]+))?>(.*)/i,yv=/<sync[^>]+?start="?([0-9]*)"?[^0-9]/i;function _v(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}var bv=function(e,t,n){var r,i,a=/<sync[ >]/gi,o=/<sync[ >]|<\/body>/gi,s=[],u=mv.exec(e),l=Array.isArray(u)?u[1]:"";o.exec(e);var d,c=function(e){for(var t=/\.(\S+)\s*{([^}]*)}/gi,n={},r=t.exec(e);null!==r;){var i=r[1],a=_v(r[2],"lang");null!=i&&null!=a&&(n[a]=i),r=t.exec(e)}return n}(l),f=function(e){var t=/p\s*{([^}]*)}/gi.exec(e);return null===t?"":t[1]}(l);if(y(n)&&void 0===(d=c[n]))throw new Error("sami: could not find lang "+n+" in CSS");for(;r=a.exec(e),i=o.exec(e),null!==r||null!==i;){if(null===r||null===i||r.index>=i.index)throw new Error("parse error");var v=e.slice(r.index,i.index),p=yv.exec(v);if(!Array.isArray(p))throw new Error("parse error (sync time attribute)");var h=+p[1];if(isNaN(h))throw new Error("parse error (sync time attribute NaN)");m(v.split("\n"),h/1e3)}return s;function m(e,n){for(var r=e.length;--r>=0;){var i=gv.exec(e[r]);if(Array.isArray(i)){var a=i[1],o=i[2];if(d===a)if("&nbsp;"===o)s[s.length-1].end=n;else{var u=document.createElement("DIV");u.className="rxp-texttrack-region";var l=document.createElement("DIV");l.className="rxp-texttrack-div",l.style.position="absolute",l.style.bottom="0",l.style.width="100%",l.style.color="#fff",l.style.textShadow="-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000";var c=document.createElement("div");c.className="rxp-texttrack-p",y(f)&&(c.style.cssText=f);for(var v=o.split(hv),p=0;p<v.length;p++){0!==p&&c.appendChild(document.createElement("BR"));var h=document.createElement("SPAN");h.className="rxp-texttrack-span",h.textContent=v[p].replace(pv,(function(e,t){return String.fromCharCode(Number(t))})),c.appendChild(h)}l.appendChild(c),u.appendChild(l),s.push({element:u,start:n+t,end:-1})}}}}};function Sv(e){e.htmlTextTracksParsers.sami=bv,e.htmlTextDisplayer=fv}var Ev={white:"#ffffff",lime:"#00ff00",cyan:"#00ffff",red:"#ff0000",yellow:"#ffff00",magenta:"#ff00ff",blue:"#0000ff",black:"#000000"};function Tv(e){var t=Object.keys(Ev).reduce((function(e,t){return e[t]="color: "+Ev[t]+";",e["bg_"+t]="background-color: "+Ev[t]+";",e}),{}),n="";return e.forEach((function(e){if(e.length>=2)for(var r=function(r){var a=e[r];if(Array.isArray(/::cue {/.exec(a)))for(a=e[++r];y(a)&&!Array.isArray(/}/.exec(a))&&0!==a.length;)n+=a,a=e[++r];else{for(var o=[],s=/::cue\(\.?(.*?)\)(?:,| {)/.exec(a);y(a)&&Array.isArray(s);)o.push(s[1]),a=e[++r],s=/::cue\(\.?(.*?)\)(?:,| {)/.exec(a);for(var u="";y(a)&&!Array.isArray(/}/.exec(a))&&0!==a.length;)u+=a,a=e[++r];o.forEach((function(e){void 0===t[e]?t[e]=u:t[e]+=u}))}i=r},i=1;i<e.length;i++)r(i)})),{classes:t,global:n}}function kv(e,t){var n,r=["u","i","b"],i=e.nodeName.toLowerCase().split(".")[0];if(Qe(["u","i","b","c","#text"],i))if("#text"===i){var a=e.wholeText.split("\n");n=document.createElement("span");for(var o=0;o<a.length;o++)if(o>0&&n.appendChild(document.createElement("br")),a[o].length>0){var s=document.createTextNode(a[o]);n.appendChild(s)}}else{var u=e.nodeName.toLowerCase().split("."),l=[];if(u.forEach((function(e){y(t[e])&&l.push(t[e])})),0!==l.length){var d=document.createAttribute("style");l.forEach((function(e){d.value+=e}));var c=Qe(r,i)?i:"span";(n=document.createElement(c)).setAttributeNode(d)}else{var f=Qe(r,i)?i:"span";n=document.createElement(f)}for(var v=0;v<e.childNodes.length;v++){var p=kv(e.childNodes[v],t);n.appendChild(p)}}else{n=document.createElement("span");for(var h=0;h<e.childNodes.length;h++){var m=kv(e.childNodes[h],t);n.appendChild(m)}}return n}var wv,Av,Iv,Rv=function(e){if(!(void 0!==e&&0!==De(e).length))return"text-align:center";var t=xv(e),n=Pv(e);return"position: absolute;margin: 0;transform: translate("+t.offset+"%,"+n.offset+"%);width: "+Lv(e.size)+"%;left: "+t.position+"%;top: "+(null!==n.position?n.position+"%":"auto")+";text-align: "+Nv(e.align)+";"};!function(e){e.LINE_LEFT="line-left",e.CENTER="center",e.LINE_RIGHT="line-right"}(wv||(wv={})),function(e){e.LEFT="left",e.CENTER="center",e.RIGHT="right"}(Av||(Av={})),function(e){e.START="start",e.CENTER="center",e.END="end"}(Iv||(Iv={}));var xv=function(e){return{position:Cv(e),offset:Mv(e)}},Cv=function(e){var t,n=Bv(e.position);if(null!==n)return n;var r=Nv(e.align);return((t={})[Av.LEFT]=0,t[Av.CENTER]=50,t[Av.RIGHT]=100,t)[r]},Mv=function(e){var t,n,r,i,a=((t={})[wv.LINE_LEFT]=0,t[wv.CENTER]=-50,t[wv.LINE_RIGHT]=-100,t),o=void 0!==e.position?(r=e.position,i=/,(line-left|line-right|center)/.exec(r),!Array.isArray(i)||i.length<2?null:i[1]):null;return null!==o?a[o]:((n={})[Av.LEFT]=0,n[Av.CENTER]=-50,n[Av.RIGHT]=-100,n)[void 0!==e.align?Nv(e.align):Av.CENTER]},Pv=function(e){return{position:Dv(e.line),offset:Ov(e.line)}},Dv=function(e){return Bv(e)},Ov=function(e){var t,n=((t={})[Iv.START]=0,t[Iv.CENTER]=-50,t[Iv.END]=-100,t);if(void 0===e)return n[Iv.START];var r,i=(r=/,(start|center|end)/.exec(e),!Array.isArray(r)||r.length<2?null:r[1]);return null!==i?n[i]:n[Iv.START]},Nv=function(e){switch(e){case"left":case"start":return"left";case"right":case"end":return"right";default:return"center"}},Lv=function(e){return Uv(e,100)},Uv=function(e,t){var n=Bv(e);return null!==n?n:t},Bv=function(e){if(void 0===e)return null;var t=/^([\d.]+)%/.exec(e);return!Array.isArray(t)||t.length<2?null:parseInt(t[1],10)};function Fv(e,t){var n=e.start,r=e.end,i=e.settings,a=e.header,o=e.payload,s=document.createElement("div"),u=document.createAttribute("style");u.value="width:100%;height:100%;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;",s.setAttributeNode(u);var l=document.createElement("p"),d=function(e){var t=document.createAttribute("style");return t.value=Rv(e),t}(i);l.setAttributeNode(d);var c=document.createElement("span"),f=document.createAttribute("style");f.value="background-color:rgba(0,0,0,0.8);color:white;",c.setAttributeNode(f);var v=t.global,p=t.classes,h=[v,y(a)?p[a]:void 0].filter((function(e){return void 0!==e})).join("");return f.value+=h,c.setAttributeNode(f),function(e,t){for(var n=e.replace(/<[0-9]{2}:[0-9]{2}.[0-9]{3}>/,"").replace(/<([u,i,b,c])(\..*?)?(?: .*?)?>(.*?)<\/\1>/g,"<$1$2>$3</$1$2>"),r=(new DOMParser).parseFromString(n,"text/html").body.childNodes,i=[],a=0;a<r.length;a++)i.push(kv(r[a],t));return i}(o.join("\n"),p).forEach((function(e){c.appendChild(e)})),s.appendChild(l),l.appendChild(c),{start:n,end:r,element:s}}var zv=function(e,t){var n=e.split(/\r\n|\n|\r/g),r=[];if(null===/^WEBVTT( |\t|\n|\r|$)/.exec(n[0]))throw new Error("Can't parse WebVTT: Invalid File.");for(var i=Tf(n),a=function(e,t){for(var n=[],r=t;r<e.length;r++)if(kf(e,r)){var i=r;for(r++;y(e[r]);)r++;var a=e.slice(i,r);n.push(a)}else if(y(e[r]))for(;y(e[r]);)r++;return n}(n,i),o=If(n,i),s=Tv(a),u=0;u<o.length;u++){var l=xf(o[u],t);if(null!=l){var d=Fv(l,s);r.push(d)}}return r};function Vv(e){e.htmlTextTracksParsers.vtt=zv,e.htmlTextDisplayer=fv}function Kv(e,t){for(var n=Of(e.split(/\r\n|\n|\r/)),r=[],i=0;i<n.length;i++){var a=Lf(n[i],t);if(null!=a){var o=Wv(a);null!=o&&r.push(o)}}return r}function Wv(e){var t=e.start,n=e.end,r=e.payload,i=document.createElement("div");i.className="rxp-texttrack-p",i.style.fontSize="28px",i.style.position="absolute",i.style.bottom="5%",i.style.width="100%",i.style.textAlign="center",i.style.color="#fff",i.style.textShadow="-1px -1px 2px #000,1px -1px 2px #000,-1px 1px 2px #000,1px 1px 2px #000";for(var a=0;a<r.length;a++){0!==a&&i.appendChild(document.createElement("br"));var o=Gv(r[a]);i.appendChild(o)}return{start:t,end:n,element:i}}function Gv(e){var t=document.createElement("div");t.innerHTML=e;return function e(t){var n=t.childNodes,r=document.createElement("span");r.className="rxp-texttrack-span";for(var i=0;i<n.length;i++){var a=n[i];if("#text"===a.nodeName){for(var o=a.wholeText.split("\n"),s=0;s<o.length;s++)if(0!==s&&r.appendChild(document.createElement("br")),o[s].length>0){var u=document.createTextNode(o[s]);r.appendChild(u)}}else if("B"===a.nodeName){var l=e(a);l.style.fontWeight="bold",r.appendChild(l)}else if("I"===a.nodeName){var d=e(a);d.style.fontStyle="italic",r.appendChild(d)}else if("U"===a.nodeName){var c=e(a);c.style.textDecoration="underline",r.appendChild(c)}else if(jv(a)&&"string"==typeof a.color){var f=e(a);f.style.color=a.color,r.appendChild(f)}else{var v=e(a);r.appendChild(v)}}return r}(t)}function jv(e){return"FONT"===e.nodeName&&"color"in e}function Hv(e){e.htmlTextTracksParsers.srt=Kv,e.htmlTextDisplayer=fv}an.addFeatures([Is,Ll,Hl,Pc,pf,Ef,Pf,Bf,vv,Sv,Vv,Hv]),e()&&oe.setLevel("DEBUG");var qv=an}(),r=r.default}()}));
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.RxPlayer=t():e.RxPlayer=t()}(self,(function(){return function(){var e={633:function(e,t,n){var r=n(738).default;function i(){"use strict";e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},a=Object.prototype,o=a.hasOwnProperty,s=Object.defineProperty||function(e,t,n){e[t]=n.value},u="function"==typeof Symbol?Symbol:{},l=u.iterator||"@@iterator",d=u.asyncIterator||"@@asyncIterator",c=u.toStringTag||"@@toStringTag";function f(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,n){return e[t]=n}}function v(e,t,n,r){var i=t&&t.prototype instanceof b?t:b,a=Object.create(i.prototype),o=new D(r||[]);return s(a,"_invoke",{value:x(e,n,o)}),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=v;var h="suspendedStart",m="suspendedYield",g="executing",y="completed",_={};function b(){}function S(){}function E(){}var T={};f(T,l,(function(){return this}));var k=Object.getPrototypeOf,w=k&&k(k(N([])));w&&w!==a&&o.call(w,l)&&(T=w);var A=E.prototype=b.prototype=Object.create(T);function I(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(i,a,s,u){var l=p(e[i],e,a);if("throw"!==l.type){var d=l.arg,c=d.value;return c&&"object"==r(c)&&o.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,u)}),(function(e){n("throw",e,s,u)})):t.resolve(c).then((function(e){d.value=e,s(d)}),(function(e){return n("throw",e,s,u)}))}u(l.arg)}var i;s(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(a,a):a()}})}function x(e,n,r){var i=h;return function(a,o){if(i===g)throw new Error("Generator is already running");if(i===y){if("throw"===a)throw o;return{value:t,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var u=C(s,r);if(u){if(u===_)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=y,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var l=p(e,n,r);if("normal"===l.type){if(i=r.done?y:m,l.arg===_)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i=y,r.method="throw",r.arg=l.arg)}}}function C(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,C(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var a=p(i,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,_;var o=a.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,_):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function M(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(M,this),this.reset(!0)}function N(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function n(){for(;++i<e.length;)if(o.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(r(e)+" is not iterable")}return S.prototype=E,s(A,"constructor",{value:E,configurable:!0}),s(E,"constructor",{value:S,configurable:!0}),S.displayName=f(E,c,"GeneratorFunction"),n.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===S||"GeneratorFunction"===(t.displayName||t.name))},n.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,f(e,c,"GeneratorFunction")),e.prototype=Object.create(A),e},n.awrap=function(e){return{__await:e}},I(R.prototype),f(R.prototype,d,(function(){return this})),n.AsyncIterator=R,n.async=function(e,t,r,i,a){void 0===a&&(a=Promise);var o=new R(v(e,t,r,i),a);return n.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},I(A),f(A,c,"Generator"),f(A,l,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),n.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},n.values=N,D.prototype={constructor:D,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var n in this)"t"===n.charAt(0)&&o.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),l=o.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,_):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),P(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;P(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:N(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),_}},n}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},738:function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},756:function(e,t,n){var r=n(633)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var r={};return function(){"use strict";function e(){return"boolean"==typeof __RX_PLAYER_DEBUG_MODE__&&__RX_PLAYER_DEBUG_MODE__}function t(e){return null==e}n.d(r,{default:function(){return Wv}});var i=function(){function e(){this._listeners={}}var n=e.prototype;return n.addEventListener=function(e,t,n){var r=this,i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],void 0!==n&&n.register((function(){r.removeEventListener(e,t)}))},n.removeEventListener=function(e,n){if(t(e))this._listeners={};else{var r=this._listeners[e];if(Array.isArray(r))if(t(n))delete this._listeners[e];else{var i=r.indexOf(n);-1!==i&&r.splice(i,1),0===r.length&&delete this._listeners[e]}}},n.trigger=function(e,t){var n=this._listeners[e];Array.isArray(n)&&n.slice().forEach((function(e){try{e(t)}catch(e){0,console.error("RxPlayer: EventEmitter error",e instanceof Error?e:null)}}))},e}(),a="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,o="undefined"==typeof window&&!a,s=a?self:o?n.g:window,u="function"==typeof queueMicrotask?queueMicrotask:function(e){Promise.resolve().then(e,(function(){return e()}))};function l(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function d(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){l(a,r,i,o,s,"next",e)}function s(e){l(a,r,i,o,s,"throw",e)}o(void 0)}))}}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function f(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}var v,p,h,m=n(756),g=n.n(m),y=!1,_=!1,b=!1,S=!1,E=!1,T=!1,k=!1,w=!1,A=!1,I=!1,R=!1,x=!1;o||(void 0!==s.MSInputMethodContext&&void 0!==document.documentMode?(_=!0,b=!0):"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&/(Trident|Edge)\//.test(navigator.userAgent)?b=!0:-1!==navigator.userAgent.toLowerCase().indexOf("edg/")?y=!0:-1!==navigator.userAgent.toLowerCase().indexOf("firefox")?S=!0:"string"==typeof navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)?T=!0:(Object.prototype.toString.call(s.HTMLElement).indexOf("Constructor")>=0||"[object SafariRemoteNotification]"===(null===(p=null===(v=s.safari)||void 0===v?void 0:v.pushNotification)||void 0===p?void 0:p.toString())||/Safari\/(\d+)/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&-1!==(null===(h=navigator.vendor)||void 0===h?void 0:h.indexOf("Apple"))&&!/Chrome\/(\d+)/.test(navigator.userAgent)&&!/Chromium\/(\d+)/.test(navigator.userAgent))&&(E=!0),/SamsungBrowser/.test(navigator.userAgent)&&(k=!0),-1!==navigator.userAgent.indexOf("PlayStation 4")?R=!0:-1!==navigator.userAgent.indexOf("PlayStation 5")?x=!0:/Tizen/.test(navigator.userAgent)?w=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(A=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\/87/.test(navigator.userAgent)||(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\/79/.test(navigator.userAgent))):/[Pp]anasonic/.test(navigator.userAgent)?I=!0:navigator.userAgent.indexOf("Xbox"));var C=x;var M={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:"native",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:"continue",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MINIMUM_MAX_BUFFER_AHEAD:{text:120},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:"none",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,BITRATE_REBUFFERING_RATIO:1.5,DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:500,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,SEGMENT_SYNCHRONIZATION_DELAY:1500,MISSING_DATA_TRIGGER_SYNC_DELAY:.1,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.005,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs="avc1.4d401e"','video/mp4;codecs="avc1.42e01e"','video/webm;codecs="vp8"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs="mp4a.40.2"',"audio/webm;codecs=opus"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:["HW_SECURE_ALL","HW_SECURE_DECODE","HW_SECURE_CRYPTO","SW_SECURE_DECODE","SW_SECURE_CRYPTO"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:["3000","2000"],EME_KEY_SYSTEMS:{clearkey:["webkit-org.w3.clearkey","org.w3.clearkey"],widevine:["com.widevine.alpha"],playready:["com.microsoft.playready.recommendation","com.microsoft.playready","com.chromecast.playready","com.youtube.playready"],fairplay:["com.apple.fps.1_0"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:"seamless",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:"reload",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:"seamless"};var P="function"==typeof Object.assign?Object.assign:function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=0;n<(arguments.length<=1?0:arguments.length-1);n++){var r=n+1<1||arguments.length<=n+1?void 0:arguments[n+1];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};function D(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}function N(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(0===n.length)return e;var i=n.shift();if(D(e)&&D(i))for(var a in i)if(D(i[a])){var o=e[a];void 0===o&&(o={},e[a]=o),N(o,i[a])}else{var s;P(e,((s={})[a]=i[a],s))}return N.apply(void 0,[e].concat(n))}var O=function(){function e(){this._config=M}var t=e.prototype;return t.update=function(e){var t=N(this._config,e);this._config=t},t.getCurrent=function(){return this._config},e}(),L=new O;function U(){}var F=function(e){function t(){var t;return(t=e.call(this)||this).error=U,t.warn=U,t.info=U,t.debug=U,t._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},t._currentLevel="NONE",t}f(t,e);var n=t.prototype;return n.setLevel=function(e,t){var n,r=this._levels[e];"number"==typeof r?(n=r,this._currentLevel=e):(n=0,this._currentLevel="NONE"),void 0===t?(this.error=n>=this._levels.ERROR?console.error.bind(console):U,this.warn=n>=this._levels.WARNING?console.warn.bind(console):U,this.info=n>=this._levels.INFO?console.info.bind(console):U,this.debug=n>=this._levels.DEBUG?console.log.bind(console):U):(this.error=n>=this._levels.ERROR?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("ERROR",n)}:U,this.warn=n>=this._levels.WARNING?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("WARNING",n)}:U,this.info=n>=this._levels.INFO?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("INFO",n)}:U,this.debug=n>=this._levels.DEBUG?function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t("DEBUG",n)}:U),this.trigger("onLogLevelChange",this._currentLevel)},n.getLevel=function(){return this._currentLevel},n.hasLevel=function(e){return this._levels[e]>=this._levels[this._currentLevel]},t}(i),B=new F,z=1/60;function V(e,t){return Math.abs(e-t)<z}function K(e,t){return{start:Math.min(e.start,t.start),end:Math.max(e.end,t.end)}}function W(e,t){return e.end<=t.start}function G(e,t){var n=e.start,r=e.end;return n<=t&&t<r}function H(e,t){return G(e,t.start)||e.start<t.end&&t.end<e.end||G(t,e.start)}function j(e,t){return V(t.start,e.end)||V(t.end,e.start)}function q(e){for(var t=[],n=0;n<e.length;n++)t.push({start:e.start(n),end:e.end(n)});return t}function Y(e,t){for(var n=e.length-1;n>=0;n--){var r=e.start(n);if(t>=r){var i=e.end(n);if(t<i)return{start:r,end:i}}}return null}function Q(e,t){for(var n=e.length-1;n>=0;n--){if(t>=e[n].start)if(t<e[n].end)return e[n]}return null}function $(e,t){for(var n=null,r=[],i=0;i<e.length;i++){var a=e[i].start,o=e[i].end;t<a||t>=o?r.push({start:a,end:o}):n={start:a,end:o}}return{outerRanges:r,innerRange:n}}function X(e,t){var n=Q(e,t);return null!==n?n.end-t:1/0}function Z(e,t){if(t.start===t.end)return e;for(var n=t,r=0;r<e.length;r++){var i=e[r],a=H(n,i),o=j(n,i);if(a||o)n=K(n,i),e.splice(r--,1);else if(0===r){if(W(n,e[0]))break}else if(W(e[r-1],n)&&W(n,i))break}return e.splice(r,0,n),function(e){for(var t=1;t<e.length;t++){var n=e[t-1],r=e[t];if(j(n,r)){var i=K(n,r);e.splice(--t,2,i)}}return e}(function(e){for(var t=0;t<e.length;t++){var n=e[t];n.start===n.end&&e.splice(t--,1)}return e}(e))}function J(e,t){for(var n=[],r=0;r<t.length;r++)H(e,t[r])&&n.push(t[r]);return n}function ee(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=[],o=J(i,t);if(o.length>0)for(var s=0;s<o.length;s++){var u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(0===a.length)n.push(i);else{for(var l=i.start,d=0;d<a.length;d++)a[d].start>l&&n.push({start:l,end:a[d].start}),l=a[d].end;l<i.end&&n.push({start:l,end:i.end})}}return n}function te(e,t,n){if("function"==typeof Array.prototype.findIndex)return e.findIndex(t,n);for(var r=e.length>>>0,i=0;i<r;i++)if(t.call(n,e[i],i,e))return i;return-1}function ne(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return re(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return re(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function re(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ie=function(){function e(e,t){var n=this;this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],void 0!==t&&(this._deregisterCancellation=t.register((function(){return n.finish()})))}var t=e.prototype;return t.getValue=function(){return this._value},t.setValue=function(e){if(!this._isFinished&&(this._value=e,0!==this._listeners.length))for(var t,n=ne(this._listeners.slice());!(t=n()).done;){var r=t.value;try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(e){}}},t.setValueIfChanged=function(e){e!==this._value&&this.setValue(e)},t.onUpdate=function(e,t){var n=this,r=function e(){if(void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.deregister(e),!i.hasBeenCleared){i.hasBeenCleared=!0;var r=n._listeners.indexOf(i);r>=0&&n._listeners.splice(r,1)}},i={trigger:e,complete:r,hasBeenCleared:!1};this._listeners.push(i),!0===(null==t?void 0:t.emitCurrentValue)&&e(this._value,r),this._isFinished||i.hasBeenCleared?r():void 0!==(null==t?void 0:t.clearSignal)&&t.clearSignal.register(r)},t.waitUntilDefined=function(e,t){var n=this;this.onUpdate((function(t,r){void 0!==t&&(r(),e(n._value))}),{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:!0})},t._onFinished=function(e,t){var n=this;if(t.isCancelled())return U;var r=function(){var e=te(n._onFinishCbs,(function(e){return e.trigger===i}));e>=0&&(n._onFinishCbs[e].hasBeenCleared=!0,n._onFinishCbs.splice(e,1))},i=function(){r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a},t.finish=function(){void 0!==this._deregisterCancellation&&this._deregisterCancellation(),this._isFinished=!0;for(var e,t=ne(this._listeners.slice());!(e=t()).done;){var n=e.value;try{n.hasBeenCleared||(n.complete(),n.hasBeenCleared=!0)}catch(e){}}if(this._listeners.length=0,this._onFinishCbs.length>0){for(var r,i=ne(this._onFinishCbs.slice());!(r=i()).done;){var a=r.value;try{a.hasBeenCleared||(a.trigger(),a.hasBeenCleared=!0)}catch(e){}}this._onFinishCbs.length=0}},e}();function ae(e,t,n){var r=new ie(t(e.getValue()),n);return e.onUpdate((function(e){r.setValue(t(e))}),{clearSignal:n}),e._onFinished((function(){r.finish()}),n),r}var oe=ie;function se(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ue(e){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ue(e)}function le(e,t,n){return le=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&c(i,n.prototype),i},le.apply(null,arguments)}function de(e){var t="function"==typeof Map?new Map:void 0;return de=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return le(e,arguments,ue(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)},de(e)}var ce=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(se(r),t.prototype),r.name="AssertionError",r.message=n,r}return f(t,e),t}(de(Error));function fe(e,t){0}function ve(e){throw new ce("Unreachable path taken")}var pe=function(){function e(){var e,t=(e=U,[function(t){e(t)},function(t){e=t}]),n=t[0],r=t[1];this._isUsed=!1,this._trigger=n,this.signal=new he(r)}var t=e.prototype;return t.isUsed=function(){return this._isUsed},t.linkToSignal=function(e){var t=this,n=e.register((function(){t.cancel()}));return this.signal.register(n),n},t.cancel=function(e){if(!this._isUsed){this._isUsed=!0;var t=null!=e?e:new me;this._trigger(t)}},e.isCancellationError=function(e){return e instanceof me},e}(),he=function(){function e(e){var t=this;this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e((function(e){for(t.cancellationError=e,t._isCancelled=!0;t._listeners.length>0;)try{var n=t._listeners.pop();null==n||n(e)}catch(e){B.error("Error while calling clean up listener",e instanceof Error?e.toString():"Unknown error")}}))}var t=e.prototype;return t.isCancelled=function(){return this._isCancelled},t.register=function(e){var t=this;return this._isCancelled?(fe(this.cancellationError),e(this.cancellationError),U):(this._listeners.push(e),function(){return t.deregister(e)})},t.deregister=function(e){for(var t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)},e}(),me=function(e){function t(){var n;return n=e.call(this)||this,Object.setPrototypeOf(se(n),t.prototype),n.name="CancellationError",n.message="This task was cancelled.",n}return f(t,e),t}(de(Error));var ge=new oe(0);var ye="undefined"!=typeof performance?function(){return performance.now()+ge.getValue()}:function(){return Date.now()+ge.getValue()};function _e(e){var t=e.map((function(t){return Math.log(t/e[0])})),n=t.map((function(e){return e-t[0]+1})),r=(n[n.length-1]-1)/(2*e.length+10),i=1/r;return e.map((function(e,t){return a(t)}));function a(t){if(0===t)return 0;var o=Math.min(Math.max(1,t),e.length-1);return e[o]===e[o-1]?a(t-1):i*(r+(e[o]*n[o-1]-e[o-1]*n[o])/(e[o]-e[o-1]))+4}}var be=function(){function e(e){this._levelsMap=_e(e).map((function(e){return e+4})),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=6e3,B.debug("ABR: Steps for buffer based chooser.",this._levelsMap.map((function(t,n){return"bufferLevel: "+t+", bitrate: "+e[n]})).join(" ,"))}var n=e.prototype;return n.onAddedSegment=function(e){var n=this._levelsMap,r=this._bitrates,i=e.bufferGap,a=e.currentBitrate,o=e.currentScore,s=e.speed;if(t(a))this._currentEstimate=r[0];else{for(var u,l=-1,d=0;d<r.length;d++){var c=r[d];if(c===a)l=d;else if(c>a)break}if(l<0||r.length!==n.length)return B.info("ABR: Current Bitrate not found in the calculated levels"),void(this._currentEstimate=r[0]);void 0!==o&&(u=0===s?o.score:o.score/s);var f=isFinite(i)?i:0,v=ye();if(f<n[l]||void 0!==u&&u<1&&1===(null==o?void 0:o.confidenceLevel)){if((void 0===this._lastUnsuitableQualityTimestamp?-1:v-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+9e3){var p=this._blockRaiseDelay+3e3;this._blockRaiseDelay=Math.min(p,15e3),B.debug("ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality",this._blockRaiseDelay)}else{var h=this._blockRaiseDelay-1e3;this._blockRaiseDelay=Math.max(6e3,h),B.debug("ABR: Lowering quality in BufferBasedChooser",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=v;for(var m=te(r,(function(e){return e===a}))-1;m>=0;m--)if(f>=n[m])return void(this._currentEstimate=r[m]);this._currentEstimate=r[0]}else if(void 0!==this._lastUnsuitableQualityTimestamp&&v-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||void 0===u||u<1.15||1!==(null==o?void 0:o.confidenceLevel))this._currentEstimate=a;else{var g=n[l],y=function(){for(var e=l+1;e<n.length;e++)if(n[e]>g)return e}();if(void 0!==y)if(i>=n[y])return B.debug("ABR: Raising quality in BufferBasedChooser",r[y]),void(this._currentEstimate=r[y]);this._currentEstimate=a}}},n.getLastEstimate=function(){return this._currentEstimate},e}();function Se(e,t,n){if("function"==typeof Array.prototype.find)return e.find(t,n);for(var r=e.length>>>0,i=0;i<r;i++){var a=e[i];if(t.call(n,a,i,e))return a}}var Ee=function(){function e(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}var t=e.prototype;return t.addSample=function(e,t){var n=Math.pow(this._alpha,e),r=t*(1-n)+n*this._lastEstimate;isNaN(r)||(this._lastEstimate=r,this._totalWeight+=e)},t.getEstimate=function(){var e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e},e}();function Te(e){if(!(e.progress.length<5)){for(var t=new Ee(2),n=e.progress,r=1;r<n.length;r++){var i=n[r].size-n[r-1].size,a=n[r].timestamp-n[r-1].timestamp,o=8*i/(a/1e3);t.addSample(a/1e3,o)}return t.getEstimate()}}function ke(e,t){var n=8*(e.totalSize-e.size);return Math.max(n/t,0)}var we=function(){function e(e,t){var n=L.getCurrent(),r=n.ABR_STARVATION_GAP,i=n.OUT_OF_STARVATION_GAP,a=n.ABR_STARVATION_FACTOR,o=n.ABR_REGULAR_FACTOR;this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,this._config=t?{starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:{starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}var n=e.prototype;return n.getBandwidthEstimate=function(e,n,r,i,a){var o,s,u=this._config,l=e.bufferGap,d=e.position,c=e.duration,f=isFinite(l)?l:0,v=L.getCurrent().ABR_STARVATION_DURATION_DELTA;return isNaN(c)||f+d.getWanted()<c-v?!this._inStarvationMode&&f<=u.starvationGap?(B.info("ABR: enter starvation mode."),this._inStarvationMode=!0):this._inStarvationMode&&f>=u.outOfStarvationGap&&(B.info("ABR: exit starvation mode."),this._inStarvationMode=!1):this._inStarvationMode&&(B.info("ABR: exit starvation mode."),this._inStarvationMode=!1),this._inStarvationMode&&(s=function(e,n,r,i,a){if(!i){var o=n.bufferGap,s=n.speed,u=n.position,l=isFinite(o)?o:0,d=function(e,t){for(var n=-1,r=0;r<e.length;r++){var i=e[r].content.segment;if(!(i.duration<=0)){var a=i.time+i.duration;if(!i.complete&&r===e.length-1&&t-i.time>-1.2){n=r;break}if(a>t&&t-i.time>-1.2){n=r;break}}}if(n<0)return[];for(var o=e[n],s=o.content.segment.time,u=[o],l=n+1;l<e.length&&e[l].content.segment.time===s;l++)u.push(e[l]);return u}(e,u.getWanted()+l);if(1===d.length){var c=d[0],f=ye(),v=1.5*c.content.segment.duration;if(v=Math.min(v,3e3),v=Math.max(v,12e3),!(f-c.requestTimestamp<v)){var p=c.progress.length>0?c.progress[c.progress.length-1]:void 0,h=Te(c);if(void 0!==p&&void 0!==h){var m=ke(p,h);if((f-p.timestamp)/1e3<=m&&m-l/s>2500)return h}if(c.content.segment.complete){var g=c.content.segment.duration,y=(f-c.requestTimestamp)/1e3,_=y<=(1.5*g+2)/s;if(!t(r)&&!_){var b=g/y,S=r.bitrate*Math.min(.7,b);return void 0===a||S<a?S:void 0}}}}}}(i,e,r,this._lowLatencyMode,a),void 0!==s&&(B.info("ABR: starvation mode emergency estimate:",s),n.reset(),o=t(r)?s:Math.min(s,r.bitrate))),t(o)&&(o=void 0!==(s=n.getEstimate())?s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):void 0!==a?a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}},n.isUrgent=function(e,t,n,r){return null===t||!(e>=t.bitrate)&&function(e,t,n){if(n)return!0;var r=isFinite(e.bufferGap)?e.bufferGap:0,i=e.position.getWanted()+r,a=Se(t,(function(e){var t=e.content;return t.segment.duration>0&&t.segment.time+t.segment.duration>i}));if(void 0===a)return!0;var o=ye(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=Te(a);if(void 0===s||void 0===u)return!0;var l=ke(s,u);return(o-s.timestamp)/1e3>1.2*l||l-r/e.speed>-1.5}(r,n,this._lowLatencyMode)},e}();function Ae(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ie(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ie(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Re=function(){function e(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}var t=e.prototype;return t.getGuess=function(e,t,n,r,i){var a=t.bufferGap,o=t.speed,s=this._lastAbrEstimate.representation;if(null===s)return null;if(r>s.bitrate)return 2===this._lastAbrEstimate.algorithmType&&(null!==this._lastAbrEstimate.representation&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;var u=this._scoreCalculator.getEstimate(n);if(2!==this._lastAbrEstimate.algorithmType){if(void 0===u)return null;if(this._canGuessHigher(a,o,u)){var l=xe(e,n);if(null!==l)return l}return null}if(this._isLastGuessValidated(s,r,u)&&(B.debug("ABR: Guessed Representation validated",s.bitrate),this._lastMaintanableBitrate=s.bitrate,this._consecutiveWrongGuesses=0),n.id!==s.id)return s;if(this._shouldStopGuess(n,u,a,i))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=ye()+Math.min(15e3*this._consecutiveWrongGuesses,12e4),function(e,t){var n=te(e,(function(e){return e.id===t.id}));if(n<0)return B.error("ABR: Current Representation not found."),null;for(;--n>=0;)if(e[n].bitrate<t.bitrate)return e[n];return null}(e,n);if(void 0===u)return n;if(this._canGuessHigher(a,o,u)){var d=xe(e,n);if(null!==d)return d}return n},t._canGuessHigher=function(e,t,n){var r=n.score,i=n.confidenceLevel;return isFinite(e)&&e>=2.5&&ye()>this._blockGuessesUntil&&1===i&&r/t>1.01},t._shouldStopGuess=function(e,t,n,r){if(void 0!==t&&t.score<1.01)return!0;if((void 0===t||t.score<1.2)&&n<.6)return!0;for(var i,a=r.filter((function(t){return t.content.representation.id===e.id})),o=ye(),s=Ae(a);!(i=s()).done;){var u=i.value,l=o-u.requestTimestamp;if(u.content.segment.isInit){if(l>1e3)return!0}else{if(l>1e3*u.content.segment.duration+200)return!0;var d=Te(u);if(void 0!==d&&d<.8*e.bitrate)return!0}}return!1},t._isLastGuessValidated=function(e,t,n){return void 0!==n&&1===n.confidenceLevel&&n.score>1.5||t>=e.bitrate&&(null===this._lastMaintanableBitrate||this._lastMaintanableBitrate<e.bitrate)},e}();function xe(e,t){var n=e.length,r=te(e,(function(e){return e.id===t.id}));if(r<0)return B.error("ABR: Current Representation not found."),null;for(;++r<n;)if(e[r].bitrate>t.bitrate)return e[r];return null}var Ce=function(){function e(){var e=L.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new Ee(t),this._slowEWMA=new Ee(n),this._bytesSampled=0}var t=e.prototype;return t.addSample=function(e,t){if(!(t<L.getCurrent().ABR_MINIMUM_CHUNK_SIZE)){var n=8e3*t/e,r=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(r,n),this._slowEWMA.addSample(r,n)}},t.getEstimate=function(){var e=L.getCurrent().ABR_MINIMUM_TOTAL_BYTES;if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())},t.reset=function(){var e=L.getCurrent(),t=e.ABR_FAST_EMA,n=e.ABR_SLOW_EMA;this._fastEWMA=new Ee(t),this._slowEWMA=new Ee(n),this._bytesSampled=0},e}();var Me=function(){function e(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}return e.prototype.update=function(e,t,n){this.representation=e,this.bandwidth=t,this.algorithmType=n},e}();function Pe(e){return Object.keys(e).map((function(t){return e[t]}))}var De="function"==typeof Object.values?Object.values:Pe,Ne=function(){function e(){this._currentRequests={}}var n=e.prototype;return n.add=function(e){var t=e.id,n=e.requestTimestamp,r=e.content;this._currentRequests[t]={requestTimestamp:n,progress:[],content:r}},n.addProgress=function(e){var n=this._currentRequests[e.id];t(n)?B.warn("ABR: progress for a request not added"):n.progress.push(e)},n.remove=function(e){t(this._currentRequests[e])&&B.warn("ABR: can't remove unknown request"),delete this._currentRequests[e]},n.getRequests=function(){return De(this._currentRequests).filter((function(e){return!t(e)})).sort((function(e,t){return e.content.segment.time-t.content.segment.time}))},e}(),Oe=function(){function e(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}var t=e.prototype;return t.addSample=function(e,t,n){var r,i=n/t,a=this._currentRepresentationData;null!==a&&a.representation.id===e.id?(r=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=n,a.loadedSegments++):((r=new Ee(5)).addSample(t,i),this._currentRepresentationData={representation:e,ewma:r,loadedDuration:n,loadedSegments:0}),r.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(B.debug("ABR: New last stable representation",e.bitrate),this._lastRepresentationWithGoodScore=e)},t.getEstimate=function(e){if(null!==this._currentRepresentationData&&this._currentRepresentationData.representation.id===e.id){var t=this._currentRepresentationData,n=t.ewma,r=t.loadedSegments,i=t.loadedDuration;return{score:n.getEstimate(),confidenceLevel:r>=5&&i>=10?1:0}}},t.getLastStableRepresentation=function(){return this._lastRepresentationWithGoodScore},e}();function Le(e,t){var n=te(e,(function(e){return e.bitrate>t}));return-1===n?e[e.length-1]:0===n?e[0]:e[n-1]}var Ue=new oe(void 0);Ue.finish();var Fe=new oe(1/0);Fe.finish();var Be=function(e){var n={},r=e.initialBitrates,i=e.throttlers,a=e.lowLatencyMode;return function(e,o,s,u,l){var d,c,f,v=e.adaptation.type,p=function(e){var r=n[e];if(t(r)){B.debug("ABR: Creating new BandwidthEstimator for ",e);var i=new Ce;return n[e]=i,i}return r}(v),h=null!==(d=r[v])&&void 0!==d?d:0;return function(e,t){var n=e.bandwidthEstimator,r=e.context,i=e.currentRepresentation,a=e.filters,o=e.initialBitrate,s=e.lowLatencyMode,u=e.playbackObserver,l=e.representations,d=new Oe,c=new we(null!=o?o:0,s),f=new Ne,v=U,p={metrics:_,requestBegin:b,requestProgress:S,requestEnd:E,addedSegment:function(e){v(e)}},h=new pe;h.linkToSignal(t);var m=g(l.getValue(),h.signal);return l.onUpdate(y,{clearSignal:t}),{estimates:m,callbacks:p};function g(e,t){if(e.length<=1)return new oe({bitrate:void 0,representation:e[0],urgent:!0,knownStableBitrate:void 0});var o=!1,l=e.sort((function(e,t){return e.bitrate-t.bitrate})),p=new be(l.map((function(e){return e.bitrate}))),h=new Me,m=new Re(d,h),g=u.getReference().getValue(),y=new oe(b());return u.listen((function(e){g=e,_()}),{includeLastObservation:!1,clearSignal:t}),v=function(e){if(null!==g){var t=g,n=t.position,r=t.speed,i=X(e.buffered,n.getWanted()),a=e.content.representation,o=d.getEstimate(a),s={bufferGap:i,currentBitrate:a.bitrate,currentScore:o,speed:r};p.onAddedSegment(s),_()}},t.register((function(){v=U})),a.throttleBitrate.onUpdate(_,{clearSignal:t}),a.limitResolution.onUpdate(_,{clearSignal:t}),y;function _(){y.setValue(b())}function b(){var e=g,t=e.bufferGap,u=e.position,v=e.maximumPosition,y=a.limitResolution.getValue(),_=a.throttleBitrate.getValue(),b=i.getValue(),S=function(e,t,n){var r=e;void 0!==n&&n<1/0&&(r=function(e,t){if(0===e.length)return[];e.sort((function(e,t){return e.bitrate-t.bitrate}));var n=e[0].bitrate,r=Math.max(t,n),i=te(e,(function(e){return e.bitrate>r}));return-1===i?e:e.slice(0,i)}(r,n));void 0!==t&&(r=function(e,t){if(void 0===t.width||void 0===t.height)return e;var n=t.width*t.pixelRatio,r=t.height*t.pixelRatio,i=e.slice().sort((function(e,t){var n,r;return(null!==(n=e.width)&&void 0!==n?n:0)-(null!==(r=t.width)&&void 0!==r?r:0)})),a=Se(i,(function(e){return"number"==typeof e.width&&e.width>=n&&"number"==typeof e.height&&e.height>=r}));if(void 0===a)return e;var o="number"==typeof a.width?a.width:0;return e.filter((function(e){return"number"!=typeof e.width||e.width<=o}))}(r,t));return r}(l,y,_),E=f.getRequests(),T=c.getBandwidthEstimate(g,n,b,E,h.bandwidth),k=T.bandwidthEstimate,w=T.bitrateChosen,A=d.getLastStableRepresentation(),I=null===A?void 0:A.bitrate/(g.speed>0?g.speed:1),R=L.getCurrent(),x=R.ABR_ENTER_BUFFER_BASED_ALGO,C=R.ABR_EXIT_BUFFER_BASED_ALGO;o&&t<=C?o=!1:!o&&isFinite(t)&&t>=x&&(o=!0);var M=Le(S,w),P=p.getLastEstimate(),D=M.bitrate,N=null;o&&void 0!==P&&P>D&&(D=(N=Le(S,P)).bitrate);var O=null;return s&&null!==b&&r.manifest.isDynamic&&v-u.getWanted()<40&&(O=m.getGuess(l,g,b,D,E)),null!==O&&O.bitrate>D?(B.debug("ABR: Choosing representation with guess-based estimation.",O.bitrate,O.id),h.update(O,k,2),{bitrate:k,representation:O,urgent:null===b||O.bitrate<b.bitrate,knownStableBitrate:I}):null!==N?(B.debug("ABR: Choosing representation with buffer-based estimation.",N.bitrate,N.id),h.update(N,k,0),{bitrate:k,representation:N,urgent:c.isUrgent(N.bitrate,b,E,g),knownStableBitrate:I}):(B.debug("ABR: Choosing representation with bandwidth estimation.",M.bitrate,M.id),h.update(M,k,1),{bitrate:k,representation:M,urgent:c.isUrgent(M.bitrate,b,E,g),knownStableBitrate:I})}}function y(){var e=l.getValue();h.cancel(),(h=new pe).linkToSignal(t),g(e,h.signal).onUpdate((function(e){m.setValue(e)}),{clearSignal:h.signal,emitCurrentValue:!0})}function _(e){var t=e.requestDuration,r=e.segmentDuration,i=e.size,a=e.content;if(n.addSample(t,i),!a.segment.isInit){var o=a.segment,s=a.representation;if(void 0===r&&!o.complete)return;var u=null!=r?r:o.duration;d.addSample(s,t/1e3,u)}}function b(e){f.add(e)}function S(e){f.addProgress(e)}function E(e){f.remove(e.id)}}({bandwidthEstimator:p,context:e,currentRepresentation:o,filters:{limitResolution:null!==(c=i.limitResolution[v])&&void 0!==c?c:Ue,throttleBitrate:null!==(f=i.throttleBitrate[v])&&void 0!==f?f:Fe},initialBitrate:h,playbackObserver:u,representations:s,lowLatencyMode:a},l)}},ze=function(e){function t(n,r,i){var a;switch(a=e.call(this)||this,Object.setPrototypeOf(se(a),t.prototype),a.name="RequestError",a.url=n,a.status=r,a.type=i,i){case"TIMEOUT":a.message="The request timed out";break;case"ERROR_EVENT":a.message="An error prevented the request to be performed successfully";break;case"PARSE_ERROR":a.message="An error happened while formatting the response data";break;case"ERROR_HTTP_CODE":a.message="An HTTP status code indicating failure was received: "+String(a.status)}return a}return f(t,e),t.prototype.serialize=function(){return{url:this.url,status:this.status,type:this.type}},t}(de(Error)),Ve={TIMEOUT:"TIMEOUT",ERROR_EVENT:"ERROR_EVENT",ERROR_HTTP_CODE:"ERROR_HTTP_CODE",PARSE_ERROR:"PARSE_ERROR"},Ke=Ve,We={NETWORK_ERROR:"NETWORK_ERROR",MEDIA_ERROR:"MEDIA_ERROR",ENCRYPTED_MEDIA_ERROR:"ENCRYPTED_MEDIA_ERROR",OTHER_ERROR:"OTHER_ERROR"},Ge={PIPELINE_LOAD_ERROR:"PIPELINE_LOAD_ERROR",PIPELINE_PARSE_ERROR:"PIPELINE_PARSE_ERROR",INTEGRITY_ERROR:"INTEGRITY_ERROR",MANIFEST_PARSE_ERROR:"MANIFEST_PARSE_ERROR",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"MANIFEST_INCOMPATIBLE_CODECS_ERROR",MANIFEST_UPDATE_ERROR:"MANIFEST_UPDATE_ERROR",MANIFEST_UNSUPPORTED_ADAPTATION_TYPE:"MANIFEST_UNSUPPORTED_ADAPTATION_TYPE",MEDIA_STARTING_TIME_NOT_FOUND:"MEDIA_STARTING_TIME_NOT_FOUND",MEDIA_TIME_BEFORE_MANIFEST:"MEDIA_TIME_BEFORE_MANIFEST",MEDIA_TIME_AFTER_MANIFEST:"MEDIA_TIME_AFTER_MANIFEST",MEDIA_TIME_NOT_FOUND:"MEDIA_TIME_NOT_FOUND",NO_PLAYABLE_REPRESENTATION:"NO_PLAYABLE_REPRESENTATION",MEDIA_IS_ENCRYPTED_ERROR:"MEDIA_IS_ENCRYPTED_ERROR",CREATE_MEDIA_KEYS_ERROR:"CREATE_MEDIA_KEYS_ERROR",MEDIA_KEYS_ATTACHMENT_ERROR:"MEDIA_KEYS_ATTACHMENT_ERROR",KEY_ERROR:"KEY_ERROR",KEY_STATUS_CHANGE_ERROR:"KEY_STATUS_CHANGE_ERROR",KEY_UPDATE_ERROR:"KEY_UPDATE_ERROR",KEY_LOAD_ERROR:"KEY_LOAD_ERROR",KEY_LOAD_TIMEOUT:"KEY_LOAD_TIMEOUT",KEY_GENERATE_REQUEST_ERROR:"KEY_GENERATE_REQUEST_ERROR",INCOMPATIBLE_KEYSYSTEMS:"INCOMPATIBLE_KEYSYSTEMS",INVALID_ENCRYPTED_EVENT:"INVALID_ENCRYPTED_EVENT",INVALID_KEY_SYSTEM:"INVALID_KEY_SYSTEM",LICENSE_SERVER_CERTIFICATE_ERROR:"LICENSE_SERVER_CERTIFICATE_ERROR",MULTIPLE_SESSIONS_SAME_INIT_DATA:"MULTIPLE_SESSIONS_SAME_INIT_DATA",BUFFER_APPEND_ERROR:"BUFFER_APPEND_ERROR",BUFFER_FULL_ERROR:"BUFFER_FULL_ERROR",BUFFER_TYPE_UNKNOWN:"BUFFER_TYPE_UNKNOWN",MEDIA_ERR_BLOCKED_AUTOPLAY:"MEDIA_ERR_BLOCKED_AUTOPLAY",MEDIA_ERR_PLAY_NOT_ALLOWED:"MEDIA_ERR_PLAY_NOT_ALLOWED",MEDIA_ERR_NOT_LOADED_METADATA:"MEDIA_ERR_NOT_LOADED_METADATA",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_UNKNOWN:"MEDIA_ERR_UNKNOWN",MEDIA_SOURCE_NOT_SUPPORTED:"MEDIA_SOURCE_NOT_SUPPORTED",MEDIA_KEYS_NOT_SUPPORTED:"MEDIA_KEYS_NOT_SUPPORTED",DISCONTINUITY_ENCOUNTERED:"DISCONTINUITY_ENCOUNTERED",NONE:"NONE"};function He(e,t){return e+": "+t}var je=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(se(a),t.prototype),a.name="EncryptedMediaError",a.type=We.ENCRYPTED_MEDIA_ERROR,a.code=n,a._originalMessage=r,a.message=He(a.code,r),a.fatal=!1,"string"==typeof(null==i?void 0:i.keyStatuses)&&(a.keyStatuses=i.keyStatuses),a}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}},t}(de(Error)),qe=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(se(a),t.prototype),a.name="MediaError",a.type=We.MEDIA_ERROR,a._originalMessage=r,a.code=n,a.message=He(a.code,r),a.fatal=!1,void 0!==(null==i?void 0:i.tracks)&&(null==i?void 0:i.tracks.length)>0&&(a.tracksInfo=i.tracks),a}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}},t}(de(Error)),Ye=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(se(i),t.prototype),i.name="NetworkError",i.type=We.NETWORK_ERROR,i.url=r.url,i.status=r.status,i.errorType=r.type,i._baseError=r,i.code=n,i.message=He(i.code,r.message),i.fatal=!1,i}f(t,e);var n=t.prototype;return n.isHttpError=function(e){return this.errorType===Ke.ERROR_HTTP_CODE&&this.status===e},n.serialize=function(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}},t}(de(Error)),Qe=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(se(i),t.prototype),i.name="OtherError",i.type=We.OTHER_ERROR,i.code=n,i.message=He(i.code,r),i.fatal=!1,i._originalMessage=r,i}return f(t,e),t.prototype.serialize=function(){return{name:this.name,code:this.code,reason:this._originalMessage}},t}(de(Error));function $e(e){return(e instanceof je||e instanceof qe||e instanceof Qe||e instanceof Ye)&&Object.keys(We).indexOf(e.type)>=0}function Xe(e,t){var n=t.defaultCode,r=t.defaultReason;if($e(e))return e;var i=e instanceof Error?e.toString():r;return new Qe(n,i)}function Ze(){var e="",t=-1;return function(){return++t>=Number.MAX_SAFE_INTEGER&&(e+="0",t=0),e+String(t)}}function Je(e,t,n){if("function"==typeof Array.prototype.includes)return e.includes(t,n);var r=e.length>>>0;if(0===r)return!1;for(var i,a,o=0|n,s=o>=0?Math.min(o,r-1):Math.max(r+o,0);s<r;){if((i=e[s])===(a=t)||"number"==typeof i&&"number"==typeof a&&isNaN(i)&&isNaN(a))return!0;s++}return!1}var et=[];function tt(e){Je(et,e)||(console.warn(e),et.push(e))}var nt=["audio","video","text"];function rt(e){var t,n,r=e.timeBounds;if(null===r.timeshiftDepth)return null!==(t=r.minimumSafePosition)&&void 0!==t?t:0;var i,a=r.maximumTimeData;if(r.maximumTimeData.isLinear){var o=ye()-a.time;i=a.maximumSafePosition+o/1e3}else i=a.maximumSafePosition;var s=i-r.timeshiftDepth;return Math.max(null!==(n=r.minimumSafePosition)&&void 0!==n?n:0,s)}function it(e){var t=e.timeBounds.maximumTimeData;if(e.isLive&&void 0!==t.livePosition){if(!t.isLinear)return t.livePosition;var n=ye()-t.time;return t.livePosition+n/1e3}}function at(e){var t=e.timeBounds.maximumTimeData;if(!t.isLinear)return t.maximumSafePosition;var n=ye()-t.time;return t.maximumSafePosition+n/1e3}function ot(e,t){if(void 0===t)return lt(e).filter((function(e){return!0===e.isSupported}));var n=e.adaptations[t];return void 0===n?[]:n.filter((function(e){return!0===e.isSupported}))}function st(e,t){var n=t.end;if(void 0===n)return null;var r=Se(e.periods,(function(e){return void 0===e.end||n<e.end}));return void 0===r?null:r}function ut(e,t,n){return t>=e.start&&(void 0===e.end||t<e.end)||t===e.end&&(null===n||n.start>e.end)}function lt(e){return Pe(e.adaptations).reduce((function(e,n){return t(n)?e:e.concat(n)}),[])}function dt(e,t){var n,r,i={language:null!==(n=e.language)&&void 0!==n?n:"",normalized:null!==(r=e.normalizedLanguage)&&void 0!==r?r:"",audioDescription:!0===e.isAudioDescription,id:e.id,representations:(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(vt),label:e.label};return!0===e.isDub&&(i.dub=!0),i}function ct(e){var t,n;return{language:null!==(t=e.language)&&void 0!==t?t:"",normalized:null!==(n=e.normalizedLanguage)&&void 0!==n?n:"",closedCaption:!0===e.isClosedCaption,id:e.id,label:e.label,forced:e.isForcedSubtitles}}function ft(e,t){var n=void 0!==e.trickModeTracks?e.trickModeTracks.map((function(e){var n=(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(pt),r={id:e.id,representations:n,isTrickModeTrack:!0};return!0===e.isSignInterpreted&&(r.signInterpreted=!0),r})):void 0,r={id:e.id,representations:(t?e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})):e.representations).map(pt),label:e.label};return!0===e.isSignInterpreted&&(r.signInterpreted=!0),!0===e.isTrickModeTrack&&(r.isTrickModeTrack=!0),void 0!==n&&(r.trickModeTracks=n),r}function vt(e){var t=e.id,n=e.bitrate,r=e.codecs,i=e.isSpatialAudio,a=e.isSupported,o=e.decipherable;return{id:t,bitrate:n,codec:null==r?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function pt(e){var t=e.id,n=e.bitrate,r=e.frameRate,i=e.width,a=e.height,o=e.codecs,s=e.hdrInfo,u=e.isSupported,l=e.decipherable;return{id:t,bitrate:n,frameRate:r,width:i,height:a,codec:null==o?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:l}}function ht(e){switch(e.type){case"audio":return{type:"audio",track:dt(e,!1)};case"video":return{type:"video",track:ft(e,!1)};case"text":return{type:"text",track:ct(e)}}}function mt(e){return"string"==typeof e&&e.length>0}var gt={aa:"aar",ab:"abk",ae:"ave",af:"afr",ak:"aka",am:"amh",an:"arg",ar:"ara",as:"asm",av:"ava",ay:"aym",az:"aze",ba:"bak",be:"bel",bg:"bul",bi:"bis",bm:"bam",bn:"ben",bo:"bod",br:"bre",bs:"bos",ca:"cat",ce:"che",ch:"cha",co:"cos",cr:"cre",cs:"ces",cu:"chu",cv:"chv",cy:"cym",da:"dan",de:"deu",dv:"div",dz:"dzo",ee:"ewe",el:"ell",en:"eng",eo:"epo",es:"spa",et:"est",eu:"eus",fa:"fas",ff:"ful",fi:"fin",fj:"fij",fo:"fao",fr:"fra",fy:"fry",ga:"gle",gd:"gla",gl:"glg",gn:"grn",gu:"guj",gv:"glv",ha:"hau",he:"heb",hi:"hin",ho:"hmo",hr:"hrv",ht:"hat",hu:"hun",hy:"hye",hz:"her",ia:"ina",id:"ind",ie:"ile",ig:"ibo",ii:"iii",ik:"ipk",io:"ido",is:"isl",it:"ita",iu:"iku",ja:"jpn",jv:"jav",ka:"kat",kg:"kon",ki:"kik",kj:"kua",kk:"kaz",kl:"kal",km:"khm",kn:"kan",ko:"kor",kr:"kau",ks:"kas",ku:"kur",kv:"kom",kw:"cor",ky:"kir",la:"lat",lb:"ltz",lg:"lug",li:"lim",ln:"lin",lo:"lao",lt:"lit",lu:"lub",lv:"lav",mg:"mlg",mh:"mah",mi:"mri",mk:"mkd",ml:"mal",mn:"mon",mr:"mar",ms:"msa",mt:"mlt",my:"mya",na:"nau",nb:"nob",nd:"nde",ne:"nep",ng:"ndo",nl:"nld",nn:"nno",no:"nor",nr:"nbl",nv:"nav",ny:"nya",oc:"oci",oj:"oji",om:"orm",or:"ori",os:"oss",pa:"pan",pi:"pli",pl:"pol",ps:"pus",pt:"por",qu:"que",rm:"roh",rn:"run",ro:"ron",ru:"rus",rw:"kin",sa:"san",sc:"srd",sd:"snd",se:"sme",sg:"sag",si:"sin",sk:"slk",sl:"slv",sm:"smo",sn:"sna",so:"som",sq:"sqi",sr:"srp",ss:"ssw",st:"sot",su:"sun",sv:"swe",sw:"swa",ta:"tam",te:"tel",tg:"tgk",th:"tha",ti:"tir",tk:"tuk",tl:"tgl",tn:"tsn",to:"ton",tr:"tur",ts:"tso",tt:"tat",tw:"twi",ty:"tah",ug:"uig",uk:"ukr",ur:"urd",uz:"uzb",ve:"ven",vi:"vie",vo:"vol",wa:"wln",wo:"wol",xh:"xho",yi:"yid",yo:"yor",za:"zha",zh:"zho",zu:"zul"},yt={alb:"sqi",arm:"hye",baq:"eus",bur:"mya",chi:"zho",cze:"ces",dut:"nld",fre:"fra",geo:"kat",ger:"deu",gre:"ell",ice:"isl",mac:"mkd",mao:"mri",may:"msa",per:"fas",slo:"slk",rum:"ron",tib:"bod",wel:"cym"};function _t(e){if(t(e)||""===e)return"";var n=function(e){var t;switch(e.length){case 2:t=gt[e];break;case 3:t=yt[e]}return t}((""+e).toLowerCase().split("-")[0]);return mt(n)?n:e}var bt=_t,St={dashParsers:{wasm:null,native:null,fastJs:null},codecSupportProber:null,createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},Et=St;function Tt(e,t){if(e.length!==t.length)return!1;if(e===t)return!0;for(var n=e.length-1;n>=0;n--)if(e[n]!==t[n])return!1;return!0}function kt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return wt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function wt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var At=Ze(),It=function(){function e(e,t){var n,r,i,a,o;if(this.id=e.id,this.uniqueId=At(),this.bitrate=e.bitrate,this.codecs=[],void 0!==e.isSpatialAudio&&(this.isSpatialAudio=e.isSpatialAudio),void 0!==e.height&&(this.height=e.height),void 0!==e.width&&(this.width=e.width),void 0!==e.mimeType&&(this.mimeType=e.mimeType),void 0!==e.contentProtections&&(this.contentProtections=e.contentProtections),void 0!==e.frameRate&&(this.frameRate=e.frameRate),void 0!==e.hdrInfo&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index,"audio"===t||"video"===t)if(null!==Et.codecSupportProber){if(void 0!==e.supplementalCodecs){var s=Et.codecSupportProber.isSupported(null!==(n=this.mimeType)&&void 0!==n?n:"",null!==(r=e.supplementalCodecs)&&void 0!==r?r:"");!1!==s&&(this.codecs=[e.supplementalCodecs],!0===s&&(this.isSupported=!0))}!0!==this.isSupported&&(this.codecs.length>0?this.codecs.push(null!==(i=e.codecs)&&void 0!==i?i:""):(this.codecs=void 0===e.codecs?[]:[e.codecs],this.isSupported=Et.codecSupportProber.isSupported(null!==(a=this.mimeType)&&void 0!==a?a:"",null!==(o=e.codecs)&&void 0!==o?o:"")))}else void 0!==e.supplementalCodecs&&this.codecs.push(e.supplementalCodecs),void 0!==e.codecs&&this.codecs.push(e.codecs);else void 0!==e.codecs&&this.codecs.push(e.codecs),this.isSupported=!0}var t=e.prototype;return t.refreshCodecSupport=function(e){var t,n=null!==(t=this.mimeType)&&void 0!==t?t:"",r=this.codecs;0===r.length&&(r=[""]);for(var i=0;i<r.length;i++)for(var a,o=kt(e);!(a=o()).done;){var s=a.value,u=r[i];if(s.codec===u&&s.mimeType===n){if(s.result)return this.isSupported=!0,void(this.codecs=[u]);if(i===r.length)return this.isSupported=!1,void(this.codecs=[u])}}},t.getMimeTypeString=function(){var e,t,n;return(null!==(e=this.mimeType)&&void 0!==e?e:"")+';codecs="'+(null!==(n=null===(t=this.codecs)||void 0===t?void 0:t[0])&&void 0!==n?n:"")+'"'},t.getEncryptionData=function(e){for(var t,n,r=this.getAllEncryptionData(),i=[],a=0;a<r.length;a++)for(var o=!1,s=r[a],u=0;u<s.values.length;u++)if(s.values[u].systemId.toLowerCase()===e.toLowerCase())if(o)i[i.length-1].values.push(s.values[u]);else{var l=null===(n=null===(t=this.contentProtections)||void 0===t?void 0:t.keyIds)||void 0===n?void 0:n.map((function(e){return e.keyId}));i.push({type:s.type,keyIds:l,values:[s.values[u]]}),o=!0}return i},t.getAllEncryptionData=function(){var e,t;if(void 0===this.contentProtections||0===this.contentProtections.initData.length)return[];var n=null===(t=null===(e=this.contentProtections)||void 0===e?void 0:e.keyIds)||void 0===t?void 0:t.map((function(e){return e.keyId}));return this.contentProtections.initData.map((function(e){return{type:e.type,keyIds:n,values:e.values}}))},t.addProtectionData=function(e,t,n){var r=!1;if(void 0===this.contentProtections)return this.contentProtections={keyIds:void 0!==t?[{keyId:t}]:[],initData:[{type:e,values:n}]},!0;if(void 0!==t){var i=this.contentProtections.keyIds;if(void 0===i)this.contentProtections.keyIds=[{keyId:t}];else{for(var a,o=!1,s=kt(i);!(a=s()).done;){Tt(a.value.keyId,t)&&(o=!0)}o||(B.warn("Manifest: found unanounced key id."),i.push({keyId:t}))}}for(var u=this.contentProtections.initData,l=0;l<u.length;l++)if(u[l].type===e){for(var d=u[l].values,c=0;c<n.length;c++){var f=n[c],v=void 0;for(v=0;v<d.length;v++)if(f.systemId===d[v].systemId){if(Tt(f.data,d[v].data))break;B.warn("Manifest: different init data for the same system ID")}v===d.length&&(d.push(f),r=!0)}return r}return this.contentProtections.initData.push({type:e,values:n}),!0},t.getMetadataSnapshot=function(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,codecs:this.codecs,mimeType:this.mimeType,width:this.width,height:this.height,frameRate:this.frameRate,isSupported:this.isSupported,hdrInfo:this.hdrInfo,contentProtections:this.contentProtections,decipherable:this.decipherable}},e}(),Rt=It;function xt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ct(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ct(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ct(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Mt=function(){function e(n,r){void 0===r&&(r={});var i=n.trickModeTracks,a=r,o=a.representationFilter,s=a.isManuallyAdded;this.id=n.id,this.type=n.type,void 0!==n.isTrickModeTrack&&(this.isTrickModeTrack=n.isTrickModeTrack),void 0!==n.language&&(this.language=n.language,this.normalizedLanguage=bt(n.language)),void 0!==n.closedCaption&&(this.isClosedCaption=n.closedCaption),void 0!==n.audioDescription&&(this.isAudioDescription=n.audioDescription),void 0!==n.isDub&&(this.isDub=n.isDub),void 0!==n.forcedSubtitles&&(this.isForcedSubtitles=n.forcedSubtitles),void 0!==n.isSignInterpreted&&(this.isSignInterpreted=n.isSignInterpreted),void 0!==n.label&&(this.label=n.label),void 0!==i&&i.length>0&&(this.trickModeTracks=i.map((function(t){return new e(t)})));for(var u,l=n.representations,d=[],c=0;c<l.length;c++){var f=new Rt(l[c],this.type),v=!0;if(!t(o)){var p={id:f.id,bitrate:f.bitrate,codecs:f.codecs,height:f.height,width:f.width,frameRate:f.frameRate,hdrInfo:f.hdrInfo};if(void 0!==f.contentProtections&&(p.contentProtections={},void 0!==f.contentProtections.keyIds)){var h=f.contentProtections.keyIds.map((function(e){return e.keyId}));p.contentProtections.keyIds=h}v=o(p,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}v?(d.push(f),void 0===u&&(!0===f.isSupported?u=!0:!1===f.isSupported&&(u=!1))):B.debug("Filtering Representation due to representationFilter",this.type,"Adaptation: "+this.id,"Representation: "+f.id,"("+f.bitrate+")")}d.sort((function(e,t){return e.bitrate-t.bitrate})),this.representations=d,this.isSupported=u,this.manuallyAdded=!0===s}var n=e.prototype;return n.refreshCodecSupport=function(e){for(var t,n=xt(this.representations);!(t=n()).done;){var r=t.value;void 0===r.isSupported&&(r.refreshCodecSupport(e),!0!==this.isSupported&&!0===r.isSupported?this.isSupported=!0:void 0===this.isSupported&&!1===r.isSupported&&(this.isSupported=!1))}},n.getRepresentation=function(e){return Se(this.representations,(function(t){var n=t.id;return e===n}))},n.getMetadataSnapshot=function(){for(var e,t=[],n=xt(this.representations);!(e=n()).done;){var r=e.value;t.push(r.getMetadataSnapshot())}return{id:this.id,type:this.type,isSupported:this.isSupported,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:t,label:this.label,isDub:this.isDub}},e}();function Pt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Dt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Dt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Dt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Nt,Ot=function(){function e(e,n,r){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((function(i,a){var o=e.adaptations[a];if(t(o))return i;var s=o.map((function(e){var t=new Mt(e,{representationFilter:r});return t.representations.length>0&&!1===t.isSupported&&n.push(t),t})).filter((function(e){return e.representations.length>0}));if(s.every((function(e){return!1===e.isSupported}))&&o.length>0&&("video"===a||"audio"===a))throw new qe("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+a+" adaptations",{tracks:void 0});return s.length>0&&(i[a]=s),i}),{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new qe("MANIFEST_PARSE_ERROR","No supported audio and video tracks.");this.duration=e.duration,this.start=e.start,t(this.duration)||t(this.start)||(this.end=this.start+this.duration),this.streamEvents=void 0===e.streamEvents?[]:e.streamEvents}var n=e.prototype;return n.refreshCodecSupport=function(e,t){var n=this;Object.keys(this.adaptations).forEach((function(r){var i=n.adaptations[r];if(void 0!==i){for(var a,o=!1,s=Pt(i);!(a=s()).done;){var u=a.value,l=u.isSupported;u.refreshCodecSupport(e),!1!==l&&!1===u.isSupported&&t.push(u),!1===o?o=u.isSupported:void 0===o&&!0===u.isSupported&&(o=!0)}if(("video"===r||"audio"===r)&&!1===o)throw new qe("MANIFEST_INCOMPATIBLE_CODECS_ERROR","No supported "+r+" adaptations",{tracks:void 0})}}),{})},n.getAdaptations=function(){return lt(this)},n.getAdaptationsForType=function(e){var t=this.adaptations[e];return null!=t?t:[]},n.getAdaptation=function(e){return Se(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n.getSupportedAdaptations=function(e){return ot(this,e)},n.containsTime=function(e,t){return ut(this,e,t)},n.getMetadataSnapshot=function(){for(var e,t={},n=Pt(this.getAdaptations());!(e=n()).done;){var r=e.value,i=t[r.type];void 0===i&&(i=[],t[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:t}},e}();function Lt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ut(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ut(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ut(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ft(e,t,n){var r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};e.start=t.start,e.end=t.end,e.duration=t.duration,e.streamEvents=t.streamEvents;for(var i=e.getAdaptations(),a=t.getAdaptations(),o=function(e){var t=i[e],o=te(a,(function(e){return e.id===t.id}));if(-1===o){B.warn('Manifest: Adaptation "'+i[e].id+'" not found when merging.');var u=i.splice(e,1)[0];e--,r.removedAdaptations.push({id:u.id,trackType:u.type})}else{var l=a.splice(o,1)[0],d=[],c=[],f=[];r.updatedAdaptations.push({adaptation:t.id,trackType:t.type,updatedRepresentations:d,addedRepresentations:c,removedRepresentations:f});for(var v,p=t.representations,h=l.representations.slice(),m=function(e){var t=p[e],r=te(h,(function(e){return e.id===t.id}));if(-1===r){B.warn('Manifest: Representation "'+p[e].id+'" not found when merging.');var i=p.splice(e,1)[0];e--,f.push(i.id)}else{var a=h.splice(r,1)[0];d.push(t.getMetadataSnapshot()),t.cdnMetadata=a.cdnMetadata,n===Nt.Full?t.index._replace(a.index):t.index._update(a.index)}g=e},g=0;g<p.length;g++)m(g);if(h.length>0)B.warn("Manifest: "+h.length+" new Representations found when merging."),(v=t.representations).push.apply(v,h),c.push.apply(c,h.map((function(e){return e.getMetadataSnapshot()})))}s=e},s=0;s<i.length;s++)o(s);if(a.length>0){B.warn("Manifest: "+a.length+" new Adaptations found when merging.");for(var u,l=Lt(a);!(u=l()).done;){var d=u.value,c=e.adaptations[d.type];void 0===c?e.adaptations[d.type]=[d]:c.push(d),r.addedAdaptations.push(d.getMetadataSnapshot())}}return r}function Bt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return zt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zt(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function zt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}!function(e){e[e.Full=0]="Full",e[e.Partial=1]="Partial"}(Nt||(Nt={}));var Vt=Ze(),Kt=function(e){function t(t,n,r){var i,a;i=e.call(this)||this;var o=n.representationFilter,s=n.manifestUpdateUrl;i.manifestFormat=0,i.id=Vt(),i.expired=null!==(a=t.expired)&&void 0!==a?a:null,i.transport=t.transportType,i.clockOffset=t.clockOffset;var u=[];if(i.periods=t.periods.map((function(e){return new Ot(e,u,o)})).sort((function(e,t){return e.start-t.start})),u.length>0){var l=new qe("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{tracks:u.map(ht)});r.push(l)}return i.adaptations=void 0===i.periods[0]?{}:i.periods[0].adaptations,i.timeBounds=t.timeBounds,i.isDynamic=t.isDynamic,i.isLive=t.isLive,i.isLastPeriodKnown=t.isLastPeriodKnown,i.uris=void 0===t.uris?[]:t.uris,i.updateUrl=s,i.lifetime=t.lifetime,i.clockOffset=t.clockOffset,i.suggestedPresentationDelay=t.suggestedPresentationDelay,i.availabilityStartTime=t.availabilityStartTime,i.publishTime=t.publishTime,i}f(t,e);var n=t.prototype;return n.refreshCodecSupport=function(e){for(var t,n=[],r=Bt(this.periods);!(t=r()).done;){t.value.refreshCodecSupport(e,n)}return n.length>0?new qe("MANIFEST_INCOMPATIBLE_CODECS_ERROR","An Adaptation contains only incompatible codecs.",{tracks:n.map(ht)}):null},n.getPeriod=function(e){return Se(this.periods,(function(t){return e===t.id}))},n.getPeriodForTime=function(e){return function(e,t){for(var n=null,r=e.periods.length-1;r>=0;r--){var i=e.periods[r];if(ut(i,t,n))return i;n=i}}(this,e)},n.getNextPeriod=function(e){return Se(this.periods,(function(t){return t.start>e}))},n.getPeriodAfter=function(e){return st(this,e)},n.getUrls=function(){return this.uris},n.replace=function(e){this._performUpdate(e,Nt.Full)},n.update=function(e){this._performUpdate(e,Nt.Partial)},n.getMinimumSafePosition=function(){return rt(this)},n.getLivePosition=function(){return it(this)},n.getMaximumSafePosition=function(){return at(this)},n.updateRepresentationsDeciperability=function(e){var t=function(e,t){for(var n,r=[],i=Bt(e.periods);!(n=i()).done;)for(var a,o=n.value,s=Bt(o.getAdaptations());!(a=s()).done;)for(var u,l=a.value,d=Bt(l.representations);!(u=d()).done;){var c=u.value,f={manifest:e,period:o,adaptation:l,representation:c},v=t(f);v!==c.decipherable&&(r.push(f),c.decipherable=v,B.debug('Decipherability changed for "'+c.id+'"',"("+c.bitrate+")",String(c.decipherable)))}return r}(this,e);t.length>0&&this.trigger("decipherabilityUpdate",t)},n.getAdaptations=function(){tt("manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead");var e=this.periods[0];if(void 0===e)return[];var t=e.adaptations,n=[];for(var r in t)if(t.hasOwnProperty(r)){var i=t[r];n.push.apply(n,i)}return n},n.getAdaptationsForType=function(e){tt("manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead");var t=this.periods[0];if(void 0===t)return[];var n=t.adaptations[e];return void 0===n?[]:n},n.getAdaptation=function(e){return tt("manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead"),Se(this.getAdaptations(),(function(t){var n=t.id;return e===n}))},n.getMetadataSnapshot=function(){for(var e,t=[],n=Bt(this.periods);!(e=n()).done;){var r=e.value;t.push(r.getMetadataSnapshot())}return{manifestFormat:1,id:this.id,periods:t,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}},n._performUpdate=function(e,t){var n;if(this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime,t===Nt.Full)this.timeBounds=e.timeBounds,this.uris=e.uris,n=function(e,t){for(var n={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0,i=0;i<t.length;i++){for(var a=t[i],o=r,s=e[o];void 0!==s&&s.id!==a.id;)s=e[++o];if(void 0!==s){var u,l,d=Ft(s,a,Nt.Full);n.updatedPeriods.push({period:{id:s.id,start:s.start,end:s.end,duration:s.duration,streamEvents:s.streamEvents},result:d});var c=t.slice(r,i),f=o-r,v=e.splice.apply(e,[r,f].concat(c));(u=n.removedPeriods).push.apply(u,v.map((function(e){return{id:e.id,start:e.start,end:e.end}}))),(l=n.addedPeriods).push.apply(l,c.map((function(e){return e.getMetadataSnapshot()}))),r=i+1}}if(r>e.length)return B.error("Manifest: error when updating Periods"),n;if(r<e.length){var p,h=e.splice(r,e.length-r);(p=n.removedPeriods).push.apply(p,h.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}var m,g=t.slice(r,t.length);return g.length>0&&(e.push.apply(e,g),(m=n.addedPeriods).push.apply(m,g.map((function(e){return e.getMetadataSnapshot()})))),n}(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],n=function(e,t){var n,r={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(0===e.length)return e.splice.apply(e,[0,0].concat(t)),(n=r.addedPeriods).push.apply(n,t.map((function(e){return e.getMetadataSnapshot()}))),r;if(0===t.length)return r;var i=e[e.length-1];if(i.start<t[0].start){var a;if(i.end!==t[0].start)throw new qe("MANIFEST_UPDATE_ERROR","Cannot perform partial update: not enough data");return e.push.apply(e,t),(a=r.addedPeriods).push.apply(a,t.map((function(e){return e.getMetadataSnapshot()}))),r}var o=te(e,(function(e){return e.id===t[0].id}));if(o<0)throw new qe("MANIFEST_UPDATE_ERROR","Cannot perform partial update: incoherent data");var s=Ft(e[o],t[0],Nt.Partial);r.updatedPeriods.push({period:P(e[o].getMetadataSnapshot(),{adaptations:void 0}),result:s});for(var u=o+1,l=1;l<t.length;l++){for(var d=t[l],c=-1,f=u;f<e.length;f++)if(d.id===e[f].id){c=f;break}if(c<0){for(var v,p=-1,h=u;h<e.length;h++)if(d.start<e[h].start){p=h;break}var m=p-u,g=e.splice(u,m,d);r.addedPeriods.push(d.getMetadataSnapshot()),(v=r.removedPeriods).push.apply(v,g.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}else{if(c>u){var y;B.warn("Manifest: old Periods not found in new when updating, removing");var _=e.splice(u,c-u);(y=r.removedPeriods).push.apply(y,_.map((function(e){return{id:e.id,start:e.start,end:e.end}}))),c=u}var b=Ft(e[c],d,Nt.Full);r.updatedPeriods.push({period:P(e[c].getMetadataSnapshot(),{adaptations:void 0}),result:b})}u++}if(u<e.length){var S;B.warn("Manifest: Ending Periods not found in new when updating, removing");var E=e.splice(u,e.length-u);(S=r.removedPeriods).push.apply(S,E.map((function(e){return{id:e.id,start:e.start,end:e.end}})))}return r}(this.periods,e.periods);for(var r=this.getMinimumSafePosition();this.periods.length>0;){var i=this.periods[0];if(void 0===i.end||i.end>r)break;this.periods.shift()}}this.adaptations=void 0===this.periods[0]?{}:this.periods[0].adaptations,this.trigger("manifestUpdate",n)},t}(i);var Wt=Kt;function Gt(e){return e instanceof ze?new Ye("PIPELINE_LOAD_ERROR",e):Xe(e,{defaultCode:"PIPELINE_LOAD_ERROR",defaultReason:"Unknown error when fetching the Manifest"})}var Ht=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(se(a),t.prototype),a.name="CustomLoaderError",a.message=n,a.canRetry=r,a.xhr=i,a}return f(t,e),t}(de(Error));function jt(e,t){var n;return new Promise((function(r,i){if(null!==e.cancellationError)return i(e.cancellationError);var a=!1;function o(e){void 0!==n&&n(),i(e)}n=t((function(t){e.deregister(o),a=!0,r(t)}),(function(t){e.deregister(o),a=!0,i(t)})),a||e.register(o)}))}function qt(e,t){return jt(t,(function(t){var n=setTimeout((function(){return t()}),e);return function(){return clearTimeout(n)}}))}var Yt=.3;function Qt(e){return e*((2*Math.random()-1)*Yt+1)}function $t(e,t,n,r,i){return Xt.apply(this,arguments)}function Xt(){return Xt=d(g().mark((function e(t,n,r,i,a){var o,s,u,l,c,f,v,p,h,m,y,_,b;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(b=function(e){var t;if(0===c.size)return e[0];var n=ye();return null===(t=e.filter((function(e){var t;return!0!==(null===(t=c.get(e))||void 0===t?void 0:t.isBlacklisted)})).reduce((function(e,t){var r,i=null===(r=c.get(t))||void 0===r?void 0:r.blockedUntil;return void 0!==i&&i<=n&&(i=void 0),void 0===e?[t,i]:void 0===e[1]?e:void 0===i?[t,void 0]:i<e[1]?[t,i]:e}),void 0))||void 0===t?void 0:t[0]},_=function(e,t){var r=c.get(e);if(void 0===r||void 0===r.blockedUntil)return p(e);var i=ye(),o=r.blockedUntil-i;if(o<=0)return p(e);var s=new pe,u=s.linkToSignal(a);return new Promise((function(r,i){function l(e){u(),r(e)}function d(e){u(),i(e)}null==n||n.addEventListener("priorityChange",(function(){var n=v();if(a.isCancelled())throw a.cancellationError;if(void 0===n)return d(t);n!==e&&(s.cancel(),_(n,t).then(l,d))}),s.signal),qt(o,s.signal).then((function(){return p(e).then(l,d)}),U)}))},y=function(){return(y=d(g().mark((function e(t){var n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=v(),!a.isCancelled()){e.next=3;break}throw a.cancellationError;case 3:if(void 0!==n){e.next=5;break}throw t;case 5:if(l(t),!a.isCancelled()){e.next=8;break}throw a.cancellationError;case 8:return e.abrupt("return",_(n,t));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)},m=function(e){return y.apply(this,arguments)},h=function(){return(h=d(g().mark((function e(t){var i,l,d,f,v;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r(t,a);case 3:return i=e.sent,e.abrupt("return",i);case 7:if(e.prev=7,e.t0=e.catch(0),!pe.isCancellationError(e.t0)){e.next=11;break}throw e.t0;case 11:if(null!==t&&null!==n&&n.downgradeCdn(t),void 0===(l=c.get(t))?(l={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},c.set(t,l)):l.errorCounter++,(p=e.t0)instanceof ze?p.type===Ke.ERROR_HTTP_CODE?p.status>=500||404===p.status||415===p.status||412===p.status:p.type===Ke.TIMEOUT||p.type===Ke.ERROR_EVENT:p instanceof Ht?"boolean"==typeof p.canRetry?p.canRetry:void 0!==p.xhr&&(p.xhr.status>=500||404===p.xhr.status||415===p.xhr.status||412===p.xhr.status):$e(p)&&"INTEGRITY_ERROR"===p.code){e.next=18;break}return l.blockedUntil=void 0,l.isBlacklisted=!0,e.abrupt("return",m(e.t0));case 18:return l.errorCounter>u?(l.blockedUntil=void 0,l.isBlacklisted=!0):(d=l.errorCounter,f=Math.min(o*Math.pow(2,d-1),s),v=Qt(f),l.blockedUntil=ye()+v),e.abrupt("return",m(e.t0));case 20:case"end":return e.stop()}var p}),e,null,[[0,7]])})))).apply(this,arguments)},p=function(e){return h.apply(this,arguments)},v=function(){if(null===t){var e=c.get(null);if(void 0!==e&&e.isBlacklisted)return;return null}if(null===n)return b(t);var r=n.getCdnPreferenceForResource(t);return b(r)},null===a.cancellationError){e.next=9;break}return e.abrupt("return",Promise.reject(a.cancellationError));case 9:if(o=i.baseDelay,s=i.maxDelay,u=i.maxRetry,l=i.onRetry,null!==t&&0===t.length&&B.warn("Fetchers: no CDN given to `scheduleRequestWithCdns`."),c=new Map,void 0!==(f=v())){e.next=15;break}throw new Error("No CDN to request");case 15:return e.abrupt("return",p(f));case 16:case"end":return e.stop()}}),e)}))),Xt.apply(this,arguments)}function Zt(e,t,n){return $t(null,null,e,t,n)}function Jt(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return en(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function en(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var tn=function(e){function t(t,n,r){var i;return(i=e.call(this)||this).scheduleManualRefresh=U,i._manifestUrls=t,i._pipelines=n.manifest,i._settings=r,i._canceller=new pe,i._isStarted=!1,i._isRefreshPending=!1,i._consecutiveUnsafeMode=0,i._prioritizedContentUrl=null,i}f(t,e);var n=t.prototype;return n.dispose=function(){this._canceller.cancel(),this.removeEventListener()},n.start=function(){var e=this;if(!this._isStarted){this._isStarted=!0;var t=this._settings.initialManifest;(t instanceof Wt?Promise.resolve({manifest:t}):void 0!==t?this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):this._fetchManifest(void 0).then((function(e){return e.parse({previousManifest:null,unsafeMode:!1})}))).then((function(t){e.trigger("manifestReady",t.manifest),e._canceller.isUsed()||e._recursivelyRefreshManifest(t.manifest,t)})).catch((function(t){return e._onFatalError(t)}))}},n.updateContentUrls=function(e,t){var n;this._prioritizedContentUrl=null!==(n=null==e?void 0:e[0])&&void 0!==n?n:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})},n._fetchManifest=function(){var e=d(g().mark((function e(t){var n,r,i,a,o,s,u,l,d=this;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=function(e){var t=a.loadManifest,n=void 0===i.requestTimeout?L.getCurrent().DEFAULT_REQUEST_TIMEOUT:i.requestTimeout,o=void 0===i.connectionTimeout?L.getCurrent().DEFAULT_CONNECTION_TIMEOUT:i.connectionTimeout;n<0&&(n=void 0),o<0&&(o=void 0);return Zt((function(){return t(e,{timeout:n,connectionTimeout:o},r)}),s,r)},r=this._canceller.signal,i=this._settings,a=this._pipelines,o=null!=t?t:null===(n=this._manifestUrls)||void 0===n?void 0:n[0],s=this._getBackoffSetting((function(e){d.trigger("warning",Gt(e))})),e.prev=6,e.next=9,l(o);case 9:return u=e.sent,e.abrupt("return",{parse:function(e){return d._parseLoadedManifest(u,e,o)}});case 13:throw e.prev=13,e.t0=e.catch(6),Gt(e.t0);case 16:case"end":return e.stop()}}),e,this,[[6,13]])})));return function(t){return e.apply(this,arguments)}}(),n.parse=function(e,t,n){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,n)},n._parseLoadedManifest=function(){var e=d(g().mark((function e(t,n,r){var i,a,o,s,u,l,c,f,v,p,h,m,y,_,b,S,E,T=this;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(E=function(e,t){S(t);var n=ye()-a;return B.info("MF: Manifest parsed in "+n+"ms"),{manifest:e,sendingTime:u,receivedTime:l,parsingTime:n}},S=function(e){for(var t,n=Jt(e);!(t=n()).done;){var r=t.value;if(o.isCancelled())return;var i=Xe(r,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown error when parsing the Manifest"});s("warning",i)}},b=function(){return(b=d(g().mark((function e(t){var n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Zt(t,c,o);case 3:return n=e.sent,e.abrupt("return",n);case 7:throw e.prev=7,e.t0=e.catch(0),Gt(e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)},_=function(e){return b.apply(this,arguments)},a=ye(),o=this._canceller.signal,s=this.trigger.bind(this),u=t.sendingTime,l=t.receivedTime,c=this._getBackoffSetting((function(e){T.trigger("warning",Gt(e))})),f=null!=r?r:null===(i=this._manifestUrls)||void 0===i?void 0:i[0],v={externalClockOffset:n.externalClockOffset,unsafeMode:n.unsafeMode,previousManifest:n.previousManifest,originalUrl:f},e.prev=11,p=this._pipelines.parseManifest(t,v,S,o,_),p instanceof Promise){e.next=17;break}return e.abrupt("return",E(p.manifest,p.warnings));case 17:return e.next=19,p;case 19:return h=e.sent,m=h.manifest,y=h.warnings,e.abrupt("return",E(m,y));case 23:e.next=29;break;case 25:throw e.prev=25,e.t0=e.catch(11),Xe(e.t0,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown error when parsing the Manifest"});case 29:case"end":return e.stop()}}),e,this,[[11,25]])})));return function(t,n,r){return e.apply(this,arguments)}}(),n._getBackoffSetting=function(e){var t=L.getCurrent(),n=t.DEFAULT_MAX_MANIFEST_REQUEST_RETRY,r=t.INITIAL_BACKOFF_DELAY_BASE,i=t.MAX_BACKOFF_DELAY_BASE,a=this._settings,o=a.lowLatencyMode,s=a.maxRetry;return{onRetry:e,baseDelay:o?r.LOW_LATENCY:r.REGULAR,maxDelay:o?i.LOW_LATENCY:i.REGULAR,maxRetry:null!=s?s:n}},n._recursivelyRefreshManifest=function(e,t){var n=this,r=t.sendingTime,i=t.parsingTime,a=t.updatingTime,o=L.getCurrent(),s=o.MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE,u=o.MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE,l=void 0!==i?i+(null!=a?a:0):void 0,d=!1;this._consecutiveUnsafeMode>0?d=this._consecutiveUnsafeMode<s:void 0!==l&&(d=l>=u);var c=void 0===r?0:ye()-r,f=Math.max(this._settings.minimumManifestUpdateInterval-c,0),v=new pe;if(v.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=function(t){var i=t.enablePartialRefresh,a=t.delay,o=t.canUseUnsafeMode&&d,s=void 0===r?0:ye()-r,u=Math.max(n._settings.minimumManifestUpdateInterval-s,0),l=setTimeout((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:i,unsafeMode:o})}),Math.max((null!=a?a:0)-s,u));v.signal.register((function(){clearTimeout(l)}))},null!==e.expired){var p=setTimeout((function(){var t;null===(t=e.expired)||void 0===t||t.then((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})}),U)}),f);v.signal.register((function(){clearTimeout(p)}))}if(void 0!==e.lifetime&&e.lifetime>=0){var h,m=1e3*e.lifetime-c;void 0===l?h=m:e.lifetime<3&&l>=100?(h=Math.min(Math.max(3e3-c,Math.max(m,0)+l),6*m),B.info("MUS: Manifest update rythm is too frequent. Postponing next request.",m,h)):l>=1e3*e.lifetime/10?(h=Math.min(Math.max(m,0)+l,6*m),B.info("MUS: Manifest took too long to parse. Postponing next request",h,h)):h=m;var g=setTimeout((function(){v.cancel(),n._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})}),Math.max(h,f));v.signal.register((function(){clearTimeout(g)}))}},n._triggerNextManifestRefresh=function(e,t){var n,r,i=this,a=t.enablePartialRefresh,o=t.unsafeMode,s=e.updateUrl;null!==this._prioritizedContentUrl?(n=!0,r=this._prioritizedContentUrl,this._prioritizedContentUrl=null):r=(n=!a||void 0===s)?e.getUrls()[0]:s;var u=e.clockOffset;o?(this._consecutiveUnsafeMode+=1,B.info('Init: Refreshing the Manifest in "unsafeMode" for the '+String(this._consecutiveUnsafeMode)+" consecutive time.")):this._consecutiveUnsafeMode>0&&(B.info('Init: Not parsing the Manifest in "unsafeMode" anymore after '+String(this._consecutiveUnsafeMode)+" consecutive times."),this._consecutiveUnsafeMode=0),this._isRefreshPending||(this._isRefreshPending=!0,this._fetchManifest(r).then((function(t){return t.parse({externalClockOffset:u,previousManifest:e,unsafeMode:o})})).then((function(t){i._isRefreshPending=!1;var r=t.manifest,a=t.sendingTime,o=t.parsingTime,s=ye();if(n)e.replace(r);else try{e.update(r)}catch(t){var u=t instanceof Error?t.message:"unknown error";B.warn("MUS: Attempt to update Manifest failed: "+u,"Re-downloading the Manifest fully");var l=L.getCurrent().FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY,d=void 0===a?0:ye()-a,c=Math.max(i._settings.minimumManifestUpdateInterval-d,0),f=U,v=setTimeout((function(){f(),i._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})}),Math.max(l-d,c));return void(f=i._canceller.signal.register((function(){clearTimeout(v)})))}var p=ye()-s;i._recursivelyRefreshManifest(e,{sendingTime:a,parsingTime:o,updatingTime:p})})).catch((function(e){i._isRefreshPending=!1,i._onFatalError(e)})))},n._onFatalError=function(e){this._canceller.isUsed()||(this.trigger("error",e),this.dispose())},t}(i);var nn=tn;function rn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return an(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return an(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function an(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var on=function(e){function t(t){var n;return(n=e.call(this)||this)._downgradedCdnList={metadata:[],timeouts:[]},t.register((function(){for(var e,t=rn(n._downgradedCdnList.timeouts);!(e=t()).done;){var r=e.value;clearTimeout(r)}n._downgradedCdnList={metadata:[],timeouts:[]}})),n}f(t,e);var n=t.prototype;return n.getCdnPreferenceForResource=function(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)},n.downgradeCdn=function(e){var t=this,n=sn(this._downgradedCdnList.metadata,e);n>=0&&this._removeIndexFromDowngradeList(n);var r=L.getCurrent().DEFAULT_CDN_DOWNGRADE_TIME;this._downgradedCdnList.metadata.push(e);var i=setTimeout((function(){var n=sn(t._downgradedCdnList.metadata,e);n>=0&&t._removeIndexFromDowngradeList(n),t.trigger("priorityChange",null)}),r);this._downgradedCdnList.timeouts.push(i),this.trigger("priorityChange",null)},n._innerGetCdnPreferenceForResource=function(e){var t=this,n=e.reduce((function(e,n){return t._downgradedCdnList.metadata.some((function(e){return e.id===n.id&&e.baseUrl===n.baseUrl}))?e[1].push(n):e[0].push(n),e}),[[],[]]),r=n[0],i=n[1];return r.concat(i)},n._removeIndexFromDowngradeList=function(e){this._downgradedCdnList.metadata.splice(e,1);var t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])},t}(i);function sn(e,t){return 0===e.length?-1:void 0!==t.id?te(e,(function(e){return e.id===t.id})):te(e,(function(e){return e.baseUrl===t.baseUrl}))}function un(e,t){return e.segment.id===t.segment.id&&e.representation.uniqueId===t.representation.uniqueId}function ln(e){if(t(e))return"";var n,r=e.period,i=e.adaptation,a=e.representation,o=e.segment;return n=o.isInit?"init":o.complete?o.time+"-"+o.duration:""+o.time,i.type+" P: "+r.id+" A: "+i.id+" R: "+a.id+" S: "+n}var dn=function(){function e(){this._cache=new WeakMap}var t=e.prototype;return t.add=function(e,t){var n=e.representation;e.segment.isInit&&this._cache.set(n,t)},t.get=function(e){var t=e.representation;if(e.segment.isInit){var n=this._cache.get(t);if(void 0!==n)return n}return null},e}(),cn=Ze();var fn=function(){function e(e){var t=e.prioritySteps;if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=t,this._prioritySteps.high>=this._prioritySteps.low)throw new Error("TP: the max high level priority should be given a lowerpriority number than the min low priority.")}var t=e.prototype;return t.create=function(e,t,n,r){var i,a=this;return jt(r,(function(o,s){return i={hasEnded:!1,priority:t,trigger:function(){if(!i.hasEnded){var e=function(){u(),a._endTask(i)},t=new pe,u=t.linkToSignal(r);i.interrupter=t,t.signal.register((function(){i.interrupter=null,r.isCancelled()||n.beforeInterrupted()})),a._minPendingPriority=null===a._minPendingPriority?i.priority:Math.min(a._minPendingPriority,i.priority),a._pendingTasks.push(i),i.taskFn(t.signal).then((function(t){n.beforeEnded(),e(),o(t)})).catch((function(n){!r.isCancelled()&&t.isUsed()&&n instanceof me||function(t){e(),s(t)}(n)}))}},taskFn:e,interrupter:null},a._canBeStartedNow(i)?(i.trigger(),a._isRunningHighPriorityTasks()&&a._interruptCancellableTasks()):a._waitingQueue.push(i),function(){return a._endTask(i)}}))},t._endTask=function(e){e.hasEnded=!0;var t=vn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{var n=vn(e.taskFn,this._pendingTasks);if(n<0)return;this._pendingTasks.splice(n,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}},t.updatePriority=function(e,t){var n=vn(e,this._waitingQueue);if(n>=0){var r=this._waitingQueue[n];if(r.priority===t)return;if(r.priority=t,!this._canBeStartedNow(r))return;return this._findAndRunWaitingQueueTask(n),void(this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks())}var i=vn(e,this._pendingTasks);if(i<0)B.warn("TP: request to update the priority of a non-existent task");else{var a=this._pendingTasks[i];if(a.priority!==t){var o=a.priority;a.priority=t,null===this._minPendingPriority||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(1===this._pendingTasks.length?this._minPendingPriority=t:this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority}))),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}}},t._loopThroughWaitingQueue=function(){var e=this._waitingQueue.reduce((function(e,t){return null===e||e>t.priority?t.priority:e}),null);if(!(null===e||null!==this._minPendingPriority&&this._minPendingPriority<e))for(var t=0;t<this._waitingQueue.length;t++){var n=null===this._minPendingPriority?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=n&&(this._findAndRunWaitingQueueTask(t),t--)}},t._interruptCancellableTasks=function(){for(var e=0;e<this._pendingTasks.length;e++){var t=this._pendingTasks[e];if(t.priority>=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}},t._findAndRunWaitingQueueTask=function(e){return e>=this._waitingQueue.length||e<0?(B.warn("TP : Tried to start a non existing task"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)},t._interruptPendingTask=function(e){var t,n=vn(e.taskFn,this._pendingTasks);n<0?B.warn("TP: Interrupting a non-existent pending task. Aborting..."):(this._pendingTasks.splice(n,1),this._waitingQueue.push(e),0===this._pendingTasks.length?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map((function(e){return e.priority})))),null===(t=e.interrupter)||void 0===t||t.cancel())},t._canBeStartedNow=function(e){return null===this._minPendingPriority||e.priority<=this._minPendingPriority},t._isRunningHighPriorityTasks=function(){return null!==this._minPendingPriority&&this._minPendingPriority<=this._prioritySteps.high},e}();function vn(e,t){return te(t,(function(t){return t.taskFn===e}))}var pn=function(){function e(e,t,n){var r=new on(n),i=L.getCurrent(),a=i.MIN_CANCELABLE_PRIORITY,o=i.MAX_HIGH_PRIORITY_LEVEL;this._transport=e,this._prioritizer=new fn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=r,this._backoffOptions=t}return e.prototype.createSegmentFetcher=function(e,n){var r,i,a,o,s,u,l,c,f,v,p,h,m,y,_=(r=this._backoffOptions,i=r.maxRetry,a=r.lowLatencyMode,o=r.requestTimeout,s=r.connectionTimeout,u=L.getCurrent(),l=u.DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,c=u.DEFAULT_REQUEST_TIMEOUT,f=u.DEFAULT_CONNECTION_TIMEOUT,v=u.INITIAL_BACKOFF_DELAY_BASE,p=u.MAX_BACKOFF_DELAY_BASE,{maxRetry:null!=i?i:l,baseDelay:a?v.LOW_LATENCY:v.REGULAR,maxDelay:a?p.LOW_LATENCY:p.REGULAR,requestTimeout:void 0===o?c:o,connectionTimeout:void 0===s?f:s}),b=function(e,n,r,i,a){var o;o=void 0===a.connectionTimeout||a.connectionTimeout<0?void 0:a.connectionTimeout;var s={timeout:a.requestTimeout<0?void 0:a.requestTimeout,connectionTimeout:o},u=Je(["audio","video"],e)?new dn:void 0,l=n.loadSegment,c=n.parseSegment;return function(){var e=d(g().mark((function e(n,o,d){var f,v,p,h,m,y,_,b,S,E,T,k,w,A,I,R,x,C,M,D,N,O,L,U;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(U=function(){var e;A||!t(T)&&void 0!==T.size&&void 0!==T.requestDuration&&k.length>0&&k.every((function(e){return e}))&&(A=!0,null===(e=i.onMetrics)||void 0===e||e.call(i,{size:T.size,requestDuration:T.requestDuration,content:n,segmentDuration:w}))},L=function(e){o.onRetry(Gt(e))},O=function(e,t){k.push(!1);var n=k.length-1;return function(r){var i={data:e,isChunked:t};try{var a=c(i,I,r);return k[n]||(w=void 0!==w&&"media"===a.segmentType&&null!==a.chunkInfos&&void 0!==a.chunkInfos.duration?w+a.chunkInfos.duration:void 0,k[n]=!0,U()),a}catch(e){throw Xe(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"Unknown parsing error"})}}},N=function(e){return l(e,I,s,d,R)},D=function(){var e;void 0===T&&(B.debug("SF: Segment request cancelled",S),T=null,null===(e=i.onRequestEnd)||void 0===e||e.call(i,{id:E}))},h=n.segment,m=n.adaptation,y=n.representation,_=n.manifest,b=n.period,S=ln(n),E=cn(),k=[],w=0,A=!1,I={segment:h,type:m.type,language:m.language,isLive:_.isLive,periodStart:b.start,periodEnd:b.end,mimeType:y.mimeType,codecs:y.codecs[0],manifestPublishTime:_.publishTime},R={onProgress:function(e){var t;void 0===T&&void 0!==e.totalSize&&e.size<e.totalSize&&(null===(t=i.onProgress)||void 0===t||t.call(i,{duration:e.duration,size:e.size,totalSize:e.totalSize,timestamp:ye(),id:E}))},onNewChunk:function(e){o.onChunk(O(e,!0))}},null===(x=void 0!==u?u.get(n):null)){e.next=18;break}return B.debug("SF: Found wanted segment in cache",S),o.onChunk(O(x,!1)),e.abrupt("return",Promise.resolve());case 18:return B.debug("SF: Beginning request",S),null===(f=i.onRequestBegin)||void 0===f||f.call(i,{requestTimestamp:ye(),id:E,content:n}),d.register(D),e.prev=21,e.next=24,$t(n.representation.cdnMetadata,r,N,P({onRetry:L},a),d);case 24:"segment-loaded"===(C=e.sent).resultType?(M=C.resultData.responseData,void 0!==u&&u.add(n,C.resultData.responseData),o.onChunk(O(M,!1))):"segment-created"===C.resultType&&o.onChunk(O(C.resultData,!1)),B.debug("SF: Segment request ended with success",S),o.onAllChunksReceived(),"segment-created"!==C.resultType?(T=C.resultData,U()):T=null,d.isCancelled()||null===(v=i.onRequestEnd)||void 0===v||v.call(i,{id:E}),d.deregister(D),e.next=43;break;case 33:if(e.prev=33,e.t0=e.catch(21),d.deregister(D),T=null,!(e.t0 instanceof me)){e.next=40;break}throw B.debug("SF: Segment request aborted",S),e.t0;case 40:throw B.debug("SF: Segment request failed",S),null===(p=i.onRequestEnd)||void 0===p||p.call(i,{id:E}),Gt(e.t0);case 43:case"end":return e.stop()}}),e,null,[[21,33]])})));return function(t,n,r){return e.apply(this,arguments)}}()}(e,this._transport[e],this._cdnPrioritizer,n,_);return h=this._prioritizer,m=b,y=new WeakMap,{createRequest:function(e,t,n,r){var i=function(t){return m(e,n,t)},a=h.create(i,t,n,r);return y.set(a,i),a},updatePriority:function(e,t){var n=y.get(e);void 0!==n?h.updatePriority(n,t):B.warn("Fetchers: Cannot update the priority of a request: task not found.")}}},e}(),hn=pn,mn=function(){function e(e){this._array=[],this._sortingFn=e}var t=e.prototype;return t.add=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];t.sort(this._sortingFn);for(var r=0,i=0;i<t.length;i++){for(var a=t[i],o=!1;!o&&r<this._array.length;)this._sortingFn(a,this._array[r])<0?(this._array.splice(r,0,a),o=!0):r++;o||this._array.push(a)}},t.length=function(){return this._array.length},t.get=function(e){if(e<0||e>=this._array.length)throw new Error("Invalid index.");return this._array[e]},t.toArray=function(){return this._array.slice()},t.findFirst=function(e){return Se(this._array,e)},t.has=function(e){return Je(this._array,e)},t.removeElement=function(e){var t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t},t.head=function(){return this._array[0]},t.last=function(){return this._array[this._array.length-1]},t.shift=function(){return this._array.shift()},t.pop=function(){return this._array.pop()},e}();function gn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return yn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function yn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var _n=function(e){function t(t,n,r){var i;(i=e.call(this)||this)._canceller=new pe,i._manifest=t,i._activeStreams=new Map,i._allBufferTypes=r,i._lastCurrentPeriodId=null;var a=new bn(t);i._maximumPositionCalculator=a;var o=i._canceller.signal;return n.listen((function(e){var n=e.position.getWanted();if(n<t.getMinimumSafePosition()){var r=new qe("MEDIA_TIME_BEFORE_MANIFEST","The current position is behind the earliest time announced in the Manifest.");i.trigger("warning",r)}else if(n>a.getMaximumAvailablePosition()){var o=new qe("MEDIA_TIME_AFTER_MANIFEST","The current position is after the latest time announced in the Manifest.");i.trigger("warning",o)}}),{includeLastObservation:!0,clearSignal:o}),t.addEventListener("manifestUpdate",(function(){i.trigger("endingPositionChange",i._getManifestEndTime()),o.isCancelled()||i._checkEndOfStream()}),o),i}f(t,e);var n=t.prototype;return n.getCurrentEndingTime=function(){return this._getManifestEndTime()},n.onAdaptationChange=function(e,t,n){if(this._manifest.isLastPeriodKnown){var r=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(null==r?void 0:r.id)&&("audio"===e||"video"===e)){"audio"===e?this._maximumPositionCalculator.updateLastAudioAdaptation(n):this._maximumPositionCalculator.updateLastVideoAdaptation(n);var i=this._maximumPositionCalculator.getEndingPosition(),a=void 0!==i?{isEnd:!0,endingPosition:i}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger("endingPositionChange",a)}}this._canceller.isUsed()||null===n&&this._addActivelyLoadedPeriod(t,e)},n.onRepresentationChange=function(e,t){this._addActivelyLoadedPeriod(t,e)},n.onPeriodCleared=function(e,t){this._removeActivelyLoadedPeriod(t,e)},n.onLastSegmentFinishedLoading=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())},n.onLastSegmentLoadingResume=function(e){var t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())},n.dispose=function(){this.removeEventListener(),this._canceller.cancel()},n._addActivelyLoadedPeriod=function(e,t){var n=this._lazilyCreateActiveStreamInfo(t);n.activePeriods.has(e)||(n.activePeriods.add(e),this._checkCurrentPeriod())},n._removeActivelyLoadedPeriod=function(e,t){var n=this._activeStreams.get(t);void 0!==n&&n.activePeriods.has(e)&&(n.activePeriods.removeElement(e),this._checkCurrentPeriod())},n._checkCurrentPeriod=function(){var e=this;if(0!==this._allBufferTypes.length){var t=this._activeStreams.get(this._allBufferTypes[0]);if(void 0!==t)for(var n,r,i=function(){for(var t=r.value,n=!0,i=1;i<e._allBufferTypes.length;i++){var a=e._activeStreams.get(e._allBufferTypes[i]);if(void 0===a)return{v:void 0};if(!a.activePeriods.toArray().some((function(e){return e.id===t.id}))){n=!1;break}}if(n)return e._lastCurrentPeriodId!==t.id&&(e._lastCurrentPeriodId=t.id,e.trigger("periodChange",t)),{v:void 0}},a=gn(t.activePeriods.toArray());!(r=a()).done;)if(n=i())return n.v}},n._getManifestEndTime=function(){var e=this._maximumPositionCalculator.getEndingPosition();return void 0!==e?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}},n._lazilyCreateActiveStreamInfo=function(e){var t=this._activeStreams.get(e);return void 0===t&&(t={activePeriods:new mn((function(e,t){return e.start-t.start})),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t},n._checkEndOfStream=function(){var e=this;this._manifest.isLastPeriodKnown&&(this._allBufferTypes.every((function(t){var n=e._activeStreams.get(t);return void 0!==n&&n.hasFinishedLoadingLastPeriod}))?this.trigger("endOfStream",null):this.trigger("resumeStream",null))},t}(i),bn=function(){function e(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}var t=e.prototype;return t.updateLastAudioAdaptation=function(e){this._lastAudioAdaptation=e},t.updateLastVideoAdaptation=function(e){this._lastVideoAdaptation=e},t.getMaximumAvailablePosition=function(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(void 0===this._lastVideoAdaptation||void 0===this._lastAudioAdaptation)return this._manifest.getMaximumSafePosition();if(null===this._lastAudioAdaptation){if(null===this._lastVideoAdaptation)return this._manifest.getMaximumSafePosition();var e=Sn(this._lastVideoAdaptation);return"number"!=typeof e?this._manifest.getMaximumSafePosition():e}if(null===this._lastVideoAdaptation){var t=Sn(this._lastAudioAdaptation);return"number"!=typeof t?this._manifest.getMaximumSafePosition():t}var n=Sn(this._lastAudioAdaptation),r=Sn(this._lastVideoAdaptation);return"number"!=typeof n||"number"!=typeof r?this._manifest.getMaximumSafePosition():Math.min(n,r)},t.getEndingPosition=function(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(void 0!==this._lastVideoAdaptation&&void 0!==this._lastAudioAdaptation){if(null===this._lastAudioAdaptation)return null===this._lastVideoAdaptation?void 0:null!==(e=En(this._lastVideoAdaptation))&&void 0!==e?e:void 0;if(null===this._lastVideoAdaptation)return null!==(t=En(this._lastAudioAdaptation))&&void 0!==t?t:void 0;var n=En(this._lastAudioAdaptation),r=En(this._lastVideoAdaptation);return"number"!=typeof n||"number"!=typeof r?void 0:Math.min(n,r)}},e}();function Sn(e){for(var n,r=e.representations,i=null,a=0;a<r.length;a++)if(r[a].index!==n){n=r[a].index;var o=r[a].index.getLastAvailablePosition();if(void 0===o)return;null!==o&&(i=t(i)?o:Math.min(i,o))}return i}function En(e){for(var n,r=e.representations,i=null,a=0;a<r.length;a++)if(r[a].index!==n){n=r[a].index;var o=r[a].index.getEnd();if(void 0===o)return;null!==o&&(i=t(i)?o:Math.min(i,o))}return i}function Tn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return kn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function kn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var wn=function(){function e(e){this._segmentSinksStore=e,this._currentFreezeTimestamp=null}return e.prototype.needToReload=function(e){var t=e.readyState,n=e.rebuffering,r=e.freezing;if((void 0!==e.bufferGap&&isFinite(e.bufferGap)?e.bufferGap:0)<6||null===n&&null===r||t>1)return this._currentFreezeTimestamp=null,!1;var i=ye();null===this._currentFreezeTimestamp&&(this._currentFreezeTimestamp=i);var a=null!==n&&i-n.timestamp>4e3,o=null!==r&&i-r.timestamp>4e3;if((a||o)&&ye()-this._currentFreezeTimestamp>4e3){for(var s=!0,u=!0,l=0,d=[this._segmentSinksStore.getStatus("audio"),this._segmentSinksStore.getStatus("video")];l<d.length;l++){var c=d[l];if("initialized"===c.type)for(var f,v=Tn(c.value.getLastKnownInventory());!(f=v()).done;){var p=f.value.infos.representation;if(!1===p.decipherable)return B.warn("Init: we have undecipherable segments left in the buffer, reloading"),this._currentFreezeTimestamp=null,!0;void 0!==p.contentProtections&&(u=!1,!0!==p.decipherable&&(s=!1))}}if(!u&&s)return B.warn("Init: we are frozen despite only having decipherable segments left in the buffer, reloading"),this._currentFreezeTimestamp=null,!0}return!1},e}();function An(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return In(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return In(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function In(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Rn=function(){function e(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}var t=e.prototype;return t.addBufferedSegment=function(e,t){var n=ye();this._history.push({date:n,buffered:t,context:e}),this._cleanHistory(n)},t.getHistoryFor=function(e){return this._history.filter((function(t){return un(t.context,e)}))},t._cleanHistory=function(e){for(var t,n=e-this._lifetime,r=0,i=An(this._history);!(t=i()).done;){if(!(t.value.date<n))break;r++}if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){var a=this._history.length-this._maxHistoryLength;this._history=this._history.splice(a)}},e}();function xn(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Cn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cn(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Cn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Mn=function(){function e(){var e=L.getCurrent(),t=e.BUFFERED_HISTORY_RETENTION_TIME,n=e.BUFFERED_HISTORY_MAXIMUM_ENTRIES;this._inventory=[],this._bufferedHistory=new Rn(t,n)}var n=e.prototype;return n.reset=function(){this._inventory.length=0},n.synchronizeBuffered=function(e){for(var n,r,i,a,o,s,u,l=this._inventory,d=0,c=l[0],f=L.getCurrent().MINIMUM_SEGMENT_SIZE,v=null==c?void 0:c.infos.adaptation.type,p=e.length,h=0;h<p;h++){if(void 0===c)return;var m=e[h].start,g=e[h].end;if(g-m<f)B.warn("SI: skipped range when synchronizing because it was too small",v,m,g);else{for(var y=d;void 0!==c&&(null!==(n=c.bufferedEnd)&&void 0!==n?n:c.end)-m<f;)c=l[++d];var _=null,b=d-y;if(b>0){var S=l[y+b-1];_={end:null!==(r=S.bufferedEnd)&&void 0!==r?r:S.end,precizeEnd:S.precizeEnd},B.debug("SI: "+b+" segments GCed.",v);for(var E,T=xn(l.splice(y,b));!(E=T()).done;){var k=E.value;void 0===k.bufferedStart&&void 0===k.bufferedEnd&&2!==k.status&&this._bufferedHistory.addBufferedSegment(k.infos,null)}d=y}if(void 0===c)return;if(g-(null!==(i=c.bufferedStart)&&void 0!==i?i:c.start)>=f){if(Nn(c,m,_,v),d===l.length-1)return void On(c,g,v);for(var w=null!==(a=(c=l[++d]).bufferedStart)&&void 0!==a?a:c.start,A=null!==(o=c.bufferedEnd)&&void 0!==o?o:c.end,I=h<p-1?e[h+1].start:void 0;void 0!==c&&g-w>=f&&(void 0===I||g-w>=A-I);){var R=l[d-1];void 0===R.bufferedEnd&&(R.bufferedEnd=c.precizeStart?c.start:R.end,B.debug("SI: calculating buffered end of contiguous segment",v,R.bufferedEnd,R.end)),c.bufferedStart=R.bufferedEnd,void 0!==(c=l[++d])&&(w=null!==(s=c.bufferedStart)&&void 0!==s?s:c.start,A=null!==(u=c.bufferedEnd)&&void 0!==u?u:c.end)}}var x=l[d-1];void 0!==x&&On(x,g,v)}}if(!t(c)){B.debug("SI: last segments have been GCed",v,d,l.length);for(var C,M=xn(l.splice(d,l.length-d));!(C=M()).done;){var P=C.value;void 0===P.bufferedStart&&void 0===P.bufferedEnd&&2!==P.status&&this._bufferedHistory.addBufferedSegment(P.infos,null)}}void 0!==v&&B.hasLevel("DEBUG")&&B.debug("SI: current "+v+" inventory timeline:\n"+function(e){var t=1/60,n={},r=[],i=null,a=null;function o(e){var t=String.fromCharCode(r.length+65);return r.push({letter:t,periodId:e.period.id,representationId:e.representation.id,bitrate:e.representation.bitrate}),t}for(var s="",u=0;u<e.length;u++){var l=e[u];if(void 0!==l.bufferedStart&&void 0!==l.bufferedEnd){var d,c=l.infos.period.id,f=l.infos.representation.id,v=n[c],p=void 0;if(void 0===v)p=o(l.infos),n[c]=((d={})[f]=p,d);else void 0===v[f]?(p=o(l.infos),v[f]=p):p=v[f];null===i?s+=l.bufferedStart.toFixed(2)+"|"+p+"|":a===p?i.bufferedEnd+t<l.bufferedStart&&(s+=i.bufferedEnd.toFixed(2)+" ~ "+l.bufferedStart.toFixed(2)+"|"+p+"|"):s+=i.bufferedEnd.toFixed(2)+" ~ "+l.bufferedStart.toFixed(2)+"|"+p+"|",i=l,a=p}}null!==i&&(s+=String(i.end.toFixed(2)));return r.forEach((function(e){var t;s+="\n["+e.letter+"] P: "+e.periodId+" || R: "+e.representationId+"("+(null!==(t=e.bitrate)&&void 0!==t?t:"unknown bitrate")+")"})),s}(this._inventory))},n.insertChunk=function(e,t,n){var r=e.period,i=e.adaptation,a=e.representation,o=e.segment,s=e.chunkSize,u=e.start,l=e.end;if(!o.isInit){var d=i.type;if(u>=l)B.warn("SI: Invalid chunked inserted: starts before it ends",d,u,l);else{for(var c=this._inventory,f={status:t?0:2,insertionTs:n,chunkSize:s,splitted:!1,start:u,end:l,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:o,period:r,adaptation:i,representation:a}},v=c.length-1;v>=0;v--){var p=c[v];if(p.start<=u){if(p.end<=u){for(B.debug("SI: Pushing segment strictly after previous one.",d,u,p.end),this._inventory.splice(v+1,0,f),v+=2;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return B.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);B.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}if(p.start===u){if(p.end<=l){for(B.debug("SI: Segment pushed replace another one",d,u,l,p.end),this._inventory.splice(v,1,f),v+=1;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return B.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);B.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}return B.debug("SI: Segment pushed ends before another with the same start",d,u,l,p.end),c.splice(v,0,f),p.start=f.end,p.bufferedStart=void 0,void(p.precizeStart=p.precizeStart&&f.precizeEnd)}if(p.end<=f.end){for(B.debug("SI: Segment pushed updates end of previous one",d,u,l,p.start,p.end),this._inventory.splice(v+1,0,f),p.end=f.start,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&f.precizeStart,v+=2;v<c.length&&c[v].start<f.end;){if(c[v].end>f.end)return B.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[v].start),c[v].start=f.end,c[v].bufferedStart=void 0,void(c[v].precizeStart=c[v].precizeStart&&f.precizeEnd);B.debug("SI: Segment pushed removes the next one",d,u,l,c[v].start,c[v].end),c.splice(v,1)}return}B.warn("SI: Segment pushed is contained in a previous one",d,u,l,p.start,p.end);var h={status:p.status,insertionTs:p.insertionTs,chunkSize:p.chunkSize,splitted:!0,start:f.end,end:p.end,precizeStart:p.precizeStart&&p.precizeEnd&&f.precizeEnd,precizeEnd:p.precizeEnd,bufferedStart:void 0,bufferedEnd:p.end,infos:p.infos};return p.end=f.start,p.splitted=!0,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&f.precizeStart,c.splice(v+1,0,f),void c.splice(v+2,0,h)}}var m=this._inventory[0];if(void 0===m)return B.debug("SI: first segment pushed",d,u,l),void this._inventory.push(f);if(!(m.start>=l)){if(m.end<=l){for(B.debug("SI: Segment pushed starts before and completely recovers the previous first one",d,u,l,m.start,m.end),this._inventory.splice(0,1,f);c.length>1&&c[1].start<f.end;){if(c[1].end>f.end)return B.debug("SI: Segment pushed updates the start of the next one",d,f.end,c[1].start),c[1].start=f.end,c[1].bufferedStart=void 0,void(c[1].precizeStart=f.precizeEnd);B.debug("SI: Segment pushed removes the next one",d,u,l,c[1].start,c[1].end),c.splice(1,1)}return}return B.debug("SI: Segment pushed start of the next one",d,u,l,m.start,m.end),m.start=l,m.bufferedStart=void 0,m.precizeStart=f.precizeEnd,void this._inventory.splice(0,0,f)}B.debug("SI: Segment pushed comes before all previous ones",d,u,l,m.start),this._inventory.splice(0,0,f)}}},n.completeSegment=function(e){if(!e.segment.isInit){for(var t=this._inventory,n=[],r=0;r<t.length;r++)if(un(t[r].infos,e)){var i=!1;n.length>0&&(i=!0,1===n.length&&(B.warn("SI: Completed Segment is splitted.",e.segment.id,e.segment.time,e.segment.end),n[0].splitted=!0));var a=r,o=t[r].chunkSize;for(r+=1;r<t.length&&un(t[r].infos,e);){var s=t[r].chunkSize;void 0!==o&&void 0!==s&&(o+=s),r++}var u=r-1,l=u-a,d=t[u].end,c=t[u].bufferedEnd;l>0&&(this._inventory.splice(a+1,l),r-=l),0===this._inventory[a].status&&(this._inventory[a].status=1),this._inventory[a].chunkSize=o,this._inventory[a].end=d,this._inventory[a].bufferedEnd=c,this._inventory[a].splitted=i,n.push(this._inventory[a])}if(0===n.length)B.warn("SI: Completed Segment not found",e.segment.id,e.segment.time);else for(var f,v=xn(n);!(f=v()).done;){var p=f.value;void 0!==p.bufferedStart&&void 0!==p.bufferedEnd?2!==p.status&&this._bufferedHistory.addBufferedSegment(p.infos,{start:p.bufferedStart,end:p.bufferedEnd}):B.debug("SI: buffered range not known after sync. Skipping history.",p.start,p.end)}}},n.getInventory=function(){return this._inventory},n.getHistoryFor=function(e){return this._bufferedHistory.getHistoryFor(e)},e}();function Pn(e){if(void 0===e.bufferedStart||1!==e.status)return!1;var t=e.start,n=e.end-t,r=L.getCurrent(),i=r.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,a=r.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(t-e.bufferedStart)<=i&&(void 0===e.bufferedEnd||e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-n)<=Math.min(a,n/3))}function Dn(e){if(void 0===e.bufferedEnd||1!==e.status)return!1;var t=e.start,n=e.end,r=n-t,i=L.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE;return Math.abs(n-e.bufferedEnd)<=a&&void 0!==e.bufferedStart&&e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-r)<=Math.min(o,r/3)}function Nn(e,t,n,r){var i=L.getCurrent(),a=i.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,o=i.MISSING_DATA_TRIGGER_SYNC_DELAY,s=i.SEGMENT_SYNCHRONIZATION_DELAY;if(void 0!==e.bufferedStart)e.bufferedStart<t&&(B.debug("SI: Segment partially GCed at the start",r,e.bufferedStart,t),e.bufferedStart=t),!e.precizeStart&&Pn(e)&&(e.start=e.bufferedStart,e.precizeStart=!0);else if(e.precizeStart)B.debug("SI: buffered start is precize start",r,e.start),e.bufferedStart=e.start;else if(null!==n&&n.end>t&&(n.precizeEnd||e.start-n.end<=a))B.debug("SI: buffered start is end of previous segment",r,t,e.start,n.end),e.bufferedStart=n.end,Pn(e)&&(e.start=n.end,e.precizeStart=!0);else if(e.start-t<=a){var u=ye();if(e.start-t>=o&&u-e.insertionTs<s)return void B.debug("SI: Ignored bufferedStart synchronization",r,t,e.start,u-e.insertionTs);B.debug("SI: found true buffered start",r,t,e.start),e.bufferedStart=t,Pn(e)&&(e.start=t,e.precizeStart=!0)}else if(t<e.start)B.debug("SI: range start too far from expected start",r,t,e.start),e.bufferedStart=e.start;else{var l=ye();if(e.start-t>=o&&l-e.insertionTs<s)return void B.debug("SI: Ignored bufferedStart synchronization",r,t,e.start,l-e.insertionTs);B.debug("SI: Segment appears immediately garbage collected at the start",r,t,e.start),e.bufferedStart=t}}function On(e,t,n){var r=L.getCurrent(),i=r.MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,a=r.MISSING_DATA_TRIGGER_SYNC_DELAY,o=r.SEGMENT_SYNCHRONIZATION_DELAY;if(void 0!==e.bufferedEnd)e.bufferedEnd>t&&(B.debug("SI: Segment partially GCed at the end",n,e.bufferedEnd,t),e.bufferedEnd=t),!e.precizeEnd&&t-e.end<=i&&Dn(e)&&(e.precizeEnd=!0,e.end=t);else if(e.precizeEnd)B.debug("SI: buffered end is precize end",n,e.end),e.bufferedEnd=e.end;else if(t-e.end<=i){var s=ye();if(t-e.end>=a&&s-e.insertionTs<o)return void B.debug("SI: Ignored bufferedEnd synchronization",n,t,e.end,s-e.insertionTs);B.debug("SI: found true buffered end",n,t,e.end),e.bufferedEnd=t,Dn(e)&&(e.end=t,e.precizeEnd=!0)}else if(t>e.end)B.debug("SI: range end too far from expected end",n,t,e.end),e.bufferedEnd=e.end;else{var u=ye();if(t-e.end>=a&&u-e.insertionTs<o)return void B.debug("SI: Ignored bufferedEnd synchronization",n,t,e.end,u-e.insertionTs);B.debug("SI: Segment appears immediately garbage collected at the end",n,e.bufferedEnd,t),e.bufferedEnd=t}}var Ln,Un=Mn,Fn=function(){function e(){this._segmentInventory=new Un}var t=e.prototype;return t.synchronizeInventory=function(e){this._segmentInventory.synchronizeBuffered(e)},t.getLastKnownInventory=function(){return this._segmentInventory.getInventory()},t.getSegmentHistory=function(e){return this._segmentInventory.getHistoryFor(e)},e}();!function(e){e[e.Push=0]="Push",e[e.Remove=1]="Remove",e[e.SignalSegmentComplete=2]="SignalSegmentComplete"}(Ln||(Ln={}));var Bn=function(e){function t(t,n,r){var i;i=e.call(this)||this,B.info("AVSB: calling `mediaSource.addSourceBuffer`",n);var a=r.addSourceBuffer(t,n);return i.bufferType=t,i._sourceBuffer=a,i._lastInitSegmentUniqueId=null,i.codec=n,i._initSegmentsMap=new Map,i._pendingOperations=[],i}f(t,e);var n=t.prototype;return n.declareInitSegment=function(e,t){zn(t),this._initSegmentsMap.set(e,t)},n.freeInitSegment=function(e){this._initSegmentsMap.delete(e)},n.pushChunk=function(){var e=d(g().mark((function e(t){var n,r,i,a,o=this;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return zn(t.data.chunk),B.debug("AVSB: receiving order to push data to the SourceBuffer",this.bufferType,ln(t.inventoryInfos)),0===(n=this._getActualDataToPush(t.data)).length&&n.push(new Uint8Array),r=Promise.all(n.map((function(e){var n=t.data,r=n.codec,i=n.timestampOffset,a=n.appendWindow;return B.debug("AVSB: pushing segment",o.bufferType,ln(t.inventoryInfos)),o._sourceBuffer.appendBuffer(e,{codec:r,timestampOffset:i,appendWindow:a})}))),this._addToOperationQueue(r,{type:Ln.Push,value:t}),e.prev=6,e.next=9,r;case 9:i=e.sent,e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(6),this._segmentInventory.insertChunk(t.inventoryInfos,!1,ye()),e.t0;case 16:return null!==t.inventoryInfos&&this._segmentInventory.insertChunk(t.inventoryInfos,!0,ye()),a=i[i.length-1],this._segmentInventory.synchronizeBuffered(a),e.abrupt("return",a);case 20:case"end":return e.stop()}}),e,this,[[6,12]])})));return function(t){return e.apply(this,arguments)}}(),n.removeBuffer=function(){var e=d(g().mark((function e(t,n){var r,i;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return B.debug("AVSB: receiving order to remove data from the SourceBuffer",this.bufferType,t,n),r=this._sourceBuffer.remove(t,n),this._addToOperationQueue(r,{type:Ln.Remove,value:{start:t,end:n}}),e.next=5,r;case 5:return i=e.sent,this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.signalSegmentComplete=function(){var e=d(g().mark((function e(t){var n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._pendingOperations.length>0)){e.next=10;break}return n=this._pendingOperations[this._pendingOperations.length-1].promise,this._addToOperationQueue(n,{type:Ln.SignalSegmentComplete,value:t}),e.prev=3,e.next=6,n;case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:this._segmentInventory.completeSegment(t);case 11:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(t){return e.apply(this,arguments)}}(),n.getPendingOperations=function(){return this._pendingOperations.map((function(e){return e.operation}))},n.dispose=function(){try{B.debug("AVSB: Calling `dispose` on the SourceBufferInterface"),this._sourceBuffer.dispose()}catch(e){B.debug("AVSB: Failed to dispose a "+this.bufferType+" SourceBufferInterface:",e instanceof Error?e:"")}},n._getActualDataToPush=function(e){var t=[];if(null!==e.initSegmentUniqueId&&!this._isLastInitSegment(e.initSegmentUniqueId)){var n=this._initSegmentsMap.get(e.initSegmentUniqueId);if(void 0===n)throw new Error("Invalid initialization segment uniqueId");var r=new ArrayBuffer(n.byteLength),i=new Uint8Array(r);i.set(n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)),n=i,t.push(n),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return null!==e.chunk&&t.push(e.chunk),t},n._isLastInitSegment=function(e){return null!==this._lastInitSegmentUniqueId&&this._lastInitSegmentUniqueId===e},n._addToOperationQueue=function(e,t){var n=this,r={operation:t,promise:e};this._pendingOperations.push(r);var i=function(){var e=n._pendingOperations.indexOf(r);e>=0&&n._pendingOperations.splice(e,1)};e.then(i,i)},t}(Fn);function zn(e){}var Vn=Bn,Kn=function(e){function t(t){var n;return B.debug("HTSB: Creating TextSegmentSink"),(n=e.call(this)||this).bufferType="text",n._sender=t,n._pendingOperations=[],n._sender.reset(),n}f(t,e);var n=t.prototype;return n.declareInitSegment=function(e){B.warn("HTSB: Declaring initialization segment for Text SegmentSink",e)},n.freeInitSegment=function(e){B.warn("HTSB: Freeing initialization segment for Text SegmentSink",e)},n.pushChunk=function(){var e=d(g().mark((function e(t){var n,r,i;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Wn((n=t.data).chunk),r=this._sender.pushTextData(Object.assign(Object.assign({},n),{chunk:n.chunk})),this._addToOperationQueue(r,{type:Ln.Push,value:t}),e.next=6,r;case 6:return i=e.sent,null!==t.inventoryInfos&&this._segmentInventory.insertChunk(t.inventoryInfos,!0,ye()),this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.removeBuffer=function(){var e=d(g().mark((function e(t,n){var r,i;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._sender.remove(t,n),this._addToOperationQueue(r,{type:Ln.Remove,value:{start:t,end:n}}),e.next=4,r;case 4:return i=e.sent,this._segmentInventory.synchronizeBuffered(i),e.abrupt("return",i);case 7:case"end":return e.stop()}}),e,this)})));return function(t,n){return e.apply(this,arguments)}}(),n.signalSegmentComplete=function(){var e=d(g().mark((function e(t){var n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this._pendingOperations.length>0)){e.next=10;break}return n=this._pendingOperations[this._pendingOperations.length-1].promise,this._addToOperationQueue(n,{type:Ln.SignalSegmentComplete,value:t}),e.prev=3,e.next=6,n;case 6:e.next=10;break;case 8:e.prev=8,e.t0=e.catch(3);case 10:this._segmentInventory.completeSegment(t);case 11:case"end":return e.stop()}}),e,this,[[3,8]])})));return function(t){return e.apply(this,arguments)}}(),n.getPendingOperations=function(){return this._pendingOperations.map((function(e){return e.operation}))},n.dispose=function(){B.debug("HTSB: Disposing TextSegmentSink"),this._sender.reset()},n._addToOperationQueue=function(e,t){var n=this,r={operation:t,promise:e};this._pendingOperations.push(r);var i=function(){var e=n._pendingOperations.indexOf(r);e>=0&&n._pendingOperations.splice(e,1)};e.then(i,i)},t}(Fn);function Wn(e){}var Gn=Kn,Hn=["audio","video","text"];function jn(e){return"audio"===e||"video"===e}var qn=function(){function e(e,t,n){this._mediaSource=e,this._textInterface=n,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}e.isNative=function(e){return jn(e)};var n=e.prototype;return n.getBufferTypes=function(){var e=this.getNativeBufferTypes();return null!==this._textInterface&&e.push("text"),e},n.getNativeBufferTypes=function(){return this._hasVideo?["video","audio"]:["audio"]},n.getStatus=function(e){var t=this._initializedSegmentSinks[e];return void 0===t?{type:"uninitialized"}:null===t?{type:"disabled"}:{type:"initialized",value:t}},n.waitForUsableBuffers=function(e){var t=this;return this._areNativeBuffersUsable()?Promise.resolve():jt(e,(function(e){var n,r=function(){var e=t._onNativeBufferAddedOrDisabled.indexOf(n);e>=0&&t._onNativeBufferAddedOrDisabled.splice(e,1)};return n=function(){t._areNativeBuffersUsable()&&(r(),e())},t._onNativeBufferAddedOrDisabled.push(n),r}))},n.disableSegmentSink=function(t){var n=this._initializedSegmentSinks[t];if(null!==n){if(void 0!==n)throw new Error("Cannot disable an active SegmentSink.");this._initializedSegmentSinks[t]=null,e.isNative(t)&&this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()}))}else B.warn("SBS: The "+t+" SegmentSink was already disabled.")},n.createSegmentSink=function(e,n){var r,i=this._initializedSegmentSinks[e];if(jn(e)){if(!t(i))return i instanceof Vn&&i.codec!==n?B.warn("SB: Reusing native SegmentSink with codec",i.codec,"for codec",n):B.info("SB: Reusing native SegmentSink with codec",n),i;B.info("SB: Adding native SegmentSink with codec",n);var a=new Vn("audio"===e?"audio":"video",n,this._mediaSource);return this._initializedSegmentSinks[e]=a,this._onNativeBufferAddedOrDisabled.forEach((function(e){return e()})),a}if(!t(i))return B.info("SB: Reusing a previous custom SegmentSink for the type",e),i;if("text"===e){if(B.info("SB: Creating a new text SegmentSink"),null===this._textInterface)throw new Error("HTML Text track feature not activated");return r=new Gn(this._textInterface),this._initializedSegmentSinks.text=r,r}throw B.error("SB: Unknown buffer type:",e),new qe("BUFFER_TYPE_UNKNOWN","The player wants to create a SegmentSink of an unknown type.")},n.disposeSegmentSink=function(e){var n=this._initializedSegmentSinks[e];t(n)?B.warn("SB: Trying to dispose a SegmentSink that does not exist"):(B.info("SB: Aborting SegmentSink",e),n.dispose(),delete this._initializedSegmentSinks[e])},n.disposeAll=function(){var e=this;Hn.forEach((function(t){"initialized"===e.getStatus(t).type&&e.disposeSegmentSink(t)}))},n._areNativeBuffersUsable=function(){var e=this,t=this.getNativeBufferTypes();return!t.some((function(t){return void 0===e._initializedSegmentSinks[t]}))&&!t.every((function(t){return null===e._initializedSegmentSinks[t]}))},e}(),Yn=function(){function e(e){this._weakMap=new WeakMap,this._fn=e}var t=e.prototype;return t.get=function(e){var t=this._weakMap.get(e);if(void 0===t){var n=this._fn(e);return this._weakMap.set(e,n),n}return t},t.destroy=function(e){this._weakMap.delete(e)},e}();function Qn(e,t){var n,r=e.segmentSink,i=e.playbackObserver,a=e.maxBufferBehind,o=e.maxBufferAhead,s=[];function u(){null!==s&&function(e,t,n,r,i,a){return $n.apply(this,arguments)}(r,n,s,a.getValue(),o.getValue(),t).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";B.error("Could not run BufferGarbageCollector:",t)}))}i.listen((function(e){n=e.position.getWanted(),s=e.buffered[r.bufferType],u()}),{includeLastObservation:!0,clearSignal:t}),a.onUpdate(u,{clearSignal:t}),o.onUpdate(u,{clearSignal:t}),u()}function $n(){return($n=d(g().mark((function e(n,r,i,a,o,s){var u,l,d,c,f,v,p,h;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(isFinite(a)||isFinite(o)){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:u=[],l=$(i,r),d=l.innerRange,c=l.outerRanges,f=function(){if(isFinite(o)){for(var e=0;e<c.length;e++){var n=c[e];r+o<=n.start?u.push(n):r<=n.start&&r+o<n.end&&r+o>n.start&&u.push({start:r+o,end:n.end})}t(d)||r+o<d.end&&u.push({start:r+o,end:d.end})}},function(){if(isFinite(a)){for(var e=0;e<c.length;e++){var n=c[e];r-a>=n.end?u.push(n):r>=n.end&&r-a>n.start&&r-a<n.end&&u.push({start:n.start,end:r-a})}t(d)||r-a>d.start&&u.push({start:d.start,end:r-a})}}(),f(),v=0,p=u;case 9:if(!(v<p.length)){e.next=20;break}if(!((h=p[v]).start<h.end)){e.next=17;break}if(B.debug("GC: cleaning range from SegmentSink",h.start,h.end),null===s.cancellationError){e.next=15;break}throw s.cancellationError;case 15:return e.next=17,n.removeBuffer(h.start,h.end);case 17:v++,e.next=9;break;case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Xn=function(e){function t(t,n,r,i){var a;return(a=e.call(this)||this)._content=t,a._currentCanceller=null,a._downloadQueue=n,a._initSegmentRequest=null,a._mediaSegmentRequest=null,a._segmentFetcher=r,a._initSegmentInfoRef=new oe(void 0),a._mediaSegmentAwaitingInitMetadata=null,i||a._initSegmentInfoRef.setValue(null),a}f(t,e);var n=t.prototype;return n.getRequestedInitSegment=function(){return null===this._initSegmentRequest?null:this._initSegmentRequest.segment},n.getRequestedMediaSegment=function(){return null===this._mediaSegmentRequest?null:this._mediaSegmentRequest.segment},n.start=function(){var e=this;null===this._currentCanceller&&(this._currentCanceller=new pe,this._downloadQueue.onUpdate((function(t){var n=t.segmentQueue;if(!(n.length>0&&n[0].segment.id===e._mediaSegmentAwaitingInitMetadata)){var r=e._mediaSegmentRequest;if(0===n.length){if(null===r)return;return B.debug("Stream: no more media segment to request. Cancelling queue.",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()}if(null===r)return B.debug("Stream: Media segments now need to be requested. Starting queue.",e._content.adaptation.type,n.length),void e._restartMediaSegmentDownloadingQueue();var i=n[0];return r.segment.id!==i.segment.id?(B.debug("Stream: Next media segment changed, cancelling previous",e._content.adaptation.type),void e._restartMediaSegmentDownloadingQueue()):void(r.priority!==i.priority&&(B.debug("Stream: Priority of next media segment changed, updating",e._content.adaptation.type,r.priority,i.priority),e._segmentFetcher.updatePriority(r.request,i.priority)))}}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate((function(t){var n,r=e._initSegmentRequest;null===t.initSegment||null===r?(null===(n=t.initSegment)||void 0===n?void 0:n.segment.id)!==(null==r?void 0:r.segment.id)&&(null===t.initSegment&&B.debug("Stream: no more init segment to request. Cancelling queue.",e._content.adaptation.type),e._restartInitSegmentDownloadingQueue(t.initSegment)):t.initSegment.priority!==r.priority&&e._segmentFetcher.updatePriority(r.request,t.initSegment.priority)}),{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))},n.stop=function(){var e;null===(e=this._currentCanceller)||void 0===e||e.cancel(),this._currentCanceller=null},n._restartMediaSegmentDownloadingQueue=function(){var e=this;null!==this._mediaSegmentRequest&&this._mediaSegmentRequest.canceller.cancel();!function t(n){if(null!==e._currentCanceller&&e._currentCanceller.isUsed())e._mediaSegmentRequest=null;else{if(void 0===n)return e._mediaSegmentRequest=null,void e.trigger("emptyQueue",null);var r=new pe,i=null===e._currentCanceller?U:r.linkToSignal(e._currentCanceller.signal),a=n.segment,o=n.priority,s=P({segment:a},e._content),u=!1,l=!1;r.signal.register((function(){e._mediaSegmentRequest=null,u||(e._mediaSegmentAwaitingInitMetadata===a.id&&(e._mediaSegmentAwaitingInitMetadata=null),u=!0,l=!1)}));var d=function(t){fe(t.segmentType),e.trigger("parsedMediaSegment",P({},t,{segment:a}))},c=function(){var n=e._downloadQueue.getValue().segmentQueue;if(0===n.length)return u=!0,void e.trigger("emptyQueue",null);n[0].segment.id===a.id&&n.shift(),u=!0,t(n[0])},f=e._segmentFetcher.createRequest(s,o,{onRetry:function(t){e.trigger("requestRetry",{segment:a,error:t})},beforeInterrupted:function(){B.info("Stream: segment request interrupted temporarly.",a.id,a.time)},onChunk:function(t){var n=e._initSegmentInfoRef.getValue();void 0!==n?d(t(null!=n?n:void 0)):(l=!0,e._initSegmentInfoRef.waitUntilDefined((function(e){d(t(null!=e?e:void 0))}),{clearSignal:r.signal}))},onAllChunksReceived:function(){l?(e._mediaSegmentAwaitingInitMetadata=a.id,e._initSegmentInfoRef.waitUntilDefined((function(){e._mediaSegmentAwaitingInitMetadata=null,l=!1,e.trigger("fullyLoadedSegment",a)}),{clearSignal:r.signal})):e.trigger("fullyLoadedSegment",a)},beforeEnded:function(){i(),e._mediaSegmentRequest=null,l?e._initSegmentInfoRef.waitUntilDefined(c,{clearSignal:r.signal}):c()}},r.signal);f.catch((function(t){i(),u||(u=!0,e.stop(),e.trigger("error",t))})),e._mediaSegmentRequest={segment:a,priority:o,request:f,canceller:r}}}(this._downloadQueue.getValue().segmentQueue[0])},n._restartInitSegmentDownloadingQueue=function(e){var t=this;if((null===this._currentCanceller||!this._currentCanceller.isUsed())&&(null!==this._initSegmentRequest&&this._initSegmentRequest.canceller.cancel(),null!==e)){var n=new pe,r=null===this._currentCanceller?U:n.linkToSignal(this._currentCanceller.signal),i=e.segment,a=e.priority,o=P({segment:i},this._content),s=!1,u=this._segmentFetcher.createRequest(o,a,{onRetry:function(e){t.trigger("requestRetry",{segment:i,error:e})},beforeInterrupted:function(){B.info("Stream: init segment request interrupted temporarly.",i.id)},beforeEnded:function(){r(),t._initSegmentRequest=null,s=!0},onChunk:function(e){var n,r=e(void 0);fe(r.segmentType),t.trigger("parsedInitSegment",P({},r,{segment:i})),"init"===r.segmentType&&t._initSegmentInfoRef.setValue(null!==(n=r.initTimescale)&&void 0!==n?n:null)},onAllChunksReceived:function(){t.trigger("fullyLoadedSegment",i)}},n.signal);u.catch((function(e){r(),s||(s=!0,t.stop(),t.trigger("error",e))})),n.signal.register((function(){t._initSegmentRequest=null,s||(s=!0)})),this._initSegmentRequest={segment:i,priority:a,request:u,canceller:n}}},t}(i);function Zn(e,t,n,r,i){var a=e.period,o=e.adaptation,s=e.representation,u=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(void 0===r.bufferedStart||void 0===r.bufferedEnd||r.bufferedStart>=t.end)return null;if(r.bufferedEnd>t.start)return n}return null}(i,t);if(null===u){if(null===n){if(r&&void 0!==a.end&&t.end>=a.end)return{start:void 0,end:null};var l=s.index.checkDiscontinuity(t.start);if(null!==l)return{start:void 0,end:l}}return null}var d=i[u];if(void 0!==d.bufferedStart&&d.bufferedStart>t.start&&(null===n||d.infos.segment.end<=n)){var c=d.bufferedStart;return r||!1===s.index.awaitSegmentBetween(t.start,c)?(B.debug("RS: current discontinuity encountered",o.type,d.bufferedStart),{start:void 0,end:c}):null}var f=function(e,t,n){if(n<=0)return B.error("RS: Asked to check a discontinuity before the first chunk."),null;for(var r=n;r<e.length;r++){var i=e[r],a=e[r-1];if(void 0===i.bufferedStart||void 0===a.bufferedEnd||i.bufferedStart>=t.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}(i,t,u+1);if(null!==f){var v=i[f-1],p=i[f];if(null===n||p.infos.segment.end<=n){if(!r&&!1!==s.index.awaitSegmentBetween(v.infos.segment.end,p.infos.segment.time))return null;var h=v.bufferedEnd,m=p.bufferedStart;return B.debug("RS: future discontinuity encountered",o.type,h,m),{start:h,end:m}}}if(null===n){if(r&&void 0!==a.end){if(t.end<a.end)return null;var g=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(void 0===r.bufferedStart)return null;if(r.bufferedStart<t)return n}return null}(i,a.end);if(null!==g){var y=i[g];if(void 0!==y.bufferedEnd&&y.bufferedEnd<a.end)return B.debug("RS: discontinuity encountered at the end of the current period",o.type,y.bufferedEnd,a.end),{start:y.bufferedEnd,end:null}}}if(void 0!==a.end&&t.end>=a.end)return null;for(var _=i.length-1;_>=0;_--){var b=i[_];if(void 0===b.bufferedStart)break;if(b.bufferedStart<t.end){if(void 0!==b.bufferedEnd&&b.bufferedEnd<t.end){var S=s.index.checkDiscontinuity(t.end);if(null!==S)return{start:b.bufferedEnd,end:S}}return null}}}return null}function Jn(e){var t=e.bufferedSegments,n=e.content,r=e.currentPlaybackTime,i=e.fastSwitchThreshold,a=e.getBufferedHistory,o=e.neededRange,s=e.segmentsBeingPushed,u=e.maxBufferSize,l=n.adaptation,d=n.representation,c=function(e,t,n){var r=8e3*n;return r-=t.reduce((function(e,t){return e+t.representation.bitrate*t.segment.duration}),0),e.reduce((function(e,t){return void 0!==t.chunkSize?e-8*t.chunkSize:e}),r)}(t,s,u),f=d.index.getSegments(o.start,o.end-o.start),v=t.filter((function(e){return!tr(e.infos,n,r,i)})).filter((function(e,t,n){var r=0===t?null:n[t-1],i=t>=n.length-1?null:n[t+1],s=null;if(function(e,t,n){var r=L.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedStart)return!1;if(null!==t&&void 0!==t.bufferedEnd&&e.bufferedStart-t.bufferedEnd<.1)return!1;if(n<e.bufferedStart&&e.bufferedStart-e.start>r)return B.info("Stream: The start of the wanted segment has been garbage collected",e.start,e.bufferedStart),!0;return!1}(e,r,o.start)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.start;if(void 0!==t&&void 0!==a&&t-a>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.start;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(s=a(e.infos),e.bufferedStart))return!1;B.debug("Stream: skipping segment gc-ed at the start",e.start,e.bufferedStart)}if(function(e,t,n){var r=L.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT;if(void 0===e.bufferedEnd)return!1;if(null!==t&&void 0!==t.bufferedStart&&t.bufferedStart-e.bufferedEnd<.1)return!1;if(n>e.bufferedEnd&&e.end-e.bufferedEnd>r)return B.info("Stream: The end of the wanted segment has been garbage collected",e.end,e.bufferedEnd),!0;return!1}(e,i,o.end)){if(function(e,t){var n,r;if(e.length<2)return!0;var i=e[e.length-1],a=null===(n=i.buffered)||void 0===n?void 0:n.end;if(void 0!==t&&void 0!==a&&a-t>.05)return!0;var o=e[e.length-2],s=null===(r=o.buffered)||void 0===r?void 0:r.end;if(void 0===s||void 0===a)return!0;return Math.abs(s-a)>.01}(s=null!=s?s:a(e.infos),e.bufferedEnd))return!1;B.debug("Stream: skipping segment gc-ed at the end",e.end,e.bufferedEnd)}return!0})),p=L.getCurrent(),h=p.MINIMUM_SEGMENT_SIZE,m=p.MIN_BUFFER_AHEAD,g=!1,y=Math.min(1/60,h),_=!1,b=[],S=f.filter((function(e){var t=P({segment:e},n);if(s.length>0&&s.some((function(e){return un(t,e)})))return!1;var u=e.duration,f=e.time,p=e.end;if(e.isInit)return!0;if(g)return b.push(e),!1;if(e.complete&&u<h)return!1;if(s.length>0&&s.some((function(e){if(e.period.id!==n.period.id||e.adaptation.id!==n.adaptation.id)return!1;var a=e.segment;return!(a.time-y>f)&&(!(a.end+y<p)&&!tr(e,t,r,i))})))return!1;for(var S=0;S<v.length;S++){var E=v[S];if(E.infos.period.id===n.period.id){var T=E.infos.segment;if(f-T.time>-y&&T.end-p>-y)return!1}}var k=u*n.representation.bitrate;if(c-k<0&&(_=!0,f>o.start+m))return g=!0,b.push(e),!1;var w=a(t);if(w.length>1){var A=w[w.length-1],I=w[w.length-2];if(null===A.buffered&&null===I.buffered)return B.warn("Stream: Segment GCed multiple times in a row, ignoring it.","If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering."+l.type,d.id,e.time),!1}for(var R=0;R<v.length;R++){var x=v[R];if(x.end+y>f){var C=x.start>f+y||er(v,R).end<p-y;return C&&(c-=k),C}}return c-=k,!0}));return{segmentsToLoad:S,segmentsOnHold:b,isBufferFull:_}}function er(e,t){for(var n=t+1,r=L.getCurrent().MINIMUM_SEGMENT_SIZE,i=Math.min(1/60,r);n<e.length-1&&e[n-1].end+i>e[n].start;)n++;return e[--n]}function tr(e,t,n,r){var i=L.getCurrent().CONTENT_REPLACEMENT_PADDING;return e.period.id===t.period.id&&(!(e.segment.time<n+i)&&(e.adaptation.id!==t.adaptation.id||function(e,t,n){var r=e.bitrate,i=L.getCurrent().BITRATE_REBUFFERING_RATIO;if(void 0===n){var a=r*i;return t.bitrate>a}return r<n&&t.bitrate>r}(e.representation,t.representation,r)))}function nr(e,t){for(var n=e-t,r=L.getCurrent().SEGMENT_PRIORITIES_STEPS,i=0;i<r.length;i++)if(n<r[i])return i;return r.length}function rr(e,n,r,i,a,o,s){var u,l,d,c=e.representation,f=null!==(l=null!==(u=r.getIsPaused())&&void 0!==u?u:r.getReference().getValue().paused.pending)&&void 0!==l?l:r.getReference().getValue().paused.last,v=null!==(d=r.getPlaybackRate())&&void 0!==d?d:r.getReference().getValue().speed,p=n;(void 0===f||void 0===v||f||v<=0)&&(p-=.1);var h=function(e,n,r){var i,a,o=e.manifest,s=e.period,u=e.representation,l=u.index.getLastAvailablePosition(),d=u.index;a=!t(l)&&qn.isNative(e.adaptation.type)&&n>=l&&d.isInitialized()&&!d.isStillAwaitingFutureSegments()&&function(e,t,n){var r,i=e.getPeriodAfter(t);return t.containsTime(n,i)&&e.isLastPeriodKnown&&t.id===(null===(r=e.periods[e.periods.length-1])||void 0===r?void 0:r.id)}(o,s,n)?l-1:n-.1;var c,f=a+r;c=!(!u.index.isInitialized()||u.index.isStillAwaitingFutureSegments()||void 0===s.end)&&(void 0===l?f>=s.end:null===l||f>=l);return{start:Math.max(a,s.start),end:Math.min(f,null!==(i=s.end)&&void 0!==i?i:1/0),hasReachedPeriodEnd:c}}(e,p,a),m=c.index.shouldRefresh(h.start,h.end),g=s.getPendingOperations().filter((function(e){return e.type===Ln.SignalSegmentComplete})).map((function(e){return e.value})),y=function(e,t){for(var n=L.getCurrent().MINIMUM_SEGMENT_SIZE,r=Math.max(1/60,n),i=e.start+r,a=e.end-r,o=[],s=t.length-1;s>=0;s--){var u=t[s],l=u.infos.representation;if(1===u.status&&!1!==l.decipherable&&!1!==l.isSupported){var d=u.infos.segment,c=d.time/d.timescale;((d.complete?c+d.duration/d.timescale:u.end)>i&&c<a||u.end>i&&u.start<a)&&o.unshift(u)}}return o}({start:Math.max(h.start-.5,0),end:h.end+.5},s.getLastKnownInventory()),_=r.getCurrentTime();void 0===_&&(_=r.getReference().getValue().position.getWanted());var b=Jn({content:e,bufferedSegments:y,currentPlaybackTime:_,fastSwitchThreshold:i,getBufferedHistory:s.getSegmentHistory.bind(s),neededRange:h,segmentsBeingPushed:g,maxBufferSize:o}),S=b.segmentsToLoad,E=b.segmentsOnHold,T=b.isBufferFull,k=S.map((function(e){return{priority:nr(e.time,p),segment:e}})),w=c.index.isInitialized()&&!c.index.isStillAwaitingFutureSegments()&&h.hasReachedPeriodEnd&&0===k.length&&0===E.length,A=null;return g.length>0&&(A=Math.min.apply(Math,g.map((function(e){return e.segment.time})))),E.length>0&&(A=null!==A?Math.min(A,E[0].time):E[0].time),k.length>0&&(A=null!==A?Math.min(A,k[0].segment.time):k[0].segment.time),{imminentDiscontinuity:Zn(e,h,A,w,y),hasFinishedLoading:w,neededSegments:k,isBufferFull:T,shouldRefreshManifest:m}}var ir=function(e){function t(n,r,i){var a;return a=e.call(this)||this,Object.setPrototypeOf(se(a),t.prototype),a.name="SourceBufferError",a.errorName=n,a.message=r,a.isBufferFull=i,a}f(t,e);var n=t.prototype;return n.serialize=function(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}},n.toString=function(){return this.errorName+": "+this.message},t}(de(Error));function ar(e){return new Promise((function(t){setTimeout(t,e)}))}function or(e,t,n,r,i){return sr.apply(this,arguments)}function sr(){return(sr=d(g().mark((function e(t,n,r,i,a){var o,s,u,l,d,c,f;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,n.pushChunk(r);case 3:case 31:return e.abrupt("return",e.sent);case 6:if(e.prev=6,e.t0=e.catch(0),!(a.isCancelled()&&e.t0 instanceof me)){e.next=12;break}throw e.t0;case 12:if(e.t0 instanceof ir&&e.t0.isBufferFull){e.next=15;break}throw o=e.t0 instanceof Error?e.t0.toString():"An unknown error happened when pushing content",new qe("BUFFER_APPEND_ERROR",o,{tracks:[ht(r.inventoryInfos.adaptation)]});case 15:return s=t.getReference().getValue(),u=s.position,l=u.getWanted(),e.prev=17,B.warn("Stream: Running garbage collector"),d=Math.max(l-5,0),c=l+i.getValue()+12,e.next=23,n.removeBuffer(0,d);case 23:return e.next=25,n.removeBuffer(c,Number.MAX_VALUE);case 25:return e.next=27,ar(200);case 27:if(null===a.cancellationError){e.next=29;break}throw a.cancellationError;case 29:return e.next=31,n.pushChunk(r);case 34:if(e.prev=34,e.t1=e.catch(17),!(e.t1 instanceof me)){e.next=38;break}throw e.t1;case 38:throw f=e.t1 instanceof Error?e.t1.toString():"Could not clean the buffer",new qe("BUFFER_FULL_ERROR",f,{tracks:[ht(r.inventoryInfos.adaptation)]});case 40:case"end":return e.stop()}}),e,null,[[0,6],[17,34]])})))).apply(this,arguments)}function ur(){return ur=d(g().mark((function e(t,n){var r,i,a,o,s,u,l,d,c,f;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.playbackObserver,i=t.content,a=t.initSegmentUniqueId,o=t.segment,s=t.segmentSink,u=t.bufferGoal,null===n.cancellationError){e.next=3;break}throw n.cancellationError;case 3:return l=i.representation.getMimeTypeString(),d={initSegmentUniqueId:a,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:l},c=P({segment:o,chunkSize:void 0,start:0,end:0},i),e.next=8,or(r,s,{data:d,inventoryInfos:c},u,n);case 8:return f=e.sent,e.abrupt("return",{content:i,segment:o,buffered:f});case 10:case"end":return e.stop()}}),e)}))),ur.apply(this,arguments)}function lr(){return lr=d(g().mark((function e(t,n){var r,i,a,o,s,u,l,d,c,f,v,p,h,m,y,_,b,S,E,T,k,w,A,I;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.playbackObserver,i=t.bufferGoal,a=t.content,o=t.initSegmentUniqueId,s=t.parsedSegment,u=t.segment,l=t.segmentSink,null!==s.chunkData){e.next=3;break}return e.abrupt("return",null);case 3:if(null===n.cancellationError){e.next=5;break}throw n.cancellationError;case 5:return f=s.chunkData,v=s.chunkInfos,p=s.chunkOffset,h=s.chunkSize,m=s.appendWindow,y=a.representation.getMimeTypeString(),_=L.getCurrent(),b=_.APPEND_WINDOW_SECURITIES,S=[void 0!==m[0]?Math.max(0,m[0]-b.START):void 0,void 0!==m[1]?m[1]+b.END:void 0],E={initSegmentUniqueId:o,chunk:f,timestampOffset:p,appendWindow:S,codec:y},T=null!==(d=null==v?void 0:v.time)&&void 0!==d?d:u.time,k=null!==(c=null==v?void 0:v.duration)&&void 0!==c?c:u.duration,w=T+k,void 0!==S[0]&&(T=Math.max(T,S[0])),void 0!==S[1]&&(w=Math.min(w,S[1])),A=P({segment:u,chunkSize:h,start:T,end:w},a),e.next=18,or(r,l,{data:E,inventoryInfos:A},i,n);case 18:return I=e.sent,e.abrupt("return",{content:a,segment:u,buffered:I});case 20:case"end":return e.stop()}}),e)}))),lr.apply(this,arguments)}function dr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return cr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function cr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var fr=function(e,t,n){var r=e.content,i=e.options,a=e.playbackObserver,o=e.segmentSink,s=e.segmentFetcher,u=e.terminate,l=r.period,d=r.adaptation,c=r.representation,f=i.bufferGoal,v=i.maxBufferSize,p=i.drmSystemId,h=i.fastSwitchThreshold,m=d.type,g=new pe;g.linkToSignal(n);var y=new pe;y.linkToSignal(g.signal);var _={segment:c.index.getInitSegment(),uniqueId:null,isLoaded:!1};g.signal.register((function(){null!==_.uniqueId&&o.freeInitSegment(_.uniqueId)}));var b=new oe({initSegment:null,segmentQueue:[]},y.signal),S=null!==_.segment;S||(_.isLoaded=!0);var E=!1;if(void 0!==p){var T=c.getEncryptionData(p);if(T.length>0&&T.every((function(e){return void 0!==e.keyIds}))&&(E=!0,t.encryptionDataEncountered(T.map((function(e){return P({content:r},e)}))),g.isUsed()))return}var k=new Xn(r,b,s,S);return k.addEventListener("error",(function(e){y.signal.isCancelled()||(g.cancel(),t.error(e))})),k.addEventListener("parsedInitSegment",A),k.addEventListener("parsedMediaSegment",A),k.addEventListener("emptyQueue",w),k.addEventListener("requestRetry",(function(e){if(t.warning(e.error),!y.signal.isCancelled()){var n=e.segment,r=c.index;!1===r.isSegmentStillAvailable(n)?w():r.canBeOutOfSyncError(e.error,n)&&t.manifestMightBeOufOfSync()}})),k.addEventListener("fullyLoadedSegment",(function(e){o.signalSegmentComplete(P({segment:e},r)).catch(I)})),k.start(),y.signal.register((function(){k.removeEventListener(),k.stop()})),a.listen(w,{includeLastObservation:!1,clearSignal:y.signal}),r.manifest.addEventListener("manifestUpdate",w,y.signal),f.onUpdate(w,{emitCurrentValue:!1,clearSignal:y.signal}),v.onUpdate(w,{emitCurrentValue:!1,clearSignal:y.signal}),u.onUpdate(w,{emitCurrentValue:!1,clearSignal:y.signal}),void w();function w(){if(!y.isUsed()){var e=a.getReference().getValue(),n=e.position.getWanted(),i=rr(r,n,a,h.getValue(),f.getValue(),v.getValue(),o),s=i.neededSegments,d=null;if(c.index.isInitialized()){if(s.length>0&&!_.isLoaded&&null!==_.segment){var p=s[0].priority;d={segment:_.segment,priority:p}}}else if(null===_.segment)B.warn("Stream: Uninitialized index without an initialization segment");else if(_.isLoaded)B.warn("Stream: Uninitialized index with an already loaded initialization segment");else{var g=e.position.getWanted();d={segment:_.segment,priority:nr(l.start,g)}}var S=u.getValue();if(null===S)b.setValue({initSegment:d,segmentQueue:s});else{if(S.urgent)return B.debug("Stream: Urgent switch, terminate now.",m),b.setValue({initSegment:null,segmentQueue:[]}),b.finish(),y.cancel(),void t.terminating();var E=s[0],T=k.getRequestedInitSegment(),w=k.getRequestedMediaSegment(),A=null===w||void 0===E||w.id!==E.segment.id?[]:[E],R=null===T?null:d;if(b.setValue({initSegment:R,segmentQueue:A}),0===A.length&&null===R)return B.debug("Stream: No request left, terminate",m),b.finish(),y.cancel(),void t.terminating()}if(t.streamStatusUpdate({period:l,position:e.position.getWanted(),bufferType:m,imminentDiscontinuity:i.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:i.hasFinishedLoading,neededSegments:i.neededSegments}),!y.signal.isCancelled()){var x=L.getCurrent().UPTO_CURRENT_POSITION_CLEANUP;if(i.isBufferFull){var C=Math.max(0,n-x);C>0&&o.removeBuffer(0,C).catch(I)}i.shouldRefreshManifest&&t.needsManifestRefresh()}}}function A(e){if(!g.isUsed()){for(var n,i=dr(e.protectionData);!(n=i()).done;){var s=n.value;c.addProtectionData(s.initDataType,s.keyId,s.initData)}if(!E){var u=c.getAllEncryptionData();if(u.length>0&&(t.encryptionDataEncountered(u.map((function(e){return P({content:r},e)}))),E=!0,g.isUsed()))return}if("init"!==e.segmentType){var l=e.inbandEvents,d=e.predictedSegments,v=e.needsManifestRefresh;if(!(void 0!==d&&c.index.addPredictedSegments(d,e.segment),!0===v&&(t.needsManifestRefresh(),g.isUsed())||void 0!==l&&l.length>0&&(t.inbandEvent(l),g.isUsed()))){var p=_.uniqueId;(function(e,t){return lr.apply(this,arguments)})({playbackObserver:a,bufferGoal:f,content:r,initSegmentUniqueId:p,parsedSegment:e,segment:e.segment,segmentSink:o},g.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(I)}}else{if(c.index.isInitialized()||void 0===e.segmentList||c.index.initialize(e.segmentList),_.isLoaded=!0,null!==e.initializationData){var h=c.uniqueId;_.uniqueId=h,o.declareInitSegment(h,e.initializationData),function(e,t){return ur.apply(this,arguments)}({playbackObserver:a,bufferGoal:f,content:r,initSegmentUniqueId:h,segment:e.segment,segmentData:e.initializationData,segmentSink:o},g.signal).then((function(e){null!==e&&t.addedSegment(e)})).catch(I)}w()}}}function I(e){g.isUsed()&&e instanceof me||(g.cancel(),t.error(e))}};function vr(e,t){for(var n=0;n<e.length;n++)if(e[n].infos.period.start>=t.start)return n>0?e[n-1]:null;return e.length>0?e[e.length-1]:null}function pr(e,t){for(var n=0;n<e.length;n++)if(e[n].infos.period.start>t.start)return e[n];return null}function hr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return mr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function mr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function gr(e,t,n,r,i){var a,o,s,u;if("lazy"===n.switchingMode)return{type:"continue",value:void 0};for(var l,d=r.getLastKnownInventory(),c=[],f=hr(d);!(l=f()).done;){var v=l.value;v.infos.period.id!==e.id||v.infos.adaptation.id===t.id&&Je(n.representationIds,v.infos.representation.id)||Z(c,{start:null!==(a=v.bufferedStart)&&void 0!==a?a:v.start,end:null!==(o=v.bufferedEnd)&&void 0!==o?o:v.end})}for(var p,h=hr(r.getPendingOperations());!(p=h()).done;){var m=p.value;if(m.type===Ln.Push){var g=m.value.inventoryInfos;if(g.period.id===e.id&&(g.adaptation.id!==t.id||!Je(n.representationIds,g.representation.id))){var y=g.segment.time;Z(c,{start:y,end:y+g.segment.duration})}}}if(0===c.length)return{type:"continue",value:void 0};if("reload"===n.switchingMode){var _=i.getReadyState();if(void 0===_||_>1)return{type:"needs-reload",value:void 0}}var b="direct"===n.switchingMode,S=[],E=vr(d,e);if(null!==E&&(void 0===E.bufferedEnd||e.start-E.bufferedEnd<1)&&S.push({start:0,end:e.start+1}),!b){var T=L.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,k=t.type,w=null!==(s=T[k].before)&&void 0!==s?s:0,A=null!==(u=T[k].after)&&void 0!==u?u:0,I=i.getCurrentTime();if(void 0===I)I=i.getReference().getValue().position.getPolled();S.push({start:I-w,end:I+A})}if(void 0!==e.end){var R=pr(d,e);null!==R&&(void 0===R.bufferedStart||R.bufferedStart-e.end<1)&&S.push({start:e.end-1,end:Number.MAX_VALUE})}var x=ee(c,S);return 0===x.length?{type:"continue",value:void 0}:b?{type:"flush-buffer",value:x}:{type:"clean-buffer",value:x}}function yr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _r(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var br=function(e,t,n){var r=e.playbackObserver,i=e.content,a=e.options,o=e.representationEstimator,s=e.segmentSink,l=e.segmentFetcherCreator,c=e.wantedBufferAhead,f=e.maxVideoBufferSize,v=i.manifest,p=i.period,h=i.adaptation,m=new pe;m.linkToSignal(n);var y,_,b=new Map,S=new oe(null,m.signal),E=i.representations.getValue().representationIds,T=i.adaptation.representations.filter((function(e){return Je(E,e.id)&&!1!==e.decipherable&&!1!==e.isSupported})),k=new oe(T,m.signal),w=o({manifest:v,period:p,adaptation:h},S,k,r,m.signal),A=w.estimates,I=w.callbacks,R=l.createSegmentFetcher(h.type,{onRequestBegin:I.requestBegin,onRequestEnd:I.requestEnd,onProgress:I.requestProgress,onMetrics:I.metrics}),x=new oe(0);return A.onUpdate((function(e){var n=e.bitrate,r=e.knownStableBitrate;a.enableFastSwitching&&x.setValueIfChanged(r),void 0!==n&&n!==y&&(y=n,B.debug("Stream: new "+h.type+" bitrate estimate",n),t.bitrateEstimateChange({type:h.type,bitrate:n}))}),{emitCurrentValue:!0,clearSignal:m.signal}),void i.representations.onUpdate((function(e){void 0!==_&&_.cancel();var n=i.representations.getValue().representationIds,r=i.adaptation.representations.filter((function(e){return Je(n,e.id)}));k.setValueIfChanged(r),(_=new pe).linkToSignal(m.signal),function(e,t){return C.apply(this,arguments)}(e,_.signal).catch((function(e){!0===(null==_?void 0:_.isUsed())&&pe.isCancellationError(e)||(m.cancel(),t.error(e))}))}),{clearSignal:m.signal,emitCurrentValue:!0});function C(){return(C=d(g().mark((function e(n,i){var a,o,l,d;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=gr(p,h,n,s,r),e.t0=a.type,e.next="continue"===e.t0?4:"needs-reload"===e.t0?5:"flush-buffer"===e.t0||"clean-buffer"===e.t0?6:20;break;case 4:return e.abrupt("break",21);case 5:return e.abrupt("return",u((function(){r.listen((function(){if(!i.isCancelled()){var e=L.getCurrent().DELTA_POSITION_AFTER_RELOAD.bitrateSwitch;return t.waitingMediaSourceReload({bufferType:h.type,period:p,timeOffset:e,stayInPeriod:!0})}}),{includeLastObservation:!0,clearSignal:i})})));case 6:o=yr(a.value);case 7:if((l=o()).done){e.next=15;break}return d=l.value,e.next=11,s.removeBuffer(d.start,d.end);case 11:if(!i.isCancelled()){e.next=13;break}return e.abrupt("return");case 13:e.next=7;break;case 15:if("flush-buffer"!==a.type){e.next=19;break}if(t.needsBufferFlush(),!i.isCancelled()){e.next=19;break}return e.abrupt("return");case 19:return e.abrupt("break",21);case 20:ve();case 21:M(i);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function M(e){var n=new pe;n.linkToSignal(e);var r=A.getValue().representation;if(null!==r){var i=new oe(null,n.signal);A.onUpdate((function(e){if(null!==e.representation&&e.representation.id!==r.id)return e.urgent?(B.info("Stream: urgent Representation switch",h.type),i.setValue({urgent:!0})):(B.info("Stream: slow Representation switch",h.type),i.setValue({urgent:!1}))}),{clearSignal:n.signal,emitCurrentValue:!0});var a={type:h.type,adaptation:h,period:p,representation:r};if(S.setValue(r),!m.isUsed()&&(t.representationChange(a),!m.isUsed())){var o={streamStatusUpdate:t.streamStatusUpdate,encryptionDataEncountered:t.encryptionDataEncountered,manifestMightBeOufOfSync:t.manifestMightBeOufOfSync,needsManifestRefresh:t.needsManifestRefresh,inbandEvent:t.inbandEvent,warning:t.warning,error:function(e){m.cancel(),t.error(e)},addedSegment:function(e){I.addedSegment(e)},terminating:function(){if(!n.isUsed())return n.cancel(),M(e)}};D(r,i,o,e)}}}function D(e,n,i,o){var u=new pe;u.linkToSignal(o);var l=ae(c,(function(t){return t*function(e){var t=b.get(e.id),n=void 0!==t?t:1;void 0===t&&b.set(e.id,n);return n}(e)}),u.signal),d="video"===h.type?f:new oe(1/0);B.info("Stream: changing representation",h.type,e.id,e.bitrate);var g=P({},i,{error:function(t){var r,a=Xe(t,{defaultCode:"NONE",defaultReason:"Unknown `RepresentationStream` error"});if("BUFFER_FULL_ERROR"!==a.code)i.error(t);else{var s=c.getValue(),u=.7*(null!==(r=b.get(e.id))&&void 0!==r?r:1);if(u<=.05||s*u<=2)throw a;b.set(e.id,u),qt(4e3,m.signal).then((function(){return D(e,n,i,o)})).catch(U)}},terminating:function(){u.cancel(),i.terminating()}});fr({playbackObserver:r,content:{representation:e,adaptation:h,period:p,manifest:v},segmentSink:s,segmentFetcher:R,terminate:n,options:{bufferGoal:l,maxBufferSize:d,drmSystemId:a.drmSystemId,fastSwitchThreshold:x}},g,o),v.addEventListener("manifestUpdate",(function(n){for(var r,i=yr(n.updatedPeriods);!(r=i()).done;){var a=r.value;if(a.period.id===p.id)for(var s,u=yr(a.result.updatedAdaptations);!(s=u()).done;){var l=s.value;if(l.adaptation===h.id)for(var d,c=yr(l.removedRepresentations);!(d=c()).done;){if(d.value===e.id){if(o.isCancelled())return;return t.waitingMediaSourceReload({bufferType:h.type,period:p,timeOffset:0,stayInPeriod:!0})}}}else if(a.period.start>p.start)break}}),o)}};function Sr(e,t,n){if("function"==typeof String.prototype.startsWith)return e.startsWith(t,n);var r="number"==typeof n?Math.max(n,0):0;return e.substring(r,r+t.length)===t}var Er=function(e,t){var n=e.split(";"),r=n[0],i=n.slice(1),a=t.split(";"),o=a[0],s=a.slice(1);if(r!==o)return!1;var u=Se(i,(function(e){return Sr(e,"codecs=")})),l=Se(s,(function(e){return Sr(e,"codecs=")}));if(void 0===u||void 0===l)return!1;var d=u.substring(7),c=l.substring(7);return d.split(".")[0]===c.split(".")[0]};function Tr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return kr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return kr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function kr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function wr(e,t,n,r,i,a){var o,s,u,l;if(void 0!==e.codec&&"reload"===a.onCodecSwitch&&!function(e,t){return e.representations.some((function(e){return!0===e.isSupported&&!1!==e.decipherable&&Er(e.getMimeTypeString(),t)}))}(n,e.codec))return{type:"needs-reload",value:void 0};for(var d,c=e.getLastKnownInventory(),f=[],v=Tr(c);!(d=v()).done;){var p=d.value;p.infos.period.id===t.id&&p.infos.adaptation.id!==n.id&&Z(f,{start:null!==(o=p.bufferedStart)&&void 0!==o?o:p.start,end:null!==(s=p.bufferedEnd)&&void 0!==s?s:p.end})}for(var h,m=Tr(e.getPendingOperations());!(h=m()).done;){var g=h.value;if(g.type===Ln.Push){var y=g.value.inventoryInfos;if(y.period.id===t.id&&y.adaptation.id!==n.id){var _=y.segment.time;Z(f,{start:_,end:_+y.segment.duration})}}}if(0===f.length)return{type:"continue",value:void 0};if("reload"===r){var b=i.getReadyState();if(void 0===b||b>1)return{type:"needs-reload",value:void 0}}var S="direct"===r,E=[],T=vr(c,t);if(null!==T&&(void 0===T.bufferedEnd||t.start-T.bufferedEnd<1)&&E.push({start:0,end:t.start+1}),!S){var k=n.type,w=L.getCurrent().ADAP_REP_SWITCH_BUFFER_PADDINGS,A=null!==(u=w[k].before)&&void 0!==u?u:0,I=null!==(l=w[k].after)&&void 0!==l?l:0,R=i.getCurrentTime();if(void 0===R)R=i.getReference().getValue().position.getPolled();E.push({start:R-A,end:R+I})}if(void 0!==t.end){var x=pr(c,t);null!==x&&(void 0===x.bufferedStart||x.bufferedStart-t.end<1)&&E.push({start:t.end-1,end:Number.MAX_VALUE})}var C=ee(f,E);return 0===C.length?{type:"continue",value:void 0}:S&&"text"!==n.type?{type:"flush-buffer",value:C}:{type:"clean-buffer",value:C}}function Ar(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ir(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ir(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ir(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Rr(e,t,n){var r=e.getStatus(t);if("initialized"===r.type)return B.info("Stream: Reusing a previous SegmentSink for the type",t),r.value;var i=function(e){var t=e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable}));if(0===t.length){throw new qe("NO_PLAYABLE_REPRESENTATION","No Representation in the chosen "+e.type+" Adaptation can be played",{tracks:[ht(e)]})}return t[0].getMimeTypeString()}(n);return e.createSegmentSink(t,i)}function xr(e,t,n,r,i,a){var o=r.period,s=!1;function u(){var r=e.getReference().getValue(),a=t.getValue(),u=r.position.getWanted();void 0!==o.end&&u+a>=o.end&&(B.debug('Stream: full "empty" AdaptationStream',n),s=!0),i.streamStatusUpdate({period:o,bufferType:n,imminentDiscontinuity:null,position:u,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}t.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),e.listen(u,{includeLastObservation:!1,clearSignal:a}),u()}var Cr=function(e,t,n){var r=e.bufferType,i=e.content,a=e.garbageCollectors,o=e.playbackObserver,s=e.representationEstimator,l=e.segmentFetcherCreator,c=e.segmentSinksStore,f=e.options,v=e.wantedBufferAhead,p=e.maxVideoBufferSize,h=i.manifest,m=i.period,y=new oe(void 0,n);if(t.periodStreamReady({type:r,manifest:h,period:m,adaptationRef:y}),!n.isCancelled()){var _,b=!0;y.onUpdate((function(e){d(g().mark((function i(){var s,u,l,d,p,y,T,k,w,A,I,R,x,C,M,P,D,N;return g().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(void 0!==e){i.next=2;break}return i.abrupt("return");case 2:if((u=new pe).linkToSignal(n),null==_||_.cancel(),_=u,null!==e){i.next=34;break}if(B.info("Stream: Set no "+r+" Adaptation. P:",m.start),"initialized"!==(l=c.getStatus(r)).type){i.next=26;break}if(B.info("Stream: Clearing previous "+r+" SegmentSink"),!qn.isNative(r)){i.next=15;break}return i.abrupt("return",E(0,!0,u.signal));case 15:if(d=null!==(s=m.end)&&void 0!==s?s:1/0,!(m.start>d)){i.next=20;break}B.warn("Stream: Can't free buffer: period's start is after its end"),i.next=24;break;case 20:return i.next=22,l.value.removeBuffer(m.start,d);case 22:if(!u.isUsed()){i.next=24;break}return i.abrupt("return");case 24:i.next=30;break;case 26:if("uninitialized"!==l.type){i.next=30;break}if(c.disableSegmentSink(r),!u.isUsed()){i.next=30;break}return i.abrupt("return");case 30:if(t.adaptationChange({type:r,adaptation:null,period:m}),!u.isUsed()){i.next=33;break}return i.abrupt("return");case 33:return i.abrupt("return",xr(o,v,r,{period:m},t,u.signal));case 34:if(p=m.adaptations[r],void 0!==(y=Se(null!=p?p:[],(function(t){return t.id===e.adaptationId})))){i.next=40;break}return _.cancel(),B.warn("Stream: Unfound chosen Adaptation choice",e.adaptationId),i.abrupt("return");case 40:if(T=L.getCurrent(),k=T.DELTA_POSITION_AFTER_RELOAD,w=!1,!b){i.next=46;break}A=0,i.next=60;break;case 46:if(void 0===e.relativeResumingPosition){i.next=50;break}A=e.relativeResumingPosition,i.next=60;break;case 50:w=!0,i.t0=r,i.next="audio"===i.t0?54:"video"===i.t0?56:58;break;case 54:return A=k.trackSwitch.audio,i.abrupt("break",60);case 56:return A=k.trackSwitch.video,i.abrupt("break",60);case 58:return A=k.trackSwitch.other,i.abrupt("break",60);case 60:if(b=!1,!qn.isNative(r)||"disabled"!==c.getStatus(r).type){i.next=63;break}return i.abrupt("return",E(A,!0,u.signal));case 63:if(h.addEventListener("manifestUpdate",(function(e){for(var t,n=Ar(e.updatedPeriods);!(t=n()).done;){var r=t.value;if(r.period.id===m.id)for(var i,a=Ar(r.result.removedAdaptations);!(i=a()).done;){if(i.value.id===y.id)return E(A,!0,u.signal)}else if(r.period.start>m.start)break}}),_.signal),I=e.representations,B.info("Stream: Updating "+r+" adaptation","A: "+y.id,"P: "+m.start),t.adaptationChange({type:r,adaptation:y,period:m}),!u.isUsed()){i.next=69;break}return i.abrupt("return");case 69:if(R=Rr(c,r,y),"needs-reload"!==(x=wr(R,m,y,e.switchingMode,o,f)).type){i.next=73;break}return i.abrupt("return",E(A,!0,u.signal));case 73:return i.next=75,c.waitForUsableBuffers(u.signal);case 75:if(!u.isUsed()){i.next=77;break}return i.abrupt("return");case 77:if("flush-buffer"!==x.type&&"clean-buffer"!==x.type){i.next=91;break}C=Ar(x.value);case 79:if((M=C()).done){i.next=87;break}return P=M.value,D=P.start,N=P.end,i.next=83,R.removeBuffer(D,N);case 83:if(!u.isUsed()){i.next=85;break}return i.abrupt("return");case 85:i.next=79;break;case 87:if("flush-buffer"!==x.type){i.next=91;break}if(t.needsBufferFlush({relativeResumingPosition:A,relativePosHasBeenDefaulted:w}),!u.isUsed()){i.next=91;break}return i.abrupt("return");case 91:a.get(R)(u.signal),S(y,I,R,u.signal);case 93:case"end":return i.stop()}}),i)})))().catch((function(e){e instanceof me||(null==_||_.cancel(),t.error(e))}))}),{clearSignal:n,emitCurrentValue:!0})}function S(e,n,i,a){var u,d,g=(u=o,d=e.type,u.deriveReadOnlyObserver((function(e,t){var n=new oe(r(),t);return e.onUpdate(i,{clearSignal:t,emitCurrentValue:!1}),n;function r(){var t=e.getValue(),n=t.buffered[d],r=null!==n?X(n,t.position.getWanted()):0;return P({},t,{bufferGap:r,buffered:n})}function i(){n.setValue(r())}})));br({content:{manifest:h,period:m,adaptation:e,representations:n},options:f,playbackObserver:g,representationEstimator:s,segmentSink:i,segmentFetcherCreator:l,wantedBufferAhead:v,maxVideoBufferSize:p},Object.assign(Object.assign({},t),{error:function(e){if(!qn.isNative(r)){B.error("Stream: "+r+" Stream crashed. Aborting it.",e instanceof Error?e:""),c.disposeSegmentSink(r);var n=Xe(e,{defaultCode:"NONE",defaultReason:"Unknown `AdaptationStream` error"});if(t.warning(n),a.isCancelled())return;return xr(o,v,r,{period:m},t,a)}B.error("Stream: "+r+" Stream crashed. Stopping playback.",e instanceof Error?e:""),t.error(e)}}),a)}function E(e,n,i){u((function(){o.listen((function(){i.isCancelled()||t.waitingMediaSourceReload({bufferType:r,period:m,timeOffset:e,stayInPeriod:n})}),{includeLastObservation:!0,clearSignal:i})}))}};function Mr(e,t){if(0===t.length)return[];for(var n,r=[],i=e.getLastKnownInventory(),a=function(){var e=i[o];if(t.some((function(t){return e.infos.period.id===t.period.id&&e.infos.adaptation.id===t.adaptation.id&&e.infos.representation.id===t.representation.id}))){var n=e.bufferedStart,a=e.bufferedEnd;if(void 0===n||void 0===a)return B.warn("SO: No buffered start or end found from a segment."),{v:[{start:0,end:Number.MAX_VALUE}]};var s=r[r.length-1];void 0!==s&&s.end===n?s.end=a:r.push({start:n,end:a})}},o=0;o<i.length;o++)if(n=a())return n.v;return r}function Pr(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Dr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Dr(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Dr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Nr(e,t){if(0===t.length)return!1;var n=e.position.getPolled();return e.speed>=0?t[t.length-1].end>=n-5:t[0].start<=n+5}var Or=function(e,n,r,i,a,o,s,l){for(var c,f=e.manifest,v=e.initialPeriod,p=o.maxBufferAhead,h=o.maxBufferBehind,m=o.wantedBufferAhead,y=o.maxVideoBufferSize,_=L.getCurrent(),b=_.MINIMUM_MAX_BUFFER_AHEAD,S=_.MAXIMUM_MAX_BUFFER_AHEAD,E=_.MAXIMUM_MAX_BUFFER_BEHIND,T=new Yn((function(e){var t,r,i=e.bufferType,a=null!==(t=E[i])&&void 0!==t?t:1/0,o=null!==(r=S[i])&&void 0!==r?r:1/0;return function(t){Qn({segmentSink:e,playbackObserver:n,maxBufferBehind:ae(h,(function(e){return Math.min(e,a)}),t),maxBufferAhead:ae(p,(function(e){var t,n=Math.max(e,null!==(t=b[i])&&void 0!==t?t:0);return Math.min(n,o)}),t)},t)}})),k=Pr(i.getBufferTypes());!(c=k()).done;){w(c.value,v)}function w(e,r){var a=new mn((function(e,t){return e.start-t.start})),o=!1,c=new pe;return c.linkToSignal(l),n.listen((function(n){var r,i=n.position.getWanted();if(o&&function(e){var n=a.head(),r=a.last();if(void 0===n||void 0===r)return!0;return n.start>e||(t(r.end)?1/0:r.end)<e}(i)){for(B.info("Stream: Destroying all PeriodStreams due to out of bounds situation",e,i),o=!1;a.length()>0;){var u=a.get(a.length()-1);a.removeElement(u),s.periodStreamCleared({type:e,manifest:f,period:u})}c.cancel(),(c=new pe).linkToSignal(l);var d=null!==(r=f.getPeriodForTime(i))&&void 0!==r?r:f.getNextPeriod(i);if(void 0===d)return B.warn("Stream: The wanted position is not found in the Manifest."),void(o=!0);v(d)}}),{clearSignal:l,includeLastObservation:!0}),f.addEventListener("decipherabilityUpdate",(function(e){l.isCancelled()||function(e){return p.apply(this,arguments)}(e).catch((function(e){l.isCancelled()||(c.cancel(),s.error(e))}))}),l),v(r);function v(t){var n=Object.assign(Object.assign({},s),{waitingMediaSourceReload:function(e){var t=a.head();void 0===t||t.id!==e.period.id?s.lockedStream({bufferType:e.bufferType,period:e.period}):s.needsMediaSourceReload({timeOffset:e.timeOffset,minimumPosition:e.stayInPeriod?e.period.start:void 0,maximumPosition:e.stayInPeriod?e.period.end:void 0})},periodStreamReady:function(e){o=!0,a.add(e.period),s.periodStreamReady(e)},periodStreamCleared:function(e){a.removeElement(e.period),s.periodStreamCleared(e)},error:function(e){c.cancel(),s.error(e)}});A(e,t,n,c.signal)}function p(){return p=d(g().mark((function t(r){var d,p,h,m,y,_,b,S,E,T,k,w,A;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(d=i.getStatus(e),0!==(p=r.filter((function(t){return t.adaptation.type===e}))).length&&"initialized"===d.type&&!p.every((function(e){return!0===e.representation.decipherable}))){t.next=4;break}return t.abrupt("return");case 4:for(h=d.value,m=p.filter((function(e){return void 0===e.representation.decipherable})),y=p.filter((function(e){return!1===e.representation.decipherable})),_=Mr(h,y),b=Mr(h,m),o=!1,B.info("Stream: Destroying all PeriodStreams for decipherability matters",e);a.length()>0;)S=a.get(a.length()-1),a.removeElement(S),s.periodStreamCleared({type:e,manifest:f,period:S});c.cancel(),(c=new pe).linkToSignal(l),E=0,T=[].concat(_,b);case 16:if(!(E<T.length)){t.next=28;break}if(k=T[E],w=k.start,A=k.end,!l.isCancelled()){t.next=20;break}return t.abrupt("return");case 20:if(!(w<A)){t.next=25;break}if(!l.isCancelled()){t.next=23;break}return t.abrupt("return");case 23:return t.next=25,h.removeBuffer(w,A);case 25:E++,t.next=16;break;case 28:u((function(){if(!l.isCancelled()){var e=n.getReference().getValue();if(Nr(e,_)){if(s.needsDecipherabilityFlush(),l.isCancelled())return}else if(Nr(e,b)&&(s.needsBufferFlush(),l.isCancelled()))return;var t=e.position.getWanted(),r=f.getPeriodForTime(t);void 0!==r?v(r):s.error(new qe("MEDIA_TIME_NOT_FOUND","The wanted position is not found in the Manifest."))}}));case 29:case"end":return t.stop()}}),t)}))),p.apply(this,arguments)}}function A(e,t,l,d){B.info("Stream: Creating new Stream for",e,t.start);var c=null,v=new pe;v.linkToSignal(d),n.listen((function(n,r){var i=n.position;if(void 0!==t.end&&i.getWanted()>=t.end){var a=f.getPeriodAfter(t);if(t.containsTime(i.getWanted(),a))return;B.info("Stream: Destroying PeriodStream as the current playhead moved above it",e,t.start,i.getWanted(),t.end),r(),l.periodStreamCleared({type:e,manifest:f,period:t}),v.cancel()}}),{clearSignal:d,includeLastObservation:!0});var p,h={bufferType:e,content:{manifest:f,period:t},garbageCollectors:T,maxVideoBufferSize:y,segmentFetcherCreator:a,segmentSinksStore:i,options:o,playbackObserver:n,representationEstimator:r,wantedBufferAhead:m},g=Object.assign(Object.assign({},l),{streamStatusUpdate:function(n){if(n.hasFinishedLoading){var r=f.getPeriodAfter(t);null!==r&&function(t){if(null!==c){if(c.period.id===t.id)return;B.warn("Stream: Creating next `PeriodStream` while one was already created.",e,t.id,c.period.id),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel()}var n=new pe;n.linkToSignal(d),c={canceller:n,period:t},A(e,t,l,c.canceller.signal)}(r)}else null!==c&&(B.info("Stream: Destroying next PeriodStream due to current one being active",e,c.period.start),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel(),c=null);l.streamStatusUpdate(n)},error:function(e){null!==c&&(c.canceller.cancel(),c=null),v.cancel(),l.error(e)}});Cr(h,g,v.signal),p=v.signal,f.addEventListener("manifestUpdate",(function(n){for(var r,i=Pr(n.removedPeriods);!(r=i()).done;){var a=r.value;if(a.id===t.id){if(f.periods.length>0&&f.periods[0].start<=a.start)return u((function(){if(!p.isCancelled())return s.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})}))}else if(a.start>t.start)break}if(n.addedPeriods.length>0&&null!==c){var o=f.getPeriodAfter(t);null!==o&&c.period.id===o.id||(B.warn("Stream: Destroying next PeriodStream due to new one being added",e,c.period.start),l.periodStreamCleared({type:e,manifest:f,period:c.period}),c.canceller.cancel(),c=null)}}),p)}},Lr=Or,Ur={createSync:function(e){return{syncValue:e,getValueAsAsync:function(){return Promise.resolve(e)}}},createAsync:function(e){var t=null;return e.then((function(e){t=e}),U),{syncValue:t,getValueAsAsync:function(){return e}}}},Fr=new WeakMap,Br={setState:function(e,t){Fr.set(e,t)},getState:function(e){var t=Fr.get(e);return void 0===t?null:t},clearState:function(e){Fr.set(e,null)}};function zr(e){var t=Br.getState(e);return null===t?null:[t.mediaKeySystemAccess.keySystem,t.mediaKeySystemAccess.getConfiguration()]}var Vr=function(e){function t(){return e.apply(this,arguments)||this}return f(t,e),t}(i);function Kr(e,t){var n={audio:null,video:null,text:null};if(null!==t&&(n.text=t.getBufferedRanges()),null===e)return n;var r=Se(e.sourceBuffers,(function(e){return"audio"===e.type})),i=Se(e.sourceBuffers,(function(e){return"video"===e.type})),a=null==r?void 0:r.getBuffered();void 0!==a&&(n.audio=a);var o=null==i?void 0:i.getBuffered();return void 0!==o&&(n.video=o),n}function Wr(e,t,n){var r=t.autoPlay,i=t.initialPlayPerformed,a=t.manifest,o=t.mediaSource,s=t.speed,u=t.textDisplayer;return e.deriveReadOnlyObserver((function(e,t){var l=new pe;l.linkToSignal(t),l.linkToSignal(n);var d=new oe(c(),l.signal);return s.onUpdate(f,{clearSignal:l.signal,emitCurrentValue:!1}),e.onUpdate(f,{clearSignal:l.signal,emitCurrentValue:!1}),d;function c(){var t=e.getValue(),n=s.getValue();return function(e,t){if(!t.isDynamic||t.isLastPeriodKnown){var n=t.periods[t.periods.length-1];if(void 0!==n&&void 0!==n.end){var r=e.position.getWanted();if(r>=n.start&&r>=n.end-1){var i=e.buffered;(0===i.length||i.end(i.length-1)<e.duration-1)&&e.position.forceWantedPosition(n.end-1)}}}}(t,a),{maximumPosition:at(a),bufferGap:t.bufferGap,position:t.position,buffered:Kr(o,u),duration:t.duration,rebuffering:t.rebuffering,freezing:t.freezing,paused:{last:t.paused,pending:Gr(i,r)},readyState:t.readyState,speed:n}}function f(){d.setValue(c())}}))}function Gr(e,t){return e.getValue()?void 0:!t}function Hr(e){var n=e.textTracks;if(!t(n)){for(var r=0;r<n.length;r++)n[r].mode="disabled";if(e.hasChildNodes())for(var i=e.childNodes,a=i.length-1;a>=0;a--)if("track"===i[a].nodeName)try{e.removeChild(i[a])}catch(e){B.warn("Compat: Could not remove text track child from element.")}}e.src="",e.removeAttribute("src")}var jr=s,qr=void 0===jr?void 0:t(jr.MediaSource)?t(jr.MozMediaSource)?t(jr.WebKitMediaSource)?jr.MSMediaSource:jr.WebKitMediaSource:jr.MozMediaSource:jr.MediaSource;var Yr=["","webkit","moz","ms"];function Qr(e,t){return t.filter((function(t){return function(e,t){var n=document.createElement(e.tagName),r="on"+t;return r in n||(n.setAttribute(r,"return;"),"function"==typeof n[r])}(e,t)}))[0]}function $r(e,t){var n,r=function(e,t){return e.reduce((function(e,n){return e.concat((void 0===t?Yr:t).map((function(e){return e+n})))}),[])}(e,t);return function(e,t,i){if(!i.isCancelled()){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement){if(void 0===n&&(n=Qr(e,r)),!mt(n))return void 0;e.addEventListener(n,t),i.register((function(){void 0!==n&&e.removeEventListener(n,t)}))}r.forEach((function(n){var r=!1;"function"==typeof e.addEventListener?e.addEventListener(n,t):(r=!0,e["on"+n]=t),i.register((function(){"function"==typeof e.removeEventListener&&e.removeEventListener(n,t),r&&delete e["on"+n]}))}))}}}function Xr(e,n){var r,i=function(e){var n,r=document;t(r.hidden)?t(r.mozHidden)?t(r.msHidden)?t(r.webkitHidden)||(n="webkit"):n="ms":n="moz":n="";var i=mt(n)?n+"Hidden":"hidden",a=mt(n)?n+"visibilitychange":"visibilitychange",o=document[i],s=new oe(!o,e);return fi(document,a,(function(){var e=!document[i];s.setValueIfChanged(e)}),e),s}(n),a=new oe(!0,n);return n.register((function(){clearTimeout(r),r=void 0})),i.onUpdate(o,{clearSignal:n}),e.onUpdate(o,{clearSignal:n}),o(),a;function o(){if(clearTimeout(r),r=void 0,e.getValue().isEnabled||i.getValue())a.setValueIfChanged(!0);else{var t=L.getCurrent().INACTIVITY_DELAY;r=setTimeout((function(){a.setValueIfChanged(!1)}),t)}}}function Zr(e){var n,r,i=t(s.devicePixelRatio)||0===s.devicePixelRatio?1:s.devicePixelRatio,a=new oe({width:null===(n=s.screen)||void 0===n?void 0:n.width,height:null===(r=s.screen)||void 0===r?void 0:r.height,pixelRatio:i},e),o=setInterval((function(){var e=a.getValue();e.width===screen.width&&e.height===screen.height&&e.pixelRatio===i||a.setValue({width:screen.width,height:screen.height,pixelRatio:i})}),2e4);return e.register((function(){clearInterval(o)})),a}function Jr(e,n,r){var i=t(s.devicePixelRatio)||0===s.devicePixelRatio?1:s.devicePixelRatio,a=new oe({width:e.clientWidth,height:e.clientHeight,pixelRatio:i},r),o=U;n.onUpdate(l,{clearSignal:r}),fi(s,"resize",l,r),fi(e,"enterpictureinpicture",l,r),fi(e,"leavepictureinpicture",l,r);var u=setInterval(l,2e4);return l(),r.register((function(){o(),clearInterval(u)})),a;function l(){o();var r=n.getValue(),s=r.pipWindow;if(r.isEnabled)if(t(s)){var u=a.getValue();void 0===u.width&&void 0===u.height&&u.pixelRatio===i||a.setValue({width:void 0,height:void 0,pixelRatio:i})}else{var l=function(){c()};s.addEventListener("resize",l),o=function(){s.removeEventListener("resize",l),o=U},c()}else{var d=a.getValue();d.width===e.clientWidth&&d.height===e.clientHeight&&d.pixelRatio===i||a.setValue({width:e.clientWidth,height:e.clientHeight,pixelRatio:i})}function c(){var e=a.getValue();e.width===(null==s?void 0:s.width)&&e.height===(null==s?void 0:s.height)&&e.pixelRatio===i||a.setValue({width:null==s?void 0:s.width,height:null==s?void 0:s.height,pixelRatio:i})}}}$r(["loadedmetadata"]),$r(["timeupdate"]),$r(["addtrack"]),$r(["removetrack"]);var ei=$r(["sourceopen","webkitsourceopen"]),ti=$r(["sourceclose","webkitsourceclose"]),ni=$r(["sourceended","webkitsourceended"]),ri=$r(["update"]),ii=$r(["removesourcebuffer"]),ai=$r(["keymessage","message"]),oi=$r(["keyadded","ready"]),si=$r(["keyerror","error"]),ui=$r(["keystatuseschange"]),li=$r(["seeking"]),di=$r(["seeked"]),ci=$r(["ended"]);function fi(e,t,n,r){e.addEventListener(t,n),r.register((function(){e.removeEventListener(t,n)}))}function vi(){for(var e,t=arguments.length,n=-1,r=0;++n<t;)r+="number"==typeof(e=n<0||arguments.length<=n?void 0:arguments[n])?e:e.length;var i=new Uint8Array(r),a=0;for(n=-1;++n<t;)"number"==typeof(e=n<0||arguments.length<=n?void 0:arguments[n])?a+=e:e.length>0&&(i.set(e,a),a+=e.length);return i}function pi(e,t){return(e[t+0]<<8)+(e[t+1]|0)}function hi(e,t){return 65536*e[t+0]+256*e[t+1]+e[t+2]}function mi(e,t){return 16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3]}function gi(e,t){return 4294967296*(16777216*e[t+0]+65536*e[t+1]+256*e[t+2]+e[t+3])+16777216*e[t+4]+65536*e[t+5]+256*e[t+6]+e[t+7]}function yi(e){return new Uint8Array([e>>>8&255,255&e])}function _i(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}function bi(e){var t=e%4294967296,n=(e-t)/4294967296;return new Uint8Array([n>>>24&255,n>>>16&255,n>>>8&255,255&n,t>>>24&255,t>>>16&255,t>>>8&255,255&t])}function Si(e){return new Uint8Array([255&e,e>>>8&255,e>>>16&255,e>>>24&255])}function Ei(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ti(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ti(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ti(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ki(e,t){if(B.debug("Init: Trying to call endOfStream"),"open"===e.readyState){var n=e.sourceBuffers,r=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];r.updating&&t.push(r)}return t}(n);if(0===r.length)return B.info("Init: Triggering end of stream"),void e.endOfStream();B.debug("Init: Waiting SourceBuffers to be updated before calling endOfStream.");var i=new pe;i.linkToSignal(t);for(var a,o=Ei(r);!(a=o()).done;){var s=a.value;ri(s,(function(){i.cancel(),ki(e,t)}),i.signal)}ii(n,(function(){i.cancel(),ki(e,t)}),i.signal)}else B.debug("Init: MediaSource not open, cancel endOfStream")}var wi=31536e3,Ai=function(){function e(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}var t=e.prototype;return t.updateDuration=function(e,t){null!==this._currentMediaSourceDurationUpdateCanceller&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new pe;var n=this._mediaSource,r=this._currentMediaSourceDurationUpdateCanceller.signal,i=function(e,t){var n=new oe("open"===e.readyState,t);return ei(e,(function(){B.debug("Init: Reacting to MediaSource open in duration updater"),n.setValueIfChanged(!0)}),t),ni(e,(function(){B.debug("Init: Reacting to MediaSource ended in duration updater"),n.setValueIfChanged(!1)}),t),ti(e,(function(){B.debug("Init: Reacting to MediaSource close in duration updater"),n.setValueIfChanged(!1)}),t),n}(n,r),a=new pe;a.linkToSignal(r),i.onUpdate((function(){if(a.cancel(),!i.getValue())return;(a=new pe).linkToSignal(r);var o=function(e,t){if(0===e.length){var n=new oe(!1);return n.finish(),n}var r=new oe(!1,t);o();for(var i=function(){var n=e[a];n.addEventListener("updatestart",o),n.addEventListener("update",o),t.register((function(){n.removeEventListener("updatestart",o),n.removeEventListener("update",o)}))},a=0;a<e.length;a++)i();return r;function o(){for(var t=0;t<e.length;t++){if(e[t].updating)return void r.setValueIfChanged(!0)}r.setValueIfChanged(!1)}}(n.sourceBuffers,a.signal),s=new pe;return s.linkToSignal(a.signal),o.onUpdate((function(r){s.cancel(),(s=new pe).linkToSignal(a.signal),r||Ri(n,e,t,s.signal)}),{clearSignal:a.signal,emitCurrentValue:!0})}),{emitCurrentValue:!0,clearSignal:r})},t.stopUpdating=function(){null!==this._currentMediaSourceDurationUpdateCanceller&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)},e}();function Ii(e,t,n){var r=t;n||(r=x?1/0:xi(t));for(var i=0,a=0;a<e.sourceBuffers.length;a++){var o=e.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===e.duration)return"success";if(i>r){if(i<e.duration)try{B.info("Init: Updating duration to what is currently buffered",i),e.duration=i}catch(e){return B.warn("Duration Updater: Can't update duration on the MediaSource.",e instanceof Error?e:""),"failed"}return"partial"}var u=e.duration;try{if(B.info("Init: Updating duration",r),e.duration=r,"open"===e.readyState&&!isFinite(r)){var l=xi(t);B.info("Init: calling `mediaSource.setLiveSeekableRange`",l),e.setLiveSeekableRange(0,l)}}catch(e){return B.warn("Duration Updater: Can't update duration on the MediaSource.",e instanceof Error?e:""),"failed"}var d=Math.abs(e.duration-r);return d>=.1?d<Math.abs(e.duration-u)?"partial":"failed":"success"}function Ri(e,t,n,r){if("success"!==Ii(e,t,n))var i=setTimeout((function(){a(),Ri(e,t,n,r)}),2e3),a=r.register((function(){clearTimeout(i)}))}function xi(e){return Math.max(Math.pow(2,32),e+wi)}function Ci(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Mi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Mi(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Mi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Pi=function(e){function n(n){var r;if((r=e.call(this)||this).id=n,r.sourceBuffers=[],r._canceller=new pe,t(qr))throw new qe("MEDIA_SOURCE_NOT_SUPPORTED","No MediaSource Object was found in the current browser.");B.info("Init: Creating MediaSource");var i=new qr;r.readyState=i.readyState;var a=i.handle;return r.handle=t(a)?{type:"media-source",value:i}:{type:"handle",value:a},r._mediaSource=i,r._durationUpdater=new Ai(i),r._endOfStreamCanceller=null,ei(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceOpen",null)}),r._canceller.signal),ni(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceEnded",null)}),r._canceller.signal),ti(i,(function(){r.readyState=i.readyState,r.trigger("mediaSourceClose",null)}),r._canceller.signal),r}f(n,e);var r=n.prototype;return r.addSourceBuffer=function(e,t){var n=this._mediaSource.addSourceBuffer(t),r=new Di(e,t,n);return this.sourceBuffers.push(r),r},r.setDuration=function(e,t){this._durationUpdater.updateDuration(e,t)},r.interruptDurationSetting=function(){this._durationUpdater.stopUpdating()},r.maintainEndOfStream=function(){var e,t,n;null===this._endOfStreamCanceller&&(this._endOfStreamCanceller=new pe,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),B.debug("Init: end-of-stream order received."),e=this._mediaSource,t=this._endOfStreamCanceller.signal,(n=new pe).linkToSignal(t),ei(e,(function(){B.debug("Init: MediaSource re-opened while end-of-stream is active"),n.cancel(),(n=new pe).linkToSignal(t),ki(e,n.signal)}),t),ki(e,n.signal))},r.stopEndOfStream=function(){null!==this._endOfStreamCanceller&&(B.debug("Init: resume-stream order received."),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)},r.dispose=function(){this.sourceBuffers.forEach((function(e){return e.dispose()})),this._canceller.cancel(),function(e){if("closed"!==e.readyState){for(var t=e.readyState,n=e.sourceBuffers,r=n.length-1;r>=0;r--){var i=n[r];try{if("open"===t){B.info("Init: Aborting SourceBuffer before removing");try{i.abort()}catch(e){}}B.info("Init: Removing SourceBuffer from mediaSource"),e.removeSourceBuffer(i)}catch(e){}}n.length>0&&B.info("Init: Not all SourceBuffers could have been removed.")}}(this._mediaSource)},n}(i),Di=function(){function e(e,t,n){var r=this;this.type=e,this.codec=t,this._canceller=new pe,this._sourceBuffer=n,this._operationQueue=[],this._currentOperations=[];var i=function(e){var t;t=e instanceof Error?e:e.error instanceof Error?e.error:new Error("Unknown SourceBuffer Error");var n=r._currentOperations;if(r._currentOperations=[],0===n.length)B.error("SBI: error for an unknown operation",t);else for(var i,a=new ir(t.name,t.message,"QuotaExceededError"===t.name),o=Ci(n);!(i=o()).done;){i.value.reject(a)}},a=function(){var e=r._currentOperations;r._currentOperations=[];try{for(var t,n=Ci(e);!(t=n()).done;){t.value.resolve(q(r._sourceBuffer.buffered))}}catch(t){for(var i,a=Ci(e);!(i=a()).done;){var o=i.value;t instanceof Error&&"InvalidStateError"===t.name?o.resolve([]):o.reject(t)}}r._performNextOperation()};n.addEventListener("error",i),n.addEventListener("updateend",a),this._canceller.signal.register((function(){n.removeEventListener("error",i),n.removeEventListener("updateend",a)}))}var t=e.prototype;return t.appendBuffer=function(){B.debug("SBI: receiving order to push data to the SourceBuffer",this.type);for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this._addToQueue({operationName:0,params:t})},t.remove=function(e,t){return B.debug("SBI: receiving order to remove data from the SourceBuffer",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})},t.getBuffered=function(){try{return q(this._sourceBuffer.buffered)}catch(e){return B.error("Failed to get buffered time range of SourceBuffer",this.type,e instanceof Error?e:null),[]}},t.abort=function(){try{this._sourceBuffer.abort()}catch(e){B.debug("Init: Failed to abort SourceBuffer:",e instanceof Error?e:null)}this._emptyCurrentQueue()},t.dispose=function(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()},t._emptyCurrentQueue=function(){var e=new me;this._currentOperations.length>0&&(this._currentOperations.forEach((function(t){t.reject(e)})),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach((function(t){t.reject(e)})),this._operationQueue=[])},t._addToQueue=function(e){var t=this;return new Promise((function(n,r){var i=0===t._operationQueue.length&&0===t._currentOperations.length,a=P({resolve:n,reject:r},e);t._operationQueue.push(a),i&&t._performNextOperation()}))},t._performNextOperation=function(){var e,t,n,r,i;if(0===this._currentOperations.length&&!this._sourceBuffer.updating){var a=this._operationQueue.shift();if(void 0!==a)if(0===a.operationName){this._currentOperations=[{operationName:0,resolve:a.resolve,reject:a.reject}];var o=a.params[0],s=a.params[1],u=o;if(this._operationQueue.length>0&&0===this._operationQueue[0].operationName){for(var l=[o instanceof ArrayBuffer?new Uint8Array(o):o instanceof Uint8Array?o:new Uint8Array(o.buffer)];0===(null===(e=this._operationQueue[0])||void 0===e?void 0:e.operationName);){var d=this._operationQueue[0],c=null!==(t=s.appendWindow)&&void 0!==t?t:[void 0,void 0],f=null!==(n=d.params[1].appendWindow)&&void 0!==n?n:[void 0,void 0],v=null!==(r=s.timestampOffset)&&void 0!==r?r:0,p=null!==(i=d.params[1].timestampOffset)&&void 0!==i?i:0;if(c[0]!==f[0]||c[1]!==f[1]||s.codec!==d.params[1].codec||v!==p)break;var h=d.params[0],m=void 0;m=h instanceof ArrayBuffer?new Uint8Array(h):h instanceof Uint8Array?h:new Uint8Array(h.buffer),l.push(m),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:d.resolve,reject:d.reject})}l.length>1&&(B.info("MMSI: Merging "+l.length+" segments together for perf",this.type),u=vi.apply(void 0,l))}try{this._appendBufferNow(u,s)}catch(e){var g=e instanceof Error?new ir(e.name,e.message,"QuotaExceededError"===e.name):new ir("Error","Unknown SourceBuffer Error during appendBuffer",!1);this._currentOperations.forEach((function(e){e.reject(g)})),this._currentOperations=[]}}else{this._currentOperations=[a];var y=a.params,_=y[0],b=y[1];B.debug("SBI: removing data from SourceBuffer",this.type,_,b);try{this._sourceBuffer.remove(_,b)}catch(e){var S=e instanceof Error?new ir(e.name,e.message,!1):new ir("Error","Unknown SourceBuffer Error during remove",!1);a.reject(S),this._currentOperations=[]}}}},t._appendBufferNow=function(e,t){var n=this._sourceBuffer,r=t.codec,i=t.timestampOffset,a=t.appendWindow,o=void 0===a?[]:a;if(void 0!==r&&r!==this.codec){B.debug("SBI: updating codec",r);var s=function(e,t){if("function"==typeof e.changeType){try{e.changeType(t)}catch(e){return B.warn("Could not call 'changeType' on the given SourceBuffer:",e instanceof Error?e:""),!1}return!0}return!1}(n,r);s?this.codec=r:B.debug("SBI: could not update codec",r,this.codec)}if(void 0!==i&&n.timestampOffset!==i){var u=i;B.debug("SBI: updating timestampOffset",r,n.timestampOffset,u),n.timestampOffset=u}if(void 0===o[0])n.appendWindowStart>0&&(B.debug("SBI: re-setting `appendWindowStart` to `0`"),n.appendWindowStart=0);else if(o[0]!==n.appendWindowStart){if(o[0]>=n.appendWindowEnd){var l=o[0]+1;B.debug("SBI: pre-updating `appendWindowEnd`",l),n.appendWindowEnd=l}B.debug("SBI: setting `appendWindowStart`",o[0]),n.appendWindowStart=o[0]}void 0===o[1]?n.appendWindowEnd!==1/0&&(B.debug("SBI: re-setting `appendWindowEnd` to `Infinity`"),n.appendWindowEnd=1/0):o[1]!==n.appendWindowEnd&&(B.debug("SBI: setting `appendWindowEnd`",o[1]),n.appendWindowEnd=o[1]),B.debug("SBI: pushing segment",this.type),n.appendBuffer(e)},e}();var Ni=Ze();function Oi(e,t){if(null!==t&&e.src===t&&(B.info("Init: Clearing HTMLMediaElement's src"),Hr(e)),null!==t)try{B.debug("Init: Revoking previous URL"),URL.revokeObjectURL(t)}catch(e){B.warn("Init: Error while revoking the media source URL",e instanceof Error?e:"")}}function Li(e,t){return jt(t,(function(n){var r=function(e,t){Oi(e,mt(e.src)?e.src:null);var n=new Pi(Ni());return t.register((function(){n.dispose()})),n}(e,t);if(r.addEventListener("mediaSourceOpen",(function(){B.info("Init: MediaSource opened"),n(r)}),t),B.info("MTCI: Attaching MediaSource URL to the media element"),"handle"===r.handle.type)e.srcObject=r.handle.value,t.register((function(){Oi(e,null)}));else{var i=URL.createObjectURL(r.handle.value);e.src=i,t.register((function(){Oi(e,i)}))}}))}function Ui(e,n,r){var i;if(!t(r)){var a=rt(e),o=at(e);if(!t(r.position))return B.debug("Init: using startAt.minimumPosition"),Math.max(Math.min(r.position,o),a);if(!t(r.wallClockTime)){B.debug("Init: using startAt.wallClockTime");var s=void 0===e.availabilityStartTime?0:e.availabilityStartTime,u=r.wallClockTime-s;return Math.max(Math.min(u,o),a)}if(!t(r.fromFirstPosition)){B.debug("Init: using startAt.fromFirstPosition");var l=r.fromFirstPosition;return l<=0?a:Math.min(o,a+l)}if(!t(r.fromLastPosition)){B.debug("Init: using startAt.fromLastPosition");var d=r.fromLastPosition;return d>=0?o:Math.max(a,o+d)}if(!t(r.fromLivePosition)){B.debug("Init: using startAt.fromLivePosition");var c=null!==(i=it(e))&&void 0!==i?i:o,f=r.fromLivePosition;return f>=0?c:Math.max(a,c+f)}if(!t(r.percentage)){B.debug("Init: using startAt.percentage");var v=r.percentage;return v>100?o:v<0?a:a+(o-a)*(+v/100)}}var p=rt(e);if(e.isLive){var h,m=e.suggestedPresentationDelay,g=e.clockOffset,y=at(e),_=L.getCurrent().DEFAULT_LIVE_GAP;if(void 0===g)B.info("Init: no clock offset found for a live content, starting close to maximum available position"),h=y;else{B.info("Init: clock offset found for a live content, checking if we can start close to it");var b=void 0===e.availabilityStartTime?0:e.availabilityStartTime,S=(ye()+g)/1e3-b;h=Math.min(y,S)}var E=null!=m?m:n?_.LOW_LATENCY:_.DEFAULT;return B.debug("Init: "+h+" defined as the live time, applying a live gap of "+E),Math.max(h-E,p)}return B.info("Init: starting at the minimum available position:",p),p}function Fi(){return k}function Bi(e,t,n,r){var i=new pe;i.linkToSignal(r);var a=new oe(!1,i.signal);return e.listen((function(e){if(null===e.rebuffering&&null===e.freezing&&0!==e.readyState){if(!function(e,t){return!e||!T||t}(n,t.hasAttribute("playsinline"))){if(isNaN(t.duration))return;if(t.duration>0)return a.setValue(!0),void i.cancel()}var r=x?4:3;return e.readyState>=r&&(null!==e.currentRange||e.ended)&&(!Fi()||t.duration>0)?(a.setValue(!0),void i.cancel()):void 0}}),{includeLastObservation:!0,clearSignal:i.signal}),a}var zi,Vi=!T;function Ki(e,t){var n=e.mediaElement,r=e.playbackObserver,i=e.startTime,a=e.mustAutoPlay,o=e.isDirectfile,s=e.onWarning,u=new oe(!1,t),l=new Promise((function(e,l){var d=t.register((function(e){l(e)}));if(!t.isCancelled()){var c=!1,f=function(e){r.setCurrentTime(e),c=!0};if(o&&"number"!=typeof i)r.listen((function(e,t){if(e.readyState>=1){t();var n="number"==typeof i?i:i();0!==n&&(Vi?f(n):setTimeout((function(){f(n)}),0)),p()}}),{includeLastObservation:!0,clearSignal:t});else{var v="number"==typeof i?i:i();0!==v&&f(v),p()}}function p(){var i=!1;r.listen((function(o,f){if(i||0===o.seeking||(i=!0),(!c||i)&&0!==o.readyState){if(f(),Fi()&&0===n.duration){var v=new qe("MEDIA_ERR_NOT_LOADED_METADATA","Cannot load automatically: your browser falsely announced having loaded the content.");s(v)}t.isCancelled()||r.listen((function(r,i){0===r.seeking&&null===r.rebuffering&&r.readyState>=1&&(i(),function(){var r,i;if(B.info("Init: Can begin to play content"),!a)return n.autoplay&&B.warn("Init: autoplay is enabled on HTML media element. Media will play as soon as possible."),u.setValue(!0),u.finish(),d(),e({type:"skipped"});if(n.ended)return B.warn("Init: autoplay is enabled but the video is ended. Skipping autoplay to prevent video to start again"),u.setValue(!0),u.finish(),d(),e({type:"skipped"});try{i=null!==(r=n.play())&&void 0!==r?r:Promise.resolve()}catch(e){return d(),l(e)}i.then((function(){if(!t.isCancelled())return u.setValue(!0),u.finish(),d(),e({type:"autoplay"})})).catch((function(n){if(d(),!t.isCancelled()){if(n instanceof Error&&"NotAllowedError"===n.name){B.warn("Init: Media element can't play. It may be due to browser auto-play policies.");var r=new qe("MEDIA_ERR_BLOCKED_AUTOPLAY","Cannot trigger auto-play automatically: your browser does not allow it.");if(s(r),t.isCancelled())return;return e({type:"autoplay-blocked"})}l(n)}}))}())}),{includeLastObservation:!0,clearSignal:t})}}),{includeLastObservation:!0,clearSignal:t})}}));return{autoPlayResult:l,initialPlayPerformed:u}}function Wi(e,t,n,r,i){if(0===t.length)return l("No `keySystems` option given.");if(null===Et.decrypt)return l("EME feature not activated.");var a=new pe;a.linkToSignal(i);var o=new oe({initializationState:{type:"uninitialized",value:null},drmSystemId:void 0},i),s=Et.decrypt;if(!s.hasEmeApis())return l("EME API not available on the current page.");B.debug("Init: Creating ContentDecryptor");var u=new s(e,t);return u.addEventListener("stateChange",(function(e){if(e===zi.WaitingForAttachment){var t=new oe(!1);t.onUpdate((function(t,n){t&&(n(),e===zi.WaitingForAttachment&&u.attach())}),{clearSignal:a.signal}),o.setValue({initializationState:{type:"awaiting-media-link",value:{isMediaLinked:t}},drmSystemId:u.systemId})}else e===zi.ReadyForContent&&(o.setValue({initializationState:{type:"initialized",value:null},drmSystemId:u.systemId}),u.removeEventListener("stateChange"))})),u.addEventListener("error",(function(e){a.cancel(),r.onError(e)})),u.addEventListener("warning",(function(e){r.onWarning(e)})),u.addEventListener("blackListProtectionData",(function(e){r.onBlackListProtectionData(e)})),u.addEventListener("keyIdsCompatibilityUpdate",(function(e){r.onKeyIdsCompatibilityUpdate(e)})),n.onUpdate((function(e){null!==e&&u.onInitializationData(e)}),{clearSignal:a.signal}),a.signal.register((function(){u.dispose()})),o;function l(e){n.onUpdate((function(t,n){if(null!==t){n();var i=new je("MEDIA_IS_ENCRYPTED_ERROR",e);r.onError(i)}}),{clearSignal:i});var t=new oe({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return t.finish(),t}}!function(e){e[e.Initializing=0]="Initializing",e[e.WaitingForAttachment=1]="WaitingForAttachment",e[e.ReadyForContent=2]="ReadyForContent",e[e.Error=3]="Error",e[e.Disposed=4]="Disposed"}(zi||(zi={}));var Gi=function(){function e(e){this._displayer=e}var t=e.prototype;return t.pushTextData=function(e){try{return Promise.resolve(this._displayer.pushTextData(e))}catch(e){return Promise.reject(e)}},t.remove=function(e,t){try{return Promise.resolve(this._displayer.removeBuffer(e,t))}catch(e){return Promise.reject(e)}},t.reset=function(){this._displayer.reset()},t.stop=function(){this._displayer.stop()},e}(),Hi=1/60,ji=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._playbackObserver=t,i._manifest=n,i._speed=r,i._discontinuitiesStore=[],i._isStarted=!1,i._canceller=new pe,i}f(t,e);var n=t.prototype;return n.start=function(){var e=this;if(!this._isStarted){this._isStarted=!0;var t=new Qi(this._playbackObserver,this._speed);this._canceller.signal.register((function(){t.dispose()}));var n=null;this._playbackObserver.listen((function(r){var i,a=e._discontinuitiesStore,o=r.buffered,s=r.position,u=r.readyState,l=r.rebuffering,d=r.freezing,c=L.getCurrent(),f=c.BUFFER_DISCONTINUITY_THRESHOLD,v=c.FREEZING_STALLED_DELAY,p=c.UNFREEZING_SEEK_DELAY,h=c.UNFREEZING_DELTA_POSITION;if(null!==d){var m=ye(),g=null===n?d.timestamp:n.attemptTimestamp;if(!s.isAwaitingFuturePosition()&&m-g>p&&(B.warn("Init: trying to seek to un-freeze player"),e._playbackObserver.setCurrentTime(e._playbackObserver.getCurrentTime()+h),n={attemptTimestamp:m}),m-d.timestamp>v)return null===l?t.stopRebuffering():t.startRebuffering(),void e.trigger("stalled","freezing")}else n=null;if(null===l)return t.stopRebuffering(),1===u?(i=0!==r.seeking?1===r.seeking?"internal-seek":"seeking":"not-ready",void e.trigger("stalled",i)):void e.trigger("unstalled",null);var y="seeking"===l.reason&&1===r.seeking?"internal-seek":l.reason;if(s.isAwaitingFuturePosition())return t.stopRebuffering(),B.debug("Init: let rebuffering happen as we're awaiting a future position"),void e.trigger("stalled",y);if(t.startRebuffering(),null!==e._manifest){var _=l.position;if(null!=_&&e._speed.getValue()>0){var b=function(e,t,n){if(0===e.length)return null;for(var r=null,i=0;i<e.length;i++){var a=e[i].period;if(a.start>n)return r;var o=void 0;if(void 0===a.end||a.end>n){var s=e[i],u=s.discontinuity,l=s.position,d=u.start,c=u.end;if(n>=(null!=d?d:l)-Hi)if(null===c){var f=st(t,a);null!==f?o=f.start+Hi:B.warn("Init: discontinuity at Period's end but no next Period")}else n<c+Hi&&(o=c+Hi);void 0!==o&&(B.info("Init: discontinuity found",n,o),r=null!==r&&r>o?r:o)}}return r}(a,e._manifest,_);if(null!==b){var S=b+.001;if(!(S<=e._playbackObserver.getCurrentTime()))return B.warn("SA: skippable discontinuity found in the stream",s.getPolled(),S),e._playbackObserver.setCurrentTime(S),void e.trigger("warning",Yi(_,S));B.info("Init: position to seek already reached, no seeking",e._playbackObserver.getCurrentTime(),S)}}var E=null!=_?_:s.getPolled(),T=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e.start(r);if(t<i)return i-t}return 1/0}(o,E);if(e._speed.getValue()>0&&T<f){var k=E+T+Hi;if(e._playbackObserver.getCurrentTime()<k)return B.warn("Init: discontinuity encountered inferior to the threshold",E,k,f),e._playbackObserver.setCurrentTime(k),void e.trigger("warning",Yi(E,k))}for(var w=e._manifest.periods.length-2;w>=0;w--){var A=e._manifest.periods[w];if(void 0!==A.end&&A.end<=E){if(e._manifest.periods[w+1].start>E&&e._manifest.periods[w+1].start>e._playbackObserver.getCurrentTime()){var I=e._manifest.periods[w+1];return e._playbackObserver.setCurrentTime(I.start),void e.trigger("warning",Yi(E,I.start))}break}}e.trigger("stalled",y)}else e.trigger("stalled",y)}),{includeLastObservation:!0,clearSignal:this._canceller.signal})}},n.updateDiscontinuityInfo=function(e){this._isStarted||this.start();var t=this._playbackObserver.getReference().getValue();!function(e,t,n){var r=Math.min(n.position.getPolled(),n.position.getWanted());for(;e.length>0&&void 0!==e[0].period.end&&e[0].period.end+10<r;)e.shift();var i=t.period,a=t.bufferType;if("audio"!==a&&"video"!==a)return;for(var o=0;o<e.length;o++)if(e[o].period.id===i.id){if(e[o].bufferType===a)return void(qi(t)?e[o]=t:e.splice(o,1))}else if(e[o].period.start>i.start)return void(qi(t)&&e.splice(o,0,t));qi(t)&&e.push(t)}(this._discontinuitiesStore,e,t)},n.onLockedStream=function(e,t){var n;this._isStarted||this.start();var r=this._playbackObserver.getReference().getValue();if(!(!r.rebuffering||r.paused||this._speed.getValue()<=0||"audio"!==e&&"video"!==e)){var i=r.position.getWanted(),a=null!==(n=r.rebuffering.position)&&void 0!==n?n:i,o=t.start;i<o&&Math.abs(a-o)<1&&(B.warn("Init: rebuffering because of a future locked stream.\nTrying to unlock by seeking to the next Period"),this._playbackObserver.setCurrentTime(o+.001))}},n.destroy=function(){this._canceller.cancel()},t}(i);function qi(e){return null!==e.discontinuity}function Yi(e,t){return new qe("DISCONTINUITY_ENCOUNTERED","A discontinuity has been encountered at position "+String(e)+", seeked at position "+String(t))}var Qi=function(){function e(e,t){this._speedUpdateCanceller=new pe,this._isRebuffering=!1,this._playbackObserver=e,this._isDisposed=!1,this._speed=t,this._updateSpeed()}var t=e.prototype;return t.startRebuffering=function(){this._isRebuffering||this._isDisposed||(this._isRebuffering=!0,this._speedUpdateCanceller.cancel(),B.info("Init: Pause playback to build buffer"),this._playbackObserver.setPlaybackRate(0))},t.stopRebuffering=function(){this._isRebuffering&&!this._isDisposed&&(this._isRebuffering=!1,this._speedUpdateCanceller=new pe,this._updateSpeed())},t.dispose=function(){this._speedUpdateCanceller.cancel(),this._isDisposed=!0},t._updateSpeed=function(){var e=this;this._speed.onUpdate((function(t){B.info("Init: Resume playback speed",t),e._playbackObserver.setPlaybackRate(t)}),{clearSignal:this._speedUpdateCanceller.signal,emitCurrentValue:!0})},e}();var $i=function(e,t){return e.id===t.id&&e.start===t.start&&e.end===t.end};var Xi=function(e,t){for(var n=[],r=t.periods,i=0;i<r.length;i++){r[i].streamEvents.forEach((function(t){for(var r,i=t.start,a=t.end,o=t.id,s=t.data,u=0;u<e.length;u++){var l=e[u];if($i(l,{id:o,start:i,end:a}))return void n.push(l)}if(void 0!==s.value.element)r=s.value.element;else{if(void 0===s.value.xmlData)return;var d=s.value.xmlData.namespaces.reduce((function(e,t){return e+"xmlns:"+t.key+'="'+t.value+'" '}),"<toremove ");d+=">";var c=(new DOMParser).parseFromString(d+s.value.xmlData.data+"</toremove>","application/xml").documentElement;r=c.children.length>0?c.children[0]:c.childNodes[0]}var f={type:s.type,value:Object.assign(Object.assign({},s.value),{element:r})};if(void 0===a){var v={start:i,id:o,data:f,publicEvent:{start:i,data:f}};n.push(v)}else{var p={start:i,end:a,id:o,data:f,publicEvent:{start:i,end:a,data:f}};n.push(p)}}))}return n};function Zi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ji(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ji(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ji(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ea=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._manifest=t,i._mediaElement=n,i._playbackObserver=r,i._canceller=null,i._scheduledEventsRef=new oe([]),i._eventsBeingPlayed=new WeakMap,i}f(t,e);var n=t.prototype;return n.start=function(){var e=this;if(null===this._canceller){this._canceller=new pe;var t=this._canceller.signal,n=this._playbackObserver,r=this._mediaElement,i=!1,a=new pe;a.linkToSignal(t),this._scheduledEventsRef.setValue(Xi([],this._manifest)),this._scheduledEventsRef.onUpdate((function(o){if(0!==o.length){if(!i){i=!0;var s=c(),u=function(){var t=c();e._emitStreamEvents(e._scheduledEventsRef.getValue(),s,t,a.signal),s=t},l=L.getCurrent().STREAM_EVENT_EMITTER_POLL_INTERVAL,d=setInterval(u,l);n.listen(u,{includeLastObservation:!1,clearSignal:a.signal}),a.signal.register((function(){clearInterval(d)}))}}else i&&(a.cancel(),(a=new pe).linkToSignal(t),i=!1);function c(){var e=n.getReference().getValue();return{currentTime:r.currentTime,isSeeking:0!==e.seeking}}}),{emitCurrentValue:!0,clearSignal:t})}},n.onManifestUpdate=function(e){var t=this._scheduledEventsRef.getValue();this._scheduledEventsRef.setValue(Xi(t,e))},n.stop=function(){null!==this._canceller&&(this._canceller.cancel(),this._canceller=null)},n._emitStreamEvents=function(e,t,n,r){for(var i=t.currentTime,a=n.isSeeking,o=n.currentTime,s=[],u=[],l=0;l<e.length;l++){var d=e[l],c=d.start,f=ta(d)?d.end:void 0;this._eventsBeingPlayed.has(d)?(c>o||void 0!==f&&o>=f)&&(ta(d)&&u.push(d.publicEvent),this._eventsBeingPlayed.delete(d)):c<=o&&void 0!==f&&o<f?(s.push({type:"stream-event",value:d.publicEvent}),this._eventsBeingPlayed.set(d,!0)):i<c&&o>=(null!=f?f:c)&&(a?s.push({type:"stream-event-skip",value:d.publicEvent}):(s.push({type:"stream-event",value:d.publicEvent}),ta(d)&&u.push(d.publicEvent)))}if(s.length>0)for(var v,p=Zi(s);!(v=p()).done;){var h=v.value;if("stream-event"===h.type?this.trigger("event",h.value):this.trigger("eventSkip",h.value),r.isCancelled())return}if(u.length>0)for(var m,g=Zi(u);!(m=g()).done;){var y=m.value;if("function"==typeof y.onExit&&y.onExit(),r.isCancelled())return}},t}(i);function ta(e){return void 0!==e.end}var na=ea;function ra(e,n,r){function i(){var r,i,a=e.error;switch(t(a)||(r=a.code,i=a.message),r){case 1:return n(new qe("MEDIA_ERR_ABORTED",i=null!=i?i:"The fetching of the associated resource was aborted by the user's request."));case 2:return n(new qe("MEDIA_ERR_NETWORK",i=null!=i?i:"A network error occurred which prevented the media from being successfully fetched"));case 3:return n(new qe("MEDIA_ERR_DECODE",i=null!=i?i:"An error occurred while trying to decode the media resource"));case 4:return n(new qe("MEDIA_ERR_SRC_NOT_SUPPORTED",i=null!=i?i:"The media resource has been found to be unsuitable."));default:return n(new qe("MEDIA_ERR_UNKNOWN",i=null!=i?i:"The HTMLMediaElement errored due to an unknown reason."))}}r.isCancelled()||(e.addEventListener("error",i),r.register((function(){e.removeEventListener("error",i)})))}function ia(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return aa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return aa(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function aa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var oa=function(e){function t(t){var n;(n=e.call(this)||this)._settings=t,n._initCanceller=new pe,n._manifest=null;var r=void 0===t.url?void 0:[t.url];return n._manifestFetcher=new nn(r,t.transport,t.manifestRequestSettings),n}f(t,e);var n=t.prototype;return n.prepare=function(){var e=this;null===this._manifest&&(this._manifest=Ur.createAsync(jt(this._initCanceller.signal,(function(t,n){e._manifestFetcher.addEventListener("warning",(function(t){return e.trigger("warning",t)})),e._manifestFetcher.addEventListener("error",(function(t){e.trigger("error",t),n(t)})),e._manifestFetcher.addEventListener("manifestReady",(function(e){t(e)}))}))),this._manifestFetcher.start(),this._initCanceller.signal.register((function(){e._manifestFetcher.dispose()})))},n.start=function(e,t){var n=this;this.prepare(),ra(e,(function(e){return n._onFatalError(e)}),this._initCanceller.signal);var r=new oe(null,this._initCanceller.signal);this._initializeMediaSourceAndDecryption(e,r).then((function(i){return n._onInitialMediaSourceReady(e,i.mediaSource,t,i.drmSystemId,r,i.unlinkMediaSource)})).catch((function(e){n._onFatalError(e)}))},n.updateContentUrls=function(e,t){this._manifestFetcher.updateContentUrls(e,t)},n.dispose=function(){this._initCanceller.cancel()},n._onFatalError=function(e){this._initCanceller.isUsed()||(this._initCanceller.cancel(),this.trigger("error",e))},n._initializeMediaSourceAndDecryption=function(e,t){var n=this,r=this._initCanceller;return jt(r.signal,(function(i){var a=n._settings.keySystems,o=Wi(e,a,t,{onWarning:function(e){return n.trigger("warning",e)},onError:function(e){return n._onFatalError(e)},onBlackListProtectionData:function(e){d(g().mark((function t(){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==n._manifest){t.next=2;break}return t.abrupt("return");case 2:if(null===(r=n._manifest.syncValue)||void 0===r){t.next=6;break}t.t0=r,t.next=9;break;case 6:return t.next=8,n._manifest.getValueAsAsync();case 8:t.t0=t.sent;case 9:ua(t.t0,e);case 11:case"end":return t.stop()}}),t)})))().catch(U)},onKeyIdsCompatibilityUpdate:function(e){d(g().mark((function t(){var r;return g().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==n._manifest){t.next=2;break}return t.abrupt("return");case 2:if(null===(r=n._manifest.syncValue)||void 0===r){t.next=6;break}t.t0=r,t.next=9;break;case 6:return t.next=8,n._manifest.getValueAsAsync();case 8:t.t0=t.sent;case 9:sa(t.t0,e.whitelistedKeyIds,e.blacklistedKeyIds,e.delistedKeyIds);case 11:case"end":return t.stop()}}),t)})))().catch(U)}},r.signal);o.onUpdate((function(t,a){if("uninitialized"!==t.initializationState.type){a();var s=new pe;s.linkToSignal(r.signal),Li(e,s.signal).then((function(e){var n=o.getValue();if("awaiting-media-link"===n.initializationState.type)n.initializationState.value.isMediaLinked.setValue(!0),o.onUpdate((function(t,n){if("initialized"===t.initializationState.type)return n(),void i({mediaSource:e,drmSystemId:t.drmSystemId,unlinkMediaSource:s})}),{emitCurrentValue:!0,clearSignal:r.signal});else if("initialized"===t.initializationState.type)return void i({mediaSource:e,drmSystemId:t.drmSystemId,unlinkMediaSource:s})})).catch((function(e){s.isUsed()||n._onFatalError(e)}))}}),{emitCurrentValue:!0,clearSignal:r.signal})}))},n._onInitialMediaSourceReady=function(){var e=d(g().mark((function e(t,n,r,i,a,o){var s,u,l,d,c,f,v,p,h,m,y,_,b,S,E,T,k,w,A,I,R,x=this;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(R=function(e,n,i,o){w({mediaElement:t,playbackObserver:r,mediaSource:e,initialTime:n,autoPlay:i,manifest:b,representationEstimator:E,segmentFetcherCreator:k,speed:p,protectionRef:a,bufferOptions:T},(function(e){if(o.cancel(),_.isUsed())return;if(A("reloadingMediaSource",e),_.isUsed())return;var n=new pe;n.linkToSignal(_.signal),Li(t,n.signal).then((function(t){R(t,e.position,e.autoPlay,n)})).catch((function(e){n.isUsed()||I(e)}))}),o.signal)},u=this._settings,l=u.adaptiveOptions,d=u.autoPlay,c=u.bufferOptions,f=u.lowLatencyMode,v=u.segmentRequestOptions,p=u.speed,h=u.startAt,m=u.textTrackOptions,y=u.transport,_=this._initCanceller,fe(this._manifest),e.prev=4,null===(s=this._manifest.syncValue)||void 0===s){e.next=9;break}e.t0=s,e.next=12;break;case 9:return e.next=11,this._manifest.getValueAsAsync();case 11:e.t0=e.sent;case 12:b=e.t0,e.next=18;break;case 15:return e.prev=15,e.t1=e.catch(4),e.abrupt("return");case 18:if(b.addEventListener("manifestUpdate",(function(e){x.trigger("manifestUpdate",e)}),_.signal),b.addEventListener("decipherabilityUpdate",(function(e){x.trigger("decipherabilityUpdate",e)}),_.signal),B.debug("Init: Calculating initial time"),S=Ui(b,f,h),B.debug("Init: Initial time calculated:",S),E=Be(l),T=P({textTrackOptions:m,drmSystemId:i},c),k=new hn(y,v,_.signal),this.trigger("manifestReady",b),!_.isUsed()){e.next=29;break}return e.abrupt("return");case 29:w=this._startBufferingOnMediaSource.bind(this),A=this.trigger.bind(this),I=this._onFatalError.bind(this),R(n,S,d,o);case 33:case"end":return e.stop()}}),e,this,[[4,15]])})));return function(t,n,r,i,a,o){return e.apply(this,arguments)}}(),n._startBufferingOnMediaSource=function(e,t,n){var r,i=this,a=e.autoPlay,o=e.bufferOptions,s=e.initialTime,u=e.manifest,l=e.mediaElement,d=e.mediaSource,c=e.playbackObserver,f=e.protectionRef,v=e.representationEstimator,p=e.segmentFetcherCreator,h=e.speed,m=null!==(r=u.getPeriodForTime(s))&&void 0!==r?r:u.getNextPeriod(s);if(void 0===m){var g=new qe("MEDIA_STARTING_TIME_NOT_FOUND","Wanted starting time not found in the Manifest.");return this._onFatalError(g)}var y=null,_=null;if("html"===this._settings.textTrackOptions.textTrackMode&&null!==Et.htmlTextDisplayer?_=new Et.htmlTextDisplayer(l,this._settings.textTrackOptions.textTrackElement):null!==Et.nativeTextDisplayer&&(_=new Et.nativeTextDisplayer(l)),null!==_){var b=new Gi(_);y=b,n.register((function(){b.stop(),null==_||_.stop()}))}var S=new qn(d,"VIDEO"===l.nodeName,y);n.register((function(){S.disposeAll()}));var E=Ki({mediaElement:l,playbackObserver:c,startTime:s,mustAutoPlay:a,onWarning:function(e){i.trigger("warning",e)},isDirectfile:!1},n),T=E.autoPlayResult,k=E.initialPlayPerformed;if(!n.isCancelled()){k.onUpdate((function(e,t){if(e){t();var r=new na(u,l,c);u.addEventListener("manifestUpdate",(function(){r.onManifestUpdate(u)}),n),r.addEventListener("event",(function(e){i.trigger("streamEvent",e)}),n),r.addEventListener("eventSkip",(function(e){i.trigger("streamEventSkip",e)}),n),r.start(),n.register((function(){r.stop()}))}}),{clearSignal:n,emitCurrentValue:!0});var w=Wr(c,{autoPlay:a,manifest:u,mediaSource:d,textDisplayer:_,initialPlayPerformed:k,speed:h},n),A=this._createRebufferingController(c,u,h,n),I=new wn(S);C&&u.addEventListener("decipherabilityUpdate",(function(e){e.some((function(e){return!0!==e.representation.decipherable}))&&M(0,void 0,void 0)}),n),c.listen((function(e){if(I.needToReload(e)){var n,r=c.getReference().getValue();n=r.position.isAwaitingFuturePosition()?r.position.getWanted():c.getCurrentTime();var i=k.getValue()?!c.getIsPaused():a;t({position:n,autoPlay:i})}}),{clearSignal:n}),w.listen((function(e){["video","audio","text"].forEach((function(t){var n,r=S.getStatus(t);"initialized"===r.type&&r.value.synchronizeInventory(null!==(n=e.buffered[t])&&void 0!==n?n:[])}))}),{clearSignal:n});var R=function(e,t,n,r,i,a){a.register((function(){t.interruptDurationSetting()}));var o=new _n(e,n,r.getBufferTypes());a.register((function(){o.dispose()})),o.addEventListener("warning",(function(e){return i.onWarning(e)})),o.addEventListener("periodChange",(function(e){return i.onPeriodChanged(e)})),o.addEventListener("endingPositionChange",(function(e){t.setDuration(e.endingPosition,e.isEnd)})),o.addEventListener("endOfStream",(function(){B.debug("Init: end-of-stream order received."),t.maintainEndOfStream()})),o.addEventListener("resumeStream",(function(){t.stopEndOfStream()}));var s=o.getCurrentEndingTime();return t.setDuration(s.endingPosition,s.isEnd),o}(u,d,w,S,{onWarning:function(e){return i.trigger("warning",e)},onPeriodChanged:function(e){return i.trigger("activePeriodChanged",{period:e})}},n);T.then((function(){Bi(c,l,!1,n).onUpdate((function(e,t){e&&(t(),i.trigger("loaded",{segmentSinksStore:S}))}),{emitCurrentValue:!0,clearSignal:n})})).catch((function(e){n.isCancelled()||i._onFatalError(e)}));var x=this;Lr({manifest:u,initialPeriod:m},w,v,S,p,o,{needsBufferFlush:function(e){var t,r,i=c.getCurrentTime(),a=null!==(t=null==e?void 0:e.relativeResumingPosition)&&void 0!==t?t:0,o=Boolean(null==e?void 0:e.relativePosHasBeenDefaulted);r=0===a&&o?i+.001:i+a,c.setCurrentTime(r),c.listen((function(e,t){(null!==e.currentRange||e.position.getPolled()>r+.1)&&(t(),c.setCurrentTime(e.position.getWanted()+.001))}),{includeLastObservation:!1,clearSignal:n})},streamStatusUpdate:function(e){var t=e.period,r=e.bufferType,i=e.imminentDiscontinuity,a=e.position;A.updateDiscontinuityInfo({period:t,bufferType:r,discontinuity:i,position:a}),n.isCancelled()||u.isLastPeriodKnown&&e.period.id===u.periods[u.periods.length-1].id&&(e.hasFinishedLoading||e.isEmptyStream?R.onLastSegmentFinishedLoading(e.bufferType):R.onLastSegmentLoadingResume(e.bufferType))},needsManifestRefresh:function(){return x._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync:function(){var e=L.getCurrent().OUT_OF_SYNC_MANIFEST_REFRESH_DELAY;x._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:e})},lockedStream:function(e){return A.onLockedStream(e.bufferType,e.period)},adaptationChange:function(e){x.trigger("adaptationChange",e),n.isCancelled()||R.onAdaptationChange(e.type,e.period,e.adaptation)},representationChange:function(e){x.trigger("representationChange",e),n.isCancelled()||R.onRepresentationChange(e.type,e.period)},inbandEvent:function(e){return x.trigger("inbandEvents",e)},warning:function(e){return x.trigger("warning",e)},periodStreamReady:function(e){return x.trigger("periodStreamReady",e)},periodStreamCleared:function(e){R.onPeriodCleared(e.type,e.period),n.isCancelled()||x.trigger("periodStreamCleared",e)},bitrateEstimateChange:function(e){return x.trigger("bitrateEstimateChange",e)},needsMediaSourceReload:function(e){M(e.timeOffset,e.minimumPosition,e.maximumPosition)},needsDecipherabilityFlush:function(){var e,n,r,i,a,o=zr(l);if(void 0===(a=null==o?void 0:o[0])||a.indexOf("widevine")<0){var s=w.getReference().getValue(),u=s.position.isAwaitingFuturePosition()?s.position.getWanted():null!==(e=w.getCurrentTime())&&void 0!==e?e:s.position.getPolled(),d=null!==(r=null!==(n=s.paused.pending)&&void 0!==n?n:w.getIsPaused())&&void 0!==r?r:s.paused.last;t({position:u,autoPlay:!d})}else{var f=w.getReference().getValue(),v=f.position.isAwaitingFuturePosition()?f.position.getWanted():null!==(i=w.getCurrentTime())&&void 0!==i?i:f.position.getPolled();v+.001<f.duration?c.setCurrentTime(l.currentTime+.001):c.setCurrentTime(v)}},encryptionDataEncountered:function(e){for(var t,r=ia(e);!(t=r()).done;){var i=t.value;if(f.setValue(i),n.isCancelled())return}},error:function(e){return x._onFatalError(e)}},n)}function M(e,n,r){var i,a,o,s=w.getReference().getValue(),u=s.position.isAwaitingFuturePosition()?s.position.getWanted():null!==(i=w.getCurrentTime())&&void 0!==i?i:s.position.getPolled(),l=null!==(o=null!==(a=s.paused.pending)&&void 0!==a?a:w.getIsPaused())&&void 0!==o?o:s.paused.last,d=u+e;void 0!==n&&(d=Math.max(n,d)),void 0!==r&&(d=Math.min(r,d)),t({position:d,autoPlay:!l})}},n._createRebufferingController=function(e,t,n,r){var i=this,a=new ji(e,t,n);return a.addEventListener("stalled",(function(e){return i.trigger("stalled",e)})),a.addEventListener("unstalled",(function(){return i.trigger("unstalled",null)})),a.addEventListener("warning",(function(e){return i.trigger("warning",e)})),r.register((function(){return a.destroy()})),a.start(),a},t}(Vr);function sa(e,t,n,r){e.updateRepresentationsDeciperability((function(e){var i=e.representation;if(void 0===i.contentProtections)return i.decipherable;var a=i.contentProtections.keyIds;if(void 0!==a)for(var o,s=ia(a);!(o=s()).done;){for(var u,l=o.value,d=ia(n);!(u=d()).done;){if(Tt(u.value,l.keyId))return!1}for(var c,f=ia(t);!(c=f()).done;){if(Tt(c.value,l.keyId))return!0}for(var v,p=ia(r);!(v=p()).done;){if(Tt(v.value,l.keyId))return}}return i.decipherable}))}function ua(e,t){e.updateRepresentationsDeciperability((function(e){var n,r,i=e.representation;if(!1===i.decipherable)return!1;for(var a,o,s=function(){var e=o.value;if((void 0===t.type||e.type===t.type)&&t.values.getFormattedValues().every((function(t){return e.values.some((function(e){return(void 0===t.systemId||e.systemId===t.systemId)&&Tt(e.data,t.data)}))})))return{v:!1}},u=ia(null!==(r=null===(n=i.contentProtections)||void 0===n?void 0:n.initData)&&void 0!==r?r:[]);!(o=u()).done;)if(a=s())return a.v;return i.decipherable}))}var la=new Map;var da=new(function(){function e(){this._cachedCodecSupport=new Map}return e.prototype.isSupported=function(e,n){var r=(null!=e?e:"")+';codecs="'+(null!=n?n:"")+'"',i=this._cachedCodecSupport.get(r);if(void 0!==i)return i;this._cachedCodecSupport.size>=50&&this._cachedCodecSupport.clear();var o=function(e){if(t(qr))return a&&B.error("Compat: Cannot request codec support in a worker without MSE."),!1;if("function"==typeof qr.isTypeSupported){var n=la.get(e);if(void 0!==n)return n;var r=qr.isTypeSupported(e);return la.size>=200&&la.clear(),la.set(e,r),r}return!0}(r);return this._cachedCodecSupport.set(r,o),o},e}());function ca(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return fa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fa(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function fa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function va(e,t){for(var n,r=e,i=ca(t);!(n=i()).done;){var a=pa(r,n.value);if(null===a)return null;r=a}return r}function pa(e,t){var n=ha(e,t);return null!==n?e.subarray(n[1],n[2]):null}function ha(e,t){for(var n,r,i=e.length,a=0,o=0;a+8<=i;){if(o=mi(e,r=a),n=mi(e,r+=4),r+=4,0===o)o=i-a;else if(1===o){if(r+8>i)return null;o=gi(e,r),r+=8}if(o<0)throw new Error("ISOBMFF: Size out of range");if(n===t)return 1970628964===t&&(r+=16),[a,r,a+o];a+=o}return null}function ma(e,t,n,r,i){for(var a,o=e.length,s=0;s<o;s+=a){var u=s;a=mi(e,u);var l=mi(e,u+=4);if(u+=4,0===a)a=o-s;else if(1===a){if(u+8>o)return;a=gi(e,u),u+=8}if(1970628964===l&&u+16<=o&&mi(e,u)===t&&mi(e,u+4)===n&&mi(e,u+8)===r&&mi(e,u+12)===i)return u+=16,e.subarray(u,s+a)}}function ga(e){var t=e.length;if(t<8)return B.warn("ISOBMFF: box inferior to 8 bytes, cannot find offsets"),null;var n=0,r=mi(e,n),i=mi(e,n+=4);if(n+=4,0===r)r=t;else if(1===r){if(n+8>t)return B.warn("ISOBMFF: box too short, cannot find offsets"),null;r=gi(e,n),n+=8}if(r<0)throw new Error("ISOBMFF: Size out of range");return 1970628964===i&&(n+=16),[0,n,r]}function ya(e){var t=pa(e,1836019558);return null===t?null:pa(t,1953653094)}function _a(e){var t=function(e,t){for(var n=[],r=e;;){var i=ha(r,t);if(null===i)return n;fe(0!==i[2]&&r.length),n.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}(e,1836019558);return t.reduce((function(e,t){var n=pa(t,1953653094);return null!==n&&e.push(n),e}),[])}function ba(e){return pa(e,1835295092)}function Sa(e,t){return void 0===t&&(t=0),pa(e.subarray(t),1701671783)}var Ea=/^(?:[a-z]+:)?\/\//i,Ta=/\/\.{1,2}\//;function ka(){var e=arguments.length;if(0===e)return"";for(var t="",n=0;n<e;n++){var r=n<0||arguments.length<=n?void 0:arguments[n];"string"==typeof r&&""!==r&&(Ea.test(r)?t=r:("/"===r[0]&&(r=r.substring(1)),"/"===t[t.length-1]&&(t=t.substring(0,t.length-1)),t=t+"/"+r))}return function(e){if(!Ta.test(e))return e;for(var t=[],n=e.split("/"),r=0,i=n.length;r<i;r++)if(".."===n[r])t.pop();else{if("."===n[r])continue;t.push(n[r])}return t.join("/")}(t)}function wa(e){var t=e.lastIndexOf("/");if(t<0)return e.length;if(Ea.test(e)){var n=e.indexOf("/");if(n>=0&&t===n+1)return e.length}var r=e.indexOf("?");return r>=0&&r<t?wa(e.substring(0,r)):t+1}var Aa="object"==typeof s&&"function"==typeof s.TextDecoder,Ia="object"==typeof s&&"function"==typeof s.TextEncoder;function Ra(e){if(Aa)try{return new TextDecoder("utf-16le").decode(e)}catch(e){var t=e instanceof Error?e:"";B.warn("Utils: could not use TextDecoder to parse UTF-16LE, fallbacking to another implementation",t)}for(var n="",r=0;r<e.length;r+=2)n+=String.fromCharCode((e[r+1]<<8)+e[r]);return n}function xa(e){if(Ia)try{return(new TextEncoder).encode(e)}catch(e){var t=e instanceof Error?e:"";B.warn("Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation",t)}var n,r=encodeURIComponent(e);if("function"==typeof unescape)n=unescape(r);else{var i=/[0-9a-fA-F]/,a=r.length;n="";for(var o=0;o<r.length;o++){var s=!1;if("%"===r[o])if(o<=a-6&&"u"===r[o+1]&&i.test(r[o+2])&&i.test(r[o+3])&&i.test(r[o+4])&&i.test(r[o+5])){var u=parseInt(r.substring(o+1,o+6),16);n+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(r[o+1])&&i.test(r[o+2])){var l=parseInt(r.substring(o+1,o+3),16);n+=String.fromCharCode(l),s=!0,o+=2}s||(n+=r[o])}}for(var d=new Uint8Array(n.length),c=0;c<n.length;c++)d[c]=255&n.charCodeAt(c);return d}function Ca(e,t){var n=e.toString(16);return n.length>=t?n:new Array(t-n.length+1).join("0")+n}function Ma(e){if(Aa)try{return(new TextDecoder).decode(e)}catch(e){var t=e instanceof Error?e:"";B.warn("Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation",t)}var n=e;239===n[0]&&187===n[1]&&191===n[2]&&(n=n.subarray(3));var r,i=function(e){for(var t="",n=0;n<e.length;n+=16e3){var r=e.subarray(n,n+16e3);t+=String.fromCharCode.apply(null,r)}return t}(n);if("function"==typeof escape)r=escape(i);else{var a=/[A-Za-z0-9*_\+-\.\/]/;r="";for(var o=0;o<i.length;o++)if(a.test(i[o]))r+=i[o];else{var s=i.charCodeAt(o);r+=s>=256?"%u"+Ca(s,4):"%"+Ca(s,2)}}return decodeURIComponent(r)}function Pa(e){for(var t=e.length,n=new Uint8Array(t/2),r=0,i=0;r<t;r+=2,i++)n[i]=255&parseInt(e.substring(r,r+2),16);return n}function Da(e,t){void 0===t&&(t="");for(var n="",r=0;r<e.byteLength;r++)n+=(e[r]>>>4).toString(16),n+=(15&e[r]).toString(16),t.length>0&&r<e.byteLength-1&&(n+=t);return n}function Na(e){fe(e.length);var t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=new Uint8Array(16);return l[0]=i,l[1]=r,l[2]=n,l[3]=t,l[4]=o,l[5]=a,l[6]=u,l[7]=s,l.set(e.subarray(8,16),8),l}function Oa(e,t){for(var n=t;n<e.length;){if(0===e[n])break;n+=1}return{end:n+1,string:Ma(e.subarray(t,n))}}var La=Math.pow(2,32)-1,Ua={};function Fa(e){if(void 0!==Ua[e])return Ua[e];var t=xa(e);return Ua[e]=t,t}function Ba(e,t){var n=t.length+8;return n<=La?vi(_i(n),Fa(e),t):vi(_i(1),Fa(e),bi(n+8),t)}function za(e,t){return Ba(e,vi.apply(void 0,t))}function Va(e){var t=[];e.periods.forEach((function(n){var r=n.id;if(Je(t,r)){B.warn("Two periods with the same ID found. Updating.");var i=r+"-dup";n.id=i,Va(e),t.push(i)}else t.push(r);var a=n.adaptations,o=[];Object.keys(a).forEach((function(t){var n=a[t];void 0!==n&&n.forEach((function(t){var n=t.id;if(Je(o,n)){B.warn("Two adaptations with the same ID found. Updating.",n);var r=n+"-dup";t.id=r,Va(e),o.push(r)}else o.push(n);var i=[];t.representations.forEach((function(t){var n=t.id;if(Je(i,n)){B.warn("Two representations with the same ID found. Updating.",n);var r=n+"-dup";t.id=r,Va(e),i.push(r)}else i.push(n)}))}))}))}))}var Ka=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],Wa=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function Ga(e){if(e>=Wa.length)throw new Error("Unable to parse base64 string.");var t=Wa[e];if(255===t)throw new Error("Unable to parse base64 string.");return t}function Ha(e){var t,n="",r=e.length;for(t=2;t<r;t+=3)n+=Ka[e[t-2]>>2],n+=Ka[(3&e[t-2])<<4|e[t-1]>>4],n+=Ka[(15&e[t-1])<<2|e[t]>>6],n+=Ka[63&e[t]];return t===r+1&&(n+=Ka[e[t-2]>>2],n+=Ka[(3&e[t-2])<<4],n+="=="),t===r&&(n+=Ka[e[t-2]>>2],n+=Ka[(3&e[t-2])<<4|e[t-1]>>4],n+=Ka[(15&e[t-1])<<2],n+="="),n}function ja(e){var t=e.length%4,n=e;0!==t&&(B.warn("base64ToBytes: base64 given miss padding"),n+=3===t?"=":2===t?"==":"===");var r=n.indexOf("=");if(-1!==r&&r<n.length-2)throw new Error("Unable to parse base64 string.");for(var i,a=n.endsWith("==")?2:n.endsWith("=")?1:0,o=n.length,s=new Uint8Array(o/4*3),u=0,l=0;u<o;u+=4,l+=3)i=Ga(n.charCodeAt(u))<<18|Ga(n.charCodeAt(u+1))<<12|Ga(n.charCodeAt(u+2))<<6|Ga(n.charCodeAt(u+3)),s[l]=i>>16,s[l+1]=i>>8&255,s[l+2]=255&i;return s.subarray(0,s.length-a)}function qa(e){return[{systemId:"edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",privateData:vi([8,1,18,16],e)}]}function Ya(e,t){if(void 0===t&&(t=qa),null===e.firstElementChild||"ProtectionHeader"!==e.firstElementChild.nodeName)throw new Error("Protection should have ProtectionHeader child");var n=e.firstElementChild,r=ja(null===n.textContent?"":n.textContent),i=Pa(function(e){var t,n,r=(0|(t=e)[0+(n=8)])+(t[n+1]<<8),i=Ra(e.subarray(10,r+10)),a=(new DOMParser).parseFromString(i,"application/xml").querySelector("KID");if(null===a)throw new Error("Cannot parse PlayReady private data: invalid XML");return Da(Na(ja(null===a.textContent?"":a.textContent))).toLowerCase()}(r)),a=n.getAttribute("SystemID");return{keyId:i,keySystems:[{systemId:(null!==a?a:"").toLowerCase().replace(/\{|\}/g,""),privateData:r}].concat(t(i))}}function Qa(e,n,r){var i,a=e.repeatCount;return a>=0?a:(i=t(n)?void 0!==r?r:Number.MAX_VALUE:n.start,Math.ceil((i-e.start)/e.duration)-1)}function $a(e,t,n){var r=e.start,i=e.duration;return i<=0?r:r+(Qa(e,t,n)+1)*i}function Xa(e,t){var n;return e*t.timescale+(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0)}function Za(e,t){var n;return(e-(null!==(n=t.indexTimeOffset)&&void 0!==n?n:0))/t.timescale}function Ja(e,t,n){var r=e.timeline,i=Xa(t,e);if(i<0)return null;var a=function(e,t){for(var n=0,r=e.length;n<r;){var i=n+r>>>1;e[i].start<=t?n=i+1:r=i}return n-1}(r,i);if(a<0||a>=r.length-1)return null;var o=r[a];if(o.duration<=0)return null;var s=r[a+1];if(void 0===s)return null;var u=s.start;return i>=$a(o,s,n)&&i<u?Za(u,e):null}function eo(e,t){return e.replace(/\{start time\}/g,String(t))}function to(e,t,n){var r=t-e;return r>0?Math.floor(r/n):0}function no(e,t){var n=e.repeatCount;if(void 0!==e.duration&&n<0){var r=void 0!==t?t.start:1/0;n=Math.ceil((r-e.start)/e.duration)-1}return n}var ro=function(){function e(e){var t=e.isLive,n=e.segmentPrivateInfos,r=e.media,i=e.sharedSmoothTimeline;if(this._sharedSmoothTimeline=i,this._initSegmentInfos={bitsPerSample:n.bitsPerSample,channels:n.channels,codecPrivateData:n.codecPrivateData,packetSize:n.packetSize,samplingRate:n.samplingRate,timescale:i.timescale,height:n.height,width:n.width,protection:n.protection},this._isLive=t,this._media=r,0!==i.timeline.length&&t){var a=i.timeline,o=i.validityTime,s=$a(a[a.length-1],null),u=o/1e3*i.timescale;this._scaledLiveGap=u-s}}var t=e.prototype;return t.getInitSegment=function(){return{id:"init",isInit:!0,privateInfos:{smoothInitSegment:this._initSegmentInfos},url:null,time:0,end:0,duration:0,timescale:1,complete:!0}},t.getSegments=function(e,t){this._refreshTimeline();for(var n,r=this._sharedSmoothTimeline,i=r.timescale,a=r.timeline,o=function(e,t,n){var r=void 0===e||0===e?1:e;return{up:t*r,to:(t+n)*r}}(i,e,t),s=o.up,u=o.to,l=this._media,d=[],c=a.length,f=void 0===this._scaledLiveGap?void 0:ye()/1e3*i-this._scaledLiveGap,v=0;v<c;v++){for(var p=a[v],h=p.duration,m=p.start,g=no(p,a[v+1]),y=to(m,s,h),_=m+y*h,b=h;_<u&&y<=g&&(void 0===f||_+b<=f);){var S=_,E=void 0!==n?n+y:void 0,T={id:String(_),isInit:!1,time:S/i,end:(S+h)/i,duration:h/i,timescale:1,number:E,url:eo(l,S),complete:!0,privateInfos:{smoothMediaSegment:{time:S,duration:h}}};d.push(T),_=m+ ++y*h}if(_>=u)return d;void 0!==n&&(n+=g+1)}return d},t.shouldRefresh=function(e,t){if(this._refreshTimeline(),!this._isLive)return!1;var n=this._sharedSmoothTimeline,r=n.timeline,i=n.timescale,a=r[r.length-1];if(void 0===a)return!1;var o=a.repeatCount,s=a.start+(o+1)*a.duration;return!(t*i<s)&&(e*i>=s||e*i>a.start+o*a.duration)},t.getFirstAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;return 0===t.length?null:t[0].start/n},t.getLastAvailablePosition=function(){this._refreshTimeline();var e=this._sharedSmoothTimeline,t=e.timeline,n=e.timescale;if(void 0===this._scaledLiveGap)return $a(t[t.length-1],null)/n;for(var r=t.length-1;r>=0;r--)for(var i=t[r],a=ye()/1e3*n,o=i.start,s=i.duration,u=i.repeatCount;u>=0;u--){var l=o+s*(u+1);if(l<=a-this._scaledLiveGap)return l/n}},t.getEnd=function(){if(!this._isLive)return this.getLastAvailablePosition()},t.awaitSegmentBetween=function(e,t){var n;if(fe(),this.isStillAwaitingFutureSegments())return!1;var r=this.getLastAvailablePosition();return!(void 0!==r&&t<r)&&(t>(null!==(n=this.getFirstAvailablePosition())&&void 0!==n?n:0)&&void 0)},t.checkDiscontinuity=function(e){return this._refreshTimeline(),Ja(this._sharedSmoothTimeline,e,void 0)},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline();for(var t=this._sharedSmoothTimeline,n=t.timeline,r=t.timescale,i=0;i<n.length;i++){var a=n[i],o=a.start/r;if(o>e.time)return!1;if(o===e.time)return!0;if(a.repeatCount>=0&&void 0!==a.duration){var s=(o-a.start)/a.duration-1;return s%1==0&&s<=a.repeatCount}}return!1},t.canBeOutOfSyncError=function(e){return!!this._isLive&&(e instanceof Ye&&(e.isHttpError(404)||e.isHttpError(412)))},t._replace=function(e){this._initialScaledLastPosition=e._initialScaledLastPosition,this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.replace(e._sharedSmoothTimeline)},t._update=function(e){this._scaledLiveGap=e._scaledLiveGap,this._sharedSmoothTimeline.update(e._sharedSmoothTimeline)},t.isStillAwaitingFutureSegments=function(){return this._isLive},t.isInitialized=function(){return!0},t.initialize=function(){B.error("A `SmoothRepresentationIndex` does not need to be initialized")},t.addPredictedSegments=function(e,t){this._sharedSmoothTimeline.addPredictedSegments(e,t)},t._refreshTimeline=function(){this._sharedSmoothTimeline.refresh()},e}();function io(e,t){for(var n=0;e.length>0;){var r=e[0];if(r.start>=t)return n;if(-1===r.repeatCount)return n;if(0===r.repeatCount)e.shift(),n+=1;else{var i=e[1];if(void 0!==i&&i.start<=t)e.shift(),n+=1;else{if(r.duration<=0)return n;for(var a=r.start+r.duration,o=1;a<t&&o<=r.repeatCount;)a+=r.duration,o++;if(!(o>r.repeatCount)){var s=r.repeatCount-o;return r.start=a,r.repeatCount=s,n+=o}e.shift(),n=r.repeatCount+1}}}return n}function ao(e,t){if(0===e.length)return e.push.apply(e,t),!0;if(0===t.length)return!1;var n=e.length,r=t[0].start;if($a(e[n-1],t[0])<r)throw new qe("MANIFEST_UPDATE_ERROR","Cannot perform partial update: not enough data");for(var i=n-1;i>=0;i--){var a=e[i].start;if(a===r){var o=n-i;return e.splice.apply(e,[i,o].concat(t)),!1}if(a<r){var s=e[i];if(s.start+s.duration>r)return B.warn("RepresentationIndex: Manifest update removed all previous segments"),e.splice.apply(e,[0,n].concat(t)),!0;if(void 0===s.repeatCount||s.repeatCount<=0)return s.repeatCount<0&&(s.repeatCount=Math.floor((r-s.start)/s.duration)-1),e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1;if(s.start+s.duration*(s.repeatCount+1)<=r)return e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1;var u=(r-s.start)/s.duration-1;if(u%1==0&&s.duration===t[0].duration){var l=t[0].repeatCount<0?-1:t[0].repeatCount+u+1;return e.splice.apply(e,[i,n-i].concat(t)),e[i].start=s.start,e[i].repeatCount=l,!1}return B.warn("RepresentationIndex: Manifest update removed previous segments"),e[i].repeatCount=Math.floor(u),e.splice.apply(e,[i+1,n-(i+1)].concat(t)),!1}}var d=e[e.length-1],c=t[t.length-1];return void 0!==d.repeatCount&&d.repeatCount<0?d.start>c.start?(B.warn("RepresentationIndex: The new index is older than the previous one"),!1):(B.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0):d.start+d.duration*(d.repeatCount+1)>=c.start+c.duration*(c.repeatCount+1)?(B.warn("RepresentationIndex: The new index is older than the previous one"),!1):(B.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,n].concat(t)),!0)}function oo(e,t,n,r){var i=e[e.length-1],a=n.timescale===t?{time:n.time,duration:n.duration}:{time:n.time/n.timescale*t,duration:n.duration/n.timescale*t};return!(r.time===a.time)&&(a.time>=$a(i,null)&&(i.duration===a.duration?i.repeatCount++:e.push({duration:a.duration,start:a.time,repeatCount:0}),!0))}var so=function(){function e(e){var t=e.timeline,n=e.timescale,r=e.timeShiftBufferDepth,i=e.manifestReceivedTime;this.timeline=t,this.timescale=n;var a=null!=i?i:ye();if(this.validityTime=a,this._timeShiftBufferDepth=r,0!==t.length){var o=$a(t[t.length-1],null);this._initialScaledLastPosition=o}}var t=e.prototype;return t.refresh=function(){if(void 0!==this._initialScaledLastPosition){var e=this._timeShiftBufferDepth,t=(ye()-this.validityTime)/1e3+this._initialScaledLastPosition/this.timescale;if(void 0!==e){var n=(t-e)*this.timescale;io(this.timeline,n)}}},t.replace=function(e){var t=this.timeline,n=e.timeline,r=this.timescale,i=e.timescale;if(this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime,0!==t.length&&0!==n.length&&r===i){var a=t[t.length-1],o=n[n.length-1],s=$a(o,null);if(!($a(a,null)<=s))for(var u=0;u<t.length;u++){var l=t[u],d=$a(l,null);if(d===s)return void(this.timeline=this.timeline.concat(t.slice(u+1)));if(d>s){if(l.duration!==o.duration)return;var c=s-l.start;if(0===c)return B.warn("Smooth Parser: a discontinuity detected in the previous manifest has been resolved."),void(this.timeline=this.timeline.concat(t.slice(u)));if(c<0||c%l.duration!=0)return;var f=c/l.duration-1,v=l.repeatCount-f;if(v<0)return;o.repeatCount+=v;var p=t.slice(u+1);return void(this.timeline=this.timeline.concat(p))}}}},t.update=function(e){ao(this.timeline,e.timeline),this._initialScaledLastPosition=e._initialScaledLastPosition,this.validityTime=e.validityTime},t.addPredictedSegments=function(e,t){var n;if(void 0!==(null===(n=t.privateInfos)||void 0===n?void 0:n.smoothMediaSegment)){this.refresh();for(var r=0;r<e.length;r++)oo(this.timeline,this.timescale,e[r],t.privateInfos.smoothMediaSegment)}else B.warn("Smooth Parser: should only encounter SmoothRepresentationIndex")},e}();function uo(e,t,n){for(var r=e.firstElementChild,i=n;null!==r;)i=t(i,r.nodeName,r),r=r.nextElementSibling;return i}var lo={audio:"audio/mp4",video:"video/mp4",text:"application/ttml+xml"},co={AACL:"audio/mp4",AVC1:"video/mp4",H264:"video/mp4",TTML:"application/ttml+xml+mp4",DFXP:"application/ttml+xml+mp4"};var fo=function(e){void 0===e&&(e={});var n=void 0===e.referenceDateTime?Date.UTC(1970,0,1,0,0,0,0)/1e3:e.referenceDateTime,r=void 0===e.minRepresentationBitrate?0:e.minRepresentationBitrate,i=e.serverSyncInfos,a=void 0!==i?i.serverTimestamp-i.clientTime:void 0;function o(e,t){var n=uo(e,(function(e,t,n){return"CustomAttributes"===t&&e.push.apply(e,uo(n,(function(e,t,n){if("Attribute"===t){var r=n.getAttribute("Name"),i=n.getAttribute("Value");null!==r&&null!==i&&e.push(r+"="+i)}return e}),[])),e}),[]);function r(t){var n=e.getAttribute(t);return null===n?void 0:n}switch(t){case"audio":var i=r("AudioTag"),a=r("BitsPerSample"),o=r("Channels"),s=r("CodecPrivateData"),u=r("FourCC"),l=r("PacketSize"),d=r("SamplingRate"),c=r("Bitrate"),f=void 0===c?0:parseInt(c,10);if(f=isNaN(f)?0:f,void 0!==u&&void 0===co[u]||void 0===s)return B.warn("Smooth parser: Unsupported audio codec. Ignoring quality level."),null;var v=function(e,t){var n;return 0==(n="AACH"===t?5:mt(e)?(248&parseInt(e.substring(0,2),16))>>3:2)?"mp4a.40.2":"mp4a.40."+n}(s,u);return{audiotag:void 0!==i?parseInt(i,10):i,bitrate:f,bitsPerSample:void 0!==a?parseInt(a,10):a,channels:void 0!==o?parseInt(o,10):o,codecPrivateData:s,codecs:v,customAttributes:n,mimeType:void 0!==u?co[u]:u,packetSize:void 0!==l?parseInt(l,10):l,samplingRate:void 0!==d?parseInt(d,10):d};case"video":var p=r("CodecPrivateData"),h=r("FourCC"),m=r("MaxWidth"),g=r("MaxHeight"),y=r("Bitrate"),_=void 0===y?0:parseInt(y,10);if(_=isNaN(_)?0:_,void 0!==h&&void 0===co[h]||void 0===p)return B.warn("Smooth parser: Unsupported video codec. Ignoring quality level."),null;var b=function(e){var t=/00000001\d7([0-9a-fA-F]{6})/.exec(e);return null!==t&&mt(t[1])?"avc1."+t[1]:"avc1.4D401E"}(p);return{bitrate:_,customAttributes:n,mimeType:void 0!==h?co[h]:h,codecPrivateData:p,codecs:b,width:void 0!==m?parseInt(m,10):void 0,height:void 0!==g?parseInt(g,10):void 0};case"text":var S=r("CodecPrivateData"),E=r("FourCC"),T=r("Bitrate"),k=void 0===T?0:parseInt(T,10);return{bitrate:k=isNaN(k)?0:k,customAttributes:n,mimeType:void 0!==E?co[E]:E,codecPrivateData:null!=S?S:""};default:return B.error("Smooth Parser: Unrecognized StreamIndex type: "+t),null}}function s(e){var n=e.root,i=e.timescale,a=e.baseUrl,s=e.protections,u=e.timeShiftBufferDepth,l=e.manifestReceivedTime,d=e.isLive,c=n.getAttribute("Timescale"),f=null===c?i:+c;isNaN(f)&&(f=i);var v=n.getAttribute("Type");if(null===v)throw new Error("StreamIndex without type.");Je(nt,v)||B.warn("Smooth Parser: Unrecognized adaptation type:",v);var p=v,h=n.getAttribute("Subtype"),m=n.getAttribute("Language"),g=n.getAttribute("Url"),y=null===g?"":g;var _,b=uo(n,(function(e,t,n){switch(t){case"QualityLevel":var i=o(n,p);if(null===i)return e;("video"!==p||i.bitrate>r)&&e.qualityLevels.push(i);break;case"c":e.cNodes.push(n)}return e}),{qualityLevels:[],cNodes:[]}),S=b.qualityLevels,E=b.cNodes,T=new so({timeline:(_=E,_.reduce((function(e,t,n){var r=t.getAttribute("d"),i=t.getAttribute("t"),a=t.getAttribute("r"),o=null!==a?+a-1:0,s=null!==i?+i:void 0,u=null!==r?+r:void 0;if(0===n)s=void 0===s||isNaN(s)?0:s;else{var l=e[n-1];if(void 0===s||isNaN(s)){if(void 0===l.duration||isNaN(l.duration))throw new Error("Smooth: Invalid CNodes. Missing timestamp.");s=l.start+l.duration*(l.repeatCount+1)}}if(void 0===u||isNaN(u)){var d=_[n+1];if(void 0===d)return e;var c=d.getAttribute("t"),f=mt(c)?+c:null;if(null===f)throw new Error("Can't build index timeline from Smooth Manifest.");u=f-s}return e.push({duration:u,start:s,repeatCount:o}),e}),[])),timescale:f,timeShiftBufferDepth:u,manifestReceivedTime:l});fe(S.length);var k=p+(mt(m)?"_"+m:""),w=S.map((function(e){var n,r,i,o,u=(n=y,r=e.bitrate,i=e.customAttributes,n.replace(/\{bitrate\}/g,String(r)).replace(/{CustomAttributes}/g,i.length>0?i[0]:"")),l=mt(e.mimeType)?e.mimeType:lo[p],c=e.codecs,f=k+"_"+(t(p)?"":p+"-")+(t(l)?"":l+"-")+(t(c)?"":c+"-")+String(e.bitrate),v=[];s.length>0&&(o=s[0],s.forEach((function(e){var t=e.keyId;e.keySystems.forEach((function(e){v.push({keyId:t,systemId:e.systemId})}))})));var h={bitsPerSample:e.bitsPerSample,channels:e.channels,codecPrivateData:e.codecPrivateData,packetSize:e.packetSize,samplingRate:e.samplingRate,height:e.height,width:e.width,protection:t(o)?void 0:{keyId:o.keyId}},m=new ro({isLive:d,sharedSmoothTimeline:T,media:u,segmentPrivateInfos:h}),g=P({},e,{index:m,cdnMetadata:[{baseUrl:a}],mimeType:l,codecs:c,id:f});if(v.length>0||void 0!==o){var _=void 0===o?[]:o.keySystems.map((function(e){var t=e.systemId,n=e.privateData,r=t.replace(/-/g,""),i=function(e,t){if(32!==e.length)throw new Error("HSS: wrong system id length");return Ba("pssh",vi([0,0,0,0],Pa(e),_i(t.length),t))}(r,n);return{systemId:r,data:i}}));if(_.length>0){var b=[{type:"cenc",values:_}];g.contentProtections={keyIds:v,initData:b}}else g.contentProtections={keyIds:v,initData:[]}}return g}));if("ADVT"===h)return null;var A={id:k,type:p,representations:w,language:null===m?void 0:m};return"text"===p&&"DESC"===h&&(A.closedCaption=!0),A}return function(r,i,o){var u="";if(void 0!==i){var l=wa(i);u=i.substring(0,l)}var d=r.documentElement;if(t(d)||"SmoothStreamingMedia"!==d.nodeName)throw new Error("document root should be SmoothStreamingMedia");var c=d.getAttribute("MajorVersion"),f=d.getAttribute("MinorVersion");if(null===c||null===f||!/^[2]-[0-2]$/.test(c+"-"+f))throw new Error("Version should be 2.0, 2.1 or 2.2");var v=d.getAttribute("Timescale"),p=mt(v)?+v:1e7;isNaN(p)&&(p=1e7);var h,m,g=uo(d,(function(t,n,r){switch(n){case"Protection":t.protections.push(Ya(r,e.keySystems));break;case"StreamIndex":t.adaptationNodes.push(r)}return t}),{adaptationNodes:[],protections:[]}),y=g.protections,_=g.adaptationNodes,b="boolean"==typeof(h=d.getAttribute("IsLive"))?h:"string"==typeof h&&"TRUE"===h.toUpperCase();if(b){var S=d.getAttribute("DVRWindowLength");null===S||isNaN(+S)||0==+S||(m=+S/p)}var E,T,k,w,A,I,R,x=_.reduce((function(e,t){var n=s({root:t,baseUrl:u,timescale:p,protections:y,isLive:b,timeShiftBufferDepth:m,manifestReceivedTime:o});if(null===n)return e;var r=n.type,i=e[r];return void 0===i?e[r]=[n]:i.push(n),e}),{}),C=null,M=void 0!==x.video?x.video[0]:void 0,P=void 0!==x.audio?x.audio[0]:void 0;if(void 0!==M||void 0!==P){var D=[],N=[];if(void 0!==M){var O=M.representations[0];if(void 0!==O){var L=O.index.getFirstAvailablePosition(),U=O.index.getLastAvailablePosition();t(L)||D.push(L),t(U)||N.push(U)}}if(void 0!==P){var F=P.representations[0];if(void 0!==F){var B=F.index.getFirstAvailablePosition(),z=F.index.getLastAvailablePosition();t(B)||D.push(B),t(z)||N.push(z)}}D.length>0&&(A=Math.max.apply(Math,D)),N.length>0&&(I=Math.min.apply(Math,N),R=Math.max.apply(Math,N))}var V=d.getAttribute("Duration"),K=null!==V&&0!=+V?+V/p:void 0;if(b){E=e.suggestedPresentationDelay,T=n,k=null!=A?A:T;var W=R;void 0===W&&(W=Date.now()/1e3-T);var G=I;void 0===G&&(G=W),w={isLinear:!0,maximumSafePosition:G,livePosition:W,time:ye()},C=null!=m?m:null}else{k=null!=A?A:0;var H=I;void 0===H&&(H=void 0!==K?k+K:1/0),w={isLinear:!1,maximumSafePosition:H,livePosition:void 0,time:ye()}}var j=b?0:k,q=b?void 0:w.maximumSafePosition,Y={availabilityStartTime:void 0===T?0:T,clockOffset:a,isLive:b,isDynamic:b,isLastPeriodKnown:!0,timeBounds:{minimumSafePosition:k,timeshiftDepth:C,maximumTimeData:w},periods:[{adaptations:x,duration:void 0!==q?q-j:K,end:q,id:"gen-smooth-period-0",start:j}],suggestedPresentationDelay:E,transportType:"smooth",uris:t(i)?[]:[i]};return Va(Y),Y}},vo=fo;var po=function(e){var n={url:e.url,headers:e.headers,responseType:t(e.responseType)?"json":e.responseType,timeout:e.timeout,connectionTimeout:e.connectionTimeout};return new Promise((function(r,i){var a,o,s=e.onProgress,u=e.cancelSignal,l=n.url,d=n.headers,c=n.responseType,f=n.timeout,v=n.connectionTimeout,p=new XMLHttpRequest;if(p.open("GET",l,!0),void 0!==f&&(p.timeout=f,a=setTimeout((function(){_(),i(new ze(l,p.status,Ve.TIMEOUT))}),f+3e3)),void 0!==v&&(o=setTimeout((function(){_(),p.readyState!==XMLHttpRequest.DONE&&p.abort(),i(new ze(l,p.status,Ve.TIMEOUT))}),v)),p.responseType=c,"document"===p.responseType&&p.overrideMimeType("text/xml"),!t(d)){var h=d;for(var m in h)h.hasOwnProperty(m)&&p.setRequestHeader(m,h[m])}var g=ye(),y=null;function _(){void 0!==a&&clearTimeout(a),void 0!==o&&clearTimeout(o),null!==y&&y()}void 0!==u&&(y=u.register((function(e){_(),p.readyState!==XMLHttpRequest.DONE&&p.abort(),i(e)})),u.isCancelled())||(p.onerror=function(){_(),i(new ze(l,p.status,Ve.ERROR_EVENT))},p.ontimeout=function(){_(),i(new ze(l,p.status,Ve.TIMEOUT))},void 0!==v&&(p.onreadystatechange=function(){p.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(o)}),void 0!==s&&(p.onprogress=function(e){var t=ye();s({url:l,duration:t-g,sendingTime:g,currentTime:t,size:e.loaded,totalSize:e.total})}),p.onload=function(e){if(p.readyState===XMLHttpRequest.DONE)if(_(),p.status>=200&&p.status<300){var n,a=ye(),o=p.response instanceof ArrayBuffer?p.response.byteLength:e.total,s=p.status,u=p.responseType,d=mt(p.responseURL)?p.responseURL:l;if(t(n="json"===u?"object"==typeof p.response?p.response:function(e){try{return JSON.parse(e)}catch(e){return null}}(p.responseText):p.response))return void i(new ze(l,p.status,Ve.PARSE_ERROR));r({status:s,url:d,responseType:u,sendingTime:g,receivedTime:a,requestDuration:a-g,size:o,responseData:n})}else i(new ze(l,p.status,Ve.ERROR_HTTP_CODE))},p.send())}))};function ho(e,t){for(var n=e.length,r=0;r+8<=n;){var i=mi(e,r);if(0===i)i=n-r;else if(1===i){if(r+16>n)return-1;i=gi(e,r+8)}if(isNaN(i)||i<=0)return-1;if(mi(e,r+4)===t)return r+i<=n?r:-1;r+=i}return-1}function mo(e,t){if(t){if(ho(e,1718909296)<0)throw new Qe("INTEGRITY_ERROR","Incomplete `ftyp` box");if(ho(e,1836019574)<0)throw new Qe("INTEGRITY_ERROR","Incomplete `moov` box")}else{if(ho(e,1836019558)<0)throw new Qe("INTEGRITY_ERROR","Incomplete `moof` box");if(ho(e,1835295092)<0)throw new Qe("INTEGRITY_ERROR","Incomplete `mdat` box")}}function go(e,t){var n=e.customManifestLoader,r=function(e){return function(t,n,r){if(void 0===t)throw new Error("Cannot perform HTTP(s) request. URL not known");switch(e){case"arraybuffer":return po({url:t,responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});case"text":return po({url:t,responseType:"text",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});case"document":return po({url:t,responseType:"document",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r});default:ve()}}}(t);return"function"!=typeof n?r:function(e,t){return function(n,r,i){return new Promise((function(a,o){var s=Date.now()-ye(),u=!1,l={reject:function(e){var t,n;if(!u&&!i.isCancelled()){u=!0,i.deregister(c);var r=e,a=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching the Manifest through a custom manifestLoader.",s=new Ht(a,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);o(s)}},resolve:function(e){if(!u&&!i.isCancelled()){u=!0,i.deregister(c);var t=void 0!==e.receivingTime?e.receivingTime-s:void 0,n=void 0!==e.sendingTime?e.sendingTime-s:void 0;a({responseData:e.data,size:e.size,requestDuration:e.duration,url:e.url,receivedTime:t,sendingTime:n})}},fallback:function(){u||i.isCancelled()||(u=!0,i.deregister(c),t(n,r,i).then(a,o))}},d=e({url:n,timeout:r.timeout},l);function c(e){u||(u=!0,"function"==typeof d&&d(),o(e))}i.register(c)}))}}(n,r)}function yo(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return _o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function bo(e,t){var n=ha(e,1936286840);if(null===n)return null;var r,i=t,a=n[2]-n[0],o=n[1],s=e[o],u=mi(e,o+=8);if(o+=4,0===s)r=mi(e,o),i+=mi(e,o+=4)+a,o+=4;else{if(1!==s)return null;r=gi(e,o),i+=gi(e,o+=8)+a,o+=8}var l=[],d=pi(e,o+=2);for(o+=2;--d>=0;){var c=mi(e,o);o+=4;var f=2147483647&c;if(1===(2147483648&c)>>>31)throw new Error("sidx with reference_type `1` not yet implemented");var v=mi(e,o);o+=4,o+=4,l.push({time:r,duration:v,timescale:u,range:[i,i+f-1]}),r+=v,i+=f}return l}function So(e){var t=pa(e,1952868452);if(null!==t){var n=1,r=hi(t,n);if(n+=3,(8&r)>0)return n+=4,(1&r)>0&&(n+=8),(2&r)>0&&(n+=4),mi(t,n)}}function Eo(e){var t=_a(e);if(0!==t.length){for(var n,r=0,i=yo(t);!(n=i()).done;){var a=n.value,o=pa(a,1953658222);if(null===o)return;var s=0;if(o[s]>1)return;var u=hi(o,s+=1);s+=3;var l=(256&u)>0,d=0;if(!l&&void 0===(d=So(a)))return;var c=(1&u)>0,f=(4&u)>0,v=(512&u)>0,p=(1024&u)>0,h=(2048&u)>0,m=mi(o,s);s+=4,c&&(s+=4),f&&(s+=4);for(var g=m,y=0;g-- >0;)l?(y+=mi(o,s),s+=4):y+=d,v&&(s+=4),p&&(s+=4),h&&(s+=4);r+=y}return r}}function To(e){var t=function(e){var t=pa(e,1836019574);if(null===t)return null;var n=pa(t,1953653099);return null===n?null:pa(n,1835297121)}(e);if(null!==t){var n=pa(t,1835296868);if(null!==n){var r=0,i=n[r];return r+=4,1===i?mi(n,r+16):0===i?mi(n,r+8):void 0}}}function ko(e){var t=e.length;if(t<4)throw new Error("Cannot update box length: box too short");var n=mi(e,0);if(0===n){if(t>La){var r=new Uint8Array(t+8);return r.set(_i(1),0),r.set(e.subarray(4,8),4),r.set(bi(t+8),8),r.set(e.subarray(8,t),16),r}return e.set(_i(t),0),e}if(1===n){if(t<16)throw new Error("Cannot update box length: box too short");return e.set(bi(t),8),e}if(t<=La)return e.set(_i(t),0),e;var i=new Uint8Array(t+8);return i.set(_i(1),0),i.set(e.subarray(4,8),4),i.set(bi(t+8),8),i.set(e.subarray(8,t),16),i}function wo(e,t,n,r,i){var a,o,s,u=[];if(i){var l=ya(e);null!==l?(s=function(e){var t=ma(e,3565190898,3392751253,2387879627,2655430559);if(void 0===t)return[];for(var n=[],r=t[0],i=t[4],a=0;a<i;a++){var o=void 0,s=void 0;1===r?(s=gi(t,16*a+5),o=gi(t,16*a+5+8)):(s=mi(t,8*a+5),o=mi(t,8*a+5+4)),n.push({time:s,duration:o})}return n}(l),o=function(e){var t=ma(e,1830656773,1121273062,2162299933,2952222642);if(void 0!==t)return{duration:gi(t,12),time:gi(t,4)}}(l)):B.warn("smooth: could not find traf atom")}if(void 0!==s)for(var d=0;d<s.length;d++)u.push({time:s[d].time,duration:s[d].duration,timescale:n});if(void 0!==o)return{nextSegments:u,chunkInfos:{time:o.time/n,duration:o.duration/n},scaledSegmentTime:o.time};if(t||!r.complete)return{nextSegments:u,chunkInfos:null,scaledSegmentTime:void 0};var c=r.duration*n,f=Math.min(.9*n,c/4),v=Eo(e),p=void 0!==(null===(a=r.privateInfos)||void 0===a?void 0:a.smoothMediaSegment)?r.privateInfos.smoothMediaSegment.time:Math.round(r.time*n);return{nextSegments:u,chunkInfos:void 0!==v&&Math.abs(v-c)<=f?{time:r.time,duration:v/n}:{time:r.time,duration:r.duration},scaledSegmentTime:p}}function Ao(e){return"string"==typeof e&&e.indexOf("mp4")>=0}function Io(e,t){return Ba("schm",vi(4,xa(e),_i(t)))}function Ro(e){return Ba("frma",xa(e))}function xo(e){var t=[7,[e.length]];return Ba("stsd",vi.apply(void 0,t.concat(e)))}function Co(e,t,n){return Ba("tenc",vi(6,[e,t],n))}function Mo(e,t,n,r,i){var a=[e,t,n];return void 0!==i&&a.push(Ba("senc",i),function(e){if(0===e.length)return Ba("saiz",new Uint8Array(0));var t=mi(e,0),n=mi(e,4),r=new Uint8Array(n+9);r.set(_i(n),5);for(var i,a,o=9,s=8;s<e.length;)s+=8,2&~t?(i=0,a=0):(a=2,s+=6*(i=pi(e,s))+2),r[o]=6*i+8+a,o++;return Ba("saiz",r)}(i),function(e,t,n,r){return Ba("saio",vi(4,[0,0,0,1],_i(e.length+t.length+n.length+r.length+8+8+8+8)))}(r,e,t,n)),za("traf",a)}function Po(e,t){var n=ha(e,1836019558);if(null===n)throw new Error("Smooth: Invalid ISOBMFF given");var r=e.subarray(n[1],n[2]),i=function(e,t){var n=ha(e,t);return null!==n?e.subarray(n[0],n[2]):null}(r,1835427940),a=pa(r,1953653094);if(null===a||null===i)throw new Error("Smooth: Invalid ISOBMFF given");var o=ha(a,1952868452),s=ha(a,1953658222);if(null===o||null===s)throw new Error("Smooth: Invalid ISOBMFF given");var u=a.subarray(o[0],o[2]),l=a.subarray(s[0],s[2]);u.set([0,0,0,1],o[1]-o[0]+4);var d=function(e){return Ba("tfdt",vi([1,0,0,0],bi(e)))}(t),c=function(e,t){var n=(1&e[t+3])>0;if(n)return e;var r=new Uint8Array(e.length+4);return r.set(e.subarray(0,t+8),0),r[t+3]=1|r[t+3],r.set([0,0,0,0],t+8),r.set(e.subarray(t+8,e.length),t+12),ko(r)}(l,s[1]-s[0]),f=Mo(u,d,c,i,ma(a,2721664850,1520127764,2722393154,2086964724)),v=za("moof",[i,f]),p=ha(v,1836019558),h=ha(f,1953653094),m=ha(c,1953658222);if(null===p||null===h||null===m)throw new Error("Smooth: Invalid moof, trun or traf generation");var g=p[1]-p[0]+i.length+(h[1]-h[0])+u.length+d.length+(m[1]-m[0])+8,y=n[2]-n[0],_=v.length-y,S=ha(e,1835295092);if(null===S)throw new Error("Smooth: Invalid ISOBMFF given");if(!b&&(0===_||_<=-8)){var E=S[1];return v.set(_i(E),g),e.set(v,n[0]),_<=-8&&e.set(Ba("free",new Uint8Array(-_-8)),v.length),e}var T=S[1]+_;v.set(_i(T),g);var k=new Uint8Array(e.length+_),w=e.subarray(0,n[0]),A=e.subarray(n[2],e.length);return k.set(w,0),k.set(v,w.length),k.set(A,w.length+v.length),k}function Do(e){var t=e[0],n=e[1];return n===1/0?"bytes="+t+"-":"bytes="+t+"-"+n}function No(e,t,n,r,i,a){var o,s,u=za("stbl",[n,Ba("stts",new Uint8Array(8)),Ba("stsc",new Uint8Array(8)),Ba("stsz",new Uint8Array(12)),Ba("stco",new Uint8Array(8))]),l=function(e){return Ba("dref",vi(7,[1],e))}(Ba("url ",new Uint8Array([0,0,0,1]))),d=za("dinf",[l]),c=za("minf",[r,d,u]),f=function(e){var t,n;switch(e){case"video":t="vide",n="VideoHandler";break;case"audio":t="soun",n="SoundHandler";break;default:t="hint",n=""}return Ba("hdlr",vi(8,xa(t),12,xa(n),1))}(t),v=function(e){return Ba("mdhd",vi(12,_i(e),8))}(e),p=za("mdia",[v,f,c]),h=function(e,t,n){return Ba("tkhd",vi(_i(7),8,_i(n),20,[1,0,0,0],[0,1,0,0],12,[0,1,0,0],12,[64,0,0,0],yi(e),2,yi(t),2))}(i,a,1),m=za("trak",[h,p]),g=za("mvex",[Ba("trex",vi(4,_i(1),[0,0,0,1],12))]),y=function(e,t){return Ba("mvhd",vi(12,_i(e),4,[0,1],2,[1,0],10,[0,1],14,[0,1],14,[64,0,0,0],26,yi(t+1)))}(e,1),_=function(e,t,n){return za("moov",[e,t,n])}(y,g,m),b=(o="isom",s=["isom","iso2","iso6","avc1","dash"],Ba("ftyp",vi.apply(void 0,[xa(o),[0,0,0,1]].concat(s.map(xa)))));return vi(b,_)}function Oo(e,t,n,r,i,a,o,s){var u=o.split("00000001"),l=u[1],d=u[2];if(void 0===l||void 0===d)throw new Error("Smooth: unsupported codec private data.");var c,f,v=function(e,t,n){var r;return r=2===n?1:4===n?3:0,Ba("avcC",vi([1,e[1],e[2],e[3],252|r,225],yi(e.length),e,[1],yi(t.length),t))}(Pa(l),Pa(d),a);if(void 0===s){var p=function(e,t,n,r,i,a,o){return Ba("avc1",vi(6,yi(1),16,yi(e),yi(t),yi(n),2,yi(r),6,[0,1,i.length],xa(i),31-i.length,yi(a),[255,255],o))}(t,n,r,i,"AVC Coding",24,v);c=xo([p])}else{var h=za("schi",[Co(1,8,s)]),m=Io("cenc",65536),g=function(e,t,n,r,i,a,o,s){return Ba("encv",vi(6,yi(1),16,yi(e),yi(t),yi(n),2,yi(r),6,[0,1,i.length],xa(i),31-i.length,yi(a),[255,255],o,s))}(t,n,r,i,"AVC Coding",24,v,za("sinf",[Ro("avc1"),m,h]));c=xo([g])}return No(e,"video",c,((f=new Uint8Array(12))[3]=1,Ba("vmhd",f)),t,n)}var Lo=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];function Uo(e,t,n,r,i,a,o){var s,u,l=function(e,t){return Ba("esds",vi(4,[3,25],yi(e),[0,4,17,64,21],11,[5,2],Pa(t),[6,1,2]))}(1,0===a.length?(s=i,u=t,Da(yi((((63&2)<<4|31&Lo.indexOf(s))<<4|31&u)<<3))):a),d=function(){if(void 0===o){var e=function(e,t,n,r,i,a){return Ba("mp4a",vi(6,yi(e),8,yi(t),yi(n),2,yi(r),yi(i),2,a))}(1,t,n,r,i,l);return xo([e])}var a=za("schi",[Co(1,8,o)]),s=Io("cenc",65536),u=za("sinf",[Ro("mp4a"),s,a]),d=function(e,t,n,r,i,a,o){return Ba("enca",vi(6,yi(e),8,yi(t),yi(n),2,yi(r),yi(i),2,a,o))}(1,t,n,r,i,l,u);return xo([d])}();return No(e,"audio",d,Ba("smhd",new Uint8Array(8)),0,0)}function Fo(e,t,n,r,i,a){var o,s=t.segment.range;return Array.isArray(s)&&(o={Range:Do(s)}),po({url:e,responseType:"arraybuffer",headers:o,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:n.onProgress}).then((function(e){if(!Ao(t.mimeType)||!0!==a)return{resultType:"segment-loaded",resultData:e};var n=new Uint8Array(e.responseData);return mo(n,t.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},e),{responseData:n})}}))}var Bo=function(e){var t=e.checkMediaSegmentIntegrity,n=e.segmentLoader;return function(e,r,i,a,o){var s=r.segment;if(s.isInit){if(void 0===s.privateInfos||void 0===s.privateInfos.smoothInitSegment)throw new Error("Smooth: Invalid segment format");var u,l=s.privateInfos.smoothInitSegment,d=l.codecPrivateData,c=l.timescale,f=l.height,v=l.width,p=l.protection,h=void 0===p?{keyId:void 0,keySystems:void 0}:p;if(void 0===d)throw new Error("Smooth: no codec private data.");switch(r.type){case"video":u=Oo(c,null!=v?v:0,null!=f?f:0,72,72,4,d,h.keyId);break;case"audio":var m=l.channels,g=void 0===m?0:m,y=l.bitsPerSample,_=void 0===y?0:y,b=l.packetSize,S=void 0===b?0:b,E=l.samplingRate;u=Uo(c,g,_,S,void 0===E?0:E,d,h.keyId);break;default:0,u=new Uint8Array(0)}return Promise.resolve({resultType:"segment-created",resultData:u})}return null===e?Promise.resolve({resultType:"segment-created",resultData:null}):"function"!=typeof n?Fo(e,r,o,i,a,t):new Promise((function(s,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a Smooth segment through a custom segmentLoader.",o=new Ht(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(e){if(!d&&!a.isCancelled()){d=!0,a.deregister(p),Ao(r.mimeType)&&!0===t||s({resultType:"segment-loaded",resultData:{responseData:e.data,size:e.size,requestDuration:e.duration}});var n=e.data instanceof Uint8Array?e.data:new Uint8Array(e.data);mo(n,r.segment.isInit),s({resultType:"segment-loaded",resultData:{responseData:n,size:e.size,requestDuration:e.duration}})}},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),Fo(e,r,o,i,a,t).then(s,u))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:e},v=n(f,c);function p(e){d||((d=!0)||"function"!=typeof v||v(),u(e))}a.register(p)}))}};function zo(e,t){return null===e?null:null===t.url?e.baseUrl:ka(e.baseUrl,t.url)}var Vo=function(e){var t=vo(e),n=Bo(e),r={loadManifest:go({customManifestLoader:e.manifestLoader},"text"),parseManifest:function(n,r){var i,a=null!==(i=n.url)&&void 0!==i?i:r.originalUrl,o=n.receivedTime,s=n.responseData,u="string"==typeof s?(new DOMParser).parseFromString(s,"text/xml"):s,l=t(u,a,o),d=[];return{manifest:new Wt(l,{representationFilter:e.representationFilter},d),url:a,warnings:d}}},i={loadSegment:function(e,t,r,i,a){var o=zo(e,t.segment);return n(o,t,r,i,a)},parseSegment:function(e,t,n){var r,i,a=t.segment,o=e.data,s=e.isChunked;if(null===o)return a.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var u=o instanceof Uint8Array?o:new Uint8Array(o);if(a.isInit){var l=null===(i=null===(r=a.privateInfos)||void 0===r?void 0:r.smoothInitSegment)||void 0===i?void 0:i.timescale;return{segmentType:"init",initializationData:o,initializationDataSize:o.byteLength,initTimescale:l,protectionData:[]}}var d=void 0!==n?wo(u,s,n,a,t.isLive):null;if(null===d||null===d.chunkInfos||void 0===d.scaledSegmentTime)throw new Error("Smooth Segment without time information");var c=d.nextSegments,f=d.chunkInfos,v=Po(u,d.scaledSegmentTime),p=c.length>0?c:void 0;return{segmentType:"media",chunkData:v,chunkInfos:f,chunkOffset:0,chunkSize:v.length,protectionData:[],predictedSegments:p,appendWindow:[void 0,void 0]}}},a={loadSegment:function(t,n,r,i,a){var o=n.segment,s=zo(t,o);return o.isInit||null===s?Promise.resolve({resultType:"segment-created",resultData:null}):Ao(n.mimeType)?po({url:s,responseType:"arraybuffer",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:a.onProgress}).then((function(t){if(!0!==e.checkMediaSegmentIntegrity)return{resultType:"segment-loaded",resultData:t};var r=new Uint8Array(t.responseData);return mo(r,n.segment.isInit),{resultType:"segment-loaded",resultData:Object.assign(Object.assign({},t),{responseData:r})}})):po({url:s,responseType:"text",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i,onProgress:a.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))},parseSegment:function(e,t,n){var r,i,a,o=t.segment,s=t.language,u=t.mimeType,l=void 0===u?"":u,d=t.codecs,c=void 0===d?"":d,f=Ao(t.mimeType),v=e.data,p=e.isChunked;if(o.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if(null===v)return{segmentType:"media",chunkData:null,chunkInfos:null,chunkOffset:0,chunkSize:0,protectionData:[],appendWindow:[void 0,void 0]};var h,m,g,y,_=null;if(f){var b;i=(b="string"==typeof v?xa(v):v instanceof Uint8Array?v:new Uint8Array(v)).length;var S=void 0!==n?wo(b,p,n,o,t.isLive):null;a=null==S?void 0:S.nextSegments,null===(_=null!==(r=null==S?void 0:S.chunkInfos)&&void 0!==r?r:null)?p?B.warn("Smooth: Unavailable time data for current text track."):(h=o.time,m=o.end):(h=_.time,m=void 0!==_.duration?_.time+_.duration:o.end);var E=c.toLowerCase();if("application/ttml+xml+mp4"===l||"stpp"===E||"stpp.ttml.im1t"===E)y="ttml";else{if("wvtt"!==E)throw new Error("could not find a text-track parser for the type "+l);y="vtt"}var T=ba(b);g=null===T?"":Ma(T)}else{var k;if(h=o.time,m=o.end,"string"!=typeof v){var w=v instanceof Uint8Array?v:new Uint8Array(v);i=w.length,k=Ma(w)}else k=v;switch(l){case"application/x-sami":case"application/smil":y="sami";break;case"application/ttml+xml":y="ttml";break;case"text/vtt":y="vtt"}if(void 0===y){if("srt"!==c.toLowerCase())throw new Error("could not find a text-track parser for the type "+l);y="srt"}g=k}return{segmentType:"media",chunkData:{type:y,data:g,start:h,end:m,language:s},chunkSize:i,chunkInfos:_,chunkOffset:null!=h?h:0,protectionData:[],predictedSegments:Array.isArray(a)&&a.length>0?a:void 0,appendWindow:[void 0,void 0]}}};return{manifest:r,audio:i,video:i,text:a}};function Ko(e){void 0===e.transports.smooth&&(e.transports.smooth=Vo),e.mainThreadMediaSourceInit=oa,e.codecSupportProber=da}function Wo(e){var t=Date.parse(e)-ye();if(!isNaN(t))return t;B.warn("DASH Parser: Invalid clock received: ",e)}function Go(e){for(var t=e.representations,n=null,r=0;r<t.length;r++){var i=t[r].index.getLastAvailablePosition();if(void 0===i)return;null!==i&&(n=null===n?i:Math.min(n,i))}return null===n?null:n}function Ho(e){for(var t=e.representations,n=null,r=0;r<t.length;r++){var i=t[r].index.getFirstAvailablePosition();if(void 0===i)return;null!==i&&(n=null===n?i:Math.max(n,i))}return null===n?null:n}function jo(e){if(0===e.length)throw new Error("DASH Parser: no period available for a dynamic content");var t=function(e){for(var t=0;t<=e.length-1;t++){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,o=null;if(void 0!==r){var s=Ho(r);if(void 0===s)return;a=s}if(void 0!==i){var u=Ho(i);if(void 0===u)return;o=u}if(void 0!==r&&null===a||void 0!==i&&null===o)return void B.info("Parser utils: found Period with no segment. ","Going to next one to calculate first position");if(null!==o)return null!==a?Math.max(a,o):o;if(null!==a)return a}}}(e),n=function(e){for(var t=e.length-1;t>=0;t--){var n=e[t].adaptations,r=void 0===n.audio?void 0:n.audio[0],i=void 0===n.video?void 0:n.video[0];if(void 0!==r||void 0!==i){var a=null,o=null;if(void 0!==r){var s=Go(r);if(void 0===s)return{safe:void 0,unsafe:void 0};a=s}if(void 0!==i){var u=Go(i);if(void 0===u)return{safe:void 0,unsafe:void 0};o=u}if(void 0!==r&&null===a||void 0!==i&&null===o)return B.info("Parser utils: found Period with no segment. ","Going to previous one to calculate last position"),{safe:void 0,unsafe:void 0};if(null!==o)return null!==a?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(null!==a)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}(e);return{minimumSafePosition:t,maximumSafePosition:n.safe,maximumUnsafePosition:n.unsafe}}var qo=function(){function e(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=e.isDynamic&&void 0!==e.timeShiftBufferDepth?e.timeShiftBufferDepth:null,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}var t=e.prototype;return t.setLastPosition=function(e,t){this._lastPosition=e,this._positionTime=t},t.lastPositionIsKnown=function(){return this._isDynamic?void 0!==this._positionTime&&void 0!==this._lastPosition:void 0!==this._lastPosition},t.getEstimatedMinimumSegmentTime=function(){var e;if(!this._isDynamic||null===this._timeShiftBufferDepth)return 0;var t=null!==(e=this.getEstimatedLiveEdge())&&void 0!==e?e:this.getEstimatedMaximumPosition(0);return void 0!==t?t-this._timeShiftBufferDepth:void 0},t.getEstimatedLiveEdge=function(){if(this._isDynamic&&void 0!==this._serverTimestampOffset)return(ye()+this._serverTimestampOffset)/1e3-this._availabilityStartTime},t.getEstimatedMaximumPosition=function(e){if(!this._isDynamic)return this._lastPosition;var t=this.getEstimatedLiveEdge();return void 0!==t&&e!==1/0?t+e:void 0!==this._positionTime&&void 0!==this._lastPosition?Math.max(this._lastPosition-this._positionTime+ye()/1e3,0):this._lastPosition},e}();function Yo(e,t){return"function"==typeof Array.prototype.flatMap?e.flatMap(t):e.reduce((function(e,n){var r=t(n);return Array.isArray(r)?(e.push.apply(e,r),e):(e.push(r),e)}),[])}function Qo(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return $o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $o(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function $o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Xo=function(e,t){for(var n,r=Qo(t);!(n=r()).done;)for(var i,a=n.value,o=a.adaptation,s=Qo(a.trickModeAttachedAdaptationIds);!(i=s()).done;)for(var u,l=i.value,d=Qo(nt);!(u=d()).done;){var c=e[u.value];if(void 0!==c)for(var f,v=Qo(c);!(f=v()).done;){var p=f.value;p.id===l&&(void 0===p.trickModeTracks&&(p.trickModeTracks=[]),p.trickModeTracks.push(o))}}},Zo=["subtitle","caption"];function Jo(e,t,n,r){function i(e,t){var n=e.split("/")[0];return Je(nt,n)?n:"application/ttml+xml"===e||"application/mp4"===e&&null!==t&&void 0!==Se(t,(function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri&&Je(Zo,e.value)}))?"text":void 0}function a(e){switch(e.substring(0,3)){case"avc":case"hev":case"hvc":case"vp8":case"vp9":case"av1":return"video";case"vtt":return"text"}switch(e.substring(0,4)){case"mp4a":return"audio";case"wvtt":case"stpp":return"text"}}if(null!==t){var o=i(t,r);if(void 0!==o)return o}if(null!==n){var s=a(n);if(void 0!==s)return s}for(var u=0;u<e.length;u++){var l=e[u].attributes,d=l.mimeType,c=l.codecs;if(void 0!==d){var f=i(d,r);if(void 0!==f)return f}if(void 0!==c){var v=a(c);if(void 0!==v)return v}}}var es=/[, ]+/g;function ts(e,n){var r,i=e.initialization,a={};return void 0!==n&&(a.isEMSGWhitelisted=n),{id:"init",isInit:!0,time:0,end:0,duration:0,timescale:1,range:t(i)?void 0:i.range,indexRange:e.indexRange,url:null!==(r=null==i?void 0:i.url)&&void 0!==r?r:null,complete:!0,privateInfos:a,timestampOffset:-e.indexTimeOffset/e.timescale}}function ns(e){return function(t,n,r){var i,a,o,s=mt(r)?parseInt(r,10):1;return i=String(e),a=s,(o=i.toString()).length>=a?o:(new Array(a+1).join("0")+o).slice(-a)}}function rs(e,t,n){return function(e,t,n){return-1===e.indexOf("$")?e:e.replace(/\$\$/g,"$").replace(/\$RepresentationID\$/g,String(t)).replace(/\$Bandwidth(\%0(\d+)d)?\$/g,ns(void 0===n?0:n))}(e,t,n)}function is(e,t){return function(n){return-1===n.indexOf("$")?n:n.replace(/\$\$/g,"$").replace(/\$Number(\%0(\d+)d)?\$/g,(function(e,n,r){if(void 0===t)throw new Error("Segment number not defined in a $Number$ scheme");return ns(t)(e,n,r)})).replace(/\$Time(\%0(\d+)d)?\$/g,(function(t,n,r){if(void 0===e)throw new Error("Segment time not defined in a $Time$ scheme");return ns(e)(t,n,r)}))}}function as(e,t,n,r,i,a){for(var o,s,u,l=r.getEstimatedMaximumPosition(null!==(o=e.availabilityTimeOffset)&&void 0!==o?o:0),d=Math.min(t+n,null!=l?l:1/0),c=Xa(t,e),f=Xa(d,e),v=e.timeline,p=e.timescale,h=e.segmentUrlTemplate,m=e.startNumber,g=e.endNumber,y=null!=m?m:1,_=[],b=v.length,S=0;S<b;S++){var E=v[S],T=E.duration,k=E.start,w=E.range,A=void 0;A=void 0===l?i:Math.min(l*p,null!=i?i:1/0);for(var I=Qa(E,v[S+1],A),R=!1!==e.availabilityTimeComplete||S!==b-1&&0!==I,x=(s=T,u=void 0,(u=c-k)>0?Math.floor(u/s):0),C=k+x*T;C<f&&x<=I;){var M=y+x;if(void 0!==g&&M>g)break;var P=null===h?null:is(C,M)(h),D=C-e.indexTimeOffset,N=T;D<0&&(N=T+D,D=0);var O={id:String(C),time:D/p,end:(D+N)/p,duration:N/p,isInit:!1,range:w,timescale:1,url:P,number:M,timestampOffset:-e.indexTimeOffset/p,complete:R,privateInfos:{isEMSGWhitelisted:a}};_.push(O),C=k+ ++x*T}if(C>=f)return _;if(y+=I+1,void 0!==g&&y>g)return _}return _}function os(e,t){if(t.timescale!==e.timescale){var n=e.timescale;e.timeline.push({start:t.time/t.timescale*n,duration:t.duration/t.timescale*n,repeatCount:void 0===t.count?0:t.count,range:t.range})}else e.timeline.push({start:t.time,duration:t.duration,repeatCount:void 0===t.count?0:t.count,range:t.range});return!0}var ss=function(){function e(e,n){var r,i,a,o,s,u=n.periodStart,l=n.periodEnd,d=n.representationId,c=n.representationBitrate,f=n.isEMSGWhitelisted,v=null!==(r=e.timescale)&&void 0!==r?r:1,p=(null!==(i=e.presentationTimeOffset)&&void 0!==i?i:0)-u*v,h=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:rs(e.initialization.media,d,c),m=void 0===e.media?null:rs(e.media,d,c);void 0!==e.initialization?s=e.initialization.range:void 0!==e.indexRange&&(s=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:p,initialization:{url:h,range:s},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:null!==(o=e.timeline)&&void 0!==o?o:[],timescale:v},this._manifestBoundsCalculator=n.manifestBoundsCalculator,this._scaledPeriodStart=Xa(u,this._index),this._scaledPeriodEnd=t(l)?void 0:Xa(l,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=f}var n=e.prototype;return n.getInitSegment=function(){return ts(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,t){return as(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)},n.shouldRefresh=function(){return!1},n.getFirstAvailablePosition=function(){var e=this._index;return 0===e.timeline.length?null:Za(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)},n.getLastAvailablePosition=function(){var e,t=this._index.timeline;if(0===t.length)return null;var n=t[t.length-1];return Za(Math.min($a(n,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)},n.getEnd=function(){return this.getLastAvailablePosition()},n.awaitSegmentBetween=function(){return!1},n.isSegmentStillAvailable=function(){return!0},n.checkDiscontinuity=function(){return null},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){return!1},n.isInitialized=function(){return this._isInitialized},n.initialize=function(e){if(!this._isInitialized){for(var t=0;t<e.length;t++)os(this._index,e[t]);this._isInitialized=!0}},n.addPredictedSegments=function(){B.warn("Cannot add predicted segments to a `BaseRepresentationIndex`")},n._replace=function(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted},n._update=function(){B.error("Base RepresentationIndex: Cannot update a SegmentList")},e}(),us=function(){function e(e,n){var r,i,a;if(void 0===e.duration)throw new Error("Invalid SegmentList: no duration");var o=n.periodStart,s=n.periodEnd,u=n.representationId,l=n.representationBitrate,d=n.isEMSGWhitelisted;this._isEMSGWhitelisted=d,this._periodStart=o,this._periodEnd=s;var c=null!==(r=e.presentationTimeOffset)&&void 0!==r?r:0,f=null!==(i=e.timescale)&&void 0!==i?i:1,v=c-o*f,p=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:rs(e.initialization.media,u,l),h=e.list.map((function(e){return{url:void 0===e.media?null:rs(e.media,u,l),mediaRange:e.mediaRange}}));this._index={list:h,timescale:f,duration:e.duration,indexTimeOffset:v,indexRange:e.indexRange,initialization:t(e.initialization)?void 0:{url:p,range:e.initialization.range}}}var n=e.prototype;return n.getInitSegment=function(){var e=ts(this._index);return void 0===e.privateInfos&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e},n.getSegments=function(e,t){for(var n=this._index,r=n.duration,i=n.list,a=n.timescale,o=r/a,s=function(e,t,n){return[e*n,(e+t)*n]}(e-this._periodStart,t,a),u=s[0],l=s[1],d=Math.min(i.length-1,Math.floor(l/r)),c=[],f=Math.floor(u/r);f<=d;){var v=i[f].mediaRange,p=i[f].url,h=f*o+this._periodStart,m={id:String(f),time:h,isInit:!1,range:v,duration:o,timescale:1,end:h+o,url:p,timestampOffset:-n.indexTimeOffset/a,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};c.push(m),f++}return c},n.shouldRefresh=function(e,t){return!1},n.getFirstAvailablePosition=function(){return this._periodStart},n.getLastAvailablePosition=function(){var e,t=this._index,n=t.duration,r=t.list;return Math.min(r.length*n/t.timescale+this._periodStart,null!==(e=this._periodEnd)&&void 0!==e?e:1/0)},n.getEnd=function(){return this.getLastAvailablePosition()},n.awaitSegmentBetween=function(){return!1},n.isSegmentStillAvailable=function(){return!0},n.checkDiscontinuity=function(){return null},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){return!1},n.isInitialized=function(){return!0},n.initialize=function(){B.error("A `ListRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){B.warn("Cannot add predicted segments to a `ListRepresentationIndex`")},n._replace=function(e){this._index=e._index},n._update=function(){B.error("A `ListRepresentationIndex` cannot be updated")},e}();function ls(e){return L.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*e}function ds(e,n,r){var i=e.start,a=e.duration,o=e.repeatCount;return void 0===i&&(null===n?i=0:t(n.duration)||(i=n.start+n.duration*(n.repeatCount+1))),void 0!==a&&!isNaN(a)||null===r||void 0===r.start||isNaN(r.start)||void 0===i||isNaN(i)||(a=r.start-i),void 0===i||isNaN(i)||void 0===a||isNaN(a)||void 0!==o&&isNaN(o)?(B.warn('DASH: A "S" Element could not have been parsed.'),null):{start:i,duration:a,repeatCount:void 0===o?0:o}}function cs(e){for(var n={},r=0,i=Object.keys(e.attributes);r<i.length;r++){var a=i[r],o=e.attributes[a];if(!t(o))switch(a){case"t":var s=parseInt(o,10);isNaN(s)?B.warn('DASH: invalid t ("'+o+'")'):n.start=s;break;case"d":var u=parseInt(o,10);isNaN(u)?B.warn('DASH: invalid d ("'+o+'")'):n.duration=u;break;case"r":var l=parseInt(o,10);isNaN(l)?B.warn('DASH: invalid r ("'+o+'")'):n.repeatCount=l}}return n}function fs(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"t":var i=parseInt(r.value,10);isNaN(i)?B.warn('DASH: invalid t ("'+r.value+'")'):t.start=i;break;case"d":var a=parseInt(r.value,10);isNaN(a)?B.warn('DASH: invalid d ("'+r.value+'")'):t.duration=a;break;case"r":var o=parseInt(r.value,10);isNaN(o)?B.warn('DASH: invalid r ("'+r.value+'")'):t.repeatCount=o}}return t}function vs(e){var t=[];if(Array.isArray(e))for(var n=0;n<e.length;n++)t.push(cs(e[n]));else for(var r=0;r<e.length;r++)t.push(fs(e[r]));for(var i=[],a=0;a<t.length;a++){var o=ds(t[a],void 0===i[i.length-1]?null:i[i.length-1],void 0===t[a+1]?null:t[a+1]);null!==o&&i.push(o)}return i}function ps(e,n){var r,i=function(e,n){if(0===e.length||0===n.length)return null;var r=e[0].start,i=Array.isArray(n)?n[0].attributes.t:n[0].getAttribute("t"),a=t(i)?null:parseInt(i,10);if(null===a||Number.isNaN(a))return null;if(r===a)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(r<a)for(var o=e[0],s=0;;){if(o.repeatCount>0){var u=a-o.start;if(u%o.duration==0&&u/o.duration<=o.repeatCount)return{repeatNumberInPrevSegments:u/o.duration,prevSegmentsIdx:s,newElementsIdx:0,repeatNumberInNewElements:0}}if(++s>=e.length)return null;if((o=e[s]).start===a)return{prevSegmentsIdx:s,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(o.start>a)return null}else for(var l=0,d=Array.isArray(n)?n[0]:null,c=Array.isArray(n)?null:n[0],f=a;;){var v=null!==d?d.attributes.d:null==c?void 0:c.getAttribute("d"),p=t(v)?null:parseInt(v,10);if(null===p||Number.isNaN(p))return null;var h=null!==d?d.attributes.r:null==c?void 0:c.getAttribute("r"),m=t(h)?null:parseInt(h,10);if(null!==m){if(Number.isNaN(m)||m<0)return null;if(m>0){var g=r-f;if(g%p==0&&g/p<=m)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:g/p,prevSegmentsIdx:0,newElementsIdx:l}}f+=p*(m+1)}else f+=p;if(++l>=n.length)return null;Array.isArray(n)?d=n[l]:c=n[l];var y=null!==d?d.attributes.t:null==c?void 0:c.getAttribute("t"),_=t(y)?null:parseInt(y,10);if(null!==_){if(Number.isNaN(_))return null;f=_}if(f===r)return{newElementsIdx:l,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(f>a)return null}}(n,e);if(null===i)return B.warn('DASH: Cannot perform "based" update. Common segment not found.'),vs(e);var a=i.prevSegmentsIdx,o=i.newElementsIdx,s=i.repeatNumberInPrevSegments,u=i.repeatNumberInNewElements,l=n.length-a+o-1;if(l>=e.length)return B.info('DASH: Cannot perform "based" update. New timeline too short'),vs(e);var d=n.slice(a);if(s>0){var c=d[0];c.start+=c.duration*s,d[0].repeatCount-=s}if(u>0&&0!==o)return B.info('DASH: Cannot perform "based" update. The new timeline has a different form.'),vs(e);var f=d[d.length-1],v=Array.isArray(e)?cs(e[l]):fs(e[l]),p=(null!==(r=v.repeatCount)&&void 0!==r?r:0)-u;if(v.duration!==f.duration||f.repeatCount>p)return B.info('DASH: Cannot perform "based" update. The new timeline has a different form at the beginning.'),vs(e);void 0!==v.repeatCount&&v.repeatCount>f.repeatCount&&(f.repeatCount=v.repeatCount);var h=[],m=[];if(Array.isArray(e))for(var g=l+1;g<e.length;g++)m.push(cs(e[g]));else for(var y=l+1;y<e.length;y++)m.push(fs(e[y]));for(var _=0;_<m.length;_++){var b=ds(m[_],void 0===h[h.length-1]?f:h[h.length-1],void 0===m[_+1]?null:m[_+1]);null!==b&&h.push(b)}return d.concat(h)}var hs=function(){function e(n,r){var i,a,o,s,u;if(!e.isTimelineIndexArgument(n))throw new Error("The given index is not compatible with a TimelineRepresentationIndex.");var l=r.availabilityTimeComplete,d=r.availabilityTimeOffset,c=r.manifestBoundsCalculator,f=r.isDynamic,v=r.isLastPeriod,p=r.representationId,h=r.representationBitrate,m=r.periodStart,g=r.periodEnd,y=r.isEMSGWhitelisted,_=null!==(i=n.timescale)&&void 0!==i?i:1,b=(null!==(a=n.presentationTimeOffset)&&void 0!==a?a:0)-m*_;this._manifestBoundsCalculator=c,this._isEMSGWhitelisted=y,this._isLastPeriod=v,this._lastUpdate=null!==(o=r.receivedTime)&&void 0!==o?o:ye(),this._unsafelyBaseOnPreviousIndex=null,null!==r.unsafelyBaseOnPreviousRepresentation&&r.unsafelyBaseOnPreviousRepresentation.index instanceof e&&(r.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=r.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=f,this._parseTimeline=null!==(s=n.timelineParser)&&void 0!==s?s:null;var S,E=void 0===(null===(u=n.initialization)||void 0===u?void 0:u.media)?null:rs(n.initialization.media,p,h),T=void 0===n.media?null:rs(n.media,p,h);S=void 0===d&&void 0===l?1/0:null!=d?d:0,this._index={availabilityTimeComplete:null==l||l,availabilityTimeOffset:S,indexRange:n.indexRange,indexTimeOffset:b,initialization:t(n.initialization)?void 0:{url:E,range:n.initialization.range},segmentUrlTemplate:T,startNumber:n.startNumber,endNumber:n.endNumber,timeline:void 0===n.timeline?null:ms(n.timeline,n.startNumber,n.endNumber),timescale:_},this._scaledPeriodStart=Xa(m,this._index),this._scaledPeriodEnd=void 0===g?void 0:Xa(g,this._index)}var n=e.prototype;return n.getInitSegment=function(){return ts(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,t){this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var n=this._index;return as({segmentUrlTemplate:n.segmentUrlTemplate,startNumber:n.startNumber,endNumber:n.endNumber,timeline:n.timeline,timescale:n.timescale,indexTimeOffset:n.indexTimeOffset},e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)},n.shouldRefresh=function(){return!1},n.getFirstAvailablePosition=function(){this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var e=this._index.timeline;return 0===e.length?null:Za(Math.max(this._scaledPeriodStart,e[0].start),this._index)},n.getLastAvailablePosition=function(){var e;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=gs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);return null===t?null:Za(Math.min(t.end,null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)},n.getEnd=function(){var e;if(!this._isDynamic||this._isLastPeriod){if(this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;var t=this._index.timeline[this._index.timeline.length-1];return Za(Math.min($a(t,null,this._scaledPeriodEnd),null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0),this._index)}},n.awaitSegmentBetween=function(e,t){var n,r;if(fe(),!this._isDynamic)return!1;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var i=this._index,a=i.timescale,o=i.timeline,s=ls(a),u=Xa(t,this._index),l=gs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(null!==l&&Math.min(l.end,null!==(n=this._scaledPeriodEnd)&&void 0!==n?n:1/0)+s>=Math.min(u,null!==(r=this._scaledPeriodEnd)&&void 0!==r?r:1/0))return!1;var d=Xa(e,this._index);if(o.length>0&&null!==l&&!l.isLastOfTimeline&&d<$a(o[o.length-1],null,this._scaledPeriodEnd)+s+s)return!0;return!!this._isLastPeriod&&(void 0===this._scaledPeriodEnd?u+s>this._scaledPeriodStart&&void 0:d-s<this._scaledPeriodEnd&&u+s>this._scaledPeriodStart)},n.isSegmentStillAvailable=function(e){return!!e.isInit||(this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline()),function(e,n,r,i){var a=gs(n,r,i);if(null===a)return!1;for(var o=0;o<n.timeline.length;o++){if(a.timelineIdx<o)return!1;var s=n.timeline[o],u=(s.start-n.indexTimeOffset)/n.timescale;if(u>e.time)return!1;if(u===e.time)return void 0===s.range?void 0===e.range:!t(e.range)&&s.range[0]===e.range[0]&&s.range[1]===e.range[1];if(s.repeatCount>=0&&void 0!==s.duration){var l=(u-s.start)/s.duration-1;return l%1==0&&l<=a.newRepeatCount}}return!1}(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))},n.checkDiscontinuity=function(e){this._refreshTimeline();var t=this._index.timeline;return null===t&&(t=this._getTimeline(),this._index.timeline=t),Ja({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)},n.canBeOutOfSyncError=function(e){return!!this._isDynamic&&(e instanceof Ye&&e.isHttpError(404))},n._replace=function(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod},n._update=function(e){null===this._index.timeline&&(this._index.timeline=this._getTimeline()),null===e._index.timeline&&(e._index.timeline=e._getTimeline()),ao(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.availabilityTimeOffset=e._index.availabilityTimeOffset,this._index.availabilityTimeComplete=e._index.availabilityTimeComplete,this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod},n.isStillAwaitingFutureSegments=function(){var e;if(!this._isDynamic)return!1;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=this._index.timeline;if(0===t.length){if(void 0!==this._scaledPeriodEnd){var n=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(void 0!==n&&Xa(n,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}var r=ls(this._index.timescale),i=gs(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(null!==i&&!i.isLastOfTimeline){var a=Math.min(i.end,null!==(e=this._scaledPeriodEnd)&&void 0!==e?e:1/0);return!(void 0!==this._scaledPeriodEnd&&a+r>=this._scaledPeriodEnd)}return!!this._isLastPeriod&&(void 0===this._scaledPeriodEnd||$a(t[t.length-1],null,this._scaledPeriodEnd)+r<this._scaledPeriodEnd)},n.isInitialized=function(){return!0},n.initialize=function(){B.error("A `TimelineRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){B.warn("Cannot add predicted segments to a `TimelineRepresentationIndex`")},e.isTimelineIndexArgument=function(e){return"function"==typeof e.timelineParser||Array.isArray(e.timeline)},n._refreshTimeline=function(){if(null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._isDynamic){var e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(!t(e)){var n=Xa(e,this._index),r=io(this._index.timeline,n);void 0!==this._index.startNumber?this._index.startNumber+=r:void 0!==this._index.endNumber&&(this._index.startNumber=r+1)}}},n._getTimeline=function(){if(null===this._parseTimeline)return null!==this._index.timeline?this._index.timeline:(B.error("DASH: Timeline already lazily parsed."),[]);var e=this._parseTimeline();this._parseTimeline=null;var t,n=L.getCurrent().MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY;return null===this._unsafelyBaseOnPreviousIndex||e.length<n?ms(vs(e),this._index.startNumber,this._index.endNumber):(null===this._unsafelyBaseOnPreviousIndex._index.timeline?(t=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=t):t=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,ms(ps(e,t),this._index.startNumber,this._index.endNumber))},e}();function ms(e,t,n){if(void 0===n)return e;for(var r=null!=t?t:1,i=0;i<e.length;i++){var a=e[i];if((r+=a.repeatCount+1)>n){if(r===n+1)return e.slice(0,i+1);var o=e.slice(0,i),s=Object.assign({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,n-u),o.push(s),o}}return e}function gs(e,t,n){if(e.timeline.length<=0)return null;if(e.availabilityTimeOffset===1/0){var r=e.timeline.length-1,i=e.timeline[r];return{isLastOfTimeline:!0,timelineIdx:r,newRepeatCount:i.repeatCount,end:$a(i,null,n)}}var a=t.getEstimatedMaximumPosition(e.availabilityTimeOffset);if(void 0===a){var o=e.timeline.length-1,s=e.timeline[o];return{isLastOfTimeline:!0,timelineIdx:o,newRepeatCount:s.repeatCount,end:$a(s,null,n)}}for(var u=e.timeline.length-1;u>=e.timeline.length;u--){var l=e.timeline[u],d=l.start+l.duration;if(Za(d,e)<=a){if(Za($a(l,e.timeline[u+1],n),e)<=a)return{isLastOfTimeline:u===e.timeline.length-1,timelineIdx:u,newRepeatCount:l.repeatCount,end:d};var c=Xa(a,e)-l.start,f=Math.floor(c/l.duration);return fe(),{isLastOfTimeline:!1,timelineIdx:u,newRepeatCount:f-1,end:l.start+f*l.duration}}}return null}var ys=hs,_s=function(){function e(e,n){var r,i,a,o=n.availabilityTimeOffset,s=n.manifestBoundsCalculator,u=n.isDynamic,l=n.periodEnd,d=n.periodStart,c=n.representationId,f=n.representationBitrate,v=n.isEMSGWhitelisted,p=null!==(r=e.timescale)&&void 0!==r?r:1;this._availabilityTimeOffset=o,this._manifestBoundsCalculator=s;var h=null!==(i=e.presentationTimeOffset)&&void 0!==i?i:0,m=h-d*p;if(void 0===e.duration)throw new Error("Invalid SegmentTemplate: no duration");var g=void 0===(null===(a=e.initialization)||void 0===a?void 0:a.media)?null:rs(e.initialization.media,c,f),y=void 0===e.media?null:rs(e.media,c,f);this._index={duration:e.duration,timescale:p,indexRange:e.indexRange,indexTimeOffset:m,initialization:t(e.initialization)?void 0:{url:g,range:e.initialization.range},url:y,presentationTimeOffset:h,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=u,this._periodStart=d,this._scaledRelativePeriodEnd=void 0===l?void 0:(l-d)*p,this._isEMSGWhitelisted=v}var n=e.prototype;return n.getInitSegment=function(){return ts(this._index,this._isEMSGWhitelisted)},n.getSegments=function(e,n){var r=this._index,i=r.duration,a=r.startNumber,o=r.endNumber,s=r.timescale,u=r.url,l=this._periodStart*s,d=this._scaledRelativePeriodEnd,c=e*s-l,f=(e+n)*s-l,v=this._getFirstSegmentStart(),p=this._getLastSegmentStart();if(t(v)||t(p))return[];var h=Math.max(v,c),m=Math.min(p,f);if(m+i<=h)return[];for(var g=[],y=null!=a?a:1,_=Math.floor(h/i),b=_*i;b<=m;b+=i){var S=_+y;if(void 0!==o&&S>o)return g;var E=!t(d)&&b+i>d?d-b:i,T=b+l,k=b+this._index.presentationTimeOffset,w=null===u?null:is(k,S)(u),A={id:String(S),number:S,time:T/s,end:(T+E)/s,duration:E/s,timescale:1,isInit:!1,scaledDuration:E/s,url:w,timestampOffset:-r.indexTimeOffset/s,complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};g.push(A),_++}return g},n.getFirstAvailablePosition=function(){var e=this._getFirstSegmentStart();return t(e)?e:e/this._index.timescale+this._periodStart},n.getLastAvailablePosition=function(){var e=this._getLastSegmentStart();if(t(e))return e;var n=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,null!=n?n:1/0)/this._index.timescale+this._periodStart},n.getEnd=function(){if(!this._isDynamic)return this.getLastAvailablePosition();var e=this._estimateRelativeScaledEnd();if(void 0!==e){var t=this._index.timescale;return(e+this._periodStart*t)/t}},n.awaitSegmentBetween=function(e,n){if(fe(),!this._isDynamic)return!1;var r=this._index.timescale,i=ls(r),a=this._periodStart*r,o=e*r-a,s=n*r-a,u=this._getLastSegmentStart();if(t(u)){var l=this._estimateRelativeScaledEnd();return void 0===l?s+i>=0:s+i>=0&&o<l-i}var d=u+this._index.duration,c=this._estimateRelativeScaledEnd();return void 0===c?s>d-i:s>d-i&&o<c-i},n.shouldRefresh=function(){return!1},n.checkDiscontinuity=function(){return null},n.isSegmentStillAvailable=function(e){if(e.isInit)return!0;var t=this.getSegments(e.time,.1);return 0!==t.length&&(t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number)},n.canBeOutOfSyncError=function(){return!1},n.isStillAwaitingFutureSegments=function(){if(!this._isDynamic)return!1;var e=this._estimateRelativeScaledEnd();if(void 0===e)return!0;var n=this._index.timescale,r=this._getLastSegmentStart();return!!t(r)||r+this._index.duration+ls(n)<e},n.isInitialized=function(){return!0},n.initialize=function(){B.error("A `TemplateRepresentationIndex` does not need to be initialized")},n.addPredictedSegments=function(){B.warn("Cannot add predicted segments to a `TemplateRepresentationIndex`")},n._replace=function(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator},n._update=function(e){this._replace(e)},n._getFirstSegmentStart=function(){var e;if(!this._isDynamic)return 0;if(0===this._scaledRelativePeriodEnd||void 0===this._scaledRelativePeriodEnd){var t=this._manifestBoundsCalculator.getEstimatedMaximumPosition(null!==(e=this._availabilityTimeOffset)&&void 0!==e?e:0);if(void 0!==t&&t<this._periodStart)return null}var n=this._index,r=n.duration,i=n.timescale,a=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(void 0!==a){var o=a>this._periodStart?(a-this._periodStart)*i:0;return Math.floor(o/r)*r}},n._getLastSegmentStart=function(){var e,t,n=this._index,r=n.duration,i=n.timescale,a=n.endNumber,o=n.startNumber,s=void 0===o?1:o;if(this._isDynamic){var u=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(void 0!==u&&void 0!==this._scaledRelativePeriodEnd&&this._scaledRelativePeriodEnd<u-this._periodStart*this._index.timescale){var l=Math.ceil(this._scaledRelativePeriodEnd/r);return void 0!==a&&a-s+1<l&&(l=a-s+1),(l-1)*r}var d=this._manifestBoundsCalculator.getEstimatedMaximumPosition(null!==(e=this._availabilityTimeOffset)&&void 0!==e?e:0);if(void 0===d)return;var c=(d-this._periodStart)*i;if(c<0)return null;var f=Math.floor(c/r);return void 0!==a&&a-s+1<f&&(f=a-s+1),f<=0?null:(f-1)*r}var v=null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:0,p=Math.ceil(v/r);void 0!==a&&a-s+1<p&&(p=a-s+1);var h=(p-1)*r,m=L.getCurrent().MINIMUM_SEGMENT_SIZE*i;return void 0!==a||v-h>m||p<2?h:(p-2)*r},n._estimateRelativeScaledEnd=function(){var e,t;if(void 0!==this._index.endNumber){var n=this._index.endNumber-(null!==(e=this._index.startNumber)&&void 0!==e?e:1)+1;return Math.max(Math.min(n*this._index.duration,null!==(t=this._scaledRelativePeriodEnd)&&void 0!==t?t:1/0),0)}if(void 0!==this._scaledRelativePeriodEnd)return Math.max(this._scaledRelativePeriodEnd,0)},e}();function bs(e,t){var n;if(0===t.length)return e;var r=t.map((function(e){return{url:e.value}}));if(0===e.length)return r;for(var i=[],a=0;a<e.length;a++)for(var o=e[a],s=0;s<r.length;s++){var u=r[s],l=ka(o.url,u.url);i.push({url:l,serviceLocation:null!==(n=u.serviceLocation)&&void 0!==n?n:o.serviceLocation})}return i}function Ss(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Es(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Es(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Es(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ts(e){var t=e.adaptationProfiles,n=e.essentialProperties,r=e.supplementalProperties,i=e.manifestProfiles,a=e.codecs;if(-1!==((null!=t?t:"")+(null!=i?i:"")).indexOf("http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10")&&("hvc1.2.4.L153.B0"===a||"hev1.2.4.L153.B0"===a))return{colorDepth:10,eotf:"pq",colorSpace:"rec2020"};var o=Se([].concat(null!=n?n:[],null!=r?r:[]),(function(e){return"urn:mpeg:mpegB:cicp:TransferCharacteristics"===e.schemeIdUri}));if(void 0!==o)switch(o.value){case"15":return;case"16":return{eotf:"pq"};case"18":return{eotf:"hlg"}}return void 0!==a&&/^vp(08|09|10)/.exec(a)?function(e){var t,n,r,i=e.split("."),a=i[0],o=(i[1],i[2],i[3]),s=(i[4],i[5]),u=i[6],l=i[7];if(("vp08"===a||"vp09"===a||"vp10"===a)&&((void 0!==o&&"10"===o||"12"===o)&&(t=parseInt(o,10)),void 0!==u&&("16"===u?n="pq":"18"===u&&(n="hlg")),void 0!==s&&void 0!==l&&"09"===s&&"09"===l&&(r="rec2020"),void 0!==t&&void 0!==n))return{colorDepth:t,eotf:n,colorSpace:r}}(a):void 0}function ks(e,t,n){for(var r,i,a,o,s,u,l=[],d=function(){for(var e=u.value,d=void 0!==e.attributes.id?e.attributes.id:String(e.attributes.bitrate)+(void 0!==e.attributes.height?"-"+e.attributes.height:"")+(void 0!==e.attributes.width?"-"+e.attributes.width:"")+(void 0!==e.attributes.mimeType?"-"+e.attributes.mimeType:"")+(void 0!==e.attributes.codecs?"-"+e.attributes.codecs:"");l.some((function(e){return e.id===d}));)d+="-dup";var c,f=null!==(i=null===(r=n.unsafelyBaseOnPreviousAdaptation)||void 0===r?void 0:r.getRepresentation(d))&&void 0!==i?i:null,v=function(e,t){var n=[];if(void 0!==e.children.inbandEventStreams&&n.push.apply(n,e.children.inbandEventStreams),void 0!==t.children.inbandEventStreams&&n.push.apply(n,t.children.inbandEventStreams),0!==n.length)return n}(e,t),p=null!==(a=e.attributes.availabilityTimeComplete)&&void 0!==a?a:n.availabilityTimeComplete;void 0===e.attributes.availabilityTimeOffset&&void 0===n.availabilityTimeOffset||(c=(null!==(o=e.attributes.availabilityTimeOffset)&&void 0!==o?o:0)+(null!==(s=n.availabilityTimeOffset)&&void 0!==s?s:0));var h,m=function(e,t){var n,r,i,a=t.availabilityTimeOffset,o=t.manifestBoundsCalculator,s=t.isDynamic,u=t.end,l=t.start,d=t.receivedTime,c=t.unsafelyBaseOnPreviousRepresentation,f=t.inbandEventStreams,v={availabilityTimeComplete:void 0,availabilityTimeOffset:a,unsafelyBaseOnPreviousRepresentation:c,isEMSGWhitelisted:function(e){return void 0!==f&&f.some((function(t){return t.schemeIdUri===e.schemeIdUri}))},isLastPeriod:t.isLastPeriod,manifestBoundsCalculator:o,isDynamic:s,periodEnd:u,periodStart:l,receivedTime:d,representationBitrate:e.attributes.bitrate,representationId:e.attributes.id};if(void 0!==e.children.segmentBase){var p=e.children.segmentBase;i=new ss(p,v)}else if(void 0!==e.children.segmentList){var h=e.children.segmentList;i=new us(h,v)}else if(void 0!==e.children.segmentTemplate||t.parentSegmentTemplates.length>0){var m=t.parentSegmentTemplates.slice(),g=e.children.segmentTemplate;void 0!==g&&m.push(g);var y=P.apply(void 0,[{}].concat(m));void 0===y.availabilityTimeOffset&&void 0===t.availabilityTimeOffset||(v.availabilityTimeOffset=(null!==(n=y.availabilityTimeOffset)&&void 0!==n?n:0)+(null!==(r=t.availabilityTimeOffset)&&void 0!==r?r:0)),i=ys.isTimelineIndexArgument(y)?new ys(y,v):new _s(y,v)}else{var _=t.adaptation.children;if(void 0!==_.segmentBase){var b=_.segmentBase;i=new ss(b,v)}else if(void 0!==_.segmentList){var S=_.segmentList;i=new us(S,v)}else i=new _s({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:""},v)}return i}(e,P({},n,{availabilityTimeOffset:c,availabilityTimeComplete:p,unsafelyBaseOnPreviousRepresentation:f,adaptation:t,inbandEventStreams:v}));void 0===e.attributes.bitrate?(B.warn("DASH: No usable bitrate found in the Representation."),h=0):h=e.attributes.bitrate;var g,y,_,b=bs(n.baseURLs,e.children.baseURLs),S={bitrate:h,cdnMetadata:0===b.length?[{baseUrl:"",id:void 0}]:b.map((function(e){return{baseUrl:e.url,id:e.serviceLocation}})),index:m,id:d};void 0!==e.children.supplementalProperties&&Se(e.children.supplementalProperties,(function(e){return"tag:dolby.com,2018:dash:EC3_ExtensionType:2018"===e.schemeIdUri&&"JOC"===e.value}))&&(S.isSpatialAudio=!0),void 0!==e.attributes.codecs?g=e.attributes.codecs:void 0!==t.attributes.codecs&&(g=t.attributes.codecs),void 0!==g&&(g="mp4a.40.02"===g?"mp4a.40.2":g,S.codecs=g),void 0!==e.attributes.supplementalCodecs?y=e.attributes.supplementalCodecs:void 0!==t.attributes.supplementalCodecs&&(y=t.attributes.supplementalCodecs),void 0!==y&&(S.supplementalCodecs=mt(_=y)?_.trim().replace(es,", "):""),void 0!==e.attributes.frameRate?S.frameRate=e.attributes.frameRate:void 0!==t.attributes.frameRate&&(S.frameRate=t.attributes.frameRate),void 0!==e.attributes.height?S.height=e.attributes.height:void 0!==t.attributes.height&&(S.height=t.attributes.height),void 0!==e.attributes.mimeType?S.mimeType=e.attributes.mimeType:void 0!==t.attributes.mimeType&&(S.mimeType=t.attributes.mimeType),void 0!==e.attributes.width?S.width=e.attributes.width:void 0!==t.attributes.width&&(S.width=t.attributes.width);var E=void 0!==t.children.contentProtections?t.children.contentProtections:[];if(void 0!==e.children.contentProtections&&E.push.apply(E,e.children.contentProtections),E.length>0){var T=E.reduce((function(e,t){var n;if(void 0!==t.attributes.schemeIdUri&&"urn:uuid:"===t.attributes.schemeIdUri.substring(0,9)&&(n=t.attributes.schemeIdUri.substring(9).replace(/-/g,"").toLowerCase()),void 0!==t.attributes.keyId&&t.attributes.keyId.length>0){var r={keyId:t.attributes.keyId,systemId:n};void 0===e.keyIds?e.keyIds=[r]:e.keyIds.push(r)}if(void 0!==n){for(var i,a=[],o=Ss(t.children.cencPssh);!(i=o()).done;){var s=i.value;a.push({systemId:n,data:s})}if(a.length>0){var u,l=Se(e.initData,(function(e){return"cenc"===e.type}));if(void 0===l)e.initData.push({type:"cenc",values:a});else(u=l.values).push.apply(u,a)}}return e}),{keyIds:void 0,initData:[]});(Object.keys(T.initData).length>0||void 0!==T.keyIds&&T.keyIds.length>0)&&(S.contentProtections=T)}S.hdrInfo=Ts({adaptationProfiles:t.attributes.profiles,supplementalProperties:t.children.supplementalProperties,essentialProperties:t.children.essentialProperties,manifestProfiles:n.manifestProfiles,codecs:g}),l.push(S)},c=Ss(e);!(u=c()).done;)d();return l}function ws(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return As(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return As(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function As(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Is(e){if(void 0===e)return!1;var t="urn:tva:metadata:cs:AudioPurposeCS:2007"===e.schemeIdUri&&"1"===e.value,n="urn:mpeg:dash:role:2011"===e.schemeIdUri&&"description"===e.value;return t||n}function Rs(e,t){if(void 0!==e&&e.some((function(e){return"urn:tva:metadata:cs:AudioPurposeCS:2007"===e.schemeIdUri&&"2"===e.value})))return!0;if(void 0!==t&&t.some((function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri&&"caption"===e.value})))return!0;return!1}function xs(e){return void 0!==e&&("urn:mpeg:dash:role:2011"===e.schemeIdUri&&"sign"===e.value)}function Cs(e,t){if(mt(e.attributes.id))return e.attributes.id;var n=t.isClosedCaption,r=t.isForcedSubtitle,i=t.isAudioDescription,a=t.isSignInterpreted,o=t.isTrickModeTrack,s=t.type;return mt(e.attributes.language)&&(s+="-"+e.attributes.language),!0===n&&(s+="-cc"),!0===r&&(s+="-cc"),!0===i&&(s+="-ad"),!0===a&&(s+="-si"),o&&(s+="-trickMode"),mt(e.attributes.contentType)&&(s+="-"+e.attributes.contentType),mt(e.attributes.codecs)&&(s+="-"+e.attributes.codecs),mt(e.attributes.mimeType)&&(s+="-"+e.attributes.mimeType),void 0!==e.attributes.frameRate&&(s+="-"+String(e.attributes.frameRate)),s}function Ms(e){if(!t(e.children.supplementalProperties))for(var n,r=ws(e.children.supplementalProperties);!(n=r()).done;){var i=n.value;if("urn:mpeg:dash:adaptation-set-switching:2016"===i.schemeIdUri&&!t(i.value))return i.value.split(",").map((function(e){return e.trim()})).filter((function(e){return e}))}return[]}function Ps(e,t){var n=t[1].priority-e[1].priority;return 0!==n?n:e[1].isMainAdaptation!==t[1].isMainAdaptation?e[1].isMainAdaptation?-1:1:e[1].indexInMpd-t[1].indexInMpd}function Ds(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Ns(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ns(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ns(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Os=Ze();function Ls(e,n){var r,i,o,s,u=[],l=function(e,n){var r=[];return e.forEach((function(i,a){var o,s;if(t(i.attributes.start))if(0===a)o=!n.isDynamic||t(n.availabilityStartTime)?0:n.availabilityStartTime;else{var u=r[r.length-1];if(t(u)||t(u.periodEnd))throw new Error("Missing start time when parsing periods.");o=u.periodEnd}else o=i.attributes.start;var l=e[a+1];t(i.attributes.duration)?a===e.length-1?s=n.duration:t(l.attributes.start)||(s=l.attributes.start-o):s=i.attributes.duration;var d=t(s)?void 0:o+s;r.push({periodStart:o,periodDuration:s,periodEnd:d})})),r}(e,n);if(l.length!==e.length)throw new Error("MPD parsing error: the time information are incoherent.");var d=n.isDynamic,c=n.manifestBoundsCalculator;d||t(n.duration)||c.setLastPosition(n.duration);for(var f=function(){var f,p=v===e.length-1,h=e[v],m=n.xlinkInfos.get(h),g=bs(n.baseURLs,h.children.baseURLs),y=l[v],_=y.periodStart,b=y.periodDuration,S=y.periodEnd;for(t(h.attributes.id)?(B.warn("DASH: No usable id found in the Period. Generating one."),f="gen-dash-period-"+Os()):f=h.attributes.id;u.some((function(e){return e.id===f}));)f+="-dup";var E=void 0!==m?m.receivedTime:n.receivedTime,T=null!==(i=null===(r=n.unsafelyBaseOnPreviousManifest)||void 0===r?void 0:r.getPeriod(f))&&void 0!==i?i:null,k=h.attributes.availabilityTimeComplete,w=h.attributes.availabilityTimeOffset,A=n.manifestProfiles,I=h.children.segmentTemplate,R={availabilityTimeComplete:k,availabilityTimeOffset:w,baseURLs:g,manifestBoundsCalculator:c,end:S,isDynamic:d,isLastPeriod:p,manifestProfiles:A,receivedTime:E,segmentTemplate:I,start:_,unsafelyBaseOnPreviousPeriod:T},x=function(e,n){for(var r,i,a,o,s,u,l,d={video:[],audio:[],text:[]},c=[],f={},v=[],p=0;p<e.length;p++){var h=e[p],m=h.children,g=m.essentialProperties,y=m.roles,_=m.label,b=Array.isArray(y)&&y.some((function(e){return"main"===e.value}))&&y.some((function(e){return"urn:mpeg:dash:role:2011"===e.schemeIdUri})),S=h.children.representations,E=null!==(r=h.attributes.availabilityTimeComplete)&&void 0!==r?r:n.availabilityTimeComplete,T=void 0;void 0===h.attributes.availabilityTimeOffset&&void 0===n.availabilityTimeOffset||(T=(null!==(i=h.attributes.availabilityTimeOffset)&&void 0!==i?i:0)+(null!==(a=n.availabilityTimeOffset)&&void 0!==a?a:0));var k=h.attributes.mimeType,w=h.attributes.codecs,A=Jo(S,mt(k)?k:null,mt(w)?w:null,t(m.roles)?null:m.roles);if(void 0!==A){var I=null!==(o=h.attributes.selectionPriority)&&void 0!==o?o:1,R=h.attributes.id,x=Ms(h),C=[];void 0!==n.segmentTemplate&&C.push(n.segmentTemplate),void 0!==h.children.segmentTemplate&&C.push(h.children.segmentTemplate);var M={availabilityTimeComplete:E,availabilityTimeOffset:T,baseURLs:bs(n.baseURLs,m.baseURLs),manifestBoundsCalculator:n.manifestBoundsCalculator,end:n.end,isDynamic:n.isDynamic,isLastPeriod:n.isLastPeriod,manifestProfiles:n.manifestProfiles,parentSegmentTemplates:C,receivedTime:n.receivedTime,start:n.start,unsafelyBaseOnPreviousAdaptation:null},P=Array.isArray(g)?Se(g,(function(e){return"http://dashif.org/guidelines/trickmode"===e.schemeIdUri})):void 0,D=null===(s=null==P?void 0:P.value)||void 0===s?void 0:s.split(" "),N=void 0!==D,O=m.accessibilities,L=void 0;void 0!==y&&y.some((function(e){return"dub"===e.value}))&&(L=!0);var U=void 0;U="text"===A&&Rs(O,y);var F=void 0;"text"===A&&void 0!==y&&y.some((function(e){return"forced-subtitle"===e.value||"forced_subtitle"===e.value}))&&(F=!0);var z=void 0;"audio"!==A?z=!1:void 0!==O&&(z=O.some(Is));var V=void 0;"video"!==A?V=!1:void 0!==O&&(V=O.some(xs));for(var K=Cs(h,{isAudioDescription:z,isForcedSubtitle:F,isClosedCaption:U,isSignInterpreted:V,isTrickModeTrack:N,type:A});Je(v,K);)K+="-dup";var W=K;v.push(K),M.unsafelyBaseOnPreviousAdaptation=null!==(l=null===(u=n.unsafelyBaseOnPreviousPeriod)||void 0===u?void 0:u.getAdaptation(K))&&void 0!==l?l:null;var G={id:K,representations:ks(S,h,M),type:A,isTrickModeTrack:N};if(t(h.attributes.language)||(G.language=h.attributes.language),t(U)||(G.closedCaption=U),t(z)||(G.audioDescription=z),!0===L&&(G.isDub=!0),void 0!==F&&(G.forcedSubtitles=F),!0===V&&(G.isSignInterpreted=!0),void 0!==_&&(G.label=_),void 0!==D)c.push({adaptation:G,trickModeAttachedAdaptationIds:D});else{for(var H,j=-1,q=function(){var e=H.value,t=f[e];if(void 0!==t&&t.newID!==W&&Je(t.adaptationSetSwitchingIDs,R)){j=te(d[A],(function(t){return t[0].id===e}));var n,r=d[A][j];if(void 0!==r&&r[0].audioDescription===G.audioDescription&&r[0].closedCaption===G.closedCaption&&r[0].language===G.language)return B.info('DASH Parser: merging "switchable" AdaptationSets',R,e),(n=r[0].representations).push.apply(n,G.representations),r[1]={priority:Math.max(I,r[1].priority),isMainAdaptation:b||r[1].isMainAdaptation,indexInMpd:Math.min(p,r[1].indexInMpd)},1}},Y=ws(x);!(H=Y()).done&&!q(););j<0&&d[A].push([G,{priority:I,isMainAdaptation:b,indexInMpd:p}])}!t(R)&&t(f[R])&&(f[R]={newID:W,adaptationSetSwitchingIDs:x})}}var Q=nt.reduce((function(e,t){var n=d[t];return n.length>0&&(n.sort(Ps),e[t]=n.map((function(e){return e[0]}))),e}),{});return d.video.sort(Ps),Xo(Q,c),Q}(h.children.adaptations,R),C=(null!==(o=n.xmlNamespaces)&&void 0!==o?o:[]).concat(null!==(s=h.attributes.namespaces)&&void 0!==s?s:[]),M=function(e,t,n){for(var r,i,o,s=[],u=Ds(e);!(o=u()).done;)for(var l,d=o.value,c=d.attributes,f=c.schemeIdUri,v=void 0===f?"":f,p=c.timescale,h=void 0===p?1:p,m=n.concat(null!==(r=d.attributes.namespaces)&&void 0!==r?r:[]),g=Ds(d.children.events);!(l=g()).done;){var y=l.value;if(void 0!==y.eventStreamData){var _=(null!==(i=y.presentationTime)&&void 0!==i?i:0)/h+t,b=void 0===y.duration?void 0:_+y.duration/h,S=void 0,E=void 0;if(!a&&y.eventStreamData instanceof Element)S=y.eventStreamData;else try{E={namespaces:m,data:"string"==typeof y.eventStreamData?y.eventStreamData:Ma(new Uint8Array(y.eventStreamData))}}catch(e){B.error("DASH: Error while parsing event-stream:",e instanceof Error?e.message:"Unknown error")}s.push({start:_,end:b,id:y.id,data:{type:"dash-event-stream",value:{schemeIdUri:v,timescale:h,element:S,xmlData:E}}})}}return s}(h.children.eventStreams,_,C),P={id:f,start:_,end:S,duration:b,adaptations:x,streamEvents:M};if(u.unshift(P),!c.lastPositionIsKnown()){var D=function(e){for(var n,r=null,i=!0,a=Ds(Yo(De(e).filter((function(e){return!t(e)})),(function(e){return e})));!(n=a()).done;)for(var o,s=Ds(n.value.representations);!(o=s()).done;){var u=o.value.index.getLastAvailablePosition();null!==u&&(i=!1,"number"==typeof u&&(r=t(r)?u:Math.max(r,u)))}if(!t(r))return r;if(i)return null;return}(x);if(d)if("number"==typeof D){var N=ye()/1e3;c.setLastPosition(D,N)}else{var O=Us(n,_);if(void 0!==O){var L=O[0],U=O[1];c.setLastPosition(L,U)}}else"number"==typeof D&&c.setLastPosition(D)}},v=e.length-1;v>=0;v--)f();if(n.isDynamic&&!c.lastPositionIsKnown()){var p=Us(n,0);if(void 0!==p){var h=p[0],m=p[1];c.setLastPosition(h,m)}}return function(e){if(0===e.length)return[];for(var t=[e[0]],n=1;n<e.length;n++){for(var r=e[n],i=t[t.length-1];(void 0===i.duration||i.start+i.duration>r.start)&&(B.warn("DASH: Updating overlapping Periods.",null==i?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0))&&(t.pop(),0!==t.length);)i=t[t.length-1];t.push(r)}return t}(u)}function Us(e,n){if(t(e.clockOffset)){var r=Date.now()/1e3;if(r>=n)return B.warn("DASH Parser: no clock synchronization mechanism found. Using the system clock instead."),[r-e.availabilityStartTime,ye()/1e3]}else{var i=e.clockOffset/1e3-e.availabilityStartTime,a=ye()/1e3,o=a+i;if(o>=n)return[o,a]}}function Fs(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Bs(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Bs(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Bs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var zs=function e(n,r,i,a,o){void 0===o&&(o=new WeakMap);var s=n.children,u=n.attributes;if(t(r.externalClockOffset)){var l="dynamic"===u.type,d=Se(s.utcTimings,(function(e){return"urn:mpeg:dash:utc:direct:2014"===e.schemeIdUri&&!t(e.value)})),c=t(d)||t(d.value)?void 0:Wo(d.value),f=t(c)||isNaN(c)?void 0:c;if(t(f)||!0===a){if(l&&!0!==a){var v=function(e){var t=e.children.utcTimings.filter((function(e){return("urn:mpeg:dash:utc:http-iso:2014"===e.schemeIdUri||"urn:mpeg:dash:utc:http-xsdate:2014"===e.schemeIdUri)&&void 0!==e.value}));return t.length>0?t[0].value:void 0}(n);if(!t(v)&&v.length>0)return{type:"needs-clock",value:{url:v,continue:function(t){return t.success?(r.externalClockOffset=Wo(t.data),e(n,r,i,!0)):(i.push(t.error),B.warn("DASH Parser: Error on fetching the clock ressource",t.error),e(n,r,i,!0))}}}}}else r.externalClockOffset=f}for(var p=[],h=0;h<s.periods.length;h++){var m=s.periods[h].attributes,g=m.xlinkHref,y=m.xlinkActuate;t(g)||"onLoad"!==y||p.push({index:h,ressource:g})}return 0===p.length?function(e,n,r,i){var a,o,s,u,l,d,c,f=e.children,v=e.attributes,p="dynamic"===v.type,h=void 0!==n.url?[{url:n.url.substring(0,wa(n.url))}]:[],m=bs(h,f.baseURLs),g=function(e,n){return"dynamic"!==e.type?0:t(e.availabilityStartTime)?null!=n?n:0:e.availabilityStartTime}(v,n.referenceDateTime),y=v.timeShiftBufferDepth,_=n.externalClockOffset,b=n.unsafelyBaseOnPreviousManifest,S=n.externalClockOffset,E=new qo({availabilityStartTime:g,isDynamic:p,timeShiftBufferDepth:y,serverTimestampOffset:S}),T={availabilityStartTime:g,baseURLs:m,clockOffset:_,duration:v.duration,isDynamic:p,manifestBoundsCalculator:E,manifestProfiles:e.attributes.profiles,receivedTime:n.manifestReceivedTime,timeShiftBufferDepth:y,unsafelyBaseOnPreviousManifest:b,xlinkInfos:i,xmlNamespaces:e.attributes.namespaces},k=Ls(f.periods,T),w=v.duration,A=null;void 0!==v.minimumUpdatePeriod&&v.minimumUpdatePeriod>=0&&(l=0===v.minimumUpdatePeriod?L.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:v.minimumUpdatePeriod);var I=jo(k),R=I.minimumSafePosition,x=I.maximumSafePosition,C=I.maximumUnsafePosition,M=ye();if(p){var P;if(void 0!==x)P=x;else if(void 0===S)B.warn("DASH Parser: use system clock to define maximum position"),P=Date.now()/1e3-g;else P=(ye()+S)/1e3-g;var D=E.getEstimatedLiveEdge();void 0===D&&(D=void 0!==C?C:P),c={isLinear:!0,maximumSafePosition:P,livePosition:D,time:M},d=R,null!==(A=null!=y?y:null)&&void 0!==d&&D-d>A&&(A=D-d)}else{void 0===(d=R)&&(d=null!==(o=null===(a=k[0])||void 0===a?void 0:a.start)&&void 0!==o?o:0);var N=null!=w?w:1/0;if(void 0!==k[k.length-1]){var O=k[k.length-1],U=null!==(s=O.end)&&void 0!==s?s:void 0!==O.duration?O.start+O.duration:void 0;void 0!==U&&U<N&&(N=U)}void 0!==x&&x<N&&(N=x),c={isLinear:!1,maximumSafePosition:N,livePosition:void 0,time:M}}var F=!p||void 0===e.attributes.minimumUpdatePeriod&&(void 0!==(null===(u=k[k.length-1])||void 0===u?void 0:u.end)||void 0!==e.attributes.duration),z={availabilityStartTime:g,clockOffset:n.externalClockOffset,isDynamic:p,isLive:p,isLastPeriodKnown:F,periods:k,publishTime:v.publishTime,suggestedPresentationDelay:v.suggestedPresentationDelay,transportType:"dash",timeBounds:{minimumSafePosition:d,timeshiftDepth:A,maximumTimeData:c},lifetime:l,uris:t(n.url)?f.locations:[n.url].concat(f.locations)};return{type:"done",value:{parsed:z,warnings:r}}}(n,r,i,o):{type:"needs-xlinks",value:{xlinksUrls:p.map((function(e){return e.ressource})),continue:function(t){if(t.length!==p.length)throw new Error("DASH parser: wrong number of loaded ressources.");for(var u=t.length-1;u>=0;u--){var l,d=p[u].index,c=t[u],f=c.parsed,v=c.warnings,h=c.receivedTime,m=c.sendingTime,g=c.url;v.length>0&&i.push.apply(i,v);for(var y,_=Fs(f);!(y=_()).done;){var b=y.value;o.set(b,{receivedTime:h,sendingTime:m,url:g})}(l=s.periods).splice.apply(l,[d,1].concat(f))}return e(n,r,i,a,o)}}}};function Vs(e){var t=e.textContent,n=[];return null===t||0===t.length?[void 0,n]:[{value:t},n]}function Ks(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"id":t.id=r.value;break;case"lang":t.language=r.value;break;case"contentType":t.contentType=r.value;break;case"par":t.par=r.value}}return t}var Ws=/^P(([\d.]*)Y)?(([\d.]*)M)?(([\d.]*)D)?T?(([\d.]*)H)?(([\d.]*)M)?(([\d.]*)S)?/,Gs=/([0-9]+)-([0-9]+)/;function Hs(e,t){return"true"===e?[!0,null]:"false"===e?[!1,null]:[!1,new nu("`"+t+'` property is not a boolean value but "'+e+'"')]}function js(e,t){var n=parseInt(e,10);return isNaN(n)?[null,new nu("`"+t+'` property is not an integer value but "'+e+'"')]:[n,null]}function qs(e,t){if("INF"===e)return[1/0,null];var n=parseFloat(e);return isNaN(n)?[null,new nu("`"+t+'` property is invalid: "'+e+'"')]:[n,null]}function Ys(e,t){if("true"===e)return[!0,null];if("false"===e)return[!1,null];var n=parseInt(e,10);return isNaN(n)?[null,new nu("`"+t+'` property is not a boolean nor an integer but "'+e+'"')]:[n,null]}function Qs(e,t){var n=Date.parse(e);return isNaN(n)?[null,new nu("`"+t+'` is in an invalid date format: "'+e+'"')]:[new Date(Date.parse(e)).getTime()/1e3,null]}function $s(e,t){if(!mt(e))return[0,new nu("`"+t+"` property is empty")];var n=Ws.exec(e);return null===n?[null,new nu("`"+t+'` property has an unrecognized format "'+e+'"')]:[365*parseFloat(mt(n[2])?n[2]:"0")*24*60*60+30*parseFloat(mt(n[4])?n[4]:"0")*24*60*60+24*parseFloat(mt(n[6])?n[6]:"0")*60*60+60*parseFloat(mt(n[8])?n[8]:"0")*60+60*parseFloat(mt(n[10])?n[10]:"0")+parseFloat(mt(n[12])?n[12]:"0"),null]}function Xs(e,t){var n=Gs.exec(e);return null===n?[null,new nu("`"+t+'` property has an unrecognized format "'+e+'"')]:[[+n[1],+n[2]],null]}function Zs(e,t){try{return[ja(e),null]}catch(n){return[null,new nu("`"+t+'` is not a valid base64 string: "'+e+'"')]}}function Js(e,t){var n=/^(\d+)\/(\d+)$/.exec(e);return null!==n?[+n[1]/+n[2],null]:qs(e,t)}function eu(e){for(var t,n,r=0;r<e.attributes.length;r++){var i=e.attributes[r];switch(i.name){case"schemeIdUri":t=i.value;break;case"value":n=i.value}}return{schemeIdUri:t,value:n}}function tu(e,t){return function(n,r){var i=r.asKey,a=(0,r.parser)(n,r.dashName),o=a[0],s=a[1];null!==s&&(B.warn(s.message),t.push(s)),null!==o&&(e[i]=o)}}var nu=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(se(r),t.prototype),r.name="MPDError",r.message=n,r}return f(t,e),t}(de(Error));function ru(e){var t=function(e){for(var t=[],n=[],r=0;r<e.length;r++)if(e[r].nodeType===Node.ELEMENT_NODE){var i=e[r];if("cenc:pssh"===i.nodeName){var a=i.textContent;if(null!==a&&a.length>0){var o=Zs(a,"cenc:pssh"),s=o[0],u=o[1];null!==u&&(B.warn(u.message),t.push(u)),null!==s&&n.push(s)}}}return[{cencPssh:n},t]}(e.childNodes),n=t[0],r=t[1];return[{children:n,attributes:function(e){for(var t={},n=0;n<e.attributes.length;n++){var r=e.attributes[n];switch(r.name){case"schemeIdUri":t.schemeIdUri=r.value;break;case"value":t.value=r.value;break;case"cenc:default_KID":t.keyId=Pa(r.value.replace(/-/g,""))}}return t}(e)},r]}function iu(e){for(var t={},n=[],r=tu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"range":r(a.value,{asKey:"range",parser:Xs,dashName:"range"});break;case"sourceURL":t.media=a.value}}return[t,n]}function au(e){for(var t={},n=[],r=tu(t,n),i=e.childNodes,a=0;a<i.length;a++)if(i[a].nodeType===Node.ELEMENT_NODE){var o=i[a];if("Initialization"===o.nodeName){var s=iu(o),u=s[0],l=s[1];t.initialization=u,n=n.concat(l)}}for(var d=0;d<e.attributes.length;d++){var c=e.attributes[d];switch(c.name){case"timescale":r(c.value,{asKey:"timescale",parser:js,dashName:"timescale"});break;case"presentationTimeOffset":r(c.value,{asKey:"presentationTimeOffset",parser:qs,dashName:"presentationTimeOffset"});break;case"indexRange":r(c.value,{asKey:"indexRange",parser:Xs,dashName:"indexRange"});break;case"indexRangeExact":r(c.value,{asKey:"indexRangeExact",parser:Hs,dashName:"indexRangeExact"});break;case"availabilityTimeOffset":r(c.value,{asKey:"availabilityTimeOffset",parser:qs,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(c.value,{asKey:"availabilityTimeComplete",parser:Hs,dashName:"availabilityTimeComplete"});break;case"duration":r(c.value,{asKey:"duration",parser:js,dashName:"duration"});break;case"startNumber":r(c.value,{asKey:"startNumber",parser:js,dashName:"startNumber"});break;case"endNumber":r(c.value,{asKey:"endNumber",parser:js,dashName:"endNumber"})}}return[t,n]}function ou(e){for(var t={},n=[],r=tu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"media":t.media=a.value;break;case"indexRange":r(a.value,{asKey:"indexRange",parser:Xs,dashName:"indexRange"});break;case"index":t.index=a.value;break;case"mediaRange":r(a.value,{asKey:"mediaRange",parser:Xs,dashName:"mediaRange"})}}return[t,n]}function su(e){for(var t=au(e),n=t[0],r=t[1],i=[],a=e.childNodes,o=0;o<a.length;o++)if(a[o].nodeType===Node.ELEMENT_NODE){var s=a[o];if("SegmentURL"===s.nodeName){var u=ou(s),l=u[0],d=u[1];i.push(l),r=r.concat(d)}}return[P(n,{list:i}),r]}function uu(e){var t=null;return function(){if(null===t){var n=e.getElementsByTagName("S");return t=n,n}return t}}function lu(e){for(var n,r=au(e),i=r[0],a=r[1],o=0;o<e.childNodes.length;o++)if(e.childNodes[o].nodeType===Node.ELEMENT_NODE){var s=e.childNodes[o];"SegmentTimeline"===s.nodeName&&(n=uu(s))}for(var u=P({},i,{duration:i.duration,timelineParser:n}),l=tu(u,a),d=0;d<e.attributes.length;d++){var c=e.attributes[d];switch(c.nodeName){case"initialization":t(u.initialization)&&(u.initialization={media:c.value});break;case"index":u.index=c.value;break;case"availabilityTimeOffset":l(c.value,{asKey:"availabilityTimeOffset",parser:qs,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":l(c.value,{asKey:"availabilityTimeComplete",parser:Hs,dashName:"availabilityTimeComplete"});break;case"media":u.media=c.value;break;case"bitstreamSwitching":l(c.value,{asKey:"bitstreamSwitching",parser:Hs,dashName:"bitstreamSwitching"})}}return[u,a]}function du(e){var n=function(e){for(var n={baseURLs:[]},r=[],i=[],a=0;a<e.length;a++)if(e[a].nodeType===Node.ELEMENT_NODE){var o=e[a];switch(o.nodeName){case"BaseURL":var s=Vs(o),u=s[0],l=s[1];void 0!==u&&n.baseURLs.push(u),i=i.concat(l);break;case"InbandEventStream":void 0===n.inbandEventStreams&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(eu(o));break;case"SegmentBase":var d=au(o),c=d[0],f=d[1];n.segmentBase=c,f.length>0&&(i=i.concat(f));break;case"SegmentList":var v=su(o),p=v[0],h=v[1];i=i.concat(h),n.segmentList=p;break;case"SegmentTemplate":var m=lu(o),g=m[0],y=m[1];i=i.concat(y),n.segmentTemplate=g;break;case"ContentProtection":var _=ru(o),b=_[0],S=_[1];S.length>0&&(i=i.concat(S)),void 0!==b&&r.push(b);break;case"SupplementalProperty":t(n.supplementalProperties)?n.supplementalProperties=[eu(o)]:n.supplementalProperties.push(eu(o))}}return r.length>0&&(n.contentProtections=r),[n,i]}(e.childNodes),r=n[0],i=n[1],a=function(e){for(var t={},n=[],r=tu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"audioSamplingRate":t.audioSamplingRate=a.value;break;case"bandwidth":r(a.value,{asKey:"bitrate",parser:js,dashName:"bandwidth"});break;case"codecs":t.codecs=a.value;break;case"codingDependency":r(a.value,{asKey:"codingDependency",parser:Hs,dashName:"codingDependency"});break;case"frameRate":r(a.value,{asKey:"frameRate",parser:Js,dashName:"frameRate"});break;case"height":r(a.value,{asKey:"height",parser:js,dashName:"height"});break;case"id":t.id=a.value;break;case"maxPlayoutRate":r(a.value,{asKey:"maxPlayoutRate",parser:qs,dashName:"maxPlayoutRate"});break;case"maximumSAPPeriod":r(a.value,{asKey:"maximumSAPPeriod",parser:qs,dashName:"maximumSAPPeriod"});break;case"mimeType":t.mimeType=a.value;break;case"profiles":t.profiles=a.value;break;case"qualityRanking":r(a.value,{asKey:"qualityRanking",parser:js,dashName:"qualityRanking"});break;case"scte214:supplementalCodecs":t.supplementalCodecs=a.value;break;case"segmentProfiles":t.segmentProfiles=a.value;break;case"width":r(a.value,{asKey:"width",parser:js,dashName:"width"});break;case"availabilityTimeOffset":r(a.value,{asKey:"availabilityTimeOffset",parser:qs,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(a.value,{asKey:"availabilityTimeComplete",parser:Hs,dashName:"availabilityTimeComplete"})}}return void 0===t.bitrate&&n.push(new nu("No bitrate found on a Representation")),[t,n]}(e),o=a[0],s=a[1];return[{children:r,attributes:o},i.concat(s)]}function cu(e){var n=function(e){for(var n={baseURLs:[],representations:[]},r=[],i=[],a=0;a<e.length;a++)if(e[a].nodeType===Node.ELEMENT_NODE){var o=e[a];switch(o.nodeName){case"Accessibility":void 0===n.accessibilities?n.accessibilities=[eu(o)]:n.accessibilities.push(eu(o));break;case"BaseURL":var s=Vs(o),u=s[0],l=s[1];void 0!==u&&n.baseURLs.push(u),l.length>0&&(i=i.concat(l));break;case"ContentComponent":n.contentComponent=Ks(o);break;case"EssentialProperty":t(n.essentialProperties)?n.essentialProperties=[eu(o)]:n.essentialProperties.push(eu(o));break;case"InbandEventStream":void 0===n.inbandEventStreams&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(eu(o));break;case"Label":var d=o.textContent;null!=d&&(n.label=d);break;case"Representation":var c=du(o),f=c[0],v=c[1];n.representations.push(f),v.length>0&&(i=i.concat(v));break;case"Role":t(n.roles)?n.roles=[eu(o)]:n.roles.push(eu(o));break;case"SupplementalProperty":t(n.supplementalProperties)?n.supplementalProperties=[eu(o)]:n.supplementalProperties.push(eu(o));break;case"SegmentBase":var p=au(o),h=p[0],m=p[1];n.segmentBase=h,m.length>0&&(i=i.concat(m));break;case"SegmentList":var g=su(o),y=g[0],_=g[1];n.segmentList=y,_.length>0&&(i=i.concat(_));break;case"SegmentTemplate":var b=lu(o),S=b[0],E=b[1];n.segmentTemplate=S,E.length>0&&(i=i.concat(E));break;case"ContentProtection":var T=ru(o),k=T[0],w=T[1];w.length>0&&(i=i.concat(w)),void 0!==k&&r.push(k)}}return r.length>0&&(n.contentProtections=r),[n,i]}(e.childNodes),r=n[0],i=n[1],a=function(e){for(var t={},n=[],r=tu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"group":r(a.value,{asKey:"group",parser:js,dashName:"group"});break;case"lang":t.language=a.value;break;case"contentType":t.contentType=a.value;break;case"par":t.par=a.value;break;case"minBandwidth":r(a.value,{asKey:"minBitrate",parser:js,dashName:"minBandwidth"});break;case"maxBandwidth":r(a.value,{asKey:"maxBitrate",parser:js,dashName:"maxBandwidth"});break;case"minWidth":r(a.value,{asKey:"minWidth",parser:js,dashName:"minWidth"});break;case"maxWidth":r(a.value,{asKey:"maxWidth",parser:js,dashName:"maxWidth"});break;case"minHeight":r(a.value,{asKey:"minHeight",parser:js,dashName:"minHeight"});break;case"maxHeight":r(a.value,{asKey:"maxHeight",parser:js,dashName:"maxHeight"});break;case"minFrameRate":r(a.value,{asKey:"minFrameRate",parser:Js,dashName:"minFrameRate"});break;case"maxFrameRate":r(a.value,{asKey:"maxFrameRate",parser:Js,dashName:"maxFrameRate"});break;case"selectionPriority":r(a.value,{asKey:"selectionPriority",parser:js,dashName:"selectionPriority"});break;case"segmentAlignment":r(a.value,{asKey:"segmentAlignment",parser:Ys,dashName:"segmentAlignment"});break;case"subsegmentAlignment":r(a.value,{asKey:"subsegmentAlignment",parser:Ys,dashName:"subsegmentAlignment"});break;case"bitstreamSwitching":r(a.value,{asKey:"bitstreamSwitching",parser:Hs,dashName:"bitstreamSwitching"});break;case"audioSamplingRate":t.audioSamplingRate=a.value;break;case"codecs":t.codecs=a.value;break;case"scte214:supplementalCodecs":t.supplementalCodecs=a.value;break;case"codingDependency":r(a.value,{asKey:"codingDependency",parser:Hs,dashName:"codingDependency"});break;case"frameRate":r(a.value,{asKey:"frameRate",parser:Js,dashName:"frameRate"});break;case"height":r(a.value,{asKey:"height",parser:js,dashName:"height"});break;case"maxPlayoutRate":r(a.value,{asKey:"maxPlayoutRate",parser:qs,dashName:"maxPlayoutRate"});break;case"maximumSAPPeriod":r(a.value,{asKey:"maximumSAPPeriod",parser:qs,dashName:"maximumSAPPeriod"});break;case"mimeType":t.mimeType=a.value;break;case"profiles":t.profiles=a.value;break;case"segmentProfiles":t.segmentProfiles=a.value;break;case"width":r(a.value,{asKey:"width",parser:js,dashName:"width"});break;case"availabilityTimeOffset":r(a.value,{asKey:"availabilityTimeOffset",parser:qs,dashName:"availabilityTimeOffset"});break;case"availabilityTimeComplete":r(a.value,{asKey:"availabilityTimeComplete",parser:Hs,dashName:"availabilityTimeComplete"})}}return[t,n]}(e),o=a[0],s=a[1];return[{children:r,attributes:o},i.concat(s)]}function fu(e){for(var t={children:{events:[]},attributes:{}},n=[],r=tu(t.attributes,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"schemeIdUri":t.attributes.schemeIdUri=a.value;break;case"timescale":r(a.value,{asKey:"timescale",parser:js,dashName:"timescale"});break;case"value":t.attributes.value=a.value}}for(var o=0;o<e.childNodes.length;o++)if(e.childNodes[o].nodeType===Node.ELEMENT_NODE){var s=e.childNodes[o];if("Event"===s.nodeName){var u=vu(s),l=u[0],d=u[1];t.children.events.push(l),d.length>0&&(n=n.concat(d))}}return[t,n]}function vu(e){for(var t={eventStreamData:e},n=[],r=tu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"presentationTime":r(a.value,{asKey:"presentationTime",parser:js,dashName:"presentationTime"});break;case"duration":r(a.value,{asKey:"duration",parser:js,dashName:"duration"});break;case"id":t.id=a.value}}return[t,n]}function pu(e){var t=function(e){for(var t,n=[],r=[],i=[],a=[],o=0;o<e.length;o++)if(e[o].nodeType===Node.ELEMENT_NODE){var s=e[o];switch(s.nodeName){case"BaseURL":var u=Vs(s),l=u[0],d=u[1];void 0!==l&&n.push(l),i=i.concat(d);break;case"AdaptationSet":var c=cu(s),f=c[0],v=c[1];r.push(f),i=i.concat(v);break;case"EventStream":var p=fu(s),h=p[0],m=p[1];a.push(h),i=i.concat(m);break;case"SegmentTemplate":var g=lu(s),y=g[0],_=g[1];t=y,_.length>0&&(i=i.concat(_))}}return[{baseURLs:n,adaptations:r,eventStreams:a,segmentTemplate:t},i]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=tu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"start":r(a.value,{asKey:"start",parser:$s,dashName:"start"});break;case"duration":r(a.value,{asKey:"duration",parser:$s,dashName:"duration"});break;case"bitstreamSwitching":r(a.value,{asKey:"bitstreamSwitching",parser:Hs,dashName:"bitstreamSwitching"});break;case"xlink:href":t.xlinkHref=a.value;break;case"xlink:actuate":t.xlinkActuate=a.value}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}function hu(e){var t=function(e){for(var t=[],n=[],r=[],i=[],a=[],o=0;o<e.length;o++)if(e[o].nodeType===Node.ELEMENT_NODE){var s=e[o];switch(s.nodeName){case"BaseURL":var u=Vs(s),l=u[0],d=u[1];void 0!==l&&t.push(l),a=a.concat(d);break;case"Location":n.push(null===s.textContent?"":s.textContent);break;case"Period":var c=pu(s),f=c[0],v=c[1];r.push(f),a=a.concat(v);break;case"UTCTiming":var p=eu(s);i.push(p)}}return[{baseURLs:t,locations:n,periods:r,utcTimings:i},a]}(e.childNodes),n=t[0],r=t[1],i=function(e){for(var t={},n=[],r=tu(t,n),i=0;i<e.attributes.length;i++){var a=e.attributes[i];switch(a.name){case"id":t.id=a.value;break;case"profiles":t.profiles=a.value;break;case"type":t.type=a.value;break;case"availabilityStartTime":r(a.value,{asKey:"availabilityStartTime",parser:Qs,dashName:"availabilityStartTime"});break;case"availabilityEndTime":r(a.value,{asKey:"availabilityEndTime",parser:Qs,dashName:"availabilityEndTime"});break;case"publishTime":r(a.value,{asKey:"publishTime",parser:Qs,dashName:"publishTime"});break;case"mediaPresentationDuration":r(a.value,{asKey:"duration",parser:$s,dashName:"mediaPresentationDuration"});break;case"minimumUpdatePeriod":r(a.value,{asKey:"minimumUpdatePeriod",parser:$s,dashName:"minimumUpdatePeriod"});break;case"minBufferTime":r(a.value,{asKey:"minBufferTime",parser:$s,dashName:"minBufferTime"});break;case"timeShiftBufferDepth":r(a.value,{asKey:"timeShiftBufferDepth",parser:$s,dashName:"timeShiftBufferDepth"});break;case"suggestedPresentationDelay":r(a.value,{asKey:"suggestedPresentationDelay",parser:$s,dashName:"suggestedPresentationDelay"});break;case"maxSegmentDuration":r(a.value,{asKey:"maxSegmentDuration",parser:$s,dashName:"maxSegmentDuration"});break;case"maxSubsegmentDuration":r(a.value,{asKey:"maxSubsegmentDuration",parser:$s,dashName:"maxSubsegmentDuration"})}}return[t,n]}(e),a=i[0],o=i[1];return[{children:n,attributes:a},r.concat(o)]}var mu=function(e,n){var r=e.documentElement;if(t(r)||"MPD"!==r.nodeName)throw new Error("DASH Parser: document root should be MPD");var i=hu(r),a=i[0],o=i[1];return function e(n){if("done"===n.type)return n;if("needs-clock"===n.type)return{type:"needs-resources",value:{urls:[n.value.url],format:"string",continue:function(t){if(1!==t.length)throw new Error("DASH parser: wrong number of loaded ressources.");var r=n.value.continue(t[0].responseData);return e(r)}}};if("needs-xlinks"===n.type)return{type:"needs-resources",value:{urls:n.value.xlinksUrls,format:"string",continue:function(r){for(var i=[],a=0;a<r.length;a++){var o=r[a],s=o.responseData,u=o.receivedTime,l=o.sendingTime,d=o.url;if(!s.success)throw s.error;var c="<root>"+s.data+"</root>",f=(new DOMParser).parseFromString(c,"text/xml");if(t(f)||0===f.children.length)throw new Error("DASH parser: Invalid external ressources");for(var v=f.children[0].children,p=[],h=[],m=0;m<v.length;m++)if(v[m].nodeType===Node.ELEMENT_NODE){var g=pu(v[m]),y=g[0],_=g[1];h.push.apply(h,_),p.push(y)}i.push({url:d,receivedTime:u,sendingTime:l,parsed:p,warnings:h})}var b=n.value.continue(i);return e(b)}}};ve()}(zs(a,n,o))};function gu(e){var t=e.referenceDateTime,n=void 0!==e.serverSyncInfos?e.serverSyncInfos.serverTimestamp-e.serverSyncInfos.clientTime:void 0;return function(r,i,a,o,s){var u,l=r.responseData,d=i.externalClockOffset,c=null!==(u=r.url)&&void 0!==u?u:i.originalUrl,f=null!=n?n:d,v={unsafelyBaseOnPreviousManifest:i.unsafeMode?i.previousManifest:null,url:c,referenceDateTime:t,externalClockOffset:f},p=Et.dashParsers;if(null===p.wasm||"uninitialized"===p.wasm.status||"failure"===p.wasm.status)return B.debug("DASH: WASM MPD Parser not initialized. Running JS one."),m();var h=function(e){if(e instanceof ArrayBuffer)return e;if("string"==typeof e)return xa(e).buffer;if(e instanceof Document)return xa(e.documentElement.innerHTML).buffer;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return function(e){var t=new DataView(e);if(61371===t.getUint16(0)&&191===t.getUint8(2))return!0;if(65279===t.getUint16(0)||65534===t.getUint16(0))return!1;return!0}(h)?"initialized"===p.wasm.status?(B.debug("DASH: Running WASM MPD Parser."),g(p.wasm.runWasmParser(h,v))):(B.debug("DASH: Awaiting WASM initialization before parsing the MPD."),p.wasm.waitForInitialization().catch((function(){})).then((function(){return null===p.wasm||"initialized"!==p.wasm.status?(B.warn("DASH: WASM MPD parser initialization failed. Running JS parser instead"),m()):(B.debug("DASH: Running WASM MPD Parser."),g(p.wasm.runWasmParser(h,v)))}))):(B.info("DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one."),m());function m(){if(null!==p.fastJs){var e=function(e){if(e instanceof ArrayBuffer)return Ma(new Uint8Array(e));if("string"==typeof e)return e;if(e instanceof Document)return e.documentElement.outerHTML;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return g(p.fastJs(e,v))}if(null!==p.native){var t=function(e){if(e instanceof ArrayBuffer)return(new DOMParser).parseFromString(Ma(new Uint8Array(e)),"text/xml");if("string"==typeof e)return(new DOMParser).parseFromString(e,"text/xml");if(e instanceof Document)return e;throw new Error("DASH Manifest Parser: Unrecognized Manifest format")}(l);return g(p.native(t,v))}throw new Error("No MPD parser is imported")}function g(t){if("done"===t.type){if(t.value.warnings.length>0&&a(t.value.warnings),o.isCancelled())return Promise.reject(o.cancellationError);var n=[];return{manifest:new Wt(t.value.parsed,e,n),url:c,warnings:n}}var r=t.value,i=r.urls.map((function(e){return s((function(){var t=L.getCurrent().DEFAULT_REQUEST_TIMEOUT,n=L.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return"string"===r.format?po({url:e,responseType:"text",timeout:t,connectionTimeout:n,cancelSignal:o}):po({url:e,responseType:"arraybuffer",timeout:t,connectionTimeout:n,cancelSignal:o})})).then((function(e){if("string"===r.format){if("string"!=typeof e.responseData)throw new Error("External DASH resources should have been a string");return P(e,{responseData:{success:!0,data:e.responseData}})}if(!(e.responseData instanceof ArrayBuffer))throw new Error("External DASH resources should have been ArrayBuffers");return P(e,{responseData:{success:!0,data:e.responseData}})}),(function(e){var t=Xe(e,{defaultCode:"PIPELINE_PARSE_ERROR",defaultReason:"An unknown error occured when parsing ressources."});return P({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:t}})}))}));return Promise.all(i).then((function(e){return r.format,g(r.continue(e))}))}}}var yu="function"==typeof Headers?Headers:null,_u="function"==typeof AbortController?AbortController:null;function bu(){return"function"==typeof s.fetch&&!t(_u)&&!t(yu)}function Su(e,t){return"audio"===e||"video"===e?"video/mp4"===t||"audio/mp4"===t?"mp4":"video/webm"===t||"audio/webm"===t?"webm":void 0:"text"===e&&"application/mp4"===t?"mp4":void 0}function Eu(e){return function(t,n,r,i,a){return new Promise((function(s,u){var l=new pe,d=l.linkToSignal(i);function c(){l.signal.deregister(u),d()}l.signal.register(u),e(t,n,r,l.signal,Object.assign(Object.assign({},a),{onNewChunk:function(e){try{o(e),a.onNewChunk(e)}catch(e){c(),l.cancel(),u(e)}}})).then((function(e){if(c(),!l.isUsed()){if("segment-loaded"===e.resultType)try{o(e.resultData.responseData)}catch(e){return void u(e)}s(e)}}),(function(e){c(),u(e)}))}));function o(e){(e instanceof ArrayBuffer||e instanceof Uint8Array)&&"mp4"===Su(n.type,n.mimeType)&&mo(new Uint8Array(e),n.segment.isInit)}}}function Tu(e,t){return null===e?null:null===t.url?e.baseUrl:ka(e.baseUrl,t.url)}function ku(e,t,n,r,i){if(void 0===t.range)return po({url:e,responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(void 0===t.indexRange)return po({url:e,headers:{Range:Do(t.range)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));if(t.range[1]+1===t.indexRange[0])return po({url:e,headers:{Range:Do([t.range[0],t.indexRange[1]])},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}));var a=po({url:e,headers:{Range:Do(t.range)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),o=po({url:e,headers:{Range:Do(t.indexRange)},responseType:"arraybuffer",timeout:n.timeout,connectionTimeout:n.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then((function(t){var n=t[0],r=t[1],i=vi(new Uint8Array(n.responseData),new Uint8Array(r.responseData)),a=Math.min(n.sendingTime,r.sendingTime),o=Math.max(n.receivedTime,r.receivedTime);return{resultType:"segment-loaded",resultData:{url:e,responseData:i,size:n.size+r.size,requestDuration:o-a,sendingTime:a,receivedTime:o}}}))}function wu(e,n,r,i,a){var o=n.segment,s=void 0!==o.range?{Range:Do(o.range)}:void 0,u=null;return function(e){var n;if(!t(e.headers))if(t(yu))n=e.headers;else{n=new yu;for(var r=Object.keys(e.headers),i=0;i<r.length;i++){var a=r[i];n.append(a,e.headers[a])}}B.debug("Fetch: Called with URL",e.url);var o,s,u=null,l=!1,c=!1,f=ye(),v=t(_u)?null:new _u;function p(){t(v)?B.warn("Fetch: AbortController API not available."):v.abort()}void 0!==e.timeout&&(o=setTimeout((function(){l=!0,void 0!==s&&clearTimeout(s),p()}),e.timeout)),void 0!==e.connectionTimeout&&(s=setTimeout((function(){c=!0,void 0!==o&&clearTimeout(o),p()}),e.connectionTimeout));var h=e.cancelSignal.register((function(e){u=e,p()})),m={method:"GET"};return void 0!==n&&(m.headers=n),m.signal=t(v)?null:v.signal,fetch(e.url,m).then((function(n){if(void 0!==s&&clearTimeout(s),n.status>=300)throw B.warn("Fetch: Request HTTP Error",n.status,n.url),new ze(n.url,n.status,Ve.ERROR_HTTP_CODE);if(t(n.body))throw new ze(n.url,n.status,Ve.PARSE_ERROR);var r=n.headers.get("Content-Length"),i=t(r)||isNaN(+r)?void 0:+r,a=n.body.getReader(),u=0;return l();function l(){return c.apply(this,arguments)}function c(){return(c=d(g().mark((function r(){var s,d,c,v,p;return g().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,a.read();case 2:if((s=r.sent).done||t(s.value)){r.next=11;break}return u+=s.value.byteLength,d=ye(),c={url:n.url,currentTime:d,duration:d-f,sendingTime:f,chunkSize:s.value.byteLength,chunk:s.value.buffer,size:u,totalSize:i},e.onData(c),r.abrupt("return",l());case 11:if(!s.done){r.next=17;break}return void 0!==o&&clearTimeout(o),h(),v=ye(),p=v-f,r.abrupt("return",{requestDuration:p,receivedTime:v,sendingTime:f,size:u,status:n.status,url:n.url});case 17:return r.abrupt("return",l());case 18:case"end":return r.stop()}}),r)})))).apply(this,arguments)}})).catch((function(t){if(null!==u)throw u;if(h(),l)throw B.warn("Fetch: Request timed out."),new ze(e.url,0,Ve.TIMEOUT);if(c)throw B.warn("Fetch: Request connection timed out."),new ze(e.url,0,Ve.TIMEOUT);if(t instanceof ze)throw t;throw B.warn("Fetch: Request Error",t instanceof Error?t.toString():""),new ze(e.url,0,Ve.ERROR_EVENT)}))}({url:e,headers:s,onData:function(e){var t=new Uint8Array(e.chunk),n=function(e){for(var t=0,n=[],r=null;t<=e.length;){if(t===e.length){r=null;break}var i=ho(r=e.subarray(t,1/0),1836019558);if(i<0)break;var a=t+i+mi(e,i+t);if(a>e.length)break;var o=ho(r,1835295092);if(o<0)break;var s=t+o+mi(e,o+t);if(s>e.length)break;var u=Math.max(a,s),l=e.subarray(t,u);n.push(l),t=u}return 0===n.length?[null,r]:[vi.apply(void 0,n),r]}(null!==u?vi(u,t):t),r=n[0];u=n[1],null!==r&&(i.onNewChunk(r),a.isCancelled())||(i.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize}),a.isCancelled())},timeout:r.timeout,cancelSignal:a}).then((function(e){return{resultType:"chunk-complete",resultData:e}}))}function Au(e,t,n,r,i,a){if(t.segment.isInit)return ku(e,t.segment,r,a,i);var o=Su(t.type,t.mimeType);if(n&&("mp4"===o||void 0===o)){if(bu())return wu(e,t,r,i,a);tt("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}var s=t.segment;return po({url:e,responseType:"arraybuffer",headers:void 0!==s.range?{Range:Do(s.range)}:void 0,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}var Iu="function"==typeof Uint8Array.prototype.slice?function(e,t,n){return e.slice(t,n)}:function(e,t,n){return new Uint8Array(Array.prototype.slice.call(e,t,n))};function Ru(e,t){if(e[t]>1)B.warn("ISOBMFF: un-handled PSSH version");else{var n=t+4;if(!(n+16>e.length))return Da(Iu(e,n,n+16))}}var xu=408125543,Cu=357149030,Mu=2807729,Pu=17545,Du=475249515,Nu=187,Ou=179,Lu=183,Uu=241;function Fu(e,t,n,r){for(var i=r[0],a=r[1],o=i;o<a;){var s=Ku(n,o);if(null===s)return null;var u=s.value,l=o+s.length,d=Wu(n,l);if(null===d)return null;var c=l+d.length,f=c+d.value;if(u===e)return[c,f];if(t.length>0)for(var v=0;v<t.length;v++){if(u===t[v])return Fu(e,t.slice(v+1,t.length),n,[c,f])}o=f}return null}function Bu(e,t){var n=Fu(Mu,[xu,Cu],e,[t,e.length]);if(null===n)return null;var r=n[1]-n[0];return 1e9/Gu(e,n[0],r)}function zu(e,t){var n=Fu(Pu,[xu,Cu],e,[t,e.length]);if(null===n)return null;var r=n[1]-n[0];return 4===r?function(e,t){return new DataView(e.buffer).getFloat32(t)}(e,n[0]):8===r?function(e,t){return new DataView(e.buffer).getFloat64(t)}(e,n[0]):null}function Vu(e,t){for(var n=1;n<=8;n++)if(e[t]>=Math.pow(2,8-n))return n}function Ku(e,t){var n=Vu(e,t);if(void 0===n)return B.warn("webm: unrepresentable length"),null;if(t+n>e.length)return B.warn("webm: impossible length"),null;for(var r=0,i=0;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return{length:n,value:r}}function Wu(e,t){var n=Vu(e,t);if(void 0===n)return B.warn("webm: unrepresentable length"),null;if(t+n>e.length)return B.warn("webm: impossible length"),null;for(var r=(e[t]&(1<<8-n)-1)*Math.pow(2,8*(n-1)),i=1;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return{length:n,value:r}}function Gu(e,t,n){for(var r=0,i=0;i<n;i++)r=e[t+i]*Math.pow(2,8*(n-i-1))+r;return r}function Hu(e,t,n,r){var i=function(e){var t=ya(e);if(null!==t){var n=pa(t,1952867444);if(null!==n){var r=n[0];return 1===r?gi(n,4):0===r?mi(n,4):void 0}}}(e);if(void 0===i||void 0===r)return null;var a,o=void 0!==n.timestampOffset?i+n.timestampOffset*r:i,s=Eo(e);if(o<0&&(void 0!==s&&(s+=o),o=0),t||!n.complete)return void 0===s&&B.warn("DASH: Chunked segments should indicate a duration through their trun boxes"),{time:o/r,duration:void 0!==s?s/r:void 0};var u=n.duration*r,l=Math.min(.9*r,u/4);return void 0!==s&&Math.abs(s-u)<=l&&(a=s),{time:o/r,duration:void 0!==a?a/r:a}}function ju(e,t){if(0!==e.length){var n=e.reduce((function(e,t){return"urn:mpeg:dash:event:2012"===t.schemeIdUri&&"1"===t.value?(void 0===e.manifestRefreshEventsFromEMSGs&&(e.manifestRefreshEventsFromEMSGs=[]),e.manifestRefreshEventsFromEMSGs.push(t)):(void 0===e.EMSGs&&(e.EMSGs=[]),e.EMSGs.push(t)),e}),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),r=n.manifestRefreshEventsFromEMSGs,i=n.EMSGs,a=null==i?void 0:i.map((function(e){return{type:"emsg",value:e}})),o=void 0!==t&&void 0!==r&&function(e,t){if(e.length<=0)return!1;for(var n=e.length,r=0;r<n;r++){var i=t,a=Ma(e[r].messageData),o=Date.parse(a);if(void 0===i||void 0===o||isNaN(o)||o>=i)return!0}return!1}(r,t);return{inbandEvents:a,needsManifestRefresh:o}}}function qu(e){var n=e.__priv_patchLastSegmentInSidx;return function(e,r,i){var a,o,s=r.segment,u=r.periodStart,l=r.periodEnd,d=e.data,c=e.isChunked,f=[u,l];if(null===d)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:f};var v=d instanceof Uint8Array?d:new Uint8Array(d),p=Su(r.type,r.mimeType),h="mp4"===p||void 0===p,m=[];if(h){var g,y=function(e){var t=0,n=pa(e,1836019574);if(null===n)return[];for(var r=[];t<n.length;){var i=void 0;try{i=ha(n,1886614376)}catch(e){var a=e instanceof Error?e:"";return B.warn("Error while removing PSSH from ISOBMFF",a),r}if(null===i)return r;var o=Iu(n,i[0],i[2]),s=Ru(o,i[1]-i[0]);void 0!==s&&r.push({systemId:s,data:o}),n[i[0]+4]=102,n[i[0]+5]=114,n[i[0]+6]=101,n[i[0]+7]=101,t=i[2]}return r}(v);s.isInit&&(g=null!==(a=function(e){var t=va(e,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(null===t)return null;var n=t.subarray(8),r=pa(n,1701733238),i=0;if(null===r?(i=28,r=pa(n,1701733217)):i=78,null===r)return null;var a=va(r.subarray(i),[1936289382,1935894633,1952804451]);return null===a||a.byteLength<24?null:a.subarray(8,24)}(v))&&void 0!==a?a:void 0),(y.length>0||void 0!==g)&&m.push({initDataType:"cenc",keyId:g,initData:y})}if(!s.isInit){var _=h?Hu(v,c,s,i):null,b=null!==(o=s.timestampOffset)&&void 0!==o?o:0;if(h){var S=function(e){for(var t=[],n=0;n<e.length;){var r=Sa(e,n);if(null===r)break;var i=r.length;n+=i;var a=r[0];if(0!==a)B.warn("ISOBMFF: EMSG version "+a.toString()+" not supported.");else{var o=4,s=Oa(r,o),u=s.end,l=s.string,d=Oa(r,o=u),c=d.end,f=d.string,v=mi(r,o=c),p=mi(r,o+=4),h=mi(r,o+=4),m=mi(r,o+=4);o+=4;var g={schemeIdUri:l,value:f,timescale:v,presentationTimeDelta:p,eventDuration:h,id:m,messageData:r.subarray(o,i)};t.push(g)}}if(0!==t.length)return t}(v);if(void 0!==S){var E=ju(S.filter((function(e){return void 0!==s.privateInfos&&void 0!==s.privateInfos.isEMSGWhitelisted&&s.privateInfos.isEMSGWhitelisted(e)})),r.manifestPublishTime);if(void 0!==E){var T=E.needsManifestRefresh,k=E.inbandEvents;return{segmentType:"media",chunkData:v,chunkSize:v.length,chunkInfos:_,chunkOffset:b,appendWindow:f,inbandEvents:k,protectionData:m,needsManifestRefresh:T}}}}return{segmentType:"media",chunkData:v,chunkSize:v.length,chunkInfos:_,chunkOffset:b,protectionData:m,appendWindow:f}}var w,A,I=s.indexRange;if("webm"===p)w=function(e,t){var n=Fu(xu,[],e,[t,e.length]);if(null===n)return null;var r=n[0],i=n[1],a=Bu(e,r);if(null===a)return null;var o=zu(e,r);if(null===o)return null;var s=Fu(Du,[],e,[r,i]);if(null===s)return null;for(var u=[],l=s[0];l<s[1];){var d=Fu(Nu,[],e,[l,s[1]]);if(null===d)break;var c=Fu(Ou,[],e,[d[0],d[1]]);if(null===c)return null;var f=Gu(e,c[0],c[1]-c[0]),v=Fu(Uu,[Lu],e,[d[0],d[1]]);if(null===v)return null;var p=Gu(e,v[0],v[1]-v[0])+r;u.push({time:f,rangeStart:p}),l=d[1]}for(var h=[],m=0;m<u.length;m++){var g=u[m];m===u.length-1?h.push({time:g.time,timescale:a,duration:0===m?o:o-g.time,range:[g.rangeStart,1/0]}):h.push({time:g.time,timescale:a,duration:u[m+1].time-g.time,range:[g.rangeStart,u[m+1].rangeStart-1]})}return h}(v,0);else if(h&&(w=bo(v,Array.isArray(I)?I[0]:0),!0===n&&null!==w&&w.length>0)){var R=w[w.length-1];Array.isArray(R.range)&&(R.range[1]=1/0)}h?A=To(v):"webm"===p&&(A=Bu(v,0));var x=t(A)?void 0:A;return{segmentType:"init",initializationData:v,initializationDataSize:v.length,protectionData:m,initTimescale:x,segmentList:null!=w?w:void 0}}}function Yu(e,t,n,r){var i,a,o=e.segment,s=e.language,u=e.codecs;if(o.isInit)return null;null===n?r?(i=o.time,a=o.end):B.warn("Transport: Unavailable time data for current text track."):(i=n.time,void 0!==n.duration?a=i+n.duration:!r&&o.complete&&(a=i+o.duration));var l=function(e){if(void 0===e)throw new Error("Cannot parse subtitles: unknown format");switch(e.toLowerCase()){case"stpp":case"stpp.ttml.im1t":return"ttml";case"wvtt":return"vtt"}throw new Error('The codec used for the subtitles "'+e+'" is not managed yet.')}(u),d=function(e){var t=ba(e);return null===t?"":Ma(t)}(t);return{data:d,type:l,language:s,start:i,end:a}}function Qu(e,t,n){var r,i,a=e.segment;return a.isInit?null:(n?B.warn("Transport: Unavailable time data for current text track."):(r=a.time,a.complete&&(i=a.time+a.duration)),{data:t,type:function(e,t){switch(t){case"application/ttml+xml":return"ttml";case"application/x-sami":case"application/smil":return"sami";case"text/vtt":return"vtt"}if(void 0!==e&&"srt"===e.toLowerCase())return"srt";throw new Error("could not find a text-track parser for the type "+(null!=t?t:""))}(e.codecs,e.mimeType),language:e.language,start:r,end:i})}function $u(e){var t=e.__priv_patchLastSegmentInSidx;return function(e,n,r){var i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=e.data,l=e.isChunked;if(null===u)return s.isInit?{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:"media",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:null!==(i=s.timestampOffset)&&void 0!==i?i:0,protectionData:[],appendWindow:[a,o]};var d=Su(n.type,n.mimeType);if("webm"===d)throw new Error("Text tracks with a WEBM container are not yet handled.");return"mp4"===d?function(e,t,n,r,i){var a,o,s=n.segment,u=s.isInit,l=s.indexRange;if(o="string"==typeof e?xa(e):e instanceof Uint8Array?e:new Uint8Array(e),u){var d=bo(o,Array.isArray(l)?l[0]:0);if(!0===i&&null!==d&&d.length>0){var c=d[d.length-1];Array.isArray(c.range)&&(c.range[1]=1/0)}return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:To(o),segmentList:null!=d?d:void 0}}var f=Hu(o,t,s,r),v=Yu(n,o,f,t),p=null!==(a=s.timestampOffset)&&void 0!==a?a:0;return{segmentType:"media",chunkData:v,chunkSize:o.length,chunkInfos:f,chunkOffset:p,protectionData:[],appendWindow:[n.periodStart,n.periodEnd]}}(u,l,n,r,t):function(e,t,n){var r,i,a=n.periodStart,o=n.periodEnd,s=n.segment,u=s.timestampOffset,l=void 0===u?0:u;if(s.isInit)return{segmentType:"init",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};if("string"!=typeof e){var d=e instanceof Uint8Array?e:new Uint8Array(e);r=Ma(d),i=d.length}else r=e;return{segmentType:"media",chunkData:Qu(n,r,t),chunkSize:i,chunkInfos:null,chunkOffset:l,protectionData:[],appendWindow:[a,o]}}(u,l,n)}}var Xu=function(e){var t=go({customManifestLoader:e.manifestLoader},null===Et.dashParsers.wasm||"initialized"!==Et.dashParsers.wasm.status&&"initializing"!==Et.dashParsers.wasm.status?"arraybuffer":"text"),n=gu(e),r=function(e){var t=e.lowLatencyMode,n=e.segmentLoader;return!0!==e.checkMediaSegmentIntegrity?r:Eu(r);function r(e,r,i,a,o){var s=Tu(e,r.segment);return null===s?Promise.resolve({resultType:"segment-created",resultData:null}):t||void 0===n?Au(s,r,t,i,o,a):new Promise((function(e,u){var l,d=!1,c={reject:function(e){var t,n;if(!d&&!a.isCancelled()){d=!0,a.deregister(p);var r=e,i=null!==(t=null==r?void 0:r.message)&&void 0!==t?t:"Unknown error when fetching a DASH segment through a custom segmentLoader.",o=new Ht(i,null!==(n=null==r?void 0:r.canRetry)&&void 0!==n&&n,null==r?void 0:r.xhr);u(o)}},resolve:function(t){d||a.isCancelled()||(d=!0,a.deregister(p),e({resultType:"segment-loaded",resultData:{responseData:t.data,size:t.size,requestDuration:t.duration}}))},progress:function(e){d||a.isCancelled()||o.onProgress({duration:e.duration,size:e.size,totalSize:e.totalSize})},fallback:function(){d||a.isCancelled()||(d=!0,a.deregister(p),Au(s,r,t,i,o,a).then(e,u))}};void 0!==r.segment.range&&(l=[r.segment.range],void 0!==r.segment.indexRange&&l.push(r.segment.indexRange));var f={isInit:r.segment.isInit,timeout:i.timeout,byteRanges:l,trackType:r.type,url:s},v=n(f,c);function p(e){d||(d=!0,"function"==typeof v&&v(),u(e))}a.register(p)}))}}(e),i=qu(e),a=function(e){var t=e.lowLatencyMode;return!0!==e.checkMediaSegmentIntegrity?n:Eu(n);function n(e,n,r,i,a){var o=n.segment,s=o.range,u=Tu(e,o);if(null===u)return Promise.resolve({resultType:"segment-created",resultData:null});if(o.isInit)return ku(u,o,r,i,a);var l=Su(n.type,n.mimeType),d="mp4"===l||void 0===l;if(t&&d){if(bu())return wu(u,n,r,a,i);tt("DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge")}return d?po({url:u,responseType:"arraybuffer",headers:Array.isArray(s)?{Range:Do(s)}:null,timeout:r.timeout,connectionTimeout:r.connectionTimeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}})):po({url:u,responseType:"text",headers:Array.isArray(s)?{Range:Do(s)}:null,timeout:r.timeout,connectionTimeout:r.connectionTimeout,onProgress:a.onProgress,cancelSignal:i}).then((function(e){return{resultType:"segment-loaded",resultData:e}}))}}(e);return{manifest:{loadManifest:t,parseManifest:n},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:$u(e)}}};function Zu(e){void 0===e.transports.dash&&(e.transports.dash=Xu),e.dashParsers.native=mu,e.mainThreadMediaSourceInit=oa,e.codecSupportProber=da}var Ju=function(e){function n(t){var n;return(n=e.call(this)||this)._settings=t,n._initCanceller=new pe,n}f(n,e);var r=n.prototype;return r.prepare=function(){},r.start=function(e,t){var n=this,r=this._initCanceller.signal,i=this._settings,a=i.keySystems,o=i.speed,s=i.url;Hr(e);var u=new oe(null);u.finish();var l=Wi(e,a,u,{onError:function(e){return n._onFatalError(e)},onWarning:function(e){return n.trigger("warning",e)},onBlackListProtectionData:U,onKeyIdsCompatibilityUpdate:U},r);ra(e,(function(e){return n._onFatalError(e)}),r);var d=new ji(t,null,o);d.addEventListener("stalled",(function(e){return n.trigger("stalled",e)})),d.addEventListener("unstalled",(function(){return n.trigger("unstalled",null)})),d.addEventListener("warning",(function(e){return n.trigger("warning",e)})),r.register((function(){d.destroy()})),d.start(),l.onUpdate((function(i,a){"uninitialized"!==i.initializationState.type&&(a(),B.info("Setting URL to HTMLMediaElement",s),e.src=s,r.register((function(){B.info("Init: Removing directfile src from media element",e.src),Hr(e)})),"awaiting-media-link"===i.initializationState.type?(i.initializationState.value.isMediaLinked.setValue(!0),l.onUpdate((function(r,i){"initialized"===r.initializationState.type&&(i(),n._seekAndPlay(e,t))}),{emitCurrentValue:!0,clearSignal:r})):(fe(i.initializationState.type),n._seekAndPlay(e,t)))}),{emitCurrentValue:!0,clearSignal:r})},r.updateContentUrls=function(e,t){throw new Error("Cannot update content URL of directfile contents")},r.dispose=function(){this._initCanceller.cancel()},r._onFatalError=function(e){this._initCanceller.cancel(),this.trigger("error",e)},r._seekAndPlay=function(e,n){var r=this,i=this._initCanceller.signal,a=this._settings,o=a.autoPlay,s=a.startAt;Ki({mediaElement:e,playbackObserver:n,startTime:function(){B.debug("Init: Calculating initial time");var n=function(e,n){if(t(n))return 0;if(!t(n.position))return n.position;if(!t(n.wallClockTime))return n.wallClockTime;if(!t(n.fromFirstPosition))return n.fromFirstPosition;var r=e.duration;if("number"==typeof n.fromLastPosition)return t(r)||!isFinite(r)?(B.warn("startAt.fromLastPosition set but no known duration, beginning at 0."),0):Math.max(0,r+n.fromLastPosition);if("number"==typeof n.fromLivePosition){var i=e.seekable.length>0?e.seekable.end(0):r;return t(i)?(B.warn("startAt.fromLivePosition set but no known live position, beginning at 0."),0):Math.max(0,i+n.fromLivePosition)}if(!t(n.percentage)){if(t(r)||!isFinite(r))return B.warn("startAt.percentage set but no known duration, beginning at 0."),0;var a=n.percentage;return a>=100?r:a<=0?0:r*(+a/100)}return 0}(e,s);return B.debug("Init: Initial time calculated:",n),n},mustAutoPlay:o,onWarning:function(e){return r.trigger("warning",e)},isDirectfile:!0},i).autoPlayResult.then((function(){return Bi(n,e,!0,i).onUpdate((function(e,t){e&&(t(),r.trigger("loaded",{segmentSinksStore:null}))}),{emitCurrentValue:!0,clearSignal:i})})).catch((function(e){i.isCancelled()||r._onFatalError(e)}))},n}(Vr);function el(e,t){var n;if(t.length!==e.length)return!0;for(var r=0;r<t.length;r++)if(t[r].nativeTrack!==(null===(n=e[r])||void 0===n?void 0:n.nativeTrack))return!0;return!1}function tl(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_audio_"+o+"_"+s.toString();r[o]=s+1;var l={language:a.language,id:u,normalized:bt(a.language),audioDescription:"descriptions"===a.kind||"description"===a.kind,representations:[]};n.push({track:l,nativeTrack:a})}return n}function nl(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_text_"+o+"_"+s.toString();r[o]=s+1;var l="forced"===a.kind||void 0,d={language:a.language,forced:l,label:a.label,id:u,normalized:bt(a.language),closedCaption:"captions"===a.kind};n.push({track:d,nativeTrack:a})}return n}function rl(e){for(var t,n=[],r={},i=0;i<e.length;i++){var a=e[i],o=""===a.language?"nolang":a.language,s=null!==(t=r[o])&&void 0!==t?t:1,u="gen_video_"+o+"_"+s.toString();r[o]=s+1,n.push({track:{id:u,representations:[]},nativeTrack:a})}return n}var il=function(e){function n(t){var n,r,i,a;return(n=e.call(this)||this)._nativeAudioTracks=t.audioTracks,n._nativeVideoTracks=t.videoTracks,n._nativeTextTracks=t.textTracks,n._audioTracks=void 0!==n._nativeAudioTracks?tl(n._nativeAudioTracks):[],n._videoTracks=void 0!==n._nativeVideoTracks?rl(n._nativeVideoTracks):[],n._textTracks=void 0!==n._nativeTextTracks?nl(n._nativeTextTracks):[],n._lastEmittedNativeAudioTrack=null===(r=n._getCurrentAudioTrack())||void 0===r?void 0:r.nativeTrack,n._lastEmittedNativeVideoTrack=null===(i=n._getCurrentVideoTrack())||void 0===i?void 0:i.nativeTrack,n._lastEmittedNativeTextTrack=null===(a=n._getCurrentTextTrack())||void 0===a?void 0:a.nativeTrack,n._handleNativeTracksCallbacks(),n}f(n,e);var r=n.prototype;return r.setAudioTrackById=function(e){for(var t=0;t<this._audioTracks.length;t++){var n=this._audioTracks[t],r=n.track,i=n.nativeTrack;if(r.id===e)return this._enableAudioTrackFromIndex(t),void(this._audioTrackLockedOn=i)}throw new Error("Audio track not found.")},r.disableTextTrack=function(){al(this._textTracks),this._textTrackLockedOn=null},r.setTextTrackById=function(e){for(var t=!1,n=0;n<this._textTracks.length;n++){var r=this._textTracks[n],i=r.track,a=r.nativeTrack;i.id===e?(a.mode="showing",t=!0,this._textTrackLockedOn=a):"showing"!==a.mode&&"hidden"!==a.mode||(a.mode="disabled")}if(!t)throw new Error("Text track not found.")},r.disableVideoTrack=function(){sl(this._videoTracks),this._videoTrackLockedOn=null},r.setVideoTrackById=function(e){for(var t=0;t<this._videoTracks.length;t++){var n=this._videoTracks[t],r=n.track,i=n.nativeTrack;if(r.id===e)return i.selected=!0,void(this._videoTrackLockedOn=i)}throw new Error("Video track not found.")},r.getChosenAudioTrack=function(){var e=this._getCurrentAudioTrack();return t(e)?e:e.track},r.getChosenTextTrack=function(){var e=this._getCurrentTextTrack();return t(e)?e:e.track},r.getChosenVideoTrack=function(){var e=this._getCurrentVideoTrack();return t(e)?e:e.track},r.getAvailableAudioTracks=function(){return this._audioTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,language:t.language,normalized:t.normalized,audioDescription:t.audioDescription,active:n.enabled,representations:t.representations}}))},r.getAvailableTextTracks=function(){return this._textTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,label:t.label,forced:t.forced,language:t.language,normalized:t.normalized,closedCaption:t.closedCaption,active:"showing"===n.mode}}))},r.getAvailableVideoTracks=function(){return this._videoTracks.map((function(e){var t=e.track,n=e.nativeTrack;return{id:t.id,representations:t.representations,active:n.selected}}))},r.dispose=function(){void 0!==this._nativeVideoTracks&&(this._nativeVideoTracks.onchange=null,this._nativeVideoTracks.onaddtrack=null,this._nativeVideoTracks.onremovetrack=null),void 0!==this._nativeAudioTracks&&(this._nativeAudioTracks.onchange=null,this._nativeAudioTracks.onaddtrack=null,this._nativeAudioTracks.onremovetrack=null),void 0!==this._nativeTextTracks&&(this._nativeTextTracks.onchange=null,this._nativeTextTracks.onaddtrack=null,this._nativeTextTracks.onremovetrack=null),this.removeEventListener()},r._getCurrentAudioTrack=function(){if(void 0!==this._nativeAudioTracks){for(var e=0;e<this._audioTracks.length;e++){var t=this._audioTracks[e];if(t.nativeTrack.enabled)return t}return null}},r._getCurrentVideoTrack=function(){if(void 0!==this._nativeVideoTracks){for(var e=0;e<this._videoTracks.length;e++){var t=this._videoTracks[e];if(t.nativeTrack.selected)return t}return null}},r._getCurrentTextTrack=function(){if(void 0!==this._nativeTextTracks){for(var e=0;e<this._textTracks.length;e++){var t=this._textTracks[e];if("showing"===t.nativeTrack.mode)return t}return null}},r._setPreviouslyLockedAudioTrack=function(){if(void 0!==this._audioTrackLockedOn)if(null===this._audioTrackLockedOn)for(var e=0;e<this._audioTracks.length;e++){this._audioTracks[e].nativeTrack.enabled=!1}else for(var t=0;t<this._audioTracks.length;t++){if(this._audioTracks[t].nativeTrack===this._audioTrackLockedOn)return void this._enableAudioTrackFromIndex(t)}},r._setPreviouslyLockedTextTrack=function(){if(void 0!==this._textTrackLockedOn)if(null!==this._textTrackLockedOn)for(var e=0;e<this._textTracks.length;e++){var t=this._textTracks[e].nativeTrack;if(t===this._textTrackLockedOn)return ol(this._textTracks,t),void("showing"!==t.mode&&(t.mode="showing"))}else al(this._textTracks)},r._setPreviouslyLockedVideoTrack=function(){if(void 0!==this._videoTrackLockedOn)if(null!==this._videoTrackLockedOn)for(var e=0;e<this._videoTracks.length;e++){var t=this._videoTracks[e].nativeTrack;if(t===this._videoTrackLockedOn)return void(t.selected=!0)}else sl(this._videoTracks)},r._handleNativeTracksCallbacks=function(){var e=this;void 0!==this._nativeAudioTracks&&(this._nativeAudioTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeAudioTracks){var r=tl(e._nativeAudioTracks);if(el(e._audioTracks,r)){e._audioTracks=r,e._setPreviouslyLockedAudioTrack(),e.trigger("availableAudioTracksChange",e.getAvailableAudioTracks());var i=e._getCurrentAudioTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeAudioTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeAudioTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeAudioTracks){var r=tl(e._nativeAudioTracks);if(el(e._audioTracks,r)){e._audioTracks=r,e.trigger("availableAudioTracksChange",e.getAvailableAudioTracks());var i=e._getCurrentAudioTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeAudioTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeAudioTracks.onchange=function(){if(void 0!==e._audioTracks)for(var t=0;t<e._audioTracks.length;t++){var n=e._audioTracks[t],r=n.track,i=n.nativeTrack;if(i.enabled)return void(i!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",r),e._lastEmittedNativeAudioTrack=i))}null!==e._lastEmittedNativeAudioTrack&&(e.trigger("audioTrackChange",null),e._lastEmittedNativeAudioTrack=null)}),void 0!==this._nativeTextTracks&&(this._nativeTextTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeTextTracks){var r=nl(e._nativeTextTracks);if(el(e._textTracks,r)){e._textTracks=r,e._setPreviouslyLockedTextTrack(),e.trigger("availableTextTracksChange",e.getAvailableTextTracks());var i=e._getCurrentTextTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeTextTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeTextTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeTextTracks){var r=nl(e._nativeTextTracks);if(el(e._textTracks,r)){e._textTracks=r,e._setPreviouslyLockedTextTrack(),e.trigger("availableTextTracksChange",e.getAvailableTextTracks());var i=e._getCurrentTextTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeTextTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeTextTracks.onchange=function(){if(void 0!==e._textTracks)for(var t=0;t<e._textTracks.length;t++){var n=e._textTracks[t],r=n.track,i=n.nativeTrack;if("showing"===i.mode)return void(i!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",r),e._lastEmittedNativeTextTrack=i))}null!==e._lastEmittedNativeTextTrack&&(e.trigger("textTrackChange",null),e._lastEmittedNativeTextTrack=null)}),void 0!==this._nativeVideoTracks&&(this._nativeVideoTracks.onaddtrack=function(){var t,n;if(void 0!==e._nativeVideoTracks){var r=rl(e._nativeVideoTracks);if(el(e._videoTracks,r)){e._videoTracks=r,e._setPreviouslyLockedVideoTrack(),e.trigger("availableVideoTracksChange",e.getAvailableVideoTracks());var i=e._getCurrentVideoTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeVideoTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeVideoTracks.onremovetrack=function(){var t,n;if(void 0!==e._nativeVideoTracks){var r=rl(e._nativeVideoTracks);if(el(e._videoTracks,r)){e._videoTracks=r,e._setPreviouslyLockedVideoTrack(),e.trigger("availableVideoTracksChange",e.getAvailableVideoTracks());var i=e._getCurrentVideoTrack();(null==i?void 0:i.nativeTrack)!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null!==(t=null==i?void 0:i.track)&&void 0!==t?t:null),e._lastEmittedNativeVideoTrack=null!==(n=null==i?void 0:i.nativeTrack)&&void 0!==n?n:null)}}},this._nativeVideoTracks.onchange=function(){if(void 0!==e._videoTracks)for(var t=0;t<e._videoTracks.length;t++){var n=e._videoTracks[t],r=n.track,i=n.nativeTrack;if(i.selected)return void(i!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",r),e._lastEmittedNativeVideoTrack=i))}null!==e._lastEmittedNativeVideoTrack&&(e.trigger("videoTrackChange",null),e._lastEmittedNativeVideoTrack=null)})},r._enableAudioTrackFromIndex=function(e){!function(e,t){for(var n=0;n<e.length;n++)w&&n===t||(e[n].enabled=!1);t<0||t>=e.length||(e[t].enabled=!0)}(this._audioTracks.map((function(e){return e.nativeTrack})),e)},n}(i);function al(e){for(var t=0;t<e.length;t++){e[t].nativeTrack.mode="disabled"}}function ol(e,t){for(var n=0;n<e.length;n++){var r=e[n].nativeTrack;r===t||"showing"!==r.mode&&"hidden"!==r.mode||(r.mode="disabled")}}function sl(e){for(var t=0;t<e.length;t++){e[t].nativeTrack.selected=!1}}function ul(e){e.directfile={initDirectFile:Ju,mediaElementTracksStore:il}}var ll,dl=s.WebKitMediaKeys;function cl(e){return cl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},cl(e)}function fl(e){var t=function(e,t){if("object"!=cl(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=cl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==cl(t)?t:String(t)}function vl(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,fl(r.key),r)}}function pl(e,t,n){return t&&vl(e.prototype,t),n&&vl(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}void 0!==dl&&"function"==typeof dl.isTypeSupported&&"function"==typeof dl.prototype.createSession&&"function"==typeof HTMLMediaElement.prototype.webkitSetMediaKeys&&(ll=dl);var hl,ml=function(){function e(e,t,n){this._keyType=e,this._mediaKeys=t,this._configuration=n}var t=e.prototype;return t.createMediaKeys=function(){var e=this;return new Promise((function(t){return t(e._mediaKeys)}))},t.getConfiguration=function(){return this._configuration},pl(e,[{key:"keySystem",get:function(){return this._keyType}}]),e}(),gl=s.MSMediaKeys;function yl(e){try{var t=e();return"object"==typeof t&&null!==t&&"function"==typeof t.then?t:Promise.resolve(t)}catch(e){return Promise.reject(e)}}void 0!==gl&&void 0!==gl.prototype&&"function"==typeof gl.isTypeSupported&&"function"==typeof gl.prototype.createSession&&(hl=gl);var _l,bl=function(e){function n(t){var n;return(n=e.call(this)||this).expiration=NaN,n.keyStatuses=new Map,n._mk=t,n._sessionClosingCanceller=new pe,n.closed=new Promise((function(e){n._sessionClosingCanceller.signal.register((function(){return e()}))})),n.update=function(e){return new Promise((function(t,r){if(void 0===n._ss)return r("MediaKeySession not set.");try{t(n._ss.update(e,""))}catch(e){r(e)}}))},n}f(n,e);var r=n.prototype;return r.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r;r=t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer),n._ss=n._mk.createSession("video/mp4",r),ai(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"message",e)}),n._sessionClosingCanceller.signal),oi(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyadded",e)}),n._sessionClosingCanceller.signal),si(n._ss,(function(e){var t;n.trigger(null!==(t=e.type)&&void 0!==t?t:"keyerror",e)}),n._sessionClosingCanceller.signal),e()}))},r.close=function(){var e=this;return new Promise((function(n){t(e._ss)||(e._ss.close(),e._ss=void 0),e._sessionClosingCanceller.cancel(),n()}))},r.load=function(){return Promise.resolve(!1)},r.remove=function(){return Promise.resolve()},pl(n,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._ss)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),n}(i),Sl=function(){function e(e){if(void 0===hl)throw new Error("No MSMediaKeys API.");this._mediaKeys=new hl(e)}var t=e.prototype;return t._setVideo=function(e){var t=this;return yl((function(){t._videoElement=e,void 0!==t._videoElement.msSetMediaKeys&&t._videoElement.msSetMediaKeys(t._mediaKeys)}))},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new bl(this._mediaKeys)},t.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();var El=s.MozMediaKeys;function Tl(e){return"function"==typeof(null==e?void 0:e.webkitGenerateKeyRequest)}void 0!==El&&void 0!==El.prototype&&"function"==typeof El.isTypeSupported&&"function"==typeof El.prototype.createSession&&(_l=El);var kl=function(e){function t(t,n){var r;(r=e.call(this)||this)._vid=t,r._key=n,r.sessionId="",r._closeSession=U,r.keyStatuses=new Map,r.expiration=NaN;var i=function(e){r.trigger(e.type,e)};return r.closed=new Promise((function(e){r._closeSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.removeEventListener(e,i),t.removeEventListener("webkit"+e,i)})),e()}})),["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(e){t.addEventListener(e,i),t.addEventListener("webkit"+e,i)})),r}f(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){try{if(t._key.indexOf("clearkey")>=0){var i=e instanceof ArrayBuffer?new Uint8Array(e):e,a=JSON.parse(Ma(i)),o=ja(a.keys[0].k),s=ja(a.keys[0].kid);n(t._vid.webkitAddKey(t._key,o,s,""))}else n(t._vid.webkitAddKey(t._key,e,null,""))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){n._vid.webkitGenerateKeyRequest(n._key,t),e()}))},n.close=function(){var e=this;return new Promise((function(t){e._closeSession(),t()}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},t}(i),wl=function(){function e(e){this._keySystem=e}var n=e.prototype;return n._setVideo=function(e){var t=this;return yl((function(){if(!Tl(e))throw new Error("Video not attached to the MediaKeys");t._videoElement=e}))},n.createSession=function(){if(t(this._videoElement))throw new Error("Video not attached to the MediaKeys");return new kl(this._videoElement,this._keySystem)},n.setServerCertificate=function(){throw new Error("Server certificate is not implemented in your browser")},e}();function Al(e,t){var n=e instanceof Uint8Array?e:new Uint8Array(e),r=t instanceof Uint8Array?t:new Uint8Array(t),i=function(e,t){return e[t+0]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]}(n,0);if(i+4!==n.length)throw new Error("Unsupported WebKit initData.");var a=Ra(n),o=a.indexOf("skd://"),s=function(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint8Array(t),r=0;r<n.length;r+=2){var i=e.charCodeAt(r/2);n[r]=255&i,n[r+1]=i>>8&255}return n}(o>-1?a.substring(o+6):a),u=0,l=new Uint8Array(n.byteLength+4+s.byteLength+4+r.byteLength);return l.set(n),u+=n.length,l.set(Si(s.byteLength),u),u+=4,l.set(s,u),u+=s.byteLength,l.set(Si(r.byteLength),u),u+=4,l.set(r,u),l}function Il(e,t){var n=e;return yl((function(){if(void 0===n.webkitSetMediaKeys)throw new Error("No webKitMediaKeys API.");n.webkitSetMediaKeys(t)}))}var Rl=function(e){function t(t,n,r){var i;return(i=e.call(this)||this)._serverCertificate=r,i._videoElement=t,i._keyType=n,i._unbindSession=U,i._closeSession=U,i.closed=new Promise((function(e){i._closeSession=e})),i.keyStatuses=new Map,i.expiration=NaN,i}f(t,e);var n=t.prototype;return n.update=function(e){var t=this;return new Promise((function(n,r){if(void 0===t._nativeSession||void 0===t._nativeSession.update||"function"!=typeof t._nativeSession.update)return r("Unavailable WebKit key session.");try{var i;i=e instanceof ArrayBuffer?new Uint8Array(e):e instanceof Uint8Array?e:new Uint8Array(e.buffer),n(t._nativeSession.update(i))}catch(e){r(e)}}))},n.generateRequest=function(e,t){var n=this;return new Promise((function(e){var r,i,a=n._videoElement;if(void 0===(null===(r=a.webkitKeys)||void 0===r?void 0:r.createSession))throw new Error("No WebKitMediaKeys API.");if(Sr(n._keyType,"com.apple.fps")){if(void 0===n._serverCertificate)throw new Error("A server certificate is needed for creating fairplay session.");i=Al(t,n._serverCertificate)}else i=t;var o=a.webkitKeys.createSession("video/mp4",i);if(null==o)throw new Error("Impossible to get the key sessions");n._listenEvent(o),n._nativeSession=o,e()}))},n.close=function(){var e=this;return new Promise((function(t,n){e._unbindSession(),e._closeSession(),void 0!==e._nativeSession?(e._nativeSession.close(),t()):n("No session to close.")}))},n.load=function(){return Promise.resolve(!1)},n.remove=function(){return Promise.resolve()},n._listenEvent=function(e){var t=this;this._unbindSession();var n=function(e){t.trigger(e.type,e)};["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.addEventListener(t,n),e.addEventListener("webkit"+t,n)})),this._unbindSession=function(){["keymessage","message","keyadded","ready","keyerror","error"].forEach((function(t){e.removeEventListener(t,n),e.removeEventListener("webkit"+t,n)}))}},pl(t,[{key:"sessionId",get:function(){var e,t;return null!==(t=null===(e=this._nativeSession)||void 0===e?void 0:e.sessionId)&&void 0!==t?t:""}}]),t}(i),xl=function(){function e(e){if(void 0===ll)throw new Error("No WebKitMediaKeys API.");this._keyType=e,this._mediaKeys=new ll(e)}var t=e.prototype;return t._setVideo=function(e){if(this._videoElement=e,void 0===this._videoElement)throw new Error("Video not attached to the MediaKeys");return Il(this._videoElement,this._mediaKeys)},t.createSession=function(){if(void 0===this._videoElement||void 0===this._mediaKeys)throw new Error("Video not attached to the MediaKeys");return new Rl(this._videoElement,this._keyType,this._serverCertificate)},t.setServerCertificate=function(e){return this._serverCertificate=e,Promise.resolve()},e}();function Cl(){if(void 0===ll)throw new Error("No WebKitMediaKeys API.");return{isTypeSupported:ll.isTypeSupported,createCustomMediaKeys:function(e){return new xl(e)},setMediaKeys:function(e,t){if(null===t)return Il(e,t);if(!(t instanceof xl))throw new Error("Custom setMediaKeys is supposed to be called with webkit custom MediaKeys.");return t._setVideo(e)}}}var Ml=function(e){var n,r,i,a,u=Pl;if("standard"!==e&&("auto"!==e||(E||T)&&void 0!==ll)||!o&&t(navigator.requestMediaKeySystemAccess)){var l,d;if("webkit"===e&&void 0!==ll){i=$r(["needkey"]);var c=Cl();l=c.isTypeSupported,d=c.createCustomMediaKeys,u=c.setMediaKeys,a="webkit"}else if(Tl(null===(n=s.HTMLVideoElement)||void 0===n?void 0:n.prototype)){i=$r(["needkey"]);var f={isTypeSupported:function(e){var n=document.querySelector("video");return t(n)&&(n=document.createElement("video")),!t(n)&&"function"==typeof n.canPlayType&&!!n.canPlayType("video/mp4",e)},createCustomMediaKeys:function(e){return new wl(e)},setMediaKeys:function(e,t){if(null===t)return Promise.resolve(void 0);if(!(t instanceof wl))throw new Error("Custom setMediaKeys is supposed to be called with old webkit custom MediaKeys.");return t._setVideo(e)}};l=f.isTypeSupported,d=f.createCustomMediaKeys,u=f.setMediaKeys,a="older-webkit"}else if(void 0!==ll){i=$r(["needkey"]);var v=Cl();l=v.isTypeSupported,d=v.createCustomMediaKeys,u=v.setMediaKeys,a="webkit"}else if(_&&void 0!==hl){i=$r(["encrypted","needkey"]);var p={isTypeSupported:function(e,t){if(void 0===hl)throw new Error("No MSMediaKeys API.");return void 0!==t?hl.isTypeSupported(e,t):hl.isTypeSupported(e)},createCustomMediaKeys:function(e){return new Sl(e)},setMediaKeys:function(e,t){if(null===t)return Promise.resolve(void 0);if(!(t instanceof Sl))throw new Error("Custom setMediaKeys is supposed to be called with IE11 custom MediaKeys.");return t._setVideo(e)}};l=p.isTypeSupported,d=p.createCustomMediaKeys,u=p.setMediaKeys,a="ms"}else if(void 0!==_l){i=$r(["encrypted","needkey"]);var h={isTypeSupported:function(e,t){if(void 0===_l)throw new Error("No MozMediaKeys API.");return void 0!==t?_l.isTypeSupported(e,t):_l.isTypeSupported(e)},createCustomMediaKeys:function(e){if(void 0===_l)throw new Error("No MozMediaKeys API.");return new _l(e)},setMediaKeys:function(e,t){return yl((function(){var n=e;if(void 0===n.mozSetMediaKeys||"function"!=typeof n.mozSetMediaKeys)throw new Error("Can't set video on MozMediaKeys.");return n.mozSetMediaKeys(t)}))}};l=h.isTypeSupported,d=h.createCustomMediaKeys,u=h.setMediaKeys,a="moz"}else{i=$r(["encrypted","needkey"]);var m=s.MediaKeys,g=function(){if(void 0===m)throw new qe("MEDIA_KEYS_NOT_SUPPORTED","No `MediaKeys` implementation found in the current browser.");if(void 0===m.isTypeSupported){throw new Error("This browser seems to be unable to play encrypted contents currently.Note: Some browsers do not allow decryption in some situations, like when not using HTTPS.")}};l=function(e){return g(),fe(m.isTypeSupported),m.isTypeSupported(e)},d=function(e){return g(),new m(e)},a="unknown"}r=function(e,n){if(!l(e))return Promise.reject(new Error("Unsupported key type"));for(var r=0;r<n.length;r++){var i=n[r],a=i.videoCapabilities,o=i.audioCapabilities,s=i.initDataTypes,u=i.distinctiveIdentifier,c=!0;if(c=(c=c&&(t(s)||s.some((function(e){return"cenc"===e}))))&&"required"!==u){var f={initDataTypes:["cenc"],distinctiveIdentifier:"not-allowed",persistentState:"required",sessionTypes:["temporary","persistent-license"]};void 0!==a&&(f.videoCapabilities=a),void 0!==o&&(f.audioCapabilities=o);var v=d(e);return Promise.resolve(new ml(e,v,f))}}return Promise.reject(new Error("Unsupported configuration"))}}else r=function(){var e;return(e=navigator).requestMediaKeySystemAccess.apply(e,arguments)},i=$r(["encrypted"]),a="standard";return{requestMediaKeySystemAccess:r,onEncrypted:i,setMediaKeys:u,implementation:a}}("auto");function Pl(e,t){try{var n,r=e;return"function"==typeof r.setMediaKeys?n=r.setMediaKeys(t):"function"==typeof r.webkitSetMediaKeys?n=r.webkitSetMediaKeys(t):"function"==typeof r.mozSetMediaKeys?n=r.mozSetMediaKeys(t):"function"==typeof r.msSetMediaKeys&&null!==t&&(n=r.msSetMediaKeys(t)),"object"==typeof n&&null!==n&&"function"==typeof n.then?n:Promise.resolve(n)}catch(e){return Promise.reject(e)}}var Dl=Ml,Nl=mi(xa("pssh"),0);function Ol(e,t){for(var n=0;n<e.length;n++){var r=e[n];if((void 0===t.systemId||void 0===r.systemId||t.systemId===r.systemId)&&Tt(t.data,r.data))return!0}return!1}function Ll(e){var n=e.initData,r=e.initDataType;if(t(n))return B.warn("Compat: No init data found on media encrypted event."),null;var i=function(e){for(var t=[],n=0;n<e.length;){if(e.length<n+8||mi(e,n+4)!==Nl)return B.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var r=mi(new Uint8Array(e),n);if(n+r>e.length)return B.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var i=e.subarray(n,n+r),a={systemId:Ru(i,8),data:i};Ol(t,a)?B.warn("Compat: Duplicated PSSH found in initialization data, removing it."):t.push(a),n+=r}return n!==e.length?(B.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}]):t}(new Uint8Array(n));return{type:r,values:i}}function Ul(e,t,n){var r=e.setMediaKeys(t,n).then((function(){B.info("Compat: MediaKeys updated with success")})).catch((function(e){if(null!==n)throw B.error("Compat: Could not update MediaKeys",e instanceof Error?e:"Unknown Error"),e;B.error("Compat: Could not reset MediaKeys",e instanceof Error?e:"Unknown Error")}));return A?r:Promise.race([r,ar(1e3)])}function Fl(e){var t,n=Br.getState(e);return Br.setState(e,null),Ul(null!==(t=null==n?void 0:n.emeImplementation)&&void 0!==t?t:Dl,e,null)}function Bl(){return(Bl=d(g().mark((function e(t,n,r){var i,a,o,s,u,l,d;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.emeImplementation,a=n.keySystemOptions,o=n.loadedSessionsStore,s=n.mediaKeySystemAccess,u=n.mediaKeys,l=Br.getState(t),d=null!==l&&l.loadedSessionsStore!==o?l.loadedSessionsStore.closeAllSessions():Promise.resolve(),e.next=5,d;case 5:if(!r.isCancelled()){e.next=7;break}throw r.cancellationError;case 7:if(Br.setState(t,{emeImplementation:i,keySystemOptions:a,mediaKeySystemAccess:s,mediaKeys:u,loadedSessionsStore:o}),t.mediaKeys!==u){e.next=10;break}return e.abrupt("return");case 10:return B.info("DRM: Attaching MediaKeys to the media element"),e.abrupt("return",Ul(i,t,u).then((function(){B.info("DRM: MediaKeys attached with success")})).catch((function(e){var t=e instanceof Error?e.toString():"Unknown Error";throw new je("MEDIA_KEYS_ATTACHMENT_ERROR","Could not attach the MediaKeys to the media element: "+t)})));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function zl(e){if(""===e.sessionId)return!1;var t=e.keyStatuses,n=[];return t.forEach((function(e){n.push(e)})),n.length<=0?(B.debug("DRM: isSessionUsable: MediaKeySession given has an empty keyStatuses",e.sessionId),!1):Je(n,"expired")?(B.debug("DRM: isSessionUsable: MediaKeySession given has an expired key",e.sessionId),!1):Je(n,"internal-error")?(B.debug("DRM: isSessionUsable: MediaKeySession given has a key with an internal-error",e.sessionId),!1):(B.debug("DRM: isSessionUsable: MediaKeySession is usable",e.sessionId),!0)}function Vl(e,t,n,r){var i=e.loadedSessionsStore,a=e.persistentSessionsStore;return"temporary"===n?Kl(i,t):null===a?(B.warn("DRM: Cannot create persistent MediaKeySession, PersistentSessionsStore not created."),Kl(i,t)):function(e,t,n,r){return Wl.apply(this,arguments)}(i,a,t,r)}function Kl(e,t){B.info("DRM: Creating a new temporary session");var n=e.createSession(t,"temporary");return Promise.resolve({type:"created-session",value:n})}function Wl(){return Wl=d(g().mark((function e(t,n,r,i){var a,o,s,u,l,c;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=function(){return c=d(g().mark((function e(){var o,s;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===i.cancellationError){e.next=2;break}throw i.cancellationError;case 2:return B.info("DRM: Removing previous persistent session."),null!==(o=n.get(r))&&n.delete(o.sessionId),e.prev=5,e.next=8,t.closeSession(a.mediaKeySession);case 8:e.next=15;break;case 10:if(e.prev=10,e.t0=e.catch(5),""===a.mediaKeySession.sessionId){e.next=14;break}throw e.t0;case 14:t.removeSessionWithoutClosingIt(a.mediaKeySession);case 15:if(null===i.cancellationError){e.next=17;break}throw i.cancellationError;case 17:return s=t.createSession(r,"persistent-license"),e.abrupt("return",{type:"created-session",value:s});case 19:case"end":return e.stop()}}),e,null,[[5,10]])}))),c.apply(this,arguments)},l=function(){return c.apply(this,arguments)},null===i.cancellationError){e.next=4;break}throw i.cancellationError;case 4:if(B.info("DRM: Creating persistent MediaKeySession"),a=t.createSession(r,"persistent-license"),null!==(o=n.getAndReuse(r))){e.next=9;break}return e.abrupt("return",{type:"created-session",value:a});case 9:return e.prev=9,e.next=12,t.loadPersistentSession(a.mediaKeySession,o.sessionId);case 12:if(s=e.sent){e.next=19;break}return B.warn("DRM: No data stored for the loaded session"),n.delete(o.sessionId),t.removeSessionWithoutClosingIt(a.mediaKeySession),u=t.createSession(r,"persistent-license"),e.abrupt("return",{type:"created-session",value:u});case 19:if(!s||!zl(a.mediaKeySession)){e.next=23;break}return n.add(r,r.keyIds,a.mediaKeySession),B.info("DRM: Succeeded to load persistent session."),e.abrupt("return",{type:"loaded-persistent-session",value:a});case 23:return B.warn("DRM: Previous persistent session not usable anymore."),e.abrupt("return",l());case 27:return e.prev=27,e.t0=e.catch(9),B.warn("DRM: Unable to load persistent session: "+(e.t0 instanceof Error?e.t0.toString():"Unknown Error")),e.abrupt("return",l());case 31:case"end":return e.stop()}}),e,null,[[9,27]])}))),Wl.apply(this,arguments)}function Gl(e,t){return Hl.apply(this,arguments)}function Hl(){return(Hl=d(g().mark((function e(t,n){var r,i,a,o,s;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n<0||n>=t.getLength())){e.next=2;break}return e.abrupt("return");case 2:for(B.info("DRM: LSS cache limit exceeded",n,t.getLength()),r=[],i=t.getAll().slice(),a=i.length-n,o=0;o<a;o++)s=i[o],r.push(t.closeSession(s.mediaKeySession));return e.next=9,Promise.all(r);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function jl(e,t,n,r,i){return ql.apply(this,arguments)}function ql(){return(ql=d(g().mark((function e(t,n,r,i,a){var o,s,u,l,d;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null,s=n.loadedSessionsStore,u=n.persistentSessionsStore,null===(l=s.reuse(t))){e.next=11;break}if(!zl(o=l.mediaKeySession)){e.next=10;break}return B.info("DRM: Reuse loaded session",o.sessionId),e.abrupt("return",{type:"loaded-open-session",value:{mediaKeySession:o,sessionType:l.sessionType,keySessionRecord:l.keySessionRecord}});case 10:null!==u&&""!==l.mediaKeySession.sessionId&&u.delete(l.mediaKeySession.sessionId);case 11:if(null===o){e.next=16;break}return e.next=14,s.closeSession(o);case 14:if(null===a.cancellationError){e.next=16;break}throw a.cancellationError;case 16:return e.next=18,Gl(s,i);case 18:if(null===a.cancellationError){e.next=20;break}throw a.cancellationError;case 20:return e.next=22,Vl(n,t,r,a);case 22:return d=e.sent,e.abrupt("return",{type:d.type,value:{mediaKeySession:d.value.mediaKeySession,sessionType:d.value.sessionType,keySessionRecord:d.value.keySessionRecord}});case 24:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Yl(e,n,r){var i=n.getConfiguration();if(_||t(i))return null;var a=e.filter((function(e){return e.type===r.type&&(!!(t(e.persistentLicenseConfig)&&"required"!==e.persistentState||"required"===i.persistentState)&&("required"!==e.distinctiveIdentifier||"required"===i.distinctiveIdentifier))}))[0];return void 0!==a?{keySystemOptions:a,keySystemAccess:n}:null}function Ql(e){var n=e.keyName,r=e.keyType,i=e.keySystemOptions,a=["temporary"],o="optional",s="optional";t(i.persistentLicenseConfig)||(o="required",a.push("persistent-license")),t(i.persistentState)||(o=i.persistentState),t(i.distinctiveIdentifier)||(s=i.distinctiveIdentifier);var u,l,d=L.getCurrent(),c=d.EME_DEFAULT_AUDIO_CODECS,f=d.EME_DEFAULT_VIDEO_CODECS,v=d.EME_DEFAULT_WIDEVINE_ROBUSTNESSES,p=d.EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES,h=i.audioCapabilitiesConfig,m=i.videoCapabilitiesConfig;if("full"===(null==h?void 0:h.type))u=h.value;else{var g;0===(g="robustness"===(null==h?void 0:h.type)?h.value:"widevine"===n?v:"com.microsoft.playready.recommendation"===r?p:[]).length&&g.push(void 0);var y="contentType"===(null==h?void 0:h.type)?h.value:c;u=Yo(g,(function(e){return y.map((function(t){return void 0!==e?{contentType:t,robustness:e}:{contentType:t}}))}))}if("full"===(null==m?void 0:m.type))l=m.value;else{var _;0===(_="robustness"===(null==m?void 0:m.type)?m.value:"widevine"===n?v:"com.microsoft.playready.recommendation"===r?p:[]).length&&_.push(void 0);var b="contentType"===(null==m?void 0:m.type)?m.value:f;l=Yo(_,(function(e){return b.map((function(t){return void 0!==e?{contentType:t,robustness:e}:{contentType:t}}))}))}var S={initDataTypes:["cenc"],videoCapabilities:l,audioCapabilities:u,distinctiveIdentifier:s,persistentState:o,sessionTypes:a};return[S,Object.assign(Object.assign({},S),{audioCapabilities:void 0,videoCapabilities:void 0})]}function $l(e,n,r){B.info("DRM: Searching for compatible MediaKeySystemAccess");var i=Br.getState(e);if(null!==i&&Dl.implementation===i.emeImplementation.implementation){var a=Yl(n,i.mediaKeySystemAccess,i.keySystemOptions);if(null!==a)return B.info("DRM: Found cached compatible keySystem"),Promise.resolve({type:"reuse-media-key-system-access",value:{mediaKeySystemAccess:a.keySystemAccess,options:a.keySystemOptions}})}var o=n.reduce((function(e,n){var r,i=L.getCurrent().EME_KEY_SYSTEMS[n.type];if(t(i)){var a=function(e){for(var t=L.getCurrent().EME_KEY_SYSTEMS,n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];if(Je(t[i],e))return i}}(n.type);r=[{keyName:a,keyType:n.type,keySystemOptions:n}]}else r=i.map((function(e){return{keyName:n.type,keyType:e,keySystemOptions:n}}));return e.concat(r)}),[]);return s(0);function s(e){return u.apply(this,arguments)}function u(){return(u=d(g().mark((function e(n){var i,a,u,l,d;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n>=o.length)){e.next=2;break}throw new je("INCOMPATIBLE_KEYSYSTEMS","No key system compatible with your wanted configuration has been found in the current browser.");case 2:if(!t(Dl.requestMediaKeySystemAccess)){e.next=4;break}throw new Error("requestMediaKeySystemAccess is not implemented in your browser.");case 4:return i=o[n],a=i.keyType,u=i.keySystemOptions,l=Ql(i),B.debug("DRM: Request keysystem access "+a+","+(n+1)+" of "+o.length),e.prev=8,e.next=11,Dl.requestMediaKeySystemAccess(a,l);case 11:return d=e.sent,B.info("DRM: Found compatible keysystem",a,n+1),e.abrupt("return",{type:"create-media-key-system-access",value:{options:u,mediaKeySystemAccess:d}});case 16:if(e.prev=16,e.t0=e.catch(8),B.debug("DRM: Rejected access to keysystem",a,n+1),null===r.cancellationError){e.next=21;break}throw r.cancellationError;case 21:return e.abrupt("return",s(n+1));case 22:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}}function Xl(e,t,n){var r;B.debug("Compat: Calling generateRequest on the MediaKeySession");try{r=function(e){B.info("Compat: Trying to move CENC PSSH from init data at the end of it.");for(var t=!1,n=new Uint8Array,r=new Uint8Array,i=0;i<e.length;){if(e.length<i+8||mi(e,i+4)!==Nl)throw B.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var a=mi(new Uint8Array(e),i);if(i+a>e.length)throw B.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var o=e.subarray(i,i+a);if(16===e[i+12]&&119===e[i+13]&&239===e[i+14]&&236===e[i+15]&&192===e[i+16]&&178===e[i+17]&&77===e[i+18]&&2===e[i+19]&&172===e[i+20]&&227===e[i+21]&&60===e[i+22]&&30===e[i+23]&&82===e[i+24]&&226===e[i+25]&&251===e[i+26]&&75===e[i+27]){var s=ga(o),u=null===s?void 0:o[s[1]];B.info("Compat: CENC PSSH found with version",u),void 0===u?B.warn("Compat: could not read version of CENC PSSH"):t===(1===u)?n=vi(n,o):1===u?(B.warn("Compat: cenc version 1 encountered, removing every other cenc pssh box."),n=o,t=!0):B.warn("Compat: filtering out cenc pssh box with wrong version",u)}else r=vi(r,o);i+=a}if(i!==e.length)throw B.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");return vi(r,n)}(n)}catch(e){r=n}var i=null!=t?t:"";return e.generateRequest(i,r).catch((function(t){if(""!==i||!(t instanceof TypeError))throw t;return B.warn('Compat: error while calling `generateRequest` with an empty initialization data type. Retrying with a default "cenc" value.',t),e.generateRequest("cenc",r)}))}var Zl=100;function Jl(e,t){return ed.apply(this,arguments)}function ed(){return(ed=d(g().mark((function e(t,n){var r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return B.info("DRM: Load persisted session",n),e.next=3,t.load(n);case 3:if((r=e.sent)&&!(t.keyStatuses.size>0)){e.next=6;break}return e.abrupt("return",r);case 6:return e.abrupt("return",new Promise((function(e){t.addEventListener("keystatuseschange",i);var n=setTimeout(i,Zl);function i(){clearTimeout(n),t.removeEventListener("keystatuseschange",i),e(r)}})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function td(e){var t=new pe;return Promise.race([e.close().then((function(){t.cancel()})),e.closed.then((function(){t.cancel()})),function(){return n.apply(this,arguments)}()]);function n(){return(n=d(g().mark((function e(){var n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,qt(1e3,t.signal);case 3:return e.next=5,r();case 5:e.next=13;break;case 7:if(e.prev=7,e.t0=e.catch(0),!(e.t0 instanceof me)){e.next=11;break}return e.abrupt("return");case 11:n=e.t0 instanceof Error?e.t0.message:"Unknown error made it impossible to close the session",B.error("DRM: "+n);case 13:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function r(){return i.apply(this,arguments)}function i(){return(i=d(g().mark((function n(){return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.update(new Uint8Array(1));case 3:n.next=13;break;case 5:if(n.prev=5,n.t0=n.catch(0),!t.isUsed()){n.next=9;break}return n.abrupt("return");case 9:if(!(n.t0 instanceof Error&&"The session is already closed."===n.t0.message)){n.next=11;break}return n.abrupt("return");case 11:return n.next=13,qt(1e3,t.signal);case 13:if(!t.isUsed()){n.next=15;break}return n.abrupt("return");case 15:throw new Error("Compat: Couldn't know if session is closed");case 16:case"end":return n.stop()}}),n,null,[[0,5]])})))).apply(this,arguments)}}function nd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return rd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function rd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function id(e,t){for(var n,r,i=function(){var e=r.value;if(!t.some((function(t){return Tt(t,e)})))return{v:!1}},a=nd(e);!(r=a()).done;)if(n=i())return n.v;return!0}function ad(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return od(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return od(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function od(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var sd=function(){function e(e){this._initializationData=e,this._keyIds=null}var t=e.prototype;return t.associateKeyIds=function(e){null===this._keyIds&&(this._keyIds=[]);for(var t=0,n=Array.from(e);t<n.length;t++){var r=n[t];this.isAssociatedWithKeyId(r)||this._keyIds.push(r)}},t.isAssociatedWithKeyId=function(e){if(null===this._keyIds)return!1;for(var t,n=ad(this._keyIds);!(t=n()).done;){if(Tt(t.value,e))return!0}return!1},t.getAssociatedKeyIds=function(){return null===this._keyIds?[]:this._keyIds},t.isCompatibleWith=function(e){var t=e.keyIds;if(void 0!==t&&t.length>0){if(null!==this._keyIds&&id(t,this._keyIds))return!0;if(void 0!==this._initializationData.keyIds)return id(t,this._initializationData.keyIds)}return this._checkInitializationDataCompatibility(e)},t._checkInitializationDataCompatibility=function(e){return void 0!==e.keyIds&&e.keyIds.length>0&&void 0!==this._initializationData.keyIds?id(e.keyIds,this._initializationData.keyIds):this._initializationData.type===e.type&&this._initializationData.values.isCompatibleWith(e.values)},e}();function ud(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return ld(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ld(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ld(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var dd=function(){function e(e){this._mediaKeys=e,this._storage=[]}var n=e.prototype;return n.createSession=function(e,n){var r=this,i=new sd(e);B.debug("DRM-LSS: calling `createSession`",n);var a=this._mediaKeys.createSession(n),o={mediaKeySession:a,sessionType:n,keySessionRecord:i,isGeneratingRequest:!1,isLoadingPersistentSession:!1,closingStatus:{type:"none"}};return t(a.closed)||a.closed.then((function(){B.info("DRM-LSS: session was closed, removing it.",a.sessionId);var e=r.getIndex(i);e>=0&&r._storage[e].mediaKeySession===a&&r._storage.splice(e,1)})).catch((function(e){B.warn("DRM-LSS: MediaKeySession.closed rejected: "+e)})),this._storage.push(Object.assign({},o)),B.debug("DRM-LSS: MediaKeySession added",o.sessionType,this._storage.length),o},n.reuse=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.keySessionRecord.isCompatibleWith(e))return this._storage.splice(t,1),this._storage.push(n),B.debug("DRM-LSS: Reusing session:",n.mediaKeySession.sessionId,n.sessionType),Object.assign({},n)}return null},n.getEntryForSession=function(e){for(var t=this._storage.length-1;t>=0;t--){var n=this._storage[t];if(n.mediaKeySession===e)return Object.assign({},n)}return null},n.generateLicenseRequest=function(){var e=d(g().mark((function e(t,n,r){var i,a,o,s;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=ud(this._storage);case 1:if((o=a()).done){e.next=8;break}if((s=o.value).mediaKeySession!==t){e.next=6;break}return i=s,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==i){e.next=11;break}return B.error("DRM-LSS: generateRequest error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Xl(t,n,r));case 11:if(i.isGeneratingRequest=!0,"none"===i.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,Xl(t,n,r);case 17:e.next=26;break;case 19:if(e.prev=19,e.t0=e.catch(14),void 0!==i){e.next=23;break}throw e.t0;case 23:throw i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start(),e.t0;case 26:if(void 0!==i){e.next=28;break}return e.abrupt("return",void 0);case 28:i.isGeneratingRequest=!1,"awaiting"===i.closingStatus.type&&i.closingStatus.start();case 30:case"end":return e.stop()}}),e,this,[[14,19]])})));return function(t,n,r){return e.apply(this,arguments)}}(),n.loadPersistentSession=function(){var e=d(g().mark((function e(t,n){var r,i,a,o,s;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=ud(this._storage);case 1:if((a=i()).done){e.next=8;break}if((o=a.value).mediaKeySession!==t){e.next=6;break}return r=o,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==r){e.next=11;break}return B.error("DRM-LSS: loadPersistentSession error. No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Jl(t,n));case 11:if(r.isLoadingPersistentSession=!0,"none"===r.closingStatus.type){e.next=14;break}throw new Error("The `MediaKeySession` is being closed.");case 14:return e.prev=14,e.next=17,Jl(t,n);case 17:s=e.sent,e.next=27;break;case 20:if(e.prev=20,e.t0=e.catch(14),void 0!==r){e.next=24;break}throw e.t0;case 24:throw r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.t0;case 27:if(void 0!==r){e.next=29;break}return e.abrupt("return",s);case 29:return r.isLoadingPersistentSession=!1,"awaiting"===r.closingStatus.type&&r.closingStatus.start(),e.abrupt("return",s);case 32:case"end":return e.stop()}}),e,this,[[14,20]])})));return function(t,n){return e.apply(this,arguments)}}(),n.closeSession=function(){var e=d(g().mark((function e(t){var n,r,i,a;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=ud(this._storage);case 1:if((i=r()).done){e.next=8;break}if((a=i.value).mediaKeySession!==t){e.next=6;break}return n=a,e.abrupt("break",8);case 6:e.next=1;break;case 8:if(void 0!==n){e.next=11;break}return B.warn("DRM-LSS: No MediaKeySession found with the given initData and initDataType"),e.abrupt("return",Promise.resolve(!1));case 11:return e.abrupt("return",this._closeEntry(n));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getLength=function(){return this._storage.length},n.getAll=function(){return this._storage},n.closeAllSessions=function(){var e=d(g().mark((function e(){var t,n,r=this;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._storage,B.debug("DRM-LSS: Closing all current MediaKeySessions",t.length),this._storage=[],n=t.map((function(e){return r._closeEntry(e)})),e.next=6,Promise.all(n);case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.removeSessionWithoutClosingIt=function(e){fe(e.sessionId);for(var t=this._storage.length-1;t>=0;t--){if(this._storage[t].mediaKeySession===e)return B.debug("DRM-LSS: Removing session without closing it",e.sessionId),this._storage.splice(t,1),!0}return!1},n.getIndex=function(e){for(var t=0;t<this._storage.length;t++){if(this._storage[t].keySessionRecord===e)return t}return-1},n._closeEntry=function(){var e=d(g().mark((function e(t){var n;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.mediaKeySession,e.abrupt("return",new Promise((function(e,r){function i(){void 0!==t&&(t.closingStatus={type:"pending"}),cd(n).then((function(){void 0!==t&&(t.closingStatus={type:"done"}),e(!0)})).catch((function(e){void 0!==t&&(t.closingStatus={type:"failed"}),r(e)}))}void 0!==t&&(t.isLoadingPersistentSession||t.isGeneratingRequest)?t.closingStatus={type:"awaiting",start:i}:i()})));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e}();function cd(e){return fd.apply(this,arguments)}function fd(){return(fd=d(g().mark((function e(t){return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return B.debug("DRM: Trying to close a MediaKeySession",t.sessionId),e.prev=1,e.next=4,td(t);case 4:return B.debug("DRM: Succeeded to close MediaKeySession"),e.abrupt("return");case 8:return e.prev=8,e.t0=e.catch(1),B.error("DRM: Could not close MediaKeySession: "+(e.t0 instanceof Error?e.t0.toString():"Unknown error")),e.abrupt("return");case 12:case"end":return e.stop()}}),e,null,[[1,8]])})))).apply(this,arguments)}function vd(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e[n],t|=0;return t}var pd=function(){function e(e){this.initData=e}return e.prototype.toJSON=function(){return Ha(this.initData)},e.decode=function(e){return ja(e)},e}();function hd(e,t){var n,r;return null!==(r=null!==(n=md(e,t))&&void 0!==n?n:md(t,e))&&void 0!==r&&r}function md(e,t){if(0===e.length)return!1;if(t.length<e.length)return null;for(var n=e[0],r=0,i=0;i<t.length;i++){var a=t[i];if(a.systemId===n.systemId){if(a.hash!==n.hash)return!1;if(!Tt(n.data instanceof Uint8Array?n.data:"string"==typeof n.data?pd.decode(n.data):n.data.initData,a.data instanceof Uint8Array?a.data:"string"==typeof a.data?pd.decode(a.data):a.data.initData))return!1;if(t.length-i<e.length)return null;for(r=1;r<e.length;r++){var o=e[r];for(i+=1;i<t.length;i++){var s=t[i];if(o.systemId===s.systemId){if(o.hash!==s.hash)return!1;if(!Tt(o.data instanceof Uint8Array?o.data:"string"==typeof o.data?pd.decode(o.data):o.data.initData,s.data instanceof Uint8Array?s.data:"string"==typeof s.data?pd.decode(s.data):s.data.initData))return!1;break}}if(r===t.length)return null}return!0}}return null}function gd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return yd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function yd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _d(e){!function(e,n,r){for(var i in void 0===r&&(r="object"),fe(t(e)),n)n.hasOwnProperty(i)&&fe((e[i],n[i]),n[i])}(e,{save:"function",load:"function"},"persistentLicenseConfig")}var bd=function(){function e(e){_d(e),this._entries=[],this._storage=e;try{var t=this._storage.load();Array.isArray(t)||(t=[]),this._entries=t}catch(e){B.warn("DRM-PSS: Could not get entries from license storage",e instanceof Error?e:""),this.dispose()}}var n=e.prototype;return n.getLength=function(){return this._entries.length},n.getAll=function(){return this._entries},n.get=function(e){var t=this._getIndex(e);return-1===t?null:this._entries[t]},n.getAndReuse=function(e){var t=this._getIndex(e);if(-1===t)return null;var n=this._entries.splice(t,1)[0];return this._entries.push(n),n},n.add=function(e,n,r){var i;if(!t(r)&&mt(r.sessionId)){var a=r.sessionId,o=this._getIndex(e);if(o>=0){var s=void 0===n?3:4,u=this._entries[o];if((null!==(i=u.version)&&void 0!==i?i:-1)>=s&&a===u.sessionId)return;B.info("DRM-PSS: Updating session info.",a),this._entries.splice(o,1)}else B.info("DRM-PSS: Add new session",a);var l=e.values.getFormattedValues().map((function(e){var t=e.systemId,n=e.data;return{systemId:t,hash:e.hash,data:new pd(n)}}));void 0===n?this._entries.push({version:3,sessionId:a,values:l,initDataType:e.type}):this._entries.push({version:4,sessionId:a,keyIds:n.map((function(e){return new pd(e)})),values:l,initDataType:e.type}),this._save()}else B.warn("DRM-PSS: Invalid Persisten Session given.")},n.delete=function(e){for(var t=-1,n=0;n<this._entries.length;n++){if(this._entries[n].sessionId===e){t=n;break}}if(-1!==t){var r=this._entries[t];B.warn("DRM-PSS: Delete session from store",r.sessionId),this._entries.splice(t,1),this._save()}else B.warn("DRM-PSS: initData to delete not found.")},n.deleteOldSessions=function(e){B.info("DRM-PSS: Deleting last "+e+" sessions."),e<=0||(e<=this._entries.length?this._entries.splice(0,e):(B.warn("DRM-PSS: Asked to remove more information that it contains",e,this._entries.length),this._entries=[]),this._save())},n.dispose=function(){this._entries=[],this._save()},n._getIndex=function(e){var t=this,n=null;function r(){if(null===n){var t=e.values.constructRequestData();n={initData:t,initDataHash:vd(t)}}return n}for(var i,a=function(){var n=t._entries[o];if(n.initDataType===e.type)switch(n.version){case 4:if(void 0!==e.keyIds){if(e.keyIds.every((function(e){for(var t,r=Ha(e),i=gd(n.keyIds);!(t=i()).done;){var a=t.value;if("string"==typeof a){if(r===a)return!0}else if(Tt(a.initData,e))return!0}return!1})))return{v:o}}else if(hd(e.values.getFormattedValues(),n.values))return{v:o};break;case 3:if(hd(e.values.getFormattedValues(),n.values))return{v:o};break;case 2:var i=r(),a=i.initData,s=i.initDataHash;if(n.initDataHash===s)try{if(Tt("string"==typeof n.initData?pd.decode(n.initData):n.initData.initData,a))return{v:o}}catch(e){B.warn("DRM-PSS: Could not decode initialization data.",e instanceof Error?e:"")}break;case 1:var u=r(),l=u.initData,d=u.initDataHash;if(n.initDataHash===d){if(void 0===n.initData.length)return{v:o};if(Tt(n.initData,l))return{v:o}}break;default:var c=r().initDataHash;if(n.initData===c)return{v:o}}},o=0;o<this._entries.length;o++)if(i=a())return i.v;return-1},n._save=function(){try{this._storage.save(this._entries)}catch(t){var e=t instanceof Error?t:void 0;B.warn("DRM-PSS: Could not save MediaKeySession information",e)}},e}();var Sd=new WeakMap,Ed={prepare:function(e){Sd.set(e,null)},set:function(e,t){var n=t instanceof Uint8Array?t:new Uint8Array(t instanceof ArrayBuffer?t:t.buffer),r=vd(n);Sd.set(e,{hash:r,serverCertificate:n})},hasOne:function(e){var t=Sd.get(e);return void 0!==t&&(null!==t||void 0)},has:function(e,t){var n=Sd.get(e);if(null==n)return!1;var r=n.hash,i=n.serverCertificate,a=t instanceof Uint8Array?t:new Uint8Array(t instanceof ArrayBuffer?t:t.buffer);if(vd(a)!==r||i.length!==a.length)return!1;for(var o=0;o<i.length;o++)if(i[o]!==a[o])return!1;return!0}};function Td(e,t,n){return kd.apply(this,arguments)}function kd(){return(kd=d(g().mark((function e(n,r,i){var a,o,s,u,l,d,c,f,v,p;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,$l(n,r,i);case 2:if(a=e.sent,null===i.cancellationError){e.next=5;break}throw i.cancellationError;case 5:if(o=a.value,s=o.options,u=o.mediaKeySystemAccess,l=Br.getState(n),h=void 0,h=s.persistentLicenseConfig,d=t(h)?null:(B.debug("DRM: Set the given license storage"),new bd(h)),A||I||null===l||"reuse-media-key-system-access"!==a.type){e.next=12;break}if(c=l.mediaKeys,f=l.loadedSessionsStore,!1!==Ed.hasOne(c)&&(t(s.serverCertificate)||!Ed.has(c,s.serverCertificate))){e.next=12;break}return e.abrupt("return",{mediaKeys:c,mediaKeySystemAccess:u,stores:{loadedSessionsStore:f,persistentSessionsStore:d},options:s});case 12:return e.next=14,wd(u);case 14:return v=e.sent,B.info("DRM: MediaKeys created with success"),p=new dd(v),e.abrupt("return",{mediaKeys:v,mediaKeySystemAccess:u,stores:{loadedSessionsStore:p,persistentSessionsStore:d},options:s});case 18:case"end":return e.stop()}var h}),e)})))).apply(this,arguments)}function wd(e){return Ad.apply(this,arguments)}function Ad(){return(Ad=d(g().mark((function e(t){var n,r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return B.info("DRM: Calling createMediaKeys on the MediaKeySystemAccess"),e.prev=1,e.next=4,t.createMediaKeys();case 4:return n=e.sent,e.abrupt("return",n);case 8:throw e.prev=8,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.message:"Unknown error when creating MediaKeys.",new je("CREATE_MEDIA_KEYS_ERROR",r);case 12:case"end":return e.stop()}}),e,null,[[1,8]])})))).apply(this,arguments)}function Id(){return(Id=d(g().mark((function e(t,n,r){var i,a;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Td(t,n,r);case 2:if(i=e.sent,a=i.mediaKeys,!(null!==t.mediaKeys&&void 0!==t.mediaKeys&&a!==t.mediaKeys)){e.next=9;break}return B.debug("DRM: Disabling old MediaKeys"),e.next=9,Fl(t);case 9:return e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Rd(e,t,n){var r=Qt(e*Math.pow(2,t-1));return Math.min(r,n)}var xd=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(se(r),t.prototype),r.reason=n,r}return f(t,e),t}(de(Error)),Cd={EXPIRED:"expired",INTERNAL_ERROR:"internal-error",OUTPUT_RESTRICTED:"output-restricted"};function Md(e,t,n){var r,i=t.onKeyInternalError,a=t.onKeyOutputRestricted,o=t.onKeyExpiration,s=[],u=[],l=[];return e.keyStatuses.forEach((function(e,t){var r="string"==typeof e?[e,t]:[t,e],d=r[0],c=function(e,t){return-1!==e.indexOf("playready")&&(b||y)?Na(t):t}(n,new Uint8Array(r[1])),f={keyId:c.buffer,keyStatus:d};switch(B.hasLevel("DEBUG")&&B.debug("DRM: key status update ("+Da(c)+"): "+d),d){case Cd.EXPIRED:var v=new je("KEY_STATUS_CHANGE_ERROR","A decryption key expired ("+Da(c)+")",{keyStatuses:[f].concat(l)});if("error"===o||void 0===o)throw v;switch(o){case"close-session":throw new xd(v);case"fallback":s.push(c);break;default:"continue"===o||void 0===o?u.push(c):ve()}l.push(f);break;case Cd.INTERNAL_ERROR:var p=new je("KEY_STATUS_CHANGE_ERROR",'A "'+d+'" status has been encountered ('+Da(c)+")",{keyStatuses:[f].concat(l)});switch(i){case void 0:case"error":throw p;case"close-session":throw new xd(p);case"fallback":s.push(c);break;case"continue":u.push(c);break;default:if(void 0===i)throw p;ve()}l.push(f);break;case Cd.OUTPUT_RESTRICTED:var h=new je("KEY_STATUS_CHANGE_ERROR",'A "'+d+'" status has been encountered ('+Da(c)+")",{keyStatuses:[f].concat(l)});switch(a){case void 0:case"error":throw h;case"fallback":s.push(c);break;case"continue":u.push(c);break;default:if(void 0===a)throw h;ve()}l.push(f);break;default:u.push(c)}})),l.length>0&&(r=new je("KEY_STATUS_CHANGE_ERROR","One or several problematic key statuses have been encountered",{keyStatuses:l})),{warning:r,blacklistedKeyIds:s,whitelistedKeyIds:u}}function Pd(e,n,r,i,a){B.info("DRM: Binding session events",e.sessionId);var o=n.getLicenseConfig,s=void 0===o?{}:o,u=new pe;return u.linkToSignal(a),t(e.closed)||e.closed.then((function(){return u.cancel()})).catch((function(e){a.isCancelled()||(u.cancel(),i.onError(e))})),si(e,(function(e){u.cancel(),i.onError(new je("KEY_ERROR",e.type))}),u.signal),ui(e,(function(){try{l()}catch(e){if(a.isCancelled()||u.isUsed()&&e instanceof he)return;u.cancel(),i.onError(e)}}),u.signal),ai(e,(function(r){var a,o=r,l=new Uint8Array(o.message),c=mt(o.messageType)?o.messageType:"license-request";B.info("DRM: Received message event, type "+c,e.sessionId),function(e,n,r){var i=n.baseDelay,a=n.maxDelay,o=n.totalRetry,s=n.shouldRetry,u=n.onRetry,l=0;return c();function c(){return f.apply(this,arguments)}function f(){return(f=d(g().mark((function n(){var d,f,v;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===r.cancellationError){n.next=2;break}throw r.cancellationError;case 2:return n.prev=2,n.next=5,e();case 5:return d=n.sent,n.abrupt("return",d);case 9:if(n.prev=9,n.t0=n.catch(2),null===r.cancellationError){n.next=13;break}throw r.cancellationError;case 13:if(!(!t(s)&&!s(n.t0)||l++>=o)){n.next=15;break}throw n.t0;case 15:return"function"==typeof u&&u(n.t0,l),f=Rd(i,l,a),n.next=19,ar(f);case 19:return v=c(),n.abrupt("return",v);case 21:case"end":return n.stop()}}),n,null,[[2,9]])})))).apply(this,arguments)}}((function(){return function(e,r){var i;return new Promise((function(a,o){try{B.debug("DRM: Calling `getLicense`",r);var u=n.getLicense(e,r),l=t(s.timeout)?1e4:s.timeout;l>=0&&(i=setTimeout((function(){o(new Ld('"getLicense" timeout exceeded ('+l+" ms)"))}),l)),Promise.resolve(u).then(d,c)}catch(e){c(e)}function d(e){void 0!==i&&clearTimeout(i),a(e)}function c(e){void 0!==i&&clearTimeout(i),o(e)}}))}(l,c)}),{totalRetry:null!=(a=s.retry)?a:2,baseDelay:200,maxDelay:3e3,shouldRetry:function(e){return e instanceof Ld||t(e)||!0!==e.noRetry},onRetry:function(e){return i.onWarning(Dd(e))}},u.signal).then((function(n){if(u.isUsed())return Promise.resolve();if(t(n))B.info("DRM: No license given, skipping session.update");else try{return function(e,t){return Nd.apply(this,arguments)}(e,n)}catch(e){u.cancel(),i.onError(e)}})).catch((function(e){if(!u.isUsed()){u.cancel();var n=Dd(e);if(!t(e))if(!0===e.fallbackOnLastTry)return B.warn("DRM: Last `getLicense` attempt failed. Blacklisting the current session."),void i.onError(new Od(n));i.onError(n)}}))}),u.signal),void l();function l(){if(B.info("DRM: keystatuseschange event received",e.sessionId),!u.isUsed()&&0!==e.keyStatuses.size){var t=Md(e,n,r),a=t.warning,o=t.blacklistedKeyIds,s=t.whitelistedKeyIds;void 0!==a&&(i.onWarning(a),u.isUsed())||i.onKeyUpdate({whitelistedKeyIds:s,blacklistedKeyIds:o})}}}function Dd(e){if(e instanceof Ld)return new je("KEY_LOAD_TIMEOUT","The license server took too much time to respond.");var n=new je("KEY_LOAD_ERROR","An error occured when calling `getLicense`.");return!t(e)&&mt(e.message)&&(n.message=e.message),n}function Nd(){return(Nd=d(g().mark((function e(t,n){var r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return B.info("DRM: Updating MediaKeySession with message"),e.prev=1,e.next=4,t.update(n);case 4:e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(1),r=e.t0 instanceof Error?e.t0.toString():"`session.update` failed",new je("KEY_UPDATE_ERROR",r);case 10:B.info("DRM: MediaKeySession update succeeded.");case 11:case"end":return e.stop()}}),e,null,[[1,6]])})))).apply(this,arguments)}var Od=function(e){function t(n){var r;return r=e.call(this)||this,Object.setPrototypeOf(se(r),t.prototype),r.sessionError=n,r}return f(t,e),t}(de(Error)),Ld=function(e){function t(t){var n;return n=e.call(this)||this,Object.setPrototypeOf(se(n),Od.prototype),n.message=t,n}return f(t,e),t}(de(Error));function Ud(e,t){return Fd.apply(this,arguments)}function Fd(){return(Fd=d(g().mark((function e(t,n){var r,i;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.setServerCertificate(n);case 3:return r=e.sent,e.abrupt("return",r);case 7:throw e.prev=7,e.t0=e.catch(0),B.warn("DRM: mediaKeys.setServerCertificate returned an error",e.t0 instanceof Error?e.t0:""),i=e.t0 instanceof Error?e.t0.toString():"`setServerCertificate` error",new je("LICENSE_SERVER_CERTIFICATE_ERROR",i);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function Bd(e,t){return zd.apply(this,arguments)}function zd(){return(zd=d(g().mark((function e(t,n){var r,i;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!0!==Ed.hasOne(t)){e.next=3;break}return B.info("DRM: The MediaKeys already has a server certificate, skipping..."),e.abrupt("return",{type:"already-has-one"});case 3:if("function"==typeof t.setServerCertificate){e.next=6;break}return B.warn("DRM: Could not set the server certificate. mediaKeys.setServerCertificate is not a function"),e.abrupt("return",{type:"method-not-implemented"});case 6:return B.info("DRM: Setting server certificate on the MediaKeys"),Ed.prepare(t),e.prev=8,e.next=11,Ud(t,n);case 11:return r=e.sent,Ed.set(t,n),e.abrupt("return",{type:"success",value:r});case 16:return e.prev=16,e.t0=e.catch(8),i=$e(e.t0)?e.t0:new je("LICENSE_SERVER_CERTIFICATE_ERROR","Unknown error when setting the server certificate."),e.abrupt("return",{type:"error",value:i});case 20:case"end":return e.stop()}}),e,null,[[8,16]])})))).apply(this,arguments)}function Vd(e,t){if(!(isNaN(t)||t<0||t>=e.getLength())){var n=e.getLength(),r=n-t;B.info("DRM: Too many stored persistent sessions, removing some.",n,r),e.deleteOldSessions(r)}}var Kd=function(){function e(e){this._innerValues=e,this._lazyFormattedValues=null}var t=e.prototype;return t.constructRequestData=function(){return vi.apply(void 0,this._innerValues.map((function(e){return e.data})))},t.isCompatibleWith=function(t){var n=t instanceof e?t.getFormattedValues():t;return hd(this.getFormattedValues(),n)},t.getFormattedValues=function(){return null===this._lazyFormattedValues&&(this._lazyFormattedValues=this._innerValues.slice().sort((function(e,t){return e.systemId===t.systemId?0:void 0===e.systemId?1:void 0===t.systemId||e.systemId<t.systemId?-1:1})).map((function(e){var t=e.systemId,n=e.data;return{systemId:t,data:n,hash:vd(n)}}))),this._lazyFormattedValues},e}();function Wd(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Gd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Gd(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Gd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Hd=function(e){function n(n,r){var i;i=e.call(this)||this,B.debug("DRM: Starting ContentDecryptor logic.");var a=new pe;return i._currentSessions=[],i._canceller=a,i._initDataQueue=[],i._stateData={state:zi.Initializing,isMediaKeysAttached:0,isInitDataQueueLocked:!0,data:null},i.error=null,Dl.onEncrypted(n,(function(e){B.debug("DRM: Encrypted event received from media element.");var t=Ll(e);null!==t&&i.onInitializationData(t)}),a.signal),function(e,t,n){return Id.apply(this,arguments)}(n,r,a.signal).then((function(e){var r,a,o=e.options,s=e.mediaKeySystemAccess;(t(o.persistentLicenseConfig)||!0===o.persistentLicenseConfig.disableRetroCompatibility)&&(r=Sr(a=s.keySystem,"com.microsoft.playready")||"com.chromecast.playready"===a||"com.youtube.playready"===a?"9a04f07998404286ab92e65be0885f95":"com.widevine.alpha"===a?"edef8ba979d64acea3c827dcd51d21ed":Sr(a,"com.apple.fps")?"94ce86fb07ff4f43adb893d2fa968ca2":Sr(a,"com.nagra.")?"adb41c242dbf4a6d958b4457c0d27b95":void 0),i.systemId=r,i._stateData.state===zi.Initializing&&(i._stateData={state:zi.WaitingForAttachment,isInitDataQueueLocked:!0,isMediaKeysAttached:0,data:{mediaKeysInfo:e,mediaElement:n}},i.trigger("stateChange",i._stateData.state))})).catch((function(e){i._onFatalError(e)})),i}f(n,e),n.hasEmeApis=function(){return!t(Dl.requestMediaKeySystemAccess)};var r=n.prototype;return r.getState=function(){return this._stateData.state},r.attach=function(){var e=this;if(this._stateData.state!==zi.WaitingForAttachment)throw new Error("`attach` should only be called when in the WaitingForAttachment state");if(0===this._stateData.isMediaKeysAttached){var n=this._stateData.data,r=n.mediaElement,i=n.mediaKeysInfo,a=i.options,o=i.mediaKeys,s=i.mediaKeySystemAccess,u=i.stores;if(!(!0===a.disableMediaKeysAttachmentLock)||(this._stateData={state:zi.ReadyForContent,isInitDataQueueLocked:!0,isMediaKeysAttached:1,data:{mediaKeysInfo:i,mediaElement:r}},this.trigger("stateChange",this._stateData.state),!this._isStopped())){this._stateData.isMediaKeysAttached=1;var l={emeImplementation:Dl,loadedSessionsStore:u.loadedSessionsStore,mediaKeySystemAccess:s,mediaKeys:o,keySystemOptions:a};B.debug("DRM: Attaching current MediaKeys"),function(e,t,n){return Bl.apply(this,arguments)}(r,l,this._canceller.signal).then(d(g().mark((function n(){var r,s,u;return g().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e._stateData.isMediaKeysAttached=2,t(r=a.serverCertificate)){n.next=7;break}return n.next=5,Bd(o,r);case 5:"error"===(s=n.sent).type&&e.trigger("warning",s.value);case 7:if(!e._isStopped()){n.next=9;break}return n.abrupt("return");case 9:u=e._stateData.state,e._stateData={state:zi.ReadyForContent,isMediaKeysAttached:2,isInitDataQueueLocked:!1,data:{mediaKeysData:i}},u!==zi.ReadyForContent&&e.trigger("stateChange",zi.ReadyForContent),e._isStopped()||e._processCurrentInitDataQueue();case 13:case"end":return n.stop()}}),n)})))).catch((function(t){e._onFatalError(t)}))}}else B.warn("DRM: ContentDecryptor's `attach` method called more than once.")},r.dispose=function(){this.removeEventListener(),this._stateData={state:zi.Disposed,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("stateChange",this._stateData.state)},r.onInitializationData=function(e){var t=this;if(!1===this._stateData.isInitDataQueueLocked){var n=this._stateData.data.mediaKeysData,r=Object.assign(Object.assign({},e),{values:new Kd(e.values)});this._processInitializationData(r,n).catch((function(e){t._onFatalError(e)}))}else{if(this._isStopped())throw new Error("ContentDecryptor either disposed or stopped.");this._initDataQueue.push(e)}},r._processInitializationData=function(){var e=d(g().mark((function e(n,r){var i,a,o,s,u,l,d,c,f,v,p,h,m,y,_,b,S,E,T,k,w,A,I,R,x,C,M,P,D,N,O,U,F,z=this;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.mediaKeySystemAccess,a=r.stores,o=r.options,!this._tryToUseAlreadyCreatedSession(n,r)&&!this._isStopped()){e.next=3;break}return e.abrupt("return");case 3:if("content"!==o.singleLicensePer){e.next=15;break}if(void 0===(s=Se(this._currentSessions,(function(e){return"created-session"===e.source})))){e.next=13;break}if(void 0!==(u=n.keyIds)){e.next=10;break}return void 0===n.content?B.warn("DRM: Unable to fallback from a non-decipherable quality."):this.trigger("blackListProtectionData",n),e.abrupt("return");case 10:return s.record.associateKeyIds(u),void 0!==n.content&&(B.hasLevel("DEBUG")&&(l=u.reduce((function(e,t){return e+", "+Da(t)}),""),B.debug("DRM: Blacklisting new key ids",l)),this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:u,delistedKeyIds:[]})),e.abrupt("return");case 13:e.next=42;break;case 15:if("periods"!==o.singleLicensePer||void 0===n.content){e.next=42;break}d=n.content.period,c=this._currentSessions.filter((function(e){return"created-session"===e.source})),Qd(f=new Set,d),v=Wd(c);case 21:if((p=v()).done){e.next=42;break}h=p.value,m=Array.from(f),y=0,_=m;case 25:if(!(y<_.length)){e.next=40;break}if(b=_[y],!h.record.isAssociatedWithKeyId(b)){e.next=37;break}h.record.associateKeyIds(f.values()),S=g().mark((function e(){var t;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=T.value,h.keyStatuses.whitelisted.some((function(e){return Tt(e,t)}))||h.keyStatuses.blacklisted.some((function(e){return Tt(e,t)}))||h.keyStatuses.blacklisted.push(t);case 2:case"end":return e.stop()}}),e)})),E=Wd(m);case 31:if((T=E()).done){e.next=35;break}return e.delegateYield(S(),"t0",33);case 33:e.next=31;break;case 35:return this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:h.keyStatuses.whitelisted,blacklistedKeyIds:h.keyStatuses.blacklisted,delistedKeyIds:[]}),e.abrupt("return");case 37:y++,e.next=25;break;case 40:e.next=21;break;case 42:return this._lockInitDataQueue(),t(o.persistentLicenseConfig)?k="temporary":jd(i)?k="persistent-license":(B.warn('DRM: Cannot create "persistent-license" session: not supported'),k="temporary"),w=L.getCurrent(),A=w.EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS,I=w.EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION,R="number"==typeof o.maxSessionCacheSize?o.maxSessionCacheSize:A,e.next=48,jl(n,a,k,R,this._canceller.signal);case 48:if(x=e.sent,!this._isStopped()){e.next=51;break}return e.abrupt("return");case 51:if(C={record:x.value.keySessionRecord,source:x.type,keyStatuses:{whitelisted:[],blacklisted:[]},blacklistedSessionError:null},this._currentSessions.push(C),M=x.value,P=M.mediaKeySession,D=M.sessionType,N=!1,Pd(P,o,i.keySystem,{onKeyUpdate:function(e){var t=qd(n,C.record,o.singleLicensePer,"created-session"===C.source,e.whitelistedKeyIds,e.blacklistedKeyIds);if(C.record.associateKeyIds(t.whitelisted),C.record.associateKeyIds(t.blacklisted),C.keyStatuses={whitelisted:t.whitelisted,blacklisted:t.blacklisted},0!==C.record.getAssociatedKeyIds().length&&"persistent-license"===D&&null!==a.persistentSessionsStore&&!N){var r=a.persistentSessionsStore;Vd(r,I-1),r.add(n,C.record.getAssociatedKeyIds(),P),N=!0}void 0!==n.content&&z.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:t.whitelisted,blacklistedKeyIds:t.blacklisted,delistedKeyIds:[]}),z._unlockInitDataQueue()},onWarning:function(e){z.trigger("warning",e)},onError:function(e){var t;if(e instanceof xd){B.warn("DRM: A session's closing condition has been triggered"),z._lockInitDataQueue();var r=z._currentSessions.indexOf(C);return r>=0&&z._currentSessions.splice(r),void 0!==n.content&&z.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:[],delistedKeyIds:C.record.getAssociatedKeyIds()}),null===(t=a.persistentSessionsStore)||void 0===t||t.delete(P.sessionId),a.loadedSessionsStore.closeSession(P).catch((function(e){var t=e instanceof Error?e:"unknown error";B.warn("DRM: failed to close expired session",t)})).then((function(){return z._unlockInitDataQueue()})).catch((function(e){return z._onFatalError(e)})),void(z._isStopped()||z.trigger("warning",e.reason))}e instanceof Od?(C.blacklistedSessionError=e,void 0!==n.content&&(B.info("DRM: blacklisting Representations based on protection data."),z.trigger("blackListProtectionData",n)),z._unlockInitDataQueue()):z._onFatalError(e)}},this._canceller.signal),void 0!==o.singleLicensePer&&"init-data"!==o.singleLicensePer||this._unlockInitDataQueue(),"created-session"!==x.type){e.next=72;break}return O=n.values.constructRequestData(),e.prev=59,e.next=62,a.loadedSessionsStore.generateLicenseRequest(P,n.type,O);case 62:e.next=72;break;case 64:if(e.prev=64,e.t1=e.catch(59),null!==(U=a.loadedSessionsStore.getEntryForSession(P))&&"none"===U.closingStatus.type){e.next=71;break}return(F=this._currentSessions.indexOf(C))>=0&&this._currentSessions.splice(F,1),e.abrupt("return",Promise.resolve());case 71:throw new je("KEY_GENERATE_REQUEST_ERROR",e.t1 instanceof Error?e.t1.toString():"Unknown error");case 72:return e.abrupt("return",Promise.resolve());case 73:case"end":return e.stop()}}),e,this,[[59,64]])})));return function(t,n){return e.apply(this,arguments)}}(),r._tryToUseAlreadyCreatedSession=function(e,n){var r=n.stores,i=n.options,a=Se(this._currentSessions,(function(t){return t.record.isCompatibleWith(e)}));if(void 0===a)return!1;if(!t(a.blacklistedSessionError))return void 0===e.type||void 0===e.content?(B.error("DRM: This initialization data has already been blacklisted but the current content is not known."),!0):(B.info("DRM: This initialization data has already been blacklisted. Blacklisting the related content."),this.trigger("blackListProtectionData",e),!0);if(void 0!==e.keyIds){var o;if(void 0===i.singleLicensePer||"init-data"===i.singleLicensePer){var s=a.keyStatuses.blacklisted;o=function(e,t){for(var n,r,i=function(){var e=r.value;if(t.some((function(t){return Tt(t,e)})))return{v:!0}},a=nd(e);!(r=a()).done;)if(n=i())return n.v;return!1}(e.keyIds,s)}else{var u=a.keyStatuses.whitelisted;o=!id(e.keyIds,u)}if(o)return void 0===e.content?(B.error("DRM: Cannot forbid key id, the content is unknown."),!0):(B.info("DRM: Current initialization data is linked to blacklisted keys. Marking Representations as not decipherable"),this.trigger("keyIdsCompatibilityUpdate",{whitelistedKeyIds:[],blacklistedKeyIds:e.keyIds,delistedKeyIds:[]}),!0)}if(null!==r.loadedSessionsStore.reuse(e))return B.debug("DRM: Init data already processed. Skipping it."),!0;var l=this._currentSessions.indexOf(a);return-1===l?B.error("DRM: Unable to remove processed init data: not found."):(B.debug("DRM: A session from a processed init data is not available anymore. Re-processing it."),this._currentSessions.splice(l,1)),!1},r._onFatalError=function(e){if(!this._canceller.isUsed()){var t=e instanceof Error?e:new Qe("NONE","Unknown decryption error");this.error=t,this._initDataQueue.length=0,this._stateData={state:zi.Error,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("error",t),this._stateData.state===zi.Error&&this.trigger("stateChange",this._stateData.state)}},r._isStopped=function(){return this._stateData.state===zi.Disposed||this._stateData.state===zi.Error},r._processCurrentInitDataQueue=function(){for(;!1===this._stateData.isInitDataQueueLocked;){var e=this._initDataQueue.shift();if(void 0===e)return;this.onInitializationData(e)}},r._lockInitDataQueue=function(){!1===this._stateData.isInitDataQueueLocked&&(this._stateData.isInitDataQueueLocked=!0)},r._unlockInitDataQueue=function(){2===this._stateData.isMediaKeysAttached?(this._stateData.isInitDataQueueLocked=!1,this._processCurrentInitDataQueue()):B.error("DRM: Trying to unlock in the wrong state")},n}(i);function jd(e){var t=e.getConfiguration().sessionTypes;return void 0!==t&&Je(t,"persistent-license")}function qd(e,t,n,r,i,a){for(var o,s,u=[].concat(i,a),l=function(){var e=s.value;u.some((function(t){return Tt(t,e)}))||(B.hasLevel("DEBUG")&&B.debug("DRM: KeySessionRecord's key missing in the license, blacklisting it",Da(e)),u.push(e))},d=Wd(t.getAssociatedKeyIds());!(s=d()).done;)l();if(void 0!==n&&"init-data"!==n){var c=e.keyIds,f=e.content;if(void 0!==c){var v=c.filter((function(e){return!u.some((function(t){return Tt(t,e)}))}));v.length>0&&(B.hasLevel("DEBUG")&&B.debug("DRM: init data keys missing in the license, blacklisting them",v.map((function(e){return Da(e)})).join(", ")),u.push.apply(u,v))}if(r&&void 0!==f)if("content"===n){for(var p,h=new Set,m=Wd(f.manifest.periods);!(p=m()).done;){Qd(h,p.value)}Yd(h,u)}else if("periods"===n)for(var g,y=Wd(f.manifest.periods);!(g=y()).done;){var _=g.value,b=new Set;if(Qd(b,_),(null===(o=e.content)||void 0===o?void 0:o.period.id)===_.id)Yd(b,u);else for(var S=Array.from(b),E=function(){var e=k[T];if(u.some((function(t){return Tt(t,e)})))return Yd(b,u),1},T=0,k=S;T<k.length&&!E();T++);}}return{whitelisted:i,blacklisted:u.slice(i.length)}}function Yd(e,t){for(var n=Array.from(e.values()),r=function(){var e=a[i];t.some((function(t){return Tt(t,e)}))||t.push(e)},i=0,a=n;i<a.length;i++)r()}function Qd(e,n){for(var r,i=Wd(Pe(n.adaptations).reduce((function(e,n){return t(n)?e:e.concat(n)}),[]));!(r=i()).done;)for(var a,o=Wd(r.value.representations);!(a=o()).done;){var s=a.value;if(void 0!==s.contentProtections&&void 0!==s.contentProtections.keyIds)for(var u,l=Wd(s.contentProtections.keyIds);!(u=l()).done;){var d=u.value;e.add(d.keyId)}}}var $d=Hd;function Xd(e){e.decrypt=$d}function Zd(e,t){if(S&&function(e,t){var n=e.activeCues;if(null===n)return!1;for(var r=0;r<n.length;r++)if(n[r]===t)return!0;return!1}(e,t)){var n=e.mode;e.mode="hidden";try{e.removeCue(t)}catch(e){B.warn("Compat: Could not remove cue from text track.")}e.mode=n}else try{e.removeCue(t)}catch(e){B.warn("Compat: Could not remove cue from text track.")}}var Jd=function(){function e(){this._ranges=[],this.length=0}var t=e.prototype;return t.insert=function(e,t){Z(this._ranges,{start:e,end:t}),this.length=this._ranges.length},t.remove=function(e,t){var n=[];e>0&&n.push({start:0,end:e}),t<1/0&&n.push({start:t,end:1/0}),this._ranges=function(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=J(i,t);if(a.length>0)for(var o=0;o<a.length;o++){var s=a[o];n.push({start:Math.max(i.start,s.start),end:Math.min(i.end,s.end)})}}return n}(this._ranges,n),this.length=this._ranges.length},t.start=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].start},t.end=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].end},e}();var ec=function(){function e(e){B.debug("NTD: Creating NativeTextDisplayer");var t=function(e){var t,n,r,i="subtitles";if(b){var a=e.textTracks.length;(n=a>0?e.textTracks[a-1]:e.addTextTrack(i)).mode=null!==(t=n.SHOWING)&&void 0!==t?t:"showing"}else r=document.createElement("track"),e.appendChild(r),n=r.track,r.kind=i,n.mode="showing";return{track:n,trackElement:r}}(e),n=t.track,r=t.trackElement;this._buffered=new Jd,this._videoElement=e,this._track=n,this._trackElement=r}var t=e.prototype;return t.pushTextData=function(e){var t,n;if(B.debug("NTD: Appending new native text tracks"),null===e.chunk)return q(this._buffered);var r,i,a=e.timestampOffset,o=e.appendWindow,s=e.chunk,u=s.start,l=s.end,d=s.data,c=s.type,f=s.language,v=null!==(t=o[0])&&void 0!==t?t:0,p=null!==(n=o[1])&&void 0!==n?n:1/0,h=function(e,t,n,r){B.debug("NTSB: Finding parser for native text tracks:",e);var i=Et.nativeTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");B.debug("NTSB: Parser found, parsing...");var a=i(t,n,r);return B.debug("NTSB: Parsed successfully!",a.length),a}(c,d,a,f);if(0!==v&&p!==1/0){for(var m=0;m<h.length&&h[m].endTime<=v;)m++;for(h.splice(0,m),m=0;m<h.length&&h[m].startTime<v;)h[m].startTime=v,m++;for(m=h.length-1;m>=0&&h[m].startTime>=p;)m--;for(h.splice(m,h.length),m=h.length-1;m>=0&&h[m].endTime>p;)h[m].endTime=p,m--}if(void 0!==u)r=Math.max(v,u);else{if(h.length<=0)return B.warn("NTD: Current text tracks have no cues nor start time. Aborting"),q(this._buffered);B.warn("NTD: No start time given. Guessing from cues."),r=h[0].startTime}if(void 0!==l)i=Math.min(p,l);else{if(h.length<=0)return B.warn("NTD: Current text tracks have no cues nor end time. Aborting"),q(this._buffered);B.warn("NTD: No end time given. Guessing from cues."),i=h[h.length-1].endTime}if(i<=r)return B.warn("NTD: Invalid text track appended: ","the start time is inferior or equal to the end time."),q(this._buffered);if(h.length>0){var g=h[0],y=this._track.cues;null!==y&&y.length>0&&g.startTime<y[y.length-1].startTime&&this._removeData(g.startTime,1/0);for(var _=0;_<h.length;_++)this._track.addCue(h[_])}return this._buffered.insert(r,i),q(this._buffered)},t.removeBuffer=function(e,t){return this._removeData(e,t),q(this._buffered)},t.getBufferedRanges=function(){return q(this._buffered)},t.reset=function(){B.debug("NTD: Aborting NativeTextDisplayer"),this._removeData(0,1/0);var e=this._trackElement,t=this._videoElement;if(void 0!==e&&t.hasChildNodes())try{t.removeChild(e)}catch(e){B.warn("NTD: Can't remove track element from the video")}var n=this._track.mode;this._track.mode="disabled",this._track.mode=n,void 0!==this._trackElement&&(this._trackElement.innerHTML="")},t.stop=function(){B.debug("NTD: Aborting NativeTextDisplayer"),this._removeData(0,1/0);var e=this._trackElement,t=this._videoElement;if(void 0!==e&&t.hasChildNodes())try{t.removeChild(e)}catch(e){B.warn("NTD: Can't remove track element from the video")}this._track.mode="disabled",void 0!==this._trackElement&&(this._trackElement.innerHTML="")},t._removeData=function(e,t){B.debug("NTD: Removing native text track data",e,t);var n=this._track,r=n.cues;if(null!==r)for(var i=r.length-1;i>=0;i--){var a=r[i],o=a.startTime,s=a.endTime;o>=e&&o<=t&&s<=t&&Zd(n,a)}this._buffered.remove(e,t)},e}(),tc=ec,nc=/(\d+) (\d+)/;function rc(e,t,n,r){for(var i,a={},o=e.slice(),s=function(){var e=t[u];if(void 0!==e){var i,s;if(e.nodeType===Node.ELEMENT_NODE)for(var l=e,d=0;d<=l.attributes.length-1;d++){var c=l.attributes[d],f=c.name;if("style"===f)i=c.value;else if("region"===f)s=c.value;else{var v=f.substring(4);if(Je(o,v)&&(a[v]=c.value,o.splice(d,1),0===o.length))return{v:a}}}if(mt(i)){var p=Se(n,(function(e){return e.id===i}));if(void 0!==p)for(var h=0;h<=o.length-1;h++){var m=o[h];if(!mt(a[m])&&mt(p.style[m])){if(a[m]=p.style[m],o.splice(h,1),0===o.length)return{v:a};h--}}}if(mt(s)){var g=Se(r,(function(e){return e.id===s}));if(void 0!==g)for(var y=0;y<=o.length-1;y++){var _=o[y];if(!mt(a[_])&&mt(g.style[_])){if(a[_]=g.style[_],o.splice(y,1),0===o.length)return{v:a};y--}}}}},u=0;u<=t.length-1;u++)if(i=s())return i.v;return a}function ic(e){if(e.nodeType!==Node.ELEMENT_NODE)return{};for(var t=e,n={},r=0;r<=t.attributes.length-1;r++){var i=t.attributes[r];if(Sr(i.name,"tts"))n[i.name.substring(4)]=i.value}return n}function ac(e,t){if(!(e.parentNode instanceof Element))return[];return function e(n){var r=[];n.tagName.toLowerCase()===t.toLowerCase()&&r.push(n);var i=n.parentNode;return i instanceof Element&&r.push.apply(r,e(i)),r}(e.parentNode)}function oc(e){var t=ac(e,"div");if(0===t.length){var n=ac(e,"tt:div");n.length>0&&(t=n)}return t}function sc(e){return"br"===e.nodeName||"tt:br"===e.nodeName}function uc(e){return"span"===e.nodeName||"tt:span"===e.nodeName}var lc=["align","backgroundColor","color","direction","display","displayAlign","extent","fontFamily","fontSize","fontStyle","fontWeight","lineHeight","opacity","origin","overflow","padding","textAlign","textDecoration","textOutline","unicodeBidi","visibility","wrapOption","writingMode"];function dc(e,t){var n=[],r=(new DOMParser).parseFromString(e,"text/xml");if(null!=r){var i=r.getElementsByTagName("tt")[0];if(void 0===i)if(void 0===(i=r.getElementsByTagNameNS("*","tt")[0]))throw new Error("invalid XML");for(var a=function(e){var t=e.getElementsByTagName("body");if(t.length>0)return t[0];var n=e.getElementsByTagName("tt:body");return n.length>0?n[0]:null}(i),o=function(e){var t=e.getElementsByTagName("style");if(t.length>0)return t;var n=e.getElementsByTagName("tt:style");return n.length>0?n:t}(i),s=function(e){var t=e.getElementsByTagName("region");if(t.length>0)return t;var n=e.getElementsByTagName("tt:region");return n.length>0?n:t}(i),u=function(e){var t=e.getElementsByTagName("p");if(t.length>0)return t;var n=e.getElementsByTagName("tt:p");return n.length>0?n:t}(i),l=function(e){var t=e.getAttribute("ttp:frameRate"),n=e.getAttribute("ttp:subFramRate"),r=e.getAttribute("ttp:tickRate"),i=e.getAttribute("ttp:frameRateMultiplier"),a=e.getAttribute("xml:space"),o=e.getAttribute("ttp:cellResolution"),s={columns:32,rows:15};if(null!==o){var u=nc.exec(o);if(null===u||u.length<3)B.warn("TTML Parser: Invalid cellResolution");else{var l=parseInt(u[1],10),d=parseInt(u[2],10);isNaN(l)||isNaN(d)?B.warn("TTML Parser: Invalid cellResolution"):s={columns:l,rows:d}}}if(mt(a)&&"default"!==a&&"preserve"!==a)throw new Error("Invalid spacing style");var c=Number(t);(isNaN(c)||c<=0)&&(c=30);var f=Number(n);(isNaN(f)||f<=0)&&(f=1);var v=Number(r);(isNaN(v)||v<=0)&&(v=void 0);var p=c,h=null!=f?f:1,m=null!=a?a:"default",g=null!=v?v:c*f;if(null!==i){var y=/^(\d+) (\d+)$/g.exec(i);null!==y&&(p=c*(Number(y[1])/Number(y[2])))}return{cellResolution:s,tickRate:g,frameRate:p,subFrameRate:h,spaceStyle:m}}(i),d=[],c=0;c<=o.length-1;c++){var f=o[c];if(f instanceof Element){var v=f.getAttribute("xml:id");if(null!==v){var p=f.getAttribute("style"),h=null===p?[]:p.split(" ");d.push({id:v,style:ic(f),extendsStyles:h})}}}!function(e){var t=[];function n(r,i){t.push(i);for(var a=function(){var i=r.extendsStyles[o],a=te(e,(function(e){return e.id===i}));if(a<0)B.warn("TTML Parser: unknown style inheritance: "+i);else{var s=e[a];Je(t,a)?B.warn("TTML Parser: infinite style inheritance loop avoided"):n(s,a),r.style=P({},s.style,r.style)}},o=0;o<r.extendsStyles.length;o++)a();r.extendsStyles.length=0}for(var r=0;r<e.length;r++)n(e[r],r),t.length=0}(d);for(var m=[],g=function(){var e=s[y];if(e instanceof Element){var t=e.getAttribute("xml:id");if(null!==t){var n=ic(e),r=e.getAttribute("style");if(mt(r)){var i=Se(d,(function(e){return e.id===r}));void 0!==i&&(n=P({},i.style,n))}m.push({id:t,style:n,extendsStyles:[]})}}},y=0;y<=s.length-1;y++)g();for(var _=rc(lc,null!==a?[a]:[],d,m),b="default"===(null!==a?a.getAttribute("xml:space"):void 0)||"default"===l.spaceStyle,S=0;S<u.length;S++){var E=u[S];if(E instanceof Element){var T=oc(E),k=P({},_,rc(lc,[E].concat(T),d,m)),w=E.getAttribute("xml:space"),A=mt(w)?"default"===w:b,I={paragraph:E,timeOffset:t,idStyles:d,regionStyles:m,body:a,paragraphStyle:k,ttParams:l,shouldTrimWhiteSpace:A};null!==I&&n.push(I)}}}return n}function cc(e){return"function"==typeof s.VTTCue&&e instanceof s.VTTCue}function fc(e,n,r){if(e>=n)return B.warn("Compat: Invalid cue times: "+e+" - "+n),null;if(t(s.VTTCue)){if(t(s.TextTrackCue))throw new Error("VTT cues not supported in your target");return new TextTrackCue(e,n,r)}return new VTTCue(e,n,r)}var vc=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,pc=/^(?:(\d{2,}):)?(\d{2}):(\d{2})$/,hc=/^(?:(\d{2,}):)?(\d{2}):(\d{2}\.\d{2,})$/,mc=/^(\d*\.?\d*)f$/,gc=/^(\d*\.?\d*)t$/,yc=/^(?:(\d*\.?\d*)h)?(?:(\d*\.?\d*)m)?(?:(\d*\.?\d*)s)?(?:(\d*\.?\d*)ms)?$/,_c=/^(\d{1,2}|100)% (\d{1,2}|100)%$/,bc=/^((?:\+|\-)?\d*(?:\.\d+)?)(px|em|c|%|rh|rw)$/,Sc=/^#([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})([0-9A-f]{2})$/,Ec=/^#([0-9A-f])([0-9A-f])([0-9A-f])([0-9A-f])$/,Tc=/^rgb\( *(\d+) *, *(\d+) *, *(\d+) *\)/,kc=/^rgba\( *(\d+) *, *(\d+) *, *(\d+) *, *(\d+) *\)/;function wc(e,t){var n=e.exec(t);if(null===n||""===n[0])return null;var r=Number(n[1]);isNaN(r)&&(r=0);var i=Number(n[2]);isNaN(i)&&(i=0);var a=Number(n[3]);isNaN(a)&&(a=0);var o=Number(n[4]);return isNaN(o)&&(o=0),o/1e3+a+60*i+3600*r}var Ac=function(e,t){return vc.test(e)?function(e,t){var n=vc.exec(t),r=Number(n[1]),i=Number(n[2]),a=Number(n[3]),o=Number(n[4]),s=Number(n[5]);isNaN(s)&&(s=0);return o+=s/e.subFrameRate,a+=o/e.frameRate,a+60*i+3600*r}(t,e):pc.test(e)?wc(pc,e):hc.test(e)?wc(hc,e):mc.test(e)?function(e,t){var n=mc.exec(t);return Number(n[1])/e.frameRate}(t,e):gc.test(e)?function(e,t){var n=gc.exec(t);return Number(n[1])/e.tickRate}(t,e):yc.test(e)?wc(yc,e):void 0};function Ic(e,n){var r=e.getAttribute("begin"),i=e.getAttribute("dur"),a=e.getAttribute("end"),o=mt(r)?Ac(r,n):null,s=mt(i)?Ac(i,n):null,u=mt(a)?Ac(a,n):null;if(t(o)||t(u)&&t(s))throw new Error("Invalid text cue");return{start:o,end:t(u)?o+s:u}}var Rc={left:"start",center:"center",right:"end",start:"start",end:"end"},xc={left:"line-left",center:"center",right:"line-right"};function Cc(e){var n=e.paragraph,r=e.timeOffset,i=e.paragraphStyle,a=e.ttParams,o=e.shouldTrimWhiteSpace;if(!n.hasAttribute("begin")&&!n.hasAttribute("end")&&/^\s*$/.test(null===n.textContent?"":n.textContent))return null;var s=Ic(n,a),u=s.start,l=s.end,d=function(e,t){function n(e,t){for(var r=e.childNodes,i="",a=0;a<r.length;a++){var o=r[a];if("#text"===o.nodeName){var s=o.textContent;if(null===s&&(s=""),t){var u=s.trim();s=u=u.replace(/\s+/g," ")}i+=s.replace(/&|\u0026/g,"&amp;").replace(/<|\u003C/g,"&lt;").replace(/>|\u2265/g,"&gt;").replace(/\u200E/g,"&lrm;").replace(/\u200F/g,"&rlm;").replace(/\u00A0/g,"&nbsp;")}else if(sc(o))i+="\n";else if(uc(o)&&o.nodeType===Node.ELEMENT_NODE&&o.childNodes.length>0){var l=o.getAttribute("xml:space");i+=n(o,mt(l)?"default"===l:t)}}return i}return n(e,t)}(n,o),c=fc(u+r,l+r,d);return null===c?null:(cc(c)&&function(e,n){var r=n.extent;if(mt(r)){var i=_c.exec(r);t(i)||(e.size=Number(i[1]))}switch(n.writingMode){case"tb":case"tblr":e.vertical="lr";break;case"tbrl":e.vertical="rl"}var a=n.origin;if(mt(a)){t(_c.exec(a))}var o=n.align;if(mt(o)){e.align=o,"center"===o&&("center"!==e.align&&(e.align="middle"),e.position="auto");var s=xc[o];e.positionAlign=void 0===s?"":s;var u=Rc[o];e.lineAlign=void 0===u?"":u}}(c,i),c)}var Mc=function(e,t){for(var n=dc(e,t),r=[],i=0;i<n.length;i++){var a=Cc(n[i]);null!==a&&r.push(a)}return r};function Pc(e){e.nativeTextTracksParsers.ttml=Mc,e.nativeTextDisplayer=tc}var Dc=/&#([0-9]+);/g,Nc=/<br>/gi,Oc=/<style[^>]*>([\s\S]*?)<\/style[^>]*>/i,Lc=/\s*<p (?:class=([^>]+))?>(.*)/i,Uc=/<sync[^>]+?start="?([0-9]*)"?[^0-9]/i;function Fc(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}var Bc=function(e,n,r){var i,a,o=/<sync[ >]/gi,s=/<sync[ >]|<\/body>/gi,u=[],l=Oc.exec(e),d=null!==l?l[1]:"";s.exec(e);var c,f=function(e){for(var n=/\.(\S+)\s*{([^}]*)}/gi,r={},i=n.exec(e);Array.isArray(i);){var a=i[1],o=Fc(i[2],"lang");t(a)||t(o)||(r[o]=a),i=n.exec(e)}return r}(d);if(mt(r)&&void 0===(c=f[r]))throw new Error("sami: could not find lang "+r+" in CSS");for(;i=o.exec(e),a=s.exec(e),null!==i||null!==a;){if(null===i||null===a||i.index>=a.index)throw new Error("parse error");var v=e.slice(i.index,a.index),p=Uc.exec(v);if(null===p)throw new Error("parse error (sync time attribute)");var h=+p[1];if(isNaN(h))throw new Error("parse error (sync time attribute NaN)");m(v.split("\n"),h/1e3)}return function(e){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=i.start,o=i.end,s=i.text;if(mt(s)&&!t(o)){var u=fc(a,o,s);null!==u&&n.push(u)}}return n}(u);function m(e,t){for(var r,i,a=e.length;--a>=0;)if(null!==(r=Lc.exec(e[a]))){var o=r,s=o[1],l=o[2];c===s&&("&nbsp;"===l?u[u.length-1].end=t:u.push({text:(i=l,i.replace(Nc,"\n").replace(Dc,(function(e,t){return String.fromCharCode(Number(t))}))),start:t+n}))}}};function zc(e){e.nativeTextTracksParsers.sami=Bc,e.nativeTextDisplayer=tc}function Vc(e){for(var t=0;t<e.length;){if(""===e[t])return t+1;t++}return t}function Kc(e,t){return"string"==typeof e[t]&&/^STYLE( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}function Wc(e,t){var n=e[t];if(void 0===n||""===n||Kc(e,t)||function(e,t){return"string"==typeof e[t]&&/^REGION( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}(e,t)||function(e,t){return"string"==typeof e[t]&&/^NOTE( .*)?$/g.test(e[t])&&(void 0===e[t+1]||e[t+1].indexOf("--\x3e")<0)}(e,t))return!1;if(n.indexOf("--\x3e")>=0)return!0;var r=e[t+1];return void 0!==r&&r.indexOf("--\x3e")>=0}function Gc(e,t){for(var n=t+1;mt(e[n]);)n++;return n}function Hc(e,t){for(var n=[],r=t;r<e.length;r++)if(Wc(e,r)){var i=Gc(e,r);n.push(e.slice(r,i)),r=i}else if(mt(e[r]))for(;mt(e[r]);)r++;return n}function jc(e){var t=e.split(":").reverse();if(mt(t[2])||mt(t[1])){var n=mt(t[2])?parseInt(t[2],10):0,r=parseInt(t[1],10),i=parseFloat(t[0].replace(",","."));if(isNaN(n)||isNaN(r)||isNaN(i))return;return 60*n*60+60*r+i}}function qc(e,t){var n,r,i,a=/-->/;if(a.test(e[0]))n=e[0],r=e.slice(1,e.length);else{if(!a.test(e[1]))return null;i=e[0],n=e[1],r=e.slice(2,e.length)}var o=function(e){var t=/^([\d:.]+)[ |\t]+-->[ |\t]+([\d:.]+)[ |\t]*(.*)$/.exec(e);if(null===t)return null;var n=jc(t[1]),r=jc(t[2]);return void 0===n||void 0===r?null:{start:n,end:r,settings:t[3].split(/ |\t/).reduce((function(e,t){var n=t.split(":");return 2===n.length&&(e[n[0]]=n[1]),e}),{})}}(n);return null===o?null:{start:o.start+t,end:o.end+t,settings:o.settings,payload:r,header:i}}function Yc(e,t){if(!mt(e.vertical)||"rl"!==e.vertical&&"lr"!==e.vertical||(t.vertical=e.vertical),mt(e.line)){var n=/^(\d+(\.\d+)?)%(,([a-z]+))?/.exec(e.line);if(Array.isArray(n))t.line=Number(n[1]),t.snapToLines=!1,Je(["start","center","end"],n[4])&&(t.lineAlign=n[4]);else{var r=/^(-?\d+)(,([a-z]+))?/.exec(e.line);Array.isArray(r)&&(t.line=Number(r[1]),t.snapToLines=!0,Je(["start","center","end"],r[3])&&(t.lineAlign=r[3]))}}if(mt(e.position)){var i=/^([\d\.]+)%(?:,(line-left|line-right|center))?$/.exec(e.position);if(Array.isArray(i)&&i.length>=2){var a=parseInt(i[1],10);isNaN(a)||(t.position=a,void 0!==i[2]&&(t.positionAlign=i[2]))}}mt(e.size)&&(t.size=e.size),"string"==typeof e.align&&Je(["start","center","end","left"],e.align)&&(t.align=e.align)}var Qc=function(e,t){var n=e.split(/\r\n|\n|\r/);if(!/^WEBVTT($| |\t)/.test(n[0]))throw new Error("Can't parse WebVTT: Invalid file.");for(var r,i=Hc(n,Vc(n)),a=[],o=0;o<i.length;o++){var s=qc(i[o],t);if(null!==s){var u=fc((r=s).start,r.end,r.payload.join("\n"));null!==u&&(cc(u)&&Yc(s.settings,u),a.push(u))}}return a};function $c(e){e.nativeTextTracksParsers.vtt=Qc,e.nativeTextDisplayer=tc}function Xc(e,t){for(var n=t+1;mt(e[n]);)n++;return n}function Zc(e){for(var t=[],n=0;n<e.length;n++)if(mt(e[n])){var r=Xc(e,n),i=e.slice(n,r);i.length>0&&(1===i.length?i[0].indexOf("--\x3e")>=0&&t.push(i):(i[1].indexOf("--\x3e")>=0||i[0].indexOf("--\x3e")>=0)&&t.push(i)),n=r}return t}function Jc(e){var t=e.split(":");if(mt(t[2])){var n=parseInt(t[0],10),r=parseInt(t[1],10),i=parseFloat(t[2].replace(",","."));if(isNaN(n)||isNaN(r)||isNaN(i))return;return 60*n*60+60*r+i}}function ef(e,t){if(0===e.length)return null;var n,r,i=[];if(mt(e[1])&&-1!==e[1].indexOf("--\x3e")){var a=e[1].split("--\x3e").map((function(e){return e.trim()}));n=a[0],r=a[1],i=e.slice(2,e.length)}if(!mt(n)||!mt(r)){var o=e[0].split("--\x3e").map((function(e){return e.trim()}));n=o[0],r=o[1],i=e.slice(1,e.length)}if(!mt(n)||!mt(r))return null;var s=Jc(n),u=Jc(r);return void 0===s||void 0===u?null:{start:s+t,end:u+t,payload:i}}function tf(e,t){for(var n,r,i,a,o,s=Zc(e.split(/\r\n|\n|\r/)),u=[],l=0;l<s.length;l++){var d=ef(s[l],t);if(null!==d){var c=(r=void 0,i=void 0,a=void 0,o=void 0,r=(n=d).start,i=n.end,a=n.payload,o=a.join("\n"),fc(r,i,o));null!==c&&u.push(c)}}return u}function nf(e){e.nativeTextTracksParsers.srt=tf,e.nativeTextDisplayer=tc}var rf=s.ResizeObserver;function af(e,t,n){return void 0===n&&(n=.2),Math.abs(e-t)<=Math.min(n,.2)}function of(e,t){for(var n=e.length-1;n>=0;n--){if(e[n].start<t)return e.slice(0,n+1)}return[]}function sf(e,t){for(var n=0;n<e.length;n++){if(e[n].end>t)return e.slice(n,e.length)}return[]}function uf(e,t,n){var r=Math.max(e.start,t),i=of(e.cues,t),a={start:e.start,end:r,cues:i},o=Math.min(n,e.end),s=sf(e.cues,n);return[a,{start:o,end:e.end,cues:s}]}var lf=function(){function e(){this._cuesBuffer=[]}var t=e.prototype;return t.isEmpty=function(){return 0===this._cuesBuffer.length},t.get=function(e){for(var t=this._cuesBuffer,n=[],r=t.length-1;r>=0;r--){var i=t[r];if(e<i.end&&e>=i.start){for(var a=i.cues,o=0;o<a.length;o++)e>=a[o].start&&e<a[o].end&&n.push(a[o].element);if(0===n.length&&a.length>0)for(var s=0;s<a.length;s++)(af(e,a[s].start,.001)||af(e,a[s].end,.001))&&n.push(a[s].element);return n}}return[]},t.remove=function(e,t){for(var n=Math.max(e,t),r=this._cuesBuffer,i=0;i<r.length;i++)if(r[i].end>e){var a=r[i];if(a.start>=n)return;if(a.end>=n){if(e<=a.start)a.cues=sf(a.cues,n),a.start=n;else{var o=uf(a,e,n),s=o[0],u=o[1];this._cuesBuffer[i]=s,r.splice(i+1,0,u)}return}a.start>=e?(r.splice(i,1),i--):(a.cues=of(a.cues,e),a.end=Math.max(e,a.start))}},t.insert=function(e,t,n){var r=this._cuesBuffer,i={start:t,end:n,cues:e},a=Math.abs(t-n)/5;function o(e){var t=r[e];void 0===t||af(i.end,t.end,a)?r[e]=i:(t.start>=i.end||(t.cues=sf(t.cues,i.end),t.start=i.end),r.splice(e,0,i))}for(var s=0;s<r.length;s++){var u=r[s];if(t<u.end){if(af(t,u.start,a)){if(af(n,u.end,a))return void(r[s]=i);if(n<u.end)return u.cues=sf(u.cues,n),u.start=n,void r.splice(s,0,i);do{r.splice(s,1),u=r[s]}while(void 0!==u&&n>u.end);return void o(s)}if(t<u.start){if(n<u.start)return void r.splice(s,0,i);if(af(n,u.start,a))return u.start=n,void r.splice(s,0,i);if(af(n,u.end,a))return void r.splice(s,1,i);if(n<u.end)return u.cues=sf(u.cues,n),u.start=n,void r.splice(s,0,i);do{r.splice(s,1),u=r[s]}while(void 0!==u&&n>u.end);return void o(s)}if(af(u.end,n,a))return u.cues=of(u.cues,t),u.end=t,void r.splice(s+1,0,i);if(u.end>n){var l=uf(u,t,n),d=l[0],c=l[1];return this._cuesBuffer[s]=d,r.splice(s+1,0,i),void r.splice(s+2,0,c)}u.cues=of(u.cues,t),u.end=t;var f=s+1;for(u=r[f];void 0!==u&&n>u.end;)r.splice(f,1),u=r[f];return void o(f)}}if(r.length){var v=r[r.length-1];af(v.end,t,a)&&(v.end=t)}r.push(i)},e}();function df(e,t,n,r){for(var i=[t/n.columns,e/n.rows],a=r.getElementsByClassName("proportional-style"),o=0;o<a.length;o++){var s=a[o];if(s instanceof HTMLElement){var u=s.getAttribute("data-proportional-font-size");null===u||isNaN(+u)||(s.style.fontSize=String(+u*i[1])+"px");var l=s.getAttribute("data-proportional-width");null===l||isNaN(+l)||(s.style.width=String(+l*i[0])+"px");var d=s.getAttribute("data-proportional-height");null===d||isNaN(+d)||(s.style.height=String(+d*i[1])+"px");var c=s.getAttribute("data-proportional-line-height");null===c||isNaN(+c)||(s.style.lineHeight=String(+c*i[1])+"px");var f=s.getAttribute("data-proportional-left");null===f||isNaN(+f)||(s.style.left=String(+f*i[0])+"px");var v=s.getAttribute("data-proportional-top");null===v||isNaN(+v)||(s.style.top=String(+v*i[1])+"px");var p=s.getAttribute("data-proportional-padding-top");null===p||isNaN(+p)||(s.style.paddingTop=String(+p*i[1])+"px");var h=s.getAttribute("data-proportional-padding-bottom");null===h||isNaN(+h)||(s.style.paddingBottom=String(+h*i[1])+"px");var m=s.getAttribute("data-proportional-padding-left");null===m||isNaN(+m)||(s.style.paddingLeft=String(+m*i[0])+"px");var g=s.getAttribute("data-proportional-padding-right");null===g||isNaN(+g)||(s.style.paddingRight=String(+g*i[0])+"px")}}return a.length>0}function cf(e,t){try{e.removeChild(t)}catch(e){B.warn("HTD: Can't remove text track: not in the element.")}}function ff(e){var t=e.getAttribute("data-resolution-rows"),n=e.getAttribute("data-resolution-columns");if(null===t||null===n)return null;var r=parseInt(t,10),i=parseInt(n,10);return null===r||null===i?null:{rows:r,columns:i}}var vf,pf=function(){function e(e,t){B.debug("HTD: Creating HTMLTextDisplayer"),this._buffered=new Jd,this._videoElement=e,this._textTrackElement=t,this._sizeUpdateCanceller=new pe,this._subtitlesIntervalCanceller=new pe,this._buffer=new lf,this._currentCues=[],this._isAutoRefreshing=!1}var t=e.prototype;return t.pushTextData=function(e){var t,n;B.debug("HTD: Appending new html text tracks");var r=e.timestampOffset,i=e.appendWindow,a=e.chunk;if(null===a)return q(this._buffered);var o,s,u=a.start,l=a.end,d=a.data,c=a.type,f=a.language,v=null!==(t=i[0])&&void 0!==t?t:0,p=null!==(n=i[1])&&void 0!==n?n:1/0,h=function(e,t,n,r){B.debug("HTSB: Finding parser for html text tracks:",e);var i=Et.htmlTextTracksParsers[e];if("function"!=typeof i)throw new Error("no parser found for the given text track");B.debug("HTSB: Parser found, parsing...");var a=i(t,n,r);return B.debug("HTTB: Parsed successfully!",a.length),a}(c,d,r,f);if(0!==v&&p!==1/0){for(var m=0;m<h.length&&h[m].end<=v;)m++;for(h.splice(0,m),m=0;m<h.length&&h[m].start<v;)h[m].start=v,m++;for(m=h.length-1;m>=0&&h[m].start>=p;)m--;for(h.splice(m,h.length),m=h.length-1;m>=0&&h[m].end>p;)h[m].end=p,m--}if(void 0!==u)o=Math.max(v,u);else{if(h.length<=0)return B.warn("HTD: Current text tracks have no cues nor start time. Aborting"),q(this._buffered);B.warn("HTD: No start time given. Guessing from cues."),o=h[0].start}if(void 0!==l)s=Math.min(p,l);else{if(h.length<=0)return B.warn("HTD: Current text tracks have no cues nor end time. Aborting"),q(this._buffered);B.warn("HTD: No end time given. Guessing from cues."),s=h[h.length-1].end}return s<=o?(B.warn("HTD: Invalid text track appended: ","the start time is inferior or equal to the end time."),q(this._buffered)):(this._buffer.insert(h,o,s),this._buffered.insert(o,s),this._isAutoRefreshing||this._buffer.isEmpty()||this.autoRefreshSubtitles(this._subtitlesIntervalCanceller.signal),q(this._buffered))},t.removeBuffer=function(e,t){return B.debug("HTD: Removing html text track data",e,t),this._buffer.remove(e,t),this._buffered.remove(e,t),this._isAutoRefreshing&&this._buffer.isEmpty()&&(this.refreshSubtitles(),this._isAutoRefreshing=!1,this._subtitlesIntervalCanceller.cancel(),this._subtitlesIntervalCanceller=new pe),q(this._buffered)},t.getBufferedRanges=function(){return q(this._buffered)},t.reset=function(){B.debug("HTD: Resetting HTMLTextDisplayer"),this.stop(),this._subtitlesIntervalCanceller=new pe},t.stop=function(){this._subtitlesIntervalCanceller.isUsed()||(B.debug("HTD: Stopping HTMLTextDisplayer"),this._disableCurrentCues(),this._buffer.remove(0,1/0),this._buffered.remove(0,1/0),this._isAutoRefreshing=!1,this._subtitlesIntervalCanceller.cancel())},t._disableCurrentCues=function(){if(this._sizeUpdateCanceller.cancel(),this._currentCues.length>0){for(var e=0;e<this._currentCues.length;e++)cf(this._textTrackElement,this._currentCues[e].element);this._currentCues=[]}},t._displayCues=function(e){if(!(this._currentCues.length===e.length&&this._currentCues.every((function(t,n){return t.element===e[n]})))){this._sizeUpdateCanceller.cancel();for(var t=0;t<this._currentCues.length;t++)cf(this._textTrackElement,this._currentCues[t].element);this._currentCues=[];for(var n=0;n<e.length;n++){var r=e[n],i=ff(r);this._currentCues.push({element:r,resolution:i}),this._textTrackElement.appendChild(r)}var a=this._currentCues.filter((function(e){return null!==e.resolution}));if(a.length>0){this._sizeUpdateCanceller=new pe,this._sizeUpdateCanceller.linkToSignal(this._subtitlesIntervalCanceller.signal);var o=L.getCurrent().TEXT_TRACK_SIZE_CHECKS_INTERVAL,s=function(e,t,n){var r=e.getBoundingClientRect(),i=r.height,a=r.width,o=new oe({height:i,width:a},n),s=i,u=a;if(void 0!==rf){var l=new rf((function(e){if(0!==e.length){var t=e[0].contentRect,n=t.height,r=t.width;n===s&&r===u||(s=n,u=r,o.setValue({height:n,width:r}))}else B.error("Compat: Resized but no observed element.")}));l.observe(e),n.register((function(){l.disconnect()}))}else{var d=setInterval((function(){var t=e.getBoundingClientRect(),n=t.height,r=t.width;n===s&&r===u||(s=n,u=r,o.setValue({height:n,width:r}))}),t);n.register((function(){clearInterval(d)}))}return o}(this._textTrackElement,o,this._sizeUpdateCanceller.signal);s.onUpdate((function(e){for(var t=e.height,n=e.width,r=0;r<a.length;r++){var i=a[r];df(t,n,i.resolution,i.element)}}),{clearSignal:this._sizeUpdateCanceller.signal,emitCurrentValue:!0})}}},t.autoRefreshSubtitles=function(e){var t=this;if(!this._isAutoRefreshing&&!e.isCancelled()){var n=null,r=L.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL,i=function(){t._isAutoRefreshing=!1,null!==n&&(n.cancel(),n=null)},a=function(){i(),t._isAutoRefreshing=!0,(n=new pe).linkToSignal(e);var a=setInterval((function(){return t.refreshSubtitles()}),r);n.signal.register((function(){clearInterval(a)})),t.refreshSubtitles()};li(this._videoElement,(function(){i(),t._disableCurrentCues()}),e),di(this._videoElement,a,e),ci(this._videoElement,a,e),a()}},t.refreshSubtitles=function(){var e,t=L.getCurrent().MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL;e=this._videoElement.paused||this._videoElement.playbackRate<=0?this._videoElement.currentTime:Math.max(this._videoElement.currentTime+t/1e3/2,0);var n=this._buffer.get(e);0===n.length?this._disableCurrentCues():this._displayCues(n)},e}(),hf=pf;function mf(e){return void 0===e.extent&&void 0===e.origin&&void 0===e.displayAlign&&void 0===e.display&&void 0===e.textAlign&&void 0===e.fontSize}function gf(e){e.extent="70% 20%",e.fontSize="1c",e.origin="15% 80%",e.displayAlign="before",e.textAlign="center"}function yf(e,t){(void 0===vf&&(vf=void 0!==e.classList&&"function"==typeof e.classList.add),vf)?e.classList.add(t):(" "+e.className+" ").indexOf(" "+t+" ")<0&&(e.className+=" "+t)}function _f(e,t){var n=t;return mt(t)&&t.trim().endsWith("%")&&(n=t.trim().slice(0,-1),n=(parseInt(n,10)/100).toString()+"em"),"-1px -1px "+n+" "+e+",1px -1px "+n+" "+e+",-1px 1px "+n+" "+e+",1px 1px "+n+" "+e}function bf(e){var n;return t(n=Sc.exec(e))?t(n=Ec.exec(e))?t(n=Tc.exec(e))?t(n=kc.exec(e))?e:"rgba("+String(+n[1])+","+String(+n[2])+","+String(+n[3])+","+String(+n[4]/255)+")":"rgb("+String(+n[1])+","+String(+n[2])+","+String(+n[3])+")":"rgba("+String(parseInt(n[1]+n[1],16))+","+String(parseInt(n[2]+n[2],16))+","+String(parseInt(n[3]+n[3],16))+","+String(parseInt(n[4]+n[4],16)/255)+")":"rgba("+String(parseInt(n[1],16))+","+String(parseInt(n[2],16))+","+String(parseInt(n[3],16))+","+String(parseInt(n[4],16)/255)+")"}var Sf=["color","direction","display","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","textOutline","unicodeBidi","visibility","wrapOption"];function Ef(e,t,n){var r=t.color;mt(r)&&(e.style.color=bf(r));var i=t.backgroundColor;mt(i)&&(e.style.backgroundColor=bf(i));var a=t.textOutline;if(mt(a)){var o=a.trim().replace(/\s+/g," ").split(" "),s=o.length;if(3===s){var u=bf(o[0]),l=o[1];e.style.textShadow=_f(u,l)}else if(mt(r)&&1===s){var d=o[0];e.style.textShadow=_f(r,d)}else if(2===s){var c=/^[#A-Z]/i.test(o[0]);if(c!==/^[0-9]/.test(o[0]))if(c){var f=bf(o[0]),v=o[1];e.style.textShadow=_f(f,v)}else if(mt(r)){var p=o[0];e.style.textShadow=_f(r,p)}}}var h=t.textDecoration;if(mt(h))switch(h){case"noUnderline":case"noLineThrough":case"noOverline":e.style.textDecoration="none";break;case"lineThrough":e.style.textDecoration="line-through";break;default:e.style.textDecoration=h}var m=t.fontFamily;if(mt(m))switch(m){case"proportionalSansSerif":e.style.fontFamily="Arial, Helvetica, Liberation Sans, sans-serif";break;case"monospaceSansSerif":case"sansSerif":e.style.fontFamily="sans-serif";break;case"monospaceSerif":case"default":e.style.fontFamily="Courier New, Liberation Mono, monospace";break;case"proportionalSerif":e.style.fontFamily="serif";break;default:e.style.fontFamily=m}var g=t.fontStyle;mt(g)&&(e.style.fontStyle=g);var y=t.fontWeight;mt(y)&&(e.style.fontWeight=y);var _=t.fontSize;mt(_)?function(e,t){var n=t.trim().split(" ");if(0!==n.length){var r=bc.exec(n[0]);if(null!==r)if("px"===r[2]||"em"===r[2])e.style.fontSize=r[1]+r[2];else if("c"===r[2])e.style.position="relative",yf(e,"proportional-style"),e.setAttribute("data-proportional-font-size",r[1]);else if("%"===r[2]){var i=Number(r[1]);isNaN(i)?B.warn('TTML Parser: could not parse fontSize value "'+r[1]+'" into a number'):(e.style.position="relative",yf(e,"proportional-style"),e.setAttribute("data-proportional-font-size",String(i/100)))}else B.warn("TTML Parser: unhandled fontSize unit:",r[2])}}(e,_):(yf(e,"proportional-style"),e.setAttribute("data-proportional-font-size","1"));var b=t.direction;mt(b)&&(e.style.direction=b);var S=t.unicodeBidi;if(mt(S))switch(S){case"bidiOverride":e.style.unicodeBidi="bidi-override";break;case"embed":e.style.unicodeBidi="embed";break;default:e.style.unicodeBidi="normal"}var E=t.visibility;mt(E)&&(e.style.visibility=E),"none"===t.display&&(e.style.display="none");var T=t.wrapOption;e.style.whiteSpace="noWrap"===T?n?"nowrap":"pre":n?"normal":"pre-wrap"}function Tf(e,t){e.style.color="white",e.style.position="absolute";var n=t.extent;mt(n)&&function(e,t){var n=t.trim();if("auto"!==n){var r=n.split(" ");if(2===r.length){var i=bc.exec(r[0]),a=bc.exec(r[1]);null!==i&&null!==a&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.width=i[1]+i[2]:"c"===i[2]?(yf(e,"proportional-style"),e.setAttribute("data-proportional-width",i[1])):B.warn("TTML Parser: unhandled extent unit:",i[2]),"px"===a[2]||"%"===a[2]||"em"===a[2]?e.style.height=a[1]+a[2]:"c"===a[2]?(yf(e,"proportional-style"),e.setAttribute("data-proportional-height",a[1])):B.warn("TTML Parser: unhandled extent unit:",a[2]))}}}(e,n),mt(t.writingMode);var r=t.overflow;e.style.overflow=mt(r)?r:"hidden";var i=t.padding;mt(i)&&function(e,t){var n=t.trim().split(" ");if(!(n.length<1)){var r=bc.exec(n[0]);if(null!==r){if("px"===r[2]||"%"===r[2]||"em"===r[2]){var i=r[1]+r[2];1===n.length?e.style.padding=i:2===n.length?(e.style.paddingTop=i,e.style.paddingBottom=i):e.style.paddingTop=i}else"c"===r[2]?(yf(e,"proportional-style"),1===n.length?(e.setAttribute("data-proportional-padding-top",r[1]),e.setAttribute("data-proportional-padding-bottom",r[1]),e.setAttribute("data-proportional-padding-left",r[1]),e.setAttribute("data-proportional-padding-right",r[1])):2===n.length?(e.setAttribute("data-proportional-padding-top",r[1]),e.setAttribute("data-proportional-padding-bottom",r[1])):e.setAttribute("data-proportional-padding-top",r[1])):B.warn("TTML Parser: unhandled padding unit:",r[2]);if(1!==n.length){var a=bc.exec(n[1]);if(null!==a){if("px"===a[2]||"%"===a[2]||"em"===a[2]){var o=a[1]+a[2];n.length<4?(e.style.paddingLeft=o,e.style.paddingRight=o):e.style.paddingRight=o}else"c"===a[2]?(yf(e,"proportional-style"),n.length<4?(e.setAttribute("data-proportional-padding-left",a[1]),e.setAttribute("data-proportional-padding-right",a[1])):e.setAttribute("data-proportional-padding-right",a[1])):B.warn("TTML Parser: unhandled padding unit:",a[2]);if(2!==n.length){var s=bc.exec(n[2]);if(null!==s){if("px"===s[2]||"%"===s[2]||"em"===s[2]){var u=s[1]+s[2];e.style.paddingBottom=u}else"c"===s[2]?(yf(e,"proportional-style"),e.setAttribute("data-proportional-padding-bottom",s[1])):B.warn("TTML Parser: unhandled padding unit:",s[2]);if(3!==n.length){var l=bc.exec(n[3]);if(null!==l)if("px"===l[2]||"%"===l[2]||"em"===l[2]){var d=l[1]+l[2];e.style.paddingLeft=d}else"c"===l[2]?(yf(e,"proportional-style"),e.setAttribute("data-proportional-padding-left",l[1])):B.warn("TTML Parser: unhandled padding unit:",l[2])}}}}}}}}(e,i);var a=t.origin;mt(a)&&function(e,t){var n=t.trim();if("auto"!==n){var r=n.split(" ");if(2===r.length){var i=bc.exec(r[0]),a=bc.exec(r[1]);null!==i&&null!==a&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.left=i[1]+i[2]:"c"===i[2]?(yf(e,"proportional-style"),e.setAttribute("data-proportional-left",i[1])):B.warn("TTML Parser: unhandled origin unit:",i[2]),"px"===a[2]||"%"===a[2]||"em"===a[2]?e.style.top=a[1]+a[2]:"c"===a[2]?(yf(e,"proportional-style"),e.setAttribute("data-proportional-top",a[1])):B.warn("TTML Parser: unhandled origin unit:",a[2]))}}}(e,a);var o=t.displayAlign;if(mt(o))switch(e.style.display="flex",e.style.flexDirection="column",o){case"before":e.style.justifyContent="flex-start";break;case"center":e.style.justifyContent="center";break;case"after":e.style.justifyContent="flex-end"}var s=t.opacity;mt(s)&&(e.style.opacity=s);var u=t.visibility;mt(u)&&(e.style.visibility=u),"none"===t.display&&(e.style.display="none")}function kf(e,t){e.style.margin="0px",yf(e,"proportional-style"),e.setAttribute("data-proportional-font-size","1");var n=t.backgroundColor;mt(n)&&(e.style.backgroundColor=bf(n));var r=t.lineHeight;mt(r)&&function(e,t){var n=t.trim(),r=n.split(" ");if("auto"!==n){var i=bc.exec(r[0]);null!==i&&("px"===i[2]||"%"===i[2]||"em"===i[2]?e.style.lineHeight=i[1]+i[2]:"c"===i[2]?(yf(e,"proportional-style"),e.setAttribute("data-proportional-line-height",i[1])):B.warn("TTML Parser: unhandled lineHeight unit:",i[2]))}}(e,r);var i=t.textAlign;if(mt(i))switch(i){case"center":e.style.textAlign="center";break;case"left":case"start":e.style.textAlign="left";break;case"right":case"end":e.style.textAlign="right"}}function wf(e,t,n){var r=document.createElement("span"),i=null===e.textContent?"":e.textContent;if(n){var a=i.trim();i=a=a.replace(/\s+/g," ")}var o=document.createTextNode(i);return r.appendChild(o),r.className="rxp-texttrack-span",Ef(r,t,n),r}function Af(e,t,n,r,i,a){var o=a.cellResolution,s=a.shouldTrimWhiteSpace,u=oc(e),l=document.createElement("DIV");if(l.className="rxp-texttrack-region",l.setAttribute("data-resolution-columns",String(o.columns)),l.setAttribute("data-resolution-rows",String(o.rows)),Tf(l,i),null!==t){var d=rc(["backgroundColor"],[].concat(u,[t]),r,n).bodyBackgroundColor;mt(d)&&(l.style.backgroundColor=bf(d))}var c=document.createElement("p");c.className="rxp-texttrack-p",kf(c,i);for(var f=function(e,t,n,r,i){return function e(r,i,a,o){for(var s=r.childNodes,u=[],l=0;l<s.length;l++){var d=s[l];if("#text"===d.nodeName){var c=rc(["backgroundColor"],a,n,t).backgroundColor;mt(c)?i.backgroundColor=c:delete i.backgroundColor;var f=wf(d,i,o);u.push(f)}else if(sc(d)){var v=document.createElement("BR");u.push(v)}else if(uc(d)&&d.nodeType===Node.ELEMENT_NODE&&d.childNodes.length>0){var p=d.getAttribute("xml:space"),h=mt(p)?"default"===p:o,m=P({},i,rc(Sf,[d],n,t));u.push.apply(u,e(d,m,[d].concat(a),h))}}return u}(e,P({},r),[],i)}(e,n,r,i,s),v=0;v<f.length;v++)c.appendChild(f[v]);return l.appendChild(c),l}function If(e){var t=e.paragraph,n=e.ttParams,r=e.body,i=e.regionStyles,a=e.idStyles,o=e.paragraphStyle,s=e.timeOffset,u=e.shouldTrimWhiteSpace;if(!t.hasAttribute("begin")&&!t.hasAttribute("end")&&/^\s*$/.test(null===t.textContent?"":t.textContent))return null;var l=n.cellResolution,d=Ic(t,n);return{start:d.start+s,end:d.end+s,element:Af(t,r,i,a,o,{cellResolution:l,shouldTrimWhiteSpace:u})}}var Rf=function(e,t){for(var n=dc(e,t),r=[],i=0;i<n.length;i++){var a=n[i].paragraphStyle;mf(a)&&gf(a);var o=If(n[i]);null!==o&&r.push(o)}return r};function xf(e){e.htmlTextTracksParsers.ttml=Rf,e.htmlTextDisplayer=hf}var Cf=/&#([0-9]+);/g,Mf=/<br>/gi,Pf=/<style[^>]*>([\s\S]*?)<\/style[^>]*>/i,Df=/\s*<p (?:class=([^>]+))?>(.*)/i,Nf=/<sync[^>]+?start="?([0-9]*)"?[^0-9]/i;function Of(e,t){var n=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(n)?n[1]:null}var Lf=function(e,n,r){var i,a,o=/<sync[ >]/gi,s=/<sync[ >]|<\/body>/gi,u=[],l=Pf.exec(e),d=Array.isArray(l)?l[1]:"";s.exec(e);var c,f=function(e){for(var n=/\.(\S+)\s*{([^}]*)}/gi,r={},i=n.exec(e);null!==i;){var a=i[1],o=Of(i[2],"lang");t(a)||t(o)||(r[o]=a),i=n.exec(e)}return r}(d),v=function(e){var t=/p\s*{([^}]*)}/gi.exec(e);return null===t?"":t[1]}(d);if(mt(r)&&void 0===(c=f[r]))throw new Error("sami: could not find lang "+r+" in CSS");for(;i=o.exec(e),a=s.exec(e),null!==i||null!==a;){if(null===i||null===a||i.index>=a.index)throw new Error("parse error");var p=e.slice(i.index,a.index),h=Nf.exec(p);if(!Array.isArray(h))throw new Error("parse error (sync time attribute)");var m=+h[1];if(isNaN(m))throw new Error("parse error (sync time attribute NaN)");g(p.split("\n"),m/1e3)}return u;function g(e,t){for(var r=e.length;--r>=0;){var i=Df.exec(e[r]);if(Array.isArray(i)){var a=i[1],o=i[2];if(c===a)if("&nbsp;"===o)u[u.length-1].end=t;else{var s=document.createElement("DIV");s.className="rxp-texttrack-region";var l=document.createElement("DIV");l.className="rxp-texttrack-div",l.style.position="absolute",l.style.bottom="0",l.style.width="100%",l.style.color="#fff",l.style.textShadow="-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000";var d=document.createElement("div");d.className="rxp-texttrack-p",mt(v)&&(d.style.cssText=v);for(var f=o.split(Mf),p=0;p<f.length;p++){0!==p&&d.appendChild(document.createElement("BR"));var h=document.createElement("SPAN");h.className="rxp-texttrack-span",h.textContent=f[p].replace(Cf,(function(e,t){return String.fromCharCode(Number(t))})),d.appendChild(h)}l.appendChild(d),s.appendChild(l),u.push({element:s,start:t+n,end:-1})}}}}};function Uf(e){e.htmlTextTracksParsers.sami=Lf,e.htmlTextDisplayer=hf}var Ff={white:"#ffffff",lime:"#00ff00",cyan:"#00ffff",red:"#ff0000",yellow:"#ffff00",magenta:"#ff00ff",blue:"#0000ff",black:"#000000"};function Bf(e){var t=Object.keys(Ff).reduce((function(e,t){return e[t]="color: "+Ff[t]+";",e["bg_"+t]="background-color: "+Ff[t]+";",e}),{}),n="";return e.forEach((function(e){if(e.length>=2)for(var r=function(r){var a=e[r];if(Array.isArray(/::cue {/.exec(a)))for(a=e[++r];mt(a)&&!Array.isArray(/}/.exec(a))&&0!==a.length;)n+=a,a=e[++r];else{for(var o=[],s=/::cue\(\.?(.*?)\)(?:,| {)/.exec(a);mt(a)&&Array.isArray(s);)o.push(s[1]),a=e[++r],s=/::cue\(\.?(.*?)\)(?:,| {)/.exec(a);for(var u="";mt(a)&&!Array.isArray(/}/.exec(a))&&0!==a.length;)u+=a,a=e[++r];o.forEach((function(e){void 0===t[e]?t[e]=u:t[e]+=u}))}i=r},i=1;i<e.length;i++)r(i)})),{classes:t,global:n}}function zf(e,t){var n,r=["u","i","b"],i=e.nodeName.toLowerCase().split(".")[0];if(Je(["u","i","b","c","#text"],i))if("#text"===i){var a=e.wholeText.split("\n");n=document.createElement("span");for(var o=0;o<a.length;o++)if(o>0&&n.appendChild(document.createElement("br")),a[o].length>0){var s=document.createTextNode(a[o]);n.appendChild(s)}}else{var u=e.nodeName.toLowerCase().split("."),l=[];if(u.forEach((function(e){mt(t[e])&&l.push(t[e])})),0!==l.length){var d=document.createAttribute("style");l.forEach((function(e){d.value+=e}));var c=Je(r,i)?i:"span";(n=document.createElement(c)).setAttributeNode(d)}else{var f=Je(r,i)?i:"span";n=document.createElement(f)}for(var v=0;v<e.childNodes.length;v++){var p=zf(e.childNodes[v],t);n.appendChild(p)}}else{n=document.createElement("span");for(var h=0;h<e.childNodes.length;h++){var m=zf(e.childNodes[h],t);n.appendChild(m)}}return n}var Vf,Kf,Wf,Gf=function(e){if(!(void 0!==e&&0!==De(e).length))return"text-align:center";var t=Hf(e),n=Yf(e);return"position: absolute;margin: 0;transform: translate("+t.offset+"%,"+n.offset+"%);width: "+Zf(e.size)+"%;left: "+t.position+"%;top: "+(null!==n.position?n.position+"%":"auto")+";text-align: "+Xf(e.align)+";"};!function(e){e.LINE_LEFT="line-left",e.CENTER="center",e.LINE_RIGHT="line-right"}(Vf||(Vf={})),function(e){e.LEFT="left",e.CENTER="center",e.RIGHT="right"}(Kf||(Kf={})),function(e){e.START="start",e.CENTER="center",e.END="end"}(Wf||(Wf={}));var Hf=function(e){return{position:jf(e),offset:qf(e)}},jf=function(e){var t,n=ev(e.position);if(null!==n)return n;var r=Xf(e.align);return((t={})[Kf.LEFT]=0,t[Kf.CENTER]=50,t[Kf.RIGHT]=100,t)[r]},qf=function(e){var t,n,r,i,a=((t={})[Vf.LINE_LEFT]=0,t[Vf.CENTER]=-50,t[Vf.LINE_RIGHT]=-100,t),o=void 0!==e.position?(r=e.position,i=/,(line-left|line-right|center)/.exec(r),!Array.isArray(i)||i.length<2?null:i[1]):null;return null!==o?a[o]:((n={})[Kf.LEFT]=0,n[Kf.CENTER]=-50,n[Kf.RIGHT]=-100,n)[void 0!==e.align?Xf(e.align):Kf.CENTER]},Yf=function(e){return{position:Qf(e.line),offset:$f(e.line)}},Qf=function(e){return ev(e)},$f=function(e){var t,n=((t={})[Wf.START]=0,t[Wf.CENTER]=-50,t[Wf.END]=-100,t);if(void 0===e)return n[Wf.START];var r,i=(r=/,(start|center|end)/.exec(e),!Array.isArray(r)||r.length<2?null:r[1]);return null!==i?n[i]:n[Wf.START]},Xf=function(e){switch(e){case"left":case"start":return"left";case"right":case"end":return"right";default:return"center"}},Zf=function(e){return Jf(e,100)},Jf=function(e,t){var n=ev(e);return null!==n?n:t},ev=function(e){if(void 0===e)return null;var t=/^([\d.]+)%/.exec(e);return!Array.isArray(t)||t.length<2?null:parseInt(t[1],10)};function tv(e,t){var n=e.start,r=e.end,i=e.settings,a=e.header,o=e.payload,s=document.createElement("div"),u=document.createAttribute("style");u.value="width:100%;height:100%;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;",s.setAttributeNode(u);var l=document.createElement("p"),d=function(e){var t=document.createAttribute("style");return t.value=Gf(e),t}(i);l.setAttributeNode(d);var c=document.createElement("span"),f=document.createAttribute("style");f.value="background-color:rgba(0,0,0,0.8);color:white;",c.setAttributeNode(f);var v=t.global,p=t.classes,h=[v,mt(a)?p[a]:void 0].filter((function(e){return void 0!==e})).join("");return f.value+=h,c.setAttributeNode(f),function(e,t){for(var n=e.replace(/<[0-9]{2}:[0-9]{2}.[0-9]{3}>/,"").replace(/<([u,i,b,c])(\..*?)?(?: .*?)?>(.*?)<\/\1>/g,"<$1$2>$3</$1$2>"),r=(new DOMParser).parseFromString(n,"text/html").body.childNodes,i=[],a=0;a<r.length;a++)i.push(zf(r[a],t));return i}(o.join("\n"),p).forEach((function(e){c.appendChild(e)})),s.appendChild(l),l.appendChild(c),{start:n,end:r,element:s}}var nv=function(e,t){var n=e.split(/\r\n|\n|\r/g),r=[];if(null===/^WEBVTT( |\t|\n|\r|$)/.exec(n[0]))throw new Error("Can't parse WebVTT: Invalid File.");for(var i=Vc(n),a=function(e,t){for(var n=[],r=t;r<e.length;r++)if(Kc(e,r)){var i=r;for(r++;mt(e[r]);)r++;var a=e.slice(i,r);n.push(a)}else if(mt(e[r]))for(;mt(e[r]);)r++;return n}(n,i),o=Hc(n,i),s=Bf(a),u=0;u<o.length;u++){var l=qc(o[u],t);if(null!==l){var d=tv(l,s);r.push(d)}}return r};function rv(e){e.htmlTextTracksParsers.vtt=nv,e.htmlTextDisplayer=hf}function iv(e,t){for(var n=Zc(e.split(/\r\n|\n|\r/)),r=[],i=0;i<n.length;i++){var a=ef(n[i],t);if(null!==a){var o=av(a);null!==o&&r.push(o)}}return r}function av(e){var t=e.start,n=e.end,r=e.payload,i=document.createElement("div");i.className="rxp-texttrack-p",i.style.fontSize="28px",i.style.position="absolute",i.style.bottom="5%",i.style.width="100%",i.style.textAlign="center",i.style.color="#fff",i.style.textShadow="-1px -1px 2px #000,1px -1px 2px #000,-1px 1px 2px #000,1px 1px 2px #000";for(var a=0;a<r.length;a++){0!==a&&i.appendChild(document.createElement("br"));var o=ov(r[a]);i.appendChild(o)}return{start:t,end:n,element:i}}function ov(e){var t=document.createElement("div");t.innerHTML=e;return function e(t){var n=t.childNodes,r=document.createElement("span");r.className="rxp-texttrack-span";for(var i=0;i<n.length;i++){var a=n[i];if("#text"===a.nodeName){for(var o=a.wholeText.split("\n"),s=0;s<o.length;s++)if(0!==s&&r.appendChild(document.createElement("br")),o[s].length>0){var u=document.createTextNode(o[s]);r.appendChild(u)}}else if("B"===a.nodeName){var l=e(a);l.style.fontWeight="bold",r.appendChild(l)}else if("I"===a.nodeName){var d=e(a);d.style.fontStyle="italic",r.appendChild(d)}else if("U"===a.nodeName){var c=e(a);c.style.textDecoration="underline",r.appendChild(c)}else if(sv(a)&&"string"==typeof a.color){var f=e(a);f.style.color=a.color,r.appendChild(f)}else{var v=e(a);r.appendChild(v)}}return r}(t)}function sv(e){return"FONT"===e.nodeName&&"color"in e}function uv(e){e.htmlTextTracksParsers.srt=iv,e.htmlTextDisplayer=hf}function lv(){if(!S)return!0;var e=function(){if(!S)return B.warn("Compat: Can't access Firefox version on no firefox browser."),null;var e=navigator.userAgent,t=/Firefox\/([0-9]+)\./.exec(e);if(null===t)return-1;var n=parseInt(t[1],10);return isNaN(n)?-1:n}();if(null===e||e<67)return!0;var t=null===HTMLVideoElement||void 0===HTMLVideoElement?void 0:HTMLVideoElement.prototype;return void 0!==(null==t?void 0:t.requirePictureInPicture)}function dv(e){var t=e;if("function"==typeof t.getStartDate){var n=t.getStartDate();if("object"==typeof n&&null!==n){var r=+n;if(!isNaN(r))return r/1e3}else if("number"==typeof n&&!isNaN(n))return n}}var cv="function"==typeof MediaSource&&!0===MediaSource.canConstructInDedicatedWorker;var fv=function(e){function t(n,r){var i;return i=e.call(this)||this,Object.setPrototypeOf(se(i),t.prototype),i.name="WorkerInitializationError",i.type="WORKER_INITIALIZATION_ERROR",i.code=n,i.message=He(i.code,r),i}return f(t,e),t}(de(Error));var vv=w;function pv(e,t,n){var r=t(e.getReference(),n);return{getCurrentTime:function(){return e.getCurrentTime()},getReadyState:function(){return e.getReadyState()},getPlaybackRate:function(){return e.getPlaybackRate()},getIsPaused:function(){return e.getIsPaused()},getReference:function(){return r},listen:function(e,t){var i;n.isCancelled()||!0===(null===(i=null==t?void 0:t.clearSignal)||void 0===i?void 0:i.isCancelled())||r.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},deriveReadOnlyObserver:function(e){return pv(this,e,n)}}}var hv=function(){function e(e,t){this._last=e,this._wanted=t}var t=e.prototype;return t.serialize=function(){return[this._last,this._wanted]},t.getPolled=function(){return this._last},t.getWanted=function(){var e;return null!==(e=this._wanted)&&void 0!==e?e:this._last},t.forceWantedPosition=function(e){this._wanted=e},t.isAwaitingFuturePosition=function(){return null!==this._wanted},e}(),mv=["canplay","ended","play","pause","seeking","seeked","loadedmetadata","ratechange"],gv=function(){function e(e,t){var n=this;this._internalSeeksIncoming=[],this._mediaElement=e,this._withMediaSource=t.withMediaSource,this._lowLatencyMode=t.lowLatencyMode,this._canceller=new pe,this._observationRef=this._createSharedReference(),this._expectedSeekingPosition=null,this._pendingSeek=null;var r=function(){if(null!==n._pendingSeek){var e=n._pendingSeek;n._pendingSeek=null,n._actuallySetCurrentTime(e)}};e.addEventListener("loadedmetadata",r),this._canceller.signal.register((function(){e.removeEventListener("loadedmetadata",r)}))}var t=e.prototype;return t.stop=function(){this._canceller.cancel()},t.getCurrentTime=function(){return this._mediaElement.currentTime},t.getPlaybackRate=function(){return this._mediaElement.playbackRate},t.getIsPaused=function(){return this._mediaElement.paused},t.setCurrentTime=function(e){this._mediaElement.readyState>=1?this._actuallySetCurrentTime(e):(this._internalSeeksIncoming=[],this._pendingSeek=e,this._generateObservationForEvent("manual"))},t.setPlaybackRate=function(e){this._mediaElement.playbackRate=e},t.getReadyState=function(){return this._mediaElement.readyState},t.getReference=function(){return this._observationRef},t.listen=function(e,t){var n;if(this._canceller.isUsed()||!0===(null===(n=null==t?void 0:t.clearSignal)||void 0===n?void 0:n.isCancelled()))return U;this._observationRef.onUpdate(e,{clearSignal:null==t?void 0:t.clearSignal,emitCurrentValue:null==t?void 0:t.includeLastObservation})},t.deriveReadOnlyObserver=function(e){return pv(this,e,this._canceller.signal)},t._actuallySetCurrentTime=function(e){B.info("API: Seeking internally",e),this._internalSeeksIncoming.push(e),this._mediaElement.currentTime=e},t._createSharedReference=function(){var e=this;if(void 0!==this._observationRef)return this._observationRef;var t,n=L.getCurrent(),r=n.SAMPLING_INTERVAL_MEDIASOURCE,i=n.SAMPLING_INTERVAL_LOW_LATENCY,a=n.SAMPLING_INTERVAL_NO_MEDIASOURCE,o=new oe(this._getCurrentObservation("init"),this._canceller.signal);t=this._lowLatencyMode?i:this._withMediaSource?r:a;var s=function(){e._generateObservationForEvent("timeupdate")},u=setInterval(s,t),l=mv.map((function(n){var r=function(){clearInterval(u),u=setInterval(s,t),e._generateObservationForEvent(n)};return e._mediaElement.addEventListener(n,r),function(){e._mediaElement.removeEventListener(n,r)}}));return this._canceller.signal.register((function(){clearInterval(u),l.forEach((function(e){return e()})),o.finish()})),o},t._getCurrentObservation=function(e){var t,n,r=e,i=void 0===this._observationRef?function(e){var t=_v(e);return P(t,{rebuffering:null,event:"init",seeking:0,position:new hv(t.position,null),freezing:null,bufferGap:0,currentRange:null})}(this._mediaElement):this._observationRef.getValue(),a=!1,o=this._pendingSeek,s=_v(this._mediaElement),u=s.buffered,l=s.readyState,d=s.position,c=s.seeking;if("seeking"===r)if(this._internalSeeksIncoming.length>0){a=!0,r="internal-seeking";var f=this._internalSeeksIncoming.shift();this._expectedSeekingPosition=vv?Math.max(d,null!=f?f:0):d}else this._expectedSeekingPosition=d;else c?this._expectedSeekingPosition=Math.max(d,null!==(t=this._expectedSeekingPosition)&&void 0!==t?t:0):vv&&null!==this._expectedSeekingPosition&&d<this._expectedSeekingPosition?o=this._expectedSeekingPosition:this._expectedSeekingPosition=null;c&&1===i.seeking&&"seeking"!==e&&(a=!0);var v,p,h=null!==(n=this._expectedSeekingPosition)&&void 0!==n?n:d;!this._withMediaSource&&0===u.length&&l>=3?(v=void 0,p=void 0):p=null!==(v=Y(u,h))?v.end-h:1/0;var m,g=function(e){var t,n,r=e.previousObservation,i=e.currentObservation,a=e.basePosition,o=e.observationEvent,s=e.withMediaSource,u=e.lowLatencyMode,l=e.bufferGap,d=e.currentRange,c=L.getCurrent().REBUFFERING_GAP,f=i.position,v=i.duration,p=i.paused,h=i.readyState,m=i.ended,g=r.rebuffering,y=r.event,_=r.position,b=function(e,t,n,r,i){var a=L.getCurrent().REBUFFERING_GAP,o=i?"LOW_LATENCY":"DEFAULT";if(void 0===t)return n&&Math.abs(r-e)<=a[o];return null!==t&&r-t.end<=a[o]}(a,d,m,v,u),S=h>=1&&"loadedmetadata"!==o&&null===g&&!(b||m),E=null,T=u?c.LOW_LATENCY:c.DEFAULT;if(s){if(S)l===1/0?(t=!0,E=a):void 0===l?h<3&&(t=!0,E=void 0):l<=T&&(t=!0,E=a+l);else if(null!==g){var k=yv(g,u);!0!==t&&null!==g&&h>1&&(b||m||void 0!==l&&isFinite(l)&&l>k)||void 0===l&&h>=3?n=!0:void 0===l?E=void 0:l===1/0?E=a:l<=k&&(E=a+l)}}else S&&(!p&&"timeupdate"===o&&"timeupdate"===y&&f===_.getPolled()||"seeking"===o&&(l===1/0||void 0===l&&h<3))?t=!0:null!==g&&("seeking"!==o&&f!==_.getPolled()||"canplay"===o||void 0===l&&h>=3||void 0!==l&&l<1/0&&(l>yv(g,u)||b||m))&&(n=!0);if(!0===n)return null;var w;if(!0===t||null!==g)return w="seeking"===o||null!==g&&"seeking"===g.reason||i.seeking?"seeking":1===h?"not-ready":"buffering",null!==g&&g.reason===w?{reason:g.reason,timestamp:g.timestamp,position:E}:{reason:w,timestamp:ye(),position:E};return null}({previousObservation:i,currentObservation:s,basePosition:h,observationEvent:r,lowLatencyMode:this._lowLatencyMode,withMediaSource:this._withMediaSource,bufferGap:p,currentRange:v}),y=function(e,t,n,r){var i=L.getCurrent().MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING;if(e.freezing)return t.ended||t.paused||0===t.readyState||0===t.playbackRate||e.position.getPolled()!==t.position?null:e.freezing;return"timeupdate"===n&&void 0!==r&&r>i&&!t.ended&&!t.paused&&t.readyState>=1&&0!==t.playbackRate&&t.position===e.position.getPolled()?{timestamp:ye()}:null}(i,s,r,p);m=a?1:c?2:0;var _=P({},s,{position:new hv(s.position,o),event:r,seeking:m,rebuffering:g,freezing:y,bufferGap:p,currentRange:v});return B.hasLevel("DEBUG")&&B.debug("API: current media element state tick","event",_.event,"position",_.position.getPolled(),"seeking",_.seeking,"internalSeek",a,"rebuffering",null!==_.rebuffering,"freezing",null!==_.freezing,"ended",_.ended,"paused",_.paused,"playbackRate",_.playbackRate,"readyState",_.readyState,"pendingPosition",o),_},t._generateObservationForEvent=function(e){var t=this._getCurrentObservation(e);B.hasLevel("DEBUG")&&B.debug("API: current playback timeline:\n"+function(e,t){for(var n="",r="",i=0;i<e.length;i++){var a=e.start(i),o=e.end(i),s=a.toFixed(2),u=o.toFixed(2),l=s+"|=="+(o-a).toFixed(2)+"==|"+u;if(n+=l,0===r.length&&o>t){var d=n.length-Math.floor(l.length/2);r=" ".repeat(d)+"^"+t}if(i<e.length-1){var c=e.start(i+1),f=" ~"+(c-o).toFixed(2)+"~ ";if(n+=f,0===r.length&&t<c){var v=n.length-Math.floor(f.length/2);r=" ".repeat(v)+"^"+t}}}0===r.length&&(r=" ".repeat(n.length)+"^"+t);return n+"\n"+r}(t.buffered,t.position.getPolled()),"\n"+e),this._observationRef.setValue(t)},e}();function yv(e,t){if(null===e)return 0;var n=t?"LOW_LATENCY":"DEFAULT",r=L.getCurrent(),i=r.RESUME_GAP_AFTER_SEEKING,a=r.RESUME_GAP_AFTER_NOT_ENOUGH_DATA,o=r.RESUME_GAP_AFTER_BUFFERING;switch(e.reason){case"seeking":return i[n];case"not-ready":return a[n];case"buffering":return o[n]}}function _v(e){return{buffered:e.buffered,position:e.currentTime,duration:e.duration,ended:e.ended,paused:e.paused,playbackRate:e.playbackRate,readyState:e.readyState,seeking:e.seeking}}function bv(e){return Sv.apply(this,arguments)}function Sv(){return(Sv=d(g().mark((function e(t){var n,r;return g().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==(n=Br.getState(t))){e.next=3;break}return e.abrupt("return",void 0);case 3:return B.info("DRM: Disposing of the current MediaKeys"),r=n.loadedSessionsStore,Br.clearState(t),e.next=8,r.closeAllSessions();case 8:return e.abrupt("return",Ul(n.emeImplementation,t,null));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ev(e){if(B.info("DRM: Clearing-up DRM session."),_)return B.info("DRM: disposing current MediaKeys."),bv(e);var t=Br.getState(e);return null!==t&&!0===t.keySystemOptions.closeSessionsOnStop?(B.info("DRM: closing all current sessions."),t.loadedSessionsStore.closeAllSessions()):(B.info("DRM: Nothing to clear. Returning right away. No state =",null===t),Promise.resolve())}var Tv=function(e){function t(t){var n;return(n=e.call(this)||this)._canceller=new pe,n._adaptationRef=t,n._updateToken=!1,n.refresh=U,n}f(t,e);var n=t.prototype;return n.start=function(e){if(this._updateToken=!0,null===e)return this._lastEmitted=null,this._updateToken=!1,void this._adaptationRef.setValue(null);var t=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:e.adaptation,switchingMode:e.switchingMode,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:e.adaptation.id,switchingMode:e.switchingMode,representations:t,relativeResumingPosition:void 0}))},n.updateTrack=function(e){if(this._updateToken=!0,null===e){if(null===this._lastEmitted)return;return this._updateToken=!1,this._canceller.cancel(),this._canceller=new pe,this._lastEmitted=null,void this._adaptationRef.setValue(null)}var t=e.adaptation,n=e.switchingMode,r=e.relativeResumingPosition;this._canceller.cancel(),this._canceller=new pe;var i=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:t,switchingMode:n,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:t.id,switchingMode:n,representations:i,relativeResumingPosition:r}))},n._constructLockedRepresentationsReference=function(e){var t=new oe({representationIds:[],switchingMode:"lazy"}),n=this;return this.refresh=r,this._canceller.signal.register((function(){n.refresh=U})),e.lockedRepresentations.onUpdate(r,{clearSignal:this._canceller.signal,emitCurrentValue:!1}),r(),t;function r(){var r,i,a=e.lockedRepresentations.getValue();if(null===a)i=e.adaptation.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})),r="lazy";else{var o=a.representationIds;if(r=a.switchingMode,0===(i=e.adaptation.representations.filter((function(e){return Je(o,e.id)})).filter((function(e){return!0===e.isSupported&&!1!==e.decipherable}))).length)return void n.trigger("noPlayableLockedRepresentation",null)}if(i.length<=0)return e.adaptation.isSupported=!1,void n.trigger("noPlayableRepresentation",null);var s=t.getValue(),u=i.map((function(e){return e.id})).slice().sort();if(u.length===s.representationIds.length){for(var l=0;l<u.length;l++)if(s.representationIds[l]!==u[l])return void t.setValue({representationIds:u,switchingMode:r})}else t.setValue({representationIds:u,switchingMode:r})}},n.dispose=function(){this.removeEventListener(),this._canceller.cancel(),this._adaptationRef.finish()},t}(i);function kv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return wv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return wv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function wv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Av=function(e){function n(t){var n,r;return(n=e.call(this)||this)._storedPeriodInfo=[],n._isDisposed=!1,n._cachedPeriodInfo=new WeakMap,n._isTrickModeTrackEnabled=t.preferTrickModeTracks,n._defaultAudioTrackSwitchingMode=null!==(r=t.defaultAudioTrackSwitchingMode)&&void 0!==r?r:L.getCurrent().DEFAULT_AUDIO_TRACK_SWITCHING_MODE,n}f(n,e);var r=n.prototype;return r.getAvailablePeriods=function(){return this._storedPeriodInfo.reduce((function(e,t){return t.isPeriodAdvertised&&e.push(Mv(t.period)),e}),[])},r.onManifestUpdate=function(e){for(var t,n,r,i,a,o,s,u=this,l=L.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=e.periods,c=[],f=0,v=function(e){var i=u._storedPeriodInfo[e].period,a=d[f];if(void 0===a)for(var o=u._storedPeriodInfo.length-1;o>=e;o--)u._storedPeriodInfo[o].inManifest=!1,Rv(u._storedPeriodInfo[o])&&u._removePeriodObject(o);else if(i===a){f++;var s=u._storedPeriodInfo[e].text.storedSettings;if(null!==s)if(!ot(a,"text").some((function(e){return e.id===s.adaptation.id}))){B.warn("TS: Chosen text Adaptation not available anymore");var v=u._storedPeriodInfo[e];if(v.text.storedSettings=null,u.trigger("trackUpdate",{period:Mv(a),trackType:"text",reason:"missing"}),u._isDisposed)return{v:void 0};var h=Iv(u._storedPeriodInfo,v.period.id);void 0!==h&&null===h.text.storedSettings&&(null===(t=h.text.dispatcher)||void 0===t||t.updateTrack(null))}var m=u._storedPeriodInfo[e].video.storedSettings;if(null!==m){var g=ot(a,"video");if(!g.some((function(e){return e.id===m.adaptation.id}))){B.warn("TS: Chosen video Adaptation not available anymore");var y,_=u._storedPeriodInfo[e];if(0===g.length)y=null;else{var b=g[0],S=xv(b,u._isTrickModeTrackEnabled),E=new oe(null);y={adaptationBase:b,adaptation:S,switchingMode:l,lockedRepresentations:E}}if(_.video.storedSettings=y,u.trigger("trackUpdate",{period:Mv(a),trackType:"video",reason:"missing"}),u._isDisposed)return{v:void 0};var T=Iv(u._storedPeriodInfo,_.period.id);void 0!==T&&T.video.storedSettings===y&&(null===(n=T.video.dispatcher)||void 0===n||n.updateTrack(y))}}var k=u._storedPeriodInfo[e].audio.storedSettings;if(null!==k){var w=ot(a,"audio");if(!w.some((function(e){return e.id===k.adaptation.id}))){B.warn("TS: Chosen audio Adaptation not available anymore");var A=u._storedPeriodInfo[e],I=0===w.length?null:{adaptation:w[0],switchingMode:u._defaultAudioTrackSwitchingMode,lockedRepresentations:new oe(null)};if(A.audio.storedSettings=I,u.trigger("trackUpdate",{period:Mv(a),trackType:"audio",reason:"missing"}),u._isDisposed)return{v:void 0};var R=Iv(u._storedPeriodInfo,A.period.id);void 0!==R&&R.audio.storedSettings===I&&(null===(r=R.audio.dispatcher)||void 0===r||r.updateTrack(I))}}}else if(i.start<=a.start)u._storedPeriodInfo[e].inManifest=!1,Rv(u._storedPeriodInfo[e])&&(u._removePeriodObject(e),e--);else{var x=Cv(a,!0,u._isTrickModeTrackEnabled,u._defaultAudioTrackSwitchingMode);u._storedPeriodInfo.splice(e,0,x),c.push(x),f++}p=e},p=0;p<this._storedPeriodInfo.length;p++)if(s=v(p))return s.v;if(f<d.length){var h,m=d.slice(f).map((function(e){return Cv(e,!0,u._isTrickModeTrackEnabled,u._defaultAudioTrackSwitchingMode)}));(h=this._storedPeriodInfo).push.apply(h,m),c.push.apply(c,m)}for(var g,y=kv(this._storedPeriodInfo);!(g=y()).done;){var _=g.value;null===(i=_.audio.dispatcher)||void 0===i||i.refresh(),null===(a=_.video.dispatcher)||void 0===a||a.refresh(),null===(o=_.text.dispatcher)||void 0===o||o.refresh()}},r.onDecipherabilityUpdates=function(){for(var e,t,n,r,i=kv(this._storedPeriodInfo);!(r=i()).done;){var a=r.value;null===(e=a.audio.dispatcher)||void 0===e||e.refresh(),null===(t=a.video.dispatcher)||void 0===t||t.refresh(),null===(n=a.text.dispatcher)||void 0===n||n.refresh()}},r.addTrackReference=function(e,n,r){var i=this,a=Iv(this._storedPeriodInfo,n.id);if(void 0===a){a=Cv(n,!1,this._isTrickModeTrackEnabled,this._defaultAudioTrackSwitchingMode);for(var o=!1,s=0;s<this._storedPeriodInfo.length;s++)this._storedPeriodInfo[s].period.start>n.start&&(this._storedPeriodInfo.splice(s,0,a),o=!0);o||this._storedPeriodInfo.push(a)}if(a.isPeriodAdvertised||(a.isPeriodAdvertised=!0,this.trigger("newAvailablePeriods",[{id:n.id,start:n.start,end:n.end}]),!this._isDisposed))if(null===a[e].dispatcher){var u=a[e].storedSettings,l=new Tv(r);a[e].dispatcher=l,l.addEventListener("noPlayableRepresentation",(function(){var r,a,o,s,u=Se(null!==(r=n.adaptations[e])&&void 0!==r?r:[],(function(e){return!1!==e.isSupported&&e.representations.filter((function(e){return!0===e.isSupported&&!1!==e.decipherable})).length>0}));if(void 0===u){var l=new qe("NO_PLAYABLE_REPRESENTATION","No "+e+" Representation can be played",{tracks:void 0});return i.trigger("error",l),void i.dispose()}var d=null===(a=Iv(i._storedPeriodInfo,n.id))||void 0===a?void 0:a[e];if(!t(d)){var c={adaptation:u,switchingMode:"audio"===e?i._defaultAudioTrackSwitchingMode:"reload",lockedRepresentations:new oe(null)};d.storedSettings=c,i.trigger("trackUpdate",{period:Mv(n),trackType:e,reason:"no-playable-representation"}),i._isDisposed||t(d=null===(o=Iv(i._storedPeriodInfo,n.id))||void 0===o?void 0:o[e])||d.storedSettings!==c||null===(s=d.dispatcher)||void 0===s||s.updateTrack(c)}})),l.addEventListener("noPlayableLockedRepresentation",(function(){null==u||u.lockedRepresentations.setValue(null),i.trigger("brokenRepresentationsLock",{period:{id:n.id,start:n.start,end:n.end},trackType:e})})),l.start(u)}else B.error("TS: Subject already added for "+e+" and Period "+n.start)},r.removeTrackReference=function(e,t){var n=function(e,t){for(var n=0;n<e.length;n++){if(e[n].period.id===t.id)return n}}(this._storedPeriodInfo,t);if(void 0!==n){var r=this._storedPeriodInfo[n],i=r[e];null!==(null==i?void 0:i.dispatcher)?(i.dispatcher.dispose(),i.dispatcher=null,Rv(r)&&this._removePeriodObject(n)):B.warn("TS: TrackDispatcher already removed for "+e+" and Period "+t.start)}else B.warn("TS: "+e+" not found for period",t.start)},r.getPeriodObjectFromPeriod=function(e){var t=Iv(this._storedPeriodInfo,e.id);return void 0===t&&void 0!==e?this._cachedPeriodInfo.get(e):t},r.getPeriodObjectFromId=function(e){return Iv(this._storedPeriodInfo,e)},r.disableVideoTrickModeTracks=function(){this._isTrickModeTrackEnabled&&(this._isTrickModeTrackEnabled=!1,this._resetVideoTrackChoices("trickmode-disabled"))},r.enableVideoTrickModeTracks=function(){this._isTrickModeTrackEnabled||(this._isTrickModeTrackEnabled=!0,this._resetVideoTrackChoices("trickmode-enabled"))},r.resetPeriodObjects=function(){for(var e,t,n,r=this._storedPeriodInfo.length-1;r>=0;r--){var i=this._storedPeriodInfo[r];null===(e=i.audio.dispatcher)||void 0===e||e.dispose(),i.audio.dispatcher=null,null===(t=i.video.dispatcher)||void 0===t||t.dispose(),i.video.dispatcher=null,null===(n=i.text.dispatcher)||void 0===n||n.dispose(),i.text.dispatcher=null,i.inManifest||this._removePeriodObject(r)}},r.isTrickModeEnabled=function(){return this._isTrickModeTrackEnabled},r.setAudioTrack=function(e){var t=e.periodRef,n=e.trackId,r=e.switchingMode,i=e.lockedRepresentations,a=e.relativeResumingPosition;return this._setAudioOrTextTrack({bufferType:"audio",periodRef:t,trackId:n,switchingMode:null!=r?r:this._defaultAudioTrackSwitchingMode,lockedRepresentations:i,relativeResumingPosition:a})},r.setTextTrack=function(e,t){return this._setAudioOrTextTrack({bufferType:"text",periodRef:e,trackId:t,switchingMode:"direct",lockedRepresentations:null,relativeResumingPosition:void 0})},r._setAudioOrTextTrack=function(e){var t,n,r=e.bufferType,i=e.periodRef,a=e.trackId,o=e.switchingMode,s=e.lockedRepresentations,u=e.relativeResumingPosition,l=i.period,d=Se(null!==(t=l.adaptations[r])&&void 0!==t?t:[],(function(e){var t=e.id;return!0===e.isSupported&&t===a}));if(void 0===d)throw new Error("Wanted "+r+" track not found.");var c,f=i[r];if(null===s)c=new oe(null);else{var v=this._getRepresentationsToLock(d,s),p="audio"===r?this._defaultAudioTrackSwitchingMode:"direct";c=new oe({representationIds:v,switchingMode:p})}var h={adaptation:d,switchingMode:o,lockedRepresentations:c,relativeResumingPosition:u};if(f.storedSettings=h,this.trigger("trackUpdate",{period:Mv(l),trackType:r,reason:"manual"}),!this._isDisposed){var m=Iv(this._storedPeriodInfo,l.id);void 0!==m&&m[r].storedSettings===h&&(null===(n=m[r].dispatcher)||void 0===n||n.updateTrack(h))}},r.setVideoTrack=function(e){var t,n,r=e.periodRef,i=e.trackId,a=e.switchingMode,o=e.lockedRepresentations,s=e.relativeResumingPosition,u=r.period,l=Se(null!==(t=u.adaptations.video)&&void 0!==t?t:[],(function(e){var t=e.id;return!0===e.isSupported&&t===i}));if(void 0===l)throw new Error("Wanted video track not found.");var d,c=L.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,f=r.video,v=xv(l,this._isTrickModeTrackEnabled);if(null===o)d=new oe(null);else{var p=this._getRepresentationsToLock(l,o);d=new oe({representationIds:p,switchingMode:c})}var h={adaptationBase:l,switchingMode:null!=a?a:c,adaptation:v,relativeResumingPosition:s,lockedRepresentations:d};if(f.storedSettings=h,this.trigger("trackUpdate",{period:Mv(u),trackType:"video",reason:"manual"}),!this._isDisposed){var m=Iv(this._storedPeriodInfo,u.id);void 0!==m&&m.video.storedSettings===h&&(null===(n=m.video.dispatcher)||void 0===n||n.updateTrack(h))}},r.disableTrack=function(e,t){var n,r,i=e[t];if(null!==i.storedSettings&&("text"!==t&&(null===(n=e[t].storedSettings)||void 0===n||n.lockedRepresentations.finish()),i.storedSettings=null,this.trigger("trackUpdate",{period:Mv(e.period),trackType:t,reason:"manual"}),!this._isDisposed)){var a=Iv(this._storedPeriodInfo,e.period.id);void 0!==a&&null===a[t].storedSettings&&(null===(r=a[t].dispatcher)||void 0===r||r.updateTrack(null))}},r.getChosenAudioTrack=function(e){return null===e.audio.storedSettings?null:dt(e.audio.storedSettings.adaptation,!0)},r.getChosenTextTrack=function(e){return null===e.text.storedSettings?null:ct(e.text.storedSettings.adaptation)},r.getChosenVideoTrack=function(e){return null===e.video.storedSettings?null:ft(e.video.storedSettings.adaptation,!0)},r.getAvailableAudioTracks=function(e){var t=e.audio.storedSettings,n=null!==t?t.adaptation.id:null;return ot(e.period,"audio").map((function(e){var t=null!==n&&n===e.id;return P(dt(e,!0),{active:t})}))},r.getAvailableTextTracks=function(e){var t=e.text.storedSettings,n=null!==t?t.adaptation.id:null;return ot(e.period,"text").map((function(e){var t=null!==n&&n===e.id;return P(ct(e),{active:t})}))},r.getAvailableVideoTracks=function(e){var t=e.video.storedSettings,n=null===t?void 0:t.adaptation.id;return ot(e.period,"video").map((function(e){var t=null!==n&&n===e.id,r=ft(e,!0),i=void 0!==r.trickModeTracks?r.trickModeTracks.map((function(e){var t=null!==n&&n===e.id;return P(e,{active:t})})):[],a=P(r,{active:t});return void 0!==i&&(a.trickModeTracks=i),a}))},r.getLockedAudioRepresentations=function(e){var t=e.audio.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representationIds},r.getLockedVideoRepresentations=function(e){var t=e.video.storedSettings;if(null===t)return null;var n=t.lockedRepresentations.getValue();return null===n?null:n.representationIds},r.lockAudioRepresentations=function(e,t){var n,r=e.audio.storedSettings;if(null!==r){var i=L.getCurrent().DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representationIds:a,switchingMode:o})}},r.lockVideoRepresentations=function(e,t){var n,r=e.video.storedSettings;if(null!==r){var i=L.getCurrent().DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE,a=this._getRepresentationsToLock(r.adaptation,t.representations),o=null!==(n=t.switchingMode)&&void 0!==n?n:i;r.lockedRepresentations.setValue({representationIds:a,switchingMode:o})}},r.unlockAudioRepresentations=function(e){var t=e.audio.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.unlockVideoRepresentations=function(e){var t=e.video.storedSettings;null!==t&&null!==t.lockedRepresentations.getValue()&&t.lockedRepresentations.setValue(null)},r.dispose=function(){for(this._isDisposed=!0;;){var e=this._storedPeriodInfo.pop();if(void 0===e)return;e.isRemoved=!0}},r._resetVideoTrackChoices=function(e){for(var t,n=0;n<this._storedPeriodInfo.length;n++){var r=this._storedPeriodInfo[n];if(null!==r.video.storedSettings){var i=r.video.storedSettings.adaptationBase;if(null!==i){var a=xv(i,this._isTrickModeTrackEnabled);r.video.storedSettings.adaptationBase=i,r.video.storedSettings.adaptation=a}}}for(var o=this._storedPeriodInfo.slice(),s=0;s<o.length;s++){var u=o[s].period,l=o[s].video.storedSettings;if(this.trigger("trackUpdate",{period:Mv(u),trackType:"video",reason:e}),this._isDisposed)return;var d=Iv(this._storedPeriodInfo,u.id);void 0!==d&&d.video.storedSettings===l&&(null===(t=d.video.dispatcher)||void 0===t||t.updateTrack(l))}},r._removePeriodObject=function(e){var t=this._storedPeriodInfo[e];this._storedPeriodInfo[e].isRemoved=!0,this._storedPeriodInfo.splice(e,1),this._cachedPeriodInfo.set(t.period,t)},r._getRepresentationsToLock=function(e,t){var n=t.reduce((function(t,n){var r=Se(e.representations,(function(e){return e.id===n}));return void 0===r?B.warn("API: Wanted locked Representation not found."):t.push(r.id),t}),[]);if(0===n.length)throw new Error("Cannot lock Representations: None of the given Representation id are found");return n},n}(i);function Iv(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.period.id===t)return r}}function Rv(e){var t,n,r;return!e.inManifest&&null===(null===(t=e.text)||void 0===t?void 0:t.dispatcher)&&null===(null===(n=e.audio)||void 0===n?void 0:n.dispatcher)&&null===(null===(r=e.video)||void 0===r?void 0:r.dispatcher)}function xv(e,t){var n;return t&&void 0!==(null===(n=e.trickModeTracks)||void 0===n?void 0:n[0])?e.trickModeTracks[0]:e}function Cv(e,t,n,r){var i,a,o=ot(e,"audio")[0],s=ot(e,"video")[0],u=xv(s,n),l=L.getCurrent().DEFAULT_VIDEO_TRACK_SWITCHING_MODE,d=void 0!==o?{adaptation:o,switchingMode:r,lockedRepresentations:new oe(null)}:null,c=void 0!==u?{adaptation:u,adaptationBase:s,switchingMode:l,lockedRepresentations:new oe(null)}:null,f=null,v=(null!==(i=e.adaptations.text)&&void 0!==i?i:[]).filter((function(e){return!0===e.isForcedSubtitles}));if(v.length>0){if(null!=o){var p=Se(v,(function(e){return e.normalizedLanguage===o.normalizedLanguage}));void 0!==p&&(f=p)}null===f&&(f=null!==(a=Se(v,(function(e){return void 0===e.normalizedLanguage})))&&void 0!==a?a:null)}var h=null;return null!==f&&(h={adaptation:f,switchingMode:"direct",lockedRepresentations:new oe(null)}),{period:e,inManifest:t,isPeriodAdvertised:!1,isRemoved:!1,audio:{storedSettings:d,dispatcher:null},video:{storedSettings:c,dispatcher:null},text:{storedSettings:h,dispatcher:null}}}function Mv(e){return{start:e.start,end:e.end,id:e.id}}var Pv=Av;function Dv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Nv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Nv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Nv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ov(e,n){var r=L.getCurrent().FORCED_ENDED_THRESHOLD;if(e.ended)return"ENDED";if(null!==n){var i=Math.abs(e.duration-e.currentTime);return!t(r)&&i<r?"ENDED":"seeking"===n?"SEEKING":"freezing"===n?"FREEZING":"BUFFERING"}return e.paused?"PAUSED":"PLAYING"}function Lv(e){return"LOADING"!==e&&"RELOADING"!==e&&"STOPPED"!==e}function Uv(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return Fv(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Fv(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Fv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Bv=Ze(),zv=["manifestLoader","segmentLoader"],Vv=function(n){function r(e){var i;void 0===e&&(e={}),i=n.call(this)||this;var a=function(e){var n,r,i,a,o,s,u=L.getCurrent(),l=u.DEFAULT_BASE_BANDWIDTH,d=u.DEFAULT_VIDEO_RESOLUTION_LIMIT,c=u.DEFAULT_MAX_BUFFER_AHEAD,f=u.DEFAULT_MAX_BUFFER_BEHIND,v=u.DEFAULT_MAX_VIDEO_BUFFER_SIZE,p=u.DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN,h=u.DEFAULT_WANTED_BUFFER_AHEAD;if(t(e.maxBufferAhead))n=c;else if(n=Number(e.maxBufferAhead),isNaN(n))throw new Error("Invalid maxBufferAhead parameter. Should be a number.");if(t(e.maxBufferBehind))r=f;else if(r=Number(e.maxBufferBehind),isNaN(r))throw new Error("Invalid maxBufferBehind parameter. Should be a number.");if(t(e.wantedBufferAhead))i=h;else if(i=Number(e.wantedBufferAhead),isNaN(i))throw new Error("Invalid wantedBufferAhead parameter. Should be a number.");if(t(e.maxVideoBufferSize))a=v;else if(a=Number(e.maxVideoBufferSize),isNaN(a))throw new Error("Invalid maxVideoBufferSize parameter. Should be a number.");var m=t(e.videoResolutionLimit)?d:e.videoResolutionLimit,g=t(e.throttleVideoBitrateWhenHidden)?p:!!e.throttleVideoBitrateWhenHidden;if(t(e.videoElement))o=document.createElement("video");else{if(!(e.videoElement instanceof HTMLMediaElement))throw new Error("Invalid videoElement parameter. Should be a HTMLMediaElement.");o=e.videoElement}if(t(e.baseBandwidth))s=l;else if(s=Number(e.baseBandwidth),isNaN(s))throw new Error("Invalid baseBandwidth parameter. Should be a number.");return{maxBufferAhead:n,maxBufferBehind:r,videoResolutionLimit:m,videoElement:o,wantedBufferAhead:i,maxVideoBufferSize:a,throttleVideoBitrateWhenHidden:g,baseBandwidth:s}}(e),o=a.baseBandwidth,s=a.videoResolutionLimit,u=a.maxBufferAhead,l=a.maxBufferBehind,d=a.throttleVideoBitrateWhenHidden,c=a.videoElement,f=a.wantedBufferAhead,v=a.maxVideoBufferSize;c.preload="auto",i.version="4.1.0-dev.2024031100",i.log=B,i.state="STOPPED",i.videoElement=c,r._priv_registerVideoElement(i.videoElement);var p=new pe;i._destroyCanceller=p,i._priv_pictureInPictureRef=function(e,t){var n=e;if(!0===n.webkitSupportsPresentationMode&&"function"==typeof n.webkitSetPresentationMode){var r="picture-in-picture"===n.webkitPresentationMode,i=new oe({isEnabled:r,pipWindow:null},t);return fi(n,"webkitpresentationmodechanged",(function(){var e="picture-in-picture"===n.webkitPresentationMode;i.setValue({isEnabled:e,pipWindow:null})}),t),i}var a=document.pictureInPictureElement===n,o=new oe({isEnabled:a,pipWindow:null},t);return fi(n,"enterpictureinpicture",(function(e){var t;o.setValue({isEnabled:!0,pipWindow:null!==(t=e.pictureInPictureWindow)&&void 0!==t?t:null})}),t),fi(n,"leavepictureinpicture",(function(){o.setValue({isEnabled:!1,pipWindow:null})}),t),o}(c,p.signal),i._priv_speed=new oe(c.playbackRate,i._destroyCanceller.signal),i._priv_preferTrickModeTracks=!1,i._priv_contentLock=new oe(!1,i._destroyCanceller.signal),i._priv_bufferOptions={wantedBufferAhead:new oe(f,i._destroyCanceller.signal),maxBufferAhead:new oe(u,i._destroyCanceller.signal),maxBufferBehind:new oe(l,i._destroyCanceller.signal),maxVideoBufferSize:new oe(v,i._destroyCanceller.signal)},i._priv_bitrateInfos={lastBitrates:{audio:o,video:o}},i._priv_throttleVideoBitrateWhenHidden=d,i._priv_videoResolutionLimit=s,i._priv_currentError=null,i._priv_contentInfos=null,i._priv_contentEventsMemory={},i._priv_reloadingMetadata={},i._priv_lastAutoPlay=!1,i._priv_worker=null;var h=function(){i.trigger("volumeChange",{volume:c.volume,muted:c.muted})};return c.addEventListener("volumechange",h),p.signal.register((function(){c.removeEventListener("volumechange",h)})),i}f(r,n),r.addFeatures=function(e){!function(e){for(var n=0;n<e.length;n++){var r=e[n];if("function"==typeof r)r(St);else{if(t(r)||"function"!=typeof r._addFeature)throw new Error("Unrecognized feature");r._addFeature(St)}}}(e)},r._priv_registerVideoElement=function(e){if(r._priv_currentlyUsedVideoElements.has(e)){console.warn("The video element is already attached to another RxPlayer instance.\nMake sure to dispose the previous instance with player.dispose() before creating a new player instance attaching that video element.")}r._priv_currentlyUsedVideoElements.add(e)},r._priv_deregisterVideoElement=function(e){r._priv_currentlyUsedVideoElements.has(e)&&r._priv_currentlyUsedVideoElements.delete(e)};var i=r.prototype;return i.attachWorker=function(t){var n=this;return new Promise((function(r,i){var a;if(!(R&&"object"==typeof Worker||"function"==typeof Worker))return B.warn("API: Cannot rely on a WebWorker: Worker API unavailable"),i(new fv("INCOMPATIBLE_ERROR","Worker unavailable"));if("string"==typeof t.workerUrl)n._priv_worker=new Worker(t.workerUrl);else{var o=URL.createObjectURL(t.workerUrl);n._priv_worker=new Worker(o),URL.revokeObjectURL(o)}n._priv_worker.onerror=function(e){null!==n._priv_worker&&(n._priv_worker.terminate(),n._priv_worker=null),B.error("API: Unexpected worker error",e.error instanceof Error?e.error:void 0),i(new fv("UNKNOWN_ERROR",'Unexpected Worker "error" event'))};n._priv_worker.addEventListener("message",(function e(t){var a=t.data;"init-error"===a.type?(B.warn("API: Processing InitError worker message: detaching worker"),null!==n._priv_worker&&(n._priv_worker.removeEventListener("message",e),n._priv_worker.terminate(),n._priv_worker=null),i(new fv("SETUP_ERROR","Worker parser initialization failed: "+a.value.errorMessage))):"init-success"===a.type&&(B.info("API: InitSuccess received from worker."),null!==n._priv_worker&&n._priv_worker.removeEventListener("message",e),r())})),B.debug("---\x3e Sending To Worker:","init"),n._priv_worker.postMessage({type:"init",value:{dashWasmUrl:t.dashWasmUrl,logLevel:B.getLevel(),sendBackLogs:e(),date:Date.now(),timestamp:ye(),hasVideo:"video"===(null===(a=n.videoElement)||void 0===a?void 0:a.nodeName.toLowerCase()),hasMseInWorker:cv}}),B.addEventListener("onLogLevelChange",(function(t){null!==n._priv_worker&&(B.debug("---\x3e Sending To Worker:","log-level-update"),n._priv_worker.postMessage({type:"log-level-update",value:{logLevel:t,sendBackLogs:e()}}))}),n._destroyCanceller.signal)}))},i.getCurrentModeInformation=function(){return null===this._priv_contentInfos?null:{isDirectFile:this._priv_contentInfos.isDirectFile,useWorker:this._priv_contentInfos.useWorker}},i.addEventListener=function(e,t){return n.prototype.addEventListener.call(this,e,t)},i.stop=function(){null!==this._priv_contentInfos&&this._priv_contentInfos.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),"STOPPED"!==this.state&&this._priv_setPlayerState("STOPPED")},i.dispose=function(){this.stop(),null!==this.videoElement&&(r._priv_deregisterVideoElement(this.videoElement),bv(this.videoElement).catch((function(e){var t=e instanceof Error?e.message:"Unknown error";B.error("API: Could not dispose decryption resources: "+t)}))),this._destroyCanceller.cancel(),this._priv_reloadingMetadata={},this.videoElement=null,null!==this._priv_worker&&(this._priv_worker.terminate(),this._priv_worker=null)},i.loadVideo=function(e){var n=function(e){var n,r,i,a,o,s,u,l,d,c,f=L.getCurrent(),v=f.DEFAULT_AUTO_PLAY,p=f.DEFAULT_CODEC_SWITCHING_BEHAVIOR,h=f.DEFAULT_ENABLE_FAST_SWITCHING,m=f.DEFAULT_TEXT_TRACK_MODE;if(t(e))throw new Error("No option set on loadVideo");if(t(e.url)){if(t(e.initialManifest)&&t(e.manifestLoader))throw new Error("Unable to load a content: no url set on loadVideo.\nPlease provide at least either an `url` argument, a `initialManifest` option or a `manifestLoader` option so the RxPlayer can load the content.")}else a=String(e.url);if(t(e.transport))throw new Error("No transport set on loadVideo");o=String(e.transport);var g=t(e.autoPlay)?v:!!e.autoPlay;if(t(e.keySystems))s=[];else for(var y,_=Dv(s=Array.isArray(e.keySystems)?e.keySystems:[e.keySystems]);!(y=_()).done;){var b=y.value;if("string"!=typeof b.type||"function"!=typeof b.getLicense)throw new Error("Invalid key system given: Missing type string or getLicense callback")}var S=void 0!==e.lowLatencyMode&&!!e.lowLatencyMode,E=e.initialManifest,T=null!==(n=e.minimumManifestUpdateInterval)&&void 0!==n?n:0,k=null!==(r=e.defaultAudioTrackSwitchingMode)&&void 0!==r?r:void 0;void 0===k||Je(["seamless","direct","reload"],k)||(B.warn("The `defaultAudioTrackSwitchingMode` loadVideo option must match one of the following strategy name:\n- `seamless`\n- `direct`\n- `reload`"),k=void 0);var w=t(e.onCodecSwitch)?p:e.onCodecSwitch;if(Je(["continue","reload"],w)||(B.warn("The `onCodecSwitch` loadVideo option must match one of the following string:\n- `continue`\n- `reload`\nIf badly set, "+p+" will be used as default"),w=p),t(e.textTrackMode))u=m;else{if("native"!==e.textTrackMode&&"html"!==e.textTrackMode)throw new Error("Invalid textTrackMode.");u=e.textTrackMode}if("html"===u){if(t(e.textTrackElement))throw new Error('You have to provide a textTrackElement in "html" textTrackMode.');if(!(e.textTrackElement instanceof HTMLElement))throw new Error("textTrackElement should be an HTMLElement.");d=e.textTrackElement}else t(e.textTrackElement)||B.warn('API: You have set a textTrackElement without being in an "html" textTrackMode. It will be ignored.');if(t(e.mode))l="auto";else{if(!Je(["auto","multithread","main"],e.mode))throw new Error("Invalid `mode` option.");l=e.mode}var A=t(e.enableFastSwitching)?h:e.enableFastSwitching;if(!t(e.startAt))if("wallClockTime"in e.startAt&&e.startAt.wallClockTime instanceof Date){var I=e.startAt.wallClockTime.getTime()/1e3;c=P({},e.startAt,{wallClockTime:I})}else c=e.startAt;var R=null!==(i=e.requestConfig)&&void 0!==i?i:{};return{__priv_patchLastSegmentInSidx:e.__priv_patchLastSegmentInSidx,__priv_manifestUpdateUrl:e.__priv_manifestUpdateUrl,checkMediaSegmentIntegrity:e.checkMediaSegmentIntegrity,autoPlay:g,defaultAudioTrackSwitchingMode:k,enableFastSwitching:A,initialManifest:E,keySystems:s,lowLatencyMode:S,manifestLoader:e.manifestLoader,minimumManifestUpdateInterval:T,requestConfig:R,onCodecSwitch:w,referenceDateTime:e.referenceDateTime,representationFilter:e.representationFilter,segmentLoader:e.segmentLoader,serverSyncInfos:e.serverSyncInfos,startAt:c,textTrackElement:d,textTrackMode:u,transport:o,mode:l,url:a}}(e);B.info("API: Calling loadvideo",n.url,n.transport),this._priv_reloadingMetadata={options:n},this._priv_initializeContentPlayback(n),this._priv_lastAutoPlay=n.autoPlay},i.reload=function(e){var t,n,r,i,a,o,s=this._priv_reloadingMetadata,u=s.options,l=s.manifest,d=s.reloadPosition,c=s.reloadInPause;if(void 0===u)throw new Error("API: Can't reload without having previously loaded a content.");if(function(e){var t,n,r,i;if(null===e||"object"!=typeof e&&void 0!==e)throw new Error("API: reload - Invalid options format.");if(null===(null==e?void 0:e.reloadAt)||"object"!=typeof(null==e?void 0:e.reloadAt)&&void 0!==(null==e?void 0:e.reloadAt))throw new Error("API: reload - Invalid 'reloadAt' option format.");if("number"!=typeof(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position)&&void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.position))throw new Error("API: reload - Invalid 'reloadAt.position' option format.");if("number"!=typeof(null===(r=null==e?void 0:e.reloadAt)||void 0===r?void 0:r.relative)&&void 0!==(null===(i=null==e?void 0:e.reloadAt)||void 0===i?void 0:i.relative))throw new Error("API: reload - Invalid 'reloadAt.relative' option format.");if(!Array.isArray(null==e?void 0:e.keySystems)&&void 0!==(null==e?void 0:e.keySystems))throw new Error("API: reload - Invalid 'keySystems' option format.");if(void 0!==(null==e?void 0:e.autoPlay)&&"boolean"!=typeof e.autoPlay)throw new Error("API: reload - Invalid 'autoPlay' option format.")}(e),void 0!==(null===(t=null==e?void 0:e.reloadAt)||void 0===t?void 0:t.position))i={position:e.reloadAt.position};else if(void 0!==(null===(n=null==e?void 0:e.reloadAt)||void 0===n?void 0:n.relative)){if(void 0===d)throw new Error("Can't reload to a relative position when previous content was not loaded.");i={position:e.reloadAt.relative+d}}else void 0!==d&&(i={position:d});void 0!==(null==e?void 0:e.autoPlay)?a=e.autoPlay:void 0!==c&&(a=!c),void 0!==(null==e?void 0:e.keySystems)?o=e.keySystems:void 0!==(null===(r=this._priv_reloadingMetadata.options)||void 0===r?void 0:r.keySystems)&&(o=this._priv_reloadingMetadata.options.keySystems);var f=Object.assign(Object.assign({},u),{initialManifest:l});void 0!==i&&(f.startAt=i),void 0!==a&&(f.autoPlay=a),void 0!==o&&(f.keySystems=o),this._priv_initializeContentPlayback(f)},i.createDebugElement=function(e){if(null===Et.createDebugElement)throw new Error("Feature `DEBUG_ELEMENT` not added to the RxPlayer");var t=new pe;return Et.createDebugElement(e,this,t.signal),{dispose:function(){t.cancel()}}},i._priv_initializeContentPlayback=function(e){var n,r,i,a,o,s,u=this,l=e.autoPlay,d=e.defaultAudioTrackSwitchingMode,c=e.enableFastSwitching,f=e.initialManifest,v=e.keySystems,p=e.lowLatencyMode,h=e.minimumManifestUpdateInterval,m=e.requestConfig,g=e.onCodecSwitch,y=e.startAt,_=e.transport,b=e.checkMediaSegmentIntegrity,S=e.manifestLoader,E=e.referenceDateTime,T=e.segmentLoader,k=e.serverSyncInfos,w=e.mode,A=e.__priv_manifestUpdateUrl,I=e.__priv_patchLastSegmentInSidx,R=e.url;if(null===this.videoElement)throw new Error("the attached video element is disposed");var x,C,M="directfile"===_,D=new pe,N=this.videoElement,O=!1,L=null;if(M){if(null===Et.directfile)throw this.stop(),this._priv_currentError=null,new Error("DirectFile feature not activated in your build.");if(t(R))throw new Error("No URL for a DirectFile content");if(B.info("API: Initializing DirectFile mode in the main thread"),L=this._priv_initializeMediaElementTracksStore(D.signal),D.isUsed())return;x=new Et.directfile.initDirectFile({autoPlay:l,keySystems:v,speed:this._priv_speed,startAt:y,url:R})}else{var U={lowLatencyMode:p,maxRetry:null===(n=m.manifest)||void 0===n?void 0:n.maxRetry,requestTimeout:null===(r=m.manifest)||void 0===r?void 0:r.timeout,connectionTimeout:null===(i=m.manifest)||void 0===i?void 0:i.connectionTimeout,minimumManifestUpdateInterval:h,initialManifest:f},F=lv(),z={throttleBitrate:{},limitResolution:{}};this._priv_throttleVideoBitrateWhenHidden&&(F?z.throttleBitrate={video:ae(Xr(this._priv_pictureInPictureRef,D.signal),(function(e){return e?1/0:0}),D.signal)}:B.warn("API: Can't apply throttleVideoBitrateWhenHidden because browser can't be trusted for visibility.")),"videoElement"===this._priv_videoResolutionLimit?F?z.limitResolution={video:Jr(N,this._priv_pictureInPictureRef,D.signal)}:B.warn("API: Can't apply videoResolutionLimit because browser can't be trusted for video size."):"screen"===this._priv_videoResolutionLimit&&(z.limitResolution={video:Zr(D.signal)});var V={initialBitrates:this._priv_bitrateInfos.lastBitrates,lowLatencyMode:p,throttlers:z},K="native"===e.textTrackMode?{textTrackMode:"native"}:{textTrackMode:"html",textTrackElement:e.textTrackElement},W=P({enableFastSwitching:c,onCodecSwitch:g},this._priv_bufferOptions),G={lowLatencyMode:p,maxRetry:null===(a=m.segment)||void 0===a?void 0:a.maxRetry,requestTimeout:null===(o=m.segment)||void 0===o?void 0:o.timeout,connectionTimeout:null===(s=m.segment)||void 0===s?void 0:s.connectionTimeout},H=null!==Et.multithread&&null!==this._priv_worker&&"dash"===_&&zv.every((function(n){return t(e[n])}))&&"function"!=typeof e.representationFilter;if("main"===w||"auto"===w&&!H){if(null===Et.mainThreadMediaSourceInit)throw new Error("Cannot load video, neither in a WebWorker nor with the `MEDIA_SOURCE_MAIN` feature");var j=Et.transports[_];if("function"!=typeof j)throw this.stop(),this._priv_currentError=null,new Error('transport "'+_+'" not supported');var q="string"==typeof e.representationFilter?(C=e.representationFilter,new Function("return ("+C+"(arguments[0], arguments[1]))")):e.representationFilter;B.info("API: Initializing MediaSource mode in the main thread");var Y=j({lowLatencyMode:p,checkMediaSegmentIntegrity:b,manifestLoader:S,referenceDateTime:E,representationFilter:q,segmentLoader:T,serverSyncInfos:k,__priv_manifestUpdateUrl:A,__priv_patchLastSegmentInSidx:I});x=new Et.mainThreadMediaSourceInit({adaptiveOptions:V,autoPlay:l,bufferOptions:W,keySystems:v,lowLatencyMode:p,transport:Y,manifestRequestSettings:U,segmentRequestOptions:G,speed:this._priv_speed,startAt:y,textTrackOptions:K,url:R})}else{if(null===Et.multithread)throw new Error("Cannot load video in multithread mode: `MULTI_THREAD` feature not imported.");if(null===this._priv_worker)throw new Error("Cannot load video in multithread mode: `attachWorker` method not called.");fe(e.representationFilter),O=!0,B.info("API: Initializing MediaSource mode in a WebWorker");var Q={lowLatencyMode:p,checkMediaSegmentIntegrity:b,referenceDateTime:E,serverSyncInfos:k,manifestLoader:void 0,segmentLoader:void 0,representationFilter:e.representationFilter,__priv_manifestUpdateUrl:A,__priv_patchLastSegmentInSidx:I};x=new Et.multithread.init({adaptiveOptions:V,autoPlay:l,bufferOptions:W,keySystems:v,lowLatencyMode:p,transportOptions:Q,manifestRequestSettings:U,segmentRequestOptions:G,speed:this._priv_speed,startAt:y,textTrackOptions:K,worker:this._priv_worker,url:R})}}var $={contentId:Bv(),originalUrl:R,currentContentCanceller:D,defaultAudioTrackSwitchingMode:d,initializer:x,isDirectFile:M,segmentSinksStore:null,manifest:null,currentPeriod:null,activeAdaptations:null,activeRepresentations:null,tracksStore:null,mediaElementTracksStore:L,useWorker:O};x.addEventListener("error",(function(e){u._priv_onFatalError(e,$)})),x.addEventListener("warning",(function(e){var t=Xe(e,{defaultCode:"NONE",defaultReason:"An unknown error happened."});B.warn("API: Sending warning:",t),u.trigger("warning",t)})),x.addEventListener("reloadingMediaSource",(function(e){$.segmentSinksStore=null,null!==$.tracksStore&&$.tracksStore.resetPeriodObjects(),u._priv_lastAutoPlay=e.autoPlay})),x.addEventListener("inbandEvents",(function(e){return u.trigger("inbandEvents",e)})),x.addEventListener("streamEvent",(function(e){return u.trigger("streamEvent",e)})),x.addEventListener("streamEventSkip",(function(e){return u.trigger("streamEventSkip",e)})),x.addEventListener("activePeriodChanged",(function(e){return u._priv_onActivePeriodChanged($,e)})),x.addEventListener("periodStreamReady",(function(e){return u._priv_onPeriodStreamReady($,e)})),x.addEventListener("periodStreamCleared",(function(e){return u._priv_onPeriodStreamCleared($,e)})),x.addEventListener("representationChange",(function(e){return u._priv_onRepresentationChange($,e)})),x.addEventListener("adaptationChange",(function(e){return u._priv_onAdaptationChange($,e)})),x.addEventListener("bitrateEstimateChange",(function(e){return u._priv_onBitrateEstimateChange(e)})),x.addEventListener("manifestReady",(function(e){return u._priv_onManifestReady($,e)})),x.addEventListener("manifestUpdate",(function(e){return u._priv_onManifestUpdate($,e)})),x.addEventListener("decipherabilityUpdate",(function(e){return u._priv_onDecipherabilityUpdate($,e)})),x.addEventListener("loaded",(function(e){$.segmentSinksStore=e.segmentSinksStore})),x.prepare(),this.stop();var X=new gv(N,{withMediaSource:!M,lowLatencyMode:p});D.signal.register((function(){X.stop()}));var Z=function(e,t,n,r){var i=new oe("LOADING",r);e.addEventListener("loaded",(function(){if("LOADING"===i.getValue()){if(i.setValue("LOADED"),!r.isCancelled()){var e=Ov(t,null);"PAUSED"!==e&&i.setValue(e)}}else"RELOADING"===i.getValue()?i.setValue(Ov(t,null)):o(null)}),r),e.addEventListener("reloadingMediaSource",(function(){Lv(i.getValue())&&i.setValueIfChanged("RELOADING")}),r);var a=null;return e.addEventListener("stalled",(function(e){e!==a&&(o(e),a=e)}),r),e.addEventListener("unstalled",(function(){null!==a&&(o(null),a=null)}),r),n.listen((function(e){Je(["seeking","ended","play","pause"],e.event)&&o(a)}),{clearSignal:r}),i;function o(e){if(Lv(i.getValue())){var n=Ov(t,e);"LOADED"===i.getValue()&&"PAUSED"===n||i.setValueIfChanged(n)}}}(x,N,X,D.signal);D.signal.register((function(){x.dispose()}));var J=function(e){switch(e){case"STOPPED":case"RELOADING":case"LOADING":break;case"ENDED":u._priv_reloadingMetadata.reloadInPause=!0,u._priv_reloadingMetadata.reloadPosition=X.getReference().getValue().position.getPolled();break;default:var t=X.getReference().getValue();u._priv_reloadingMetadata.reloadInPause=t.paused,u._priv_reloadingMetadata.reloadPosition=t.position.getWanted()}},ee=null,te=function(e){null!==ee&&(ee.cancel(),ee=null),Z.onUpdate((function(t,n){var r,i,a,o;Lv(t)&&(n(),null!==ee&&ee.cancel(),(ee=new pe).linkToSignal(D.signal),e!==!N.paused&&(N.paused?u.trigger("pause",null):u.trigger("play",null)),r=N,i=function(){return u.trigger("play",null)},a=function(){return u.trigger("pause",null)},(o=D.signal).isCancelled()||null===r||(r.addEventListener("play",i),r.addEventListener("pause",a),o.register((function(){r.removeEventListener("play",i),r.removeEventListener("pause",a)}))))}),{emitCurrentValue:!1,clearSignal:D.signal})};te(l),x.addEventListener("reloadingMediaSource",(function(e){te(e.autoPlay)})),this._priv_currentError=null,this._priv_contentInfos=$;var ne=null;Z.onUpdate((function(e){J(e),u._priv_setPlayerState(e),D.isUsed()||(null!==ne?Lv(u.state)||(ne.cancel(),ne=null):Lv(u.state)&&((ne=new pe).linkToSignal(D.signal),function(e,t,n,r,i){if(!i.isCancelled()&&null!==e){var a=2===t.getReference().getValue().seeking;a&&(n(),i.isCancelled())||t.listen((function(e){"seeking"===e.event?(a=!0,n()):a&&"seeked"===e.event&&(a=!1,r())}),{includeLastObservation:!0,clearSignal:i})}}(N,X,(function(){return u.trigger("seeking",null)}),(function(){return u.trigger("seeked",null)}),ne.signal)))}),{emitCurrentValue:!0,clearSignal:D.signal}),X.listen((function(e){J(u.state),u._priv_triggerPositionUpdate($,e)}),{clearSignal:D.signal}),D.signal.register((function(){x.removeEventListener()})),this._priv_contentLock.onUpdate((function(e,t){e||(t(),x.start(N,X))}),{emitCurrentValue:!0,clearSignal:D.signal})},i.getError=function(){return this._priv_currentError},i.getVideoElement=function(){return this.videoElement},i.getPlayerState=function(){return this.state},i.isContentLoaded=function(){return!Je(["LOADING","RELOADING","STOPPED"],this.state)},i.isBuffering=function(){return Je(["BUFFERING","SEEKING","LOADING","RELOADING"],this.state)},i.isPaused=function(){return!this.videoElement||(Je(["LOADING","RELOADING"],this.state)?!this._priv_lastAutoPlay:this.videoElement.paused)},i.isLive=function(){if(null===this._priv_contentInfos)return!1;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return!t&&null!==n&&n.isLive},i.areTrickModeTracksEnabled=function(){return this._priv_preferTrickModeTracks},i.getContentUrls=function(){if(null!==this._priv_contentInfos){var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest,r=e.originalUrl;return t?void 0===r?void 0:[r]:null!==n?n.uris:void 0}},i.updateContentUrls=function(e,t){if(null===this._priv_contentInfos)throw new Error("No content loaded");var n=!0===(null==t?void 0:t.refresh);this._priv_contentInfos.initializer.updateContentUrls(e,n)},i.getMediaDuration=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration},i.getCurrentBufferGap=function(){if(null===this.videoElement)throw new Error("Disposed player");var e,t,n,r=this.videoElement,i=(e=r.buffered,t=r.currentTime,null!==(n=Y(e,t))?n.end-t:1/0);return i===1/0?0:i},i.getWallClockTime=function(){if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)return this.videoElement.currentTime;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){var r=dv(this.videoElement);return(null!=r?r:0)+this.videoElement.currentTime}return null!==n?this.videoElement.currentTime+(void 0!==n.availabilityStartTime?n.availabilityStartTime:0):0},i.getPosition=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.currentTime},i.getLastStoredContentPosition=function(){return this._priv_reloadingMetadata.reloadPosition},i.getPlaybackRate=function(){return this._priv_speed.getValue()},i.setPlaybackRate=function(e,n){var r;e!==this._priv_speed.getValue()&&this._priv_speed.setValue(e);var i=null==n?void 0:n.preferTrickModeTracks;if("boolean"==typeof i){this._priv_preferTrickModeTracks=i;var a=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.tracksStore;t(a)||(i&&!a.isTrickModeEnabled()?a.enableVideoTrickModeTracks():!i&&a.isTrickModeEnabled()&&a.disableVideoTrickModeTracks())}},i.getVideoRepresentation=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e)return e.video},i.getAudioRepresentation=function(){var e=this.__priv_getCurrentRepresentations();if(null!==e)return e.audio},i.play=function(){var e=this;if(null===this.videoElement)throw new Error("Disposed player");var n=this.videoElement.play();return t(n)||"function"!=typeof n.catch?Promise.resolve():n.catch((function(t){if("NotAllowedError"===t.name){var n=new qe("MEDIA_ERR_PLAY_NOT_ALLOWED",t.toString());e.trigger("warning",n)}throw t}))},i.pause=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.pause()},i.seekTo=function(e){var n;if(null===this.videoElement)throw new Error("Disposed player");if(null===this._priv_contentInfos)throw new Error("player: no content loaded");var r,i=this._priv_contentInfos,a=i.isDirectFile,o=i.manifest;if(!a&&null===o)throw new Error("player: the content did not load yet");if("number"==typeof e)r=e;else if("object"==typeof e){var s=e,u=this.videoElement.currentTime;if(t(s.relative))if(t(s.position)){if(t(s.wallClockTime))throw new Error('invalid time object. You must set one of the following properties: "relative", "position" or "wallClockTime"');if(null!==o)r=s.wallClockTime-(null!==(n=o.availabilityStartTime)&&void 0!==n?n:0);else if(a&&null!==this.videoElement){var l=dv(this.videoElement);void 0!==l&&(r=s.wallClockTime-l)}void 0===r&&(r=s.wallClockTime)}else r=s.position;else r=u+s.relative}if(void 0===r)throw new Error("invalid time given");return B.info("API: API Seek to",r),this.videoElement.currentTime=r,r},i.getVolume=function(){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.volume},i.setVolume=function(e){if(null===this.videoElement)throw new Error("Disposed player");var t=this.videoElement;e!==t.volume&&(t.volume=e)},i.isMute=function(){var e;return!0===(null===(e=this.videoElement)||void 0===e?void 0:e.muted)},i.mute=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.muted||(this.videoElement.muted=!0)},i.unMute=function(){if(null===this.videoElement)throw new Error("Disposed player");this.videoElement.muted&&(this.videoElement.muted=!1)},i.setMaxBufferBehind=function(e){this._priv_bufferOptions.maxBufferBehind.setValue(e)},i.setMaxBufferAhead=function(e){this._priv_bufferOptions.maxBufferAhead.setValue(e)},i.setWantedBufferAhead=function(e){this._priv_bufferOptions.wantedBufferAhead.setValue(e)},i.setMaxVideoBufferSize=function(e){this._priv_bufferOptions.maxVideoBufferSize.setValue(e)},i.getMaxBufferBehind=function(){return this._priv_bufferOptions.maxBufferBehind.getValue()},i.getMaxBufferAhead=function(){return this._priv_bufferOptions.maxBufferAhead.getValue()},i.getWantedBufferAhead=function(){return this._priv_bufferOptions.wantedBufferAhead.getValue()},i.getMaxVideoBufferSize=function(){return this._priv_bufferOptions.maxVideoBufferSize.getValue()},i.getCurrentPeriod=function(){var e,n=null===(e=this._priv_contentInfos)||void 0===e?void 0:e.currentPeriod;return t(n)?null:{id:n.id,start:n.start,end:n.end}},i.getKeySystemConfiguration=function(){if(null===this.videoElement)throw new Error("Disposed player");var e=zr(this.videoElement);return null===e?null:{keySystem:e[0],configuration:e[1]}},i.getAvailablePeriods=function(){if(null===this._priv_contentInfos)return[];var e=this._priv_contentInfos,t=e.isDirectFile,n=e.tracksStore;return t||null===n?[]:n.getAvailablePeriods().slice()},i.getAvailableAudioTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableAudioTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableAudioTracks(t))&&void 0!==n?n:[]}))},i.getAvailableTextTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableTextTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableTextTracks(t))&&void 0!==n?n:[]}))},i.getAvailableVideoTracks=function(e){var t;if(null===this._priv_contentInfos)return[];var n=this._priv_contentInfos,r=n.isDirectFile,i=n.mediaElementTracksStore;return r?null!==(t=null==i?void 0:i.getAvailableVideoTracks())&&void 0!==t?t:[]:this._priv_callTracksStoreGetterSetter(e,[],(function(e,t){var n;return null!==(n=e.getAvailableVideoTracks(t))&&void 0!==n?n:[]}))},i.getAudioTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenAudioTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenAudioTrack(t)}))}},i.getTextTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenTextTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenTextTrack(t)}))}},i.getVideoTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(n){if(null===r)return;return r.getChosenVideoTrack()}return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.getChosenVideoTrack(t)}))}},i.setAudioTrack=function(e){var t;if(null===this._priv_contentInfos)throw new Error("No content loaded");var n,r,i,a=this._priv_contentInfos,o=a.isDirectFile,s=a.mediaElementTracksStore;if(o)try{var u="string"==typeof e?e:e.trackId;return void(null==s||s.setAudioTrackById(u))}catch(e){throw new Error("player: unknown audio track")}var l,d=null;return"string"==typeof e?r=e:(r=e.trackId,n=e.periodId,i=e.switchingMode,d=null!==(t=e.lockedRepresentations)&&void 0!==t?t:null,l=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,t){return e.setAudioTrack({periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:d,relativeResumingPosition:l})}))},i.setTextTrack=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r=this._priv_contentInfos,i=r.isDirectFile,a=r.mediaElementTracksStore;if(i)try{var o="string"==typeof e?e:e.trackId;return void(null==a||a.setTextTrackById(o))}catch(e){throw new Error("player: unknown text track")}return"string"==typeof e?n=e:(n=e.trackId,t=e.periodId),this._priv_callTracksStoreGetterSetter(t,void 0,(function(e,t){return e.setTextTrack(t,n)}))},i.disableTextTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;if(!n)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.disableTrack(t,"text")}));null==r||r.disableTextTrack()}},i.setVideoTrack=function(e){var t;if(null===this._priv_contentInfos)throw new Error("No content loaded");var n,r,i,a=this._priv_contentInfos,o=a.isDirectFile,s=a.mediaElementTracksStore;if(o)try{var u="string"==typeof e?e:e.trackId;return void(null==s||s.setVideoTrackById(u))}catch(e){throw new Error("player: unknown video track")}var l,d=null;return"string"==typeof e?r=e:(r=e.trackId,n=e.periodId,i=e.switchingMode,d=null!==(t=e.lockedRepresentations)&&void 0!==t?t:null,l=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,t){return e.setVideoTrack({periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:d,relativeResumingPosition:l})}))},i.disableVideoTrack=function(e){if(null!==this._priv_contentInfos){var t=this._priv_contentInfos,n=t.isDirectFile,r=t.mediaElementTracksStore;return n&&null!==r?r.disableVideoTrack():this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.disableTrack(t,"video")}))}},i.lockVideoRepresentations=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r;if(this._priv_contentInfos.isDirectFile)throw new Error("Cannot lock video Representations in directfile mode.");return Array.isArray(e)?(t=e,n=void 0):(t=e.representations,n=e.periodId,r=e.switchingMode),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,n){return e.lockVideoRepresentations(n,{representations:t,switchingMode:r})}))},i.lockAudioRepresentations=function(e){if(null===this._priv_contentInfos)throw new Error("No content loaded");var t,n,r;if(this._priv_contentInfos.isDirectFile)throw new Error("Cannot lock audio Representations in directfile mode.");return Array.isArray(e)?(t=e,n=void 0):(t=e.representations,n=e.periodId,r=e.switchingMode),this._priv_callTracksStoreGetterSetter(n,void 0,(function(e,n){return e.lockAudioRepresentations(n,{representations:t,switchingMode:r})}))},i.getLockedVideoRepresentations=function(e){return null===this._priv_contentInfos||this._priv_contentInfos.isDirectFile?null:this._priv_callTracksStoreGetterSetter(e,null,(function(e,t){return e.getLockedVideoRepresentations(t)}))},i.getLockedAudioRepresentations=function(e){return null===this._priv_contentInfos||this._priv_contentInfos.isDirectFile?null:this._priv_callTracksStoreGetterSetter(e,null,(function(e,t){return e.getLockedAudioRepresentations(t)}))},i.unlockVideoRepresentations=function(e){if(null!==this._priv_contentInfos&&!this._priv_contentInfos.isDirectFile)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.unlockVideoRepresentations(t)}))},i.unlockAudioRepresentations=function(e){if(null!==this._priv_contentInfos&&!this._priv_contentInfos.isDirectFile)return this._priv_callTracksStoreGetterSetter(e,void 0,(function(e,t){return e.unlockAudioRepresentations(t)}))},i.getMinimumPosition=function(){if(null===this._priv_contentInfos)return null;if(this._priv_contentInfos.isDirectFile)return 0;var e=this._priv_contentInfos.manifest;return null!==e?rt(e):null},i.getLivePosition=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;return t?void 0:!0!==(null==n?void 0:n.isLive)?null:it(n)},i.getMaximumPosition=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,t=e.isDirectFile,n=e.manifest;if(t){if(null===this.videoElement)throw new Error("Disposed player");return this.videoElement.duration}return null!==n?n.isDynamic||null===this.videoElement?at(n):this.videoElement.duration:null},i.__priv_getSegmentSinkContent=function(e){if(null===this._priv_contentInfos||null===this._priv_contentInfos.segmentSinksStore)return null;var t=this._priv_contentInfos.segmentSinksStore.getStatus(e);return"initialized"===t.type?t.value.getLastKnownInventory():null},i.__priv_getManifest=function(){return null===this._priv_contentInfos?null:this._priv_contentInfos.manifest},i.__priv_getCurrentAdaptation=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,n=e.currentPeriod,r=e.activeAdaptations;return null===n||null===r||t(r[n.id])?null:r[n.id]},i.__priv_getCurrentRepresentations=function(){if(null===this._priv_contentInfos)return null;var e=this._priv_contentInfos,n=e.currentPeriod,r=e.activeRepresentations;return null===n||null===r||t(r[n.id])?null:r[n.id]},i._priv_cleanUpCurrentContentState=function(){var e,n,r,i,a=this;B.debug("Locking `contentLock` to clean-up the current content."),this._priv_contentLock.setValue(!0),null===(n=null===(e=this._priv_contentInfos)||void 0===e?void 0:e.tracksStore)||void 0===n||n.dispose(),null===(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.mediaElementTracksStore)||void 0===i||i.dispose(),this._priv_contentInfos=null,this._priv_contentEventsMemory={};var o=function(){null!==a.videoElement&&(B.debug("Unlocking `contentLock`. Next content can begin."),a._priv_contentLock.setValue(!1))};t(this.videoElement)?o():Ev(this.videoElement).then((function(){B.debug("API: DRM session cleaned-up with success!"),o()}),(function(e){B.error("API: An error arised when trying to clean-up the DRM session:"+(e instanceof Error?e.toString():"Unknown Error")),o()}))},i._priv_onManifestReady=function(e,t){var n,r=this;if(e.contentId===(null===(n=this._priv_contentInfos)||void 0===n?void 0:n.contentId)){e.manifest=t,0===t.manifestFormat&&(this._priv_reloadingMetadata.manifest=t);var i=new Pv({preferTrickModeTracks:this._priv_preferTrickModeTracks,defaultAudioTrackSwitchingMode:e.defaultAudioTrackSwitchingMode});e.tracksStore=i,i.addEventListener("newAvailablePeriods",(function(e){r.trigger("newAvailablePeriods",e)})),i.addEventListener("brokenRepresentationsLock",(function(e){r.trigger("brokenRepresentationsLock",e)})),i.addEventListener("trackUpdate",(function(e){var t,n;r.trigger("trackUpdate",e);var i=null!==(n=null===(t=r._priv_contentInfos)||void 0===t?void 0:t.currentPeriod)&&void 0!==n?n:void 0;"no-playable-representation"===e.reason&&e.period.id===(null==i?void 0:i.id)&&r._priv_onAvailableTracksMayHaveChanged(e.trackType)})),e.tracksStore.addEventListener("warning",(function(e){r.trigger("warning",e)})),e.tracksStore.addEventListener("error",(function(t){r._priv_onFatalError(t,e)})),e.tracksStore.onManifestUpdate(t)}},i._priv_onManifestUpdate=function(e,n){var r,i,a;if(null!==this._priv_contentInfos&&null!==this._priv_contentInfos.manifest){t(null==e?void 0:e.tracksStore)||e.tracksStore.onManifestUpdate(this._priv_contentInfos.manifest);var o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,s=null===(a=this._priv_contentInfos)||void 0===a?void 0:a.tracksStore;if(void 0!==o&&!t(s))for(var u,l=Uv(n.updatedPeriods);!(u=l()).done;){var d=u.value;if(d.period.id===o.id&&(d.result.addedAdaptations.length>0||d.result.removedAdaptations.length>0)){if(void 0===s.getPeriodObjectFromPeriod(o))return;this._priv_onAvailableTracksMayHaveChanged("audio"),this._priv_onAvailableTracksMayHaveChanged("text"),this._priv_onAvailableTracksMayHaveChanged("video")}}}},i._priv_onDecipherabilityUpdate=function(e,n){if(null!==e&&null!==e.manifest){t(null==e?void 0:e.tracksStore)||e.tracksStore.onDecipherabilityUpdates();for(var r,i=n.reduce((function(t,n){var r,i,a;if(!(void 0!==Se(t,(function(e){return e[0].id===n.period.id&&e[1]===n.adaptation.type})))){var o=e.tracksStore;if(null===o)return t;var s=!1,u=o.getPeriodObjectFromPeriod(n.period);if(void 0===u)return t;switch(n.adaptation.type){case"audio":s=(null===(r=o.getChosenAudioTrack(u))||void 0===r?void 0:r.id)===n.adaptation.id;break;case"video":s=(null===(i=o.getChosenVideoTrack(u))||void 0===i?void 0:i.id)===n.adaptation.id;break;case"text":s=(null===(a=o.getChosenTextTrack(u))||void 0===a?void 0:a.id)===n.adaptation.id}s&&t.push([n.period,n.adaptation.type])}return t}),[]),a=Uv(i);!(r=a()).done;){var o=r.value,s=o[0],u=o[1];this._priv_triggerEventIfNotStopped("representationListUpdate",{period:{start:s.start,end:s.end,id:s.id},trackType:u,reason:"decipherability-update"},e.currentContentCanceller.signal)}}},i._priv_onActivePeriodChanged=function(e,n){var r,i,a,o,s,u,l=n.period;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){e.currentPeriod=l;var d=e.currentContentCanceller.signal;this._priv_contentEventsMemory.periodChange!==l&&(this._priv_contentEventsMemory.periodChange=l,this._priv_triggerEventIfNotStopped("periodChange",{start:l.start,end:l.end,id:l.id},d)),this._priv_triggerEventIfNotStopped("availableAudioTracksChange",this.getAvailableAudioTracks(),d),this._priv_triggerEventIfNotStopped("availableTextTracksChange",this.getAvailableTextTracks(),d),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",this.getAvailableVideoTracks(),d);var c=null===(i=this._priv_contentInfos)||void 0===i?void 0:i.tracksStore;if(t(c))this._priv_triggerEventIfNotStopped("audioTrackChange",null,d),this._priv_triggerEventIfNotStopped("textTrackChange",null,d),this._priv_triggerEventIfNotStopped("videoTrackChange",null,d);else{var f=c.getPeriodObjectFromPeriod(l);if(f){var v=c.getChosenAudioTrack(f);this._priv_triggerEventIfNotStopped("audioTrackChange",v,d);var p=c.getChosenTextTrack(f);this._priv_triggerEventIfNotStopped("textTrackChange",p,d);var h=c.getChosenVideoTrack(f);this._priv_triggerEventIfNotStopped("videoTrackChange",h,d)}}var m=null!==(o=null===(a=this.__priv_getCurrentRepresentations())||void 0===a?void 0:a.audio)&&void 0!==o?o:null;this._priv_triggerEventIfNotStopped("audioRepresentationChange",m,d);var g=null!==(u=null===(s=this.__priv_getCurrentRepresentations())||void 0===s?void 0:s.video)&&void 0!==u?u:null;this._priv_triggerEventIfNotStopped("videoRepresentationChange",g,d)}},i._priv_onPeriodStreamReady=function(e,n){var r;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var i=n.type,a=n.period,o=n.adaptationRef,s=e.tracksStore;switch(i){case"video":case"audio":case"text":t(s)?(B.error("API: TracksStore not instanciated for a new "+i+" period"),o.setValue(null)):s.addTrackReference(i,a,o);break;default:ve()}}},i._priv_onPeriodStreamCleared=function(e,n){var r;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var i=n.type,a=n.period,o=e.tracksStore;switch(i){case"audio":case"text":case"video":t(o)||o.removeTrackReference(i,a)}var s=e.activeAdaptations,u=e.activeRepresentations;if(!t(s)&&!t(s[a.id])){var l=s[a.id];delete l[i],0===Object.keys(l).length&&delete s[a.id]}if(!t(u)&&!t(u[a.id])){var d=u[a.id];delete d[i],0===Object.keys(d).length&&delete u[a.id]}}},i._priv_onAdaptationChange=function(e,n){var r,i=n.type,a=n.adaptation,o=n.period;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){null===e.activeAdaptations&&(e.activeAdaptations={});var s,u=e.activeAdaptations,l=e.currentPeriod,d=u[o.id];if(t(d))u[o.id]=((s={})[i]=a,s);else d[i]=a;var c=e.tracksStore,f=e.currentContentCanceller.signal;if(null!==c&&null!==l&&!t(o)&&o.id===l.id){var v=c.getPeriodObjectFromPeriod(o);if(void 0===v)return;switch(i){case"audio":var p=c.getChosenAudioTrack(v);this._priv_triggerEventIfNotStopped("audioTrackChange",p,f);break;case"text":var h=c.getChosenTextTrack(v);this._priv_triggerEventIfNotStopped("textTrackChange",h,f);break;case"video":var m=c.getChosenVideoTrack(v);this._priv_triggerEventIfNotStopped("videoTrackChange",m,f)}}}},i._priv_onRepresentationChange=function(e,n){var r,i=n.type,a=n.period,o=n.representation;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){null===e.activeRepresentations&&(e.activeRepresentations={});var s,u=e.activeRepresentations,l=e.currentPeriod,d=u[a.id];if(t(d))u[a.id]=((s={})[i]=o,s);else d[i]=o;if(!t(a)&&null!==l&&l.id===a.id){var c=this._priv_contentInfos.currentContentCanceller.signal;"video"===i?this._priv_triggerEventIfNotStopped("videoRepresentationChange",o,c):"audio"===i&&this._priv_triggerEventIfNotStopped("audioRepresentationChange",o,c)}}},i._priv_onBitrateEstimateChange=function(e){var t=e.type,n=e.bitrate;void 0!==n&&(this._priv_bitrateInfos.lastBitrates[t]=n),this.trigger("__priv_bitrateEstimateChange",{type:t,bitrate:n})},i._priv_setPlayerState=function(e){this.state!==e&&(this.state=e,B.info("API: playerStateChange event",e),this.trigger("playerStateChange",e))},i._priv_triggerPositionUpdate=function(e,n){var r,i;if(e.contentId===(null===(r=this._priv_contentInfos)||void 0===r?void 0:r.contentId)){var a=e.isDirectFile,o=e.manifest;if((a||null!==o)&&!t(n)){var s=null!==o?at(o):void 0,u={position:n.position.getPolled(),duration:n.duration,playbackRate:n.playbackRate,maximumPosition:s,bufferGap:void 0!==n.bufferGap&&isFinite(n.bufferGap)?n.bufferGap:0};if(null!==o&&o.isLive&&n.position.getPolled()>0){var l=null!==(i=o.availabilityStartTime)&&void 0!==i?i:0;u.wallClockTime=n.position.getPolled()+l;var d=it(o);void 0!==d&&(u.liveGap=d-n.position.getPolled())}else if(a&&null!==this.videoElement){var c=dv(this.videoElement);void 0!==c&&(u.wallClockTime=c+n.position.getPolled())}this.trigger("positionUpdate",u)}}},i._priv_triggerEventIfNotStopped=function(e,t,n){n.isCancelled()||this.trigger(e,t)},i._priv_initializeMediaElementTracksStore=function(e){var t,n,r,i=this;fe(Et.directfile),fe(this.videoElement);var a=new Et.directfile.mediaElementTracksStore(this.videoElement);return this._priv_triggerEventIfNotStopped("availableAudioTracksChange",a.getAvailableAudioTracks(),e),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",a.getAvailableVideoTracks(),e),this._priv_triggerEventIfNotStopped("availableTextTracksChange",a.getAvailableTextTracks(),e),this._priv_triggerEventIfNotStopped("audioTrackChange",null!==(t=a.getChosenAudioTrack())&&void 0!==t?t:null,e),this._priv_triggerEventIfNotStopped("textTrackChange",null!==(n=a.getChosenTextTrack())&&void 0!==n?n:null,e),this._priv_triggerEventIfNotStopped("videoTrackChange",null!==(r=a.getChosenVideoTrack())&&void 0!==r?r:null,e),a.addEventListener("availableVideoTracksChange",(function(e){return i.trigger("availableVideoTracksChange",e)})),a.addEventListener("availableAudioTracksChange",(function(e){return i.trigger("availableAudioTracksChange",e)})),a.addEventListener("availableTextTracksChange",(function(e){return i.trigger("availableTextTracksChange",e)})),a.addEventListener("audioTrackChange",(function(e){return i.trigger("audioTrackChange",e)})),a.addEventListener("videoTrackChange",(function(e){return i.trigger("videoTrackChange",e)})),a.addEventListener("textTrackChange",(function(e){return i.trigger("textTrackChange",e)})),a},i._priv_callTracksStoreGetterSetter=function(e,t,n){var r,i;if(null===this._priv_contentInfos||null===this._priv_contentInfos.tracksStore)return B.warn("API: Trying to call track API too soon"),t;var a=this._priv_contentInfos.tracksStore,o=null!==(i=null===(r=this._priv_contentInfos)||void 0===r?void 0:r.currentPeriod)&&void 0!==i?i:void 0,s=null!=e?e:null==o?void 0:o.id;if(void 0===s)return t;var u=s===(null==o?void 0:o.id)?a.getPeriodObjectFromPeriod(o):a.getPeriodObjectFromId(s);return void 0===u?t:n(a,u)},i._priv_onAvailableTracksMayHaveChanged=function(e,n){var r=this._priv_contentInfos;if(null!==r){var i=r.currentPeriod,a=r.tracksStore,o=r.currentContentCanceller.signal;if(!t(i)&&null!==a){var s=null!=n?n:a.getPeriodObjectFromPeriod(i);if(void 0!==s)switch(e){case"video":var u=a.getAvailableVideoTracks(s);this._priv_triggerEventIfNotStopped("availableVideoTracksChange",null!=u?u:[],o);break;case"audio":var l=a.getAvailableAudioTracks(s);this._priv_triggerEventIfNotStopped("availableAudioTracksChange",null!=l?l:[],o);break;case"text":var d=a.getAvailableTextTracks(s);this._priv_triggerEventIfNotStopped("availableTextTracksChange",null!=d?d:[],o);break;default:ve()}}}},i._priv_onFatalError=function(e,t){var n=Xe(e,{defaultCode:"NONE",defaultReason:"An unknown error stopped content playback."});n.fatal=!0,t.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this._priv_currentError=n,B.error("API: The player stopped because of an error",n),this._priv_setPlayerState("STOPPED"),this._priv_currentError===n&&this.trigger("error",n)},pl(r,null,[{key:"ErrorTypes",get:function(){return We}},{key:"ErrorCodes",get:function(){return Ge}},{key:"LogLevel",get:function(){return B.getLevel()},set:function(e){B.setLevel(e)}}]),r}(i);Vv._priv_currentlyUsedVideoElements=new WeakSet,Vv.version="4.1.0-dev.2024031100";var Kv=Vv;!function(){if(!o&&!t(s.WebKitSourceBuffer)&&void 0===s.WebKitSourceBuffer.prototype.addEventListener){var e=s.WebKitSourceBuffer.prototype;for(var n in i.prototype)i.prototype.hasOwnProperty(n)&&(e[n]=i.prototype[n]);e._listeners=[],e._emitUpdate=function(e,t){var n=this;u((function(){n.trigger(e,t),n.updating=!1,n.trigger("updateend")}))},e.appendBuffer=function(e){if(this.updating)throw new Error("updating");this.trigger("updatestart"),this.updating=!0;try{this.append(e)}catch(e){return void this._emitUpdate("error",e)}this._emitUpdate("update")}}}(),Kv.addFeatures([Ko,Zu,ul,Xd,Pc,zc,$c,nf,xf,Uf,rv,uv]),e()&&B.setLevel("DEBUG");var Wv=Kv}(),r=r.default}()}));