rx-player 4.3.0-dev.2025030400 → 4.3.0-dev.2025040100

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 (522) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  5. package/dist/commonjs/compat/add_class_name.d.ts.map +1 -1
  6. package/dist/commonjs/compat/add_class_name.js +1 -4
  7. package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
  8. package/dist/commonjs/compat/browser_compatibility_types.js +0 -1
  9. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.d.ts.map +1 -1
  10. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.js +0 -2
  11. package/dist/commonjs/compat/eme/eme-api-implementation.js +0 -1
  12. package/dist/commonjs/compat/eme/generate_key_request.d.ts +2 -2
  13. package/dist/commonjs/compat/eme/generate_key_request.js +2 -2
  14. package/dist/commonjs/compat/is_vtt_cue.d.ts.map +1 -1
  15. package/dist/commonjs/compat/is_vtt_cue.js +0 -1
  16. package/dist/commonjs/compat/patch_webkit_source_buffer.js +1 -1
  17. package/dist/commonjs/core/fetchers/index.d.ts +5 -2
  18. package/dist/commonjs/core/fetchers/index.d.ts.map +1 -1
  19. package/dist/commonjs/core/fetchers/index.js +6 -1
  20. package/dist/commonjs/core/fetchers/segment/segment_queue_creator.d.ts +4 -3
  21. package/dist/commonjs/core/fetchers/segment/segment_queue_creator.d.ts.map +1 -1
  22. package/dist/commonjs/core/fetchers/segment/segment_queue_creator.js +3 -4
  23. package/dist/commonjs/core/fetchers/thumbnails/index.d.ts +6 -0
  24. package/dist/commonjs/core/fetchers/thumbnails/index.d.ts.map +1 -0
  25. package/dist/commonjs/core/fetchers/thumbnails/index.js +6 -0
  26. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.d.ts +87 -0
  27. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -0
  28. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.js +176 -0
  29. package/dist/commonjs/core/main/common/get_thumbnail_data.d.ts +13 -0
  30. package/dist/commonjs/core/main/common/get_thumbnail_data.d.ts.map +1 -0
  31. package/dist/commonjs/core/main/common/get_thumbnail_data.js +72 -0
  32. package/dist/commonjs/core/main/worker/content_preparer.d.ts +3 -0
  33. package/dist/commonjs/core/main/worker/content_preparer.d.ts.map +1 -1
  34. package/dist/commonjs/core/main/worker/content_preparer.js +88 -1
  35. package/dist/commonjs/core/main/worker/worker_main.d.ts.map +1 -1
  36. package/dist/commonjs/core/main/worker/worker_main.js +45 -3
  37. package/dist/commonjs/core/segment_sinks/garbage_collector.d.ts.map +1 -1
  38. package/dist/commonjs/core/segment_sinks/garbage_collector.js +4 -0
  39. package/dist/commonjs/core/stream/representation/representation_stream.d.ts.map +1 -1
  40. package/dist/commonjs/core/stream/representation/representation_stream.js +29 -45
  41. package/dist/commonjs/core/stream/representation/utils/push_init_segment.d.ts.map +1 -1
  42. package/dist/commonjs/core/stream/representation/utils/push_init_segment.js +0 -3
  43. package/dist/commonjs/core/stream/representation/utils/push_media_segment.d.ts.map +1 -1
  44. package/dist/commonjs/core/stream/representation/utils/push_media_segment.js +0 -3
  45. package/dist/commonjs/default_config.d.ts +22 -0
  46. package/dist/commonjs/default_config.d.ts.map +1 -1
  47. package/dist/commonjs/default_config.js +27 -1
  48. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/api/index.js +1 -1
  49. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/capabilities.d.ts +2 -2
  50. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/capabilities.js +2 -2
  51. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +1 -1
  52. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  53. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +0 -1
  54. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.d.ts.map +1 -1
  55. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +0 -1
  56. package/dist/commonjs/index.js +1 -1
  57. package/dist/commonjs/main_thread/api/public_api.d.ts +136 -7
  58. package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
  59. package/dist/commonjs/main_thread/api/public_api.js +95 -15
  60. package/dist/commonjs/main_thread/decrypt/session_events_listener.d.ts.map +1 -1
  61. package/dist/commonjs/main_thread/decrypt/session_events_listener.js +26 -18
  62. package/dist/commonjs/main_thread/decrypt/utils/loaded_sessions_store.d.ts +1 -1
  63. package/dist/commonjs/main_thread/decrypt/utils/loaded_sessions_store.js +1 -1
  64. package/dist/commonjs/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  65. package/dist/commonjs/main_thread/init/directfile_content_initializer.js +3 -0
  66. package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts.map +1 -1
  67. package/dist/commonjs/main_thread/init/media_source_content_initializer.js +14 -3
  68. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts +1 -6
  69. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -1
  70. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.js +77 -17
  71. package/dist/commonjs/main_thread/init/types.d.ts +8 -0
  72. package/dist/commonjs/main_thread/init/types.d.ts.map +1 -1
  73. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts +5 -4
  74. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  75. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +10 -4
  76. package/dist/commonjs/main_thread/render_thumbnail.d.ts +27 -0
  77. package/dist/commonjs/main_thread/render_thumbnail.d.ts.map +1 -0
  78. package/dist/commonjs/main_thread/render_thumbnail.js +255 -0
  79. package/dist/commonjs/manifest/classes/index.d.ts +2 -1
  80. package/dist/commonjs/manifest/classes/index.d.ts.map +1 -1
  81. package/dist/commonjs/manifest/classes/manifest.js +1 -1
  82. package/dist/commonjs/manifest/classes/period.d.ts +56 -1
  83. package/dist/commonjs/manifest/classes/period.d.ts.map +1 -1
  84. package/dist/commonjs/manifest/classes/period.js +24 -0
  85. package/dist/commonjs/manifest/classes/representation.d.ts +2 -0
  86. package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
  87. package/dist/commonjs/manifest/classes/representation.js +1 -0
  88. package/dist/commonjs/manifest/classes/representation_index/static.d.ts +15 -0
  89. package/dist/commonjs/manifest/classes/representation_index/static.d.ts.map +1 -1
  90. package/dist/commonjs/manifest/classes/representation_index/static.js +17 -0
  91. package/dist/commonjs/manifest/classes/representation_index/types.d.ts +20 -0
  92. package/dist/commonjs/manifest/classes/representation_index/types.d.ts.map +1 -1
  93. package/dist/commonjs/manifest/classes/update_period_in_place.d.ts +9 -0
  94. package/dist/commonjs/manifest/classes/update_period_in_place.d.ts.map +1 -1
  95. package/dist/commonjs/manifest/classes/update_period_in_place.js +85 -15
  96. package/dist/commonjs/manifest/index.d.ts +2 -2
  97. package/dist/commonjs/manifest/index.d.ts.map +1 -1
  98. package/dist/commonjs/manifest/types.d.ts +56 -0
  99. package/dist/commonjs/manifest/types.d.ts.map +1 -1
  100. package/dist/commonjs/manifest/utils.d.ts.map +1 -1
  101. package/dist/commonjs/manifest/utils.js +120 -56
  102. package/dist/commonjs/minimal.js +1 -1
  103. package/dist/commonjs/multithread_types.d.ts +33 -7
  104. package/dist/commonjs/multithread_types.d.ts.map +1 -1
  105. package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +1 -1
  106. package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.js +1 -1
  107. package/dist/commonjs/parsers/manifest/dash/common/get_hdr_information.d.ts.map +1 -1
  108. package/dist/commonjs/parsers/manifest/dash/common/get_hdr_information.js +17 -0
  109. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts +15 -0
  110. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.d.ts.map +1 -1
  111. package/dist/commonjs/parsers/manifest/dash/common/indexes/base.js +22 -0
  112. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts +15 -0
  113. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.d.ts.map +1 -1
  114. package/dist/commonjs/parsers/manifest/dash/common/indexes/list.js +18 -0
  115. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts +10 -0
  116. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts.map +1 -1
  117. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +12 -0
  118. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +15 -0
  119. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts.map +1 -1
  120. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +26 -0
  121. package/dist/commonjs/parsers/manifest/dash/common/indexes/tokens.js +3 -3
  122. package/dist/commonjs/parsers/manifest/dash/common/infer_adaptation_type.d.ts +15 -10
  123. package/dist/commonjs/parsers/manifest/dash/common/infer_adaptation_type.d.ts.map +1 -1
  124. package/dist/commonjs/parsers/manifest/dash/common/infer_adaptation_type.js +56 -4
  125. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.d.ts +5 -2
  126. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.d.ts.map +1 -1
  127. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +71 -4
  128. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.d.ts.map +1 -1
  129. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +3 -2
  130. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.d.ts +1 -0
  131. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.d.ts.map +1 -1
  132. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +19 -1
  133. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.d.ts.map +1 -1
  134. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +8 -0
  135. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts.map +1 -1
  136. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Representation.d.ts.map +1 -1
  137. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Representation.js +8 -0
  138. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/utils.d.ts.map +1 -1
  139. package/dist/commonjs/parsers/manifest/dash/node_parser_types.d.ts +1 -0
  140. package/dist/commonjs/parsers/manifest/dash/node_parser_types.d.ts.map +1 -1
  141. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Representation.d.ts.map +1 -1
  142. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +10 -0
  143. package/dist/commonjs/parsers/manifest/local/parse_local_manifest.js +1 -0
  144. package/dist/commonjs/parsers/manifest/local/representation_index.d.ts +15 -0
  145. package/dist/commonjs/parsers/manifest/local/representation_index.d.ts.map +1 -1
  146. package/dist/commonjs/parsers/manifest/local/representation_index.js +20 -0
  147. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +1 -0
  148. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts +10 -0
  149. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.d.ts.map +1 -1
  150. package/dist/commonjs/parsers/manifest/metaplaylist/representation_index.js +9 -0
  151. package/dist/commonjs/parsers/manifest/smooth/create_parser.d.ts.map +1 -1
  152. package/dist/commonjs/parsers/manifest/smooth/create_parser.js +1 -0
  153. package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts +15 -0
  154. package/dist/commonjs/parsers/manifest/smooth/representation_index.d.ts.map +1 -1
  155. package/dist/commonjs/parsers/manifest/smooth/representation_index.js +23 -0
  156. package/dist/commonjs/parsers/manifest/types.d.ts +61 -0
  157. package/dist/commonjs/parsers/manifest/types.d.ts.map +1 -1
  158. package/dist/commonjs/parsers/texttracks/ttml/parse_ttml.d.ts +1 -1
  159. package/dist/commonjs/parsers/texttracks/ttml/regexps.d.ts.map +1 -1
  160. package/dist/commonjs/parsers/texttracks/ttml/regexps.js +1 -1
  161. package/dist/commonjs/parsers/texttracks/webvtt/native/set_settings_on_cue.js +1 -1
  162. package/dist/commonjs/public_types.d.ts +60 -0
  163. package/dist/commonjs/public_types.d.ts.map +1 -1
  164. package/dist/commonjs/transports/dash/pipelines.d.ts.map +1 -1
  165. package/dist/commonjs/transports/dash/pipelines.js +5 -0
  166. package/dist/commonjs/transports/dash/thumbnails.d.ts +21 -0
  167. package/dist/commonjs/transports/dash/thumbnails.d.ts.map +1 -0
  168. package/dist/commonjs/transports/dash/thumbnails.js +127 -0
  169. package/dist/commonjs/transports/local/pipelines.d.ts.map +1 -1
  170. package/dist/commonjs/transports/local/pipelines.js +8 -0
  171. package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
  172. package/dist/commonjs/transports/metaplaylist/pipelines.js +8 -0
  173. package/dist/commonjs/transports/smooth/pipelines.d.ts.map +1 -1
  174. package/dist/commonjs/transports/smooth/pipelines.js +8 -0
  175. package/dist/commonjs/transports/smooth/segment_loader.d.ts.map +1 -1
  176. package/dist/commonjs/transports/types.d.ts +29 -0
  177. package/dist/commonjs/transports/types.d.ts.map +1 -1
  178. package/dist/commonjs/utils/are_codecs_compatible.js +1 -1
  179. package/dist/commonjs/utils/array_find.js +1 -1
  180. package/dist/commonjs/utils/array_find_index.js +1 -1
  181. package/dist/commonjs/utils/array_includes.js +1 -1
  182. package/dist/commonjs/utils/assert.js +1 -1
  183. package/dist/commonjs/utils/flat_map.d.ts.map +1 -1
  184. package/dist/commonjs/utils/flat_map.js +0 -1
  185. package/dist/commonjs/utils/logger.d.ts.map +1 -1
  186. package/dist/commonjs/utils/logger.js +0 -2
  187. package/dist/commonjs/utils/noop.js +1 -1
  188. package/dist/commonjs/utils/object_assign.d.ts.map +1 -1
  189. package/dist/commonjs/utils/object_assign.js +3 -4
  190. package/dist/commonjs/utils/object_values.js +1 -1
  191. package/dist/commonjs/utils/request/xhr.js +1 -1
  192. package/dist/commonjs/utils/starts_with.d.ts.map +1 -1
  193. package/dist/commonjs/utils/starts_with.js +0 -1
  194. package/dist/commonjs/utils/string_parsing.js +1 -1
  195. package/dist/commonjs/utils/url-utils.js +2 -2
  196. package/dist/commonjs/utils/weak_map_memory.d.ts.map +1 -1
  197. package/dist/commonjs/utils/weak_map_memory.js +0 -1
  198. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  199. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  200. package/dist/es2017/compat/add_class_name.d.ts.map +1 -1
  201. package/dist/es2017/compat/add_class_name.js +1 -4
  202. package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
  203. package/dist/es2017/compat/browser_compatibility_types.js +0 -1
  204. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.d.ts.map +1 -1
  205. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.js +0 -2
  206. package/dist/es2017/compat/eme/eme-api-implementation.js +0 -1
  207. package/dist/es2017/compat/eme/generate_key_request.d.ts +2 -2
  208. package/dist/es2017/compat/eme/generate_key_request.js +2 -2
  209. package/dist/es2017/compat/is_vtt_cue.d.ts.map +1 -1
  210. package/dist/es2017/compat/is_vtt_cue.js +0 -1
  211. package/dist/es2017/compat/patch_webkit_source_buffer.js +1 -1
  212. package/dist/es2017/core/fetchers/index.d.ts +5 -2
  213. package/dist/es2017/core/fetchers/index.d.ts.map +1 -1
  214. package/dist/es2017/core/fetchers/index.js +3 -1
  215. package/dist/es2017/core/fetchers/segment/segment_queue_creator.d.ts +4 -3
  216. package/dist/es2017/core/fetchers/segment/segment_queue_creator.d.ts.map +1 -1
  217. package/dist/es2017/core/fetchers/segment/segment_queue_creator.js +3 -4
  218. package/dist/es2017/core/fetchers/thumbnails/index.d.ts +6 -0
  219. package/dist/es2017/core/fetchers/thumbnails/index.d.ts.map +1 -0
  220. package/dist/es2017/core/fetchers/thumbnails/index.js +3 -0
  221. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.d.ts +87 -0
  222. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -0
  223. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.js +123 -0
  224. package/dist/es2017/core/main/common/get_thumbnail_data.d.ts +13 -0
  225. package/dist/es2017/core/main/common/get_thumbnail_data.d.ts.map +1 -0
  226. package/dist/es2017/core/main/common/get_thumbnail_data.js +28 -0
  227. package/dist/es2017/core/main/worker/content_preparer.d.ts +3 -0
  228. package/dist/es2017/core/main/worker/content_preparer.d.ts.map +1 -1
  229. package/dist/es2017/core/main/worker/content_preparer.js +40 -1
  230. package/dist/es2017/core/main/worker/worker_main.d.ts.map +1 -1
  231. package/dist/es2017/core/main/worker/worker_main.js +45 -3
  232. package/dist/es2017/core/segment_sinks/garbage_collector.d.ts.map +1 -1
  233. package/dist/es2017/core/segment_sinks/garbage_collector.js +4 -0
  234. package/dist/es2017/core/stream/representation/representation_stream.d.ts.map +1 -1
  235. package/dist/es2017/core/stream/representation/representation_stream.js +29 -45
  236. package/dist/es2017/core/stream/representation/utils/push_init_segment.d.ts.map +1 -1
  237. package/dist/es2017/core/stream/representation/utils/push_init_segment.js +0 -3
  238. package/dist/es2017/core/stream/representation/utils/push_media_segment.d.ts.map +1 -1
  239. package/dist/es2017/core/stream/representation/utils/push_media_segment.js +0 -3
  240. package/dist/es2017/default_config.d.ts +22 -0
  241. package/dist/es2017/default_config.d.ts.map +1 -1
  242. package/dist/es2017/default_config.js +27 -1
  243. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/api/index.js +1 -1
  244. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/capabilities.d.ts +2 -2
  245. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/capabilities.js +2 -2
  246. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +1 -1
  247. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  248. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +0 -1
  249. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.d.ts.map +1 -1
  250. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +0 -1
  251. package/dist/es2017/index.js +1 -1
  252. package/dist/es2017/main_thread/api/public_api.d.ts +136 -7
  253. package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
  254. package/dist/es2017/main_thread/api/public_api.js +90 -14
  255. package/dist/es2017/main_thread/decrypt/session_events_listener.d.ts.map +1 -1
  256. package/dist/es2017/main_thread/decrypt/session_events_listener.js +4 -6
  257. package/dist/es2017/main_thread/decrypt/utils/loaded_sessions_store.d.ts +1 -1
  258. package/dist/es2017/main_thread/decrypt/utils/loaded_sessions_store.js +1 -1
  259. package/dist/es2017/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  260. package/dist/es2017/main_thread/init/directfile_content_initializer.js +1 -0
  261. package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts.map +1 -1
  262. package/dist/es2017/main_thread/init/media_source_content_initializer.js +11 -3
  263. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts +1 -6
  264. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -1
  265. package/dist/es2017/main_thread/init/multi_thread_content_initializer.js +72 -16
  266. package/dist/es2017/main_thread/init/types.d.ts +8 -0
  267. package/dist/es2017/main_thread/init/types.d.ts.map +1 -1
  268. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts +5 -4
  269. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  270. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +10 -4
  271. package/dist/es2017/main_thread/render_thumbnail.d.ts +27 -0
  272. package/dist/es2017/main_thread/render_thumbnail.d.ts.map +1 -0
  273. package/dist/es2017/main_thread/render_thumbnail.js +187 -0
  274. package/dist/es2017/manifest/classes/index.d.ts +2 -1
  275. package/dist/es2017/manifest/classes/index.d.ts.map +1 -1
  276. package/dist/es2017/manifest/classes/manifest.js +1 -1
  277. package/dist/es2017/manifest/classes/period.d.ts +56 -1
  278. package/dist/es2017/manifest/classes/period.d.ts.map +1 -1
  279. package/dist/es2017/manifest/classes/period.js +24 -0
  280. package/dist/es2017/manifest/classes/representation.d.ts +2 -0
  281. package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
  282. package/dist/es2017/manifest/classes/representation.js +1 -0
  283. package/dist/es2017/manifest/classes/representation_index/static.d.ts +15 -0
  284. package/dist/es2017/manifest/classes/representation_index/static.d.ts.map +1 -1
  285. package/dist/es2017/manifest/classes/representation_index/static.js +17 -0
  286. package/dist/es2017/manifest/classes/representation_index/types.d.ts +20 -0
  287. package/dist/es2017/manifest/classes/representation_index/types.d.ts.map +1 -1
  288. package/dist/es2017/manifest/classes/update_period_in_place.d.ts +9 -0
  289. package/dist/es2017/manifest/classes/update_period_in_place.d.ts.map +1 -1
  290. package/dist/es2017/manifest/classes/update_period_in_place.js +64 -0
  291. package/dist/es2017/manifest/index.d.ts +2 -2
  292. package/dist/es2017/manifest/index.d.ts.map +1 -1
  293. package/dist/es2017/manifest/types.d.ts +56 -0
  294. package/dist/es2017/manifest/types.d.ts.map +1 -1
  295. package/dist/es2017/manifest/utils.d.ts.map +1 -1
  296. package/dist/es2017/manifest/utils.js +24 -0
  297. package/dist/es2017/minimal.js +1 -1
  298. package/dist/es2017/multithread_types.d.ts +33 -7
  299. package/dist/es2017/multithread_types.d.ts.map +1 -1
  300. package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.d.ts +1 -1
  301. package/dist/es2017/parsers/manifest/dash/common/convert_supplemental_codecs.js +1 -1
  302. package/dist/es2017/parsers/manifest/dash/common/get_hdr_information.d.ts.map +1 -1
  303. package/dist/es2017/parsers/manifest/dash/common/get_hdr_information.js +17 -0
  304. package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts +15 -0
  305. package/dist/es2017/parsers/manifest/dash/common/indexes/base.d.ts.map +1 -1
  306. package/dist/es2017/parsers/manifest/dash/common/indexes/base.js +22 -0
  307. package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts +15 -0
  308. package/dist/es2017/parsers/manifest/dash/common/indexes/list.d.ts.map +1 -1
  309. package/dist/es2017/parsers/manifest/dash/common/indexes/list.js +18 -0
  310. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts +10 -0
  311. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts.map +1 -1
  312. package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +12 -0
  313. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts +15 -0
  314. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts.map +1 -1
  315. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +26 -0
  316. package/dist/es2017/parsers/manifest/dash/common/indexes/tokens.js +3 -3
  317. package/dist/es2017/parsers/manifest/dash/common/infer_adaptation_type.d.ts +15 -10
  318. package/dist/es2017/parsers/manifest/dash/common/infer_adaptation_type.d.ts.map +1 -1
  319. package/dist/es2017/parsers/manifest/dash/common/infer_adaptation_type.js +51 -4
  320. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.d.ts +5 -2
  321. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.d.ts.map +1 -1
  322. package/dist/es2017/parsers/manifest/dash/common/parse_adaptation_sets.js +72 -5
  323. package/dist/es2017/parsers/manifest/dash/common/parse_periods.d.ts.map +1 -1
  324. package/dist/es2017/parsers/manifest/dash/common/parse_periods.js +2 -1
  325. package/dist/es2017/parsers/manifest/dash/common/parse_representations.d.ts +1 -0
  326. package/dist/es2017/parsers/manifest/dash/common/parse_representations.d.ts.map +1 -1
  327. package/dist/es2017/parsers/manifest/dash/common/parse_representations.js +19 -1
  328. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.d.ts.map +1 -1
  329. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +8 -0
  330. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts.map +1 -1
  331. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/Representation.d.ts.map +1 -1
  332. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/Representation.js +8 -0
  333. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/utils.d.ts.map +1 -1
  334. package/dist/es2017/parsers/manifest/dash/node_parser_types.d.ts +1 -0
  335. package/dist/es2017/parsers/manifest/dash/node_parser_types.d.ts.map +1 -1
  336. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Representation.d.ts.map +1 -1
  337. package/dist/es2017/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +10 -0
  338. package/dist/es2017/parsers/manifest/local/parse_local_manifest.js +1 -0
  339. package/dist/es2017/parsers/manifest/local/representation_index.d.ts +15 -0
  340. package/dist/es2017/parsers/manifest/local/representation_index.d.ts.map +1 -1
  341. package/dist/es2017/parsers/manifest/local/representation_index.js +20 -0
  342. package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +1 -0
  343. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts +10 -0
  344. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.d.ts.map +1 -1
  345. package/dist/es2017/parsers/manifest/metaplaylist/representation_index.js +9 -0
  346. package/dist/es2017/parsers/manifest/smooth/create_parser.d.ts.map +1 -1
  347. package/dist/es2017/parsers/manifest/smooth/create_parser.js +1 -0
  348. package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts +15 -0
  349. package/dist/es2017/parsers/manifest/smooth/representation_index.d.ts.map +1 -1
  350. package/dist/es2017/parsers/manifest/smooth/representation_index.js +23 -0
  351. package/dist/es2017/parsers/manifest/types.d.ts +61 -0
  352. package/dist/es2017/parsers/manifest/types.d.ts.map +1 -1
  353. package/dist/es2017/parsers/texttracks/ttml/parse_ttml.d.ts +1 -1
  354. package/dist/es2017/parsers/texttracks/ttml/regexps.d.ts.map +1 -1
  355. package/dist/es2017/parsers/texttracks/ttml/regexps.js +1 -1
  356. package/dist/es2017/parsers/texttracks/webvtt/native/set_settings_on_cue.js +1 -1
  357. package/dist/es2017/public_types.d.ts +60 -0
  358. package/dist/es2017/public_types.d.ts.map +1 -1
  359. package/dist/es2017/transports/dash/pipelines.d.ts.map +1 -1
  360. package/dist/es2017/transports/dash/pipelines.js +5 -0
  361. package/dist/es2017/transports/dash/thumbnails.d.ts +21 -0
  362. package/dist/es2017/transports/dash/thumbnails.d.ts.map +1 -0
  363. package/dist/es2017/transports/dash/thumbnails.js +72 -0
  364. package/dist/es2017/transports/local/pipelines.d.ts.map +1 -1
  365. package/dist/es2017/transports/local/pipelines.js +6 -0
  366. package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
  367. package/dist/es2017/transports/metaplaylist/pipelines.js +6 -0
  368. package/dist/es2017/transports/smooth/pipelines.d.ts.map +1 -1
  369. package/dist/es2017/transports/smooth/pipelines.js +6 -0
  370. package/dist/es2017/transports/smooth/segment_loader.d.ts.map +1 -1
  371. package/dist/es2017/transports/types.d.ts +29 -0
  372. package/dist/es2017/transports/types.d.ts.map +1 -1
  373. package/dist/es2017/utils/are_codecs_compatible.js +1 -1
  374. package/dist/es2017/utils/array_find.js +1 -1
  375. package/dist/es2017/utils/array_find_index.js +1 -1
  376. package/dist/es2017/utils/array_includes.js +1 -1
  377. package/dist/es2017/utils/assert.js +1 -1
  378. package/dist/es2017/utils/flat_map.d.ts.map +1 -1
  379. package/dist/es2017/utils/flat_map.js +0 -1
  380. package/dist/es2017/utils/logger.d.ts.map +1 -1
  381. package/dist/es2017/utils/logger.js +0 -2
  382. package/dist/es2017/utils/noop.js +1 -1
  383. package/dist/es2017/utils/object_assign.d.ts.map +1 -1
  384. package/dist/es2017/utils/object_assign.js +3 -4
  385. package/dist/es2017/utils/object_values.js +1 -1
  386. package/dist/es2017/utils/request/xhr.js +1 -1
  387. package/dist/es2017/utils/starts_with.d.ts.map +1 -1
  388. package/dist/es2017/utils/starts_with.js +0 -1
  389. package/dist/es2017/utils/string_parsing.js +1 -1
  390. package/dist/es2017/utils/url-utils.js +2 -2
  391. package/dist/es2017/utils/weak_map_memory.d.ts.map +1 -1
  392. package/dist/es2017/utils/weak_map_memory.js +0 -1
  393. package/dist/rx-player.js +1014 -259
  394. package/dist/rx-player.min.js +18 -18
  395. package/dist/worker.js +8 -8
  396. package/eslint.config.mjs +423 -0
  397. package/package.json +48 -39
  398. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  399. package/src/compat/__tests__/should_wait_for_data_before_loaded.test.ts +0 -1
  400. package/src/compat/add_class_name.ts +1 -4
  401. package/src/compat/browser_compatibility_types.ts +0 -1
  402. package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +0 -2
  403. package/src/compat/eme/eme-api-implementation.ts +0 -1
  404. package/src/compat/eme/generate_key_request.ts +2 -2
  405. package/src/compat/is_vtt_cue.ts +0 -1
  406. package/src/compat/patch_webkit_source_buffer.ts +1 -1
  407. package/src/core/fetchers/index.ts +11 -1
  408. package/src/core/fetchers/segment/segment_queue_creator.ts +4 -6
  409. package/src/core/fetchers/thumbnails/index.ts +8 -0
  410. package/src/core/fetchers/thumbnails/thumbnail_fetcher.ts +233 -0
  411. package/src/core/main/common/get_thumbnail_data.ts +43 -0
  412. package/src/core/main/worker/content_preparer.ts +47 -2
  413. package/src/core/main/worker/worker_main.ts +67 -3
  414. package/src/core/segment_sinks/garbage_collector.ts +4 -0
  415. package/src/core/stream/representation/representation_stream.ts +29 -64
  416. package/src/core/stream/representation/utils/push_init_segment.ts +0 -3
  417. package/src/core/stream/representation/utils/push_media_segment.ts +0 -3
  418. package/src/default_config.ts +30 -1
  419. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/DRMInfos.test.ts +0 -3
  420. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/HDCPPolicy.test.ts +0 -2
  421. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/decodingInfos.test.ts +0 -2
  422. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/defaultCodecFinder.test.ts +1 -1
  423. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaContentType.test.ts +0 -2
  424. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +0 -7
  425. package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +1 -1
  426. package/src/experimental/tools/mediaCapabilitiesProber/capabilities.ts +2 -2
  427. package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +1 -1
  428. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +0 -1
  429. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.ts +0 -1
  430. package/src/index.ts +1 -1
  431. package/src/main_thread/api/public_api.ts +142 -22
  432. package/src/main_thread/decrypt/__tests__/__global__/utils.ts +8 -4
  433. package/src/main_thread/decrypt/__tests__/find_key_system.test.ts +5 -5
  434. package/src/main_thread/decrypt/session_events_listener.ts +9 -8
  435. package/src/main_thread/decrypt/utils/loaded_sessions_store.ts +1 -1
  436. package/src/main_thread/init/directfile_content_initializer.ts +4 -0
  437. package/src/main_thread/init/media_source_content_initializer.ts +35 -3
  438. package/src/main_thread/init/multi_thread_content_initializer.ts +104 -28
  439. package/src/main_thread/init/types.ts +12 -0
  440. package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +326 -0
  441. package/src/main_thread/init/utils/update_manifest_codec_support.ts +13 -3
  442. package/src/main_thread/render_thumbnail.ts +255 -0
  443. package/src/manifest/classes/__tests__/adaptation.test.ts +3 -0
  444. package/src/manifest/classes/__tests__/manifest.test.ts +21 -8
  445. package/src/manifest/classes/__tests__/period.test.ts +50 -12
  446. package/src/manifest/classes/__tests__/representation.test.ts +3 -0
  447. package/src/manifest/classes/__tests__/update_period_in_place.test.ts +388 -0
  448. package/src/manifest/classes/__tests__/update_periods.test.ts +12 -10
  449. package/src/manifest/classes/index.ts +2 -0
  450. package/src/manifest/classes/manifest.ts +1 -1
  451. package/src/manifest/classes/period.ts +86 -1
  452. package/src/manifest/classes/representation.ts +3 -0
  453. package/src/manifest/classes/representation_index/static.ts +18 -0
  454. package/src/manifest/classes/representation_index/types.ts +23 -0
  455. package/src/manifest/classes/update_period_in_place.ts +84 -0
  456. package/src/manifest/index.ts +2 -0
  457. package/src/manifest/types.ts +58 -0
  458. package/src/manifest/utils.ts +36 -0
  459. package/src/minimal.ts +1 -1
  460. package/src/multithread_types.ts +37 -5
  461. package/src/parsers/manifest/dash/common/__tests__/flatten_overlapping_period.test.ts +16 -13
  462. package/src/parsers/manifest/dash/common/convert_supplemental_codecs.ts +1 -1
  463. package/src/parsers/manifest/dash/common/get_hdr_information.ts +17 -0
  464. package/src/parsers/manifest/dash/common/indexes/base.ts +23 -0
  465. package/src/parsers/manifest/dash/common/indexes/list.ts +19 -0
  466. package/src/parsers/manifest/dash/common/indexes/template.ts +16 -0
  467. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +27 -0
  468. package/src/parsers/manifest/dash/common/indexes/tokens.ts +3 -3
  469. package/src/parsers/manifest/dash/common/infer_adaptation_type.ts +75 -8
  470. package/src/parsers/manifest/dash/common/parse_adaptation_sets.ts +95 -12
  471. package/src/parsers/manifest/dash/common/parse_periods.ts +5 -1
  472. package/src/parsers/manifest/dash/common/parse_representations.ts +19 -1
  473. package/src/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.ts +7 -0
  474. package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/AdaptationSet.test.ts +3 -7
  475. package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/ContentComponent.test.ts +1 -1
  476. package/src/parsers/manifest/dash/fast-js-parser/node_parsers/__tests__/ContentProtection.test.ts +1 -1
  477. package/src/parsers/manifest/dash/native-parser/node_parsers/Representation.ts +7 -0
  478. package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/AdaptationSet.test.ts +3 -3
  479. package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/ContentComponent.test.ts +1 -1
  480. package/src/parsers/manifest/dash/native-parser/node_parsers/__tests__/ContentProtection.test.ts +2 -2
  481. package/src/parsers/manifest/dash/node_parser_types.ts +1 -0
  482. package/src/parsers/manifest/dash/wasm-parser/ts/generators/Representation.ts +11 -0
  483. package/src/parsers/manifest/local/parse_local_manifest.ts +1 -0
  484. package/src/parsers/manifest/local/representation_index.ts +21 -0
  485. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +1 -0
  486. package/src/parsers/manifest/metaplaylist/representation_index.ts +10 -0
  487. package/src/parsers/manifest/smooth/create_parser.ts +1 -0
  488. package/src/parsers/manifest/smooth/representation_index.ts +24 -0
  489. package/src/parsers/manifest/types.ts +62 -0
  490. package/src/parsers/manifest/utils/__tests__/get_first_time_from_adaptations.test.ts +3 -0
  491. package/src/parsers/manifest/utils/__tests__/get_last_time_from_adaptation.test.ts +3 -0
  492. package/src/parsers/texttracks/ttml/parse_ttml.ts +1 -1
  493. package/src/parsers/texttracks/ttml/regexps.ts +1 -1
  494. package/src/parsers/texttracks/webvtt/native/set_settings_on_cue.ts +1 -1
  495. package/src/public_types.ts +62 -0
  496. package/src/transports/dash/pipelines.ts +5 -0
  497. package/src/transports/dash/thumbnails.ts +97 -0
  498. package/src/transports/local/pipelines.ts +9 -0
  499. package/src/transports/metaplaylist/pipelines.ts +9 -0
  500. package/src/transports/smooth/pipelines.ts +7 -0
  501. package/src/transports/types.ts +43 -0
  502. package/src/utils/__tests__/are_codecs_compatible.test.ts +21 -1
  503. package/src/utils/__tests__/array_find.test.ts +1 -1
  504. package/src/utils/__tests__/array_find_index.test.ts +0 -1
  505. package/src/utils/__tests__/array_includes.test.ts +1 -1
  506. package/src/utils/__tests__/id_generator.test.ts +0 -2
  507. package/src/utils/are_codecs_compatible.ts +1 -1
  508. package/src/utils/array_find.ts +1 -1
  509. package/src/utils/array_find_index.ts +1 -1
  510. package/src/utils/array_includes.ts +1 -1
  511. package/src/utils/assert.ts +1 -1
  512. package/src/utils/flat_map.ts +0 -1
  513. package/src/utils/logger.ts +0 -2
  514. package/src/utils/noop.ts +1 -1
  515. package/src/utils/object_assign.ts +3 -4
  516. package/src/utils/object_values.ts +1 -1
  517. package/src/utils/request/xhr.ts +2 -2
  518. package/src/utils/starts_with.ts +0 -1
  519. package/src/utils/string_parsing.ts +1 -1
  520. package/src/utils/url-utils.ts +2 -2
  521. package/src/utils/weak_map_memory.ts +0 -1
  522. package/vitest.config.mjs +46 -22
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EMBEDDED_WORKER = void 0;
4
- var blob = new Blob(["(function(){" + "\"use strict\";(()=>{var bu=Object.defineProperty,Su=Object.defineProperties;var yu=Object.getOwnPropertyDescriptors;var Ja=Object.getOwnPropertySymbols;var Tu=Object.prototype.hasOwnProperty,Eu=Object.prototype.propertyIsEnumerable;var eo=(n,e,t)=>e in n?bu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ee=(n,e)=>{for(var t in e||(e={}))Tu.call(e,t)&&eo(n,t,e[t]);if(Ja)for(var t of Ja(e))Eu.call(e,t)&&eo(n,t,e[t]);return n},oe=(n,e)=>Su(n,yu(e));var I={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var to={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,FREEZING_FLUSH_FAILURE_DELAY:{MAXIMUM:2e4,MINIMUM:4e3,POSITION_DELTA:1},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:.001,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/mp4;codecs=\"hvc1.1.6.L93.B0\"','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\"},no=to;function Ru(n,...e){if(n==null)throw new TypeError(\"Cannot convert undefined or null to object\");let t=Object(n);for(let r of e)for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t}var G=typeof Object.assign==\"function\"?Object.assign:Ru;function Jr(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function Xt(n,...e){if(e.length===0)return n;let t=e.shift();if(Jr(n)&&Jr(t))for(let r in t)if(Jr(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),Xt(i,t[r])}else G(n,{[r]:t[r]});return Xt(n,...e)}function v(n){return n==null}var le=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],r!==void 0&&r.register(()=>{this.removeEventListener(e,t)})}removeEventListener(e,t){if(v(e)){this._listeners={};return}let r=this._listeners[e];if(!Array.isArray(r))return;if(v(t)){delete this._listeners[e];return}let i=r.indexOf(t);i!==-1&&r.splice(i,1),r.length===0&&delete this._listeners[e]}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i(t)}catch(a){if(I.CURRENT_ENV===I.DEV)throw a instanceof Error?a:new Error(\"EventEmitter: listener error\");console.error(\"RxPlayer: EventEmitter error\",a instanceof Error?a:null)}})}};var ei=class extends le{constructor(){super(...arguments);this.updated=!1;this._config=no}update(t){let r=Xt(this._config,t);this._config=r,this.updated=!0,this.trigger(\"update\",t)}getCurrent(){return this._config}},Pu=new ei,F=Pu;var je=class n extends Error{constructor(e,t,r){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"CustomLoaderError\",this.canRetry=t,this.xhr=r}};function re(n,e,t){if(typeof Array.prototype.findIndex==\"function\")return n.findIndex(e,t);let r=n.length>>>0;for(let i=0;i<r;i++)if(e.call(t,n[i],i,n))return i;return-1}function D(){}var sr=class{constructor(e,t){this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],t!==void 0&&(this._deregisterCancellation=t.register(()=>this.finish()))}getValue(){return this._value}setValue(e){if(this._isFinished){I.CURRENT_ENV===I.DEV&&console.error(\"Finished shared references cannot be updated\");return}if(this._value=e,this._listeners.length===0)return;let t=this._listeners.slice();for(let r of t)try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(i){}}setValueIfChanged(e){e!==this._value&&this.setValue(e)}onUpdate(e,t){let r=()=>{if(t.clearSignal!==void 0&&t.clearSignal.deregister(r),i.hasBeenCleared)return;i.hasBeenCleared=!0;let a=this._listeners.indexOf(i);a>=0&&this._listeners.splice(a,1)},i={trigger:e,complete:r,hasBeenCleared:!1};if(this._listeners.push(i),t.emitCurrentValue===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return D;let r=()=>{let o=re(this._onFinishCbs,s=>s.trigger===i);o>=0&&(this._onFinishCbs[o].hasBeenCleared=!0,this._onFinishCbs.splice(o,1))},i=()=>{r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a}finish(){this._deregisterCancellation!==void 0&&this._deregisterCancellation(),this._isFinished=!0;let e=this._listeners.slice();for(let t of e)try{t.hasBeenCleared||(t.complete(),t.hasBeenCleared=!0)}catch(r){}if(this._listeners.length=0,this._onFinishCbs.length>0){let t=this._onFinishCbs.slice();for(let r of t)try{r.hasBeenCleared||(r.trigger(),r.hasBeenCleared=!0)}catch(i){}this._onFinishCbs.length=0}}};function Zt(n,e,t){let r=new sr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var j=sr;var ti=new j(0);function ro({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;ti.setValueIfChanged(r-t)}var vu=typeof performance!=\"undefined\"?()=>performance.now()+ti.getValue():()=>Date.now()+ti.getValue(),L=vu;var Cu=\"NONE\",Jt=class extends le{constructor(){super(),this.error=D,this.warn=D,this.info=D,this.debug=D,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentFormat=\"standard\",this._currentLevel=Cu}setLevel(e,t,r){let i,a=this._levels[e];typeof a==\"number\"?(i=a,this._currentLevel=e):(i=0,this._currentLevel=\"NONE\");let o;if(t===\"standard\"||t===\"full\"?o=t:o=\"standard\",o===\"full\"&&o!==this._currentFormat){let u=L();console.log(String(u.toFixed(2)),\"[Init]\",`Local-Date: ${Date.now()}`)}this._currentFormat=o;let s=this._currentFormat===\"full\"?(u,d)=>(...f)=>{let l=L();return d(String(l.toFixed(2)),`[${u}]`,...f)}:(u,d)=>d;if(r===void 0)this.error=i>=this._levels.ERROR?s(\"error\",console.error.bind(console)):D,this.warn=i>=this._levels.WARNING?s(\"warn\",console.warn.bind(console)):D,this.info=i>=this._levels.INFO?s(\"info\",console.info.bind(console)):D,this.debug=i>=this._levels.DEBUG?s(\"log\",console.log.bind(console)):D;else{let u=d=>i>=this._levels[d]?(...f)=>r(d,f):D;this.error=u(\"ERROR\"),this.warn=u(\"WARNING\"),this.info=u(\"INFO\"),this.debug=u(\"DEBUG\")}this.trigger(\"onLogLevelChange\",{level:this._currentLevel,format:this._currentFormat})}getLevel(){return this._currentLevel}getFormat(){return this._currentFormat}hasLevel(e){return this._levels[e]>=this._levels[this._currentLevel]}};var Au=new Jt,m=Au;var wt=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var ku=typeof window==\"undefined\"&&!wt,ur=ku;var dr;wt?dr=self:ur?dr=global:dr=window;var ae=dr;var se=class n extends Error{constructor(e,t,r){let i;switch(r){case\"TIMEOUT\":i=\"The request timed out\";break;case\"ERROR_EVENT\":i=\"An error prevented the request to be performed successfully\";break;case\"PARSE_ERROR\":i=\"An error happened while formatting the response data\";break;case\"ERROR_HTTP_CODE\":i=\"An HTTP status code indicating failure was received: \"+String(t);break}super(i),Object.setPrototypeOf(this,n.prototype),this.name=\"RequestError\",this.url=e,this.status=t,this.type=r}serialize(){return{url:this.url,status:this.status,type:this.type}}},Ee={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var ni=typeof Headers==\"function\"?Headers:null,ri=typeof AbortController==\"function\"?AbortController:null;function lr(n){var c,g;let e;if(!v(n.headers))if(v(ni))e=n.headers;else{e=new ni;let p=Object.keys(n.headers);for(let h=0;h<p.length;h++){let b=p[h];e.append(b,n.headers[b])}}m.debug(\"Fetch: Called with URL\",n.url);let t=null,r=!1,i=!1,a=L(),o=v(ri)?null:new ri;function s(){if(v(o)){m.warn(\"Fetch: AbortController API not available.\");return}o.abort()}let u;n.timeout!==void 0&&(u=setTimeout(()=>{r=!0,d!==void 0&&clearTimeout(d),s()},n.timeout));let d;n.connectionTimeout!==void 0&&(d=setTimeout(()=>{i=!0,u!==void 0&&clearTimeout(u),s()},n.connectionTimeout));let f=n.cancelSignal.register(function(h){t=h,s()}),l={method:\"GET\"};if(e!==void 0&&(l.headers=e),l.signal=v(o)?null:o.signal,m.hasLevel(\"DEBUG\")){let p=\"FETCH: Sending GET \"+n.url;n.timeout!==void 0&&(p+=\" to=\"+String(n.timeout/1e3)),n.connectionTimeout!==void 0&&(p+=\" cto=\"+String(n.connectionTimeout/1e3)),((c=n.headers)==null?void 0:c.Range)!==void 0&&(p+=\" Range=\"+((g=n.headers)==null?void 0:g.Range)),m.debug(p)}return fetch(n.url,l).then(p=>{if(d!==void 0&&clearTimeout(d),p.status>=300)throw m.warn(\"Fetch: Request HTTP Error\",p.status,p.url),new se(p.url,p.status,Ee.ERROR_HTTP_CODE);if(v(p.body))throw new se(p.url,p.status,Ee.PARSE_ERROR);let h=p.headers.get(\"Content-Length\"),b=!v(h)&&!isNaN(+h)?+h:void 0,y=p.body.getReader(),T=0;return P();async function P(){let E=await y.read();if(!E.done&&!v(E.value)){T+=E.value.byteLength;let C=L(),_={url:p.url,currentTime:C,duration:C-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:T,totalSize:b};return n.onData(_),P()}else if(E.done){u!==void 0&&clearTimeout(u),f();let C=L();return{requestDuration:C-a,receivedTime:C,sendingTime:a,size:T,status:p.status,url:p.url}}return P()}}).catch(p=>{throw t!==null?t:(f(),r?(m.warn(\"Fetch: Request timed out.\"),new se(n.url,0,Ee.TIMEOUT)):i?(m.warn(\"Fetch: Request connection timed out.\"),new se(n.url,0,Ee.TIMEOUT)):p instanceof se?p:(m.warn(\"Fetch: Request Error\",p instanceof Error?p.toString():\"\"),new se(n.url,0,Ee.ERROR_EVENT)))})}function en(){return typeof ae.fetch==\"function\"&&!v(ri)&&!v(ni)}function K(n){return typeof n==\"string\"&&n.length>0}var xu=\"json\";function ii(n){let e={url:n.url,headers:n.headers,responseType:v(n.responseType)?xu:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:u,timeout:d,connectionTimeout:f}=e,l=new XMLHttpRequest;l.open(\"GET\",o,!0);let c;d!==void 0&&(l.timeout=d,c=setTimeout(()=>{b(),r(new se(o,l.status,Ee.TIMEOUT))},d+3e3));let g;if(f!==void 0&&(g=setTimeout(()=>{b(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new se(o,l.status,Ee.TIMEOUT))},f)),l.responseType=u,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!v(s)){let y=s;for(let T in y)y.hasOwnProperty(T)&&l.setRequestHeader(T,y[T])}let p=L(),h=null;if(a!==void 0&&(h=a.register(function(T){b(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(T)}),a.isCancelled()))return;if(l.onerror=function(){b(),r(new se(o,l.status,Ee.ERROR_EVENT))},l.ontimeout=function(){b(),r(new se(o,l.status,Ee.TIMEOUT))},f!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(g)}),i!==void 0&&(l.onprogress=function(T){let P=L();i({url:o,duration:P-p,sendingTime:p,currentTime:P,size:T.loaded,totalSize:T.total})}),l.onload=function(T){if(l.readyState===XMLHttpRequest.DONE)if(b(),l.status>=200&&l.status<300){let P=L(),E=l.response instanceof ArrayBuffer?l.response.byteLength:T.total,C=l.status,_=l.responseType,O=K(l.responseURL)?l.responseURL:o,k;if(_===\"json\"?k=typeof l.response==\"object\"?l.response:Mu(l.responseText):k=l.response,v(k)){r(new se(o,l.status,Ee.PARSE_ERROR));return}t({status:C,url:O,responseType:_,sendingTime:p,receivedTime:P,requestDuration:P-p,size:E,responseData:k})}else r(new se(o,l.status,Ee.ERROR_HTTP_CODE))},m.hasLevel(\"DEBUG\")){let y=\"XHR: Sending GET \"+o;n.responseType!==void 0&&(y+=\" type=\"+n.responseType),d!==void 0&&(y+=\" to=\"+String(d/1e3)),f!==void 0&&(y+=\" cto=\"+String(f/1e3)),(s==null?void 0:s.Range)!==void 0&&(y+=\" Range=\"+(s==null?void 0:s.Range)),m.debug(y)}l.send();function b(){c!==void 0&&clearTimeout(c),g!==void 0&&clearTimeout(g),h!==null&&h()}})}function Mu(n){try{return JSON.parse(n)}catch(e){return null}}var he=ii;var yt=Ee,ze={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function Ze(n,e){return`${n}: ${e}`}var tn=class n extends Error{constructor(e,t,r){super(Ze(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=ze.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.fatal=!1,typeof(r==null?void 0:r.keyStatuses)==\"string\"&&(this.keyStatuses=r.keyStatuses)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}}};var X=class n extends Error{constructor(e,t,r){super(Ze(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=ze.MEDIA_ERROR,this._originalMessage=t,this.code=e,this.fatal=!1,(r==null?void 0:r.tracks)!==void 0&&(r==null?void 0:r.tracks.length)>0&&(this.tracksInfo=r.tracks)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var Ye=class n extends Error{constructor(e,t){super(Ze(e,t.message)),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=ze.NETWORK_ERROR,this.url=t.url,this.status=t.status,this.errorType=t.type,this._baseError=t,this.code=e,this.fatal=!1}isHttpError(e){return this.errorType===yt.ERROR_HTTP_CODE&&this.status===e}serialize(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var Se=class n extends Error{constructor(e,t){super(Ze(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=ze.OTHER_ERROR,this.code=e,this.fatal=!1,this._originalMessage=t}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage}}};function Dt(n){return(n instanceof tn||n instanceof X||n instanceof Se||n instanceof Ye)&&Object.keys(ze).indexOf(n.type)>=0}function ye(n,{defaultCode:e,defaultReason:t}){if(Dt(n))return n;let r=n instanceof Error?n.toString():t;return new Se(e,r)}var Ce=class n extends Error{constructor(e,t,r){super(t),Object.setPrototypeOf(this,n.prototype),this.name=\"SourceBufferError\",this.errorName=e,this.isBufferFull=r}serialize(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}}toString(){return`${this.errorName}: ${this.message}`}};var Ou={dashParsers:{wasm:null,native:null,fastJs:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},io=Ou;var we=io;function Q(n,e,t){if(typeof Array.prototype.find==\"function\")return n.find(e,t);let r=n.length>>>0;for(let i=0;i<r;i++){let a=n[i];if(e.call(t,a,i,n))return a}}var wu={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\"},ao=wu;var Du={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\"},oo=Du;function Nu(n){if(v(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=Bu(t);return K(r)?r:n}function Bu(n){let e;switch(n.length){case 2:e=ao[n];break;case 3:e=oo[n];break}return e}var so=Nu;var uo=so;function fr(n,e){if(n.length!==e.length)return!1;if(n===e)return!0;for(let t=n.length-1;t>=0;t--)if(n[t]!==e[t])return!1;return!0}function ai(n){return Object.keys(n).map(e=>n[e])}var cr=typeof Object.values==\"function\"?Object.values:ai;var Nt=[\"audio\",\"video\",\"text\"];function fo(n){var a,o;let e=n.timeBounds;if(e.timeshiftDepth===null)return(a=e.minimumSafePosition)!=null?a:0;let{maximumTimeData:t}=e,r;if(!e.maximumTimeData.isLinear)r=t.maximumSafePosition;else{let s=L()-t.time;r=t.maximumSafePosition+s/1e3}let i=r-e.timeshiftDepth;return Math.max((o=e.minimumSafePosition)!=null?o:0,i)}function co(n){let{maximumTimeData:e}=n.timeBounds;if(!n.isLive||e.livePosition===void 0)return;if(!e.isLinear)return e.livePosition;let t=L()-e.time;return e.livePosition+t/1e3}function mo(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=L()-e.time;return e.maximumSafePosition+t/1e3}function po(n,e){if(e===void 0)return si(n).filter(r=>r.supportStatus.hasSupportedCodec!==!1&&r.supportStatus.isDecipherable!==!1);let t=n.adaptations[e];return t===void 0?[]:t.filter(r=>r.supportStatus.hasSupportedCodec!==!1&&r.supportStatus.isDecipherable!==!1)}function go(n,e){let t=null;for(let r of n.periods){if(oi(r,e,t))return r;t=r}}function ho(n,e){let t=e.end;if(t===void 0)return null;let r=Q(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function oi(n,e,t){return e>=n.start&&(n.end===void 0||e<n.end)?!0:e===n.end&&(t===null||t.start>n.end)}function si(n){let e=n.adaptations;return ai(e).reduce((t,r)=>v(r)?t:t.concat(r),[])}function Uu(n,e){var r,i;let t={language:(r=n.language)!=null?r:\"\",normalized:(i=n.normalizedLanguage)!=null?i:\"\",audioDescription:n.isAudioDescription===!0,id:n.id,representations:(e?n.representations.filter(a=>nn(a)===!0):n.representations).map(zu),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function Lu(n){var e,t;return{language:(e=n.language)!=null?e:\"\",normalized:(t=n.normalizedLanguage)!=null?t:\"\",closedCaption:n.isClosedCaption===!0,id:n.id,label:n.label,forced:n.isForcedSubtitles}}function Fu(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>nn(s)===!0):i.representations).map(lo),o={id:i.id,representations:a,isTrickModeTrack:!0};return i.isSignInterpreted===!0&&(o.signInterpreted=!0),o}):void 0,r={id:n.id,representations:(e?n.representations.filter(i=>nn(i)===!0):n.representations).map(lo),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function zu(n){let{id:e,bitrate:t,codecs:r,isSpatialAudio:i,isSupported:a,decipherable:o}=n;return{id:e,bitrate:t,codec:r==null?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function lo(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:u,decipherable:d,contentProtections:f}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:d,contentProtections:f!==void 0?{keyIds:f.keyIds}:void 0}}function lt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:Uu(n,!1)};case\"video\":return{type:\"video\",track:Fu(n,!1)};case\"text\":return{type:\"text\",track:Lu(n)}}}function nn(n){return n.decipherable===!1?!1:n.isSupported}function Io(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}function Ae(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var Wu=Ae(),ui=class{constructor(e,t,r){var a,o,s,u,d;this.id=e.id,this.uniqueId=Wu(),this.shouldBeAvoided=!1,this.bitrate=e.bitrate,this.codecs=[],this.trackType=t,e.isSpatialAudio!==void 0&&(this.isSpatialAudio=e.isSpatialAudio),e.height!==void 0&&(this.height=e.height),e.width!==void 0&&(this.width=e.width),e.mimeType!==void 0&&(this.mimeType=e.mimeType),e.contentProtections!==void 0&&(this.contentProtections=e.contentProtections),e.frameRate!==void 0&&(this.frameRate=e.frameRate),e.hdrInfo!==void 0&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index;let i=this.contentProtections!==void 0;if(t===\"audio\"||t===\"video\"){if(e.supplementalCodecs!==void 0){let f=r.isSupported((a=this.mimeType)!=null?a:\"\",(o=e.supplementalCodecs)!=null?o:\"\",i);f!==!1&&(this.codecs=[e.supplementalCodecs],this.isSupported=f)}this.isSupported!==!0&&(this.codecs.length>0?this.codecs.push((s=e.codecs)!=null?s:\"\"):(this.codecs=e.codecs===void 0?[]:[e.codecs],this.isSupported=r.isSupported((u=this.mimeType)!=null?u:\"\",(d=e.codecs)!=null?d:\"\",i)))}else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var s,u;if(this.isSupported!==void 0)return;let t=this.contentProtections!==void 0,r=!1,i=(s=this.mimeType)!=null?s:\"\",a=(u=this.codecs)!=null?u:[];a.length===0&&(a=[\"\"]);let o=!1;for(let d of a){if(r=e.isSupported(i,d,t),r===!0){this.codecs=[d];break}r===void 0&&(o=!0)}r===!0?this.isSupported=!0:o?this.isSupported=void 0:this.isSupported=!1}getMimeTypeString(){var e,t,r;return`${(e=this.mimeType)!=null?e:\"\"};codecs=\"${(r=(t=this.codecs)==null?void 0:t[0])!=null?r:\"\"}\"`}getEncryptionData(e){var i;let t=this.getAllEncryptionData(),r=[];for(let a=0;a<t.length;a++){let o=!1,s=t[a];for(let u=0;u<s.values.length;u++)if(s.values[u].systemId.toLowerCase()===e.toLowerCase())if(o)r[r.length-1].values.push(s.values[u]);else{let d=(i=this.contentProtections)==null?void 0:i.keyIds;r.push({type:s.type,keyIds:d,values:[s.values[u]]}),o=!0}}return r}getAllEncryptionData(){var t;if(this.contentProtections===void 0||this.contentProtections.initData.length===0)return[];let e=(t=this.contentProtections)==null?void 0:t.keyIds;return this.contentProtections.initData.map(r=>({type:r.type,keyIds:e,values:r.values}))}addProtectionData(e,t,r){let i=!1;if(this.contentProtections===void 0)return this.contentProtections={keyIds:t!==void 0?[t]:[],initData:[{type:e,values:r}]},!0;if(t!==void 0){let o=this.contentProtections.keyIds;if(o===void 0)this.contentProtections.keyIds=[t];else{let s=!1;for(let u of o)fr(u,t)&&(s=!0);s||(m.warn(\"Manifest: found unanounced key id.\"),o.push(t))}}let a=this.contentProtections.initData;for(let o=0;o<a.length;o++)if(a[o].type===e){let s=a[o].values;for(let u=0;u<r.length;u++){let d=r[u],f;for(f=0;f<s.length;f++)if(d.systemId===s[f].systemId){if(fr(d.data,s[f].data))break;m.warn(\"Manifest: different init data for the same system ID\")}f===s.length&&(s.push(d),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}isPlayable(){return nn(this)}getMetadataSnapshot(){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}}},rn=ui;var ft=class n{constructor(e,t,r={}){let{trickModeTracks:i}=e,{representationFilter:a,isManuallyAdded:o}=r;this.id=e.id,this.type=e.type,e.isTrickModeTrack!==void 0&&(this.isTrickModeTrack=e.isTrickModeTrack),e.language!==void 0&&(this.language=e.language,this.normalizedLanguage=uo(e.language)),e.closedCaption!==void 0&&(this.isClosedCaption=e.closedCaption),e.audioDescription!==void 0&&(this.isAudioDescription=e.audioDescription),e.isDub!==void 0&&(this.isDub=e.isDub),e.forcedSubtitles!==void 0&&(this.isForcedSubtitles=e.forcedSubtitles),e.isSignInterpreted!==void 0&&(this.isSignInterpreted=e.isSignInterpreted),e.label!==void 0&&(this.label=e.label),i!==void 0&&i.length>0&&(this.trickModeTracks=i.map(d=>new n(d,t)));let s=e.representations,u=[];this.supportStatus={hasSupportedCodec:!1,hasCodecWithUndefinedSupport:!1,isDecipherable:!1};for(let d=0;d<s.length;d++){let f=new rn(s[d],this.type,t),l=!0;if(!v(a)){let c={id:f.id,bitrate:f.bitrate,codecs:f.codecs,height:f.height,width:f.width,frameRate:f.frameRate,hdrInfo:f.hdrInfo};if(f.contentProtections!==void 0&&(c.contentProtections={},f.contentProtections.keyIds!==void 0)){let g=f.contentProtections.keyIds;c.contentProtections.keyIds=g}l=a(c,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}l?(u.push(f),f.isSupported===void 0?(this.supportStatus.hasCodecWithUndefinedSupport=!0,this.supportStatus.hasSupportedCodec===!1&&(this.supportStatus.hasSupportedCodec=void 0)):f.isSupported&&(this.supportStatus.hasSupportedCodec=!0),f.decipherable===void 0?this.supportStatus.isDecipherable===!1&&(this.supportStatus.isDecipherable=void 0):f.decipherable&&(this.supportStatus.isDecipherable=!0)):m.debug(\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${f.id}`,`(${f.bitrate})`)}u.sort((d,f)=>d.bitrate-f.bitrate),this.representations=u,this.manuallyAdded=o===!0}refreshCodecSupport(e){let t=!1,r=!1;for(let i of this.representations)i.refreshCodecSupport(e),i.isSupported===void 0?t=!0:i.isSupported&&(r=!0);r?this.supportStatus.hasSupportedCodec=!0:t?this.supportStatus.hasSupportedCodec=void 0:this.supportStatus.hasSupportedCodec=!1,this.supportStatus.hasCodecWithUndefinedSupport=t}getRepresentation(e){return Q(this.representations,({id:t})=>e===t)}getMetadataSnapshot(){let e=[],t=this.representations;for(let r of t)e.push(r.getMetadataSnapshot());return{id:this.id,type:this.type,supportStatus:this.supportStatus,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:e,label:this.label,isDub:this.isDub}}};var Ie=ae,bo,So,yo,To,Eo,an=(Eo=(To=(yo=(So=(bo=Ie==null?void 0:Ie.MediaSource)!=null?bo:Ie==null?void 0:Ie.MozMediaSource)!=null?So:Ie==null?void 0:Ie.WebKitMediaSource)!=null?yo:Ie==null?void 0:Ie.MSMediaSource)!=null?To:Ie==null?void 0:Ie.ManagedMediaSource)!=null?Eo:void 0,qg=an!==void 0&&an===(Ie==null?void 0:Ie.ManagedMediaSource);var Vu=!1,qu=!1,_o=!1,Hu=!1,Gu=!1,Ku=!1,ju=!1,Yu=!1,Qu=!1,$u=!1,Xu=!1,Zu=!1,Ju=!1,ed=!1,di=!1,td=!1,nd=!1;(function(){var e,t,r;ur||(typeof ae.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?(qu=!0,_o=!0):navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?_o=!0:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?Vu=!0:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?Hu=!0:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?Ku=!0:(Object.prototype.toString.call(ae.HTMLElement).indexOf(\"Constructor\")>=0||((t=(e=ae.safari)==null?void 0:e.pushNotification)==null?void 0:t.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((r=navigator.vendor)==null?void 0:r.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(Gu=!0),/SamsungBrowser/.test(navigator.userAgent)&&(ju=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?ed=!0:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?di=!0:/Tizen/.test(navigator.userAgent)?Yu=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(Qu=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?Xu=!0:(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent))&&($u=!0)):navigator.userAgent.indexOf(\"NETTV\")!==-1&&navigator.userAgent.indexOf(\"Philips\")!==-1?Ju=!0:/[Pp]anasonic/.test(navigator.userAgent)?Zu=!0:navigator.userAgent.indexOf(\"Xbox\")!==-1?td=!0:navigator.userAgent.indexOf(\"Model/a1-kstb40xx\")!==-1&&(nd=!0))})();function li(n){return new Promise(e=>{setTimeout(e,n)})}function Et(n,e){let t;return new Promise((r,i)=>{if(n.cancellationError!==null)return i(n.cancellationError);let a=!1;t=e(function(u){n.deregister(o),a=!0,r(u)},function(u){n.deregister(o),a=!0,i(u)}),a||n.register(o);function o(s){t!==void 0&&t(),i(s)}})}function on(n,e){return Et(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var mr=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\"}};function ce(n,e){if(I.DEV===I.CURRENT_ENV&&!n)throw new mr(e===void 0?\"invalid assertion\":e)}function Ne(n){throw new mr(\"Unreachable path taken\")}var W=class{constructor(){let[e,t]=rd();this._isUsed=!1,this._trigger=e,this.signal=new fi(t)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(()=>{this.cancel()});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=e!=null?e:new ue;this._trigger(t)}static isCancellationError(e){return e instanceof ue}},fi=class{constructor(e){this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e(t=>{for(this.cancellationError=t,this._isCancelled=!0;this._listeners.length>0;)try{let r=this._listeners.pop();r==null||r(t)}catch(r){m.error(\"Error while calling clean up listener\",r instanceof Error?r.toString():\"Unknown error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(ce(this.cancellationError!==null),e(this.cancellationError),D):(this._listeners.push(e),()=>this.deregister(e))}deregister(e){for(let t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)}},ue=class n extends Error{constructor(){super(\"This task was cancelled.\"),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\"}};function rd(){let n=D;return[function(t){n(t)},function(t){n=t}]}var id=[\"\",\"webkit\",\"moz\",\"ms\"];function ad(n,e){let t=document.createElement(n.tagName),r=\"on\"+e;return r in t?!0:(t.setAttribute(r,\"return;\"),typeof t[r]==\"function\")}function od(n,e){return e.filter(t=>ad(n,t))[0]}function sd(n,e){return n.reduce((t,r)=>t.concat((e===void 0?id:e).map(i=>i+r)),[])}function _e(n,e){let t,r=sd(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=od(i,r)),K(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{I.CURRENT_ENV===I.DEV&&m.warn(`compat: element ${i.tagName} does not support any of these events: `+r.join(\", \"));return}r.forEach(s=>{let u=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(u=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),u&&delete i[\"on\"+s]})})}}}var Sh=_e([\"loadedmetadata\"]),yh=_e([\"timeupdate\"]),Th=_e([\"addtrack\"]),Eh=_e([\"removetrack\"]),Bt=_e([\"sourceopen\",\"webkitsourceopen\"]),pr=_e([\"sourceclose\",\"webkitsourceclose\"]),gr=_e([\"sourceended\",\"webkitsourceended\"]),Ro=_e([\"update\"]),Po=_e([\"removesourcebuffer\"]),_h=_e([\"keymessage\",\"message\"]),Rh=_e([\"keyadded\",\"ready\"]),Ph=_e([\"keyerror\",\"error\"]),vh=_e([\"keystatuseschange\"]),Ch=_e([\"seeking\"]),Ah=_e([\"seeked\"]),kh=_e([\"ended\"]);var vo=[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 hr(n){if(n>=vo.length)throw new Error(\"Unable to parse base64 string.\");let e=vo[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function Ir(n){let e=n.length%4,t=n;e!==0&&(m.warn(\"base64ToBytes: base64 given miss padding\"),t+=e===3?\"=\":e===2?\"==\":\"===\");let r=t.indexOf(\"=\");if(r!==-1&&r<t.length-2)throw new Error(\"Unable to parse base64 string.\");let i=t.endsWith(\"==\")?2:t.endsWith(\"=\")?1:0,a=t.length,o=new Uint8Array(a/4*3),s;for(let u=0,d=0;u<a;u+=4,d+=3)s=hr(t.charCodeAt(u))<<18|hr(t.charCodeAt(u+1))<<12|hr(t.charCodeAt(u+2))<<6|hr(t.charCodeAt(u+3)),o[d]=s>>16,o[d+1]=s>>8&255,o[d+2]=s&255;return o.subarray(0,o.length-i)}var ud=typeof ae==\"object\"&&typeof ae.TextDecoder==\"function\",dd=typeof ae==\"object\"&&typeof ae.TextEncoder==\"function\";function sn(n){if(dd)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"\";m.warn(\"Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation\",a)}let e,t=encodeURIComponent(n);if(typeof unescape==\"function\")e=unescape(t);else{let i=/[0-9a-fA-F]/,a=t.length;e=\"\";for(let o=0;o<t.length;o++){let s=!1;if(t[o]===\"%\"){if(o<=a-6&&t[o+1]===\"u\"&&i.test(t[o+2])&&i.test(t[o+3])&&i.test(t[o+4])&&i.test(t[o+5])){let u=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let u=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(u),s=!0,o+=2}}s||(e+=t[o])}}let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i)&255;return r}function ld(n){let t=\"\";for(let r=0;r<n.length;r+=16e3){let i=n.subarray(r,r+16e3);t+=String.fromCharCode.apply(null,i)}return t}function Co(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Be(n){if(ud)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"\";m.warn(\"Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation\",a)}let e=n;e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let t=ld(e),r;if(typeof escape==\"function\")r=escape(t);else{let i=/[A-Za-z0-9*_\\+-\\.\\/]/;r=\"\";for(let a=0;a<t.length;a++)if(i.test(t[a]))r+=t[a];else{let o=t.charCodeAt(a);r+=o>=256?\"%u\"+Co(o,4):\"%\"+Co(o,2)}}return decodeURIComponent(r)}function un(n){let e=n.length,t=new Uint8Array(e/2);for(let r=0,i=0;r<e;r+=2,i++)t[i]=parseInt(n.substring(r,r+2),16)&255;return t}function Ao(n,e=\"\"){let t=\"\";for(let r=0;r<n.byteLength;r++)t+=(n[r]>>>4).toString(16),t+=(n[r]&15).toString(16),e.length>0&&r<n.byteLength-1&&(t+=e);return t}function ci(n,e){let t=e;for(;t<n.length&&n[t]!==0;)t+=1;let r=n.subarray(e,t);return{end:t+1,string:Be(r)}}function We(n,e,t){if(typeof String.prototype.startsWith==\"function\")return n.startsWith(e,t);let r=typeof t==\"number\"?Math.max(t,0):0;return n.substring(r,r+e.length)===e}function _t(...n){let e=n.length,t=-1,r=0,i;for(;++t<e;)i=n[t],r+=typeof i==\"number\"?i:i.length;let a=new Uint8Array(r),o=0;for(t=-1;++t<e;)i=n[t],typeof i==\"number\"?o+=i:i.length>0&&(a.set(i,o),o+=i.length);return a}function ko(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function mi(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function te(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function ct(n,e){return(n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3])*4294967296+n[e+4]*16777216+n[e+5]*65536+n[e+6]*256+n[e+7]}function Qe(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=te(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=ct(n,r+8)}if(isNaN(i)||i<=0)return-1;if(te(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function br(n){let e=0,t=[],r=null;for(;e<=n.length;){if(e===n.length){r=null;break}r=n.subarray(e,1/0);let i=Qe(r,1836019558);if(i<0)break;let a=te(n,i+e),o=e+i+a;if(o>n.length)break;let s=Qe(r,1835295092);if(s<0)break;let u=te(n,s+e),d=e+s+u;if(d>n.length)break;let f=Math.max(o,d),l=n.subarray(e,f);t.push(l),e=f}return t.length===0?[null,r]:[t,r]}function fd(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function cd(n,e,t){return n.slice(e,t)}var pi=typeof Uint8Array.prototype.slice==\"function\"?cd:fd;function gi(n,e){let t=n;for(let r of e){let i=pe(t,r);if(i===null)return null;t=i}return t}function pe(n,e){let t=Ut(n,e);return t!==null?n.subarray(t[1],t[2]):null}function xo(n,e){let t=[],r=n;for(;;){let i=Ut(r,e);if(i===null)return t;ce(i[2]!==0&&r.length!==0),t.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}function Ut(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=te(n,o),o+=4,i=te(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=ct(n,o),o+=8}if(a<0)throw new Error(\"ISOBMFF: Size out of range\");if(i===e)return e===1970628964&&(o+=16),[r,o,r+a];r+=a}return null}function Sr(n){let e=0,t=pe(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=Ut(t,1886614376)}catch(s){let u=s instanceof Error?s:\"\";return m.warn(\"Error while removing PSSH from ISOBMFF\",u),r}if(i===null)return r;let a=pi(t,i[0],i[2]),o=Mo(a,i[1]-i[0]);o!==void 0&&r.push({systemId:o,data:a}),t[i[0]+4]=102,t[i[0]+5]=114,t[i[0]+6]=101,t[i[0]+7]=101,e=i[2]}return r}function Mo(n,e){if(n[e]>1){m.warn(\"ISOBMFF: un-handled PSSH version\");return}let t=e+4;if(t+16>n.length)return;let r=pi(n,t,t+16);return Ao(r)}function hi(n){let e=pe(n,1836019558);return e===null?null:pe(e,1953653094)}function Oo(n){return xo(n,1836019558).reduce((t,r)=>{let i=pe(r,1953653094);return i!==null&&t.push(i),t},[])}function Ii(n){return pe(n,1835295092)}function bi(n){let e=pe(n,1836019574);if(e===null)return null;let t=pe(e,1953653099);return t===null?null:pe(t,1835297121)}function wo(n,e=0){return pe(n.subarray(e),1701671783)}function dn(n,e){let t=Ut(n,1936286840);if(t===null)return null;let r=e,i=t[2]-t[0],a=t[1],o=n[a];a+=8;let s=te(n,a);a+=4;let u;if(o===0)u=te(n,a),a+=4,r+=te(n,a)+i,a+=4;else if(o===1)u=ct(n,a),a+=8,r+=ct(n,a)+i,a+=8;else return null;let d=[];a+=2;let f=ko(n,a);for(a+=2;--f>=0;){let l=te(n,a);a+=4;let c=(l&2147483648)>>>31,g=l&2147483647;if(c===1)throw new Error(\"sidx with reference_type `1` not yet implemented\");let p=te(n,a);a+=4,a+=4,d.push({time:u,duration:p,timescale:s,range:[r,r+g-1]}),u+=p,r+=g}return d}function Si(n){let e=hi(n);if(e===null)return;let t=pe(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return ct(t,4);if(r===0)return te(t,4)}function md(n){let e=pe(n,1952868452);if(e===null)return;let t=1,r=mi(e,t);t+=3;let i=(r&1)>0,a=(r&2)>0;return(r&8)>0?(t+=4,i&&(t+=8),a&&(t+=4),te(e,t)):void 0}function yi(n){let e=Oo(n);if(e.length===0)return;let t=0;for(let r of e){let i=pe(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=mi(i,a);a+=3;let u=(s&256)>0,d=0;if(!u&&(d=md(r),d===void 0))return;let f=(s&1)>0,l=(s&4)>0,c=(s&512)>0,g=(s&1024)>0,p=(s&2048)>0,h=te(i,a);a+=4,f&&(a+=4),l&&(a+=4);let b=h,y=0;for(;b-- >0;)u?(y+=te(i,a),a+=4):y+=d,c&&(a+=4),g&&(a+=4),p&&(a+=4);t+=y}return t}function ln(n){let e=bi(n);if(e===null)return;let t=pe(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return te(t,r+16);if(i===0)return te(t,r+8)}function Do(n){let e=[],t=0;for(;t<n.length;){let r=wo(n,t);if(r===null)break;let i=r.length;t+=i;let a=r[0];if(a!==0)m.warn(\"ISOBMFF: EMSG version \"+a.toString()+\" not supported.\");else{let o=4,{end:s,string:u}=ci(r,o);o=s;let{end:d,string:f}=ci(r,o);o=d;let l=te(r,o);o+=4;let c=te(r,o);o+=4;let g=te(r,o);o+=4;let p=te(r,o);o+=4;let h=r.subarray(o,i),b={schemeIdUri:u,value:f,timescale:l,presentationTimeDelta:c,eventDuration:g,id:p,messageData:h};e.push(b)}}if(e.length!==0)return e}function No(n){let e=gi(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=pe(t,1701733238),i=0;if(r===null?(i=28,r=pe(t,1701733217)):i=78,r===null)return null;let a=gi(r.subarray(i),[1936289382,1935894633,1952804451]);if(a===null||a.byteLength<24)return null;let o=a.subarray(8,24);return o.every(s=>s===0)?null:o}function ge(n,e,t){if(typeof Array.prototype.includes==\"function\")return n.includes(e,t);let r=n.length>>>0;if(r===0)return!1;let i=t|0,a=i>=0?Math.min(i,r-1):Math.max(r+i,0),o=(s,u)=>s===u||typeof s==\"number\"&&typeof u==\"number\"&&isNaN(s)&&isNaN(u);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}function pd(n,e){let{mimeType:t,codecs:r}=Bo(n),{mimeType:i,codecs:a}=Bo(e);if(t!==i||r===\"\"||a===\"\")return!1;let o=r.split(\".\")[0];o=o===\"hev1\"?\"hvc1\":o;let s=a.split(\".\")[0];return s=s===\"hev1\"?\"hvc1\":s,o===s}var gd=7;function Bo(n){var i;let[e,...t]=n.split(\";\"),r=(i=Q(t,a=>We(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(gd),r[0]==='\"'&&(r=r.substring(1,r.length-2)),{mimeType:e,codecs:r}}var Uo=pd;function Ti(n,e){return typeof Array.prototype.flatMap==\"function\"?n.flatMap(e):n.reduce((t,r)=>{let i=e(r);return Array.isArray(i)?(t.push(...i),t):(t.push(i),t)},[])}function Ei(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function Lo(n){var t,r,i,a,o;let e=[];for(let s of n.periods){let u=[...(t=s.adaptations.video)!=null?t:[],...(r=s.adaptations.audio)!=null?r:[]];for(let d of u)if(d.supportStatus.hasCodecWithUndefinedSupport)for(let f of d.representations)f.isSupported===void 0&&e.push({mimeType:(i=f.mimeType)!=null?i:\"\",codec:(o=(a=f.codecs)==null?void 0:a[0])!=null?o:\"\"})}return e}var Fo=[];function et(n){ge(Fo,n)||(console.warn(n),Fo.push(n))}var fn=class{constructor(e){this.supportMap=new Map,this.addCodecs(e)}addCodecs(e){for(let t of e){let r=this.supportMap.get(t.mimeType);r===void 0&&(r=new Map,this.supportMap.set(t.mimeType,r)),r.set(t.codec,{supported:t.supported,supportedIfEncrypted:t.supportedIfEncrypted})}}isSupported(e,t,r){let i=this.supportMap.get(e);if(i===void 0)return;let a=i.get(t);if(a!==void 0)return r?a.supportedIfEncrypted:a.supported}};var mt=class{constructor(e,t,r,i){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((a,o)=>{let s=e.adaptations[o];if(v(s))return a;let u=s.map(d=>{let f=new ft(d,r,{representationFilter:i});return f.representations.length>0&&f.supportStatus.hasSupportedCodec===!1&&t.push(f),f}).filter(d=>d.representations.length>0);if(u.every(d=>d.supportStatus.hasSupportedCodec===!1)&&s.length>0&&(o===\"video\"||o===\"audio\"))throw new X(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+o+\" adaptations\",{tracks:void 0});return u.length>0&&(a[o]=u),a},{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new X(\"MANIFEST_PARSE_ERROR\",\"No supported audio and video tracks.\");this.duration=e.duration,this.start=e.start,!v(this.duration)&&!v(this.start)&&(this.end=this.start+this.duration),this.streamEvents=e.streamEvents===void 0?[]:e.streamEvents}refreshCodecSupport(e,t){Object.keys(this.adaptations).forEach(r=>{let i=this.adaptations[r];if(i===void 0)return;let a=!1;for(let o of i){if(!o.supportStatus.hasCodecWithUndefinedSupport){o.supportStatus.hasSupportedCodec===!0&&(a=!0);continue}let s=o.supportStatus.hasSupportedCodec;o.refreshCodecSupport(t),s!==!1&&o.supportStatus.hasSupportedCodec===!1&&e.push(o),a===!1?a=o.supportStatus.hasSupportedCodec:a===void 0&&o.supportStatus.hasSupportedCodec===!0&&(a=!0)}if((r===\"video\"||r===\"audio\")&&a===!1)throw new X(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+r+\" adaptations\",{tracks:void 0})},{})}getAdaptations(){return si(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return Q(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return po(this,e)}containsTime(e,t){return oi(this,e,t)}getMetadataSnapshot(){let e={},t=this.getAdaptations();for(let r of t){let i=e[r.type];i===void 0&&(i=[],e[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:e}}};function cn(n,e,t){let r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};n.start=e.start,n.end=e.end,n.duration=e.duration,n.streamEvents=e.streamEvents;let i=n.getAdaptations(),a=e.getAdaptations();for(let o=0;o<i.length;o++){let s=i[o],u=re(a,d=>d.id===s.id);if(u===-1){m.warn('Manifest: Adaptation \"'+i[o].id+'\" not found when merging.');let[d]=i.splice(o,1);o--,r.removedAdaptations.push({id:d.id,trackType:d.type})}else{let[d]=a.splice(u,1),f=[],l=[],c=[];r.updatedAdaptations.push({adaptation:s.id,trackType:s.type,updatedRepresentations:f,addedRepresentations:l,removedRepresentations:c});let g=s.representations,p=d.representations.slice();for(let h=0;h<g.length;h++){let b=g[h],y=re(p,T=>T.id===b.id);if(y===-1){m.warn(`Manifest: Representation \"${g[h].id}\" not found when merging.`);let[T]=g.splice(h,1);h--,c.push(T.id)}else{let[T]=p.splice(y,1);f.push(b.getMetadataSnapshot()),b.cdnMetadata=T.cdnMetadata,t===0?b.index._replace(T.index):b.index._update(T.index)}}p.length>0&&(m.warn(`Manifest: ${p.length} new Representations found when merging.`),s.representations.push(...p),l.push(...p.map(h=>h.getMetadataSnapshot())))}}if(a.length>0){m.warn(`Manifest: ${a.length} new Adaptations found when merging.`);for(let o of a){let s=n.adaptations[o.type];s===void 0?n.adaptations[o.type]=[o]:s.push(o),r.addedAdaptations.push(o.getMetadataSnapshot())}}return r}function zo(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,u=n[s];for(;u!==void 0&&u.id!==o.id;)s++,u=n[s];if(u!==void 0){let d=cn(u,o,0);t.updatedPeriods.push({period:{id:u.id,start:u.start,end:u.end,duration:u.duration,streamEvents:u.streamEvents},result:d});let f=e.slice(r,a),l=s-r,c=n.splice(r,l,...f);t.removedPeriods.push(...c.map(g=>({id:g.id,start:g.start,end:g.end}))),t.addedPeriods.push(...f.map(g=>g.getMetadataSnapshot())),r=a+1}}if(r>n.length)return m.error(\"Manifest: error when updating Periods\"),t;if(r<n.length){let a=n.splice(r,n.length-r);t.removedPeriods.push(...a.map(o=>({id:o.id,start:o.start,end:o.end})))}let i=e.slice(r,e.length);return i.length>0&&(n.push(...i),t.addedPeriods.push(...i.map(a=>a.getMetadataSnapshot()))),t}function Wo(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(n.length===0)return n.splice(0,0,...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t;if(e.length===0)return t;let r=n[n.length-1];if(r.start<e[0].start){if(r.end!==e[0].start)throw new X(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");return n.push(...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t}let i=re(n,({id:s})=>s===e[0].id);if(i<0)throw new X(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=cn(n[i],e[0],1);t.updatedPeriods.push({period:G(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let u=e[s],d=-1;for(let f=o;f<n.length;f++)if(u.id===n[f].id){d=f;break}if(d<0){let f=-1;for(let g=o;g<n.length;g++)if(u.start<n[g].start){f=g;break}let l=f-o,c=n.splice(o,l,u);t.addedPeriods.push(u.getMetadataSnapshot()),t.removedPeriods.push(...c.map(g=>({id:g.id,start:g.start,end:g.end})))}else{if(d>o){m.warn(\"Manifest: old Periods not found in new when updating, removing\");let l=n.splice(o,d-o);t.removedPeriods.push(...l.map(c=>({id:c.id,start:c.start,end:c.end}))),d=o}let f=cn(n[d],u,0);t.updatedPeriods.push({period:G(n[d].getMetadataSnapshot(),{adaptations:void 0}),result:f})}o++}if(o<n.length){m.warn(\"Manifest: Ending Periods not found in new when updating, removing\");let s=n.splice(o,n.length-o);t.removedPeriods.push(...s.map(u=>({id:u.id,start:u.start,end:u.end})))}return t}var hd=Ae(),mn=class extends le{constructor(e,t,r){var s;super();let{representationFilter:i,manifestUpdateUrl:a}=t;this.manifestFormat=0,this.id=hd(),this.expired=(s=e.expired)!=null?s:null,this.transport=e.transportType,this.clockOffset=e.clockOffset,this._cachedCodecSupport=new fn([]);let o=[];if(this.periods=e.periods.map(u=>new mt(u,o,this._cachedCodecSupport,i)).sort((u,d)=>u.start-d.start),o.length>0){let u=new X(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:o.map(lt)});r.push(u)}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.timeBounds=e.timeBounds,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.uris=e.uris===void 0?[]:e.uris,this.updateUrl=a,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.availabilityStartTime=e.availabilityStartTime,this.publishTime=e.publishTime}updateCodecSupport(e=[]){if(e.length===0)return null;this._cachedCodecSupport.addCodecs(e);let t=[];for(let r of this.periods)r.refreshCodecSupport(t,this._cachedCodecSupport);return this.trigger(\"supportUpdate\",null),t.length>0?new X(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:t.map(lt)}):null}getPeriod(e){return Q(this.periods,t=>e===t.id)}getPeriodForTime(e){return go(this,e)}getNextPeriod(e){return Q(this.periods,t=>t.start>e)}getPeriodAfter(e){return ho(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return fo(this)}getLivePosition(){return co(this)}getMaximumSafePosition(){return mo(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=Id(this,e);t.length>0&&this.trigger(\"decipherabilityUpdate\",t)}addRepresentationsToAvoid(e){let t=[];for(let r of e){let i=this.getPeriod(r.period.id);if(i===void 0)continue;let a=i.getAdaptation(r.adaptation.id);if(a===void 0)continue;let o=a.getRepresentation(r.representation.id);o!==void 0&&(o.shouldBeAvoided=!0,t.push({manifest:this,period:i,adaptation:a,representation:o}))}t.length>0&&this.trigger(\"representationAvoidanceUpdate\",t)}getAdaptations(){et(\"manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead\");let e=this.periods[0];if(e===void 0)return[];let t=e.adaptations,r=[];for(let i in t)if(t.hasOwnProperty(i)){let a=t[i];r.push(...a)}return r}getAdaptationsForType(e){et(\"manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead\");let t=this.periods[0];if(t===void 0)return[];let r=t.adaptations[e];return r===void 0?[]:r}getAdaptation(e){return et(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),Q(this.getAdaptations(),({id:t})=>e===t)}getMetadataSnapshot(){let e=[];for(let t of this.periods)e.push(t.getMetadataSnapshot());return{manifestFormat:1,id:this.id,periods:e,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}}getCodecsWithUnknownSupport(){return Lo(this)}_performUpdate(e,t){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;let r;if(t===0)this.timeBounds=e.timeBounds,this.uris=e.uris,r=zo(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=Wo(this.periods,e.periods);let i=this.getMinimumSafePosition();for(;this.periods.length>0;){let a=this.periods[0];if(a.end===void 0||a.end>i)break;this.periods.shift()}}this.updateCodecSupport(),this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.trigger(\"manifestUpdate\",r)}};function Id(n,e){let t=[];for(let r of n.periods)for(let i of r.getAdaptations()){let a=!0;for(let o of i.representations){let s={manifest:n,period:r,adaptation:i,representation:o},u=e(s);u!==!1&&(a=!1),u!==o.decipherable&&(t.push(s),o.decipherable=u,u===!0?i.supportStatus.isDecipherable=!0:u===void 0&&i.supportStatus.isDecipherable===!1&&(i.supportStatus.isDecipherable=void 0),m.debug(`Decipherability changed for \"${o.id}\"`,`(${o.bitrate})`,String(o.decipherable)))}a&&(i.supportStatus.isDecipherable=!1)}return t}function Je(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function Tt(n){if(v(n))return\"\";let{period:e,adaptation:t,representation:r,segment:i}=n,a;return i.isInit?a=\"init\":i.complete?a=`${i.time}-${i.duration}`:a=`${i.time}`,`${t.type} P: ${e.id} A: ${t.id} R: ${r.id} S: ${a}`}var Lt=mn;var bd=\"<\",Sd=60,Vo=\">\",yr=62,_i=45,qo=47,yd=33,Ho=39,Go=34,Ri=91,Td=93,Ed=`\\r\n\t>/= `;function Pi(n,e={}){var c,g;let t=(c=e.pos)!=null?c:0,r=e.keepComments===!0,i=e.keepWhitespace===!0,a;if(e.attrValue!==void 0)for(e.attrName=(g=e.attrName)!=null?g:\"id\",a=[];(t=l())!==-1;)t=n.lastIndexOf(\"<\",t),t!==-1&&a.push(d()),n=n.substring(t),t=0;else a=o(\"\");return e.filter!==void 0&&(a=Ko(a,e.filter)),a;function o(p){let h=[];for(;n[t]!==void 0;)if(n.charCodeAt(t)===Sd){if(n.charCodeAt(t+1)===qo){let y=t+2;if(t=n.indexOf(Vo,t),n.substring(y,t).indexOf(p)===-1){let P=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(P.length-1)+`\nColumn: `+(P[P.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),h}else if(n.charCodeAt(t+1)===yd){if(n.charCodeAt(t+2)===_i){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===yr&&n.charCodeAt(t-1)===_i&&n.charCodeAt(t-2)===_i);)t=n.indexOf(Vo,t+1);t===-1&&(t=n.length),r&&h.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===Ri&&n.charCodeAt(t+8)===Ri&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(h.push(n.substring(t+9)),t=n.length):(h.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let T=!1;for(;(n.charCodeAt(t)!==yr||T)&&n[t]!==void 0;)n.charCodeAt(t)===Ri?T=!0:T&&n.charCodeAt(t)===Td&&(T=!1),t++;h.push(n.substring(y,t))}t++;continue}let b=d();h.push(b),b.tagName[0]===\"?\"&&(h.push(...b.children),b.children=[])}else{let b=s();if(i)b.length>0&&h.push(b);else{let y=b.trim();y.length>0&&h.push(y)}t++}return h}function s(){let p=t;return t=n.indexOf(bd,t)-1,t===-2&&(t=n.length),n.slice(p,t+1)}function u(){let p=t;for(;Ed.indexOf(n[t])===-1&&n[t]!==void 0;)t++;return n.slice(p,t)}function d(){let p=t;t++;let h=u(),b={},y=[];for(;n.charCodeAt(t)!==yr&&n[t]!==void 0;){let T=n.charCodeAt(t);if(T>64&&T<91||T>96&&T<123){let P=u(),E=n.charCodeAt(t);for(;!isNaN(E)&&E!==Ho&&E!==Go&&!(E>64&&E<91||E>96&&E<123)&&E!==yr;)t++,E=n.charCodeAt(t);let C;E===Ho||E===Go?C=f():(C=null,t--),b[P]=C===null?null:jo(C)}t++}return n.charCodeAt(t-1)!==qo?(t++,y=o(h)):t++,{tagName:h,attributes:b,children:y,posStart:p,posEnd:t}}function f(){let p=n[t],h=t+1;return t=n.indexOf(p,h),n.slice(h,t)}function l(){let p=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return p!==null?p.index:-1}}function Ko(n,e,t=0,r=\"\"){let i=[];return n.forEach(function(a,o){if(typeof a==\"object\"&&(e(a,o,t,r)&&i.push(a),a.children.length>0)){let s=Ko(a.children,e,t+1,(K(r)?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function Tr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+Tr(t),e=e.trim()}),e}else return typeof n==\"object\"?Tr(n.children):\" \"+jo(n)}function jo(n){return n.indexOf(\"&\")<0?n:n.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&apos;/g,\"'\").replace(/&#x([A-Fa-f0-9]+);/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/&amp;/g,\"&\")}function vi(n,e,t){let{repeatCount:r}=n;if(r>=0)return r;let i;return v(e)?t!==void 0?i=t:i=Number.MAX_VALUE:i=e.start,Math.ceil((i-n.start)/n.duration)-1}function Ue(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=vi(n,e,t);return r+(a+1)*i}function Pe(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function $e(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function Yo(n,e,t){return[n*t,(n+e)*t]}function _d(n,e){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i].start<=e?t=i+1:r=i}return t-1}function Qo(n,e,t){let{timeline:r}=n,i=Pe(e,n);if(i<0)return null;let a=_d(r,i);if(a<0||a>=r.length-1)return null;let o=r[a];if(o.duration<=0)return null;let s=r[a+1];if(s===void 0)return null;let u=s.start,d=Ue(o,s,t);return i>=d&&i<u?$e(u,n):null}function tt(n,e){var i;let{initialization:t}=n,r={};return e!==void 0&&(r.isEMSGWhitelisted=e),{id:\"init\",isInit:!0,time:0,end:0,duration:0,timescale:1,range:v(t)?void 0:t.range,indexRange:n.indexRange,url:(i=t==null?void 0:t.url)!=null?i:null,complete:!0,privateInfos:r,timestampOffset:-(n.indexTimeOffset/n.timescale)}}function Rd(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function Ci(n){return(e,t,r)=>{let i=K(r)?parseInt(r,10):1;return Rd(String(n),i)}}function Le(n,e,t){return Pd(n,e,t)}function Pd(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(\\%0(\\d+)d)?\\$/g,Ci(t===void 0?0:t))}function Er(n,e){return function(r){return r.indexOf(\"$\")===-1?r:r.replace(/\\$\\$/g,\"$\").replace(/\\$Number(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(e===void 0)throw new Error(\"Segment number not defined in a $Number$ scheme\");return Ci(e)(i,a,o)}).replace(/\\$Time(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(n===void 0)throw new Error(\"Segment time not defined in a $Time$ scheme\");return Ci(n)(i,a,o)})}}function vd(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function pn(n,e,t,r,i,a){var T;let o=r.getEstimatedMaximumPosition((T=n.availabilityTimeOffset)!=null?T:0),s=Math.min(e+t,o!=null?o:1/0),u=Pe(e,n),d=Pe(s,n),{timeline:f,timescale:l,segmentUrlTemplate:c,startNumber:g,endNumber:p}=n,h=g!=null?g:1,b=[],y=f.length;for(let P=0;P<y;P++){let E=f[P],{duration:C,start:_,range:O}=E,k;o===void 0?k=i:k=Math.min(o*l,i!=null?i:1/0);let A=vi(E,f[P+1],k),R=n.availabilityTimeComplete!==!1||P!==y-1&&A!==0,x=vd(_,C,u),N=_+x*C;for(;N<d&&x<=A;){let w=h+x;if(p!==void 0&&w>p)break;let M=c===null?null:Er(N,w)(c),B=N-n.indexTimeOffset,U=C;B<0&&(U=C+B,B=0);let V={id:String(N),time:B/l,end:(B+U)/l,duration:U/l,isInit:!1,range:O,timescale:1,url:M,number:w,timestampOffset:-(n.indexTimeOffset/l),complete:R,privateInfos:{isEMSGWhitelisted:a}};b.push(V),x++,N=_+x*C}if(N>=d||(h+=A+1,p!==void 0&&h>p))return b}return b}function Cd(n,e){if(e.timescale!==n.timescale){let{timescale:t}=n;n.timeline.push({start:e.time/e.timescale*t,duration:e.duration/e.timescale*t,repeatCount:e.count===void 0?0:e.count,range:e.range})}else n.timeline.push({start:e.time,duration:e.duration,repeatCount:e.count===void 0?0:e.count,range:e.range});return!0}var Rt=class{constructor(e,t){var p,h,b,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,u=(p=e.timescale)!=null?p:1,f=((h=e.presentationTimeOffset)!=null?h:0)-r*u,l=((b=e.initialization)==null?void 0:b.media)===void 0?null:Le(e.initialization.media,a,o),c=e.media===void 0?null:Le(e.media,a,o),g;e.initialization!==void 0?g=e.initialization.range:e.indexRange!==void 0&&(g=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:f,initialization:{url:l,range:g},segmentUrlTemplate:c,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:u},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Pe(r,this._index),this._scaledPeriodEnd=v(i)?void 0:Pe(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return tt(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return pn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:$e(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)}getLastAvailablePosition(){var i;let{timeline:e}=this._index;if(e.length===0)return null;let t=e[e.length-1],r=Math.min(Ue(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return $e(r,this._index)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return this._isInitialized}initialize(e){if(!this._isInitialized){for(let t=0;t<e.length;t++)Cd(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){m.warn(\"Cannot add predicted segments to a `BaseRepresentationIndex`\")}_replace(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted}_update(){m.error(\"Base RepresentationIndex: Cannot update a SegmentList\")}};var Pt=class{constructor(e,t){var g,p,h;if(e.duration===void 0)throw new Error(\"Invalid SegmentList: no duration\");let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t;this._isEMSGWhitelisted=s,this._periodStart=r,this._periodEnd=i;let u=(g=e.presentationTimeOffset)!=null?g:0,d=(p=e.timescale)!=null?p:1,f=u-r*d,l=((h=e.initialization)==null?void 0:h.media)===void 0?null:Le(e.initialization.media,a,o),c=e.list.map(b=>({url:b.media===void 0?null:Le(b.media,a,o),mediaRange:b.mediaRange}));this._index={list:c,timescale:d,duration:e.duration,indexTimeOffset:f,indexRange:e.indexRange,initialization:v(e.initialization)?void 0:{url:l,range:e.initialization.range}}}getInitSegment(){let e=tt(this._index);return e.privateInfos===void 0&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e}getSegments(e,t){let r=this._index,{duration:i,list:a,timescale:o}=r,s=i/o,u=e-this._periodStart,[d,f]=Yo(u,t,o),l=Math.min(a.length-1,Math.floor(f/i)),c=[],g=Math.floor(d/i);for(;g<=l;){let p=a[g].mediaRange,h=a[g].url,b=g*s+this._periodStart,y={id:String(g),time:b,isInit:!1,range:p,duration:s,timescale:1,end:b+s,url:h,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};c.push(y),g++}return c}shouldRefresh(e,t){return!1}getFirstAvailablePosition(){return this._periodStart}getLastAvailablePosition(){var i;let e=this._index,{duration:t,list:r}=e;return Math.min(r.length*t/e.timescale+this._periodStart,(i=this._periodEnd)!=null?i:1/0)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return!0}initialize(){m.error(\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){m.warn(\"Cannot add predicted segments to a `ListRepresentationIndex`\")}_replace(e){this._index=e._index}_update(){m.error(\"A `ListRepresentationIndex` cannot be updated\")}};function Ft(n){return F.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var vt=class{constructor(e,t){var y,T,P;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:u,representationBitrate:d,isEMSGWhitelisted:f}=t,l=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let c=(T=e.presentationTimeOffset)!=null?T:0,g=s*l,p=c-g;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let h=((P=e.initialization)==null?void 0:P.media)===void 0?null:Le(e.initialization.media,u,d),b=e.media===void 0?null:Le(e.media,u,d);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:p,initialization:v(e.initialization)?void 0:{url:h,range:e.initialization.range},url:b,presentationTimeOffset:c,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=a,this._periodStart=s,this._scaledRelativePeriodEnd=o===void 0?void 0:(o-s)*l,this._isEMSGWhitelisted=f}getInitSegment(){return tt(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:u}=r,d=this._periodStart*s,f=this._scaledRelativePeriodEnd,l=e*s-d,c=(e+t)*s-d,g=this._getFirstSegmentStart(),p=this._getLastSegmentStart();if(v(g)||v(p))return[];let h=Math.max(g,l),b=Math.min(p,c);if(b+i<=h)return[];let y=[],T=a!=null?a:1,P=Math.floor(h/i);for(let E=P*i;E<=b;E+=i){let C=P+T;if(o!==void 0&&C>o)return y;let _=!v(f)&&E+i>f?f-E:i,O=E+d,k=E+this._index.presentationTimeOffset,A=u===null?null:Er(k,C)(u),R={id:String(C),number:C,time:O/s,end:(O+_)/s,duration:_/s,timescale:1,isInit:!1,scaledDuration:_/s,url:A,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(R),P++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return v(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(v(e))return e;let t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,t!=null?t:1/0)/this._index.timescale+this._periodStart}getEnd(){if(!this._isDynamic)return this.getLastAvailablePosition();let e=this._estimateRelativeScaledEnd();if(e===void 0)return;let{timescale:t}=this._index;return(e+this._periodStart*t)/t}awaitSegmentBetween(e,t){if(ce(e<=t),!this._isDynamic)return!1;let{timescale:r}=this._index,i=Ft(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,u=this._getLastSegmentStart();if(v(u)){let l=this._estimateRelativeScaledEnd();return l===void 0?s+i>=0:s+i>=0&&o<l-i}let d=u+this._index.duration,f=this._estimateRelativeScaledEnd();return f===void 0?s>d-i:s>d-i&&o<f-i}shouldRefresh(){return!1}checkDiscontinuity(){return null}isSegmentStillAvailable(e){if(e.isInit)return!0;let t=this.getSegments(e.time,.1);return t.length===0?!1:t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){if(!this._isDynamic)return!1;let e=this._estimateRelativeScaledEnd();if(e===void 0)return!0;let{timescale:t}=this._index,r=this._getLastSegmentStart();if(v(r))return!0;let i=r+this._index.duration,a=Ft(t);return i+a<e}isInitialized(){return!0}initialize(){m.error(\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){m.warn(\"Cannot add predicted segments to a `TemplateRepresentationIndex`\")}_replace(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator}_update(e){this._replace(e)}_getFirstSegmentStart(){var o;if(!this._isDynamic)return 0;if(this._scaledRelativePeriodEnd===0||this._scaledRelativePeriodEnd===void 0){let s=this._manifestBoundsCalculator.getEstimatedMaximumPosition((o=this._availabilityTimeOffset)!=null?o:0);if(s!==void 0&&s<this._periodStart)return null}let{duration:e,timescale:t}=this._index,r=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime(e/t);if(r===void 0)return;let i=r>this._periodStart?(r-this._periodStart)*t:0;return Math.floor(i/e)*e}_getLastSegmentStart(){var a,o;let{duration:e,timescale:t,endNumber:r,startNumber:i=1}=this._index;if(this._isDynamic){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&this._scaledRelativePeriodEnd!==void 0&&this._scaledRelativePeriodEnd<s-this._periodStart*this._index.timescale){let l=Math.ceil(this._scaledRelativePeriodEnd/e);return r!==void 0&&r-i+1<l&&(l=r-i+1),(l-1)*e}let u=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(u===void 0)return;let d=(u-this._periodStart)*t;if(d<0)return null;let f=Math.floor(d/e);return r!==void 0&&r-i+1<f&&(f=r-i+1),f<=0?null:(f-1)*e}else{let s=(o=this._scaledRelativePeriodEnd)!=null?o:0,u=Math.ceil(s/e);r!==void 0&&r-i+1<u&&(u=r-i+1);let d=(u-1)*e,f=F.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-d>f||u<2?d:(u-2)*e}}_estimateRelativeScaledEnd(){var e,t;if(this._index.endNumber!==void 0){let r=this._index.endNumber-((e=this._index.startNumber)!=null?e:1)+1;return Math.max(Math.min(r*this._index.duration,(t=this._scaledRelativePeriodEnd)!=null?t:1/0),0)}if(this._scaledRelativePeriodEnd!==void 0)return Math.max(this._scaledRelativePeriodEnd,0)}};function Ai(n,e){let t=0;for(;n.length>0;){let r=n[0];if(r.start>=e||r.repeatCount===-1)return t;if(r.repeatCount===0)n.shift(),t+=1;else{let i=n[1];if(i!==void 0&&i.start<=e)n.shift(),t+=1;else{if(r.duration<=0)return t;let a=r.start+r.duration,o=1;for(;a<e&&o<=r.repeatCount;)a+=r.duration,o++;if(o>r.repeatCount)n.shift(),t=r.repeatCount+1;else{let s=r.repeatCount-o;return r.start=a,r.repeatCount=s,t+=o,t}}}}return t}function ki(n,e){if(n.length===0)return n.push(...e),!0;if(e.length===0)return!1;let t=n.length,r=e[0].start,i=n[t-1];if(Ue(i,e[0])<r)throw new X(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");for(let f=t-1;f>=0;f--){let l=n[f].start;if(l===r){let c=t-f;return n.splice(f,c,...e),!1}else if(l<r){let c=n[f];if(c.start+c.duration>r)return m.warn(\"RepresentationIndex: Manifest update removed all previous segments\"),n.splice(0,t,...e),!0;if(c.repeatCount===void 0||c.repeatCount<=0)return c.repeatCount<0&&(c.repeatCount=Math.floor((r-c.start)/c.duration)-1),n.splice(f+1,t-(f+1),...e),!1;if(c.start+c.duration*(c.repeatCount+1)<=r)return n.splice(f+1,t-(f+1),...e),!1;let p=(r-c.start)/c.duration-1;if(p%1===0&&c.duration===e[0].duration){let h=e[0].repeatCount<0?-1:e[0].repeatCount+p+1;return n.splice(f,t-f,...e),n[f].start=c.start,n[f].repeatCount=h,!1}return m.warn(\"RepresentationIndex: Manifest update removed previous segments\"),n[f].repeatCount=Math.floor(p),n.splice(f+1,t-(f+1),...e),!1}}let o=n[n.length-1],s=e[e.length-1];if(o.repeatCount!==void 0&&o.repeatCount<0)return o.start>s.start?(m.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(m.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let u=o.start+o.duration*(o.repeatCount+1),d=s.start+s.duration*(s.repeatCount+1);return u>=d?(m.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(m.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function gn(n,e,t){let r=n.start,i=n.duration,a=n.repeatCount;return r===void 0&&(e===null?r=0:v(e.duration)||(r=e.start+e.duration*(e.repeatCount+1))),(i===void 0||isNaN(i))&&t!==null&&t.start!==void 0&&!isNaN(t.start)&&r!==void 0&&!isNaN(r)&&(i=t.start-r),r!==void 0&&!isNaN(r)&&i!==void 0&&!isNaN(i)&&(a===void 0||!isNaN(a))?{start:r,duration:i,repeatCount:a===void 0?0:a}:(m.warn('DASH: A \"S\" Element could not have been parsed.'),null)}function hn(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"t\":{let i=parseInt(r,10);isNaN(i)?m.warn(`DASH: invalid t (\"${r}\")`):e.start=i;break}case\"d\":{let i=parseInt(r,10);isNaN(i)?m.warn(`DASH: invalid d (\"${r}\")`):e.duration=i;break}case\"r\":{let i=parseInt(r,10);isNaN(i)?m.warn(`DASH: invalid r (\"${r}\")`):e.repeatCount=i;break}}}return e}function In(n){let e={};for(let t=0;t<n.attributes.length;t++){let r=n.attributes[t];switch(r.name){case\"t\":{let i=parseInt(r.value,10);isNaN(i)?m.warn(`DASH: invalid t (\"${r.value}\")`):e.start=i;break}case\"d\":{let i=parseInt(r.value,10);isNaN(i)?m.warn(`DASH: invalid d (\"${r.value}\")`):e.duration=i;break}case\"r\":{let i=parseInt(r.value,10);isNaN(i)?m.warn(`DASH: invalid r (\"${r.value}\")`):e.repeatCount=i;break}}}return e}function pt(n){let e=[];if(Array.isArray(n))for(let r=0;r<n.length;r++)e.push(hn(n[r]));else for(let r=0;r<n.length;r++)e.push(In(n[r]));let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[t.length-1]===void 0?null:t[t.length-1],o=e[r+1]===void 0?null:e[r+1],s=gn(i,a,o);s!==null&&t.push(s)}return t}function xi(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=Array.isArray(e)?e[0].attributes.t:e[0].getAttribute(\"t\"),i=v(r)?null:parseInt(r,10);if(i===null||Number.isNaN(i))return null;if(t===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(t<i){let a=n[0],o=0;for(;;){if(a.repeatCount>0){let 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++,o>=n.length)return null;if(a=n[o],a.start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}}else{let a=0,o=Array.isArray(e)?e[0]:null,s=Array.isArray(e)?null:e[0],u=i;for(;;){let d=o!==null?o.attributes.d:s==null?void 0:s.getAttribute(\"d\"),f=v(d)?null:parseInt(d,10);if(f===null||Number.isNaN(f))return null;let l=o!==null?o.attributes.r:s==null?void 0:s.getAttribute(\"r\"),c=v(l)?null:parseInt(l,10);if(c!==null){if(Number.isNaN(c)||c<0)return null;if(c>0){let h=t-u;if(h%f===0&&h/f<=c)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/f,prevSegmentsIdx:0,newElementsIdx:a}}u+=f*(c+1)}else u+=f;if(a++,a>=e.length)return null;Array.isArray(e)?o=e[a]:s=e[a];let g=o!==null?o.attributes.t:s==null?void 0:s.getAttribute(\"t\"),p=v(g)?null:parseInt(g,10);if(p!==null){if(Number.isNaN(p))return null;u=p}if(u===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(u>i)return null}}}function Mi(n,e){var h;let t=xi(e,n);if(t===null)return m.warn('DASH: Cannot perform \"based\" update. Common segment not found.'),pt(n);let{prevSegmentsIdx:r,newElementsIdx:i,repeatNumberInPrevSegments:a,repeatNumberInNewElements:o}=t,u=e.length-r+i-1;if(u>=n.length)return m.info('DASH: Cannot perform \"based\" update. New timeline too short'),pt(n);let d=e.slice(r);if(a>0){let b=d[0];b.start+=b.duration*a,d[0].repeatCount-=a}if(o>0&&i!==0)return m.info('DASH: Cannot perform \"based\" update. The new timeline has a different form.'),pt(n);let f=d[d.length-1],l=Array.isArray(n)?hn(n[u]):In(n[u]),c=((h=l.repeatCount)!=null?h:0)-o;if(l.duration!==f.duration||f.repeatCount>c)return m.info('DASH: Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),pt(n);l.repeatCount!==void 0&&l.repeatCount>f.repeatCount&&(f.repeatCount=l.repeatCount);let g=[],p=[];if(Array.isArray(n))for(let b=u+1;b<n.length;b++)p.push(hn(n[b]));else for(let b=u+1;b<n.length;b++)p.push(In(n[b]));for(let b=0;b<p.length;b++){let y=p[b],T=g[g.length-1]===void 0?f:g[g.length-1],P=p[b+1]===void 0?null:p[b+1],E=gn(y,T,P);E!==null&&g.push(E)}return d.concat(g)}var bn=class n{constructor(e,t){var E,C,_,O,k;if(!n.isTimelineIndexArgument(e))throw new Error(\"The given index is not compatible with a TimelineRepresentationIndex.\");let{availabilityTimeComplete:r,availabilityTimeOffset:i,manifestBoundsCalculator:a,isDynamic:o,isLastPeriod:s,representationId:u,representationBitrate:d,periodStart:f,periodEnd:l,isEMSGWhitelisted:c}=t,g=(E=e.timescale)!=null?E:1,p=(C=e.presentationTimeOffset)!=null?C:0,h=f*g,b=p-h;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=c,this._isLastPeriod=s,this._lastUpdate=(_=t.receivedTime)!=null?_:L(),this._unsafelyBaseOnPreviousIndex=null,t.unsafelyBaseOnPreviousRepresentation!==null&&t.unsafelyBaseOnPreviousRepresentation.index instanceof n&&(t.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=t.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=o,this._parseTimeline=(O=e.timelineParser)!=null?O:null;let y=((k=e.initialization)==null?void 0:k.media)===void 0?null:Le(e.initialization.media,u,d),T=e.media===void 0?null:Le(e.media,u,d),P;i===void 0&&r===void 0?P=1/0:P=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:P,indexRange:e.indexRange,indexTimeOffset:b,initialization:v(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:T,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:Oi(e.timeline,e.startNumber,e.endNumber),timescale:g},this._scaledPeriodStart=Pe(f,this._index),this._scaledPeriodEnd=l===void 0?void 0:Pe(l,this._index)}getInitSegment(){return tt(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),pn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=this._index.timeline;return e.length===0?null:$e(Math.max(this._scaledPeriodStart,e[0].start),this._index)}getLastAvailablePosition(){var r;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=_r(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(e===null)return null;let t=Math.min(e.end,(r=this._scaledPeriodEnd)!=null?r:1/0);return $e(t,this._index)}getEnd(){var r;if(this._isDynamic&&!this._isLastPeriod)return;if(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;let e=this._index.timeline[this._index.timeline.length-1],t=Math.min(Ue(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return $e(t,this._index)}awaitSegmentBetween(e,t){var d,f;if(ce(e<=t),!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timescale:r,timeline:i}=this._index,a=Ft(r),o=Pe(t,this._index),s=_r(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(d=this._scaledPeriodEnd)!=null?d:1/0)+a>=Math.min(o,(f=this._scaledPeriodEnd)!=null?f:1/0))return!1;let u=Pe(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],g=Ue(l,null,this._scaledPeriodEnd)+a;if(u<g+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:u-a<this._scaledPeriodEnd&&o+a>this._scaledPeriodStart:!1}isSegmentStillAvailable(e){return e.isInit?!0:(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),Ad(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))}checkDiscontinuity(e){this._refreshTimeline();let t=this._index.timeline;return t===null&&(t=this._getTimeline(),this._index.timeline=t),Qo({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof Ye&&e.isHttpError(404):!1}_replace(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}_update(e){this._index.timeline===null&&(this._index.timeline=this._getTimeline()),e._index.timeline===null&&(e._index.timeline=e._getTimeline()),ki(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}isStillAwaitingFutureSegments(){var o;if(!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timeline:e}=this._index;if(e.length===0){if(this._scaledPeriodEnd!==void 0){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&Pe(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Ft(this._index.timescale),r=_r(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(r!==null&&!r.isLastOfTimeline){let s=Math.min(r.end,(o=this._scaledPeriodEnd)!=null?o:1/0);return!(this._scaledPeriodEnd!==void 0&&s+t>=this._scaledPeriodEnd)}if(!this._isLastPeriod)return!1;if(this._scaledPeriodEnd===void 0)return!0;let i=e[e.length-1];return Ue(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){m.error(\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){m.warn(\"Cannot add predicted segments to a `TimelineRepresentationIndex`\")}static isTimelineIndexArgument(e){return typeof e.timelineParser==\"function\"||Array.isArray(e.timeline)}_refreshTimeline(){var i,a;if(this._index.timeline===null&&(this._index.timeline=this._getTimeline()),!this._isDynamic)return;let e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime(((a=(i=this._index.timeline[0])==null?void 0:i.duration)!=null?a:0)/this._index.timescale);if(v(e))return;let t=Pe(e,this._index),r=Ai(this._index.timeline,t);this._index.startNumber!==void 0?this._index.startNumber+=r:this._index.endNumber!==void 0&&(this._index.startNumber=r+1)}_getTimeline(){if(this._parseTimeline===null)return this._index.timeline!==null?this._index.timeline:(m.error(\"DASH: Timeline already lazily parsed.\"),[]);let e=this._parseTimeline();this._parseTimeline=null;let{MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:t}=F.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return Oi(pt(e),this._index.startNumber,this._index.endNumber);let r;return this._unsafelyBaseOnPreviousIndex._index.timeline===null?(r=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=r):r=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,Oi(Mi(e,r),this._index.startNumber,this._index.endNumber)}};function Oi(n,e,t){if(t===void 0)return n;let r=e!=null?e:1;for(let i=0;i<n.length;i++){let a=n[i];if(r+=a.repeatCount+1,r>t){if(r===t+1)return n.slice(0,i+1);{let o=n.slice(0,i),s=ee({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-u),o.push(s),o}}}return n}function Ad(n,e,t,r){let i=_r(e,t,r);if(i===null)return!1;for(let a=0;a<e.timeline.length;a++){if(i.timelineIdx<a)return!1;let o=e.timeline[a],s=(o.start-e.indexTimeOffset)/e.timescale;if(s>n.time)return!1;if(s===n.time)return o.range===void 0?n.range===void 0:!v(n.range)&&o.range[0]===n.range[0]&&o.range[1]===n.range[1];if(o.repeatCount>=0&&o.duration!==void 0){let d=(s-o.start)/o.duration-1;return d%1===0&&d<=i.newRepeatCount}}return!1}function _r(n,e,t){if(n.timeline.length<=0)return null;if(n.availabilityTimeOffset===1/0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:Ue(a,null,t)}}let r=e.getEstimatedMaximumPosition(n.availabilityTimeOffset);if(r===void 0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:Ue(a,null,t)}}for(let i=n.timeline.length-1;i>=n.timeline.length;i--){let a=n.timeline[i],o=a.start+a.duration;if($e(o,n)<=r){let s=Ue(a,n.timeline[i+1],t);if($e(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let d=Pe(r,n)-a.start,f=Math.floor(d/a.duration);return ce(f>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:f-1,end:a.start+f*a.duration}}}}return null}var Rr=bn;var kd=/^(?:[a-z]+:)?\\/\\//i,xd=/^(?:([^:\\/?#]+):)?(?:\\/\\/([^\\/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Di(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(kd.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Di(n.substring(0,t)):e+1}function $o(n,e){let t=Pr(n),r=Pr(e);if(t.scheme!==r.scheme||t.authority!==r.authority||t.path[0]!==void 0&&t.path[0]!==\"/\"&&r.path[0]===\"/\"||r.path[0]!==void 0&&r.path[0]!==\"/\"&&t.path[0]===\"/\")return null;let i=yn(t.path),a=yn(r.path),o;if(i===a)o=\"\";else{let u=i.split(\"/\");u.pop();let d=a.split(\"/\");for(;u.length>0&&d.length>0&&u[0]===d[0];)u.shift(),d.shift();for(;u.length>0;)u.shift(),d.unshift(\"..\");let f=d.join(\"/\");(f.endsWith(\"../\")||f.endsWith(\"./\"))&&(f=f.slice(0,f.length-1)),o=f===\"\"?\".\":f}let s=o;return o===\"\"&&r.query===t.query||K(r.query)&&(s+=\"?\",s+=r.query),K(r.fragment)&&(s+=\"#\",s+=r.fragment),s}function Md(n,e){let t=Pr(n),r=Pr(e);if(K(r.scheme))return wi(r);let i={scheme:t.scheme,authority:t.authority,path:\"\",query:r.query,fragment:r.fragment};return K(r.authority)?(i.authority=r.authority,i.path=yn(r.path),wi(i)):(r.path===\"\"?(i.path=t.path,K(r.query)||(i.query=t.query)):We(r.path,\"/\")?i.path=yn(r.path):i.path=yn(wd(t,r.path)),wi(i))}var Sn=new Map,Od=200;function Pr(n){var r,i,a,o,s;if(Sn.has(n))return Sn.get(n);let e=n.match(xd),t;return e===null?t={scheme:\"\",authority:\"\",path:\"\",query:\"\",fragment:\"\"}:t={scheme:(r=e[1])!=null?r:\"\",authority:(i=e[2])!=null?i:\"\",path:(a=e[3])!=null?a:\"\",query:(o=e[4])!=null?o:\"\",fragment:(s=e[5])!=null?s:\"\"},Sn.size>=Od&&Sn.clear(),Sn.set(n,t),t}function wi(n){let e=\"\";return K(n.scheme)&&(e+=n.scheme+\":\"),K(n.authority)&&(e+=\"//\"+n.authority),e+=n.path,K(n.query)&&(e+=\"?\"+n.query),K(n.fragment)&&(e+=\"#\"+n.fragment),e}function yn(n){let e=n.split(/(?=\\/)/),t=[];for(let r=0;r<e.length;r++){let i=e[r];if(!(i===\"..\"||i===\".\"||i===\"\")){if(i===\"/..\"){t.pop(),r===e.length-1&&t.push(\"/\");continue}if(i===\"/.\"){r===e.length-1&&t.push(\"/\");continue}t.push(i)}}return t.join(\"\")}function wd(n,e){if(K(n.authority)&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function Tn(...n){var r,i,a;let e=n.filter(o=>o!==\"\"),t=e.length;if(t===0)return\"\";if(t===1)return(r=e[0])!=null?r:\"\";{let o=(i=e[0])!=null?i:\"\",s=(a=e[1])!=null?a:\"\",u=Md(o,s),d=e.slice(2);return Tn(u,...d)}}var En=class{constructor(){this._refs=new Map,this._stored=[]}addReferences(e){for(let t of e)t.attributes.refId!==void 0&&this._refs.set(t.attributes.refId,t)}add(e,t){this._tryParsing(e,t,!1)||this._stored.push([e,t]),t.attributes.refId!==void 0&&(this._refs.set(t.attributes.refId,t),this._resolveStoredRefs(!1))}finalize(){this._resolveStoredRefs(!0)}_resolveStoredRefs(e){for(let t=this._stored.length-1;t>=0;t--){let[r,i]=this._stored[t];(this._tryParsing(r,i,e)||e)&&this._stored.splice(t,1)}return this._stored.length===0}_tryParsing(e,t,r){if(t.attributes.ref===void 0)return Ni(e,t),!0;let i=this._getReferenced(t.attributes.ref);return i===void 0?(r&&(m.warn(\"DASH: forcing the parsing of a referencing ContentProtection\"),Ni(e,t)),!1):(t.children.cencPssh.push(...i.children.cencPssh),t.attributes.keyId===void 0&&i.attributes.keyId!==void 0&&(t.attributes.keyId=i.attributes.keyId),t.attributes.schemeIdUri===void 0&&i.attributes.schemeIdUri!==void 0&&(t.attributes.schemeIdUri=i.attributes.schemeIdUri),t.attributes.value===void 0&&i.attributes.value!==void 0&&(t.attributes.value=i.attributes.value),Ni(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function Ni(n,e){let t;if(e.attributes.schemeIdUri!==void 0&&e.attributes.schemeIdUri.substring(0,9)===\"urn:uuid:\"&&(t=e.attributes.schemeIdUri.substring(9).replace(/-/g,\"\").toLowerCase()),e.attributes.keyId!==void 0&&e.attributes.keyId.length>0){let o=e.attributes.keyId;n.contentProtections===void 0?n.contentProtections={keyIds:[o],initData:[]}:n.contentProtections.keyIds===void 0?n.contentProtections.keyIds=[o]:n.contentProtections.keyIds.push(o)}if(t===void 0)return;let{cencPssh:r}=e.children,i=[];for(let o of r)i.push({systemId:t,data:o});if(i.length===0)return;if(n.contentProtections===void 0){n.contentProtections={keyIds:[],initData:[{type:\"cenc\",values:i}]};return}let a=Q(n.contentProtections.initData,o=>o.type===\"cenc\");a===void 0?n.contentProtections.initData.push({type:\"cenc\",values:i}):a.values.push(...i)}function vr(n){let e=Date.parse(n)-L();if(isNaN(e)){m.warn(\"DASH Parser: Invalid clock received: \",n);return}return e}function Bi(n){let e=n.children.utcTimings.filter(t=>(t.schemeIdUri===\"urn:mpeg:dash:utc:http-iso:2014\"||t.schemeIdUri===\"urn:mpeg:dash:utc:http-xsdate:2014\")&&t.value!==void 0);return e.length>0?e[0].value:void 0}function Cr(n){let{representations:e}=n,t=null;for(let r of e){let i=r.index.getLastAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.min(t,i))}return t===null?null:t}function Ui(n){for(let e=n.length-1;e>=0;e--){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=Cr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=Cr(i);if(s===void 0)return{safe:void 0,unsafe:void 0};o=s}if(r!==void 0&&a===null||i!==void 0&&o===null)return m.info(\"Parser utils: found Period with no segment. \",\"Going to previous one to calculate last position\"),{safe:void 0,unsafe:void 0};if(o!==null)return a!==null?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(a!==null)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}function Ar(n){let{representations:e}=n,t=null;for(let r of e){let i=r.index.getFirstAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.max(t,i))}return t===null?null:t}function Li(n){for(let e=0;e<=n.length-1;e++){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=Ar(r);if(s===void 0)return;a=s}if(i!==void 0){let s=Ar(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){m.info(\"Parser utils: found Period with no segment. \",\"Going to next one to calculate first position\");return}if(o!==null)return a!==null?Math.max(a,o):o;if(a!==null)return a}}}function Fi(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=Li(n),t=Ui(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var _n=class{constructor(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=!e.isDynamic||e.timeShiftBufferDepth===void 0?null:e.timeShiftBufferDepth,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}setLastPosition(e,t){this._lastPosition=e,this._positionTime=t}lastPositionIsKnown(){return this._isDynamic?this._positionTime!==void 0&&this._lastPosition!==void 0:this._lastPosition!==void 0}getEstimatedMinimumSegmentTime(e){var i;if(!this._isDynamic||this._timeShiftBufferDepth===null)return 0;let t=(i=this.getEstimatedLiveEdge())!=null?i:this.getEstimatedMaximumPosition(0);return t===void 0?void 0:t-(this._timeShiftBufferDepth+e)}getEstimatedLiveEdge(){if(!(!this._isDynamic||this._serverTimestampOffset===void 0))return(L()+this._serverTimestampOffset)/1e3-this._availabilityStartTime}getEstimatedMaximumPosition(e){if(!this._isDynamic)return this._lastPosition;let t=this.getEstimatedLiveEdge();return t!==void 0&&e!==1/0?t+e:this._positionTime!==void 0&&this._lastPosition!==void 0?Math.max(this._lastPosition-this._positionTime+L()/1e3,0):this._lastPosition}};function zi(n,e){return n.type!==\"dynamic\"?0:v(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function Wi(n){if(n.length===0)return[];let e=[n[0]];for(let t=1;t<n.length;t++){let r=n[t],i=e[e.length-1];for(;(i.duration===void 0||i.start+i.duration>r.start)&&(m.warn(\"DASH: Updating overlapping Periods.\",i==null?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0));){if(e.pop(),e.length===0)break;i=e[e.length-1]}e.push(r)}return e}function Vi(n,e){let t=[];return n.forEach((r,i)=>{let a;if(!v(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||v(e.availabilityStartTime)?0:e.availabilityStartTime;else{let d=t[t.length-1];if(!v(d)&&!v(d.periodEnd))a=d.periodEnd;else throw new Error(\"Missing start time when parsing periods.\")}let o,s=n[i+1];v(r.attributes.duration)?i===n.length-1?o=e.duration:v(s.attributes.start)||(o=s.attributes.start-a):o=r.attributes.duration;let u=v(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:u})}),t}function Dd(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Nt){let s=n[o];if(s!==void 0)for(let u of s)u.id===a&&(u.trickModeTracks===void 0&&(u.trickModeTracks=[]),u.trickModeTracks.push(r))}}}var Xo=Dd;var Nd=[\"subtitle\",\"caption\"];function qi(n,e,t,r){function i(o,s){let u=o.split(\"/\")[0];if(ge(Nt,u))return u;if(o===\"application/ttml+xml\")return\"text\";if(o===\"application/mp4\")return s!==null&&Q(s,d=>d.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&ge(Nd,d.value))!==void 0?\"text\":void 0}function a(o){switch(o.substring(0,3)){case\"avc\":case\"hev\":case\"hvc\":case\"vp8\":case\"vp9\":case\"av1\":return\"video\";case\"vtt\":return\"text\"}switch(o.substring(0,4)){case\"mp4a\":return\"audio\";case\"wvtt\":case\"stpp\":return\"text\"}}if(e!==null){let o=i(e,r);if(o!==void 0)return o}if(t!==null){let o=a(t);if(o!==void 0)return o}for(let o=0;o<n.length;o++){let s=n[o],{mimeType:u,codecs:d}=s.attributes;if(u!==void 0){let f=i(u,r);if(f!==void 0)return f}if(d!==void 0){let f=a(d);if(f!==void 0)return f}}}var Bd=/[, ]+/g;function Zo(n){return K(n)?n.trim().replace(Bd,\", \"):\"\"}function Jo(n){let[e,t,r,i,a,o,s,u]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let d,f,l;if((i!==void 0&&i===\"10\"||i===\"12\")&&(d=parseInt(i,10)),s!==void 0&&(s===\"16\"?f=\"pq\":s===\"18\"&&(f=\"hlg\")),o!==void 0&&u!==void 0&&o===\"09\"&&u===\"09\"&&(l=\"rec2020\"),!(d===void 0||f===void 0))return{colorDepth:d,eotf:f,colorSpace:l}}function Hi(n,e){var p,h,b;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:u,inbandEventStreams:d,isLastPeriod:f}=e,c={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:u,isEMSGWhitelisted:y=>d===void 0?!1:d.some(({schemeIdUri:T})=>T===y.schemeIdUri),isLastPeriod:f,manifestBoundsCalculator:r,isDynamic:i,periodEnd:a,periodStart:o,receivedTime:s,representationBitrate:n.attributes.bitrate,representationId:n.attributes.id},g;if(n.children.segmentBase!==void 0){let{segmentBase:y}=n.children;g=new Rt(y,c)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;g=new Pt(y,c)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let y=e.parentSegmentTemplates.slice(),T=n.children.segmentTemplate;T!==void 0&&y.push(T);let P=G({},...y);(P.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(c.availabilityTimeOffset=((p=P.availabilityTimeOffset)!=null?p:0)+((h=e.availabilityTimeOffset)!=null?h:0)),(P.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(c.availabilityTimeComplete=(b=P.availabilityTimeComplete)!=null?b:e.availabilityTimeComplete),g=Rr.isTimelineIndexArgument(P)?new Rr(P,c):new vt(P,c)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:T}=y;g=new Rt(T,c)}else if(y.segmentList!==void 0){let{segmentList:T}=y;g=new Pt(T,c)}else g=new vt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},c)}return g}function nt(n,e){var i;if(e.length===0)return n;let t=e.map(a=>({url:a.value}));if(n.length===0)return t;let r=[];for(let a=0;a<n.length;a++){let o=n[a];for(let s=0;s<t.length;s++){let u=t[s],d=Tn(o.url,u.url);r.push({url:d,serviceLocation:(i=u.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Ud(n,e){let t=[];if(n.children.inbandEventStreams!==void 0&&t.push(...n.children.inbandEventStreams),e.children.inbandEventStreams!==void 0&&t.push(...e.children.inbandEventStreams),t.length!==0)return t}function Ld({adaptationProfiles:n,essentialProperties:e,supplementalProperties:t,manifestProfiles:r,codecs:i}){if(((n!=null?n:\"\")+(r!=null?r:\"\")).indexOf(\"http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10\")!==-1&&(i===\"hvc1.2.4.L153.B0\"||i===\"hev1.2.4.L153.B0\"))return{colorDepth:10,eotf:\"pq\",colorSpace:\"rec2020\"};let o=Q([...e!=null?e:[],...t!=null?t:[]],s=>s.schemeIdUri===\"urn:mpeg:mpegB:cicp:TransferCharacteristics\");if(o!==void 0)switch(o.value){case\"15\":return;case\"16\":return{eotf:\"pq\"};case\"18\":return{eotf:\"hlg\"}}if(i!==void 0&&/^vp(08|09|10)/.test(i))return Jo(i)}function Gi(n,e,t){var i,a,o,s,u,d,f;let r=[];for(let l of n){let c=l.attributes.id!==void 0?l.attributes.id:String(l.attributes.bitrate)+(l.attributes.height!==void 0?`-${l.attributes.height}`:\"\")+(l.attributes.width!==void 0?`-${l.attributes.width}`:\"\")+(l.attributes.mimeType!==void 0?`-${l.attributes.mimeType}`:\"\")+(l.attributes.codecs!==void 0?`-${l.attributes.codecs}`:\"\");for(;r.some(A=>A.id===c);)c+=\"-dup\";let g=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(c))!=null?a:null,p=Ud(l,e),h=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,b;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(b=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((u=t.availabilityTimeOffset)!=null?u:0));let y=G({},t,{availabilityTimeOffset:b,availabilityTimeComplete:h,unsafelyBaseOnPreviousRepresentation:g,adaptation:e,inbandEventStreams:p}),T=Hi(l,y),P;l.attributes.bitrate===void 0?(m.warn(\"DASH: No usable bitrate found in the Representation.\"),P=0):P=l.attributes.bitrate;let E=nt(t.baseURLs,l.children.baseURLs),C=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(A=>({baseUrl:A.url,id:A.serviceLocation})),_={bitrate:P,cdnMetadata:C,index:T,id:c};l.children.supplementalProperties!==void 0&&Q(l.children.supplementalProperties,A=>A.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&A.value===\"JOC\")!==void 0&&(_.isSpatialAudio=!0);let O;l.attributes.codecs!==void 0?O=l.attributes.codecs:e.attributes.codecs!==void 0&&(O=e.attributes.codecs),O!==void 0&&(O=O===\"mp4a.40.02\"?\"mp4a.40.2\":O,_.codecs=O);let k;l.attributes.supplementalCodecs!==void 0?k=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(k=e.attributes.supplementalCodecs),k!==void 0&&(_.supplementalCodecs=Zo(k)),l.attributes.frameRate!==void 0?_.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(_.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?_.height=l.attributes.height:e.attributes.height!==void 0&&(_.height=e.attributes.height),l.attributes.mimeType!==void 0?_.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(_.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?_.width=l.attributes.width:e.attributes.width!==void 0&&(_.width=e.attributes.width);{let A=[...(d=e.children.contentProtections)!=null?d:[],...(f=l.children.contentProtections)!=null?f:[]];for(let R of A)t.contentProtectionParser.add(_,R)}_.hdrInfo=Ld({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:O}),r.push(_)}return r}function Fd(n){if(n===void 0)return!1;let e=n.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&n.value===\"1\",t=n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"description\";return e||t}function zd(n,e){return!!(n!==void 0&&n.some(r=>r.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&r.value===\"2\")||e!==void 0&&e.some(r=>r.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&r.value===\"caption\"))}function Wd(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function Vd(n,e){if(K(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,u=s;return K(n.attributes.language)&&(u+=`-${n.attributes.language}`),t===!0&&(u+=\"-cc\"),r===!0&&(u+=\"-cc\"),i===!0&&(u+=\"-ad\"),a===!0&&(u+=\"-si\"),o&&(u+=\"-trickMode\"),K(n.attributes.contentType)&&(u+=`-${n.attributes.contentType}`),K(n.attributes.codecs)&&(u+=`-${n.attributes.codecs}`),K(n.attributes.mimeType)&&(u+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(u+=`-${String(n.attributes.frameRate)}`),u}function qd(n){if(!v(n.children.supplementalProperties)){let{supplementalProperties:e}=n.children;for(let t of e)if(t.schemeIdUri===\"urn:mpeg:dash:adaptation-set-switching:2016\"&&!v(t.value))return t.value.split(\",\").map(r=>r.trim()).filter(r=>K(r))}return[]}function Ki(n,e){var s,u,d,f,l,c,g;let t={video:[],audio:[],text:[]},r=[],i={},a=[];for(let p=0;p<n.length;p++){let h=n[p],b=h.children,{essentialProperties:y,roles:T,label:P}=b,E=Array.isArray(T)&&T.some(Te=>Te.value===\"main\")&&T.some(Te=>Te.schemeIdUri===\"urn:mpeg:dash:role:2011\"),C=h.children.representations,_=(s=h.attributes.availabilityTimeComplete)!=null?s:e.availabilityTimeComplete,O;(h.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(O=((u=h.attributes.availabilityTimeOffset)!=null?u:0)+((d=e.availabilityTimeOffset)!=null?d:0));let k=h.attributes.mimeType,A=h.attributes.codecs,R=qi(C,K(k)?k:null,K(A)?A:null,v(b.roles)?null:b.roles);if(R===void 0)continue;let x=(f=h.attributes.selectionPriority)!=null?f:1,N=h.attributes.id,w=qd(h),M=[];e.segmentTemplate!==void 0&&M.push(e.segmentTemplate),h.children.segmentTemplate!==void 0&&M.push(h.children.segmentTemplate);let B={availabilityTimeComplete:_,availabilityTimeOffset:O,baseURLs:nt(e.baseURLs,b.baseURLs),contentProtectionParser:e.contentProtectionParser,manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:M,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},U=Array.isArray(y)?Q(y,Te=>Te.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,V=(l=U==null?void 0:U.value)==null?void 0:l.split(\" \"),Z=V!==void 0,{accessibilities:Y}=b,H;T!==void 0&&T.some(Te=>Te.value===\"dub\")&&(H=!0);let q;R!==\"text\"?q=!1:q=zd(Y,T);let J;R===\"text\"&&T!==void 0&&T.some(Te=>Te.value===\"forced-subtitle\"||Te.value===\"forced_subtitle\")&&(J=!0);let de;R!==\"audio\"?de=!1:Y!==void 0&&(de=Y.some(Fd));let me;R!==\"video\"?me=!1:Y!==void 0&&(me=Y.some(Wd));let ie=Vd(h,{isAudioDescription:de,isForcedSubtitle:J,isClosedCaption:q,isSignInterpreted:me,isTrickModeTrack:Z,type:R});for(;ge(a,ie);)ie+=\"-dup\";let Ge=ie;a.push(ie),B.unsafelyBaseOnPreviousAdaptation=(g=(c=e.unsafelyBaseOnPreviousPeriod)==null?void 0:c.getAdaptation(ie))!=null?g:null;let Me=Gi(C,h,B),fe={id:ie,representations:Me,type:R,isTrickModeTrack:Z};if(v(h.attributes.language)||(fe.language=h.attributes.language),v(q)||(fe.closedCaption=q),v(de)||(fe.audioDescription=de),H===!0&&(fe.isDub=!0),J!==void 0&&(fe.forcedSubtitles=J),me===!0&&(fe.isSignInterpreted=!0),P!==void 0&&(fe.label=P),V!==void 0)r.push({adaptation:fe,trickModeAttachedAdaptationIds:V});else{let Te=-1;for(let $t of w){let Ke=i[$t];if(Ke!==void 0&&Ke.newID!==Ge&&ge(Ke.adaptationSetSwitchingIDs,N)){Te=re(t[R],Ot=>Ot[0].id===$t);let Oe=t[R][Te];if(Oe!==void 0&&Oe[0].audioDescription===fe.audioDescription&&Oe[0].closedCaption===fe.closedCaption&&Oe[0].language===fe.language){m.info('DASH Parser: merging \"switchable\" AdaptationSets',N,$t),Oe[0].representations.push(...fe.representations),Oe[1]={priority:Math.max(x,Oe[1].priority),isMainAdaptation:E||Oe[1].isMainAdaptation,indexInMpd:Math.min(p,Oe[1].indexInMpd)};break}}}Te<0&&t[R].push([fe,{priority:x,isMainAdaptation:E,indexInMpd:p}])}!v(N)&&v(i[N])&&(i[N]={newID:Ge,adaptationSetSwitchingIDs:w})}let o=Nt.reduce((p,h)=>{let b=t[h];return b.length>0&&(b.sort(es),p[h]=b.map(([y])=>y)),p},{});return t.video.sort(es),Xo(o,r),o}function es(n,e){let t=e[1].priority-n[1].priority;return t!==0?t:n[1].isMainAdaptation!==e[1].isMainAdaptation?n[1].isMainAdaptation?-1:1:n[1].indexInMpd-e[1].indexInMpd}var Hd=Ae();function ji(n,e){var o,s,u,d,f;let t=[],r=Vi(n,e);if(r.length!==n.length)throw new Error(\"MPD parsing error: the time information are incoherent.\");let{isDynamic:i,manifestBoundsCalculator:a}=e;!i&&!v(e.duration)&&a.setLastPosition(e.duration);for(let l=n.length-1;l>=0;l--){let c=l===n.length-1,g=n[l],p=e.xlinkInfos.get(g),h=nt(e.baseURLs,g.children.baseURLs),{periodStart:b,periodDuration:y,periodEnd:T}=r[l],P;for(v(g.attributes.id)?(m.warn(\"DASH: No usable id found in the Period. Generating one.\"),P=\"gen-dash-period-\"+Hd()):P=g.attributes.id;t.some(U=>U.id===P);)P+=\"-dup\";let E=p!==void 0?p.receivedTime:e.receivedTime,C=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(P))!=null?s:null,_=g.attributes.availabilityTimeComplete,O=g.attributes.availabilityTimeOffset,{manifestProfiles:k,contentProtectionParser:A}=e,{segmentTemplate:R}=g.children;A.addReferences((u=g.children.contentProtections)!=null?u:[]);let x={availabilityTimeComplete:_,availabilityTimeOffset:O,baseURLs:h,contentProtectionParser:A,manifestBoundsCalculator:a,end:T,isDynamic:i,isLastPeriod:c,manifestProfiles:k,receivedTime:E,segmentTemplate:R,start:b,unsafelyBaseOnPreviousPeriod:C},N=Ki(g.children.adaptations,x),w=((d=e.xmlNamespaces)!=null?d:[]).concat((f=g.attributes.namespaces)!=null?f:[]),M=Kd(g.children.eventStreams,b,w),B={id:P,start:b,end:T,duration:y,adaptations:N,streamEvents:M};if(t.unshift(B),!a.lastPositionIsKnown()){let U=Gd(N);if(!i)typeof U==\"number\"&&a.setLastPosition(U);else if(typeof U==\"number\"){let V=L()/1e3;a.setLastPosition(U,V)}else{let V=ts(e,b);if(V!==void 0){let[Z,Y]=V;a.setLastPosition(Z,Y)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=ts(e,0);if(l!==void 0){let[c,g]=l;a.setLastPosition(c,g)}}return Wi(t)}function ts(n,e){if(v(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){m.warn(\"DASH Parser: no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=L()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=L()/1e3,i=r+t;if(i>=e)return[i,r]}}function Gd(n){let e=null,t=!0,r=cr(n).filter(a=>!v(a)),i=Ti(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let u=s.index.getLastAvailablePosition();u!==null&&(t=!1,typeof u==\"number\"&&(e=v(e)?u:Math.max(e,u)))}}if(v(e)){if(t)return null}else return e}function Kd(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:u=1}=o.attributes,d=t.concat((i=o.attributes.namespaces)!=null?i:[]);for(let f of o.children.events)if(f.eventStreamData!==void 0){let l=((a=f.presentationTime)!=null?a:0)/u+e,c=f.duration===void 0?void 0:l+f.duration/u,g,p;if(!wt&&f.eventStreamData instanceof Element)g=f.eventStreamData;else try{p={namespaces:d,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:Be(new Uint8Array(f.eventStreamData))}}catch(h){m.error(\"DASH: Error while parsing event-stream:\",h instanceof Error?h.message:\"Unknown error\")}r.push({start:l,end:c,id:f.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:u,element:g,xmlData:p}}})}}return r}function zt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(v(e.externalClockOffset)){let u=o.type===\"dynamic\",d=Q(a.utcTimings,c=>c.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!v(c.value)),f=!v(d)&&!v(d.value)?vr(d.value):void 0,l=!v(f)&&!isNaN(f)?f:void 0;if(!v(l)&&r!==!0)e.externalClockOffset=l;else if(u&&r!==!0){let c=Bi(n);if(!v(c)&&c.length>0)return{type:\"needs-clock\",value:{url:c,continue:function(p){return p.success?(e.externalClockOffset=vr(p.data),zt(n,e,t,!0)):(t.push(p.error),m.warn(\"DASH Parser: Error on fetching the clock ressource\",p.error),zt(n,e,t,!0))}}}}}let s=[];for(let u=0;u<a.periods.length;u++){let{xlinkHref:d,xlinkActuate:f}=a.periods[u].attributes;!v(d)&&f===\"onLoad\"&&s.push({index:u,ressource:d})}return s.length===0?jd(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:u})=>u),continue:function(d){if(d.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let f=d.length-1;f>=0;f--){let l=s[f].index,{parsed:c,warnings:g,receivedTime:p,sendingTime:h,url:b}=d[f];g.length>0&&t.push(...g);for(let y of c)i.set(y,{receivedTime:p,sendingTime:h,url:b});a.periods.splice(l,1,...c)}return zt(n,e,t,r,i)}}}}function jd(n,e,t,r){var M,B,U,V,Z;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Di(e.url))}]:[],u=nt(s,i.baseURLs),d=zi(a,e.referenceDateTime),f=a.timeShiftBufferDepth,l=a.maxSegmentDuration,{externalClockOffset:c,unsafelyBaseOnPreviousManifest:g}=e,{externalClockOffset:p}=e,h=new _n({availabilityStartTime:d,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:p}),b=new En;b.addReferences((M=i.contentProtections)!=null?M:[]);let y={availabilityStartTime:d,baseURLs:u,clockOffset:c,contentProtectionParser:b,duration:a.duration,isDynamic:o,manifestBoundsCalculator:h,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,unsafelyBaseOnPreviousManifest:g,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},T=ji(i.periods,y);b.finalize();let P=a.duration,E,C,_=null,O;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(E=a.minimumUpdatePeriod===0?F.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:k,maximumSafePosition:A,maximumUnsafePosition:R}=Fi(T),x=L();if(o){let Y;A!==void 0?Y=A:p===void 0?(m.warn(\"DASH Parser: use system clock to define maximum position\"),Y=Date.now()/1e3-d):Y=(L()+p)/1e3-d;let H=h.getEstimatedLiveEdge();H===void 0&&(R!==void 0?H=R:H=Y),O={isLinear:!0,maximumSafePosition:Y,livePosition:H,time:x},C=k,_=f!=null?f:null,_!==null&&(_+=l!=null?l:0),_!==null&&C!==void 0&&H-C>_&&(_=H-C)}else{C=k,C===void 0&&(C=(U=(B=T[0])==null?void 0:B.start)!=null?U:0);let Y=P!=null?P:1/0;if(T[T.length-1]!==void 0){let H=T[T.length-1],q=(V=H.end)!=null?V:H.duration!==void 0?H.start+H.duration:void 0;q!==void 0&&q<Y&&(Y=q)}A!==void 0&&A<Y&&(Y=A),O={isLinear:!1,maximumSafePosition:Y,livePosition:void 0,time:x}}let N=!o||n.attributes.minimumUpdatePeriod===void 0&&(((Z=T[T.length-1])==null?void 0:Z.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:d,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:N,periods:T,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:C,timeshiftDepth:_,maximumTimeData:O},lifetime:E,uris:v(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var kr=zt;var Yd=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,Qd=/([0-9]+)-([0-9]+)/;function ve(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new De(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ne(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new De(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function ke(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new De(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function Yi(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new De(`\\`${e}\\` property is not a boolean nor an integer but \"${n}\"`)]:[t,null]}function xr(n,e){let t=Date.parse(n);return isNaN(t)?[null,new De(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function Ve(n,e){if(!K(n))return[0,new De(`\\`${e}\\` property is empty`)];let t=Yd.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(K(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(K(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(K(t[6])?t[6]:\"0\")*24*60*60+parseFloat(K(t[8])?t[8]:\"0\")*60*60+parseFloat(K(t[10])?t[10]:\"0\")*60+parseFloat(K(t[12])?t[12]:\"0\"),null]}function Ct(n,e){let t=Qd.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function ns(n,e){try{return[Ir(n),null]}catch(t){return[null,new De(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Wt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:ke(n,e)}function Re(n){let e,t;for(let r of Object.keys(n.attributes)){let i=n.attributes[r];if(!v(i))switch(r){case\"schemeIdUri\":e=i;break;case\"value\":t=i;break}}return{schemeIdUri:e,value:t}}function be(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(m.warn(s.message),e.push(s)),o!==null&&(n[r]=o)}}var De=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\"}};function gt(n){return Tr(n)}function rt(n){let e=typeof n==\"string\"?n:gt(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function $d(n){let e=[],t=[];for(let r=0;r<n.length;r++){let i=n[r];if(typeof i!=\"string\"&&i.tagName===\"cenc:pssh\"){let a=gt(i.children);if(a!==null&&a.length>0){let[o,s]=ns(a,\"cenc:pssh\");s!==null&&(m.warn(s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function Xd(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"schemeIdUri\":e.schemeIdUri=r;break;case\"value\":e.value=r;break;case\"cenc:default_KID\":e.keyId=un(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function it(n){let[e,t]=$d(n.children),r=Xd(n);return[{children:e,attributes:r},t]}function Qi(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"id\":e.id=r;break;case\"lang\":e.language=r;break;case\"contentType\":e.contentType=r;break;case\"par\":e.par=r;break}}return e}function $i(n){let e={},t=[],r=be(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"range\":r(a,{asKey:\"range\",parser:Ct,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function at(n){let e={},t=[],r=be(e,t),i=n.children;for(let a=0;a<i.length;a++){let o=i[a];if(typeof o!=\"string\"&&o.tagName===\"Initialization\"){let[s,u]=$i(o);e.initialization=s,t=t.concat(u)}}for(let a of Object.keys(n.attributes)){let o=n.attributes[a];if(!v(o))switch(a){case\"timescale\":r(o,{asKey:\"timescale\",parser:ne,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:ke,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Ct,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:ve,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ne,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ne,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ne,dashName:\"endNumber\"});break}}return[e,t]}function Xi(n){let e={},t=[],r=be(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"media\":e.media=a;break;case\"indexRange\":r(a,{asKey:\"indexRange\",parser:Ct,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Ct,dashName:\"mediaRange\"});break}}return[e,t]}function Rn(n){let[e,t]=at(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let u=a[s];if(typeof u!=\"string\"&&u.tagName===\"SegmentURL\"){let[d,f]=Xi(u);i.push(d),r=r.concat(f)}}return[G(e,{list:i}),r]}function Zi(n){let e=n.children;return function(){for(let t=e.length-1;t>=0;t--){let r=e[t];(typeof r==\"string\"||r.tagName!==\"S\")&&e.splice(t,1)}return e}}function At(n){let[e,t]=at(n),r=t,i;for(let s=0;s<n.children.length;s++){let u=n.children[s];typeof u!=\"string\"&&u.tagName===\"SegmentTimeline\"&&(i=Zi(u))}let a=G({},e,{duration:e.duration,timelineParser:i}),o=be(a,r);for(let s of Object.keys(n.attributes)){let u=n.attributes[s];if(!v(u))switch(s){case\"initialization\":v(a.initialization)&&(a.initialization={media:u});break;case\"index\":a.index=u;break;case\"availabilityTimeOffset\":o(u,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(u,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=u;break;case\"bitstreamSwitching\":o(u,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function Zd(n){let e={baseURLs:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"BaseURL\":{let[o,s]=rt(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break}case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Re(a));break;case\"SegmentBase\":{let[o,s]=at(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=Rn(a);r=r.concat(s),e.segmentList=o;break}case\"SegmentTemplate\":{let[o,s]=At(a);r=r.concat(s),e.segmentTemplate=o;break}case\"ContentProtection\":{let[o,s]=it(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Re(a)]:e.supplementalProperties.push(Re(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function Jd(n){let e={},t=[],r=be(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"bandwidth\":r(a,{asKey:\"bitrate\",parser:ne,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:ve,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Wt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ne,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:ke,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:ke,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ne,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ne,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new De(\"No bitrate found on a Representation\")),[e,t]}function rs(n){let[e,t]=Zd(n.children),[r,i]=Jd(n),a=t.concat(i);return[{children:e,attributes:r},a]}function el(n){let e={baseURLs:[],representations:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"Accessibility\":e.accessibilities===void 0?e.accessibilities=[Re(a)]:e.accessibilities.push(Re(a));break;case\"BaseURL\":{let[o,s]=rt(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break}case\"ContentComponent\":e.contentComponent=Qi(a);break;case\"EssentialProperty\":v(e.essentialProperties)?e.essentialProperties=[Re(a)]:e.essentialProperties.push(Re(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Re(a));break;case\"Label\":{let o=gt(a.children);o!=null&&(e.label=o);break}case\"Representation\":{let[o,s]=rs(a);e.representations.push(o),s.length>0&&(r=r.concat(s));break}case\"Role\":v(e.roles)?e.roles=[Re(a)]:e.roles.push(Re(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Re(a)]:e.supplementalProperties.push(Re(a));break;case\"SegmentBase\":{let[o,s]=at(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=Rn(a);e.segmentList=o,s.length>0&&(r=r.concat(s));break}case\"SegmentTemplate\":{let[o,s]=At(a);e.segmentTemplate=o,s.length>0&&(r=r.concat(s));break}case\"ContentProtection\":{let[o,s]=it(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}}}return t.length>0&&(e.contentProtections=t),[e,r]}function tl(n){let e={},t=[],r=be(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"group\":r(a,{asKey:\"group\",parser:ne,dashName:\"group\"});break;case\"lang\":e.language=a;break;case\"contentType\":e.contentType=a;break;case\"par\":e.par=a;break;case\"minBandwidth\":r(a,{asKey:\"minBitrate\",parser:ne,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ne,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ne,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ne,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ne,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ne,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:Wt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Wt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ne,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:Yi,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:Yi,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break;case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"codecs\":e.codecs=a;break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:ve,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Wt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ne,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:ke,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:ke,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ne,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function is(n){let e=n.children,[t,r]=el(e),[i,a]=tl(n),o=r.concat(a);return[{children:t,attributes:i},o]}function nl(n){let e={},t=[],r=be(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"schemeIdUri\":e.schemeIdUri=a;break;case\"value\":e.value=a;break;case\"timescale\":r(a,{asKey:\"timescale\",parser:ne,dashName:\"timescale\"});break;default:We(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function as(n,e){let[t,r]=nl(n),i=[];for(let a of n.children)if(typeof a!=\"string\"&&a.tagName===\"Event\"){let o={};if(v(a.attributes.id)||(o.id=a.attributes.id),!v(a.attributes.presentationTime)){let[s,u]=ne(a.attributes.presentationTime,\"presentationTime\");u!==null&&r.push(u),s!==null&&(o.presentationTime=s)}if(!v(a.attributes.duration)){let[s,u]=ne(a.attributes.duration,\"duration\");u!==null&&r.push(u),s!==null&&(o.duration=s)}if(a.posStart<a.posEnd){let s=e.substring(a.posStart,a.posEnd);o.eventStreamData=s}i.push(o)}return[{children:{events:i},attributes:t},r]}function rl(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let u=0;u<n.length;u++){let d=n[u];if(typeof d!=\"string\")switch(d.tagName){case\"BaseURL\":{let[f,l]=rt(d);f!==void 0&&t.push(f),o=o.concat(l);break}case\"AdaptationSet\":{let[f,l]=is(d);r.push(f),o=o.concat(l);break}case\"EventStream\":{let[f,l]=as(d,e);s.push(f),o=o.concat(l);break}case\"SegmentTemplate\":{let[f,l]=At(d);i=f,l.length>0&&(o=o.concat(l));break}case\"ContentProtection\":{let[f,l]=it(d);l.length>0&&(o=o.concat(l)),f!==void 0&&a.push(f);break}}}return[{baseURLs:t,adaptations:r,eventStreams:s,segmentTemplate:i,contentProtections:a},o]}function il(n){let e={},t=[],r=be(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"start\":r(a,{asKey:\"start\",parser:Ve,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:Ve,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:We(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Mr(n,e){let[t,r]=rl(n.children,e),[i,a]=il(n),o=r.concat(a);return[{children:t,attributes:i},o]}function al(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let u=0;u<n.length;u++){let d=n[u];if(typeof d!=\"string\")switch(d.tagName){case\"BaseURL\":{let[f,l]=rt(d);f!==void 0&&t.push(f),s=s.concat(l);break}case\"Location\":r.push(gt(d.children));break;case\"Period\":{let[f,l]=Mr(d,e);i.push(f),s=s.concat(l);break}case\"UTCTiming\":{let f=Re(d);a.push(f);break}case\"ContentProtection\":{let[f,l]=it(d);l.length>0&&(s=s.concat(l)),f!==void 0&&o.push(f);break}}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a,contentProtections:o},s]}function ol(n){let e={},t=[],r=be(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"profiles\":e.profiles=a;break;case\"type\":e.type=a;break;case\"availabilityStartTime\":r(a,{asKey:\"availabilityStartTime\",parser:xr,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:xr,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:xr,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:Ve,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:Ve,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:Ve,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:Ve,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:Ve,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:Ve,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:Ve,dashName:\"maxSubsegmentDuration\"});break;default:We(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function os(n,e){let[t,r]=al(n.children,e),[i,a]=ol(n),o=r.concat(a);return[{children:t,attributes:i},o]}function Ji(n,e){let t=Pi(n),r=t[t.length-1];if(r===void 0||typeof r==\"string\"||r.tagName!==\"MPD\")throw new Error(\"DASH Parser: document root should be MPD\");let[i,a]=os(r,n),o=kr(i,e,a);return s(o);function s(u){if(u.type===\"done\")return u;if(u.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[u.value.url],format:\"string\",continue(d){if(d.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let f=u.value.continue(d[0].responseData);return s(f)}}};if(u.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:u.value.xlinksUrls,format:\"string\",continue(d){let f=[];for(let c=0;c<d.length;c++){let{responseData:g,receivedTime:p,sendingTime:h,url:b}=d[c];if(!g.success)throw g.error;let y=\"<root>\"+g.data+\"</root>\",T=Pi(y),P=T[T.length-1];if(P===void 0||typeof P==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let E=P.children,C=[],_=[];for(let O=0;O<E.length;O++){let k=E[O];if(typeof k==\"string\"||k.tagName!==\"Period\")continue;let[A,R]=Mr(k,y);_.push(...R),C.push(A)}f.push({url:b,receivedTime:p,sendingTime:h,parsed:C,warnings:_})}let l=u.value.continue(f);return s(l)}}};Ne(u)}}var ss=Ji;var sl=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",us=sl;function z(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function ea(n){return n===1/0?!0:n===-1/0?!1:n}function ht(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=z(t,e.buffer,a,o))}}function It(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,u){switch(o){case 16:t.schemeIdUri=z(i,e.buffer,s,u);break;case 13:t.value=z(i,e.buffer,s,u);break;case 14:{let d=z(i,e.buffer,s,u);t.keyId=un(d.replace(/-/g,\"\"));break}case 15:try{let d=z(i,e.buffer,s,u);r.cencPssh.push(Ir(d))}catch(d){}break;case 78:t.ref=z(i,e.buffer,s,u);break;case 79:t.refId=z(i,e.buffer,s,u);break}}}function ds(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=z(t,e.buffer,a,o);break;case 60:n.language=z(t,e.buffer,a,o);break;case 61:n.contentType=z(t,e.buffer,a,o);break;case 62:n.par=z(t,e.buffer,a,o);break}}}function ls(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.label=z(t,e.buffer,a,o))}}function qe(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=z(t,e.buffer,a,o);break;case 17:n.value=z(t,e.buffer,a,o);break}}}function Vt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 29:{let s=new DataView(e.buffer);n.initialization===void 0&&(n.initialization={}),n.initialization.range=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 67:n.initialization===void 0&&(n.initialization={}),n.initialization.media=z(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function fs(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=z(t,e.buffer,a,o);break;case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 30:n.media=z(t,e.buffer,a,o);break;case 18:{let s=new DataView(e.buffer);n.mediaRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}}}}function Or(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=fs(a,e);t.pushParsers(i,D,o);break}default:t.pushParsers(i,D,D);break}}}function qt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let u=a;for(let d=0;d<o/24;d++)n.timeline.push({start:s.getFloat64(u,!0),duration:s.getFloat64(u+8,!0),repeatCount:s.getFloat64(u+16,!0)}),u+=24;break}case 67:n.initialization={media:z(t,e.buffer,a,o)};break;case 28:n.index=z(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 30:n.media=z(t,e.buffer,a,o);break;case 32:{n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function cs(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,D,ht(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=It(a,e);t.pushParsers(i,D,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,D,qe(a,e));break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=qe(a,e);t.pushParsers(i,D,o);break}case 17:{let a={};n.segmentBase=a;let o=Vt(a,e);t.pushParsers(i,D,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Or(a,e,t),s=Vt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,D,qt(a,e));break}default:t.pushParsers(i,D,D);break}}}function ms(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=z(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=z(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=z(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=z(t,e.buffer,a,o);break;case 5:n.codingDependency=new DataView(e.buffer).getUint8(0)===0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 11:n.mimeType=z(t,e.buffer,a,o);break;case 2:n.profiles=z(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=z(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break}}}function ps(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=qe(a,e);t.pushParsers(i,D,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=ht(a,e);t.pushParsers(i,D,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,D,ds(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=It(a,e);t.pushParsers(i,D,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=D,s=qe(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=D,s=qe(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=cs(a.children,e,t),s=ms(a.attributes,e);t.pushParsers(i,o,s);break}case 12:{let a={};n.roles===void 0&&(n.roles=[]),n.roles.push(a);let o=qe(a,e);t.pushParsers(i,D,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=qe(a,e);t.pushParsers(i,D,o);break}case 17:{let a={};n.segmentBase=a;let o=Vt(a,e);t.pushParsers(i,D,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Or(a,e,t),s=Vt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,D,qt(a,e));break}case 21:{t.pushParsers(i,D,ls(n,e));break}default:t.pushParsers(i,D,D);break}}}function gs(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=z(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=z(t,e.buffer,a,o);break;case 61:n.contentType=z(t,e.buffer,a,o);break;case 62:n.par=z(t,e.buffer,a,o);break;case 53:n.minBitrate=s.getFloat64(a,!0);break;case 49:n.maxBitrate=s.getFloat64(a,!0);break;case 56:n.minWidth=s.getFloat64(a,!0);break;case 52:n.maxWidth=s.getFloat64(a,!0);break;case 55:n.minHeight=s.getFloat64(a,!0);break;case 51:n.maxHeight=s.getFloat64(a,!0);break;case 54:n.minFrameRate=s.getFloat64(a,!0);break;case 50:n.maxFrameRate=s.getFloat64(a,!0);break;case 57:n.selectionPriority=s.getFloat64(a,!0);break;case 58:n.segmentAlignment=ea(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=ea(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=z(t,e.buffer,a,o);break;case 4:n.codecs=z(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=z(t,e.buffer,a,o);break;case 2:n.profiles=z(t,e.buffer,a,o);break;case 12:n.segmentProfiles=z(t,e.buffer,a,o);break;case 11:n.mimeType=z(t,e.buffer,a,o);break;case 5:n.codingDependency=s.getFloat64(a,!0)!==0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break}}}function hs(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=ul(o,e,r);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function Is(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=z(t,e.buffer,a,o);break;case 17:n.value=z(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:{let u={key:\"\",value:\"\"},d=a,f=s.getUint32(d);d+=4,u.key=z(t,e.buffer,d,f),d+=f;let l=s.getUint32(d);d+=4,u.value=z(t,e.buffer,d,l),n.namespaces===void 0?n.namespaces=[u]:n.namespaces.push(u);break}}}}function ul(n,e,t){let r=new TextDecoder;return function(a,o,s){let u=new DataView(e.buffer);switch(a){case 25:n.presentationTime=u.getFloat64(o,!0);break;case 1:n.duration=u.getFloat64(o,!0);break;case 0:n.id=z(r,e.buffer,o,s);break;case 69:{let d=u.getFloat64(o,!0),f=u.getFloat64(o+8,!0);n.eventStreamData=t.slice(d,f);break}}}}function wr(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=ps(o.children,e,t),u=gs(o.attributes,e);t.pushParsers(a,s,u);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=D,u=ht(o,e);t.pushParsers(a,s,u);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=hs(o.children,e,t,r),u=Is(o.attributes,e);t.pushParsers(a,s,u);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,D,qt(o,e));break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=It(o,e);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function Dr(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=z(t,e.buffer,a,o);break;case 45:n.start=new DataView(e.buffer).getFloat64(a,!0);break;case 1:n.duration=new DataView(e.buffer).getFloat64(a,!0);break;case 32:n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break;case 46:n.xlinkHref=z(t,e.buffer,a,o);break;case 47:n.xlinkActuate=z(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=new DataView(e.buffer).getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break;case 70:{let s={key:\"\",value:\"\"},u=new DataView(e.buffer),d=a,f=u.getUint32(d);d+=4,s.key=z(t,e.buffer,d,f),d+=f;let l=u.getUint32(d);d+=4,s.value=z(t,e.buffer,d,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}}function bs(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=D,u=ht(o,e);t.pushParsers(a,s,u);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=wr(o.children,e,t,r),u=Dr(o.attributes,e);t.pushParsers(a,s,u);break}case 3:{let o={};n.utcTimings.push(o);let s=D,u=qe(o,e);t.pushParsers(a,s,u);break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=It(o,e);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function Ss(n,e,t){let r,i=new TextDecoder;return function(o,s,u){switch(o){case 0:e.id=z(i,t.buffer,s,u);break;case 2:e.profiles=z(i,t.buffer,s,u);break;case 33:e.type=z(i,t.buffer,s,u);break;case 34:{let d=z(i,t.buffer,s,u);e.availabilityStartTime=new Date(d).getTime()/1e3;break}case 35:{let d=z(i,t.buffer,s,u);e.availabilityEndTime=new Date(d).getTime()/1e3;break}case 36:{let d=z(i,t.buffer,s,u);e.publishTime=new Date(d).getTime()/1e3;break}case 68:r=new DataView(t.buffer),e.duration=r.getFloat64(s,!0);break;case 37:r=new DataView(t.buffer),e.minimumUpdatePeriod=r.getFloat64(s,!0);break;case 38:r=new DataView(t.buffer),e.minBufferTime=r.getFloat64(s,!0);break;case 39:r=new DataView(t.buffer),e.timeShiftBufferDepth=r.getFloat64(s,!0);break;case 40:r=new DataView(t.buffer),e.suggestedPresentationDelay=r.getFloat64(s,!0);break;case 41:r=new DataView(t.buffer),e.maxSegmentDuration=r.getFloat64(s,!0);break;case 42:r=new DataView(t.buffer),e.maxSubsegmentDuration=r.getFloat64(s,!0);break;case 66:{let d=z(i,t.buffer,s,u);n.locations.push(d);break}case 70:{let d={key:\"\",value:\"\"};r=new DataView(t.buffer);let f=s,l=r.getUint32(f);f+=4,d.key=z(i,t.buffer,f,l),f+=l;let c=r.getUint32(f);f+=4,d.value=z(i,t.buffer,f,c),e.namespaces===void 0?e.namespaces=[d]:e.namespaces.push(d);break}}}}function ta(n,e,t,r){return function(a){switch(a){case 1:{n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=bs(n.mpd.children,e,t,r),s=Ss(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break}default:t.pushParsers(a,D,D);break}}}function ys(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=wr(o.children,e,t,r),u=Dr(o.attributes,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,D,D);break}}}var Pn=class{constructor(){this._currentNodeId=null,this.childrenParser=D,this.attributeParser=D,this._stack=[{nodeId:null,children:D,attribute:D}]}pushParsers(e,t,r){this._currentNodeId=e,this.childrenParser=t,this.attributeParser=r,this._stack.push({nodeId:e,attribute:r,children:t})}popIfCurrent(e){if(this._currentNodeId!==e)return;this._stack.pop();let{nodeId:t,children:r,attribute:i}=this._stack[this._stack.length-1];this._currentNodeId=t,this.attributeParser=i,this.childrenParser=r}reset(){this.childrenParser=D,this.attributeParser=D,this._stack=[{nodeId:null,children:D,attribute:D}]}};var dl=15e3,vn=class{constructor(){this._parsersStack=new Pn,this._instance=null,this._mpdData=null,this._linearMemory=null,this.status=\"uninitialized\",this._initProm=null,this._warnings=[],this._isParsing=!1}waitForInitialization(){var e;return(e=this._initProm)!=null?e:Promise.reject(\"No initialization performed yet.\")}async initialize(e){if(this.status!==\"uninitialized\")return Promise.reject(new Error(\"DashWasmParser already initialized.\"));if(!this.isCompatible())return this.status=\"failure\",Promise.reject(new Error(\"Target not compatible with WebAssembly.\"));this.status=\"initializing\";let t=this._parsersStack,r=new TextDecoder,i=this,a={env:{memoryBase:0,tableBase:0,memory:new WebAssembly.Memory({initial:10}),table:new WebAssembly.Table({initial:1,element:\"anyfunc\"}),onTagOpen:d,onCustomEvent:c,onAttribute:l,readNext:g,onTagClose:f}},o=null,s;typeof e.wasmUrl==\"string\"?s=fetch(e.wasmUrl):(o=URL.createObjectURL(new Blob([e.wasmUrl],{type:\"application/wasm\"})),s=fetch(o));let u=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=u.catch(async p=>{o!==null&&(URL.revokeObjectURL(o),o=null),m.warn(\"Unable to call `instantiateStreaming` on WASM\",p instanceof Error?p:\"\");let h=await s;if(h.status<200||h.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(h.status));let b=await h.arrayBuffer();return WebAssembly.instantiate(b,a)}).then(p=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=p,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(p=>{let h=p instanceof Error?p.toString():\"Unknown error\";throw m.warn(\"DW: Could not create DASH-WASM parser:\",h),this.status=\"failure\",p}),this._initProm;function d(p){return t.childrenParser(p)}function f(p){return t.popIfCurrent(p)}function l(p,h,b){return t.attributeParser(p,h,b)}function c(p,h,b){let y=i._linearMemory,T=new Uint8Array(y.buffer,h,b);if(p===1){let P=r.decode(T);m.warn(\"WASM Error Event:\",P),i._warnings.push(new Error(P))}else if(p===0){let P=r.decode(T);m.warn(\"WASM Log Event:\",P)}}function g(p,h){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let b=i._linearMemory,{mpd:y,cursor:T}=i._mpdData,P=Math.min(h,dl,y.byteLength-T);return new Uint8Array(b.buffer,p,P).set(new Uint8Array(y,T,P)),i._mpdData.cursor+=P,P}}runWasmParser(e,t){let[r,i]=this._parseMpd(e);if(r===null)throw new Error(\"DASH Parser: Unknown error while parsing the MPD\");let a=kr(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return us&&typeof ae.TextDecoder==\"function\"}_parseMpd(e){var s;if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={},r=this._linearMemory,i=ta(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,D),this._warnings=[];try{this._instance.instance.exports.parse()}catch(u){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,u}let a=(s=t.mpd)!=null?s:null,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_parseXlink(e){if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={periods:[]},r=this._linearMemory,i=ys(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,D),this._warnings=[];try{this._instance.instance.exports.parse()}catch(s){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,s}let{periods:a}=t,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_processParserReturnValue(e){if(e.type===\"done\")return e;if(e.type===\"needs-clock\"){let t=r=>{if(r.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let i=e.value.continue(r[0].responseData);return this._processParserReturnValue(i)};return{type:\"needs-resources\",value:{urls:[e.value.url],format:\"string\",continue:t}}}else if(e.type===\"needs-xlinks\"){let t=r=>{let i=[];for(let o=0;o<r.length;o++){let{responseData:s,receivedTime:u,sendingTime:d,url:f}=r[o];if(!s.success)throw s.error;let[l,c]=this._parseXlink(s.data);i.push({url:f,receivedTime:u,sendingTime:d,parsed:l,warnings:c})}let a=e.value.continue(i);return this._processParserReturnValue(a)};return{type:\"needs-resources\",value:{urls:e.value.xlinksUrls,format:\"arraybuffer\",continue:t}}}else Ne(e)}};var Ts=vn;var kt=class{constructor(e,t){this._last=e,this._wanted=t}serialize(){return[this._last,this._wanted]}getPolled(){return this._last}getWanted(){var e;return(e=this._wanted)!=null?e:this._last}forceWantedPosition(e){this._wanted=e}isAwaitingFuturePosition(){return this._wanted!==null}};function Nr(n,e,t){let r=e(n.getReference(),t);return{getCurrentTime(){return n.getCurrentTime()},getReadyState(){return n.getReadyState()},getPlaybackRate(){return n.getPlaybackRate()},getIsPaused(){return n.getIsPaused()},getReference(){return r},listen(i,a){t.isCancelled()||a.clearSignal.isCancelled()||r.onUpdate(i,{clearSignal:a.clearSignal,emitCurrentValue:a.includeLastObservation})},deriveReadOnlyObserver(i){return Nr(this,i,t)}}}var Cn=class{constructor(e,t,r,i){this._src=e,this._contentId=t,this._messageSender=r,this._cancelSignal=i}getCurrentTime(){}getReadyState(){}getIsPaused(){}getReference(){return this._src}setPlaybackRate(e){this._messageSender({type:\"update-playback-rate\",contentId:this._contentId,value:e})}getPlaybackRate(){}listen(e,t){this._cancelSignal.isCancelled()||t.clearSignal.isCancelled()||this._src.onUpdate(e,{clearSignal:t.clearSignal,emitCurrentValue:t.includeLastObservation})}deriveReadOnlyObserver(e){return Nr(this,e,this._cancelSignal)}};function ot(n,e){if(e.length===0)return n;let t,r=\"\",i=n.indexOf(\"#\"),a=n;i>=0&&(r=n.substring(i),a=n.substring(0,i));let o=a.indexOf(\"?\");o===-1?t=\"?\":o+1===a.length?t=\"\":t=\"&\";let s=a+t;for(let u=0;u<e.length;u++){let d=e[u];d[1]===null?s+=d[0]:s+=`${d[0]}=${d[1]}`,u<e.length-1&&(s+=\"&\")}return r.length>0&&(s+=r),s}function na(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-L(),u=!1,c={reject:h=>{var P,E;if(u||i.isCancelled())return;u=!0,i.deregister(p);let b=h,y=(P=b==null?void 0:b.message)!=null?P:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",T=new je(y,(E=b==null?void 0:b.canRetry)!=null?E:!1,b==null?void 0:b.xhr);o(T)},resolve:h=>{if(u||i.isCancelled())return;u=!0,i.deregister(p);let b=h.receivingTime!==void 0?h.receivingTime-s:void 0,y=h.sendingTime!==void 0?h.sendingTime-s:void 0;a({responseData:h.data,size:h.size,requestDuration:h.duration,url:h.url,receivedTime:b,sendingTime:y})},fallback:()=>{u||i.isCancelled()||(u=!0,i.deregister(p),e(t,r,i).then(a,o))}},g=n({url:t,timeout:r.timeout,cmcdPayload:r.cmcdPayload},c);i.register(p);function p(h){u||(u=!0,typeof g==\"function\"&&g(),o(h))}})}function ll(n){return function(t,r,i){var s,u;if(t===void 0)throw new Error(\"Cannot perform HTTP(s) request. URL not known\");let a=((s=r.cmcdPayload)==null?void 0:s.type)===\"query\"?ot(t,r.cmcdPayload.value):t,o=((u=r.cmcdPayload)==null?void 0:u.type)===\"headers\"?r.cmcdPayload.value:void 0;switch(n){case\"arraybuffer\":return he({url:a,headers:o,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return he({url:a,headers:o,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return he({url:a,headers:o,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:Ne(n)}}}function ra({customManifestLoader:n},e,t){let r=ll(e),i=typeof n!=\"function\"?r:na(n,r);return t!==null?t(i):i}function ia(n,e){if(e){if(Qe(n,1718909296)<0)throw new Se(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Qe(n,1836019574)<0)throw new Se(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Qe(n,1836019558)<0)throw new Se(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Qe(n,1835295092)<0)throw new Se(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function He(n,e){if(n===\"audio\"||n===\"video\")return e===\"video/mp4\"||e===\"audio/mp4\"?\"mp4\":e===\"video/webm\"||e===\"audio/webm\"?\"webm\":void 0;if(n===\"text\")return e===\"application/mp4\"?\"mp4\":void 0}function Br(n){return(e,t,r,i,a)=>{return new Promise((s,u)=>{let d=new W,f=d.linkToSignal(i);d.signal.register(u),n(e,t,r,d.signal,oe(ee({},a),{onNewChunk(c){try{o(c),a.onNewChunk(c)}catch(g){l(),d.cancel(),u(g)}}})).then(c=>{if(l(),!d.isUsed()){if(c.resultType===\"segment-loaded\")try{o(c.resultData.responseData)}catch(g){u(g);return}s(c)}},c=>{l(),u(c)});function l(){d.signal.deregister(u),f()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||He(t.type,t.mimeType)!==\"mp4\"||ia(new Uint8Array(s),t.segment.isInit)}}}function Es(n){return async(e,t,r)=>{let i=await n(e,t,r);return a(i.responseData),i;function a(o){if(typeof o==\"string\"){let s=o.length-1,u=[\"</\",\"MPD\",\">\"];for(let d=u.length-1;d>=0;d--){let f=u[d];for(;fl(o[s]);)s--;for(let l=f.length-1;l>=0;l--){if(o[s]!==f[l])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(o instanceof ArrayBuffer){let s=o.byteLength-1,u=new DataView(o),d=[[60,47],[77,80,68],[62]];for(let f=d.length-1;f>=0;f--){let l=d[f];for(;cl(u.getUint8(s));)s--;for(let c=l.length-1;c>=0;c--){if(u.getUint8(s)!==l[c])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(!v(ae.Document)&&o instanceof ae.Document&&o.documentElement.nodeName!==\"MPD\")throw new Se(\"INTEGRITY_ERROR\",\"MPD does not end with </MPD>\")}}}function fl(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function cl(n){return n===32||n===9||n===13||n===10}function aa(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,u){var T;let{responseData:d}=i,f=a.externalClockOffset,l=(T=i.url)!=null?T:a.originalUrl,c=t!=null?t:f,p={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:c},h=we.dashParsers;if(h.wasm===null||h.wasm.status===\"uninitialized\"||h.wasm.status===\"failure\")return m.debug(\"DASH: WASM MPD Parser not initialized. Running JS one.\"),b();{let P=Il(d);if(!bl(P))return m.info(\"DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),b();if(h.wasm.status===\"initialized\"){m.debug(\"DASH: Running WASM MPD Parser.\");let E=h.wasm.runWasmParser(P,p);return y(E)}else return m.debug(\"DASH: Awaiting WASM initialization before parsing the MPD.\"),h.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(h.wasm===null||h.wasm.status!==\"initialized\")return m.warn(\"DASH: WASM MPD parser initialization failed. Running JS parser instead\"),b();m.debug(\"DASH: Running WASM MPD Parser.\");let C=h.wasm.runWasmParser(P,p);return y(C)})}function b(){if(h.fastJs!==null){let P=gl(d),E=h.fastJs(P,p);return y(E)}else if(h.native!==null){let P=hl(d),E=h.native(P,p);return y(E)}else throw new Error(\"No MPD parser is imported\")}function y(P){if(P.type===\"done\"){if(P.value.warnings.length>0&&o(P.value.warnings),s.isCancelled())return Promise.reject(s.cancellationError);let _=[];return{manifest:new Lt(P.value.parsed,n,_),url:l,warnings:_}}let{value:E}=P,C=E.urls.map(_=>u(()=>{let O=F.getCurrent().DEFAULT_REQUEST_TIMEOUT,k=F.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return E.format===\"string\"?he({url:_,responseType:\"text\",timeout:O,connectionTimeout:k,cancelSignal:s}):he({url:_,responseType:\"arraybuffer\",timeout:O,connectionTimeout:k,cancelSignal:s})}).then(O=>{if(E.format===\"string\"){if(typeof O.responseData!=\"string\")throw new Error(\"External DASH resources should have been a string\");return G(O,{responseData:{success:!0,data:O.responseData}})}else{if(!(O.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return G(O,{responseData:{success:!0,data:O.responseData}})}},O=>{let k=ye(O,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return G({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:k}})}));return Promise.all(C).then(_=>E.format===\"string\"?(ml(_),y(E.continue(_))):(pl(_),y(E.continue(_))))}}}function ml(n){I.CURRENT_ENV!==I.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&typeof t.data==\"string\")&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function pl(n){I.CURRENT_ENV!==I.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&t.data instanceof ArrayBuffer)&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function gl(n){if(n instanceof ArrayBuffer)return Be(new Uint8Array(n));if(typeof n==\"string\")return n;if(n instanceof Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function hl(n){if(n instanceof ArrayBuffer)return new DOMParser().parseFromString(Be(new Uint8Array(n)),\"text/xml\");if(typeof n==\"string\")return new DOMParser().parseFromString(n,\"text/xml\");if(n instanceof Document)return n;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Il(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return sn(n).buffer;if(n instanceof Document)return sn(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function bl(n){let e=new DataView(n);return e.getUint16(0)===61371&&e.getUint8(2)===191?!0:!(e.getUint16(0)===65279||e.getUint16(0)===65534)}function Xe([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function An(n,e){return n===null?null:e.url===null?n.baseUrl:Tn(n.baseUrl,e.url)}function kn(n,e,t,r,i){var d,f;let a=n;((d=t.cmcdPayload)==null?void 0:d.type)===\"query\"&&(a=ot(a,t.cmcdPayload.value));let o=((f=t.cmcdPayload)==null?void 0:f.type)===\"headers\"?t.cmcdPayload.value:void 0;if(e.range===void 0)return he({url:a,responseType:\"arraybuffer\",headers:o,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));if(e.indexRange===void 0)return he({url:a,headers:oe(ee({},o),{Range:Xe(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));if(e.range[1]+1===e.indexRange[0])return he({url:a,headers:oe(ee({},o),{Range:Xe([e.range[0],e.indexRange[1]])}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));let s=he({url:a,headers:oe(ee({},o),{Range:Xe(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),u=he({url:a,headers:oe(ee({},o),{Range:Xe(e.indexRange)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([s,u]).then(([l,c])=>{let g=_t(new Uint8Array(l.responseData),new Uint8Array(c.responseData)),p=Math.min(l.sendingTime,c.sendingTime),h=Math.max(l.receivedTime,c.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:a,responseData:g,size:l.size+c.size,requestDuration:h-p,sendingTime:p,receivedTime:h}}})}async function xn(n,e,t,r){let i=null;function a(s){let u=new Uint8Array(s.chunk),d=i!==null?_t(i,u):u,f=br(d),l=f[0];i=f[1],!(l!==null&&(l.forEach(c=>{t.onNewChunk(c)}),r.isCancelled()))&&(t.onProgress({duration:s.duration,size:s.size,totalSize:s.totalSize}),r.isCancelled())}return{resultType:\"chunk-complete\",resultData:await lr({url:n,headers:e.headers,onData:a,timeout:e.timeout,connectionTimeout:e.connectionTimeout,cancelSignal:r})}}async function _s(n,e,t,r,i,a){var c,g;if(e.segment.isInit)return kn(n,e.segment,r,a,i);let o=((c=r.cmcdPayload)==null?void 0:c.type)===\"query\"?ot(n,r.cmcdPayload.value):n,s=((g=r.cmcdPayload)==null?void 0:g.type)===\"headers\"?r.cmcdPayload.value:void 0,{segment:u}=e,d;u.range!==void 0?d=oe(ee({},s),{Range:Xe(u.range)}):s!==void 0&&(d=s);let f=He(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(en())return xn(o,{headers:d,timeout:r.timeout,connectionTimeout:r.connectionTimeout},i,a);et(\"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{resultType:\"segment-loaded\",resultData:await he({url:o,responseType:\"arraybuffer\",headers:d,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress})}}function oa({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:Br(r);function r(i,a,o,s,u){let d=An(i,a.segment);return d===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?_s(d,a,n,o,u,s):new Promise((f,l)=>{let c=!1,y={reject:_=>{var R,x;if(c||s.isCancelled())return;c=!0,s.deregister(C);let O=_,k=(R=O==null?void 0:O.message)!=null?R:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",A=new je(k,(x=O==null?void 0:O.canRetry)!=null?x:!1,O==null?void 0:O.xhr);l(A)},resolve:_=>{c||s.isCancelled()||(c=!0,s.deregister(C),f({resultType:\"segment-loaded\",resultData:{responseData:_.data,size:_.size,requestDuration:_.duration}}))},progress:_=>{c||s.isCancelled()||u.onProgress({duration:_.duration,size:_.size,totalSize:_.totalSize})},fallback:()=>{c||s.isCancelled()||(c=!0,s.deregister(C),_s(d,a,n,o,u,s).then(f,l))}},T;a.segment.range!==void 0&&(T=[a.segment.range],a.segment.indexRange!==void 0&&T.push(a.segment.indexRange));let P={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:T,trackType:a.type,url:d,cmcdPayload:o.cmcdPayload},E=e(P,y);s.register(C);function C(_){c||(c=!0,typeof E==\"function\"&&E(),l(_))}})}}var ua=408125543,Rs=357149030,Sl=2807729,yl=17545,Tl=475249515,El=187,_l=179,Rl=183,Pl=241;function bt(n,e,t,[r,i]){let a=r;for(;a<i;){let o=Cl(t,a);if(o===null)return null;let{value:s,length:u}=o,d=a+u,f=Al(t,d);if(f===null)return null;let{length:l,value:c}=f,g=d+l,p=g+c;if(s===n)return[g,p];if(e.length>0){for(let h=0;h<e.length;h++)if(s===e[h]){let b=e.slice(h+1,e.length);return bt(n,b,t,[g,p])}}a=p}return null}function Ur(n,e){let t=bt(Sl,[ua,Rs],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/sa(n,t[0],r)}function vl(n,e){let t=bt(yl,[ua,Rs],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?kl(n,t[0]):r===8?xl(n,t[0]):null}function da(n,e){let t=bt(ua,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=Ur(n,r);if(a===null)return null;let o=vl(n,r);if(o===null)return null;let s=bt(Tl,[],n,[r,i]);if(s===null)return null;let u=[],d=s[0];for(;d<s[1];){let l=bt(El,[],n,[d,s[1]]);if(l===null)break;let c=bt(_l,[],n,[l[0],l[1]]);if(c===null)return null;let g=sa(n,c[0],c[1]-c[0]),p=bt(Pl,[Rl],n,[l[0],l[1]]);if(p===null)return null;let h=sa(n,p[0],p[1]-p[0])+r;u.push({time:g,rangeStart:h}),d=l[1]}let f=[];for(let l=0;l<u.length;l++){let c=u[l];l===u.length-1?f.push({time:c.time,timescale:a,duration:l===0?o:o-c.time,range:[c.rangeStart,1/0]}):f.push({time:c.time,timescale:a,duration:u[l+1].time-c.time,range:[c.rangeStart,u[l+1].rangeStart-1]})}return f}function Ps(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function Cl(n,e){let t=Ps(n,e);if(t===void 0)return m.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return m.warn(\"webm: impossible length\"),null;let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function Al(n,e){let t=Ps(n,e);if(t===void 0)return m.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return m.warn(\"webm: impossible length\"),null;let r=(n[e]&(1<<8-t)-1)*Math.pow(2,(t-1)*8);for(let i=1;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function kl(n,e){return new DataView(n.buffer).getFloat32(e)}function xl(n,e){return new DataView(n.buffer).getFloat64(e)}function sa(n,e,t){let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return r}function Mn(n,e,t,r){let i=Si(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=yi(n);if(a<0&&(o!==void 0&&(o+=a),a=0),e||!t.complete)return o===void 0&&m.warn(\"DASH: Chunked segments should indicate a duration through their trun boxes\"),{time:a/r,duration:o!==void 0?o/r:void 0};let s,u=t.duration*r,d=Math.min(r*.9,u/4);return o!==void 0&&Math.abs(o-u)<=d&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function Ml(n,e){if(n.length<=0)return!1;let t=n.length;for(let r=0;r<t;r++){let i=n[r],a=e,{messageData:o}=i,s=Be(o),u=Date.parse(s);if(a===void 0||u===void 0||isNaN(u)||u>=a)return!0}return!1}function la(n,e){if(n.length===0)return;let{manifestRefreshEventsFromEMSGs:t,EMSGs:r}=n.reduce((o,s)=>(s.schemeIdUri===\"urn:mpeg:dash:event:2012\"&&s.value===\"1\"?(o.manifestRefreshEventsFromEMSGs===void 0&&(o.manifestRefreshEventsFromEMSGs=[]),o.manifestRefreshEventsFromEMSGs.push(s)):(o.EMSGs===void 0&&(o.EMSGs=[]),o.EMSGs.push(s)),o),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),i=r==null?void 0:r.map(o=>({type:\"emsg\",value:o})),a=e===void 0||t===void 0?!1:Ml(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function fa({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var P,E;let{segment:a,periodStart:o,periodEnd:s}=r,{data:u,isChunked:d}=t,f=[o,s];if(u===null)return a.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:f};let l=u instanceof Uint8Array?u:new Uint8Array(u),c=He(r.type,r.mimeType),g=c===\"mp4\"||c===void 0,p=[];if(g){let C=Sr(l),_;a.isInit&&(_=(P=No(l))!=null?P:void 0),(C.length>0||_!==void 0)&&p.push({initDataType:\"cenc\",keyId:_,initData:C})}if(!a.isInit){let C=g?Mn(l,d,a,i):null,_=(E=a.timestampOffset)!=null?E:0;if(g){let O=Do(l);if(O!==void 0){let k=O.filter(R=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(R)),A=la(k,r.manifestPublishTime);if(A!==void 0){let{needsManifestRefresh:R,inbandEvents:x}=A;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:_,appendWindow:f,inbandEvents:x,protectionData:p,needsManifestRefresh:R}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:_,protectionData:p,appendWindow:f}}let{indexRange:h}=a,b;if(c===\"webm\")b=da(l,0);else if(g&&(b=dn(l,Array.isArray(h)?h[0]:0),n===!0&&b!==null&&b.length>0)){let C=b[b.length-1];Array.isArray(C.range)&&(C.range[1]=1/0)}let y;g?y=ln(l):c===\"webm\"&&(y=Ur(l,0));let T=v(y)?void 0:y;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:p,initTimescale:T,segmentList:b!=null?b:void 0}}}function ca({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:Br(t);async function t(r,i,a,o,s){var b,y;let{segment:u}=i,d=An(r,u);if(d===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(u.isInit)return kn(d,u,a,o,s);let f=((b=a.cmcdPayload)==null?void 0:b.type)===\"query\"?ot(d,a.cmcdPayload.value):d,l=((y=a.cmcdPayload)==null?void 0:y.type)===\"headers\"?a.cmcdPayload.value:void 0,c;u.range!==void 0?c=oe(ee({},l),{Range:Xe(u.range)}):l!==void 0&&(c=l);let g=He(i.type,i.mimeType),p=g===\"mp4\"||g===void 0;if(n&&p){if(en())return xn(f,{headers:c,timeout:a.timeout,connectionTimeout:a.connectionTimeout},s,o);et(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}let h;return p?h=await he({url:f,responseType:\"arraybuffer\",headers:c,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}):h=await he({url:f,responseType:\"text\",headers:c,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}),{resultType:\"segment-loaded\",resultData:h}}}function Ol(n){let e=Ii(n);return e===null?\"\":Be(e)}function wl(n){if(n===void 0)throw new Error(\"Cannot parse subtitles: unknown format\");switch(n.toLowerCase()){case\"stpp\":case\"stpp.ttml\":case\"stpp.ttml.im1t\":return\"ttml\";case\"wvtt\":return\"vtt\"}throw new Error(`The codec used for the subtitles \"${n}\" is not managed yet.`)}function Dl(n,e){switch(e){case\"application/ttml+xml\":return\"ttml\";case\"application/x-sami\":case\"application/smil\":return\"sami\";case\"text/vtt\":return\"vtt\"}if(n!==void 0&&n.toLowerCase()===\"srt\")return\"srt\";throw new Error(`could not find a text-track parser for the type ${e!=null?e:\"\"}`)}function vs({segment:n,language:e,codecs:t},r,i,a){if(n.isInit)return null;let o,s;i===null?a?(o=n.time,s=n.end):m.warn(\"Transport: Unavailable time data for current text track.\"):(o=i.time,i.duration!==void 0?s=o+i.duration:!a&&n.complete&&(s=o+n.duration));let u=wl(t);return{data:Ol(r),type:u,language:e,start:o,end:s}}function Cs(n,e,t){let{segment:r}=n;if(r.isInit)return null;let i,a;t?m.warn(\"Transport: Unavailable time data for current text track.\"):(i=r.time,r.complete&&(a=r.time+r.duration));let o=Dl(n.codecs,n.mimeType);return{data:e,type:o,language:n.language,start:i,end:a}}function Nl(n,e,t,r,i){var c;let{segment:a}=t,{isInit:o,indexRange:s}=a,u;if(typeof n==\"string\"?u=sn(n):n instanceof Uint8Array?u=n:u=new Uint8Array(n),o){let g=dn(u,Array.isArray(s)?s[0]:0);if(i===!0&&g!==null&&g.length>0){let h=g[g.length-1];Array.isArray(h.range)&&(h.range[1]=1/0)}let p=ln(u);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:p,segmentList:g!=null?g:void 0}}let d=Mn(u,e,a,r),f=vs(t,u,d,e),l=(c=a.timestampOffset)!=null?c:0;return{segmentType:\"media\",chunkData:f,chunkSize:u.length,chunkInfos:d,chunkOffset:l,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Bl(n,e,t){let{periodStart:r,periodEnd:i,segment:a}=t,{timestampOffset:o=0}=a;if(a.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let s,u;if(typeof n!=\"string\"){let f=n instanceof Uint8Array?n:new Uint8Array(n);s=Be(f),u=f.length}else s=n;return{segmentType:\"media\",chunkData:Cs(t,s,e),chunkSize:u,chunkInfos:null,chunkOffset:o,protectionData:[],appendWindow:[r,i]}}function ma({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var l;let{periodStart:a,periodEnd:o,segment:s}=r,{data:u,isChunked:d}=t;if(u===null)return s.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:(l=s.timestampOffset)!=null?l:0,protectionData:[],appendWindow:[a,o]};let f=He(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?Nl(u,d,r,i,n):Bl(u,d,r)}}function As(n){let e=ra({customManifestLoader:n.manifestLoader},Ul()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?Es:null),t=aa(n),r=oa(n),i=fa(n),a=ca(n),o=ma(n);return{transportName:\"dash\",manifest:{loadManifest:e,parseManifest:t},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:o}}}function Ul(){return we.dashParsers.wasm!==null&&(we.dashParsers.wasm.status===\"initialized\"||we.dashParsers.wasm.status===\"initializing\")}var ks=As;var xt=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var Mt=class{constructor(e){this._array=[],this._sortingFn=e}add(...e){e.sort(this._sortingFn);let t=0;for(let r=0;r<e.length;r++){let i=e[r],a=!1;for(;!a&&t<this._array.length;)this._sortingFn(i,this._array[t])<0?(this._array.splice(t,0,i),a=!0):t++;a||this._array.push(i)}}length(){return this._array.length}get(e){if(e<0||e>=this._array.length)throw new Error(\"Invalid index.\");return this._array[e]}toArray(){return this._array.slice()}findFirst(e){return Q(this._array,e)}has(e){return ge(this._array,e)}removeElement(e){let t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t}head(){return this._array[0]}last(){return this._array[this._array.length-1]}shift(){return this._array.shift()}pop(){return this._array.pop()}};var On=class{constructor(e){this._weakMap=new WeakMap,this._fn=e}get(e){let t=this._weakMap.get(e);if(t===void 0){let r=this._fn(e);return this._weakMap.set(e,r),r}else return t}destroy(e){this._weakMap.delete(e)}};var Ll=.016666666666666666;function xs(n,e){return Math.abs(n-e)<Ll}function Os(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function Fl(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function zl(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(Ds(t,r)){let i=Os(t,r);n.splice(--e,2,i)}}return n}function pa(n,e){return n.end<=e.start}function Ms({start:n,end:e},t){return n<=t&&t<e}function ws(n,e){return Ms(n,e.start)||n.start<e.end&&e.end<n.end||Ms(e,n.start)}function Ds(n,e){return xs(e.start,n.end)||xs(e.end,n.start)}function ga(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function Wl(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t].start;if(e>=r){let i=n[t].end;if(e<i)return n[t]}}return null}function Ns(n,e){let t=null,r=[];for(let i=0;i<n.length;i++){let a=n[i].start,o=n[i].end;e<a||e>=o?r.push({start:a,end:o}):t={start:a,end:o}}return{outerRanges:r,innerRange:t}}function Lr(n,e){let t=Wl(n,e);return t!==null?t.end-e:1/0}function Ht(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=ws(t,i),o=Ds(t,i);if(a||o)t=Os(t,i),n.splice(r--,1);else if(r===0){if(pa(t,n[0]))break}else if(pa(n[r-1],t)&&pa(t,i))break}return n.splice(r,0,t),zl(Fl(n))}function Vl(n,e){let t=[];for(let r=0;r<e.length;r++)ws(n,e[r])&&t.push(e[r]);return t}function Fr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=Vl(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let u=0;u<a.length;u++)a[u].start>s&&t.push({start:s,end:a[u].start}),s=a[u].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function zr({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(u=>{a=u.position.getWanted(),o=u.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&ql(n,a,o,t.getValue(),r.getValue(),i).catch(u=>{let d=u instanceof Error?u.message:\"Unknown error\";m.error(\"Could not run BufferGarbageCollector:\",d)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function ql(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:u}=Ns(t,e),d=()=>{if(isFinite(r)){for(let l of u)e-r>=l.end?o.push(l):e>=l.end&&e-r>l.start&&e-r<l.end&&o.push({start:l.start,end:e-r});v(s)||e-r>s.start&&o.push({start:s.start,end:e-r})}},f=()=>{if(isFinite(i)){for(let l of u)e+i<=l.start?o.push(l):e<=l.start&&e+i<l.end&&e+i>l.start&&o.push({start:e+i,end:l.end});v(s)||e+i<s.end&&o.push({start:e+i,end:s.end})}};d(),f();for(let l of o)if(l.start<l.end){if(m.debug(\"GC: cleaning range from SegmentSink\",l.start,l.end),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(l.start,l.end)}}var wn=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=L();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>Je(t.context,e))}_cleanHistory(e){let t=e-this._lifetime,r=0;for(let i of this._history)if(i.date<t)r++;else break;if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){let i=this._history.length-this._maxHistoryLength;this._history=this._history.splice(i)}}};var Dn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=F.getCurrent();this._inventory=[],this._bufferedHistory=new wn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var u,d,f,l,c,g,p;let t=this._inventory,r=0,i=t[0],{MINIMUM_SEGMENT_SIZE:a}=F.getCurrent(),o=i==null?void 0:i.infos.adaptation.type;if(m.hasLevel(\"DEBUG\")){let h=e.map(b=>`${b.start}-${b.end}`).join(\",\");m.debug(`SI: synchronizing ${o!=null?o:\"unknown\"} buffered ranges:`,h)}let s=e.length;for(let h=0;h<s;h++){if(i===void 0)return;let b=e[h].start,y=e[h].end;if(y-b<a){m.warn(\"SI: skipped range when synchronizing because it was too small\",o,b,y);continue}let T=r;for(;i!==void 0&&((u=i.bufferedEnd)!=null?u:i.end)-b<a;)i=t[++r];let P=null,E=r-T;if(E>0){let _=t[T+E-1];P={end:(d=_.bufferedEnd)!=null?d:_.end,precizeEnd:_.precizeEnd},m.debug(`SI: ${E} segments GCed.`,o);let O=t.splice(T,E);for(let k of O)k.bufferedStart===void 0&&k.bufferedEnd===void 0&&k.status!==2&&this._bufferedHistory.addBufferedSegment(k.infos,null);r=T}if(i===void 0)return;if(y-((f=i.bufferedStart)!=null?f:i.start)>=a){if(Hl(i,b,P,o),r===t.length-1){Us(i,y,o);return}i=t[++r];let _=(l=i.bufferedStart)!=null?l:i.start,O=(c=i.bufferedEnd)!=null?c:i.end,k=h<s-1?e[h+1].start:void 0;for(;i!==void 0&&!(y<_||y-_<a&&O-y>=a||k!==void 0&&y-_<O-k);){let A=t[r-1];A.bufferedEnd===void 0&&(i.precizeStart?A.bufferedEnd=i.start:A.infos.segment.complete?A.bufferedEnd=A.end:A.bufferedEnd=i.start,m.debug(\"SI: calculating buffered end of contiguous segment\",o,A.bufferedEnd,A.end)),i.bufferedStart=A.bufferedEnd,i=t[++r],i!==void 0&&(_=(g=i.bufferedStart)!=null?g:i.start,O=(p=i.bufferedEnd)!=null?p:i.end)}}let C=t[r-1];C!==void 0&&Us(C,y,o)}if(!v(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:h}=F.getCurrent(),b=L();for(let y=r;y<t.length;y++){let T=t[y];b-T.insertionTs>=h&&(m.debug(\"SI: A segment at the end has been completely GCed\",o,`${T.start}-${T.end}`),T.bufferedStart===void 0&&T.bufferedEnd===void 0&&T.status!==2&&this._bufferedHistory.addBufferedSegment(T.infos,null),t.splice(y,1),y--)}}o!==void 0&&m.hasLevel(\"DEBUG\")&&m.debug(`SI: current ${o} inventory timeline:\n`+Gl(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},u,d){if(i.isInit)return;let f=t.type;if(o>=s){m.warn(\"SI: Invalid chunked inserted: starts before it ends\",f,o,s);return}let l=this._inventory,c={status:u?0:2,insertionTs:d,chunkSize:a,splitted:!1,start:o,end:s,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:i,period:e,adaptation:t,representation:r}};for(let p=l.length-1;p>=0;p--){let h=l[p];if(h.start<=o)if(h.end<=o){for(m.debug(\"SI: Pushing segment strictly after previous one.\",f,o,h.end),this._inventory.splice(p+1,0,c),p+=2;p<l.length&&l[p].start<c.end;){if(l[p].end>c.end){m.debug(\"SI: Segment pushed updates the start of the next one\",f,c.end,l[p].start),l[p].start=c.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&c.precizeEnd;return}m.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else if(h.start===o)if(h.end<=s){for(m.debug(\"SI: Segment pushed replace another one\",f,o,s,h.end),this._inventory.splice(p,1,c),p+=1;p<l.length&&l[p].start<c.end;){if(l[p].end>c.end){m.debug(\"SI: Segment pushed updates the start of the next one\",f,c.end,l[p].start),l[p].start=c.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&c.precizeEnd;return}m.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else{m.debug(\"SI: Segment pushed ends before another with the same start\",f,o,s,h.end),l.splice(p,0,c),h.start=c.end,h.bufferedStart=void 0,h.precizeStart=h.precizeStart&&c.precizeEnd;return}else if(h.end<=c.end){for(m.debug(\"SI: Segment pushed updates end of previous one\",f,o,s,h.start,h.end),this._inventory.splice(p+1,0,c),h.end=c.start,h.bufferedEnd=void 0,h.precizeEnd=h.precizeEnd&&c.precizeStart,p+=2;p<l.length&&l[p].start<c.end;){if(l[p].end>c.end){m.debug(\"SI: Segment pushed updates the start of the next one\",f,c.end,l[p].start),l[p].start=c.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&c.precizeEnd;return}m.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else{m.warn(\"SI: Segment pushed is contained in a previous one\",f,o,s,h.start,h.end);let b={status:h.status,insertionTs:h.insertionTs,chunkSize:h.chunkSize,splitted:!0,start:c.end,end:h.end,precizeStart:h.precizeStart&&h.precizeEnd&&c.precizeEnd,precizeEnd:h.precizeEnd,bufferedStart:void 0,bufferedEnd:h.end,infos:h.infos};h.end=c.start,h.splitted=!0,h.bufferedEnd=void 0,h.precizeEnd=h.precizeEnd&&c.precizeStart,l.splice(p+1,0,c),l.splice(p+2,0,b);return}}let g=this._inventory[0];if(g===void 0){m.debug(\"SI: first segment pushed\",f,o,s),this._inventory.push(c);return}if(g.start>=s)m.debug(\"SI: Segment pushed comes before all previous ones\",f,o,s,g.start),this._inventory.splice(0,0,c);else if(g.end<=s){for(m.debug(\"SI: Segment pushed starts before and completely recovers the previous first one\",f,o,s,g.start,g.end),this._inventory.splice(0,1,c);l.length>1&&l[1].start<c.end;){if(l[1].end>c.end){m.debug(\"SI: Segment pushed updates the start of the next one\",f,c.end,l[1].start),l[1].start=c.end,l[1].bufferedStart=void 0,l[1].precizeStart=c.precizeEnd;return}m.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[1].start,l[1].end),l.splice(1,1)}return}else{m.debug(\"SI: Segment pushed start of the next one\",f,o,s,g.start,g.end),g.start=s,g.bufferedStart=void 0,g.precizeStart=c.precizeEnd,this._inventory.splice(0,0,c);return}}completeSegment(e){if(e.segment.isInit)return;let t=this._inventory,r=[];for(let i=0;i<t.length;i++)if(Je(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(m.warn(\"SI: Completed Segment is splitted.\",e.segment.id,e.segment.time,e.segment.end),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&Je(t[i].infos,e);){let c=t[i].chunkSize;s!==void 0&&c!==void 0&&(s+=c),i++}let u=i-1,d=u-o,f=t[u].end,l=t[u].bufferedEnd;d>0&&(this._inventory.splice(o+1,d),i-=d),this._inventory[o].status===0&&(this._inventory[o].status=1),this._inventory[o].chunkSize=s,this._inventory[o].end=f,this._inventory[o].bufferedEnd=l,this._inventory[o].splitted=a,r.push(this._inventory[o])}if(r.length===0)m.warn(\"SI: Completed Segment not found\",e.segment.id,e.segment.time);else for(let i of r)i.bufferedStart!==void 0&&i.bufferedEnd!==void 0?i.status!==2&&this._bufferedHistory.addBufferedSegment(i.infos,{start:i.bufferedStart,end:i.bufferedEnd}):m.debug(\"SI: buffered range not known after sync. Skipping history.\",i.start,i.end)}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function ha(n){if(n.bufferedStart===void 0||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=F.getCurrent();return Math.abs(e-n.bufferedStart)<=i&&(n.bufferedEnd===void 0||n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3))}function Bs(n){if(n.bufferedEnd===void 0||!n.infos.segment.complete||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=F.getCurrent();return Math.abs(t-n.bufferedEnd)<=i&&n.bufferedStart!==void 0&&n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3)}function Hl(n,e,t,r){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MISSING_DATA_TRIGGER_SYNC_DELAY:a,SEGMENT_SYNCHRONIZATION_DELAY:o}=F.getCurrent();if(n.bufferedStart!==void 0)n.bufferedStart<e&&(m.debug(\"SI: Segment partially GCed at the start\",r,n.bufferedStart,e),n.bufferedStart=e),!n.precizeStart&&ha(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)m.debug(\"SI: buffered start is precize start\",r,n.start),n.bufferedStart=n.start;else if(t!==null&&t.end>e&&(t.precizeEnd||n.start-t.end<=i))m.debug(\"SI: buffered start is end of previous segment\",r,e,n.start,t.end),n.bufferedStart=t.end,ha(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=L();if(n.start-e>=a&&s-n.insertionTs<o){m.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}m.debug(\"SI: found true buffered start\",r,e,n.start),n.bufferedStart=e,ha(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)m.debug(\"SI: range start too far from expected start\",r,e,n.start),n.bufferedStart=n.start;else{let s=L();if(n.start-e>=a&&s-n.insertionTs<o){m.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}m.debug(\"SI: Segment appears immediately garbage collected at the start\",r,e,n.start),n.bufferedStart=e}}function Us(n,e,t){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:r,MISSING_DATA_TRIGGER_SYNC_DELAY:i,SEGMENT_SYNCHRONIZATION_DELAY:a}=F.getCurrent();if(n.bufferedEnd!==void 0)n.bufferedEnd>e&&(m.debug(\"SI: Segment partially GCed at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&Bs(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)m.debug(\"SI: buffered end is precize end\",t,n.end),n.bufferedEnd=n.end;else if(e-n.end<=r||!n.infos.segment.complete){let o=L();if(e-n.end>=i&&o-n.insertionTs<a){m.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}m.debug(\"SI: found true buffered end\",t,e,n.end),n.bufferedEnd=e,Bs(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)m.debug(\"SI: range end too far from expected end\",t,e,n.end),n.bufferedEnd=n.end;else{let o=L();if(e-n.end>=i&&o-n.insertionTs<a){m.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}m.debug(\"SI: Segment appears immediately garbage collected at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e}}function Gl(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(u){let d=String.fromCharCode(r.length+65);return r.push({letter:d,periodId:u.period.id,representationId:u.representation.id,bitrate:u.representation.bitrate}),d}let s=\"\";for(let u of n)if(u.bufferedStart!==void 0&&u.bufferedEnd!==void 0){let d=u.infos.period.id,f=u.infos.representation.id,l=t[d],c;if(l===void 0)c=o(u.infos),t[d]={[f]:c};else{let g=l[f];g===void 0?(c=o(u.infos),l[f]=c):c=g}i===null?s+=`${u.bufferedStart.toFixed(2)}|${c}|`:a===c?i.bufferedEnd+e<u.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${u.bufferedStart.toFixed(2)}|${c}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${u.bufferedStart.toFixed(2)}|${c}|`,i=u,a=c}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(u=>{var d;s+=`\n[${u.letter}] P: ${u.periodId} || R: ${u.representationId}(${(d=u.bitrate)!=null?d:\"unknown bitrate\"})`}),s}function Gt(n,e){for(let t=0;t<n.length;t++)if(n[t].infos.period.start>=e.start)return t>0?n[t-1]:null;return n.length>0?n[n.length-1]:null}function Kt(n,e){for(let t of n)if(t.infos.period.start>e.start)return t;return null}var Ls=Dn;var jt=class{constructor(){this._segmentInventory=new Ls}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var Nn=class extends jt{constructor(e,t,r){super(),m.info(\"AVSB: calling `mediaSource.addSourceBuffer`\",t);let i=r.addSourceBuffer(e,t);this.bufferType=e,this._sourceBuffer=i,this._lastInitSegmentUniqueId=null,this.codec=t,this._initSegmentsMap=new Map,this._pendingOperations=[]}declareInitSegment(e,t){Fs(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){Fs(e.data.chunk),m.debug(\"AVSB: receiving order to push data to the SourceBuffer\",this.bufferType,Tt(e.inventoryInfos));let t=this._getActualDataToPush(e.data);t.length===0&&t.push(new Uint8Array);let r=Promise.all(t.map(o=>{let{codec:s,timestampOffset:u,appendWindow:d}=e.data;return m.debug(\"AVSB: pushing segment\",this.bufferType,Tt(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:u,appendWindow:d})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,L()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){m.debug(\"AVSB: receiving order to remove data from the SourceBuffer\",this.bufferType,e,t);let r=this._sourceBuffer.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){try{m.debug(\"AVSB: Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose()}catch(e){m.debug(`AVSB: Failed to dispose a ${this.bufferType} SourceBufferInterface:`,e instanceof Error?e:\"\")}}_getActualDataToPush(e){let t=[];if(e.initSegmentUniqueId!==null&&!this._isLastInitSegment(e.initSegmentUniqueId)){let r=this._initSegmentsMap.get(e.initSegmentUniqueId);if(r===void 0)throw new Error(\"Invalid initialization segment uniqueId\");let i=new ArrayBuffer(r.byteLength),a=new Uint8Array(i);a.set(r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer)),r=a,t.push(r),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return e.chunk!==null&&t.push(e.chunk),t}_isLastInitSegment(e){return this._lastInitSegmentUniqueId===null?!1:this._lastInitSegmentUniqueId===e}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function Fs(n){if(I.CURRENT_ENV!==I.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var Vr=Nn;var Bn=class extends jt{constructor(e){m.debug(\"HTSB: Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){m.warn(\"HTSB: Declaring initialization segment for Text SegmentSink\",e)}freeInitSegment(e){m.warn(\"HTSB: Freeing initialization segment for Text SegmentSink\",e)}async pushChunk(e){let{data:t}=e;jl(t.chunk);let r=this._sender.pushTextData(oe(ee({},t),{chunk:t.chunk}));this._addToOperationQueue(r,{type:0,value:e});let i=await r;return e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L()),this._segmentInventory.synchronizeBuffered(i),i}async removeBuffer(e,t){let r=this._sender.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){m.debug(\"HTSB: Disposing TextSegmentSink\"),this._sender.reset()}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function jl(n){if(I.CURRENT_ENV!==I.PRODUCTION&&(typeof n!=\"object\"||n===null||typeof n.data!=\"string\"||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\"))throw new Error(\"Invalid format given to a TextSegmentSink\")}I.CURRENT_ENV===I.DEV&&(Yl=function(e){function t(r){}});var Yl;var zs=Bn;var Ql=[\"audio\",\"video\",\"text\"],Un=class n{static isNative(e){return Ws(e)}constructor(e,t,r){this._mediaSource=e,this._textInterface=r,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}getBufferTypes(){let e=this.getNativeBufferTypes();return this._textInterface!==null&&e.push(\"text\"),e}getNativeBufferTypes(){return this._hasVideo?[\"video\",\"audio\"]:[\"audio\"]}getStatus(e){let t=this._initializedSegmentSinks[e];return t===void 0?{type:\"uninitialized\"}:t===null?{type:\"disabled\"}:{type:\"initialized\",value:t}}waitForUsableBuffers(e){return this._areNativeBuffersUsable()?Promise.resolve():Et(e,t=>{let r=D,i=()=>{let a=this._onNativeBufferAddedOrDisabled.indexOf(r);a>=0&&this._onNativeBufferAddedOrDisabled.splice(a,1)};return r=()=>{this._areNativeBuffersUsable()&&(i(),t())},this._onNativeBufferAddedOrDisabled.push(r),i})}disableSegmentSink(e){let t=this._initializedSegmentSinks[e];if(t===null){m.warn(`SBS: The ${e} SegmentSink was already disabled.`);return}if(t!==void 0)throw new Error(\"Cannot disable an active SegmentSink.\");this._initializedSegmentSinks[e]=null,n.isNative(e)&&(this._onNativeBufferAddedOrDisabled.slice().forEach(r=>r()),ce(this._onNativeBufferAddedOrDisabled.length===0))}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(Ws(e)){if(!v(r))return r instanceof Vr&&r.codec!==t?m.warn(\"SB: Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):m.info(\"SB: Reusing native SegmentSink with codec\",t),r;m.info(\"SB: Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new Vr(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.slice().forEach(s=>s()),ce(this._onNativeBufferAddedOrDisabled.length===0),o}if(!v(r))return m.info(\"SB: Reusing a previous custom SegmentSink for the type\",e),r;let i;if(e===\"text\"){if(m.info(\"SB: Creating a new text SegmentSink\"),this._textInterface===null)throw new Error(\"HTML Text track feature not activated\");return i=new zs(this._textInterface),this._initializedSegmentSinks.text=i,i}throw m.error(\"SB: Unknown buffer type:\",e),new X(\"BUFFER_TYPE_UNKNOWN\",\"The player wants to create a SegmentSink of an unknown type.\")}disposeSegmentSink(e){let t=this._initializedSegmentSinks[e];if(v(t)){m.warn(\"SB: Trying to dispose a SegmentSink that does not exist\");return}m.info(\"SB: Aborting SegmentSink\",e),t.dispose(),delete this._initializedSegmentSinks[e]}disposeAll(){Ql.forEach(e=>{this.getStatus(e).type===\"initialized\"&&this.disposeSegmentSink(e)})}_areNativeBuffersUsable(){let e=this.getNativeBufferTypes();return!(e.some(i=>this._initializedSegmentSinks[i]===void 0)||e.every(i=>this._initializedSegmentSinks[i]===null))}createSegmentSinkMetricsForType(e){var i,a;let t=(i=this._initializedSegmentSinks[e])==null?void 0:i.getLastKnownInventory(),r;if(t!==void 0){r=0;for(let o of t){if(o.chunkSize===void 0||r===void 0){r=void 0;break}r+=o.chunkSize}}return{bufferType:e,sizeEstimate:r,codec:(a=this._initializedSegmentSinks[e])==null?void 0:a.codec,segmentInventory:t==null?void 0:t.map(o=>oe(ee({},o),{infos:$l(o.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function Ws(n){return n===\"audio\"||n===\"video\"}function $l(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var St=Un;function Ia(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,u=Xl(i,e);if(u===null){if(t===null){if(r&&a.end!==void 0&&e.end>=a.end)return{start:void 0,end:null};let l=s.index.checkDiscontinuity(e.start);if(l!==null)return{start:void 0,end:l}}return null}let d=i[u];if(d.bufferedStart!==void 0&&d.bufferedStart>e.start&&(t===null||d.infos.segment.end<=t)){let l=d.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,l)!==!1?null:(m.debug(\"RS: current discontinuity encountered\",o.type,d.bufferedStart),{start:void 0,end:l})}let f=Zl(i,e,u+1);if(f!==null){let l=i[f-1],c=i[f];if(t===null||c.infos.segment.end<=t){if(!r&&s.index.awaitSegmentBetween(l.infos.segment.end,c.infos.segment.time)!==!1)return null;let g=l.bufferedEnd,p=c.bufferedStart;return m.debug(\"RS: future discontinuity encountered\",o.type,g,p),{start:g,end:p}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let l=Jl(i,a.end);if(l!==null){let c=i[l];if(c.bufferedEnd!==void 0&&c.bufferedEnd<a.end)return m.debug(\"RS: discontinuity encountered at the end of the current period\",o.type,c.bufferedEnd,a.end),{start:c.bufferedEnd,end:null}}}if(a.end!==void 0&&e.end>=a.end)return null;for(let l=i.length-1;l>=0;l--){let c=i[l];if(c.bufferedStart===void 0)break;if(c.bufferedStart<e.end){if(c.bufferedEnd!==void 0&&c.bufferedEnd<e.end){let g=s.index.checkDiscontinuity(e.end);if(g!==null)return{start:c.bufferedEnd,end:g}}return null}}}return null}function Xl(n,e){for(let t=0;t<n.length;t++){let r=n[t];if(r.bufferedStart===void 0||r.bufferedEnd===void 0||r.bufferedStart>=e.end)return null;if(r.bufferedEnd>e.start)return t}return null}function Zl(n,e,t){if(t<=0)return m.error(\"RS: Asked to check a discontinuity before the first chunk.\"),null;for(let r=t;r<n.length;r++){let i=n[r],a=n[r-1];if(i.bufferedStart===void 0||a.bufferedEnd===void 0||i.bufferedStart>=e.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}function Jl(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t];if(r.bufferedStart===void 0)return null;if(r.bufferedStart<e)return t}return null}function ba({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:u,representation:d}=e,f=ef(n,o,s),l=d.index.getSegments(a.start,a.end-a.start),c=n.filter(C=>!Vs(C.infos,e,t,r)),g=uf(c,a,i),{MINIMUM_SEGMENT_SIZE:p,MIN_BUFFER_AHEAD:h}=F.getCurrent(),b=!1,y=Math.min(1/60,p),T=!1,P=[];return{segmentsToLoad:l.filter(C=>{let _=G({segment:C},e);if(o.length>0&&o.some(w=>Je(_,w)))return!1;let{duration:O,time:k,end:A}=C;if(C.isInit)return!0;if(b)return P.push(C),!1;if(C.complete&&O<p||o.length>0&&o.some(w=>{if(w.period.id!==e.period.id||w.adaptation.id!==e.adaptation.id)return!1;let{segment:M}=w;if(M.time-y>k)return!1;if(M.complete){if(M.end+y<A)return!1}else if(Math.abs(k-M.time)>k)return!1;return!Vs(w,_,t,r)}))return!1;for(let N of g){let w=N.infos.period.id===e.period.id;if(N.status===1&&w){let M=N.infos.segment;if(k-M.time>-y){if(M.complete){if(M.end-A>-y)return!1}else if(Math.abs(k-M.time)<y)return!1}}}let R=O*e.representation.bitrate;if(f-R<0&&(T=!0,k>a.start+h))return b=!0,P.push(C),!1;let x=i(_);if(x.length>1){let N=x[x.length-1],w=x[x.length-2];if(N.buffered===null&&w.buffered===null)return m.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.\"+u.type,d.id,C.time),!1}for(let N=0;N<g.length;N++){let w=g[N];if(w.end+y>k){let M=w.start>k+y||tf(g,N).end<A-y;return M&&(f-=R),M}}return f-=R,!0}),segmentsOnHold:P,isBufferFull:T}}function ef(n,e,t){let r=t*8e3;return r-=e.reduce((i,a)=>{let{bitrate:o}=a.representation,{duration:s}=a.segment;return i+o*s},0),n.reduce((i,a)=>a.chunkSize!==void 0?i-a.chunkSize*8:i,r)}function tf(n,e){let t=e+1,{MINIMUM_SEGMENT_SIZE:r}=F.getCurrent(),i=Math.min(1/60,r);for(;t<n.length-1&&n[t-1].end+i>n[t].start;)t++;return t--,n[t]}function Vs(n,e,t,r){let{CONTENT_REPLACEMENT_PADDING:i}=F.getCurrent();if(n.period.id!==e.period.id)return!1;let{segment:a}=n;return a.time<t+i?!1:n.adaptation.id!==e.adaptation.id?!0:nf(n.representation,e.representation,r)}function nf(n,e,t){let r=n.bitrate,{BITRATE_REBUFFERING_RATIO:i}=F.getCurrent();if(t===void 0){let a=r*i;return e.bitrate>a}return r<t&&e.bitrate>r}function rf(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=F.getCurrent();return n.bufferedStart===void 0||e!==null&&e.bufferedEnd!==void 0&&n.bufferedStart-e.bufferedEnd<.1?!1:t<n.bufferedStart&&n.bufferedStart-n.start>r?(m.info(\"Stream: The start of the wanted segment has been garbage collected\",n.start,n.bufferedStart),!0):!1}function af(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=F.getCurrent();return n.bufferedEnd===void 0||e!==null&&e.bufferedStart!==void 0&&e.bufferedStart-n.bufferedEnd<.1?!1:t>n.bufferedEnd&&n.end-n.bufferedEnd>r?(m.info(\"Stream: The end of the wanted segment has been garbage collected\",n.end,n.bufferedEnd),!0):!1}function of(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.start;if(e!==void 0&&r!==void 0&&e-r>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.start;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function sf(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.end;if(e!==void 0&&r!==void 0&&r-e>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.end;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function uf(n,e,t){return n.filter((r,i,a)=>{let o=i===0?null:a[i-1],s=i>=a.length-1?null:a[i+1],u=null;if(rf(r,o,e.start)){if(u=t(r.infos),of(u,r.bufferedStart))return!1;m.debug(\"Stream: skipping segment gc-ed at the start\",r.start,r.bufferedStart)}if(af(r,s,e.end)){if(u=u!=null?u:t(r.infos),sf(u,r.bufferedEnd))return!1;m.debug(\"Stream: skipping segment gc-ed at the end\",r.end,r.bufferedEnd)}return!0})}function Ln(n,e){let t=n-e,{SEGMENT_PRIORITIES_STEPS:r}=F.getCurrent();for(let i=0;i<r.length;i++)if(t<r[i])return i;return r.length}function Sa(n,e,t,r,i,a,o){var k,A,R;let{representation:s}=n,u=(A=(k=t.getIsPaused())!=null?k:t.getReference().getValue().paused.pending)!=null?A:t.getReference().getValue().paused.last,d=(R=t.getPlaybackRate())!=null?R:t.getReference().getValue().speed,f=e;(u===void 0||d===void 0||u||d<=0)&&(f-=.1);let l=df(n,f,i),c=s.index.shouldRefresh(l.start,l.end),g=o.getPendingOperations().filter(x=>x.type===2).map(x=>x.value),p=o.getLastKnownInventory(),h=t.getCurrentTime();h===void 0&&(h=t.getReference().getValue().position.getWanted());let b=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:T,isBufferFull:P}=ba({content:n,bufferedSegments:p,currentPlaybackTime:h,fastSwitchThreshold:r,getBufferedHistory:b,neededRange:l,segmentsBeingPushed:g,maxBufferSize:a}),E=y.map(x=>({priority:Ln(x.time,f),segment:x})),C=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&E.length===0&&T.length===0,_=null;return g.length>0&&(_=Math.min(...g.map(x=>x.segment.time))),T.length>0&&(_=_!==null?Math.min(_,T[0].time):T[0].time),E.length>0&&(_=_!==null?Math.min(_,E[0].segment.time):E[0].segment.time),{imminentDiscontinuity:Ia(n,l,_,C,p),hasFinishedLoading:C,neededSegments:E,isBufferFull:P,shouldRefreshManifest:c}}function df(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),u=o.index;!v(s)&&St.isNative(n.adaptation.type)&&e>=s&&u.isInitialized()&&!u.isStillAwaitingFutureSegments()&&lf(i,a,e)?r=s-1:r=e-.1;let d=r+t,f;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?f=!1:s===void 0?f=d>=a.end:s===null?f=!0:f=d>=s,{start:Math.max(r,a.start),end:Math.min(d,(l=a.end)!=null?l:1/0),hasReachedPeriodEnd:f}}function lf(n,e,t){var i;let r=n.getPeriodAfter(e);return e.containsTime(t,r)&&n.isLastPeriodKnown&&e.id===((i=n.periods[n.periods.length-1])==null?void 0:i.id)}async function Fn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof ue)throw a;if(!(a instanceof Ce)||!a.isBufferFull){let u=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new X(\"BUFFER_APPEND_ERROR\",u,{tracks:[lt(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{m.warn(\"Stream: Running garbage collector\");let u=Math.max(s-5,0),d=s+r.getValue()+12;if(u>0&&await e.removeBuffer(0,u),d<Number.MAX_VALUE&&await e.removeBuffer(d,Number.MAX_VALUE),await li(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(u){if(u instanceof ue)throw u;let d=u instanceof Error?u.toString():\"Could not clean the buffer\";throw new X(\"BUFFER_FULL_ERROR\",d,{tracks:[lt(t.inventoryInfos.adaptation)]})}}}async function ya({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){if(o.cancellationError!==null)throw o.cancellationError;let s=e.representation.getMimeTypeString(),u={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},d=G({segment:r,chunkSize:void 0,start:0,end:0},e),f=await Fn(n,i,{data:u,inventoryInfos:d},a,o);return{content:e,segment:r,buffered:f}}async function Ta({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var _,O;if(i.chunkData===null)return null;if(s.cancellationError!==null)throw s.cancellationError;let{chunkData:u,chunkInfos:d,chunkOffset:f,chunkSize:l,appendWindow:c}=i,g=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:p}=F.getCurrent(),h=[c[0]!==void 0?Math.max(0,c[0]-p.START):void 0,c[1]!==void 0?c[1]+p.END:void 0],b={initSegmentUniqueId:r,chunk:u,timestampOffset:f,appendWindow:h,codec:g},y=(_=d==null?void 0:d.time)!=null?_:a.time,T=(O=d==null?void 0:d.duration)!=null?O:a.duration,P=y+T;h[0]!==void 0&&(y=Math.max(y,h[0])),h[1]!==void 0&&(P=Math.min(P,h[1]));let E=G({segment:a,chunkSize:l,start:y,end:P},t),C=await Fn(n,o,{data:b,inventoryInfos:E},e,s);return{content:t,segment:a,buffered:C}}function Ea({content:n,options:e,playbackObserver:t,segmentSink:r,segmentQueue:i,terminate:a},o,s){m.debug(\"Stream: Creating RepresentationStream\",n.adaptation.type,n.representation.bitrate);let{period:u,adaptation:d,representation:f}=n,{bufferGoal:l,maxBufferSize:c,drmSystemId:g,fastSwitchThreshold:p}=e,h=d.type,b=new W;b.linkToSignal(s);let y=new W;y.linkToSignal(b.signal);let T={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};b.signal.register(()=>{T.uniqueId!==null&&r.freeInitSegment(T.uniqueId)});let P=T.segment!==null;P||(T.isLoaded=!0);let E=!1;if(g!==void 0){let A=f.getEncryptionData(g);if(A.length>0&&A.every(R=>R.keyIds!==void 0)&&(E=!0,o.encryptionDataEncountered(A.map(R=>G({content:n},R))),b.isUsed()))return}i.addEventListener(\"error\",A=>{y.signal.isCancelled()||(b.cancel(),o.error(A))}),i.addEventListener(\"parsedInitSegment\",O,y.signal),i.addEventListener(\"parsedMediaSegment\",O,y.signal),i.addEventListener(\"emptyQueue\",_,y.signal),i.addEventListener(\"requestRetry\",A=>{if(o.warning(A.error),y.signal.isCancelled())return;let R=A.segment,{index:x}=f;x.isSegmentStillAvailable(R)===!1?_():x.canBeOutOfSyncError(A.error,R)&&o.manifestMightBeOufOfSync()},y.signal),i.addEventListener(\"fullyLoadedSegment\",A=>{r.signalSegmentComplete(G({segment:A},n)).catch(k)},y.signal);let C=i.resetForContent(n,P);y.signal.register(()=>{i.stop()}),t.listen(_,{includeLastObservation:!1,clearSignal:y.signal}),n.manifest.addEventListener(\"manifestUpdate\",_,y.signal),l.onUpdate(_,{emitCurrentValue:!1,clearSignal:y.signal}),c.onUpdate(_,{emitCurrentValue:!1,clearSignal:y.signal}),a.onUpdate(_,{emitCurrentValue:!1,clearSignal:y.signal}),_();return;function _(){if(y.isUsed())return;let A=t.getReference().getValue(),R=A.position.getWanted(),x=Sa(n,R,t,p.getValue(),l.getValue(),c.getValue(),r),{neededSegments:N}=x,w=null;if(f.index.isInitialized()){if(N.length>0&&!T.isLoaded&&T.segment!==null){let U=N[0].priority;w={segment:T.segment,priority:U}}}else if(T.segment===null)m.warn(\"Stream: Uninitialized index without an initialization segment\");else if(T.isLoaded)m.warn(\"Stream: Uninitialized index with an already loaded initialization segment\");else{let U=A.position.getWanted();w={segment:T.segment,priority:Ln(u.start,U)}}let M=a.getValue();if(M===null)C.setValue({initSegment:w,segmentQueue:N});else if(M.urgent){m.debug(\"Stream: Urgent switch, terminate now.\",h),C.setValue({initSegment:null,segmentQueue:[]}),C.finish(),y.cancel(),o.terminating();return}else{let U=N[0],V=i.getRequestedInitSegment(),Z=i.getRequestedMediaSegment(),Y=Z===null||U===void 0||Z.id!==U.segment.id?[]:[U],H=V===null?null:w;if(C.setValue({initSegment:H,segmentQueue:Y}),Y.length===0&&H===null){m.debug(\"Stream: No request left, terminate\",h),C.finish(),y.cancel(),o.terminating();return}}if(o.streamStatusUpdate({period:u,position:A.position.getWanted(),bufferType:h,imminentDiscontinuity:x.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:x.hasFinishedLoading,neededSegments:x.neededSegments}),y.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:B}=F.getCurrent();if(x.isBufferFull){let U=Math.max(0,R-B);U>0&&r.removeBuffer(0,U).catch(k)}x.shouldRefreshManifest&&o.needsManifestRefresh()}function O(A){if(!b.isUsed()){for(let R of A.protectionData)f.addProtectionData(R.initDataType,R.keyId,R.initData);if(!E){let R=f.getAllEncryptionData();if(R.length>0&&(o.encryptionDataEncountered(R.map(x=>G({content:n},x))),E=!0,b.isUsed()))return}if(A.segmentType===\"init\"){if(!f.index.isInitialized()&&A.segmentList!==void 0&&f.index.initialize(A.segmentList),T.isLoaded=!0,A.initializationData!==null){let R=f.uniqueId;T.uniqueId=R,r.declareInitSegment(R,A.initializationData),ya({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:R,segment:A.segment,segmentData:A.initializationData,segmentSink:r},b.signal).then(x=>{x!==null&&o.addedSegment(x)}).catch(k)}_();return}else{let{inbandEvents:R,predictedSegments:x,needsManifestRefresh:N}=A;if(x!==void 0&&f.index.addPredictedSegments(x,A.segment),N===!0&&(o.needsManifestRefresh(),b.isUsed())||R!==void 0&&R.length>0&&(o.inbandEvent(R),b.isUsed()))return;let w=T.uniqueId;Ta({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:w,parsedSegment:A,segment:A.segment,segmentSink:r},b.signal).then(M=>{M!==null&&o.addedSegment(M)}).catch(k)}}}function k(A){b.isUsed()&&A instanceof ue||(m.warn(\"Stream: Received fatal buffer error\",d.type,f.bitrate,A instanceof Error?A:null),b.cancel(),o.error(A))}}var qs=Ea;function _a(n,e,t,r,i){var c,g,p,h;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let b of a)b.infos.period.id===n.id&&(b.infos.adaptation.id!==e.id||!ge(t.representationIds,b.infos.representation.id))&&Ht(o,{start:(c=b.bufferedStart)!=null?c:b.start,end:(g=b.bufferedEnd)!=null?g:b.end});let s=r.getPendingOperations();for(let b of s)if(b.type===0){let y=b.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!ge(t.representationIds,y.representation.id))){let T=y.segment.time,P=T+y.segment.duration;Ht(o,{start:T,end:P})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let b=i.getReadyState();if(b===void 0||b>1)return{type:\"needs-reload\",value:void 0}}let u=t.switchingMode===\"direct\",d=[],f=Gt(a,n);if(f!==null&&(f.bufferedEnd===void 0||n.start-f.bufferedEnd<1)&&d.push({start:0,end:n.start+1}),!u){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:b}=F.getCurrent(),y=e.type,T=(p=b[y].before)!=null?p:0,P=(h=b[y].after)!=null?h:0,E=i.getCurrentTime();E===void 0&&(E=i.getReference().getValue().position.getPolled()),d.push({start:E-T,end:E+P})}if(n.end!==void 0){let b=Kt(a,n);b!==null&&(b.bufferedStart===void 0||b.bufferedStart-n.end<1)&&d.push({start:n.end-1,end:Number.MAX_VALUE})}let l=Fr(o,d);return l.length===0?{type:\"continue\",value:void 0}:u?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function Ra({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentQueueCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},u,d){let{manifest:f,period:l,adaptation:c}=e,g=new W;g.linkToSignal(d);let p=new Map,h=new j(null,g.signal),b,y=e.representations.getValue().representationIds,T=Hs(e.adaptation.representations,y),P=new j(T,g.signal),{estimates:E,callbacks:C}=r({manifest:f,period:l,adaptation:c},h,P,n,g.signal),_=new j(!1);n.listen(M=>{var U;let B=(U=M.canStream)!=null?U:!0;_.getValue()===B&&(m.debug(\"Stream: isMediaSegmentQueueInterrupted updated to\",!B),_.setValue(!B))},{clearSignal:g.signal});let O=a.createSegmentQueue(c.type,{onRequestBegin:C.requestBegin,onRequestEnd:C.requestEnd,onProgress:C.requestProgress,onMetrics:C.metrics},_),k=new j(0);E.onUpdate(({bitrate:M,knownStableBitrate:B})=>{t.enableFastSwitching&&k.setValueIfChanged(B),!(M===void 0||M===b)&&(b=M,m.debug(`Stream: new ${c.type} bitrate estimate`,M),u.bitrateEstimateChange({type:c.type,bitrate:M}))},{emitCurrentValue:!0,clearSignal:g.signal});let A;e.representations.onUpdate(M=>{A!==void 0&&A.cancel();let B=e.representations.getValue().representationIds,U=Hs(e.adaptation.representations,B);P.setValueIfChanged(U),A=new W,A.linkToSignal(g.signal),R(M,A.signal).catch(V=>{(A==null?void 0:A.isUsed())===!0&&W.isCancellationError(V)||(g.cancel(),u.error(V))})},{clearSignal:g.signal,emitCurrentValue:!0});return;async function R(M,B){let U=_a(l,c,M,i,n);switch(U.type){case\"continue\":break;case\"needs-reload\":return xt(()=>{n.listen(()=>{if(B.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:V}=F.getCurrent(),Z=V.bitrateSwitch;return u.waitingMediaSourceReload({bufferType:c.type,period:l,timeOffset:Z,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:B})});case\"flush-buffer\":case\"clean-buffer\":for(let V of U.value)if(await i.removeBuffer(V.start,V.end),B.isCancelled())return;if(U.type===\"flush-buffer\"&&(u.needsBufferFlush(),B.isCancelled()))return;break;default:Ne(U)}x(B)}function x(M){let B=new W;B.linkToSignal(M);let{representation:U}=E.getValue();if(U===null)return;let V=new j(null,B.signal);E.onUpdate(H=>{if(!(H.representation===null||H.representation.id===U.id))return H.urgent?(m.info(\"Stream: urgent Representation switch\",c.type),V.setValue({urgent:!0})):(m.info(\"Stream: slow Representation switch\",c.type),V.setValue({urgent:!1}))},{clearSignal:B.signal,emitCurrentValue:!0});let Z={type:c.type,adaptation:c,period:l,representation:U};if(h.setValue(U),M.isCancelled()||(u.representationChange(Z),M.isCancelled()))return;let Y={streamStatusUpdate:u.streamStatusUpdate,encryptionDataEncountered:u.encryptionDataEncountered,manifestMightBeOufOfSync:u.manifestMightBeOufOfSync,needsManifestRefresh:u.needsManifestRefresh,inbandEvent:u.inbandEvent,warning:u.warning,error(H){g.cancel(),u.error(H)},addedSegment(H){C.addedSegment(H)},terminating(){if(!B.isUsed())return B.cancel(),x(M)}};N(U,V,Y,M)}function N(M,B,U,V){let Z=!1,Y=new W;Y.linkToSignal(V);let H=Zt(o,de=>w(M,de),Y.signal),q=c.type===\"video\"?s:new j(1/0);m.info(\"Stream: changing representation\",c.type,M.id,M.bitrate);let J=G({},U,{error(de){var ie;if(Z){m.warn(\"Stream: Ignoring RepresentationStream error\",de);return}Z=!0;let me=ye(de,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(me.code!==\"BUFFER_FULL_ERROR\")U.error(de);else{m.warn(\"Stream: received BUFFER_FULL_ERROR\",c.type,M.bitrate);let Ge=o.getValue(),fe=((ie=p.get(M.id))!=null?ie:1)*.7;if(p.set(M.id,fe),fe<=.05||w(M,Ge)<=2){U.error(me);return}on(4e3,V).then(()=>N(M,B,U,V)).catch(D)}},terminating(){Y.cancel(),U.terminating()}});qs({playbackObserver:n,content:{representation:M,adaptation:c,period:l,manifest:f},segmentSink:i,segmentQueue:O,terminate:B,options:{bufferGoal:H,maxBufferSize:q,drmSystemId:t.drmSystemId,fastSwitchThreshold:k}},J,V),f.addEventListener(\"manifestUpdate\",de=>{for(let me of de.updatedPeriods)if(me.period.id===l.id){for(let ie of me.result.updatedAdaptations)if(ie.adaptation===c.id){for(let Ge of ie.removedRepresentations)if(Ge===M.id)return V.isCancelled()?void 0:u.waitingMediaSourceReload({bufferType:c.type,period:l,timeOffset:0,stayInPeriod:!0})}}else if(me.period.start>l.start)break},V)}function w(M,B){let U=p.get(M.id),V=U!==void 0?U:1;return U===void 0&&p.set(M.id,V),V<1&&B===1/0?5*60*1e3*V:B*V}}function Hs(n,e){let t=n.filter(r=>ge(e,r.id)&&!r.shouldBeAvoided&&r.isPlayable()!==!1);return t.length>0?t:n.filter(r=>ge(e,r.id)&&r.isPlayable()!==!1)}var Gs=Ra;function Pa(n,e,t,r,i,a){var g,p,h,b;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!ff(t,n.codec))return{type:\"needs-reload\",value:void 0};let o=n.getLastKnownInventory(),s=[];for(let y of o)y.infos.period.id===e.id&&y.infos.adaptation.id!==t.id&&Ht(s,{start:(g=y.bufferedStart)!=null?g:y.start,end:(p=y.bufferedEnd)!=null?p:y.end});let u=n.getPendingOperations();for(let y of u)if(y.type===0){let T=y.value.inventoryInfos;if(T.period.id===e.id&&T.adaptation.id!==t.id){let P=T.segment.time,E=P+T.segment.duration;Ht(s,{start:P,end:E})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let y=i.getReadyState();if(y===void 0||y>1)return{type:\"needs-reload\",value:void 0}}let d=r===\"direct\",f=[],l=Gt(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!d){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:T}=F.getCurrent(),P=(h=T[y].before)!=null?h:0,E=(b=T[y].after)!=null?b:0,C=i.getCurrentTime();C===void 0&&(C=i.getReference().getValue().position.getPolled()),f.push({start:C-P,end:C+E})}if(e.end!==void 0){let y=Kt(o,e);y!==null&&(y.bufferedStart===void 0||y.bufferedStart-e.end<1)&&f.push({start:e.end-1,end:Number.MAX_VALUE})}let c=Fr(s,f);return c.length===0?{type:\"continue\",value:void 0}:d&&t.type!==\"text\"?{type:\"flush-buffer\",value:c}:{type:\"clean-buffer\",value:c}}function ff(n,e){return n.representations.some(t=>t.isPlayable()===!0&&Uo(t.getMimeTypeString(),e))}function va({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentQueueCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:u,maxVideoBufferSize:d},f,l){let{manifest:c,period:g}=e,p=new j(void 0,l);if(f.periodStreamReady({type:n,manifest:c,period:g,adaptationRef:p}),l.isCancelled())return;let h,b=!0;p.onUpdate(P=>{(async()=>{var w;if(P===void 0)return;let E=new W;if(E.linkToSignal(l),h==null||h.cancel(),h=E,P===null){m.info(`Stream: Set no ${n} Adaptation. P:`,g.start);let M=o.getStatus(n);if(M.type===\"initialized\"){if(m.info(`Stream: Clearing previous ${n} SegmentSink`),St.isNative(n))return T(0,!0,E.signal);{let B=(w=g.end)!=null?w:1/0;if(g.start>B)m.warn(\"Stream: Can't free buffer: period's start is after its end\");else if(await M.value.removeBuffer(g.start,B),E.isUsed())return}}else if(M.type===\"uninitialized\"&&(o.disableSegmentSink(n),E.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:g}),E.isUsed()?void 0:Ks(r,u,n,{period:g},f,E.signal)}let C=g.adaptations[n],_=Q(C!=null?C:[],M=>M.id===P.adaptationId);if(_===void 0){h.cancel(),m.warn(\"Stream: Unfound chosen Adaptation choice\",P.adaptationId);return}let{DELTA_POSITION_AFTER_RELOAD:O}=F.getCurrent(),k=!1,A;if(b)A=0;else if(P.relativeResumingPosition!==void 0)A=P.relativeResumingPosition;else switch(k=!0,n){case\"audio\":A=O.trackSwitch.audio;break;case\"video\":A=O.trackSwitch.video;break;default:A=O.trackSwitch.other;break}if(b=!1,St.isNative(n)&&o.getStatus(n).type===\"disabled\")return T(A,!0,E.signal);c.addEventListener(\"manifestUpdate\",M=>{for(let B of M.updatedPeriods)if(B.period.id===g.id){for(let U of B.result.removedAdaptations)if(U.id===_.id)return T(A,!0,E.signal)}else if(B.period.start>g.start)break},h.signal);let{representations:R}=P;if(m.info(`Stream: Updating ${n} adaptation`,`A: ${_.id}`,`P: ${g.start}`),f.adaptationChange({type:n,adaptation:_,period:g}),E.isUsed())return;let x=cf(o,n,_),N=Pa(x,g,_,P.switchingMode,r,s);if(N.type===\"needs-reload\")return T(A,!0,E.signal);if(await o.waitForUsableBuffers(E.signal),!E.isUsed()){if(N.type===\"flush-buffer\"||N.type===\"clean-buffer\"){for(let{start:M,end:B}of N.value)if(await x.removeBuffer(M,B),E.isUsed())return;if(N.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:A,relativePosHasBeenDefaulted:k}),E.isUsed()))return}t.get(x)(E.signal),y(_,R,x,E.signal)}})().catch(E=>{E instanceof ue||(h==null||h.cancel(),f.error(E))})},{clearSignal:l,emitCurrentValue:!0});function y(P,E,C,_){let O=pf(r,P.type);Gs({content:{manifest:c,period:g,adaptation:P,representations:E},options:s,playbackObserver:O,representationEstimator:i,segmentSink:C,segmentQueueCreator:a,wantedBufferAhead:u,maxVideoBufferSize:d},oe(ee({},f),{error:k}),_);function k(A){if(!St.isNative(n)){m.error(`Stream: ${n} Stream crashed. Aborting it.`,A instanceof Error?A:\"\"),o.disposeSegmentSink(n);let R=ye(A,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(R),_.isCancelled()?void 0:Ks(r,u,n,{period:g},f,_)}m.error(`Stream: ${n} Stream crashed. Stopping playback.`,A instanceof Error?A:\"\"),f.error(A)}}function T(P,E,C){xt(()=>{r.listen(()=>{C.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:g,timeOffset:P,stayInPeriod:E})},{includeLastObservation:!0,clearSignal:C})})}}function cf(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return m.info(\"Stream: Reusing a previous SegmentSink for the type\",e),r.value;let i=mf(t);return n.createSegmentSink(e,i)}function mf(n){let e=n.representations.filter(t=>t.isPlayable()!==!1);if(e.length===0)throw new X(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[lt(n)]});return e[0].getMimeTypeString()}function pf(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new j(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let u=r.getValue(),d=u.buffered[e],f=d!==null?Lr(d,u.position.getWanted()):0;return G({},u,{bufferGap:f,buffered:d})}function s(){a.setValue(o())}})}function Ks(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),n.listen(u,{includeLastObservation:!1,clearSignal:a}),u();function u(){let d=n.getReference().getValue(),f=e.getValue(),l=d.position.getWanted();o.end!==void 0&&l+f>=o.end&&(m.debug('Stream: full \"empty\" AdaptationStream',t),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:l,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var js=va;function qr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory();for(let i of r)if(e.some(o=>i.infos.period.id===o.period.id&&i.infos.adaptation.id===o.adaptation.id&&i.infos.representation.id===o.representation.id)){let{bufferedStart:o,bufferedEnd:s}=i;if(o===void 0||s===void 0)return m.warn(\"SO: No buffered start or end found from a segment.\"),[{start:0,end:Number.MAX_VALUE}];let u=t[t.length-1];u!==void 0&&u.end===o?u.end=s:t.push({start:o,end:s})}return t}function Ca(n,e,t,r,i,a,o,s){let{manifest:u,initialPeriod:d}=n,{maxBufferAhead:f,maxBufferBehind:l,wantedBufferAhead:c,maxVideoBufferSize:g}=a,{MINIMUM_MAX_BUFFER_AHEAD:p,MAXIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_BEHIND:b}=F.getCurrent(),y=new On(E=>{var k,A;let{bufferType:C}=E,_=(k=b[C])!=null?k:1/0,O=(A=h[C])!=null?A:1/0;return R=>{zr({segmentSink:E,playbackObserver:e,maxBufferBehind:Zt(l,x=>Math.min(x,_),R),maxBufferAhead:Zt(f,x=>{var w;let N=Math.max(x,(w=p[C])!=null?w:0);return Math.min(N,O)},R)},R)}});for(let E of r.getBufferTypes())T(E,d);function T(E,C){let _=new Mt((N,w)=>N.start-w.start),O=!1,k=new W;return k.linkToSignal(s),e.listen(({position:N})=>{var B;let w=N.getWanted();if(!O||!R(w))return;for(m.info(\"Stream: Destroying all PeriodStreams due to out of bounds situation\",E,w),O=!1;_.length()>0;){let U=_.get(_.length()-1);_.removeElement(U),o.periodStreamCleared({type:E,manifest:u,period:U})}k.cancel(),k=new W,k.linkToSignal(s);let M=(B=u.getPeriodForTime(w))!=null?B:u.getNextPeriod(w);if(M===void 0){m.warn(\"Stream: The wanted position is not found in the Manifest.\"),O=!0;return}A(M)},{clearSignal:s,includeLastObservation:!0}),u.addEventListener(\"decipherabilityUpdate\",N=>{s.isCancelled()||x(N).catch(w=>{s.isCancelled()||(k.cancel(),o.error(w))})},s),A(C);function A(N){let w=oe(ee({},o),{waitingMediaSourceReload(M){let B=_.head();B===void 0||B.id!==M.period.id?o.lockedStream({bufferType:M.bufferType,period:M.period}):o.needsMediaSourceReload({timeOffset:M.timeOffset,minimumPosition:M.stayInPeriod?M.period.start:void 0,maximumPosition:M.stayInPeriod?M.period.end:void 0})},periodStreamReady(M){O=!0,_.add(M.period),o.periodStreamReady(M)},periodStreamCleared(M){_.removeElement(M.period),o.periodStreamCleared(M)},error(M){k.cancel(),o.error(M)}});P(E,N,w,k.signal)}function R(N){let w=_.head(),M=_.last();return w===void 0||M===void 0?!0:w.start>N||(v(M.end)?1/0:M.end)<N}async function x(N){let w=r.getStatus(E),M=N.filter(H=>H.adaptation.type===E);if(M.length===0||w.type!==\"initialized\"||M.every(H=>H.representation.decipherable===!0))return;let B=w.value,U=M.filter(H=>H.representation.decipherable===void 0),V=M.filter(H=>H.representation.decipherable===!1),Z=qr(B,V),Y=qr(B,U);for(O=!1,m.info(\"Stream: Destroying all PeriodStreams for decipherability matters\",E);_.length()>0;){let H=_.get(_.length()-1);_.removeElement(H),o.periodStreamCleared({type:E,manifest:u,period:H})}k.cancel(),k=new W,k.linkToSignal(s);for(let{start:H,end:q}of[...Z,...Y]){if(s.isCancelled())return;if(H<q){if(s.isCancelled())return;await B.removeBuffer(H,q)}}xt(()=>{if(s.isCancelled())return;let H=e.getReference().getValue();if(Ys(H,Z)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(Ys(H,Y)&&(o.needsBufferFlush(),s.isCancelled()))return;let q=H.position.getWanted(),J=u.getPeriodForTime(q);if(J===void 0){o.error(new X(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}A(J)})}}function P(E,C,_,O){m.info(\"Stream: Creating new Stream for\",E,C.start);let k=null,A=new W;A.linkToSignal(O),e.listen(({position:M},B)=>{if(C.end!==void 0&&M.getWanted()>=C.end){let U=u.getPeriodAfter(C);if(C.containsTime(M.getWanted(),U))return;m.info(\"Stream: Destroying PeriodStream as the current playhead moved above it\",E,C.start,M.getWanted(),C.end),B(),_.periodStreamCleared({type:E,manifest:u,period:C}),A.cancel()}},{clearSignal:O,includeLastObservation:!0});let R={bufferType:E,content:{manifest:u,period:C},garbageCollectors:y,maxVideoBufferSize:g,segmentQueueCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:c},x=oe(ee({},_),{streamStatusUpdate(M){if(M.hasFinishedLoading){let B=u.getPeriodAfter(C);B!==null&&N(B)}else k!==null&&(m.info(\"Stream: Destroying next PeriodStream due to current one being active\",E,k.period.start),_.periodStreamCleared({type:E,manifest:u,period:k.period}),k.canceller.cancel(),k=null);_.streamStatusUpdate(M)},error(M){k!==null&&(k.canceller.cancel(),k=null),A.cancel(),_.error(M)}});js(R,x,A.signal),w(A.signal);function N(M){if(k!==null){if(k.period.id===M.id)return;m.warn(\"Stream: Creating next `PeriodStream` while one was already created.\",E,M.id,k.period.id),_.periodStreamCleared({type:E,manifest:u,period:k.period}),k.canceller.cancel()}let B=new W;B.linkToSignal(O),k={canceller:B,period:M},P(E,M,_,k.canceller.signal)}function w(M){u.addEventListener(\"manifestUpdate\",B=>{for(let U of B.removedPeriods)if(U.id===C.id){if(u.periods.length>0&&u.periods[0].start<=U.start)return xt(()=>{if(!M.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(U.start>C.start)break;if(B.addedPeriods.length>0&&k!==null){let U=u.getPeriodAfter(C);(U===null||k.period.id!==U.id)&&(m.warn(\"Stream: Destroying next PeriodStream due to new one being added\",E,k.period.start),_.periodStreamCleared({type:E,manifest:u,period:k.period}),k.canceller.cancel(),k=null)}},M)}}}function Ys(n,e){if(e.length===0)return!1;let t=n.position.getPolled();return n.speed>=0?e[e.length-1].end>=t-5:e[0].start<=t+5}var Qs=Ca;var $s=Qs;var zn=class extends le{constructor(e,t,r){super(),this._canceller=new W,this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new Aa(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let u=new X(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",u)}else if(s>i.getMaximumAvailablePosition()){let u=new X(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",u)}},{includeLastObservation:!0,clearSignal:a}),e.addEventListener(\"manifestUpdate\",()=>{this.trigger(\"endingPositionChange\",this._getManifestEndTime()),!a.isCancelled()&&this._checkEndOfStream()},a)}getCurrentEndingTime(){return this._getManifestEndTime()}onAdaptationChange(e,t,r){if(this._manifest.isLastPeriodKnown){let i=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(i==null?void 0:i.id)&&(e===\"audio\"||e===\"video\")){e===\"audio\"?this._maximumPositionCalculator.updateLastAudioAdaptation(r):this._maximumPositionCalculator.updateLastVideoAdaptation(r);let a=this._maximumPositionCalculator.getEndingPosition(),o=a!==void 0?{isEnd:!0,endingPosition:a}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger(\"endingPositionChange\",o)}}this._canceller.isUsed()||r===null&&this._addActivelyLoadedPeriod(t,e)}onRepresentationChange(e,t){this._addActivelyLoadedPeriod(t,e)}onPeriodCleared(e,t){this._removeActivelyLoadedPeriod(t,e)}onLastSegmentFinishedLoading(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())}onLastSegmentLoadingResume(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())}dispose(){this.removeEventListener(),this._canceller.cancel()}_addActivelyLoadedPeriod(e,t){let r=this._lazilyCreateActiveStreamInfo(t);r.activePeriods.has(e)||(r.activePeriods.add(e),this._checkCurrentPeriod())}_removeActivelyLoadedPeriod(e,t){let r=this._activeStreams.get(t);r!==void 0&&r.activePeriods.has(e)&&(r.activePeriods.removeElement(e),this._checkCurrentPeriod())}_checkCurrentPeriod(){if(this._allBufferTypes.length===0)return;let e=this._activeStreams.get(this._allBufferTypes[0]);if(e!==void 0)for(let t of e.activePeriods.toArray()){let r=!0;for(let i of this._allBufferTypes){let a=this._activeStreams.get(i);if(a===void 0)return;if(!a.activePeriods.toArray().some(u=>u.id===t.id)){r=!1;break}}if(r){this._lastCurrentPeriodId!==t.id&&(this._lastCurrentPeriodId=t.id,this.trigger(\"periodChange\",t));return}}}_getManifestEndTime(){let e=this._maximumPositionCalculator.getEndingPosition();return e!==void 0?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}}_lazilyCreateActiveStreamInfo(e){let t=this._activeStreams.get(e);return t===void 0&&(t={activePeriods:new Mt((r,i)=>r.start-i.start),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t}_checkEndOfStream(){if(!this._manifest.isLastPeriodKnown)return;this._allBufferTypes.every(t=>{let r=this._activeStreams.get(t);return r!==void 0&&r.hasFinishedLoadingLastPeriod})?this.trigger(\"endOfStream\",null):this.trigger(\"resumeStream\",null)}},Aa=class{constructor(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}updateLastAudioAdaptation(e){this._lastAudioAdaptation=e}updateLastVideoAdaptation(e){this._lastVideoAdaptation=e}getMaximumAvailablePosition(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)return this._manifest.getMaximumSafePosition();if(this._lastAudioAdaptation===null){if(this._lastVideoAdaptation===null)return this._manifest.getMaximumSafePosition();{let e=Hr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Hr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Hr(this._lastAudioAdaptation),t=Hr(this._lastVideoAdaptation);return typeof e!=\"number\"||typeof t!=\"number\"?this._manifest.getMaximumSafePosition():Math.min(e,t)}}getEndingPosition(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(!(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)){if(this._lastAudioAdaptation===null)return this._lastVideoAdaptation===null?void 0:(e=Gr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=Gr(this._lastAudioAdaptation))!=null?t:void 0;{let r=Gr(this._lastAudioAdaptation),i=Gr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Hr(n){let{representations:e}=n,t=null,r;for(let i of e)if(i.index!==r){r=i.index;let a=i.index.getLastAvailablePosition();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function Gr(n){let{representations:e}=n,t=null,r;for(let i of e)if(i.index!==r){r=i.index;let a=i.index.getEnd();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function ka(n,e,t,r,i,a){a.register(()=>{e.interruptDurationSetting()});let o=new zn(n,t,r.getBufferTypes());a.register(()=>{o.dispose()}),o.addEventListener(\"warning\",u=>i.onWarning(u)),o.addEventListener(\"periodChange\",u=>i.onPeriodChanged(u)),o.addEventListener(\"endingPositionChange\",u=>{e.setDuration(u.endingPosition,u.isEnd)}),o.addEventListener(\"endOfStream\",()=>{m.debug(\"Init: end-of-stream order received.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function xa(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=Q(n.sourceBuffers,s=>s.type===\"audio\"),i=Q(n.sourceBuffers,s=>s.type===\"video\"),a=r==null?void 0:r.getBuffered();a!==void 0&&(t.audio=a);let o=i==null?void 0:i.getBuffered();return o!==void 0&&(t.video=o),t}function Ma(n,e){[\"video\",\"audio\",\"text\"].forEach(t=>{var i;let r=e.getStatus(t);r.type===\"initialized\"&&r.value.synchronizeInventory((i=n.buffered[t])!=null?i:[])})}function Oa(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return m.warn(\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}function gf(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Wn(n,e){if(m.debug(\"Init: Trying to call endOfStream\"),n.readyState!==\"open\"){m.debug(\"Init: MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=gf(t);if(r.length===0){m.info(\"Init: Triggering end of stream\");try{n.endOfStream()}catch(a){m.error(\"Unable to call endOfStream\",a instanceof Error?a:new Error(\"Unknown error\"))}return}m.debug(\"Init: Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new W;i.linkToSignal(e);for(let a of r)Ro(a,()=>{i.cancel(),Wn(n,e)},i.signal);Po(t,()=>{i.cancel(),Wn(n,e)},i.signal)}function Xs(n,e){let t=new W;t.linkToSignal(e),Bt(n,()=>{m.debug(\"Init: MediaSource re-opened while end-of-stream is active\"),t.cancel(),t=new W,t.linkToSignal(e),Wn(n,t.signal)},e),Wn(n,t.signal)}function wa(){return di}var hf=365*24*3600,Vn=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new W;let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Sf(r,i),o=new W;o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(),!a.getValue())return;o=new W,o.linkToSignal(i);let u=bf(r.sourceBuffers,o.signal),d=new W;return d.linkToSignal(o.signal),u.onUpdate(f=>{d.cancel(),d=new W,d.linkToSignal(o.signal),!f&&Js(r,e,t,d.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)}};function If(n,e,t){let r=e;t||(r=wa()?1/0:Zs(e));let i=0;for(let a=0;a<n.sourceBuffers.length;a++){let o=n.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{m.info(\"Init: Updating duration to what is currently buffered\",i),n.duration=i}catch(a){return m.warn(\"Duration Updater: Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(m.info(\"Init: Updating duration\",r),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=Zs(e);m.info(\"Init: calling `mediaSource.setLiveSeekableRange`\",s),n.setLiveSeekableRange(0,s)}}catch(s){return m.warn(\"Duration Updater: Can't update duration on the MediaSource.\",s instanceof Error?s:\"\"),\"failed\"}let o=Math.abs(n.duration-r);if(o>=.1){let s=Math.abs(n.duration-a);return o<s?\"partial\":\"failed\"}return\"success\"}}function bf(n,e){if(n.length===0){let i=new j(!1);return i.finish(),i}let t=new j(!1,e);r();for(let i=0;i<n.length;i++){let a=n[i];a.addEventListener(\"updatestart\",r),a.addEventListener(\"update\",r),e.register(()=>{a.removeEventListener(\"updatestart\",r),a.removeEventListener(\"update\",r)})}return t;function r(){for(let i=0;i<n.length;i++)if(n[i].updating){t.setValueIfChanged(!0);return}t.setValueIfChanged(!1)}}function Sf(n,e){let t=new j(n.readyState===\"open\",e);return Bt(n,()=>{m.debug(\"Init: Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),gr(n,()=>{m.debug(\"Init: Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),pr(n,()=>{m.debug(\"Init: Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function Js(n,e,t,r){if(If(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),Js(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function Zs(n){return Math.max(Math.pow(2,32),n+hf)}var qn=class extends le{constructor(e){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new W,v(an))throw new X(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");m.info(\"Init: Creating MediaSource\");let t=new an,r=t.handle;this.handle=v(r)?{type:\"media-source\",value:t}:{type:\"handle\",value:r},this._mediaSource=t,this.readyState=t.readyState,this._durationUpdater=new Vn(t),this._endOfStreamCanceller=null,Bt(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),gr(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),pr(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceClose\",null)},this._canceller.signal),this._mediaSource.streaming!==void 0&&(this.streaming=this._mediaSource.streaming),this._mediaSource.addEventListener(\"startstreaming\",()=>{this.streaming=!0,this.trigger(\"streamingChanged\",null)}),this._mediaSource.addEventListener(\"endstreaming\",()=>{this.streaming=!1,this.trigger(\"streamingChanged\",null)})}addSourceBuffer(e,t){let r=this._mediaSource.addSourceBuffer(t),i=new Da(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(){this._durationUpdater.stopUpdating()}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new W,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),m.debug(\"Init: end-of-stream order received.\"),Xs(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(m.debug(\"Init: resume-stream order received.\"),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),yf(this._mediaSource)}},Da=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new W,this._sourceBuffer=r,this._operationQueue=[],this._currentOperations=[];let i=this._onError.bind(this),a=this._onUpdateEnd.bind(this);r.addEventListener(\"updateend\",a),r.addEventListener(\"error\",i),this._canceller.signal.register(()=>{r.removeEventListener(\"updateend\",a),r.removeEventListener(\"error\",i)})}appendBuffer(...e){return m.debug(\"SBI: receiving order to push data to the SourceBuffer\",this.type),this._addToQueue({operationName:0,params:e})}remove(e,t){return m.debug(\"SBI: receiving order to remove data from the SourceBuffer\",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return ga(this._sourceBuffer.buffered)}catch(e){return m.error(\"Failed to get buffered time range of SourceBuffer\",this.type,e instanceof Error?e:null),[]}}abort(){try{this._sourceBuffer.abort()}catch(e){m.debug(\"Init: Failed to abort SourceBuffer:\",e instanceof Error?e:null)}this._emptyCurrentQueue()}dispose(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()}_onError(e){let t;e instanceof Error?t=e:e.error instanceof Error?t=e.error:t=new Error(\"Unknown SourceBuffer Error\");let r=this._currentOperations;if(this._currentOperations=[],r.length===0)m.error(\"SBI: error for an unknown operation\",t);else{let i=new Ce(t.name,t.message,t.name===\"QuotaExceededError\");for(let a of r)a.reject(i)}}_onUpdateEnd(){let e=this._currentOperations;this._currentOperations=[];try{for(let t of e)t.resolve(ga(this._sourceBuffer.buffered))}catch(t){for(let r of e)t instanceof Error&&t.name===\"InvalidStateError\"?r.resolve([]):r.reject(t)}this._performNextOperation()}_emptyCurrentQueue(){let e=new ue;this._currentOperations.length>0&&(this._currentOperations.forEach(t=>{t.reject(e)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(t=>{t.reject(e)}),this._operationQueue=[])}_addToQueue(e){return new Promise((t,r)=>{let i=this._operationQueue.length===0&&this._currentOperations.length===0,a=G({resolve:t,reject:r},e);this._operationQueue.push(a),i&&this._performNextOperation()})}_performNextOperation(){var t,r,i,a,o;if(this._currentOperations.length!==0||this._sourceBuffer.updating)return;let e=this._operationQueue.shift();if(e!==void 0)if(e.operationName===0){this._currentOperations=[{operationName:0,resolve:e.resolve,reject:e.reject}];let s=e.params[0],u=e.params[1],d=s;if(this._operationQueue.length>0&&this._operationQueue[0].operationName===0){let f;s instanceof ArrayBuffer?f=new Uint8Array(s):s instanceof Uint8Array?f=s:f=new Uint8Array(s.buffer);let l=[f];for(;((t=this._operationQueue[0])==null?void 0:t.operationName)===0;){let c=this._operationQueue[0],g=(r=u.appendWindow)!=null?r:[void 0,void 0],p=(i=c.params[1].appendWindow)!=null?i:[void 0,void 0],h=(a=u.timestampOffset)!=null?a:0,b=(o=c.params[1].timestampOffset)!=null?o:0;if(g[0]===p[0]&&g[1]===p[1]&&u.codec===c.params[1].codec&&h===b){let y=c.params[0],T;y instanceof ArrayBuffer?T=new Uint8Array(y):y instanceof Uint8Array?T=y:T=new Uint8Array(y.buffer),l.push(T),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:c.resolve,reject:c.reject})}else break}l.length>1&&(m.info(`MMSI: Merging ${l.length} segments together for perf`,this.type),d=_t(...l))}try{this._appendBufferNow(d,u)}catch(f){let l=f instanceof Error?new Ce(f.name,f.message,f.name===\"QuotaExceededError\"):new Ce(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(c=>{c.reject(l)}),this._currentOperations=[],this._performNextOperation()}}else{this._currentOperations=[e];let[s,u]=e.params;m.debug(\"SBI: removing data from SourceBuffer\",this.type,s,u);try{this._sourceBuffer.remove(s,u)}catch(d){let f=d instanceof Error?new Ce(d.name,d.message,!1):new Ce(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(f),this._currentOperations.forEach(l=>{l.reject(f)}),this._currentOperations=[],this._performNextOperation()}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(m.debug(\"SBI: updating codec\",i),Oa(r,i)?this.codec=i:m.debug(\"SBI: could not update codec\",i,this.codec)),a!==void 0&&r.timestampOffset!==a){let s=a;m.debug(\"SBI: updating timestampOffset\",i,r.timestampOffset,s),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(m.debug(\"SBI: re-setting `appendWindowStart` to `0`\"),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;m.debug(\"SBI: pre-updating `appendWindowEnd`\",s),r.appendWindowEnd=s}m.debug(\"SBI: setting `appendWindowStart`\",o[0]),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(m.debug(\"SBI: re-setting `appendWindowEnd` to `Infinity`\"),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(m.debug(\"SBI: setting `appendWindowEnd`\",o[1]),r.appendWindowEnd=o[1]),m.debug(\"SBI: pushing segment\",this.type),r.appendBuffer(e)}};function yf(n){if(n.readyState!==\"closed\"){let{readyState:e,sourceBuffers:t}=n;for(let r=t.length-1;r>=0;r--){let i=t[r];try{if(e===\"open\"){m.info(\"Init: Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}m.info(\"Init: Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&m.info(\"Init: Not all SourceBuffers could have been removed.\")}}var Tf=Ae(),Kr=Ae(),eu=1/0,Hn=class extends le{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new W,this.readyState=\"closed\",this._messageSender=r;let i=Tf();this._messageSender({type:\"create-media-source\",contentId:t,mediaSourceId:i})}onMediaSourceReadyStateChanged(e){switch(e){case\"closed\":this.readyState=\"closed\",this.trigger(\"mediaSourceClose\",null);break;case\"open\":this.readyState=\"open\",this.trigger(\"mediaSourceOpen\",null);break;case\"ended\":this.readyState=\"ended\",this.trigger(\"mediaSourceEnded\",null);break}}addSourceBuffer(e,t){this._messageSender({type:\"add-source-buffer\",mediaSourceId:this.id,value:{sourceBufferType:e,codec:t}});let r=new Na(e,t,this.id,this._messageSender);return this.sourceBuffers.push(r),r}setDuration(e,t){this._messageSender({type:\"update-media-source-duration\",mediaSourceId:this.id,value:{duration:e,isRealEndKnown:t}})}interruptDurationSetting(){this._messageSender({type:\"stop-media-source-duration\",mediaSourceId:this.id,value:null})}maintainEndOfStream(){this._messageSender({type:\"end-of-stream\",mediaSourceId:this.id,value:null})}stopEndOfStream(){this._messageSender({type:\"stop-end-of-stream\",mediaSourceId:this.id,value:null})}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},Na=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new W,this._mediaSourceId=r,this._queuedOperations=[],this._pendingOperations=new Map,this._messageSender=i}onOperationSuccess(e,t){let r=this._pendingOperations.get(e);r===void 0?m.warn(\"SBI: unknown SourceBuffer operation succeeded\"):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new ue:new Ce(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?m.info(\"SBI: unknown SourceBuffer operation failed\",r):(this._pendingOperations.delete(e),i.reject(r));let a=new ue;for(let o of this._queuedOperations)o.reject(a);this._queuedOperations=[]}appendBuffer(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=eu){this._queuedOperations.push({operationName:0,params:[e,t],resolve:r,reject:i});return}try{let a;e instanceof ArrayBuffer?a=e:e.byteLength===e.buffer.byteLength?a=e.buffer:a=e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset);let o=Kr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:o,value:{data:a,params:t}},[a]),this._addOperationToQueue(o,r,i)}catch(a){i(a)}})}remove(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=eu){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=Kr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{start:e,end:t}}),this._addOperationToQueue(a,r,i)}catch(a){i(a)}})}abort(){this._messageSender({type:\"abort-source-buffer\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,value:null})}dispose(){this.abort(),this._canceller.cancel()}getBuffered(){}_addOperationToQueue(e,t,r){this._pendingOperations.set(e,{resolve:a,reject:o});let i=this._canceller.signal.register(s=>{this._pendingOperations.delete(e),r(s)});function a(s){i(),t(s)}function o(s){i(),r(s)}}_performNextQueuedOperationIfItExists(){let e=this._queuedOperations.shift();if(e!==void 0)try{if(e.operationName===0){let[t,r]=e.params,i;t instanceof ArrayBuffer?i=t:t.byteLength===t.buffer.byteLength?i=t.buffer:i=t.buffer.slice(t.byteOffset,t.byteLength+t.byteOffset);let a=Kr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{data:i,params:r}},[i]),this._addOperationToQueue(a,e.resolve,e.reject)}else{let[t,r]=e.params,i=Kr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:i,value:{start:t,end:r}}),this._addOperationToQueue(i,e.resolve,e.reject)}}catch(t){e.reject(t)}}};function Ba(n){let e=n.map(o=>Math.log(o/n[0])),t=e.map(o=>o-e[0]+1),r=(t[t.length-1]-1)/(n.length*2+10),i=1/r;return n.map((o,s)=>a(s));function a(o){if(o===0)return 0;let s=Math.min(Math.max(1,o),n.length-1);return n[s]===n[s-1]?a(o-1):i*(r+(n[s]*t[s-1]-n[s-1]*t[s])/(n[s]-n[s-1]))+4}}var Fe=class{constructor(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}addSample(e,t){let r=Math.pow(this._alpha,e),i=t*(1-r)+r*this._lastEstimate;isNaN(i)||(this._lastEstimate=i,this._totalWeight+=e)}getEstimate(){let e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e}};var Gn=class{constructor(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}addSample(e,t,r){let i=r/t,a=this._currentRepresentationData,o;a!==null&&a.representation.id===e.id?(o=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=r,a.loadedSegments++):(o=new Fe(5),o.addSample(t,i),this._currentRepresentationData={representation:e,ewma:o,loadedDuration:r,loadedSegments:0}),o.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(m.debug(\"ABR: New last stable representation\",e.bitrate),this._lastRepresentationWithGoodScore=e)}getEstimate(e){if(this._currentRepresentationData===null||this._currentRepresentationData.representation.id!==e.id)return;let{ewma:t,loadedSegments:r,loadedDuration:i}=this._currentRepresentationData,a=t.getEstimate(),o=r>=5&&i>=10?1:0;return{score:a,confidenceLevel:o}}getLastStableRepresentation(){return this._lastRepresentationWithGoodScore}};var tu=6e3,Ef=15e3,_f=3e3,Rf=1e3,Pf=9e3,Kn=class{constructor(e){this._levelsMap=Ba(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=tu,m.debug(\"ABR: Steps for buffer based chooser.\",this._levelsMap.map((t,r)=>`bufferLevel: ${t}, bitrate: ${e[r]}`).join(\" ,\"))}onAddedSegment(e){let t=this._levelsMap,r=this._bitrates,{bufferGap:i,currentBitrate:a,currentScore:o,speed:s}=e;if(v(a)){this._currentEstimate=r[0];return}let u=-1;for(let p=0;p<r.length;p++){let h=r[p];if(h===a)u=p;else if(h>a)break}if(u<0||r.length!==t.length){m.info(\"ABR: Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let d;o!==void 0&&(d=s===0?o.score:o.score/s);let f=isFinite(i)?i:0,l=L();if(f<t[u]||d!==void 0&&d<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Pf){let b=this._blockRaiseDelay+_f;this._blockRaiseDelay=Math.min(b,Ef),m.debug(\"ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality\",this._blockRaiseDelay)}else{let b=this._blockRaiseDelay-Rf;this._blockRaiseDelay=Math.max(tu,b),m.debug(\"ABR: Lowering quality in BufferBasedChooser\",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=l;let h=re(r,b=>b===a);for(let b=h-1;b>=0;b--)if(f>=t[b]){this._currentEstimate=r[b];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||d===void 0||d<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let c=t[u],g=(()=>{for(let p=u+1;p<t.length;p++)if(t[p]>c)return p})();if(g!==void 0){let p=t[g];if(i>=p){m.debug(\"ABR: Raising quality in BufferBasedChooser\",r[g]),this._currentEstimate=r[g];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function vf(n,e){let t=-1;for(let o=0;o<n.length;o++){let{segment:s}=n[o].content;if(s.duration<=0)continue;let u=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(u>e&&e-s.time>-1.2){t=o;break}}if(t<0)return[];let r=n[t],i=r.content.segment.time,a=[r];for(let o=t+1;o<n.length&&n[o].content.segment.time===i;o++)a.push(n[o]);return a}function jr(n){if(n.progress.length<5)return;let e=new Fe(2),{progress:t}=n;for(let r=1;r<t.length;r++){let i=t[r].size-t[r-1].size,a=t[r].timestamp-t[r-1].timestamp,o=i*8/(a/1e3);e.addSample(a/1e3,o)}return e.getEstimate()}function nu(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function Cf(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,u=isFinite(a)?a:0,d=s.getWanted()+u,f=vf(n,d);if(f.length!==1)return;let l=f[0],c=L(),g=l.content.segment.duration*1.5;if(g=Math.min(g,3e3),g=Math.max(g,12e3),c-l.requestTimestamp<g)return;let p=l.progress.length>0?l.progress[l.progress.length-1]:void 0,h=jr(l);if(p!==void 0&&h!==void 0){let C=nu(p,h);if((c-p.timestamp)/1e3<=C&&C-u/o>2500)return h}if(!l.content.segment.complete)return;let b=l.content.segment.duration,y=(c-l.requestTimestamp)/1e3,T=y<=(b*1.5+2)/o;if(v(t)||T)return;let P=b/y,E=t.bitrate*Math.min(.7,P);if(i===void 0||E<i)return E}function Af(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=Q(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(a===void 0)return!0;let o=L(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=jr(a);if(s===void 0||u===void 0)return!0;let d=nu(s,u);return(o-s.timestamp)/1e3>d*1.2?!0:d-r/n.speed>-1.5}var jn=class{constructor(e,t){let{ABR_STARVATION_GAP:r,OUT_OF_STARVATION_GAP:i,ABR_STARVATION_FACTOR:a,ABR_REGULAR_FACTOR:o}=F.getCurrent();this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,t?this._config={starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:this._config={starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}getBandwidthEstimate(e,t,r,i,a){let o,s,u=this._config,{bufferGap:d,position:f,duration:l}=e,c=isFinite(d)?d:0,{ABR_STARVATION_DURATION_DELTA:g}=F.getCurrent();return isNaN(l)||c+f.getWanted()<l-g?!this._inStarvationMode&&c<=u.starvationGap?(m.info(\"ABR: enter starvation mode.\"),this._inStarvationMode=!0):this._inStarvationMode&&c>=u.outOfStarvationGap&&(m.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1):this._inStarvationMode&&(m.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1),this._inStarvationMode&&(s=Cf(i,e,r,this._lowLatencyMode,a),s!==void 0&&(m.info(\"ABR: starvation mode emergency estimate:\",s),t.reset(),o=v(r)?s:Math.min(s,r.bitrate))),v(o)&&(s=t.getEstimate(),s!==void 0?o=s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):o=this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}}isUrgent(e,t,r,i){return t===null?!0:e>=t.bitrate?!1:Af(i,r,this._lowLatencyMode)}};var Yn=class{constructor(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}update(e,t,r){this.representation=e,this.bandwidth=t,this.algorithmType=r}};var Qn=class{constructor(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}getGuess(e,t,r,i,a){let{bufferGap:o,speed:s}=t,u=this._lastAbrEstimate.representation;if(u===null)return null;if(i>u.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let d=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(d===void 0)return null;if(this._canGuessHigher(o,s,d)){let l=ru(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(u,i,d)&&(m.debug(\"ABR: Guessed Representation validated\",u.bitrate),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),r.id!==u.id)return u;if(this._shouldStopGuess(r,d,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=L()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),kf(e,r);if(d===void 0)return r;if(this._canGuessHigher(o,s,d)){let l=ru(e,r);if(l!==null)return l}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&L()>this._blockGuessesUntil&&i===1&&r/t>1.01}_shouldStopGuess(e,t,r,i){if(t!==void 0&&t.score<1.01)return!0;if((t===void 0||t.score<1.2)&&r<.6)return!0;let a=i.filter(s=>s.content.representation.id===e.id),o=L();for(let s of a){let u=o-s.requestTimestamp;if(s.content.segment.isInit){if(u>1e3)return!0}else{if(u>s.content.segment.duration*1e3+200)return!0;{let d=jr(s);if(d!==void 0&&d<e.bitrate*.8)return!0}}}return!1}_isLastGuessValidated(e,t,r){return r!==void 0&&r.confidenceLevel===1&&r.score>1.5?!0:t>=e.bitrate&&(this._lastMaintanableBitrate===null||this._lastMaintanableBitrate<e.bitrate)}};function ru(n,e){let t=n.length,r=re(n,({id:i})=>i===e.id);if(r<0)return m.error(\"ABR: Current Representation not found.\"),null;for(;++r<t;)if(n[r].bitrate>e.bitrate)return n[r];return null}function kf(n,e){let t=re(n,({id:r})=>r===e.id);if(t<0)return m.error(\"ABR: Current Representation not found.\"),null;for(;--t>=0;)if(n[t].bitrate<e.bitrate)return n[t];return null}var $n=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=F.getCurrent();this._fastEWMA=new Fe(e),this._slowEWMA=new Fe(t),this._bytesSampled=0}addSample(e,t){let{ABR_MINIMUM_CHUNK_SIZE:r}=F.getCurrent();if(t<r)return;let i=t*8e3/e,a=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(a,i),this._slowEWMA.addSample(a,i)}getEstimate(){let{ABR_MINIMUM_TOTAL_BYTES:e}=F.getCurrent();if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())}reset(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=F.getCurrent();this._fastEWMA=new Fe(e),this._slowEWMA=new Fe(t),this._bytesSampled=0}};function Ua(n,e){if(n.length===0)return[];n.sort((a,o)=>a.bitrate-o.bitrate);let t=n[0].bitrate,r=Math.max(e,t),i=re(n,a=>a.bitrate>r);return i===-1?n:n.slice(0,i)}function La(n,e){if(e.width===void 0||e.height===void 0)return n;let t=e.width*e.pixelRatio,r=e.height*e.pixelRatio,i=n.slice().sort((s,u)=>{var d,f;return((d=s.width)!=null?d:0)-((f=u.width)!=null?f:0)}),a=Q(i,s=>typeof s.width==\"number\"&&s.width>=t&&typeof s.height==\"number\"&&s.height>=r);if(a===void 0)return n;let o=typeof a.width==\"number\"?a.width:0;return n.filter(s=>typeof s.width==\"number\"?s.width<=o:!0)}var Xn=class{constructor(){this._currentRequests={}}add(e){let{id:t,requestTimestamp:r,content:i}=e;this._currentRequests[t]={requestTimestamp:r,progress:[],content:i}}addProgress(e){let t=this._currentRequests[e.id];if(v(t)){if(I.CURRENT_ENV===I.DEV)throw new Error(\"ABR: progress for a request not added\");m.warn(\"ABR: progress for a request not added\");return}t.progress.push(e)}remove(e){if(v(this._currentRequests[e])){if(I.CURRENT_ENV===I.DEV)throw new Error(\"ABR: can't remove unknown request\");m.warn(\"ABR: can't remove unknown request\")}delete this._currentRequests[e]}getRequests(){return cr(this._currentRequests).filter(e=>!v(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Yr(n,e){let t=re(n,r=>r.bitrate>e);return t===-1?n[n.length-1]:t===0?n[0]:n[t-1]}var iu=new j(void 0);iu.finish();var au=new j(1/0);au.finish();function Fa(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,u,d,f,l){var b,y,T;let{type:c}=s.adaptation,g=a(c),p=(b=t[c])!=null?b:0,h={limitResolution:(y=r.limitResolution[c])!=null?y:iu,throttleBitrate:(T=r.throttleBitrate[c])!=null?T:au};return xf({bandwidthEstimator:g,context:s,currentRepresentation:u,filters:h,initialBitrate:p,playbackObserver:f,representations:d,lowLatencyMode:i},l)};function a(o){let s=e[o];if(v(s)){m.debug(\"ABR: Creating new BandwidthEstimator for \",o);let u=new $n;return e[o]=u,u}return s}}function xf({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},u){let d=new Gn,f=new jn(i!=null?i:0,a),l=new Xn,c=D,g={metrics:T,requestBegin:P,requestProgress:E,requestEnd:C,addedSegment(_){c(_)}},p=new W;p.linkToSignal(u);let h=b(s.getValue(),p.signal);return s.onUpdate(y,{clearSignal:u}),{estimates:h,callbacks:g};function b(_,O){if(_.length<=1)return new j({bitrate:void 0,representation:_[0],urgent:!0,knownStableBitrate:void 0});let k=!1,A=_.sort((V,Z)=>V.bitrate-Z.bitrate),R=new Kn(A.map(V=>V.bitrate)),x=new Yn,N=new Qn(d,x),w=o.getReference().getValue(),M=new j(U());return o.listen(V=>{w=V,B()},{includeLastObservation:!1,clearSignal:O}),c=function(V){if(w===null)return;let{position:Z,speed:Y}=w,H=V.buffered,q=Lr(H,Z.getWanted()),{representation:J}=V.content,de=d.getEstimate(J),me=J.bitrate,ie={bufferGap:q,currentBitrate:me,currentScore:de,speed:Y};R.onAddedSegment(ie),B()},O.register(()=>{c=D}),r.throttleBitrate.onUpdate(B,{clearSignal:O}),r.limitResolution.onUpdate(B,{clearSignal:O}),M;function B(){M.setValue(U())}function U(){let{bufferGap:V,position:Z,maximumPosition:Y}=w,H=r.limitResolution.getValue(),q=r.throttleBitrate.getValue(),J=t.getValue(),de=Mf(A,H,q),me=l.getRequests(),{bandwidthEstimate:ie,bitrateChosen:Ge}=f.getBandwidthEstimate(w,n,J,me,x.bandwidth),Me=d.getLastStableRepresentation(),fe=Me===null?void 0:Me.bitrate/(w.speed>0?w.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:Te,ABR_EXIT_BUFFER_BASED_ALGO:$t}=F.getCurrent();k&&V<=$t?k=!1:!k&&isFinite(V)&&V>=Te&&(k=!0);let Ke=Yr(de,Ge),Oe=R.getLastEstimate(),Ot=Ke.bitrate,ut=null;k&&Oe!==void 0&&Oe>Ot&&(ut=Yr(de,Oe),Ot=ut.bitrate);let dt=null;return a&&J!==null&&e.manifest.isDynamic&&Y-Z.getWanted()<40&&(dt=N.getGuess(A,w,J,Ot,me)),dt!==null&&dt.bitrate>Ot?(m.debug(\"ABR: Choosing representation with guess-based estimation.\",dt.bitrate,dt.id),x.update(dt,ie,2),{bitrate:ie,representation:dt,urgent:J===null||dt.bitrate<J.bitrate,knownStableBitrate:fe}):ut!==null?(m.debug(\"ABR: Choosing representation with buffer-based estimation.\",ut.bitrate,ut.id),x.update(ut,ie,0),{bitrate:ie,representation:ut,urgent:f.isUrgent(ut.bitrate,J,me,w),knownStableBitrate:fe}):(m.debug(\"ABR: Choosing representation with bandwidth estimation.\",Ke.bitrate,Ke.id),x.update(Ke,ie,1),{bitrate:ie,representation:Ke,urgent:f.isUrgent(Ke.bitrate,J,me,w),knownStableBitrate:fe})}}function y(){let _=s.getValue();p.cancel(),p=new W,p.linkToSignal(u),b(_,p.signal).onUpdate(function(A){h.setValue(A)},{clearSignal:p.signal,emitCurrentValue:!0})}function T(_){let{requestDuration:O,segmentDuration:k,size:A,content:R}=_;if(n.addSample(O,A),!R.segment.isInit){let{segment:x,representation:N}=R;if(k===void 0&&!x.complete)return;let w=k!=null?k:x.duration;d.addSample(N,O/1e3,w)}}function P(_){l.add(_)}function E(_){l.addProgress(_)}function C(_){l.remove(_.id)}}function Mf(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Ua(r,t)),e!==void 0&&(r=La(r,e)),r}var ou=Fa;function Qr(){var t;if(typeof((t=ae.crypto)==null?void 0:t.randomUUID)==\"function\")return ae.crypto.randomUUID();let n=new Date().getTime(),e=L();return\"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g,function(r){let i=Math.random()*16;return n>0?(i=(n+i)%16|0,n=Math.floor(n/16)):(i=(e+i)%16|0,e=Math.floor(e/16)),(r===\"x\"?i:i&3|8).toString(16)})}var Of=4,Zn=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Qr(),this._contentId=(r=e.contentId)!=null?r:Qr(),this._typePreference=e.communicationType===\"headers\"?0:1,this._bufferStarvationToggle=!1,this._playbackObserver=null,this._lastThroughput={},this._canceller=null}startMonitoringPlayback(e){var t;(t=this._canceller)==null||t.cancel(),this._canceller=new W,this._playbackObserver=e,e.listen(r=>{r.rebuffering!==null&&(this._bufferStarvationToggle=!0)},{includeLastObservation:!0,clearSignal:this._canceller.signal})}stopMonitoringPlayback(){var e;(e=this._canceller)==null||e.cancel(),this._canceller=null,this._playbackObserver=null}updateThroughput(e,t){this._lastThroughput[e]=t}_getCommonCmcdData(e){var i;let t={};t.bs=this._bufferStarvationToggle,this._bufferStarvationToggle=!1,t.cid=this._contentId,t.mtp=e!==void 0?Math.floor(Math.round(e/1e3/100)*100):void 0,t.sid=this._sessionId;let r=(i=this._playbackObserver)==null?void 0:i.getReference().getValue();return t.pr=r===void 0||r.speed===1?void 0:r.speed,r!==void 0&&(t.su=r.rebuffering!==null),t}getCmcdDataForManifest(e){var r;let t=this._getCommonCmcdData((r=this._lastThroughput.video)!=null?r:this._lastThroughput.audio);switch(t.ot=\"m\",e){case\"dash\":t.sf=\"d\";break;case\"smooth\":t.sf=\"s\";break;default:t.sf=\"o\";break}return this._producePayload(t)}getCmcdDataForSegmentRequest(e){var o,s,u,d;let t=(o=this._playbackObserver)==null?void 0:o.getReference().getValue(),r=this._getCommonCmcdData(this._lastThroughput[e.adaptation.type]);switch(r.br=Math.round(e.representation.bitrate/1e3),r.d=Math.round(e.segment.duration*1e3),e.adaptation.type){case\"video\":r.ot=\"v\";break;case\"audio\":r.ot=\"a\";break;case\"text\":r.ot=\"c\";break}if(e.segment.isInit&&(r.ot=\"i\"),!v(e.nextSegment)&&e.segment.url!==null&&e.nextSegment.url!==null&&(!e.nextSegment.isInit||e.nextSegment.indexRange===void 0)){let f=e.segment.url,l=e.nextSegment.url,c=$o(f,l);c!==null&&(c!==\".\"&&(r.nor=encodeURIComponent(c)),e.nextSegment.range!==void 0&&(r.nrr=String(e.nextSegment.range[0])+\"-\",isFinite(e.nextSegment.range[1])&&(r.nrr+=String(e.nextSegment.range[1]))))}let i;if(t!==void 0&&(r.ot===\"v\"||r.ot===\"a\"||r.ot===\"av\")){let f=t.buffered[e.adaptation.type];if(!v(f)){let l=(d=(u=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?u:t.position.getWanted())!=null?d:t.position.getPolled();for(let c of f)if(l>=c.start&&l<c.end){i=(c.end-l)*1e3,r.bl=Math.floor(Math.round(i/100)*100);break}}}let a=i===void 0||t===void 0?void 0:i/t.speed;if(r.dl=a===void 0?void 0:Math.floor(Math.round(a/100)*100),a!==void 0){let l=e.representation.bitrate*e.segment.duration/1e3/(a/1e3);r.rtp=Math.floor(Math.round(l*Of/100)*100)}switch(e.manifest.transport){case\"dash\":r.sf=\"d\";break;case\"smooth\":r.sf=\"s\";break;default:r.sf=\"o\";break}return r.st=e.manifest.isDynamic?\"l\":\"v\",r.tb=e.adaptation.representations.reduce((f,l)=>l.isPlayable()!==!0?f:f===void 0?Math.round(l.bitrate/1e3):Math.max(f,Math.round(l.bitrate/1e3)),void 0),this._producePayload(r)}_producePayload(e){let t={object:\"\",request:\"\",session:\"\",status:\"\"},r=\"\",i=(d,f)=>{this._typePreference===0?t[f]+=d:r+=d},a=(d,f)=>{let l=e[d];if(l!==void 0){let c=`${d}=${String(l)},`;i(c,f)}},o=(d,f)=>{if(e[d]===!0){let l=`${d},`;i(l,f)}},s=(d,f)=>{let l=e[d];if(l!==void 0){let g=`prop=${`\"${l.replace(\"\\\\\",\"\\\\\\\\\").replace('\"','\\\\\"')}\"`},`;i(g,f)}},u=(d,f)=>{let l=e[d];if(l!==void 0){let c=`prop=${l},`;i(c,f)}};return a(\"bl\",\"request\"),a(\"br\",\"object\"),o(\"bs\",\"status\"),s(\"cid\",\"session\"),a(\"d\",\"object\"),a(\"dl\",\"request\"),a(\"mtp\",\"request\"),s(\"nor\",\"request\"),s(\"nrr\",\"request\"),u(\"ot\",\"object\"),a(\"pr\",\"session\"),a(\"rtp\",\"status\"),u(\"sf\",\"session\"),s(\"sid\",\"session\"),u(\"st\",\"session\"),o(\"su\",\"request\"),a(\"tb\",\"object\"),this._typePreference===0?(t.object[t.object.length-1]===\",\"&&(t.object=t.object.substring(0,t.object.length-1)),t.request[t.request.length-1]===\",\"&&(t.request=t.request.substring(0,t.request.length-1)),t.session[t.session.length-1]===\",\"&&(t.session=t.session.substring(0,t.session.length-1)),t.status[t.status.length-1]===\",\"&&(t.status=t.status.substring(0,t.status.length-1)),m.debug(\"CMCD: proposing headers payload\"),{type:\"headers\",value:{\"CMCD-Object\":t.object,\"CMCD-Request\":t.request,\"CMCD-Session\":t.session,\"CMCD-Status\":t.status}}):(r[r.length-1]===\",\"&&(r=r.substring(0,r.length-1)),r=encodeURIComponent(r),m.debug(\"CMCD: proposing query string payload\",r),{type:\"query\",value:[[\"CMCD\",r]]})}};var su=Zn;function st(n){return n instanceof se?new Ye(\"PIPELINE_LOAD_ERROR\",n):ye(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function wf(n){return n instanceof se?n.type===yt.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===yt.TIMEOUT||n.type===yt.ERROR_EVENT:n instanceof je?typeof n.canRetry==\"boolean\"?n.canRetry:n.xhr!==void 0?n.xhr.status>=500||n.xhr.status===404||n.xhr.status===415||n.xhr.status===412:!1:Dt(n)&&n.code===\"INTEGRITY_ERROR\"}async function za(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:u}=r;n!==null&&n.length===0&&m.warn(\"Fetchers: no CDN given to `scheduleRequestWithCdns`.\");let d=new Map,f=l();if(f===void 0)throw new Error(\"No CDN to request\");return c(f);function l(){if(n===null){let b=d.get(null);return b!==void 0&&b.isBlacklisted?void 0:null}else{if(e===null)return h(n);{let b=e.getCdnPreferenceForResource(n);return h(b)}}}async function c(b){try{return await t(b,i)}catch(y){if(W.isCancellationError(y))throw y;b!==null&&e!==null&&e.downgradeCdn(b);let T=d.get(b);if(T===void 0?(T={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},d.set(b,T)):T.errorCounter++,!wf(y))return T.blockedUntil=void 0,T.isBlacklisted=!0,g(y);if(T.errorCounter>s)T.blockedUntil=void 0,T.isBlacklisted=!0;else{let P=T.errorCounter,E=Math.min(a*Math.pow(2,P-1),o),C=Ei(E);T.blockedUntil=L()+C}return g(y)}}async function g(b){let y=l();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw b;if(u(b),i.isCancelled())throw i.cancellationError;return p(y,b)}function p(b,y){let T=d.get(b);if(T===void 0||T.blockedUntil===void 0)return c(b);let P=L(),E=T.blockedUntil-P;if(E<=0)return c(b);let C=new W,_=C.linkToSignal(i);return new Promise((O,k)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let x=l();if(i.isCancelled())throw i.cancellationError;if(x===void 0)return R(y);x!==b&&(C.cancel(),p(x,y).then(A,R))},C.signal),on(E,C.signal).then(()=>c(b).then(A,R),D);function A(x){_(),O(x)}function R(x){_(),k(x)}})}function h(b){var T;if(d.size===0)return b[0];let y=L();return(T=b.filter(P=>{var E;return((E=d.get(P))==null?void 0:E.isBlacklisted)!==!0}).reduce((P,E)=>{var _;let C=(_=d.get(E))==null?void 0:_.blockedUntil;return C!==void 0&&C<=y&&(C=void 0),P===void 0?[E,C]:P[1]===void 0?P:C===void 0?[E,void 0]:C<P[1]?[E,C]:P},void 0))==null?void 0:T[0]}}function Wa(n,e,t){return za(null,null,n,e,t)}var Jn=class extends le{constructor(e,t,r){super(),this.scheduleManualRefresh=D,this._manifestUrls=e,this._pipelines=t.manifest,this._transportName=t.transportName,this._settings=r,this._canceller=new W,this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(){this._canceller.cancel(),this.removeEventListener()}start(){if(this._isStarted)return;this._isStarted=!0;let e,t=this._settings.initialManifest;t instanceof Lt?e=Promise.resolve({manifest:t}):t!==void 0?e=this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):e=this._fetchManifest(void 0).then(r=>r.parse({previousManifest:null,unsafeMode:!1})),e.then(r=>{this.trigger(\"manifestReady\",r.manifest),this._canceller.isUsed()||this._recursivelyRefreshManifest(r.manifest,r)}).catch(r=>this._onFatalError(r))}updateContentUrls(e,t){var r;this._prioritizedContentUrl=(r=e==null?void 0:e[0])!=null?r:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})}async _fetchManifest(e){var d;let t=this._canceller.signal,r=this._settings,i=this._transportName,a=this._pipelines,o=e!=null?e:(d=this._manifestUrls)==null?void 0:d[0],s=this._getBackoffSetting(f=>{this.trigger(\"warning\",st(f))});try{let f=await u(o);return{parse:l=>this._parseLoadedManifest(f,l,o)}}catch(f){throw st(f)}function u(f){var b;let{loadManifest:l}=a,c=r.requestTimeout===void 0?F.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,g=r.connectionTimeout===void 0?F.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;c<0&&(c=void 0),g<0&&(g=void 0);let p={timeout:c,connectionTimeout:g,cmcdPayload:(b=r.cmcdDataBuilder)==null?void 0:b.getCmcdDataForManifest(i)};return Wa(()=>l(f,p,t),s,t)}}parse(e,t,r){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,r)}async _parseLoadedManifest(e,t,r){var h;let i=L(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:u}=e,d=this._getBackoffSetting(b=>{this.trigger(\"warning\",st(b))}),f=r!=null?r:(h=this._manifestUrls)==null?void 0:h[0],l={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:f};try{let b=this._pipelines.parseManifest(e,l,g,a,c);if(Df(b)){let{manifest:y,warnings:T}=await b;return p(y,T)}else return p(b.manifest,b.warnings)}catch(b){throw ye(b,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function c(b){try{return await Wa(b,d,a)}catch(y){throw st(y)}}function g(b){for(let y of b){if(a.isCancelled())return;let T=ye(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",T)}}function p(b,y){g(y);let T=L()-i;return m.info(`MF: Manifest parsed in ${T}ms`),{manifest:b,sendingTime:s,receivedTime:u,parsingTime:T}}}_getBackoffSetting(e){let{DEFAULT_MAX_MANIFEST_REQUEST_RETRY:t,INITIAL_BACKOFF_DELAY_BASE:r,MAX_BACKOFF_DELAY_BASE:i}=F.getCurrent(),{lowLatencyMode:a,maxRetry:o}=this._settings,s=a?r.LOW_LATENCY:r.REGULAR,u=a?i.LOW_LATENCY:i.REGULAR,d=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:u,maxRetry:d}}_recursivelyRefreshManifest(e,{sendingTime:t,parsingTime:r,updatingTime:i}){let{MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:a,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:o}=F.getCurrent(),s=r!==void 0?r+(i!=null?i:0):void 0,u=!1;this._consecutiveUnsafeMode>0?u=this._consecutiveUnsafeMode<a:s!==void 0&&(u=s>=o);let d=t===void 0?0:L()-t,f=Math.max(this._settings.minimumManifestUpdateInterval-d,0),l=new W;if(l.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=c=>{let{enablePartialRefresh:g,delay:p,canUseUnsafeMode:h}=c,b=h&&u,y=t===void 0?0:L()-t,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),P=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:g,unsafeMode:b})},Math.max((p!=null?p:0)-y,T));l.signal.register(()=>{clearTimeout(P)})},e.expired!==null){let c=setTimeout(()=>{var g;(g=e.expired)==null||g.then(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},D)},f);l.signal.register(()=>{clearTimeout(c)})}if(e.lifetime!==void 0&&e.lifetime>=0){let c=e.lifetime*1e3-d,g;s===void 0?g=c:e.lifetime<3&&s>=100?(g=Math.min(Math.max(3e3-d,Math.max(c,0)+s),c*6),m.info(\"MUS: Manifest update rythm is too frequent. Postponing next request.\",c,g)):s>=e.lifetime*1e3/10?(g=Math.min(Math.max(c,0)+s,c*6),m.info(\"MUS: Manifest took too long to parse. Postponing next request\",g,g)):g=c;let p=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},Math.max(g,f));l.signal.register(()=>{clearTimeout(p)})}}_triggerNextManifestRefresh(e,{enablePartialRefresh:t,unsafeMode:r}){let i=e.updateUrl,a,o;this._prioritizedContentUrl!==null?(a=!0,o=this._prioritizedContentUrl,this._prioritizedContentUrl=null):(a=!t||i===void 0,o=a?e.getUrls()[0]:i);let s=e.clockOffset;r?(this._consecutiveUnsafeMode+=1,m.info('Init: Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(m.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(o).then(u=>u.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(u=>{this._isRefreshPending=!1;let{manifest:d,sendingTime:f,parsingTime:l}=u,c=L();if(a)e.replace(d);else try{e.update(d)}catch(p){let h=p instanceof Error?p.message:\"unknown error\";m.warn(`MUS: Attempt to update Manifest failed: ${h}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:b}=F.getCurrent(),y=f===void 0?0:L()-f,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),P=D,E=setTimeout(()=>{P(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(b-y,T));P=this._canceller.signal.register(()=>{clearTimeout(E)});return}let g=L()-c;this._recursivelyRefreshManifest(e,{sendingTime:f,parsingTime:l,updatingTime:g})}).catch(u=>{this._isRefreshPending=!1,this._onFatalError(u)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose())}};function Df(n){return n instanceof Promise}var Va=Jn;var er=class extends le{constructor(e){super(),this._downgradedCdnList={metadata:[],timeouts:[]},e.register(()=>{for(let t of this._downgradedCdnList.timeouts)clearTimeout(t);this._downgradedCdnList={metadata:[],timeouts:[]}})}getCdnPreferenceForResource(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)}downgradeCdn(e){let t=uu(this._downgradedCdnList.metadata,e);t>=0&&this._removeIndexFromDowngradeList(t);let{DEFAULT_CDN_DOWNGRADE_TIME:r}=F.getCurrent(),i=r;this._downgradedCdnList.metadata.push(e);let a=setTimeout(()=>{let o=uu(this._downgradedCdnList.metadata,e);o>=0&&this._removeIndexFromDowngradeList(o),this.trigger(\"priorityChange\",null)},i);this._downgradedCdnList.timeouts.push(a),this.trigger(\"priorityChange\",null)}_innerGetCdnPreferenceForResource(e){let[t,r]=e.reduce((i,a)=>(this._downgradedCdnList.metadata.some(o=>o.id===a.id&&o.baseUrl===a.baseUrl)?i[1].push(a):i[0].push(a),i),[[],[]]);return t.concat(r)}_removeIndexFromDowngradeList(e){this._downgradedCdnList.metadata.splice(e,1);let t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])}};function uu(n,e){return n.length===0?-1:e.id!==void 0?re(n,t=>t.id===e.id):re(n,t=>t.baseUrl===e.baseUrl)}function qa(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=d=>e(r,a,d),u=n.create(s,i,a,o);return t.set(u,s),u},updatePriority(r,i){let a=t.get(r);if(a===void 0){m.warn(\"Fetchers: Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Ha=class{constructor(){this._cache=new WeakMap}add({representation:e,segment:t},r){t.isInit&&this._cache.set(e,r)}get({representation:e,segment:t}){if(t.isInit){let r=this._cache.get(e);if(r!==void 0)return r}return null}},du=Ha;var Nf=Ae();function Ga({bufferType:n,pipeline:e,cdnPrioritizer:t,cmcdDataBuilder:r,eventListeners:i,requestOptions:a}){let o;a.connectionTimeout===void 0||a.connectionTimeout<0?o=void 0:o=a.connectionTimeout;let s={timeout:a.requestTimeout<0?void 0:a.requestTimeout,connectionTimeout:o,cmcdPayload:void 0},u=ge([\"audio\",\"video\"],n)?new du:void 0,{loadSegment:d,parseSegment:f}=e;return async function(c,g,p){var Z,Y,H;let{segment:h,adaptation:b,representation:y,manifest:T,period:P}=c,E=Tt(c),C=Nf(),_,O=[],k=0,A=!1,R={segment:h,type:b.type,language:b.language,isLive:T.isLive,periodStart:P.start,periodEnd:P.end,mimeType:y.mimeType,codecs:y.codecs[0],manifestPublishTime:T.publishTime},x={onProgress(q){var J;_===void 0&&q.totalSize!==void 0&&q.size<q.totalSize&&((J=i.onProgress)==null||J.call(i,{duration:q.duration,size:q.size,totalSize:q.totalSize,timestamp:L(),id:C}))},onNewChunk(q){g.onChunk(B(q,!0))}},N=u!==void 0?u.get(c):null;if(N!==null)return m.debug(\"SF: Found wanted segment in cache\",E),g.onChunk(B(N,!1)),Promise.resolve();m.debug(\"SF: Beginning request\",E),(Z=i.onRequestBegin)==null||Z.call(i,{requestTimestamp:L(),id:C,content:c}),p.register(w);try{let q=await za(c.representation.cdnMetadata,t,M,G({onRetry:U},a),p);if(q.resultType===\"segment-loaded\"){let J=q.resultData.responseData;u!==void 0&&u.add(c,q.resultData.responseData),g.onChunk(B(J,!1))}else q.resultType===\"segment-created\"&&g.onChunk(B(q.resultData,!1));m.debug(\"SF: Segment request ended with success\",E),g.onAllChunksReceived(),q.resultType!==\"segment-created\"?(_=q.resultData,V()):_=null,p.isCancelled()||(Y=i.onRequestEnd)==null||Y.call(i,{id:C}),p.deregister(w)}catch(q){throw p.deregister(w),_=null,q instanceof ue?(m.debug(\"SF: Segment request aborted\",E),q):(m.debug(\"SF: Segment request failed\",E),(H=i.onRequestEnd)==null||H.call(i,{id:C}),st(q))}function w(){var q;_===void 0&&(m.debug(\"SF: Segment request cancelled\",E),_=null,(q=i.onRequestEnd)==null||q.call(i,{id:C}))}function M(q){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(c),d(q,R,s,p,x)}function B(q,J){O.push(!1);let de=O.length-1;return function(ie){let Ge={data:q,isChunked:J};try{let Me=f(Ge,R,ie);return O[de]||(k=k!==void 0&&Me.segmentType===\"media\"&&Me.chunkInfos!==null&&Me.chunkInfos.duration!==void 0?k+Me.chunkInfos.duration:void 0,O[de]=!0,V()),Me}catch(Me){throw ye(Me,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function U(q){g.onRetry(st(q))}function V(){var q;A||!v(_)&&_.size!==void 0&&_.requestDuration!==void 0&&O.length>0&&O.every(J=>J)&&(A=!0,(q=i.onMetrics)==null||q.call(i,{size:_.size,requestDuration:_.requestDuration,content:c,segmentDuration:k}))}}}function lu({maxRetry:n,lowLatencyMode:e,requestTimeout:t,connectionTimeout:r}){let{DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:i,DEFAULT_REQUEST_TIMEOUT:a,DEFAULT_CONNECTION_TIMEOUT:o,INITIAL_BACKOFF_DELAY_BASE:s,MAX_BACKOFF_DELAY_BASE:u}=F.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?u.LOW_LATENCY:u.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var tr=class extends le{constructor(e,t){super(),this._segmentFetcher=e,this._currentContentInfo=null,this.isMediaSegmentQueueInterrupted=t}getRequestedInitSegment(){var e,t,r;return(r=(t=(e=this._currentContentInfo)==null?void 0:e.initSegmentRequest)==null?void 0:t.segment)!=null?r:null}getRequestedMediaSegment(){var e,t,r;return(r=(t=(e=this._currentContentInfo)==null?void 0:e.mediaSegmentRequest)==null?void 0:t.segment)!=null?r:null}resetForContent(e,t){var o;(o=this._currentContentInfo)==null||o.currentCanceller.cancel();let r=new j({initSegment:null,segmentQueue:[]}),i=new W;i.signal.register(()=>{r.finish()});let a={content:e,downloadQueue:r,initSegmentInfoRef:t?new j(void 0):new j(null),currentCanceller:i,initSegmentRequest:null,mediaSegmentRequest:null,mediaSegmentAwaitingInitMetadata:null};return this._currentContentInfo=a,this.isMediaSegmentQueueInterrupted.onUpdate(s=>{s||(m.debug(\"SQ: Media segment can be loaded again, restarting queue.\",e.adaptation.type),this._restartMediaSegmentDownloadingQueue(a))},{clearSignal:i.signal}),r.onUpdate(s=>{let{segmentQueue:u}=s;if(u.length>0&&u[0].segment.id===a.mediaSegmentAwaitingInitMetadata)return;let d=a.mediaSegmentRequest;if(u.length===0){if(d===null)return;m.debug(\"SQ: no more media segment to request. Cancelling queue.\",e.adaptation.type),this._restartMediaSegmentDownloadingQueue(a);return}else if(d===null){m.debug(\"SQ: Media segments now need to be requested. Starting queue.\",e.adaptation.type,u.length),this._restartMediaSegmentDownloadingQueue(a);return}else{let f=u[0];if(d.segment.id!==f.segment.id){m.debug(\"SQ: Next media segment changed, cancelling previous\",e.adaptation.type),this._restartMediaSegmentDownloadingQueue(a);return}d.priority!==f.priority&&(m.debug(\"SQ: Priority of next media segment changed, updating\",e.adaptation.type,d.priority,f.priority),this._segmentFetcher.updatePriority(d.request,f.priority));return}},{emitCurrentValue:!0,clearSignal:i.signal}),r.onUpdate(s=>{var d;let u=a.initSegmentRequest;if(s.initSegment!==null&&u!==null){s.initSegment.priority!==u.priority&&this._segmentFetcher.updatePriority(u.request,s.initSegment.priority);return}else if(((d=s.initSegment)==null?void 0:d.segment.id)===(u==null?void 0:u.segment.id))return;s.initSegment===null&&m.debug(\"SQ: no more init segment to request. Cancelling queue.\",e.adaptation.type),this._restartInitSegmentDownloadingQueue(a,s.initSegment)},{emitCurrentValue:!0,clearSignal:i.signal}),r}stop(){var e;(e=this._currentContentInfo)==null||e.currentCanceller.cancel(),this._currentContentInfo=null}_restartMediaSegmentDownloadingQueue(e){e.mediaSegmentRequest!==null&&e.mediaSegmentRequest.canceller.cancel();let{downloadQueue:t,content:r,initSegmentInfoRef:i,currentCanceller:a}=e,o=()=>{var P;if(this.isMediaSegmentQueueInterrupted.getValue()){m.debug(\"SQ: Segment fetching postponed because it cannot stream now.\");return}let{segmentQueue:s}=t.getValue(),u=s[0];if(a!==null&&a.isUsed()){e.mediaSegmentRequest=null;return}if(u===void 0){e.mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let d=new W,f=a===null?D:d.linkToSignal(a.signal),{segment:l,priority:c}=u,g=G({segment:l,nextSegment:(P=s[1])==null?void 0:P.segment},r),p=!1,h=!1;d.signal.register(()=>{e.mediaSegmentRequest=null,!p&&(e.mediaSegmentAwaitingInitMetadata===l.id&&(e.mediaSegmentAwaitingInitMetadata=null),p=!0,h=!1)});let b=E=>{ce(E.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",G({},E,{segment:l}))},y=()=>{let E=t.getValue().segmentQueue;if(E.length===0){p=!0,this.trigger(\"emptyQueue\",null);return}else E[0].segment.id===l.id&&E.shift();p=!0,o()},T=this._segmentFetcher.createRequest(g,c,{onRetry:E=>{this.trigger(\"requestRetry\",{segment:l,error:E})},beforeInterrupted(){m.info(\"SQ: segment request interrupted temporarly.\",l.id,l.time)},onChunk:E=>{let C=i.getValue();C!==void 0?b(E(C!=null?C:void 0)):(h=!0,i.waitUntilDefined(_=>{b(E(_!=null?_:void 0))},{clearSignal:d.signal}))},onAllChunksReceived:()=>{h?(e.mediaSegmentAwaitingInitMetadata=l.id,i.waitUntilDefined(()=>{e.mediaSegmentAwaitingInitMetadata=null,h=!1,this.trigger(\"fullyLoadedSegment\",l)},{clearSignal:d.signal})):this.trigger(\"fullyLoadedSegment\",l)},beforeEnded:()=>{f(),e.mediaSegmentRequest=null,h?i.waitUntilDefined(y,{clearSignal:d.signal}):y()}},d.signal);T.catch(E=>{f(),p||(p=!0,this.stop(),this.trigger(\"error\",E))}),e.mediaSegmentRequest={segment:l,priority:c,request:T,canceller:d}};o()}_restartInitSegmentDownloadingQueue(e,t){let{content:r,initSegmentInfoRef:i}=e;if(e.initSegmentRequest!==null&&e.initSegmentRequest.canceller.cancel(),t===null)return;let a=new W,o=e.currentCanceller===null?D:a.linkToSignal(e.currentCanceller.signal),{segment:s,priority:u}=t,d=G({segment:s,nextSegment:void 0},r),f=!1,l=this._segmentFetcher.createRequest(d,u,{onRetry:c=>{this.trigger(\"requestRetry\",{segment:s,error:c})},beforeInterrupted:()=>{m.info(\"SQ: init segment request interrupted temporarly.\",s.id)},beforeEnded:()=>{o(),e.initSegmentRequest=null,f=!0},onChunk:c=>{var p;let g=c(void 0);ce(g.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",G({},g,{segment:s})),g.segmentType===\"init\"&&i.setValue((p=g.initTimescale)!=null?p:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",s)}},a.signal);l.catch(c=>{o(),f||(f=!0,this.stop(),this.trigger(\"error\",c))}),a.signal.register(()=>{e.initSegmentRequest=null,!f&&(f=!0)}),e.initSegmentRequest={segment:s,priority:u,request:l,canceller:a}}};var rr=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,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.\")}create(e,t,r,i){let a;return Et(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let d=()=>{g(),this._endTask(a)},f=p=>{r.beforeEnded(),d(),o(p)},l=p=>{d(),s(p)},c=new W,g=c.linkToSignal(i);a.interrupter=c,c.signal.register(()=>{a.interrupter=null,i.isCancelled()||r.beforeInterrupted()}),this._minPendingPriority=this._minPendingPriority===null?a.priority:Math.min(this._minPendingPriority,a.priority),this._pendingTasks.push(a),a.taskFn(c.signal).then(f).catch(p=>{!i.isCancelled()&&c.isUsed()&&p instanceof ue||l(p)})},taskFn:e,interrupter:null},this._canBeStartedNow(a)?(a.trigger(),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()):this._waitingQueue.push(a),()=>this._endTask(a)))}_endTask(e){e.hasEnded=!0;let t=nr(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=nr(e.taskFn,this._pendingTasks);if(r<0)return;this._pendingTasks.splice(r,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}}updatePriority(e,t){let r=nr(e,this._waitingQueue);if(r>=0){let s=this._waitingQueue[r];if(s.priority===t||(s.priority=t,!this._canBeStartedNow(s)))return;this._findAndRunWaitingQueueTask(r),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks();return}let i=nr(e,this._pendingTasks);if(i<0){m.warn(\"TP: request to update the priority of a non-existent task\");return}let a=this._pendingTasks[i];if(a.priority===t)return;let o=a.priority;a.priority=t,this._minPendingPriority===null||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(this._pendingTasks.length===1?this._minPendingPriority=t:this._minPendingPriority=Math.min(...this._pendingTasks.map(s=>s.priority)),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}_loopThroughWaitingQueue(){let e=this._waitingQueue.reduce((t,r)=>t===null||t>r.priority?r.priority:t,null);if(!(e===null||this._minPendingPriority!==null&&this._minPendingPriority<e))for(let t=0;t<this._waitingQueue.length;t++){let r=this._minPendingPriority===null?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=r&&(this._findAndRunWaitingQueueTask(t),t--)}}_interruptCancellableTasks(){for(let e of this._pendingTasks)if(e.priority>=this._prioritySteps.low)return this._interruptPendingTask(e),this._interruptCancellableTasks()}_findAndRunWaitingQueueTask(e){return e>=this._waitingQueue.length||e<0?(m.warn(\"TP : Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=nr(e.taskFn,this._pendingTasks);if(t<0){m.warn(\"TP: Interrupting a non-existent pending task. Aborting...\");return}this._pendingTasks.splice(t,1),this._waitingQueue.push(e),this._pendingTasks.length===0?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))),(r=e.interrupter)==null||r.cancel()}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function nr(n,e){return re(e,t=>t.taskFn===n)}var ir=class{constructor(e,t,r,i){let a=new er(i),{MIN_CANCELABLE_PRIORITY:o,MAX_HIGH_PRIORITY_LEVEL:s}=F.getCurrent();this._transport=e,this._prioritizer=new rr({prioritySteps:{high:s,low:o}}),this._cdnPrioritizer=a,this._backoffOptions=r,this._cmcdDataBuilder=t}createSegmentQueue(e,t,r){let i=lu(this._backoffOptions),a=this._transport[e],o=Ga({bufferType:e,pipeline:a,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:i}),s=qa(this._prioritizer,o);return new tr(s,r)}};var Ka=ir;var fu=6,ja=4e3,$r=6e3,Bf=6e4,Yt=class{constructor(e){this._segmentSinksStore=e,this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=null,this._lastFlushAttempt=null,this._lastSegmentInfo={audio:[],video:[]}}onNewObservation(e){var b,y;let t=L();if(this._addPositionToHistory(e,t),this._ignoreFreezeUntil!==null&&t<this._ignoreFreezeUntil)return null;this._ignoreFreezeUntil=null;let{UNFREEZING_SEEK_DELAY:r,UNFREEZING_DELTA_POSITION:i,FREEZING_FLUSH_FAILURE_DELAY:a}=F.getCurrent(),{readyState:o,rebuffering:s,freezing:u,fullyLoaded:d}=e,f=e.position.getPolled(),l=cu(e.bufferGap);if(!(u!==null||s!==null&&o===1&&(l>=fu||d)))return this._decipherabilityFreezeStartingTimestamp=null,null;let g=(y=(b=u==null?void 0:u.timestamp)!=null?b:s==null?void 0:s.timestamp)!=null?y:null;if(m.info(\"FR: Freeze detected\",g,t-(g!=null?g:t)),this._lastFlushAttempt!==null&&t-this._lastFlushAttempt.timestamp<a.MAXIMUM&&t-this._lastFlushAttempt.timestamp>=a.MINIMUM&&Math.abs(f-this._lastFlushAttempt.position)<a.POSITION_DELTA){let T=this._getStrategyIfFlushingFails(f);return this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+$r,T}let h=this._checkForDecipherabilityRelatedFreeze(e,t);return h!==null?h:g!==null&&t-g>r?(this._lastFlushAttempt={timestamp:t,position:f+i},m.debug(\"FR: trying to flush to un-freeze\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+$r,{type:\"flush\",value:{relativeSeek:i}}):null}_checkForDecipherabilityRelatedFreeze(e,t){let{readyState:r,rebuffering:i,freezing:a,fullyLoaded:o}=e,s=cu(e.bufferGap),u=i!==null&&t-i.timestamp>ja,d=a!==null&&t-a.timestamp>ja;(u||d)&&(s>=fu||o)&&r<=1?this._decipherabilityFreezeStartingTimestamp===null&&(m.debug(\"FR: Start of a potential decipherability freeze detected\"),this._decipherabilityFreezeStartingTimestamp=t):this._decipherabilityFreezeStartingTimestamp=null;let l=this._decipherabilityFreezeStartingTimestamp!==null&&L()-this._decipherabilityFreezeStartingTimestamp>ja,c=!0,g=!0;for(let p of[\"audio\",\"video\"]){let h=this._segmentSinksStore.getStatus(p);if(h.type===\"initialized\")for(let b of h.value.getLastKnownInventory()){let{representation:y}=b.infos;if(y.decipherable===!1)return m.warn(\"FR: we have undecipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+$r,{type:\"reload\",value:null};y.contentProtections!==void 0&&(g=!1,y.decipherable!==!0&&(c=!1))}}return l&&!g&&c?(m.warn(\"FR: we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+$r,{type:\"reload\",value:null}):null}_getStrategyIfFlushingFails(e){m.warn(\"FR: A recent flush seemed to have no effect on freeze, checking for transitions\");let t=[];for(let r of[\"audio\",\"video\"]){let i=this._lastSegmentInfo[r];if(i.length===0)continue;let a=i[i.length-1];if(a.segment===null)continue;let o=a.segment,s;for(let u=i.length-2;u>=0;u--){let d=i[u];if(d.segment===null){s=d;break}else if(d.segment.infos.representation.uniqueId!==o.infos.representation.uniqueId&&a.timestamp-d.timestamp<5e3){s=d;break}else d.segment.start===o.start&&e-d.position<3e3&&(a=d)}if(s===void 0||s.segment===null)m.debug(\"FR: Freeze when beginning to play a content, try avoiding this quality\"),t.push({adaptation:o.infos.adaptation,period:o.infos.period,representation:o.infos.representation});else{if(o.infos.period.id!==s.segment.infos.period.id)return m.debug(\"FR: Freeze when switching Period, reloading\"),{type:\"reload\",value:null};o.infos.representation.uniqueId!==s.segment.infos.representation.uniqueId&&(m.warn(\"FR: Freeze when switching Representation, avoiding\",o.infos.representation.bitrate),t.push({adaptation:o.infos.adaptation,period:o.infos.period,representation:o.infos.representation}))}}return t.length>0?{type:\"avoid-representations\",value:t}:(m.debug(\"FR: Reloading because flush doesn't work\"),{type:\"reload\",value:null})}_addPositionToHistory(e,t){var i,a;let r=e.position.getPolled();for(let o of[\"audio\",\"video\"]){let s=this._segmentSinksStore.getStatus(o);if(s.type===\"initialized\")for(let f of s.value.getLastKnownInventory())((i=f.bufferedStart)!=null?i:f.start)<=r&&((a=f.bufferedEnd)!=null?a:f.end)>r&&this._lastSegmentInfo[o].push({segment:f,position:r,timestamp:t});else this._lastSegmentInfo[o].push({segment:null,position:r,timestamp:t});if(this._lastSegmentInfo[o].length>100){let f=this._lastSegmentInfo[o].length-100;this._lastSegmentInfo[o].splice(0,f)}let u=t-Bf,d;for(d=0;d<this._lastSegmentInfo[o].length&&!(this._lastSegmentInfo[o][d].timestamp>u);d++);d>0&&this._lastSegmentInfo[o].splice(0,d)}}};function cu(n){return n!==void 0&&isFinite(n)?n:0}var{DEFAULT_WANTED_BUFFER_AHEAD:Uf,DEFAULT_MAX_VIDEO_BUFFER_SIZE:Lf,DEFAULT_MAX_BUFFER_AHEAD:Ff,DEFAULT_MAX_BUFFER_BEHIND:zf}=F.getCurrent(),Ya=new j(Uf),Qa=new j(Lf),$a=new j(Ff),Xa=new j(zf),Xr=new j({height:void 0,width:void 0,pixelRatio:1}),Zr=new j(1/0);function $(n,e){m.debug(\"<--- Sending to Main:\",n.type),e===void 0?postMessage(n):postMessage(n,e)}function xe(n){return ye(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var ar=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,u,d,f,l,c;for(let g of this._refs.keys())(t=(e=this._refs.get(g))==null?void 0:e.audio)==null||t.trackReference.finish(),(i=(r=this._refs.get(g))==null?void 0:r.audio)==null||i.representations.finish(),(o=(a=this._refs.get(g))==null?void 0:a.video)==null||o.trackReference.finish(),(u=(s=this._refs.get(g))==null?void 0:s.video)==null||u.representations.finish(),(f=(d=this._refs.get(g))==null?void 0:d.text)==null||f.trackReference.finish(),(c=(l=this._refs.get(g))==null?void 0:l.text)==null||c.representations.finish();this._refs=new Map}addTrackSetter(e,t,r){var s,u;let i=this._refs.get(e);i===void 0&&(i={},this._refs.set(e,i)),i[t]!==void 0&&(m.warn(\"WP: Track for periodId already declared\",e,t),(s=i[t])==null||s.trackReference.finish(),(u=i[t])==null||u.representations.finish());let a=r.getValue(),o;v(a)?o=new j({representationIds:[],switchingMode:\"lazy\"}):(o=new j(a.representations.getValue()),r.setValue(G({},a,{representations:o}))),i[t]={trackReference:r,representations:o}}setTrack(e,t,r){var a;let i=(a=this._refs.get(e))==null?void 0:a[t];return i===void 0?(m.debug(\"WP: Setting track for inexistent periodId\",e,t),!1):(v(r)?(i.representations=new j({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new j(r.initialRepresentations),i.trackReference.setValue({adaptationId:r.adaptationId,switchingMode:r.switchingMode,representations:i.representations,relativeResumingPosition:r.relativeResumingPosition})),!0)}updateRepresentations(e,t,r,i){var s;let a=(s=this._refs.get(e))==null?void 0:s[r];if(a===void 0)return m.debug(\"WP: Setting track for inexistent periodId\",e,r),!1;let o=a.trackReference.getValue();return v(o)||o.adaptationId!==t?(m.debug(\"WP: Desynchronized Adaptation id\",o==null?void 0:o.adaptationId,t),!1):(a.representations.setValue(i),!0)}removeTrackSetter(e,t){let r=this._refs.get(e),i=r==null?void 0:r[t];return r===void 0||i===void 0?(m.debug(\"WP: Removing track setter for inexistent periodId\",e,t),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};var or=class{constructor(e,t){this._contentId=e,this._messageSender=t,this._queues={pushTextData:[],remove:[]}}pushTextData(e){return new Promise((t,r)=>{this._messageSender({type:\"push-text-data\",contentId:this._contentId,value:e}),this._queues.pushTextData.push({resolve:t,reject:r})})}remove(e,t){return new Promise((r,i)=>{this._messageSender({type:\"remove-text-data\",contentId:this._contentId,value:{start:e,end:t}}),this._queues.remove.push({resolve:r,reject:i})})}reset(){this._messageSender({type:\"reset-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}stop(){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}_resetCurrentQueue(){let e=new ue;this._queues.pushTextData.forEach(t=>{t.reject(e)}),this._queues.remove.forEach(t=>{t.reject(e)})}onPushedTrackSuccess(e){let t=this._queues.pushTextData.shift();if(t===void 0){m.error(\"WMS: pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){m.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){m.error(\"WMS: remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){m.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}};var mu=Ae(),Qt=class{constructor({hasMseInWorker:e,hasVideo:t}){this._currentContent=null,this._currentMediaSourceCanceller=new W,this._hasVideo=t,this._hasMseInWorker=e;let r=new W;this._contentCanceller=r}initializeNewContent(e){return new Promise((t,r)=>{var A,R;this.disposeCurrentContent();let i=this._contentCanceller,a=new W;this._currentMediaSourceCanceller=a,a.linkToSignal(i.signal);let{contentId:o,url:s,hasText:u,transportOptions:d,enableRepresentationAvoidance:f}=e,l=null;ce(we.transports.dash!==void 0,\"Multithread RxPlayer should have access to the DASH feature\");let c=typeof d.representationFilter==\"string\"?Io(d.representationFilter):void 0,g=we.transports.dash(oe(ee({},d),{representationFilter:c})),p=e.cmcd===void 0?null:new su(e.cmcd),h=new Va(s===void 0?void 0:[s],g,ee({cmcdDataBuilder:p},e.manifestRetryOptions)),b=ou({initialBitrates:{audio:(A=e.initialAudioBitrate)!=null?A:0,video:(R=e.initialVideoBitrate)!=null?R:0},lowLatencyMode:d.lowLatencyMode,throttlers:{limitResolution:{video:Xr},throttleBitrate:{video:Zr}}}),y=a.signal.register(x=>{r(x)}),T=new Ka(g,p,e.segmentRetryOptions,i.signal),P=new ar,[E,C,_]=pu(o,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:u},a.signal),O=new Yt(C);this._currentContent={cmcdDataBuilder:p,contentId:o,enableRepresentationAvoidance:f,freezeResolver:O,mediaSource:E,manifest:null,manifestFetcher:h,representationEstimator:b,segmentSinksStore:C,segmentQueueCreator:T,workerTextSender:_,trackChoiceSetter:P},E.addEventListener(\"mediaSourceOpen\",function(){k()},a.signal),i.signal.register(()=>{h.dispose()}),h.addEventListener(\"warning\",x=>{$({type:\"warning\",contentId:o,value:xe(x)})},i.signal),h.addEventListener(\"manifestReady\",x=>{if(l!==null){m.warn(\"WP: Multiple `manifestReady` events, ignoring\");return}l=x,this._currentContent!==null&&(this._currentContent.manifest=l),k()},a.signal),h.addEventListener(\"error\",x=>{$({type:\"error\",contentId:o,value:xe(x)}),r(x)},i.signal),h.start();function k(){if(l===null||E.readyState===\"closed\"||a.isUsed())return;let x=l.getMetadataSnapshot();l.addEventListener(\"manifestUpdate\",N=>{if(l===null)return;let w=G(l.getMetadataSnapshot(),{periods:[]});$({type:\"manifest-update\",contentId:o,value:{manifest:w,updates:N}})},i.signal),y(),t(x)}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new W,$({type:\"reloading-media-source\",contentId:this._currentContent.contentId,value:e},[]);let[t,r,i]=pu(this._currentContent.contentId,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.workerTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.freezeResolver=new Yt(r),this._currentContent.workerTextSender=i,new Promise((a,o)=>{t.addEventListener(\"mediaSourceOpen\",function(){a()},this._currentMediaSourceCanceller.signal),t.addEventListener(\"mediaSourceClose\",function(){o(new Error(\"MediaSource ReadyState changed to close during init.\"))},this._currentMediaSourceCanceller.signal),this._currentMediaSourceCanceller.signal.register(s=>{o(s)})})}disposeCurrentContent(){this._contentCanceller.cancel(),this._contentCanceller=new W}};function pu(n,e,t){let r;if(e.hasMseInWorker){let s=new qn(mu());r=s;let u,d=s.handle;if(d.type===\"handle\")u={type:\"handle\",value:d.value};else{let f=URL.createObjectURL(d.value);u={type:\"url\",value:f},t.register(()=>{URL.revokeObjectURL(f)})}$({type:\"attach-media-source\",contentId:n,value:u,mediaSourceId:r.id},[d.value])}else r=new Hn(mu(),n,$);let i=e.hasText?new or(n,$):null,{hasVideo:a}=e,o=new St(r,a,i);return t.register(()=>{o.disposeAll(),i==null||i.stop(),r.dispose()}),[r,o,i]}function Za(){let n=!1,e=new Qt({hasMseInWorker:!1,hasVideo:!0}),t=null,r=new Ts;we.dashParsers.wasm=r,we.dashParsers.fastJs=ss,we.transports.dash=ks;let i=null;ae.onmessageerror=a=>{m.error(\"MTCI: Error when receiving message from main thread.\")},onmessage=function(a){var s,u;m.debug(\"Worker: received message\",a.data.type);let o=a.data;switch(o.type){case\"init\":ce(!n),n=!0,ro(o.value),gu(o.value.logLevel,o.value.logFormat,o.value.sendBackLogs),o.value.dashWasmUrl!==void 0&&r.isCompatible()&&r.initialize({wasmUrl:o.value.dashWasmUrl}).catch(d=>{let f=d instanceof Error?d.toString():\"Unknown Error\";m.error(\"Worker: Could not initialize DASH_WASM parser\",f)}),(!o.value.hasVideo||o.value.hasMseInWorker)&&(e.disposeCurrentContent(),e=new Qt({hasMseInWorker:o.value.hasMseInWorker,hasVideo:o.value.hasVideo})),$({type:\"init-success\",value:null});break;case\"log-level-update\":gu(o.value.logLevel,o.value.logFormat,o.value.sendBackLogs);break;case\"prepare\":Wf(e,o.value);break;case\"start\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;t!==null&&(t.cancel(),t=null);let f=new W,l=new j(G(o.value.initialObservation,{position:new kt(...o.value.initialObservation.position)}));i=l,t=f,t.signal.register(()=>{l.finish()}),m.debug(\"WP: Loading new pepared content.\"),hu(o.value,e,l,f.signal);break}case\"observation\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;let f=o.value,{buffered:l}=f,c=xa(d.mediaSource,null);c.audio!==null&&(l.audio=c.audio),c.video!==null&&(l.video=c.video),i==null||i.setValue(G(f,{position:new kt(...o.value.position)}));break}case\"ref-update\":Vf(o);break;case\"stop\":if(o.contentId!==((s=e.getCurrentContent())==null?void 0:s.contentId))return;e.disposeCurrentContent(),t!==null&&(t.cancel(),t=null);break;case\"sb-success\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,l=Q(f,c=>c.type===o.sourceBufferType);if(l===void 0){m.info(\"WP: Success for an unknown SourceBuffer\",o.sourceBufferType);return}if(l.onOperationSuccess===void 0){m.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}l.onOperationSuccess(o.operationId,o.value.buffered);break}case\"sb-error\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,l=Q(f,c=>c.type===o.sourceBufferType);if(l===void 0){m.info(\"WP: Error for an unknown SourceBuffer\",o.sourceBufferType);return}if(l.onOperationFailure===void 0){m.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}l.onOperationFailure(o.operationId,o.value);break}case\"media-source-ready-state-change\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;if(d.mediaSource.onMediaSourceReadyStateChanged===void 0){m.warn(\"WP: A MediaSourceInterface with MSE performed a cross-thread operation\");return}d.mediaSource.onMediaSourceReadyStateChanged(o.value);break}case\"decipherability-update\":{if(o.contentId!==((u=e.getCurrentContent())==null?void 0:u.contentId))return;let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let f=o.value;d.manifest.updateRepresentationsDeciperability(l=>{for(let c of f)if(l.representation.uniqueId===c.representationUniqueId)return c.decipherable;return l.representation.decipherable});break}case\"codec-support-update\":{let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let f=o.value;try{let l=d.manifest.updateCodecSupport(f);l!==null&&$({type:\"warning\",contentId:d.contentId,value:xe(l)})}catch(l){$({type:\"error\",contentId:d.contentId,value:xe(l)})}break}case\"urls-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.manifestFetcher.updateContentUrls(o.value.urls,o.value.refreshNow);break}case\"track-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.setTrack(o.value.periodId,o.value.bufferType,o.value.choice);break}case\"rep-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.updateRepresentations(o.value.periodId,o.value.adaptationId,o.value.bufferType,o.value.choice);break}case\"add-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){m.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackSuccess(o.value.ranges);break}case\"push-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){m.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackError(new Error(o.value.message));break}case\"remove-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){m.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveSuccess(o.value.ranges);break}case\"remove-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){m.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveError(new Error(o.value.message));break}case\"pull-segment-sink-store-infos\":{qf(e,o.value.messageId);break}case\"config-update\":{F.update(o.value);break}default:Ne(o)}}}function Wf(n,e){n.initializeNewContent(e).then(t=>{$({type:\"manifest-ready\",contentId:e.contentId,value:{manifest:t}})},t=>{$({type:\"error\",contentId:e.contentId,value:xe(t)})})}function Vf(n){switch(n.value.name){case\"wantedBufferAhead\":Ya.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":Qa.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":Xa.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":$a.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":Xr.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":Zr.setValueIfChanged(n.value.newVal);break;default:Ne(n.value)}}function hu(n,e,t,r){var A;m.debug(\"WP: Loading prepared content\");let i=new W;i.linkToSignal(r);let a=new Map,o=e.getCurrentContent();if(o===null||o.manifest===null){let R=new Se(\"NONE\",\"Loading content when none is prepared\");$({type:\"error\",contentId:void 0,value:xe(R)});return}let{contentId:s,cmcdDataBuilder:u,enableRepresentationAvoidance:d,manifest:f,mediaSource:l,representationEstimator:c,segmentSinksStore:g,segmentQueueCreator:p}=o,{drmSystemId:h,enableFastSwitching:b,initialTime:y,onCodecSwitch:T}=n;t.onUpdate(R=>{Ma(R,g);let x=o.freezeResolver.onNewObservation(R);x!==null&&Hf(x,{contentId:s,manifest:f,handleMediaSourceReload:k,enableRepresentationAvoidance:d})},{clearSignal:i.signal});let P=(A=f.getPeriodForTime(y))!=null?A:f.getNextPeriod(y);if(P===void 0){let R=new X(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");$({type:\"error\",contentId:s,value:xe(R)});return}let E=new Cn(t,s,$,i.signal);u==null||u.startMonitoringPlayback(E),i.signal.register(()=>{u==null||u.stopMonitoringPlayback()});let C=ka(f,l,E,g,{onWarning:R=>$({type:\"warning\",contentId:s,value:xe(R)}),onPeriodChanged:R=>{$({type:\"active-period-changed\",contentId:s,value:{periodId:R.id}})}},i.signal);$s({initialPeriod:P,manifest:f},E,c,g,p,{wantedBufferAhead:Ya,maxVideoBufferSize:Qa,maxBufferAhead:$a,maxBufferBehind:Xa,drmSystemId:h,enableFastSwitching:b,onCodecSwitch:T},_(),i.signal);function _(){return{needsBufferFlush(R){$({type:\"needs-buffer-flush\",contentId:s,value:R})},streamStatusUpdate(R){O(R),f.isLastPeriodKnown&&R.period.id===f.periods[f.periods.length-1].id&&(R.hasFinishedLoading||R.isEmptyStream?C.onLastSegmentFinishedLoading(R.bufferType):C.onLastSegmentLoadingResume(R.bufferType))},needsManifestRefresh(){e.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:R}=F.getCurrent();e.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:R})},lockedStream(R){$({type:\"locked-stream\",contentId:s,value:{periodId:R.period.id,bufferType:R.bufferType}})},adaptationChange(R){var x,N;C.onAdaptationChange(R.type,R.period,R.adaptation),!i.signal.isCancelled()&&$({type:\"adaptation-changed\",contentId:s,value:{adaptationId:(N=(x=R.adaptation)==null?void 0:x.id)!=null?N:null,periodId:R.period.id,type:R.type}})},representationChange(R){var x,N;C.onRepresentationChange(R.type,R.period),!i.signal.isCancelled()&&$({type:\"representation-changed\",contentId:s,value:{adaptationId:R.adaptation.id,representationId:(N=(x=R.representation)==null?void 0:x.id)!=null?N:null,periodId:R.period.id,type:R.type}})},inbandEvent(R){$({type:\"inband-event\",contentId:s,value:R})},warning(R){$({type:\"warning\",contentId:s,value:xe(R)})},periodStreamReady(R){o!==null&&(o.trackChoiceSetter.addTrackSetter(R.period.id,R.type,R.adaptationRef),$({type:\"period-stream-ready\",contentId:s,value:{periodId:R.period.id,bufferType:R.type}}))},periodStreamCleared(R){if(o===null)return;let x=a.get(R.period);x!==void 0&&(x.delete(R.type),x.size===0&&a.delete(R.period)),C.onPeriodCleared(R.type,R.period),o.trackChoiceSetter.removeTrackSetter(R.period.id,R.type),$({type:\"period-stream-cleared\",contentId:s,value:{periodId:R.period.id,bufferType:R.type}})},bitrateEstimateChange(R){var x;o!==null&&((x=o.cmcdDataBuilder)==null||x.updateThroughput(R.type,R.bitrate)),$({type:\"bitrate-estimate-change\",contentId:s,value:{bitrate:R.bitrate,bufferType:R.type}})},needsMediaSourceReload(R){k(R)},needsDecipherabilityFlush(){$({type:\"needs-decipherability-flush\",contentId:s,value:null})},encryptionDataEncountered(R){for(let x of R){let N=x.content,w=ee({},N);w.manifest instanceof Lt&&(w.manifest=w.manifest.getMetadataSnapshot()),w.period instanceof mt&&(w.period=w.period.getMetadataSnapshot()),w.adaptation instanceof ft&&(w.adaptation=w.adaptation.getMetadataSnapshot()),w.representation instanceof rn&&(w.representation=w.representation.getMetadataSnapshot()),$({type:\"encryption-data-encountered\",contentId:s,value:{keyIds:x.keyIds,values:x.values,content:w,type:x.type}})}},error(R){$({type:\"error\",contentId:s,value:xe(R)})}}}function O(R){let{imminentDiscontinuity:x}=R,N=a.get(R.period),w=N==null?void 0:N.get(R.bufferType);if(w!==void 0){if(w.discontinuity===null){if(x===null)return}else if(x!==null&&w.discontinuity.start===x.start&&w.discontinuity.end===x.end)return}N===void 0&&(N=new Map,a.set(R.period,N));let M={periodId:R.period.id,bufferType:R.bufferType,discontinuity:R.imminentDiscontinuity,position:R.position};N.set(R.bufferType,M),$({type:\"discontinuity-update\",contentId:s,value:M})}function k(R){let N=t.getValue().position.getWanted();i!==null&&i.cancel(),m.debug(\"WP: Reloading MediaSource\",R.timeOffset,R.minimumPosition,R.maximumPosition),e.reloadMediaSource(R).then(()=>{m.info(\"WP: MediaSource Reloaded, loading content again\"),hu({initialTime:N,drmSystemId:n.drmSystemId,enableFastSwitching:n.enableFastSwitching,onCodecSwitch:n.onCodecSwitch},e,t,r)},w=>{if(W.isCancellationError(w)){m.info(\"WP: A reloading operation was cancelled\");return}$({type:\"error\",contentId:s,value:xe(w)})})}}function gu(n,e,t){t?m.setLevel(n,\"standard\",(r,i)=>{let a=i.map(o=>o instanceof Error?xe(o):o);postMessage({type:\"log\",value:{logLevel:r,logs:a}})}):m.setLevel(n,e)}function qf(n,e){let t=n.getCurrentContent();if(t===null)return;let r=t.segmentSinksStore.getSegmentSinksMetrics();$({type:\"segment-sink-store-update\",contentId:t.contentId,value:{segmentSinkMetrics:r,messageId:e}})}function Hf(n,{contentId:e,manifest:t,handleMediaSourceReload:r,enableRepresentationAvoidance:i}){switch(n.type){case\"reload\":{m.info(\"WP: Planning reload due to freeze\"),r({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}case\"flush\":{m.info(\"WP: Flushing buffer due to freeze\"),$({type:\"needs-buffer-flush\",contentId:e,value:{relativeResumingPosition:n.value.relativeSeek,relativePosHasBeenDefaulted:!1}});break}case\"avoid-representations\":{m.info(\"WP: Planning Representation avoidance due to freeze\");let a=n.value;i&&t.addRepresentationsToAvoid(a),r({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}default:Ne(n)}}var Iu=Za;Iu();})();\n" + "})()"], { type: "application/javascript" });
4
+ var blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Ru=Object.defineProperty,Pu=Object.defineProperties;var vu=Object.getOwnPropertyDescriptors;var ro=Object.getOwnPropertySymbols;var Cu=Object.prototype.hasOwnProperty,Au=Object.prototype.propertyIsEnumerable;var io=(n,e,t)=>e in n?Ru(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ee=(n,e)=>{for(var t in e||(e={}))Cu.call(e,t)&&io(n,t,e[t]);if(ro)for(var t of ro(e))Au.call(e,t)&&io(n,t,e[t]);return n},oe=(n,e)=>Pu(n,vu(e));var I={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var ao={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,FREEZING_FLUSH_FAILURE_DELAY:{MAXIMUM:2e4,MINIMUM:4e3,POSITION_DELTA:1},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:.001,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/mp4;codecs=\"hvc1.1.6.L93.B0\"','video/webm;codecs=\"vp8\"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs=\"mp4a.40.2\"','audio/webm;codecs=\"opus\"','audio/mp4;codecs=\"ec-3\"'],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\",DEFAULT_MAX_THUMBNAIL_REQUESTS_RETRY_ON_ERROR:1,DEFAULT_THUMBNAIL_REQUEST_TIMEOUT:1e4,DEFAULT_THUMBNAIL_CONNECTION_TIMEOUT:7e3},oo=ao;function xu(n,...e){if(n==null)throw new TypeError(\"Cannot convert undefined or null to object\");let t=Object(n);for(let r of e)for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t}var G=typeof Object.assign==\"function\"?Object.assign:xu;function ri(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function Zt(n,...e){if(e.length===0)return n;let t=e.shift();if(ri(n)&&ri(t))for(let r in t)if(ri(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),Zt(i,t[r])}else G(n,{[r]:t[r]});return Zt(n,...e)}function P(n){return n==null}var fe=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],r!==void 0&&r.register(()=>{this.removeEventListener(e,t)})}removeEventListener(e,t){if(P(e)){this._listeners={};return}let r=this._listeners[e];if(!Array.isArray(r))return;if(P(t)){delete this._listeners[e];return}let i=r.indexOf(t);i!==-1&&r.splice(i,1),r.length===0&&delete this._listeners[e]}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i(t)}catch(a){if(I.CURRENT_ENV===I.DEV)throw a instanceof Error?a:new Error(\"EventEmitter: listener error\");console.error(\"RxPlayer: EventEmitter error\",a instanceof Error?a:null)}})}};var ii=class extends fe{constructor(){super(...arguments);this.updated=!1;this._config=oo}update(t){let r=Zt(this._config,t);this._config=r,this.updated=!0,this.trigger(\"update\",t)}getCurrent(){return this._config}},Mu=new ii,U=Mu;var Ye=class n extends Error{constructor(e,t,r){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"CustomLoaderError\",this.canRetry=t,this.xhr=r}};function ne(n,e,t){if(typeof Array.prototype.findIndex==\"function\")return n.findIndex(e,t);let r=n.length>>>0;for(let i=0;i<r;i++)if(e.call(t,n[i],i,n))return i;return-1}function N(){}var dr=class{constructor(e,t){this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],t!==void 0&&(this._deregisterCancellation=t.register(()=>this.finish()))}getValue(){return this._value}setValue(e){if(this._isFinished){I.CURRENT_ENV===I.DEV&&console.error(\"Finished shared references cannot be updated\");return}if(this._value=e,this._listeners.length===0)return;let t=this._listeners.slice();for(let r of t)try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(i){}}setValueIfChanged(e){e!==this._value&&this.setValue(e)}onUpdate(e,t){let r=()=>{if(t.clearSignal!==void 0&&t.clearSignal.deregister(r),i.hasBeenCleared)return;i.hasBeenCleared=!0;let a=this._listeners.indexOf(i);a>=0&&this._listeners.splice(a,1)},i={trigger:e,complete:r,hasBeenCleared:!1};if(this._listeners.push(i),t.emitCurrentValue===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return N;let r=()=>{let o=ne(this._onFinishCbs,s=>s.trigger===i);o>=0&&(this._onFinishCbs[o].hasBeenCleared=!0,this._onFinishCbs.splice(o,1))},i=()=>{r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a}finish(){this._deregisterCancellation!==void 0&&this._deregisterCancellation(),this._isFinished=!0;let e=this._listeners.slice();for(let t of e)try{t.hasBeenCleared||(t.complete(),t.hasBeenCleared=!0)}catch(r){}if(this._listeners.length=0,this._onFinishCbs.length>0){let t=this._onFinishCbs.slice();for(let r of t)try{r.hasBeenCleared||(r.trigger(),r.hasBeenCleared=!0)}catch(i){}this._onFinishCbs.length=0}}};function Jt(n,e,t){let r=new dr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var Y=dr;var ai=new Y(0);function so({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;ai.setValueIfChanged(r-t)}var Ou=typeof performance!=\"undefined\"?()=>performance.now()+ai.getValue():()=>Date.now()+ai.getValue(),L=Ou;var wu=\"NONE\",en=class extends fe{constructor(){super(),this.error=N,this.warn=N,this.info=N,this.debug=N,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentFormat=\"standard\",this._currentLevel=wu}setLevel(e,t,r){let i,a=this._levels[e];typeof a==\"number\"?(i=a,this._currentLevel=e):(i=0,this._currentLevel=\"NONE\");let o;if(t===\"standard\"||t===\"full\"?o=t:o=\"standard\",o===\"full\"&&o!==this._currentFormat){let u=L();console.log(String(u.toFixed(2)),\"[Init]\",`Local-Date: ${Date.now()}`)}this._currentFormat=o;let s=this._currentFormat===\"full\"?(u,d)=>(...f)=>{let l=L();return d(String(l.toFixed(2)),`[${u}]`,...f)}:(u,d)=>d;if(r===void 0)this.error=i>=this._levels.ERROR?s(\"error\",console.error.bind(console)):N,this.warn=i>=this._levels.WARNING?s(\"warn\",console.warn.bind(console)):N,this.info=i>=this._levels.INFO?s(\"info\",console.info.bind(console)):N,this.debug=i>=this._levels.DEBUG?s(\"log\",console.log.bind(console)):N;else{let u=d=>i>=this._levels[d]?(...f)=>r(d,f):N;this.error=u(\"ERROR\"),this.warn=u(\"WARNING\"),this.info=u(\"INFO\"),this.debug=u(\"DEBUG\")}this.trigger(\"onLogLevelChange\",{level:this._currentLevel,format:this._currentFormat})}getLevel(){return this._currentLevel}getFormat(){return this._currentFormat}hasLevel(e){return this._levels[e]>=this._levels[this._currentLevel]}};var Du=new en,c=Du;var Ot=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var Nu=typeof window==\"undefined\"&&!Ot,lr=Nu;var fr;Ot?fr=self:lr?fr=global:fr=window;var ue=fr;var de=class n extends Error{constructor(e,t,r){let i;switch(r){case\"TIMEOUT\":i=\"The request timed out\";break;case\"ERROR_EVENT\":i=\"An error prevented the request to be performed successfully\";break;case\"PARSE_ERROR\":i=\"An error happened while formatting the response data\";break;case\"ERROR_HTTP_CODE\":i=\"An HTTP status code indicating failure was received: \"+String(t);break}super(i),Object.setPrototypeOf(this,n.prototype),this.name=\"RequestError\",this.url=e,this.status=t,this.type=r}serialize(){return{url:this.url,status:this.status,type:this.type}}},Re={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var oi=typeof Headers==\"function\"?Headers:null,si=typeof AbortController==\"function\"?AbortController:null;function mr(n){var m,g;let e;if(!P(n.headers))if(P(oi))e=n.headers;else{e=new oi;let p=Object.keys(n.headers);for(let b=0;b<p.length;b++){let h=p[b];e.append(h,n.headers[h])}}c.debug(\"Fetch: Called with URL\",n.url);let t=null,r=!1,i=!1,a=L(),o=P(si)?null:new si;function s(){if(P(o)){c.warn(\"Fetch: AbortController API not available.\");return}o.abort()}let u;n.timeout!==void 0&&(u=setTimeout(()=>{r=!0,d!==void 0&&clearTimeout(d),s()},n.timeout));let d;n.connectionTimeout!==void 0&&(d=setTimeout(()=>{i=!0,u!==void 0&&clearTimeout(u),s()},n.connectionTimeout));let f=n.cancelSignal.register(function(b){t=b,s()}),l={method:\"GET\"};if(e!==void 0&&(l.headers=e),l.signal=P(o)?null:o.signal,c.hasLevel(\"DEBUG\")){let p=\"FETCH: Sending GET \"+n.url;n.timeout!==void 0&&(p+=\" to=\"+String(n.timeout/1e3)),n.connectionTimeout!==void 0&&(p+=\" cto=\"+String(n.connectionTimeout/1e3)),((m=n.headers)==null?void 0:m.Range)!==void 0&&(p+=\" Range=\"+((g=n.headers)==null?void 0:g.Range)),c.debug(p)}return fetch(n.url,l).then(p=>{if(d!==void 0&&clearTimeout(d),p.status>=300)throw c.warn(\"Fetch: Request HTTP Error\",p.status,p.url),new de(p.url,p.status,Re.ERROR_HTTP_CODE);if(P(p.body))throw new de(p.url,p.status,Re.PARSE_ERROR);let b=p.headers.get(\"Content-Length\"),h=!P(b)&&!isNaN(+b)?+b:void 0,y=p.body.getReader(),E=0;return R();async function R(){let T=await y.read();if(!T.done&&!P(T.value)){E+=T.value.byteLength;let v=L(),_={url:p.url,currentTime:v,duration:v-a,sendingTime:a,chunkSize:T.value.byteLength,chunk:T.value.buffer,size:E,totalSize:h};return n.onData(_),R()}else if(T.done){u!==void 0&&clearTimeout(u),f();let v=L();return{requestDuration:v-a,receivedTime:v,sendingTime:a,size:E,status:p.status,url:p.url}}return R()}}).catch(p=>{throw t!==null?t:(f(),r?(c.warn(\"Fetch: Request timed out.\"),new de(n.url,0,Re.TIMEOUT)):i?(c.warn(\"Fetch: Request connection timed out.\"),new de(n.url,0,Re.TIMEOUT)):p instanceof de?p:(c.warn(\"Fetch: Request Error\",p instanceof Error?p.toString():\"\"),new de(n.url,0,Re.ERROR_EVENT)))})}function tn(){return typeof ue.fetch==\"function\"&&!P(si)&&!P(oi)}function K(n){return typeof n==\"string\"&&n.length>0}var Bu=\"json\";function nn(n){let e={url:n.url,headers:n.headers,responseType:P(n.responseType)?Bu:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:u,timeout:d,connectionTimeout:f}=e,l=new XMLHttpRequest;l.open(\"GET\",o,!0);let m;d!==void 0&&(l.timeout=d,m=setTimeout(()=>{h(),r(new de(o,l.status,Re.TIMEOUT))},d+3e3));let g;if(f!==void 0&&(g=setTimeout(()=>{h(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new de(o,l.status,Re.TIMEOUT))},f)),l.responseType=u,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!P(s)){let y=s;for(let E in y)Object.prototype.hasOwnProperty.call(y,E)&&l.setRequestHeader(E,y[E])}let p=L(),b=null;if(a!==void 0&&(b=a.register(function(E){h(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(E)}),a.isCancelled()))return;if(l.onerror=function(){h(),r(new de(o,l.status,Re.ERROR_EVENT))},l.ontimeout=function(){h(),r(new de(o,l.status,Re.TIMEOUT))},f!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(g)}),i!==void 0&&(l.onprogress=function(E){let R=L();i({url:o,duration:R-p,sendingTime:p,currentTime:R,size:E.loaded,totalSize:E.total})}),l.onload=function(E){if(l.readyState===XMLHttpRequest.DONE)if(h(),l.status>=200&&l.status<300){let R=L(),T=l.response instanceof ArrayBuffer?l.response.byteLength:E.total,v=l.status,_=l.responseType,M=K(l.responseURL)?l.responseURL:o,A;if(_===\"json\"?A=typeof l.response==\"object\"?l.response:Uu(l.responseText):A=l.response,P(A)){r(new de(o,l.status,Re.PARSE_ERROR));return}t({status:v,url:M,responseType:_,sendingTime:p,receivedTime:R,requestDuration:R-p,size:T,responseData:A})}else r(new de(o,l.status,Re.ERROR_HTTP_CODE))},c.hasLevel(\"DEBUG\")){let y=\"XHR: Sending GET \"+o;n.responseType!==void 0&&(y+=\" type=\"+n.responseType),d!==void 0&&(y+=\" to=\"+String(d/1e3)),f!==void 0&&(y+=\" cto=\"+String(f/1e3)),(s==null?void 0:s.Range)!==void 0&&(y+=\" Range=\"+(s==null?void 0:s.Range)),c.debug(y)}l.send();function h(){m!==void 0&&clearTimeout(m),g!==void 0&&clearTimeout(g),b!==null&&b()}})}function Uu(n){try{return JSON.parse(n)}catch(e){return null}}var be=nn;var St=Re,qe={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function Ze(n,e){return`${n}: ${e}`}var rn=class n extends Error{constructor(e,t,r){super(Ze(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=qe.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.fatal=!1,typeof(r==null?void 0:r.keyStatuses)==\"string\"&&(this.keyStatuses=r.keyStatuses)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}}};var Z=class n extends Error{constructor(e,t,r){super(Ze(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=qe.MEDIA_ERROR,this._originalMessage=t,this.code=e,this.fatal=!1,(r==null?void 0:r.tracks)!==void 0&&(r==null?void 0:r.tracks.length)>0&&(this.tracksInfo=r.tracks)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var Qe=class n extends Error{constructor(e,t){super(Ze(e,t.message)),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=qe.NETWORK_ERROR,this.url=t.url,this.status=t.status,this.errorType=t.type,this._baseError=t,this.code=e,this.fatal=!1}isHttpError(e){return this.errorType===St.ERROR_HTTP_CODE&&this.status===e}serialize(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var Ee=class n extends Error{constructor(e,t){super(Ze(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=qe.OTHER_ERROR,this.code=e,this.fatal=!1,this._originalMessage=t}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage}}};function wt(n){return(n instanceof rn||n instanceof Z||n instanceof Ee||n instanceof Qe)&&Object.keys(qe).indexOf(n.type)>=0}function ge(n,{defaultCode:e,defaultReason:t}){if(wt(n))return n;let r=n instanceof Error?n.toString():t;return new Ee(e,r)}var ke=class n extends Error{constructor(e,t,r){super(t),Object.setPrototypeOf(this,n.prototype),this.name=\"SourceBufferError\",this.errorName=e,this.isBufferFull=r}serialize(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}}toString(){return`${this.errorName}: ${this.message}`}};var Lu={dashParsers:{wasm:null,native:null,fastJs:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},uo=Lu;var Oe=uo;function j(n,e,t){if(typeof Array.prototype.find==\"function\")return n.find(e,t);let r=n.length>>>0;for(let i=0;i<r;i++){let a=n[i];if(e.call(t,a,i,n))return a}}var Fu={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\"},lo=Fu;var zu={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\"},fo=zu;function Wu(n){if(P(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=qu(t);return K(r)?r:n}function qu(n){let e;switch(n.length){case 2:e=lo[n];break;case 3:e=fo[n];break}return e}var mo=Wu;var co=mo;function cr(n,e){if(n.length!==e.length)return!1;if(n===e)return!0;for(let t=n.length-1;t>=0;t--)if(n[t]!==e[t])return!1;return!0}function ui(n){return Object.keys(n).map(e=>n[e])}var pr=typeof Object.values==\"function\"?Object.values:ui;var Dt=[\"audio\",\"video\",\"text\"];function go(n){var a,o;let e=n.timeBounds;if(e.timeshiftDepth===null)return(a=e.minimumSafePosition)!=null?a:0;let{maximumTimeData:t}=e,r;if(!e.maximumTimeData.isLinear)r=t.maximumSafePosition;else{let s=L()-t.time;r=t.maximumSafePosition+s/1e3}let i=r-e.timeshiftDepth;return Math.max((o=e.minimumSafePosition)!=null?o:0,i)}function ho(n){let{maximumTimeData:e}=n.timeBounds;if(!n.isLive||e.livePosition===void 0)return;if(!e.isLinear)return e.livePosition;let t=L()-e.time;return e.livePosition+t/1e3}function Io(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=L()-e.time;return e.maximumSafePosition+t/1e3}function bo(n,e){if(e===void 0)return li(n).filter(r=>r.supportStatus.hasSupportedCodec!==!1&&r.supportStatus.isDecipherable!==!1);let t=n.adaptations[e];return t===void 0?[]:t.filter(r=>r.supportStatus.hasSupportedCodec!==!1&&r.supportStatus.isDecipherable!==!1)}function So(n,e){let t=null;for(let r of n.periods){if(di(r,e,t))return r;t=r}}function yo(n,e){let t=e.end;if(t===void 0)return null;let r=j(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function di(n,e,t){return e>=n.start&&(n.end===void 0||e<n.end)?!0:e===n.end&&(t===null||t.start>n.end)}function li(n){let e=n.adaptations;return ui(e).reduce((t,r)=>P(r)?t:t.concat(r),[])}function Vu(n,e){var r,i;let t={language:(r=n.language)!=null?r:\"\",normalized:(i=n.normalizedLanguage)!=null?i:\"\",audioDescription:n.isAudioDescription===!0,id:n.id,representations:(e?n.representations.filter(a=>an(a)===!0):n.representations).map(Ku),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function Hu(n){var e,t;return{language:(e=n.language)!=null?e:\"\",normalized:(t=n.normalizedLanguage)!=null?t:\"\",closedCaption:n.isClosedCaption===!0,id:n.id,label:n.label,forced:n.isForcedSubtitles}}function Gu(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>an(s)===!0):i.representations).map(po),o={id:i.id,representations:a,isTrickModeTrack:!0};return i.isSignInterpreted===!0&&(o.signInterpreted=!0),o}):void 0,r={id:n.id,representations:(e?n.representations.filter(i=>an(i)===!0):n.representations).map(po),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function Ku(n){let{id:e,bitrate:t,codecs:r,isSpatialAudio:i,isSupported:a,decipherable:o}=n;return{id:e,bitrate:t,codec:r==null?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function po(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:u,decipherable:d,contentProtections:f}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:d,contentProtections:f!==void 0?{keyIds:f.keyIds}:void 0}}function ut(n){switch(n.type){case\"audio\":return{type:\"audio\",track:Vu(n,!1)};case\"video\":return{type:\"video\",track:Gu(n,!1)};case\"text\":return{type:\"text\",track:Hu(n)}}}function an(n){return n.decipherable===!1?!1:n.isSupported}function To(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}function xe(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var ju=xe(),fi=class{constructor(e,t,r){var a,o,s,u,d;this.id=e.id,this.uniqueId=ju(),this.shouldBeAvoided=!1,this.bitrate=e.bitrate,this.codecs=[],this.trackType=t,e.isSpatialAudio!==void 0&&(this.isSpatialAudio=e.isSpatialAudio),e.height!==void 0&&(this.height=e.height),e.width!==void 0&&(this.width=e.width),e.mimeType!==void 0&&(this.mimeType=e.mimeType),e.contentProtections!==void 0&&(this.contentProtections=e.contentProtections),e.frameRate!==void 0&&(this.frameRate=e.frameRate),e.hdrInfo!==void 0&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index;let i=this.contentProtections!==void 0;if(t===\"audio\"||t===\"video\"){if(e.supplementalCodecs!==void 0){let f=r.isSupported((a=this.mimeType)!=null?a:\"\",(o=e.supplementalCodecs)!=null?o:\"\",i);f!==!1&&(this.codecs=[e.supplementalCodecs],this.isSupported=f)}this.isSupported!==!0&&(this.codecs.length>0?this.codecs.push((s=e.codecs)!=null?s:\"\"):(this.codecs=e.codecs===void 0?[]:[e.codecs],this.isSupported=r.isSupported((u=this.mimeType)!=null?u:\"\",(d=e.codecs)!=null?d:\"\",i)))}else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var s,u;if(this.isSupported!==void 0)return;let t=this.contentProtections!==void 0,r=!1,i=(s=this.mimeType)!=null?s:\"\",a=(u=this.codecs)!=null?u:[];a.length===0&&(a=[\"\"]);let o=!1;for(let d of a){if(r=e.isSupported(i,d,t),r===!0){this.codecs=[d];break}r===void 0&&(o=!0)}r===!0?this.isSupported=!0:o?this.isSupported=void 0:this.isSupported=!1}getMimeTypeString(){var e,t,r;return`${(e=this.mimeType)!=null?e:\"\"};codecs=\"${(r=(t=this.codecs)==null?void 0:t[0])!=null?r:\"\"}\"`}getEncryptionData(e){var i;let t=this.getAllEncryptionData(),r=[];for(let a=0;a<t.length;a++){let o=!1,s=t[a];for(let u=0;u<s.values.length;u++)if(s.values[u].systemId.toLowerCase()===e.toLowerCase())if(o)r[r.length-1].values.push(s.values[u]);else{let d=(i=this.contentProtections)==null?void 0:i.keyIds;r.push({type:s.type,keyIds:d,values:[s.values[u]]}),o=!0}}return r}getAllEncryptionData(){var t;if(this.contentProtections===void 0||this.contentProtections.initData.length===0)return[];let e=(t=this.contentProtections)==null?void 0:t.keyIds;return this.contentProtections.initData.map(r=>({type:r.type,keyIds:e,values:r.values}))}addProtectionData(e,t,r){let i=!1;if(this.contentProtections===void 0)return this.contentProtections={keyIds:t!==void 0?[t]:[],initData:[{type:e,values:r}]},!0;if(t!==void 0){let o=this.contentProtections.keyIds;if(o===void 0)this.contentProtections.keyIds=[t];else{let s=!1;for(let u of o)cr(u,t)&&(s=!0);s||(c.warn(\"Manifest: found unanounced key id.\"),o.push(t))}}let a=this.contentProtections.initData;for(let o=0;o<a.length;o++)if(a[o].type===e){let s=a[o].values;for(let u=0;u<r.length;u++){let d=r[u],f;for(f=0;f<s.length;f++)if(d.systemId===s[f].systemId){if(cr(d.data,s[f].data))break;c.warn(\"Manifest: different init data for the same system ID\")}f===s.length&&(s.push(d),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}isPlayable(){return an(this)}getMetadataSnapshot(){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,isCodecSupportedInWebWorker:this.isCodecSupportedInWebWorker}}},on=fi;var dt=class n{constructor(e,t,r={}){let{trickModeTracks:i}=e,{representationFilter:a,isManuallyAdded:o}=r;this.id=e.id,this.type=e.type,e.isTrickModeTrack!==void 0&&(this.isTrickModeTrack=e.isTrickModeTrack),e.language!==void 0&&(this.language=e.language,this.normalizedLanguage=co(e.language)),e.closedCaption!==void 0&&(this.isClosedCaption=e.closedCaption),e.audioDescription!==void 0&&(this.isAudioDescription=e.audioDescription),e.isDub!==void 0&&(this.isDub=e.isDub),e.forcedSubtitles!==void 0&&(this.isForcedSubtitles=e.forcedSubtitles),e.isSignInterpreted!==void 0&&(this.isSignInterpreted=e.isSignInterpreted),e.label!==void 0&&(this.label=e.label),i!==void 0&&i.length>0&&(this.trickModeTracks=i.map(d=>new n(d,t)));let s=e.representations,u=[];this.supportStatus={hasSupportedCodec:!1,hasCodecWithUndefinedSupport:!1,isDecipherable:!1};for(let d=0;d<s.length;d++){let f=new on(s[d],this.type,t),l=!0;if(!P(a)){let m={id:f.id,bitrate:f.bitrate,codecs:f.codecs,height:f.height,width:f.width,frameRate:f.frameRate,hdrInfo:f.hdrInfo};if(f.contentProtections!==void 0&&(m.contentProtections={},f.contentProtections.keyIds!==void 0)){let g=f.contentProtections.keyIds;m.contentProtections.keyIds=g}l=a(m,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}l?(u.push(f),f.isSupported===void 0?(this.supportStatus.hasCodecWithUndefinedSupport=!0,this.supportStatus.hasSupportedCodec===!1&&(this.supportStatus.hasSupportedCodec=void 0)):f.isSupported&&(this.supportStatus.hasSupportedCodec=!0),f.decipherable===void 0?this.supportStatus.isDecipherable===!1&&(this.supportStatus.isDecipherable=void 0):f.decipherable&&(this.supportStatus.isDecipherable=!0)):c.debug(\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${f.id}`,`(${f.bitrate})`)}u.sort((d,f)=>d.bitrate-f.bitrate),this.representations=u,this.manuallyAdded=o===!0}refreshCodecSupport(e){let t=!1,r=!1;for(let i of this.representations)i.refreshCodecSupport(e),i.isSupported===void 0?t=!0:i.isSupported&&(r=!0);r?this.supportStatus.hasSupportedCodec=!0:t?this.supportStatus.hasSupportedCodec=void 0:this.supportStatus.hasSupportedCodec=!1,this.supportStatus.hasCodecWithUndefinedSupport=t}getRepresentation(e){return j(this.representations,({id:t})=>e===t)}getMetadataSnapshot(){let e=[],t=this.representations;for(let r of t)e.push(r.getMetadataSnapshot());return{id:this.id,type:this.type,supportStatus:this.supportStatus,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:e,label:this.label,isDub:this.isDub}}};var Se=ue,Eo,_o,Ro,Po,vo,lt=(vo=(Po=(Ro=(_o=(Eo=Se==null?void 0:Se.MediaSource)!=null?Eo:Se==null?void 0:Se.MozMediaSource)!=null?_o:Se==null?void 0:Se.WebKitMediaSource)!=null?Ro:Se==null?void 0:Se.MSMediaSource)!=null?Po:Se==null?void 0:Se.ManagedMediaSource)!=null?vo:void 0,Zg=lt!==void 0&&lt===(Se==null?void 0:Se.ManagedMediaSource);var Yu=!1,Qu=!1,Co=!1,$u=!1,Xu=!1,Zu=!1,Ju=!1,ed=!1,td=!1,nd=!1,rd=!1,id=!1,ad=!1,od=!1,mi=!1,sd=!1,ud=!1;(function(){var e,t,r;lr||(typeof ue.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?(Qu=!0,Co=!0):navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?Co=!0:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?Yu=!0:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?$u=!0:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?Zu=!0:(Object.prototype.toString.call(ue.HTMLElement).indexOf(\"Constructor\")>=0||((t=(e=ue.safari)==null?void 0:e.pushNotification)==null?void 0:t.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((r=navigator.vendor)==null?void 0:r.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(Xu=!0),/SamsungBrowser/.test(navigator.userAgent)&&(Ju=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?od=!0:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?mi=!0:/Tizen/.test(navigator.userAgent)?ed=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(td=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?rd=!0:(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent))&&(nd=!0)):navigator.userAgent.indexOf(\"NETTV\")!==-1&&navigator.userAgent.indexOf(\"Philips\")!==-1?ad=!0:/[Pp]anasonic/.test(navigator.userAgent)?id=!0:navigator.userAgent.indexOf(\"Xbox\")!==-1?sd=!0:navigator.userAgent.indexOf(\"Model/a1-kstb40xx\")!==-1&&(ud=!0))})();function ci(n){return new Promise(e=>{setTimeout(e,n)})}function Tt(n,e){let t;return new Promise((r,i)=>{if(n.cancellationError!==null)return i(n.cancellationError);let a=!1;t=e(function(u){n.deregister(o),a=!0,r(u)},function(u){n.deregister(o),a=!0,i(u)}),a||n.register(o);function o(s){t!==void 0&&t(),i(s)}})}function sn(n,e){return Tt(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var gr=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\"}};function ce(n,e){if(I.DEV===I.CURRENT_ENV&&!n)throw new gr(e===void 0?\"invalid assertion\":e)}function De(n){throw new gr(\"Unreachable path taken\")}var F=class{constructor(){let[e,t]=dd();this._isUsed=!1,this._trigger=e,this.signal=new pi(t)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(()=>{this.cancel()});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=e!=null?e:new se;this._trigger(t)}static isCancellationError(e){return e instanceof se}},pi=class{constructor(e){this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e(t=>{for(this.cancellationError=t,this._isCancelled=!0;this._listeners.length>0;)try{let r=this._listeners.pop();r==null||r(t)}catch(r){c.error(\"Error while calling clean up listener\",r instanceof Error?r.toString():\"Unknown error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(ce(this.cancellationError!==null),e(this.cancellationError),N):(this._listeners.push(e),()=>this.deregister(e))}deregister(e){for(let t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)}},se=class n extends Error{constructor(){super(\"This task was cancelled.\"),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\"}};function dd(){let n=N;return[function(t){n(t)},function(t){n=t}]}var ld=[\"\",\"webkit\",\"moz\",\"ms\"];function fd(n,e){let t=document.createElement(n.tagName),r=\"on\"+e;return r in t?!0:(t.setAttribute(r,\"return;\"),typeof t[r]==\"function\")}function md(n,e){return e.filter(t=>fd(n,t))[0]}function cd(n,e){return n.reduce((t,r)=>t.concat((e===void 0?ld:e).map(i=>i+r)),[])}function Pe(n,e){let t,r=cd(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=md(i,r)),K(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{I.CURRENT_ENV===I.DEV&&c.warn(`compat: element ${i.tagName} does not support any of these events: `+r.join(\", \"));return}r.forEach(s=>{let u=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(u=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),u&&delete i[\"on\"+s]})})}}}var Ah=Pe([\"loadedmetadata\"]),kh=Pe([\"timeupdate\"]),xh=Pe([\"addtrack\"]),Mh=Pe([\"removetrack\"]),Nt=Pe([\"sourceopen\",\"webkitsourceopen\"]),hr=Pe([\"sourceclose\",\"webkitsourceclose\"]),Ir=Pe([\"sourceended\",\"webkitsourceended\"]),Ao=Pe([\"update\"]),ko=Pe([\"removesourcebuffer\"]),Oh=Pe([\"keymessage\",\"message\"]),wh=Pe([\"keyadded\",\"ready\"]),Dh=Pe([\"keyerror\",\"error\"]),Nh=Pe([\"keystatuseschange\"]),Bh=Pe([\"seeking\"]),Uh=Pe([\"seeked\"]),Lh=Pe([\"ended\"]);var 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 br(n){if(n>=xo.length)throw new Error(\"Unable to parse base64 string.\");let e=xo[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function Sr(n){let e=n.length%4,t=n;e!==0&&(c.warn(\"base64ToBytes: base64 given miss padding\"),t+=e===3?\"=\":e===2?\"==\":\"===\");let r=t.indexOf(\"=\");if(r!==-1&&r<t.length-2)throw new Error(\"Unable to parse base64 string.\");let i=t.endsWith(\"==\")?2:t.endsWith(\"=\")?1:0,a=t.length,o=new Uint8Array(a/4*3),s;for(let u=0,d=0;u<a;u+=4,d+=3)s=br(t.charCodeAt(u))<<18|br(t.charCodeAt(u+1))<<12|br(t.charCodeAt(u+2))<<6|br(t.charCodeAt(u+3)),o[d]=s>>16,o[d+1]=s>>8&255,o[d+2]=s&255;return o.subarray(0,o.length-i)}var pd=typeof ue==\"object\"&&typeof ue.TextDecoder==\"function\",gd=typeof ue==\"object\"&&typeof ue.TextEncoder==\"function\";function un(n){if(gd)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"\";c.warn(\"Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation\",a)}let e,t=encodeURIComponent(n);if(typeof unescape==\"function\")e=unescape(t);else{let i=/[0-9a-fA-F]/,a=t.length;e=\"\";for(let o=0;o<t.length;o++){let s=!1;if(t[o]===\"%\"){if(o<=a-6&&t[o+1]===\"u\"&&i.test(t[o+2])&&i.test(t[o+3])&&i.test(t[o+4])&&i.test(t[o+5])){let u=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let u=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(u),s=!0,o+=2}}s||(e+=t[o])}}let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i)&255;return r}function hd(n){let t=\"\";for(let r=0;r<n.length;r+=16e3){let i=n.subarray(r,r+16e3);t+=String.fromCharCode.apply(null,i)}return t}function Mo(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Ne(n){if(pd)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"\";c.warn(\"Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation\",a)}let e=n;e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let t=hd(e),r;if(typeof escape==\"function\")r=escape(t);else{let i=/[A-Za-z0-9*_+-./]/;r=\"\";for(let a=0;a<t.length;a++)if(i.test(t[a]))r+=t[a];else{let o=t.charCodeAt(a);r+=o>=256?\"%u\"+Mo(o,4):\"%\"+Mo(o,2)}}return decodeURIComponent(r)}function dn(n){let e=n.length,t=new Uint8Array(e/2);for(let r=0,i=0;r<e;r+=2,i++)t[i]=parseInt(n.substring(r,r+2),16)&255;return t}function Oo(n,e=\"\"){let t=\"\";for(let r=0;r<n.byteLength;r++)t+=(n[r]>>>4).toString(16),t+=(n[r]&15).toString(16),e.length>0&&r<n.byteLength-1&&(t+=e);return t}function gi(n,e){let t=e;for(;t<n.length&&n[t]!==0;)t+=1;let r=n.subarray(e,t);return{end:t+1,string:Ne(r)}}function Ve(n,e,t){if(typeof String.prototype.startsWith==\"function\")return n.startsWith(e,t);let r=typeof t==\"number\"?Math.max(t,0):0;return n.substring(r,r+e.length)===e}function Et(...n){let e=n.length,t=-1,r=0,i;for(;++t<e;)i=n[t],r+=typeof i==\"number\"?i:i.length;let a=new Uint8Array(r),o=0;for(t=-1;++t<e;)i=n[t],typeof i==\"number\"?o+=i:i.length>0&&(a.set(i,o),o+=i.length);return a}function wo(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function hi(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function re(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function ft(n,e){return(n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3])*4294967296+n[e+4]*16777216+n[e+5]*65536+n[e+6]*256+n[e+7]}function $e(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=re(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=ft(n,r+8)}if(isNaN(i)||i<=0)return-1;if(re(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function yr(n){let e=0,t=[],r=null;for(;e<=n.length;){if(e===n.length){r=null;break}r=n.subarray(e,1/0);let i=$e(r,1836019558);if(i<0)break;let a=re(n,i+e),o=e+i+a;if(o>n.length)break;let s=$e(r,1835295092);if(s<0)break;let u=re(n,s+e),d=e+s+u;if(d>n.length)break;let f=Math.max(o,d),l=n.subarray(e,f);t.push(l),e=f}return t.length===0?[null,r]:[t,r]}function Id(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function bd(n,e,t){return n.slice(e,t)}var Ii=typeof Uint8Array.prototype.slice==\"function\"?bd:Id;function bi(n,e){let t=n;for(let r of e){let i=he(t,r);if(i===null)return null;t=i}return t}function he(n,e){let t=Bt(n,e);return t!==null?n.subarray(t[1],t[2]):null}function Do(n,e){let t=[],r=n;for(;;){let i=Bt(r,e);if(i===null)return t;ce(i[2]!==0&&r.length!==0),t.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}function Bt(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=re(n,o),o+=4,i=re(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=ft(n,o),o+=8}if(a<0)throw new Error(\"ISOBMFF: Size out of range\");if(i===e)return e===1970628964&&(o+=16),[r,o,r+a];r+=a}return null}function Tr(n){let e=0,t=he(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=Bt(t,1886614376)}catch(s){let u=s instanceof Error?s:\"\";return c.warn(\"Error while removing PSSH from ISOBMFF\",u),r}if(i===null)return r;let a=Ii(t,i[0],i[2]),o=No(a,i[1]-i[0]);o!==void 0&&r.push({systemId:o,data:a}),t[i[0]+4]=102,t[i[0]+5]=114,t[i[0]+6]=101,t[i[0]+7]=101,e=i[2]}return r}function No(n,e){if(n[e]>1){c.warn(\"ISOBMFF: un-handled PSSH version\");return}let t=e+4;if(t+16>n.length)return;let r=Ii(n,t,t+16);return Oo(r)}function Si(n){let e=he(n,1836019558);return e===null?null:he(e,1953653094)}function Bo(n){return Do(n,1836019558).reduce((t,r)=>{let i=he(r,1953653094);return i!==null&&t.push(i),t},[])}function yi(n){return he(n,1835295092)}function Ti(n){let e=he(n,1836019574);if(e===null)return null;let t=he(e,1953653099);return t===null?null:he(t,1835297121)}function Uo(n,e=0){return he(n.subarray(e),1701671783)}function ln(n,e){let t=Bt(n,1936286840);if(t===null)return null;let r=e,i=t[2]-t[0],a=t[1],o=n[a];a+=8;let s=re(n,a);a+=4;let u;if(o===0)u=re(n,a),a+=4,r+=re(n,a)+i,a+=4;else if(o===1)u=ft(n,a),a+=8,r+=ft(n,a)+i,a+=8;else return null;let d=[];a+=2;let f=wo(n,a);for(a+=2;--f>=0;){let l=re(n,a);a+=4;let m=(l&2147483648)>>>31,g=l&2147483647;if(m===1)throw new Error(\"sidx with reference_type `1` not yet implemented\");let p=re(n,a);a+=4,a+=4,d.push({time:u,duration:p,timescale:s,range:[r,r+g-1]}),u+=p,r+=g}return d}function Ei(n){let e=Si(n);if(e===null)return;let t=he(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return ft(t,4);if(r===0)return re(t,4)}function Sd(n){let e=he(n,1952868452);if(e===null)return;let t=1,r=hi(e,t);t+=3;let i=(r&1)>0,a=(r&2)>0;return(r&8)>0?(t+=4,i&&(t+=8),a&&(t+=4),re(e,t)):void 0}function _i(n){let e=Bo(n);if(e.length===0)return;let t=0;for(let r of e){let i=he(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=hi(i,a);a+=3;let u=(s&256)>0,d=0;if(!u&&(d=Sd(r),d===void 0))return;let f=(s&1)>0,l=(s&4)>0,m=(s&512)>0,g=(s&1024)>0,p=(s&2048)>0,b=re(i,a);a+=4,f&&(a+=4),l&&(a+=4);let h=b,y=0;for(;h-- >0;)u?(y+=re(i,a),a+=4):y+=d,m&&(a+=4),g&&(a+=4),p&&(a+=4);t+=y}return t}function fn(n){let e=Ti(n);if(e===null)return;let t=he(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return re(t,r+16);if(i===0)return re(t,r+8)}function Lo(n){let e=[],t=0;for(;t<n.length;){let r=Uo(n,t);if(r===null)break;let i=r.length;t+=i;let a=r[0];if(a!==0)c.warn(\"ISOBMFF: EMSG version \"+a.toString()+\" not supported.\");else{let o=4,{end:s,string:u}=gi(r,o);o=s;let{end:d,string:f}=gi(r,o);o=d;let l=re(r,o);o+=4;let m=re(r,o);o+=4;let g=re(r,o);o+=4;let p=re(r,o);o+=4;let b=r.subarray(o,i),h={schemeIdUri:u,value:f,timescale:l,presentationTimeDelta:m,eventDuration:g,id:p,messageData:b};e.push(h)}}if(e.length!==0)return e}function Fo(n){let e=bi(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=he(t,1701733238),i=0;if(r===null?(i=28,r=he(t,1701733217)):i=78,r===null)return null;let a=bi(r.subarray(i),[1936289382,1935894633,1952804451]);if(a===null||a.byteLength<24)return null;let o=a.subarray(8,24);return o.every(s=>s===0)?null:o}function Ie(n,e,t){if(typeof Array.prototype.includes==\"function\")return n.includes(e,t);let r=n.length>>>0;if(r===0)return!1;let i=t|0,a=i>=0?Math.min(i,r-1):Math.max(r+i,0),o=(s,u)=>s===u||typeof s==\"number\"&&typeof u==\"number\"&&isNaN(s)&&isNaN(u);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}function yd(n,e){let{mimeType:t,codecs:r}=zo(n),{mimeType:i,codecs:a}=zo(e);if(t!==i||r===\"\"||a===\"\")return!1;let o=r.split(\".\")[0];o=o===\"hev1\"?\"hvc1\":o;let s=a.split(\".\")[0];return s=s===\"hev1\"?\"hvc1\":s,o===s}var Td=7;function zo(n){var i;let[e,...t]=n.split(\";\"),r=(i=j(t,a=>Ve(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(Td),r[0]==='\"'&&(r=r.substring(1,r.length-1)),{mimeType:e,codecs:r}}var Wo=yd;function Ri(n,e){return typeof Array.prototype.flatMap==\"function\"?n.flatMap(e):n.reduce((t,r)=>{let i=e(r);return Array.isArray(i)?(t.push(...i),t):(t.push(i),t)},[])}function Pi(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function qo(n){var t,r,i,a,o;let e=[];for(let s of n.periods){let u=[...(t=s.adaptations.video)!=null?t:[],...(r=s.adaptations.audio)!=null?r:[]];for(let d of u)if(d.supportStatus.hasCodecWithUndefinedSupport)for(let f of d.representations)f.isSupported===void 0&&e.push({mimeType:(i=f.mimeType)!=null?i:\"\",codec:(o=(a=f.codecs)==null?void 0:a[0])!=null?o:\"\"})}return e}var Vo=[];function et(n){Ie(Vo,n)||(console.warn(n),Vo.push(n))}var mn=class{constructor(e){this.supportMap=new Map,this.addCodecs(e)}addCodecs(e){for(let t of e){let r=this.supportMap.get(t.mimeType);r===void 0&&(r=new Map,this.supportMap.set(t.mimeType,r)),r.set(t.codec,{supported:t.supported,supportedIfEncrypted:t.supportedIfEncrypted})}}isSupported(e,t,r){let i=this.supportMap.get(e);if(i===void 0)return;let a=i.get(t);if(a!==void 0)return r?a.supportedIfEncrypted:a.supported}};var mt=class{constructor(e,t,r,i){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((a,o)=>{let s=e.adaptations[o];if(P(s))return a;let u=s.map(d=>{let f=new dt(d,r,{representationFilter:i});return f.representations.length>0&&f.supportStatus.hasSupportedCodec===!1&&t.push(f),f}).filter(d=>d.representations.length>0);if(u.every(d=>d.supportStatus.hasSupportedCodec===!1)&&s.length>0&&(o===\"video\"||o===\"audio\"))throw new Z(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+o+\" adaptations\",{tracks:void 0});return u.length>0&&(a[o]=u),a},{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new Z(\"MANIFEST_PARSE_ERROR\",\"No supported audio and video tracks.\");this.thumbnailTracks=e.thumbnailTracks.map(a=>({id:a.id,mimeType:a.mimeType,index:a.index,cdnMetadata:a.cdnMetadata,height:a.height,width:a.width,horizontalTiles:a.horizontalTiles,verticalTiles:a.verticalTiles,start:a.start,end:a.end,tileDuration:a.tileDuration})),this.duration=e.duration,this.start=e.start,!P(this.duration)&&!P(this.start)&&(this.end=this.start+this.duration),this.streamEvents=e.streamEvents===void 0?[]:e.streamEvents}refreshCodecSupport(e,t){Object.keys(this.adaptations).forEach(r=>{let i=this.adaptations[r];if(i===void 0)return;let a=!1;for(let o of i){if(!o.supportStatus.hasCodecWithUndefinedSupport){o.supportStatus.hasSupportedCodec===!0&&(a=!0);continue}let s=o.supportStatus.hasSupportedCodec;o.refreshCodecSupport(t),s!==!1&&o.supportStatus.hasSupportedCodec===!1&&e.push(o),a===!1?a=o.supportStatus.hasSupportedCodec:a===void 0&&o.supportStatus.hasSupportedCodec===!0&&(a=!0)}if((r===\"video\"||r===\"audio\")&&a===!1)throw new Z(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+r+\" adaptations\",{tracks:void 0})},{})}getAdaptations(){return li(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return j(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return bo(this,e)}containsTime(e,t){return di(this,e,t)}getMetadataSnapshot(){let e={},t=this.getAdaptations();for(let r of t){let i=e[r.type];i===void 0&&(i=[],e[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:e,thumbnailTracks:this.thumbnailTracks.map(r=>({id:r.id,mimeType:r.mimeType,height:r.height,width:r.width,horizontalTiles:r.horizontalTiles,verticalTiles:r.verticalTiles,start:r.start,end:r.end,tileDuration:r.tileDuration}))}}};function cn(n,e,t){let r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[],updatedThumbnailTracks:[],removedThumbnailTracks:[],addedThumbnailTracks:[]};n.start=e.start,n.end=e.end,n.duration=e.duration,n.streamEvents=e.streamEvents;let i=n.thumbnailTracks,a=e.thumbnailTracks;for(let u=0;u<i.length;u++){let d=i[u],f=ne(a,l=>l.id===d.id);if(f===-1){c.warn('Manifest: ThumbnailTrack \"'+i[u].id+'\" not found when merging.');let[l]=i.splice(u,1);u--,r.removedThumbnailTracks.push({id:l.id})}else{let[l]=a.splice(f,1);d.mimeType=l.mimeType,d.height=l.height,d.width=l.width,d.horizontalTiles=l.horizontalTiles,d.verticalTiles=l.verticalTiles,d.start=l.start,d.end=l.end,d.tileDuration=l.tileDuration,d.cdnMetadata=l.cdnMetadata,t===0?d.index._replace(l.index):d.index._update(l.index),r.updatedThumbnailTracks.push({id:d.id,mimeType:d.mimeType,height:d.height,width:d.width,horizontalTiles:d.horizontalTiles,verticalTiles:d.verticalTiles,start:d.start,end:d.end,tileDuration:d.tileDuration})}}a.length>0&&(c.warn(`Manifest: ${a.length} new Thumbnail tracks found when merging.`),r.addedThumbnailTracks.push(...a.map(u=>({id:u.id,mimeType:u.mimeType,height:u.height,width:u.width,horizontalTiles:u.horizontalTiles,verticalTiles:u.verticalTiles,start:u.start,end:u.end,tileDuration:u.tileDuration}))),n.thumbnailTracks.push(...a));let o=n.getAdaptations(),s=e.getAdaptations();for(let u=0;u<o.length;u++){let d=o[u],f=ne(s,l=>l.id===d.id);if(f===-1){c.warn('Manifest: Adaptation \"'+o[u].id+'\" not found when merging.');let[l]=o.splice(u,1);u--,r.removedAdaptations.push({id:l.id,trackType:l.type})}else{let[l]=s.splice(f,1),m=[],g=[],p=[];r.updatedAdaptations.push({adaptation:d.id,trackType:d.type,updatedRepresentations:m,addedRepresentations:g,removedRepresentations:p});let b=d.representations,h=l.representations.slice();for(let y=0;y<b.length;y++){let E=b[y],R=ne(h,T=>T.id===E.id);if(R===-1){c.warn(`Manifest: Representation \"${b[y].id}\" not found when merging.`);let[T]=b.splice(y,1);y--,p.push(T.id)}else{let[T]=h.splice(R,1);m.push(E.getMetadataSnapshot()),E.cdnMetadata=T.cdnMetadata,t===0?E.index._replace(T.index):E.index._update(T.index)}}h.length>0&&(c.warn(`Manifest: ${h.length} new Representations found when merging.`),d.representations.push(...h),g.push(...h.map(y=>y.getMetadataSnapshot())))}}if(s.length>0){c.warn(`Manifest: ${s.length} new Adaptations found when merging.`);for(let u of s){let d=n.adaptations[u.type];d===void 0?n.adaptations[u.type]=[u]:d.push(u),r.addedAdaptations.push(u.getMetadataSnapshot())}}return r}function Ho(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,u=n[s];for(;u!==void 0&&u.id!==o.id;)s++,u=n[s];if(u!==void 0){let d=cn(u,o,0);t.updatedPeriods.push({period:{id:u.id,start:u.start,end:u.end,duration:u.duration,streamEvents:u.streamEvents},result:d});let f=e.slice(r,a),l=s-r,m=n.splice(r,l,...f);t.removedPeriods.push(...m.map(g=>({id:g.id,start:g.start,end:g.end}))),t.addedPeriods.push(...f.map(g=>g.getMetadataSnapshot())),r=a+1}}if(r>n.length)return c.error(\"Manifest: error when updating Periods\"),t;if(r<n.length){let a=n.splice(r,n.length-r);t.removedPeriods.push(...a.map(o=>({id:o.id,start:o.start,end:o.end})))}let i=e.slice(r,e.length);return i.length>0&&(n.push(...i),t.addedPeriods.push(...i.map(a=>a.getMetadataSnapshot()))),t}function Go(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(n.length===0)return n.splice(0,0,...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t;if(e.length===0)return t;let r=n[n.length-1];if(r.start<e[0].start){if(r.end!==e[0].start)throw new Z(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");return n.push(...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t}let i=ne(n,({id:s})=>s===e[0].id);if(i<0)throw new Z(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=cn(n[i],e[0],1);t.updatedPeriods.push({period:G(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let u=e[s],d=-1;for(let f=o;f<n.length;f++)if(u.id===n[f].id){d=f;break}if(d<0){let f=-1;for(let g=o;g<n.length;g++)if(u.start<n[g].start){f=g;break}let l=f-o,m=n.splice(o,l,u);t.addedPeriods.push(u.getMetadataSnapshot()),t.removedPeriods.push(...m.map(g=>({id:g.id,start:g.start,end:g.end})))}else{if(d>o){c.warn(\"Manifest: old Periods not found in new when updating, removing\");let l=n.splice(o,d-o);t.removedPeriods.push(...l.map(m=>({id:m.id,start:m.start,end:m.end}))),d=o}let f=cn(n[d],u,0);t.updatedPeriods.push({period:G(n[d].getMetadataSnapshot(),{adaptations:void 0}),result:f})}o++}if(o<n.length){c.warn(\"Manifest: Ending Periods not found in new when updating, removing\");let s=n.splice(o,n.length-o);t.removedPeriods.push(...s.map(u=>({id:u.id,start:u.start,end:u.end})))}return t}var Ed=xe(),pn=class extends fe{constructor(e,t,r){var s;super();let{representationFilter:i,manifestUpdateUrl:a}=t;this.manifestFormat=0,this.id=Ed(),this.expired=(s=e.expired)!=null?s:null,this.transport=e.transportType,this.clockOffset=e.clockOffset,this._cachedCodecSupport=new mn([]);let o=[];if(this.periods=e.periods.map(u=>new mt(u,o,this._cachedCodecSupport,i)).sort((u,d)=>u.start-d.start),o.length>0){let u=new Z(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:o.map(ut)});r.push(u)}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.timeBounds=e.timeBounds,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.uris=e.uris===void 0?[]:e.uris,this.updateUrl=a,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.availabilityStartTime=e.availabilityStartTime,this.publishTime=e.publishTime}updateCodecSupport(e=[]){if(e.length===0)return null;this._cachedCodecSupport.addCodecs(e);let t=[];for(let r of this.periods)r.refreshCodecSupport(t,this._cachedCodecSupport);return this.trigger(\"supportUpdate\",null),t.length>0?new Z(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:t.map(ut)}):null}getPeriod(e){return j(this.periods,t=>e===t.id)}getPeriodForTime(e){return So(this,e)}getNextPeriod(e){return j(this.periods,t=>t.start>e)}getPeriodAfter(e){return yo(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return go(this)}getLivePosition(){return ho(this)}getMaximumSafePosition(){return Io(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=_d(this,e);t.length>0&&this.trigger(\"decipherabilityUpdate\",t)}addRepresentationsToAvoid(e){let t=[];for(let r of e){let i=this.getPeriod(r.period.id);if(i===void 0)continue;let a=i.getAdaptation(r.adaptation.id);if(a===void 0)continue;let o=a.getRepresentation(r.representation.id);o!==void 0&&(o.shouldBeAvoided=!0,t.push({manifest:this,period:i,adaptation:a,representation:o}))}t.length>0&&this.trigger(\"representationAvoidanceUpdate\",t)}getAdaptations(){et(\"manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead\");let e=this.periods[0];if(e===void 0)return[];let t=e.adaptations,r=[];for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i)){let a=t[i];r.push(...a)}return r}getAdaptationsForType(e){et(\"manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead\");let t=this.periods[0];if(t===void 0)return[];let r=t.adaptations[e];return r===void 0?[]:r}getAdaptation(e){return et(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),j(this.getAdaptations(),({id:t})=>e===t)}getMetadataSnapshot(){let e=[];for(let t of this.periods)e.push(t.getMetadataSnapshot());return{manifestFormat:1,id:this.id,periods:e,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}}getCodecsWithUnknownSupport(){return qo(this)}_performUpdate(e,t){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;let r;if(t===0)this.timeBounds=e.timeBounds,this.uris=e.uris,r=Ho(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=Go(this.periods,e.periods);let i=this.getMinimumSafePosition();for(;this.periods.length>0;){let a=this.periods[0];if(a.end===void 0||a.end>i)break;this.periods.shift()}}this.updateCodecSupport(),this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.trigger(\"manifestUpdate\",r)}};function _d(n,e){let t=[];for(let r of n.periods)for(let i of r.getAdaptations()){let a=!0;for(let o of i.representations){let s={manifest:n,period:r,adaptation:i,representation:o},u=e(s);u!==!1&&(a=!1),u!==o.decipherable&&(t.push(s),o.decipherable=u,u===!0?i.supportStatus.isDecipherable=!0:u===void 0&&i.supportStatus.isDecipherable===!1&&(i.supportStatus.isDecipherable=void 0),c.debug(`Decipherability changed for \"${o.id}\"`,`(${o.bitrate})`,String(o.decipherable)))}a&&(i.supportStatus.isDecipherable=!1)}return t}function Je(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function yt(n){if(P(n))return\"\";let{period:e,adaptation:t,representation:r,segment:i}=n,a;return i.isInit?a=\"init\":i.complete?a=`${i.time}-${i.duration}`:a=`${i.time}`,`${t.type} P: ${e.id} A: ${t.id} R: ${r.id} S: ${a}`}var Ut=pn;var Rd=\"<\",Pd=60,Ko=\">\",Er=62,vi=45,jo=47,vd=33,Yo=39,Qo=34,Ci=91,Cd=93,Ad=`\\r\n\t>/= `;function Ai(n,e={}){var m,g;let t=(m=e.pos)!=null?m:0,r=e.keepComments===!0,i=e.keepWhitespace===!0,a;if(e.attrValue!==void 0)for(e.attrName=(g=e.attrName)!=null?g:\"id\",a=[];(t=l())!==-1;)t=n.lastIndexOf(\"<\",t),t!==-1&&a.push(d()),n=n.substring(t),t=0;else a=o(\"\");return e.filter!==void 0&&(a=$o(a,e.filter)),a;function o(p){let b=[];for(;n[t]!==void 0;)if(n.charCodeAt(t)===Pd){if(n.charCodeAt(t+1)===jo){let y=t+2;if(t=n.indexOf(Ko,t),n.substring(y,t).indexOf(p)===-1){let R=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(R.length-1)+`\nColumn: `+(R[R.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),b}else if(n.charCodeAt(t+1)===vd){if(n.charCodeAt(t+2)===vi){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===Er&&n.charCodeAt(t-1)===vi&&n.charCodeAt(t-2)===vi);)t=n.indexOf(Ko,t+1);t===-1&&(t=n.length),r&&b.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===Ci&&n.charCodeAt(t+8)===Ci&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(b.push(n.substring(t+9)),t=n.length):(b.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let E=!1;for(;(n.charCodeAt(t)!==Er||E)&&n[t]!==void 0;)n.charCodeAt(t)===Ci?E=!0:E&&n.charCodeAt(t)===Cd&&(E=!1),t++;b.push(n.substring(y,t))}t++;continue}let h=d();b.push(h),h.tagName[0]===\"?\"&&(b.push(...h.children),h.children=[])}else{let h=s();if(i)h.length>0&&b.push(h);else{let y=h.trim();y.length>0&&b.push(y)}t++}return b}function s(){let p=t;return t=n.indexOf(Rd,t)-1,t===-2&&(t=n.length),n.slice(p,t+1)}function u(){let p=t;for(;Ad.indexOf(n[t])===-1&&n[t]!==void 0;)t++;return n.slice(p,t)}function d(){let p=t;t++;let b=u(),h={},y=[];for(;n.charCodeAt(t)!==Er&&n[t]!==void 0;){let E=n.charCodeAt(t);if(E>64&&E<91||E>96&&E<123){let R=u(),T=n.charCodeAt(t);for(;!isNaN(T)&&T!==Yo&&T!==Qo&&!(T>64&&T<91||T>96&&T<123)&&T!==Er;)t++,T=n.charCodeAt(t);let v;T===Yo||T===Qo?v=f():(v=null,t--),h[R]=v===null?null:Xo(v)}t++}return n.charCodeAt(t-1)!==jo?(t++,y=o(b)):t++,{tagName:b,attributes:h,children:y,posStart:p,posEnd:t}}function f(){let p=n[t],b=t+1;return t=n.indexOf(p,b),n.slice(b,t)}function l(){let p=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return p!==null?p.index:-1}}function $o(n,e,t=0,r=\"\"){let i=[];return n.forEach(function(a,o){if(typeof a==\"object\"&&(e(a,o,t,r)&&i.push(a),a.children.length>0)){let s=$o(a.children,e,t+1,(K(r)?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function _r(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+_r(t),e=e.trim()}),e}else return typeof n==\"object\"?_r(n.children):\" \"+Xo(n)}function Xo(n){return n.indexOf(\"&\")<0?n:n.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&apos;/g,\"'\").replace(/&#x([A-Fa-f0-9]+);/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/&amp;/g,\"&\")}function ki(n,e,t){let{repeatCount:r}=n;if(r>=0)return r;let i;return P(e)?t!==void 0?i=t:i=Number.MAX_VALUE:i=e.start,Math.ceil((i-n.start)/n.duration)-1}function Be(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=ki(n,e,t);return r+(a+1)*i}function ve(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function Xe(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function Zo(n,e,t){return[n*t,(n+e)*t]}function kd(n,e){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i].start<=e?t=i+1:r=i}return t-1}function Jo(n,e,t){let{timeline:r}=n,i=ve(e,n);if(i<0)return null;let a=kd(r,i);if(a<0||a>=r.length-1)return null;let o=r[a];if(o.duration<=0)return null;let s=r[a+1];if(s===void 0)return null;let u=s.start,d=Be(o,s,t);return i>=d&&i<u?Xe(u,n):null}function tt(n,e){var i;let{initialization:t}=n,r={};return e!==void 0&&(r.isEMSGWhitelisted=e),{id:\"init\",isInit:!0,time:0,end:0,duration:0,timescale:1,range:P(t)?void 0:t.range,indexRange:n.indexRange,url:(i=t==null?void 0:t.url)!=null?i:null,complete:!0,privateInfos:r,timestampOffset:-(n.indexTimeOffset/n.timescale)}}function xd(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function xi(n){return(e,t,r)=>{let i=K(r)?parseInt(r,10):1;return xd(String(n),i)}}function Ue(n,e,t){return Md(n,e,t)}function Md(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(%0(\\d+)d)?\\$/g,xi(t===void 0?0:t))}function Rr(n,e){return function(r){return r.indexOf(\"$\")===-1?r:r.replace(/\\$\\$/g,\"$\").replace(/\\$Number(%0(\\d+)d)?\\$/g,(i,a,o)=>{if(e===void 0)throw new Error(\"Segment number not defined in a $Number$ scheme\");return xi(e)(i,a,o)}).replace(/\\$Time(%0(\\d+)d)?\\$/g,(i,a,o)=>{if(n===void 0)throw new Error(\"Segment time not defined in a $Time$ scheme\");return xi(n)(i,a,o)})}}function Od(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function gn(n,e,t,r,i,a){var E;let o=r.getEstimatedMaximumPosition((E=n.availabilityTimeOffset)!=null?E:0),s=Math.min(e+t,o!=null?o:1/0),u=ve(e,n),d=ve(s,n),{timeline:f,timescale:l,segmentUrlTemplate:m,startNumber:g,endNumber:p}=n,b=g!=null?g:1,h=[],y=f.length;for(let R=0;R<y;R++){let T=f[R],{duration:v,start:_,range:M}=T,A;o===void 0?A=i:A=Math.min(o*l,i!=null?i:1/0);let k=ki(T,f[R+1],A),C=n.availabilityTimeComplete!==!1||R!==y-1&&k!==0,O=Od(_,v,u),B=_+O*v;for(;B<d&&O<=k;){let w=b+O;if(p!==void 0&&w>p)break;let x=m===null?null:Rr(B,w)(m),D=B-n.indexTimeOffset,W=v;D<0&&(W=v+D,D=0);let q={id:String(B),time:D/l,end:(D+W)/l,duration:W/l,isInit:!1,range:M,timescale:1,url:x,number:w,timestampOffset:-(n.indexTimeOffset/l),complete:C,privateInfos:{isEMSGWhitelisted:a}};h.push(q),O++,B=_+O*v}if(B>=d||(b+=k+1,p!==void 0&&b>p))return h}return h}function wd(n,e){if(e.timescale!==n.timescale){let{timescale:t}=n;n.timeline.push({start:e.time/e.timescale*t,duration:e.duration/e.timescale*t,repeatCount:e.count===void 0?0:e.count,range:e.range})}else n.timeline.push({start:e.time,duration:e.duration,repeatCount:e.count===void 0?0:e.count,range:e.range});return!0}var _t=class{constructor(e,t){var p,b,h,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,u=(p=e.timescale)!=null?p:1,f=((b=e.presentationTimeOffset)!=null?b:0)-r*u,l=((h=e.initialization)==null?void 0:h.media)===void 0?null:Ue(e.initialization.media,a,o),m=e.media===void 0?null:Ue(e.media,a,o),g;e.initialization!==void 0?g=e.initialization.range:e.indexRange!==void 0&&(g=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:f,initialization:{url:l,range:g},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:u},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=ve(r,this._index),this._scaledPeriodEnd=P(i)?void 0:ve(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return tt(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return gn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:Xe(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)}getLastAvailablePosition(){var i;let{timeline:e}=this._index;if(e.length===0)return null;let t=e[e.length-1],r=Math.min(Be(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return Xe(r,this._index)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return this._isInitialized}initialize(e){if(!this._isInitialized){for(let t=0;t<e.length;t++)wd(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `BaseRepresentationIndex`\")}getTargetSegmentDuration(){let{timeline:e,timescale:t}=this._index,r=e[0];if(r!==void 0)return{duration:r.duration/t,isPrecize:!1}}_replace(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted}_update(){c.error(\"Base RepresentationIndex: Cannot update a SegmentList\")}};var Rt=class{constructor(e,t){var g,p,b;if(e.duration===void 0)throw new Error(\"Invalid SegmentList: no duration\");let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t;this._isEMSGWhitelisted=s,this._periodStart=r,this._periodEnd=i;let u=(g=e.presentationTimeOffset)!=null?g:0,d=(p=e.timescale)!=null?p:1,f=u-r*d,l=((b=e.initialization)==null?void 0:b.media)===void 0?null:Ue(e.initialization.media,a,o),m=e.list.map(h=>({url:h.media===void 0?null:Ue(h.media,a,o),mediaRange:h.mediaRange}));this._index={list:m,timescale:d,duration:e.duration,indexTimeOffset:f,indexRange:e.indexRange,initialization:P(e.initialization)?void 0:{url:l,range:e.initialization.range}}}getInitSegment(){let e=tt(this._index);return e.privateInfos===void 0&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e}getSegments(e,t){let r=this._index,{duration:i,list:a,timescale:o}=r,s=i/o,u=e-this._periodStart,[d,f]=Zo(u,t,o),l=Math.min(a.length-1,Math.floor(f/i)),m=[],g=Math.floor(d/i);for(;g<=l;){let p=a[g].mediaRange,b=a[g].url,h=g*s+this._periodStart,y={id:String(g),time:h,isInit:!1,range:p,duration:s,timescale:1,end:h+s,url:b,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(y),g++}return m}shouldRefresh(e,t){return!1}getFirstAvailablePosition(){return this._periodStart}getLastAvailablePosition(){var i;let e=this._index,{duration:t,list:r}=e;return Math.min(r.length*t/e.timescale+this._periodStart,(i=this._periodEnd)!=null?i:1/0)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return!0}initialize(){c.error(\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `ListRepresentationIndex`\")}getTargetSegmentDuration(){let{duration:e,timescale:t}=this._index;return{duration:e/t,isPrecize:!0}}_replace(e){this._index=e._index}_update(){c.error(\"A `ListRepresentationIndex` cannot be updated\")}};function Lt(n){return U.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var Pt=class{constructor(e,t){var y,E,R;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:u,representationBitrate:d,isEMSGWhitelisted:f}=t,l=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(E=e.presentationTimeOffset)!=null?E:0,g=s*l,p=m-g;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let b=((R=e.initialization)==null?void 0:R.media)===void 0?null:Ue(e.initialization.media,u,d),h=e.media===void 0?null:Ue(e.media,u,d);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:p,initialization:P(e.initialization)?void 0:{url:b,range:e.initialization.range},url:h,presentationTimeOffset:m,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=a,this._periodStart=s,this._scaledRelativePeriodEnd=o===void 0?void 0:(o-s)*l,this._isEMSGWhitelisted=f}getInitSegment(){return tt(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:u}=r,d=this._periodStart*s,f=this._scaledRelativePeriodEnd,l=e*s-d,m=(e+t)*s-d,g=this._getFirstSegmentStart(),p=this._getLastSegmentStart();if(P(g)||P(p))return[];let b=Math.max(g,l),h=Math.min(p,m);if(h+i<=b)return[];let y=[],E=a!=null?a:1,R=Math.floor(b/i);for(let T=R*i;T<=h;T+=i){let v=R+E;if(o!==void 0&&v>o)return y;let _=!P(f)&&T+i>f?f-T:i,M=T+d,A=T+this._index.presentationTimeOffset,k=u===null?null:Rr(A,v)(u),C={id:String(v),number:v,time:M/s,end:(M+_)/s,duration:_/s,timescale:1,isInit:!1,scaledDuration:_/s,url:k,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(C),R++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return P(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(P(e))return e;let t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,t!=null?t:1/0)/this._index.timescale+this._periodStart}getEnd(){if(!this._isDynamic)return this.getLastAvailablePosition();let e=this._estimateRelativeScaledEnd();if(e===void 0)return;let{timescale:t}=this._index;return(e+this._periodStart*t)/t}awaitSegmentBetween(e,t){if(ce(e<=t),!this._isDynamic)return!1;let{timescale:r}=this._index,i=Lt(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,u=this._getLastSegmentStart();if(P(u)){let l=this._estimateRelativeScaledEnd();return l===void 0?s+i>=0:s+i>=0&&o<l-i}let d=u+this._index.duration,f=this._estimateRelativeScaledEnd();return f===void 0?s>d-i:s>d-i&&o<f-i}shouldRefresh(){return!1}checkDiscontinuity(){return null}isSegmentStillAvailable(e){if(e.isInit)return!0;let t=this.getSegments(e.time,.1);return t.length===0?!1:t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){if(!this._isDynamic)return!1;let e=this._estimateRelativeScaledEnd();if(e===void 0)return!0;let{timescale:t}=this._index,r=this._getLastSegmentStart();if(P(r))return!0;let i=r+this._index.duration,a=Lt(t);return i+a<e}isInitialized(){return!0}initialize(){c.error(\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `TemplateRepresentationIndex`\")}getTargetSegmentDuration(){return{duration:this._index.duration/this._index.timescale,isPrecize:!0}}_replace(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator}_update(e){this._replace(e)}_getFirstSegmentStart(){var o;if(!this._isDynamic)return 0;if(this._scaledRelativePeriodEnd===0||this._scaledRelativePeriodEnd===void 0){let s=this._manifestBoundsCalculator.getEstimatedMaximumPosition((o=this._availabilityTimeOffset)!=null?o:0);if(s!==void 0&&s<this._periodStart)return null}let{duration:e,timescale:t}=this._index,r=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime(e/t);if(r===void 0)return;let i=r>this._periodStart?(r-this._periodStart)*t:0;return Math.floor(i/e)*e}_getLastSegmentStart(){var a,o;let{duration:e,timescale:t,endNumber:r,startNumber:i=1}=this._index;if(this._isDynamic){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&this._scaledRelativePeriodEnd!==void 0&&this._scaledRelativePeriodEnd<s-this._periodStart*this._index.timescale){let l=Math.ceil(this._scaledRelativePeriodEnd/e);return r!==void 0&&r-i+1<l&&(l=r-i+1),(l-1)*e}let u=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(u===void 0)return;let d=(u-this._periodStart)*t;if(d<0)return null;let f=Math.floor(d/e);return r!==void 0&&r-i+1<f&&(f=r-i+1),f<=0?null:(f-1)*e}else{let s=(o=this._scaledRelativePeriodEnd)!=null?o:0,u=Math.ceil(s/e);r!==void 0&&r-i+1<u&&(u=r-i+1);let d=(u-1)*e,f=U.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-d>f||u<2?d:(u-2)*e}}_estimateRelativeScaledEnd(){var e,t;if(this._index.endNumber!==void 0){let r=this._index.endNumber-((e=this._index.startNumber)!=null?e:1)+1;return Math.max(Math.min(r*this._index.duration,(t=this._scaledRelativePeriodEnd)!=null?t:1/0),0)}if(this._scaledRelativePeriodEnd!==void 0)return Math.max(this._scaledRelativePeriodEnd,0)}};function Mi(n,e){let t=0;for(;n.length>0;){let r=n[0];if(r.start>=e||r.repeatCount===-1)return t;if(r.repeatCount===0)n.shift(),t+=1;else{let i=n[1];if(i!==void 0&&i.start<=e)n.shift(),t+=1;else{if(r.duration<=0)return t;let a=r.start+r.duration,o=1;for(;a<e&&o<=r.repeatCount;)a+=r.duration,o++;if(o>r.repeatCount)n.shift(),t=r.repeatCount+1;else{let s=r.repeatCount-o;return r.start=a,r.repeatCount=s,t+=o,t}}}}return t}function Oi(n,e){if(n.length===0)return n.push(...e),!0;if(e.length===0)return!1;let t=n.length,r=e[0].start,i=n[t-1];if(Be(i,e[0])<r)throw new Z(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");for(let f=t-1;f>=0;f--){let l=n[f].start;if(l===r){let m=t-f;return n.splice(f,m,...e),!1}else if(l<r){let m=n[f];if(m.start+m.duration>r)return c.warn(\"RepresentationIndex: Manifest update removed all previous segments\"),n.splice(0,t,...e),!0;if(m.repeatCount===void 0||m.repeatCount<=0)return m.repeatCount<0&&(m.repeatCount=Math.floor((r-m.start)/m.duration)-1),n.splice(f+1,t-(f+1),...e),!1;if(m.start+m.duration*(m.repeatCount+1)<=r)return n.splice(f+1,t-(f+1),...e),!1;let p=(r-m.start)/m.duration-1;if(p%1===0&&m.duration===e[0].duration){let b=e[0].repeatCount<0?-1:e[0].repeatCount+p+1;return n.splice(f,t-f,...e),n[f].start=m.start,n[f].repeatCount=b,!1}return c.warn(\"RepresentationIndex: Manifest update removed previous segments\"),n[f].repeatCount=Math.floor(p),n.splice(f+1,t-(f+1),...e),!1}}let o=n[n.length-1],s=e[e.length-1];if(o.repeatCount!==void 0&&o.repeatCount<0)return o.start>s.start?(c.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(c.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let u=o.start+o.duration*(o.repeatCount+1),d=s.start+s.duration*(s.repeatCount+1);return u>=d?(c.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(c.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function hn(n,e,t){let r=n.start,i=n.duration,a=n.repeatCount;return r===void 0&&(e===null?r=0:P(e.duration)||(r=e.start+e.duration*(e.repeatCount+1))),(i===void 0||isNaN(i))&&t!==null&&t.start!==void 0&&!isNaN(t.start)&&r!==void 0&&!isNaN(r)&&(i=t.start-r),r!==void 0&&!isNaN(r)&&i!==void 0&&!isNaN(i)&&(a===void 0||!isNaN(a))?{start:r,duration:i,repeatCount:a===void 0?0:a}:(c.warn('DASH: A \"S\" Element could not have been parsed.'),null)}function In(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!P(r))switch(t){case\"t\":{let i=parseInt(r,10);isNaN(i)?c.warn(`DASH: invalid t (\"${r}\")`):e.start=i;break}case\"d\":{let i=parseInt(r,10);isNaN(i)?c.warn(`DASH: invalid d (\"${r}\")`):e.duration=i;break}case\"r\":{let i=parseInt(r,10);isNaN(i)?c.warn(`DASH: invalid r (\"${r}\")`):e.repeatCount=i;break}}}return e}function bn(n){let e={};for(let t=0;t<n.attributes.length;t++){let r=n.attributes[t];switch(r.name){case\"t\":{let i=parseInt(r.value,10);isNaN(i)?c.warn(`DASH: invalid t (\"${r.value}\")`):e.start=i;break}case\"d\":{let i=parseInt(r.value,10);isNaN(i)?c.warn(`DASH: invalid d (\"${r.value}\")`):e.duration=i;break}case\"r\":{let i=parseInt(r.value,10);isNaN(i)?c.warn(`DASH: invalid r (\"${r.value}\")`):e.repeatCount=i;break}}}return e}function ct(n){let e=[];if(Array.isArray(n))for(let r=0;r<n.length;r++)e.push(In(n[r]));else for(let r=0;r<n.length;r++)e.push(bn(n[r]));let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[t.length-1]===void 0?null:t[t.length-1],o=e[r+1]===void 0?null:e[r+1],s=hn(i,a,o);s!==null&&t.push(s)}return t}function wi(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=Array.isArray(e)?e[0].attributes.t:e[0].getAttribute(\"t\"),i=P(r)?null:parseInt(r,10);if(i===null||Number.isNaN(i))return null;if(t===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(t<i){let a=n[0],o=0;for(;;){if(a.repeatCount>0){let 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++,o>=n.length)return null;if(a=n[o],a.start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}}else{let a=0,o=Array.isArray(e)?e[0]:null,s=Array.isArray(e)?null:e[0],u=i;for(;;){let d=o!==null?o.attributes.d:s==null?void 0:s.getAttribute(\"d\"),f=P(d)?null:parseInt(d,10);if(f===null||Number.isNaN(f))return null;let l=o!==null?o.attributes.r:s==null?void 0:s.getAttribute(\"r\"),m=P(l)?null:parseInt(l,10);if(m!==null){if(Number.isNaN(m)||m<0)return null;if(m>0){let b=t-u;if(b%f===0&&b/f<=m)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:b/f,prevSegmentsIdx:0,newElementsIdx:a}}u+=f*(m+1)}else u+=f;if(a++,a>=e.length)return null;Array.isArray(e)?o=e[a]:s=e[a];let g=o!==null?o.attributes.t:s==null?void 0:s.getAttribute(\"t\"),p=P(g)?null:parseInt(g,10);if(p!==null){if(Number.isNaN(p))return null;u=p}if(u===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(u>i)return null}}}function Di(n,e){var b;let t=wi(e,n);if(t===null)return c.warn('DASH: Cannot perform \"based\" update. Common segment not found.'),ct(n);let{prevSegmentsIdx:r,newElementsIdx:i,repeatNumberInPrevSegments:a,repeatNumberInNewElements:o}=t,u=e.length-r+i-1;if(u>=n.length)return c.info('DASH: Cannot perform \"based\" update. New timeline too short'),ct(n);let d=e.slice(r);if(a>0){let h=d[0];h.start+=h.duration*a,d[0].repeatCount-=a}if(o>0&&i!==0)return c.info('DASH: Cannot perform \"based\" update. The new timeline has a different form.'),ct(n);let f=d[d.length-1],l=Array.isArray(n)?In(n[u]):bn(n[u]),m=((b=l.repeatCount)!=null?b:0)-o;if(l.duration!==f.duration||f.repeatCount>m)return c.info('DASH: Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),ct(n);l.repeatCount!==void 0&&l.repeatCount>f.repeatCount&&(f.repeatCount=l.repeatCount);let g=[],p=[];if(Array.isArray(n))for(let h=u+1;h<n.length;h++)p.push(In(n[h]));else for(let h=u+1;h<n.length;h++)p.push(bn(n[h]));for(let h=0;h<p.length;h++){let y=p[h],E=g[g.length-1]===void 0?f:g[g.length-1],R=p[h+1]===void 0?null:p[h+1],T=hn(y,E,R);T!==null&&g.push(T)}return d.concat(g)}var Sn=class n{constructor(e,t){var T,v,_,M,A;if(!n.isTimelineIndexArgument(e))throw new Error(\"The given index is not compatible with a TimelineRepresentationIndex.\");let{availabilityTimeComplete:r,availabilityTimeOffset:i,manifestBoundsCalculator:a,isDynamic:o,isLastPeriod:s,representationId:u,representationBitrate:d,periodStart:f,periodEnd:l,isEMSGWhitelisted:m}=t,g=(T=e.timescale)!=null?T:1,p=(v=e.presentationTimeOffset)!=null?v:0,b=f*g,h=p-b;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(_=t.receivedTime)!=null?_:L(),this._unsafelyBaseOnPreviousIndex=null,t.unsafelyBaseOnPreviousRepresentation!==null&&t.unsafelyBaseOnPreviousRepresentation.index instanceof n&&(t.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=t.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=o,this._parseTimeline=(M=e.timelineParser)!=null?M:null;let y=((A=e.initialization)==null?void 0:A.media)===void 0?null:Ue(e.initialization.media,u,d),E=e.media===void 0?null:Ue(e.media,u,d),R;i===void 0&&r===void 0?R=1/0:R=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:R,indexRange:e.indexRange,indexTimeOffset:h,initialization:P(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:E,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:Ni(e.timeline,e.startNumber,e.endNumber),timescale:g},this._scaledPeriodStart=ve(f,this._index),this._scaledPeriodEnd=l===void 0?void 0:ve(l,this._index)}getInitSegment(){return tt(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),gn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=this._index.timeline;return e.length===0?null:Xe(Math.max(this._scaledPeriodStart,e[0].start),this._index)}getLastAvailablePosition(){var r;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=Pr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(e===null)return null;let t=Math.min(e.end,(r=this._scaledPeriodEnd)!=null?r:1/0);return Xe(t,this._index)}getEnd(){var r;if(this._isDynamic&&!this._isLastPeriod)return;if(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;let e=this._index.timeline[this._index.timeline.length-1],t=Math.min(Be(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return Xe(t,this._index)}awaitSegmentBetween(e,t){var d,f;if(ce(e<=t),!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timescale:r,timeline:i}=this._index,a=Lt(r),o=ve(t,this._index),s=Pr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(d=this._scaledPeriodEnd)!=null?d:1/0)+a>=Math.min(o,(f=this._scaledPeriodEnd)!=null?f:1/0))return!1;let u=ve(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],g=Be(l,null,this._scaledPeriodEnd)+a;if(u<g+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:u-a<this._scaledPeriodEnd&&o+a>this._scaledPeriodStart:!1}isSegmentStillAvailable(e){return e.isInit?!0:(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),Dd(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))}checkDiscontinuity(e){this._refreshTimeline();let t=this._index.timeline;return t===null&&(t=this._getTimeline(),this._index.timeline=t),Jo({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof Qe&&e.isHttpError(404):!1}_replace(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}_update(e){this._index.timeline===null&&(this._index.timeline=this._getTimeline()),e._index.timeline===null&&(e._index.timeline=e._getTimeline()),Oi(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}isStillAwaitingFutureSegments(){var o;if(!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timeline:e}=this._index;if(e.length===0){if(this._scaledPeriodEnd!==void 0){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&ve(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Lt(this._index.timescale),r=Pr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(r!==null&&!r.isLastOfTimeline){let s=Math.min(r.end,(o=this._scaledPeriodEnd)!=null?o:1/0);return!(this._scaledPeriodEnd!==void 0&&s+t>=this._scaledPeriodEnd)}if(!this._isLastPeriod)return!1;if(this._scaledPeriodEnd===void 0)return!0;let i=e[e.length-1];return Be(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){c.error(\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `TimelineRepresentationIndex`\")}getTargetSegmentDuration(){this._refreshTimeline();let{timeline:e,timescale:t}=this._index;if(e===null)return;let r=e[0];if(r!==void 0)return{duration:r.duration/t,isPrecize:!1}}static isTimelineIndexArgument(e){return typeof e.timelineParser==\"function\"||Array.isArray(e.timeline)}_refreshTimeline(){var i,a;if(this._index.timeline===null&&(this._index.timeline=this._getTimeline()),!this._isDynamic)return;let e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime(((a=(i=this._index.timeline[0])==null?void 0:i.duration)!=null?a:0)/this._index.timescale);if(P(e))return;let t=ve(e,this._index),r=Mi(this._index.timeline,t);this._index.startNumber!==void 0?this._index.startNumber+=r:this._index.endNumber!==void 0&&(this._index.startNumber=r+1)}_getTimeline(){if(this._parseTimeline===null)return this._index.timeline!==null?this._index.timeline:(c.error(\"DASH: Timeline already lazily parsed.\"),[]);let e=this._parseTimeline();this._parseTimeline=null;let{MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:t}=U.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return Ni(ct(e),this._index.startNumber,this._index.endNumber);let r;return this._unsafelyBaseOnPreviousIndex._index.timeline===null?(r=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=r):r=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,Ni(Di(e,r),this._index.startNumber,this._index.endNumber)}};function Ni(n,e,t){if(t===void 0)return n;let r=e!=null?e:1;for(let i=0;i<n.length;i++){let a=n[i];if(r+=a.repeatCount+1,r>t){if(r===t+1)return n.slice(0,i+1);{let o=n.slice(0,i),s=ee({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-u),o.push(s),o}}}return n}function Dd(n,e,t,r){let i=Pr(e,t,r);if(i===null)return!1;for(let a=0;a<e.timeline.length;a++){if(i.timelineIdx<a)return!1;let o=e.timeline[a],s=(o.start-e.indexTimeOffset)/e.timescale;if(s>n.time)return!1;if(s===n.time)return o.range===void 0?n.range===void 0:!P(n.range)&&o.range[0]===n.range[0]&&o.range[1]===n.range[1];if(o.repeatCount>=0&&o.duration!==void 0){let d=(s-o.start)/o.duration-1;return d%1===0&&d<=i.newRepeatCount}}return!1}function Pr(n,e,t){if(n.timeline.length<=0)return null;if(n.availabilityTimeOffset===1/0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:Be(a,null,t)}}let r=e.getEstimatedMaximumPosition(n.availabilityTimeOffset);if(r===void 0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:Be(a,null,t)}}for(let i=n.timeline.length-1;i>=n.timeline.length;i--){let a=n.timeline[i],o=a.start+a.duration;if(Xe(o,n)<=r){let s=Be(a,n.timeline[i+1],t);if(Xe(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let d=ve(r,n)-a.start,f=Math.floor(d/a.duration);return ce(f>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:f-1,end:a.start+f*a.duration}}}}return null}var vr=Sn;var Nd=/^(?:[a-z]+:)?\\/\\//i,Bd=/^(?:([^:/?#]+):)?(?:\\/\\/([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Ui(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(Nd.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Ui(n.substring(0,t)):e+1}function es(n,e){let t=Cr(n),r=Cr(e);if(t.scheme!==r.scheme||t.authority!==r.authority||t.path[0]!==void 0&&t.path[0]!==\"/\"&&r.path[0]===\"/\"||r.path[0]!==void 0&&r.path[0]!==\"/\"&&t.path[0]===\"/\")return null;let i=Tn(t.path),a=Tn(r.path),o;if(i===a)o=\"\";else{let u=i.split(\"/\");u.pop();let d=a.split(\"/\");for(;u.length>0&&d.length>0&&u[0]===d[0];)u.shift(),d.shift();for(;u.length>0;)u.shift(),d.unshift(\"..\");let f=d.join(\"/\");(f.endsWith(\"../\")||f.endsWith(\"./\"))&&(f=f.slice(0,f.length-1)),o=f===\"\"?\".\":f}let s=o;return o===\"\"&&r.query===t.query||K(r.query)&&(s+=\"?\",s+=r.query),K(r.fragment)&&(s+=\"#\",s+=r.fragment),s}function Ud(n,e){let t=Cr(n),r=Cr(e);if(K(r.scheme))return Bi(r);let i={scheme:t.scheme,authority:t.authority,path:\"\",query:r.query,fragment:r.fragment};return K(r.authority)?(i.authority=r.authority,i.path=Tn(r.path),Bi(i)):(r.path===\"\"?(i.path=t.path,K(r.query)||(i.query=t.query)):Ve(r.path,\"/\")?i.path=Tn(r.path):i.path=Tn(Fd(t,r.path)),Bi(i))}var yn=new Map,Ld=200;function Cr(n){var r,i,a,o,s;if(yn.has(n))return yn.get(n);let e=n.match(Bd),t;return e===null?t={scheme:\"\",authority:\"\",path:\"\",query:\"\",fragment:\"\"}:t={scheme:(r=e[1])!=null?r:\"\",authority:(i=e[2])!=null?i:\"\",path:(a=e[3])!=null?a:\"\",query:(o=e[4])!=null?o:\"\",fragment:(s=e[5])!=null?s:\"\"},yn.size>=Ld&&yn.clear(),yn.set(n,t),t}function Bi(n){let e=\"\";return K(n.scheme)&&(e+=n.scheme+\":\"),K(n.authority)&&(e+=\"//\"+n.authority),e+=n.path,K(n.query)&&(e+=\"?\"+n.query),K(n.fragment)&&(e+=\"#\"+n.fragment),e}function Tn(n){let e=n.split(/(?=\\/)/),t=[];for(let r=0;r<e.length;r++){let i=e[r];if(!(i===\"..\"||i===\".\"||i===\"\")){if(i===\"/..\"){t.pop(),r===e.length-1&&t.push(\"/\");continue}if(i===\"/.\"){r===e.length-1&&t.push(\"/\");continue}t.push(i)}}return t.join(\"\")}function Fd(n,e){if(K(n.authority)&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function En(...n){var r,i,a;let e=n.filter(o=>o!==\"\"),t=e.length;if(t===0)return\"\";if(t===1)return(r=e[0])!=null?r:\"\";{let o=(i=e[0])!=null?i:\"\",s=(a=e[1])!=null?a:\"\",u=Ud(o,s),d=e.slice(2);return En(u,...d)}}var _n=class{constructor(){this._refs=new Map,this._stored=[]}addReferences(e){for(let t of e)t.attributes.refId!==void 0&&this._refs.set(t.attributes.refId,t)}add(e,t){this._tryParsing(e,t,!1)||this._stored.push([e,t]),t.attributes.refId!==void 0&&(this._refs.set(t.attributes.refId,t),this._resolveStoredRefs(!1))}finalize(){this._resolveStoredRefs(!0)}_resolveStoredRefs(e){for(let t=this._stored.length-1;t>=0;t--){let[r,i]=this._stored[t];(this._tryParsing(r,i,e)||e)&&this._stored.splice(t,1)}return this._stored.length===0}_tryParsing(e,t,r){if(t.attributes.ref===void 0)return Li(e,t),!0;let i=this._getReferenced(t.attributes.ref);return i===void 0?(r&&(c.warn(\"DASH: forcing the parsing of a referencing ContentProtection\"),Li(e,t)),!1):(t.children.cencPssh.push(...i.children.cencPssh),t.attributes.keyId===void 0&&i.attributes.keyId!==void 0&&(t.attributes.keyId=i.attributes.keyId),t.attributes.schemeIdUri===void 0&&i.attributes.schemeIdUri!==void 0&&(t.attributes.schemeIdUri=i.attributes.schemeIdUri),t.attributes.value===void 0&&i.attributes.value!==void 0&&(t.attributes.value=i.attributes.value),Li(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function Li(n,e){let t;if(e.attributes.schemeIdUri!==void 0&&e.attributes.schemeIdUri.substring(0,9)===\"urn:uuid:\"&&(t=e.attributes.schemeIdUri.substring(9).replace(/-/g,\"\").toLowerCase()),e.attributes.keyId!==void 0&&e.attributes.keyId.length>0){let o=e.attributes.keyId;n.contentProtections===void 0?n.contentProtections={keyIds:[o],initData:[]}:n.contentProtections.keyIds===void 0?n.contentProtections.keyIds=[o]:n.contentProtections.keyIds.push(o)}if(t===void 0)return;let{cencPssh:r}=e.children,i=[];for(let o of r)i.push({systemId:t,data:o});if(i.length===0)return;if(n.contentProtections===void 0){n.contentProtections={keyIds:[],initData:[{type:\"cenc\",values:i}]};return}let a=j(n.contentProtections.initData,o=>o.type===\"cenc\");a===void 0?n.contentProtections.initData.push({type:\"cenc\",values:i}):a.values.push(...i)}function Ar(n){let e=Date.parse(n)-L();if(isNaN(e)){c.warn(\"DASH Parser: Invalid clock received: \",n);return}return e}function Fi(n){let e=n.children.utcTimings.filter(t=>(t.schemeIdUri===\"urn:mpeg:dash:utc:http-iso:2014\"||t.schemeIdUri===\"urn:mpeg:dash:utc:http-xsdate:2014\")&&t.value!==void 0);return e.length>0?e[0].value:void 0}function kr(n){let{representations:e}=n,t=null;for(let r of e){let i=r.index.getLastAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.min(t,i))}return t===null?null:t}function zi(n){for(let e=n.length-1;e>=0;e--){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=kr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=kr(i);if(s===void 0)return{safe:void 0,unsafe:void 0};o=s}if(r!==void 0&&a===null||i!==void 0&&o===null)return c.info(\"Parser utils: found Period with no segment. \",\"Going to previous one to calculate last position\"),{safe:void 0,unsafe:void 0};if(o!==null)return a!==null?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(a!==null)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}function xr(n){let{representations:e}=n,t=null;for(let r of e){let i=r.index.getFirstAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.max(t,i))}return t===null?null:t}function Wi(n){for(let e=0;e<=n.length-1;e++){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=xr(r);if(s===void 0)return;a=s}if(i!==void 0){let s=xr(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){c.info(\"Parser utils: found Period with no segment. \",\"Going to next one to calculate first position\");return}if(o!==null)return a!==null?Math.max(a,o):o;if(a!==null)return a}}}function qi(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=Wi(n),t=zi(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var Rn=class{constructor(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=!e.isDynamic||e.timeShiftBufferDepth===void 0?null:e.timeShiftBufferDepth,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}setLastPosition(e,t){this._lastPosition=e,this._positionTime=t}lastPositionIsKnown(){return this._isDynamic?this._positionTime!==void 0&&this._lastPosition!==void 0:this._lastPosition!==void 0}getEstimatedMinimumSegmentTime(e){var i;if(!this._isDynamic||this._timeShiftBufferDepth===null)return 0;let t=(i=this.getEstimatedLiveEdge())!=null?i:this.getEstimatedMaximumPosition(0);return t===void 0?void 0:t-(this._timeShiftBufferDepth+e)}getEstimatedLiveEdge(){if(!(!this._isDynamic||this._serverTimestampOffset===void 0))return(L()+this._serverTimestampOffset)/1e3-this._availabilityStartTime}getEstimatedMaximumPosition(e){if(!this._isDynamic)return this._lastPosition;let t=this.getEstimatedLiveEdge();return t!==void 0&&e!==1/0?t+e:this._positionTime!==void 0&&this._lastPosition!==void 0?Math.max(this._lastPosition-this._positionTime+L()/1e3,0):this._lastPosition}};function Vi(n,e){return n.type!==\"dynamic\"?0:P(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function Hi(n){if(n.length===0)return[];let e=[n[0]];for(let t=1;t<n.length;t++){let r=n[t],i=e[e.length-1];for(;(i.duration===void 0||i.start+i.duration>r.start)&&(c.warn(\"DASH: Updating overlapping Periods.\",i==null?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0));){if(e.pop(),e.length===0)break;i=e[e.length-1]}e.push(r)}return e}function Gi(n,e){let t=[];return n.forEach((r,i)=>{let a;if(!P(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||P(e.availabilityStartTime)?0:e.availabilityStartTime;else{let d=t[t.length-1];if(!P(d)&&!P(d.periodEnd))a=d.periodEnd;else throw new Error(\"Missing start time when parsing periods.\")}let o,s=n[i+1];P(r.attributes.duration)?i===n.length-1?o=e.duration:P(s.attributes.start)||(o=s.attributes.start-a):o=r.attributes.duration;let u=P(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:u})}),t}function zd(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Dt){let s=n[o];if(s!==void 0)for(let u of s)u.id===a&&(u.trickModeTracks===void 0&&(u.trickModeTracks=[]),u.trickModeTracks.push(r))}}}var ts=zd;var Wd=[\"subtitle\",\"caption\"];function Ki(n,e){var s,u,d,f;let t=(f=j((s=n.children.essentialProperties)!=null?s:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\"))!=null?f:j((d=(u=e!=null?e:n.children.representations[0])==null?void 0:u.children.essentialProperties)!=null?d:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\");if(t===void 0)return null;let r=/(\\d+)x(\\d+)/;if(t===void 0||t.value===void 0||!r.test(t.value))return c.warn(\"DASH: Invalid thumbnails Representation, no tile-related information\"),null;let i=t.value.match(r),a=parseInt(i[1],10),o=parseInt(i[2],10);return{horizontalTiles:a,verticalTiles:o}}function ji(n,e){if(n.attributes.contentType===\"image\")return Ki(n)!==null?\"thumbnails\":void 0;let t=K(n.attributes.mimeType)?n.attributes.mimeType:null,r=K(n.attributes.codecs)?n.attributes.codecs:null,i=P(n.children.roles)?null:n.children.roles;function a(s,u){let d=s.split(\"/\")[0];if(Ie(Dt,d))return d;if(s===\"application/ttml+xml\")return\"text\";if(s===\"application/mp4\")return u!==null&&j(u,f=>f.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&Ie(Wd,f.value))!==void 0?\"text\":void 0}function o(s){switch(s.substring(0,3)){case\"avc\":case\"hev\":case\"hvc\":case\"vp8\":case\"vp9\":case\"av1\":return\"video\";case\"vtt\":return\"text\"}switch(s.substring(0,4)){case\"mp4a\":return\"audio\";case\"wvtt\":case\"stpp\":return\"text\"}}if(t!==null){let s=a(t,i);if(s!==void 0)return s}if(r!==null){let s=o(r);if(s!==void 0)return s}for(let s=0;s<e.length;s++){let u=e[s],{mimeType:d,codecs:f}=u.attributes;if(d!==void 0){let l=a(d,i);if(l!==void 0)return l}if(f!==void 0){let l=o(f);if(l!==void 0)return l}}}var qd=/[, ]+/g;function ns(n){return K(n)?n.trim().replace(qd,\", \"):\"\"}function rs(n){let[e,t,r,i,a,o,s,u]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let d,f,l;if((i!==void 0&&i===\"10\"||i===\"12\")&&(d=parseInt(i,10)),s!==void 0&&(s===\"16\"?f=\"pq\":s===\"18\"&&(f=\"hlg\")),o!==void 0&&u!==void 0&&o===\"09\"&&u===\"09\"&&(l=\"rec2020\"),!(d===void 0||f===void 0))return{colorDepth:d,eotf:f,colorSpace:l}}function Yi(n,e){var p,b,h;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:u,inbandEventStreams:d,isLastPeriod:f}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:u,isEMSGWhitelisted:y=>d===void 0?!1:d.some(({schemeIdUri:E})=>E===y.schemeIdUri),isLastPeriod:f,manifestBoundsCalculator:r,isDynamic:i,periodEnd:a,periodStart:o,receivedTime:s,representationBitrate:n.attributes.bitrate,representationId:n.attributes.id},g;if(n.children.segmentBase!==void 0){let{segmentBase:y}=n.children;g=new _t(y,m)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;g=new Rt(y,m)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let y=e.parentSegmentTemplates.slice(),E=n.children.segmentTemplate;E!==void 0&&y.push(E);let R=G({},...y);(R.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((p=R.availabilityTimeOffset)!=null?p:0)+((b=e.availabilityTimeOffset)!=null?b:0)),(R.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(h=R.availabilityTimeComplete)!=null?h:e.availabilityTimeComplete),g=vr.isTimelineIndexArgument(R)?new vr(R,m):new Pt(R,m)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:E}=y;g=new _t(E,m)}else if(y.segmentList!==void 0){let{segmentList:E}=y;g=new Rt(E,m)}else g=new Pt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return g}function nt(n,e){var i;if(e.length===0)return n;let t=e.map(a=>({url:a.value}));if(n.length===0)return t;let r=[];for(let a=0;a<n.length;a++){let o=n[a];for(let s=0;s<t.length;s++){let u=t[s],d=En(o.url,u.url);r.push({url:d,serviceLocation:(i=u.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Vd(n,e){let t=[];if(n.children.inbandEventStreams!==void 0&&t.push(...n.children.inbandEventStreams),e.children.inbandEventStreams!==void 0&&t.push(...e.children.inbandEventStreams),t.length!==0)return t}function Hd({adaptationProfiles:n,essentialProperties:e,supplementalProperties:t,manifestProfiles:r,codecs:i}){if(((n!=null?n:\"\")+(r!=null?r:\"\")).indexOf(\"http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10\")!==-1&&(i===\"hvc1.2.4.L153.B0\"||i===\"hev1.2.4.L153.B0\"))return{colorDepth:10,eotf:\"pq\",colorSpace:\"rec2020\"};let o=j([...e!=null?e:[],...t!=null?t:[]],s=>s.schemeIdUri===\"urn:mpeg:mpegB:cicp:TransferCharacteristics\");if(o!==void 0)switch(o.value){case\"15\":return;case\"16\":return{eotf:\"pq\"};case\"18\":return{eotf:\"hlg\"}}if(i!==void 0&&/^vp(08|09|10)/.test(i))return rs(i)}function Qi(n,e,t){var i,a,o,s,u,d,f;let r=[];for(let l of n){let m=l.attributes.id!==void 0?l.attributes.id:String(l.attributes.bitrate)+(l.attributes.height!==void 0?`-${l.attributes.height}`:\"\")+(l.attributes.width!==void 0?`-${l.attributes.width}`:\"\")+(l.attributes.mimeType!==void 0?`-${l.attributes.mimeType}`:\"\")+(l.attributes.codecs!==void 0?`-${l.attributes.codecs}`:\"\");for(;r.some(k=>k.id===m);)m+=\"-dup\";let g=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(m))!=null?a:null,p=Vd(l,e),b=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,h;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(h=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((u=t.availabilityTimeOffset)!=null?u:0));let y=G({},t,{availabilityTimeOffset:h,availabilityTimeComplete:b,unsafelyBaseOnPreviousRepresentation:g,adaptation:e,inbandEventStreams:p}),E=Yi(l,y),R;l.attributes.bitrate===void 0?(c.warn(\"DASH: No usable bitrate found in the Representation.\"),R=0):R=l.attributes.bitrate;let T=nt(t.baseURLs,l.children.baseURLs),v=T.length===0?[{baseUrl:\"\",id:void 0}]:T.map(k=>({baseUrl:k.url,id:k.serviceLocation})),_={bitrate:R,cdnMetadata:v,index:E,id:m};l.children.supplementalProperties!==void 0&&j(l.children.supplementalProperties,k=>k.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&k.value===\"JOC\")!==void 0&&(_.isSpatialAudio=!0);let M;l.attributes.codecs!==void 0?M=l.attributes.codecs:e.attributes.codecs!==void 0&&(M=e.attributes.codecs),M!==void 0&&(M=M===\"mp4a.40.02\"?\"mp4a.40.2\":M,_.codecs=M);let A;l.attributes.supplementalCodecs!==void 0?A=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(A=e.attributes.supplementalCodecs),A!==void 0&&(_.supplementalCodecs=ns(A)),l.attributes.frameRate!==void 0?_.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(_.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?_.height=l.attributes.height:e.attributes.height!==void 0&&(_.height=e.attributes.height),l.attributes.mimeType!==void 0?_.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(_.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?_.width=l.attributes.width:e.attributes.width!==void 0&&(_.width=e.attributes.width);{let k=[...(d=e.children.contentProtections)!=null?d:[],...(f=l.children.contentProtections)!=null?f:[]];for(let C of k)t.contentProtectionParser.add(_,C)}_.hdrInfo=Hd({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:M}),r.push(_)}return r}function Gd(n){if(n===void 0)return!1;let e=n.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&n.value===\"1\",t=n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"description\";return e||t}function Kd(n,e){return!!(n!==void 0&&n.some(r=>r.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&r.value===\"2\")||e!==void 0&&e.some(r=>r.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&r.value===\"caption\"))}function jd(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function Yd(n,e){if(K(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,u=s;return K(n.attributes.language)&&(u+=`-${n.attributes.language}`),t===!0&&(u+=\"-cc\"),r===!0&&(u+=\"-cc\"),i===!0&&(u+=\"-ad\"),a===!0&&(u+=\"-si\"),o&&(u+=\"-trickMode\"),K(n.attributes.contentType)&&(u+=`-${n.attributes.contentType}`),K(n.attributes.codecs)&&(u+=`-${n.attributes.codecs}`),K(n.attributes.mimeType)&&(u+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(u+=`-${String(n.attributes.frameRate)}`),u}function Qd(n){if(!P(n.children.supplementalProperties)){let{supplementalProperties:e}=n.children;for(let t of e)if(t.schemeIdUri===\"urn:mpeg:dash:adaptation-set-switching:2016\"&&!P(t.value))return t.value.split(\",\").map(r=>r.trim()).filter(r=>K(r))}return[]}function $i(n,e){var u,d,f,l,m,g,p;let t={video:[],audio:[],text:[]},r=[],i=[],a={},o=[];for(let b=0;b<n.length;b++){let h=n[b],y=h.children,{essentialProperties:E,roles:R,label:T}=y,v=Array.isArray(R)&&R.some(ae=>ae.value===\"main\")&&R.some(ae=>ae.schemeIdUri===\"urn:mpeg:dash:role:2011\"),_=h.children.representations,M=(u=h.attributes.availabilityTimeComplete)!=null?u:e.availabilityTimeComplete,A;(h.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(A=((d=h.attributes.availabilityTimeOffset)!=null?d:0)+((f=e.availabilityTimeOffset)!=null?f:0));let k=ji(h,_);if(k===void 0)continue;let C=(l=h.attributes.selectionPriority)!=null?l:1,O=h.attributes.id,B=Qd(h),w=[];e.segmentTemplate!==void 0&&w.push(e.segmentTemplate),h.children.segmentTemplate!==void 0&&w.push(h.children.segmentTemplate);let x={availabilityTimeComplete:M,availabilityTimeOffset:A,baseURLs:nt(e.baseURLs,y.baseURLs),contentProtectionParser:e.contentProtectionParser,manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:w,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},D=Array.isArray(E)?j(E,ae=>ae.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,W=(m=D==null?void 0:D.value)==null?void 0:m.split(\" \"),q=W!==void 0,{accessibilities:$}=y,X;R!==void 0&&R.some(ae=>ae.value===\"dub\")&&(X=!0);let V;k!==\"text\"?V=!1:V=Kd($,R);let H;k===\"text\"&&R!==void 0&&R.some(ae=>ae.value===\"forced-subtitle\"||ae.value===\"forced_subtitle\")&&(H=!0);let J;k!==\"audio\"?J=!1:$!==void 0&&(J=$.some(Gd));let me;k!==\"video\"?me=!1:$!==void 0&&(me=$.some(jd));let le=Yd(h,{isAudioDescription:J,isForcedSubtitle:H,isClosedCaption:V,isSignInterpreted:me,isTrickModeTrack:q,type:k});for(;Ie(o,le);)le+=\"-dup\";let pe=le;o.push(le),x.unsafelyBaseOnPreviousAdaptation=(p=(g=e.unsafelyBaseOnPreviousPeriod)==null?void 0:g.getAdaptation(le))!=null?p:null;let je=Qi(_,h,x);if(k===\"thumbnails\"){let ae=$d(h,je);ae!==null&&r.push(...ae);continue}let te={id:le,representations:je,type:k,isTrickModeTrack:q};if(P(h.attributes.language)||(te.language=h.attributes.language),P(V)||(te.closedCaption=V),P(J)||(te.audioDescription=J),X===!0&&(te.isDub=!0),H!==void 0&&(te.forcedSubtitles=H),me===!0&&(te.isSignInterpreted=!0),T!==void 0&&(te.label=T),W!==void 0)i.push({adaptation:te,trickModeAttachedAdaptationIds:W});else{let ae=-1;for(let Qt of B){let $t=a[Qt];if($t!==void 0&&$t.newID!==pe&&Ie($t.adaptationSetSwitchingIDs,O)){ae=ne(t[k],Xt=>Xt[0].id===Qt);let _e=t[k][ae];if(_e!==void 0&&_e[0].audioDescription===te.audioDescription&&_e[0].closedCaption===te.closedCaption&&_e[0].language===te.language){c.info('DASH Parser: merging \"switchable\" AdaptationSets',O,Qt),_e[0].representations.push(...te.representations),_e[1]={priority:Math.max(C,_e[1].priority),isMainAdaptation:v||_e[1].isMainAdaptation,indexInMpd:Math.min(b,_e[1].indexInMpd)};break}}}ae<0&&t[k].push([te,{priority:C,isMainAdaptation:v,indexInMpd:b}])}!P(O)&&P(a[O])&&(a[O]={newID:pe,adaptationSetSwitchingIDs:B})}let s=Dt.reduce((b,h)=>{let y=t[h];return y.length>0&&(y.sort(is),b[h]=y.map(([E])=>E)),b},{});return t.video.sort(is),ts(s,i),{adaptations:s,thumbnailTracks:r}}function $d(n,e){var r,i;let t=[];for(let a=0;a<e.length;a++){let o=e[a];if(o!==void 0){if(o.mimeType===void 0){c.warn(\"DASH: Invalid thumbnails Representation, no mime-type\");continue}let s=Ki(n,n.children.representations[a]);if(s===null)continue;if(o.height===void 0){c.warn(\"DASH: Invalid thumbnails Representation, no height information\");continue}if(o.width===void 0){c.warn(\"DASH: Invalid thumbnails Representation, no width information\");continue}let u=(r=o.index.getFirstAvailablePosition())!=null?r:void 0,d=(i=o.index.getEnd())!=null?i:void 0,f,l=o.index.getTargetSegmentDuration();l!==void 0&&l.isPrecize?f=l.duration:c.warn(\"DASH: Cannot produce duration estimate for thumbnail track\"),t.push({id:o.id,cdnMetadata:o.cdnMetadata,index:o.index,mimeType:o.mimeType,height:o.height,width:o.width,horizontalTiles:s.horizontalTiles,verticalTiles:s.verticalTiles,start:u,end:d,tileDuration:f===void 0?void 0:f/(s.horizontalTiles*s.verticalTiles)})}}return t}function is(n,e){let t=e[1].priority-n[1].priority;return t!==0?t:n[1].isMainAdaptation!==e[1].isMainAdaptation?n[1].isMainAdaptation?-1:1:n[1].indexInMpd-e[1].indexInMpd}var Xd=xe();function Xi(n,e){var o,s,u,d,f;let t=[],r=Gi(n,e);if(r.length!==n.length)throw new Error(\"MPD parsing error: the time information are incoherent.\");let{isDynamic:i,manifestBoundsCalculator:a}=e;!i&&!P(e.duration)&&a.setLastPosition(e.duration);for(let l=n.length-1;l>=0;l--){let m=l===n.length-1,g=n[l],p=e.xlinkInfos.get(g),b=nt(e.baseURLs,g.children.baseURLs),{periodStart:h,periodDuration:y,periodEnd:E}=r[l],R;for(P(g.attributes.id)?(c.warn(\"DASH: No usable id found in the Period. Generating one.\"),R=\"gen-dash-period-\"+Xd()):R=g.attributes.id;t.some(q=>q.id===R);)R+=\"-dup\";let T=p!==void 0?p.receivedTime:e.receivedTime,v=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(R))!=null?s:null,_=g.attributes.availabilityTimeComplete,M=g.attributes.availabilityTimeOffset,{manifestProfiles:A,contentProtectionParser:k}=e,{segmentTemplate:C}=g.children;k.addReferences((u=g.children.contentProtections)!=null?u:[]);let O={availabilityTimeComplete:_,availabilityTimeOffset:M,baseURLs:b,contentProtectionParser:k,manifestBoundsCalculator:a,end:E,isDynamic:i,isLastPeriod:m,manifestProfiles:A,receivedTime:T,segmentTemplate:C,start:h,unsafelyBaseOnPreviousPeriod:v},{adaptations:B,thumbnailTracks:w}=$i(g.children.adaptations,O),x=((d=e.xmlNamespaces)!=null?d:[]).concat((f=g.attributes.namespaces)!=null?f:[]),D=Jd(g.children.eventStreams,h,x),W={id:R,start:h,end:E,duration:y,thumbnailTracks:w,adaptations:B,streamEvents:D};if(t.unshift(W),!a.lastPositionIsKnown()){let q=Zd(B);if(!i)typeof q==\"number\"&&a.setLastPosition(q);else if(typeof q==\"number\"){let $=L()/1e3;a.setLastPosition(q,$)}else{let $=as(e,h);if($!==void 0){let[X,V]=$;a.setLastPosition(X,V)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=as(e,0);if(l!==void 0){let[m,g]=l;a.setLastPosition(m,g)}}return Hi(t)}function as(n,e){if(P(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){c.warn(\"DASH Parser: no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=L()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=L()/1e3,i=r+t;if(i>=e)return[i,r]}}function Zd(n){let e=null,t=!0,r=pr(n).filter(a=>!P(a)),i=Ri(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let u=s.index.getLastAvailablePosition();u!==null&&(t=!1,typeof u==\"number\"&&(e=P(e)?u:Math.max(e,u)))}}if(P(e)){if(t)return null}else return e}function Jd(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:u=1}=o.attributes,d=t.concat((i=o.attributes.namespaces)!=null?i:[]);for(let f of o.children.events)if(f.eventStreamData!==void 0){let l=((a=f.presentationTime)!=null?a:0)/u+e,m=f.duration===void 0?void 0:l+f.duration/u,g,p;if(!Ot&&f.eventStreamData instanceof Element)g=f.eventStreamData;else try{p={namespaces:d,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:Ne(new Uint8Array(f.eventStreamData))}}catch(b){c.error(\"DASH: Error while parsing event-stream:\",b instanceof Error?b.message:\"Unknown error\")}r.push({start:l,end:m,id:f.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:u,element:g,xmlData:p}}})}}return r}function Ft(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(P(e.externalClockOffset)){let u=o.type===\"dynamic\",d=j(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!P(m.value)),f=!P(d)&&!P(d.value)?Ar(d.value):void 0,l=!P(f)&&!isNaN(f)?f:void 0;if(!P(l)&&r!==!0)e.externalClockOffset=l;else if(u&&r!==!0){let m=Fi(n);if(!P(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(p){return p.success?(e.externalClockOffset=Ar(p.data),Ft(n,e,t,!0)):(t.push(p.error),c.warn(\"DASH Parser: Error on fetching the clock ressource\",p.error),Ft(n,e,t,!0))}}}}}let s=[];for(let u=0;u<a.periods.length;u++){let{xlinkHref:d,xlinkActuate:f}=a.periods[u].attributes;!P(d)&&f===\"onLoad\"&&s.push({index:u,ressource:d})}return s.length===0?el(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:u})=>u),continue:function(d){if(d.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let f=d.length-1;f>=0;f--){let l=s[f].index,{parsed:m,warnings:g,receivedTime:p,sendingTime:b,url:h}=d[f];g.length>0&&t.push(...g);for(let y of m)i.set(y,{receivedTime:p,sendingTime:b,url:h});a.periods.splice(l,1,...m)}return Ft(n,e,t,r,i)}}}}function el(n,e,t,r){var x,D,W,q,$;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Ui(e.url))}]:[],u=nt(s,i.baseURLs),d=Vi(a,e.referenceDateTime),f=a.timeShiftBufferDepth,l=a.maxSegmentDuration,{externalClockOffset:m,unsafelyBaseOnPreviousManifest:g}=e,{externalClockOffset:p}=e,b=new Rn({availabilityStartTime:d,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:p}),h=new _n;h.addReferences((x=i.contentProtections)!=null?x:[]);let y={availabilityStartTime:d,baseURLs:u,clockOffset:m,contentProtectionParser:h,duration:a.duration,isDynamic:o,manifestBoundsCalculator:b,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,unsafelyBaseOnPreviousManifest:g,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},E=Xi(i.periods,y);h.finalize();let R=a.duration,T,v,_=null,M;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(T=a.minimumUpdatePeriod===0?U.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:A,maximumSafePosition:k,maximumUnsafePosition:C}=qi(E),O=L();if(o){let X;k!==void 0?X=k:p===void 0?(c.warn(\"DASH Parser: use system clock to define maximum position\"),X=Date.now()/1e3-d):X=(L()+p)/1e3-d;let V=b.getEstimatedLiveEdge();V===void 0&&(C!==void 0?V=C:V=X),M={isLinear:!0,maximumSafePosition:X,livePosition:V,time:O},v=A,_=f!=null?f:null,_!==null&&(_+=l!=null?l:0),_!==null&&v!==void 0&&V-v>_&&(_=V-v)}else{v=A,v===void 0&&(v=(W=(D=E[0])==null?void 0:D.start)!=null?W:0);let X=R!=null?R:1/0;if(E[E.length-1]!==void 0){let V=E[E.length-1],H=(q=V.end)!=null?q:V.duration!==void 0?V.start+V.duration:void 0;H!==void 0&&H<X&&(X=H)}k!==void 0&&k<X&&(X=k),M={isLinear:!1,maximumSafePosition:X,livePosition:void 0,time:O}}let B=!o||n.attributes.minimumUpdatePeriod===void 0&&((($=E[E.length-1])==null?void 0:$.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:d,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:B,periods:E,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:v,timeshiftDepth:_,maximumTimeData:M},lifetime:T,uris:P(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var Mr=Ft;var tl=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,nl=/([0-9]+)-([0-9]+)/;function Ce(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new we(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ie(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new we(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function Me(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new we(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function Zi(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new we(`\\`${e}\\` property is not a boolean nor an integer but \"${n}\"`)]:[t,null]}function Or(n,e){let t=Date.parse(n);return isNaN(t)?[null,new we(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function He(n,e){if(!K(n))return[0,new we(`\\`${e}\\` property is empty`)];let t=tl.exec(n);return t===null?[null,new we(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(K(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(K(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(K(t[6])?t[6]:\"0\")*24*60*60+parseFloat(K(t[8])?t[8]:\"0\")*60*60+parseFloat(K(t[10])?t[10]:\"0\")*60+parseFloat(K(t[12])?t[12]:\"0\"),null]}function vt(n,e){let t=nl.exec(n);return t===null?[null,new we(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function os(n,e){try{return[Sr(n),null]}catch(t){return[null,new we(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function zt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:Me(n,e)}function ye(n){let e,t;for(let r of Object.keys(n.attributes)){let i=n.attributes[r];if(!P(i))switch(r){case\"schemeIdUri\":e=i;break;case\"value\":t=i;break}}return{schemeIdUri:e,value:t}}function Te(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(c.warn(s.message),e.push(s)),o!==null&&(n[r]=o)}}var we=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\"}};function pt(n){return _r(n)}function rt(n){let e=typeof n==\"string\"?n:pt(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function rl(n){let e=[],t=[];for(let r=0;r<n.length;r++){let i=n[r];if(typeof i!=\"string\"&&i.tagName===\"cenc:pssh\"){let a=pt(i.children);if(a!==null&&a.length>0){let[o,s]=os(a,\"cenc:pssh\");s!==null&&(c.warn(s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function il(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!P(r))switch(t){case\"schemeIdUri\":e.schemeIdUri=r;break;case\"value\":e.value=r;break;case\"cenc:default_KID\":e.keyId=dn(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function it(n){let[e,t]=rl(n.children),r=il(n);return[{children:e,attributes:r},t]}function Ji(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!P(r))switch(t){case\"id\":e.id=r;break;case\"lang\":e.language=r;break;case\"contentType\":e.contentType=r;break;case\"par\":e.par=r;break}}return e}function ea(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!P(a))switch(i){case\"range\":r(a,{asKey:\"range\",parser:vt,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function at(n){let e={},t=[],r=Te(e,t),i=n.children;for(let a=0;a<i.length;a++){let o=i[a];if(typeof o!=\"string\"&&o.tagName===\"Initialization\"){let[s,u]=ea(o);e.initialization=s,t=t.concat(u)}}for(let a of Object.keys(n.attributes)){let o=n.attributes[a];if(!P(o))switch(a){case\"timescale\":r(o,{asKey:\"timescale\",parser:ie,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:Me,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:vt,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:Ce,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:Me,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:Ce,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ie,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ie,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ie,dashName:\"endNumber\"});break}}return[e,t]}function ta(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!P(a))switch(i){case\"media\":e.media=a;break;case\"indexRange\":r(a,{asKey:\"indexRange\",parser:vt,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:vt,dashName:\"mediaRange\"});break}}return[e,t]}function Pn(n){let[e,t]=at(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let u=a[s];if(typeof u!=\"string\"&&u.tagName===\"SegmentURL\"){let[d,f]=ta(u);i.push(d),r=r.concat(f)}}return[G(e,{list:i}),r]}function na(n){let e=n.children;return function(){for(let t=e.length-1;t>=0;t--){let r=e[t];(typeof r==\"string\"||r.tagName!==\"S\")&&e.splice(t,1)}return e}}function Ct(n){let[e,t]=at(n),r=t,i;for(let s=0;s<n.children.length;s++){let u=n.children[s];typeof u!=\"string\"&&u.tagName===\"SegmentTimeline\"&&(i=na(u))}let a=G({},e,{duration:e.duration,timelineParser:i}),o=Te(a,r);for(let s of Object.keys(n.attributes)){let u=n.attributes[s];if(!P(u))switch(s){case\"initialization\":P(a.initialization)&&(a.initialization={media:u});break;case\"index\":a.index=u;break;case\"availabilityTimeOffset\":o(u,{asKey:\"availabilityTimeOffset\",parser:Me,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(u,{asKey:\"availabilityTimeComplete\",parser:Ce,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=u;break;case\"bitstreamSwitching\":o(u,{asKey:\"bitstreamSwitching\",parser:Ce,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function al(n){let e={baseURLs:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"BaseURL\":{let[o,s]=rt(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break}case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(ye(a));break;case\"SegmentBase\":{let[o,s]=at(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=Pn(a);r=r.concat(s),e.segmentList=o;break}case\"SegmentTemplate\":{let[o,s]=Ct(a);r=r.concat(s),e.segmentTemplate=o;break}case\"ContentProtection\":{let[o,s]=it(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}case\"EssentialProperty\":P(e.essentialProperties)?e.essentialProperties=[ye(a)]:e.essentialProperties.push(ye(a));break;case\"SupplementalProperty\":P(e.supplementalProperties)?e.supplementalProperties=[ye(a)]:e.supplementalProperties.push(ye(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function ol(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!P(a))switch(i){case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"bandwidth\":r(a,{asKey:\"bitrate\",parser:ie,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:Ce,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:zt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ie,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:Me,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:Me,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ie,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ie,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:Me,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ce,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new we(\"No bitrate found on a Representation\")),[e,t]}function ss(n){let[e,t]=al(n.children),[r,i]=ol(n),a=t.concat(i);return[{children:e,attributes:r},a]}function sl(n){let e={baseURLs:[],representations:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"Accessibility\":e.accessibilities===void 0?e.accessibilities=[ye(a)]:e.accessibilities.push(ye(a));break;case\"BaseURL\":{let[o,s]=rt(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break}case\"ContentComponent\":e.contentComponent=Ji(a);break;case\"EssentialProperty\":P(e.essentialProperties)?e.essentialProperties=[ye(a)]:e.essentialProperties.push(ye(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(ye(a));break;case\"Label\":{let o=pt(a.children);o!=null&&(e.label=o);break}case\"Representation\":{let[o,s]=ss(a);e.representations.push(o),s.length>0&&(r=r.concat(s));break}case\"Role\":P(e.roles)?e.roles=[ye(a)]:e.roles.push(ye(a));break;case\"SupplementalProperty\":P(e.supplementalProperties)?e.supplementalProperties=[ye(a)]:e.supplementalProperties.push(ye(a));break;case\"SegmentBase\":{let[o,s]=at(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=Pn(a);e.segmentList=o,s.length>0&&(r=r.concat(s));break}case\"SegmentTemplate\":{let[o,s]=Ct(a);e.segmentTemplate=o,s.length>0&&(r=r.concat(s));break}case\"ContentProtection\":{let[o,s]=it(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}}}return t.length>0&&(e.contentProtections=t),[e,r]}function ul(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!P(a))switch(i){case\"id\":e.id=a;break;case\"group\":r(a,{asKey:\"group\",parser:ie,dashName:\"group\"});break;case\"lang\":e.language=a;break;case\"contentType\":e.contentType=a;break;case\"par\":e.par=a;break;case\"minBandwidth\":r(a,{asKey:\"minBitrate\",parser:ie,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ie,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ie,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ie,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ie,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ie,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:zt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:zt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ie,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:Zi,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:Zi,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ce,dashName:\"bitstreamSwitching\"});break;case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"codecs\":e.codecs=a;break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:Ce,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:zt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ie,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:Me,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:Me,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ie,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:Me,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ce,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function us(n){let e=n.children,[t,r]=sl(e),[i,a]=ul(n),o=r.concat(a);return[{children:t,attributes:i},o]}function dl(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!P(a))switch(i){case\"schemeIdUri\":e.schemeIdUri=a;break;case\"value\":e.value=a;break;case\"timescale\":r(a,{asKey:\"timescale\",parser:ie,dashName:\"timescale\"});break;default:Ve(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function ds(n,e){let[t,r]=dl(n),i=[];for(let a of n.children)if(typeof a!=\"string\"&&a.tagName===\"Event\"){let o={};if(P(a.attributes.id)||(o.id=a.attributes.id),!P(a.attributes.presentationTime)){let[s,u]=ie(a.attributes.presentationTime,\"presentationTime\");u!==null&&r.push(u),s!==null&&(o.presentationTime=s)}if(!P(a.attributes.duration)){let[s,u]=ie(a.attributes.duration,\"duration\");u!==null&&r.push(u),s!==null&&(o.duration=s)}if(a.posStart<a.posEnd){let s=e.substring(a.posStart,a.posEnd);o.eventStreamData=s}i.push(o)}return[{children:{events:i},attributes:t},r]}function ll(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let u=0;u<n.length;u++){let d=n[u];if(typeof d!=\"string\")switch(d.tagName){case\"BaseURL\":{let[f,l]=rt(d);f!==void 0&&t.push(f),o=o.concat(l);break}case\"AdaptationSet\":{let[f,l]=us(d);r.push(f),o=o.concat(l);break}case\"EventStream\":{let[f,l]=ds(d,e);s.push(f),o=o.concat(l);break}case\"SegmentTemplate\":{let[f,l]=Ct(d);i=f,l.length>0&&(o=o.concat(l));break}case\"ContentProtection\":{let[f,l]=it(d);l.length>0&&(o=o.concat(l)),f!==void 0&&a.push(f);break}}}return[{baseURLs:t,adaptations:r,eventStreams:s,segmentTemplate:i,contentProtections:a},o]}function fl(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!P(a))switch(i){case\"id\":e.id=a;break;case\"start\":r(a,{asKey:\"start\",parser:He,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:He,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ce,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:Ve(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function wr(n,e){let[t,r]=ll(n.children,e),[i,a]=fl(n),o=r.concat(a);return[{children:t,attributes:i},o]}function ml(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let u=0;u<n.length;u++){let d=n[u];if(typeof d!=\"string\")switch(d.tagName){case\"BaseURL\":{let[f,l]=rt(d);f!==void 0&&t.push(f),s=s.concat(l);break}case\"Location\":r.push(pt(d.children));break;case\"Period\":{let[f,l]=wr(d,e);i.push(f),s=s.concat(l);break}case\"UTCTiming\":{let f=ye(d);a.push(f);break}case\"ContentProtection\":{let[f,l]=it(d);l.length>0&&(s=s.concat(l)),f!==void 0&&o.push(f);break}}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a,contentProtections:o},s]}function cl(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!P(a))switch(i){case\"id\":e.id=a;break;case\"profiles\":e.profiles=a;break;case\"type\":e.type=a;break;case\"availabilityStartTime\":r(a,{asKey:\"availabilityStartTime\",parser:Or,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:Or,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:Or,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:He,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:He,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:He,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:He,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:He,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:He,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:He,dashName:\"maxSubsegmentDuration\"});break;default:Ve(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function ls(n,e){let[t,r]=ml(n.children,e),[i,a]=cl(n),o=r.concat(a);return[{children:t,attributes:i},o]}function ra(n,e){let t=Ai(n),r=t[t.length-1];if(r===void 0||typeof r==\"string\"||r.tagName!==\"MPD\")throw new Error(\"DASH Parser: document root should be MPD\");let[i,a]=ls(r,n),o=Mr(i,e,a);return s(o);function s(u){if(u.type===\"done\")return u;if(u.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[u.value.url],format:\"string\",continue(d){if(d.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let f=u.value.continue(d[0].responseData);return s(f)}}};if(u.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:u.value.xlinksUrls,format:\"string\",continue(d){let f=[];for(let m=0;m<d.length;m++){let{responseData:g,receivedTime:p,sendingTime:b,url:h}=d[m];if(!g.success)throw g.error;let y=\"<root>\"+g.data+\"</root>\",E=Ai(y),R=E[E.length-1];if(R===void 0||typeof R==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let T=R.children,v=[],_=[];for(let M=0;M<T.length;M++){let A=T[M];if(typeof A==\"string\"||A.tagName!==\"Period\")continue;let[k,C]=wr(A,y);_.push(...C),v.push(k)}f.push({url:h,receivedTime:p,sendingTime:b,parsed:v,warnings:_})}let l=u.value.continue(f);return s(l)}}};De(u)}}var fs=ra;var pl=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",ms=pl;function z(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function ia(n){return n===1/0?!0:n===-1/0?!1:n}function gt(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=z(t,e.buffer,a,o))}}function ht(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,u){switch(o){case 16:t.schemeIdUri=z(i,e.buffer,s,u);break;case 13:t.value=z(i,e.buffer,s,u);break;case 14:{let d=z(i,e.buffer,s,u);t.keyId=dn(d.replace(/-/g,\"\"));break}case 15:try{let d=z(i,e.buffer,s,u);r.cencPssh.push(Sr(d))}catch(d){}break;case 78:t.ref=z(i,e.buffer,s,u);break;case 79:t.refId=z(i,e.buffer,s,u);break}}}function cs(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=z(t,e.buffer,a,o);break;case 60:n.language=z(t,e.buffer,a,o);break;case 61:n.contentType=z(t,e.buffer,a,o);break;case 62:n.par=z(t,e.buffer,a,o);break}}}function ps(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.label=z(t,e.buffer,a,o))}}function Le(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=z(t,e.buffer,a,o);break;case 17:n.value=z(t,e.buffer,a,o);break}}}function Wt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 29:{let s=new DataView(e.buffer);n.initialization===void 0&&(n.initialization={}),n.initialization.range=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 67:n.initialization===void 0&&(n.initialization={}),n.initialization.media=z(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function gs(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=z(t,e.buffer,a,o);break;case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 30:n.media=z(t,e.buffer,a,o);break;case 18:{let s=new DataView(e.buffer);n.mediaRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}}}}function Dr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=gs(a,e);t.pushParsers(i,N,o);break}default:t.pushParsers(i,N,N);break}}}function qt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let u=a;for(let d=0;d<o/24;d++)n.timeline.push({start:s.getFloat64(u,!0),duration:s.getFloat64(u+8,!0),repeatCount:s.getFloat64(u+16,!0)}),u+=24;break}case 67:n.initialization={media:z(t,e.buffer,a,o)};break;case 28:n.index=z(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 30:n.media=z(t,e.buffer,a,o);break;case 32:{n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function hs(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,N,gt(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=ht(a,e);t.pushParsers(i,N,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,N,Le(a,e));break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=Le(a,e);t.pushParsers(i,N,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Le(a,e);t.pushParsers(i,N,o);break}case 17:{let a={};n.segmentBase=a;let o=Wt(a,e);t.pushParsers(i,N,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Dr(a,e,t),s=Wt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,N,qt(a,e));break}default:t.pushParsers(i,N,N);break}}}function Is(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=z(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=z(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=z(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=z(t,e.buffer,a,o);break;case 5:n.codingDependency=new DataView(e.buffer).getUint8(0)===0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 11:n.mimeType=z(t,e.buffer,a,o);break;case 2:n.profiles=z(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=z(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break}}}function bs(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=Le(a,e);t.pushParsers(i,N,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=gt(a,e);t.pushParsers(i,N,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,N,cs(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=ht(a,e);t.pushParsers(i,N,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=N,s=Le(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=N,s=Le(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=hs(a.children,e,t),s=Is(a.attributes,e);t.pushParsers(i,o,s);break}case 12:{let a={};n.roles===void 0&&(n.roles=[]),n.roles.push(a);let o=Le(a,e);t.pushParsers(i,N,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Le(a,e);t.pushParsers(i,N,o);break}case 17:{let a={};n.segmentBase=a;let o=Wt(a,e);t.pushParsers(i,N,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Dr(a,e,t),s=Wt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,N,qt(a,e));break}case 21:{t.pushParsers(i,N,ps(n,e));break}default:t.pushParsers(i,N,N);break}}}function Ss(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=z(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=z(t,e.buffer,a,o);break;case 61:n.contentType=z(t,e.buffer,a,o);break;case 62:n.par=z(t,e.buffer,a,o);break;case 53:n.minBitrate=s.getFloat64(a,!0);break;case 49:n.maxBitrate=s.getFloat64(a,!0);break;case 56:n.minWidth=s.getFloat64(a,!0);break;case 52:n.maxWidth=s.getFloat64(a,!0);break;case 55:n.minHeight=s.getFloat64(a,!0);break;case 51:n.maxHeight=s.getFloat64(a,!0);break;case 54:n.minFrameRate=s.getFloat64(a,!0);break;case 50:n.maxFrameRate=s.getFloat64(a,!0);break;case 57:n.selectionPriority=s.getFloat64(a,!0);break;case 58:n.segmentAlignment=ia(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=ia(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=z(t,e.buffer,a,o);break;case 4:n.codecs=z(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=z(t,e.buffer,a,o);break;case 2:n.profiles=z(t,e.buffer,a,o);break;case 12:n.segmentProfiles=z(t,e.buffer,a,o);break;case 11:n.mimeType=z(t,e.buffer,a,o);break;case 5:n.codingDependency=s.getFloat64(a,!0)!==0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break}}}function ys(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=gl(o,e,r);t.pushParsers(a,N,s);break}default:t.pushParsers(a,N,N);break}}}function Ts(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=z(t,e.buffer,a,o);break;case 17:n.value=z(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:{let u={key:\"\",value:\"\"},d=a,f=s.getUint32(d);d+=4,u.key=z(t,e.buffer,d,f),d+=f;let l=s.getUint32(d);d+=4,u.value=z(t,e.buffer,d,l),n.namespaces===void 0?n.namespaces=[u]:n.namespaces.push(u);break}}}}function gl(n,e,t){let r=new TextDecoder;return function(a,o,s){let u=new DataView(e.buffer);switch(a){case 25:n.presentationTime=u.getFloat64(o,!0);break;case 1:n.duration=u.getFloat64(o,!0);break;case 0:n.id=z(r,e.buffer,o,s);break;case 69:{let d=u.getFloat64(o,!0),f=u.getFloat64(o+8,!0);n.eventStreamData=t.slice(d,f);break}}}}function Nr(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=bs(o.children,e,t),u=Ss(o.attributes,e);t.pushParsers(a,s,u);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=N,u=gt(o,e);t.pushParsers(a,s,u);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=ys(o.children,e,t,r),u=Ts(o.attributes,e);t.pushParsers(a,s,u);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,N,qt(o,e));break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=ht(o,e);t.pushParsers(a,N,s);break}default:t.pushParsers(a,N,N);break}}}function Br(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=z(t,e.buffer,a,o);break;case 45:n.start=new DataView(e.buffer).getFloat64(a,!0);break;case 1:n.duration=new DataView(e.buffer).getFloat64(a,!0);break;case 32:n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break;case 46:n.xlinkHref=z(t,e.buffer,a,o);break;case 47:n.xlinkActuate=z(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=new DataView(e.buffer).getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break;case 70:{let s={key:\"\",value:\"\"},u=new DataView(e.buffer),d=a,f=u.getUint32(d);d+=4,s.key=z(t,e.buffer,d,f),d+=f;let l=u.getUint32(d);d+=4,s.value=z(t,e.buffer,d,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}}function Es(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=N,u=gt(o,e);t.pushParsers(a,s,u);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Nr(o.children,e,t,r),u=Br(o.attributes,e);t.pushParsers(a,s,u);break}case 3:{let o={};n.utcTimings.push(o);let s=N,u=Le(o,e);t.pushParsers(a,s,u);break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=ht(o,e);t.pushParsers(a,N,s);break}default:t.pushParsers(a,N,N);break}}}function _s(n,e,t){let r,i=new TextDecoder;return function(o,s,u){switch(o){case 0:e.id=z(i,t.buffer,s,u);break;case 2:e.profiles=z(i,t.buffer,s,u);break;case 33:e.type=z(i,t.buffer,s,u);break;case 34:{let d=z(i,t.buffer,s,u);e.availabilityStartTime=new Date(d).getTime()/1e3;break}case 35:{let d=z(i,t.buffer,s,u);e.availabilityEndTime=new Date(d).getTime()/1e3;break}case 36:{let d=z(i,t.buffer,s,u);e.publishTime=new Date(d).getTime()/1e3;break}case 68:r=new DataView(t.buffer),e.duration=r.getFloat64(s,!0);break;case 37:r=new DataView(t.buffer),e.minimumUpdatePeriod=r.getFloat64(s,!0);break;case 38:r=new DataView(t.buffer),e.minBufferTime=r.getFloat64(s,!0);break;case 39:r=new DataView(t.buffer),e.timeShiftBufferDepth=r.getFloat64(s,!0);break;case 40:r=new DataView(t.buffer),e.suggestedPresentationDelay=r.getFloat64(s,!0);break;case 41:r=new DataView(t.buffer),e.maxSegmentDuration=r.getFloat64(s,!0);break;case 42:r=new DataView(t.buffer),e.maxSubsegmentDuration=r.getFloat64(s,!0);break;case 66:{let d=z(i,t.buffer,s,u);n.locations.push(d);break}case 70:{let d={key:\"\",value:\"\"};r=new DataView(t.buffer);let f=s,l=r.getUint32(f);f+=4,d.key=z(i,t.buffer,f,l),f+=l;let m=r.getUint32(f);f+=4,d.value=z(i,t.buffer,f,m),e.namespaces===void 0?e.namespaces=[d]:e.namespaces.push(d);break}}}}function aa(n,e,t,r){return function(a){switch(a){case 1:{n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=Es(n.mpd.children,e,t,r),s=_s(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break}default:t.pushParsers(a,N,N);break}}}function Rs(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Nr(o.children,e,t,r),u=Br(o.attributes,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,N,N);break}}}var vn=class{constructor(){this._currentNodeId=null,this.childrenParser=N,this.attributeParser=N,this._stack=[{nodeId:null,children:N,attribute:N}]}pushParsers(e,t,r){this._currentNodeId=e,this.childrenParser=t,this.attributeParser=r,this._stack.push({nodeId:e,attribute:r,children:t})}popIfCurrent(e){if(this._currentNodeId!==e)return;this._stack.pop();let{nodeId:t,children:r,attribute:i}=this._stack[this._stack.length-1];this._currentNodeId=t,this.attributeParser=i,this.childrenParser=r}reset(){this.childrenParser=N,this.attributeParser=N,this._stack=[{nodeId:null,children:N,attribute:N}]}};var hl=15e3,Cn=class{constructor(){this._parsersStack=new vn,this._instance=null,this._mpdData=null,this._linearMemory=null,this.status=\"uninitialized\",this._initProm=null,this._warnings=[],this._isParsing=!1}waitForInitialization(){var e;return(e=this._initProm)!=null?e:Promise.reject(\"No initialization performed yet.\")}async initialize(e){if(this.status!==\"uninitialized\")return Promise.reject(new Error(\"DashWasmParser already initialized.\"));if(!this.isCompatible())return this.status=\"failure\",Promise.reject(new Error(\"Target not compatible with WebAssembly.\"));this.status=\"initializing\";let t=this._parsersStack,r=new TextDecoder,i=this,a={env:{memoryBase:0,tableBase:0,memory:new WebAssembly.Memory({initial:10}),table:new WebAssembly.Table({initial:1,element:\"anyfunc\"}),onTagOpen:d,onCustomEvent:m,onAttribute:l,readNext:g,onTagClose:f}},o=null,s;typeof e.wasmUrl==\"string\"?s=fetch(e.wasmUrl):(o=URL.createObjectURL(new Blob([e.wasmUrl],{type:\"application/wasm\"})),s=fetch(o));let u=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=u.catch(async p=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"Unable to call `instantiateStreaming` on WASM\",p instanceof Error?p:\"\");let b=await s;if(b.status<200||b.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(b.status));let h=await b.arrayBuffer();return WebAssembly.instantiate(h,a)}).then(p=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=p,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(p=>{let b=p instanceof Error?p.toString():\"Unknown error\";throw c.warn(\"DW: Could not create DASH-WASM parser:\",b),this.status=\"failure\",p}),this._initProm;function d(p){return t.childrenParser(p)}function f(p){return t.popIfCurrent(p)}function l(p,b,h){return t.attributeParser(p,b,h)}function m(p,b,h){let y=i._linearMemory,E=new Uint8Array(y.buffer,b,h);if(p===1){let R=r.decode(E);c.warn(\"WASM Error Event:\",R),i._warnings.push(new Error(R))}else if(p===0){let R=r.decode(E);c.warn(\"WASM Log Event:\",R)}}function g(p,b){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let h=i._linearMemory,{mpd:y,cursor:E}=i._mpdData,R=Math.min(b,hl,y.byteLength-E);return new Uint8Array(h.buffer,p,R).set(new Uint8Array(y,E,R)),i._mpdData.cursor+=R,R}}runWasmParser(e,t){let[r,i]=this._parseMpd(e);if(r===null)throw new Error(\"DASH Parser: Unknown error while parsing the MPD\");let a=Mr(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return ms&&typeof ue.TextDecoder==\"function\"}_parseMpd(e){var s;if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={},r=this._linearMemory,i=aa(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,N),this._warnings=[];try{this._instance.instance.exports.parse()}catch(u){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,u}let a=(s=t.mpd)!=null?s:null,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_parseXlink(e){if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={periods:[]},r=this._linearMemory,i=Rs(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,N),this._warnings=[];try{this._instance.instance.exports.parse()}catch(s){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,s}let{periods:a}=t,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_processParserReturnValue(e){if(e.type===\"done\")return e;if(e.type===\"needs-clock\"){let t=r=>{if(r.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let i=e.value.continue(r[0].responseData);return this._processParserReturnValue(i)};return{type:\"needs-resources\",value:{urls:[e.value.url],format:\"string\",continue:t}}}else if(e.type===\"needs-xlinks\"){let t=r=>{let i=[];for(let o=0;o<r.length;o++){let{responseData:s,receivedTime:u,sendingTime:d,url:f}=r[o];if(!s.success)throw s.error;let[l,m]=this._parseXlink(s.data);i.push({url:f,receivedTime:u,sendingTime:d,parsed:l,warnings:m})}let a=e.value.continue(i);return this._processParserReturnValue(a)};return{type:\"needs-resources\",value:{urls:e.value.xlinksUrls,format:\"arraybuffer\",continue:t}}}else De(e)}};var Ps=Cn;var At=class{constructor(e,t){this._last=e,this._wanted=t}serialize(){return[this._last,this._wanted]}getPolled(){return this._last}getWanted(){var e;return(e=this._wanted)!=null?e:this._last}forceWantedPosition(e){this._wanted=e}isAwaitingFuturePosition(){return this._wanted!==null}};function Ur(n,e,t){let r=e(n.getReference(),t);return{getCurrentTime(){return n.getCurrentTime()},getReadyState(){return n.getReadyState()},getPlaybackRate(){return n.getPlaybackRate()},getIsPaused(){return n.getIsPaused()},getReference(){return r},listen(i,a){t.isCancelled()||a.clearSignal.isCancelled()||r.onUpdate(i,{clearSignal:a.clearSignal,emitCurrentValue:a.includeLastObservation})},deriveReadOnlyObserver(i){return Ur(this,i,t)}}}var An=class{constructor(e,t,r,i){this._src=e,this._contentId=t,this._messageSender=r,this._cancelSignal=i}getCurrentTime(){}getReadyState(){}getIsPaused(){}getReference(){return this._src}setPlaybackRate(e){this._messageSender({type:\"update-playback-rate\",contentId:this._contentId,value:e})}getPlaybackRate(){}listen(e,t){this._cancelSignal.isCancelled()||t.clearSignal.isCancelled()||this._src.onUpdate(e,{clearSignal:t.clearSignal,emitCurrentValue:t.includeLastObservation})}deriveReadOnlyObserver(e){return Ur(this,e,this._cancelSignal)}};function Ge(n,e){if(e.length===0)return n;let t,r=\"\",i=n.indexOf(\"#\"),a=n;i>=0&&(r=n.substring(i),a=n.substring(0,i));let o=a.indexOf(\"?\");o===-1?t=\"?\":o+1===a.length?t=\"\":t=\"&\";let s=a+t;for(let u=0;u<e.length;u++){let d=e[u];d[1]===null?s+=d[0]:s+=`${d[0]}=${d[1]}`,u<e.length-1&&(s+=\"&\")}return r.length>0&&(s+=r),s}function oa(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-L(),u=!1,m={reject:b=>{var R,T;if(u||i.isCancelled())return;u=!0,i.deregister(p);let h=b,y=(R=h==null?void 0:h.message)!=null?R:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",E=new Ye(y,(T=h==null?void 0:h.canRetry)!=null?T:!1,h==null?void 0:h.xhr);o(E)},resolve:b=>{if(u||i.isCancelled())return;u=!0,i.deregister(p);let h=b.receivingTime!==void 0?b.receivingTime-s:void 0,y=b.sendingTime!==void 0?b.sendingTime-s:void 0;a({responseData:b.data,size:b.size,requestDuration:b.duration,url:b.url,receivedTime:h,sendingTime:y})},fallback:()=>{u||i.isCancelled()||(u=!0,i.deregister(p),e(t,r,i).then(a,o))}},g=n({url:t,timeout:r.timeout,cmcdPayload:r.cmcdPayload},m);i.register(p);function p(b){u||(u=!0,typeof g==\"function\"&&g(),o(b))}})}function Il(n){return function(t,r,i){var s,u;if(t===void 0)throw new Error(\"Cannot perform HTTP(s) request. URL not known\");let a=((s=r.cmcdPayload)==null?void 0:s.type)===\"query\"?Ge(t,r.cmcdPayload.value):t,o=((u=r.cmcdPayload)==null?void 0:u.type)===\"headers\"?r.cmcdPayload.value:void 0;switch(n){case\"arraybuffer\":return be({url:a,headers:o,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return be({url:a,headers:o,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return be({url:a,headers:o,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:De(n)}}}function sa({customManifestLoader:n},e,t){let r=Il(e),i=typeof n!=\"function\"?r:oa(n,r);return t!==null?t(i):i}function ua(n,e){if(e){if($e(n,1718909296)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if($e(n,1836019574)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if($e(n,1836019558)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if($e(n,1835295092)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function Ke(n,e){if(n===\"audio\"||n===\"video\")return e===\"video/mp4\"||e===\"audio/mp4\"?\"mp4\":e===\"video/webm\"||e===\"audio/webm\"?\"webm\":void 0;if(n===\"text\")return e===\"application/mp4\"?\"mp4\":void 0}function Lr(n){return(e,t,r,i,a)=>{return new Promise((s,u)=>{let d=new F,f=d.linkToSignal(i);d.signal.register(u),n(e,t,r,d.signal,oe(ee({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(g){l(),d.cancel(),u(g)}}})).then(m=>{if(l(),!d.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(g){u(g);return}s(m)}},m=>{l(),u(m)});function l(){d.signal.deregister(u),f()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||Ke(t.type,t.mimeType)!==\"mp4\"||ua(new Uint8Array(s),t.segment.isInit)}}}function vs(n){return async(e,t,r)=>{let i=await n(e,t,r);return a(i.responseData),i;function a(o){if(typeof o==\"string\"){let s=o.length-1,u=[\"</\",\"MPD\",\">\"];for(let d=u.length-1;d>=0;d--){let f=u[d];for(;bl(o[s]);)s--;for(let l=f.length-1;l>=0;l--){if(o[s]!==f[l])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(o instanceof ArrayBuffer){let s=o.byteLength-1,u=new DataView(o),d=[[60,47],[77,80,68],[62]];for(let f=d.length-1;f>=0;f--){let l=d[f];for(;Sl(u.getUint8(s));)s--;for(let m=l.length-1;m>=0;m--){if(u.getUint8(s)!==l[m])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(!P(ue.Document)&&o instanceof ue.Document&&o.documentElement.nodeName!==\"MPD\")throw new Ee(\"INTEGRITY_ERROR\",\"MPD does not end with </MPD>\")}}}function bl(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function Sl(n){return n===32||n===9||n===13||n===10}function da(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,u){var E;let{responseData:d}=i,f=a.externalClockOffset,l=(E=i.url)!=null?E:a.originalUrl,m=t!=null?t:f,p={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:m},b=Oe.dashParsers;if(b.wasm===null||b.wasm.status===\"uninitialized\"||b.wasm.status===\"failure\")return c.debug(\"DASH: WASM MPD Parser not initialized. Running JS one.\"),h();{let R=Rl(d);if(!Pl(R))return c.info(\"DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),h();if(b.wasm.status===\"initialized\"){c.debug(\"DASH: Running WASM MPD Parser.\");let T=b.wasm.runWasmParser(R,p);return y(T)}else return c.debug(\"DASH: Awaiting WASM initialization before parsing the MPD.\"),b.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(b.wasm===null||b.wasm.status!==\"initialized\")return c.warn(\"DASH: WASM MPD parser initialization failed. Running JS parser instead\"),h();c.debug(\"DASH: Running WASM MPD Parser.\");let v=b.wasm.runWasmParser(R,p);return y(v)})}function h(){if(b.fastJs!==null){let R=El(d),T=b.fastJs(R,p);return y(T)}else if(b.native!==null){let R=_l(d),T=b.native(R,p);return y(T)}else throw new Error(\"No MPD parser is imported\")}function y(R){if(R.type===\"done\"){if(R.value.warnings.length>0&&o(R.value.warnings),s.isCancelled())return Promise.reject(s.cancellationError);let _=[];return{manifest:new Ut(R.value.parsed,n,_),url:l,warnings:_}}let{value:T}=R,v=T.urls.map(_=>u(()=>{let M=U.getCurrent().DEFAULT_REQUEST_TIMEOUT,A=U.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return T.format===\"string\"?be({url:_,responseType:\"text\",timeout:M,connectionTimeout:A,cancelSignal:s}):be({url:_,responseType:\"arraybuffer\",timeout:M,connectionTimeout:A,cancelSignal:s})}).then(M=>{if(T.format===\"string\"){if(typeof M.responseData!=\"string\")throw new Error(\"External DASH resources should have been a string\");return G(M,{responseData:{success:!0,data:M.responseData}})}else{if(!(M.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return G(M,{responseData:{success:!0,data:M.responseData}})}},M=>{let A=ge(M,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return G({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:A}})}));return Promise.all(v).then(_=>T.format===\"string\"?(yl(_),y(T.continue(_))):(Tl(_),y(T.continue(_))))}}}function yl(n){I.CURRENT_ENV!==I.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&typeof t.data==\"string\")&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function Tl(n){I.CURRENT_ENV!==I.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&t.data instanceof ArrayBuffer)&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function El(n){if(n instanceof ArrayBuffer)return Ne(new Uint8Array(n));if(typeof n==\"string\")return n;if(n instanceof Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function _l(n){if(n instanceof ArrayBuffer)return new DOMParser().parseFromString(Ne(new Uint8Array(n)),\"text/xml\");if(typeof n==\"string\")return new DOMParser().parseFromString(n,\"text/xml\");if(n instanceof Document)return n;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Rl(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return un(n).buffer;if(n instanceof Document)return un(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Pl(n){let e=new DataView(n);return e.getUint16(0)===61371&&e.getUint8(2)===191?!0:!(e.getUint16(0)===65279||e.getUint16(0)===65534)}function Fe([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function kt(n,e){return n===null?null:e.url===null?n.baseUrl:En(n.baseUrl,e.url)}function kn(n,e,t,r,i){var d,f;let a=n;((d=t.cmcdPayload)==null?void 0:d.type)===\"query\"&&(a=Ge(a,t.cmcdPayload.value));let o=((f=t.cmcdPayload)==null?void 0:f.type)===\"headers\"?t.cmcdPayload.value:void 0;if(e.range===void 0)return be({url:a,responseType:\"arraybuffer\",headers:o,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));if(e.indexRange===void 0)return be({url:a,headers:oe(ee({},o),{Range:Fe(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));if(e.range[1]+1===e.indexRange[0])return be({url:a,headers:oe(ee({},o),{Range:Fe([e.range[0],e.indexRange[1]])}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));let s=be({url:a,headers:oe(ee({},o),{Range:Fe(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),u=be({url:a,headers:oe(ee({},o),{Range:Fe(e.indexRange)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([s,u]).then(([l,m])=>{let g=Et(new Uint8Array(l.responseData),new Uint8Array(m.responseData)),p=Math.min(l.sendingTime,m.sendingTime),b=Math.max(l.receivedTime,m.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:a,responseData:g,size:l.size+m.size,requestDuration:b-p,sendingTime:p,receivedTime:b}}})}async function xn(n,e,t,r){let i=null;function a(s){let u=new Uint8Array(s.chunk),d=i!==null?Et(i,u):u,f=yr(d),l=f[0];i=f[1],!(l!==null&&(l.forEach(m=>{t.onNewChunk(m)}),r.isCancelled()))&&(t.onProgress({duration:s.duration,size:s.size,totalSize:s.totalSize}),r.isCancelled())}return{resultType:\"chunk-complete\",resultData:await mr({url:n,headers:e.headers,onData:a,timeout:e.timeout,connectionTimeout:e.connectionTimeout,cancelSignal:r})}}async function Cs(n,e,t,r,i,a){var m,g;if(e.segment.isInit)return kn(n,e.segment,r,a,i);let o=((m=r.cmcdPayload)==null?void 0:m.type)===\"query\"?Ge(n,r.cmcdPayload.value):n,s=((g=r.cmcdPayload)==null?void 0:g.type)===\"headers\"?r.cmcdPayload.value:void 0,{segment:u}=e,d;u.range!==void 0?d=oe(ee({},s),{Range:Fe(u.range)}):s!==void 0&&(d=s);let f=Ke(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(tn())return xn(o,{headers:d,timeout:r.timeout,connectionTimeout:r.connectionTimeout},i,a);et(\"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{resultType:\"segment-loaded\",resultData:await be({url:o,responseType:\"arraybuffer\",headers:d,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress})}}function la({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:Lr(r);function r(i,a,o,s,u){let d=kt(i,a.segment);return d===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?Cs(d,a,n,o,u,s):new Promise((f,l)=>{let m=!1,y={reject:_=>{var C,O;if(m||s.isCancelled())return;m=!0,s.deregister(v);let M=_,A=(C=M==null?void 0:M.message)!=null?C:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",k=new Ye(A,(O=M==null?void 0:M.canRetry)!=null?O:!1,M==null?void 0:M.xhr);l(k)},resolve:_=>{m||s.isCancelled()||(m=!0,s.deregister(v),f({resultType:\"segment-loaded\",resultData:{responseData:_.data,size:_.size,requestDuration:_.duration}}))},progress:_=>{m||s.isCancelled()||u.onProgress({duration:_.duration,size:_.size,totalSize:_.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(v),Cs(d,a,n,o,u,s).then(f,l))}},E;a.segment.range!==void 0&&(E=[a.segment.range],a.segment.indexRange!==void 0&&E.push(a.segment.indexRange));let R={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:E,trackType:a.type,url:d,cmcdPayload:o.cmcdPayload},T=e(R,y);s.register(v);function v(_){m||(m=!0,typeof T==\"function\"&&T(),l(_))}})}}var ma=408125543,As=357149030,vl=2807729,Cl=17545,Al=475249515,kl=187,xl=179,Ml=183,Ol=241;function It(n,e,t,[r,i]){let a=r;for(;a<i;){let o=Dl(t,a);if(o===null)return null;let{value:s,length:u}=o,d=a+u,f=Nl(t,d);if(f===null)return null;let{length:l,value:m}=f,g=d+l,p=g+m;if(s===n)return[g,p];if(e.length>0){for(let b=0;b<e.length;b++)if(s===e[b]){let h=e.slice(b+1,e.length);return It(n,h,t,[g,p])}}a=p}return null}function Fr(n,e){let t=It(vl,[ma,As],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/fa(n,t[0],r)}function wl(n,e){let t=It(Cl,[ma,As],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?Bl(n,t[0]):r===8?Ul(n,t[0]):null}function ca(n,e){let t=It(ma,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=Fr(n,r);if(a===null)return null;let o=wl(n,r);if(o===null)return null;let s=It(Al,[],n,[r,i]);if(s===null)return null;let u=[],d=s[0];for(;d<s[1];){let l=It(kl,[],n,[d,s[1]]);if(l===null)break;let m=It(xl,[],n,[l[0],l[1]]);if(m===null)return null;let g=fa(n,m[0],m[1]-m[0]),p=It(Ol,[Ml],n,[l[0],l[1]]);if(p===null)return null;let b=fa(n,p[0],p[1]-p[0])+r;u.push({time:g,rangeStart:b}),d=l[1]}let f=[];for(let l=0;l<u.length;l++){let m=u[l];l===u.length-1?f.push({time:m.time,timescale:a,duration:l===0?o:o-m.time,range:[m.rangeStart,1/0]}):f.push({time:m.time,timescale:a,duration:u[l+1].time-m.time,range:[m.rangeStart,u[l+1].rangeStart-1]})}return f}function ks(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function Dl(n,e){let t=ks(n,e);if(t===void 0)return c.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm: impossible length\"),null;let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function Nl(n,e){let t=ks(n,e);if(t===void 0)return c.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm: impossible length\"),null;let r=(n[e]&(1<<8-t)-1)*Math.pow(2,(t-1)*8);for(let i=1;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function Bl(n,e){return new DataView(n.buffer).getFloat32(e)}function Ul(n,e){return new DataView(n.buffer).getFloat64(e)}function fa(n,e,t){let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return r}function Mn(n,e,t,r){let i=Ei(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=_i(n);if(a<0&&(o!==void 0&&(o+=a),a=0),e||!t.complete)return o===void 0&&c.warn(\"DASH: Chunked segments should indicate a duration through their trun boxes\"),{time:a/r,duration:o!==void 0?o/r:void 0};let s,u=t.duration*r,d=Math.min(r*.9,u/4);return o!==void 0&&Math.abs(o-u)<=d&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function Ll(n,e){if(n.length<=0)return!1;let t=n.length;for(let r=0;r<t;r++){let i=n[r],a=e,{messageData:o}=i,s=Ne(o),u=Date.parse(s);if(a===void 0||u===void 0||isNaN(u)||u>=a)return!0}return!1}function pa(n,e){if(n.length===0)return;let{manifestRefreshEventsFromEMSGs:t,EMSGs:r}=n.reduce((o,s)=>(s.schemeIdUri===\"urn:mpeg:dash:event:2012\"&&s.value===\"1\"?(o.manifestRefreshEventsFromEMSGs===void 0&&(o.manifestRefreshEventsFromEMSGs=[]),o.manifestRefreshEventsFromEMSGs.push(s)):(o.EMSGs===void 0&&(o.EMSGs=[]),o.EMSGs.push(s)),o),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),i=r==null?void 0:r.map(o=>({type:\"emsg\",value:o})),a=e===void 0||t===void 0?!1:Ll(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function ga({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var R,T;let{segment:a,periodStart:o,periodEnd:s}=r,{data:u,isChunked:d}=t,f=[o,s];if(u===null)return a.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:f};let l=u instanceof Uint8Array?u:new Uint8Array(u),m=Ke(r.type,r.mimeType),g=m===\"mp4\"||m===void 0,p=[];if(g){let v=Tr(l),_;a.isInit&&(_=(R=Fo(l))!=null?R:void 0),(v.length>0||_!==void 0)&&p.push({initDataType:\"cenc\",keyId:_,initData:v})}if(!a.isInit){let v=g?Mn(l,d,a,i):null,_=(T=a.timestampOffset)!=null?T:0;if(g){let M=Lo(l);if(M!==void 0){let A=M.filter(C=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(C)),k=pa(A,r.manifestPublishTime);if(k!==void 0){let{needsManifestRefresh:C,inbandEvents:O}=k;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:v,chunkOffset:_,appendWindow:f,inbandEvents:O,protectionData:p,needsManifestRefresh:C}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:v,chunkOffset:_,protectionData:p,appendWindow:f}}let{indexRange:b}=a,h;if(m===\"webm\")h=ca(l,0);else if(g&&(h=ln(l,Array.isArray(b)?b[0]:0),n===!0&&h!==null&&h.length>0)){let v=h[h.length-1];Array.isArray(v.range)&&(v.range[1]=1/0)}let y;g?y=fn(l):m===\"webm\"&&(y=Fr(l,0));let E=P(y)?void 0:y;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:p,initTimescale:E,segmentList:h!=null?h:void 0}}}function ha({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:Lr(t);async function t(r,i,a,o,s){var h,y;let{segment:u}=i,d=kt(r,u);if(d===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(u.isInit)return kn(d,u,a,o,s);let f=((h=a.cmcdPayload)==null?void 0:h.type)===\"query\"?Ge(d,a.cmcdPayload.value):d,l=((y=a.cmcdPayload)==null?void 0:y.type)===\"headers\"?a.cmcdPayload.value:void 0,m;u.range!==void 0?m=oe(ee({},l),{Range:Fe(u.range)}):l!==void 0&&(m=l);let g=Ke(i.type,i.mimeType),p=g===\"mp4\"||g===void 0;if(n&&p){if(tn())return xn(f,{headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout},s,o);et(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}let b;return p?b=await be({url:f,responseType:\"arraybuffer\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}):b=await be({url:f,responseType:\"text\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}),{resultType:\"segment-loaded\",resultData:b}}}function Fl(n){let e=yi(n);return e===null?\"\":Ne(e)}function zl(n){if(n===void 0)throw new Error(\"Cannot parse subtitles: unknown format\");switch(n.toLowerCase()){case\"stpp\":case\"stpp.ttml\":case\"stpp.ttml.im1t\":return\"ttml\";case\"wvtt\":return\"vtt\"}throw new Error(`The codec used for the subtitles \"${n}\" is not managed yet.`)}function Wl(n,e){switch(e){case\"application/ttml+xml\":return\"ttml\";case\"application/x-sami\":case\"application/smil\":return\"sami\";case\"text/vtt\":return\"vtt\"}if(n!==void 0&&n.toLowerCase()===\"srt\")return\"srt\";throw new Error(`could not find a text-track parser for the type ${e!=null?e:\"\"}`)}function xs({segment:n,language:e,codecs:t},r,i,a){if(n.isInit)return null;let o,s;i===null?a?(o=n.time,s=n.end):c.warn(\"Transport: Unavailable time data for current text track.\"):(o=i.time,i.duration!==void 0?s=o+i.duration:!a&&n.complete&&(s=o+n.duration));let u=zl(t);return{data:Fl(r),type:u,language:e,start:o,end:s}}function Ms(n,e,t){let{segment:r}=n;if(r.isInit)return null;let i,a;t?c.warn(\"Transport: Unavailable time data for current text track.\"):(i=r.time,r.complete&&(a=r.time+r.duration));let o=Wl(n.codecs,n.mimeType);return{data:e,type:o,language:n.language,start:i,end:a}}function ql(n,e,t,r,i){var m;let{segment:a}=t,{isInit:o,indexRange:s}=a,u;if(typeof n==\"string\"?u=un(n):n instanceof Uint8Array?u=n:u=new Uint8Array(n),o){let g=ln(u,Array.isArray(s)?s[0]:0);if(i===!0&&g!==null&&g.length>0){let b=g[g.length-1];Array.isArray(b.range)&&(b.range[1]=1/0)}let p=fn(u);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:p,segmentList:g!=null?g:void 0}}let d=Mn(u,e,a,r),f=xs(t,u,d,e),l=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:f,chunkSize:u.length,chunkInfos:d,chunkOffset:l,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Vl(n,e,t){let{periodStart:r,periodEnd:i,segment:a}=t,{timestampOffset:o=0}=a;if(a.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let s,u;if(typeof n!=\"string\"){let f=n instanceof Uint8Array?n:new Uint8Array(n);s=Ne(f),u=f.length}else s=n;return{segmentType:\"media\",chunkData:Ms(t,s,e),chunkSize:u,chunkInfos:null,chunkOffset:o,protectionData:[],appendWindow:[r,i]}}function Ia({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var l;let{periodStart:a,periodEnd:o,segment:s}=r,{data:u,isChunked:d}=t;if(u===null)return s.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:(l=s.timestampOffset)!=null?l:0,protectionData:[],appendWindow:[a,o]};let f=Ke(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?ql(u,d,r,i,n):Vl(u,d,r)}}async function Os(n,e,t,r){var u,d;let i=kt(n,e);if(i===null)return Promise.reject(new Error(\"Cannot load thumbnail: no URL\"));let a=((u=t.cmcdPayload)==null?void 0:u.type)===\"query\"?Ge(i,t.cmcdPayload.value):i,o=((d=t.cmcdPayload)==null?void 0:d.type)===\"headers\"?t.cmcdPayload.value:void 0,s;return e.range!==void 0?s=oe(ee({},o),{Range:Fe(e.range)}):o!==void 0&&(s=o),nn({url:a,responseType:\"arraybuffer\",headers:s,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r})}function ws(n,e){var d;let{thumbnailTrack:t,thumbnail:r}=e,i=t.height/t.verticalTiles,a=t.width/t.horizontalTiles,o=[],s=(d=t.tileDuration)!=null?d:(r.end-r.time)/(t.horizontalTiles*t.verticalTiles),u=r.time;for(let f=0;f<t.verticalTiles;f++)for(let l=0;l<t.horizontalTiles;l++)o.push({start:u,end:u+s,offsetX:Math.round(l*a),offsetY:Math.round(f*i),height:Math.floor(i),width:Math.floor(a)}),u+=s;return{mimeType:t.mimeType,data:n,thumbnails:o}}function Ds(n){let e=sa({customManifestLoader:n.manifestLoader},Hl()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?vs:null),t=da(n),r=la(n),i=ga(n),a=ha(n),o=Ia(n);return{transportName:\"dash\",manifest:{loadManifest:e,parseManifest:t},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:o},thumbnails:{loadThumbnail:Os,parseThumbnail:ws}}}function Hl(){return Oe.dashParsers.wasm!==null&&(Oe.dashParsers.wasm.status===\"initialized\"||Oe.dashParsers.wasm.status===\"initializing\")}var Ns=Ds;var xt=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var Mt=class{constructor(e){this._array=[],this._sortingFn=e}add(...e){e.sort(this._sortingFn);let t=0;for(let r=0;r<e.length;r++){let i=e[r],a=!1;for(;!a&&t<this._array.length;)this._sortingFn(i,this._array[t])<0?(this._array.splice(t,0,i),a=!0):t++;a||this._array.push(i)}}length(){return this._array.length}get(e){if(e<0||e>=this._array.length)throw new Error(\"Invalid index.\");return this._array[e]}toArray(){return this._array.slice()}findFirst(e){return j(this._array,e)}has(e){return Ie(this._array,e)}removeElement(e){let t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t}head(){return this._array[0]}last(){return this._array[this._array.length-1]}shift(){return this._array.shift()}pop(){return this._array.pop()}};var On=class{constructor(e){this._weakMap=new WeakMap,this._fn=e}get(e){let t=this._weakMap.get(e);if(t===void 0){let r=this._fn(e);return this._weakMap.set(e,r),r}else return t}destroy(e){this._weakMap.delete(e)}};var Gl=.016666666666666666;function Bs(n,e){return Math.abs(n-e)<Gl}function Ls(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function Kl(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function jl(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(zs(t,r)){let i=Ls(t,r);n.splice(--e,2,i)}}return n}function ba(n,e){return n.end<=e.start}function Us({start:n,end:e},t){return n<=t&&t<e}function Fs(n,e){return Us(n,e.start)||n.start<e.end&&e.end<n.end||Us(e,n.start)}function zs(n,e){return Bs(e.start,n.end)||Bs(e.end,n.start)}function Sa(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function Yl(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t].start;if(e>=r){let i=n[t].end;if(e<i)return n[t]}}return null}function Ws(n,e){let t=null,r=[];for(let i=0;i<n.length;i++){let a=n[i].start,o=n[i].end;e<a||e>=o?r.push({start:a,end:o}):t={start:a,end:o}}return{outerRanges:r,innerRange:t}}function zr(n,e){let t=Yl(n,e);return t!==null?t.end-e:1/0}function Vt(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=Fs(t,i),o=zs(t,i);if(a||o)t=Ls(t,i),n.splice(r--,1);else if(r===0){if(ba(t,n[0]))break}else if(ba(n[r-1],t)&&ba(t,i))break}return n.splice(r,0,t),jl(Kl(n))}function Ql(n,e){let t=[];for(let r=0;r<e.length;r++)Fs(n,e[r])&&t.push(e[r]);return t}function Wr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=Ql(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let u=0;u<a.length;u++)a[u].start>s&&t.push({start:s,end:a[u].start}),s=a[u].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function qr({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(u=>{a=u.position.getWanted(),o=u.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&$l(n,a,o,t.getValue(),r.getValue(),i).catch(u=>{if(i.isCancelled()&&F.isCancellationError(u))return;let d=u instanceof Error?u.message:\"Unknown error\";c.error(\"Could not run BufferGarbageCollector:\",d)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function $l(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:u}=Ws(t,e),d=()=>{if(isFinite(r)){for(let l of u)e-r>=l.end?o.push(l):e>=l.end&&e-r>l.start&&e-r<l.end&&o.push({start:l.start,end:e-r});P(s)||e-r>s.start&&o.push({start:s.start,end:e-r})}},f=()=>{if(isFinite(i)){for(let l of u)e+i<=l.start?o.push(l):e<=l.start&&e+i<l.end&&e+i>l.start&&o.push({start:e+i,end:l.end});P(s)||e+i<s.end&&o.push({start:e+i,end:s.end})}};d(),f();for(let l of o)if(l.start<l.end){if(c.debug(\"GC: cleaning range from SegmentSink\",l.start,l.end),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(l.start,l.end)}}var wn=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=L();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>Je(t.context,e))}_cleanHistory(e){let t=e-this._lifetime,r=0;for(let i of this._history)if(i.date<t)r++;else break;if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){let i=this._history.length-this._maxHistoryLength;this._history=this._history.splice(i)}}};var Dn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=U.getCurrent();this._inventory=[],this._bufferedHistory=new wn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var u,d,f,l,m,g,p;let t=this._inventory,r=0,i=t[0],{MINIMUM_SEGMENT_SIZE:a}=U.getCurrent(),o=i==null?void 0:i.infos.adaptation.type;if(c.hasLevel(\"DEBUG\")){let b=e.map(h=>`${h.start}-${h.end}`).join(\",\");c.debug(`SI: synchronizing ${o!=null?o:\"unknown\"} buffered ranges:`,b)}let s=e.length;for(let b=0;b<s;b++){if(i===void 0)return;let h=e[b].start,y=e[b].end;if(y-h<a){c.warn(\"SI: skipped range when synchronizing because it was too small\",o,h,y);continue}let E=r;for(;i!==void 0&&((u=i.bufferedEnd)!=null?u:i.end)-h<a;)i=t[++r];let R=null,T=r-E;if(T>0){let _=t[E+T-1];R={end:(d=_.bufferedEnd)!=null?d:_.end,precizeEnd:_.precizeEnd},c.debug(`SI: ${T} segments GCed.`,o);let M=t.splice(E,T);for(let A of M)A.bufferedStart===void 0&&A.bufferedEnd===void 0&&A.status!==2&&this._bufferedHistory.addBufferedSegment(A.infos,null);r=E}if(i===void 0)return;if(y-((f=i.bufferedStart)!=null?f:i.start)>=a){if(Xl(i,h,R,o),r===t.length-1){Vs(i,y,o);return}i=t[++r];let _=(l=i.bufferedStart)!=null?l:i.start,M=(m=i.bufferedEnd)!=null?m:i.end,A=b<s-1?e[b+1].start:void 0;for(;i!==void 0&&!(y<_||y-_<a&&M-y>=a||A!==void 0&&y-_<M-A);){let k=t[r-1];k.bufferedEnd===void 0&&(i.precizeStart?k.bufferedEnd=i.start:k.infos.segment.complete?k.bufferedEnd=k.end:k.bufferedEnd=i.start,c.debug(\"SI: calculating buffered end of contiguous segment\",o,k.bufferedEnd,k.end)),i.bufferedStart=k.bufferedEnd,i=t[++r],i!==void 0&&(_=(g=i.bufferedStart)!=null?g:i.start,M=(p=i.bufferedEnd)!=null?p:i.end)}}let v=t[r-1];v!==void 0&&Vs(v,y,o)}if(!P(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:b}=U.getCurrent(),h=L();for(let y=r;y<t.length;y++){let E=t[y];h-E.insertionTs>=b&&(c.debug(\"SI: A segment at the end has been completely GCed\",o,`${E.start}-${E.end}`),E.bufferedStart===void 0&&E.bufferedEnd===void 0&&E.status!==2&&this._bufferedHistory.addBufferedSegment(E.infos,null),t.splice(y,1),y--)}}o!==void 0&&c.hasLevel(\"DEBUG\")&&c.debug(`SI: current ${o} inventory timeline:\n`+Zl(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},u,d){if(i.isInit)return;let f=t.type;if(o>=s){c.warn(\"SI: Invalid chunked inserted: starts before it ends\",f,o,s);return}let l=this._inventory,m={status:u?0:2,insertionTs:d,chunkSize:a,splitted:!1,start:o,end:s,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:i,period:e,adaptation:t,representation:r}};for(let p=l.length-1;p>=0;p--){let b=l[p];if(b.start<=o)if(b.end<=o){for(c.debug(\"SI: Pushing segment strictly after previous one.\",f,o,b.end),this._inventory.splice(p+1,0,m),p+=2;p<l.length&&l[p].start<m.end;){if(l[p].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",f,m.end,l[p].start),l[p].start=m.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else if(b.start===o)if(b.end<=s){for(c.debug(\"SI: Segment pushed replace another one\",f,o,s,b.end),this._inventory.splice(p,1,m),p+=1;p<l.length&&l[p].start<m.end;){if(l[p].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",f,m.end,l[p].start),l[p].start=m.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else{c.debug(\"SI: Segment pushed ends before another with the same start\",f,o,s,b.end),l.splice(p,0,m),b.start=m.end,b.bufferedStart=void 0,b.precizeStart=b.precizeStart&&m.precizeEnd;return}else if(b.end<=m.end){for(c.debug(\"SI: Segment pushed updates end of previous one\",f,o,s,b.start,b.end),this._inventory.splice(p+1,0,m),b.end=m.start,b.bufferedEnd=void 0,b.precizeEnd=b.precizeEnd&&m.precizeStart,p+=2;p<l.length&&l[p].start<m.end;){if(l[p].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",f,m.end,l[p].start),l[p].start=m.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else{c.warn(\"SI: Segment pushed is contained in a previous one\",f,o,s,b.start,b.end);let h={status:b.status,insertionTs:b.insertionTs,chunkSize:b.chunkSize,splitted:!0,start:m.end,end:b.end,precizeStart:b.precizeStart&&b.precizeEnd&&m.precizeEnd,precizeEnd:b.precizeEnd,bufferedStart:void 0,bufferedEnd:b.end,infos:b.infos};b.end=m.start,b.splitted=!0,b.bufferedEnd=void 0,b.precizeEnd=b.precizeEnd&&m.precizeStart,l.splice(p+1,0,m),l.splice(p+2,0,h);return}}let g=this._inventory[0];if(g===void 0){c.debug(\"SI: first segment pushed\",f,o,s),this._inventory.push(m);return}if(g.start>=s)c.debug(\"SI: Segment pushed comes before all previous ones\",f,o,s,g.start),this._inventory.splice(0,0,m);else if(g.end<=s){for(c.debug(\"SI: Segment pushed starts before and completely recovers the previous first one\",f,o,s,g.start,g.end),this._inventory.splice(0,1,m);l.length>1&&l[1].start<m.end;){if(l[1].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",f,m.end,l[1].start),l[1].start=m.end,l[1].bufferedStart=void 0,l[1].precizeStart=m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[1].start,l[1].end),l.splice(1,1)}return}else{c.debug(\"SI: Segment pushed start of the next one\",f,o,s,g.start,g.end),g.start=s,g.bufferedStart=void 0,g.precizeStart=m.precizeEnd,this._inventory.splice(0,0,m);return}}completeSegment(e){if(e.segment.isInit)return;let t=this._inventory,r=[];for(let i=0;i<t.length;i++)if(Je(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(c.warn(\"SI: Completed Segment is splitted.\",e.segment.id,e.segment.time,e.segment.end),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&Je(t[i].infos,e);){let m=t[i].chunkSize;s!==void 0&&m!==void 0&&(s+=m),i++}let u=i-1,d=u-o,f=t[u].end,l=t[u].bufferedEnd;d>0&&(this._inventory.splice(o+1,d),i-=d),this._inventory[o].status===0&&(this._inventory[o].status=1),this._inventory[o].chunkSize=s,this._inventory[o].end=f,this._inventory[o].bufferedEnd=l,this._inventory[o].splitted=a,r.push(this._inventory[o])}if(r.length===0)c.warn(\"SI: Completed Segment not found\",e.segment.id,e.segment.time);else for(let i of r)i.bufferedStart!==void 0&&i.bufferedEnd!==void 0?i.status!==2&&this._bufferedHistory.addBufferedSegment(i.infos,{start:i.bufferedStart,end:i.bufferedEnd}):c.debug(\"SI: buffered range not known after sync. Skipping history.\",i.start,i.end)}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function ya(n){if(n.bufferedStart===void 0||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=U.getCurrent();return Math.abs(e-n.bufferedStart)<=i&&(n.bufferedEnd===void 0||n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3))}function qs(n){if(n.bufferedEnd===void 0||!n.infos.segment.complete||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=U.getCurrent();return Math.abs(t-n.bufferedEnd)<=i&&n.bufferedStart!==void 0&&n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3)}function Xl(n,e,t,r){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MISSING_DATA_TRIGGER_SYNC_DELAY:a,SEGMENT_SYNCHRONIZATION_DELAY:o}=U.getCurrent();if(n.bufferedStart!==void 0)n.bufferedStart<e&&(c.debug(\"SI: Segment partially GCed at the start\",r,n.bufferedStart,e),n.bufferedStart=e),!n.precizeStart&&ya(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)c.debug(\"SI: buffered start is precize start\",r,n.start),n.bufferedStart=n.start;else if(t!==null&&t.end>e&&(t.precizeEnd||n.start-t.end<=i))c.debug(\"SI: buffered start is end of previous segment\",r,e,n.start,t.end),n.bufferedStart=t.end,ya(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=L();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}c.debug(\"SI: found true buffered start\",r,e,n.start),n.bufferedStart=e,ya(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)c.debug(\"SI: range start too far from expected start\",r,e,n.start),n.bufferedStart=n.start;else{let s=L();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}c.debug(\"SI: Segment appears immediately garbage collected at the start\",r,e,n.start),n.bufferedStart=e}}function Vs(n,e,t){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:r,MISSING_DATA_TRIGGER_SYNC_DELAY:i,SEGMENT_SYNCHRONIZATION_DELAY:a}=U.getCurrent();if(n.bufferedEnd!==void 0)n.bufferedEnd>e&&(c.debug(\"SI: Segment partially GCed at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&qs(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)c.debug(\"SI: buffered end is precize end\",t,n.end),n.bufferedEnd=n.end;else if(e-n.end<=r||!n.infos.segment.complete){let o=L();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}c.debug(\"SI: found true buffered end\",t,e,n.end),n.bufferedEnd=e,qs(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)c.debug(\"SI: range end too far from expected end\",t,e,n.end),n.bufferedEnd=n.end;else{let o=L();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}c.debug(\"SI: Segment appears immediately garbage collected at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e}}function Zl(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(u){let d=String.fromCharCode(r.length+65);return r.push({letter:d,periodId:u.period.id,representationId:u.representation.id,bitrate:u.representation.bitrate}),d}let s=\"\";for(let u of n)if(u.bufferedStart!==void 0&&u.bufferedEnd!==void 0){let d=u.infos.period.id,f=u.infos.representation.id,l=t[d],m;if(l===void 0)m=o(u.infos),t[d]={[f]:m};else{let g=l[f];g===void 0?(m=o(u.infos),l[f]=m):m=g}i===null?s+=`${u.bufferedStart.toFixed(2)}|${m}|`:a===m?i.bufferedEnd+e<u.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${u.bufferedStart.toFixed(2)}|${m}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${u.bufferedStart.toFixed(2)}|${m}|`,i=u,a=m}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(u=>{var d;s+=`\n[${u.letter}] P: ${u.periodId} || R: ${u.representationId}(${(d=u.bitrate)!=null?d:\"unknown bitrate\"})`}),s}function Ht(n,e){for(let t=0;t<n.length;t++)if(n[t].infos.period.start>=e.start)return t>0?n[t-1]:null;return n.length>0?n[n.length-1]:null}function Gt(n,e){for(let t of n)if(t.infos.period.start>e.start)return t;return null}var Hs=Dn;var Kt=class{constructor(){this._segmentInventory=new Hs}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var Nn=class extends Kt{constructor(e,t,r){super(),c.info(\"AVSB: calling `mediaSource.addSourceBuffer`\",t);let i=r.addSourceBuffer(e,t);this.bufferType=e,this._sourceBuffer=i,this._lastInitSegmentUniqueId=null,this.codec=t,this._initSegmentsMap=new Map,this._pendingOperations=[]}declareInitSegment(e,t){Gs(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){Gs(e.data.chunk),c.debug(\"AVSB: receiving order to push data to the SourceBuffer\",this.bufferType,yt(e.inventoryInfos));let t=this._getActualDataToPush(e.data);t.length===0&&t.push(new Uint8Array);let r=Promise.all(t.map(o=>{let{codec:s,timestampOffset:u,appendWindow:d}=e.data;return c.debug(\"AVSB: pushing segment\",this.bufferType,yt(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:u,appendWindow:d})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,L()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){c.debug(\"AVSB: receiving order to remove data from the SourceBuffer\",this.bufferType,e,t);let r=this._sourceBuffer.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){try{c.debug(\"AVSB: Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose()}catch(e){c.debug(`AVSB: Failed to dispose a ${this.bufferType} SourceBufferInterface:`,e instanceof Error?e:\"\")}}_getActualDataToPush(e){let t=[];if(e.initSegmentUniqueId!==null&&!this._isLastInitSegment(e.initSegmentUniqueId)){let r=this._initSegmentsMap.get(e.initSegmentUniqueId);if(r===void 0)throw new Error(\"Invalid initialization segment uniqueId\");let i=new ArrayBuffer(r.byteLength),a=new Uint8Array(i);a.set(r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer)),r=a,t.push(r),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return e.chunk!==null&&t.push(e.chunk),t}_isLastInitSegment(e){return this._lastInitSegmentUniqueId===null?!1:this._lastInitSegmentUniqueId===e}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function Gs(n){if(I.CURRENT_ENV!==I.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var Hr=Nn;var Bn=class extends Kt{constructor(e){c.debug(\"HTSB: Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){c.warn(\"HTSB: Declaring initialization segment for Text SegmentSink\",e)}freeInitSegment(e){c.warn(\"HTSB: Freeing initialization segment for Text SegmentSink\",e)}async pushChunk(e){let{data:t}=e;ef(t.chunk);let r=this._sender.pushTextData(oe(ee({},t),{chunk:t.chunk}));this._addToOperationQueue(r,{type:0,value:e});let i=await r;return e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L()),this._segmentInventory.synchronizeBuffered(i),i}async removeBuffer(e,t){let r=this._sender.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){c.debug(\"HTSB: Disposing TextSegmentSink\"),this._sender.reset()}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function ef(n){if(I.CURRENT_ENV!==I.PRODUCTION&&(typeof n!=\"object\"||n===null||typeof n.data!=\"string\"||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\"))throw new Error(\"Invalid format given to a TextSegmentSink\")}I.CURRENT_ENV===I.DEV&&(tf=function(e){function t(r){}});var tf;var Ks=Bn;var nf=[\"audio\",\"video\",\"text\"],Un=class n{static isNative(e){return js(e)}constructor(e,t,r){this._mediaSource=e,this._textInterface=r,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}getBufferTypes(){let e=this.getNativeBufferTypes();return this._textInterface!==null&&e.push(\"text\"),e}getNativeBufferTypes(){return this._hasVideo?[\"video\",\"audio\"]:[\"audio\"]}getStatus(e){let t=this._initializedSegmentSinks[e];return t===void 0?{type:\"uninitialized\"}:t===null?{type:\"disabled\"}:{type:\"initialized\",value:t}}waitForUsableBuffers(e){return this._areNativeBuffersUsable()?Promise.resolve():Tt(e,t=>{let r=N,i=()=>{let a=this._onNativeBufferAddedOrDisabled.indexOf(r);a>=0&&this._onNativeBufferAddedOrDisabled.splice(a,1)};return r=()=>{this._areNativeBuffersUsable()&&(i(),t())},this._onNativeBufferAddedOrDisabled.push(r),i})}disableSegmentSink(e){let t=this._initializedSegmentSinks[e];if(t===null){c.warn(`SBS: The ${e} SegmentSink was already disabled.`);return}if(t!==void 0)throw new Error(\"Cannot disable an active SegmentSink.\");this._initializedSegmentSinks[e]=null,n.isNative(e)&&(this._onNativeBufferAddedOrDisabled.slice().forEach(r=>r()),ce(this._onNativeBufferAddedOrDisabled.length===0))}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(js(e)){if(!P(r))return r instanceof Hr&&r.codec!==t?c.warn(\"SB: Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):c.info(\"SB: Reusing native SegmentSink with codec\",t),r;c.info(\"SB: Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new Hr(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.slice().forEach(s=>s()),ce(this._onNativeBufferAddedOrDisabled.length===0),o}if(!P(r))return c.info(\"SB: Reusing a previous custom SegmentSink for the type\",e),r;let i;if(e===\"text\"){if(c.info(\"SB: Creating a new text SegmentSink\"),this._textInterface===null)throw new Error(\"HTML Text track feature not activated\");return i=new Ks(this._textInterface),this._initializedSegmentSinks.text=i,i}throw c.error(\"SB: Unknown buffer type:\",e),new Z(\"BUFFER_TYPE_UNKNOWN\",\"The player wants to create a SegmentSink of an unknown type.\")}disposeSegmentSink(e){let t=this._initializedSegmentSinks[e];if(P(t)){c.warn(\"SB: Trying to dispose a SegmentSink that does not exist\");return}c.info(\"SB: Aborting SegmentSink\",e),t.dispose(),delete this._initializedSegmentSinks[e]}disposeAll(){nf.forEach(e=>{this.getStatus(e).type===\"initialized\"&&this.disposeSegmentSink(e)})}_areNativeBuffersUsable(){let e=this.getNativeBufferTypes();return!(e.some(i=>this._initializedSegmentSinks[i]===void 0)||e.every(i=>this._initializedSegmentSinks[i]===null))}createSegmentSinkMetricsForType(e){var i,a;let t=(i=this._initializedSegmentSinks[e])==null?void 0:i.getLastKnownInventory(),r;if(t!==void 0){r=0;for(let o of t){if(o.chunkSize===void 0||r===void 0){r=void 0;break}r+=o.chunkSize}}return{bufferType:e,sizeEstimate:r,codec:(a=this._initializedSegmentSinks[e])==null?void 0:a.codec,segmentInventory:t==null?void 0:t.map(o=>oe(ee({},o),{infos:rf(o.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function js(n){return n===\"audio\"||n===\"video\"}function rf(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var bt=Un;function Ta(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,u=af(i,e);if(u===null){if(t===null){if(r&&a.end!==void 0&&e.end>=a.end)return{start:void 0,end:null};let l=s.index.checkDiscontinuity(e.start);if(l!==null)return{start:void 0,end:l}}return null}let d=i[u];if(d.bufferedStart!==void 0&&d.bufferedStart>e.start&&(t===null||d.infos.segment.end<=t)){let l=d.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,l)!==!1?null:(c.debug(\"RS: current discontinuity encountered\",o.type,d.bufferedStart),{start:void 0,end:l})}let f=of(i,e,u+1);if(f!==null){let l=i[f-1],m=i[f];if(t===null||m.infos.segment.end<=t){if(!r&&s.index.awaitSegmentBetween(l.infos.segment.end,m.infos.segment.time)!==!1)return null;let g=l.bufferedEnd,p=m.bufferedStart;return c.debug(\"RS: future discontinuity encountered\",o.type,g,p),{start:g,end:p}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let l=sf(i,a.end);if(l!==null){let m=i[l];if(m.bufferedEnd!==void 0&&m.bufferedEnd<a.end)return c.debug(\"RS: discontinuity encountered at the end of the current period\",o.type,m.bufferedEnd,a.end),{start:m.bufferedEnd,end:null}}}if(a.end!==void 0&&e.end>=a.end)return null;for(let l=i.length-1;l>=0;l--){let m=i[l];if(m.bufferedStart===void 0)break;if(m.bufferedStart<e.end){if(m.bufferedEnd!==void 0&&m.bufferedEnd<e.end){let g=s.index.checkDiscontinuity(e.end);if(g!==null)return{start:m.bufferedEnd,end:g}}return null}}}return null}function af(n,e){for(let t=0;t<n.length;t++){let r=n[t];if(r.bufferedStart===void 0||r.bufferedEnd===void 0||r.bufferedStart>=e.end)return null;if(r.bufferedEnd>e.start)return t}return null}function of(n,e,t){if(t<=0)return c.error(\"RS: Asked to check a discontinuity before the first chunk.\"),null;for(let r=t;r<n.length;r++){let i=n[r],a=n[r-1];if(i.bufferedStart===void 0||a.bufferedEnd===void 0||i.bufferedStart>=e.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}function sf(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t];if(r.bufferedStart===void 0)return null;if(r.bufferedStart<e)return t}return null}function Ea({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:u,representation:d}=e,f=uf(n,o,s),l=d.index.getSegments(a.start,a.end-a.start),m=n.filter(v=>!Ys(v.infos,e,t,r)),g=gf(m,a,i),{MINIMUM_SEGMENT_SIZE:p,MIN_BUFFER_AHEAD:b}=U.getCurrent(),h=!1,y=Math.min(1/60,p),E=!1,R=[];return{segmentsToLoad:l.filter(v=>{let _=G({segment:v},e);if(o.length>0&&o.some(w=>Je(_,w)))return!1;let{duration:M,time:A,end:k}=v;if(v.isInit)return!0;if(h)return R.push(v),!1;if(v.complete&&M<p||o.length>0&&o.some(w=>{if(w.period.id!==e.period.id||w.adaptation.id!==e.adaptation.id)return!1;let{segment:x}=w;if(x.time-y>A)return!1;if(x.complete){if(x.end+y<k)return!1}else if(Math.abs(A-x.time)>A)return!1;return!Ys(w,_,t,r)}))return!1;for(let B of g){let w=B.infos.period.id===e.period.id;if(B.status===1&&w){let x=B.infos.segment;if(A-x.time>-y){if(x.complete){if(x.end-k>-y)return!1}else if(Math.abs(A-x.time)<y)return!1}}}let C=M*e.representation.bitrate;if(f-C<0&&(E=!0,A>a.start+b))return h=!0,R.push(v),!1;let O=i(_);if(O.length>1){let B=O[O.length-1],w=O[O.length-2];if(B.buffered===null&&w.buffered===null)return c.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.\"+u.type,d.id,v.time),!1}for(let B=0;B<g.length;B++){let w=g[B];if(w.end+y>A){let x=w.start>A+y||df(g,B).end<k-y;return x&&(f-=C),x}}return f-=C,!0}),segmentsOnHold:R,isBufferFull:E}}function uf(n,e,t){let r=t*8e3;return r-=e.reduce((i,a)=>{let{bitrate:o}=a.representation,{duration:s}=a.segment;return i+o*s},0),n.reduce((i,a)=>a.chunkSize!==void 0?i-a.chunkSize*8:i,r)}function df(n,e){let t=e+1,{MINIMUM_SEGMENT_SIZE:r}=U.getCurrent(),i=Math.min(1/60,r);for(;t<n.length-1&&n[t-1].end+i>n[t].start;)t++;return t--,n[t]}function Ys(n,e,t,r){let{CONTENT_REPLACEMENT_PADDING:i}=U.getCurrent();if(n.period.id!==e.period.id)return!1;let{segment:a}=n;return a.time<t+i?!1:n.adaptation.id!==e.adaptation.id?!0:lf(n.representation,e.representation,r)}function lf(n,e,t){let r=n.bitrate,{BITRATE_REBUFFERING_RATIO:i}=U.getCurrent();if(t===void 0){let a=r*i;return e.bitrate>a}return r<t&&e.bitrate>r}function ff(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=U.getCurrent();return n.bufferedStart===void 0||e!==null&&e.bufferedEnd!==void 0&&n.bufferedStart-e.bufferedEnd<.1?!1:t<n.bufferedStart&&n.bufferedStart-n.start>r?(c.info(\"Stream: The start of the wanted segment has been garbage collected\",n.start,n.bufferedStart),!0):!1}function mf(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=U.getCurrent();return n.bufferedEnd===void 0||e!==null&&e.bufferedStart!==void 0&&e.bufferedStart-n.bufferedEnd<.1?!1:t>n.bufferedEnd&&n.end-n.bufferedEnd>r?(c.info(\"Stream: The end of the wanted segment has been garbage collected\",n.end,n.bufferedEnd),!0):!1}function cf(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.start;if(e!==void 0&&r!==void 0&&e-r>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.start;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function pf(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.end;if(e!==void 0&&r!==void 0&&r-e>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.end;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function gf(n,e,t){return n.filter((r,i,a)=>{let o=i===0?null:a[i-1],s=i>=a.length-1?null:a[i+1],u=null;if(ff(r,o,e.start)){if(u=t(r.infos),cf(u,r.bufferedStart))return!1;c.debug(\"Stream: skipping segment gc-ed at the start\",r.start,r.bufferedStart)}if(mf(r,s,e.end)){if(u=u!=null?u:t(r.infos),pf(u,r.bufferedEnd))return!1;c.debug(\"Stream: skipping segment gc-ed at the end\",r.end,r.bufferedEnd)}return!0})}function Ln(n,e){let t=n-e,{SEGMENT_PRIORITIES_STEPS:r}=U.getCurrent();for(let i=0;i<r.length;i++)if(t<r[i])return i;return r.length}function _a(n,e,t,r,i,a,o){var A,k,C;let{representation:s}=n,u=(k=(A=t.getIsPaused())!=null?A:t.getReference().getValue().paused.pending)!=null?k:t.getReference().getValue().paused.last,d=(C=t.getPlaybackRate())!=null?C:t.getReference().getValue().speed,f=e;(u===void 0||d===void 0||u||d<=0)&&(f-=.1);let l=hf(n,f,i),m=s.index.shouldRefresh(l.start,l.end),g=o.getPendingOperations().filter(O=>O.type===2).map(O=>O.value),p=o.getLastKnownInventory(),b=t.getCurrentTime();b===void 0&&(b=t.getReference().getValue().position.getWanted());let h=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:E,isBufferFull:R}=Ea({content:n,bufferedSegments:p,currentPlaybackTime:b,fastSwitchThreshold:r,getBufferedHistory:h,neededRange:l,segmentsBeingPushed:g,maxBufferSize:a}),T=y.map(O=>({priority:Ln(O.time,f),segment:O})),v=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&T.length===0&&E.length===0,_=null;return g.length>0&&(_=Math.min(...g.map(O=>O.segment.time))),E.length>0&&(_=_!==null?Math.min(_,E[0].time):E[0].time),T.length>0&&(_=_!==null?Math.min(_,T[0].segment.time):T[0].segment.time),{imminentDiscontinuity:Ta(n,l,_,v,p),hasFinishedLoading:v,neededSegments:T,isBufferFull:R,shouldRefreshManifest:m}}function hf(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),u=o.index;!P(s)&&bt.isNative(n.adaptation.type)&&e>=s&&u.isInitialized()&&!u.isStillAwaitingFutureSegments()&&If(i,a,e)?r=s-1:r=e-.1;let d=r+t,f;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?f=!1:s===void 0?f=d>=a.end:s===null?f=!0:f=d>=s,{start:Math.max(r,a.start),end:Math.min(d,(l=a.end)!=null?l:1/0),hasReachedPeriodEnd:f}}function If(n,e,t){var i;let r=n.getPeriodAfter(e);return e.containsTime(t,r)&&n.isLastPeriodKnown&&e.id===((i=n.periods[n.periods.length-1])==null?void 0:i.id)}async function Fn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof se)throw a;if(!(a instanceof ke)||!a.isBufferFull){let u=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new Z(\"BUFFER_APPEND_ERROR\",u,{tracks:[ut(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{c.warn(\"Stream: Running garbage collector\");let u=Math.max(s-5,0),d=s+r.getValue()+12;if(u>0&&await e.removeBuffer(0,u),d<Number.MAX_VALUE&&await e.removeBuffer(d,Number.MAX_VALUE),await ci(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(u){if(u instanceof se)throw u;let d=u instanceof Error?u.toString():\"Could not clean the buffer\";throw new Z(\"BUFFER_FULL_ERROR\",d,{tracks:[ut(t.inventoryInfos.adaptation)]})}}}async function Ra({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){let s=e.representation.getMimeTypeString(),u={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},d=G({segment:r,chunkSize:void 0,start:0,end:0},e),f=await Fn(n,i,{data:u,inventoryInfos:d},a,o);return{content:e,segment:r,buffered:f}}async function Pa({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var _,M;if(i.chunkData===null)return null;let{chunkData:u,chunkInfos:d,chunkOffset:f,chunkSize:l,appendWindow:m}=i,g=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:p}=U.getCurrent(),b=[m[0]!==void 0?Math.max(0,m[0]-p.START):void 0,m[1]!==void 0?m[1]+p.END:void 0],h={initSegmentUniqueId:r,chunk:u,timestampOffset:f,appendWindow:b,codec:g},y=(_=d==null?void 0:d.time)!=null?_:a.time,E=(M=d==null?void 0:d.duration)!=null?M:a.duration,R=y+E;b[0]!==void 0&&(y=Math.max(y,b[0])),b[1]!==void 0&&(R=Math.min(R,b[1]));let T=G({segment:a,chunkSize:l,start:y,end:R},t),v=await Fn(n,o,{data:h,inventoryInfos:T},e,s);return{content:t,segment:a,buffered:v}}function va({content:n,options:e,playbackObserver:t,segmentSink:r,segmentQueue:i,terminate:a},o,s){c.debug(\"Stream: Creating RepresentationStream\",n.adaptation.type,n.representation.bitrate);let{period:u,adaptation:d,representation:f}=n,{bufferGoal:l,maxBufferSize:m,drmSystemId:g,fastSwitchThreshold:p}=e,b=d.type,h=new F;h.linkToSignal(s);let y={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};h.signal.register(()=>{y.uniqueId!==null&&r.freeInitSegment(y.uniqueId)});let E=y.segment!==null;E||(y.isLoaded=!0);let R=!1;if(g!==void 0){let A=f.getEncryptionData(g);if(A.length>0&&A.every(k=>k.keyIds!==void 0)&&(R=!0,o.encryptionDataEncountered(A.map(k=>G({content:n},k))),h.isUsed()))return}i.addEventListener(\"error\",A=>{h.signal.isCancelled()||(h.cancel(),o.error(A))}),i.addEventListener(\"parsedInitSegment\",_,h.signal),i.addEventListener(\"parsedMediaSegment\",_,h.signal),i.addEventListener(\"emptyQueue\",v,h.signal),i.addEventListener(\"requestRetry\",A=>{if(o.warning(A.error),h.signal.isCancelled())return;let k=A.segment,{index:C}=f;C.isSegmentStillAvailable(k)===!1?v():C.canBeOutOfSyncError(A.error,k)&&o.manifestMightBeOufOfSync()},h.signal),i.addEventListener(\"fullyLoadedSegment\",A=>{r.signalSegmentComplete(G({segment:A},n)).catch(M)},h.signal);let T=i.resetForContent(n,E);h.signal.register(()=>{i.stop()}),t.listen(v,{includeLastObservation:!1,clearSignal:h.signal}),n.manifest.addEventListener(\"manifestUpdate\",v,h.signal),l.onUpdate(v,{emitCurrentValue:!1,clearSignal:h.signal}),m.onUpdate(v,{emitCurrentValue:!1,clearSignal:h.signal}),a.onUpdate(v,{emitCurrentValue:!1,clearSignal:h.signal}),v();return;function v(){if(h.isUsed())return;let A=t.getReference().getValue(),k=A.position.getWanted(),C=_a(n,k,t,p.getValue(),l.getValue(),m.getValue(),r),{neededSegments:O}=C,B=null;if(f.index.isInitialized()){if(O.length>0&&!y.isLoaded&&y.segment!==null){let D=O[0].priority;B={segment:y.segment,priority:D}}}else if(y.segment===null)c.warn(\"Stream: Uninitialized index without an initialization segment\");else if(y.isLoaded)c.warn(\"Stream: Uninitialized index with an already loaded initialization segment\");else{let D=A.position.getWanted();B={segment:y.segment,priority:Ln(u.start,D)}}let w=a.getValue();if(w===null)T.setValue({initSegment:B,segmentQueue:O});else if(w.urgent){c.debug(\"Stream: Urgent switch, terminate now.\",b),T.setValue({initSegment:null,segmentQueue:[]}),T.finish(),h.cancel(),o.terminating();return}else{let D=O[0],W=i.getRequestedInitSegment(),q=i.getRequestedMediaSegment(),$=q===null||D===void 0||q.id!==D.segment.id?[]:[D],X=W===null?null:B;if(T.setValue({initSegment:X,segmentQueue:$}),$.length===0&&X===null){c.debug(\"Stream: No request left, terminate\",b),T.finish(),h.cancel(),o.terminating();return}}if(o.streamStatusUpdate({period:u,position:A.position.getWanted(),bufferType:b,imminentDiscontinuity:C.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:C.hasFinishedLoading,neededSegments:C.neededSegments}),h.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:x}=U.getCurrent();if(C.isBufferFull){let D=Math.max(0,k-x);D>0&&r.removeBuffer(0,D).catch(M)}C.shouldRefreshManifest&&o.needsManifestRefresh()}function _(A){for(let k of A.protectionData)f.addProtectionData(k.initDataType,k.keyId,k.initData);if(!R){let k=f.getAllEncryptionData();k.length>0&&(o.encryptionDataEncountered(k.map(C=>G({content:n},C))),R=!0)}if(A.segmentType===\"init\"){if(!f.index.isInitialized()&&A.segmentList!==void 0&&f.index.initialize(A.segmentList),y.isLoaded=!0,A.initializationData!==null){let k=f.uniqueId;y.uniqueId=k,r.declareInitSegment(k,A.initializationData),Ra({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:k,segment:A.segment,segmentData:A.initializationData,segmentSink:r},h.signal).then(C=>{C!==null&&o.addedSegment(C)}).catch(M)}v();return}else{let{inbandEvents:k,predictedSegments:C,needsManifestRefresh:O}=A;if(C!==void 0&&f.index.addPredictedSegments(C,A.segment),O===!0&&(o.needsManifestRefresh(),h.isUsed())||k!==void 0&&k.length>0&&(o.inbandEvent(k),h.isUsed()))return;let B=y.uniqueId;Pa({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:B,parsedSegment:A,segment:A.segment,segmentSink:r},h.signal).then(w=>{w!==null&&o.addedSegment(w)}).catch(M)}}function M(A){h.isUsed()&&A instanceof se||(c.warn(\"Stream: Received fatal buffer error\",d.type,f.bitrate,A instanceof Error?A:null),h.cancel(),o.error(A))}}var Qs=va;function Ca(n,e,t,r,i){var m,g,p,b;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let h of a)h.infos.period.id===n.id&&(h.infos.adaptation.id!==e.id||!Ie(t.representationIds,h.infos.representation.id))&&Vt(o,{start:(m=h.bufferedStart)!=null?m:h.start,end:(g=h.bufferedEnd)!=null?g:h.end});let s=r.getPendingOperations();for(let h of s)if(h.type===0){let y=h.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!Ie(t.representationIds,y.representation.id))){let E=y.segment.time,R=E+y.segment.duration;Vt(o,{start:E,end:R})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let h=i.getReadyState();if(h===void 0||h>1)return{type:\"needs-reload\",value:void 0}}let u=t.switchingMode===\"direct\",d=[],f=Ht(a,n);if(f!==null&&(f.bufferedEnd===void 0||n.start-f.bufferedEnd<1)&&d.push({start:0,end:n.start+1}),!u){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:h}=U.getCurrent(),y=e.type,E=(p=h[y].before)!=null?p:0,R=(b=h[y].after)!=null?b:0,T=i.getCurrentTime();T===void 0&&(T=i.getReference().getValue().position.getPolled()),d.push({start:T-E,end:T+R})}if(n.end!==void 0){let h=Gt(a,n);h!==null&&(h.bufferedStart===void 0||h.bufferedStart-n.end<1)&&d.push({start:n.end-1,end:Number.MAX_VALUE})}let l=Wr(o,d);return l.length===0?{type:\"continue\",value:void 0}:u?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function Aa({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentQueueCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},u,d){let{manifest:f,period:l,adaptation:m}=e,g=new F;g.linkToSignal(d);let p=new Map,b=new Y(null,g.signal),h,y=e.representations.getValue().representationIds,E=$s(e.adaptation.representations,y),R=new Y(E,g.signal),{estimates:T,callbacks:v}=r({manifest:f,period:l,adaptation:m},b,R,n,g.signal),_=new Y(!1);n.listen(x=>{var W;let D=(W=x.canStream)!=null?W:!0;_.getValue()===D&&(c.debug(\"Stream: isMediaSegmentQueueInterrupted updated to\",!D),_.setValue(!D))},{clearSignal:g.signal});let M=a.createSegmentQueue(m.type,{onRequestBegin:v.requestBegin,onRequestEnd:v.requestEnd,onProgress:v.requestProgress,onMetrics:v.metrics},_),A=new Y(0);T.onUpdate(({bitrate:x,knownStableBitrate:D})=>{t.enableFastSwitching&&A.setValueIfChanged(D),!(x===void 0||x===h)&&(h=x,c.debug(`Stream: new ${m.type} bitrate estimate`,x),u.bitrateEstimateChange({type:m.type,bitrate:x}))},{emitCurrentValue:!0,clearSignal:g.signal});let k;e.representations.onUpdate(x=>{k!==void 0&&k.cancel();let D=e.representations.getValue().representationIds,W=$s(e.adaptation.representations,D);R.setValueIfChanged(W),k=new F,k.linkToSignal(g.signal),C(x,k.signal).catch(q=>{(k==null?void 0:k.isUsed())===!0&&F.isCancellationError(q)||(g.cancel(),u.error(q))})},{clearSignal:g.signal,emitCurrentValue:!0});return;async function C(x,D){let W=Ca(l,m,x,i,n);switch(W.type){case\"continue\":break;case\"needs-reload\":return xt(()=>{n.listen(()=>{if(D.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:q}=U.getCurrent(),$=q.bitrateSwitch;return u.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:$,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:D})});case\"flush-buffer\":case\"clean-buffer\":for(let q of W.value)if(await i.removeBuffer(q.start,q.end),D.isCancelled())return;if(W.type===\"flush-buffer\"&&(u.needsBufferFlush(),D.isCancelled()))return;break;default:De(W)}O(D)}function O(x){let D=new F;D.linkToSignal(x);let{representation:W}=T.getValue();if(W===null)return;let q=new Y(null,D.signal);T.onUpdate(V=>{if(!(V.representation===null||V.representation.id===W.id))return V.urgent?(c.info(\"Stream: urgent Representation switch\",m.type),q.setValue({urgent:!0})):(c.info(\"Stream: slow Representation switch\",m.type),q.setValue({urgent:!1}))},{clearSignal:D.signal,emitCurrentValue:!0});let $={type:m.type,adaptation:m,period:l,representation:W};if(b.setValue(W),x.isCancelled()||(u.representationChange($),x.isCancelled()))return;let X={streamStatusUpdate:u.streamStatusUpdate,encryptionDataEncountered:u.encryptionDataEncountered,manifestMightBeOufOfSync:u.manifestMightBeOufOfSync,needsManifestRefresh:u.needsManifestRefresh,inbandEvent:u.inbandEvent,warning:u.warning,error(V){g.cancel(),u.error(V)},addedSegment(V){v.addedSegment(V)},terminating(){if(!D.isUsed())return D.cancel(),O(x)}};B(W,q,X,x)}function B(x,D,W,q){let $=!1,X=new F;X.linkToSignal(q);let V=Jt(o,me=>w(x,me),X.signal),H=m.type===\"video\"?s:new Y(1/0);c.info(\"Stream: changing representation\",m.type,x.id,x.bitrate);let J=G({},W,{error(me){var pe;if($){c.warn(\"Stream: Ignoring RepresentationStream error\",me);return}$=!0;let le=ge(me,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(le.code!==\"BUFFER_FULL_ERROR\")W.error(me);else{c.warn(\"Stream: received BUFFER_FULL_ERROR\",m.type,x.bitrate);let je=o.getValue(),ae=((pe=p.get(x.id))!=null?pe:1)*.7;if(p.set(x.id,ae),ae<=.05||w(x,je)<=2){W.error(le);return}sn(4e3,q).then(()=>B(x,D,W,q)).catch(N)}},terminating(){X.cancel(),W.terminating()}});Qs({playbackObserver:n,content:{representation:x,adaptation:m,period:l,manifest:f},segmentSink:i,segmentQueue:M,terminate:D,options:{bufferGoal:V,maxBufferSize:H,drmSystemId:t.drmSystemId,fastSwitchThreshold:A}},J,q),f.addEventListener(\"manifestUpdate\",me=>{for(let le of me.updatedPeriods)if(le.period.id===l.id){for(let pe of le.result.updatedAdaptations)if(pe.adaptation===m.id){for(let je of pe.removedRepresentations)if(je===x.id)return q.isCancelled()?void 0:u.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:0,stayInPeriod:!0})}}else if(le.period.start>l.start)break},q)}function w(x,D){let W=p.get(x.id),q=W!==void 0?W:1;return W===void 0&&p.set(x.id,q),q<1&&D===1/0?5*60*1e3*q:D*q}}function $s(n,e){let t=n.filter(r=>Ie(e,r.id)&&!r.shouldBeAvoided&&r.isPlayable()!==!1);return t.length>0?t:n.filter(r=>Ie(e,r.id)&&r.isPlayable()!==!1)}var Xs=Aa;function ka(n,e,t,r,i,a){var g,p,b,h;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!bf(t,n.codec))return{type:\"needs-reload\",value:void 0};let o=n.getLastKnownInventory(),s=[];for(let y of o)y.infos.period.id===e.id&&y.infos.adaptation.id!==t.id&&Vt(s,{start:(g=y.bufferedStart)!=null?g:y.start,end:(p=y.bufferedEnd)!=null?p:y.end});let u=n.getPendingOperations();for(let y of u)if(y.type===0){let E=y.value.inventoryInfos;if(E.period.id===e.id&&E.adaptation.id!==t.id){let R=E.segment.time,T=R+E.segment.duration;Vt(s,{start:R,end:T})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let y=i.getReadyState();if(y===void 0||y>1)return{type:\"needs-reload\",value:void 0}}let d=r===\"direct\",f=[],l=Ht(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!d){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:E}=U.getCurrent(),R=(b=E[y].before)!=null?b:0,T=(h=E[y].after)!=null?h:0,v=i.getCurrentTime();v===void 0&&(v=i.getReference().getValue().position.getPolled()),f.push({start:v-R,end:v+T})}if(e.end!==void 0){let y=Gt(o,e);y!==null&&(y.bufferedStart===void 0||y.bufferedStart-e.end<1)&&f.push({start:e.end-1,end:Number.MAX_VALUE})}let m=Wr(s,f);return m.length===0?{type:\"continue\",value:void 0}:d&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function bf(n,e){return n.representations.some(t=>t.isPlayable()===!0&&Wo(t.getMimeTypeString(),e))}function xa({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentQueueCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:u,maxVideoBufferSize:d},f,l){let{manifest:m,period:g}=e,p=new Y(void 0,l);if(f.periodStreamReady({type:n,manifest:m,period:g,adaptationRef:p}),l.isCancelled())return;let b,h=!0;p.onUpdate(R=>{(async()=>{var w;if(R===void 0)return;let T=new F;if(T.linkToSignal(l),b==null||b.cancel(),b=T,R===null){c.info(`Stream: Set no ${n} Adaptation. P:`,g.start);let x=o.getStatus(n);if(x.type===\"initialized\"){if(c.info(`Stream: Clearing previous ${n} SegmentSink`),bt.isNative(n))return E(0,!0,T.signal);{let D=(w=g.end)!=null?w:1/0;if(g.start>D)c.warn(\"Stream: Can't free buffer: period's start is after its end\");else if(await x.value.removeBuffer(g.start,D),T.isUsed())return}}else if(x.type===\"uninitialized\"&&(o.disableSegmentSink(n),T.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:g}),T.isUsed()?void 0:Zs(r,u,n,{period:g},f,T.signal)}let v=g.adaptations[n],_=j(v!=null?v:[],x=>x.id===R.adaptationId);if(_===void 0){b.cancel(),c.warn(\"Stream: Unfound chosen Adaptation choice\",R.adaptationId);return}let{DELTA_POSITION_AFTER_RELOAD:M}=U.getCurrent(),A=!1,k;if(h)k=0;else if(R.relativeResumingPosition!==void 0)k=R.relativeResumingPosition;else switch(A=!0,n){case\"audio\":k=M.trackSwitch.audio;break;case\"video\":k=M.trackSwitch.video;break;default:k=M.trackSwitch.other;break}if(h=!1,bt.isNative(n)&&o.getStatus(n).type===\"disabled\")return E(k,!0,T.signal);m.addEventListener(\"manifestUpdate\",x=>{for(let D of x.updatedPeriods)if(D.period.id===g.id){for(let W of D.result.removedAdaptations)if(W.id===_.id)return E(k,!0,T.signal)}else if(D.period.start>g.start)break},b.signal);let{representations:C}=R;if(c.info(`Stream: Updating ${n} adaptation`,`A: ${_.id}`,`P: ${g.start}`),f.adaptationChange({type:n,adaptation:_,period:g}),T.isUsed())return;let O=Sf(o,n,_),B=ka(O,g,_,R.switchingMode,r,s);if(B.type===\"needs-reload\")return E(k,!0,T.signal);if(await o.waitForUsableBuffers(T.signal),!T.isUsed()){if(B.type===\"flush-buffer\"||B.type===\"clean-buffer\"){for(let{start:x,end:D}of B.value)if(await O.removeBuffer(x,D),T.isUsed())return;if(B.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:k,relativePosHasBeenDefaulted:A}),T.isUsed()))return}t.get(O)(T.signal),y(_,C,O,T.signal)}})().catch(T=>{T instanceof se||(b==null||b.cancel(),f.error(T))})},{clearSignal:l,emitCurrentValue:!0});function y(R,T,v,_){let M=Tf(r,R.type);Xs({content:{manifest:m,period:g,adaptation:R,representations:T},options:s,playbackObserver:M,representationEstimator:i,segmentSink:v,segmentQueueCreator:a,wantedBufferAhead:u,maxVideoBufferSize:d},oe(ee({},f),{error:A}),_);function A(k){if(!bt.isNative(n)){c.error(`Stream: ${n} Stream crashed. Aborting it.`,k instanceof Error?k:\"\"),o.disposeSegmentSink(n);let C=ge(k,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(C),_.isCancelled()?void 0:Zs(r,u,n,{period:g},f,_)}c.error(`Stream: ${n} Stream crashed. Stopping playback.`,k instanceof Error?k:\"\"),f.error(k)}}function E(R,T,v){xt(()=>{r.listen(()=>{v.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:g,timeOffset:R,stayInPeriod:T})},{includeLastObservation:!0,clearSignal:v})})}}function Sf(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return c.info(\"Stream: Reusing a previous SegmentSink for the type\",e),r.value;let i=yf(t);return n.createSegmentSink(e,i)}function yf(n){let e=n.representations.filter(t=>t.isPlayable()!==!1);if(e.length===0)throw new Z(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[ut(n)]});return e[0].getMimeTypeString()}function Tf(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new Y(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let u=r.getValue(),d=u.buffered[e],f=d!==null?zr(d,u.position.getWanted()):0;return G({},u,{bufferGap:f,buffered:d})}function s(){a.setValue(o())}})}function Zs(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),n.listen(u,{includeLastObservation:!1,clearSignal:a}),u();function u(){let d=n.getReference().getValue(),f=e.getValue(),l=d.position.getWanted();o.end!==void 0&&l+f>=o.end&&(c.debug('Stream: full \"empty\" AdaptationStream',t),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:l,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var Js=xa;function Gr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory();for(let i of r)if(e.some(o=>i.infos.period.id===o.period.id&&i.infos.adaptation.id===o.adaptation.id&&i.infos.representation.id===o.representation.id)){let{bufferedStart:o,bufferedEnd:s}=i;if(o===void 0||s===void 0)return c.warn(\"SO: No buffered start or end found from a segment.\"),[{start:0,end:Number.MAX_VALUE}];let u=t[t.length-1];u!==void 0&&u.end===o?u.end=s:t.push({start:o,end:s})}return t}function Ma(n,e,t,r,i,a,o,s){let{manifest:u,initialPeriod:d}=n,{maxBufferAhead:f,maxBufferBehind:l,wantedBufferAhead:m,maxVideoBufferSize:g}=a,{MINIMUM_MAX_BUFFER_AHEAD:p,MAXIMUM_MAX_BUFFER_AHEAD:b,MAXIMUM_MAX_BUFFER_BEHIND:h}=U.getCurrent(),y=new On(T=>{var A,k;let{bufferType:v}=T,_=(A=h[v])!=null?A:1/0,M=(k=b[v])!=null?k:1/0;return C=>{qr({segmentSink:T,playbackObserver:e,maxBufferBehind:Jt(l,O=>Math.min(O,_),C),maxBufferAhead:Jt(f,O=>{var w;let B=Math.max(O,(w=p[v])!=null?w:0);return Math.min(B,M)},C)},C)}});for(let T of r.getBufferTypes())E(T,d);function E(T,v){let _=new Mt((B,w)=>B.start-w.start),M=!1,A=new F;return A.linkToSignal(s),e.listen(({position:B})=>{var D;let w=B.getWanted();if(!M||!C(w))return;for(c.info(\"Stream: Destroying all PeriodStreams due to out of bounds situation\",T,w),M=!1;_.length()>0;){let W=_.get(_.length()-1);_.removeElement(W),o.periodStreamCleared({type:T,manifest:u,period:W})}A.cancel(),A=new F,A.linkToSignal(s);let x=(D=u.getPeriodForTime(w))!=null?D:u.getNextPeriod(w);if(x===void 0){c.warn(\"Stream: The wanted position is not found in the Manifest.\"),M=!0;return}k(x)},{clearSignal:s,includeLastObservation:!0}),u.addEventListener(\"decipherabilityUpdate\",B=>{s.isCancelled()||O(B).catch(w=>{s.isCancelled()||(A.cancel(),o.error(w))})},s),k(v);function k(B){let w=oe(ee({},o),{waitingMediaSourceReload(x){let D=_.head();D===void 0||D.id!==x.period.id?o.lockedStream({bufferType:x.bufferType,period:x.period}):o.needsMediaSourceReload({timeOffset:x.timeOffset,minimumPosition:x.stayInPeriod?x.period.start:void 0,maximumPosition:x.stayInPeriod?x.period.end:void 0})},periodStreamReady(x){M=!0,_.add(x.period),o.periodStreamReady(x)},periodStreamCleared(x){_.removeElement(x.period),o.periodStreamCleared(x)},error(x){A.cancel(),o.error(x)}});R(T,B,w,A.signal)}function C(B){let w=_.head(),x=_.last();return w===void 0||x===void 0?!0:w.start>B||(P(x.end)?1/0:x.end)<B}async function O(B){let w=r.getStatus(T),x=B.filter(V=>V.adaptation.type===T);if(x.length===0||w.type!==\"initialized\"||x.every(V=>V.representation.decipherable===!0))return;let D=w.value,W=x.filter(V=>V.representation.decipherable===void 0),q=x.filter(V=>V.representation.decipherable===!1),$=Gr(D,q),X=Gr(D,W);for(M=!1,c.info(\"Stream: Destroying all PeriodStreams for decipherability matters\",T);_.length()>0;){let V=_.get(_.length()-1);_.removeElement(V),o.periodStreamCleared({type:T,manifest:u,period:V})}A.cancel(),A=new F,A.linkToSignal(s);for(let{start:V,end:H}of[...$,...X]){if(s.isCancelled())return;if(V<H){if(s.isCancelled())return;await D.removeBuffer(V,H)}}xt(()=>{if(s.isCancelled())return;let V=e.getReference().getValue();if(eu(V,$)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(eu(V,X)&&(o.needsBufferFlush(),s.isCancelled()))return;let H=V.position.getWanted(),J=u.getPeriodForTime(H);if(J===void 0){o.error(new Z(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}k(J)})}}function R(T,v,_,M){c.info(\"Stream: Creating new Stream for\",T,v.start);let A=null,k=new F;k.linkToSignal(M),e.listen(({position:x},D)=>{if(v.end!==void 0&&x.getWanted()>=v.end){let W=u.getPeriodAfter(v);if(v.containsTime(x.getWanted(),W))return;c.info(\"Stream: Destroying PeriodStream as the current playhead moved above it\",T,v.start,x.getWanted(),v.end),D(),_.periodStreamCleared({type:T,manifest:u,period:v}),k.cancel()}},{clearSignal:M,includeLastObservation:!0});let C={bufferType:T,content:{manifest:u,period:v},garbageCollectors:y,maxVideoBufferSize:g,segmentQueueCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},O=oe(ee({},_),{streamStatusUpdate(x){if(x.hasFinishedLoading){let D=u.getPeriodAfter(v);D!==null&&B(D)}else A!==null&&(c.info(\"Stream: Destroying next PeriodStream due to current one being active\",T,A.period.start),_.periodStreamCleared({type:T,manifest:u,period:A.period}),A.canceller.cancel(),A=null);_.streamStatusUpdate(x)},error(x){A!==null&&(A.canceller.cancel(),A=null),k.cancel(),_.error(x)}});Js(C,O,k.signal),w(k.signal);function B(x){if(A!==null){if(A.period.id===x.id)return;c.warn(\"Stream: Creating next `PeriodStream` while one was already created.\",T,x.id,A.period.id),_.periodStreamCleared({type:T,manifest:u,period:A.period}),A.canceller.cancel()}let D=new F;D.linkToSignal(M),A={canceller:D,period:x},R(T,x,_,A.canceller.signal)}function w(x){u.addEventListener(\"manifestUpdate\",D=>{for(let W of D.removedPeriods)if(W.id===v.id){if(u.periods.length>0&&u.periods[0].start<=W.start)return xt(()=>{if(!x.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(W.start>v.start)break;if(D.addedPeriods.length>0&&A!==null){let W=u.getPeriodAfter(v);(W===null||A.period.id!==W.id)&&(c.warn(\"Stream: Destroying next PeriodStream due to new one being added\",T,A.period.start),_.periodStreamCleared({type:T,manifest:u,period:A.period}),A.canceller.cancel(),A=null)}},x)}}}function eu(n,e){if(e.length===0)return!1;let t=n.position.getPolled();return n.speed>=0?e[e.length-1].end>=t-5:e[0].start<=t+5}var tu=Ma;var nu=tu;var zn=class extends fe{constructor(e,t,r){super(),this._canceller=new F,this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new Oa(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let u=new Z(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",u)}else if(s>i.getMaximumAvailablePosition()){let u=new Z(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",u)}},{includeLastObservation:!0,clearSignal:a}),e.addEventListener(\"manifestUpdate\",()=>{this.trigger(\"endingPositionChange\",this._getManifestEndTime()),!a.isCancelled()&&this._checkEndOfStream()},a)}getCurrentEndingTime(){return this._getManifestEndTime()}onAdaptationChange(e,t,r){if(this._manifest.isLastPeriodKnown){let i=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(i==null?void 0:i.id)&&(e===\"audio\"||e===\"video\")){e===\"audio\"?this._maximumPositionCalculator.updateLastAudioAdaptation(r):this._maximumPositionCalculator.updateLastVideoAdaptation(r);let a=this._maximumPositionCalculator.getEndingPosition(),o=a!==void 0?{isEnd:!0,endingPosition:a}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger(\"endingPositionChange\",o)}}this._canceller.isUsed()||r===null&&this._addActivelyLoadedPeriod(t,e)}onRepresentationChange(e,t){this._addActivelyLoadedPeriod(t,e)}onPeriodCleared(e,t){this._removeActivelyLoadedPeriod(t,e)}onLastSegmentFinishedLoading(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())}onLastSegmentLoadingResume(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())}dispose(){this.removeEventListener(),this._canceller.cancel()}_addActivelyLoadedPeriod(e,t){let r=this._lazilyCreateActiveStreamInfo(t);r.activePeriods.has(e)||(r.activePeriods.add(e),this._checkCurrentPeriod())}_removeActivelyLoadedPeriod(e,t){let r=this._activeStreams.get(t);r!==void 0&&r.activePeriods.has(e)&&(r.activePeriods.removeElement(e),this._checkCurrentPeriod())}_checkCurrentPeriod(){if(this._allBufferTypes.length===0)return;let e=this._activeStreams.get(this._allBufferTypes[0]);if(e!==void 0)for(let t of e.activePeriods.toArray()){let r=!0;for(let i of this._allBufferTypes){let a=this._activeStreams.get(i);if(a===void 0)return;if(!a.activePeriods.toArray().some(u=>u.id===t.id)){r=!1;break}}if(r){this._lastCurrentPeriodId!==t.id&&(this._lastCurrentPeriodId=t.id,this.trigger(\"periodChange\",t));return}}}_getManifestEndTime(){let e=this._maximumPositionCalculator.getEndingPosition();return e!==void 0?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}}_lazilyCreateActiveStreamInfo(e){let t=this._activeStreams.get(e);return t===void 0&&(t={activePeriods:new Mt((r,i)=>r.start-i.start),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t}_checkEndOfStream(){if(!this._manifest.isLastPeriodKnown)return;this._allBufferTypes.every(t=>{let r=this._activeStreams.get(t);return r!==void 0&&r.hasFinishedLoadingLastPeriod})?this.trigger(\"endOfStream\",null):this.trigger(\"resumeStream\",null)}},Oa=class{constructor(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}updateLastAudioAdaptation(e){this._lastAudioAdaptation=e}updateLastVideoAdaptation(e){this._lastVideoAdaptation=e}getMaximumAvailablePosition(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)return this._manifest.getMaximumSafePosition();if(this._lastAudioAdaptation===null){if(this._lastVideoAdaptation===null)return this._manifest.getMaximumSafePosition();{let e=Kr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Kr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Kr(this._lastAudioAdaptation),t=Kr(this._lastVideoAdaptation);return typeof e!=\"number\"||typeof t!=\"number\"?this._manifest.getMaximumSafePosition():Math.min(e,t)}}getEndingPosition(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(!(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)){if(this._lastAudioAdaptation===null)return this._lastVideoAdaptation===null?void 0:(e=jr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=jr(this._lastAudioAdaptation))!=null?t:void 0;{let r=jr(this._lastAudioAdaptation),i=jr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Kr(n){let{representations:e}=n,t=null,r;for(let i of e)if(i.index!==r){r=i.index;let a=i.index.getLastAvailablePosition();if(a===void 0)return;a!==null&&(t=P(t)?a:Math.min(t,a))}return t}function jr(n){let{representations:e}=n,t=null,r;for(let i of e)if(i.index!==r){r=i.index;let a=i.index.getEnd();if(a===void 0)return;a!==null&&(t=P(t)?a:Math.min(t,a))}return t}function wa(n,e,t,r,i,a){a.register(()=>{e.interruptDurationSetting()});let o=new zn(n,t,r.getBufferTypes());a.register(()=>{o.dispose()}),o.addEventListener(\"warning\",u=>i.onWarning(u)),o.addEventListener(\"periodChange\",u=>i.onPeriodChanged(u)),o.addEventListener(\"endingPositionChange\",u=>{e.setDuration(u.endingPosition,u.isEnd)}),o.addEventListener(\"endOfStream\",()=>{c.debug(\"Init: end-of-stream order received.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function Da(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=j(n.sourceBuffers,s=>s.type===\"audio\"),i=j(n.sourceBuffers,s=>s.type===\"video\"),a=r==null?void 0:r.getBuffered();a!==void 0&&(t.audio=a);let o=i==null?void 0:i.getBuffered();return o!==void 0&&(t.video=o),t}var Wn=class extends fe{constructor(e){super(),this._downgradedCdnList={metadata:[],timeouts:[]},e.register(()=>{for(let t of this._downgradedCdnList.timeouts)clearTimeout(t);this._downgradedCdnList={metadata:[],timeouts:[]}})}getCdnPreferenceForResource(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)}downgradeCdn(e){let t=ru(this._downgradedCdnList.metadata,e);t>=0&&this._removeIndexFromDowngradeList(t);let{DEFAULT_CDN_DOWNGRADE_TIME:r}=U.getCurrent(),i=r;this._downgradedCdnList.metadata.push(e);let a=setTimeout(()=>{let o=ru(this._downgradedCdnList.metadata,e);o>=0&&this._removeIndexFromDowngradeList(o),this.trigger(\"priorityChange\",null)},i);this._downgradedCdnList.timeouts.push(a),this.trigger(\"priorityChange\",null)}_innerGetCdnPreferenceForResource(e){let[t,r]=e.reduce((i,a)=>(this._downgradedCdnList.metadata.some(o=>o.id===a.id&&o.baseUrl===a.baseUrl)?i[1].push(a):i[0].push(a),i),[[],[]]);return t.concat(r)}_removeIndexFromDowngradeList(e){this._downgradedCdnList.metadata.splice(e,1);let t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])}};function ru(n,e){return n.length===0?-1:e.id!==void 0?ne(n,t=>t.id===e.id):ne(n,t=>t.baseUrl===e.baseUrl)}function ze(n){return n instanceof de?new Qe(\"PIPELINE_LOAD_ERROR\",n):ge(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function Ef(n){return n instanceof de?n.type===St.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===St.TIMEOUT||n.type===St.ERROR_EVENT:n instanceof Ye?typeof n.canRetry==\"boolean\"?n.canRetry:n.xhr!==void 0?n.xhr.status>=500||n.xhr.status===404||n.xhr.status===415||n.xhr.status===412:!1:wt(n)&&n.code===\"INTEGRITY_ERROR\"}async function qn(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:u}=r;n!==null&&n.length===0&&c.warn(\"Fetchers: no CDN given to `scheduleRequestWithCdns`.\");let d=new Map,f=l();if(f===void 0)throw new Error(\"No CDN to request\");return m(f);function l(){if(n===null){let h=d.get(null);return h!==void 0&&h.isBlacklisted?void 0:null}else{if(e===null)return b(n);{let h=e.getCdnPreferenceForResource(n);return b(h)}}}async function m(h){try{return await t(h,i)}catch(y){if(F.isCancellationError(y))throw y;h!==null&&e!==null&&e.downgradeCdn(h);let E=d.get(h);if(E===void 0?(E={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},d.set(h,E)):E.errorCounter++,!Ef(y))return E.blockedUntil=void 0,E.isBlacklisted=!0,g(y);if(E.errorCounter>s)E.blockedUntil=void 0,E.isBlacklisted=!0;else{let R=E.errorCounter,T=Math.min(a*Math.pow(2,R-1),o),v=Pi(T);E.blockedUntil=L()+v}return g(y)}}async function g(h){let y=l();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw h;if(u(h),i.isCancelled())throw i.cancellationError;return p(y,h)}function p(h,y){let E=d.get(h);if(E===void 0||E.blockedUntil===void 0)return m(h);let R=L(),T=E.blockedUntil-R;if(T<=0)return m(h);let v=new F,_=v.linkToSignal(i);return new Promise((M,A)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let O=l();if(i.isCancelled())throw i.cancellationError;if(O===void 0)return C(y);O!==h&&(v.cancel(),p(O,y).then(k,C))},v.signal),sn(T,v.signal).then(()=>m(h).then(k,C),N);function k(O){_(),M(O)}function C(O){_(),A(O)}})}function b(h){var E;if(d.size===0)return h[0];let y=L();return(E=h.filter(R=>{var T;return((T=d.get(R))==null?void 0:T.isBlacklisted)!==!0}).reduce((R,T)=>{var _;let v=(_=d.get(T))==null?void 0:_.blockedUntil;return v!==void 0&&v<=y&&(v=void 0),R===void 0?[T,v]:R[1]===void 0?R:v===void 0?[T,void 0]:v<R[1]?[T,v]:R},void 0))==null?void 0:E[0]}}function Na(n,e,t){return qn(null,null,n,e,t)}var Vn=class extends fe{constructor(e,t,r){super(),this.scheduleManualRefresh=N,this._manifestUrls=e,this._pipelines=t.manifest,this._transportName=t.transportName,this._settings=r,this._canceller=new F,this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(){this._canceller.cancel(),this.removeEventListener()}start(){if(this._isStarted)return;this._isStarted=!0;let e,t=this._settings.initialManifest;t instanceof Ut?e=Promise.resolve({manifest:t}):t!==void 0?e=this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):e=this._fetchManifest(void 0).then(r=>r.parse({previousManifest:null,unsafeMode:!1})),e.then(r=>{this.trigger(\"manifestReady\",r.manifest),this._canceller.isUsed()||this._recursivelyRefreshManifest(r.manifest,r)}).catch(r=>this._onFatalError(r))}updateContentUrls(e,t){var r;this._prioritizedContentUrl=(r=e==null?void 0:e[0])!=null?r:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})}async _fetchManifest(e){var d;let t=this._canceller.signal,r=this._settings,i=this._transportName,a=this._pipelines,o=e!=null?e:(d=this._manifestUrls)==null?void 0:d[0],s=this._getBackoffSetting(f=>{this.trigger(\"warning\",ze(f))});try{let f=await u(o);return{parse:l=>this._parseLoadedManifest(f,l,o)}}catch(f){throw ze(f)}function u(f){var h;let{loadManifest:l}=a,m=r.requestTimeout===void 0?U.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,g=r.connectionTimeout===void 0?U.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;m<0&&(m=void 0),g<0&&(g=void 0);let p={timeout:m,connectionTimeout:g,cmcdPayload:(h=r.cmcdDataBuilder)==null?void 0:h.getCmcdDataForManifest(i)};return Na(()=>l(f,p,t),s,t)}}parse(e,t,r){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,r)}async _parseLoadedManifest(e,t,r){var b;let i=L(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:u}=e,d=this._getBackoffSetting(h=>{this.trigger(\"warning\",ze(h))}),f=r!=null?r:(b=this._manifestUrls)==null?void 0:b[0],l={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:f};try{let h=this._pipelines.parseManifest(e,l,g,a,m);if(_f(h)){let{manifest:y,warnings:E}=await h;return p(y,E)}else return p(h.manifest,h.warnings)}catch(h){throw ge(h,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(h){try{return await Na(h,d,a)}catch(y){throw ze(y)}}function g(h){for(let y of h){if(a.isCancelled())return;let E=ge(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",E)}}function p(h,y){g(y);let E=L()-i;return c.info(`MF: Manifest parsed in ${E}ms`),{manifest:h,sendingTime:s,receivedTime:u,parsingTime:E}}}_getBackoffSetting(e){let{DEFAULT_MAX_MANIFEST_REQUEST_RETRY:t,INITIAL_BACKOFF_DELAY_BASE:r,MAX_BACKOFF_DELAY_BASE:i}=U.getCurrent(),{lowLatencyMode:a,maxRetry:o}=this._settings,s=a?r.LOW_LATENCY:r.REGULAR,u=a?i.LOW_LATENCY:i.REGULAR,d=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:u,maxRetry:d}}_recursivelyRefreshManifest(e,{sendingTime:t,parsingTime:r,updatingTime:i}){let{MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:a,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:o}=U.getCurrent(),s=r!==void 0?r+(i!=null?i:0):void 0,u=!1;this._consecutiveUnsafeMode>0?u=this._consecutiveUnsafeMode<a:s!==void 0&&(u=s>=o);let d=t===void 0?0:L()-t,f=Math.max(this._settings.minimumManifestUpdateInterval-d,0),l=new F;if(l.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:g,delay:p,canUseUnsafeMode:b}=m,h=b&&u,y=t===void 0?0:L()-t,E=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:g,unsafeMode:h})},Math.max((p!=null?p:0)-y,E));l.signal.register(()=>{clearTimeout(R)})},e.expired!==null){let m=setTimeout(()=>{var g;(g=e.expired)==null||g.then(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},N)},f);l.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-d,g;s===void 0?g=m:e.lifetime<3&&s>=100?(g=Math.min(Math.max(3e3-d,Math.max(m,0)+s),m*6),c.info(\"MUS: Manifest update rythm is too frequent. Postponing next request.\",m,g)):s>=e.lifetime*1e3/10?(g=Math.min(Math.max(m,0)+s,m*6),c.info(\"MUS: Manifest took too long to parse. Postponing next request\",g,g)):g=m;let p=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},Math.max(g,f));l.signal.register(()=>{clearTimeout(p)})}}_triggerNextManifestRefresh(e,{enablePartialRefresh:t,unsafeMode:r}){let i=e.updateUrl,a,o;this._prioritizedContentUrl!==null?(a=!0,o=this._prioritizedContentUrl,this._prioritizedContentUrl=null):(a=!t||i===void 0,o=a?e.getUrls()[0]:i);let s=e.clockOffset;r?(this._consecutiveUnsafeMode+=1,c.info('Init: Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(c.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(o).then(u=>u.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(u=>{this._isRefreshPending=!1;let{manifest:d,sendingTime:f,parsingTime:l}=u,m=L();if(a)e.replace(d);else try{e.update(d)}catch(p){let b=p instanceof Error?p.message:\"unknown error\";c.warn(`MUS: Attempt to update Manifest failed: ${b}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:h}=U.getCurrent(),y=f===void 0?0:L()-f,E=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=N,T=setTimeout(()=>{R(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(h-y,E));R=this._canceller.signal.register(()=>{clearTimeout(T)});return}let g=L()-m;this._recursivelyRefreshManifest(e,{sendingTime:f,parsingTime:l,updatingTime:g})}).catch(u=>{this._isRefreshPending=!1,this._onFatalError(u)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose())}};function _f(n){return n instanceof Promise}var Ba=Vn;function Ua(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=d=>e(r,a,d),u=n.create(s,i,a,o);return t.set(u,s),u},updatePriority(r,i){let a=t.get(r);if(a===void 0){c.warn(\"Fetchers: Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var La=class{constructor(){this._cache=new WeakMap}add({representation:e,segment:t},r){t.isInit&&this._cache.set(e,r)}get({representation:e,segment:t}){if(t.isInit){let r=this._cache.get(e);if(r!==void 0)return r}return null}},iu=La;var Rf=xe();function Fa({bufferType:n,pipeline:e,cdnPrioritizer:t,cmcdDataBuilder:r,eventListeners:i,requestOptions:a}){let o;a.connectionTimeout===void 0||a.connectionTimeout<0?o=void 0:o=a.connectionTimeout;let s={timeout:a.requestTimeout<0?void 0:a.requestTimeout,connectionTimeout:o,cmcdPayload:void 0},u=Ie([\"audio\",\"video\"],n)?new iu:void 0,{loadSegment:d,parseSegment:f}=e;return async function(m,g,p){var $,X,V;let{segment:b,adaptation:h,representation:y,manifest:E,period:R}=m,T=yt(m),v=Rf(),_,M=[],A=0,k=!1,C={segment:b,type:h.type,language:h.language,isLive:E.isLive,periodStart:R.start,periodEnd:R.end,mimeType:y.mimeType,codecs:y.codecs[0],manifestPublishTime:E.publishTime},O={onProgress(H){var J;_===void 0&&H.totalSize!==void 0&&H.size<H.totalSize&&((J=i.onProgress)==null||J.call(i,{duration:H.duration,size:H.size,totalSize:H.totalSize,timestamp:L(),id:v}))},onNewChunk(H){g.onChunk(D(H,!0))}},B=u!==void 0?u.get(m):null;if(B!==null)return c.debug(\"SF: Found wanted segment in cache\",T),g.onChunk(D(B,!1)),Promise.resolve();c.debug(\"SF: Beginning request\",T),($=i.onRequestBegin)==null||$.call(i,{requestTimestamp:L(),id:v,content:m}),p.register(w);try{let H=await qn(m.representation.cdnMetadata,t,x,G({onRetry:W},a),p);if(H.resultType===\"segment-loaded\"){let J=H.resultData.responseData;u!==void 0&&u.add(m,H.resultData.responseData),g.onChunk(D(J,!1))}else H.resultType===\"segment-created\"&&g.onChunk(D(H.resultData,!1));c.debug(\"SF: Segment request ended with success\",T),g.onAllChunksReceived(),H.resultType!==\"segment-created\"?(_=H.resultData,q()):_=null,p.isCancelled()||(X=i.onRequestEnd)==null||X.call(i,{id:v}),p.deregister(w)}catch(H){throw p.deregister(w),_=null,H instanceof se?(c.debug(\"SF: Segment request aborted\",T),H):(c.debug(\"SF: Segment request failed\",T),(V=i.onRequestEnd)==null||V.call(i,{id:v}),ze(H))}function w(){var H;_===void 0&&(c.debug(\"SF: Segment request cancelled\",T),_=null,(H=i.onRequestEnd)==null||H.call(i,{id:v}))}function x(H){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(m),d(H,C,s,p,O)}function D(H,J){M.push(!1);let me=M.length-1;return function(pe){let je={data:H,isChunked:J};try{let te=f(je,C,pe);return M[me]||(A=A!==void 0&&te.segmentType===\"media\"&&te.chunkInfos!==null&&te.chunkInfos.duration!==void 0?A+te.chunkInfos.duration:void 0,M[me]=!0,q()),te}catch(te){throw ge(te,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function W(H){g.onRetry(ze(H))}function q(){var H;k||!P(_)&&_.size!==void 0&&_.requestDuration!==void 0&&M.length>0&&M.every(J=>J)&&(k=!0,(H=i.onMetrics)==null||H.call(i,{size:_.size,requestDuration:_.requestDuration,content:m,segmentDuration:A}))}}}function au({maxRetry:n,lowLatencyMode:e,requestTimeout:t,connectionTimeout:r}){let{DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:i,DEFAULT_REQUEST_TIMEOUT:a,DEFAULT_CONNECTION_TIMEOUT:o,INITIAL_BACKOFF_DELAY_BASE:s,MAX_BACKOFF_DELAY_BASE:u}=U.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?u.LOW_LATENCY:u.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var Hn=class extends fe{constructor(e,t){super(),this._segmentFetcher=e,this._currentContentInfo=null,this.isMediaSegmentQueueInterrupted=t}getRequestedInitSegment(){var e,t,r;return(r=(t=(e=this._currentContentInfo)==null?void 0:e.initSegmentRequest)==null?void 0:t.segment)!=null?r:null}getRequestedMediaSegment(){var e,t,r;return(r=(t=(e=this._currentContentInfo)==null?void 0:e.mediaSegmentRequest)==null?void 0:t.segment)!=null?r:null}resetForContent(e,t){var o;(o=this._currentContentInfo)==null||o.currentCanceller.cancel();let r=new Y({initSegment:null,segmentQueue:[]}),i=new F;i.signal.register(()=>{r.finish()});let a={content:e,downloadQueue:r,initSegmentInfoRef:t?new Y(void 0):new Y(null),currentCanceller:i,initSegmentRequest:null,mediaSegmentRequest:null,mediaSegmentAwaitingInitMetadata:null};return this._currentContentInfo=a,this.isMediaSegmentQueueInterrupted.onUpdate(s=>{s||(c.debug(\"SQ: Media segment can be loaded again, restarting queue.\",e.adaptation.type),this._restartMediaSegmentDownloadingQueue(a))},{clearSignal:i.signal}),r.onUpdate(s=>{let{segmentQueue:u}=s;if(u.length>0&&u[0].segment.id===a.mediaSegmentAwaitingInitMetadata)return;let d=a.mediaSegmentRequest;if(u.length===0){if(d===null)return;c.debug(\"SQ: no more media segment to request. Cancelling queue.\",e.adaptation.type),this._restartMediaSegmentDownloadingQueue(a);return}else if(d===null){c.debug(\"SQ: Media segments now need to be requested. Starting queue.\",e.adaptation.type,u.length),this._restartMediaSegmentDownloadingQueue(a);return}else{let f=u[0];if(d.segment.id!==f.segment.id){c.debug(\"SQ: Next media segment changed, cancelling previous\",e.adaptation.type),this._restartMediaSegmentDownloadingQueue(a);return}d.priority!==f.priority&&(c.debug(\"SQ: Priority of next media segment changed, updating\",e.adaptation.type,d.priority,f.priority),this._segmentFetcher.updatePriority(d.request,f.priority));return}},{emitCurrentValue:!0,clearSignal:i.signal}),r.onUpdate(s=>{var d;let u=a.initSegmentRequest;if(s.initSegment!==null&&u!==null){s.initSegment.priority!==u.priority&&this._segmentFetcher.updatePriority(u.request,s.initSegment.priority);return}else if(((d=s.initSegment)==null?void 0:d.segment.id)===(u==null?void 0:u.segment.id))return;s.initSegment===null&&c.debug(\"SQ: no more init segment to request. Cancelling queue.\",e.adaptation.type),this._restartInitSegmentDownloadingQueue(a,s.initSegment)},{emitCurrentValue:!0,clearSignal:i.signal}),r}stop(){var e;(e=this._currentContentInfo)==null||e.currentCanceller.cancel(),this._currentContentInfo=null}_restartMediaSegmentDownloadingQueue(e){e.mediaSegmentRequest!==null&&e.mediaSegmentRequest.canceller.cancel();let{downloadQueue:t,content:r,initSegmentInfoRef:i,currentCanceller:a}=e,o=()=>{var R;if(this.isMediaSegmentQueueInterrupted.getValue()){c.debug(\"SQ: Segment fetching postponed because it cannot stream now.\");return}let{segmentQueue:s}=t.getValue(),u=s[0];if(a!==null&&a.isUsed()){e.mediaSegmentRequest=null;return}if(u===void 0){e.mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let d=new F,f=a===null?N:d.linkToSignal(a.signal),{segment:l,priority:m}=u,g=G({segment:l,nextSegment:(R=s[1])==null?void 0:R.segment},r),p=!1,b=!1;d.signal.register(()=>{e.mediaSegmentRequest=null,!p&&(e.mediaSegmentAwaitingInitMetadata===l.id&&(e.mediaSegmentAwaitingInitMetadata=null),p=!0,b=!1)});let h=T=>{ce(T.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",G({},T,{segment:l}))},y=()=>{let T=t.getValue().segmentQueue;if(T.length===0){p=!0,this.trigger(\"emptyQueue\",null);return}else T[0].segment.id===l.id&&T.shift();p=!0,o()},E=this._segmentFetcher.createRequest(g,m,{onRetry:T=>{this.trigger(\"requestRetry\",{segment:l,error:T})},beforeInterrupted(){c.info(\"SQ: segment request interrupted temporarly.\",l.id,l.time)},onChunk:T=>{let v=i.getValue();v!==void 0?h(T(v!=null?v:void 0)):(b=!0,i.waitUntilDefined(_=>{h(T(_!=null?_:void 0))},{clearSignal:d.signal}))},onAllChunksReceived:()=>{b?(e.mediaSegmentAwaitingInitMetadata=l.id,i.waitUntilDefined(()=>{e.mediaSegmentAwaitingInitMetadata=null,b=!1,this.trigger(\"fullyLoadedSegment\",l)},{clearSignal:d.signal})):this.trigger(\"fullyLoadedSegment\",l)},beforeEnded:()=>{f(),e.mediaSegmentRequest=null,b?i.waitUntilDefined(y,{clearSignal:d.signal}):y()}},d.signal);E.catch(T=>{f(),p||(p=!0,this.stop(),this.trigger(\"error\",T))}),e.mediaSegmentRequest={segment:l,priority:m,request:E,canceller:d}};o()}_restartInitSegmentDownloadingQueue(e,t){let{content:r,initSegmentInfoRef:i}=e;if(e.initSegmentRequest!==null&&e.initSegmentRequest.canceller.cancel(),t===null)return;let a=new F,o=e.currentCanceller===null?N:a.linkToSignal(e.currentCanceller.signal),{segment:s,priority:u}=t,d=G({segment:s,nextSegment:void 0},r),f=!1,l=this._segmentFetcher.createRequest(d,u,{onRetry:m=>{this.trigger(\"requestRetry\",{segment:s,error:m})},beforeInterrupted:()=>{c.info(\"SQ: init segment request interrupted temporarly.\",s.id)},beforeEnded:()=>{o(),e.initSegmentRequest=null,f=!0},onChunk:m=>{var p;let g=m(void 0);ce(g.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",G({},g,{segment:s})),g.segmentType===\"init\"&&i.setValue((p=g.initTimescale)!=null?p:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",s)}},a.signal);l.catch(m=>{o(),f||(f=!0,this.stop(),this.trigger(\"error\",m))}),a.signal.register(()=>{e.initSegmentRequest=null,!f&&(f=!0)}),e.initSegmentRequest={segment:s,priority:u,request:l,canceller:a}}};var Kn=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,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.\")}create(e,t,r,i){let a;return Tt(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let d=()=>{g(),this._endTask(a)},f=p=>{r.beforeEnded(),d(),o(p)},l=p=>{d(),s(p)},m=new F,g=m.linkToSignal(i);a.interrupter=m,m.signal.register(()=>{a.interrupter=null,i.isCancelled()||r.beforeInterrupted()}),this._minPendingPriority=this._minPendingPriority===null?a.priority:Math.min(this._minPendingPriority,a.priority),this._pendingTasks.push(a),a.taskFn(m.signal).then(f).catch(p=>{!i.isCancelled()&&m.isUsed()&&p instanceof se||l(p)})},taskFn:e,interrupter:null},this._canBeStartedNow(a)?(a.trigger(),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()):this._waitingQueue.push(a),()=>this._endTask(a)))}_endTask(e){e.hasEnded=!0;let t=Gn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=Gn(e.taskFn,this._pendingTasks);if(r<0)return;this._pendingTasks.splice(r,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}}updatePriority(e,t){let r=Gn(e,this._waitingQueue);if(r>=0){let s=this._waitingQueue[r];if(s.priority===t||(s.priority=t,!this._canBeStartedNow(s)))return;this._findAndRunWaitingQueueTask(r),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks();return}let i=Gn(e,this._pendingTasks);if(i<0){c.warn(\"TP: request to update the priority of a non-existent task\");return}let a=this._pendingTasks[i];if(a.priority===t)return;let o=a.priority;a.priority=t,this._minPendingPriority===null||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(this._pendingTasks.length===1?this._minPendingPriority=t:this._minPendingPriority=Math.min(...this._pendingTasks.map(s=>s.priority)),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}_loopThroughWaitingQueue(){let e=this._waitingQueue.reduce((t,r)=>t===null||t>r.priority?r.priority:t,null);if(!(e===null||this._minPendingPriority!==null&&this._minPendingPriority<e))for(let t=0;t<this._waitingQueue.length;t++){let r=this._minPendingPriority===null?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=r&&(this._findAndRunWaitingQueueTask(t),t--)}}_interruptCancellableTasks(){for(let e of this._pendingTasks)if(e.priority>=this._prioritySteps.low)return this._interruptPendingTask(e),this._interruptCancellableTasks()}_findAndRunWaitingQueueTask(e){return e>=this._waitingQueue.length||e<0?(c.warn(\"TP : Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=Gn(e.taskFn,this._pendingTasks);if(t<0){c.warn(\"TP: Interrupting a non-existent pending task. Aborting...\");return}this._pendingTasks.splice(t,1),this._waitingQueue.push(e),this._pendingTasks.length===0?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))),(r=e.interrupter)==null||r.cancel()}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function Gn(n,e){return ne(e,t=>t.taskFn===n)}var jn=class{constructor(e,t,r,i){let{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=U.getCurrent();this._transport=e,this._prioritizer=new Kn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=t,this._backoffOptions=i,this._cmcdDataBuilder=r}createSegmentQueue(e,t,r){let i=au(this._backoffOptions),a=this._transport[e],o=Fa({bufferType:e,pipeline:a,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:i}),s=Ua(this._prioritizer,o);return new Hn(s,r)}};var za=jn;function Yr(n,e){let{loadThumbnail:t}=n;return async function(i,a,o,s){let u;o.connectionTimeout===void 0||o.connectionTimeout<0?u=void 0:u=o.connectionTimeout;let d={timeout:o.requestTimeout<0?void 0:o.requestTimeout,connectionTimeout:u,cmcdPayload:void 0};c.debug(\"TF: Beginning thumbnail request\",i.time),s.register(l);let f;try{if(f=await qn(a.cdnMetadata,e,m,G({onRetry:g},o),s),s.isCancelled())return Promise.reject(s.cancellationError);c.debug(\"TF: Thumbnail request ended with success\",i.time),s.deregister(l)}catch(p){throw s.deregister(l),p instanceof se?(c.debug(\"TF: Thumbnail request aborted\",i.time),p):(c.debug(\"TF: Thumbnail request failed\",i.time),ze(p))}try{return n.parseThumbnail(f.responseData,{thumbnail:i,thumbnailTrack:a})}catch(p){throw ge(p,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}function l(){c.debug(\"TF: Thumbnail request cancelled\",i.time)}function m(p){return t(p,i,d,s)}function g(p){let b=ze(p);c.warn(\"TF: Thumbnail request retry \",i.time,b)}}}function Qr({maxRetry:n,requestTimeout:e,connectionTimeout:t}){let{DEFAULT_MAX_THUMBNAIL_REQUESTS_RETRY_ON_ERROR:r,DEFAULT_THUMBNAIL_REQUEST_TIMEOUT:i,DEFAULT_THUMBNAIL_CONNECTION_TIMEOUT:a,INITIAL_BACKOFF_DELAY_BASE:o,MAX_BACKOFF_DELAY_BASE:s}=U.getCurrent();return{maxRetry:n!=null?n:r,baseDelay:o.REGULAR,maxDelay:s.REGULAR,requestTimeout:e===void 0?i:e,connectionTimeout:t===void 0?a:t}}async function Wa(n,e,t,r,i){let a=e.getPeriod(t);if(a===void 0)throw new Error(\"Wanted Period not found.\");let o=j(a.thumbnailTracks,u=>u.id===r);if(o===void 0)throw new Error(\"Wanted Period has no thumbnail track.\");let s=o.index.getSegments(i,1)[0];if(s===void 0)throw new Error(\"No thumbnail for the given timestamp\");return n(s,o,Qr({}),new F().signal)}function qa(n,e){[\"video\",\"audio\",\"text\"].forEach(t=>{var i;let r=e.getStatus(t);r.type===\"initialized\"&&r.value.synchronizeInventory((i=n.buffered[t])!=null?i:[])})}function Va(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return c.warn(\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}function Pf(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Yn(n,e){if(c.debug(\"Init: Trying to call endOfStream\"),n.readyState!==\"open\"){c.debug(\"Init: MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=Pf(t);if(r.length===0){c.info(\"Init: Triggering end of stream\");try{n.endOfStream()}catch(a){c.error(\"Unable to call endOfStream\",a instanceof Error?a:new Error(\"Unknown error\"))}return}c.debug(\"Init: Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new F;i.linkToSignal(e);for(let a of r)Ao(a,()=>{i.cancel(),Yn(n,e)},i.signal);ko(t,()=>{i.cancel(),Yn(n,e)},i.signal)}function ou(n,e){let t=new F;t.linkToSignal(e),Nt(n,()=>{c.debug(\"Init: MediaSource re-opened while end-of-stream is active\"),t.cancel(),t=new F,t.linkToSignal(e),Yn(n,t.signal)},e),Yn(n,t.signal)}function Ha(){return mi}var vf=365*24*3600,Qn=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new F;let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=kf(r,i),o=new F;o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(),!a.getValue())return;o=new F,o.linkToSignal(i);let u=Af(r.sourceBuffers,o.signal),d=new F;return d.linkToSignal(o.signal),u.onUpdate(f=>{d.cancel(),d=new F,d.linkToSignal(o.signal),!f&&uu(r,e,t,d.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)}};function Cf(n,e,t){let r=e;t||(r=Ha()?1/0:su(e));let i=0;for(let a=0;a<n.sourceBuffers.length;a++){let o=n.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{c.info(\"Init: Updating duration to what is currently buffered\",i),n.duration=i}catch(a){return c.warn(\"Duration Updater: Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(c.info(\"Init: Updating duration\",r),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=su(e);c.info(\"Init: calling `mediaSource.setLiveSeekableRange`\",s),n.setLiveSeekableRange(0,s)}}catch(s){return c.warn(\"Duration Updater: Can't update duration on the MediaSource.\",s instanceof Error?s:\"\"),\"failed\"}let o=Math.abs(n.duration-r);if(o>=.1){let s=Math.abs(n.duration-a);return o<s?\"partial\":\"failed\"}return\"success\"}}function Af(n,e){if(n.length===0){let i=new Y(!1);return i.finish(),i}let t=new Y(!1,e);r();for(let i=0;i<n.length;i++){let a=n[i];a.addEventListener(\"updatestart\",r),a.addEventListener(\"update\",r),e.register(()=>{a.removeEventListener(\"updatestart\",r),a.removeEventListener(\"update\",r)})}return t;function r(){for(let i=0;i<n.length;i++)if(n[i].updating){t.setValueIfChanged(!0);return}t.setValueIfChanged(!1)}}function kf(n,e){let t=new Y(n.readyState===\"open\",e);return Nt(n,()=>{c.debug(\"Init: Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),Ir(n,()=>{c.debug(\"Init: Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),hr(n,()=>{c.debug(\"Init: Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function uu(n,e,t,r){if(Cf(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),uu(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function su(n){return Math.max(Math.pow(2,32),n+vf)}var $n=class extends fe{constructor(e){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new F,P(lt))throw new Z(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"Init: Creating MediaSource\");let t=new lt,r=t.handle;this.handle=P(r)?{type:\"media-source\",value:t}:{type:\"handle\",value:r},this._mediaSource=t,this.readyState=t.readyState,this._durationUpdater=new Qn(t),this._endOfStreamCanceller=null,Nt(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),Ir(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),hr(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceClose\",null)},this._canceller.signal),this._mediaSource.streaming!==void 0&&(this.streaming=this._mediaSource.streaming),this._mediaSource.addEventListener(\"startstreaming\",()=>{this.streaming=!0,this.trigger(\"streamingChanged\",null)}),this._mediaSource.addEventListener(\"endstreaming\",()=>{this.streaming=!1,this.trigger(\"streamingChanged\",null)})}addSourceBuffer(e,t){let r=this._mediaSource.addSourceBuffer(t),i=new Ga(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(){this._durationUpdater.stopUpdating()}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new F,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"Init: end-of-stream order received.\"),ou(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"Init: resume-stream order received.\"),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),xf(this._mediaSource)}},Ga=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new F,this._sourceBuffer=r,this._operationQueue=[],this._currentOperations=[];let i=this._onError.bind(this),a=this._onUpdateEnd.bind(this);r.addEventListener(\"updateend\",a),r.addEventListener(\"error\",i),this._canceller.signal.register(()=>{r.removeEventListener(\"updateend\",a),r.removeEventListener(\"error\",i)})}appendBuffer(...e){return c.debug(\"SBI: receiving order to push data to the SourceBuffer\",this.type),this._addToQueue({operationName:0,params:e})}remove(e,t){return c.debug(\"SBI: receiving order to remove data from the SourceBuffer\",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return Sa(this._sourceBuffer.buffered)}catch(e){return c.error(\"Failed to get buffered time range of SourceBuffer\",this.type,e instanceof Error?e:null),[]}}abort(){try{this._sourceBuffer.abort()}catch(e){c.debug(\"Init: Failed to abort SourceBuffer:\",e instanceof Error?e:null)}this._emptyCurrentQueue()}dispose(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()}_onError(e){let t;e instanceof Error?t=e:e.error instanceof Error?t=e.error:t=new Error(\"Unknown SourceBuffer Error\");let r=this._currentOperations;if(this._currentOperations=[],r.length===0)c.error(\"SBI: error for an unknown operation\",t);else{let i=new ke(t.name,t.message,t.name===\"QuotaExceededError\");for(let a of r)a.reject(i)}}_onUpdateEnd(){let e=this._currentOperations;this._currentOperations=[];try{for(let t of e)t.resolve(Sa(this._sourceBuffer.buffered))}catch(t){for(let r of e)t instanceof Error&&t.name===\"InvalidStateError\"?r.resolve([]):r.reject(t)}this._performNextOperation()}_emptyCurrentQueue(){let e=new se;this._currentOperations.length>0&&(this._currentOperations.forEach(t=>{t.reject(e)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(t=>{t.reject(e)}),this._operationQueue=[])}_addToQueue(e){return new Promise((t,r)=>{let i=this._operationQueue.length===0&&this._currentOperations.length===0,a=G({resolve:t,reject:r},e);this._operationQueue.push(a),i&&this._performNextOperation()})}_performNextOperation(){var t,r,i,a,o;if(this._currentOperations.length!==0||this._sourceBuffer.updating)return;let e=this._operationQueue.shift();if(e!==void 0)if(e.operationName===0){this._currentOperations=[{operationName:0,resolve:e.resolve,reject:e.reject}];let s=e.params[0],u=e.params[1],d=s;if(this._operationQueue.length>0&&this._operationQueue[0].operationName===0){let f;s instanceof ArrayBuffer?f=new Uint8Array(s):s instanceof Uint8Array?f=s:f=new Uint8Array(s.buffer);let l=[f];for(;((t=this._operationQueue[0])==null?void 0:t.operationName)===0;){let m=this._operationQueue[0],g=(r=u.appendWindow)!=null?r:[void 0,void 0],p=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],b=(a=u.timestampOffset)!=null?a:0,h=(o=m.params[1].timestampOffset)!=null?o:0;if(g[0]===p[0]&&g[1]===p[1]&&u.codec===m.params[1].codec&&b===h){let y=m.params[0],E;y instanceof ArrayBuffer?E=new Uint8Array(y):y instanceof Uint8Array?E=y:E=new Uint8Array(y.buffer),l.push(E),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:m.resolve,reject:m.reject})}else break}l.length>1&&(c.info(`MMSI: Merging ${l.length} segments together for perf`,this.type),d=Et(...l))}try{this._appendBufferNow(d,u)}catch(f){let l=f instanceof Error?new ke(f.name,f.message,f.name===\"QuotaExceededError\"):new ke(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(m=>{m.reject(l)}),this._currentOperations=[],this._performNextOperation()}}else{this._currentOperations=[e];let[s,u]=e.params;c.debug(\"SBI: removing data from SourceBuffer\",this.type,s,u);try{this._sourceBuffer.remove(s,u)}catch(d){let f=d instanceof Error?new ke(d.name,d.message,!1):new ke(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(f),this._currentOperations.forEach(l=>{l.reject(f)}),this._currentOperations=[],this._performNextOperation()}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(c.debug(\"SBI: updating codec\",i),Va(r,i)?this.codec=i:c.debug(\"SBI: could not update codec\",i,this.codec)),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"SBI: updating timestampOffset\",i,r.timestampOffset,s),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"SBI: re-setting `appendWindowStart` to `0`\"),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;c.debug(\"SBI: pre-updating `appendWindowEnd`\",s),r.appendWindowEnd=s}c.debug(\"SBI: setting `appendWindowStart`\",o[0]),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"SBI: re-setting `appendWindowEnd` to `Infinity`\"),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"SBI: setting `appendWindowEnd`\",o[1]),r.appendWindowEnd=o[1]),c.debug(\"SBI: pushing segment\",this.type),r.appendBuffer(e)}};function xf(n){if(n.readyState!==\"closed\"){let{readyState:e,sourceBuffers:t}=n;for(let r=t.length-1;r>=0;r--){let i=t[r];try{if(e===\"open\"){c.info(\"Init: Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}c.info(\"Init: Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&c.info(\"Init: Not all SourceBuffers could have been removed.\")}}var Mf=xe(),$r=xe(),du=1/0,Xn=class extends fe{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new F,this.readyState=\"closed\",this._messageSender=r;let i=Mf();this._messageSender({type:\"create-media-source\",contentId:t,mediaSourceId:i})}onMediaSourceReadyStateChanged(e){switch(e){case\"closed\":this.readyState=\"closed\",this.trigger(\"mediaSourceClose\",null);break;case\"open\":this.readyState=\"open\",this.trigger(\"mediaSourceOpen\",null);break;case\"ended\":this.readyState=\"ended\",this.trigger(\"mediaSourceEnded\",null);break}}addSourceBuffer(e,t){this._messageSender({type:\"add-source-buffer\",mediaSourceId:this.id,value:{sourceBufferType:e,codec:t}});let r=new Ka(e,t,this.id,this._messageSender);return this.sourceBuffers.push(r),r}setDuration(e,t){this._messageSender({type:\"update-media-source-duration\",mediaSourceId:this.id,value:{duration:e,isRealEndKnown:t}})}interruptDurationSetting(){this._messageSender({type:\"stop-media-source-duration\",mediaSourceId:this.id,value:null})}maintainEndOfStream(){this._messageSender({type:\"end-of-stream\",mediaSourceId:this.id,value:null})}stopEndOfStream(){this._messageSender({type:\"stop-end-of-stream\",mediaSourceId:this.id,value:null})}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},Ka=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new F,this._mediaSourceId=r,this._queuedOperations=[],this._pendingOperations=new Map,this._messageSender=i}onOperationSuccess(e,t){let r=this._pendingOperations.get(e);r===void 0?c.warn(\"SBI: unknown SourceBuffer operation succeeded\"):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new se:new ke(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"SBI: unknown SourceBuffer operation failed\",r):(this._pendingOperations.delete(e),i.reject(r));let a=new se;for(let o of this._queuedOperations)o.reject(a);this._queuedOperations=[]}appendBuffer(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=du){this._queuedOperations.push({operationName:0,params:[e,t],resolve:r,reject:i});return}try{let a;e instanceof ArrayBuffer?a=e:e.byteLength===e.buffer.byteLength?a=e.buffer:a=e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset);let o=$r();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:o,value:{data:a,params:t}},[a]),this._addOperationToQueue(o,r,i)}catch(a){i(a)}})}remove(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=du){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=$r();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{start:e,end:t}}),this._addOperationToQueue(a,r,i)}catch(a){i(a)}})}abort(){this._messageSender({type:\"abort-source-buffer\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,value:null})}dispose(){this.abort(),this._canceller.cancel()}getBuffered(){}_addOperationToQueue(e,t,r){this._pendingOperations.set(e,{resolve:a,reject:o});let i=this._canceller.signal.register(s=>{this._pendingOperations.delete(e),r(s)});function a(s){i(),t(s)}function o(s){i(),r(s)}}_performNextQueuedOperationIfItExists(){let e=this._queuedOperations.shift();if(e!==void 0)try{if(e.operationName===0){let[t,r]=e.params,i;t instanceof ArrayBuffer?i=t:t.byteLength===t.buffer.byteLength?i=t.buffer:i=t.buffer.slice(t.byteOffset,t.byteLength+t.byteOffset);let a=$r();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{data:i,params:r}},[i]),this._addOperationToQueue(a,e.resolve,e.reject)}else{let[t,r]=e.params,i=$r();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:i,value:{start:t,end:r}}),this._addOperationToQueue(i,e.resolve,e.reject)}}catch(t){e.reject(t)}}};function ja(n){let e=n.map(o=>Math.log(o/n[0])),t=e.map(o=>o-e[0]+1),r=(t[t.length-1]-1)/(n.length*2+10),i=1/r;return n.map((o,s)=>a(s));function a(o){if(o===0)return 0;let s=Math.min(Math.max(1,o),n.length-1);return n[s]===n[s-1]?a(o-1):i*(r+(n[s]*t[s-1]-n[s-1]*t[s])/(n[s]-n[s-1]))+4}}var We=class{constructor(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}addSample(e,t){let r=Math.pow(this._alpha,e),i=t*(1-r)+r*this._lastEstimate;isNaN(i)||(this._lastEstimate=i,this._totalWeight+=e)}getEstimate(){let e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e}};var Zn=class{constructor(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}addSample(e,t,r){let i=r/t,a=this._currentRepresentationData,o;a!==null&&a.representation.id===e.id?(o=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=r,a.loadedSegments++):(o=new We(5),o.addSample(t,i),this._currentRepresentationData={representation:e,ewma:o,loadedDuration:r,loadedSegments:0}),o.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(c.debug(\"ABR: New last stable representation\",e.bitrate),this._lastRepresentationWithGoodScore=e)}getEstimate(e){if(this._currentRepresentationData===null||this._currentRepresentationData.representation.id!==e.id)return;let{ewma:t,loadedSegments:r,loadedDuration:i}=this._currentRepresentationData,a=t.getEstimate(),o=r>=5&&i>=10?1:0;return{score:a,confidenceLevel:o}}getLastStableRepresentation(){return this._lastRepresentationWithGoodScore}};var lu=6e3,Of=15e3,wf=3e3,Df=1e3,Nf=9e3,Jn=class{constructor(e){this._levelsMap=ja(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=lu,c.debug(\"ABR: Steps for buffer based chooser.\",this._levelsMap.map((t,r)=>`bufferLevel: ${t}, bitrate: ${e[r]}`).join(\" ,\"))}onAddedSegment(e){let t=this._levelsMap,r=this._bitrates,{bufferGap:i,currentBitrate:a,currentScore:o,speed:s}=e;if(P(a)){this._currentEstimate=r[0];return}let u=-1;for(let p=0;p<r.length;p++){let b=r[p];if(b===a)u=p;else if(b>a)break}if(u<0||r.length!==t.length){c.info(\"ABR: Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let d;o!==void 0&&(d=s===0?o.score:o.score/s);let f=isFinite(i)?i:0,l=L();if(f<t[u]||d!==void 0&&d<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Nf){let h=this._blockRaiseDelay+wf;this._blockRaiseDelay=Math.min(h,Of),c.debug(\"ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality\",this._blockRaiseDelay)}else{let h=this._blockRaiseDelay-Df;this._blockRaiseDelay=Math.max(lu,h),c.debug(\"ABR: Lowering quality in BufferBasedChooser\",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=l;let b=ne(r,h=>h===a);for(let h=b-1;h>=0;h--)if(f>=t[h]){this._currentEstimate=r[h];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||d===void 0||d<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[u],g=(()=>{for(let p=u+1;p<t.length;p++)if(t[p]>m)return p})();if(g!==void 0){let p=t[g];if(i>=p){c.debug(\"ABR: Raising quality in BufferBasedChooser\",r[g]),this._currentEstimate=r[g];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function Bf(n,e){let t=-1;for(let o=0;o<n.length;o++){let{segment:s}=n[o].content;if(s.duration<=0)continue;let u=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(u>e&&e-s.time>-1.2){t=o;break}}if(t<0)return[];let r=n[t],i=r.content.segment.time,a=[r];for(let o=t+1;o<n.length&&n[o].content.segment.time===i;o++)a.push(n[o]);return a}function Xr(n){if(n.progress.length<5)return;let e=new We(2),{progress:t}=n;for(let r=1;r<t.length;r++){let i=t[r].size-t[r-1].size,a=t[r].timestamp-t[r-1].timestamp,o=i*8/(a/1e3);e.addSample(a/1e3,o)}return e.getEstimate()}function fu(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function Uf(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,u=isFinite(a)?a:0,d=s.getWanted()+u,f=Bf(n,d);if(f.length!==1)return;let l=f[0],m=L(),g=l.content.segment.duration*1.5;if(g=Math.min(g,3e3),g=Math.max(g,12e3),m-l.requestTimestamp<g)return;let p=l.progress.length>0?l.progress[l.progress.length-1]:void 0,b=Xr(l);if(p!==void 0&&b!==void 0){let v=fu(p,b);if((m-p.timestamp)/1e3<=v&&v-u/o>2500)return b}if(!l.content.segment.complete)return;let h=l.content.segment.duration,y=(m-l.requestTimestamp)/1e3,E=y<=(h*1.5+2)/o;if(P(t)||E)return;let R=h/y,T=t.bitrate*Math.min(.7,R);if(i===void 0||T<i)return T}function Lf(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=j(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(a===void 0)return!0;let o=L(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=Xr(a);if(s===void 0||u===void 0)return!0;let d=fu(s,u);return(o-s.timestamp)/1e3>d*1.2?!0:d-r/n.speed>-1.5}var er=class{constructor(e,t){let{ABR_STARVATION_GAP:r,OUT_OF_STARVATION_GAP:i,ABR_STARVATION_FACTOR:a,ABR_REGULAR_FACTOR:o}=U.getCurrent();this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,t?this._config={starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:this._config={starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}getBandwidthEstimate(e,t,r,i,a){let o,s,u=this._config,{bufferGap:d,position:f,duration:l}=e,m=isFinite(d)?d:0,{ABR_STARVATION_DURATION_DELTA:g}=U.getCurrent();return isNaN(l)||m+f.getWanted()<l-g?!this._inStarvationMode&&m<=u.starvationGap?(c.info(\"ABR: enter starvation mode.\"),this._inStarvationMode=!0):this._inStarvationMode&&m>=u.outOfStarvationGap&&(c.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1),this._inStarvationMode&&(s=Uf(i,e,r,this._lowLatencyMode,a),s!==void 0&&(c.info(\"ABR: starvation mode emergency estimate:\",s),t.reset(),o=P(r)?s:Math.min(s,r.bitrate))),P(o)&&(s=t.getEstimate(),s!==void 0?o=s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):o=this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}}isUrgent(e,t,r,i){return t===null?!0:e>=t.bitrate?!1:Lf(i,r,this._lowLatencyMode)}};var tr=class{constructor(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}update(e,t,r){this.representation=e,this.bandwidth=t,this.algorithmType=r}};var nr=class{constructor(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}getGuess(e,t,r,i,a){let{bufferGap:o,speed:s}=t,u=this._lastAbrEstimate.representation;if(u===null)return null;if(i>u.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let d=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(d===void 0)return null;if(this._canGuessHigher(o,s,d)){let l=mu(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(u,i,d)&&(c.debug(\"ABR: Guessed Representation validated\",u.bitrate),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),r.id!==u.id)return u;if(this._shouldStopGuess(r,d,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=L()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),Ff(e,r);if(d===void 0)return r;if(this._canGuessHigher(o,s,d)){let l=mu(e,r);if(l!==null)return l}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&L()>this._blockGuessesUntil&&i===1&&r/t>1.01}_shouldStopGuess(e,t,r,i){if(t!==void 0&&t.score<1.01)return!0;if((t===void 0||t.score<1.2)&&r<.6)return!0;let a=i.filter(s=>s.content.representation.id===e.id),o=L();for(let s of a){let u=o-s.requestTimestamp;if(s.content.segment.isInit){if(u>1e3)return!0}else{if(u>s.content.segment.duration*1e3+200)return!0;{let d=Xr(s);if(d!==void 0&&d<e.bitrate*.8)return!0}}}return!1}_isLastGuessValidated(e,t,r){return r!==void 0&&r.confidenceLevel===1&&r.score>1.5?!0:t>=e.bitrate&&(this._lastMaintanableBitrate===null||this._lastMaintanableBitrate<e.bitrate)}};function mu(n,e){let t=n.length,r=ne(n,({id:i})=>i===e.id);if(r<0)return c.error(\"ABR: Current Representation not found.\"),null;for(;++r<t;)if(n[r].bitrate>e.bitrate)return n[r];return null}function Ff(n,e){let t=ne(n,({id:r})=>r===e.id);if(t<0)return c.error(\"ABR: Current Representation not found.\"),null;for(;--t>=0;)if(n[t].bitrate<e.bitrate)return n[t];return null}var rr=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new We(e),this._slowEWMA=new We(t),this._bytesSampled=0}addSample(e,t){let{ABR_MINIMUM_CHUNK_SIZE:r}=U.getCurrent();if(t<r)return;let i=t*8e3/e,a=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(a,i),this._slowEWMA.addSample(a,i)}getEstimate(){let{ABR_MINIMUM_TOTAL_BYTES:e}=U.getCurrent();if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())}reset(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new We(e),this._slowEWMA=new We(t),this._bytesSampled=0}};function Ya(n,e){if(n.length===0)return[];n.sort((a,o)=>a.bitrate-o.bitrate);let t=n[0].bitrate,r=Math.max(e,t),i=ne(n,a=>a.bitrate>r);return i===-1?n:n.slice(0,i)}function Qa(n,e){if(e.width===void 0||e.height===void 0)return n;let t=e.width*e.pixelRatio,r=e.height*e.pixelRatio,i=n.slice().sort((s,u)=>{var d,f;return((d=s.width)!=null?d:0)-((f=u.width)!=null?f:0)}),a=j(i,s=>typeof s.width==\"number\"&&s.width>=t&&typeof s.height==\"number\"&&s.height>=r);if(a===void 0)return n;let o=typeof a.width==\"number\"?a.width:0;return n.filter(s=>typeof s.width==\"number\"?s.width<=o:!0)}var ir=class{constructor(){this._currentRequests={}}add(e){let{id:t,requestTimestamp:r,content:i}=e;this._currentRequests[t]={requestTimestamp:r,progress:[],content:i}}addProgress(e){let t=this._currentRequests[e.id];if(P(t)){if(I.CURRENT_ENV===I.DEV)throw new Error(\"ABR: progress for a request not added\");c.warn(\"ABR: progress for a request not added\");return}t.progress.push(e)}remove(e){if(P(this._currentRequests[e])){if(I.CURRENT_ENV===I.DEV)throw new Error(\"ABR: can't remove unknown request\");c.warn(\"ABR: can't remove unknown request\")}delete this._currentRequests[e]}getRequests(){return pr(this._currentRequests).filter(e=>!P(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Zr(n,e){let t=ne(n,r=>r.bitrate>e);return t===-1?n[n.length-1]:t===0?n[0]:n[t-1]}var cu=new Y(void 0);cu.finish();var pu=new Y(1/0);pu.finish();function $a(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,u,d,f,l){var h,y,E;let{type:m}=s.adaptation,g=a(m),p=(h=t[m])!=null?h:0,b={limitResolution:(y=r.limitResolution[m])!=null?y:cu,throttleBitrate:(E=r.throttleBitrate[m])!=null?E:pu};return zf({bandwidthEstimator:g,context:s,currentRepresentation:u,filters:b,initialBitrate:p,playbackObserver:f,representations:d,lowLatencyMode:i},l)};function a(o){let s=e[o];if(P(s)){c.debug(\"ABR: Creating new BandwidthEstimator for \",o);let u=new rr;return e[o]=u,u}return s}}function zf({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},u){let d=new Zn,f=new er(i!=null?i:0,a),l=new ir,m=N,g={metrics:E,requestBegin:R,requestProgress:T,requestEnd:v,addedSegment(_){m(_)}},p=new F;p.linkToSignal(u);let b=h(s.getValue(),p.signal);return s.onUpdate(y,{clearSignal:u}),{estimates:b,callbacks:g};function h(_,M){if(_.length<=1)return new Y({bitrate:void 0,representation:_[0],urgent:!0,knownStableBitrate:void 0});let A=!1,k=_.sort((q,$)=>q.bitrate-$.bitrate),C=new Jn(k.map(q=>q.bitrate)),O=new tr,B=new nr(d,O),w=o.getReference().getValue(),x=new Y(W());return o.listen(q=>{w=q,D()},{includeLastObservation:!1,clearSignal:M}),m=function(q){if(w===null)return;let{position:$,speed:X}=w,V=q.buffered,H=zr(V,$.getWanted()),{representation:J}=q.content,me=d.getEstimate(J),le=J.bitrate,pe={bufferGap:H,currentBitrate:le,currentScore:me,speed:X};C.onAddedSegment(pe),D()},M.register(()=>{m=N}),r.throttleBitrate.onUpdate(D,{clearSignal:M}),r.limitResolution.onUpdate(D,{clearSignal:M}),x;function D(){x.setValue(W())}function W(){let{bufferGap:q,position:$,maximumPosition:X}=w,V=r.limitResolution.getValue(),H=r.throttleBitrate.getValue(),J=t.getValue(),me=Wf(k,V,H),le=l.getRequests(),{bandwidthEstimate:pe,bitrateChosen:je}=f.getBandwidthEstimate(w,n,J,le,O.bandwidth),te=d.getLastStableRepresentation(),ae=te===null?void 0:te.bitrate/(w.speed>0?w.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:Qt,ABR_EXIT_BUFFER_BASED_ALGO:$t}=U.getCurrent();A&&q<=$t?A=!1:!A&&isFinite(q)&&q>=Qt&&(A=!0);let _e=Zr(me,je),Xt=C.getLastEstimate(),ur=_e.bitrate,ot=null;A&&Xt!==void 0&&Xt>ur&&(ot=Zr(me,Xt),ur=ot.bitrate);let st=null;return a&&J!==null&&e.manifest.isDynamic&&X-$.getWanted()<40&&(st=B.getGuess(k,w,J,ur,le)),st!==null&&st.bitrate>ur?(c.debug(\"ABR: Choosing representation with guess-based estimation.\",st.bitrate,st.id),O.update(st,pe,2),{bitrate:pe,representation:st,urgent:J===null||st.bitrate<J.bitrate,knownStableBitrate:ae}):ot!==null?(c.debug(\"ABR: Choosing representation with buffer-based estimation.\",ot.bitrate,ot.id),O.update(ot,pe,0),{bitrate:pe,representation:ot,urgent:f.isUrgent(ot.bitrate,J,le,w),knownStableBitrate:ae}):(c.debug(\"ABR: Choosing representation with bandwidth estimation.\",_e.bitrate,_e.id),O.update(_e,pe,1),{bitrate:pe,representation:_e,urgent:f.isUrgent(_e.bitrate,J,le,w),knownStableBitrate:ae})}}function y(){let _=s.getValue();p.cancel(),p=new F,p.linkToSignal(u),h(_,p.signal).onUpdate(function(k){b.setValue(k)},{clearSignal:p.signal,emitCurrentValue:!0})}function E(_){let{requestDuration:M,segmentDuration:A,size:k,content:C}=_;if(n.addSample(M,k),!C.segment.isInit){let{segment:O,representation:B}=C;if(A===void 0&&!O.complete)return;let w=A!=null?A:O.duration;d.addSample(B,M/1e3,w)}}function R(_){l.add(_)}function T(_){l.addProgress(_)}function v(_){l.remove(_.id)}}function Wf(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Ya(r,t)),e!==void 0&&(r=Qa(r,e)),r}var gu=$a;function Jr(){var t;if(typeof((t=ue.crypto)==null?void 0:t.randomUUID)==\"function\")return ue.crypto.randomUUID();let n=new Date().getTime(),e=L();return\"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g,function(r){let i=Math.random()*16;return n>0?(i=(n+i)%16|0,n=Math.floor(n/16)):(i=(e+i)%16|0,e=Math.floor(e/16)),(r===\"x\"?i:i&3|8).toString(16)})}var qf=4,ar=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Jr(),this._contentId=(r=e.contentId)!=null?r:Jr(),this._typePreference=e.communicationType===\"headers\"?0:1,this._bufferStarvationToggle=!1,this._playbackObserver=null,this._lastThroughput={},this._canceller=null}startMonitoringPlayback(e){var t;(t=this._canceller)==null||t.cancel(),this._canceller=new F,this._playbackObserver=e,e.listen(r=>{r.rebuffering!==null&&(this._bufferStarvationToggle=!0)},{includeLastObservation:!0,clearSignal:this._canceller.signal})}stopMonitoringPlayback(){var e;(e=this._canceller)==null||e.cancel(),this._canceller=null,this._playbackObserver=null}updateThroughput(e,t){this._lastThroughput[e]=t}_getCommonCmcdData(e){var i;let t={};t.bs=this._bufferStarvationToggle,this._bufferStarvationToggle=!1,t.cid=this._contentId,t.mtp=e!==void 0?Math.floor(Math.round(e/1e3/100)*100):void 0,t.sid=this._sessionId;let r=(i=this._playbackObserver)==null?void 0:i.getReference().getValue();return t.pr=r===void 0||r.speed===1?void 0:r.speed,r!==void 0&&(t.su=r.rebuffering!==null),t}getCmcdDataForManifest(e){var r;let t=this._getCommonCmcdData((r=this._lastThroughput.video)!=null?r:this._lastThroughput.audio);switch(t.ot=\"m\",e){case\"dash\":t.sf=\"d\";break;case\"smooth\":t.sf=\"s\";break;default:t.sf=\"o\";break}return this._producePayload(t)}getCmcdDataForSegmentRequest(e){var o,s,u,d;let t=(o=this._playbackObserver)==null?void 0:o.getReference().getValue(),r=this._getCommonCmcdData(this._lastThroughput[e.adaptation.type]);switch(r.br=Math.round(e.representation.bitrate/1e3),r.d=Math.round(e.segment.duration*1e3),e.adaptation.type){case\"video\":r.ot=\"v\";break;case\"audio\":r.ot=\"a\";break;case\"text\":r.ot=\"c\";break}if(e.segment.isInit&&(r.ot=\"i\"),!P(e.nextSegment)&&e.segment.url!==null&&e.nextSegment.url!==null&&(!e.nextSegment.isInit||e.nextSegment.indexRange===void 0)){let f=e.segment.url,l=e.nextSegment.url,m=es(f,l);m!==null&&(m!==\".\"&&(r.nor=encodeURIComponent(m)),e.nextSegment.range!==void 0&&(r.nrr=String(e.nextSegment.range[0])+\"-\",isFinite(e.nextSegment.range[1])&&(r.nrr+=String(e.nextSegment.range[1]))))}let i;if(t!==void 0&&(r.ot===\"v\"||r.ot===\"a\"||r.ot===\"av\")){let f=t.buffered[e.adaptation.type];if(!P(f)){let l=(d=(u=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?u:t.position.getWanted())!=null?d:t.position.getPolled();for(let m of f)if(l>=m.start&&l<m.end){i=(m.end-l)*1e3,r.bl=Math.floor(Math.round(i/100)*100);break}}}let a=i===void 0||t===void 0?void 0:i/t.speed;if(r.dl=a===void 0?void 0:Math.floor(Math.round(a/100)*100),a!==void 0){let l=e.representation.bitrate*e.segment.duration/1e3/(a/1e3);r.rtp=Math.floor(Math.round(l*qf/100)*100)}switch(e.manifest.transport){case\"dash\":r.sf=\"d\";break;case\"smooth\":r.sf=\"s\";break;default:r.sf=\"o\";break}return r.st=e.manifest.isDynamic?\"l\":\"v\",r.tb=e.adaptation.representations.reduce((f,l)=>l.isPlayable()!==!0?f:f===void 0?Math.round(l.bitrate/1e3):Math.max(f,Math.round(l.bitrate/1e3)),void 0),this._producePayload(r)}_producePayload(e){let t={object:\"\",request:\"\",session:\"\",status:\"\"},r=\"\",i=(d,f)=>{this._typePreference===0?t[f]+=d:r+=d},a=(d,f)=>{let l=e[d];if(l!==void 0){let m=`${d}=${String(l)},`;i(m,f)}},o=(d,f)=>{if(e[d]===!0){let l=`${d},`;i(l,f)}},s=(d,f)=>{let l=e[d];if(l!==void 0){let g=`prop=${`\"${l.replace(\"\\\\\",\"\\\\\\\\\").replace('\"','\\\\\"')}\"`},`;i(g,f)}},u=(d,f)=>{let l=e[d];if(l!==void 0){let m=`prop=${l},`;i(m,f)}};return a(\"bl\",\"request\"),a(\"br\",\"object\"),o(\"bs\",\"status\"),s(\"cid\",\"session\"),a(\"d\",\"object\"),a(\"dl\",\"request\"),a(\"mtp\",\"request\"),s(\"nor\",\"request\"),s(\"nrr\",\"request\"),u(\"ot\",\"object\"),a(\"pr\",\"session\"),a(\"rtp\",\"status\"),u(\"sf\",\"session\"),s(\"sid\",\"session\"),u(\"st\",\"session\"),o(\"su\",\"request\"),a(\"tb\",\"object\"),this._typePreference===0?(t.object[t.object.length-1]===\",\"&&(t.object=t.object.substring(0,t.object.length-1)),t.request[t.request.length-1]===\",\"&&(t.request=t.request.substring(0,t.request.length-1)),t.session[t.session.length-1]===\",\"&&(t.session=t.session.substring(0,t.session.length-1)),t.status[t.status.length-1]===\",\"&&(t.status=t.status.substring(0,t.status.length-1)),c.debug(\"CMCD: proposing headers payload\"),{type:\"headers\",value:{\"CMCD-Object\":t.object,\"CMCD-Request\":t.request,\"CMCD-Session\":t.session,\"CMCD-Status\":t.status}}):(r[r.length-1]===\",\"&&(r=r.substring(0,r.length-1)),r=encodeURIComponent(r),c.debug(\"CMCD: proposing query string payload\",r),{type:\"query\",value:[[\"CMCD\",r]]})}};var hu=ar;var Iu=6,Xa=4e3,ei=6e3,Vf=6e4,jt=class{constructor(e){this._segmentSinksStore=e,this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=null,this._lastFlushAttempt=null,this._lastSegmentInfo={audio:[],video:[]}}onNewObservation(e){var h,y;let t=L();if(this._addPositionToHistory(e,t),this._ignoreFreezeUntil!==null&&t<this._ignoreFreezeUntil)return null;this._ignoreFreezeUntil=null;let{UNFREEZING_SEEK_DELAY:r,UNFREEZING_DELTA_POSITION:i,FREEZING_FLUSH_FAILURE_DELAY:a}=U.getCurrent(),{readyState:o,rebuffering:s,freezing:u,fullyLoaded:d}=e,f=e.position.getPolled(),l=bu(e.bufferGap);if(!(u!==null||s!==null&&o===1&&(l>=Iu||d)))return this._decipherabilityFreezeStartingTimestamp=null,null;let g=(y=(h=u==null?void 0:u.timestamp)!=null?h:s==null?void 0:s.timestamp)!=null?y:null;if(c.info(\"FR: Freeze detected\",g,t-(g!=null?g:t)),this._lastFlushAttempt!==null&&t-this._lastFlushAttempt.timestamp<a.MAXIMUM&&t-this._lastFlushAttempt.timestamp>=a.MINIMUM&&Math.abs(f-this._lastFlushAttempt.position)<a.POSITION_DELTA){let E=this._getStrategyIfFlushingFails(f);return this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+ei,E}let b=this._checkForDecipherabilityRelatedFreeze(e,t);return b!==null?b:g!==null&&t-g>r?(this._lastFlushAttempt={timestamp:t,position:f+i},c.debug(\"FR: trying to flush to un-freeze\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+ei,{type:\"flush\",value:{relativeSeek:i}}):null}_checkForDecipherabilityRelatedFreeze(e,t){let{readyState:r,rebuffering:i,freezing:a,fullyLoaded:o}=e,s=bu(e.bufferGap),u=i!==null&&t-i.timestamp>Xa,d=a!==null&&t-a.timestamp>Xa;(u||d)&&(s>=Iu||o)&&r<=1?this._decipherabilityFreezeStartingTimestamp===null&&(c.debug(\"FR: Start of a potential decipherability freeze detected\"),this._decipherabilityFreezeStartingTimestamp=t):this._decipherabilityFreezeStartingTimestamp=null;let l=this._decipherabilityFreezeStartingTimestamp!==null&&L()-this._decipherabilityFreezeStartingTimestamp>Xa,m=!0,g=!0;for(let p of[\"audio\",\"video\"]){let b=this._segmentSinksStore.getStatus(p);if(b.type===\"initialized\")for(let h of b.value.getLastKnownInventory()){let{representation:y}=h.infos;if(y.decipherable===!1)return c.warn(\"FR: we have undecipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+ei,{type:\"reload\",value:null};y.contentProtections!==void 0&&(g=!1,y.decipherable!==!0&&(m=!1))}}return l&&!g&&m?(c.warn(\"FR: we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+ei,{type:\"reload\",value:null}):null}_getStrategyIfFlushingFails(e){c.warn(\"FR: A recent flush seemed to have no effect on freeze, checking for transitions\");let t=[];for(let r of[\"audio\",\"video\"]){let i=this._lastSegmentInfo[r];if(i.length===0)continue;let a=i[i.length-1];if(a.segment===null)continue;let o=a.segment,s;for(let u=i.length-2;u>=0;u--){let d=i[u];if(d.segment===null){s=d;break}else if(d.segment.infos.representation.uniqueId!==o.infos.representation.uniqueId&&a.timestamp-d.timestamp<5e3){s=d;break}else d.segment.start===o.start&&e-d.position<3e3&&(a=d)}if(s===void 0||s.segment===null)c.debug(\"FR: Freeze when beginning to play a content, try avoiding this quality\"),t.push({adaptation:o.infos.adaptation,period:o.infos.period,representation:o.infos.representation});else{if(o.infos.period.id!==s.segment.infos.period.id)return c.debug(\"FR: Freeze when switching Period, reloading\"),{type:\"reload\",value:null};o.infos.representation.uniqueId!==s.segment.infos.representation.uniqueId&&(c.warn(\"FR: Freeze when switching Representation, avoiding\",o.infos.representation.bitrate),t.push({adaptation:o.infos.adaptation,period:o.infos.period,representation:o.infos.representation}))}}return t.length>0?{type:\"avoid-representations\",value:t}:(c.debug(\"FR: Reloading because flush doesn't work\"),{type:\"reload\",value:null})}_addPositionToHistory(e,t){var i,a;let r=e.position.getPolled();for(let o of[\"audio\",\"video\"]){let s=this._segmentSinksStore.getStatus(o);if(s.type===\"initialized\")for(let f of s.value.getLastKnownInventory())((i=f.bufferedStart)!=null?i:f.start)<=r&&((a=f.bufferedEnd)!=null?a:f.end)>r&&this._lastSegmentInfo[o].push({segment:f,position:r,timestamp:t});else this._lastSegmentInfo[o].push({segment:null,position:r,timestamp:t});if(this._lastSegmentInfo[o].length>100){let f=this._lastSegmentInfo[o].length-100;this._lastSegmentInfo[o].splice(0,f)}let u=t-Vf,d;for(d=0;d<this._lastSegmentInfo[o].length&&!(this._lastSegmentInfo[o][d].timestamp>u);d++);d>0&&this._lastSegmentInfo[o].splice(0,d)}}};function bu(n){return n!==void 0&&isFinite(n)?n:0}var{DEFAULT_WANTED_BUFFER_AHEAD:Hf,DEFAULT_MAX_VIDEO_BUFFER_SIZE:Gf,DEFAULT_MAX_BUFFER_AHEAD:Kf,DEFAULT_MAX_BUFFER_BEHIND:jf}=U.getCurrent(),Za=new Y(Hf),Ja=new Y(Gf),eo=new Y(Kf),to=new Y(jf),ti=new Y({height:void 0,width:void 0,pixelRatio:1}),ni=new Y(1/0);function Q(n,e){c.debug(\"<--- Sending to Main:\",n.type),e===void 0?postMessage(n):postMessage(n,e)}function Ae(n){return ge(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var or=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,u,d,f,l,m;for(let g of this._refs.keys())(t=(e=this._refs.get(g))==null?void 0:e.audio)==null||t.trackReference.finish(),(i=(r=this._refs.get(g))==null?void 0:r.audio)==null||i.representations.finish(),(o=(a=this._refs.get(g))==null?void 0:a.video)==null||o.trackReference.finish(),(u=(s=this._refs.get(g))==null?void 0:s.video)==null||u.representations.finish(),(f=(d=this._refs.get(g))==null?void 0:d.text)==null||f.trackReference.finish(),(m=(l=this._refs.get(g))==null?void 0:l.text)==null||m.representations.finish();this._refs=new Map}addTrackSetter(e,t,r){var s,u;let i=this._refs.get(e);i===void 0&&(i={},this._refs.set(e,i)),i[t]!==void 0&&(c.warn(\"WP: Track for periodId already declared\",e,t),(s=i[t])==null||s.trackReference.finish(),(u=i[t])==null||u.representations.finish());let a=r.getValue(),o;P(a)?o=new Y({representationIds:[],switchingMode:\"lazy\"}):(o=new Y(a.representations.getValue()),r.setValue(G({},a,{representations:o}))),i[t]={trackReference:r,representations:o}}setTrack(e,t,r){var a;let i=(a=this._refs.get(e))==null?void 0:a[t];return i===void 0?(c.debug(\"WP: Setting track for inexistent periodId\",e,t),!1):(P(r)?(i.representations=new Y({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new Y(r.initialRepresentations),i.trackReference.setValue({adaptationId:r.adaptationId,switchingMode:r.switchingMode,representations:i.representations,relativeResumingPosition:r.relativeResumingPosition})),!0)}updateRepresentations(e,t,r,i){var s;let a=(s=this._refs.get(e))==null?void 0:s[r];if(a===void 0)return c.debug(\"WP: Setting track for inexistent periodId\",e,r),!1;let o=a.trackReference.getValue();return P(o)||o.adaptationId!==t?(c.debug(\"WP: Desynchronized Adaptation id\",o==null?void 0:o.adaptationId,t),!1):(a.representations.setValue(i),!0)}removeTrackSetter(e,t){let r=this._refs.get(e),i=r==null?void 0:r[t];return r===void 0||i===void 0?(c.debug(\"WP: Removing track setter for inexistent periodId\",e,t),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};var sr=class{constructor(e,t){this._contentId=e,this._messageSender=t,this._queues={pushTextData:[],remove:[]}}pushTextData(e){return new Promise((t,r)=>{this._messageSender({type:\"push-text-data\",contentId:this._contentId,value:e}),this._queues.pushTextData.push({resolve:t,reject:r})})}remove(e,t){return new Promise((r,i)=>{this._messageSender({type:\"remove-text-data\",contentId:this._contentId,value:{start:e,end:t}}),this._queues.remove.push({resolve:r,reject:i})})}reset(){this._messageSender({type:\"reset-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}stop(){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}_resetCurrentQueue(){let e=new se;this._queues.pushTextData.forEach(t=>{t.reject(e)}),this._queues.remove.forEach(t=>{t.reject(e)})}onPushedTrackSuccess(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"WMS: remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}};var Su=xe(),Yt=class{constructor({hasMseInWorker:e,hasVideo:t}){this._currentContent=null,this._currentMediaSourceCanceller=new F,this._hasVideo=t,this._hasMseInWorker=e;let r=new F;this._contentCanceller=r}initializeNewContent(e){return new Promise((t,r)=>{var O,B;this.disposeCurrentContent();let i=this._contentCanceller,a=new F;this._currentMediaSourceCanceller=a,a.linkToSignal(i.signal);let{contentId:o,url:s,hasText:u,transportOptions:d,enableRepresentationAvoidance:f}=e,l=null;ce(Oe.transports.dash!==void 0,\"Multithread RxPlayer should have access to the DASH feature\");let m=typeof d.representationFilter==\"string\"?To(d.representationFilter):void 0,g=Oe.transports.dash(oe(ee({},d),{representationFilter:m})),p=e.cmcd===void 0?null:new hu(e.cmcd),b=new Ba(s===void 0?void 0:[s],g,ee({cmcdDataBuilder:p},e.manifestRetryOptions)),h=gu({initialBitrates:{audio:(O=e.initialAudioBitrate)!=null?O:0,video:(B=e.initialVideoBitrate)!=null?B:0},lowLatencyMode:d.lowLatencyMode,throttlers:{limitResolution:{video:ti},throttleBitrate:{video:ni}}}),y=a.signal.register(w=>{r(w)}),E=new Wn(i.signal),R=new za(g,E,p,e.segmentRetryOptions),T=Yr(g.thumbnails,E),v=new or,[_,M,A]=yu(o,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:u},a.signal),k=new jt(M);this._currentContent={cmcdDataBuilder:p,contentId:o,enableRepresentationAvoidance:f,freezeResolver:k,mediaSource:_,manifest:null,manifestFetcher:b,representationEstimator:h,segmentSinksStore:M,segmentQueueCreator:R,fetchThumbnailData:T,workerTextSender:A,trackChoiceSetter:v},_.addEventListener(\"mediaSourceOpen\",function(){C()},a.signal),i.signal.register(()=>{b.dispose()}),b.addEventListener(\"warning\",w=>{Q({type:\"warning\",contentId:o,value:Ae(w)})},i.signal),b.addEventListener(\"manifestReady\",w=>{if(l!==null){c.warn(\"WP: Multiple `manifestReady` events, ignoring\");return}l=w,this._currentContent!==null&&(this._currentContent.manifest=l),C()},a.signal),b.addEventListener(\"error\",w=>{Q({type:\"error\",contentId:o,value:Ae(w)}),r(w)},i.signal),b.start();function C(){if(l===null||_.readyState===\"closed\"||a.isUsed())return;Yf(l);let w=l.getMetadataSnapshot();l.addEventListener(\"manifestUpdate\",x=>{if(l===null)return;let D=G(l.getMetadataSnapshot(),{periods:[]});Q({type:\"manifest-update\",contentId:o,value:{manifest:D,updates:x}})},i.signal),y(),t(w)}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new F,Q({type:\"reloading-media-source\",contentId:this._currentContent.contentId,value:e},[]);let[t,r,i]=yu(this._currentContent.contentId,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.workerTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.freezeResolver=new jt(r),this._currentContent.workerTextSender=i,new Promise((a,o)=>{t.addEventListener(\"mediaSourceOpen\",function(){a()},this._currentMediaSourceCanceller.signal),t.addEventListener(\"mediaSourceClose\",function(){o(new Error(\"MediaSource ReadyState changed to close during init.\"))},this._currentMediaSourceCanceller.signal),this._currentMediaSourceCanceller.signal.register(s=>{o(s)})})}disposeCurrentContent(){this._contentCanceller.cancel(),this._contentCanceller=new F}};function yu(n,e,t){let r;if(e.hasMseInWorker){let s=new $n(Su());r=s;let u,d=s.handle;if(d.type===\"handle\")u={type:\"handle\",value:d.value};else{let f=URL.createObjectURL(d.value);u={type:\"url\",value:f},t.register(()=>{URL.revokeObjectURL(f)})}Q({type:\"attach-media-source\",contentId:n,value:u,mediaSourceId:r.id},[d.value])}else r=new Xn(Su(),n,Q);let i=e.hasText?new sr(n,Q):null,{hasVideo:a}=e,o=new bt(r,a,i);return t.register(()=>{o.disposeAll(),i==null||i.stop(),r.dispose()}),[r,o,i]}function Yf(n){var t,r;if(P(lt))return;let e=new Map;for(let i of n.periods){let a=[...(t=i.adaptations.video)!=null?t:[],...(r=i.adaptations.audio)!=null?r:[]];for(let o of a)for(let s of o.representations){let u=`${s.mimeType};codecs=\"${s.codecs[0]}\"`;if(e.has(u))s.isCodecSupportedInWebWorker=e.get(u);else{let d=lt.isTypeSupported(u);s.isCodecSupportedInWebWorker=d,e.set(u,d)}}}}function no(){let n=!1,e=new Yt({hasMseInWorker:!1,hasVideo:!0}),t=null,r=new Ps;Oe.dashParsers.wasm=r,Oe.dashParsers.fastJs=fs,Oe.transports.dash=Ns;let i=null;ue.onmessageerror=a=>{c.error(\"MTCI: Error when receiving message from main thread.\")},onmessage=function(a){var s,u;c.debug(\"Worker: received message\",a.data.type);let o=a.data;switch(o.type){case\"init\":ce(!n),n=!0,so(o.value),Tu(o.value.logLevel,o.value.logFormat,o.value.sendBackLogs),o.value.dashWasmUrl!==void 0&&r.isCompatible()&&r.initialize({wasmUrl:o.value.dashWasmUrl}).catch(d=>{let f=d instanceof Error?d.toString():\"Unknown Error\";c.error(\"Worker: Could not initialize DASH_WASM parser\",f)}),(!o.value.hasVideo||o.value.hasMseInWorker)&&(e.disposeCurrentContent(),e=new Yt({hasMseInWorker:o.value.hasMseInWorker,hasVideo:o.value.hasVideo})),Q({type:\"init-success\",value:null});break;case\"log-level-update\":Tu(o.value.logLevel,o.value.logFormat,o.value.sendBackLogs);break;case\"prepare\":Qf(e,o.value);break;case\"start\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;t!==null&&(t.cancel(),t=null);let f=new F,l=new Y(G(o.value.initialObservation,{position:new At(...o.value.initialObservation.position)}));i=l,t=f,t.signal.register(()=>{l.finish()}),c.debug(\"WP: Loading new pepared content.\"),Eu(o.value,e,l,f.signal);break}case\"observation\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;let f=o.value,{buffered:l}=f,m=Da(d.mediaSource,null);m.audio!==null&&(l.audio=m.audio),m.video!==null&&(l.video=m.video),i==null||i.setValue(G(f,{position:new At(...o.value.position)}));break}case\"ref-update\":$f(o);break;case\"stop\":if(o.contentId!==((s=e.getCurrentContent())==null?void 0:s.contentId))return;e.disposeCurrentContent(),t!==null&&(t.cancel(),t=null);break;case\"sb-success\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,l=j(f,m=>m.type===o.sourceBufferType);if(l===void 0){c.info(\"WP: Success for an unknown SourceBuffer\",o.sourceBufferType);return}if(l.onOperationSuccess===void 0){c.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}l.onOperationSuccess(o.operationId,o.value.buffered);break}case\"sb-error\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,l=j(f,m=>m.type===o.sourceBufferType);if(l===void 0){c.info(\"WP: Error for an unknown SourceBuffer\",o.sourceBufferType);return}if(l.onOperationFailure===void 0){c.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}l.onOperationFailure(o.operationId,o.value);break}case\"media-source-ready-state-change\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;if(d.mediaSource.onMediaSourceReadyStateChanged===void 0){c.warn(\"WP: A MediaSourceInterface with MSE performed a cross-thread operation\");return}d.mediaSource.onMediaSourceReadyStateChanged(o.value);break}case\"decipherability-update\":{if(o.contentId!==((u=e.getCurrentContent())==null?void 0:u.contentId))return;let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let f=o.value;d.manifest.updateRepresentationsDeciperability(l=>{for(let m of f)if(l.representation.uniqueId===m.representationUniqueId)return m.decipherable;return l.representation.decipherable});break}case\"codec-support-update\":{let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let f=o.value;try{let l=d.manifest.updateCodecSupport(f);l!==null&&Q({type:\"warning\",contentId:d.contentId,value:Ae(l)})}catch(l){Q({type:\"error\",contentId:d.contentId,value:Ae(l)})}break}case\"urls-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.manifestFetcher.updateContentUrls(o.value.urls,o.value.refreshNow);break}case\"track-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.setTrack(o.value.periodId,o.value.bufferType,o.value.choice);break}case\"rep-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.updateRepresentations(o.value.periodId,o.value.adaptationId,o.value.bufferType,o.value.choice);break}case\"add-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackSuccess(o.value.ranges);break}case\"push-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackError(new Error(o.value.message));break}case\"remove-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveSuccess(o.value.ranges);break}case\"remove-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveError(new Error(o.value.message));break}case\"pull-segment-sink-store-infos\":{Xf(e,o.value.requestId);break}case\"thumbnail-request\":{Jf(e,o);break}case\"config-update\":{U.update(o.value);break}default:De(o)}}}function Qf(n,e){n.initializeNewContent(e).then(t=>{Q({type:\"manifest-ready\",contentId:e.contentId,value:{manifest:t}})},t=>{Q({type:\"error\",contentId:e.contentId,value:Ae(t)})})}function $f(n){switch(n.value.name){case\"wantedBufferAhead\":Za.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":Ja.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":to.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":eo.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":ti.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":ni.setValueIfChanged(n.value.newVal);break;default:De(n.value)}}function Eu(n,e,t,r){var k;c.debug(\"WP: Loading prepared content\");let i=new F;i.linkToSignal(r);let a=new Map,o=e.getCurrentContent();if(o===null||o.manifest===null){let C=new Ee(\"NONE\",\"Loading content when none is prepared\");Q({type:\"error\",contentId:void 0,value:Ae(C)});return}let{contentId:s,cmcdDataBuilder:u,enableRepresentationAvoidance:d,manifest:f,mediaSource:l,representationEstimator:m,segmentSinksStore:g,segmentQueueCreator:p}=o,{drmSystemId:b,enableFastSwitching:h,initialTime:y,onCodecSwitch:E}=n;t.onUpdate(C=>{qa(C,g);let O=o.freezeResolver.onNewObservation(C);O!==null&&Zf(O,{contentId:s,manifest:f,handleMediaSourceReload:A,enableRepresentationAvoidance:d})},{clearSignal:i.signal});let R=(k=f.getPeriodForTime(y))!=null?k:f.getNextPeriod(y);if(R===void 0){let C=new Z(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");Q({type:\"error\",contentId:s,value:Ae(C)});return}let T=new An(t,s,Q,i.signal);u==null||u.startMonitoringPlayback(T),i.signal.register(()=>{u==null||u.stopMonitoringPlayback()});let v=wa(f,l,T,g,{onWarning:C=>Q({type:\"warning\",contentId:s,value:Ae(C)}),onPeriodChanged:C=>{Q({type:\"active-period-changed\",contentId:s,value:{periodId:C.id}})}},i.signal);nu({initialPeriod:R,manifest:f},T,m,g,p,{wantedBufferAhead:Za,maxVideoBufferSize:Ja,maxBufferAhead:eo,maxBufferBehind:to,drmSystemId:b,enableFastSwitching:h,onCodecSwitch:E},_(),i.signal);function _(){return{needsBufferFlush(C){Q({type:\"needs-buffer-flush\",contentId:s,value:C})},streamStatusUpdate(C){M(C),f.isLastPeriodKnown&&C.period.id===f.periods[f.periods.length-1].id&&(C.hasFinishedLoading||C.isEmptyStream?v.onLastSegmentFinishedLoading(C.bufferType):v.onLastSegmentLoadingResume(C.bufferType))},needsManifestRefresh(){e.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:C}=U.getCurrent();e.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:C})},lockedStream(C){Q({type:\"locked-stream\",contentId:s,value:{periodId:C.period.id,bufferType:C.bufferType}})},adaptationChange(C){var O,B;v.onAdaptationChange(C.type,C.period,C.adaptation),!i.signal.isCancelled()&&Q({type:\"adaptation-changed\",contentId:s,value:{adaptationId:(B=(O=C.adaptation)==null?void 0:O.id)!=null?B:null,periodId:C.period.id,type:C.type}})},representationChange(C){var O,B;v.onRepresentationChange(C.type,C.period),!i.signal.isCancelled()&&Q({type:\"representation-changed\",contentId:s,value:{adaptationId:C.adaptation.id,representationId:(B=(O=C.representation)==null?void 0:O.id)!=null?B:null,periodId:C.period.id,type:C.type}})},inbandEvent(C){Q({type:\"inband-event\",contentId:s,value:C})},warning(C){Q({type:\"warning\",contentId:s,value:Ae(C)})},periodStreamReady(C){o!==null&&(o.trackChoiceSetter.addTrackSetter(C.period.id,C.type,C.adaptationRef),Q({type:\"period-stream-ready\",contentId:s,value:{periodId:C.period.id,bufferType:C.type}}))},periodStreamCleared(C){if(o===null)return;let O=a.get(C.period);O!==void 0&&(O.delete(C.type),O.size===0&&a.delete(C.period)),v.onPeriodCleared(C.type,C.period),o.trackChoiceSetter.removeTrackSetter(C.period.id,C.type),Q({type:\"period-stream-cleared\",contentId:s,value:{periodId:C.period.id,bufferType:C.type}})},bitrateEstimateChange(C){var O;o!==null&&((O=o.cmcdDataBuilder)==null||O.updateThroughput(C.type,C.bitrate)),Q({type:\"bitrate-estimate-change\",contentId:s,value:{bitrate:C.bitrate,bufferType:C.type}})},needsMediaSourceReload(C){A(C)},needsDecipherabilityFlush(){Q({type:\"needs-decipherability-flush\",contentId:s,value:null})},encryptionDataEncountered(C){for(let O of C){let B=O.content,w=ee({},B);w.manifest instanceof Ut&&(w.manifest=w.manifest.getMetadataSnapshot()),w.period instanceof mt&&(w.period=w.period.getMetadataSnapshot()),w.adaptation instanceof dt&&(w.adaptation=w.adaptation.getMetadataSnapshot()),w.representation instanceof on&&(w.representation=w.representation.getMetadataSnapshot()),Q({type:\"encryption-data-encountered\",contentId:s,value:{keyIds:O.keyIds,values:O.values,content:w,type:O.type}})}},error(C){Q({type:\"error\",contentId:s,value:Ae(C)})}}}function M(C){let{imminentDiscontinuity:O}=C,B=a.get(C.period),w=B==null?void 0:B.get(C.bufferType);if(w!==void 0){if(w.discontinuity===null){if(O===null)return}else if(O!==null&&w.discontinuity.start===O.start&&w.discontinuity.end===O.end)return}B===void 0&&(B=new Map,a.set(C.period,B));let x={periodId:C.period.id,bufferType:C.bufferType,discontinuity:C.imminentDiscontinuity,position:C.position};B.set(C.bufferType,x),Q({type:\"discontinuity-update\",contentId:s,value:x})}function A(C){let B=t.getValue().position.getWanted();i!==null&&i.cancel(),c.debug(\"WP: Reloading MediaSource\",C.timeOffset,C.minimumPosition,C.maximumPosition),e.reloadMediaSource(C).then(()=>{c.info(\"WP: MediaSource Reloaded, loading content again\"),Eu({initialTime:B,drmSystemId:n.drmSystemId,enableFastSwitching:n.enableFastSwitching,onCodecSwitch:n.onCodecSwitch},e,t,r)},w=>{if(F.isCancellationError(w)){c.info(\"WP: A reloading operation was cancelled\");return}Q({type:\"error\",contentId:s,value:Ae(w)})})}}function Tu(n,e,t){t?c.setLevel(n,\"standard\",(r,i)=>{let a=i.map(o=>o instanceof Error?Ae(o):o);postMessage({type:\"log\",value:{logLevel:r,logs:a}})}):c.setLevel(n,e)}function Xf(n,e){let t=n.getCurrentContent();if(t===null)return;let r=t.segmentSinksStore.getSegmentSinksMetrics();Q({type:\"segment-sink-store-update\",contentId:t.contentId,value:{segmentSinkMetrics:r,requestId:e}})}function Zf(n,{contentId:e,manifest:t,handleMediaSourceReload:r,enableRepresentationAvoidance:i}){switch(n.type){case\"reload\":{c.info(\"WP: Planning reload due to freeze\"),r({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}case\"flush\":{c.info(\"WP: Flushing buffer due to freeze\"),Q({type:\"needs-buffer-flush\",contentId:e,value:{relativeResumingPosition:n.value.relativeSeek,relativePosHasBeenDefaulted:!1}});break}case\"avoid-representations\":{c.info(\"WP: Planning Representation avoidance due to freeze\");let a=n.value;i&&t.addRepresentationsToAvoid(a),r({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}default:De(n)}}function Jf(n,e){let t=n.getCurrentContent(),r=i=>{Q({type:\"thumbnail-response\",contentId:e.contentId,value:{status:\"error\",requestId:e.value.requestId,error:Ae(i)}})};if(t===null||t.manifest===null||t.contentId!==e.contentId)return r(new Error(\"Content changed\"));Wa(t.fetchThumbnailData,t.manifest,e.value.periodId,e.value.thumbnailTrackId,e.value.time).then(i=>{Q({type:\"thumbnail-response\",contentId:e.contentId,value:{status:\"success\",requestId:e.value.requestId,data:i}},[i.data])},i=>r(i))}var _u=no;_u();})();\n" + "})()"], { type: "application/javascript" });
5
5
  exports.EMBEDDED_WORKER = blob;
6
6
  exports.default = blob;