rx-player 4.4.0 → 4.4.1-dev.2025101500

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 (341) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +52 -113
  3. package/VERSION +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  5. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  6. package/dist/commonjs/core/{main/common → entry}/FreezeResolver.d.ts +3 -3
  7. package/dist/commonjs/core/entry/FreezeResolver.d.ts.map +1 -0
  8. package/dist/commonjs/core/{main/common → entry}/FreezeResolver.js +3 -3
  9. package/dist/{es2017/core/main/worker → commonjs/core/entry}/content_preparer.d.ts +22 -15
  10. package/dist/commonjs/core/entry/content_preparer.d.ts.map +1 -0
  11. package/dist/commonjs/core/{main/worker → entry}/content_preparer.js +62 -64
  12. package/dist/{es2017/core/main/common → commonjs/core/entry}/content_time_boundaries_observer.d.ts +5 -5
  13. package/dist/commonjs/core/entry/content_time_boundaries_observer.d.ts.map +1 -0
  14. package/dist/commonjs/core/{main/common → entry}/content_time_boundaries_observer.js +6 -6
  15. package/dist/commonjs/core/entry/core_entry.d.ts +36 -0
  16. package/dist/commonjs/core/entry/core_entry.d.ts.map +1 -0
  17. package/dist/commonjs/core/{main/worker/worker_main.js → entry/core_entry.js} +192 -153
  18. package/dist/commonjs/core/{main/worker/worker_text_displayer_interface.d.ts → entry/core_text_displayer_interface.d.ts} +11 -11
  19. package/dist/commonjs/core/entry/core_text_displayer_interface.d.ts.map +1 -0
  20. package/dist/commonjs/core/{main/worker/worker_text_displayer_interface.js → entry/core_text_displayer_interface.js} +22 -22
  21. package/dist/commonjs/core/{main/common → entry}/create_content_time_boundaries_observer.d.ts +6 -6
  22. package/dist/commonjs/core/entry/create_content_time_boundaries_observer.d.ts.map +1 -0
  23. package/dist/commonjs/core/{main/common → entry}/create_content_time_boundaries_observer.js +1 -1
  24. package/dist/commonjs/core/{main/common → entry}/get_buffered_data_per_media_buffer.d.ts +4 -4
  25. package/dist/commonjs/core/entry/get_buffered_data_per_media_buffer.d.ts.map +1 -0
  26. package/dist/commonjs/core/{main/common → entry}/get_buffered_data_per_media_buffer.js +1 -1
  27. package/dist/{es2017/core/main/common → commonjs/core/entry}/get_thumbnail_data.d.ts +3 -3
  28. package/dist/commonjs/core/entry/get_thumbnail_data.d.ts.map +1 -0
  29. package/dist/commonjs/core/{main/common → entry}/get_thumbnail_data.js +2 -2
  30. package/dist/commonjs/core/entry/index.d.ts +5 -0
  31. package/dist/commonjs/core/entry/index.d.ts.map +1 -0
  32. package/dist/commonjs/core/entry/index.js +4 -0
  33. package/dist/{es2017/core/main/common → commonjs/core/entry}/synchronize_sinks_on_observation.d.ts +2 -2
  34. package/dist/commonjs/core/entry/synchronize_sinks_on_observation.d.ts.map +1 -0
  35. package/dist/commonjs/core/{main/worker → entry}/track_choice_setter.d.ts +4 -4
  36. package/dist/commonjs/core/entry/track_choice_setter.d.ts.map +1 -0
  37. package/dist/commonjs/core/{main/worker → entry}/track_choice_setter.js +4 -4
  38. package/dist/commonjs/core/entry/utils.d.ts +3 -0
  39. package/dist/commonjs/core/entry/utils.d.ts.map +1 -0
  40. package/dist/commonjs/core/entry/utils.js +11 -0
  41. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.d.ts.map +1 -1
  42. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +17 -0
  43. package/dist/commonjs/core/types.d.ts +519 -1
  44. package/dist/commonjs/core/types.d.ts.map +1 -1
  45. package/dist/commonjs/core/types.js +1 -0
  46. package/dist/commonjs/experimental/features/local.d.ts.map +1 -1
  47. package/dist/commonjs/experimental/features/local.js +7 -1
  48. package/dist/commonjs/experimental/features/metaplaylist.d.ts.map +1 -1
  49. package/dist/commonjs/experimental/features/metaplaylist.js +7 -1
  50. package/dist/commonjs/experimental/features/multi_thread.d.ts.map +1 -1
  51. package/dist/commonjs/experimental/features/multi_thread.js +6 -2
  52. package/dist/commonjs/features/features_object.js +1 -1
  53. package/dist/commonjs/features/list/dash.d.ts.map +1 -1
  54. package/dist/commonjs/features/list/dash.js +7 -1
  55. package/dist/commonjs/features/list/dash_wasm.d.ts.map +1 -1
  56. package/dist/commonjs/features/list/dash_wasm.js +7 -1
  57. package/dist/commonjs/features/list/media_source_main.d.ts.map +1 -1
  58. package/dist/commonjs/features/list/media_source_main.js +7 -1
  59. package/dist/commonjs/features/list/smooth.d.ts.map +1 -1
  60. package/dist/commonjs/features/list/smooth.js +7 -1
  61. package/dist/commonjs/features/types.d.ts +20 -4
  62. package/dist/commonjs/features/types.d.ts.map +1 -1
  63. package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
  64. package/dist/commonjs/main_thread/api/public_api.js +39 -42
  65. package/dist/commonjs/main_thread/core_interface/base.d.ts +13 -0
  66. package/dist/commonjs/main_thread/core_interface/base.d.ts.map +1 -0
  67. package/dist/commonjs/main_thread/core_interface/base.js +32 -0
  68. package/dist/commonjs/main_thread/core_interface/monothread.d.ts +13 -0
  69. package/dist/commonjs/main_thread/core_interface/monothread.d.ts.map +1 -0
  70. package/dist/commonjs/main_thread/core_interface/monothread.js +56 -0
  71. package/dist/commonjs/main_thread/core_interface/multithread.d.ts +25 -0
  72. package/dist/commonjs/main_thread/core_interface/multithread.d.ts.map +1 -0
  73. package/dist/commonjs/main_thread/core_interface/multithread.js +67 -0
  74. package/dist/commonjs/main_thread/core_interface/types.d.ts +6 -0
  75. package/dist/commonjs/main_thread/core_interface/types.d.ts.map +1 -0
  76. package/dist/commonjs/main_thread/core_interface/types.js +2 -0
  77. package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts +166 -108
  78. package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts.map +1 -1
  79. package/dist/commonjs/main_thread/init/media_source_content_initializer.js +1492 -919
  80. package/dist/commonjs/main_thread/init/utils/create_core_playback_observer.d.ts.map +1 -1
  81. package/dist/commonjs/main_thread/init/utils/create_core_playback_observer.js +2 -1
  82. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts +1 -1
  83. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  84. package/dist/commonjs/main_thread/types.d.ts +537 -0
  85. package/dist/commonjs/main_thread/types.d.ts.map +1 -1
  86. package/dist/commonjs/manifest/utils.d.ts.map +1 -1
  87. package/dist/commonjs/manifest/utils.js +18 -4
  88. package/dist/commonjs/mse/worker_media_source_interface.d.ts +2 -2
  89. package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
  90. package/dist/commonjs/mse/worker_media_source_interface.js +12 -12
  91. package/dist/commonjs/parsers/manifest/smooth/create_parser.d.ts +1 -1
  92. package/dist/commonjs/parsers/manifest/smooth/create_parser.d.ts.map +1 -1
  93. package/dist/commonjs/parsers/manifest/smooth/create_parser.js +31 -27
  94. package/dist/commonjs/parsers/manifest/smooth/parse_C_nodes.d.ts +3 -2
  95. package/dist/commonjs/parsers/manifest/smooth/parse_C_nodes.d.ts.map +1 -1
  96. package/dist/commonjs/parsers/manifest/smooth/parse_C_nodes.js +16 -7
  97. package/dist/commonjs/parsers/manifest/smooth/parse_protection_node.d.ts +3 -2
  98. package/dist/commonjs/parsers/manifest/smooth/parse_protection_node.d.ts.map +1 -1
  99. package/dist/commonjs/parsers/manifest/smooth/parse_protection_node.js +37 -6
  100. package/dist/commonjs/parsers/manifest/smooth/utils/parseBoolean.d.ts +1 -1
  101. package/dist/commonjs/parsers/manifest/smooth/utils/parseBoolean.d.ts.map +1 -1
  102. package/dist/commonjs/parsers/manifest/smooth/utils/reduceChildren.d.ts +3 -2
  103. package/dist/commonjs/parsers/manifest/smooth/utils/reduceChildren.d.ts.map +1 -1
  104. package/dist/commonjs/parsers/manifest/smooth/utils/reduceChildren.js +28 -5
  105. package/dist/{es2017/playback_observer/worker_playback_observer.d.ts → commonjs/playback_observer/core_playback_observer.d.ts} +8 -8
  106. package/dist/commonjs/playback_observer/core_playback_observer.d.ts.map +1 -0
  107. package/dist/commonjs/playback_observer/{worker_playback_observer.js → core_playback_observer.js} +13 -13
  108. package/dist/commonjs/transports/smooth/pipelines.d.ts.map +1 -1
  109. package/dist/commonjs/transports/smooth/pipelines.js +25 -3
  110. package/dist/commonjs/worker_entry_point.js +62 -2
  111. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  112. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  113. package/dist/es2017/core/{main/common → entry}/FreezeResolver.d.ts +3 -3
  114. package/dist/es2017/core/entry/FreezeResolver.d.ts.map +1 -0
  115. package/dist/es2017/core/{main/common → entry}/FreezeResolver.js +3 -3
  116. package/dist/{commonjs/core/main/worker → es2017/core/entry}/content_preparer.d.ts +22 -15
  117. package/dist/es2017/core/entry/content_preparer.d.ts.map +1 -0
  118. package/dist/es2017/core/{main/worker → entry}/content_preparer.js +53 -55
  119. package/dist/{commonjs/core/main/common → es2017/core/entry}/content_time_boundaries_observer.d.ts +5 -5
  120. package/dist/es2017/core/entry/content_time_boundaries_observer.d.ts.map +1 -0
  121. package/dist/es2017/core/{main/common → entry}/content_time_boundaries_observer.js +6 -6
  122. package/dist/es2017/core/entry/core_entry.d.ts +36 -0
  123. package/dist/es2017/core/entry/core_entry.d.ts.map +1 -0
  124. package/dist/es2017/core/{main/worker/worker_main.js → entry/core_entry.js} +153 -114
  125. package/dist/es2017/core/{main/worker/worker_text_displayer_interface.d.ts → entry/core_text_displayer_interface.d.ts} +11 -11
  126. package/dist/es2017/core/entry/core_text_displayer_interface.d.ts.map +1 -0
  127. package/dist/es2017/core/{main/worker/worker_text_displayer_interface.js → entry/core_text_displayer_interface.js} +10 -10
  128. package/dist/es2017/core/{main/common → entry}/create_content_time_boundaries_observer.d.ts +6 -6
  129. package/dist/es2017/core/entry/create_content_time_boundaries_observer.d.ts.map +1 -0
  130. package/dist/es2017/core/{main/common → entry}/create_content_time_boundaries_observer.js +1 -1
  131. package/dist/es2017/core/{main/common → entry}/get_buffered_data_per_media_buffer.d.ts +4 -4
  132. package/dist/es2017/core/entry/get_buffered_data_per_media_buffer.d.ts.map +1 -0
  133. package/dist/es2017/core/{main/common → entry}/get_buffered_data_per_media_buffer.js +1 -1
  134. package/dist/{commonjs/core/main/common → es2017/core/entry}/get_thumbnail_data.d.ts +3 -3
  135. package/dist/es2017/core/entry/get_thumbnail_data.d.ts.map +1 -0
  136. package/dist/es2017/core/{main/common → entry}/get_thumbnail_data.js +2 -2
  137. package/dist/es2017/core/entry/index.d.ts +5 -0
  138. package/dist/es2017/core/entry/index.d.ts.map +1 -0
  139. package/dist/es2017/core/entry/index.js +2 -0
  140. package/dist/{commonjs/core/main/common → es2017/core/entry}/synchronize_sinks_on_observation.d.ts +2 -2
  141. package/dist/es2017/core/entry/synchronize_sinks_on_observation.d.ts.map +1 -0
  142. package/dist/es2017/core/{main/worker → entry}/track_choice_setter.d.ts +4 -4
  143. package/dist/es2017/core/entry/track_choice_setter.d.ts.map +1 -0
  144. package/dist/es2017/core/{main/worker → entry}/track_choice_setter.js +4 -4
  145. package/dist/es2017/core/entry/utils.d.ts +3 -0
  146. package/dist/es2017/core/entry/utils.d.ts.map +1 -0
  147. package/dist/es2017/core/entry/utils.js +8 -0
  148. package/dist/es2017/core/stream/orchestrator/stream_orchestrator.d.ts.map +1 -1
  149. package/dist/es2017/core/stream/orchestrator/stream_orchestrator.js +18 -1
  150. package/dist/es2017/core/types.d.ts +519 -1
  151. package/dist/es2017/core/types.d.ts.map +1 -1
  152. package/dist/es2017/core/types.js +1 -0
  153. package/dist/es2017/experimental/features/local.d.ts.map +1 -1
  154. package/dist/es2017/experimental/features/local.js +7 -1
  155. package/dist/es2017/experimental/features/metaplaylist.d.ts.map +1 -1
  156. package/dist/es2017/experimental/features/metaplaylist.js +7 -1
  157. package/dist/es2017/experimental/features/multi_thread.d.ts.map +1 -1
  158. package/dist/es2017/experimental/features/multi_thread.js +6 -2
  159. package/dist/es2017/features/features_object.js +1 -1
  160. package/dist/es2017/features/list/dash.d.ts.map +1 -1
  161. package/dist/es2017/features/list/dash.js +7 -1
  162. package/dist/es2017/features/list/dash_wasm.d.ts.map +1 -1
  163. package/dist/es2017/features/list/dash_wasm.js +7 -1
  164. package/dist/es2017/features/list/media_source_main.d.ts.map +1 -1
  165. package/dist/es2017/features/list/media_source_main.js +7 -1
  166. package/dist/es2017/features/list/smooth.d.ts.map +1 -1
  167. package/dist/es2017/features/list/smooth.js +7 -1
  168. package/dist/es2017/features/types.d.ts +20 -4
  169. package/dist/es2017/features/types.d.ts.map +1 -1
  170. package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
  171. package/dist/es2017/main_thread/api/public_api.js +40 -43
  172. package/dist/es2017/main_thread/core_interface/base.d.ts +13 -0
  173. package/dist/es2017/main_thread/core_interface/base.d.ts.map +1 -0
  174. package/dist/es2017/main_thread/core_interface/base.js +28 -0
  175. package/dist/es2017/main_thread/core_interface/monothread.d.ts +13 -0
  176. package/dist/es2017/main_thread/core_interface/monothread.d.ts.map +1 -0
  177. package/dist/es2017/main_thread/core_interface/monothread.js +32 -0
  178. package/dist/es2017/main_thread/core_interface/multithread.d.ts +25 -0
  179. package/dist/es2017/main_thread/core_interface/multithread.d.ts.map +1 -0
  180. package/dist/es2017/main_thread/core_interface/multithread.js +45 -0
  181. package/dist/es2017/main_thread/core_interface/types.d.ts +6 -0
  182. package/dist/es2017/main_thread/core_interface/types.d.ts.map +1 -0
  183. package/dist/es2017/main_thread/core_interface/types.js +1 -0
  184. package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts +166 -108
  185. package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts.map +1 -1
  186. package/dist/es2017/main_thread/init/media_source_content_initializer.js +1405 -760
  187. package/dist/es2017/main_thread/init/utils/create_core_playback_observer.d.ts.map +1 -1
  188. package/dist/es2017/main_thread/init/utils/create_core_playback_observer.js +2 -1
  189. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts +1 -1
  190. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  191. package/dist/es2017/main_thread/types.d.ts +537 -0
  192. package/dist/es2017/main_thread/types.d.ts.map +1 -1
  193. package/dist/es2017/manifest/utils.d.ts.map +1 -1
  194. package/dist/es2017/manifest/utils.js +16 -4
  195. package/dist/es2017/mse/worker_media_source_interface.d.ts +2 -2
  196. package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
  197. package/dist/es2017/mse/worker_media_source_interface.js +12 -12
  198. package/dist/es2017/parsers/manifest/smooth/create_parser.d.ts +1 -1
  199. package/dist/es2017/parsers/manifest/smooth/create_parser.d.ts.map +1 -1
  200. package/dist/es2017/parsers/manifest/smooth/create_parser.js +31 -27
  201. package/dist/es2017/parsers/manifest/smooth/parse_C_nodes.d.ts +3 -2
  202. package/dist/es2017/parsers/manifest/smooth/parse_C_nodes.d.ts.map +1 -1
  203. package/dist/es2017/parsers/manifest/smooth/parse_C_nodes.js +16 -7
  204. package/dist/es2017/parsers/manifest/smooth/parse_protection_node.d.ts +3 -2
  205. package/dist/es2017/parsers/manifest/smooth/parse_protection_node.d.ts.map +1 -1
  206. package/dist/es2017/parsers/manifest/smooth/parse_protection_node.js +15 -6
  207. package/dist/es2017/parsers/manifest/smooth/utils/parseBoolean.d.ts +1 -1
  208. package/dist/es2017/parsers/manifest/smooth/utils/parseBoolean.d.ts.map +1 -1
  209. package/dist/es2017/parsers/manifest/smooth/utils/reduceChildren.d.ts +3 -2
  210. package/dist/es2017/parsers/manifest/smooth/utils/reduceChildren.d.ts.map +1 -1
  211. package/dist/es2017/parsers/manifest/smooth/utils/reduceChildren.js +6 -5
  212. package/dist/{commonjs/playback_observer/worker_playback_observer.d.ts → es2017/playback_observer/core_playback_observer.d.ts} +8 -8
  213. package/dist/es2017/playback_observer/core_playback_observer.d.ts.map +1 -0
  214. package/dist/es2017/playback_observer/{worker_playback_observer.js → core_playback_observer.js} +2 -2
  215. package/dist/es2017/transports/smooth/pipelines.d.ts.map +1 -1
  216. package/dist/es2017/transports/smooth/pipelines.js +25 -3
  217. package/dist/es2017/worker_entry_point.js +62 -2
  218. package/dist/rx-player.js +21882 -19021
  219. package/dist/rx-player.min.js +20 -20
  220. package/dist/worker.js +8 -8
  221. package/package.json +1 -1
  222. package/src/README.md +88 -198
  223. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  224. package/src/core/{main/common → entry}/FreezeResolver.ts +7 -7
  225. package/src/core/{main → entry}/README.md +1 -1
  226. package/src/core/{main/worker → entry}/content_preparer.ts +77 -76
  227. package/src/core/{main/common → entry}/content_time_boundaries_observer.ts +10 -10
  228. package/src/core/{main/worker/worker_main.ts → entry/core_entry.ts} +223 -149
  229. package/src/core/{main/worker/worker_text_displayer_interface.ts → entry/core_text_displayer_interface.ts} +26 -26
  230. package/src/core/{main/common → entry}/create_content_time_boundaries_observer.ts +7 -7
  231. package/src/core/{main/common → entry}/get_buffered_data_per_media_buffer.ts +6 -6
  232. package/src/core/{main/common → entry}/get_thumbnail_data.ts +5 -5
  233. package/src/core/entry/index.ts +4 -0
  234. package/src/core/{main/common → entry}/synchronize_sinks_on_observation.ts +2 -2
  235. package/src/core/{main/worker → entry}/track_choice_setter.ts +7 -7
  236. package/src/core/entry/utils.ts +11 -0
  237. package/src/core/stream/orchestrator/stream_orchestrator.ts +26 -1
  238. package/src/core/types.ts +631 -3
  239. package/src/experimental/features/__tests__/local.test.ts +11 -2
  240. package/src/experimental/features/__tests__/metaplaylist.test.ts +11 -2
  241. package/src/experimental/features/__tests__/multi_thread.test.ts +8 -3
  242. package/src/experimental/features/local.ts +7 -1
  243. package/src/experimental/features/metaplaylist.ts +7 -1
  244. package/src/experimental/features/multi_thread.ts +6 -2
  245. package/src/features/features_object.ts +1 -1
  246. package/src/features/list/__tests__/dash.test.ts +12 -3
  247. package/src/features/list/__tests__/smooth.test.ts +11 -2
  248. package/src/features/list/dash.ts +7 -1
  249. package/src/features/list/dash_wasm.ts +7 -1
  250. package/src/features/list/media_source_main.ts +7 -1
  251. package/src/features/list/smooth.ts +7 -1
  252. package/src/features/types.ts +23 -4
  253. package/src/main_thread/README.md +8 -0
  254. package/src/main_thread/api/public_api.ts +46 -48
  255. package/src/main_thread/core_interface/README.md +22 -0
  256. package/src/main_thread/core_interface/base.ts +36 -0
  257. package/src/main_thread/core_interface/monothread.ts +46 -0
  258. package/src/main_thread/core_interface/multithread.ts +49 -0
  259. package/src/main_thread/core_interface/types.ts +5 -0
  260. package/src/main_thread/init/media_source_content_initializer.ts +2034 -1152
  261. package/src/main_thread/init/utils/create_core_playback_observer.ts +2 -1
  262. package/src/main_thread/init/utils/update_manifest_codec_support.ts +1 -1
  263. package/src/main_thread/types.ts +610 -0
  264. package/src/manifest/utils.ts +20 -4
  265. package/src/mse/worker_media_source_interface.ts +35 -35
  266. package/src/parsers/manifest/smooth/create_parser.ts +40 -34
  267. package/src/parsers/manifest/smooth/parse_C_nodes.ts +19 -8
  268. package/src/parsers/manifest/smooth/parse_protection_node.ts +17 -9
  269. package/src/parsers/manifest/smooth/utils/parseBoolean.ts +1 -1
  270. package/src/parsers/manifest/smooth/utils/reduceChildren.ts +10 -7
  271. package/src/playback_observer/{worker_playback_observer.ts → core_playback_observer.ts} +13 -13
  272. package/src/transports/smooth/pipelines.ts +25 -5
  273. package/src/worker_entry_point.ts +71 -2
  274. package/dist/commonjs/core/main/common/FreezeResolver.d.ts.map +0 -1
  275. package/dist/commonjs/core/main/common/content_time_boundaries_observer.d.ts.map +0 -1
  276. package/dist/commonjs/core/main/common/create_content_time_boundaries_observer.d.ts.map +0 -1
  277. package/dist/commonjs/core/main/common/get_buffered_data_per_media_buffer.d.ts.map +0 -1
  278. package/dist/commonjs/core/main/common/get_thumbnail_data.d.ts.map +0 -1
  279. package/dist/commonjs/core/main/common/synchronize_sinks_on_observation.d.ts.map +0 -1
  280. package/dist/commonjs/core/main/worker/content_preparer.d.ts.map +0 -1
  281. package/dist/commonjs/core/main/worker/globals.d.ts +0 -14
  282. package/dist/commonjs/core/main/worker/globals.d.ts.map +0 -1
  283. package/dist/commonjs/core/main/worker/globals.js +0 -26
  284. package/dist/commonjs/core/main/worker/index.d.ts +0 -3
  285. package/dist/commonjs/core/main/worker/index.d.ts.map +0 -1
  286. package/dist/commonjs/core/main/worker/index.js +0 -4
  287. package/dist/commonjs/core/main/worker/send_message.d.ts +0 -4
  288. package/dist/commonjs/core/main/worker/send_message.d.ts.map +0 -1
  289. package/dist/commonjs/core/main/worker/send_message.js +0 -23
  290. package/dist/commonjs/core/main/worker/track_choice_setter.d.ts.map +0 -1
  291. package/dist/commonjs/core/main/worker/worker_main.d.ts +0 -2
  292. package/dist/commonjs/core/main/worker/worker_main.d.ts.map +0 -1
  293. package/dist/commonjs/core/main/worker/worker_text_displayer_interface.d.ts.map +0 -1
  294. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts +0 -308
  295. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts.map +0 -1
  296. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.js +0 -1713
  297. package/dist/commonjs/main_thread/init/send_message.d.ts +0 -3
  298. package/dist/commonjs/main_thread/init/send_message.d.ts.map +0 -1
  299. package/dist/commonjs/main_thread/init/send_message.js +0 -13
  300. package/dist/commonjs/multithread_types.d.ts +0 -915
  301. package/dist/commonjs/multithread_types.d.ts.map +0 -1
  302. package/dist/commonjs/multithread_types.js +0 -7
  303. package/dist/commonjs/playback_observer/worker_playback_observer.d.ts.map +0 -1
  304. package/dist/es2017/core/main/common/FreezeResolver.d.ts.map +0 -1
  305. package/dist/es2017/core/main/common/content_time_boundaries_observer.d.ts.map +0 -1
  306. package/dist/es2017/core/main/common/create_content_time_boundaries_observer.d.ts.map +0 -1
  307. package/dist/es2017/core/main/common/get_buffered_data_per_media_buffer.d.ts.map +0 -1
  308. package/dist/es2017/core/main/common/get_thumbnail_data.d.ts.map +0 -1
  309. package/dist/es2017/core/main/common/synchronize_sinks_on_observation.d.ts.map +0 -1
  310. package/dist/es2017/core/main/worker/content_preparer.d.ts.map +0 -1
  311. package/dist/es2017/core/main/worker/globals.d.ts +0 -14
  312. package/dist/es2017/core/main/worker/globals.d.ts.map +0 -1
  313. package/dist/es2017/core/main/worker/globals.js +0 -18
  314. package/dist/es2017/core/main/worker/index.d.ts +0 -3
  315. package/dist/es2017/core/main/worker/index.d.ts.map +0 -1
  316. package/dist/es2017/core/main/worker/index.js +0 -2
  317. package/dist/es2017/core/main/worker/send_message.d.ts +0 -4
  318. package/dist/es2017/core/main/worker/send_message.d.ts.map +0 -1
  319. package/dist/es2017/core/main/worker/send_message.js +0 -19
  320. package/dist/es2017/core/main/worker/track_choice_setter.d.ts.map +0 -1
  321. package/dist/es2017/core/main/worker/worker_main.d.ts +0 -2
  322. package/dist/es2017/core/main/worker/worker_main.d.ts.map +0 -1
  323. package/dist/es2017/core/main/worker/worker_text_displayer_interface.d.ts.map +0 -1
  324. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts +0 -308
  325. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts.map +0 -1
  326. package/dist/es2017/main_thread/init/multi_thread_content_initializer.js +0 -1559
  327. package/dist/es2017/main_thread/init/send_message.d.ts +0 -3
  328. package/dist/es2017/main_thread/init/send_message.d.ts.map +0 -1
  329. package/dist/es2017/main_thread/init/send_message.js +0 -10
  330. package/dist/es2017/multithread_types.d.ts +0 -915
  331. package/dist/es2017/multithread_types.d.ts.map +0 -1
  332. package/dist/es2017/multithread_types.js +0 -6
  333. package/dist/es2017/playback_observer/worker_playback_observer.d.ts.map +0 -1
  334. package/src/core/main/worker/globals.ts +0 -38
  335. package/src/core/main/worker/index.ts +0 -2
  336. package/src/core/main/worker/send_message.ts +0 -28
  337. package/src/main_thread/init/multi_thread_content_initializer.ts +0 -2330
  338. package/src/main_thread/init/send_message.ts +0 -15
  339. package/src/multithread_types.ts +0 -1095
  340. /package/dist/commonjs/core/{main/common → entry}/synchronize_sinks_on_observation.js +0 -0
  341. /package/dist/es2017/core/{main/common → entry}/synchronize_sinks_on_observation.js +0 -0
@@ -1,3 +1,3 @@
1
- const blob = new Blob(["(function(){" + "\"use strict\";(()=>{var vu=Object.defineProperty,Cu=Object.defineProperties;var Au=Object.getOwnPropertyDescriptors;var ao=Object.getOwnPropertySymbols;var ku=Object.prototype.hasOwnProperty,xu=Object.prototype.propertyIsEnumerable;var oo=(n,e,t)=>e in n?vu(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ee=(n,e)=>{for(var t in e||(e={}))ku.call(e,t)&&oo(n,t,e[t]);if(ao)for(var t of ao(e))xu.call(e,t)&&oo(n,t,e[t]);return n},se=(n,e)=>Cu(n,Au(e));var I={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var so={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_AUDIO_TRACKS_NOT_PLAYABLE_BEHAVIOR:\"error\",DEFAULT_VIDEO_TRACKS_NOT_PLAYABLE_BEHAVIOR:\"error\",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,FORCE_CANNOT_RELY_ON_REQUEST_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_CANNOT_REUSE_MEDIA_KEYS:!1,FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:!1,FORCE_IS_SEEKING_APPROXIMATE:!1,FORCE_MEDIA_ELEMENT_FAIL_ON_UNDECIPHERABLE_DATA:!1,FORCE_SHOULD_AWAIT_SET_MEDIA_KEYS:!1,FORCE_SHOULD_FAVOUR_CUSTOM_SAFARI_EME:!1,FORCE_SHOULD_RELOAD_MEDIA_SOURCE_ON_DECIPHERABILITY_UPDATE:!1,FORCE_SHOULD_RENEW_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_SHOULD_UNSET_MEDIA_KEYS:!1,FORCE_SHOULD_VALIDATE_METADATA:!1,FORCE_DONT_WAIT_FOR_DATA_BEFORE_LOADED:!1,FORCE_WAIT_FOR_HAVE_ENOUGH_DATA:!1},uo=so;function Ou(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 H=typeof Object.assign==\"function\"?Object.assign:Ou;function ai(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function en(n,...e){if(e.length===0)return n;let t=e.shift();if(ai(n)&&ai(t))for(let r in t)if(ai(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),en(i,t[r])}else H(n,{[r]:t[r]});return en(n,...e)}function v(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(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 oi=class extends fe{constructor(){super(...arguments);this.updated=!1;this._config=uo}update(t){let r=en(this._config,t);this._config=r,this.updated=!0,this.trigger(\"update\",t)}getCurrent(){return this._config}},wu=new oi,U=wu;var Xe=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 lr=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 tn(n,e,t){let r=new lr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var Y=lr;var si=new Y(0);function lo({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;si.setValueIfChanged(r-t)}var Du=typeof performance!=\"undefined\"?()=>performance.now()+si.getValue():()=>Date.now()+si.getValue(),L=Du;var Bu=\"NONE\",nn=class extends fe{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=Bu}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,...l)=>{let m=L();return d(String(m.toFixed(2)),`[${u}]`,f+\":\",...l.map(g=>typeof g==\"object\"&&g!==null&&!(g instanceof Error)?fo(g):g))}:(u,d)=>(f,...l)=>d(f+\":\",...l.map(m=>typeof m==\"object\"&&m!==null&&!(m instanceof Error)?fo(m):m));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,...l)=>r(d,f,l):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]}};function fo(n){let e=\"\";for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)){e.length>0&&(e+=\" \");let r=n[t];r instanceof Error?e+=`${t}=\"${JSON.stringify(r==null?void 0:r.toString())}\"`:e+=`${t}=${typeof r==\"string\"?`${JSON.stringify(r)}`:String(r)}`}return e}var Nu=new nn,c=Nu;var fr=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var Uu=typeof window==\"undefined\"&&!fr,mr=Uu;var cr;fr?cr=self:mr?cr=global:cr=window;var te=cr;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}}},Pe={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var ui=typeof Headers==\"function\"?Headers:null,pr=typeof AbortController==\"function\"?AbortController:null;function gr(n){var m,g;let e;if(!v(n.headers))if(v(ui))e=n.headers;else{e=new ui;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(\"utils\",\"Fetch\",{url:n.url});let t=null,r=!1,i=!1,a=L(),o=v(pr)?null:new pr;function s(){if(v(o)){c.warn(\"utils\",\"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=v(o)?null:o.signal,c.hasLevel(\"DEBUG\")){let p=\"fetch 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(\"utils\",p)}return fetch(n.url,l).then(p=>{if(d!==void 0&&clearTimeout(d),p.status>=300)throw c.warn(\"utils\",\"Fetch: Request HTTP Error\",{status:p.status,responseUrl:p.url}),new de(p.url,p.status,Pe.ERROR_HTTP_CODE);if(v(p.body))throw new de(p.url,p.status,Pe.PARSE_ERROR);let b=p.headers.get(\"Content-Length\"),h=!v(b)&&!isNaN(+b)?+b:void 0,S=p.body.getReader(),_=0;return P();async function P(){let T=await S.read();if(!T.done&&!v(T.value)){_+=T.value.byteLength;let R=L(),E={url:p.url,currentTime:R,duration:R-a,sendingTime:a,chunkSize:T.value.byteLength,chunk:T.value.buffer,size:_,totalSize:h};return n.onData(E),P()}else if(T.done){u!==void 0&&clearTimeout(u),f();let R=L();return{requestDuration:R-a,receivedTime:R,sendingTime:a,size:_,status:p.status,url:p.url}}return P()}}).catch(p=>{throw t!==null?t:(f(),r?(c.warn(\"utils\",\"Fetch: Request timed out.\",{url:n.url,timeout:n.timeout}),new de(n.url,0,Pe.TIMEOUT)):i?(c.warn(\"utils\",\"Fetch: Request connection timed out.\",{url:n.url,connectionTimeout:n.connectionTimeout}),new de(n.url,0,Pe.TIMEOUT)):p instanceof de?p:(c.warn(\"utils\",\"Fetch: Request Error\",{error:p instanceof Error?p.toString():\"Unkwown Error\"}),new de(n.url,0,Pe.ERROR_EVENT)))})}function rn(){let n=/\\[\\s*native\\s+code\\s*\\]/;return typeof te.fetch==\"function\"&&!v(pr)&&n.test(pr.toString())&&!v(ui)}function j(n){return typeof n==\"string\"&&n.length>0}var Lu=\"json\";function an(n){let e={url:n.url,headers:n.headers,responseType:v(n.responseType)?Lu: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,Pe.TIMEOUT))},d+3e3));let g;if(f!==void 0&&(g=setTimeout(()=>{h(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new de(o,l.status,Pe.TIMEOUT))},f)),l.responseType=u,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!v(s)){let S=s;for(let _ in S)Object.prototype.hasOwnProperty.call(S,_)&&l.setRequestHeader(_,S[_])}let p=L(),b=null;if(a!==void 0&&(b=a.register(function(_){h(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(_)}),a.isCancelled()))return;if(l.onerror=function(){h(),r(new de(o,l.status,Pe.ERROR_EVENT))},l.ontimeout=function(){h(),r(new de(o,l.status,Pe.TIMEOUT))},f!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(g)}),i!==void 0&&(l.onprogress=function(_){let P=L();i({url:o,duration:P-p,sendingTime:p,currentTime:P,size:_.loaded,totalSize:_.total})}),l.onload=function(_){if(l.readyState===XMLHttpRequest.DONE)if(h(),l.status>=200&&l.status<300){let P=L(),T=l.response instanceof ArrayBuffer?l.response.byteLength:_.total,R=l.status,E=l.responseType,M=j(l.responseURL)?l.responseURL:o,C;if(E===\"json\"?C=typeof l.response==\"object\"?l.response:Fu(l.responseText):C=l.response,v(C)){r(new de(o,l.status,Pe.PARSE_ERROR));return}t({status:R,url:M,responseType:E,sendingTime:p,receivedTime:P,requestDuration:P-p,size:T,responseData:C})}else r(new de(o,l.status,Pe.ERROR_HTTP_CODE))},c.hasLevel(\"DEBUG\")){let S=\"XHR GET \"+o;n.responseType!==void 0&&(S+=\" type=\"+n.responseType),d!==void 0&&(S+=\" to=\"+String(d/1e3)),f!==void 0&&(S+=\" cto=\"+String(f/1e3)),(s==null?void 0:s.Range)!==void 0&&(S+=\" Range=\"+(s==null?void 0:s.Range)),c.debug(\"utils\",S)}l.send();function h(){m!==void 0&&clearTimeout(m),g!==void 0&&clearTimeout(g),b!==null&&b()}})}function Fu(n){try{return JSON.parse(n)}catch(e){return null}}var be=an;var Rt=Pe,Ge={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function tt(n,e){return`${n}: ${e}`}var on=class n extends Error{constructor(e,t,r){super(tt(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=Ge.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.fatal=!1,this.keyStatuses=r.keyStatuses,this.keySystemConfiguration=r.keySystemConfiguration,this.keySystem=r.keySystem}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses,keySystemConfiguration:this.keySystemConfiguration,keySystem:this.keySystem}}};var Z=class n extends Error{constructor(e,t,r){super(tt(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=Ge.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{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var Ze=class n extends Error{constructor(e,t){super(tt(e,t.message)),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=Ge.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===Rt.ERROR_HTTP_CODE&&this.status===e}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var _e=class n extends Error{constructor(e,t){super(tt(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=Ge.OTHER_ERROR,this.code=e,this.fatal=!1,this._originalMessage=t}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage}}};function Nt(n){return(n instanceof on||n instanceof Z||n instanceof _e||n instanceof Ze)&&Object.keys(Ge).indexOf(n.type)>=0}function ge(n,{defaultCode:e,defaultReason:t}){if(Nt(n))return n;let r=n instanceof Error?n.toString():t;return new _e(e,r)}var xe=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 zu={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},mo=zu;var De=mo;function K(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\"},co=Wu;var qu={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\"},po=qu;function Vu(n){if(v(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=Gu(t);return j(r)?r:n}function Gu(n){let e;switch(n.length){case 2:e=co[n];break;case 3:e=po[n];break}return e}var go=Vu;var ho=go;function hr(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 di(n){return Object.keys(n).map(e=>n[e])}var Ir=typeof Object.values==\"function\"?Object.values:di;var Ut=[\"audio\",\"video\",\"text\"];function bo(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 yo(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 So(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=L()-e.time;return e.maximumSafePosition+t/1e3}function To(n,e){if(e===void 0)return fi(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 Eo(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(li(i,e,t))return i;t=i}}function _o(n,e){let t=e.end;if(t===void 0)return null;let r=K(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function li(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 fi(n){let e=n.adaptations;return di(e).reduce((t,r)=>v(r)?t:t.concat(r),[])}function Hu(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=>sn(a)===!0):n.representations).map(Yu),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function Ku(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 ju(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>sn(s)===!0):i.representations).map(Io),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=>sn(i)===!0):n.representations).map(Io),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function Yu(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 Io(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 Pt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:Hu(n,!1)};case\"video\":return{type:\"video\",track:ju(n,!1)};case\"text\":return{type:\"text\",track:Ku(n)}}}function sn(n){return n.decipherable===!1?!1:n.isSupported}function Ro(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}function Me(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var br=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 br(e===void 0?\"invalid assertion\":e)}function Ne(n){throw new br(\"Unreachable path taken\")}var Qu=typeof te==\"object\"&&typeof te.TextDecoder==\"function\",$u=typeof te==\"object\"&&typeof te.TextEncoder==\"function\";function un(n){if($u)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"Unknown Error\";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 Xu(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 Po(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Ke(n){if(Qu)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"Unknown Error\";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=Xu(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\"+Po(o,4):\"%\"+Po(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 yr(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 mi(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:Ke(r)}}var Zu=Me(),ci=class{constructor(e,t,r){var a,o,s,u,d;this.id=e.id,this.uniqueId=Zu(),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)hr(u,t)&&(s=!0);s||(c.warn(\"manifest\",\"found unanounced key id.\",{keyId:yr(t)}),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(hr(d.data,s[f].data))break;c.warn(\"manifest\",\"different init data for the same system ID\",{systemId:d.systemId})}f===s.length&&(s.push(d),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}isPlayable(){return sn(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}}},ln=ci;var mt=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=ho(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 ln(s[d],this.type,t),l=!0;if(!v(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(\"manifest\",\"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 K(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 ye=te,vo,Co,Ao,ko,xo,ct=(xo=(ko=(Ao=(Co=(vo=ye==null?void 0:ye.MediaSource)!=null?vo:ye==null?void 0:ye.MozMediaSource)!=null?Co:ye==null?void 0:ye.WebKitMediaSource)!=null?Ao:ye==null?void 0:ye.MSMediaSource)!=null?ko:ye==null?void 0:ye.ManagedMediaSource)!=null?xo:void 0,Zg=ct!==void 0&&ct===(ye==null?void 0:ye.ManagedMediaSource);var pt={EdgeChromium:0,Firefox:1,Ie11:2,OtherIeOrEdgePreEdgeChromium:3,SafariDesktop:4,SafariMobile:5,Other:6},Ue={A1KStb40xx:100,Panasonic:101,PhilipsNetTv:102,PlayStation4:103,PlayStation5:104,Tizen:105,WebOs2021:106,WebOs2022:107,WebOsOther:108,Xbox:109,Other:110},Se={DEVICES:Ue,BROWSERS:pt,browser:pt.Other,device:Ue.Other,isSamsungBrowser:!1};Ju();function Ju(){var n,e,t;mr||(typeof te.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?Se.browser=pt.Ie11:navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?Se.browser=pt.OtherIeOrEdgePreEdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?Se.browser=pt.EdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?Se.browser=pt.Firefox:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?Se.browser=pt.SafariMobile:(Object.prototype.toString.call(te.HTMLElement).indexOf(\"Constructor\")>=0||((e=(n=te.safari)==null?void 0:n.pushNotification)==null?void 0:e.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((t=navigator.vendor)==null?void 0:t.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(Se.browser=pt.SafariDesktop),/SamsungBrowser/.test(navigator.userAgent)&&(Se.isSamsungBrowser=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?Se.device=Ue.PlayStation4:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?Se.device=Ue.PlayStation5:/Tizen/.test(navigator.userAgent)?Se.device=Ue.Tizen:/[Ww]eb[O0]S/.test(navigator.userAgent)?/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?Se.device=Ue.WebOs2022:/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent)?Se.device=Ue.WebOs2021:Se.device=Ue.WebOsOther:navigator.userAgent.indexOf(\"NETTV\")!==-1&&navigator.userAgent.indexOf(\"Philips\")!==-1?Se.device=Ue.PhilipsNetTv:/[Pp]anasonic/.test(navigator.userAgent)?Se.device=Ue.Panasonic:navigator.userAgent.indexOf(\"Xbox\")!==-1?Se.device=Ue.Xbox:navigator.userAgent.indexOf(\"Model/a1-kstb40xx\")!==-1&&(Se.device=Ue.A1KStb40xx))}var pi=Se;function gi(n){return new Promise(e=>{setTimeout(e,n)})}function vt(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 fn(n,e){return vt(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var F=class{constructor(){let[e,t]=ed();this._isUsed=!1,this._trigger=e,this.signal=new hi(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}},hi=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(\"utils\",\"Error while calling clean up listener\",r instanceof Error?r:\"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 ed(){let n=D;return[function(t){n(t)},function(t){n=t}]}var td=[\"\",\"webkit\",\"moz\",\"ms\"];function nd(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 rd(n,e){return e.filter(t=>nd(n,t))[0]}function id(n,e){return n.reduce((t,r)=>t.concat((e===void 0?td:e).map(i=>i+r)),[])}function ve(n,e){let t,r=id(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=rd(i,r)),j(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{c.warn(\"utils\",`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 Ph=ve([\"loadedmetadata\"]),vh=ve([\"timeupdate\"]),Ch=ve([\"addtrack\"]),Ah=ve([\"removetrack\"]),Lt=ve([\"sourceopen\",\"webkitsourceopen\"]),Sr=ve([\"sourceclose\",\"webkitsourceclose\"]),Tr=ve([\"sourceended\",\"webkitsourceended\"]),Mo=ve([\"update\"]),Oo=ve([\"removesourcebuffer\"]),kh=ve([\"keymessage\",\"message\"]),xh=ve([\"keyadded\",\"ready\"]),Mh=ve([\"keyerror\",\"error\"]),Oh=ve([\"keystatuseschange\"]),wh=ve([\"seeking\"]),Dh=ve([\"seeked\"]),Bh=ve([\"ended\"]);var wo=[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 Er(n){if(n>=wo.length)throw new Error(\"Unable to parse base64 string.\");let e=wo[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function _r(n){let e=n.length%4,t=n;e!==0&&(c.warn(\"utils\",\"base64ToBytes: base64 given miss padding\",{padding:e}),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=Er(t.charCodeAt(u))<<18|Er(t.charCodeAt(u+1))<<12|Er(t.charCodeAt(u+2))<<6|Er(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)}function Ct(...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 Do(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function Ii(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function ie(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function gt(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 Bo(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)}function Oe(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 Je(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=ie(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=gt(n,r+8)}if(isNaN(i)||i<=0)return-1;if(ie(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function Rr(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=Je(r,1836019558);if(i<0)break;let a=ie(n,i+e),o=e+i+a;if(o>n.length)break;let s=Je(r,1835295092);if(s<0)break;let u=ie(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 ad(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function od(n,e,t){return n.slice(e,t)}var bi=typeof Uint8Array.prototype.slice==\"function\"?od:ad;function yi(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=Ft(n,e);return t!==null?n.subarray(t[1],t[2]):null}function No(n,e){let t=[],r=n;for(;;){let i=Ft(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 Ft(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=ie(n,o),o+=4,i=ie(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=gt(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 Pr(n){let e=0,t=he(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=Ft(t,1886614376)}catch(s){let u=s instanceof Error?s:\"\";return c.warn(\"isobmff\",\"Error while removing PSSH from ISOBMFF\",u),r}if(i===null)return r;let a=bi(t,i[0],i[2]),o=Uo(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 Uo(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=bi(n,t,t+16);return yr(r)}function Si(n){let e=he(n,1836019558);return e===null?null:he(e,1953653094)}function Lo(n){return No(n,1836019558).reduce((t,r)=>{let i=he(r,1953653094);return i!==null&&t.push(i),t},[])}function Ti(n){return he(n,1835295092)}function Ei(n){let e=he(n,1836019574);if(e===null)return null;let t=he(e,1953653099);return t===null?null:he(t,1835297121)}function Fo(n,e=0){return he(n.subarray(e),1701671783)}function mn(n,e){let t=Ft(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=ie(n,a);a+=4;let u;if(o===0)u=ie(n,a),a+=4,r+=ie(n,a)+i,a+=4;else if(o===1)u=gt(n,a),a+=8,r+=gt(n,a)+i,a+=8;else return null;let d=[];a+=2;let f=Do(n,a);for(a+=2;--f>=0;){let l=ie(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=ie(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 _i(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 gt(t,4);if(r===0)return ie(t,4)}function sd(n){let e=he(n,1952868452);if(e===null)return;let t=1,r=Ii(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),ie(e,t)):void 0}function Ri(n){let e=Lo(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=Ii(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=ie(i,a);a+=4,f&&(a+=4),l&&(a+=4);let h=b,S=0;for(;h-- >0;)u?(S+=ie(i,a),a+=4):S+=d,m&&(a+=4),g&&(a+=4),p&&(a+=4);t+=S}return t}function cn(n){let e=Ei(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 ie(t,r+16);if(i===0)return ie(t,r+8)}function zo(n){let e=[],t=0;for(;t<n.length;){let r=Fo(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}=mi(r,o);o=s;let{end:d,string:f}=mi(r,o);o=d;let l=ie(r,o);o+=4;let m=ie(r,o);o+=4;let g=ie(r,o);o+=4;let p=ie(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 Wo(n){let e=yi(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=yi(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 ud(n,e){let{mimeType:t,codecs:r}=qo(n),{mimeType:i,codecs:a}=qo(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 dd=7;function qo(n){var i;let[e,...t]=n.split(\";\"),r=(i=K(t,a=>Oe(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(dd),r[0]==='\"'&&(r=r.substring(1,r.length-1)),{mimeType:e,codecs:r}}var Vo=ud;function Pi(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 vi(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function Go(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 Ho=[];function rt(n){Ie(Ho,n)||(console.warn(n),Ho.push(n))}var pn=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 ht=class{constructor(e,t,r){if(this.id=e.id,this.adaptations=ld(e.adaptations,t,r),Ko(this.adaptations.video)&&Ko(this.adaptations.audio))throw new Z(\"MANIFEST_PARSE_ERROR\",\"The manifest has no video nor audio tracks.\");this.thumbnailTracks=e.thumbnailTracks.map(i=>({id:i.id,mimeType:i.mimeType,index:i.index,cdnMetadata:i.cdnMetadata,height:i.height,width:i.width,horizontalTiles:i.horizontalTiles,verticalTiles:i.verticalTiles,start:i.start,end:i.end,tileDuration:i.tileDuration})),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)for(let a of i){if(!a.supportStatus.hasCodecWithUndefinedSupport)continue;let o=a.supportStatus.hasSupportedCodec;a.refreshCodecSupport(t),o!==!1&&a.supportStatus.hasSupportedCodec===!1&&e.push(a)}},{})}getAdaptations(){return fi(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return K(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return To(this,e)}containsTime(e,t){return li(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 Ko(n){return Array.isArray(n)?n.length===0:!0}function ld(n,e,t){let r={};for(let[i,a]of Object.entries(n))v(a)||(r[i]=a.map(o=>new mt(o,e,{representationFilter:t})).filter(o=>o.representations.length>0));return r}function gn(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=re(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=re(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 S=0;S<b.length;S++){let _=b[S],P=re(h,T=>T.id===_.id);if(P===-1){c.warn(\"manifest\",`Representation \"${b[S].id}\" not found when merging.`);let[T]=b.splice(S,1);S--,p.push(T.id)}else{let[T]=h.splice(P,1);m.push(_.getMetadataSnapshot()),_.cdnMetadata=T.cdnMetadata,t===0?_.index._replace(T.index):_.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(S=>S.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 jo(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=gn(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 Yo(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=re(n,({id:s})=>s===e[0].id);if(i<0)throw new Z(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=gn(n[i],e[0],1);t.updatedPeriods.push({period:H(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=gn(n[d],u,0);t.updatedPeriods.push({period:H(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 fd=Me(),hn=class extends fe{constructor(e,t){var a;super();let{representationFilter:r,manifestUpdateUrl:i}=t;this.manifestFormat=0,this.id=fd(),this.expired=(a=e.expired)!=null?a:null,this.transport=e.transportType,this.clockOffset=e.clockOffset,this._cachedCodecSupport=new pn([]),this.periods=e.periods.map(o=>new ht(o,this._cachedCodecSupport,r)).sort((o,s)=>o.start-s.start),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=i,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(Pt)}):null}getPeriod(e){return K(this.periods,t=>e===t.id)}getPeriodForTime(e){return Eo(this,e)}getNextPeriod(e){return K(this.periods,t=>t.start>e)}getPeriodAfter(e){return _o(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return bo(this)}getLivePosition(){return yo(this)}getMaximumSafePosition(){return So(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=md(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(){rt(\"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){rt(\"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 rt(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),K(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 Go(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=jo(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=Yo(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 md(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(\"manifest\",`Decipherability changed for \"${o.id}\"`,`(${o.bitrate})`,String(o.decipherable)))}a&&(i.supportStatus.isDecipherable=!1)}return t}function nt(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function He(n){if(v(n))return null;let{period:e,adaptation:t,representation:r,segment:i}=n;return{t:t.type[0],p:e.id,a:t.id,r:r.id,ss:i.isInit?null:i.time,se:i.isInit||!i.complete?null:i.end}}var zt=hn;var cd=\"<\",pd=60,Qo=\">\",vr=62,Ci=45,$o=47,gd=33,Xo=39,Zo=34,Ai=91,hd=93,Id=`\\r\n\t>/= `;function ki(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=Jo(a,e.filter)),a;function o(p){let b=[];for(;n[t]!==void 0;)if(n.charCodeAt(t)===pd){if(n.charCodeAt(t+1)===$o){let S=t+2;if(t=n.indexOf(Qo,t),n.substring(S,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),b}else if(n.charCodeAt(t+1)===gd){if(n.charCodeAt(t+2)===Ci){let S=t;for(;t!==-1&&!(n.charCodeAt(t)===vr&&n.charCodeAt(t-1)===Ci&&n.charCodeAt(t-2)===Ci);)t=n.indexOf(Qo,t+1);t===-1&&(t=n.length),r&&b.push(n.substring(S,t+1))}else if(n.charCodeAt(t+2)===Ai&&n.charCodeAt(t+8)===Ai&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let S=n.indexOf(\"]]>\",t);S===-1?(b.push(n.substring(t+9)),t=n.length):(b.push(n.substring(t+9,S)),t=S+3);continue}else{let S=t+1;t+=2;let _=!1;for(;(n.charCodeAt(t)!==vr||_)&&n[t]!==void 0;)n.charCodeAt(t)===Ai?_=!0:_&&n.charCodeAt(t)===hd&&(_=!1),t++;b.push(n.substring(S,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 S=h.trim();S.length>0&&b.push(S)}t++}return b}function s(){let p=t;return t=n.indexOf(cd,t)-1,t===-2&&(t=n.length),n.slice(p,t+1)}function u(){let p=t;for(;Id.indexOf(n[t])===-1&&n[t]!==void 0;)t++;return n.slice(p,t)}function d(){let p=t;t++;let b=u(),h={},S=[];for(;n.charCodeAt(t)!==vr&&n[t]!==void 0;){let _=n.charCodeAt(t);if(_>64&&_<91||_>96&&_<123){let P=u(),T=n.charCodeAt(t);for(;!isNaN(T)&&T!==Xo&&T!==Zo&&!(T>64&&T<91||T>96&&T<123)&&T!==vr;)t++,T=n.charCodeAt(t);let R;T===Xo||T===Zo?R=f():(R=null,t--),h[P]=R===null?null:es(R)}t++}return n.charCodeAt(t-1)!==$o?(t++,S=o(b)):t++,{tagName:b,attributes:h,children:S,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 Jo(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=Jo(a.children,e,t+1,(j(r)?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function Cr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+Cr(t),e=e.trim()}),e}else return typeof n==\"object\"?Cr(n.children):\" \"+es(n)}function es(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 xi(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 Le(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=xi(n,e,t);return r+(a+1)*i}function Ce(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function et(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function ts(n,e,t){return[n*t,(n+e)*t]}function bd(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 ns(n,e,t){let{timeline:r}=n,i=Ce(e,n);if(i<0)return null;let a=bd(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=Le(o,s,t);return i>=d&&i<u?et(u,n):null}function it(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 yd(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function Mi(n){return(e,t,r)=>{let i=j(r)?parseInt(r,10):1;return yd(String(n),i)}}function Fe(n,e,t){return Sd(n,e,t)}function Sd(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(%0(\\d+)d)?\\$/g,Mi(t===void 0?0:t))}function Ar(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 Mi(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 Mi(n)(i,a,o)})}}function Td(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function In(n,e,t,r,i,a){var _;let o=r.getEstimatedMaximumPosition((_=n.availabilityTimeOffset)!=null?_:0),s=Math.min(e+t,o!=null?o:1/0),u=Ce(e,n),d=Ce(s,n),{timeline:f,timescale:l,segmentUrlTemplate:m,startNumber:g,endNumber:p}=n,b=g!=null?g:1,h=[],S=f.length;for(let P=0;P<S;P++){let T=f[P],{duration:R,start:E,range:M}=T,C;o===void 0?C=i:C=Math.min(o*l,i!=null?i:1/0);let x=xi(T,f[P+1],C),N=n.availabilityTimeComplete!==!1||P!==S-1&&x!==0,B=Td(E,R,u),A=E+B*R;for(;A<d&&B<=x;){let w=b+B;if(p!==void 0&&w>p)break;let k=m===null?null:Ar(A,w)(m),O=A-n.indexTimeOffset,z=R;O<0&&(z=R+O,O=0);let q={id:String(A),time:O/l,end:(O+z)/l,duration:z/l,isInit:!1,range:M,timescale:1,url:k,number:w,timestampOffset:-(n.indexTimeOffset/l),complete:N,privateInfos:{isEMSGWhitelisted:a}};h.push(q),B++,A=E+B*R}if(A>=d||(b+=x+1,p!==void 0&&b>p))return h}return h}function Ed(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 At=class{constructor(e,t){var p,b,h,S;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:Fe(e.initialization.media,a,o),m=e.media===void 0?null:Fe(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:(S=e.timeline)!=null?S:[],timescale:u},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Ce(r,this._index),this._scaledPeriodEnd=v(i)?void 0:Ce(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return In(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:et(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(Le(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return et(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++)Ed(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){c.warn(\"dash\",\"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(\"dash\",\"Base RepresentationIndex: Cannot update a SegmentList\")}};var kt=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:Fe(e.initialization.media,a,o),m=e.list.map(h=>({url:h.media===void 0?null:Fe(h.media,a,o),mediaRange:h.mediaRange}));this._index={list:m,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=it(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]=ts(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,S={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(S),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(\"dash\",\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"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(\"dash\",\"A `ListRepresentationIndex` cannot be updated\")}};function Wt(n){return U.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var xt=class{constructor(e,t){var S,_,P;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:u,representationBitrate:d,isEMSGWhitelisted:f}=t,l=(S=e.timescale)!=null?S:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(_=e.presentationTimeOffset)!=null?_:0,g=s*l,p=m-g;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let b=((P=e.initialization)==null?void 0:P.media)===void 0?null:Fe(e.initialization.media,u,d),h=e.media===void 0?null:Fe(e.media,u,d);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:p,initialization:v(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 it(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(v(g)||v(p))return[];let b=Math.max(g,l),h=Math.min(p,m);if(h+i<=b)return[];let S=[],_=a!=null?a:1,P=Math.floor(b/i);for(let T=P*i;T<=h;T+=i){let R=P+_;if(o!==void 0&&R>o)return S;let E=!v(f)&&T+i>f?f-T:i,M=T+d,C=T+this._index.presentationTimeOffset,x=u===null?null:Ar(C,R)(u),N={id:String(R),number:R,time:M/s,end:(M+E)/s,duration:E/s,timescale:1,isInit:!1,scaledDuration:E/s,url:x,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};S.push(N),P++}return S}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=Wt(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=Wt(t);return i+a<e}isInitialized(){return!0}initialize(){c.error(\"dash\",\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"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 Oi(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 wi(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(Le(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(\"utils\",\"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(\"utils\",\"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(\"utils\",\"The new index is older than the previous one\"),!1):(c.warn(\"utils\",'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(\"utils\",\"The new index is older than the previous one\"),!1):(c.warn(\"utils\",'The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function bn(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}:(c.warn(\"dash\",'A \"S\" Element could not have been parsed.'),null)}function yn(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)?c.warn(\"dash\",\"invalid t value for <S> element\",{val:r}):e.start=i;break}case\"d\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid d value for <S> element\",{val:r}):e.duration=i;break}case\"r\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid r value for <S> element\",{val:r}):e.repeatCount=i;break}}}return e}function It(n){let e=[];for(let r=0;r<n.length;r++)e.push(yn(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=bn(i,a,o);s!==null&&t.push(s)}return t}function Di(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=e[0].attributes.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=e[0],s=i;for(;;){let u=o.attributes.d,d=v(u)?null:parseInt(u,10);if(d===null||Number.isNaN(d))return null;let f=o.attributes.r,l=v(f)?null:parseInt(f,10);if(l!==null){if(Number.isNaN(l)||l<0)return null;if(l>0){let p=t-s;if(p%d===0&&p/d<=l)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:p/d,prevSegmentsIdx:0,newElementsIdx:a}}s+=d*(l+1)}else s+=d;if(a++,a>=e.length)return null;o=e[a];let m=o.attributes.t,g=v(m)?null:parseInt(m,10);if(g!==null){if(Number.isNaN(g))return null;s=g}if(s===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(s>i)return null}}}function Bi(n,e){var b;let t=Di(e,n);if(t===null)return c.warn(\"dash\",'Cannot perform \"based\" update. Common segment not found.'),It(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'),It(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.'),It(n);let f=d[d.length-1],l=yn(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.'),It(n);l.repeatCount!==void 0&&l.repeatCount>f.repeatCount&&(f.repeatCount=l.repeatCount);let g=[],p=[];for(let h=u+1;h<n.length;h++)p.push(yn(n[h]));for(let h=0;h<p.length;h++){let S=p[h],_=g[g.length-1]===void 0?f:g[g.length-1],P=p[h+1]===void 0?null:p[h+1],T=bn(S,_,P);T!==null&&g.push(T)}return d.concat(g)}var Sn=class n{constructor(e,t){var T,R,E,M,C;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=(R=e.presentationTimeOffset)!=null?R:0,b=f*g,h=p-b;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(E=t.receivedTime)!=null?E: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 S=((C=e.initialization)==null?void 0:C.media)===void 0?null:Fe(e.initialization.media,u,d),_=e.media===void 0?null:Fe(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:h,initialization:v(e.initialization)?void 0:{url:S,range:e.initialization.range},segmentUrlTemplate:_,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:Ni(e.timeline,e.startNumber,e.endNumber),timescale:g},this._scaledPeriodStart=Ce(f,this._index),this._scaledPeriodEnd=l===void 0?void 0:Ce(l,this._index)}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),In(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:et(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=kr(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 et(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(Le(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return et(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=Wt(r),o=Ce(t,this._index),s=kr(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=Ce(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],g=Le(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()),_d(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),ns({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof Ze&&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()),wi(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&&Ce(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Wt(this._index.timescale),r=kr(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 Le(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){c.error(\"dash\",\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"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(v(e))return;let t=Ce(e,this._index),r=Oi(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(It(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(Bi(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 _d(n,e,t,r){let i=kr(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 kr(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:Le(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:Le(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(et(o,n)<=r){let s=Le(a,n.timeline[i+1],t);if(et(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let d=Ce(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 xr=Sn;var Rd=/^(?:[a-z]+:)?\\/\\//i,Pd=/^(?:([^:/?#]+):)?(?:\\/\\/([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Li(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(Rd.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Li(n.substring(0,t)):e+1}function rs(n,e){let t=Mr(n),r=Mr(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=En(t.path),a=En(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||j(r.query)&&(s+=\"?\",s+=r.query),j(r.fragment)&&(s+=\"#\",s+=r.fragment),s}function vd(n,e){let t=Mr(n),r=Mr(e);if(j(r.scheme))return Ui(r);let i={scheme:t.scheme,authority:t.authority,path:\"\",query:r.query,fragment:r.fragment};return j(r.authority)?(i.authority=r.authority,i.path=En(r.path),Ui(i)):(r.path===\"\"?(i.path=t.path,j(r.query)||(i.query=t.query)):Oe(r.path,\"/\")?i.path=En(r.path):i.path=En(Ad(t,r.path)),Ui(i))}var Tn=new Map,Cd=200;function Mr(n){var r,i,a,o,s;if(Tn.has(n))return Tn.get(n);let e=n.match(Pd),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:\"\"},Tn.size>=Cd&&Tn.clear(),Tn.set(n,t),t}function Ui(n){let e=\"\";return j(n.scheme)&&(e+=n.scheme+\":\"),j(n.authority)&&(e+=\"//\"+n.authority),e+=n.path,j(n.query)&&(e+=\"?\"+n.query),j(n.fragment)&&(e+=\"#\"+n.fragment),e}function En(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 Ad(n,e){if(j(n.authority)&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function _n(...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=vd(o,s),d=e.slice(2);return _n(u,...d)}}var Rn=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 Fi(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\"),Fi(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),Fi(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function Fi(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=K(n.contentProtections.initData,o=>o.type===\"cenc\");a===void 0?n.contentProtections.initData.push({type:\"cenc\",values:i}):a.values.push(...i)}function Or(n){let e=Date.parse(n)-L();if(isNaN(e)){c.warn(\"dash\",\"Invalid clock received\",{clock:n});return}return e}function zi(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 wr(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 Wi(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=wr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=wr(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(\"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 Dr(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 qi(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=Dr(r);if(s===void 0)return;a=s}if(i!==void 0){let s=Dr(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){c.info(\"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 Vi(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=qi(n),t=Wi(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var Pn=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 Gi(n,e){return n.type!==\"dynamic\"?0:v(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.\",{lastStart:i==null?void 0:i.start,newStart: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 Ki(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 kd(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Ut){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 is=kd;var xd=[\"subtitle\",\"caption\"];function ji(n,e){var s,u,d,f;let t=(f=K((s=n.children.essentialProperties)!=null?s:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\"))!=null?f:K((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 Yi(n,e){if(n.attributes.contentType===\"image\")return ji(n)!==null?\"thumbnails\":void 0;let t=j(n.attributes.mimeType)?n.attributes.mimeType:null,r=j(n.attributes.codecs)?n.attributes.codecs:null,i=v(n.children.roles)?null:n.children.roles;function a(s,u){let d=s.split(\"/\")[0];if(Ie(Ut,d))return d;if(s===\"application/ttml+xml\")return\"text\";if(s===\"application/mp4\")return u!==null&&K(u,f=>f.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&Ie(xd,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 Md=/[, ]+/g;function as(n){return j(n)?n.trim().replace(Md,\", \"):\"\"}function os(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 Qi(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:S=>d===void 0?!1:d.some(({schemeIdUri:_})=>_===S.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:S}=n.children;g=new At(S,m)}else if(n.children.segmentList!==void 0){let{segmentList:S}=n.children;g=new kt(S,m)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let S=e.parentSegmentTemplates.slice(),_=n.children.segmentTemplate;_!==void 0&&S.push(_);let P=H({},...S);(P.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((p=P.availabilityTimeOffset)!=null?p:0)+((b=e.availabilityTimeOffset)!=null?b:0)),(P.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(h=P.availabilityTimeComplete)!=null?h:e.availabilityTimeComplete),g=xr.isTimelineIndexArgument(P)?new xr(P,m):new xt(P,m)}else{let S=e.adaptation.children;if(S.segmentBase!==void 0){let{segmentBase:_}=S;g=new At(_,m)}else if(S.segmentList!==void 0){let{segmentList:_}=S;g=new kt(_,m)}else g=new xt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return g}function at(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=_n(o.url,u.url);r.push({url:d,serviceLocation:(i=u.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Od(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 wd({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=K([...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 os(i)}function $i(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(x=>x.id===m);)m+=\"-dup\";let g=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(m))!=null?a:null,p=Od(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 S=H({},t,{availabilityTimeOffset:h,availabilityTimeComplete:b,unsafelyBaseOnPreviousRepresentation:g,adaptation:e,inbandEventStreams:p}),_=Qi(l,S),P;l.attributes.bitrate===void 0?(c.warn(\"dash\",\"No usable bitrate found in the Representation.\"),P=0):P=l.attributes.bitrate;let T=at(t.baseURLs,l.children.baseURLs),R=T.length===0?[{baseUrl:\"\",id:void 0}]:T.map(x=>({baseUrl:x.url,id:x.serviceLocation})),E={bitrate:P,cdnMetadata:R,index:_,id:m};l.children.supplementalProperties!==void 0&&K(l.children.supplementalProperties,x=>x.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&x.value===\"JOC\")!==void 0&&(E.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,E.codecs=M);let C;l.attributes.supplementalCodecs!==void 0?C=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(C=e.attributes.supplementalCodecs),C!==void 0&&(E.supplementalCodecs=as(C)),l.attributes.frameRate!==void 0?E.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(E.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?E.height=l.attributes.height:e.attributes.height!==void 0&&(E.height=e.attributes.height),l.attributes.mimeType!==void 0?E.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(E.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?E.width=l.attributes.width:e.attributes.width!==void 0&&(E.width=e.attributes.width);{let x=[...(d=e.children.contentProtections)!=null?d:[],...(f=l.children.contentProtections)!=null?f:[]];for(let N of x)t.contentProtectionParser.add(E,N)}E.hdrInfo=wd({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:M}),r.push(E)}return r}function Dd(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 Bd(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 Nd(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function Ud(n,e){if(j(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,u=s;return j(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\"),j(n.attributes.contentType)&&(u+=`-${n.attributes.contentType}`),j(n.attributes.codecs)&&(u+=`-${n.attributes.codecs}`),j(n.attributes.mimeType)&&(u+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(u+=`-${String(n.attributes.frameRate)}`),u}function Ld(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=>j(r))}return[]}function Xi(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],S=h.children,{essentialProperties:_,roles:P,label:T}=S,R=Array.isArray(P)&&P.some(oe=>oe.value===\"main\")&&P.some(oe=>oe.schemeIdUri===\"urn:mpeg:dash:role:2011\"),E=h.children.representations,M=(u=h.attributes.availabilityTimeComplete)!=null?u:e.availabilityTimeComplete,C;(h.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(C=((d=h.attributes.availabilityTimeOffset)!=null?d:0)+((f=e.availabilityTimeOffset)!=null?f:0));let x=Yi(h,E);if(x===void 0)continue;let N=(l=h.attributes.selectionPriority)!=null?l:1,B=h.attributes.id,A=Ld(h),w=[];e.segmentTemplate!==void 0&&w.push(e.segmentTemplate),h.children.segmentTemplate!==void 0&&w.push(h.children.segmentTemplate);let k={availabilityTimeComplete:M,availabilityTimeOffset:C,baseURLs:at(e.baseURLs,S.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},O=Array.isArray(_)?K(_,oe=>oe.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,z=(m=O==null?void 0:O.value)==null?void 0:m.split(\" \"),q=z!==void 0,{accessibilities:$}=S,X;P!==void 0&&P.some(oe=>oe.value===\"dub\")&&(X=!0);let V;x!==\"text\"?V=!1:V=Bd($,P);let G;x===\"text\"&&P!==void 0&&P.some(oe=>oe.value===\"forced-subtitle\"||oe.value===\"forced_subtitle\")&&(G=!0);let J;x!==\"audio\"?J=!1:$!==void 0&&(J=$.some(Dd));let me;x!==\"video\"?me=!1:$!==void 0&&(me=$.some(Nd));let le=Ud(h,{isAudioDescription:J,isForcedSubtitle:G,isClosedCaption:V,isSignInterpreted:me,isTrickModeTrack:q,type:x});for(;Ie(o,le);)le+=\"-dup\";let pe=le;o.push(le),k.unsafelyBaseOnPreviousAdaptation=(p=(g=e.unsafelyBaseOnPreviousPeriod)==null?void 0:g.getAdaptation(le))!=null?p:null;let $e=$i(E,h,k);if(x===\"thumbnails\"){let oe=Fd(h,$e);oe!==null&&r.push(...oe);continue}let ne={id:le,representations:$e,type:x,isTrickModeTrack:q};if(v(h.attributes.language)||(ne.language=h.attributes.language),v(V)||(ne.closedCaption=V),v(J)||(ne.audioDescription=J),X===!0&&(ne.isDub=!0),G!==void 0&&(ne.forcedSubtitles=G),me===!0&&(ne.isSignInterpreted=!0),T!==void 0&&(ne.label=T),z!==void 0)i.push({adaptation:ne,trickModeAttachedAdaptationIds:z});else{let oe=-1;for(let Xt of A){let Zt=a[Xt];if(Zt!==void 0&&Zt.newID!==pe&&Ie(Zt.adaptationSetSwitchingIDs,B)){oe=re(t[x],Jt=>Jt[0].id===Xt);let Re=t[x][oe];if(Re!==void 0&&Re[0].audioDescription===ne.audioDescription&&Re[0].closedCaption===ne.closedCaption&&Re[0].language===ne.language){c.info(\"dash\",'merging \"switchable\" AdaptationSets',{originalID:B,id:Xt}),Re[0].representations.push(...ne.representations),Re[1]={priority:Math.max(N,Re[1].priority),isMainAdaptation:R||Re[1].isMainAdaptation,indexInMpd:Math.min(b,Re[1].indexInMpd)};break}}}oe<0&&t[x].push([ne,{priority:N,isMainAdaptation:R,indexInMpd:b}])}!v(B)&&v(a[B])&&(a[B]={newID:pe,adaptationSetSwitchingIDs:A})}let s=Ut.reduce((b,h)=>{let S=t[h];return S.length>0&&(S.sort(ss),b[h]=S.map(([_])=>_)),b},{});return t.video.sort(ss),is(s,i),{adaptations:s,thumbnailTracks:r}}function Fd(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=ji(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 ss(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 zd=Me();function Zi(n,e){var o,s,u,d,f;let t=[],r=Ki(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 m=l===n.length-1,g=n[l],p=e.xlinkInfos.get(g),b=at(e.baseURLs,g.children.baseURLs),{periodStart:h,periodDuration:S,periodEnd:_}=r[l],P;for(v(g.attributes.id)?(P=\"gen-dash-period-\"+zd(),c.warn(\"dash\",\"No usable id found in the Period. Generating one.\",{periodId:P})):P=g.attributes.id;t.some(q=>q.id===P);)P+=\"-dup\";let T=p!==void 0?p.receivedTime:e.receivedTime,R=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(P))!=null?s:null,E=g.attributes.availabilityTimeComplete,M=g.attributes.availabilityTimeOffset,{manifestProfiles:C,contentProtectionParser:x}=e,{segmentTemplate:N}=g.children;x.addReferences((u=g.children.contentProtections)!=null?u:[]);let B={availabilityTimeComplete:E,availabilityTimeOffset:M,baseURLs:b,contentProtectionParser:x,manifestBoundsCalculator:a,end:_,isDynamic:i,isLastPeriod:m,manifestProfiles:C,receivedTime:T,segmentTemplate:N,start:h,unsafelyBaseOnPreviousPeriod:R},{adaptations:A,thumbnailTracks:w}=Xi(g.children.adaptations,B),k=((d=e.xmlNamespaces)!=null?d:[]).concat((f=g.attributes.namespaces)!=null?f:[]),O=qd(g.children.eventStreams,h,k),z={id:P,start:h,end:_,duration:S,thumbnailTracks:w,adaptations:A,streamEvents:O};if(t.unshift(z),!a.lastPositionIsKnown()){let q=Wd(A);if(!i)typeof q==\"number\"&&a.setLastPosition(q);else if(typeof q==\"number\"){let $=L()/1e3;a.setLastPosition(q,$)}else{let $=us(e,h);if($!==void 0){let[X,V]=$;a.setLastPosition(X,V)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=us(e,0);if(l!==void 0){let[m,g]=l;a.setLastPosition(m,g)}}return Hi(t)}function us(n,e){if(v(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){c.warn(\"dash\",\"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 Wd(n){let e=null,t=!0,r=Ir(n).filter(a=>!v(a)),i=Pi(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 qd(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;try{p={namespaces:d,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:Ke(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 qt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(v(e.externalClockOffset)){let u=o.type===\"dynamic\",d=K(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!v(m.value)),f=!v(d)&&!v(d.value)?Or(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 m=zi(n);if(!v(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(p){return p.success?(e.externalClockOffset=Or(p.data),qt(n,e,t,!0)):(t.push(p.error),c.warn(\"dash\",\"Error on fetching the clock ressource\",p.error),qt(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?Vd(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 S of m)i.set(S,{receivedTime:p,sendingTime:b,url:h});a.periods.splice(l,1,...m)}return qt(n,e,t,r,i)}}}}function Vd(n,e,t,r){var k,O,z,q,$;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Li(e.url))}]:[],u=at(s,i.baseURLs),d=Gi(a,e.referenceDateTime),f=a.timeShiftBufferDepth,l=a.maxSegmentDuration,{externalClockOffset:m,unsafelyBaseOnPreviousManifest:g}=e,{externalClockOffset:p}=e,b=new Pn({availabilityStartTime:d,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:p}),h=new Rn;h.addReferences((k=i.contentProtections)!=null?k:[]);let S={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},_=Zi(i.periods,S);h.finalize();let P=a.duration,T,R,E=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:C,maximumSafePosition:x,maximumUnsafePosition:N}=Vi(_),B=L();if(o){let X;x!==void 0?X=x:p===void 0?(c.warn(\"dash\",\"use system clock to define maximum position\"),X=Date.now()/1e3-d):X=(L()+p)/1e3-d;let V=b.getEstimatedLiveEdge();V===void 0&&(N!==void 0?V=N:V=X),M={isLinear:!0,maximumSafePosition:X,livePosition:V,time:B},R=C,E=f!=null?f:null,E!==null&&(E+=l!=null?l:0),E!==null&&R!==void 0&&V-R>E&&(E=V-R)}else{R=C,R===void 0&&(R=(z=(O=_[0])==null?void 0:O.start)!=null?z:0);let X=P!=null?P:1/0;if(_[_.length-1]!==void 0){let V=_[_.length-1],G=(q=V.end)!=null?q:V.duration!==void 0?V.start+V.duration:void 0;G!==void 0&&G<X&&(X=G)}x!==void 0&&x<X&&(X=x),M={isLinear:!1,maximumSafePosition:X,livePosition:void 0,time:B}}let A=!o||n.attributes.minimumUpdatePeriod===void 0&&((($=_[_.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:A,periods:_,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:R,timeshiftDepth:E,maximumTimeData:M},lifetime:T,uris:v(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var Br=qt;var Gd=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,Hd=/([0-9]+)-([0-9]+)/;function Ae(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new Be(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ae(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new Be(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function we(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new Be(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function Ji(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new Be(`\\`${e}\\` property is not a boolean nor an integer but \"${n}\"`)]:[t,null]}function Nr(n,e){let t=Date.parse(n);return isNaN(t)?[null,new Be(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function je(n,e){if(!j(n))return[0,new Be(`\\`${e}\\` property is empty`)];let t=Gd.exec(n);return t===null?[null,new Be(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(j(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(j(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(j(t[6])?t[6]:\"0\")*24*60*60+parseFloat(j(t[8])?t[8]:\"0\")*60*60+parseFloat(j(t[10])?t[10]:\"0\")*60+parseFloat(j(t[12])?t[12]:\"0\"),null]}function Mt(n,e){let t=Hd.exec(n);return t===null?[null,new Be(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function ds(n,e){try{return[_r(n),null]}catch(t){return[null,new Be(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Vt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:we(n,e)}function Te(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 Ee(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(c.warn(\"dash\",\"failed to parse DASH value:\",s.message,{dashName:a}),e.push(s)),o!==null&&(n[r]=o)}}var Be=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\"}};function bt(n){return Cr(n)}function ot(n){let e=typeof n==\"string\"?n:bt(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function Kd(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=bt(i.children);if(a!==null&&a.length>0){let[o,s]=ds(a,\"cenc:pssh\");s!==null&&(c.warn(\"dash\",\"Content protection parsing failure\",s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function jd(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=dn(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function st(n){let[e,t]=Kd(n.children),r=jd(n);return[{children:e,attributes:r},t]}function ea(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 ta(n){let e={},t=[],r=Ee(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:Mt,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function ut(n){let e={},t=[],r=Ee(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]=ta(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:ae,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:we,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Mt,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:Ae,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ae,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ae,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ae,dashName:\"endNumber\"});break}}return[e,t]}function na(n){let e={},t=[],r=Ee(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:Mt,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Mt,dashName:\"mediaRange\"});break}}return[e,t]}function vn(n){let[e,t]=ut(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]=na(u);i.push(d),r=r.concat(f)}}return[H(e,{list:i}),r]}function ra(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 Ot(n){let[e,t]=ut(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=ra(u))}let a=H({},e,{duration:e.duration,timelineParser:i}),o=Ee(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:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(u,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=u;break;case\"bitstreamSwitching\":o(u,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function Yd(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]=ot(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break}case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Te(a));break;case\"SegmentBase\":{let[o,s]=ut(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=vn(a);r=r.concat(s),e.segmentList=o;break}case\"SegmentTemplate\":{let[o,s]=Ot(a);r=r.concat(s),e.segmentTemplate=o;break}case\"ContentProtection\":{let[o,s]=st(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}case\"EssentialProperty\":v(e.essentialProperties)?e.essentialProperties=[Te(a)]:e.essentialProperties.push(Te(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Te(a)]:e.supplementalProperties.push(Te(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function Qd(n){let e={},t=[],r=Ee(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:ae,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:Ae,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Vt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ae,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:we,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:we,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ae,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ae,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new Be(\"No bitrate found on a Representation\")),[e,t]}function ls(n){let[e,t]=Yd(n.children),[r,i]=Qd(n),a=t.concat(i);return[{children:e,attributes:r},a]}function $d(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=[Te(a)]:e.accessibilities.push(Te(a));break;case\"BaseURL\":{let[o,s]=ot(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break}case\"ContentComponent\":e.contentComponent=ea(a);break;case\"EssentialProperty\":v(e.essentialProperties)?e.essentialProperties=[Te(a)]:e.essentialProperties.push(Te(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Te(a));break;case\"Label\":{let o=bt(a.children);o!=null&&(e.label=o);break}case\"Representation\":{let[o,s]=ls(a);e.representations.push(o),s.length>0&&(r=r.concat(s));break}case\"Role\":v(e.roles)?e.roles=[Te(a)]:e.roles.push(Te(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Te(a)]:e.supplementalProperties.push(Te(a));break;case\"SegmentBase\":{let[o,s]=ut(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=vn(a);e.segmentList=o,s.length>0&&(r=r.concat(s));break}case\"SegmentTemplate\":{let[o,s]=Ot(a);e.segmentTemplate=o,s.length>0&&(r=r.concat(s));break}case\"ContentProtection\":{let[o,s]=st(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 Xd(n){let e={},t=[],r=Ee(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:ae,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:ae,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ae,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ae,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ae,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ae,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ae,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:Vt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Vt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ae,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:Ji,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:Ji,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ae,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:Ae,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Vt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ae,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:we,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:we,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:ae,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function fs(n){let e=n.children,[t,r]=$d(e),[i,a]=Xd(n),o=r.concat(a);return[{children:t,attributes:i},o]}function Zd(n){let e={},t=[],r=Ee(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:ae,dashName:\"timescale\"});break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function ms(n,e){let[t,r]=Zd(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]=ae(a.attributes.presentationTime,\"presentationTime\");u!==null&&r.push(u),s!==null&&(o.presentationTime=s)}if(!v(a.attributes.duration)){let[s,u]=ae(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 Jd(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]=ot(d);f!==void 0&&t.push(f),o=o.concat(l);break}case\"AdaptationSet\":{let[f,l]=fs(d);r.push(f),o=o.concat(l);break}case\"EventStream\":{let[f,l]=ms(d,e);s.push(f),o=o.concat(l);break}case\"SegmentTemplate\":{let[f,l]=Ot(d);i=f,l.length>0&&(o=o.concat(l));break}case\"ContentProtection\":{let[f,l]=st(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 el(n){let e={},t=[],r=Ee(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:je,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:je,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Ur(n,e){let[t,r]=Jd(n.children,e),[i,a]=el(n),o=r.concat(a);return[{children:t,attributes:i},o]}function tl(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]=ot(d);f!==void 0&&t.push(f),s=s.concat(l);break}case\"Location\":r.push(bt(d.children));break;case\"Period\":{let[f,l]=Ur(d,e);i.push(f),s=s.concat(l);break}case\"UTCTiming\":{let f=Te(d);a.push(f);break}case\"ContentProtection\":{let[f,l]=st(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 nl(n){let e={},t=[],r=Ee(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:Nr,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:Nr,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:Nr,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:je,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:je,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:je,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:je,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:je,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:je,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:je,dashName:\"maxSubsegmentDuration\"});break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function cs(n,e){let[t,r]=tl(n.children,e),[i,a]=nl(n),o=r.concat(a);return[{children:t,attributes:i},o]}function ia(n,e){let t=ki(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]=cs(r,n),o=Br(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 S=\"<root>\"+g.data+\"</root>\",_=ki(S),P=_[_.length-1];if(P===void 0||typeof P==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let T=P.children,R=[],E=[];for(let M=0;M<T.length;M++){let C=T[M];if(typeof C==\"string\"||C.tagName!==\"Period\")continue;let[x,N]=Ur(C,S);E.push(...N),R.push(x)}f.push({url:h,receivedTime:p,sendingTime:b,parsed:R,warnings:E})}let l=u.value.continue(f);return s(l)}}};Ne(u)}}var ps=ia;var rl=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",gs=rl;function W(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function aa(n){return n===1/0?!0:n===-1/0?!1:n}function yt(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=W(t,e.buffer,a,o))}}function St(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,u){switch(o){case 16:t.schemeIdUri=W(i,e.buffer,s,u);break;case 13:t.value=W(i,e.buffer,s,u);break;case 14:{let d=W(i,e.buffer,s,u);t.keyId=dn(d.replace(/-/g,\"\"));break}case 15:try{let d=W(i,e.buffer,s,u);r.cencPssh.push(_r(d))}catch(d){}break;case 78:t.ref=W(i,e.buffer,s,u);break;case 79:t.refId=W(i,e.buffer,s,u);break}}}function hs(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=W(t,e.buffer,a,o);break;case 60:n.language=W(t,e.buffer,a,o);break;case 61:n.contentType=W(t,e.buffer,a,o);break;case 62:n.par=W(t,e.buffer,a,o);break}}}function Is(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.label=W(t,e.buffer,a,o))}}function ze(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=W(t,e.buffer,a,o);break;case 17:n.value=W(t,e.buffer,a,o);break}}}function Gt(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=W(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 bs(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=W(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=W(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 Lr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=bs(a,e);t.pushParsers(i,D,o);break}default:t.pushParsers(i,D,D);break}}}function Ht(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:W(t,e.buffer,a,o)};break;case 28:n.index=W(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=W(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 ys(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,D,yt(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=St(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,ze(a,e));break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=ze(a,e);t.pushParsers(i,D,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=ze(a,e);t.pushParsers(i,D,o);break}case 17:{let a={};n.segmentBase=a;let o=Gt(a,e);t.pushParsers(i,D,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Lr(a,e,t),s=Gt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,D,Ht(a,e));break}default:t.pushParsers(i,D,D);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=W(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=W(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=W(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=W(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=W(t,e.buffer,a,o);break;case 2:n.profiles=W(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=W(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 Ts(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=ze(a,e);t.pushParsers(i,D,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=yt(a,e);t.pushParsers(i,D,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,D,hs(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=St(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=ze(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=ze(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=ys(a.children,e,t),s=Ss(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=ze(a,e);t.pushParsers(i,D,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=ze(a,e);t.pushParsers(i,D,o);break}case 17:{let a={};n.segmentBase=a;let o=Gt(a,e);t.pushParsers(i,D,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Lr(a,e,t),s=Gt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,D,Ht(a,e));break}case 21:{t.pushParsers(i,D,Is(n,e));break}default:t.pushParsers(i,D,D);break}}}function Es(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=W(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=W(t,e.buffer,a,o);break;case 61:n.contentType=W(t,e.buffer,a,o);break;case 62:n.par=W(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=aa(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=aa(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=W(t,e.buffer,a,o);break;case 4:n.codecs=W(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=W(t,e.buffer,a,o);break;case 2:n.profiles=W(t,e.buffer,a,o);break;case 12:n.segmentProfiles=W(t,e.buffer,a,o);break;case 11:n.mimeType=W(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 _s(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=il(o,e,r);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function Rs(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=W(t,e.buffer,a,o);break;case 17:n.value=W(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=W(t,e.buffer,d,f),d+=f;let l=s.getUint32(d);d+=4,u.value=W(t,e.buffer,d,l),n.namespaces===void 0?n.namespaces=[u]:n.namespaces.push(u);break}}}}function il(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=W(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 Fr(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=Ts(o.children,e,t),u=Es(o.attributes,e);t.pushParsers(a,s,u);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=D,u=yt(o,e);t.pushParsers(a,s,u);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=_s(o.children,e,t,r),u=Rs(o.attributes,e);t.pushParsers(a,s,u);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,D,Ht(o,e));break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=St(o,e);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function zr(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=W(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=W(t,e.buffer,a,o);break;case 47:n.xlinkActuate=W(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=W(t,e.buffer,d,f),d+=f;let l=u.getUint32(d);d+=4,s.value=W(t,e.buffer,d,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}}function Ps(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=D,u=yt(o,e);t.pushParsers(a,s,u);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Fr(o.children,e,t,r),u=zr(o.attributes,e);t.pushParsers(a,s,u);break}case 3:{let o={};n.utcTimings.push(o);let s=D,u=ze(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=St(o,e);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function vs(n,e,t){let r,i=new TextDecoder;return function(o,s,u){switch(o){case 0:e.id=W(i,t.buffer,s,u);break;case 2:e.profiles=W(i,t.buffer,s,u);break;case 33:e.type=W(i,t.buffer,s,u);break;case 34:{let d=W(i,t.buffer,s,u);e.availabilityStartTime=new Date(d).getTime()/1e3;break}case 35:{let d=W(i,t.buffer,s,u);e.availabilityEndTime=new Date(d).getTime()/1e3;break}case 36:{let d=W(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=W(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=W(i,t.buffer,f,l),f+=l;let m=r.getUint32(f);f+=4,d.value=W(i,t.buffer,f,m),e.namespaces===void 0?e.namespaces=[d]:e.namespaces.push(d);break}}}}function oa(n,e,t,r){return function(a){switch(a){case 1:{n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=Ps(n.mpd.children,e,t,r),s=vs(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break}default:t.pushParsers(a,D,D);break}}}function Cs(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Fr(o.children,e,t,r),u=zr(o.attributes,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,D,D);break}}}var Cn=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 al=15e3,An=class{constructor(){this._parsersStack=new Cn,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(\"dash\",\"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(\"dash\",\"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 S=i._linearMemory,_=new Uint8Array(S.buffer,b,h);if(p===1){let P=r.decode(_);c.warn(\"dash\",\"WASM Error Event:\",P),i._warnings.push(new Error(P))}else if(p===0){let P=r.decode(_);c.warn(\"dash\",\"WASM Log Event:\",P)}}function g(p,b){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let h=i._linearMemory,{mpd:S,cursor:_}=i._mpdData,P=Math.min(b,al,S.byteLength-_);return new Uint8Array(h.buffer,p,P).set(new Uint8Array(S,_,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=Br(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return gs&&typeof te.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=oa(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=Cs(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,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 Ne(e)}};var As=An;var wt=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 Wr(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 Wr(this,i,t)}}}var kn=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 Wr(this,e,this._cancelSignal)}};function Ye(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 sa(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-L(),u=!1,m={reject:b=>{var P,T;if(u||i.isCancelled())return;u=!0,i.deregister(p);let h=b,S=(P=h==null?void 0:h.message)!=null?P:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",_=new Xe(S,(T=h==null?void 0:h.canRetry)!=null?T:!1,h==null?void 0:h.xhr);o(_)},resolve:b=>{if(u||i.isCancelled())return;u=!0,i.deregister(p);let h=b.receivingTime!==void 0?b.receivingTime-s:void 0,S=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:S})},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 ol(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\"?Ye(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:Ne(n)}}}function ua({customManifestLoader:n},e,t){let r=ol(e),i=typeof n!=\"function\"?r:sa(n,r);return t!==null?t(i):i}function da(n,e){if(e){if(Je(n,1718909296)<0)throw new _e(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Je(n,1836019574)<0)throw new _e(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Je(n,1836019558)<0)throw new _e(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Je(n,1835295092)<0)throw new _e(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function Qe(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 qr(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,se(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)||Qe(t.type,t.mimeType)!==\"mp4\"||da(new Uint8Array(s),t.segment.isInit)}}}function ks(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(;sl(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(;ul(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(!v(te.Document)&&o instanceof te.Document&&o.documentElement.nodeName!==\"MPD\")throw new _e(\"INTEGRITY_ERROR\",\"MPD does not end with </MPD>\")}}}function sl(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function ul(n){return n===32||n===9||n===13||n===10}function la(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 _;let{responseData:d}=i,f=a.externalClockOffset,l=(_=i.url)!=null?_:a.originalUrl,m=t!=null?t:f,p={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:m},b=De.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 P=ml(d);if(!cl(P))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(P,p);return S(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 R=b.wasm.runWasmParser(P,p);return S(R)})}function h(){if(b.js!==null){let P=fl(d),T=b.js(P,p);return S(T)}else throw new Error(\"No MPD parser is imported\")}function S(P){if(P.type===\"done\")return P.value.warnings.length>0&&o(P.value.warnings),s.isCancelled()?Promise.reject(s.cancellationError):{manifest:new zt(P.value.parsed,n),url:l};let{value:T}=P,R=T.urls.map(E=>u(()=>{let M=U.getCurrent().DEFAULT_REQUEST_TIMEOUT,C=U.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return T.format===\"string\"?be({url:E,responseType:\"text\",timeout:M,connectionTimeout:C,cancelSignal:s}):be({url:E,responseType:\"arraybuffer\",timeout:M,connectionTimeout:C,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 H(M,{responseData:{success:!0,data:M.responseData}})}else{if(!(M.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return H(M,{responseData:{success:!0,data:M.responseData}})}},M=>{let C=ge(M,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return H({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:C}})}));return Promise.all(R).then(E=>T.format===\"string\"?(dl(E),S(T.continue(E))):(ll(E),S(T.continue(E))))}}}function dl(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 ll(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 fl(n){if(n instanceof ArrayBuffer)return Ke(new Uint8Array(n));if(typeof n==\"string\")return n;if(!v(te.Document)&&n instanceof te.Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function ml(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return un(n).buffer;if(!v(te.Document)&&n instanceof te.Document)return un(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function cl(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 We([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function Dt(n,e){return n===null?null:e.url===null?n.baseUrl:_n(n.baseUrl,e.url)}function xn(n,e,t,r,i){var d,f;let a=n;((d=t.cmcdPayload)==null?void 0:d.type)===\"query\"&&(a=Ye(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:se(ee({},o),{Range:We(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:se(ee({},o),{Range:We([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:se(ee({},o),{Range:We(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),u=be({url:a,headers:se(ee({},o),{Range:We(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=Ct(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 Mn(n,e,t,r){let i=null;function a(s){let u=new Uint8Array(s.chunk),d=i!==null?Ct(i,u):u,f=Rr(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 gr({url:n,headers:e.headers,onData:a,timeout:e.timeout,connectionTimeout:e.connectionTimeout,cancelSignal:r})}}async function xs(n,e,t,r,i,a){var m,g;if(e.segment.isInit)return xn(n,e.segment,r,a,i);let o=((m=r.cmcdPayload)==null?void 0:m.type)===\"query\"?Ye(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=se(ee({},s),{Range:We(u.range)}):s!==void 0&&(d=s);let f=Qe(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(rn())return Mn(o,{headers:d,timeout:r.timeout,connectionTimeout:r.connectionTimeout},i,a);rt(\"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 fa({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:qr(r);function r(i,a,o,s,u){let d=Dt(i,a.segment);return d===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?xs(d,a,n,o,u,s):new Promise((f,l)=>{let m=!1,S={reject:E=>{var N,B;if(m||s.isCancelled())return;m=!0,s.deregister(R);let M=E,C=(N=M==null?void 0:M.message)!=null?N:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",x=new Xe(C,(B=M==null?void 0:M.canRetry)!=null?B:!1,M==null?void 0:M.xhr);l(x)},resolve:E=>{if(m||s.isCancelled())return;m=!0,s.deregister(R);let M;E.data instanceof Uint8Array?E.data.buffer instanceof ArrayBuffer?M=E.data:M=E.data.slice():M=E.data,f({resultType:\"segment-loaded\",resultData:{responseData:M,size:E.size,requestDuration:E.duration}})},progress:E=>{m||s.isCancelled()||u.onProgress({duration:E.duration,size:E.size,totalSize:E.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(R),xs(d,a,n,o,u,s).then(f,l))}},_;a.segment.range!==void 0&&(_=[a.segment.range],a.segment.indexRange!==void 0&&_.push(a.segment.indexRange));let P={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:_,trackType:a.type,url:d,cmcdPayload:o.cmcdPayload},T=e(P,S);s.register(R);function R(E){m||(m=!0,typeof T==\"function\"&&T(),l(E))}})}}var ca=408125543,Ms=357149030,pl=2807729,gl=17545,hl=475249515,Il=187,bl=179,yl=183,Sl=241;function Tt(n,e,t,[r,i]){let a=r;for(;a<i;){let o=El(t,a);if(o===null)return null;let{value:s,length:u}=o,d=a+u,f=_l(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 Tt(n,h,t,[g,p])}}a=p}return null}function Vr(n,e){let t=Tt(pl,[ca,Ms],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/ma(n,t[0],r)}function Tl(n,e){let t=Tt(gl,[ca,Ms],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?Rl(n,t[0]):r===8?Pl(n,t[0]):null}function pa(n,e){let t=Tt(ca,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=Vr(n,r);if(a===null)return null;let o=Tl(n,r);if(o===null)return null;let s=Tt(hl,[],n,[r,i]);if(s===null)return null;let u=[],d=s[0];for(;d<s[1];){let l=Tt(Il,[],n,[d,s[1]]);if(l===null)break;let m=Tt(bl,[],n,[l[0],l[1]]);if(m===null)return null;let g=ma(n,m[0],m[1]-m[0]),p=Tt(Sl,[yl],n,[l[0],l[1]]);if(p===null)return null;let b=ma(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 Os(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function El(n,e){let t=Os(n,e);if(t===void 0)return c.warn(\"webm\",\"unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm\",\"impossible length\",{offset:e,length:t,bufferLength:n.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 _l(n,e){let t=Os(n,e);if(t===void 0)return c.warn(\"webm\",\"unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm\",\"impossible length\",{offset:e,length:t,bufferLength:n.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 Rl(n,e){return new DataView(n.buffer).getFloat32(e)}function Pl(n,e){return new DataView(n.buffer).getFloat64(e)}function ma(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 On(n,e,t,r){let i=_i(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=Ri(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 vl(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=Ke(o),u=Date.parse(s);if(a===void 0||u===void 0||isNaN(u)||u>=a)return!0}return!1}function ga(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:vl(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function ha({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var P,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=Bo(u),m=Qe(r.type,r.mimeType),g=m===\"mp4\"||m===void 0,p=[];if(g){let R=Pr(l),E;a.isInit&&(E=(P=Wo(l))!=null?P:void 0),(R.length>0||E!==void 0)&&p.push({initDataType:\"cenc\",keyId:E,initData:R})}if(!a.isInit){let R=g?On(l,d,a,i):null,E=(T=a.timestampOffset)!=null?T:0;if(g){let M=zo(l);if(M!==void 0){let C=M.filter(N=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(N)),x=ga(C,r.manifestPublishTime);if(x!==void 0){let{needsManifestRefresh:N,inbandEvents:B}=x;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:R,chunkOffset:E,appendWindow:f,inbandEvents:B,protectionData:p,needsManifestRefresh:N}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:R,chunkOffset:E,protectionData:p,appendWindow:f}}let{indexRange:b}=a,h;if(m===\"webm\")h=pa(l,0);else if(g&&(h=mn(l,Array.isArray(b)?b[0]:0),n===!0&&h!==null&&h.length>0)){let R=h[h.length-1];Array.isArray(R.range)&&(R.range[1]=1/0)}let S;g?S=cn(l):m===\"webm\"&&(S=Vr(l,0));let _=v(S)?void 0:S;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:p,initTimescale:_,segmentList:h!=null?h:void 0}}}function Ia({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:qr(t);async function t(r,i,a,o,s){var h,S;let{segment:u}=i,d=Dt(r,u);if(d===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(u.isInit)return xn(d,u,a,o,s);let f=((h=a.cmcdPayload)==null?void 0:h.type)===\"query\"?Ye(d,a.cmcdPayload.value):d,l=((S=a.cmcdPayload)==null?void 0:S.type)===\"headers\"?a.cmcdPayload.value:void 0,m;u.range!==void 0?m=se(ee({},l),{Range:We(u.range)}):l!==void 0&&(m=l);let g=Qe(i.type,i.mimeType),p=g===\"mp4\"||g===void 0;if(n&&p){if(rn())return Mn(f,{headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout},s,o);rt(\"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 Cl(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 Al(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 ws({segment:n,language:e,codecs:t},r,i,a,o){if(n.isInit)return null;let s,u;a===null?o?(s=n.time,u=n.end):c.warn(\"utils\",\"Unavailable time data for current text track.\"):(s=a.time,a.duration!==void 0?u=s+a.duration:!o&&n.complete&&(u=s+n.duration));let d=Cl(t),f=Ti(r),l=f!==null?Ke(f):\"\";return t===\"wvtt\"&&!Oe(l,\"WEBVTT\")&&!Oe(l,\"\\xFE\\xFFWEBVTT\")?{data:r,type:\"mp4vtt\",language:e,start:s,end:u,initTimescale:i!=null?i:null}:{data:l,type:d,language:e,start:s,end:u,initTimescale:i!=null?i:null}}function Ds(n,e,t,r){let{segment:i}=n;if(i.isInit)return null;let a,o;r?c.warn(\"utils\",\"Unavailable time data for current text track.\"):(a=i.time,i.complete&&(o=i.time+i.duration));let s=Al(n.codecs,n.mimeType);return{data:e,type:s,language:n.language,start:a,end:o,initTimescale:t!=null?t:null}}function kl(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=mn(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=cn(u);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:p,segmentList:g!=null?g:void 0}}let d=On(u,e,a,r),f=ws(t,u,r,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 xl(n,e,t,r){let{periodStart:i,periodEnd:a,segment:o}=r,{timestampOffset:s=0}=o;if(o.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let u,d;if(typeof n!=\"string\"){let l=n instanceof Uint8Array?n:new Uint8Array(n);u=Ke(l),d=l.length}else u=n;return{segmentType:\"media\",chunkData:Ds(r,u,e,t),chunkSize:d,chunkInfos:null,chunkOffset:s,protectionData:[],appendWindow:[i,a]}}function ba({__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=Qe(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?kl(u,d,r,i,n):xl(u,i,d,r)}}async function Bs(n,e,t,r){var u,d;let i=Dt(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\"?Ye(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=se(ee({},o),{Range:We(e.range)}):o!==void 0&&(s=o),an({url:a,responseType:\"arraybuffer\",headers:s,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r})}function Ns(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 Us(n){let e=ua({customManifestLoader:n.manifestLoader},Ml()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?ks:null),t=la(n),r=fa(n),i=ha(n),a=Ia(n),o=ba(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:Bs,parseThumbnail:Ns}}}function Ml(){return De.dashParsers.wasm!==null&&(De.dashParsers.wasm.status===\"initialized\"||De.dashParsers.wasm.status===\"initializing\")}var Ls=Us;var dt=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var Bt=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 K(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 wn=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 Ol=.016666666666666666;function Fs(n,e){return Math.abs(n-e)<Ol}function Ws(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function wl(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function Dl(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(Vs(t,r)){let i=Ws(t,r);n.splice(--e,2,i)}}return n}function ya(n,e){return n.end<=e.start}function zs({start:n,end:e},t){return n<=t&&t<e}function qs(n,e){return zs(n,e.start)||n.start<e.end&&e.end<n.end||zs(e,n.start)}function Vs(n,e){return Fs(e.start,n.end)||Fs(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 Bl(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 Gs(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 Gr(n,e){let t=Bl(n,e);return t!==null?t.end-e:1/0}function Et(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=qs(t,i),o=Vs(t,i);if(a||o)t=Ws(t,i),n.splice(r--,1);else if(r===0){if(ya(t,n[0]))break}else if(ya(n[r-1],t)&&ya(t,i))break}return n.splice(r,0,t),Dl(wl(n))}function Nl(n,e){let t=[];for(let r=0;r<e.length;r++)qs(n,e[r])&&t.push(e[r]);return t}function Hr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=Nl(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 Kr({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&&Ul(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(\"Stream\",\"Could not run BufferGarbageCollector:\",d)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function Ul(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:u}=Gs(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(c.debug(\"Stream\",\"cleaning range from SegmentSink\",{start:l.start,end:l.end}),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(l.start,l.end)}}var Dn=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=>nt(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 Bn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=U.getCurrent();this._inventory=[],this._bufferedHistory=new Dn(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,S=e[b].end;if(S-h<a){c.warn(\"SI\",\"skipped range when synchronizing because it was too small\",{t:o,rangeStart:h,rangeEnd:S});continue}let _=r;for(;i!==void 0&&((u=i.bufferedEnd)!=null?u:i.end)-h<a;)i=t[++r];let P=null,T=r-_;if(T>0){let E=t[_+T-1];P={end:(d=E.bufferedEnd)!=null?d:E.end,precizeEnd:E.precizeEnd},c.debug(\"SI\",`${T} segments GCed.`,{t:o});let M=t.splice(_,T);for(let C of M)C.bufferedStart===void 0&&C.bufferedEnd===void 0&&C.status!==2&&this._bufferedHistory.addBufferedSegment(C.infos,null);r=_}if(i===void 0)return;if(S-((f=i.bufferedStart)!=null?f:i.start)>=a){if(Ll(i,h,P,o),r===t.length-1){Ks(i,S,o);return}i=t[++r];let E=(l=i.bufferedStart)!=null?l:i.start,M=(m=i.bufferedEnd)!=null?m:i.end,C=b<s-1?e[b+1].start:void 0;for(;i!==void 0&&!(S<E||S-E<a&&M-S>=a||C!==void 0&&S-E<M-C);){let x=t[r-1];x.bufferedEnd===void 0&&(i.precizeStart?x.bufferedEnd=i.start:x.infos.segment.complete?x.bufferedEnd=x.end:x.bufferedEnd=i.start,c.debug(\"SI\",\"calculating buffered end of contiguous segment\",{t:o,prevSegmentBufferedEnd:x.bufferedEnd,pse:x.end})),i.bufferedStart=x.bufferedEnd,i=t[++r],i!==void 0&&(E=(g=i.bufferedStart)!=null?g:i.start,M=(p=i.bufferedEnd)!=null?p:i.end)}}let R=t[r-1];R!==void 0&&Ks(R,S,o)}if(!v(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:b}=U.getCurrent(),h=L();for(let S=r;S<t.length;S++){let _=t[S];h-_.insertionTs>=b&&(c.debug(\"SI\",\"A segment at the end has been completely GCed\",He(_.infos)),_.bufferedStart===void 0&&_.bufferedEnd===void 0&&_.status!==2&&this._bufferedHistory.addBufferedSegment(_.infos,null),t.splice(S,1),S--)}}o!==void 0&&c.hasLevel(\"DEBUG\")&&c.debug(\"SI\",`current ${o} inventory timeline:\n`+Fl(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\",{t:f,start:o,end: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.\",{t:f,pse:b.end,ss:o}),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\",{t:f,pss:l[p].start,ss:o,se:s}),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\",{t:f,ss:o,se:s,pss:l[p].start,pse: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\",{t:f,ss:o,se:s,pss:b.start,pse: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\",{t:f,ss:o,se:s,pss:l[p].start,pse:l[p].end}),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\",{t:f,ss:o,se:s,pss:l[p].start,pse:l[p].end}),l.splice(p,1)}return}else{c.debug(\"SI\",\"Segment pushed ends before another with the same start\",{t:f,ss:o,se:s,pse: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\",{t:f,ss:o,se:s,pss:b.start,pse: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\",{t:f,ss:o,se:s,pss: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\",{t:f,ss:o,se:s,pss:l[p].start,pse:l[p].end}),l.splice(p,1)}return}else{c.warn(\"SI\",\"Segment pushed is contained in a previous one\",{t:f,ss:o,se:s,pss:b.start,pse: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\",{t:f,ss:o,se:s}),this._inventory.push(m);return}if(g.start>=s)c.debug(\"SI\",\"Segment pushed comes before all previous ones\",{t:f,ss:o,se:s,pss: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\",{t:f,ss:o,se:s,pss:g.start,pse: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\",{t:f,ss:o,se:s,pss:l[1].start,pse:l[1].end}),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\",{t:f,ss:o,se:s,pss:l[1].start,pse:l[1].end}),l.splice(1,1)}return}else{c.debug(\"SI\",\"Segment pushed start of the next one\",f,{ss:o,se:s,pss:g.start,pse: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(nt(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(c.warn(\"SI\",\"Completed Segment is splitted.\",He(e)),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&nt(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\",He(e));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.\",{ss:i.start,se:i.end})}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function Ta(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 Hs(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 Ll(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\",{t:r,firstsbs:n.bufferedStart,rs:e}),n.bufferedStart=e),!n.precizeStart&&Ta(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)c.debug(\"SI\",\"buffered start is precize start\",{t:r,firstss: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\",{t:r,rs:e,firstss:n.start,lastdelse:t.end}),n.bufferedStart=t.end,Ta(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\",{t:r,rs:e,firstss:n.start,delta:s-n.insertionTs});return}c.debug(\"SI\",\"found true buffered start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=e,Ta(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)c.debug(\"SI\",\"range start too far from expected start\",{t:r,rs:e,firstss: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\",{t:r,rs:e,firstss:n.start,delta:s-n.insertionTs});return}c.debug(\"SI\",\"Segment appears immediately garbage collected at the start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=e}}function Ks(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,lastsbe:n.bufferedEnd,re:e}),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&Hs(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)c.debug(\"SI\",\"buffered end is precize end\",{t,lastse: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,re:e,lastse:n.end,delta:o-n.insertionTs});return}c.debug(\"SI\",\"found true buffered end\",{t,re:e,lastse:n.end}),n.bufferedEnd=e,Hs(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)c.debug(\"SI\",\"range end too far from expected end\",{t,re:e,lastse: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,re:e,lastse:n.end,delta:o-n.insertionTs});return}c.debug(\"SI\",\"Segment appears immediately garbage collected at the end\",{t,lastsbe:n.bufferedEnd,re:e}),n.bufferedEnd=e}}function Fl(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 Kt(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 jt(n,e){for(let t of n)if(t.infos.period.start>e.start)return t;return null}var js=Bn;var Yt=class{constructor(){this._segmentInventory=new js}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var Nn=class extends Yt{constructor(e,t,r){super(),c.info(\"Stream\",\"calling `mediaSource.addSourceBuffer`\",{codec: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){Ys(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){Ys(e.data.chunk),c.debug(\"Stream\",\"queuing push order\",He(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(\"Stream\",\"now pushing\",He(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(\"Stream\",\"queuing remove order\",{bufferType:this.bufferType,start:e,end: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(\"Stream\",\"Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose()}catch(e){c.debug(\"Stream\",`Failed to dispose a ${this.bufferType} SourceBufferInterface:`,e instanceof Error?e:\"Unknown Error\")}}_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 Ys(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 Yr=Nn;var Un=class extends Yt{constructor(e){c.debug(\"Stream\",\"Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){c.warn(\"Stream\",\"Declaring initialization segment for Text SegmentSink\",{uniqueId:e})}freeInitSegment(e){c.warn(\"Stream\",\"Freeing initialization segment for Text SegmentSink\",{uniqueId:e})}async pushChunk(e){let{data:t}=e;Wl(t.chunk);let r=this._sender.pushTextData(se(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(\"Stream\",\"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 Wl(n){if(I.CURRENT_ENV!==I.PRODUCTION){if(typeof n!=\"object\"||n===null||v(n.data))throw new Error(\"Invalid format given to a TextSegmentSink\");if(!ql(n))throw new Error(\"Invalid format given to a TextSegmentSink\");if(typeof n.data!=\"string\"&&typeof n.data.byteLength!=\"number\")throw new Error(\"Invalid format given to a TextSegmentSink\")}}function ql(n){return!(typeof n!=\"object\"||n===null||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.initTimescale!==null&&typeof n.initTimescale!=\"number\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\")}I.CURRENT_ENV===I.DEV&&(Vl=function(e){function t(r){}});var Vl;var Qs=Un;var Gl=[\"audio\",\"video\",\"text\"],Ln=class n{static isNative(e){return $s(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():vt(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){c.warn(\"Stream\",`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($s(e)){if(!v(r))return r instanceof Yr&&r.codec!==t?c.warn(\"Stream\",\"Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):c.info(\"Stream\",\"Reusing native SegmentSink with codec\",t),r;c.info(\"Stream\",\"Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new Yr(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 c.info(\"Stream\",\"Reusing a previous custom SegmentSink\",{bufferType:e}),r;let i;if(e===\"text\"){if(c.info(\"Stream\",\"Creating a new text SegmentSink\"),this._textInterface===null)throw new Error(\"HTML Text track feature not activated\");return i=new Qs(this._textInterface),this._initializedSegmentSinks.text=i,i}throw c.error(\"Stream\",\"Unknown buffer type:\",{bufferType: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(v(t)){c.warn(\"Stream\",\"Trying to dispose a SegmentSink that does not exist\",{bufferType:e});return}c.info(\"Stream\",\"Aborting SegmentSink\",{bufferType:e}),t.dispose(),delete this._initializedSegmentSinks[e]}disposeAll(){Gl.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=>se(ee({},o),{infos:Hl(o.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function $s(n){return n===\"audio\"||n===\"video\"}function Hl(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var _t=Ln;function Ea(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,u=Kl(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(\"Stream\",\"current discontinuity encountered\",{bufferType:o.type,nextSegmentTime:d.bufferedStart,checkStartTime:e.start}),{start:void 0,end:l})}let f=jl(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(\"Stream\",\"future discontinuity encountered\",{bufferType:o.type,discontinuityStart:g,discontinuityEnd:p}),{start:g,end:p}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let l=Yl(i,a.end);if(l!==null){let m=i[l];if(m.bufferedEnd!==void 0&&m.bufferedEnd<a.end)return c.debug(\"Stream\",\"discontinuity encountered at the end of the current period\",{bufferType:o.type,segmentsEndTimeFromPeriod:m.bufferedEnd,periodEnd: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 Kl(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 jl(n,e,t){if(t<=0)return c.error(\"Stream\",\"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 Yl(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 _a({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:u,representation:d}=e,f=Ql(n,o,s),l=d.index.getSegments(a.start,a.end-a.start),m=n.filter(R=>!Xs(R.infos,e,t,r)),g=nf(m,a,i),{MINIMUM_SEGMENT_SIZE:p,MIN_BUFFER_AHEAD:b}=U.getCurrent(),h=!1,S=Math.min(1/60,p),_=!1,P=[];return{segmentsToLoad:l.filter(R=>{let E=H({segment:R},e);if(o.length>0&&o.some(w=>nt(E,w)))return!1;let{duration:M,time:C,end:x}=R;if(R.isInit)return!0;if(h)return P.push(R),!1;if(R.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:k}=w;if(k.time-S>C)return!1;if(k.complete){if(k.end+S<x)return!1}else if(Math.abs(C-k.time)>C)return!1;return!Xs(w,E,t,r)}))return!1;for(let A of g){let w=A.infos.period.id===e.period.id;if(A.status===1&&w){let k=A.infos.segment;if(C-k.time>-S){if(k.complete){if(k.end-x>-S)return!1}else if(Math.abs(C-k.time)<S)return!1}}}let N=M*e.representation.bitrate;if(f-N<0&&(_=!0,C>a.start+b))return h=!0,P.push(R),!1;let B=i(E);if(B.length>1){let A=B[B.length-1],w=B[B.length-2];if(A.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.\",{bufferType:u.type,representationId:d.id,segmentTime:R.time}),!1}for(let A=0;A<g.length;A++){let w=g[A];if(w.end+S>C){let k=w.start>C+S||$l(g,A).end<x-S;return k&&(f-=N),k}}return f-=N,!0}),segmentsOnHold:P,isBufferFull:_}}function Ql(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 $l(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 Xs(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:Xl(n.representation,e.representation,r)}function Xl(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 Zl(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\",{segmentStart:n.start,currentStartInBuffer:n.bufferedStart}),!0):!1}function Jl(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\",{segmentEnd:n.end,currentEndInBuffer:n.bufferedEnd}),!0):!1}function ef(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 tf(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 nf(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(Zl(r,o,e.start)){if(u=t(r.infos),ef(u,r.bufferedStart))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the start\",{segmentStart:r.start,currentStartInBuffer:r.bufferedStart})}if(Jl(r,s,e.end)){if(u=u!=null?u:t(r.infos),tf(u,r.bufferedEnd))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the end\",{segmentEnd:r.end,currentEndInBuffer:r.bufferedEnd})}return!0})}function Fn(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 Ra(n,e,t,r,i,a,o){var C,x,N;let{representation:s}=n,u=(x=(C=t.getIsPaused())!=null?C:t.getReference().getValue().paused.pending)!=null?x:t.getReference().getValue().paused.last,d=(N=t.getPlaybackRate())!=null?N:t.getReference().getValue().speed,f=e;(u===void 0||d===void 0||u||d<=0)&&(f-=.1);let l=rf(n,f,i),m=s.index.shouldRefresh(l.start,l.end),g=o.getPendingOperations().filter(B=>B.type===2).map(B=>B.value),p=o.getLastKnownInventory(),b=t.getCurrentTime();b===void 0&&(b=t.getReference().getValue().position.getWanted());let h=o.getSegmentHistory.bind(o),{segmentsToLoad:S,segmentsOnHold:_,isBufferFull:P}=_a({content:n,bufferedSegments:p,currentPlaybackTime:b,fastSwitchThreshold:r,getBufferedHistory:h,neededRange:l,segmentsBeingPushed:g,maxBufferSize:a}),T=S.map(B=>({priority:Fn(B.time,f),segment:B})),R=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&T.length===0&&_.length===0,E=null;return g.length>0&&(E=Math.min(...g.map(B=>B.segment.time))),_.length>0&&(E=E!==null?Math.min(E,_[0].time):_[0].time),T.length>0&&(E=E!==null?Math.min(E,T[0].segment.time):T[0].segment.time),{imminentDiscontinuity:Ea(n,l,E,R,p),hasFinishedLoading:R,neededSegments:T,isBufferFull:P,shouldRefreshManifest:m}}function rf(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),u=o.index;!v(s)&&_t.isNative(n.adaptation.type)&&e>=s&&u.isInitialized()&&!u.isStillAwaitingFutureSegments()&&af(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 af(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 zn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof ue)throw a;if(!(a instanceof xe)||!a.isBufferFull){let u=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new Z(\"BUFFER_APPEND_ERROR\",u,{tracks:[Pt(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 gi(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 Z(\"BUFFER_FULL_ERROR\",d,{tracks:[Pt(t.inventoryInfos.adaptation)]})}}}async function Pa({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=H({segment:r,chunkSize:void 0,start:0,end:0},e),f=await zn(n,i,{data:u,inventoryInfos:d},a,o);return{content:e,segment:r,buffered:f}}async function va({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var E,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},S=(E=d==null?void 0:d.time)!=null?E:a.time,_=(M=d==null?void 0:d.duration)!=null?M:a.duration,P=S+_;b[0]!==void 0&&(S=Math.max(S,b[0])),b[1]!==void 0&&(P=Math.min(P,b[1]));let T=H({segment:a,chunkSize:l,start:S,end:P},t),R=await zn(n,o,{data:h,inventoryInfos:T},e,s);return{content:t,segment:a,buffered:R}}function Ca({content:n,options:e,playbackObserver:t,segmentSink:r,segmentQueue:i,terminate:a},o,s){c.debug(\"Stream\",\"Creating RepresentationStream\",{periodStart:n.period.start,bufferType:n.adaptation.type,adaptationId:n.adaptation.id,representationBitrate:n.representation.bitrate,mimeType:n.representation.getMimeTypeString()});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 S={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};h.signal.register(()=>{S.uniqueId!==null&&r.freeInitSegment(S.uniqueId)});let _=S.segment!==null;_||(S.isLoaded=!0);let P=!1;if(g!==void 0){let C=f.getEncryptionData(g);if(C.length>0&&C.every(x=>x.keyIds!==void 0)&&(P=!0,o.encryptionDataEncountered(C.map(x=>H({content:n},x))),h.isUsed()))return}i.addEventListener(\"error\",C=>{h.signal.isCancelled()||(h.cancel(),o.error(C))}),i.addEventListener(\"parsedInitSegment\",E,h.signal),i.addEventListener(\"parsedMediaSegment\",E,h.signal),i.addEventListener(\"emptyQueue\",R,h.signal),i.addEventListener(\"requestRetry\",C=>{if(o.warning(C.error),h.signal.isCancelled())return;let x=C.segment,{index:N}=f;N.isSegmentStillAvailable(x)===!1?R():N.canBeOutOfSyncError(C.error,x)&&o.manifestMightBeOufOfSync()},h.signal),i.addEventListener(\"fullyLoadedSegment\",C=>{r.signalSegmentComplete(H({segment:C},n)).catch(M)},h.signal);let T=i.resetForContent(n,_);h.signal.register(()=>{i.stop()}),t.listen(R,{includeLastObservation:!1,clearSignal:h.signal}),n.manifest.addEventListener(\"manifestUpdate\",R,h.signal),l.onUpdate(R,{emitCurrentValue:!1,clearSignal:h.signal}),m.onUpdate(R,{emitCurrentValue:!1,clearSignal:h.signal}),a.onUpdate(R,{emitCurrentValue:!1,clearSignal:h.signal}),R();return;function R(){if(h.isUsed())return;let C=t.getReference().getValue(),x=C.position.getWanted(),N=Ra(n,x,t,p.getValue(),l.getValue(),m.getValue(),r),{neededSegments:B}=N,A=null;if(f.index.isInitialized()){if(B.length>0&&!S.isLoaded&&S.segment!==null){let O=B[0].priority;A={segment:S.segment,priority:O}}}else if(S.segment===null)c.warn(\"Stream\",\"Uninitialized index without an initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else if(S.isLoaded)c.warn(\"Stream\",\"Uninitialized index with an already loaded initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else{let O=C.position.getWanted();A={segment:S.segment,priority:Fn(u.start,O)}}let w=a.getValue();if(w===null)T.setValue({initSegment:A,segmentQueue:B});else if(w.urgent){c.debug(\"Stream\",\"Urgent switch, terminate now.\",{bufferType:b,representationBitrate:n.representation.bitrate}),T.setValue({initSegment:null,segmentQueue:[]}),T.finish(),h.cancel(),o.terminating();return}else{let O=B[0],z=i.getRequestedInitSegment(),q=i.getRequestedMediaSegment(),$=q===null||O===void 0||q.id!==O.segment.id?[]:[O],X=z===null?null:A;if(T.setValue({initSegment:X,segmentQueue:$}),$.length===0&&X===null){c.debug(\"Stream\",\"No request left, terminate\",{bufferType:b,representationBitrate:n.representation.bitrate}),T.finish(),h.cancel(),o.terminating();return}}if(o.streamStatusUpdate({period:u,position:C.position.getWanted(),bufferType:b,imminentDiscontinuity:N.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:N.hasFinishedLoading,neededSegments:N.neededSegments}),h.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:k}=U.getCurrent();if(N.isBufferFull){let O=Math.max(0,x-k);O>0&&r.removeBuffer(0,O).catch(M)}N.shouldRefreshManifest&&o.needsManifestRefresh()}function E(C){for(let x of C.protectionData)f.addProtectionData(x.initDataType,x.keyId,x.initData);if(!P){let x=f.getAllEncryptionData();x.length>0&&(o.encryptionDataEncountered(x.map(N=>H({content:n},N))),P=!0)}if(C.segmentType===\"init\"){if(!f.index.isInitialized()&&C.segmentList!==void 0&&f.index.initialize(C.segmentList),S.isLoaded=!0,C.initializationData!==null){let x=f.uniqueId;S.uniqueId=x,r.declareInitSegment(x,C.initializationData),Pa({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:x,segment:C.segment,segmentData:C.initializationData,segmentSink:r},h.signal).then(N=>{N!==null&&o.addedSegment(N)}).catch(M)}R();return}else{let{inbandEvents:x,predictedSegments:N,needsManifestRefresh:B}=C;if(N!==void 0&&f.index.addPredictedSegments(N,C.segment),B===!0&&(o.needsManifestRefresh(),h.isUsed())||x!==void 0&&x.length>0&&(o.inbandEvent(x),h.isUsed()))return;let A=S.uniqueId;va({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:A,parsedSegment:C,segment:C.segment,segmentSink:r},h.signal).then(w=>{w!==null&&o.addedSegment(w)}).catch(M)}}function M(C){h.isUsed()&&C instanceof ue||(c.warn(\"Stream\",\"Received fatal buffer error\",{bufferType:b,representationBitrate:n.representation.bitrate},C instanceof Error?C:null),h.cancel(),o.error(C))}}var Zs=Ca;function Aa(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))&&Et(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 S=h.value.inventoryInfos;if(S.period.id===n.id&&(S.adaptation.id!==e.id||!Ie(t.representationIds,S.representation.id))){let _=S.segment.time,P=_+S.segment.duration;Et(o,{start:_,end:P})}}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=Kt(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(),S=e.type,_=(p=h[S].before)!=null?p:0,P=(b=h[S].after)!=null?b:0,T=i.getCurrentTime();T===void 0&&(T=i.getReference().getValue().position.getPolled()),d.push({start:T-_,end:T+P})}if(n.end!==void 0){let h=jt(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=Hr(o,d);return l.length===0?{type:\"continue\",value:void 0}:u?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function ka({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,S=e.representations.getValue().representationIds,_=Js(e.adaptation.representations,S),P=new Y(_,g.signal),{estimates:T,callbacks:R}=r({manifest:f,period:l,adaptation:m},b,P,n,g.signal),E=new Y(!1);n.listen(k=>{var z;let O=(z=k.canStream)!=null?z:!0;E.getValue()===O&&(c.debug(\"Stream\",\"isMediaSegmentQueueInterrupted updated to\",!O),E.setValue(!O))},{clearSignal:g.signal});let M=a.createSegmentQueue(m.type,{onRequestBegin:R.requestBegin,onRequestEnd:R.requestEnd,onProgress:R.requestProgress,onMetrics:R.metrics},E),C=new Y(0);T.onUpdate(({bitrate:k,knownStableBitrate:O})=>{t.enableFastSwitching&&C.setValueIfChanged(O),!(k===void 0||k===h)&&(h=k,c.debug(\"Stream\",`new ${m.type} bitrate estimate received from ABR`,{bitrate:k}),u.bitrateEstimateChange({type:m.type,bitrate:k}))},{emitCurrentValue:!0,clearSignal:g.signal});let x;e.representations.onUpdate(k=>{x!==void 0&&x.cancel();let O=e.representations.getValue().representationIds,z=Js(e.adaptation.representations,O);P.setValueIfChanged(z),x=new F,x.linkToSignal(g.signal),N(k,x.signal).catch(q=>{(x==null?void 0:x.isUsed())===!0&&F.isCancellationError(q)||(g.cancel(),u.error(q))})},{clearSignal:g.signal,emitCurrentValue:!0});return;async function N(k,O){let z=Aa(l,m,k,i,n);switch(z.type){case\"continue\":break;case\"needs-reload\":return dt(()=>{n.listen(()=>{if(O.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:O})});case\"flush-buffer\":case\"clean-buffer\":for(let q of z.value)if(await i.removeBuffer(q.start,q.end),O.isCancelled())return;if(z.type===\"flush-buffer\"&&(u.needsBufferFlush(),O.isCancelled()))return;break;default:Ne(z)}B(O)}function B(k){let O=new F;O.linkToSignal(k);let{representation:z}=T.getValue();if(z===null)return;let q=new Y(null,O.signal);T.onUpdate(V=>{if(!(V.representation===null||V.representation.id===z.id))return V.urgent?(c.info(\"Stream\",\"urgent Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:z.bitrate,newRepresentationBitrate:V.representation.bitrate}),q.setValue({urgent:!0})):(c.info(\"Stream\",\"slow Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:z.bitrate,newRepresentationBitrate:V.representation.bitrate}),q.setValue({urgent:!1}))},{clearSignal:O.signal,emitCurrentValue:!0});let $={type:m.type,adaptation:m,period:l,representation:z};if(b.setValue(z),k.isCancelled()||(u.representationChange($),k.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){R.addedSegment(V)},terminating(){if(!O.isUsed())return O.cancel(),B(k)}};A(z,q,X,k)}function A(k,O,z,q){let $=!1,X=new F;X.linkToSignal(q);let V=tn(o,me=>w(k,me),X.signal),G=m.type===\"video\"?s:new Y(1/0);c.info(\"Stream\",\"changing representation\",{bufferType:m.type,representationId:k.id,representationBitrate:k.bitrate});let J=H({},z,{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\")z.error(me);else{c.warn(\"Stream\",\"received BUFFER_FULL_ERROR\",{bufferType:m.type,representationBitrate:k.bitrate});let $e=o.getValue(),oe=((pe=p.get(k.id))!=null?pe:1)*.7;if(p.set(k.id,oe),oe<=.05||w(k,$e)<=2){z.error(le);return}fn(4e3,q).then(()=>A(k,O,z,q)).catch(D)}},terminating(){X.cancel(),z.terminating()}});Zs({playbackObserver:n,content:{representation:k,adaptation:m,period:l,manifest:f},segmentSink:i,segmentQueue:M,terminate:O,options:{bufferGoal:V,maxBufferSize:G,drmSystemId:t.drmSystemId,fastSwitchThreshold:C}},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 $e of pe.removedRepresentations)if($e===k.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(k,O){let z=p.get(k.id),q=z!==void 0?z:1;return z===void 0&&p.set(k.id,q),q<1&&O===1/0?300*1e3*q:O*q}}function Js(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 eu=ka;function xa(n,e,t,r,i,a){var g,p,b,h;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!of(t,n.codec))return{type:\"needs-reload\",value:void 0};let o=n.getLastKnownInventory(),s=[];for(let S of o)S.infos.period.id===e.id&&S.infos.adaptation.id!==t.id&&Et(s,{start:(g=S.bufferedStart)!=null?g:S.start,end:(p=S.bufferedEnd)!=null?p:S.end});let u=n.getPendingOperations();for(let S of u)if(S.type===0){let _=S.value.inventoryInfos;if(_.period.id===e.id&&_.adaptation.id!==t.id){let P=_.segment.time,T=P+_.segment.duration;Et(s,{start:P,end:T})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let S=i.getReadyState();if(S===void 0||S>1)return{type:\"needs-reload\",value:void 0}}let d=r===\"direct\",f=[],l=Kt(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!d){let S=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:_}=U.getCurrent(),P=(b=_[S].before)!=null?b:0,T=(h=_[S].after)!=null?h:0,R=i.getCurrentTime();R===void 0&&(R=i.getReference().getValue().position.getPolled()),f.push({start:R-P,end:R+T})}if(e.end!==void 0){let S=jt(o,e);S!==null&&(S.bufferedStart===void 0||S.bufferedStart-e.end<1)&&f.push({start:e.end-1,end:Number.MAX_VALUE})}let m=Hr(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 of(n,e){return n.representations.some(t=>t.isPlayable()===!0&&Vo(t.getMimeTypeString(),e))}function Ma({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(P=>{(async()=>{var w;if(P===void 0)return;let T=new F;if(T.linkToSignal(l),b==null||b.cancel(),b=T,P===null){c.info(\"Stream\",\"Set no Adaptation\",{periodStart:g.start,bufferType:n});let k=o.getStatus(n);if(k.type===\"initialized\"){if(c.info(\"Stream\",\"Clearing previous SegmentSink\",{periodStart:g.start,bufferType:n}),_t.isNative(n))return _(0,!0,T.signal);{let O=(w=g.end)!=null?w:1/0;if(g.start>O)c.warn(\"Stream\",\"Can't free buffer: period's start is after its end\",{periodStart:g.start,periodEnd:O,bufferType:n});else if(await k.value.removeBuffer(g.start,O),T.isUsed())return}}else if(k.type===\"uninitialized\"&&(o.disableSegmentSink(n),T.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:g}),T.isUsed()?void 0:tu(r,u,n,{period:g},f,T.signal)}let R=g.adaptations[n],E=K(R!=null?R:[],k=>k.id===P.adaptationId);if(E===void 0){b.cancel(),c.warn(\"Stream\",\"Unfound chosen Adaptation choice\",{adaptationId:P.adaptationId});return}let{DELTA_POSITION_AFTER_RELOAD:M}=U.getCurrent(),C=!1,x;if(h)x=0;else if(P.relativeResumingPosition!==void 0)x=P.relativeResumingPosition;else switch(C=!0,n){case\"audio\":x=M.trackSwitch.audio;break;case\"video\":x=M.trackSwitch.video;break;default:x=M.trackSwitch.other;break}if(h=!1,_t.isNative(n)&&o.getStatus(n).type===\"disabled\")return _(x,!0,T.signal);m.addEventListener(\"manifestUpdate\",k=>{for(let O of k.updatedPeriods)if(O.period.id===g.id){for(let z of O.result.removedAdaptations)if(z.id===E.id)return _(x,!0,T.signal)}else if(O.period.start>g.start)break},b.signal);let{representations:N}=P;if(c.info(\"Stream\",\"Updating adaptation\",{bufferType:E.type,periodStart:g.start,adaptationId:E.id}),f.adaptationChange({type:n,adaptation:E,period:g}),T.isUsed())return;let B=sf(o,n,E),A=xa(B,g,E,P.switchingMode,r,s);if(A.type===\"needs-reload\")return _(x,!0,T.signal);if(await o.waitForUsableBuffers(T.signal),!T.isUsed()){if(A.type===\"flush-buffer\"||A.type===\"clean-buffer\"){for(let{start:k,end:O}of A.value)if(await B.removeBuffer(k,O),T.isUsed())return;if(A.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:x,relativePosHasBeenDefaulted:C}),T.isUsed()))return}t.get(B)(T.signal),S(E,N,B,T.signal)}})().catch(T=>{T instanceof ue||(b==null||b.cancel(),f.error(T))})},{clearSignal:l,emitCurrentValue:!0});function S(P,T,R,E){let M=df(r,P.type);eu({content:{manifest:m,period:g,adaptation:P,representations:T},options:s,playbackObserver:M,representationEstimator:i,segmentSink:R,segmentQueueCreator:a,wantedBufferAhead:u,maxVideoBufferSize:d},se(ee({},f),{error:C}),E);function C(x){if(!_t.isNative(n)){c.error(\"Stream\",`${n} Stream crashed. Aborting it.`,x instanceof Error?x:\"\"),o.disposeSegmentSink(n);let N=ge(x,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(N),E.isCancelled()?void 0:tu(r,u,n,{period:g},f,E)}c.error(\"Stream\",`${n} Stream crashed. Stopping playback.`,x instanceof Error?x:\"\"),f.error(x)}}function _(P,T,R){dt(()=>{r.listen(()=>{R.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:g,timeOffset:P,stayInPeriod:T})},{includeLastObservation:!0,clearSignal:R})})}}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\",{bufferType:e}),r.value;let i=uf(t);return n.createSegmentSink(e,i)}function uf(n){let e=n.representations.filter(t=>t.isPlayable()!==!1);if(e.length>0)return e[0].getMimeTypeString();if(n.representations.length>0)return n.representations[0].getMimeTypeString();throw new Z(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[Pt(n)]})}function df(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?Gr(d,u.position.getWanted()):0;return H({},u,{bufferGap:f,buffered:d})}function s(){a.setValue(o())}})}function tu(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',{bufferType:t,periodEnd:o.end,position:l,wantedBufferAhead:f}),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:l,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var nu=Ma;function Qr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory(),i=n.getPendingOperations();for(let a of r)if(e.some(s=>a.infos.period.id===s.period.id&&a.infos.adaptation.id===s.adaptation.id&&a.infos.representation.id===s.representation.id)){let{bufferedStart:s,bufferedEnd:u}=a;if(s===void 0||u===void 0)return c.warn(\"Stream\",\"No buffered start or end found from a segment.\",{bufferType:a.infos.adaptation.type,segmentStart:a.infos.segment.time}),[{start:0,end:Number.MAX_VALUE}];let d=t[t.length-1];d!==void 0&&d.end===s?d.end=u:t.push({start:s,end:u})}for(let a of i){if(a.type!==0)continue;let o=a.value;e.some(u=>o.inventoryInfos.period.id===u.period.id&&o.inventoryInfos.adaptation.id===u.adaptation.id&&o.inventoryInfos.representation.id===u.representation.id)&&Et(t,{start:o.inventoryInfos.start,end:o.inventoryInfos.end})}return t}function Oa(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(),S=new wn(T=>{var C,x;let{bufferType:R}=T,E=(C=h[R])!=null?C:1/0,M=(x=b[R])!=null?x:1/0;return N=>{Kr({segmentSink:T,playbackObserver:e,maxBufferBehind:tn(l,B=>Math.min(B,E),N),maxBufferAhead:tn(f,B=>{var w;let A=Math.max(B,(w=p[R])!=null?w:0);return Math.min(A,M)},N)},N)}});for(let T of r.getBufferTypes())_(T,d);function _(T,R){let E=new Bt((A,w)=>A.start-w.start),M=!1,C=new F;return C.linkToSignal(s),e.listen(({position:A})=>{let w=A.getWanted();if(!M||!N(w))return;let k=()=>{var z;return(z=u.getPeriodForTime(w))!=null?z:u.getNextPeriod(w)},O=k();if(!(!v(O)&&E.has(O))){for(c.info(\"Stream\",\"Destroying all PeriodStreams due to out of bounds situation\",{bufferType:T,time:w}),M=!1;E.length()>0;){let z=E.get(E.length()-1);E.removeElement(z),o.periodStreamCleared({type:T,manifest:u,period:z})}if(C.cancel(),C=new F,C.linkToSignal(s),O=k(),O===void 0){c.warn(\"Stream\",\"The wanted position is not found in the Manifest.\"),M=!0;return}x(O)}},{clearSignal:s,includeLastObservation:!0}),u.addEventListener(\"decipherabilityUpdate\",A=>{s.isCancelled()||B(A).catch(w=>{s.isCancelled()||(C.cancel(),o.error(w))})},s),x(R);function x(A){let w=se(ee({},o),{waitingMediaSourceReload(k){let O=E.head();O===void 0||O.id!==k.period.id?o.lockedStream({bufferType:k.bufferType,period:k.period}):o.needsMediaSourceReload({timeOffset:k.timeOffset,minimumPosition:k.stayInPeriod?k.period.start:void 0,maximumPosition:k.stayInPeriod?k.period.end:void 0})},periodStreamReady(k){M=!0,E.add(k.period),o.periodStreamReady(k)},periodStreamCleared(k){E.removeElement(k.period),o.periodStreamCleared(k)},error(k){C.cancel(),o.error(k)}});P(T,A,w,C.signal)}function N(A){let w=E.head(),k=E.last();return w===void 0||k===void 0?!0:w.start>A||(v(k.end)?1/0:k.end)<A}async function B(A){let w=r.getStatus(T),k=A.filter(V=>V.adaptation.type===T);if(k.length===0||w.type!==\"initialized\"||k.every(V=>V.representation.decipherable===!0))return;let O=w.value,z=k.filter(V=>V.representation.decipherable===void 0),q=k.filter(V=>V.representation.decipherable===!1),$=Qr(O,q),X=Qr(O,z);for(M=!1,c.info(\"Stream\",\"Destroying all PeriodStreams for decipherability matters\",{bufferType:T});E.length()>0;){let V=E.get(E.length()-1);E.removeElement(V),o.periodStreamCleared({type:T,manifest:u,period:V})}C.cancel(),C=new F,C.linkToSignal(s);for(let{start:V,end:G}of[...$,...X]){if(s.isCancelled())return;if(V<G){if(s.isCancelled())return;await O.removeBuffer(V,G)}}dt(()=>{if(s.isCancelled())return;let V=e.getReference().getValue();if(ru(V,$)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(ru(V,X)&&(o.needsBufferFlush(),s.isCancelled()))return;let G=V.position.getWanted(),J=u.getPeriodForTime(G);if(J===void 0){o.error(new Z(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}x(J)})}}function P(T,R,E,M){c.info(\"Stream\",\"Creating new PeriodStream\",{bufferType:T,periodStart:R.start});let C=null,x=new F;x.linkToSignal(M),e.listen(({position:k},O)=>{if(R.end!==void 0&&k.getWanted()>=R.end){let z=u.getPeriodAfter(R);if(R.containsTime(k.getWanted(),z))return;c.info(\"Stream\",\"Destroying PeriodStream as the current playhead moved above it\",{bufferType:T,periodStart:R.start,periodEnd:R.end,position:k.getWanted()}),O(),E.periodStreamCleared({type:T,manifest:u,period:R}),x.cancel()}},{clearSignal:M,includeLastObservation:!0});let N={bufferType:T,content:{manifest:u,period:R},garbageCollectors:S,maxVideoBufferSize:g,segmentQueueCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},B=se(ee({},E),{streamStatusUpdate(k){if(k.hasFinishedLoading){let O=u.getPeriodAfter(R);O!==null&&A(O)}else C!==null&&(c.info(\"Stream\",\"Destroying next PeriodStream due to current one being active\",{bufferType:T,periodStart:R.start,nextPeriodStart:C.period.start}),E.periodStreamCleared({type:T,manifest:u,period:C.period}),C.canceller.cancel(),C=null);E.streamStatusUpdate(k)},error(k){C!==null&&(C.canceller.cancel(),C=null),x.cancel(),E.error(k)}});nu(N,B,x.signal),w(x.signal);function A(k){if(C!==null){if(C.period.id===k.id)return;c.warn(\"Stream\",\"Creating next `PeriodStream` while one was already created.\",{bufferType:T,nextPeriodStart:k.start}),E.periodStreamCleared({type:T,manifest:u,period:C.period}),C.canceller.cancel()}let O=new F;O.linkToSignal(M),C={canceller:O,period:k},P(T,k,E,C.canceller.signal)}function w(k){u.addEventListener(\"manifestUpdate\",O=>{for(let z of O.removedPeriods)if(z.id===R.id){if(u.periods.length>0&&u.periods[0].start<=z.start)return dt(()=>{if(!k.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(z.start>R.start)break;if(O.addedPeriods.length>0&&C!==null){let z=u.getPeriodAfter(R);(z===null||C.period.id!==z.id)&&(c.warn(\"Stream\",\"Destroying next PeriodStream due to new one being added\",{bufferType:T,nextPeriodStart:C.period.start}),E.periodStreamCleared({type:T,manifest:u,period:C.period}),C.canceller.cancel(),C=null)}},k)}}}function ru(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 iu=Oa;var au=iu;var Wn=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 wa(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;dt(()=>{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:!1,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 Bt((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)}},wa=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=$r(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=$r(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=$r(this._lastAudioAdaptation),t=$r(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=Xr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=Xr(this._lastAudioAdaptation))!=null?t:void 0;{let r=Xr(this._lastAudioAdaptation),i=Xr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function $r(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 Xr(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 Da(n,e,t,r,i,a){a.register(()=>{e.interruptDurationSetting()});let o=new Wn(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(\"mse\",\"Start applying end-of-stream order.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function Ba(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=K(n.sourceBuffers,s=>s.type===\"audio\"),i=K(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}async function Na(n,e,t,r,i){let a=e.getPeriod(t);if(a===void 0)throw new Error(\"Wanted Period not found.\");let o=K(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({segment:s,track:o,period:a},new F().signal)}function Ua(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 La(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return c.warn(\"mse\",\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}function lf(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function qn(n,e){if(c.debug(\"mse\",\"Trying to call endOfStream\"),n.readyState!==\"open\"){c.debug(\"mse\",\"MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=lf(t);if(r.length===0){c.info(\"mse\",\"Triggering end of stream\");try{n.endOfStream()}catch(a){c.error(\"mse\",\"Unable to call endOfStream\",a instanceof Error?a:new Error(\"Unknown error\"))}return}c.debug(\"mse\",\"Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new F;i.linkToSignal(e);for(let a of r)Mo(a,()=>{i.cancel(),qn(n,e)},i.signal);Oo(t,()=>{i.cancel(),qn(n,e)},i.signal)}function ou(n,e){let t=new F;t.linkToSignal(e),Lt(n,()=>{c.debug(\"mse\",\"MediaSource re-opened while end-of-stream is active\"),t.cancel(),t=new F,t.linkToSignal(e),qn(n,t.signal)},e),qn(n,t.signal)}function Fa(){let{FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:n}=U.getCurrent();return n||pi.device===pi.DEVICES.PlayStation5}var ff=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 F;let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=pf(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=cf(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 mf(n,e,t){let r=e;t||(r=Fa()?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(i,o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{c.info(\"mse\",\"Updating duration to what is currently buffered\",{maxBufferedEnd:i}),n.duration=i}catch(a){return c.warn(\"mse\",\"Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(c.info(\"mse\",\"Updating duration\",{newDuration:r}),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=su(e);c.info(\"mse\",\"calling `mediaSource.setLiveSeekableRange`\",{maxSeekable:s}),n.setLiveSeekableRange(0,s)}}catch(s){return c.warn(\"mse\",\"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 cf(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 pf(n,e){let t=new Y(n.readyState===\"open\",e);return Lt(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),Tr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),Sr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function uu(n,e,t,r){if(mf(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+ff)}var Gn=class extends fe{constructor(e,t){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new F,v(ct))throw new Z(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"mse\",\"Creating MediaSource\");let r=t!==void 0?new t:new ct,i=r.handle;this.handle=v(i)?{type:\"media-source\",value:r}:{type:\"handle\",value:i},this._mediaSource=r,this.readyState=r.readyState,this._durationUpdater=new Vn(r),this._endOfStreamCanceller=null,Lt(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),Tr(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),Sr(r,()=>{this.readyState=r.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 za(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(\"mse\",\"end-of-stream order received.\"),ou(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"mse\",\"resume-stream order received.\"),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),gf(this._mediaSource)}},za=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(\"mse\",\"receiving order to push data to the SourceBuffer\",{type:this.type}),this._addToQueue({operationName:0,params:e})}remove(e,t){return c.debug(\"mse\",\"receiving order to remove data from the SourceBuffer\",{type:this.type,start:e,end:t}),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return Sa(this._sourceBuffer.buffered)}catch(e){return c.error(\"mse\",\"Failed to get buffered time range of SourceBuffer\",{type:this.type},e instanceof Error?e:\"Unknown Error\"),[]}}abort(){try{this._sourceBuffer.abort()}catch(e){c.debug(\"mse\",\"Failed to abort SourceBuffer:\",e instanceof Error?e:\"Unknown Error\")}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(\"mse\",\"error for an unknown operation\",t);else{let i=new xe(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 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=H({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 S=m.params[0],_;S instanceof ArrayBuffer?_=new Uint8Array(S):S instanceof Uint8Array?_=S:_=new Uint8Array(S.buffer),l.push(_),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:m.resolve,reject:m.reject})}else break}l.length>1&&(c.info(\"mse\",`: Merging ${l.length} segments together for perf`,{type:this.type}),d=Ct(...l).buffer)}try{this._appendBufferNow(d,u)}catch(f){let l=f instanceof Error?new xe(f.name,f.message,f.name===\"QuotaExceededError\"):new xe(\"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(\"mse\",\"removing data from SourceBuffer\",{type:this.type,start:s,end:u});try{this._sourceBuffer.remove(s,u)}catch(d){let f=d instanceof Error?new xe(d.name,d.message,!1):new xe(\"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(\"mse\",\"updating codec\",{prevCodec:this.codec,newCodec:i}),La(r,i)?this.codec=i:c.debug(\"mse\",\"could not update codec\",{prevCodec:this.codec,newCodec:i})),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"mse\",\"updating timestampOffset\",{codec:i,prevTimestampOffset:r.timestampOffset,newTimestampOffset:s}),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"mse\",\"re-setting `appendWindowStart`\",{prevWindowStart:r.appendWindowStart}),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;c.debug(\"mse\",\"pre-updating `appendWindowEnd`\",{prevWindowEnd:r.appendWindowEnd,newWindowEnd:s}),r.appendWindowEnd=s}c.debug(\"mse\",\"setting `appendWindowStart`\",{appendWindowStart:o[0]}),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"mse\",\"re-setting `appendWindowEnd`\",{prevWindowStart:r.appendWindowStart}),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"mse\",\"setting `appendWindowEnd`\",{prevWindowEnd:r.appendWindowEnd,newWindowEnd:o[1]}),r.appendWindowEnd=o[1]),c.debug(\"mse\",\"pushing segment\",{type:this.type}),r.appendBuffer(e)}};function gf(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(\"mse\",\"Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}c.info(\"mse\",\"Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&c.info(\"mse\",\"Not all SourceBuffers could have been removed.\")}}var hf=Me(),Zr=Me(),du=1/0,Hn=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=hf();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 Wa(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})}},Wa=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(\"mse\",\"unknown SourceBuffer operation succeeded\"):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new ue:new xe(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"mse\",\"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>=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=Zr();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=Zr();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=Zr();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=Zr();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 qa(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 qe=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 Kn=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 qe(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\",{bitrate: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,If=15e3,bf=3e3,yf=1e3,Sf=9e3,jn=class{constructor(e){this._levelsMap=qa(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(v(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+Sf){let h=this._blockRaiseDelay+bf;c.debug(\"ABR\",\"Incrementing blocking raise in BufferBasedChooser due to unstable quality\",{prevDelay:this._blockRaiseDelay,newDelay:h}),this._blockRaiseDelay=Math.min(h,If)}else{let h=this._blockRaiseDelay-yf;c.debug(\"ABR\",\"Lowering quality in BufferBasedChooser\",{prevDelay:this._blockRaiseDelay,newDelay:h}),this._blockRaiseDelay=Math.max(lu,h)}this._lastUnsuitableQualityTimestamp=l;let b=re(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\",{bitrate:r[g]}),this._currentEstimate=r[g];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function Tf(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 qe(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 Ef(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=Tf(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=Jr(l);if(p!==void 0&&b!==void 0){let R=fu(p,b);if((m-p.timestamp)/1e3<=R&&R-u/o>2500)return b}if(!l.content.segment.complete)return;let h=l.content.segment.duration,S=(m-l.requestTimestamp)/1e3,_=S<=(h*1.5+2)/o;if(v(t)||_)return;let P=h/S,T=t.bitrate*Math.min(.7,P);if(i===void 0||T<i)return T}function _f(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=K(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=fu(s,u);return(o-s.timestamp)/1e3>d*1.2?!0:d-r/n.speed>-1.5}var Yn=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.\",{buffergap:m,enterStarvation:u.starvationGap}),this._inStarvationMode=!0):this._inStarvationMode&&m>=u.outOfStarvationGap&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m,outOfStarvation:u.starvationGap}),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m}),this._inStarvationMode=!1),this._inStarvationMode&&(s=Ef(i,e,r,this._lowLatencyMode,a),s!==void 0&&(c.info(\"ABR\",\"starvation mode emergency estimate:\",{bandwidth: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:_f(i,r,this._lowLatencyMode)}};var Qn=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 $n=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\",{chosenBitrate:u.bitrate,otherAbrAlgosBitrate:i,scoreData:d==null?void 0:d.score,scoreConfidence:d==null?void 0:d.confidenceLevel}),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),Rf(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=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 mu(n,e){let t=n.length,r=re(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 Rf(n,e){let t=re(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 Xn=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new qe(e),this._slowEWMA=new qe(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 qe(e),this._slowEWMA=new qe(t),this._bytesSampled=0}};function Va(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 Ga(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=K(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 Zn=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\");c.warn(\"ABR\",\"progress for a request not added\",{requestId:e.id});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\");c.warn(\"ABR\",\"can't remove unknown request\",{requestId:e})}delete this._currentRequests[e]}getRequests(){return Ir(this._currentRequests).filter(e=>!v(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function ei(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 cu=new Y(void 0);cu.finish();var pu=new Y(1/0);pu.finish();function Ha(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,u,d,f,l){var h,S,_;let{type:m}=s.adaptation,g=a(m),p=(h=t[m])!=null?h:0,b={limitResolution:(S=r.limitResolution[m])!=null?S:cu,throttleBitrate:(_=r.throttleBitrate[m])!=null?_:pu};return Pf({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(v(s)){c.debug(\"ABR\",\"Creating new BandwidthEstimator\",{bufferType:o});let u=new Xn;return e[o]=u,u}return s}}function Pf({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},u){let d=new Kn,f=new Yn(i!=null?i:0,a),l=new Zn,m=D,g={metrics:_,requestBegin:P,requestProgress:T,requestEnd:R,addedSegment(E){m(E)}},p=new F;p.linkToSignal(u);let b=h(s.getValue(),p.signal);return s.onUpdate(S,{clearSignal:u}),{estimates:b,callbacks:g};function h(E,M){if(E.length<=1)return new Y({bitrate:void 0,representation:E[0],urgent:!0,knownStableBitrate:void 0});let C=!1,x=E.sort((q,$)=>q.bitrate-$.bitrate),N=new jn(x.map(q=>q.bitrate)),B=new Qn,A=new $n(d,B),w=o.getReference().getValue(),k=new Y(z());return o.listen(q=>{w=q,O()},{includeLastObservation:!1,clearSignal:M}),m=function(q){if(w===null)return;let{position:$,speed:X}=w,V=q.buffered,G=Gr(V,$.getWanted()),{representation:J}=q.content,me=d.getEstimate(J),le=J.bitrate,pe={bufferGap:G,currentBitrate:le,currentScore:me,speed:X};N.onAddedSegment(pe),O()},M.register(()=>{m=D}),r.throttleBitrate.onUpdate(O,{clearSignal:M}),r.limitResolution.onUpdate(O,{clearSignal:M}),k;function O(){k.setValue(z())}function z(){let{bufferGap:q,position:$,maximumPosition:X}=w,V=r.limitResolution.getValue(),G=r.throttleBitrate.getValue(),J=t.getValue(),me=vf(x,V,G),le=l.getRequests(),{bandwidthEstimate:pe,bitrateChosen:$e}=f.getBandwidthEstimate(w,n,J,le,B.bandwidth),ne=d.getLastStableRepresentation(),oe=ne===null?void 0:ne.bitrate/(w.speed>0?w.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:Xt,ABR_EXIT_BUFFER_BASED_ALGO:Zt}=U.getCurrent();C&&q<=Zt?C=!1:!C&&isFinite(q)&&q>=Xt&&(C=!0);let Re=ei(me,$e),Jt=N.getLastEstimate(),dr=Re.bitrate,lt=null;C&&Jt!==void 0&&Jt>dr&&(lt=ei(me,Jt),dr=lt.bitrate);let ft=null;return a&&J!==null&&e.manifest.isDynamic&&X-$.getWanted()<40&&(ft=A.getGuess(x,w,J,dr,le)),ft!==null&&ft.bitrate>dr?(c.debug(\"ABR\",\"new guess-based estimate\",{bitrate:ft.bitrate,representation:ft.id}),B.update(ft,pe,2),{bitrate:pe,representation:ft,urgent:J===null||ft.bitrate<J.bitrate,knownStableBitrate:oe}):lt!==null?(c.debug(\"ABR\",\"new buffer-based estimate\",{bitrate:lt.bitrate,representation:lt.id}),B.update(lt,pe,0),{bitrate:pe,representation:lt,urgent:f.isUrgent(lt.bitrate,J,le,w),knownStableBitrate:oe}):(c.debug(\"ABR\",\"new bandwidth estimate\",{bitrate:Re.bitrate,representation:Re.id}),B.update(Re,pe,1),{bitrate:pe,representation:Re,urgent:f.isUrgent(Re.bitrate,J,le,w),knownStableBitrate:oe})}}function S(){let E=s.getValue();p.cancel(),p=new F,p.linkToSignal(u),h(E,p.signal).onUpdate(function(x){b.setValue(x)},{clearSignal:p.signal,emitCurrentValue:!0})}function _(E){let{requestDuration:M,segmentDuration:C,size:x,content:N}=E;if(n.addSample(M,x),!N.segment.isInit){let{segment:B,representation:A}=N;if(C===void 0&&!B.complete)return;let w=C!=null?C:B.duration;d.addSample(A,M/1e3,w)}}function P(E){l.add(E)}function T(E){l.addProgress(E)}function R(E){l.remove(E.id)}}function vf(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Va(r,t)),e!==void 0&&(r=Ga(r,e)),r}var gu=Ha;function ti(){var t;if(typeof((t=te.crypto)==null?void 0:t.randomUUID)==\"function\")return te.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 Cf=4,Jn=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:ti(),this._contentId=(r=e.contentId)!=null?r:ti(),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\"),!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,m=rs(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(!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 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*Cf/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\",{queryString:r}),{type:\"query\",value:[[\"CMCD\",r]]})}};var hu=Jn;var er=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=Iu(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=Iu(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 Iu(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 Ve(n){return n instanceof de?new Ze(\"PIPELINE_LOAD_ERROR\",n):ge(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function Af(n){return n instanceof de?n.type===Rt.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===Rt.TIMEOUT||n.type===Rt.ERROR_EVENT:n instanceof Xe?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:Nt(n)&&n.code===\"INTEGRITY_ERROR\"}async function tr(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(\"utils\",\"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(S){if(F.isCancellationError(S))throw S;h!==null&&e!==null&&e.downgradeCdn(h);let _=d.get(h);if(_===void 0?(_={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},d.set(h,_)):_.errorCounter++,!Af(S))return _.blockedUntil=void 0,_.isBlacklisted=!0,g(S);if(_.errorCounter>s)_.blockedUntil=void 0,_.isBlacklisted=!0;else{let P=_.errorCounter,T=Math.min(a*Math.pow(2,P-1),o),R=vi(T);_.blockedUntil=L()+R}return g(S)}}async function g(h){let S=l();if(i.isCancelled())throw i.cancellationError;if(S===void 0)throw h;if(u(h),i.isCancelled())throw i.cancellationError;return p(S,h)}function p(h,S){let _=d.get(h);if(_===void 0||_.blockedUntil===void 0)return m(h);let P=L(),T=_.blockedUntil-P;if(T<=0)return m(h);let R=new F,E=R.linkToSignal(i);return new Promise((M,C)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let B=l();if(i.isCancelled())throw i.cancellationError;if(B===void 0)return N(S);B!==h&&(R.cancel(),p(B,S).then(x,N))},R.signal),fn(T,R.signal).then(()=>m(h).then(x,N),D);function x(B){E(),M(B)}function N(B){E(),C(B)}})}function b(h){var _;if(d.size===0)return h[0];let S=L();return(_=h.filter(P=>{var T;return((T=d.get(P))==null?void 0:T.isBlacklisted)!==!0}).reduce((P,T)=>{var E;let R=(E=d.get(T))==null?void 0:E.blockedUntil;return R!==void 0&&R<=S&&(R=void 0),P===void 0?[T,R]:P[1]===void 0?P:R===void 0?[T,void 0]:R<P[1]?[T,R]:P},void 0))==null?void 0:_[0]}}function Ka(n,e,t){return tr(null,null,n,e,t)}var nr=class extends fe{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 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 zt?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\",Ve(f))});try{let f=await u(o);return{parse:l=>this._parseLoadedManifest(f,l,o)}}catch(f){throw Ve(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 Ka(()=>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\",Ve(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(kf(h)){let{manifest:S}=await h;return p(S)}else return p(h.manifest)}catch(h){throw ge(h,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(h){try{return await Ka(h,d,a)}catch(S){throw Ve(S)}}function g(h){for(let S of h){if(a.isCancelled())return;let _=ge(S,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",_)}}function p(h){let S=L()-i;return c.info(\"MF\",`Manifest parsed in ${S}ms`),{manifest:h,sendingTime:s,receivedTime:u,parsingTime:S}}}_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,S=t===void 0?0:L()-t,_=Math.max(this._settings.minimumManifestUpdateInterval-S,0),P=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:g,unsafeMode:h})},Math.max((p!=null?p:0)-S,_));l.signal.register(()=>{clearTimeout(P)})},e.expired!==null){let m=setTimeout(()=>{var g;(g=e.expired)==null||g.then(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},D)},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(\"MF\",\"Manifest update rythm is too frequent. Postponing next request.\",{regularRefreshDelay:m,newRefreshDelay:g})):s>=e.lifetime*1e3/10?(g=Math.min(Math.max(m,0)+s,m*6),c.info(\"MF\",\"Manifest took too long to parse. Postponing next request\",{regularRefreshDelay:m,newRefreshDelay: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(\"MF\",'Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(c.info(\"MF\",'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(\"MF\",`Attempt to update Manifest failed: ${b}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:h}=U.getCurrent(),S=f===void 0?0:L()-f,_=Math.max(this._settings.minimumManifestUpdateInterval-S,0),P=D,T=setTimeout(()=>{P(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(h-S,_));P=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 kf(n){return n instanceof Promise}var ja=nr;function Ya(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(\"SF\",\"Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Qa=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}},bu=Qa;var xf=Me();function $a({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 bu:void 0,{loadSegment:d,parseSegment:f}=e;return async function(m,g,p){var $,X,V;let{segment:b,adaptation:h,representation:S,manifest:_,period:P}=m,T=He(m),R=xf(),E,M=[],C=0,x=!1,N={segment:b,type:h.type,language:h.language,isLive:_.isLive,periodStart:P.start,periodEnd:P.end,mimeType:S.mimeType,codecs:S.codecs[0],manifestPublishTime:_.publishTime},B={onProgress(G){var J;E===void 0&&G.totalSize!==void 0&&G.size<G.totalSize&&((J=i.onProgress)==null||J.call(i,{duration:G.duration,size:G.size,totalSize:G.totalSize,timestamp:L(),id:R}))},onNewChunk(G){g.onChunk(O(G,!0))}},A=u!==void 0?u.get(m):null;if(A!==null)return c.debug(\"SF\",\"Found wanted segment in cache\",T),g.onChunk(O(A,!1)),Promise.resolve();c.debug(\"SF\",\"Beginning request\",T),($=i.onRequestBegin)==null||$.call(i,{requestTimestamp:L(),id:R,content:m}),p.register(w);try{let G=await tr(m.representation.cdnMetadata,t,k,H({onRetry:z},a),p);if(G.resultType===\"segment-loaded\"){let J=G.resultData.responseData;u!==void 0&&u.add(m,G.resultData.responseData),g.onChunk(O(J,!1))}else G.resultType===\"segment-created\"&&g.onChunk(O(G.resultData,!1));c.debug(\"SF\",\"Segment request ended with success\",T),g.onAllChunksReceived(),G.resultType!==\"segment-created\"?(E=G.resultData,q()):E=null,p.isCancelled()||(X=i.onRequestEnd)==null||X.call(i,{id:R}),p.deregister(w)}catch(G){throw p.deregister(w),E=null,G instanceof ue?(c.debug(\"SF\",\"Segment request aborted\",T),G):(c.debug(\"SF\",\"Segment request failed\",T),(V=i.onRequestEnd)==null||V.call(i,{id:R}),Ve(G))}function w(){var G;E===void 0&&(c.debug(\"SF\",\"Segment request cancelled\",T),E=null,(G=i.onRequestEnd)==null||G.call(i,{id:R}))}function k(G){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(m),d(G,N,s,p,B)}function O(G,J){M.push(!1);let me=M.length-1;return function(pe){let $e={data:G,isChunked:J};try{let ne=f($e,N,pe);return M[me]||(C=C!==void 0&&ne.segmentType===\"media\"&&ne.chunkInfos!==null&&ne.chunkInfos.duration!==void 0?C+ne.chunkInfos.duration:void 0,M[me]=!0,q()),ne}catch(ne){throw ge(ne,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function z(G){g.onRetry(Ve(G))}function q(){var G;x||!v(E)&&E.size!==void 0&&E.requestDuration!==void 0&&M.length>0&&M.every(J=>J)&&(x=!0,(G=i.onMetrics)==null||G.call(i,{size:E.size,requestDuration:E.requestDuration,content:m,segmentDuration:C}))}}}function yu({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 rr=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(\"SF\",\"Media segment can be loaded again, restarting queue.\",{type: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(\"SF\",\"no more media segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(a);return}else if(d===null){c.debug(\"SF\",\"Media segments now need to be requested. Starting queue.\",{type:e.adaptation.type,queueLength:u.length}),this._restartMediaSegmentDownloadingQueue(a);return}else{let f=u[0];if(d.segment.id!==f.segment.id){c.debug(\"SF\",\"Next media segment changed, cancelling previous\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(a);return}d.priority!==f.priority&&(c.debug(\"SF\",\"Priority of next media segment changed, updating\",{type:e.adaptation.type,prevPriority:d.priority,newPriority: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(\"SF\",\"no more init segment to request. Cancelling queue.\",{type: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()){c.debug(\"SF\",\"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?D:d.linkToSignal(a.signal),{segment:l,priority:m}=u,g=H({segment:l,nextSegment:(P=s[1])==null?void 0:P.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\",H({},T,{segment:l}))},S=()=>{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()},_=this._segmentFetcher.createRequest(g,m,{onRetry:T=>{this.trigger(\"requestRetry\",{segment:l,error:T})},beforeInterrupted(){c.info(\"SF\",\"segment request interrupted temporarly.\",{segmentId:l.id,segmentTime:l.time})},onChunk:T=>{let R=i.getValue();R!==void 0?h(T(R!=null?R:void 0)):(b=!0,i.waitUntilDefined(E=>{h(T(E!=null?E: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(S,{clearSignal:d.signal}):S()}},d.signal);_.catch(T=>{f(),p||(p=!0,this.stop(),this.trigger(\"error\",T))}),e.mediaSegmentRequest={segment:l,priority:m,request:_,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?D:a.linkToSignal(e.currentCanceller.signal),{segment:s,priority:u}=t,d=H({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(\"SF\",\"init segment request interrupted temporarly.\",{segmentId: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\",H({},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 ar=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"The max high level priority should be given a lowerpriority number than the min low priority.\")}create(e,t,r,i){let a;return vt(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 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=ir(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=ir(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=ir(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=ir(e,this._pendingTasks);if(i<0){c.warn(\"SF\",\"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(\"SF\",\"Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=ir(e.taskFn,this._pendingTasks);if(t<0){c.warn(\"SF\",\"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 ir(n,e){return re(e,t=>t.taskFn===n)}var or=class{constructor(e,t,r,i){let{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=U.getCurrent();this._transport=e,this._prioritizer=new ar({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=t,this._backoffOptions=i,this._cmcdDataBuilder=r}createSegmentQueue(e,t,r){let i=yu(this._backoffOptions),a=this._transport[e],o=$a({bufferType:e,pipeline:a,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:i}),s=Ya(this._prioritizer,o);return new rr(s,r)}};var Xa=or;function Za(n,e){let{loadThumbnail:t}=n,r=[];return async function(a,o){o.register(_);let s,u=K(r,({thumbnailContext:R})=>R.period.id===a.period.id&&R.track.id===a.track.id&&R.segment.id===a.segment.id);if(u!==void 0){c.debug(\"Thumbnails\",\"Requesting same thumbnail than the pending one\",{time:a.segment.time}),s=u,s.referenceCount++;let R;try{R=await s.promise}catch(E){throw o.deregister(_),E}return o.deregister(_),R}let{segment:d,track:f}=a,l=Mf({}),m;l.connectionTimeout===void 0||l.connectionTimeout<0?m=void 0:m=l.connectionTimeout;let g={timeout:l.requestTimeout<0?void 0:l.requestTimeout,connectionTimeout:m,cmcdPayload:void 0},p=new F,b=S();s={thumbnailContext:a,promise:b,referenceCount:1},r.push(s);let h=()=>{let R=r.indexOf(s);R>=0&&r.splice(R,1)};try{let R=await b;return h(),R}catch(R){throw h(),R}async function S(){c.debug(\"Thumbnails\",\"Beginning thumbnail request\",{time:d.time});let R;try{if(R=await tr(f.cdnMetadata,e,P,H({onRetry:T},l),p.signal),o.isCancelled())return Promise.reject(o.cancellationError);c.debug(\"Thumbnails\",\"Thumbnail request ended with success\",{time:d.time}),o.deregister(_)}catch(E){throw o.deregister(_),E instanceof ue?(c.debug(\"Thumbnails\",\"Thumbnail request aborted\",{time:d.time}),E):(c.debug(\"Thumbnails\",\"Thumbnail request failed\",{time:d.time}),Ve(E))}try{return n.parseThumbnail(R.responseData,{thumbnail:d,thumbnailTrack:f})}catch(E){throw ge(E,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}function _(){c.debug(\"Thumbnails\",\"Thumbnail request cancelled\",{time:d.time});let R=r.indexOf(s);R<0||(r[R].referenceCount--,r[R].referenceCount<=0&&(p.cancel(),r.splice(R,1)))}function P(R){return t(R,d,g,o)}function T(R){let E=Ve(R);c.warn(\"Thumbnails\",\"Thumbnail request retry \",{time:d.time},E)}}}function Mf({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}}var Su=6,Ja=4e3,ni=6e3,Of=6e4,Qt=class{constructor(e){this._segmentSinksStore=e,this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=null,this._lastFlushAttempt=null,this._lastSegmentInfo={audio:[],video:[]}}onNewObservation(e){var h,S;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=Tu(e.bufferGap);if(!(u!==null||o===1&&(l>=Su||d)))return this._decipherabilityFreezeStartingTimestamp=null,null;let g=(S=(h=u==null?void 0:u.timestamp)!=null?h:s==null?void 0:s.timestamp)!=null?S:null;if(c.info(\"Freeze\",\"Freeze detected\",{freezeStart:g,timeFrozen: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 _=this._getStrategyIfFlushingFails(f);return this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+ni,_}let b=this._checkForDecipherabilityRelatedFreeze(e,t);return b!==null?b:g!==null&&t-g>r?(this._lastFlushAttempt={timestamp:t,position:f+i},c.debug(\"Freeze\",\"Trying to flush to un-freeze\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+ni,{type:\"flush\",value:{relativeSeek:i}}):null}_checkForDecipherabilityRelatedFreeze(e,t){let{readyState:r,rebuffering:i,freezing:a,fullyLoaded:o}=e,s=Tu(e.bufferGap),u=i!==null&&t-i.timestamp>Ja,{hasUndecipherableData:d,hasEncryptedData:f}=wf(this._segmentSinksStore);if(d===!0)return c.warn(\"Freeze\",\"we have undecipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+ni,{type:\"reload\",value:null};let l=a!==null&&t-a.timestamp>Ja;return(u||l)&&(s>=Su||o)&&r<=1?this._decipherabilityFreezeStartingTimestamp===null&&(c.debug(\"Freeze\",\"Start of a potential decipherability freeze detected\"),this._decipherabilityFreezeStartingTimestamp=t):this._decipherabilityFreezeStartingTimestamp=null,this._decipherabilityFreezeStartingTimestamp!==null&&L()-this._decipherabilityFreezeStartingTimestamp>Ja&&f&&d===!1?(c.warn(\"Freeze\",\"we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+ni,{type:\"reload\",value:null}):null}_getStrategyIfFlushingFails(e){c.warn(\"Freeze\",\"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(\"Freeze\",\"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(\"Freeze\",\"Freeze when switching Period, reloading\"),{type:\"reload\",value:null};o.infos.representation.uniqueId!==s.segment.infos.representation.uniqueId&&(c.warn(\"Freeze\",\"Freeze when switching Representation, avoiding\",{bitrate: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(\"Freeze\",\"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-Of,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 wf(n){let e=!0,t=!0;for(let r of[\"audio\",\"video\"]){let i=n.getStatus(r);if(i.type===\"initialized\")for(let a of i.value.getLastKnownInventory()){let{representation:o}=a.infos;if(o.decipherable===!1)return{hasUndecipherableData:!0,hasEncryptedData:!0};o.contentProtections!==void 0&&(t=!1,o.decipherable!==!0&&(e=!1))}}return{hasEncryptedData:!t,hasUndecipherableData:e?!1:void 0}}function Tu(n){return n!==void 0&&isFinite(n)?n:0}var{DEFAULT_WANTED_BUFFER_AHEAD:Df,DEFAULT_MAX_VIDEO_BUFFER_SIZE:Bf,DEFAULT_MAX_BUFFER_AHEAD:Nf,DEFAULT_MAX_BUFFER_BEHIND:Uf}=U.getCurrent(),eo=new Y(Df),to=new Y(Bf),no=new Y(Nf),ro=new Y(Uf),ri=new Y({height:void 0,width:void 0,pixelRatio:1}),ii=new Y(1/0);function Q(n,e){c.debug(\"M<--C\",\"Sending message\",{name:n.type}),e===void 0?postMessage(n):postMessage(n,e)}function ke(n){return ge(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var sr=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(\"Track\",\"Track for periodId already declared\",{periodId:e,bufferType:t}),(s=i[t])==null||s.trackReference.finish(),(u=i[t])==null||u.representations.finish());let a=r.getValue(),o;v(a)?o=new Y({representationIds:[],switchingMode:\"lazy\"}):(o=new Y(a.representations.getValue()),r.setValue(H({},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(\"Track\",\"Setting track for inexistent periodId\",{periodId:e,bufferType:t}),!1):(v(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(\"Track\",\"Setting track for inexistent periodId\",{periodId:e,bufferType:r}),!1;let o=a.trackReference.getValue();return v(o)||o.adaptationId!==t?(c.debug(\"Track\",\"Desynchronized Adaptation id\",{oldId:o==null?void 0:o.adaptationId,newId: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(\"Track\",\"Removing track setter for inexistent periodId\",{periodId:e,bufferType:t}),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};var ur=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){c.error(\"text\",\"pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"text\",\"remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}};var Eu=Me(),$t=class{constructor({hasVideo:e}){this._currentContent=null,this._currentMediaSourceCanceller=new F,this._hasVideo=e;let t=new F;this._contentCanceller=t}initializeNewContent(e){return new Promise((t,r)=>{var A,w;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,useMseInWorker:f,enableRepresentationAvoidance:l}=e,m=null;ce(De.transports.dash!==void 0,\"Multithread RxPlayer should have access to the DASH feature\");let g=typeof d.representationFilter==\"string\"?Ro(d.representationFilter):void 0,p=De.transports.dash(se(ee({},d),{representationFilter:g})),b=e.cmcd===void 0?null:new hu(e.cmcd),h=new ja(s===void 0?void 0:[s],p,ee({cmcdDataBuilder:b},e.manifestRetryOptions)),S=gu({initialBitrates:{audio:(A=e.initialAudioBitrate)!=null?A:0,video:(w=e.initialVideoBitrate)!=null?w:0},lowLatencyMode:d.lowLatencyMode,throttlers:{limitResolution:{video:ri},throttleBitrate:{video:ii}}}),_=a.signal.register(k=>{r(k)}),P=new er(i.signal),T=new Xa(p,P,b,e.segmentRetryOptions),R=Za(p.thumbnails,P),E=new sr,[M,C,x]=_u(o,{useMseInWorker:f,hasVideo:this._hasVideo,hasText:u},a.signal),N=new Qt(C);this._currentContent={cmcdDataBuilder:b,contentId:o,enableRepresentationAvoidance:l,freezeResolver:N,mediaSource:M,manifest:null,manifestFetcher:h,representationEstimator:S,segmentSinksStore:C,segmentQueueCreator:T,fetchThumbnailData:R,workerTextSender:x,trackChoiceSetter:E,useMseInWorker:f},M.addEventListener(\"mediaSourceOpen\",function(){B()},a.signal),i.signal.register(()=>{h.dispose()}),h.addEventListener(\"warning\",k=>{Q({type:\"warning\",contentId:o,value:ke(k)})},i.signal),h.addEventListener(\"manifestReady\",k=>{if(m!==null){c.warn(\"Core\",\"Multiple `manifestReady` events, ignoring\");return}m=k,this._currentContent!==null&&(this._currentContent.manifest=m),B()},a.signal),h.addEventListener(\"error\",k=>{Q({type:\"error\",contentId:o,value:ke(k)}),r(k)},i.signal),h.start();function B(){if(m===null||M.readyState===\"closed\"||a.isUsed())return;Lf(m);let k=m.getMetadataSnapshot();m.addEventListener(\"manifestUpdate\",O=>{if(m===null)return;let z=H(m.getMetadataSnapshot(),{periods:[]});Q({type:\"manifest-update\",contentId:o,value:{manifest:z,updates:O}})},i.signal),_(),t(k)}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(){if(this._currentMediaSourceCanceller.cancel(),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new F;let[e,t,r]=_u(this._currentContent.contentId,{useMseInWorker:this._currentContent.useMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.workerTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=e,this._currentContent.segmentSinksStore=t,this._currentContent.freezeResolver=new Qt(t),this._currentContent.workerTextSender=r,new Promise((i,a)=>{e.addEventListener(\"mediaSourceOpen\",function(){i()},this._currentMediaSourceCanceller.signal),e.addEventListener(\"mediaSourceClose\",function(){a(new Error(\"MediaSource ReadyState changed to close during init.\"))},this._currentMediaSourceCanceller.signal),this._currentMediaSourceCanceller.signal.register(o=>{a(o)})})}disposeCurrentContent(){this._contentCanceller.cancel(),this._contentCanceller=new F}};function _u(n,e,t){let r;if(e.useMseInWorker){let s=new Gn(Eu());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 Hn(Eu(),n,Q);let i=e.hasText?new ur(n,Q):null,{hasVideo:a}=e,o=new _t(r,a,i);return t.register(()=>{o.disposeAll(),i==null||i.stop(),r.dispose()}),[r,o,i]}function Lf(n){var t,r;if(v(ct))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=ct.isTypeSupported(u);s.isCodecSupportedInWebWorker=d,e.set(u,d)}}}}function io(){let n=!1,e=new $t({hasVideo:!0}),t=null,r=new As;De.dashParsers.wasm=r,De.dashParsers.js=ps,De.transports.dash=Ls;let i=null;te.onmessageerror=a=>{c.error(\"Core\",\"Error when receiving message from main thread.\")},onmessage=function(a){var s,u;c.debug(\"Core\",\"received message\",{name:a.data.type});let o=a.data;switch(o.type){case\"init\":ce(!n),n=!0,lo(o.value),Ru(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(\"Core\",\"Could not initialize DASH_WASM parser\",f)}),o.value.hasVideo||(e.disposeCurrentContent(),e=new $t({hasVideo:o.value.hasVideo})),Q({type:\"init-success\",value:null});break;case\"log-level-update\":Ru(o.value.logLevel,o.value.logFormat,o.value.sendBackLogs);break;case\"prepare\":Ff(e,o.value);break;case\"start\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;t==null||t.stop(),i==null||i.finish();let f=new Y(H(o.value.initialObservation,{position:new wt(...o.value.initialObservation.position)}));i=f,t=Wf(o.value,e,f);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=Ba(d.mediaSource,null);m.audio!==null&&(l.audio=m.audio),m.video!==null&&(l.video=m.video),i==null||i.setValue(H(f,{position:new wt(...o.value.position)}));break}case\"ref-update\":zf(o);break;case\"stop\":if(o.contentId!==((s=e.getCurrentContent())==null?void 0:s.contentId))return;e.disposeCurrentContent(),t==null||t.stop(),t=null,i==null||i.finish(),i=null;break;case\"ms-reload\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;t==null||t.signalMediaSourceReload()}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=K(f,m=>m.type===o.sourceBufferType);if(l===void 0){c.info(\"Core\",\"Success for an unknown SourceBuffer\",{sourceBufferType:o.sourceBufferType});return}if(l.onOperationSuccess===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType: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=K(f,m=>m.type===o.sourceBufferType);if(l===void 0){c.info(\"Core\",\"Error for an unknown SourceBuffer\",{sourceBufferType:o.sourceBufferType});return}if(l.onOperationFailure===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType: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(\"Core\",\"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:ke(l)})}catch(l){Q({type:\"error\",contentId:d.contentId,value:ke(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(\"Core\",\"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(\"Core\",\"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(\"Core\",\"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(\"Core\",\"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.requestId);break}case\"thumbnail-request\":{Gf(e,o);break}case\"config-update\":{U.update(o.value);break}default:Ne(o)}}}function Ff(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:ke(t)})})}function zf(n){switch(n.value.name){case\"wantedBufferAhead\":eo.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":to.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":ro.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":no.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":ri.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":ii.setValueIfChanged(n.value.newVal);break;default:Ne(n.value)}}function Wf(n,e,t){c.debug(\"Core\",\"Loading pepared content.\");let r=new F,i=null;return a(n.initialTime),{signalMediaSourceReload:()=>s(),stop:()=>{r.cancel()}};function a(u){var B;i==null||i.cancel(),i=new F,i.linkToSignal(r.signal);let d=new Map,f=e.getCurrentContent();if(f===null||f.manifest===null){let A=new _e(\"NONE\",\"Loading content when none is prepared\");throw Q({type:\"error\",contentId:void 0,value:ke(A)}),A}let{contentId:l,cmcdDataBuilder:m,enableRepresentationAvoidance:g,manifest:p,mediaSource:b,representationEstimator:h,segmentSinksStore:S,segmentQueueCreator:_}=f,{drmSystemId:P,enableFastSwitching:T,onCodecSwitch:R}=n;t.onUpdate(A=>{Ua(A,S);let w=f.freezeResolver.onNewObservation(A);w!==null&&Vf(w,{contentId:l,manifest:p,handleMediaSourceReload:o,enableRepresentationAvoidance:g})},{clearSignal:i.signal});let E=(B=p.getPeriodForTime(u))!=null?B:p.getNextPeriod(u);if(E===void 0){let A=new Z(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");throw Q({type:\"error\",contentId:l,value:ke(A)}),A}let M=new kn(t,l,Q,i.signal);m==null||m.startMonitoringPlayback(M),i.signal.register(()=>{m==null||m.stopMonitoringPlayback()});let C=Da(p,b,M,S,{onWarning:A=>Q({type:\"warning\",contentId:l,value:ke(A)}),onPeriodChanged:A=>{Q({type:\"active-period-changed\",contentId:l,value:{periodId:A.id}})}},i.signal);au({initialPeriod:E,manifest:p},M,h,S,_,{wantedBufferAhead:eo,maxVideoBufferSize:to,maxBufferAhead:no,maxBufferBehind:ro,drmSystemId:P,enableFastSwitching:T,onCodecSwitch:R},x(),i.signal);function x(){return{needsBufferFlush(A){Q({type:\"needs-buffer-flush\",contentId:l,value:A})},streamStatusUpdate(A){N(A),p.isLastPeriodKnown&&A.period.id===p.periods[p.periods.length-1].id&&(A.hasFinishedLoading||A.isEmptyStream?C.onLastSegmentFinishedLoading(A.bufferType):C.onLastSegmentLoadingResume(A.bufferType))},needsManifestRefresh(){e.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:A}=U.getCurrent();e.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:A})},lockedStream(A){Q({type:\"locked-stream\",contentId:l,value:{periodId:A.period.id,bufferType:A.bufferType}})},adaptationChange(A){var w,k;C.onAdaptationChange(A.type,A.period,A.adaptation),!(i===null||i.signal.isCancelled())&&Q({type:\"adaptation-changed\",contentId:l,value:{adaptationId:(k=(w=A.adaptation)==null?void 0:w.id)!=null?k:null,periodId:A.period.id,type:A.type}})},representationChange(A){var w,k;C.onRepresentationChange(A.type,A.period),!(i===null||i.signal.isCancelled())&&Q({type:\"representation-changed\",contentId:l,value:{adaptationId:A.adaptation.id,representationId:(k=(w=A.representation)==null?void 0:w.id)!=null?k:null,periodId:A.period.id,type:A.type}})},inbandEvent(A){Q({type:\"inband-event\",contentId:l,value:A})},warning(A){Q({type:\"warning\",contentId:l,value:ke(A)})},periodStreamReady(A){f!==null&&(f.trackChoiceSetter.addTrackSetter(A.period.id,A.type,A.adaptationRef),Q({type:\"period-stream-ready\",contentId:l,value:{periodId:A.period.id,bufferType:A.type}}))},periodStreamCleared(A){if(f===null)return;let w=d.get(A.period);w!==void 0&&(w.delete(A.type),w.size===0&&d.delete(A.period)),C.onPeriodCleared(A.type,A.period),f.trackChoiceSetter.removeTrackSetter(A.period.id,A.type),Q({type:\"period-stream-cleared\",contentId:l,value:{periodId:A.period.id,bufferType:A.type}})},bitrateEstimateChange(A){var w;f!==null&&((w=f.cmcdDataBuilder)==null||w.updateThroughput(A.type,A.bitrate)),Q({type:\"bitrate-estimate-change\",contentId:l,value:{bitrate:A.bitrate,bufferType:A.type}})},needsMediaSourceReload(A){o(A)},needsDecipherabilityFlush(){Q({type:\"needs-decipherability-flush\",contentId:l,value:null})},encryptionDataEncountered(A){for(let w of A){let k=w.content,O=ee({},k);O.manifest instanceof zt&&(O.manifest=O.manifest.getMetadataSnapshot()),O.period instanceof ht&&(O.period=O.period.getMetadataSnapshot()),O.adaptation instanceof mt&&(O.adaptation=O.adaptation.getMetadataSnapshot()),O.representation instanceof ln&&(O.representation=O.representation.getMetadataSnapshot()),Q({type:\"encryption-data-encountered\",contentId:l,value:{keyIds:w.keyIds,values:w.values,content:O,type:w.type}})}},error(A){Q({type:\"error\",contentId:l,value:ke(A)})}}}function N(A){let{imminentDiscontinuity:w}=A,k=d.get(A.period),O=k==null?void 0:k.get(A.bufferType);if(O!==void 0){if(O.discontinuity===null){if(w===null)return}else if(w!==null&&O.discontinuity.start===w.start&&O.discontinuity.end===w.end)return}k===void 0&&(k=new Map,d.set(A.period,k));let z={periodId:A.period.id,bufferType:A.bufferType,discontinuity:A.imminentDiscontinuity,position:A.position};k.set(A.bufferType,z),Q({type:\"discontinuity-update\",contentId:l,value:z})}}function o(u){var f;i!==null&&(i.cancel(),i=null);let d=(f=e.getCurrentContent())==null?void 0:f.mediaSource.id;if(d===void 0){c.warn(\"Core\",\"Cannot reload MediaSource: no MediaSource currently.\");return}c.debug(\"Core\",\"Reloading MediaSource\",{timeOffset:u.timeOffset,minimumPosition:u.minimumPosition,maximumPosition:u.maximumPosition}),Q({type:\"reloading-media-source\",mediaSourceId:d,value:u},[]),s()}function s(){var l;let d=t.getValue().position.getWanted();i!==null&&(i.cancel(),i=null);let f=(l=e.getCurrentContent())==null?void 0:l.contentId;e.reloadMediaSource().then(()=>{c.info(\"Core\",\"MediaSource Reloaded, loading content again\",{newInitialTime:d}),a(d)},m=>{if(F.isCancellationError(m)){c.info(\"Core\",\"A reloading operation was cancelled\");return}Q({type:\"error\",contentId:f,value:ke(m)})})}}function Ru(n,e,t){t?c.setLevel(n,\"standard\",(r,i,a)=>{let o=a.map(s=>s instanceof Error?ke(s):s);postMessage({type:\"log\",value:{namespace:i,logLevel:r,logs:o}})}):c.setLevel(n,e)}function qf(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 Vf(n,{contentId:e,manifest:t,handleMediaSourceReload:r,enableRepresentationAvoidance:i}){switch(n.type){case\"reload\":{c.info(\"Core\",\"Planning reload due to freeze\"),r({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}case\"flush\":{c.info(\"Core\",\"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(\"Core\",\"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)}}function Gf(n,e){let t=n.getCurrentContent(),r=i=>{Q({type:\"thumbnail-response\",contentId:e.contentId,value:{status:\"error\",requestId:e.value.requestId,error:ke(i)}})};if(t===null||t.manifest===null||t.contentId!==e.contentId)return r(new Error(\"Content changed\"));Na(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 Pu=io;Pu();})();\n" + "})()"], { type: "application/javascript" });
1
+ const blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Su=Object.defineProperty,Tu=Object.defineProperties;var Eu=Object.getOwnPropertyDescriptors;var Ja=Object.getOwnPropertySymbols;var _u=Object.prototype.hasOwnProperty,Ru=Object.prototype.propertyIsEnumerable;var eo=(n,e,t)=>e in n?Su(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,J=(n,e)=>{for(var t in e||(e={}))_u.call(e,t)&&eo(n,t,e[t]);if(Ja)for(var t of Ja(e))Ru.call(e,t)&&eo(n,t,e[t]);return n},oe=(n,e)=>Tu(n,Eu(e));var b={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_AUDIO_TRACKS_NOT_PLAYABLE_BEHAVIOR:\"error\",DEFAULT_VIDEO_TRACKS_NOT_PLAYABLE_BEHAVIOR:\"error\",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,FORCE_CANNOT_RELY_ON_REQUEST_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_CANNOT_REUSE_MEDIA_KEYS:!1,FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:!1,FORCE_IS_SEEKING_APPROXIMATE:!1,FORCE_MEDIA_ELEMENT_FAIL_ON_UNDECIPHERABLE_DATA:!1,FORCE_SHOULD_AWAIT_SET_MEDIA_KEYS:!1,FORCE_SHOULD_FAVOUR_CUSTOM_SAFARI_EME:!1,FORCE_SHOULD_RELOAD_MEDIA_SOURCE_ON_DECIPHERABILITY_UPDATE:!1,FORCE_SHOULD_RENEW_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_SHOULD_UNSET_MEDIA_KEYS:!1,FORCE_SHOULD_VALIDATE_METADATA:!1,FORCE_DONT_WAIT_FOR_DATA_BEFORE_LOADED:!1,FORCE_WAIT_FOR_HAVE_ENOUGH_DATA:!1},no=to;function vu(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 K=typeof Object.assign==\"function\"?Object.assign:vu;function ri(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function en(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),en(i,t[r])}else K(n,{[r]:t[r]});return en(n,...e)}function C(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(C(e)){this._listeners={};return}let r=this._listeners[e];if(!Array.isArray(r))return;if(C(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(b.CURRENT_ENV===b.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 le{constructor(){super(...arguments);this.updated=!1;this._config=no}update(t){let r=en(this._config,t);this._config=r,this.updated=!0,this.trigger(\"update\",t)}getCurrent(){return this._config}},Cu=new ii,L=Cu;var $e=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 O(){}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){b.CURRENT_ENV===b.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 O;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 tn(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 $=dr;var ai=new $(0);function ro({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;ai.setValueIfChanged(r-t)}var Au=typeof performance!=\"undefined\"?()=>performance.now()+ai.getValue():()=>Date.now()+ai.getValue(),F=Au;var xu=\"NONE\",Rt=class extends le{constructor(){super(),this.error=O,this.warn=O,this.info=O,this.debug=O,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentFormat=\"standard\",this._currentLevel=xu}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=F();console.log(String(u.toFixed(2)),\"[Init]\",`Local-Date: ${Date.now()}`)}this._currentFormat=o;let s=this._currentFormat===\"full\"?(u,l)=>(f,...d)=>{let m=F();return l(String(m.toFixed(2)),`[${u}]`,f+\":\",...d.map(g=>typeof g==\"object\"&&g!==null&&!(g instanceof Error)?io(g):g))}:(u,l)=>(f,...d)=>l(f+\":\",...d.map(m=>typeof m==\"object\"&&m!==null&&!(m instanceof Error)?io(m):m));if(r===void 0)this.error=i>=this._levels.ERROR?s(\"error\",console.error.bind(console)):O,this.warn=i>=this._levels.WARNING?s(\"warn\",console.warn.bind(console)):O,this.info=i>=this._levels.INFO?s(\"info\",console.info.bind(console)):O,this.debug=i>=this._levels.DEBUG?s(\"log\",console.log.bind(console)):O;else{let u=l=>i>=this._levels[l]?(f,...d)=>r(l,f,d):O;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]}};function io(n){let e=\"\";for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)){e.length>0&&(e+=\" \");let r=n[t];r instanceof Error?e+=`${t}=\"${JSON.stringify(r==null?void 0:r.toString())}\"`:e+=`${t}=${typeof r==\"string\"?`${JSON.stringify(r)}`:String(r)}`}return e}var ku=new Rt,c=ku;var lr=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var Mu=typeof window==\"undefined\"&&!lr,fr=Mu;var mr;lr?mr=self:fr?mr=global:mr=window;var ee=mr;var ue=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,cr=typeof AbortController==\"function\"?AbortController:null;function pr(n){var m,g;let e;if(!C(n.headers))if(C(oi))e=n.headers;else{e=new oi;let h=Object.keys(n.headers);for(let p=0;p<h.length;p++){let I=h[p];e.append(I,n.headers[I])}}c.debug(\"utils\",\"Fetch\",{url:n.url});let t=null,r=!1,i=!1,a=F(),o=C(cr)?null:new cr;function s(){if(C(o)){c.warn(\"utils\",\"Fetch: AbortController API not available.\");return}o.abort()}let u;n.timeout!==void 0&&(u=setTimeout(()=>{r=!0,l!==void 0&&clearTimeout(l),s()},n.timeout));let l;n.connectionTimeout!==void 0&&(l=setTimeout(()=>{i=!0,u!==void 0&&clearTimeout(u),s()},n.connectionTimeout));let f=n.cancelSignal.register(function(p){t=p,s()}),d={method:\"GET\"};if(e!==void 0&&(d.headers=e),d.signal=C(o)?null:o.signal,c.hasLevel(\"DEBUG\")){let h=\"fetch GET \"+n.url;n.timeout!==void 0&&(h+=\" to=\"+String(n.timeout/1e3)),n.connectionTimeout!==void 0&&(h+=\" cto=\"+String(n.connectionTimeout/1e3)),((m=n.headers)==null?void 0:m.Range)!==void 0&&(h+=\" Range=\"+((g=n.headers)==null?void 0:g.Range)),c.debug(\"utils\",h)}return fetch(n.url,d).then(h=>{if(l!==void 0&&clearTimeout(l),h.status>=300)throw c.warn(\"utils\",\"Fetch: Request HTTP Error\",{status:h.status,responseUrl:h.url}),new ue(h.url,h.status,Re.ERROR_HTTP_CODE);if(C(h.body))throw new ue(h.url,h.status,Re.PARSE_ERROR);let p=h.headers.get(\"Content-Length\"),I=!C(p)&&!isNaN(+p)?+p:void 0,y=h.body.getReader(),E=0;return v();async function v(){let T=await y.read();if(!T.done&&!C(T.value)){E+=T.value.byteLength;let P=F(),_={url:h.url,currentTime:P,duration:P-a,sendingTime:a,chunkSize:T.value.byteLength,chunk:T.value.buffer,size:E,totalSize:I};return n.onData(_),v()}else if(T.done){u!==void 0&&clearTimeout(u),f();let P=F();return{requestDuration:P-a,receivedTime:P,sendingTime:a,size:E,status:h.status,url:h.url}}return v()}}).catch(h=>{throw t!==null?t:(f(),r?(c.warn(\"utils\",\"Fetch: Request timed out.\",{url:n.url,timeout:n.timeout}),new ue(n.url,0,Re.TIMEOUT)):i?(c.warn(\"utils\",\"Fetch: Request connection timed out.\",{url:n.url,connectionTimeout:n.connectionTimeout}),new ue(n.url,0,Re.TIMEOUT)):h instanceof ue?h:(c.warn(\"utils\",\"Fetch: Request Error\",{error:h instanceof Error?h.toString():\"Unkwown Error\"}),new ue(n.url,0,Re.ERROR_EVENT)))})}function nn(){let n=/\\[\\s*native\\s+code\\s*\\]/;return typeof ee.fetch==\"function\"&&!C(cr)&&n.test(cr.toString())&&!C(oi)}function Q(n){return typeof n==\"string\"&&n.length>0}var Ou=\"json\";function rn(n){let e={url:n.url,headers:n.headers,responseType:C(n.responseType)?Ou: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:l,connectionTimeout:f}=e,d=new XMLHttpRequest;d.open(\"GET\",o,!0);let m;l!==void 0&&(d.timeout=l,m=setTimeout(()=>{I(),r(new ue(o,d.status,Re.TIMEOUT))},l+3e3));let g;if(f!==void 0&&(g=setTimeout(()=>{I(),d.readyState!==XMLHttpRequest.DONE&&d.abort(),r(new ue(o,d.status,Re.TIMEOUT))},f)),d.responseType=u,d.responseType===\"document\"&&d.overrideMimeType(\"text/xml\"),!C(s)){let y=s;for(let E in y)Object.prototype.hasOwnProperty.call(y,E)&&d.setRequestHeader(E,y[E])}let h=F(),p=null;if(a!==void 0&&(p=a.register(function(E){I(),d.readyState!==XMLHttpRequest.DONE&&d.abort(),r(E)}),a.isCancelled()))return;if(d.onerror=function(){I(),r(new ue(o,d.status,Re.ERROR_EVENT))},d.ontimeout=function(){I(),r(new ue(o,d.status,Re.TIMEOUT))},f!==void 0&&(d.onreadystatechange=function(){d.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(g)}),i!==void 0&&(d.onprogress=function(E){let v=F();i({url:o,duration:v-h,sendingTime:h,currentTime:v,size:E.loaded,totalSize:E.total})}),d.onload=function(E){if(d.readyState===XMLHttpRequest.DONE)if(I(),d.status>=200&&d.status<300){let v=F(),T=d.response instanceof ArrayBuffer?d.response.byteLength:E.total,P=d.status,_=d.responseType,M=Q(d.responseURL)?d.responseURL:o,A;if(_===\"json\"?A=typeof d.response==\"object\"?d.response:wu(d.responseText):A=d.response,C(A)){r(new ue(o,d.status,Re.PARSE_ERROR));return}t({status:P,url:M,responseType:_,sendingTime:h,receivedTime:v,requestDuration:v-h,size:T,responseData:A})}else r(new ue(o,d.status,Re.ERROR_HTTP_CODE))},c.hasLevel(\"DEBUG\")){let y=\"XHR GET \"+o;n.responseType!==void 0&&(y+=\" type=\"+n.responseType),l!==void 0&&(y+=\" to=\"+String(l/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(\"utils\",y)}d.send();function I(){m!==void 0&&clearTimeout(m),g!==void 0&&clearTimeout(g),p!==null&&p()}})}function wu(n){try{return JSON.parse(n)}catch(e){return null}}var he=rn;var Pt=Re,qe={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function et(n,e){return`${n}: ${e}`}var an=class n extends Error{constructor(e,t,r){super(et(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,this.keyStatuses=r.keyStatuses,this.keySystemConfiguration=r.keySystemConfiguration,this.keySystem=r.keySystem}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses,keySystemConfiguration:this.keySystemConfiguration,keySystem:this.keySystem}}};var Z=class n extends Error{constructor(e,t,r){super(et(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{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var Xe=class n extends Error{constructor(e,t){super(et(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===Pt.ERROR_HTTP_CODE&&this.status===e}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var Ee=class n extends Error{constructor(e,t){super(et(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{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage}}};function Ut(n){return(n instanceof an||n instanceof Z||n instanceof Ee||n instanceof Xe)&&Object.keys(qe).indexOf(n.type)>=0}function ce(n,{defaultCode:e,defaultReason:t}){if(Ut(n))return n;let r=n instanceof Error?n.toString():t;return new Ee(e,r)}var xe=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 Du={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},monothread:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},ao=Du;var ke=ao;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 Bu={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\"},oo=Bu;var Nu={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\"},so=Nu;function Uu(n){if(C(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=Lu(t);return Q(r)?r:n}function Lu(n){let e;switch(n.length){case 2:e=oo[n];break;case 3:e=so[n];break}return e}var uo=Uu;var lo=uo;function gr(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 si(n){return Object.keys(n).map(e=>n[e])}var hr=typeof Object.values==\"function\"?Object.values:si;var Lt=[\"audio\",\"video\",\"text\"];function mo(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=F()-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=F()-e.time;return e.livePosition+t/1e3}function po(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=F()-e.time;return e.maximumSafePosition+t/1e3}function go(n,e){if(e===void 0)return di(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 ho(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(ui(i,e,t))return i;t=i}}function Io(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 ui(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 di(n){let e=n.adaptations;return si(e).reduce((t,r)=>C(r)?t:t.concat(r),[])}function Fu(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=>on(a)===!0):n.representations).map(Wu),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function zu(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 Vu(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>on(s)===!0):i.representations).map(fo),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=>on(i)===!0):n.representations).map(fo),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function Wu(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 fo(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:u,decipherable:l,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:l,contentProtections:f!==void 0?{keyIds:f.keyIds}:void 0}}function vt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:Fu(n,!1)};case\"video\":return{type:\"video\",track:Vu(n,!1)};case\"text\":return{type:\"text\",track:zu(n)}}}function on(n){return n.decipherable===!1?!1:n.isSupported}function bo(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}function Me(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var Ir=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\"}};function Ie(n,e){if(b.DEV===b.CURRENT_ENV&&!n)throw new Ir(e===void 0?\"invalid assertion\":e)}function Be(n){throw new Ir(\"Unreachable path taken\")}var qu=typeof ee==\"object\"&&typeof ee.TextDecoder==\"function\",Gu=typeof ee==\"object\"&&typeof ee.TextEncoder==\"function\";function sn(n){if(Gu)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"Unknown Error\";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 Hu(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 yo(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function He(n){if(qu)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"Unknown Error\";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=Hu(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\"+yo(o,4):\"%\"+yo(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 br(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 li(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:He(r)}}var Ku=Me(),fi=class{constructor(e,t,r){var a,o,s,u,l;this.id=e.id,this.uniqueId=Ku(),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:\"\",(l=e.codecs)!=null?l:\"\",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 l of a){if(r=e.isSupported(i,l,t),r===!0){this.codecs=[l];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 l=(i=this.contentProtections)==null?void 0:i.keyIds;r.push({type:s.type,keyIds:l,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)gr(u,t)&&(s=!0);s||(c.warn(\"manifest\",\"found unanounced key id.\",{keyId:br(t)}),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 l=r[u],f;for(f=0;f<s.length;f++)if(l.systemId===s[f].systemId){if(gr(l.data,s[f].data))break;c.warn(\"manifest\",\"different init data for the same system ID\",{systemId:l.systemId})}f===s.length&&(s.push(l),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}isPlayable(){return on(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}}},dn=fi;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=lo(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(l=>new n(l,t)));let s=e.representations,u=[];this.supportStatus={hasSupportedCodec:!1,hasCodecWithUndefinedSupport:!1,isDecipherable:!1};for(let l=0;l<s.length;l++){let f=new dn(s[l],this.type,t),d=!0;if(!C(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}d=a(m,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}d?(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(\"manifest\",\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${f.id}`,`(${f.bitrate})`)}u.sort((l,f)=>l.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 be=ee,So,To,Eo,_o,Ro,mt=(Ro=(_o=(Eo=(To=(So=be==null?void 0:be.MediaSource)!=null?So:be==null?void 0:be.MozMediaSource)!=null?To:be==null?void 0:be.WebKitMediaSource)!=null?Eo:be==null?void 0:be.MSMediaSource)!=null?_o:be==null?void 0:be.ManagedMediaSource)!=null?Ro:void 0,Kg=mt!==void 0&&mt===(be==null?void 0:be.ManagedMediaSource);var ct={EdgeChromium:0,Firefox:1,Ie11:2,OtherIeOrEdgePreEdgeChromium:3,SafariDesktop:4,SafariMobile:5,Other:6},Ne={A1KStb40xx:100,Panasonic:101,PhilipsNetTv:102,PlayStation4:103,PlayStation5:104,Tizen:105,WebOs2021:106,WebOs2022:107,WebOsOther:108,Xbox:109,Other:110},ye={DEVICES:Ne,BROWSERS:ct,browser:ct.Other,device:Ne.Other,isSamsungBrowser:!1};ju();function ju(){var n,e,t;fr||(typeof ee.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?ye.browser=ct.Ie11:navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?ye.browser=ct.OtherIeOrEdgePreEdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?ye.browser=ct.EdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?ye.browser=ct.Firefox:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?ye.browser=ct.SafariMobile:(Object.prototype.toString.call(ee.HTMLElement).indexOf(\"Constructor\")>=0||((e=(n=ee.safari)==null?void 0:n.pushNotification)==null?void 0:e.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((t=navigator.vendor)==null?void 0:t.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(ye.browser=ct.SafariDesktop),/SamsungBrowser/.test(navigator.userAgent)&&(ye.isSamsungBrowser=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?ye.device=Ne.PlayStation4:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?ye.device=Ne.PlayStation5:/Tizen/.test(navigator.userAgent)?ye.device=Ne.Tizen:/[Ww]eb[O0]S/.test(navigator.userAgent)?/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?ye.device=Ne.WebOs2022:/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent)?ye.device=Ne.WebOs2021:ye.device=Ne.WebOsOther:navigator.userAgent.indexOf(\"NETTV\")!==-1&&navigator.userAgent.indexOf(\"Philips\")!==-1?ye.device=Ne.PhilipsNetTv:/[Pp]anasonic/.test(navigator.userAgent)?ye.device=Ne.Panasonic:navigator.userAgent.indexOf(\"Xbox\")!==-1?ye.device=Ne.Xbox:navigator.userAgent.indexOf(\"Model/a1-kstb40xx\")!==-1&&(ye.device=Ne.A1KStb40xx))}var mi=ye;function ci(n){return new Promise(e=>{setTimeout(e,n)})}function Ct(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 ln(n,e){return Ct(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var z=class{constructor(){let[e,t]=Yu();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(\"utils\",\"Error while calling clean up listener\",r instanceof Error?r:\"Unknown Error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(Ie(this.cancellationError!==null),e(this.cancellationError),O):(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 Yu(){let n=O;return[function(t){n(t)},function(t){n=t}]}var Qu=[\"\",\"webkit\",\"moz\",\"ms\"];function $u(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 Xu(n,e){return e.filter(t=>$u(n,t))[0]}function Zu(n,e){return n.reduce((t,r)=>t.concat((e===void 0?Qu:e).map(i=>i+r)),[])}function Pe(n,e){let t,r=Zu(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=Xu(i,r)),Q(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{c.warn(\"utils\",`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 yh=Pe([\"loadedmetadata\"]),Sh=Pe([\"timeupdate\"]),Th=Pe([\"addtrack\"]),Eh=Pe([\"removetrack\"]),Ft=Pe([\"sourceopen\",\"webkitsourceopen\"]),yr=Pe([\"sourceclose\",\"webkitsourceclose\"]),Sr=Pe([\"sourceended\",\"webkitsourceended\"]),Po=Pe([\"update\"]),vo=Pe([\"removesourcebuffer\"]),_h=Pe([\"keymessage\",\"message\"]),Rh=Pe([\"keyadded\",\"ready\"]),Ph=Pe([\"keyerror\",\"error\"]),vh=Pe([\"keystatuseschange\"]),Ch=Pe([\"seeking\"]),Ah=Pe([\"seeked\"]),xh=Pe([\"ended\"]);var Co=[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 Tr(n){if(n>=Co.length)throw new Error(\"Unable to parse base64 string.\");let e=Co[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function Er(n){let e=n.length%4,t=n;e!==0&&(c.warn(\"utils\",\"base64ToBytes: base64 given miss padding\",{padding:e}),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,l=0;u<a;u+=4,l+=3)s=Tr(t.charCodeAt(u))<<18|Tr(t.charCodeAt(u+1))<<12|Tr(t.charCodeAt(u+2))<<6|Tr(t.charCodeAt(u+3)),o[l]=s>>16,o[l+1]=s>>8&255,o[l+2]=s&255;return o.subarray(0,o.length-i)}function At(...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 Ao(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function gi(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 pt(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 xo(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)}function Oe(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 Ze(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=pt(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 _r(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=Ze(r,1836019558);if(i<0)break;let a=re(n,i+e),o=e+i+a;if(o>n.length)break;let s=Ze(r,1835295092);if(s<0)break;let u=re(n,s+e),l=e+s+u;if(l>n.length)break;let f=Math.max(o,l),d=n.subarray(e,f);t.push(d),e=f}return t.length===0?[null,r]:[t,r]}function Ju(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function ed(n,e,t){return n.slice(e,t)}var hi=typeof Uint8Array.prototype.slice==\"function\"?ed:Ju;function Ii(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=zt(n,e);return t!==null?n.subarray(t[1],t[2]):null}function ko(n,e){let t=[],r=n;for(;;){let i=zt(r,e);if(i===null)return t;Ie(i[2]!==0&&r.length!==0),t.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}function zt(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=pt(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 Rr(n){let e=0,t=pe(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=zt(t,1886614376)}catch(s){let u=s instanceof Error?s:\"\";return c.warn(\"isobmff\",\"Error while removing PSSH from ISOBMFF\",u),r}if(i===null)return r;let a=hi(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){c.warn(\"isobmff\",\"un-handled PSSH version\");return}let t=e+4;if(t+16>n.length)return;let r=hi(n,t,t+16);return br(r)}function bi(n){let e=pe(n,1836019558);return e===null?null:pe(e,1953653094)}function Oo(n){return ko(n,1836019558).reduce((t,r)=>{let i=pe(r,1953653094);return i!==null&&t.push(i),t},[])}function yi(n){return pe(n,1835295092)}function Si(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 fn(n,e){let t=zt(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=pt(n,a),a+=8,r+=pt(n,a)+i,a+=8;else return null;let l=[];a+=2;let f=Ao(n,a);for(a+=2;--f>=0;){let d=re(n,a);a+=4;let m=(d&2147483648)>>>31,g=d&2147483647;if(m===1)throw new Error(\"sidx with reference_type `1` not yet implemented\");let h=re(n,a);a+=4,a+=4,l.push({time:u,duration:h,timescale:s,range:[r,r+g-1]}),u+=h,r+=g}return l}function Ti(n){let e=bi(n);if(e===null)return;let t=pe(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return pt(t,4);if(r===0)return re(t,4)}function td(n){let e=pe(n,1952868452);if(e===null)return;let t=1,r=gi(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 Ei(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=gi(i,a);a+=3;let u=(s&256)>0,l=0;if(!u&&(l=td(r),l===void 0))return;let f=(s&1)>0,d=(s&4)>0,m=(s&512)>0,g=(s&1024)>0,h=(s&2048)>0,p=re(i,a);a+=4,f&&(a+=4),d&&(a+=4);let I=p,y=0;for(;I-- >0;)u?(y+=re(i,a),a+=4):y+=l,m&&(a+=4),g&&(a+=4),h&&(a+=4);t+=y}return t}function mn(n){let e=Si(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 re(t,r+16);if(i===0)return re(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)c.warn(\"isobmff\",\"EMSG version \"+a.toString()+\" not supported.\");else{let o=4,{end:s,string:u}=li(r,o);o=s;let{end:l,string:f}=li(r,o);o=l;let d=re(r,o);o+=4;let m=re(r,o);o+=4;let g=re(r,o);o+=4;let h=re(r,o);o+=4;let p=r.subarray(o,i),I={schemeIdUri:u,value:f,timescale:d,presentationTimeDelta:m,eventDuration:g,id:h,messageData:p};e.push(I)}}if(e.length!==0)return e}function Bo(n){let e=Ii(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=Ii(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 nd(n,e){let{mimeType:t,codecs:r}=No(n),{mimeType:i,codecs:a}=No(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 rd=7;function No(n){var i;let[e,...t]=n.split(\";\"),r=(i=j(t,a=>Oe(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(rd),r[0]==='\"'&&(r=r.substring(1,r.length-1)),{mimeType:e,codecs:r}}var Uo=nd;function _i(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 Ri(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 l of u)if(l.supportStatus.hasCodecWithUndefinedSupport)for(let f of l.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 nt(n){ge(Fo,n)||(console.warn(n),Fo.push(n))}var cn=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 gt=class{constructor(e,t,r){if(this.id=e.id,this.adaptations=id(e.adaptations,t,r),zo(this.adaptations.video)&&zo(this.adaptations.audio))throw new Z(\"MANIFEST_PARSE_ERROR\",\"The manifest has no video nor audio tracks.\");this.thumbnailTracks=e.thumbnailTracks.map(i=>({id:i.id,mimeType:i.mimeType,index:i.index,cdnMetadata:i.cdnMetadata,height:i.height,width:i.width,horizontalTiles:i.horizontalTiles,verticalTiles:i.verticalTiles,start:i.start,end:i.end,tileDuration:i.tileDuration})),this.duration=e.duration,this.start=e.start,!C(this.duration)&&!C(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)for(let a of i){if(!a.supportStatus.hasCodecWithUndefinedSupport)continue;let o=a.supportStatus.hasSupportedCodec;a.refreshCodecSupport(t),o!==!1&&a.supportStatus.hasSupportedCodec===!1&&e.push(a)}},{})}getAdaptations(){return di(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 go(this,e)}containsTime(e,t){return ui(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 zo(n){return Array.isArray(n)?n.length===0:!0}function id(n,e,t){let r={};for(let[i,a]of Object.entries(n))C(a)||(r[i]=a.map(o=>new ft(o,e,{representationFilter:t})).filter(o=>o.representations.length>0));return r}function pn(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 l=i[u],f=ne(a,d=>d.id===l.id);if(f===-1){c.warn(\"manifest\",'ThumbnailTrack \"'+i[u].id+'\" not found when merging.');let[d]=i.splice(u,1);u--,r.removedThumbnailTracks.push({id:d.id})}else{let[d]=a.splice(f,1);l.mimeType=d.mimeType,l.height=d.height,l.width=d.width,l.horizontalTiles=d.horizontalTiles,l.verticalTiles=d.verticalTiles,l.start=d.start,l.end=d.end,l.tileDuration=d.tileDuration,l.cdnMetadata=d.cdnMetadata,t===0?l.index._replace(d.index):l.index._update(d.index),r.updatedThumbnailTracks.push({id:l.id,mimeType:l.mimeType,height:l.height,width:l.width,horizontalTiles:l.horizontalTiles,verticalTiles:l.verticalTiles,start:l.start,end:l.end,tileDuration:l.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 l=o[u],f=ne(s,d=>d.id===l.id);if(f===-1){c.warn(\"manifest\",'Adaptation \"'+o[u].id+'\" not found when merging.');let[d]=o.splice(u,1);u--,r.removedAdaptations.push({id:d.id,trackType:d.type})}else{let[d]=s.splice(f,1),m=[],g=[],h=[];r.updatedAdaptations.push({adaptation:l.id,trackType:l.type,updatedRepresentations:m,addedRepresentations:g,removedRepresentations:h});let p=l.representations,I=d.representations.slice();for(let y=0;y<p.length;y++){let E=p[y],v=ne(I,T=>T.id===E.id);if(v===-1){c.warn(\"manifest\",`Representation \"${p[y].id}\" not found when merging.`);let[T]=p.splice(y,1);y--,h.push(T.id)}else{let[T]=I.splice(v,1);m.push(E.getMetadataSnapshot()),E.cdnMetadata=T.cdnMetadata,t===0?E.index._replace(T.index):E.index._update(T.index)}}I.length>0&&(c.warn(\"manifest\",`${I.length} new Representations found when merging.`),l.representations.push(...I),g.push(...I.map(y=>y.getMetadataSnapshot())))}}if(s.length>0){c.warn(\"manifest\",`${s.length} new Adaptations found when merging.`);for(let u of s){let l=n.adaptations[u.type];l===void 0?n.adaptations[u.type]=[u]:l.push(u),r.addedAdaptations.push(u.getMetadataSnapshot())}}return r}function Vo(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 l=pn(u,o,0);t.updatedPeriods.push({period:{id:u.id,start:u.start,end:u.end,duration:u.duration,streamEvents:u.streamEvents},result:l});let f=e.slice(r,a),d=s-r,m=n.splice(r,d,...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 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 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=pn(n[i],e[0],1);t.updatedPeriods.push({period:K(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let u=e[s],l=-1;for(let f=o;f<n.length;f++)if(u.id===n[f].id){l=f;break}if(l<0){let f=-1;for(let g=o;g<n.length;g++)if(u.start<n[g].start){f=g;break}let d=f-o,m=n.splice(o,d,u);t.addedPeriods.push(u.getMetadataSnapshot()),t.removedPeriods.push(...m.map(g=>({id:g.id,start:g.start,end:g.end})))}else{if(l>o){c.warn(\"manifest\",\"old Periods not found in new when updating, removing\");let d=n.splice(o,l-o);t.removedPeriods.push(...d.map(m=>({id:m.id,start:m.start,end:m.end}))),l=o}let f=pn(n[l],u,0);t.updatedPeriods.push({period:K(n[l].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 ad=Me(),gn=class extends le{constructor(e,t){var a;super();let{representationFilter:r,manifestUpdateUrl:i}=t;this.manifestFormat=0,this.id=ad(),this.expired=(a=e.expired)!=null?a:null,this.transport=e.transportType,this.clockOffset=e.clockOffset,this._cachedCodecSupport=new cn([]),this.periods=e.periods.map(o=>new gt(o,this._cachedCodecSupport,r)).sort((o,s)=>o.start-s.start),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=i,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(vt)}):null}getPeriod(e){return j(this.periods,t=>e===t.id)}getPeriodForTime(e){return ho(this,e)}getNextPeriod(e){return j(this.periods,t=>t.start>e)}getPeriodAfter(e){return Io(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return mo(this)}getLivePosition(){return co(this)}getMaximumSafePosition(){return po(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=od(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(){nt(\"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){nt(\"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 nt(\"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 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=Vo(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 od(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(\"manifest\",`Decipherability changed for \"${o.id}\"`,`(${o.bitrate})`,String(o.decipherable)))}a&&(i.supportStatus.isDecipherable=!1)}return t}function tt(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function Ge(n){if(C(n))return null;let{period:e,adaptation:t,representation:r,segment:i}=n;return{t:t.type[0],p:e.id,a:t.id,r:r.id,ss:i.isInit?null:i.time,se:i.isInit||!i.complete?null:i.end}}var ht=gn;var xt=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 Pr(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 Pr(this,i,t)}}}var hn=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 Pr(this,e,this._cancelSignal)}};var rt=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var kt=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 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 In=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 sd=.016666666666666666;function qo(n,e){return Math.abs(n-e)<sd}function Ho(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function ud(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function dd(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(jo(t,r)){let i=Ho(t,r);n.splice(--e,2,i)}}return n}function Pi(n,e){return n.end<=e.start}function Go({start:n,end:e},t){return n<=t&&t<e}function Ko(n,e){return Go(n,e.start)||n.start<e.end&&e.end<n.end||Go(e,n.start)}function jo(n,e){return qo(e.start,n.end)||qo(e.end,n.start)}function vi(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function ld(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 Yo(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 vr(n,e){let t=ld(n,e);return t!==null?t.end-e:1/0}function It(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=Ko(t,i),o=jo(t,i);if(a||o)t=Ho(t,i),n.splice(r--,1);else if(r===0){if(Pi(t,n[0]))break}else if(Pi(n[r-1],t)&&Pi(t,i))break}return n.splice(r,0,t),dd(ud(n))}function fd(n,e){let t=[];for(let r=0;r<e.length;r++)Ko(n,e[r])&&t.push(e[r]);return t}function Cr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=fd(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 Ar({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&&md(n,a,o,t.getValue(),r.getValue(),i).catch(u=>{if(i.isCancelled()&&z.isCancellationError(u))return;let l=u instanceof Error?u.message:\"Unknown error\";c.error(\"Stream\",\"Could not run BufferGarbageCollector:\",l)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function md(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:u}=Yo(t,e),l=()=>{if(isFinite(r)){for(let d of u)e-r>=d.end?o.push(d):e>=d.end&&e-r>d.start&&e-r<d.end&&o.push({start:d.start,end:e-r});C(s)||e-r>s.start&&o.push({start:s.start,end:e-r})}},f=()=>{if(isFinite(i)){for(let d of u)e+i<=d.start?o.push(d):e<=d.start&&e+i<d.end&&e+i>d.start&&o.push({start:e+i,end:d.end});C(s)||e+i<s.end&&o.push({start:e+i,end:s.end})}};l(),f();for(let d of o)if(d.start<d.end){if(c.debug(\"Stream\",\"cleaning range from SegmentSink\",{start:d.start,end:d.end}),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(d.start,d.end)}}var bn=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=F();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>tt(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 yn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=L.getCurrent();this._inventory=[],this._bufferedHistory=new bn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var u,l,f,d,m,g,h;let t=this._inventory,r=0,i=t[0],{MINIMUM_SEGMENT_SIZE:a}=L.getCurrent(),o=i==null?void 0:i.infos.adaptation.type;if(c.hasLevel(\"DEBUG\")){let p=e.map(I=>`${I.start}-${I.end}`).join(\",\");c.debug(\"SI\",`synchronizing ${o!=null?o:\"unknown\"} buffered ranges:`,p)}let s=e.length;for(let p=0;p<s;p++){if(i===void 0)return;let I=e[p].start,y=e[p].end;if(y-I<a){c.warn(\"SI\",\"skipped range when synchronizing because it was too small\",{t:o,rangeStart:I,rangeEnd:y});continue}let E=r;for(;i!==void 0&&((u=i.bufferedEnd)!=null?u:i.end)-I<a;)i=t[++r];let v=null,T=r-E;if(T>0){let _=t[E+T-1];v={end:(l=_.bufferedEnd)!=null?l:_.end,precizeEnd:_.precizeEnd},c.debug(\"SI\",`${T} segments GCed.`,{t: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(cd(i,I,v,o),r===t.length-1){$o(i,y,o);return}i=t[++r];let _=(d=i.bufferedStart)!=null?d:i.start,M=(m=i.bufferedEnd)!=null?m:i.end,A=p<s-1?e[p+1].start:void 0;for(;i!==void 0&&!(y<_||y-_<a&&M-y>=a||A!==void 0&&y-_<M-A);){let x=t[r-1];x.bufferedEnd===void 0&&(i.precizeStart?x.bufferedEnd=i.start:x.infos.segment.complete?x.bufferedEnd=x.end:x.bufferedEnd=i.start,c.debug(\"SI\",\"calculating buffered end of contiguous segment\",{t:o,prevSegmentBufferedEnd:x.bufferedEnd,pse:x.end})),i.bufferedStart=x.bufferedEnd,i=t[++r],i!==void 0&&(_=(g=i.bufferedStart)!=null?g:i.start,M=(h=i.bufferedEnd)!=null?h:i.end)}}let P=t[r-1];P!==void 0&&$o(P,y,o)}if(!C(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:p}=L.getCurrent(),I=F();for(let y=r;y<t.length;y++){let E=t[y];I-E.insertionTs>=p&&(c.debug(\"SI\",\"A segment at the end has been completely GCed\",Ge(E.infos)),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`+pd(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},u,l){if(i.isInit)return;let f=t.type;if(o>=s){c.warn(\"SI\",\"Invalid chunked inserted: starts before it ends\",{t:f,start:o,end:s});return}let d=this._inventory,m={status:u?0:2,insertionTs:l,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 h=d.length-1;h>=0;h--){let p=d[h];if(p.start<=o)if(p.end<=o){for(c.debug(\"SI\",\"Pushing segment strictly after previous one.\",{t:f,pse:p.end,ss:o}),this._inventory.splice(h+1,0,m),h+=2;h<d.length&&d[h].start<m.end;){if(d[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,pss:d[h].start,ss:o,se:s}),d[h].start=m.end,d[h].bufferedStart=void 0,d[h].precizeStart=d[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:d[h].start,pse:d[h].end}),d.splice(h,1)}return}else if(p.start===o)if(p.end<=s){for(c.debug(\"SI\",\"Segment pushed replace another one\",{t:f,ss:o,se:s,pss:p.start,pse:p.end}),this._inventory.splice(h,1,m),h+=1;h<d.length&&d[h].start<m.end;){if(d[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:d[h].start,pse:d[h].end}),d[h].start=m.end,d[h].bufferedStart=void 0,d[h].precizeStart=d[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:d[h].start,pse:d[h].end}),d.splice(h,1)}return}else{c.debug(\"SI\",\"Segment pushed ends before another with the same start\",{t:f,ss:o,se:s,pse:p.end}),d.splice(h,0,m),p.start=m.end,p.bufferedStart=void 0,p.precizeStart=p.precizeStart&&m.precizeEnd;return}else if(p.end<=m.end){for(c.debug(\"SI\",\"Segment pushed updates end of previous one\",{t:f,ss:o,se:s,pss:p.start,pse:p.end}),this._inventory.splice(h+1,0,m),p.end=m.start,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&m.precizeStart,h+=2;h<d.length&&d[h].start<m.end;){if(d[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:d[h].start}),d[h].start=m.end,d[h].bufferedStart=void 0,d[h].precizeStart=d[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:d[h].start,pse:d[h].end}),d.splice(h,1)}return}else{c.warn(\"SI\",\"Segment pushed is contained in a previous one\",{t:f,ss:o,se:s,pss:p.start,pse:p.end});let I={status:p.status,insertionTs:p.insertionTs,chunkSize:p.chunkSize,splitted:!0,start:m.end,end:p.end,precizeStart:p.precizeStart&&p.precizeEnd&&m.precizeEnd,precizeEnd:p.precizeEnd,bufferedStart:void 0,bufferedEnd:p.end,infos:p.infos};p.end=m.start,p.splitted=!0,p.bufferedEnd=void 0,p.precizeEnd=p.precizeEnd&&m.precizeStart,d.splice(h+1,0,m),d.splice(h+2,0,I);return}}let g=this._inventory[0];if(g===void 0){c.debug(\"SI\",\"first segment pushed\",{t:f,ss:o,se:s}),this._inventory.push(m);return}if(g.start>=s)c.debug(\"SI\",\"Segment pushed comes before all previous ones\",{t:f,ss:o,se:s,pss: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\",{t:f,ss:o,se:s,pss:g.start,pse:g.end}),this._inventory.splice(0,1,m);d.length>1&&d[1].start<m.end;){if(d[1].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:d[1].start,pse:d[1].end}),d[1].start=m.end,d[1].bufferedStart=void 0,d[1].precizeStart=m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:d[1].start,pse:d[1].end}),d.splice(1,1)}return}else{c.debug(\"SI\",\"Segment pushed start of the next one\",f,{ss:o,se:s,pss:g.start,pse: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(tt(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(c.warn(\"SI\",\"Completed Segment is splitted.\",Ge(e)),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&tt(t[i].infos,e);){let m=t[i].chunkSize;s!==void 0&&m!==void 0&&(s+=m),i++}let u=i-1,l=u-o,f=t[u].end,d=t[u].bufferedEnd;l>0&&(this._inventory.splice(o+1,l),i-=l),this._inventory[o].status===0&&(this._inventory[o].status=1),this._inventory[o].chunkSize=s,this._inventory[o].end=f,this._inventory[o].bufferedEnd=d,this._inventory[o].splitted=a,r.push(this._inventory[o])}if(r.length===0)c.warn(\"SI\",\"Completed Segment not found\",Ge(e));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.\",{ss:i.start,se:i.end})}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function Ci(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}=L.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 Qo(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}=L.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 cd(n,e,t,r){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MISSING_DATA_TRIGGER_SYNC_DELAY:a,SEGMENT_SYNCHRONIZATION_DELAY:o}=L.getCurrent();if(n.bufferedStart!==void 0)n.bufferedStart<e&&(c.debug(\"SI\",\"Segment partially GCed at the start\",{t:r,firstsbs:n.bufferedStart,rs:e}),n.bufferedStart=e),!n.precizeStart&&Ci(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)c.debug(\"SI\",\"buffered start is precize start\",{t:r,firstss: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\",{t:r,rs:e,firstss:n.start,lastdelse:t.end}),n.bufferedStart=t.end,Ci(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=F();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI\",\"Ignored bufferedStart synchronization\",{t:r,rs:e,firstss:n.start,delta:s-n.insertionTs});return}c.debug(\"SI\",\"found true buffered start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=e,Ci(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)c.debug(\"SI\",\"range start too far from expected start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=n.start;else{let s=F();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI\",\"Ignored bufferedStart synchronization\",{t:r,rs:e,firstss:n.start,delta:s-n.insertionTs});return}c.debug(\"SI\",\"Segment appears immediately garbage collected at the start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=e}}function $o(n,e,t){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:r,MISSING_DATA_TRIGGER_SYNC_DELAY:i,SEGMENT_SYNCHRONIZATION_DELAY:a}=L.getCurrent();if(n.bufferedEnd!==void 0)n.bufferedEnd>e&&(c.debug(\"SI\",\"Segment partially GCed at the end\",{t,lastsbe:n.bufferedEnd,re:e}),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&Qo(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)c.debug(\"SI\",\"buffered end is precize end\",{t,lastse:n.end}),n.bufferedEnd=n.end;else if(e-n.end<=r||!n.infos.segment.complete){let o=F();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI\",\"Ignored bufferedEnd synchronization\",{t,re:e,lastse:n.end,delta:o-n.insertionTs});return}c.debug(\"SI\",\"found true buffered end\",{t,re:e,lastse:n.end}),n.bufferedEnd=e,Qo(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)c.debug(\"SI\",\"range end too far from expected end\",{t,re:e,lastse:n.end}),n.bufferedEnd=n.end;else{let o=F();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI\",\"Ignored bufferedEnd synchronization\",{t,re:e,lastse:n.end,delta:o-n.insertionTs});return}c.debug(\"SI\",\"Segment appears immediately garbage collected at the end\",{t,lastsbe:n.bufferedEnd,re:e}),n.bufferedEnd=e}}function pd(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(u){let l=String.fromCharCode(r.length+65);return r.push({letter:l,periodId:u.period.id,representationId:u.representation.id,bitrate:u.representation.bitrate}),l}let s=\"\";for(let u of n)if(u.bufferedStart!==void 0&&u.bufferedEnd!==void 0){let l=u.infos.period.id,f=u.infos.representation.id,d=t[l],m;if(d===void 0)m=o(u.infos),t[l]={[f]:m};else{let g=d[f];g===void 0?(m=o(u.infos),d[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 l;s+=`\n[${u.letter}] P: ${u.periodId} || R: ${u.representationId}(${(l=u.bitrate)!=null?l:\"unknown bitrate\"})`}),s}function Vt(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 Wt(n,e){for(let t of n)if(t.infos.period.start>e.start)return t;return null}var Xo=yn;var qt=class{constructor(){this._segmentInventory=new Xo}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var Sn=class extends qt{constructor(e,t,r){super(),c.info(\"Stream\",\"calling `mediaSource.addSourceBuffer`\",{codec: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){Zo(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){Zo(e.data.chunk),c.debug(\"Stream\",\"queuing push order\",Ge(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:l}=e.data;return c.debug(\"Stream\",\"now pushing\",Ge(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:u,appendWindow:l})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,F()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,F());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){c.debug(\"Stream\",\"queuing remove order\",{bufferType:this.bufferType,start:e,end: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(\"Stream\",\"Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose()}catch(e){c.debug(\"Stream\",`Failed to dispose a ${this.bufferType} SourceBufferInterface:`,e instanceof Error?e:\"Unknown Error\")}}_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 Zo(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var kr=Sn;var Tn=class extends qt{constructor(e){c.debug(\"Stream\",\"Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){c.warn(\"Stream\",\"Declaring initialization segment for Text SegmentSink\",{uniqueId:e})}freeInitSegment(e){c.warn(\"Stream\",\"Freeing initialization segment for Text SegmentSink\",{uniqueId:e})}async pushChunk(e){let{data:t}=e;hd(t.chunk);let r=this._sender.pushTextData(oe(J({},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,F()),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(\"Stream\",\"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 hd(n){if(b.CURRENT_ENV!==b.PRODUCTION){if(typeof n!=\"object\"||n===null||C(n.data))throw new Error(\"Invalid format given to a TextSegmentSink\");if(!Id(n))throw new Error(\"Invalid format given to a TextSegmentSink\");if(typeof n.data!=\"string\"&&typeof n.data.byteLength!=\"number\")throw new Error(\"Invalid format given to a TextSegmentSink\")}}function Id(n){return!(typeof n!=\"object\"||n===null||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.initTimescale!==null&&typeof n.initTimescale!=\"number\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\")}b.CURRENT_ENV===b.DEV&&(bd=function(e){function t(r){}});var bd;var Jo=Tn;var yd=[\"audio\",\"video\",\"text\"],En=class n{static isNative(e){return es(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():Ct(e,t=>{let r=O,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(\"Stream\",`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()),Ie(this._onNativeBufferAddedOrDisabled.length===0))}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(es(e)){if(!C(r))return r instanceof kr&&r.codec!==t?c.warn(\"Stream\",\"Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):c.info(\"Stream\",\"Reusing native SegmentSink with codec\",t),r;c.info(\"Stream\",\"Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new kr(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.slice().forEach(s=>s()),Ie(this._onNativeBufferAddedOrDisabled.length===0),o}if(!C(r))return c.info(\"Stream\",\"Reusing a previous custom SegmentSink\",{bufferType:e}),r;let i;if(e===\"text\"){if(c.info(\"Stream\",\"Creating a new text SegmentSink\"),this._textInterface===null)throw new Error(\"HTML Text track feature not activated\");return i=new Jo(this._textInterface),this._initializedSegmentSinks.text=i,i}throw c.error(\"Stream\",\"Unknown buffer type:\",{bufferType: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(C(t)){c.warn(\"Stream\",\"Trying to dispose a SegmentSink that does not exist\",{bufferType:e});return}c.info(\"Stream\",\"Aborting SegmentSink\",{bufferType:e}),t.dispose(),delete this._initializedSegmentSinks[e]}disposeAll(){yd.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(J({},o),{infos:Sd(o.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function es(n){return n===\"audio\"||n===\"video\"}function Sd(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var bt=En;function Ai(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,u=Td(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 d=s.index.checkDiscontinuity(e.start);if(d!==null)return{start:void 0,end:d}}return null}let l=i[u];if(l.bufferedStart!==void 0&&l.bufferedStart>e.start&&(t===null||l.infos.segment.end<=t)){let d=l.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,d)!==!1?null:(c.debug(\"Stream\",\"current discontinuity encountered\",{bufferType:o.type,nextSegmentTime:l.bufferedStart,checkStartTime:e.start}),{start:void 0,end:d})}let f=Ed(i,e,u+1);if(f!==null){let d=i[f-1],m=i[f];if(t===null||m.infos.segment.end<=t){if(!r&&s.index.awaitSegmentBetween(d.infos.segment.end,m.infos.segment.time)!==!1)return null;let g=d.bufferedEnd,h=m.bufferedStart;return c.debug(\"Stream\",\"future discontinuity encountered\",{bufferType:o.type,discontinuityStart:g,discontinuityEnd:h}),{start:g,end:h}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let d=_d(i,a.end);if(d!==null){let m=i[d];if(m.bufferedEnd!==void 0&&m.bufferedEnd<a.end)return c.debug(\"Stream\",\"discontinuity encountered at the end of the current period\",{bufferType:o.type,segmentsEndTimeFromPeriod:m.bufferedEnd,periodEnd:a.end}),{start:m.bufferedEnd,end:null}}}if(a.end!==void 0&&e.end>=a.end)return null;for(let d=i.length-1;d>=0;d--){let m=i[d];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 Td(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 Ed(n,e,t){if(t<=0)return c.error(\"Stream\",\"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 _d(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 xi({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:u,representation:l}=e,f=Rd(n,o,s),d=l.index.getSegments(a.start,a.end-a.start),m=n.filter(P=>!ts(P.infos,e,t,r)),g=Md(m,a,i),{MINIMUM_SEGMENT_SIZE:h,MIN_BUFFER_AHEAD:p}=L.getCurrent(),I=!1,y=Math.min(1/60,h),E=!1,v=[];return{segmentsToLoad:d.filter(P=>{let _=K({segment:P},e);if(o.length>0&&o.some(U=>tt(_,U)))return!1;let{duration:M,time:A,end:x}=P;if(P.isInit)return!0;if(I)return v.push(P),!1;if(P.complete&&M<h||o.length>0&&o.some(U=>{if(U.period.id!==e.period.id||U.adaptation.id!==e.adaptation.id)return!1;let{segment:R}=U;if(R.time-y>A)return!1;if(R.complete){if(R.end+y<x)return!1}else if(Math.abs(A-R.time)>A)return!1;return!ts(U,_,t,r)}))return!1;for(let V of g){let U=V.infos.period.id===e.period.id;if(V.status===1&&U){let R=V.infos.segment;if(A-R.time>-y){if(R.complete){if(R.end-x>-y)return!1}else if(Math.abs(A-R.time)<y)return!1}}}let B=M*e.representation.bitrate;if(f-B<0&&(E=!0,A>a.start+p))return I=!0,v.push(P),!1;let D=i(_);if(D.length>1){let V=D[D.length-1],U=D[D.length-2];if(V.buffered===null&&U.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.\",{bufferType:u.type,representationId:l.id,segmentTime:P.time}),!1}for(let V=0;V<g.length;V++){let U=g[V];if(U.end+y>A){let R=U.start>A+y||Pd(g,V).end<x-y;return R&&(f-=B),R}}return f-=B,!0}),segmentsOnHold:v,isBufferFull:E}}function Rd(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 Pd(n,e){let t=e+1,{MINIMUM_SEGMENT_SIZE:r}=L.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 ts(n,e,t,r){let{CONTENT_REPLACEMENT_PADDING:i}=L.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:vd(n.representation,e.representation,r)}function vd(n,e,t){let r=n.bitrate,{BITRATE_REBUFFERING_RATIO:i}=L.getCurrent();if(t===void 0){let a=r*i;return e.bitrate>a}return r<t&&e.bitrate>r}function Cd(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=L.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\",{segmentStart:n.start,currentStartInBuffer:n.bufferedStart}),!0):!1}function Ad(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=L.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\",{segmentEnd:n.end,currentEndInBuffer:n.bufferedEnd}),!0):!1}function xd(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 kd(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 Md(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(Cd(r,o,e.start)){if(u=t(r.infos),xd(u,r.bufferedStart))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the start\",{segmentStart:r.start,currentStartInBuffer:r.bufferedStart})}if(Ad(r,s,e.end)){if(u=u!=null?u:t(r.infos),kd(u,r.bufferedEnd))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the end\",{segmentEnd:r.end,currentEndInBuffer:r.bufferedEnd})}return!0})}function _n(n,e){let t=n-e,{SEGMENT_PRIORITIES_STEPS:r}=L.getCurrent();for(let i=0;i<r.length;i++)if(t<r[i])return i;return r.length}function ki(n,e,t,r,i,a,o){var A,x,B;let{representation:s}=n,u=(x=(A=t.getIsPaused())!=null?A:t.getReference().getValue().paused.pending)!=null?x:t.getReference().getValue().paused.last,l=(B=t.getPlaybackRate())!=null?B:t.getReference().getValue().speed,f=e;(u===void 0||l===void 0||u||l<=0)&&(f-=.1);let d=Od(n,f,i),m=s.index.shouldRefresh(d.start,d.end),g=o.getPendingOperations().filter(D=>D.type===2).map(D=>D.value),h=o.getLastKnownInventory(),p=t.getCurrentTime();p===void 0&&(p=t.getReference().getValue().position.getWanted());let I=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:E,isBufferFull:v}=xi({content:n,bufferedSegments:h,currentPlaybackTime:p,fastSwitchThreshold:r,getBufferedHistory:I,neededRange:d,segmentsBeingPushed:g,maxBufferSize:a}),T=y.map(D=>({priority:_n(D.time,f),segment:D})),P=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&d.hasReachedPeriodEnd&&T.length===0&&E.length===0,_=null;return g.length>0&&(_=Math.min(...g.map(D=>D.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:Ai(n,d,_,P,h),hasFinishedLoading:P,neededSegments:T,isBufferFull:v,shouldRefreshManifest:m}}function Od(n,e,t){var d;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),u=o.index;!C(s)&&bt.isNative(n.adaptation.type)&&e>=s&&u.isInitialized()&&!u.isStillAwaitingFutureSegments()&&wd(i,a,e)?r=s-1:r=e-.1;let l=r+t,f;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?f=!1:s===void 0?f=l>=a.end:s===null?f=!0:f=l>=s,{start:Math.max(r,a.start),end:Math.min(l,(d=a.end)!=null?d:1/0),hasReachedPeriodEnd:f}}function wd(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 Rn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof se)throw a;if(!(a instanceof xe)||!a.isBufferFull){let u=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new Z(\"BUFFER_APPEND_ERROR\",u,{tracks:[vt(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),l=s+r.getValue()+12;if(u>0&&await e.removeBuffer(0,u),l<Number.MAX_VALUE&&await e.removeBuffer(l,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 l=u instanceof Error?u.toString():\"Could not clean the buffer\";throw new Z(\"BUFFER_FULL_ERROR\",l,{tracks:[vt(t.inventoryInfos.adaptation)]})}}}async function Mi({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},l=K({segment:r,chunkSize:void 0,start:0,end:0},e),f=await Rn(n,i,{data:u,inventoryInfos:l},a,o);return{content:e,segment:r,buffered:f}}async function Oi({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:l,chunkOffset:f,chunkSize:d,appendWindow:m}=i,g=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:h}=L.getCurrent(),p=[m[0]!==void 0?Math.max(0,m[0]-h.START):void 0,m[1]!==void 0?m[1]+h.END:void 0],I={initSegmentUniqueId:r,chunk:u,timestampOffset:f,appendWindow:p,codec:g},y=(_=l==null?void 0:l.time)!=null?_:a.time,E=(M=l==null?void 0:l.duration)!=null?M:a.duration,v=y+E;p[0]!==void 0&&(y=Math.max(y,p[0])),p[1]!==void 0&&(v=Math.min(v,p[1]));let T=K({segment:a,chunkSize:d,start:y,end:v},t),P=await Rn(n,o,{data:I,inventoryInfos:T},e,s);return{content:t,segment:a,buffered:P}}function wi({content:n,options:e,playbackObserver:t,segmentSink:r,segmentQueue:i,terminate:a},o,s){c.debug(\"Stream\",\"Creating RepresentationStream\",{periodStart:n.period.start,bufferType:n.adaptation.type,adaptationId:n.adaptation.id,representationBitrate:n.representation.bitrate,mimeType:n.representation.getMimeTypeString()});let{period:u,adaptation:l,representation:f}=n,{bufferGoal:d,maxBufferSize:m,drmSystemId:g,fastSwitchThreshold:h}=e,p=l.type,I=new z;I.linkToSignal(s);let y={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};I.signal.register(()=>{y.uniqueId!==null&&r.freeInitSegment(y.uniqueId)});let E=y.segment!==null;E||(y.isLoaded=!0);let v=!1;if(g!==void 0){let A=f.getEncryptionData(g);if(A.length>0&&A.every(x=>x.keyIds!==void 0)&&(v=!0,o.encryptionDataEncountered(A.map(x=>K({content:n},x))),I.isUsed()))return}i.addEventListener(\"error\",A=>{I.signal.isCancelled()||(I.cancel(),o.error(A))}),i.addEventListener(\"parsedInitSegment\",_,I.signal),i.addEventListener(\"parsedMediaSegment\",_,I.signal),i.addEventListener(\"emptyQueue\",P,I.signal),i.addEventListener(\"requestRetry\",A=>{if(o.warning(A.error),I.signal.isCancelled())return;let x=A.segment,{index:B}=f;B.isSegmentStillAvailable(x)===!1?P():B.canBeOutOfSyncError(A.error,x)&&o.manifestMightBeOufOfSync()},I.signal),i.addEventListener(\"fullyLoadedSegment\",A=>{r.signalSegmentComplete(K({segment:A},n)).catch(M)},I.signal);let T=i.resetForContent(n,E);I.signal.register(()=>{i.stop()}),t.listen(P,{includeLastObservation:!1,clearSignal:I.signal}),n.manifest.addEventListener(\"manifestUpdate\",P,I.signal),d.onUpdate(P,{emitCurrentValue:!1,clearSignal:I.signal}),m.onUpdate(P,{emitCurrentValue:!1,clearSignal:I.signal}),a.onUpdate(P,{emitCurrentValue:!1,clearSignal:I.signal}),P();return;function P(){if(I.isUsed())return;let A=t.getReference().getValue(),x=A.position.getWanted(),B=ki(n,x,t,h.getValue(),d.getValue(),m.getValue(),r),{neededSegments:D}=B,V=null;if(f.index.isInitialized()){if(D.length>0&&!y.isLoaded&&y.segment!==null){let k=D[0].priority;V={segment:y.segment,priority:k}}}else if(y.segment===null)c.warn(\"Stream\",\"Uninitialized index without an initialization segment\",{bufferType:p,representationBitrate:n.representation.bitrate});else if(y.isLoaded)c.warn(\"Stream\",\"Uninitialized index with an already loaded initialization segment\",{bufferType:p,representationBitrate:n.representation.bitrate});else{let k=A.position.getWanted();V={segment:y.segment,priority:_n(u.start,k)}}let U=a.getValue();if(U===null)T.setValue({initSegment:V,segmentQueue:D});else if(U.urgent){c.debug(\"Stream\",\"Urgent switch, terminate now.\",{bufferType:p,representationBitrate:n.representation.bitrate}),T.setValue({initSegment:null,segmentQueue:[]}),T.finish(),I.cancel(),o.terminating();return}else{let k=D[0],w=i.getRequestedInitSegment(),N=i.getRequestedMediaSegment(),H=N===null||k===void 0||N.id!==k.segment.id?[]:[k],X=w===null?null:V;if(T.setValue({initSegment:X,segmentQueue:H}),H.length===0&&X===null){c.debug(\"Stream\",\"No request left, terminate\",{bufferType:p,representationBitrate:n.representation.bitrate}),T.finish(),I.cancel(),o.terminating();return}}if(o.streamStatusUpdate({period:u,position:A.position.getWanted(),bufferType:p,imminentDiscontinuity:B.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:B.hasFinishedLoading,neededSegments:B.neededSegments}),I.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:R}=L.getCurrent();if(B.isBufferFull){let k=Math.max(0,x-R);k>0&&r.removeBuffer(0,k).catch(M)}B.shouldRefreshManifest&&o.needsManifestRefresh()}function _(A){for(let x of A.protectionData)f.addProtectionData(x.initDataType,x.keyId,x.initData);if(!v){let x=f.getAllEncryptionData();x.length>0&&(o.encryptionDataEncountered(x.map(B=>K({content:n},B))),v=!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 x=f.uniqueId;y.uniqueId=x,r.declareInitSegment(x,A.initializationData),Mi({playbackObserver:t,bufferGoal:d,content:n,initSegmentUniqueId:x,segment:A.segment,segmentData:A.initializationData,segmentSink:r},I.signal).then(B=>{B!==null&&o.addedSegment(B)}).catch(M)}P();return}else{let{inbandEvents:x,predictedSegments:B,needsManifestRefresh:D}=A;if(B!==void 0&&f.index.addPredictedSegments(B,A.segment),D===!0&&(o.needsManifestRefresh(),I.isUsed())||x!==void 0&&x.length>0&&(o.inbandEvent(x),I.isUsed()))return;let V=y.uniqueId;Oi({playbackObserver:t,bufferGoal:d,content:n,initSegmentUniqueId:V,parsedSegment:A,segment:A.segment,segmentSink:r},I.signal).then(U=>{U!==null&&o.addedSegment(U)}).catch(M)}}function M(A){I.isUsed()&&A instanceof se||(c.warn(\"Stream\",\"Received fatal buffer error\",{bufferType:p,representationBitrate:n.representation.bitrate},A instanceof Error?A:null),I.cancel(),o.error(A))}}var ns=wi;function Di(n,e,t,r,i){var m,g,h,p;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let I of a)I.infos.period.id===n.id&&(I.infos.adaptation.id!==e.id||!ge(t.representationIds,I.infos.representation.id))&&It(o,{start:(m=I.bufferedStart)!=null?m:I.start,end:(g=I.bufferedEnd)!=null?g:I.end});let s=r.getPendingOperations();for(let I of s)if(I.type===0){let y=I.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!ge(t.representationIds,y.representation.id))){let E=y.segment.time,v=E+y.segment.duration;It(o,{start:E,end:v})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let I=i.getReadyState();if(I===void 0||I>1)return{type:\"needs-reload\",value:void 0}}let u=t.switchingMode===\"direct\",l=[],f=Vt(a,n);if(f!==null&&(f.bufferedEnd===void 0||n.start-f.bufferedEnd<1)&&l.push({start:0,end:n.start+1}),!u){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:I}=L.getCurrent(),y=e.type,E=(h=I[y].before)!=null?h:0,v=(p=I[y].after)!=null?p:0,T=i.getCurrentTime();T===void 0&&(T=i.getReference().getValue().position.getPolled()),l.push({start:T-E,end:T+v})}if(n.end!==void 0){let I=Wt(a,n);I!==null&&(I.bufferedStart===void 0||I.bufferedStart-n.end<1)&&l.push({start:n.end-1,end:Number.MAX_VALUE})}let d=Cr(o,l);return d.length===0?{type:\"continue\",value:void 0}:u?{type:\"flush-buffer\",value:d}:{type:\"clean-buffer\",value:d}}function Bi({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentQueueCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},u,l){let{manifest:f,period:d,adaptation:m}=e,g=new z;g.linkToSignal(l);let h=new Map,p=new $(null,g.signal),I,y=e.representations.getValue().representationIds,E=rs(e.adaptation.representations,y),v=new $(E,g.signal),{estimates:T,callbacks:P}=r({manifest:f,period:d,adaptation:m},p,v,n,g.signal),_=new $(!1);n.listen(R=>{var w;let k=(w=R.canStream)!=null?w:!0;_.getValue()===k&&(c.debug(\"Stream\",\"isMediaSegmentQueueInterrupted updated to\",!k),_.setValue(!k))},{clearSignal:g.signal});let M=a.createSegmentQueue(m.type,{onRequestBegin:P.requestBegin,onRequestEnd:P.requestEnd,onProgress:P.requestProgress,onMetrics:P.metrics},_),A=new $(0);T.onUpdate(({bitrate:R,knownStableBitrate:k})=>{t.enableFastSwitching&&A.setValueIfChanged(k),!(R===void 0||R===I)&&(I=R,c.debug(\"Stream\",`new ${m.type} bitrate estimate received from ABR`,{bitrate:R}),u.bitrateEstimateChange({type:m.type,bitrate:R}))},{emitCurrentValue:!0,clearSignal:g.signal});let x;e.representations.onUpdate(R=>{x!==void 0&&x.cancel();let k=e.representations.getValue().representationIds,w=rs(e.adaptation.representations,k);v.setValueIfChanged(w),x=new z,x.linkToSignal(g.signal),B(R,x.signal).catch(N=>{(x==null?void 0:x.isUsed())===!0&&z.isCancellationError(N)||(g.cancel(),u.error(N))})},{clearSignal:g.signal,emitCurrentValue:!0});return;async function B(R,k){let w=Di(d,m,R,i,n);switch(w.type){case\"continue\":break;case\"needs-reload\":return rt(()=>{n.listen(()=>{if(k.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:N}=L.getCurrent(),H=N.bitrateSwitch;return u.waitingMediaSourceReload({bufferType:m.type,period:d,timeOffset:H,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:k})});case\"flush-buffer\":case\"clean-buffer\":for(let N of w.value)if(await i.removeBuffer(N.start,N.end),k.isCancelled())return;if(w.type===\"flush-buffer\"&&(u.needsBufferFlush(),k.isCancelled()))return;break;default:Be(w)}D(k)}function D(R){let k=new z;k.linkToSignal(R);let{representation:w}=T.getValue();if(w===null)return;let N=new $(null,k.signal);T.onUpdate(q=>{if(!(q.representation===null||q.representation.id===w.id))return q.urgent?(c.info(\"Stream\",\"urgent Representation switch\",{bufferType:m.type,estimateBitrate:q.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:q.representation.bitrate}),N.setValue({urgent:!0})):(c.info(\"Stream\",\"slow Representation switch\",{bufferType:m.type,estimateBitrate:q.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:q.representation.bitrate}),N.setValue({urgent:!1}))},{clearSignal:k.signal,emitCurrentValue:!0});let H={type:m.type,adaptation:m,period:d,representation:w};if(p.setValue(w),R.isCancelled()||(u.representationChange(H),R.isCancelled()))return;let X={streamStatusUpdate:u.streamStatusUpdate,encryptionDataEncountered:u.encryptionDataEncountered,manifestMightBeOufOfSync:u.manifestMightBeOufOfSync,needsManifestRefresh:u.needsManifestRefresh,inbandEvent:u.inbandEvent,warning:u.warning,error(q){g.cancel(),u.error(q)},addedSegment(q){P.addedSegment(q)},terminating(){if(!k.isUsed())return k.cancel(),D(R)}};V(w,N,X,R)}function V(R,k,w,N){let H=!1,X=new z;X.linkToSignal(N);let q=tn(o,fe=>U(R,fe),X.signal),G=m.type===\"video\"?s:new $(1/0);c.info(\"Stream\",\"changing representation\",{bufferType:m.type,representationId:R.id,representationBitrate:R.bitrate});let Y=K({},w,{error(fe){var me;if(H){c.warn(\"Stream\",\"Ignoring RepresentationStream error\",fe);return}H=!0;let de=ce(fe,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(de.code!==\"BUFFER_FULL_ERROR\")w.error(fe);else{c.warn(\"Stream\",\"received BUFFER_FULL_ERROR\",{bufferType:m.type,representationBitrate:R.bitrate});let Qe=o.getValue(),ae=((me=h.get(R.id))!=null?me:1)*.7;if(h.set(R.id,ae),ae<=.05||U(R,Qe)<=2){w.error(de);return}ln(4e3,N).then(()=>V(R,k,w,N)).catch(O)}},terminating(){X.cancel(),w.terminating()}});ns({playbackObserver:n,content:{representation:R,adaptation:m,period:d,manifest:f},segmentSink:i,segmentQueue:M,terminate:k,options:{bufferGoal:q,maxBufferSize:G,drmSystemId:t.drmSystemId,fastSwitchThreshold:A}},Y,N),f.addEventListener(\"manifestUpdate\",fe=>{for(let de of fe.updatedPeriods)if(de.period.id===d.id){for(let me of de.result.updatedAdaptations)if(me.adaptation===m.id){for(let Qe of me.removedRepresentations)if(Qe===R.id)return N.isCancelled()?void 0:u.waitingMediaSourceReload({bufferType:m.type,period:d,timeOffset:0,stayInPeriod:!0})}}else if(de.period.start>d.start)break},N)}function U(R,k){let w=h.get(R.id),N=w!==void 0?w:1;return w===void 0&&h.set(R.id,N),N<1&&k===1/0?300*1e3*N:k*N}}function rs(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 is=Bi;function Ni(n,e,t,r,i,a){var g,h,p,I;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!Dd(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&&It(s,{start:(g=y.bufferedStart)!=null?g:y.start,end:(h=y.bufferedEnd)!=null?h: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 v=E.segment.time,T=v+E.segment.duration;It(s,{start:v,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 l=r===\"direct\",f=[],d=Vt(o,e);if(d!==null&&(d.bufferedEnd===void 0||e.start-d.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!l){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:E}=L.getCurrent(),v=(p=E[y].before)!=null?p:0,T=(I=E[y].after)!=null?I:0,P=i.getCurrentTime();P===void 0&&(P=i.getReference().getValue().position.getPolled()),f.push({start:P-v,end:P+T})}if(e.end!==void 0){let y=Wt(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=Cr(s,f);return m.length===0?{type:\"continue\",value:void 0}:l&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function Dd(n,e){return n.representations.some(t=>t.isPlayable()===!0&&Uo(t.getMimeTypeString(),e))}function Ui({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentQueueCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:u,maxVideoBufferSize:l},f,d){let{manifest:m,period:g}=e,h=new $(void 0,d);if(f.periodStreamReady({type:n,manifest:m,period:g,adaptationRef:h}),d.isCancelled())return;let p,I=!0;h.onUpdate(v=>{(async()=>{var U;if(v===void 0)return;let T=new z;if(T.linkToSignal(d),p==null||p.cancel(),p=T,v===null){c.info(\"Stream\",\"Set no Adaptation\",{periodStart:g.start,bufferType:n});let R=o.getStatus(n);if(R.type===\"initialized\"){if(c.info(\"Stream\",\"Clearing previous SegmentSink\",{periodStart:g.start,bufferType:n}),bt.isNative(n))return E(0,!0,T.signal);{let k=(U=g.end)!=null?U:1/0;if(g.start>k)c.warn(\"Stream\",\"Can't free buffer: period's start is after its end\",{periodStart:g.start,periodEnd:k,bufferType:n});else if(await R.value.removeBuffer(g.start,k),T.isUsed())return}}else if(R.type===\"uninitialized\"&&(o.disableSegmentSink(n),T.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:g}),T.isUsed()?void 0:as(r,u,n,{period:g},f,T.signal)}let P=g.adaptations[n],_=j(P!=null?P:[],R=>R.id===v.adaptationId);if(_===void 0){p.cancel(),c.warn(\"Stream\",\"Unfound chosen Adaptation choice\",{adaptationId:v.adaptationId});return}let{DELTA_POSITION_AFTER_RELOAD:M}=L.getCurrent(),A=!1,x;if(I)x=0;else if(v.relativeResumingPosition!==void 0)x=v.relativeResumingPosition;else switch(A=!0,n){case\"audio\":x=M.trackSwitch.audio;break;case\"video\":x=M.trackSwitch.video;break;default:x=M.trackSwitch.other;break}if(I=!1,bt.isNative(n)&&o.getStatus(n).type===\"disabled\")return E(x,!0,T.signal);m.addEventListener(\"manifestUpdate\",R=>{for(let k of R.updatedPeriods)if(k.period.id===g.id){for(let w of k.result.removedAdaptations)if(w.id===_.id)return E(x,!0,T.signal)}else if(k.period.start>g.start)break},p.signal);let{representations:B}=v;if(c.info(\"Stream\",\"Updating adaptation\",{bufferType:_.type,periodStart:g.start,adaptationId:_.id}),f.adaptationChange({type:n,adaptation:_,period:g}),T.isUsed())return;let D=Bd(o,n,_),V=Ni(D,g,_,v.switchingMode,r,s);if(V.type===\"needs-reload\")return E(x,!0,T.signal);if(await o.waitForUsableBuffers(T.signal),!T.isUsed()){if(V.type===\"flush-buffer\"||V.type===\"clean-buffer\"){for(let{start:R,end:k}of V.value)if(await D.removeBuffer(R,k),T.isUsed())return;if(V.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:x,relativePosHasBeenDefaulted:A}),T.isUsed()))return}t.get(D)(T.signal),y(_,B,D,T.signal)}})().catch(T=>{T instanceof se||(p==null||p.cancel(),f.error(T))})},{clearSignal:d,emitCurrentValue:!0});function y(v,T,P,_){let M=Ud(r,v.type);is({content:{manifest:m,period:g,adaptation:v,representations:T},options:s,playbackObserver:M,representationEstimator:i,segmentSink:P,segmentQueueCreator:a,wantedBufferAhead:u,maxVideoBufferSize:l},oe(J({},f),{error:A}),_);function A(x){if(!bt.isNative(n)){c.error(\"Stream\",`${n} Stream crashed. Aborting it.`,x instanceof Error?x:\"\"),o.disposeSegmentSink(n);let B=ce(x,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(B),_.isCancelled()?void 0:as(r,u,n,{period:g},f,_)}c.error(\"Stream\",`${n} Stream crashed. Stopping playback.`,x instanceof Error?x:\"\"),f.error(x)}}function E(v,T,P){rt(()=>{r.listen(()=>{P.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:g,timeOffset:v,stayInPeriod:T})},{includeLastObservation:!0,clearSignal:P})})}}function Bd(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return c.info(\"Stream\",\"Reusing a previous SegmentSink for the type\",{bufferType:e}),r.value;let i=Nd(t);return n.createSegmentSink(e,i)}function Nd(n){let e=n.representations.filter(t=>t.isPlayable()!==!1);if(e.length>0)return e[0].getMimeTypeString();if(n.representations.length>0)return n.representations[0].getMimeTypeString();throw new Z(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[vt(n)]})}function Ud(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new $(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let u=r.getValue(),l=u.buffered[e],f=l!==null?vr(l,u.position.getWanted()):0;return K({},u,{bufferGap:f,buffered:l})}function s(){a.setValue(o())}})}function as(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 l=n.getReference().getValue(),f=e.getValue(),d=l.position.getWanted();o.end!==void 0&&d+f>=o.end&&(c.debug(\"Stream\",'full \"empty\" AdaptationStream',{bufferType:t,periodEnd:o.end,position:d,wantedBufferAhead:f}),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:d,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var os=Ui;function Mr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory(),i=n.getPendingOperations();for(let a of r)if(e.some(s=>a.infos.period.id===s.period.id&&a.infos.adaptation.id===s.adaptation.id&&a.infos.representation.id===s.representation.id)){let{bufferedStart:s,bufferedEnd:u}=a;if(s===void 0||u===void 0)return c.warn(\"Stream\",\"No buffered start or end found from a segment.\",{bufferType:a.infos.adaptation.type,segmentStart:a.infos.segment.time}),[{start:0,end:Number.MAX_VALUE}];let l=t[t.length-1];l!==void 0&&l.end===s?l.end=u:t.push({start:s,end:u})}for(let a of i){if(a.type!==0)continue;let o=a.value;e.some(u=>o.inventoryInfos.period.id===u.period.id&&o.inventoryInfos.adaptation.id===u.adaptation.id&&o.inventoryInfos.representation.id===u.representation.id)&&It(t,{start:o.inventoryInfos.start,end:o.inventoryInfos.end})}return t}function Li(n,e,t,r,i,a,o,s){let{manifest:u,initialPeriod:l}=n,{maxBufferAhead:f,maxBufferBehind:d,wantedBufferAhead:m,maxVideoBufferSize:g}=a,{MINIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_AHEAD:p,MAXIMUM_MAX_BUFFER_BEHIND:I}=L.getCurrent(),y=new In(T=>{var A,x;let{bufferType:P}=T,_=(A=I[P])!=null?A:1/0,M=(x=p[P])!=null?x:1/0;return B=>{Ar({segmentSink:T,playbackObserver:e,maxBufferBehind:tn(d,D=>Math.min(D,_),B),maxBufferAhead:tn(f,D=>{var U;let V=Math.max(D,(U=h[P])!=null?U:0);return Math.min(V,M)},B)},B)}});for(let T of r.getBufferTypes())E(T,l);function E(T,P){let _=new kt((V,U)=>V.start-U.start),M=!1,A=new z;return A.linkToSignal(s),e.listen(({position:V})=>{let U=V.getWanted();if(!M||!B(U))return;let R=()=>{var w;return(w=u.getPeriodForTime(U))!=null?w:u.getNextPeriod(U)},k=R();if(!(!C(k)&&_.has(k))){for(c.info(\"Stream\",\"Destroying all PeriodStreams due to out of bounds situation\",{bufferType:T,time:U}),M=!1;_.length()>0;){let w=_.get(_.length()-1);_.removeElement(w),o.periodStreamCleared({type:T,manifest:u,period:w})}if(A.cancel(),A=new z,A.linkToSignal(s),k=R(),k===void 0){c.warn(\"Stream\",\"The wanted position is not found in the Manifest.\"),M=!0;return}x(k)}},{clearSignal:s,includeLastObservation:!0}),u.addEventListener(\"decipherabilityUpdate\",V=>{s.isCancelled()||D(V).catch(U=>{s.isCancelled()||(A.cancel(),o.error(U))})},s),x(P);function x(V){let U=oe(J({},o),{waitingMediaSourceReload(R){let k=_.head();k===void 0||k.id!==R.period.id?o.lockedStream({bufferType:R.bufferType,period:R.period}):o.needsMediaSourceReload({timeOffset:R.timeOffset,minimumPosition:R.stayInPeriod?R.period.start:void 0,maximumPosition:R.stayInPeriod?R.period.end:void 0})},periodStreamReady(R){M=!0,_.add(R.period),o.periodStreamReady(R)},periodStreamCleared(R){_.removeElement(R.period),o.periodStreamCleared(R)},error(R){A.cancel(),o.error(R)}});v(T,V,U,A.signal)}function B(V){let U=_.head(),R=_.last();return U===void 0||R===void 0?!0:U.start>V||(C(R.end)?1/0:R.end)<V}async function D(V){let U=r.getStatus(T),R=V.filter(q=>q.adaptation.type===T);if(R.length===0||U.type!==\"initialized\"||R.every(q=>q.representation.decipherable===!0))return;let k=U.value,w=R.filter(q=>q.representation.decipherable===void 0),N=R.filter(q=>q.representation.decipherable===!1),H=Mr(k,N),X=Mr(k,w);for(M=!1,c.info(\"Stream\",\"Destroying all PeriodStreams for decipherability matters\",{bufferType:T});_.length()>0;){let q=_.get(_.length()-1);_.removeElement(q),o.periodStreamCleared({type:T,manifest:u,period:q})}A.cancel(),A=new z,A.linkToSignal(s);for(let{start:q,end:G}of[...H,...X]){if(s.isCancelled())return;if(q<G){if(s.isCancelled())return;await k.removeBuffer(q,G)}}rt(()=>{if(s.isCancelled())return;let q=e.getReference().getValue();if(ss(q,H)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(ss(q,X)&&(o.needsBufferFlush(),s.isCancelled()))return;let G=q.position.getWanted(),Y=u.getPeriodForTime(G);if(Y===void 0&&(Y=u.getNextPeriod(G),c.warn(\"Stream\",\"No Period found for the reloading position, selecting next one instead\",{reloadPosition:G,nextPeriodStart:Y==null?void 0:Y.start})),Y===void 0&&(Y=u.periods[u.periods.length-1],c.warn(\"Stream\",\"No Period found for of after the reloading position, selecting the last one\",{reloadPosition:G,nextPeriodStart:Y==null?void 0:Y.start,nextPeriodEnd:Y==null?void 0:Y.end})),Y===void 0){o.error(new Z(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}x(Y)})}}function v(T,P,_,M){c.info(\"Stream\",\"Creating new PeriodStream\",{bufferType:T,periodStart:P.start});let A=null,x=new z;x.linkToSignal(M),e.listen(({position:R},k)=>{if(P.end!==void 0&&R.getWanted()>=P.end){let w=u.getPeriodAfter(P);if(P.containsTime(R.getWanted(),w))return;c.info(\"Stream\",\"Destroying PeriodStream as the current playhead moved above it\",{bufferType:T,periodStart:P.start,periodEnd:P.end,position:R.getWanted()}),k(),_.periodStreamCleared({type:T,manifest:u,period:P}),x.cancel()}},{clearSignal:M,includeLastObservation:!0});let B={bufferType:T,content:{manifest:u,period:P},garbageCollectors:y,maxVideoBufferSize:g,segmentQueueCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},D=oe(J({},_),{streamStatusUpdate(R){if(R.hasFinishedLoading){let k=u.getPeriodAfter(P);k!==null&&V(k)}else A!==null&&(c.info(\"Stream\",\"Destroying next PeriodStream due to current one being active\",{bufferType:T,periodStart:P.start,nextPeriodStart:A.period.start}),_.periodStreamCleared({type:T,manifest:u,period:A.period}),A.canceller.cancel(),A=null);_.streamStatusUpdate(R)},error(R){A!==null&&(A.canceller.cancel(),A=null),x.cancel(),_.error(R)}});os(B,D,x.signal),U(x.signal);function V(R){if(A!==null){if(A.period.id===R.id)return;c.warn(\"Stream\",\"Creating next `PeriodStream` while one was already created.\",{bufferType:T,nextPeriodStart:R.start}),_.periodStreamCleared({type:T,manifest:u,period:A.period}),A.canceller.cancel()}let k=new z;k.linkToSignal(M),A={canceller:k,period:R},v(T,R,_,A.canceller.signal)}function U(R){u.addEventListener(\"manifestUpdate\",k=>{for(let w of k.removedPeriods)if(w.id===P.id){if(u.periods.length>0&&u.periods[0].start<=w.start)return rt(()=>{if(!R.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(w.start>P.start)break;if(k.addedPeriods.length>0&&A!==null){let w=u.getPeriodAfter(P);(w===null||A.period.id!==w.id)&&(c.warn(\"Stream\",\"Destroying next PeriodStream due to new one being added\",{bufferType:T,nextPeriodStart:A.period.start}),_.periodStreamCleared({type:T,manifest:u,period:A.period}),A.canceller.cancel(),A=null)}},R)}}}function ss(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 us=Li;var ds=us;function Fi(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return c.warn(\"mse\",\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}function Ld(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Pn(n,e){if(c.debug(\"mse\",\"Trying to call endOfStream\"),n.readyState!==\"open\"){c.debug(\"mse\",\"MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=Ld(t);if(r.length===0){c.info(\"mse\",\"Triggering end of stream\");try{n.endOfStream()}catch(a){c.error(\"mse\",\"Unable to call endOfStream\",a instanceof Error?a:new Error(\"Unknown error\"))}return}c.debug(\"mse\",\"Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new z;i.linkToSignal(e);for(let a of r)Po(a,()=>{i.cancel(),Pn(n,e)},i.signal);vo(t,()=>{i.cancel(),Pn(n,e)},i.signal)}function ls(n,e){let t=new z;t.linkToSignal(e),Ft(n,()=>{c.debug(\"mse\",\"MediaSource re-opened while end-of-stream is active\"),t.cancel(),t=new z,t.linkToSignal(e),Pn(n,t.signal)},e),Pn(n,t.signal)}function zi(){let{FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:n}=L.getCurrent();return n||mi.device===mi.DEVICES.PlayStation5}var Fd=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 z;let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Wd(r,i),o=new z;o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(),!a.getValue())return;o=new z,o.linkToSignal(i);let u=Vd(r.sourceBuffers,o.signal),l=new z;return l.linkToSignal(o.signal),u.onUpdate(f=>{l.cancel(),l=new z,l.linkToSignal(o.signal),!f&&ms(r,e,t,l.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)}};function zd(n,e,t){let r=e;t||(r=zi()?1/0:fs(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(i,o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{c.info(\"mse\",\"Updating duration to what is currently buffered\",{maxBufferedEnd:i}),n.duration=i}catch(a){return c.warn(\"mse\",\"Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(c.info(\"mse\",\"Updating duration\",{newDuration:r}),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=fs(e);c.info(\"mse\",\"calling `mediaSource.setLiveSeekableRange`\",{maxSeekable:s}),n.setLiveSeekableRange(0,s)}}catch(s){return c.warn(\"mse\",\"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 Vd(n,e){if(n.length===0){let i=new $(!1);return i.finish(),i}let t=new $(!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 Wd(n,e){let t=new $(n.readyState===\"open\",e);return Ft(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),Sr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),yr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function ms(n,e,t,r){if(zd(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),ms(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function fs(n){return Math.max(Math.pow(2,32),n+Fd)}var Cn=class extends le{constructor(e,t){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new z,C(mt))throw new Z(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"mse\",\"Creating MediaSource\");let r=t!==void 0?new t:new mt,i=r.handle;this.handle=C(i)?{type:\"media-source\",value:r}:{type:\"handle\",value:i},this._mediaSource=r,this.readyState=r.readyState,this._durationUpdater=new vn(r),this._endOfStreamCanceller=null,Ft(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),Sr(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),yr(r,()=>{this.readyState=r.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 Vi(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 z,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"mse\",\"end-of-stream order received.\"),ls(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"mse\",\"resume-stream order received.\"),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),qd(this._mediaSource)}},Vi=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new z,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(\"mse\",\"receiving order to push data to the SourceBuffer\",{type:this.type}),this._addToQueue({operationName:0,params:e})}remove(e,t){return c.debug(\"mse\",\"receiving order to remove data from the SourceBuffer\",{type:this.type,start:e,end:t}),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return vi(this._sourceBuffer.buffered)}catch(e){return c.error(\"mse\",\"Failed to get buffered time range of SourceBuffer\",{type:this.type},e instanceof Error?e:\"Unknown Error\"),[]}}abort(){try{this._sourceBuffer.abort()}catch(e){c.debug(\"mse\",\"Failed to abort SourceBuffer:\",e instanceof Error?e:\"Unknown Error\")}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(\"mse\",\"error for an unknown operation\",t);else{let i=new xe(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(vi(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=K({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],l=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 d=[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],h=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],p=(a=u.timestampOffset)!=null?a:0,I=(o=m.params[1].timestampOffset)!=null?o:0;if(g[0]===h[0]&&g[1]===h[1]&&u.codec===m.params[1].codec&&p===I){let y=m.params[0],E;y instanceof ArrayBuffer?E=new Uint8Array(y):y instanceof Uint8Array?E=y:E=new Uint8Array(y.buffer),d.push(E),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:m.resolve,reject:m.reject})}else break}d.length>1&&(c.info(\"mse\",`: Merging ${d.length} segments together for perf`,{type:this.type}),l=At(...d).buffer)}try{this._appendBufferNow(l,u)}catch(f){let d=f instanceof Error?new xe(f.name,f.message,f.name===\"QuotaExceededError\"):new xe(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(m=>{m.reject(d)}),this._currentOperations=[],this._performNextOperation()}}else{this._currentOperations=[e];let[s,u]=e.params;c.debug(\"mse\",\"removing data from SourceBuffer\",{type:this.type,start:s,end:u});try{this._sourceBuffer.remove(s,u)}catch(l){let f=l instanceof Error?new xe(l.name,l.message,!1):new xe(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(f),this._currentOperations.forEach(d=>{d.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(\"mse\",\"updating codec\",{prevCodec:this.codec,newCodec:i}),Fi(r,i)?this.codec=i:c.debug(\"mse\",\"could not update codec\",{prevCodec:this.codec,newCodec:i})),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"mse\",\"updating timestampOffset\",{codec:i,prevTimestampOffset:r.timestampOffset,newTimestampOffset:s}),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"mse\",\"re-setting `appendWindowStart`\",{prevWindowStart:r.appendWindowStart}),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;c.debug(\"mse\",\"pre-updating `appendWindowEnd`\",{prevWindowEnd:r.appendWindowEnd,newWindowEnd:s}),r.appendWindowEnd=s}c.debug(\"mse\",\"setting `appendWindowStart`\",{appendWindowStart:o[0]}),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"mse\",\"re-setting `appendWindowEnd`\",{prevWindowStart:r.appendWindowStart}),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"mse\",\"setting `appendWindowEnd`\",{prevWindowEnd:r.appendWindowEnd,newWindowEnd:o[1]}),r.appendWindowEnd=o[1]),c.debug(\"mse\",\"pushing segment\",{type:this.type}),r.appendBuffer(e)}};function qd(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(\"mse\",\"Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}c.info(\"mse\",\"Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&c.info(\"mse\",\"Not all SourceBuffers could have been removed.\")}}var Gd=Me(),Or=Me(),cs=1/0,An=class extends le{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new z,this.readyState=\"closed\",this._messageSender=r;let i=Gd();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 Wi(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})}},Wi=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new z,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(\"mse\",\"unknown SourceBuffer operation succeeded\"):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new se:new xe(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"mse\",\"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>=cs){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=Or();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>=cs){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=Or();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=Or();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=Or();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 qi(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 Ue=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 xn=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 Ue(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\",{bitrate: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 ps=6e3,Hd=15e3,Kd=3e3,jd=1e3,Yd=9e3,kn=class{constructor(e){this._levelsMap=qi(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=ps,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(C(a)){this._currentEstimate=r[0];return}let u=-1;for(let h=0;h<r.length;h++){let p=r[h];if(p===a)u=h;else if(p>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 l;o!==void 0&&(l=s===0?o.score:o.score/s);let f=isFinite(i)?i:0,d=F();if(f<t[u]||l!==void 0&&l<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:d-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Yd){let I=this._blockRaiseDelay+Kd;c.debug(\"ABR\",\"Incrementing blocking raise in BufferBasedChooser due to unstable quality\",{prevDelay:this._blockRaiseDelay,newDelay:I}),this._blockRaiseDelay=Math.min(I,Hd)}else{let I=this._blockRaiseDelay-jd;c.debug(\"ABR\",\"Lowering quality in BufferBasedChooser\",{prevDelay:this._blockRaiseDelay,newDelay:I}),this._blockRaiseDelay=Math.max(ps,I)}this._lastUnsuitableQualityTimestamp=d;let p=ne(r,I=>I===a);for(let I=p-1;I>=0;I--)if(f>=t[I]){this._currentEstimate=r[I];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&d-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||l===void 0||l<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[u],g=(()=>{for(let h=u+1;h<t.length;h++)if(t[h]>m)return h})();if(g!==void 0){let h=t[g];if(i>=h){c.debug(\"ABR\",\"Raising quality in BufferBasedChooser\",{bitrate:r[g]}),this._currentEstimate=r[g];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function Qd(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 wr(n){if(n.progress.length<5)return;let e=new Ue(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 gs(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function $d(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,u=isFinite(a)?a:0,l=s.getWanted()+u,f=Qd(n,l);if(f.length!==1)return;let d=f[0],m=F(),g=d.content.segment.duration*1.5;if(g=Math.min(g,3e3),g=Math.max(g,12e3),m-d.requestTimestamp<g)return;let h=d.progress.length>0?d.progress[d.progress.length-1]:void 0,p=wr(d);if(h!==void 0&&p!==void 0){let P=gs(h,p);if((m-h.timestamp)/1e3<=P&&P-u/o>2500)return p}if(!d.content.segment.complete)return;let I=d.content.segment.duration,y=(m-d.requestTimestamp)/1e3,E=y<=(I*1.5+2)/o;if(C(t)||E)return;let v=I/y,T=t.bitrate*Math.min(.7,v);if(i===void 0||T<i)return T}function Xd(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=j(e,({content:d})=>d.segment.duration>0&&d.segment.time+d.segment.duration>i);if(a===void 0)return!0;let o=F(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=wr(a);if(s===void 0||u===void 0)return!0;let l=gs(s,u);return(o-s.timestamp)/1e3>l*1.2?!0:l-r/n.speed>-1.5}var Mn=class{constructor(e,t){let{ABR_STARVATION_GAP:r,OUT_OF_STARVATION_GAP:i,ABR_STARVATION_FACTOR:a,ABR_REGULAR_FACTOR:o}=L.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:l,position:f,duration:d}=e,m=isFinite(l)?l:0,{ABR_STARVATION_DURATION_DELTA:g}=L.getCurrent();return isNaN(d)||m+f.getWanted()<d-g?!this._inStarvationMode&&m<=u.starvationGap?(c.info(\"ABR\",\"enter starvation mode.\",{buffergap:m,enterStarvation:u.starvationGap}),this._inStarvationMode=!0):this._inStarvationMode&&m>=u.outOfStarvationGap&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m,outOfStarvation:u.starvationGap}),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m}),this._inStarvationMode=!1),this._inStarvationMode&&(s=$d(i,e,r,this._lowLatencyMode,a),s!==void 0&&(c.info(\"ABR\",\"starvation mode emergency estimate:\",{bandwidth:s}),t.reset(),o=C(r)?s:Math.min(s,r.bitrate))),C(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:Xd(i,r,this._lowLatencyMode)}};var On=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 wn=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 l=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(l===void 0)return null;if(this._canGuessHigher(o,s,l)){let d=hs(e,r);if(d!==null)return d}return null}if(this._isLastGuessValidated(u,i,l)&&(c.debug(\"ABR\",\"Guessed Representation validated\",{chosenBitrate:u.bitrate,otherAbrAlgosBitrate:i,scoreData:l==null?void 0:l.score,scoreConfidence:l==null?void 0:l.confidenceLevel}),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),r.id!==u.id)return u;if(this._shouldStopGuess(r,l,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=F()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),Zd(e,r);if(l===void 0)return r;if(this._canGuessHigher(o,s,l)){let d=hs(e,r);if(d!==null)return d}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&F()>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=F();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 l=wr(s);if(l!==void 0&&l<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 hs(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 Zd(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 Dn=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=L.getCurrent();this._fastEWMA=new Ue(e),this._slowEWMA=new Ue(t),this._bytesSampled=0}addSample(e,t){let{ABR_MINIMUM_CHUNK_SIZE:r}=L.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}=L.getCurrent();if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())}reset(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=L.getCurrent();this._fastEWMA=new Ue(e),this._slowEWMA=new Ue(t),this._bytesSampled=0}};function Gi(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 Hi(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 l,f;return((l=s.width)!=null?l: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 Bn=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(C(t)){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: progress for a request not added\");c.warn(\"ABR\",\"progress for a request not added\",{requestId:e.id});return}t.progress.push(e)}remove(e){if(C(this._currentRequests[e])){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: can't remove unknown request\");c.warn(\"ABR\",\"can't remove unknown request\",{requestId:e})}delete this._currentRequests[e]}getRequests(){return hr(this._currentRequests).filter(e=>!C(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Dr(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 Is=new $(void 0);Is.finish();var bs=new $(1/0);bs.finish();function Ki(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,u,l,f,d){var I,y,E;let{type:m}=s.adaptation,g=a(m),h=(I=t[m])!=null?I:0,p={limitResolution:(y=r.limitResolution[m])!=null?y:Is,throttleBitrate:(E=r.throttleBitrate[m])!=null?E:bs};return Jd({bandwidthEstimator:g,context:s,currentRepresentation:u,filters:p,initialBitrate:h,playbackObserver:f,representations:l,lowLatencyMode:i},d)};function a(o){let s=e[o];if(C(s)){c.debug(\"ABR\",\"Creating new BandwidthEstimator\",{bufferType:o});let u=new Dn;return e[o]=u,u}return s}}function Jd({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},u){let l=new xn,f=new Mn(i!=null?i:0,a),d=new Bn,m=O,g={metrics:E,requestBegin:v,requestProgress:T,requestEnd:P,addedSegment(_){m(_)}},h=new z;h.linkToSignal(u);let p=I(s.getValue(),h.signal);return s.onUpdate(y,{clearSignal:u}),{estimates:p,callbacks:g};function I(_,M){if(_.length<=1)return new $({bitrate:void 0,representation:_[0],urgent:!0,knownStableBitrate:void 0});let A=!1,x=_.sort((N,H)=>N.bitrate-H.bitrate),B=new kn(x.map(N=>N.bitrate)),D=new On,V=new wn(l,D),U=o.getReference().getValue(),R=new $(w());return o.listen(N=>{U=N,k()},{includeLastObservation:!1,clearSignal:M}),m=function(N){if(U===null)return;let{position:H,speed:X}=U,q=N.buffered,G=vr(q,H.getWanted()),{representation:Y}=N.content,fe=l.getEstimate(Y),de=Y.bitrate,me={bufferGap:G,currentBitrate:de,currentScore:fe,speed:X};B.onAddedSegment(me),k()},M.register(()=>{m=O}),r.throttleBitrate.onUpdate(k,{clearSignal:M}),r.limitResolution.onUpdate(k,{clearSignal:M}),R;function k(){R.setValue(w())}function w(){let{bufferGap:N,position:H,maximumPosition:X}=U,q=r.limitResolution.getValue(),G=r.throttleBitrate.getValue(),Y=t.getValue(),fe=el(x,q,G),de=d.getRequests(),{bandwidthEstimate:me,bitrateChosen:Qe}=f.getBandwidthEstimate(U,n,Y,de,D.bandwidth),te=l.getLastStableRepresentation(),ae=te===null?void 0:te.bitrate/(U.speed>0?U.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:Xt,ABR_EXIT_BUFFER_BASED_ALGO:Zt}=L.getCurrent();A&&N<=Zt?A=!1:!A&&isFinite(N)&&N>=Xt&&(A=!0);let _e=Dr(fe,Qe),Jt=B.getLastEstimate(),ur=_e.bitrate,dt=null;A&&Jt!==void 0&&Jt>ur&&(dt=Dr(fe,Jt),ur=dt.bitrate);let lt=null;return a&&Y!==null&&e.manifest.isDynamic&&X-H.getWanted()<40&&(lt=V.getGuess(x,U,Y,ur,de)),lt!==null&&lt.bitrate>ur?(c.debug(\"ABR\",\"new guess-based estimate\",{bitrate:lt.bitrate,representation:lt.id}),D.update(lt,me,2),{bitrate:me,representation:lt,urgent:Y===null||lt.bitrate<Y.bitrate,knownStableBitrate:ae}):dt!==null?(c.debug(\"ABR\",\"new buffer-based estimate\",{bitrate:dt.bitrate,representation:dt.id}),D.update(dt,me,0),{bitrate:me,representation:dt,urgent:f.isUrgent(dt.bitrate,Y,de,U),knownStableBitrate:ae}):(c.debug(\"ABR\",\"new bandwidth estimate\",{bitrate:_e.bitrate,representation:_e.id}),D.update(_e,me,1),{bitrate:me,representation:_e,urgent:f.isUrgent(_e.bitrate,Y,de,U),knownStableBitrate:ae})}}function y(){let _=s.getValue();h.cancel(),h=new z,h.linkToSignal(u),I(_,h.signal).onUpdate(function(x){p.setValue(x)},{clearSignal:h.signal,emitCurrentValue:!0})}function E(_){let{requestDuration:M,segmentDuration:A,size:x,content:B}=_;if(n.addSample(M,x),!B.segment.isInit){let{segment:D,representation:V}=B;if(A===void 0&&!D.complete)return;let U=A!=null?A:D.duration;l.addSample(V,M/1e3,U)}}function v(_){d.add(_)}function T(_){d.addProgress(_)}function P(_){d.remove(_.id)}}function el(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Gi(r,t)),e!==void 0&&(r=Hi(r,e)),r}var ys=Ki;function Br(){var t;if(typeof((t=ee.crypto)==null?void 0:t.randomUUID)==\"function\")return ee.crypto.randomUUID();let n=new Date().getTime(),e=F();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 tl=/^(?:[a-z]+:)?\\/\\//i,nl=/^(?:([^:/?#]+):)?(?:\\/\\/([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Yi(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(tl.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Yi(n.substring(0,t)):e+1}function Ss(n,e){let t=Nr(n),r=Nr(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=Un(t.path),a=Un(r.path),o;if(i===a)o=\"\";else{let u=i.split(\"/\");u.pop();let l=a.split(\"/\");for(;u.length>0&&l.length>0&&u[0]===l[0];)u.shift(),l.shift();for(;u.length>0;)u.shift(),l.unshift(\"..\");let f=l.join(\"/\");(f.endsWith(\"../\")||f.endsWith(\"./\"))&&(f=f.slice(0,f.length-1)),o=f===\"\"?\".\":f}let s=o;return o===\"\"&&r.query===t.query||Q(r.query)&&(s+=\"?\",s+=r.query),Q(r.fragment)&&(s+=\"#\",s+=r.fragment),s}function rl(n,e){let t=Nr(n),r=Nr(e);if(Q(r.scheme))return ji(r);let i={scheme:t.scheme,authority:t.authority,path:\"\",query:r.query,fragment:r.fragment};return Q(r.authority)?(i.authority=r.authority,i.path=Un(r.path),ji(i)):(r.path===\"\"?(i.path=t.path,Q(r.query)||(i.query=t.query)):Oe(r.path,\"/\")?i.path=Un(r.path):i.path=Un(al(t,r.path)),ji(i))}var Nn=new Map,il=200;function Nr(n){var r,i,a,o,s;if(Nn.has(n))return Nn.get(n);let e=n.match(nl),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:\"\"},Nn.size>=il&&Nn.clear(),Nn.set(n,t),t}function ji(n){let e=\"\";return Q(n.scheme)&&(e+=n.scheme+\":\"),Q(n.authority)&&(e+=\"//\"+n.authority),e+=n.path,Q(n.query)&&(e+=\"?\"+n.query),Q(n.fragment)&&(e+=\"#\"+n.fragment),e}function Un(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 al(n,e){if(Q(n.authority)&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function Ln(...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=rl(o,s),l=e.slice(2);return Ln(u,...l)}}var ol=4,Fn=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Br(),this._contentId=(r=e.contentId)!=null?r:Br(),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 z,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,l;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\"),!C(e.nextSegment)&&e.segment.url!==null&&e.nextSegment.url!==null&&(!e.nextSegment.isInit||e.nextSegment.indexRange===void 0)){let f=e.segment.url,d=e.nextSegment.url,m=Ss(f,d);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(!C(f)){let d=(l=(u=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?u:t.position.getWanted())!=null?l:t.position.getPolled();for(let m of f)if(d>=m.start&&d<m.end){i=(m.end-d)*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 d=e.representation.bitrate*e.segment.duration/1e3/(a/1e3);r.rtp=Math.floor(Math.round(d*ol/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,d)=>d.isPlayable()!==!0?f:f===void 0?Math.round(d.bitrate/1e3):Math.max(f,Math.round(d.bitrate/1e3)),void 0),this._producePayload(r)}_producePayload(e){let t={object:\"\",request:\"\",session:\"\",status:\"\"},r=\"\",i=(l,f)=>{this._typePreference===0?t[f]+=l:r+=l},a=(l,f)=>{let d=e[l];if(d!==void 0){let m=`${l}=${String(d)},`;i(m,f)}},o=(l,f)=>{if(e[l]===!0){let d=`${l},`;i(d,f)}},s=(l,f)=>{let d=e[l];if(d!==void 0){let g=`prop=${`\"${d.replace(\"\\\\\",\"\\\\\\\\\").replace('\"','\\\\\"')}\"`},`;i(g,f)}},u=(l,f)=>{let d=e[l];if(d!==void 0){let m=`prop=${d},`;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\",{queryString:r}),{type:\"query\",value:[[\"CMCD\",r]]})}};var Ts=Fn;var zn=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=Es(this._downgradedCdnList.metadata,e);t>=0&&this._removeIndexFromDowngradeList(t);let{DEFAULT_CDN_DOWNGRADE_TIME:r}=L.getCurrent(),i=r;this._downgradedCdnList.metadata.push(e);let a=setTimeout(()=>{let o=Es(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 Es(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 Le(n){return n instanceof ue?new Xe(\"PIPELINE_LOAD_ERROR\",n):ce(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function sl(n){return n instanceof ue?n.type===Pt.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===Pt.TIMEOUT||n.type===Pt.ERROR_EVENT:n instanceof $e?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:Ut(n)&&n.code===\"INTEGRITY_ERROR\"}async function Vn(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(\"utils\",\"No CDN given to `scheduleRequestWithCdns`.\");let l=new Map,f=d();if(f===void 0)throw new Error(\"No CDN to request\");return m(f);function d(){if(n===null){let I=l.get(null);return I!==void 0&&I.isBlacklisted?void 0:null}else{if(e===null)return p(n);{let I=e.getCdnPreferenceForResource(n);return p(I)}}}async function m(I){try{return await t(I,i)}catch(y){if(z.isCancellationError(y))throw y;I!==null&&e!==null&&e.downgradeCdn(I);let E=l.get(I);if(E===void 0?(E={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},l.set(I,E)):E.errorCounter++,!sl(y))return E.blockedUntil=void 0,E.isBlacklisted=!0,g(y);if(E.errorCounter>s)E.blockedUntil=void 0,E.isBlacklisted=!0;else{let v=E.errorCounter,T=Math.min(a*Math.pow(2,v-1),o),P=Ri(T);E.blockedUntil=F()+P}return g(y)}}async function g(I){let y=d();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw I;if(u(I),i.isCancelled())throw i.cancellationError;return h(y,I)}function h(I,y){let E=l.get(I);if(E===void 0||E.blockedUntil===void 0)return m(I);let v=F(),T=E.blockedUntil-v;if(T<=0)return m(I);let P=new z,_=P.linkToSignal(i);return new Promise((M,A)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let D=d();if(i.isCancelled())throw i.cancellationError;if(D===void 0)return B(y);D!==I&&(P.cancel(),h(D,y).then(x,B))},P.signal),ln(T,P.signal).then(()=>m(I).then(x,B),O);function x(D){_(),M(D)}function B(D){_(),A(D)}})}function p(I){var E;if(l.size===0)return I[0];let y=F();return(E=I.filter(v=>{var T;return((T=l.get(v))==null?void 0:T.isBlacklisted)!==!0}).reduce((v,T)=>{var _;let P=(_=l.get(T))==null?void 0:_.blockedUntil;return P!==void 0&&P<=y&&(P=void 0),v===void 0?[T,P]:v[1]===void 0?v:P===void 0?[T,void 0]:P<v[1]?[T,P]:v},void 0))==null?void 0:E[0]}}function Qi(n,e,t){return Vn(null,null,n,e,t)}var Wn=class extends le{constructor(e,t,r){super(),this.scheduleManualRefresh=O,this._manifestUrls=e,this._pipelines=t.manifest,this._transportName=t.transportName,this._settings=r,this._canceller=new z,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 ht?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 l;let t=this._canceller.signal,r=this._settings,i=this._transportName,a=this._pipelines,o=e!=null?e:(l=this._manifestUrls)==null?void 0:l[0],s=this._getBackoffSetting(f=>{this.trigger(\"warning\",Le(f))});try{let f=await u(o);return{parse:d=>this._parseLoadedManifest(f,d,o)}}catch(f){throw Le(f)}function u(f){var I;let{loadManifest:d}=a,m=r.requestTimeout===void 0?L.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,g=r.connectionTimeout===void 0?L.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;m<0&&(m=void 0),g<0&&(g=void 0);let h={timeout:m,connectionTimeout:g,cmcdPayload:(I=r.cmcdDataBuilder)==null?void 0:I.getCmcdDataForManifest(i)};return Qi(()=>d(f,h,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 p;let i=F(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:u}=e,l=this._getBackoffSetting(I=>{this.trigger(\"warning\",Le(I))}),f=r!=null?r:(p=this._manifestUrls)==null?void 0:p[0],d={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:f};try{let I=this._pipelines.parseManifest(e,d,g,a,m);if(ul(I)){let{manifest:y}=await I;return h(y)}else return h(I.manifest)}catch(I){throw ce(I,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(I){try{return await Qi(I,l,a)}catch(y){throw Le(y)}}function g(I){for(let y of I){if(a.isCancelled())return;let E=ce(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",E)}}function h(I){let y=F()-i;return c.info(\"MF\",`Manifest parsed in ${y}ms`),{manifest:I,sendingTime:s,receivedTime:u,parsingTime:y}}}_getBackoffSetting(e){let{DEFAULT_MAX_MANIFEST_REQUEST_RETRY:t,INITIAL_BACKOFF_DELAY_BASE:r,MAX_BACKOFF_DELAY_BASE:i}=L.getCurrent(),{lowLatencyMode:a,maxRetry:o}=this._settings,s=a?r.LOW_LATENCY:r.REGULAR,u=a?i.LOW_LATENCY:i.REGULAR,l=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:u,maxRetry:l}}_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}=L.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 l=t===void 0?0:F()-t,f=Math.max(this._settings.minimumManifestUpdateInterval-l,0),d=new z;if(d.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:g,delay:h,canUseUnsafeMode:p}=m,I=p&&u,y=t===void 0?0:F()-t,E=Math.max(this._settings.minimumManifestUpdateInterval-y,0),v=setTimeout(()=>{d.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:g,unsafeMode:I})},Math.max((h!=null?h:0)-y,E));d.signal.register(()=>{clearTimeout(v)})},e.expired!==null){let m=setTimeout(()=>{var g;(g=e.expired)==null||g.then(()=>{d.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},O)},f);d.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-l,g;s===void 0?g=m:e.lifetime<3&&s>=100?(g=Math.min(Math.max(3e3-l,Math.max(m,0)+s),m*6),c.info(\"MF\",\"Manifest update rythm is too frequent. Postponing next request.\",{regularRefreshDelay:m,newRefreshDelay:g})):s>=e.lifetime*1e3/10?(g=Math.min(Math.max(m,0)+s,m*6),c.info(\"MF\",\"Manifest took too long to parse. Postponing next request\",{regularRefreshDelay:m,newRefreshDelay:g})):g=m;let h=setTimeout(()=>{d.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},Math.max(g,f));d.signal.register(()=>{clearTimeout(h)})}}_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(\"MF\",'Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(c.info(\"MF\",'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:l,sendingTime:f,parsingTime:d}=u,m=F();if(a)e.replace(l);else try{e.update(l)}catch(h){let p=h instanceof Error?h.message:\"unknown error\";c.warn(\"MF\",`Attempt to update Manifest failed: ${p}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:I}=L.getCurrent(),y=f===void 0?0:F()-f,E=Math.max(this._settings.minimumManifestUpdateInterval-y,0),v=O,T=setTimeout(()=>{v(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(I-y,E));v=this._canceller.signal.register(()=>{clearTimeout(T)});return}let g=F()-m;this._recursivelyRefreshManifest(e,{sendingTime:f,parsingTime:d,updatingTime:g})}).catch(u=>{this._isRefreshPending=!1,this._onFatalError(u)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose())}};function ul(n){return n instanceof Promise}var $i=Wn;function Xi(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=l=>e(r,a,l),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(\"SF\",\"Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Zi=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}},_s=Zi;var dl=Me();function Ji({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 _s:void 0,{loadSegment:l,parseSegment:f}=e;return async function(m,g,h){var H,X,q;let{segment:p,adaptation:I,representation:y,manifest:E,period:v}=m,T=Ge(m),P=dl(),_,M=[],A=0,x=!1,B={segment:p,type:I.type,language:I.language,isLive:E.isLive,periodStart:v.start,periodEnd:v.end,mimeType:y.mimeType,codecs:y.codecs[0],manifestPublishTime:E.publishTime},D={onProgress(G){var Y;_===void 0&&G.totalSize!==void 0&&G.size<G.totalSize&&((Y=i.onProgress)==null||Y.call(i,{duration:G.duration,size:G.size,totalSize:G.totalSize,timestamp:F(),id:P}))},onNewChunk(G){g.onChunk(k(G,!0))}},V=u!==void 0?u.get(m):null;if(V!==null)return c.debug(\"SF\",\"Found wanted segment in cache\",T),g.onChunk(k(V,!1)),Promise.resolve();c.debug(\"SF\",\"Beginning request\",T),(H=i.onRequestBegin)==null||H.call(i,{requestTimestamp:F(),id:P,content:m}),h.register(U);try{let G=await Vn(m.representation.cdnMetadata,t,R,K({onRetry:w},a),h);if(G.resultType===\"segment-loaded\"){let Y=G.resultData.responseData;u!==void 0&&u.add(m,G.resultData.responseData),g.onChunk(k(Y,!1))}else G.resultType===\"segment-created\"&&g.onChunk(k(G.resultData,!1));c.debug(\"SF\",\"Segment request ended with success\",T),g.onAllChunksReceived(),G.resultType!==\"segment-created\"?(_=G.resultData,N()):_=null,h.isCancelled()||(X=i.onRequestEnd)==null||X.call(i,{id:P}),h.deregister(U)}catch(G){throw h.deregister(U),_=null,G instanceof se?(c.debug(\"SF\",\"Segment request aborted\",T),G):(c.debug(\"SF\",\"Segment request failed\",T),(q=i.onRequestEnd)==null||q.call(i,{id:P}),Le(G))}function U(){var G;_===void 0&&(c.debug(\"SF\",\"Segment request cancelled\",T),_=null,(G=i.onRequestEnd)==null||G.call(i,{id:P}))}function R(G){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(m),l(G,B,s,h,D)}function k(G,Y){M.push(!1);let fe=M.length-1;return function(me){let Qe={data:G,isChunked:Y};try{let te=f(Qe,B,me);return M[fe]||(A=A!==void 0&&te.segmentType===\"media\"&&te.chunkInfos!==null&&te.chunkInfos.duration!==void 0?A+te.chunkInfos.duration:void 0,M[fe]=!0,N()),te}catch(te){throw ce(te,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function w(G){g.onRetry(Le(G))}function N(){var G;x||!C(_)&&_.size!==void 0&&_.requestDuration!==void 0&&M.length>0&&M.every(Y=>Y)&&(x=!0,(G=i.onMetrics)==null||G.call(i,{size:_.size,requestDuration:_.requestDuration,content:m,segmentDuration:A}))}}}function Rs({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}=L.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 qn=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 $({initSegment:null,segmentQueue:[]}),i=new z;i.signal.register(()=>{r.finish()});let a={content:e,downloadQueue:r,initSegmentInfoRef:t?new $(void 0):new $(null),currentCanceller:i,initSegmentRequest:null,mediaSegmentRequest:null,mediaSegmentAwaitingInitMetadata:null};return this._currentContentInfo=a,this.isMediaSegmentQueueInterrupted.onUpdate(s=>{s||(c.debug(\"SF\",\"Media segment can be loaded again, restarting queue.\",{type: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 l=a.mediaSegmentRequest;if(u.length===0){if(l===null)return;c.debug(\"SF\",\"no more media segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(a);return}else if(l===null){c.debug(\"SF\",\"Media segments now need to be requested. Starting queue.\",{type:e.adaptation.type,queueLength:u.length}),this._restartMediaSegmentDownloadingQueue(a);return}else{let f=u[0];if(l.segment.id!==f.segment.id){c.debug(\"SF\",\"Next media segment changed, cancelling previous\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(a);return}l.priority!==f.priority&&(c.debug(\"SF\",\"Priority of next media segment changed, updating\",{type:e.adaptation.type,prevPriority:l.priority,newPriority:f.priority}),this._segmentFetcher.updatePriority(l.request,f.priority));return}},{emitCurrentValue:!0,clearSignal:i.signal}),r.onUpdate(s=>{var l;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(((l=s.initSegment)==null?void 0:l.segment.id)===(u==null?void 0:u.segment.id))return;s.initSegment===null&&c.debug(\"SF\",\"no more init segment to request. Cancelling queue.\",{type: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 v;if(this.isMediaSegmentQueueInterrupted.getValue()){c.debug(\"SF\",\"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 l=new z,f=a===null?O:l.linkToSignal(a.signal),{segment:d,priority:m}=u,g=K({segment:d,nextSegment:(v=s[1])==null?void 0:v.segment},r),h=!1,p=!1;l.signal.register(()=>{e.mediaSegmentRequest=null,!h&&(e.mediaSegmentAwaitingInitMetadata===d.id&&(e.mediaSegmentAwaitingInitMetadata=null),h=!0,p=!1)});let I=T=>{Ie(T.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",K({},T,{segment:d}))},y=()=>{let T=t.getValue().segmentQueue;if(T.length===0){h=!0,this.trigger(\"emptyQueue\",null);return}else T[0].segment.id===d.id&&T.shift();h=!0,o()},E=this._segmentFetcher.createRequest(g,m,{onRetry:T=>{this.trigger(\"requestRetry\",{segment:d,error:T})},beforeInterrupted(){c.info(\"SF\",\"segment request interrupted temporarly.\",{segmentId:d.id,segmentTime:d.time})},onChunk:T=>{let P=i.getValue();P!==void 0?I(T(P!=null?P:void 0)):(p=!0,i.waitUntilDefined(_=>{I(T(_!=null?_:void 0))},{clearSignal:l.signal}))},onAllChunksReceived:()=>{p?(e.mediaSegmentAwaitingInitMetadata=d.id,i.waitUntilDefined(()=>{e.mediaSegmentAwaitingInitMetadata=null,p=!1,this.trigger(\"fullyLoadedSegment\",d)},{clearSignal:l.signal})):this.trigger(\"fullyLoadedSegment\",d)},beforeEnded:()=>{f(),e.mediaSegmentRequest=null,p?i.waitUntilDefined(y,{clearSignal:l.signal}):y()}},l.signal);E.catch(T=>{f(),h||(h=!0,this.stop(),this.trigger(\"error\",T))}),e.mediaSegmentRequest={segment:d,priority:m,request:E,canceller:l}};o()}_restartInitSegmentDownloadingQueue(e,t){let{content:r,initSegmentInfoRef:i}=e;if(e.initSegmentRequest!==null&&e.initSegmentRequest.canceller.cancel(),t===null)return;let a=new z,o=e.currentCanceller===null?O:a.linkToSignal(e.currentCanceller.signal),{segment:s,priority:u}=t,l=K({segment:s,nextSegment:void 0},r),f=!1,d=this._segmentFetcher.createRequest(l,u,{onRetry:m=>{this.trigger(\"requestRetry\",{segment:s,error:m})},beforeInterrupted:()=>{c.info(\"SF\",\"init segment request interrupted temporarly.\",{segmentId:s.id})},beforeEnded:()=>{o(),e.initSegmentRequest=null,f=!0},onChunk:m=>{var h;let g=m(void 0);Ie(g.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",K({},g,{segment:s})),g.segmentType===\"init\"&&i.setValue((h=g.initTimescale)!=null?h:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",s)}},a.signal);d.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:d,canceller:a}}};var Hn=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"The max high level priority should be given a lowerpriority number than the min low priority.\")}create(e,t,r,i){let a;return Ct(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let l=()=>{g(),this._endTask(a)},f=h=>{r.beforeEnded(),l(),o(h)},d=h=>{l(),s(h)},m=new z,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(h=>{!i.isCancelled()&&m.isUsed()&&h instanceof se||d(h)})},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(\"SF\",\"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(\"SF\",\"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(\"SF\",\"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 Kn=class{constructor(e,t,r,i){let{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=L.getCurrent();this._transport=e,this._prioritizer=new Hn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=t,this._backoffOptions=i,this._cmcdDataBuilder=r}createSegmentQueue(e,t,r){let i=Rs(this._backoffOptions),a=this._transport[e],o=Ji({bufferType:e,pipeline:a,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:i}),s=Xi(this._prioritizer,o);return new qn(s,r)}};var ea=Kn;function ta(n,e){let{loadThumbnail:t}=n,r=[];return async function(a,o){o.register(E);let s,u=j(r,({thumbnailContext:P})=>P.period.id===a.period.id&&P.track.id===a.track.id&&P.segment.id===a.segment.id);if(u!==void 0){c.debug(\"Thumbnails\",\"Requesting same thumbnail than the pending one\",{time:a.segment.time}),s=u,s.referenceCount++;let P;try{P=await s.promise}catch(_){throw o.deregister(E),_}return o.deregister(E),P}let{segment:l,track:f}=a,d=ll({}),m;d.connectionTimeout===void 0||d.connectionTimeout<0?m=void 0:m=d.connectionTimeout;let g={timeout:d.requestTimeout<0?void 0:d.requestTimeout,connectionTimeout:m,cmcdPayload:void 0},h=new z,p=y();s={thumbnailContext:a,promise:p,referenceCount:1},r.push(s);let I=()=>{let P=r.indexOf(s);P>=0&&r.splice(P,1)};try{let P=await p;return I(),P}catch(P){throw I(),P}async function y(){c.debug(\"Thumbnails\",\"Beginning thumbnail request\",{time:l.time});let P;try{if(P=await Vn(f.cdnMetadata,e,v,K({onRetry:T},d),h.signal),o.isCancelled())return Promise.reject(o.cancellationError);c.debug(\"Thumbnails\",\"Thumbnail request ended with success\",{time:l.time}),o.deregister(E)}catch(_){throw o.deregister(E),_ instanceof se?(c.debug(\"Thumbnails\",\"Thumbnail request aborted\",{time:l.time}),_):(c.debug(\"Thumbnails\",\"Thumbnail request failed\",{time:l.time}),Le(_))}try{return n.parseThumbnail(P.responseData,{thumbnail:l,thumbnailTrack:f})}catch(_){throw ce(_,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}function E(){c.debug(\"Thumbnails\",\"Thumbnail request cancelled\",{time:l.time});let P=r.indexOf(s);P<0||(r[P].referenceCount--,r[P].referenceCount<=0&&(h.cancel(),r.splice(P,1)))}function v(P){return t(P,l,g,o)}function T(P){let _=Le(P);c.warn(\"Thumbnails\",\"Thumbnail request retry \",{time:l.time},_)}}}function ll({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}=L.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}}var jn=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(\"text\",\"pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"text\",\"remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}};var Ps=6,na=4e3,Ur=6e3,fl=6e4,Gt=class{constructor(e){this._segmentSinksStore=e,this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=null,this._lastFlushAttempt=null,this._lastSegmentInfo={audio:[],video:[]}}onNewObservation(e){var I,y;let t=F();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}=L.getCurrent(),{readyState:o,rebuffering:s,freezing:u,fullyLoaded:l}=e,f=e.position.getPolled(),d=vs(e.bufferGap);if(!(u!==null||o===1&&(d>=Ps||l)))return this._decipherabilityFreezeStartingTimestamp=null,null;let g=(y=(I=u==null?void 0:u.timestamp)!=null?I:s==null?void 0:s.timestamp)!=null?y:null;if(c.info(\"Freeze\",\"Freeze detected\",{freezeStart:g,timeFrozen: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+Ur,E}let p=this._checkForDecipherabilityRelatedFreeze(e,t);return p!==null?p:g!==null&&t-g>r?(this._lastFlushAttempt={timestamp:t,position:f+i},c.debug(\"Freeze\",\"Trying to flush to un-freeze\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Ur,{type:\"flush\",value:{relativeSeek:i}}):null}_checkForDecipherabilityRelatedFreeze(e,t){let{readyState:r,rebuffering:i,freezing:a,fullyLoaded:o}=e,s=vs(e.bufferGap),u=i!==null&&t-i.timestamp>na,{hasUndecipherableData:l,hasEncryptedData:f}=ml(this._segmentSinksStore);if(l===!0)return c.warn(\"Freeze\",\"we have undecipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Ur,{type:\"reload\",value:null};let d=a!==null&&t-a.timestamp>na;return(u||d)&&(s>=Ps||o)&&r<=1?this._decipherabilityFreezeStartingTimestamp===null&&(c.debug(\"Freeze\",\"Start of a potential decipherability freeze detected\"),this._decipherabilityFreezeStartingTimestamp=t):this._decipherabilityFreezeStartingTimestamp=null,this._decipherabilityFreezeStartingTimestamp!==null&&F()-this._decipherabilityFreezeStartingTimestamp>na&&f&&l===!1?(c.warn(\"Freeze\",\"we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Ur,{type:\"reload\",value:null}):null}_getStrategyIfFlushingFails(e){c.warn(\"Freeze\",\"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 l=i[u];if(l.segment===null){s=l;break}else if(l.segment.infos.representation.uniqueId!==o.infos.representation.uniqueId&&a.timestamp-l.timestamp<5e3){s=l;break}else l.segment.start===o.start&&e-l.position<3e3&&(a=l)}if(s===void 0||s.segment===null)c.debug(\"Freeze\",\"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(\"Freeze\",\"Freeze when switching Period, reloading\"),{type:\"reload\",value:null};o.infos.representation.uniqueId!==s.segment.infos.representation.uniqueId&&(c.warn(\"Freeze\",\"Freeze when switching Representation, avoiding\",{bitrate: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(\"Freeze\",\"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-fl,l;for(l=0;l<this._lastSegmentInfo[o].length&&!(this._lastSegmentInfo[o][l].timestamp>u);l++);l>0&&this._lastSegmentInfo[o].splice(0,l)}}};function ml(n){let e=!0,t=!0;for(let r of[\"audio\",\"video\"]){let i=n.getStatus(r);if(i.type===\"initialized\")for(let a of i.value.getLastKnownInventory()){let{representation:o}=a.infos;if(o.decipherable===!1)return{hasUndecipherableData:!0,hasEncryptedData:!0};o.contentProtections!==void 0&&(t=!1,o.decipherable!==!0&&(e=!1))}}return{hasEncryptedData:!t,hasUndecipherableData:e?!1:void 0}}function vs(n){return n!==void 0&&isFinite(n)?n:0}var Yn=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,u,l,f,d,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=(l=this._refs.get(g))==null?void 0:l.text)==null||f.trackReference.finish(),(m=(d=this._refs.get(g))==null?void 0:d.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(\"Track\",\"Track for periodId already declared\",{periodId:e,bufferType:t}),(s=i[t])==null||s.trackReference.finish(),(u=i[t])==null||u.representations.finish());let a=r.getValue(),o;C(a)?o=new $({representationIds:[],switchingMode:\"lazy\"}):(o=new $(a.representations.getValue()),r.setValue(K({},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(\"Track\",\"Setting track for inexistent periodId\",{periodId:e,bufferType:t}),!1):(C(r)?(i.representations=new $({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new $(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(\"Track\",\"Setting track for inexistent periodId\",{periodId:e,bufferType:r}),!1;let o=a.trackReference.getValue();return C(o)||o.adaptationId!==t?(c.debug(\"Track\",\"Desynchronized Adaptation id\",{oldId:o==null?void 0:o.adaptationId,newId: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(\"Track\",\"Removing track setter for inexistent periodId\",{periodId:e,bufferType:t}),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};function ve(n){return ce(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var Cs=Me(),Ht=class{constructor({hasVideo:e}){this._currentContent=null,this._currentMediaSourceCanceller=new z,this._hasVideo=e;let t=new z;this._contentCanceller=t}initializeNewContent(e,t,r){return new Promise((i,a)=>{var w,N;this.disposeCurrentContent();let o=this._contentCanceller,s=new z;this._currentMediaSourceCanceller=s,s.linkToSignal(o.signal);let{contentId:u,url:l,hasText:f,transportOptions:d,useMseInWorker:m,enableRepresentationAvoidance:g,transport:h}=t,p=null,I=ke.transports[h];if(typeof I!=\"function\"){a(new Error(`transport \"${h}\" not supported. Did you add the corresponding feature?`));return}let y=typeof d.representationFilter==\"string\"?bo(d.representationFilter):d.representationFilter,E=I(oe(J({},d),{representationFilter:y})),v=t.cmcd===void 0?null:new Ts(t.cmcd),T=new $i(l===void 0?void 0:[l],E,J({cmcdDataBuilder:v},t.manifestRetryOptions)),P=ys({initialBitrates:{audio:(w=t.initialAudioBitrate)!=null?w:0,video:(N=t.initialVideoBitrate)!=null?N:0},lowLatencyMode:d.lowLatencyMode,throttlers:r}),_=s.signal.register(H=>{a(H)}),M=new zn(o.signal),A=new ea(E,M,v,t.segmentRetryOptions),x=ta(E.thumbnails,M),B=new Yn,[D,V,U]=As(e,u,{useMseInWorker:m,hasVideo:this._hasVideo,hasText:f},s.signal),R=new Gt(V);this._currentContent={cmcdDataBuilder:v,contentId:u,enableRepresentationAvoidance:g,freezeResolver:R,mediaSource:D,manifest:null,manifestFetcher:T,representationEstimator:P,segmentSinksStore:V,segmentQueueCreator:A,fetchThumbnailData:x,coreTextSender:U,trackChoiceSetter:B,useMseInWorker:m},D.addEventListener(\"mediaSourceOpen\",function(){k()},s.signal),o.signal.register(()=>{T.dispose()}),T.addEventListener(\"warning\",H=>{e({type:\"warning\",contentId:u,value:ve(H)})},o.signal),T.addEventListener(\"manifestReady\",H=>{if(p!==null){c.warn(\"Core\",\"Multiple `manifestReady` events, ignoring\");return}p=H,this._currentContent!==null&&(this._currentContent.manifest=p),k()},s.signal),T.addEventListener(\"error\",H=>{e({type:\"error\",contentId:u,value:ve(H)}),a(H)},o.signal),T.start();function k(){p===null||D.readyState===\"closed\"||s.isUsed()||(cl(p),p.addEventListener(\"manifestUpdate\",H=>{p!==null&&e({type:\"manifest-update\",contentId:u,value:{manifest:p,updates:H}})},o.signal),_(),i(p))}})}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 z;let[t,r,i]=As(e,this._currentContent.contentId,{useMseInWorker:this._currentContent.useMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.coreTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.freezeResolver=new Gt(r),this._currentContent.coreTextSender=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 z}};function As(n,e,t,r){let i;if(t.useMseInWorker){let u=new Cn(Cs());i=u;let l,f=u.handle;if(f.type===\"handle\")l={type:\"handle\",value:f.value};else{let d=URL.createObjectURL(f.value);l={type:\"url\",value:d},r.register(()=>{URL.revokeObjectURL(d)})}n({type:\"attach-media-source\",contentId:e,value:l,mediaSourceId:i.id},[f.value])}else i=new An(Cs(),e,n);let a=t.hasText?new jn(e,n):null,{hasVideo:o}=t,s=new bt(i,o,a);return r.register(()=>{s.disposeAll(),a==null||a.stop(),i.dispose()}),[i,s,a]}function cl(n){var t,r;if(C(mt))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 l=mt.isTypeSupported(u);s.isCodecSupportedInWebWorker=l,e.set(u,l)}}}}var Qn=class extends le{constructor(e,t,r){super(),this._canceller=new z,this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new ra(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;rt(()=>{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:!1,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 kt((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)}},ra=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=Lr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Lr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Lr(this._lastAudioAdaptation),t=Lr(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=Fr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=Fr(this._lastAudioAdaptation))!=null?t:void 0;{let r=Fr(this._lastAudioAdaptation),i=Fr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Lr(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=C(t)?a:Math.min(t,a))}return t}function Fr(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=C(t)?a:Math.min(t,a))}return t}function ia(n,e,t,r,i,a){a.register(()=>{e.interruptDurationSetting()});let o=new Qn(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(\"mse\",\"Start applying end-of-stream order.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function aa(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}async function oa(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({segment:s,track:o,period:a},new z().signal)}function sa(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 ua(n,e){let{DEFAULT_WANTED_BUFFER_AHEAD:t,DEFAULT_MAX_VIDEO_BUFFER_SIZE:r,DEFAULT_MAX_BUFFER_AHEAD:i,DEFAULT_MAX_BUFFER_BEHIND:a}=L.getCurrent(),o={wantedBufferAhead:new $(t),maxVideoBufferSize:new $(r),maxBufferAhead:new $(i),maxBufferBehind:new $(a),limitVideoResolution:new $({height:void 0,width:void 0,pixelRatio:1}),throttleVideoBitrate:new $(1/0)},s=!1,u=new Ht({hasVideo:!0}),l=null,f=null;n(d=>{var g,h;c.debug(\"Core\",\"received message\",{name:d.data.type});let m=d.data;switch(m.type){case\"init\":{Ie(!s),s=!0,ro(m.value),xs(m.value.logLevel,m.value.logFormat,m.value.sendBackLogs);let p=ke.dashParsers.wasm;p!==null&&m.value.dashWasmUrl!==void 0&&p.isCompatible()&&p.initialize({wasmUrl:m.value.dashWasmUrl}).catch(I=>{let y=I instanceof Error?I.toString():\"Unknown Error\";c.error(\"Core\",\"Could not initialize DASH_WASM parser\",y)}),m.value.hasVideo||(u.disposeCurrentContent(),u=new Ht({hasVideo:m.value.hasVideo})),e({type:\"init-success\",value:null})}break;case\"log-level-update\":xs(m.value.logLevel,m.value.logFormat,m.value.sendBackLogs);break;case\"prepare\":pl(e,u,m.value,o);break;case\"start\":{let p=u.getCurrentContent();if(m.contentId!==(p==null?void 0:p.contentId))return;l==null||l.stop(),f==null||f.finish();let I=new $(K(m.value.initialObservation,{position:new xt(...m.value.initialObservation.position)}));f=I,l=hl(e,m.value,u,I,o);break}case\"observation\":{let p=u.getCurrentContent();if(m.contentId!==(p==null?void 0:p.contentId))return;let I=m.value,{buffered:y}=I,E=aa(p.mediaSource,null);E.audio!==null&&(y.audio=E.audio),E.video!==null&&(y.video=E.video),f==null||f.setValue(K(I,{position:new xt(...m.value.position)}));break}case\"ref-update\":gl(m,o);break;case\"stop\":if(m.contentId!==((g=u.getCurrentContent())==null?void 0:g.contentId))return;u.disposeCurrentContent(),l==null||l.stop(),l=null,f==null||f.finish(),f=null;break;case\"ms-reload\":{let p=u.getCurrentContent();if(m.mediaSourceId!==(p==null?void 0:p.mediaSource.id))return;l==null||l.signalMediaSourceReload()}break;case\"sb-success\":{let p=u.getCurrentContent();if(m.mediaSourceId!==(p==null?void 0:p.mediaSource.id))return;let{sourceBuffers:I}=p.mediaSource,y=j(I,E=>E.type===m.sourceBufferType);if(y===void 0){c.info(\"Core\",\"Success for an unknown SourceBuffer\",{sourceBufferType:m.sourceBufferType});return}if(y.onOperationSuccess===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:m.sourceBufferType});return}y.onOperationSuccess(m.operationId,m.value.buffered);break}case\"sb-error\":{let p=u.getCurrentContent();if(m.mediaSourceId!==(p==null?void 0:p.mediaSource.id))return;let{sourceBuffers:I}=p.mediaSource,y=j(I,E=>E.type===m.sourceBufferType);if(y===void 0){c.info(\"Core\",\"Error for an unknown SourceBuffer\",{sourceBufferType:m.sourceBufferType});return}if(y.onOperationFailure===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:m.sourceBufferType});return}y.onOperationFailure(m.operationId,m.value);break}case\"media-source-ready-state-change\":{let p=u.getCurrentContent();if(m.mediaSourceId!==(p==null?void 0:p.mediaSource.id))return;if(p.mediaSource.onMediaSourceReadyStateChanged===void 0){c.warn(\"Core\",\"A MediaSourceInterface with MSE performed a cross-thread operation\");return}p.mediaSource.onMediaSourceReadyStateChanged(m.value);break}case\"decipherability-update\":{if(m.contentId!==((h=u.getCurrentContent())==null?void 0:h.contentId))return;let p=u.getCurrentContent();if(p===null||p.manifest===null)return;let I=m.value;p.manifest.updateRepresentationsDeciperability(y=>{for(let E of I)if(y.representation.uniqueId===E.representationUniqueId)return E.decipherable;return y.representation.decipherable});break}case\"codec-support-update\":{let p=u.getCurrentContent();if(p===null||p.manifest===null)return;let I=m.value;try{let y=p.manifest.updateCodecSupport(I);y!==null&&e({type:\"warning\",contentId:p.contentId,value:ve(y)})}catch(y){e({type:\"error\",contentId:p.contentId,value:ve(y)})}break}case\"urls-update\":{let p=u.getCurrentContent();if(p===null||p.contentId!==m.contentId)return;p.manifestFetcher.updateContentUrls(m.value.urls,m.value.refreshNow);break}case\"track-update\":{let p=u.getCurrentContent();if(p===null||p.contentId!==m.contentId)return;p.trackChoiceSetter.setTrack(m.value.periodId,m.value.bufferType,m.value.choice);break}case\"rep-update\":{let p=u.getCurrentContent();if(p===null||p.contentId!==m.contentId)return;p.trackChoiceSetter.updateRepresentations(m.value.periodId,m.value.adaptationId,m.value.bufferType,m.value.choice);break}case\"add-text-success\":{let p=u.getCurrentContent();if(p===null||p.contentId!==m.contentId)return;if(p.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}p.coreTextSender.onPushedTrackSuccess(m.value.ranges);break}case\"push-text-error\":{let p=u.getCurrentContent();if(p===null||p.contentId!==m.contentId)return;if(p.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}p.coreTextSender.onPushedTrackError(new Error(m.value.message));break}case\"remove-text-success\":{let p=u.getCurrentContent();if(p===null||p.contentId!==m.contentId)return;if(p.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}p.coreTextSender.onRemoveSuccess(m.value.ranges);break}case\"remove-text-error\":{let p=u.getCurrentContent();if(p===null||p.contentId!==m.contentId)return;if(p.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}p.coreTextSender.onRemoveError(new Error(m.value.message));break}case\"pull-segment-sink-store-infos\":{Il(e,u,m.value.requestId);break}case\"thumbnail-request\":{yl(e,u,m);break}case\"config-update\":{L.update(m.value);break}default:Be(m)}})}function pl(n,e,t,r){e.initializeNewContent(n,t,{limitResolution:{video:r.limitVideoResolution},throttleBitrate:{video:r.throttleVideoBitrate}}).then(i=>{n({type:\"manifest-ready\",contentId:t.contentId,value:{manifest:i}})},i=>{n({type:\"error\",contentId:t.contentId,value:ve(i)})})}function gl(n,e){switch(n.value.name){case\"wantedBufferAhead\":e.wantedBufferAhead.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":e.maxVideoBufferSize.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":e.maxBufferBehind.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":e.maxBufferAhead.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":e.limitVideoResolution.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":e.throttleVideoBitrate.setValueIfChanged(n.value.newVal);break;default:Be(n.value)}}function hl(n,e,t,r,i){c.debug(\"Core\",\"Loading pepared content.\");let a=new z,o=null;return s(e.initialTime),{signalMediaSourceReload:()=>l(),stop:()=>{a.cancel()}};function s(f){var U;o==null||o.cancel(),o=new z,o.linkToSignal(a.signal);let d=new Map,m=t.getCurrentContent();if(m===null||m.manifest===null){let R=new Ee(\"NONE\",\"Loading content when none is prepared\");throw n({type:\"error\",contentId:void 0,value:ve(R)}),R}let{contentId:g,cmcdDataBuilder:h,enableRepresentationAvoidance:p,manifest:I,mediaSource:y,representationEstimator:E,segmentSinksStore:v,segmentQueueCreator:T}=m,{drmSystemId:P,enableFastSwitching:_,onCodecSwitch:M}=e;r.onUpdate(R=>{sa(R,v);let k=m.freezeResolver.onNewObservation(R);k!==null&&bl(n,k,{contentId:g,manifest:I,handleMediaSourceReload:u,enableRepresentationAvoidance:p})},{clearSignal:o.signal});let A=(U=I.getPeriodForTime(f))!=null?U:I.getNextPeriod(f);if(A===void 0){let R=new Z(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");throw n({type:\"error\",contentId:g,value:ve(R)}),R}let x=new hn(r,g,n,o.signal);h==null||h.startMonitoringPlayback(x),o.signal.register(()=>{h==null||h.stopMonitoringPlayback()});let B=ia(I,y,x,v,{onWarning:R=>n({type:\"warning\",contentId:g,value:ve(R)}),onPeriodChanged:R=>{n({type:\"active-period-changed\",contentId:g,value:{periodId:R.id}})}},o.signal);ds({initialPeriod:A,manifest:I},x,E,v,T,{wantedBufferAhead:i.wantedBufferAhead,maxVideoBufferSize:i.maxVideoBufferSize,maxBufferAhead:i.maxBufferAhead,maxBufferBehind:i.maxBufferBehind,drmSystemId:P,enableFastSwitching:_,onCodecSwitch:M},D(),o.signal);function D(){return{needsBufferFlush(R){n({type:\"needs-buffer-flush\",contentId:g,value:R})},streamStatusUpdate(R){V(R),I.isLastPeriodKnown&&R.period.id===I.periods[I.periods.length-1].id&&(R.hasFinishedLoading||R.isEmptyStream?B.onLastSegmentFinishedLoading(R.bufferType):B.onLastSegmentLoadingResume(R.bufferType))},needsManifestRefresh(){t.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:R}=L.getCurrent();t.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:R})},lockedStream(R){n({type:\"locked-stream\",contentId:g,value:{periodId:R.period.id,bufferType:R.bufferType}})},adaptationChange(R){var k,w;B.onAdaptationChange(R.type,R.period,R.adaptation),!(o===null||o.signal.isCancelled())&&n({type:\"adaptation-changed\",contentId:g,value:{adaptationId:(w=(k=R.adaptation)==null?void 0:k.id)!=null?w:null,periodId:R.period.id,type:R.type}})},representationChange(R){var k,w;B.onRepresentationChange(R.type,R.period),!(o===null||o.signal.isCancelled())&&n({type:\"representation-changed\",contentId:g,value:{adaptationId:R.adaptation.id,representationId:(w=(k=R.representation)==null?void 0:k.id)!=null?w:null,periodId:R.period.id,type:R.type}})},inbandEvent(R){n({type:\"inband-event\",contentId:g,value:R})},warning(R){n({type:\"warning\",contentId:g,value:ve(R)})},periodStreamReady(R){m!==null&&(m.trackChoiceSetter.addTrackSetter(R.period.id,R.type,R.adaptationRef),n({type:\"period-stream-ready\",contentId:g,value:{periodId:R.period.id,bufferType:R.type}}))},periodStreamCleared(R){if(m===null)return;let k=d.get(R.period);k!==void 0&&(k.delete(R.type),k.size===0&&d.delete(R.period)),B.onPeriodCleared(R.type,R.period),m.trackChoiceSetter.removeTrackSetter(R.period.id,R.type),n({type:\"period-stream-cleared\",contentId:g,value:{periodId:R.period.id,bufferType:R.type}})},bitrateEstimateChange(R){var k;m!==null&&((k=m.cmcdDataBuilder)==null||k.updateThroughput(R.type,R.bitrate)),n({type:\"bitrate-estimate-change\",contentId:g,value:{bitrate:R.bitrate,bufferType:R.type}})},needsMediaSourceReload(R){u(R)},needsDecipherabilityFlush(){n({type:\"needs-decipherability-flush\",contentId:g,value:null})},encryptionDataEncountered(R){for(let k of R){let w=k.content,N=J({},w);N.manifest instanceof ht&&(N.manifest=N.manifest.getMetadataSnapshot()),N.period instanceof gt&&(N.period=N.period.getMetadataSnapshot()),N.adaptation instanceof ft&&(N.adaptation=N.adaptation.getMetadataSnapshot()),N.representation instanceof dn&&(N.representation=N.representation.getMetadataSnapshot()),n({type:\"encryption-data-encountered\",contentId:g,value:{keyIds:k.keyIds,values:k.values,content:N,type:k.type}})}},error(R){n({type:\"error\",contentId:g,value:ve(R)})}}}function V(R){let{imminentDiscontinuity:k}=R,w=d.get(R.period),N=w==null?void 0:w.get(R.bufferType);if(N!==void 0){if(N.discontinuity===null){if(k===null)return}else if(k!==null&&N.discontinuity.start===k.start&&N.discontinuity.end===k.end)return}w===void 0&&(w=new Map,d.set(R.period,w));let H={periodId:R.period.id,bufferType:R.bufferType,discontinuity:R.imminentDiscontinuity,position:R.position};w.set(R.bufferType,H),n({type:\"discontinuity-update\",contentId:g,value:H})}}function u(f){var m;o!==null&&(o.cancel(),o=null);let d=(m=t.getCurrentContent())==null?void 0:m.mediaSource.id;if(d===void 0){c.warn(\"Core\",\"Cannot reload MediaSource: no MediaSource currently.\");return}c.debug(\"Core\",\"Reloading MediaSource\",{timeOffset:f.timeOffset,minimumPosition:f.minimumPosition,maximumPosition:f.maximumPosition}),n({type:\"reloading-media-source\",mediaSourceId:d,value:f},[]),l()}function l(){var g;let d=r.getValue().position.getWanted();o!==null&&(o.cancel(),o=null);let m=(g=t.getCurrentContent())==null?void 0:g.contentId;t.reloadMediaSource(n).then(()=>{c.info(\"Core\",\"MediaSource Reloaded, loading content again\",{newInitialTime:d}),s(d)},h=>{if(z.isCancellationError(h)){c.info(\"Core\",\"A reloading operation was cancelled\");return}n({type:\"error\",contentId:m,value:ve(h)})})}}function xs(n,e,t){t?c.setLevel(n,\"standard\",(r,i,a)=>{let o=a.map(s=>s instanceof Error?ve(s):s);postMessage({type:\"log\",value:{namespace:i,logLevel:r,logs:o}})}):c.setLevel(n,e)}function Il(n,e,t){let r=e.getCurrentContent();if(r===null)return;let i=r.segmentSinksStore.getSegmentSinksMetrics();n({type:\"segment-sink-store-update\",contentId:r.contentId,value:{segmentSinkMetrics:i,requestId:t}})}function bl(n,e,{contentId:t,manifest:r,handleMediaSourceReload:i,enableRepresentationAvoidance:a}){switch(e.type){case\"reload\":{c.info(\"Core\",\"Planning reload due to freeze\"),i({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}case\"flush\":{c.info(\"Core\",\"Flushing buffer due to freeze\"),n({type:\"needs-buffer-flush\",contentId:t,value:{relativeResumingPosition:e.value.relativeSeek,relativePosHasBeenDefaulted:!1}});break}case\"avoid-representations\":{c.info(\"Core\",\"Planning Representation avoidance due to freeze\");let o=e.value;a&&r.addRepresentationsToAvoid(o),i({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}default:Be(e)}}function yl(n,e,t){let r=e.getCurrentContent(),i=a=>{n({type:\"thumbnail-response\",contentId:t.contentId,value:{status:\"error\",requestId:t.value.requestId,error:ve(a)}})};if(r===null||r.manifest===null||r.contentId!==t.contentId)return i(new Error(\"Content changed\"));oa(r.fetchThumbnailData,r.manifest,t.value.periodId,t.value.thumbnailTrackId,t.value.time).then(a=>{n({type:\"thumbnail-response\",contentId:t.contentId,value:{status:\"success\",requestId:t.value.requestId,data:a}},[a.data])},a=>i(a))}var ks=ua;var Sl=new Rt,zr=Sl;var Tl=\"<\",El=60,Ms=\">\",Vr=62,da=45,Os=47,_l=33,ws=39,Ds=34,la=91,Rl=93,Pl=`\\r\n\t>/= `;function fa(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=d())!==-1;)t=n.lastIndexOf(\"<\",t),t!==-1&&a.push(l()),n=n.substring(t),t=0;else a=o(\"\");return e.filter!==void 0&&(a=Bs(a,e.filter)),a;function o(h){let p=[];for(;n[t]!==void 0;)if(n.charCodeAt(t)===El){if(n.charCodeAt(t+1)===Os){let y=t+2;if(t=n.indexOf(Ms,t),n.substring(y,t).indexOf(h)===-1){let v=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(v.length-1)+`\nColumn: `+(v[v.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),p}else if(n.charCodeAt(t+1)===_l){if(n.charCodeAt(t+2)===da){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===Vr&&n.charCodeAt(t-1)===da&&n.charCodeAt(t-2)===da);)t=n.indexOf(Ms,t+1);t===-1&&(t=n.length),r&&p.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===la&&n.charCodeAt(t+8)===la&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(p.push(n.substring(t+9)),t=n.length):(p.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let E=!1;for(;(n.charCodeAt(t)!==Vr||E)&&n[t]!==void 0;)n.charCodeAt(t)===la?E=!0:E&&n.charCodeAt(t)===Rl&&(E=!1),t++;p.push(n.substring(y,t))}t++;continue}let I=l();p.push(I),I.tagName[0]===\"?\"&&(p.push(...I.children),I.children=[])}else{let I=s();if(i)I.length>0&&p.push(I);else{let y=I.trim();y.length>0&&p.push(y)}t++}return p}function s(){let h=t;return t=n.indexOf(Tl,t)-1,t===-2&&(t=n.length),n.slice(h,t+1)}function u(){let h=t;for(;Pl.indexOf(n[t])===-1&&n[t]!==void 0;)t++;return n.slice(h,t)}function l(){let h=t;t++;let p=u(),I={},y=[];for(;n.charCodeAt(t)!==Vr&&n[t]!==void 0;){let E=n.charCodeAt(t);if(E>64&&E<91||E>96&&E<123){let v=u(),T=n.charCodeAt(t);for(;!isNaN(T)&&T!==ws&&T!==Ds&&!(T>64&&T<91||T>96&&T<123)&&T!==Vr;)t++,T=n.charCodeAt(t);let P;T===ws||T===Ds?P=f():(P=null,t--),I[v]=P===null?null:Ns(P)}t++}return n.charCodeAt(t-1)!==Os?(t++,y=o(p)):t++,{tagName:p,attributes:I,children:y,posStart:h,posEnd:t}}function f(){let h=n[t],p=t+1;return t=n.indexOf(h,p),n.slice(p,t)}function d(){let h=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return h!==null?h.index:-1}}function Bs(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=Bs(a.children,e,t+1,(Q(r)?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function Wr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+Wr(t),e=e.trim()}),e}else return typeof n==\"object\"?Wr(n.children):\" \"+Ns(n)}function Ns(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 ma(n,e,t){let{repeatCount:r}=n;if(r>=0)return r;let i;return C(e)?t!==void 0?i=t:i=Number.MAX_VALUE:i=e.start,Math.ceil((i-n.start)/n.duration)-1}function Fe(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=ma(n,e,t);return r+(a+1)*i}function Ce(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function Je(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function Us(n,e,t){return[n*t,(n+e)*t]}function vl(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 Ls(n,e,t){let{timeline:r}=n,i=Ce(e,n);if(i<0)return null;let a=vl(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,l=Fe(o,s,t);return i>=l&&i<u?Je(u,n):null}function it(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:C(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 Cl(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function ca(n){return(e,t,r)=>{let i=Q(r)?parseInt(r,10):1;return Cl(String(n),i)}}function ze(n,e,t){return Al(n,e,t)}function Al(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(%0(\\d+)d)?\\$/g,ca(t===void 0?0:t))}function qr(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 ca(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 ca(n)(i,a,o)})}}function xl(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function $n(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=Ce(e,n),l=Ce(s,n),{timeline:f,timescale:d,segmentUrlTemplate:m,startNumber:g,endNumber:h}=n,p=g!=null?g:1,I=[],y=f.length;for(let v=0;v<y;v++){let T=f[v],{duration:P,start:_,range:M}=T,A;o===void 0?A=i:A=Math.min(o*d,i!=null?i:1/0);let x=ma(T,f[v+1],A),B=n.availabilityTimeComplete!==!1||v!==y-1&&x!==0,D=xl(_,P,u),V=_+D*P;for(;V<l&&D<=x;){let U=p+D;if(h!==void 0&&U>h)break;let R=m===null?null:qr(V,U)(m),k=V-n.indexTimeOffset,w=P;k<0&&(w=P+k,k=0);let N={id:String(V),time:k/d,end:(k+w)/d,duration:w/d,isInit:!1,range:M,timescale:1,url:R,number:U,timestampOffset:-(n.indexTimeOffset/d),complete:B,privateInfos:{isEMSGWhitelisted:a}};I.push(N),D++,V=_+D*P}if(V>=l||(p+=x+1,h!==void 0&&p>h))return I}return I}function kl(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 Mt=class{constructor(e,t){var h,p,I,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,u=(h=e.timescale)!=null?h:1,f=((p=e.presentationTimeOffset)!=null?p:0)-r*u,d=((I=e.initialization)==null?void 0:I.media)===void 0?null:ze(e.initialization.media,a,o),m=e.media===void 0?null:ze(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:d,range:g},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:u},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Ce(r,this._index),this._scaledPeriodEnd=C(i)?void 0:Ce(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return $n(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:Je(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(Fe(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return Je(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++)kl(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){c.warn(\"dash\",\"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(\"dash\",\"Base RepresentationIndex: Cannot update a SegmentList\")}};var Ot=class{constructor(e,t){var g,h,p;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,l=(h=e.timescale)!=null?h:1,f=u-r*l,d=((p=e.initialization)==null?void 0:p.media)===void 0?null:ze(e.initialization.media,a,o),m=e.list.map(I=>({url:I.media===void 0?null:ze(I.media,a,o),mediaRange:I.mediaRange}));this._index={list:m,timescale:l,duration:e.duration,indexTimeOffset:f,indexRange:e.indexRange,initialization:C(e.initialization)?void 0:{url:d,range:e.initialization.range}}}getInitSegment(){let e=it(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,[l,f]=Us(u,t,o),d=Math.min(a.length-1,Math.floor(f/i)),m=[],g=Math.floor(l/i);for(;g<=d;){let h=a[g].mediaRange,p=a[g].url,I=g*s+this._periodStart,y={id:String(g),time:I,isInit:!1,range:h,duration:s,timescale:1,end:I+s,url:p,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(\"dash\",\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"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(\"dash\",\"A `ListRepresentationIndex` cannot be updated\")}};function Kt(n){return L.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var wt=class{constructor(e,t){var y,E,v;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:u,representationBitrate:l,isEMSGWhitelisted:f}=t,d=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(E=e.presentationTimeOffset)!=null?E:0,g=s*d,h=m-g;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let p=((v=e.initialization)==null?void 0:v.media)===void 0?null:ze(e.initialization.media,u,l),I=e.media===void 0?null:ze(e.media,u,l);this._index={duration:e.duration,timescale:d,indexRange:e.indexRange,indexTimeOffset:h,initialization:C(e.initialization)?void 0:{url:p,range:e.initialization.range},url:I,presentationTimeOffset:m,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=a,this._periodStart=s,this._scaledRelativePeriodEnd=o===void 0?void 0:(o-s)*d,this._isEMSGWhitelisted=f}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:u}=r,l=this._periodStart*s,f=this._scaledRelativePeriodEnd,d=e*s-l,m=(e+t)*s-l,g=this._getFirstSegmentStart(),h=this._getLastSegmentStart();if(C(g)||C(h))return[];let p=Math.max(g,d),I=Math.min(h,m);if(I+i<=p)return[];let y=[],E=a!=null?a:1,v=Math.floor(p/i);for(let T=v*i;T<=I;T+=i){let P=v+E;if(o!==void 0&&P>o)return y;let _=!C(f)&&T+i>f?f-T:i,M=T+l,A=T+this._index.presentationTimeOffset,x=u===null?null:qr(A,P)(u),B={id:String(P),number:P,time:M/s,end:(M+_)/s,duration:_/s,timescale:1,isInit:!1,scaledDuration:_/s,url:x,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(B),v++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return C(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(C(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(Ie(e<=t),!this._isDynamic)return!1;let{timescale:r}=this._index,i=Kt(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,u=this._getLastSegmentStart();if(C(u)){let d=this._estimateRelativeScaledEnd();return d===void 0?s+i>=0:s+i>=0&&o<d-i}let l=u+this._index.duration,f=this._estimateRelativeScaledEnd();return f===void 0?s>l-i:s>l-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(C(r))return!0;let i=r+this._index.duration,a=Kt(t);return i+a<e}isInitialized(){return!0}initialize(){c.error(\"dash\",\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"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 d=Math.ceil(this._scaledRelativePeriodEnd/e);return r!==void 0&&r-i+1<d&&(d=r-i+1),(d-1)*e}let u=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(u===void 0)return;let l=(u-this._periodStart)*t;if(l<0)return null;let f=Math.floor(l/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 l=(u-1)*e,f=L.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-l>f||u<2?l:(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 pa(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 ga(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(Fe(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 d=n[f].start;if(d===r){let m=t-f;return n.splice(f,m,...e),!1}else if(d<r){let m=n[f];if(m.start+m.duration>r)return c.warn(\"utils\",\"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 h=(r-m.start)/m.duration-1;if(h%1===0&&m.duration===e[0].duration){let p=e[0].repeatCount<0?-1:e[0].repeatCount+h+1;return n.splice(f,t-f,...e),n[f].start=m.start,n[f].repeatCount=p,!1}return c.warn(\"utils\",\"Manifest update removed previous segments\"),n[f].repeatCount=Math.floor(h),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(\"utils\",\"The new index is older than the previous one\"),!1):(c.warn(\"utils\",'The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let u=o.start+o.duration*(o.repeatCount+1),l=s.start+s.duration*(s.repeatCount+1);return u>=l?(c.warn(\"utils\",\"The new index is older than the previous one\"),!1):(c.warn(\"utils\",'The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function Xn(n,e,t){let r=n.start,i=n.duration,a=n.repeatCount;return r===void 0&&(e===null?r=0:C(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 Zn(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!C(r))switch(t){case\"t\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid t value for <S> element\",{val:r}):e.start=i;break}case\"d\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid d value for <S> element\",{val:r}):e.duration=i;break}case\"r\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid r value for <S> element\",{val:r}):e.repeatCount=i;break}}}return e}function yt(n){let e=[];for(let r=0;r<n.length;r++)e.push(Zn(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=Xn(i,a,o);s!==null&&t.push(s)}return t}function ha(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=e[0].attributes.t,i=C(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=e[0],s=i;for(;;){let u=o.attributes.d,l=C(u)?null:parseInt(u,10);if(l===null||Number.isNaN(l))return null;let f=o.attributes.r,d=C(f)?null:parseInt(f,10);if(d!==null){if(Number.isNaN(d)||d<0)return null;if(d>0){let h=t-s;if(h%l===0&&h/l<=d)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/l,prevSegmentsIdx:0,newElementsIdx:a}}s+=l*(d+1)}else s+=l;if(a++,a>=e.length)return null;o=e[a];let m=o.attributes.t,g=C(m)?null:parseInt(m,10);if(g!==null){if(Number.isNaN(g))return null;s=g}if(s===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(s>i)return null}}}function Ia(n,e){var p;let t=ha(e,n);if(t===null)return c.warn(\"dash\",'Cannot perform \"based\" update. Common segment not found.'),yt(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'),yt(n);let l=e.slice(r);if(a>0){let I=l[0];I.start+=I.duration*a,l[0].repeatCount-=a}if(o>0&&i!==0)return c.info(\"dash\",'Cannot perform \"based\" update. The new timeline has a different form.'),yt(n);let f=l[l.length-1],d=Zn(n[u]),m=((p=d.repeatCount)!=null?p:0)-o;if(d.duration!==f.duration||f.repeatCount>m)return c.info(\"dash\",'Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),yt(n);d.repeatCount!==void 0&&d.repeatCount>f.repeatCount&&(f.repeatCount=d.repeatCount);let g=[],h=[];for(let I=u+1;I<n.length;I++)h.push(Zn(n[I]));for(let I=0;I<h.length;I++){let y=h[I],E=g[g.length-1]===void 0?f:g[g.length-1],v=h[I+1]===void 0?null:h[I+1],T=Xn(y,E,v);T!==null&&g.push(T)}return l.concat(g)}var Jn=class n{constructor(e,t){var T,P,_,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:l,periodStart:f,periodEnd:d,isEMSGWhitelisted:m}=t,g=(T=e.timescale)!=null?T:1,h=(P=e.presentationTimeOffset)!=null?P:0,p=f*g,I=h-p;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(_=t.receivedTime)!=null?_:F(),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:ze(e.initialization.media,u,l),E=e.media===void 0?null:ze(e.media,u,l),v;i===void 0&&r===void 0?v=1/0:v=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:v,indexRange:e.indexRange,indexTimeOffset:I,initialization:C(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:E,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:ba(e.timeline,e.startNumber,e.endNumber),timescale:g},this._scaledPeriodStart=Ce(f,this._index),this._scaledPeriodEnd=d===void 0?void 0:Ce(d,this._index)}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),$n(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:Je(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=Gr(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 Je(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(Fe(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return Je(t,this._index)}awaitSegmentBetween(e,t){var l,f;if(Ie(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=Kt(r),o=Ce(t,this._index),s=Gr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(l=this._scaledPeriodEnd)!=null?l:1/0)+a>=Math.min(o,(f=this._scaledPeriodEnd)!=null?f:1/0))return!1;let u=Ce(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let d=i[i.length-1],g=Fe(d,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()),Ml(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),Ls({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof Xe&&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()),ga(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&&Ce(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Kt(this._index.timescale),r=Gr(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 Fe(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){c.error(\"dash\",\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"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(C(e))return;let t=Ce(e,this._index),r=pa(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}=L.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return ba(yt(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,ba(Ia(e,r),this._index.startNumber,this._index.endNumber)}};function ba(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=J({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-u),o.push(s),o}}}return n}function Ml(n,e,t,r){let i=Gr(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:!C(n.range)&&o.range[0]===n.range[0]&&o.range[1]===n.range[1];if(o.repeatCount>=0&&o.duration!==void 0){let l=(s-o.start)/o.duration-1;return l%1===0&&l<=i.newRepeatCount}}return!1}function Gr(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:Fe(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:Fe(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(Je(o,n)<=r){let s=Fe(a,n.timeline[i+1],t);if(Je(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let l=Ce(r,n)-a.start,f=Math.floor(l/a.duration);return Ie(f>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:f-1,end:a.start+f*a.duration}}}}return null}var Hr=Jn;var er=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 ya(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\"),ya(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),ya(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function ya(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 Kr(n){let e=Date.parse(n)-F();if(isNaN(e)){c.warn(\"dash\",\"Invalid clock received\",{clock:n});return}return e}function Sa(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 jr(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 Ta(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=jr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=jr(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(\"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 Yr(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 Ea(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=Yr(r);if(s===void 0)return;a=s}if(i!==void 0){let s=Yr(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){c.info(\"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 _a(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=Ea(n),t=Ta(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var tr=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(F()+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+F()/1e3,0):this._lastPosition}};function Ra(n,e){return n.type!==\"dynamic\"?0:C(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function Pa(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.\",{lastStart:i==null?void 0:i.start,newStart: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 va(n,e){let t=[];return n.forEach((r,i)=>{let a;if(!C(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||C(e.availabilityStartTime)?0:e.availabilityStartTime;else{let l=t[t.length-1];if(!C(l)&&!C(l.periodEnd))a=l.periodEnd;else throw new Error(\"Missing start time when parsing periods.\")}let o,s=n[i+1];C(r.attributes.duration)?i===n.length-1?o=e.duration:C(s.attributes.start)||(o=s.attributes.start-a):o=r.attributes.duration;let u=C(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:u})}),t}function Ol(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Lt){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 Fs=Ol;var wl=[\"subtitle\",\"caption\"];function Ca(n,e){var s,u,l,f;let t=(f=j((s=n.children.essentialProperties)!=null?s:[],d=>d.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||d.schemeIdUri===\"http://dashif.org/thumbnail_tile\"))!=null?f:j((l=(u=e!=null?e:n.children.representations[0])==null?void 0:u.children.essentialProperties)!=null?l:[],d=>d.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||d.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 Aa(n,e){if(n.attributes.contentType===\"image\")return Ca(n)!==null?\"thumbnails\":void 0;let t=Q(n.attributes.mimeType)?n.attributes.mimeType:null,r=Q(n.attributes.codecs)?n.attributes.codecs:null,i=C(n.children.roles)?null:n.children.roles;function a(s,u){let l=s.split(\"/\")[0];if(ge(Lt,l))return l;if(s===\"application/ttml+xml\")return\"text\";if(s===\"application/mp4\")return u!==null&&j(u,f=>f.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&ge(wl,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:l,codecs:f}=u.attributes;if(l!==void 0){let d=a(l,i);if(d!==void 0)return d}if(f!==void 0){let d=o(f);if(d!==void 0)return d}}}var Dl=/[, ]+/g;function zs(n){return Q(n)?n.trim().replace(Dl,\", \"):\"\"}function Vs(n){let[e,t,r,i,a,o,s,u]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let l,f,d;if((i!==void 0&&i===\"10\"||i===\"12\")&&(l=parseInt(i,10)),s!==void 0&&(s===\"16\"?f=\"pq\":s===\"18\"&&(f=\"hlg\")),o!==void 0&&u!==void 0&&o===\"09\"&&u===\"09\"&&(d=\"rec2020\"),!(l===void 0||f===void 0))return{colorDepth:l,eotf:f,colorSpace:d}}function xa(n,e){var h,p,I;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:u,inbandEventStreams:l,isLastPeriod:f}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:u,isEMSGWhitelisted:y=>l===void 0?!1:l.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 Mt(y,m)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;g=new Ot(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 v=K({},...y);(v.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((h=v.availabilityTimeOffset)!=null?h:0)+((p=e.availabilityTimeOffset)!=null?p:0)),(v.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(I=v.availabilityTimeComplete)!=null?I:e.availabilityTimeComplete),g=Hr.isTimelineIndexArgument(v)?new Hr(v,m):new wt(v,m)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:E}=y;g=new Mt(E,m)}else if(y.segmentList!==void 0){let{segmentList:E}=y;g=new Ot(E,m)}else g=new wt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return g}function at(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],l=Ln(o.url,u.url);r.push({url:l,serviceLocation:(i=u.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Bl(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 Nl({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 Vs(i)}function ka(n,e,t){var i,a,o,s,u,l,f;let r=[];for(let d of n){let m=d.attributes.id!==void 0?d.attributes.id:String(d.attributes.bitrate)+(d.attributes.height!==void 0?`-${d.attributes.height}`:\"\")+(d.attributes.width!==void 0?`-${d.attributes.width}`:\"\")+(d.attributes.mimeType!==void 0?`-${d.attributes.mimeType}`:\"\")+(d.attributes.codecs!==void 0?`-${d.attributes.codecs}`:\"\");for(;r.some(x=>x.id===m);)m+=\"-dup\";let g=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(m))!=null?a:null,h=Bl(d,e),p=(o=d.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,I;(d.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(I=((s=d.attributes.availabilityTimeOffset)!=null?s:0)+((u=t.availabilityTimeOffset)!=null?u:0));let y=K({},t,{availabilityTimeOffset:I,availabilityTimeComplete:p,unsafelyBaseOnPreviousRepresentation:g,adaptation:e,inbandEventStreams:h}),E=xa(d,y),v;d.attributes.bitrate===void 0?(c.warn(\"dash\",\"No usable bitrate found in the Representation.\"),v=0):v=d.attributes.bitrate;let T=at(t.baseURLs,d.children.baseURLs),P=T.length===0?[{baseUrl:\"\",id:void 0}]:T.map(x=>({baseUrl:x.url,id:x.serviceLocation})),_={bitrate:v,cdnMetadata:P,index:E,id:m};d.children.supplementalProperties!==void 0&&j(d.children.supplementalProperties,x=>x.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&x.value===\"JOC\")!==void 0&&(_.isSpatialAudio=!0);let M;d.attributes.codecs!==void 0?M=d.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;d.attributes.supplementalCodecs!==void 0?A=d.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(A=e.attributes.supplementalCodecs),A!==void 0&&(_.supplementalCodecs=zs(A)),d.attributes.frameRate!==void 0?_.frameRate=d.attributes.frameRate:e.attributes.frameRate!==void 0&&(_.frameRate=e.attributes.frameRate),d.attributes.height!==void 0?_.height=d.attributes.height:e.attributes.height!==void 0&&(_.height=e.attributes.height),d.attributes.mimeType!==void 0?_.mimeType=d.attributes.mimeType:e.attributes.mimeType!==void 0&&(_.mimeType=e.attributes.mimeType),d.attributes.width!==void 0?_.width=d.attributes.width:e.attributes.width!==void 0&&(_.width=e.attributes.width);{let x=[...(l=e.children.contentProtections)!=null?l:[],...(f=d.children.contentProtections)!=null?f:[]];for(let B of x)t.contentProtectionParser.add(_,B)}_.hdrInfo=Nl({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:M}),r.push(_)}return r}function Ul(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 Ll(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 Fl(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function zl(n,e){if(Q(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,u=s;return Q(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\"),Q(n.attributes.contentType)&&(u+=`-${n.attributes.contentType}`),Q(n.attributes.codecs)&&(u+=`-${n.attributes.codecs}`),Q(n.attributes.mimeType)&&(u+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(u+=`-${String(n.attributes.frameRate)}`),u}function Vl(n){if(!C(n.children.supplementalProperties)){let{supplementalProperties:e}=n.children;for(let t of e)if(t.schemeIdUri===\"urn:mpeg:dash:adaptation-set-switching:2016\"&&!C(t.value))return t.value.split(\",\").map(r=>r.trim()).filter(r=>Q(r))}return[]}function Ma(n,e){var u,l,f,d,m,g,h;let t={video:[],audio:[],text:[]},r=[],i=[],a={},o=[];for(let p=0;p<n.length;p++){let I=n[p],y=I.children,{essentialProperties:E,roles:v,label:T}=y,P=Array.isArray(v)&&v.some(ae=>ae.value===\"main\")&&v.some(ae=>ae.schemeIdUri===\"urn:mpeg:dash:role:2011\"),_=I.children.representations,M=(u=I.attributes.availabilityTimeComplete)!=null?u:e.availabilityTimeComplete,A;(I.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(A=((l=I.attributes.availabilityTimeOffset)!=null?l:0)+((f=e.availabilityTimeOffset)!=null?f:0));let x=Aa(I,_);if(x===void 0)continue;let B=(d=I.attributes.selectionPriority)!=null?d:1,D=I.attributes.id,V=Vl(I),U=[];e.segmentTemplate!==void 0&&U.push(e.segmentTemplate),I.children.segmentTemplate!==void 0&&U.push(I.children.segmentTemplate);let R={availabilityTimeComplete:M,availabilityTimeOffset:A,baseURLs:at(e.baseURLs,y.baseURLs),contentProtectionParser:e.contentProtectionParser,manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:U,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},k=Array.isArray(E)?j(E,ae=>ae.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,w=(m=k==null?void 0:k.value)==null?void 0:m.split(\" \"),N=w!==void 0,{accessibilities:H}=y,X;v!==void 0&&v.some(ae=>ae.value===\"dub\")&&(X=!0);let q;x!==\"text\"?q=!1:q=Ll(H,v);let G;x===\"text\"&&v!==void 0&&v.some(ae=>ae.value===\"forced-subtitle\"||ae.value===\"forced_subtitle\")&&(G=!0);let Y;x!==\"audio\"?Y=!1:H!==void 0&&(Y=H.some(Ul));let fe;x!==\"video\"?fe=!1:H!==void 0&&(fe=H.some(Fl));let de=zl(I,{isAudioDescription:Y,isForcedSubtitle:G,isClosedCaption:q,isSignInterpreted:fe,isTrickModeTrack:N,type:x});for(;ge(o,de);)de+=\"-dup\";let me=de;o.push(de),R.unsafelyBaseOnPreviousAdaptation=(h=(g=e.unsafelyBaseOnPreviousPeriod)==null?void 0:g.getAdaptation(de))!=null?h:null;let Qe=ka(_,I,R);if(x===\"thumbnails\"){let ae=Wl(I,Qe);ae!==null&&r.push(...ae);continue}let te={id:de,representations:Qe,type:x,isTrickModeTrack:N};if(C(I.attributes.language)||(te.language=I.attributes.language),C(q)||(te.closedCaption=q),C(Y)||(te.audioDescription=Y),X===!0&&(te.isDub=!0),G!==void 0&&(te.forcedSubtitles=G),fe===!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 Xt of V){let Zt=a[Xt];if(Zt!==void 0&&Zt.newID!==me&&ge(Zt.adaptationSetSwitchingIDs,D)){ae=ne(t[x],Jt=>Jt[0].id===Xt);let _e=t[x][ae];if(_e!==void 0&&_e[0].audioDescription===te.audioDescription&&_e[0].closedCaption===te.closedCaption&&_e[0].language===te.language){c.info(\"dash\",'merging \"switchable\" AdaptationSets',{originalID:D,id:Xt}),_e[0].representations.push(...te.representations),_e[1]={priority:Math.max(B,_e[1].priority),isMainAdaptation:P||_e[1].isMainAdaptation,indexInMpd:Math.min(p,_e[1].indexInMpd)};break}}}ae<0&&t[x].push([te,{priority:B,isMainAdaptation:P,indexInMpd:p}])}!C(D)&&C(a[D])&&(a[D]={newID:me,adaptationSetSwitchingIDs:V})}let s=Lt.reduce((p,I)=>{let y=t[I];return y.length>0&&(y.sort(Ws),p[I]=y.map(([E])=>E)),p},{});return t.video.sort(Ws),Fs(s,i),{adaptations:s,thumbnailTracks:r}}function Wl(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=Ca(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,l=(i=o.index.getEnd())!=null?i:void 0,f,d=o.index.getTargetSegmentDuration();d!==void 0&&d.isPrecize?f=d.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:l,tileDuration:f===void 0?void 0:f/(s.horizontalTiles*s.verticalTiles)})}}return t}function Ws(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 ql=Me();function Oa(n,e){var o,s,u,l,f;let t=[],r=va(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&&!C(e.duration)&&a.setLastPosition(e.duration);for(let d=n.length-1;d>=0;d--){let m=d===n.length-1,g=n[d],h=e.xlinkInfos.get(g),p=at(e.baseURLs,g.children.baseURLs),{periodStart:I,periodDuration:y,periodEnd:E}=r[d],v;for(C(g.attributes.id)?(v=\"gen-dash-period-\"+ql(),c.warn(\"dash\",\"No usable id found in the Period. Generating one.\",{periodId:v})):v=g.attributes.id;t.some(N=>N.id===v);)v+=\"-dup\";let T=h!==void 0?h.receivedTime:e.receivedTime,P=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(v))!=null?s:null,_=g.attributes.availabilityTimeComplete,M=g.attributes.availabilityTimeOffset,{manifestProfiles:A,contentProtectionParser:x}=e,{segmentTemplate:B}=g.children;x.addReferences((u=g.children.contentProtections)!=null?u:[]);let D={availabilityTimeComplete:_,availabilityTimeOffset:M,baseURLs:p,contentProtectionParser:x,manifestBoundsCalculator:a,end:E,isDynamic:i,isLastPeriod:m,manifestProfiles:A,receivedTime:T,segmentTemplate:B,start:I,unsafelyBaseOnPreviousPeriod:P},{adaptations:V,thumbnailTracks:U}=Ma(g.children.adaptations,D),R=((l=e.xmlNamespaces)!=null?l:[]).concat((f=g.attributes.namespaces)!=null?f:[]),k=Hl(g.children.eventStreams,I,R),w={id:v,start:I,end:E,duration:y,thumbnailTracks:U,adaptations:V,streamEvents:k};if(t.unshift(w),!a.lastPositionIsKnown()){let N=Gl(V);if(!i)typeof N==\"number\"&&a.setLastPosition(N);else if(typeof N==\"number\"){let H=F()/1e3;a.setLastPosition(N,H)}else{let H=qs(e,I);if(H!==void 0){let[X,q]=H;a.setLastPosition(X,q)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let d=qs(e,0);if(d!==void 0){let[m,g]=d;a.setLastPosition(m,g)}}return Pa(t)}function qs(n,e){if(C(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){c.warn(\"dash\",\"no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=F()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=F()/1e3,i=r+t;if(i>=e)return[i,r]}}function Gl(n){let e=null,t=!0,r=hr(n).filter(a=>!C(a)),i=_i(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=C(e)?u:Math.max(e,u)))}}if(C(e)){if(t)return null}else return e}function Hl(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:u=1}=o.attributes,l=t.concat((i=o.attributes.namespaces)!=null?i:[]);for(let f of o.children.events)if(f.eventStreamData!==void 0){let d=((a=f.presentationTime)!=null?a:0)/u+e,m=f.duration===void 0?void 0:d+f.duration/u,g,h;try{h={namespaces:l,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:He(new Uint8Array(f.eventStreamData))}}catch(p){c.error(\"dash\",\"Error while parsing event-stream:\",p instanceof Error?p.message:\"Unknown error\")}r.push({start:d,end:m,id:f.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:u,element:g,xmlData:h}}})}}return r}function jt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(C(e.externalClockOffset)){let u=o.type===\"dynamic\",l=j(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!C(m.value)),f=!C(l)&&!C(l.value)?Kr(l.value):void 0,d=!C(f)&&!isNaN(f)?f:void 0;if(!C(d)&&r!==!0)e.externalClockOffset=d;else if(u&&r!==!0){let m=Sa(n);if(!C(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(h){return h.success?(e.externalClockOffset=Kr(h.data),jt(n,e,t,!0)):(t.push(h.error),c.warn(\"dash\",\"Error on fetching the clock ressource\",h.error),jt(n,e,t,!0))}}}}}let s=[];for(let u=0;u<a.periods.length;u++){let{xlinkHref:l,xlinkActuate:f}=a.periods[u].attributes;!C(l)&&f===\"onLoad\"&&s.push({index:u,ressource:l})}return s.length===0?Kl(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:u})=>u),continue:function(l){if(l.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let f=l.length-1;f>=0;f--){let d=s[f].index,{parsed:m,warnings:g,receivedTime:h,sendingTime:p,url:I}=l[f];g.length>0&&t.push(...g);for(let y of m)i.set(y,{receivedTime:h,sendingTime:p,url:I});a.periods.splice(d,1,...m)}return jt(n,e,t,r,i)}}}}function Kl(n,e,t,r){var R,k,w,N,H;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Yi(e.url))}]:[],u=at(s,i.baseURLs),l=Ra(a,e.referenceDateTime),f=a.timeShiftBufferDepth,d=a.maxSegmentDuration,{externalClockOffset:m,unsafelyBaseOnPreviousManifest:g}=e,{externalClockOffset:h}=e,p=new tr({availabilityStartTime:l,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:h}),I=new er;I.addReferences((R=i.contentProtections)!=null?R:[]);let y={availabilityStartTime:l,baseURLs:u,clockOffset:m,contentProtectionParser:I,duration:a.duration,isDynamic:o,manifestBoundsCalculator:p,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,unsafelyBaseOnPreviousManifest:g,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},E=Oa(i.periods,y);I.finalize();let v=a.duration,T,P,_=null,M;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(T=a.minimumUpdatePeriod===0?L.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:A,maximumSafePosition:x,maximumUnsafePosition:B}=_a(E),D=F();if(o){let X;x!==void 0?X=x:h===void 0?(c.warn(\"dash\",\"use system clock to define maximum position\"),X=Date.now()/1e3-l):X=(F()+h)/1e3-l;let q=p.getEstimatedLiveEdge();q===void 0&&(B!==void 0?q=B:q=X),M={isLinear:!0,maximumSafePosition:X,livePosition:q,time:D},P=A,_=f!=null?f:null,_!==null&&(_+=d!=null?d:0),_!==null&&P!==void 0&&q-P>_&&(_=q-P)}else{P=A,P===void 0&&(P=(w=(k=E[0])==null?void 0:k.start)!=null?w:0);let X=v!=null?v:1/0;if(E[E.length-1]!==void 0){let q=E[E.length-1],G=(N=q.end)!=null?N:q.duration!==void 0?q.start+q.duration:void 0;G!==void 0&&G<X&&(X=G)}x!==void 0&&x<X&&(X=x),M={isLinear:!1,maximumSafePosition:X,livePosition:void 0,time:D}}let V=!o||n.attributes.minimumUpdatePeriod===void 0&&(((H=E[E.length-1])==null?void 0:H.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:l,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:V,periods:E,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:P,timeshiftDepth:_,maximumTimeData:M},lifetime:T,uris:C(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var Qr=jt;var jl=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,Yl=/([0-9]+)-([0-9]+)/;function Ae(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new De(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ie(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 we(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 wa(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 $r(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 Ke(n,e){if(!Q(n))return[0,new De(`\\`${e}\\` property is empty`)];let t=jl.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(Q(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(Q(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(Q(t[6])?t[6]:\"0\")*24*60*60+parseFloat(Q(t[8])?t[8]:\"0\")*60*60+parseFloat(Q(t[10])?t[10]:\"0\")*60+parseFloat(Q(t[12])?t[12]:\"0\"),null]}function Dt(n,e){let t=Yl.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function Gs(n,e){try{return[Er(n),null]}catch(t){return[null,new De(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Yt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:we(n,e)}function Se(n){let e,t;for(let r of Object.keys(n.attributes)){let i=n.attributes[r];if(!C(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(\"dash\",\"failed to parse DASH value:\",s.message,{dashName:a}),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 St(n){return Wr(n)}function ot(n){let e=typeof n==\"string\"?n:St(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function Ql(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=St(i.children);if(a!==null&&a.length>0){let[o,s]=Gs(a,\"cenc:pssh\");s!==null&&(c.warn(\"dash\",\"Content protection parsing failure\",s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function $l(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!C(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 st(n){let[e,t]=Ql(n.children),r=$l(n);return[{children:e,attributes:r},t]}function Da(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!C(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 Ba(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"range\":r(a,{asKey:\"range\",parser:Dt,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function ut(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]=Ba(o);e.initialization=s,t=t.concat(u)}}for(let a of Object.keys(n.attributes)){let o=n.attributes[a];if(!C(o))switch(a){case\"timescale\":r(o,{asKey:\"timescale\",parser:ie,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:we,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Dt,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:Ae,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:Ae,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 Na(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"media\":e.media=a;break;case\"indexRange\":r(a,{asKey:\"indexRange\",parser:Dt,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Dt,dashName:\"mediaRange\"});break}}return[e,t]}function nr(n){let[e,t]=ut(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[l,f]=Na(u);i.push(l),r=r.concat(f)}}return[K(e,{list:i}),r]}function Ua(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 Bt(n){let[e,t]=ut(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=Ua(u))}let a=K({},e,{duration:e.duration,timelineParser:i}),o=Te(a,r);for(let s of Object.keys(n.attributes)){let u=n.attributes[s];if(!C(u))switch(s){case\"initialization\":C(a.initialization)&&(a.initialization={media:u});break;case\"index\":a.index=u;break;case\"availabilityTimeOffset\":o(u,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(u,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=u;break;case\"bitstreamSwitching\":o(u,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function Xl(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]=ot(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break}case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Se(a));break;case\"SegmentBase\":{let[o,s]=ut(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=nr(a);r=r.concat(s),e.segmentList=o;break}case\"SegmentTemplate\":{let[o,s]=Bt(a);r=r.concat(s),e.segmentTemplate=o;break}case\"ContentProtection\":{let[o,s]=st(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}case\"EssentialProperty\":C(e.essentialProperties)?e.essentialProperties=[Se(a)]:e.essentialProperties.push(Se(a));break;case\"SupplementalProperty\":C(e.supplementalProperties)?e.supplementalProperties=[Se(a)]:e.supplementalProperties.push(Se(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function Zl(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(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:Ae,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Yt,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:we,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:we,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:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new De(\"No bitrate found on a Representation\")),[e,t]}function Hs(n){let[e,t]=Xl(n.children),[r,i]=Zl(n),a=t.concat(i);return[{children:e,attributes:r},a]}function Jl(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=[Se(a)]:e.accessibilities.push(Se(a));break;case\"BaseURL\":{let[o,s]=ot(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break}case\"ContentComponent\":e.contentComponent=Da(a);break;case\"EssentialProperty\":C(e.essentialProperties)?e.essentialProperties=[Se(a)]:e.essentialProperties.push(Se(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Se(a));break;case\"Label\":{let o=St(a.children);o!=null&&(e.label=o);break}case\"Representation\":{let[o,s]=Hs(a);e.representations.push(o),s.length>0&&(r=r.concat(s));break}case\"Role\":C(e.roles)?e.roles=[Se(a)]:e.roles.push(Se(a));break;case\"SupplementalProperty\":C(e.supplementalProperties)?e.supplementalProperties=[Se(a)]:e.supplementalProperties.push(Se(a));break;case\"SegmentBase\":{let[o,s]=ut(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=nr(a);e.segmentList=o,s.length>0&&(r=r.concat(s));break}case\"SegmentTemplate\":{let[o,s]=Bt(a);e.segmentTemplate=o,s.length>0&&(r=r.concat(s));break}case\"ContentProtection\":{let[o,s]=st(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 ef(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(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:Yt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Yt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ie,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:wa,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:wa,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ae,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:Ae,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Yt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ie,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:we,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:we,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:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function Ks(n){let e=n.children,[t,r]=Jl(e),[i,a]=ef(n),o=r.concat(a);return[{children:t,attributes:i},o]}function tf(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(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:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function js(n,e){let[t,r]=tf(n),i=[];for(let a of n.children)if(typeof a!=\"string\"&&a.tagName===\"Event\"){let o={};if(C(a.attributes.id)||(o.id=a.attributes.id),!C(a.attributes.presentationTime)){let[s,u]=ie(a.attributes.presentationTime,\"presentationTime\");u!==null&&r.push(u),s!==null&&(o.presentationTime=s)}if(!C(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 nf(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let u=0;u<n.length;u++){let l=n[u];if(typeof l!=\"string\")switch(l.tagName){case\"BaseURL\":{let[f,d]=ot(l);f!==void 0&&t.push(f),o=o.concat(d);break}case\"AdaptationSet\":{let[f,d]=Ks(l);r.push(f),o=o.concat(d);break}case\"EventStream\":{let[f,d]=js(l,e);s.push(f),o=o.concat(d);break}case\"SegmentTemplate\":{let[f,d]=Bt(l);i=f,d.length>0&&(o=o.concat(d));break}case\"ContentProtection\":{let[f,d]=st(l);d.length>0&&(o=o.concat(d)),f!==void 0&&a.push(f);break}}}return[{baseURLs:t,adaptations:r,eventStreams:s,segmentTemplate:i,contentProtections:a},o]}function rf(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"id\":e.id=a;break;case\"start\":r(a,{asKey:\"start\",parser:Ke,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:Ke,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Xr(n,e){let[t,r]=nf(n.children,e),[i,a]=rf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function af(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let u=0;u<n.length;u++){let l=n[u];if(typeof l!=\"string\")switch(l.tagName){case\"BaseURL\":{let[f,d]=ot(l);f!==void 0&&t.push(f),s=s.concat(d);break}case\"Location\":r.push(St(l.children));break;case\"Period\":{let[f,d]=Xr(l,e);i.push(f),s=s.concat(d);break}case\"UTCTiming\":{let f=Se(l);a.push(f);break}case\"ContentProtection\":{let[f,d]=st(l);d.length>0&&(s=s.concat(d)),f!==void 0&&o.push(f);break}}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a,contentProtections:o},s]}function of(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(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:$r,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:$r,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:$r,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:Ke,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:Ke,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:Ke,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:Ke,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:Ke,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:Ke,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:Ke,dashName:\"maxSubsegmentDuration\"});break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Ys(n,e){let[t,r]=af(n.children,e),[i,a]=of(n),o=r.concat(a);return[{children:t,attributes:i},o]}function La(n,e){let t=fa(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]=Ys(r,n),o=Qr(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(l){if(l.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let f=u.value.continue(l[0].responseData);return s(f)}}};if(u.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:u.value.xlinksUrls,format:\"string\",continue(l){let f=[];for(let m=0;m<l.length;m++){let{responseData:g,receivedTime:h,sendingTime:p,url:I}=l[m];if(!g.success)throw g.error;let y=\"<root>\"+g.data+\"</root>\",E=fa(y),v=E[E.length-1];if(v===void 0||typeof v==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let T=v.children,P=[],_=[];for(let M=0;M<T.length;M++){let A=T[M];if(typeof A==\"string\"||A.tagName!==\"Period\")continue;let[x,B]=Xr(A,y);_.push(...B),P.push(x)}f.push({url:I,receivedTime:h,sendingTime:p,parsed:P,warnings:_})}let d=u.value.continue(f);return s(d)}}};Be(u)}}var Qs=La;var sf=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",$s=sf;function W(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function Fa(n){return n===1/0?!0:n===-1/0?!1:n}function Tt(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=W(t,e.buffer,a,o))}}function Et(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,u){switch(o){case 16:t.schemeIdUri=W(i,e.buffer,s,u);break;case 13:t.value=W(i,e.buffer,s,u);break;case 14:{let l=W(i,e.buffer,s,u);t.keyId=un(l.replace(/-/g,\"\"));break}case 15:try{let l=W(i,e.buffer,s,u);r.cencPssh.push(Er(l))}catch(l){}break;case 78:t.ref=W(i,e.buffer,s,u);break;case 79:t.refId=W(i,e.buffer,s,u);break}}}function Xs(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=W(t,e.buffer,a,o);break;case 60:n.language=W(t,e.buffer,a,o);break;case 61:n.contentType=W(t,e.buffer,a,o);break;case 62:n.par=W(t,e.buffer,a,o);break}}}function Zs(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.label=W(t,e.buffer,a,o))}}function Ve(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=W(t,e.buffer,a,o);break;case 17:n.value=W(t,e.buffer,a,o);break}}}function Qt(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=W(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 Js(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=W(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=W(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 Zr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=Js(a,e);t.pushParsers(i,O,o);break}default:t.pushParsers(i,O,O);break}}}function $t(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 l=0;l<o/24;l++)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:W(t,e.buffer,a,o)};break;case 28:n.index=W(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=W(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 eu(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,O,Tt(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=Et(a,e);t.pushParsers(i,O,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,O,Ve(a,e));break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=Ve(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Ve(a,e);t.pushParsers(i,O,o);break}case 17:{let a={};n.segmentBase=a;let o=Qt(a,e);t.pushParsers(i,O,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Zr(a,e,t),s=Qt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,O,$t(a,e));break}default:t.pushParsers(i,O,O);break}}}function tu(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=W(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=W(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=W(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=W(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=W(t,e.buffer,a,o);break;case 2:n.profiles=W(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=W(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 nu(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=Ve(a,e);t.pushParsers(i,O,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=Tt(a,e);t.pushParsers(i,O,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,O,Xs(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=Et(a,e);t.pushParsers(i,O,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=O,s=Ve(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=O,s=Ve(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=eu(a.children,e,t),s=tu(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=Ve(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Ve(a,e);t.pushParsers(i,O,o);break}case 17:{let a={};n.segmentBase=a;let o=Qt(a,e);t.pushParsers(i,O,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Zr(a,e,t),s=Qt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,O,$t(a,e));break}case 21:{t.pushParsers(i,O,Zs(n,e));break}default:t.pushParsers(i,O,O);break}}}function ru(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=W(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=W(t,e.buffer,a,o);break;case 61:n.contentType=W(t,e.buffer,a,o);break;case 62:n.par=W(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=Fa(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=Fa(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=W(t,e.buffer,a,o);break;case 4:n.codecs=W(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=W(t,e.buffer,a,o);break;case 2:n.profiles=W(t,e.buffer,a,o);break;case 12:n.segmentProfiles=W(t,e.buffer,a,o);break;case 11:n.mimeType=W(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 iu(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=uf(o,e,r);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function au(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=W(t,e.buffer,a,o);break;case 17:n.value=W(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:{let u={key:\"\",value:\"\"},l=a,f=s.getUint32(l);l+=4,u.key=W(t,e.buffer,l,f),l+=f;let d=s.getUint32(l);l+=4,u.value=W(t,e.buffer,l,d),n.namespaces===void 0?n.namespaces=[u]:n.namespaces.push(u);break}}}}function uf(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=W(r,e.buffer,o,s);break;case 69:{let l=u.getFloat64(o,!0),f=u.getFloat64(o+8,!0);n.eventStreamData=t.slice(l,f);break}}}}function Jr(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=nu(o.children,e,t),u=ru(o.attributes,e);t.pushParsers(a,s,u);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,u=Tt(o,e);t.pushParsers(a,s,u);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=iu(o.children,e,t,r),u=au(o.attributes,e);t.pushParsers(a,s,u);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,O,$t(o,e));break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=Et(o,e);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function ei(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=W(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=W(t,e.buffer,a,o);break;case 47:n.xlinkActuate=W(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),l=a,f=u.getUint32(l);l+=4,s.key=W(t,e.buffer,l,f),l+=f;let d=u.getUint32(l);l+=4,s.value=W(t,e.buffer,l,d),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}}function ou(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,u=Tt(o,e);t.pushParsers(a,s,u);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Jr(o.children,e,t,r),u=ei(o.attributes,e);t.pushParsers(a,s,u);break}case 3:{let o={};n.utcTimings.push(o);let s=O,u=Ve(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=Et(o,e);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function su(n,e,t){let r,i=new TextDecoder;return function(o,s,u){switch(o){case 0:e.id=W(i,t.buffer,s,u);break;case 2:e.profiles=W(i,t.buffer,s,u);break;case 33:e.type=W(i,t.buffer,s,u);break;case 34:{let l=W(i,t.buffer,s,u);e.availabilityStartTime=new Date(l).getTime()/1e3;break}case 35:{let l=W(i,t.buffer,s,u);e.availabilityEndTime=new Date(l).getTime()/1e3;break}case 36:{let l=W(i,t.buffer,s,u);e.publishTime=new Date(l).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 l=W(i,t.buffer,s,u);n.locations.push(l);break}case 70:{let l={key:\"\",value:\"\"};r=new DataView(t.buffer);let f=s,d=r.getUint32(f);f+=4,l.key=W(i,t.buffer,f,d),f+=d;let m=r.getUint32(f);f+=4,l.value=W(i,t.buffer,f,m),e.namespaces===void 0?e.namespaces=[l]:e.namespaces.push(l);break}}}}function za(n,e,t,r){return function(a){switch(a){case 1:{n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=ou(n.mpd.children,e,t,r),s=su(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break}default:t.pushParsers(a,O,O);break}}}function uu(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Jr(o.children,e,t,r),u=ei(o.attributes,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,O,O);break}}}var rr=class{constructor(){this._currentNodeId=null,this.childrenParser=O,this.attributeParser=O,this._stack=[{nodeId:null,children:O,attribute:O}]}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=O,this.attributeParser=O,this._stack=[{nodeId:null,children:O,attribute:O}]}};var df=15e3,ir=class{constructor(){this._parsersStack=new rr,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:l,onCustomEvent:m,onAttribute:d,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 h=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"dash\",\"Unable to call `instantiateStreaming` on WASM\",h instanceof Error?h:\"\");let p=await s;if(p.status<200||p.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(p.status));let I=await p.arrayBuffer();return WebAssembly.instantiate(I,a)}).then(h=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=h,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(h=>{let p=h instanceof Error?h.toString():\"Unknown error\";throw c.warn(\"dash\",\"Could not create DASH-WASM parser:\",p),this.status=\"failure\",h}),this._initProm;function l(h){return t.childrenParser(h)}function f(h){return t.popIfCurrent(h)}function d(h,p,I){return t.attributeParser(h,p,I)}function m(h,p,I){let y=i._linearMemory,E=new Uint8Array(y.buffer,p,I);if(h===1){let v=r.decode(E);c.warn(\"dash\",\"WASM Error Event:\",v),i._warnings.push(new Error(v))}else if(h===0){let v=r.decode(E);c.warn(\"dash\",\"WASM Log Event:\",v)}}function g(h,p){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let I=i._linearMemory,{mpd:y,cursor:E}=i._mpdData,v=Math.min(p,df,y.byteLength-E);return new Uint8Array(I.buffer,h,v).set(new Uint8Array(y,E,v)),i._mpdData.cursor+=v,v}}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=Qr(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return $s&&typeof ee.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=za(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,O),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=uu(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,O),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:l,url:f}=r[o];if(!s.success)throw s.error;let[d,m]=this._parseXlink(s.data);i.push({url:f,receivedTime:u,sendingTime:l,parsed:d,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 Be(e)}};var du=ir;function je(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 l=e[u];l[1]===null?s+=l[0]:s+=`${l[0]}=${l[1]}`,u<e.length-1&&(s+=\"&\")}return r.length>0&&(s+=r),s}function Va(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-F(),u=!1,m={reject:p=>{var v,T;if(u||i.isCancelled())return;u=!0,i.deregister(h);let I=p,y=(v=I==null?void 0:I.message)!=null?v:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",E=new $e(y,(T=I==null?void 0:I.canRetry)!=null?T:!1,I==null?void 0:I.xhr);o(E)},resolve:p=>{if(u||i.isCancelled())return;u=!0,i.deregister(h);let I=p.receivingTime!==void 0?p.receivingTime-s:void 0,y=p.sendingTime!==void 0?p.sendingTime-s:void 0;a({responseData:p.data,size:p.size,requestDuration:p.duration,url:p.url,receivedTime:I,sendingTime:y})},fallback:()=>{u||i.isCancelled()||(u=!0,i.deregister(h),e(t,r,i).then(a,o))}},g=n({url:t,timeout:r.timeout,cmcdPayload:r.cmcdPayload},m);i.register(h);function h(p){u||(u=!0,typeof g==\"function\"&&g(),o(p))}})}function lf(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\"?je(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:Be(n)}}}function Wa({customManifestLoader:n},e,t){let r=lf(e),i=typeof n!=\"function\"?r:Va(n,r);return t!==null?t(i):i}function qa(n,e){if(e){if(Ze(n,1718909296)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Ze(n,1836019574)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Ze(n,1836019558)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Ze(n,1835295092)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function Ye(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 ti(n){return(e,t,r,i,a)=>{return new Promise((s,u)=>{let l=new z,f=l.linkToSignal(i);l.signal.register(u),n(e,t,r,l.signal,oe(J({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(g){d(),l.cancel(),u(g)}}})).then(m=>{if(d(),!l.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(g){u(g);return}s(m)}},m=>{d(),u(m)});function d(){l.signal.deregister(u),f()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||Ye(t.type,t.mimeType)!==\"mp4\"||qa(new Uint8Array(s),t.segment.isInit)}}}function lu(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 l=u.length-1;l>=0;l--){let f=u[l];for(;ff(o[s]);)s--;for(let d=f.length-1;d>=0;d--){if(o[s]!==f[d])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),l=[[60,47],[77,80,68],[62]];for(let f=l.length-1;f>=0;f--){let d=l[f];for(;mf(u.getUint8(s));)s--;for(let m=d.length-1;m>=0;m--){if(u.getUint8(s)!==d[m])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(!C(ee.Document)&&o instanceof ee.Document&&o.documentElement.nodeName!==\"MPD\")throw new Ee(\"INTEGRITY_ERROR\",\"MPD does not end with </MPD>\")}}}function ff(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function mf(n){return n===32||n===9||n===13||n===10}function Ga(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:l}=i,f=a.externalClockOffset,d=(E=i.url)!=null?E:a.originalUrl,m=t!=null?t:f,h={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:d,referenceDateTime:e,externalClockOffset:m},p=ke.dashParsers;if(p.wasm===null||p.wasm.status===\"uninitialized\"||p.wasm.status===\"failure\")return c.debug(\"dash\",\"WASM MPD Parser not initialized. Running JS one.\"),I();{let v=hf(l);if(!If(v))return c.info(\"dash\",\"MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),I();if(p.wasm.status===\"initialized\"){c.debug(\"dash\",\"Running WASM MPD Parser.\");let T=p.wasm.runWasmParser(v,h);return y(T)}else return c.debug(\"dash\",\"Awaiting WASM initialization before parsing the MPD.\"),p.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(p.wasm===null||p.wasm.status!==\"initialized\")return c.warn(\"dash\",\"WASM MPD parser initialization failed. Running JS parser instead\"),I();c.debug(\"dash\",\"Running WASM MPD Parser.\");let P=p.wasm.runWasmParser(v,h);return y(P)})}function I(){if(p.js!==null){let v=gf(l),T=p.js(v,h);return y(T)}else throw new Error(\"No MPD parser is imported\")}function y(v){if(v.type===\"done\")return v.value.warnings.length>0&&o(v.value.warnings),s.isCancelled()?Promise.reject(s.cancellationError):{manifest:new ht(v.value.parsed,n),url:d};let{value:T}=v,P=T.urls.map(_=>u(()=>{let M=L.getCurrent().DEFAULT_REQUEST_TIMEOUT,A=L.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return T.format===\"string\"?he({url:_,responseType:\"text\",timeout:M,connectionTimeout:A,cancelSignal:s}):he({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 K(M,{responseData:{success:!0,data:M.responseData}})}else{if(!(M.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return K(M,{responseData:{success:!0,data:M.responseData}})}},M=>{let A=ce(M,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return K({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:A}})}));return Promise.all(P).then(_=>T.format===\"string\"?(cf(_),y(T.continue(_))):(pf(_),y(T.continue(_))))}}}function cf(n){b.CURRENT_ENV!==b.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 pf(n){b.CURRENT_ENV!==b.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 gf(n){if(n instanceof ArrayBuffer)return He(new Uint8Array(n));if(typeof n==\"string\")return n;if(!C(ee.Document)&&n instanceof ee.Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function hf(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return sn(n).buffer;if(!C(ee.Document)&&n instanceof ee.Document)return sn(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function If(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 We([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function Nt(n,e){return n===null?null:e.url===null?n.baseUrl:Ln(n.baseUrl,e.url)}function ar(n,e,t,r,i){var l,f;let a=n;((l=t.cmcdPayload)==null?void 0:l.type)===\"query\"&&(a=je(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(d=>({resultType:\"segment-loaded\",resultData:d}));if(e.indexRange===void 0)return he({url:a,headers:oe(J({},o),{Range:We(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(d=>({resultType:\"segment-loaded\",resultData:d}));if(e.range[1]+1===e.indexRange[0])return he({url:a,headers:oe(J({},o),{Range:We([e.range[0],e.indexRange[1]])}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(d=>({resultType:\"segment-loaded\",resultData:d}));let s=he({url:a,headers:oe(J({},o),{Range:We(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),u=he({url:a,headers:oe(J({},o),{Range:We(e.indexRange)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([s,u]).then(([d,m])=>{let g=At(new Uint8Array(d.responseData),new Uint8Array(m.responseData)),h=Math.min(d.sendingTime,m.sendingTime),p=Math.max(d.receivedTime,m.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:a,responseData:g,size:d.size+m.size,requestDuration:p-h,sendingTime:h,receivedTime:p}}})}async function or(n,e,t,r){let i=null;function a(s){let u=new Uint8Array(s.chunk),l=i!==null?At(i,u):u,f=_r(l),d=f[0];i=f[1],!(d!==null&&(d.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 pr({url:n,headers:e.headers,onData:a,timeout:e.timeout,connectionTimeout:e.connectionTimeout,cancelSignal:r})}}async function fu(n,e,t,r,i,a){var m,g;if(e.segment.isInit)return ar(n,e.segment,r,a,i);let o=((m=r.cmcdPayload)==null?void 0:m.type)===\"query\"?je(n,r.cmcdPayload.value):n,s=((g=r.cmcdPayload)==null?void 0:g.type)===\"headers\"?r.cmcdPayload.value:void 0,{segment:u}=e,l;u.range!==void 0?l=oe(J({},s),{Range:We(u.range)}):s!==void 0&&(l=s);let f=Ye(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(nn())return or(o,{headers:l,timeout:r.timeout,connectionTimeout:r.connectionTimeout},i,a);nt(\"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:l,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress})}}function Ha({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:ti(r);function r(i,a,o,s,u){let l=Nt(i,a.segment);return l===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?fu(l,a,n,o,u,s):new Promise((f,d)=>{let m=!1,y={reject:_=>{var B,D;if(m||s.isCancelled())return;m=!0,s.deregister(P);let M=_,A=(B=M==null?void 0:M.message)!=null?B:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",x=new $e(A,(D=M==null?void 0:M.canRetry)!=null?D:!1,M==null?void 0:M.xhr);d(x)},resolve:_=>{if(m||s.isCancelled())return;m=!0,s.deregister(P);let M;_.data instanceof Uint8Array?_.data.buffer instanceof ArrayBuffer?M=_.data:M=_.data.slice():M=_.data,f({resultType:\"segment-loaded\",resultData:{responseData:M,size:_.size,requestDuration:_.duration}})},progress:_=>{m||s.isCancelled()||u.onProgress({duration:_.duration,size:_.size,totalSize:_.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(P),fu(l,a,n,o,u,s).then(f,d))}},E;a.segment.range!==void 0&&(E=[a.segment.range],a.segment.indexRange!==void 0&&E.push(a.segment.indexRange));let v={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:E,trackType:a.type,url:l,cmcdPayload:o.cmcdPayload},T=e(v,y);s.register(P);function P(_){m||(m=!0,typeof T==\"function\"&&T(),d(_))}})}}var ja=408125543,mu=357149030,bf=2807729,yf=17545,Sf=475249515,Tf=187,Ef=179,_f=183,Rf=241;function _t(n,e,t,[r,i]){let a=r;for(;a<i;){let o=vf(t,a);if(o===null)return null;let{value:s,length:u}=o,l=a+u,f=Cf(t,l);if(f===null)return null;let{length:d,value:m}=f,g=l+d,h=g+m;if(s===n)return[g,h];if(e.length>0){for(let p=0;p<e.length;p++)if(s===e[p]){let I=e.slice(p+1,e.length);return _t(n,I,t,[g,h])}}a=h}return null}function ni(n,e){let t=_t(bf,[ja,mu],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/Ka(n,t[0],r)}function Pf(n,e){let t=_t(yf,[ja,mu],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?Af(n,t[0]):r===8?xf(n,t[0]):null}function Ya(n,e){let t=_t(ja,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=ni(n,r);if(a===null)return null;let o=Pf(n,r);if(o===null)return null;let s=_t(Sf,[],n,[r,i]);if(s===null)return null;let u=[],l=s[0];for(;l<s[1];){let d=_t(Tf,[],n,[l,s[1]]);if(d===null)break;let m=_t(Ef,[],n,[d[0],d[1]]);if(m===null)return null;let g=Ka(n,m[0],m[1]-m[0]),h=_t(Rf,[_f],n,[d[0],d[1]]);if(h===null)return null;let p=Ka(n,h[0],h[1]-h[0])+r;u.push({time:g,rangeStart:p}),l=d[1]}let f=[];for(let d=0;d<u.length;d++){let m=u[d];d===u.length-1?f.push({time:m.time,timescale:a,duration:d===0?o:o-m.time,range:[m.rangeStart,1/0]}):f.push({time:m.time,timescale:a,duration:u[d+1].time-m.time,range:[m.rangeStart,u[d+1].rangeStart-1]})}return f}function cu(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function vf(n,e){let t=cu(n,e);if(t===void 0)return c.warn(\"webm\",\"unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm\",\"impossible length\",{offset:e,length:t,bufferLength:n.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 Cf(n,e){let t=cu(n,e);if(t===void 0)return c.warn(\"webm\",\"unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm\",\"impossible length\",{offset:e,length:t,bufferLength:n.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 Af(n,e){return new DataView(n.buffer).getFloat32(e)}function xf(n,e){return new DataView(n.buffer).getFloat64(e)}function Ka(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 sr(n,e,t,r){let i=Ti(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=Ei(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,l=Math.min(r*.9,u/4);return o!==void 0&&Math.abs(o-u)<=l&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function kf(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=He(o),u=Date.parse(s);if(a===void 0||u===void 0||isNaN(u)||u>=a)return!0}return!1}function Qa(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:kf(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function $a({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var v,T;let{segment:a,periodStart:o,periodEnd:s}=r,{data:u,isChunked:l}=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 d=xo(u),m=Ye(r.type,r.mimeType),g=m===\"mp4\"||m===void 0,h=[];if(g){let P=Rr(d),_;a.isInit&&(_=(v=Bo(d))!=null?v:void 0),(P.length>0||_!==void 0)&&h.push({initDataType:\"cenc\",keyId:_,initData:P})}if(!a.isInit){let P=g?sr(d,l,a,i):null,_=(T=a.timestampOffset)!=null?T:0;if(g){let M=Do(d);if(M!==void 0){let A=M.filter(B=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(B)),x=Qa(A,r.manifestPublishTime);if(x!==void 0){let{needsManifestRefresh:B,inbandEvents:D}=x;return{segmentType:\"media\",chunkData:d,chunkSize:d.length,chunkInfos:P,chunkOffset:_,appendWindow:f,inbandEvents:D,protectionData:h,needsManifestRefresh:B}}}}return{segmentType:\"media\",chunkData:d,chunkSize:d.length,chunkInfos:P,chunkOffset:_,protectionData:h,appendWindow:f}}let{indexRange:p}=a,I;if(m===\"webm\")I=Ya(d,0);else if(g&&(I=fn(d,Array.isArray(p)?p[0]:0),n===!0&&I!==null&&I.length>0)){let P=I[I.length-1];Array.isArray(P.range)&&(P.range[1]=1/0)}let y;g?y=mn(d):m===\"webm\"&&(y=ni(d,0));let E=C(y)?void 0:y;return{segmentType:\"init\",initializationData:d,initializationDataSize:d.length,protectionData:h,initTimescale:E,segmentList:I!=null?I:void 0}}}function Xa({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:ti(t);async function t(r,i,a,o,s){var I,y;let{segment:u}=i,l=Nt(r,u);if(l===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(u.isInit)return ar(l,u,a,o,s);let f=((I=a.cmcdPayload)==null?void 0:I.type)===\"query\"?je(l,a.cmcdPayload.value):l,d=((y=a.cmcdPayload)==null?void 0:y.type)===\"headers\"?a.cmcdPayload.value:void 0,m;u.range!==void 0?m=oe(J({},d),{Range:We(u.range)}):d!==void 0&&(m=d);let g=Ye(i.type,i.mimeType),h=g===\"mp4\"||g===void 0;if(n&&h){if(nn())return or(f,{headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout},s,o);nt(\"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 p;return h?p=await he({url:f,responseType:\"arraybuffer\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}):p=await he({url:f,responseType:\"text\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}),{resultType:\"segment-loaded\",resultData:p}}}function Mf(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 Of(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 pu({segment:n,language:e,codecs:t},r,i,a,o){if(n.isInit)return null;let s,u;a===null?o?(s=n.time,u=n.end):c.warn(\"utils\",\"Unavailable time data for current text track.\"):(s=a.time,a.duration!==void 0?u=s+a.duration:!o&&n.complete&&(u=s+n.duration));let l=Mf(t),f=yi(r),d=f!==null?He(f):\"\";return t===\"wvtt\"&&!Oe(d,\"WEBVTT\")&&!Oe(d,\"\\xFE\\xFFWEBVTT\")?{data:r,type:\"mp4vtt\",language:e,start:s,end:u,initTimescale:i!=null?i:null}:{data:d,type:l,language:e,start:s,end:u,initTimescale:i!=null?i:null}}function gu(n,e,t,r){let{segment:i}=n;if(i.isInit)return null;let a,o;r?c.warn(\"utils\",\"Unavailable time data for current text track.\"):(a=i.time,i.complete&&(o=i.time+i.duration));let s=Of(n.codecs,n.mimeType);return{data:e,type:s,language:n.language,start:a,end:o,initTimescale:t!=null?t:null}}function wf(n,e,t,r,i){var m;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=fn(u,Array.isArray(s)?s[0]:0);if(i===!0&&g!==null&&g.length>0){let p=g[g.length-1];Array.isArray(p.range)&&(p.range[1]=1/0)}let h=mn(u);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:h,segmentList:g!=null?g:void 0}}let l=sr(u,e,a,r),f=pu(t,u,r,l,e),d=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:f,chunkSize:u.length,chunkInfos:l,chunkOffset:d,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Df(n,e,t,r){let{periodStart:i,periodEnd:a,segment:o}=r,{timestampOffset:s=0}=o;if(o.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let u,l;if(typeof n!=\"string\"){let d=n instanceof Uint8Array?n:new Uint8Array(n);u=He(d),l=d.length}else u=n;return{segmentType:\"media\",chunkData:gu(r,u,e,t),chunkSize:l,chunkInfos:null,chunkOffset:s,protectionData:[],appendWindow:[i,a]}}function Za({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var d;let{periodStart:a,periodEnd:o,segment:s}=r,{data:u,isChunked:l}=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:(d=s.timestampOffset)!=null?d:0,protectionData:[],appendWindow:[a,o]};let f=Ye(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?wf(u,l,r,i,n):Df(u,i,l,r)}}async function hu(n,e,t,r){var u,l;let i=Nt(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\"?je(i,t.cmcdPayload.value):i,o=((l=t.cmcdPayload)==null?void 0:l.type)===\"headers\"?t.cmcdPayload.value:void 0,s;return e.range!==void 0?s=oe(J({},o),{Range:We(e.range)}):o!==void 0&&(s=o),rn({url:a,responseType:\"arraybuffer\",headers:s,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r})}function Iu(n,e){var l;let{thumbnailTrack:t,thumbnail:r}=e,i=t.height/t.verticalTiles,a=t.width/t.horizontalTiles,o=[],s=(l=t.tileDuration)!=null?l:(r.end-r.time)/(t.horizontalTiles*t.verticalTiles),u=r.time;for(let f=0;f<t.verticalTiles;f++)for(let d=0;d<t.horizontalTiles;d++)o.push({start:u,end:u+s,offsetX:Math.round(d*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 bu(n){let e=Wa({customManifestLoader:n.manifestLoader},Bf()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?lu:null),t=Ga(n),r=Ha(n),i=$a(n),a=Xa(n),o=Za(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:hu,parseThumbnail:Iu}}}function Bf(){return ke.dashParsers.wasm!==null&&(ke.dashParsers.wasm.status===\"initialized\"||ke.dashParsers.wasm.status===\"initializing\")}var yu=bu;var Nf=new du;ke.dashParsers.wasm=Nf;ke.dashParsers.js=Qs;ke.transports.dash=yu;ee.onmessageerror=n=>{zr.error(\"Core\",\"Error when receiving message from main thread.\")};ks(n=>{onmessage=n},Uf);function Uf(n,e){Lf(n),n.type!==\"log\"&&zr.debug(\"M<--C\",\"Sending message from worker\",{name:n.type}),e===void 0?postMessage(n):postMessage(n,e)}function Lf(n){(n.type===\"manifest-ready\"||n.type===\"manifest-update\")&&(n.value.manifest instanceof ht?(n.value.manifest=n.value.manifest.getMetadataSnapshot(),n.type===\"manifest-update\"&&(n.value.manifest.periods=[])):zr.warn(\"Core\",\"the Manifest instance should be communicated to `sendMessage`.\"))}})();\n" + "})()"], { type: "application/javascript" });
2
2
  export { blob as EMBEDDED_WORKER };
3
3
  export default blob;