rx-player 4.5.0-dev.2026031700 → 4.5.0-dev.2026033100

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 (222) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  5. package/dist/commonjs/compat/browser_compatibility_types.d.ts +16 -14
  6. package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
  7. package/dist/commonjs/compat/browser_compatibility_types.js +7 -4
  8. package/dist/commonjs/compat/browser_version.d.ts +2 -1
  9. package/dist/commonjs/compat/browser_version.d.ts.map +1 -1
  10. package/dist/commonjs/compat/browser_version.js +13 -0
  11. package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
  12. package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.js +1 -1
  13. package/dist/commonjs/compat/is_codec_supported.d.ts.map +1 -1
  14. package/dist/commonjs/compat/is_codec_supported.js +4 -3
  15. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
  16. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
  17. package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +45 -0
  18. package/dist/commonjs/core/entry/utils.js +3 -3
  19. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  20. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -1
  21. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  22. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
  23. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  24. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +8 -6
  25. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  26. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +4 -3
  27. package/dist/commonjs/initialize_worker.js +1 -1
  28. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
  29. package/dist/commonjs/main_thread/api/public_api.js +2 -2
  30. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  31. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +24 -12
  32. package/dist/commonjs/manifest/classes/adaptation.d.ts.map +1 -1
  33. package/dist/commonjs/manifest/classes/adaptation.js +3 -1
  34. package/dist/commonjs/manifest/classes/representation.d.ts +6 -2
  35. package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
  36. package/dist/commonjs/manifest/classes/representation.js +45 -23
  37. package/dist/commonjs/manifest/types.d.ts +14 -6
  38. package/dist/commonjs/manifest/types.d.ts.map +1 -1
  39. package/dist/commonjs/manifest/utils.js +4 -4
  40. package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
  41. package/dist/commonjs/mse/main_media_source_interface.js +3 -2
  42. package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
  43. package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts +12 -1
  44. package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts.map +1 -1
  45. package/dist/commonjs/parsers/containers/isobmff/get_box.js +16 -0
  46. package/dist/commonjs/parsers/containers/isobmff/index.d.ts +2 -1
  47. package/dist/commonjs/parsers/containers/isobmff/index.d.ts.map +1 -1
  48. package/dist/commonjs/parsers/containers/isobmff/index.js +3 -1
  49. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
  50. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
  51. package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.js +180 -0
  52. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
  53. package/dist/commonjs/transports/dash/segment_parser.d.ts.map +1 -1
  54. package/dist/commonjs/transports/dash/segment_parser.js +6 -0
  55. package/dist/commonjs/transports/dash/text_parser.d.ts.map +1 -1
  56. package/dist/commonjs/transports/dash/text_parser.js +5 -1
  57. package/dist/commonjs/transports/local/text_parser.d.ts.map +1 -1
  58. package/dist/commonjs/transports/local/text_parser.js +5 -1
  59. package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
  60. package/dist/commonjs/transports/metaplaylist/pipelines.js +2 -1
  61. package/dist/commonjs/transports/smooth/pipelines.js +3 -3
  62. package/dist/commonjs/transports/types.d.ts +28 -2
  63. package/dist/commonjs/transports/types.d.ts.map +1 -1
  64. package/dist/commonjs/transports/utils/parse_text_track.d.ts +9 -2
  65. package/dist/commonjs/transports/utils/parse_text_track.d.ts.map +1 -1
  66. package/dist/commonjs/transports/utils/parse_text_track.js +1 -1
  67. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  68. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  69. package/dist/es2017/compat/browser_compatibility_types.d.ts +16 -14
  70. package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
  71. package/dist/es2017/compat/browser_compatibility_types.js +7 -1
  72. package/dist/es2017/compat/browser_version.d.ts +2 -1
  73. package/dist/es2017/compat/browser_version.d.ts.map +1 -1
  74. package/dist/es2017/compat/browser_version.js +13 -1
  75. package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
  76. package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.js +2 -2
  77. package/dist/es2017/compat/is_codec_supported.d.ts.map +1 -1
  78. package/dist/es2017/compat/is_codec_supported.js +2 -1
  79. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
  80. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
  81. package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +42 -0
  82. package/dist/es2017/core/entry/utils.js +4 -4
  83. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  84. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +2 -1
  85. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  86. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
  87. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  88. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +3 -1
  89. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
  90. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +2 -1
  91. package/dist/es2017/initialize_worker.js +1 -1
  92. package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
  93. package/dist/es2017/main_thread/api/public_api.js +2 -2
  94. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
  95. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +9 -7
  96. package/dist/es2017/manifest/classes/adaptation.d.ts.map +1 -1
  97. package/dist/es2017/manifest/classes/adaptation.js +3 -1
  98. package/dist/es2017/manifest/classes/representation.d.ts +6 -2
  99. package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
  100. package/dist/es2017/manifest/classes/representation.js +45 -23
  101. package/dist/es2017/manifest/types.d.ts +14 -6
  102. package/dist/es2017/manifest/types.d.ts.map +1 -1
  103. package/dist/es2017/manifest/utils.js +4 -4
  104. package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
  105. package/dist/es2017/mse/main_media_source_interface.js +2 -1
  106. package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
  107. package/dist/es2017/parsers/containers/isobmff/get_box.d.ts +12 -1
  108. package/dist/es2017/parsers/containers/isobmff/get_box.d.ts.map +1 -1
  109. package/dist/es2017/parsers/containers/isobmff/get_box.js +16 -1
  110. package/dist/es2017/parsers/containers/isobmff/index.d.ts +2 -1
  111. package/dist/es2017/parsers/containers/isobmff/index.d.ts.map +1 -1
  112. package/dist/es2017/parsers/containers/isobmff/index.js +2 -1
  113. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
  114. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
  115. package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.js +155 -0
  116. package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
  117. package/dist/es2017/transports/dash/segment_parser.d.ts.map +1 -1
  118. package/dist/es2017/transports/dash/segment_parser.js +7 -1
  119. package/dist/es2017/transports/dash/text_parser.d.ts.map +1 -1
  120. package/dist/es2017/transports/dash/text_parser.js +5 -1
  121. package/dist/es2017/transports/local/text_parser.d.ts.map +1 -1
  122. package/dist/es2017/transports/local/text_parser.js +5 -1
  123. package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
  124. package/dist/es2017/transports/metaplaylist/pipelines.js +2 -1
  125. package/dist/es2017/transports/smooth/pipelines.js +3 -3
  126. package/dist/es2017/transports/types.d.ts +28 -2
  127. package/dist/es2017/transports/types.d.ts.map +1 -1
  128. package/dist/es2017/transports/utils/parse_text_track.d.ts +9 -2
  129. package/dist/es2017/transports/utils/parse_text_track.d.ts.map +1 -1
  130. package/dist/es2017/transports/utils/parse_text_track.js +1 -1
  131. package/dist/worker.js +6 -6
  132. package/eslint.config.mjs +1 -14
  133. package/package.json +1 -1
  134. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  135. package/src/compat/__tests__/browser_compatibility_types.test.ts +15 -26
  136. package/src/compat/__tests__/browser_version.test.ts +57 -18
  137. package/src/compat/__tests__/clear_element_src.test.ts +20 -40
  138. package/src/compat/__tests__/is_codec_supported.test.ts +39 -44
  139. package/src/compat/__tests__/is_vtt_cue.test.ts +5 -8
  140. package/src/compat/__tests__/make_vtt_cue.test.ts +20 -31
  141. package/src/compat/__tests__/remove_cue.test.ts +8 -20
  142. package/src/compat/__tests__/should_patch_out_dolby_vision_config_data_from_mp4.test.ts +78 -0
  143. package/src/compat/browser_compatibility_types.ts +8 -1
  144. package/src/compat/browser_version.ts +17 -1
  145. package/src/compat/disable_remote_playback_on_managed_media_source.ts +2 -2
  146. package/src/compat/is_codec_supported.ts +2 -1
  147. package/src/compat/should_patch_out_dolby_vision_config_data_from_mp4.ts +50 -0
  148. package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +68 -28
  149. package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +26 -84
  150. package/src/core/entry/__tests__/utils.test.ts +7 -1
  151. package/src/core/entry/utils.ts +4 -4
  152. package/src/core/fetchers/segment/segment_fetcher.ts +2 -1
  153. package/src/errors/__tests__/format_error.test.ts +23 -24
  154. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +2 -1
  155. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +106 -0
  156. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/HDCPPolicy.test.ts +19 -42
  157. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/decodingInfo.test.ts +33 -40
  158. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/defaultCodecsFinder.test.ts +44 -68
  159. package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/mediaContentType.test.ts +45 -80
  160. package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +3 -1
  161. package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +2 -1
  162. package/src/features/__tests__/add_features.test.ts +12 -27
  163. package/src/initialize_worker.ts +1 -1
  164. package/src/main_thread/api/__tests__/option_utils.test.ts +38 -67
  165. package/src/main_thread/api/__tests__/public_api.test.ts +56 -138
  166. package/src/main_thread/api/debug/modules/segment_buffer_content.ts +3 -3
  167. package/src/main_thread/api/public_api.ts +2 -2
  168. package/src/main_thread/decrypt/__tests__/__global__/find_key_system.test.ts +46 -28
  169. package/src/main_thread/decrypt/__tests__/__global__/get_license.test.ts +40 -10
  170. package/src/main_thread/decrypt/__tests__/__global__/init_data.test.ts +112 -129
  171. package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +282 -377
  172. package/src/main_thread/decrypt/__tests__/__global__/media_keys.test.ts +70 -63
  173. package/src/main_thread/decrypt/__tests__/__global__/server_certificate.test.ts +73 -54
  174. package/src/main_thread/decrypt/__tests__/__global__/utils.ts +43 -83
  175. package/src/main_thread/decrypt/__tests__/find_key_system.test.ts +36 -17
  176. package/src/main_thread/decrypt/utils/__tests__/clean_old_stored_persistent_info.test.ts +44 -48
  177. package/src/main_thread/init/utils/__tests__/are_same_stream_events.test.ts +7 -22
  178. package/src/main_thread/init/utils/__tests__/refresh_scheduled_events_list.test.ts +3 -6
  179. package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +42 -19
  180. package/src/main_thread/init/utils/update_manifest_codec_support.ts +8 -6
  181. package/src/manifest/classes/__tests__/adaptation.test.ts +69 -125
  182. package/src/manifest/classes/__tests__/manifest.test.ts +88 -95
  183. package/src/manifest/classes/__tests__/period.test.ts +167 -117
  184. package/src/manifest/classes/__tests__/representation.test.ts +84 -25
  185. package/src/manifest/classes/__tests__/update_periods.test.ts +96 -225
  186. package/src/manifest/classes/adaptation.ts +4 -1
  187. package/src/manifest/classes/representation.ts +59 -27
  188. package/src/manifest/types.ts +14 -6
  189. package/src/manifest/utils.ts +4 -4
  190. package/src/mse/__tests__/main_media_source_interface.test.ts +3 -1
  191. package/src/mse/__tests__/worker_media_source_interface.test.ts +608 -0
  192. package/src/mse/main_media_source_interface.ts +2 -1
  193. package/src/mse/worker_media_source_interface.ts +2 -2
  194. package/src/parsers/containers/isobmff/__tests__/get_box.test.ts +449 -0
  195. package/src/parsers/containers/isobmff/__tests__/remove_dolby_vision_config_data.test.ts +282 -0
  196. package/src/parsers/containers/isobmff/get_box.ts +17 -0
  197. package/src/parsers/containers/isobmff/index.ts +8 -1
  198. package/src/parsers/containers/isobmff/remove_dolby_vision_config_data.ts +179 -0
  199. package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +19 -25
  200. package/src/parsers/manifest/dash/common/__tests__/get_http_utc-timing_url.test.ts +7 -19
  201. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentProtection.test.ts +26 -37
  202. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/Initialization.test.ts +24 -53
  203. package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentURL.test.ts +31 -78
  204. package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +6 -4
  205. package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +79 -87
  206. package/src/parsers/texttracks/ttml/__tests__/resolve_styles_inheritance.test.ts +20 -26
  207. package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.ts +2 -7
  208. package/src/parsers/texttracks/webvtt/__tests__/parse_cue_block.test.ts +33 -30
  209. package/src/parsers/texttracks/webvtt/__tests__/parse_style_block.test.ts +33 -100
  210. package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +16 -18
  211. package/src/parsers/texttracks/webvtt/html/__tests__/parse_webvtt_to_div.test.ts +73 -78
  212. package/src/parsers/texttracks/webvtt/html/__tests__/to_html.test.ts +36 -37
  213. package/src/transports/dash/segment_parser.ts +13 -0
  214. package/src/transports/dash/text_parser.ts +5 -1
  215. package/src/transports/local/text_parser.ts +5 -1
  216. package/src/transports/metaplaylist/pipelines.ts +2 -1
  217. package/src/transports/smooth/isobmff/__tests__/create_boxes.test.ts +150 -127
  218. package/src/transports/smooth/pipelines.ts +3 -3
  219. package/src/transports/types.ts +28 -2
  220. package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +49 -75
  221. package/src/transports/utils/parse_text_track.ts +10 -3
  222. package/src/utils/__tests__/object_assign.test.ts +2 -2
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EMBEDDED_WORKER = void 0;
4
- var blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Rd=Object.defineProperty,Pd=Object.defineProperties;var vd=Object.getOwnPropertyDescriptors;var eo=Object.getOwnPropertySymbols;var Cd=Object.prototype.hasOwnProperty,Ad=Object.prototype.propertyIsEnumerable;var to=(n,e,t)=>e in n?Rd(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,J=(n,e)=>{for(var t in e||(e={}))Cd.call(e,t)&&to(n,t,e[t]);if(eo)for(var t of eo(e))Ad.call(e,t)&&to(n,t,e[t]);return n},se=(n,e)=>Pd(n,vd(e));var I={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var no={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,FORCE_INITIAL_SEEK_TO_ZERO:!1},ro=no;function kd(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:kd;function ii(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(ii(n)&&ii(t))for(let r in t)if(ii(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 v(n){return n==null}function O(){}var fe=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=O;if(r!==void 0){if(r.isCancelled())return;i=r.register(()=>this.removeEventListener(e,t))}let a=this._listeners[e];Array.isArray(a)?a.push({cb:t,onRemove:i}):this._listeners[e]=[{cb:t,onRemove:i}]}removeEventListener(e,t){if(v(e)){for(let i of Object.keys(this._listeners)){let a=this._listeners[i];Array.isArray(a)&&a.forEach(o=>o.onRemove())}this._listeners={};return}let r=this._listeners[e];if(Array.isArray(r)){if(v(t)){r.forEach(i=>i.onRemove()),delete this._listeners[e];return}for(let i=0;i<r.length;i++)if(r[i].cb===t){r[i].onRemove(),r.splice(i,1);break}r.length===0&&delete this._listeners[e]}}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i.cb(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 ai=class extends fe{constructor(){super(...arguments);this.updated=!1;this._config=ro}update(t){let r=en(this._config,t);this._config=r,this.updated=!0,this.trigger(\"update\",t)}getCurrent(){return this._config}},Md=new ai,L=Md;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}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 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 lr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var X=lr;var oi=new X(0);function io({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;oi.setValueIfChanged(r-t)}var Od=typeof performance!=\"undefined\"?()=>performance.now()+oi.getValue():()=>Date.now()+oi.getValue(),F=Od;var wd=\"NONE\",Rt=class extends fe{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=wd}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 d=F();console.log(String(d.toFixed(2)),\"[Init]\",`Local-Date: ${Date.now()}`)}this._currentFormat=o;let s=this._currentFormat===\"full\"?(d,u)=>(f,...l)=>{let m=F();return u(String(m.toFixed(2)),`[${d}]`,f+\":\",...l.map(p=>typeof p==\"object\"&&p!==null&&!(p instanceof Error)?ao(p):p))}:(d,u)=>(f,...l)=>u(f+\":\",...l.map(m=>typeof m==\"object\"&&m!==null&&!(m instanceof Error)?ao(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 d=u=>i>=this._levels[u]?(f,...l)=>r(u,f,l):O;this.error=d(\"ERROR\"),this.warn=d(\"WARNING\"),this.info=d(\"INFO\"),this.debug=d(\"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 ao(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 Dd=new Rt,c=Dd;var fr=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var Bd=typeof window==\"undefined\"&&!fr,mr=Bd;var cr;fr?cr=self:mr?cr=global:cr=window;var ee=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}}},Re={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var si=typeof Headers==\"function\"?Headers:null,pr=typeof AbortController==\"function\"?AbortController:null;function gr(n){var m,p;let e;if(!v(n.headers))if(v(si))e=n.headers;else{e=new si;let h=Object.keys(n.headers);for(let b=0;b<h.length;b++){let g=h[b];e.append(g,n.headers[g])}}c.debug(\"utils\",\"Fetch\",{url:n.url});let t=null,r=!1,i=!1,a=F(),o=v(pr)?null:new pr;function s(){if(v(o)){c.warn(\"utils\",\"Fetch: AbortController API not available.\");return}o.abort()}let d;n.timeout!==void 0&&(d=setTimeout(()=>{r=!0,u!==void 0&&clearTimeout(u),s()},n.timeout));let u;n.connectionTimeout!==void 0&&(u=setTimeout(()=>{i=!0,d!==void 0&&clearTimeout(d),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 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=\"+((p=n.headers)==null?void 0:p.Range)),c.debug(\"utils\",h)}return fetch(n.url,l).then(h=>{if(u!==void 0&&clearTimeout(u),h.status>=300)throw c.warn(\"utils\",\"Fetch: Request HTTP Error\",{status:h.status,responseUrl:h.url}),new de(h.url,h.status,Re.ERROR_HTTP_CODE);if(v(h.body))throw new de(h.url,h.status,Re.PARSE_ERROR);let b=h.headers.get(\"Content-Length\"),g=!v(b)&&!isNaN(+b)?+b:void 0,y=h.body.getReader(),T=0;return R();async function R(){let E=await y.read();if(!E.done&&!v(E.value)){T+=E.value.byteLength;let C=F(),P={url:h.url,currentTime:C,duration:C-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:T,totalSize:g};return n.onData(P),R()}else if(E.done){d!==void 0&&clearTimeout(d),f();let C=F();return{requestDuration:C-a,receivedTime:C,sendingTime:a,size:T,status:h.status,url:h.url}}return R()}}).catch(h=>{throw t!==null?t:(f(),r?(c.warn(\"utils\",\"Fetch: Request timed out.\",{url:n.url,timeout:n.timeout}),new de(n.url,0,Re.TIMEOUT)):i?(c.warn(\"utils\",\"Fetch: Request connection timed out.\",{url:n.url,connectionTimeout:n.connectionTimeout}),new de(n.url,0,Re.TIMEOUT)):h instanceof de?h:(c.warn(\"utils\",\"Fetch: Request Error\",{error:h instanceof Error?h.toString():\"Unkwown Error\"}),new de(n.url,0,Re.ERROR_EVENT)))})}function nn(){let n=/\\[\\s*native\\s+code\\s*\\]/;return typeof ee.fetch==\"function\"&&!v(pr)&&n.test(pr.toString())&&!v(si)}function Q(n){return typeof n==\"string\"&&n.length>0}var Nd=\"json\";function rn(n){let e={url:n.url,headers:n.headers,responseType:v(n.responseType)?Nd:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:d,timeout:u,connectionTimeout:f}=e,l=new XMLHttpRequest;l.open(\"GET\",o,!0);let m;u!==void 0&&(l.timeout=u,m=setTimeout(()=>{g(),r(new de(o,l.status,Re.TIMEOUT))},u+3e3));let p;if(f!==void 0&&(p=setTimeout(()=>{g(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new de(o,l.status,Re.TIMEOUT))},f)),l.responseType=d,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!v(s)){let y=s;for(let T in y)Object.prototype.hasOwnProperty.call(y,T)&&l.setRequestHeader(T,y[T])}let h=F(),b=null;if(a!==void 0&&(b=a.register(function(T){g(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(T)}),a.isCancelled()))return;if(l.onerror=function(){g(),r(new de(o,l.status,Re.ERROR_EVENT))},l.ontimeout=function(){g(),r(new de(o,l.status,Re.TIMEOUT))},f!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(p)}),i!==void 0&&(l.onprogress=function(T){let R=F();i({url:o,duration:R-h,sendingTime:h,currentTime:R,size:T.loaded,totalSize:T.total})}),l.onload=function(T){if(l.readyState===XMLHttpRequest.DONE)if(g(),l.status>=200&&l.status<300){let R=F(),E=l.response instanceof ArrayBuffer?l.response.byteLength:T.total,C=l.status,P=l.responseType,x=Q(l.responseURL)?l.responseURL:o,A;if(P===\"json\"?A=typeof l.response==\"object\"?l.response:Ud(l.responseText):A=l.response,v(A)){r(new de(o,l.status,Re.PARSE_ERROR));return}t({status:C,url:x,responseType:P,sendingTime:h,receivedTime:R,requestDuration:R-h,size:E,responseData:A})}else r(new de(o,l.status,Re.ERROR_HTTP_CODE))},c.hasLevel(\"DEBUG\")){let y=\"XHR GET \"+o;n.responseType!==void 0&&(y+=\" type=\"+n.responseType),u!==void 0&&(y+=\" to=\"+String(u/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)}l.send();function g(){m!==void 0&&clearTimeout(m),p!==void 0&&clearTimeout(p),b!==null&&b()}})}function Ud(n){try{return JSON.parse(n)}catch(e){return null}}var he=rn;var Pt=Re,Ve={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=Ve.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=Ve.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=Ve.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=Ve.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(Ve).indexOf(n.type)>=0}function pe(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 Ld={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},monothread:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},oo=Ld;var ke=oo;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 Fd={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\"},so=Fd;var zd={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\"},uo=zd;function qd(n){if(v(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=Wd(t);return Q(r)?r:n}function Wd(n){let e;switch(n.length){case 2:e=so[n];break;case 3:e=uo[n];break}return e}var lo=qd;var fo=lo;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 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(I.DEV===I.CURRENT_ENV&&!n)throw new Ir(e===void 0?\"invalid assertion\":e)}function Be(n){throw new Ir(\"Unreachable path taken\")}var Vd=typeof ee==\"object\"&&typeof ee.TextDecoder==\"function\",Gd=typeof ee==\"object\"&&typeof ee.TextEncoder==\"function\";function on(n){if(Gd)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 d=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(d),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let d=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(d),s=!0,o+=2}}s||(e+=t[o])}}let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i)&255;return r}function Hd(n){let t=\"\";for(let r=0;r<n.length;r+=16e3){let i=n.subarray(r,r+16e3);t+=String.fromCharCode.apply(null,i)}return t}function mo(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Ge(n){if(Vd)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=Hd(e),r;if(typeof escape==\"function\")r=escape(t);else{let i=/[A-Za-z0-9*_+-./]/;r=\"\";for(let a=0;a<t.length;a++)if(i.test(t[a]))r+=t[a];else{let o=t.charCodeAt(a);r+=o>=256?\"%u\"+mo(o,4):\"%\"+mo(o,2)}}return decodeURIComponent(r)}function sn(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 di(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:Ge(r)}}function ui(n){return Object.keys(n).map(e=>n[e])}var yr=typeof Object.values==\"function\"?Object.values:ui;var Lt=[\"audio\",\"video\",\"text\"];function po(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 go(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 ho(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=F()-e.time;return e.maximumSafePosition+t/1e3}function Io(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 bo(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 yo(n,e){let t=e.end;if(t===void 0)return null;let r=j(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function 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 ui(e).reduce((t,r)=>v(r)?t:t.concat(r),[])}function Kd(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=>dn(a)===!0):n.representations).map(Qd),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function jd(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 Yd(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>dn(s)===!0):i.representations).map(co),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=>dn(i)===!0):n.representations).map(co),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function Qd(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 co(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:d,decipherable:u,contentProtections:f}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:d,decipherable:u,contentProtections:f!==void 0?{keyIds:f.keyIds}:void 0}}function vt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:Kd(n,!1)};case\"video\":return{type:\"video\",track:Yd(n,!1)};case\"text\":return{type:\"text\",track:jd(n)}}}function dn(n){return n.decipherable===!1?!1:n.isSupported}function So(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}var $d=Me(),mi=class{constructor(e,t,r){var a,o,s,d,u;this.id=e.id,this.uniqueId=$d(),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((d=this.mimeType)!=null?d:\"\",(u=e.codecs)!=null?u:\"\",i)))}else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var s,d;if(this.isSupported!==void 0)return;let t=this.contentProtections!==void 0,r=!1,i=(s=this.mimeType)!=null?s:\"\",a=(d=this.codecs)!=null?d:[];a.length===0&&(a=[\"\"]);let o=!1;for(let u of a){if(r=e.isSupported(i,u,t),r===!0){this.codecs=[u];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 d=0;d<s.values.length;d++)if(s.values[d].systemId.toLowerCase()===e.toLowerCase())if(o)r[r.length-1].values.push(s.values[d]);else{let u=(i=this.contentProtections)==null?void 0:i.keyIds;r.push({type:s.type,keyIds:u,values:[s.values[d]]}),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 d of o)hr(d,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 d=0;d<r.length;d++){let u=r[d],f;for(f=0;f<s.length;f++)if(u.systemId===s[f].systemId){if(hr(u.data,s[f].data))break;c.warn(\"manifest\",\"different init data for the same system ID\",{systemId:u.systemId})}f===s.length&&(s.push(u),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}isPlayable(){return dn(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}}},un=mi;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=fo(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(u=>new n(u,t)));let s=e.representations,d=[];this.supportStatus={hasSupportedCodec:!1,hasCodecWithUndefinedSupport:!1,isDecipherable:!1};for(let u=0;u<s.length;u++){let f=new un(s[u],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 p=f.contentProtections.keyIds;m.contentProtections.keyIds=p}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?(d.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})`)}d.sort((u,f)=>u.bitrate-f.bitrate),this.representations=d,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,To,Eo,_o,Ro,Po,mt=(Po=(Ro=(_o=(Eo=(To=be==null?void 0:be.MediaSource)!=null?To:be==null?void 0:be.MozMediaSource)!=null?Eo:be==null?void 0:be.WebKitMediaSource)!=null?_o:be==null?void 0:be.MSMediaSource)!=null?Ro:be==null?void 0:be.ManagedMediaSource)!=null?Po:void 0,Gg=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};Xd();function Xd(){var n,e,t;mr||(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 ci=ye;function pi(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(d){n.deregister(o),a=!0,r(d)},function(d){n.deregister(o),a=!0,i(d)}),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(e){let[t,r]=Zd();this._isUsed=!1,this._trigger=t,this._taskName=e,this.signal=new gi(r)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(r=>{this.cancel(r.reason)});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=new oe(this._taskName,e);this._trigger(t)}static isCancellationError(e){return e instanceof oe}},gi=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)}},oe=class n extends Error{constructor(e,t){let r=e!==void 0?`\"${e}\" task cancelled.`:\"This task was cancelled.\";t!==void 0&&(r+=\" Reason: \"+t),super(r),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\",this.reason=t,e!==void 0&&c.debug(\"utils\",`task cancellation: \"${e}\"`+(t===void 0?\"\":` - Reason: \"${t}\"`))}};function Zd(){let n=O;return[function(t){n(t)},function(t){n=t}]}var Jd=[\"\",\"webkit\",\"moz\",\"ms\"];function eu(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 tu(n,e){return e.filter(t=>eu(n,t))[0]}function nu(n,e){return n.reduce((t,r)=>t.concat((e===void 0?Jd:e).map(i=>i+r)),[])}function Pe(n,e){let t,r=nu(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=tu(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 d=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(d=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),d&&delete i[\"on\"+s]})})}}}var Ih=Pe([\"loadedmetadata\"]),bh=Pe([\"timeupdate\"]),yh=Pe([\"addtrack\"]),Sh=Pe([\"removetrack\"]),Ft=Pe([\"sourceopen\",\"webkitsourceopen\"]),Sr=Pe([\"sourceclose\",\"webkitsourceclose\"]),Tr=Pe([\"sourceended\",\"webkitsourceended\"]),vo=Pe([\"update\"]),Co=Pe([\"removesourcebuffer\"]),Th=Pe([\"keymessage\",\"message\"]),Eh=Pe([\"keyadded\",\"ready\"]),_h=Pe([\"keyerror\",\"error\"]),Rh=Pe([\"keystatuseschange\"]),Ph=Pe([\"seeking\"]),vh=Pe([\"seeked\"]),Ch=Pe([\"ended\"]);var Ao=[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>=Ao.length)throw new Error(\"Unable to parse base64 string.\");let e=Ao[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function _r(n){if(typeof Uint8Array.fromBase64==\"function\")return Uint8Array.fromBase64(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 d=0,u=0;d<a;d+=4,u+=3)s=Er(t.charCodeAt(d))<<18|Er(t.charCodeAt(d+1))<<12|Er(t.charCodeAt(d+2))<<6|Er(t.charCodeAt(d+3)),o[u]=s>>16,o[u+1]=s>>8&255,o[u+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 xo(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function hi(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function re(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function 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 ko(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 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=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 d=re(n,s+e),u=e+s+d;if(u>n.length)break;let f=Math.max(o,u),l=n.subarray(e,f);t.push(l),e=f}return t.length===0?[null,r]:[t,r]}function ru(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function iu(n,e,t){return n.slice(e,t)}var Ii=typeof Uint8Array.prototype.slice==\"function\"?iu:ru;function bi(n,e){let t=n;for(let r of e){let i=ge(t,r);if(i===null)return null;t=i}return t}function ge(n,e){let t=zt(n,e);return t!==null?n.subarray(t[1],t[2]):null}function Mo(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 Pr(n){let e=0,t=ge(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=zt(t,1886614376)}catch(s){let d=s instanceof Error?s:\"\";return c.warn(\"isobmff\",\"Error while removing PSSH from ISOBMFF\",d),r}if(i===null)return r;let a=Ii(t,i[0],i[2]),o=Oo(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 Oo(n,e){if(n[e]>1){c.warn(\"isobmff\",\"un-handled PSSH version\");return}let t=e+4;if(t+16>n.length)return;let r=Ii(n,t,t+16);return br(r)}function yi(n){let e=ge(n,1836019558);return e===null?null:ge(e,1953653094)}function wo(n){return Mo(n,1836019558).reduce((t,r)=>{let i=ge(r,1953653094);return i!==null&&t.push(i),t},[])}function Si(n){return ge(n,1835295092)}function Ti(n){let e=ge(n,1836019574);if(e===null)return null;let t=ge(e,1953653099);return t===null?null:ge(t,1835297121)}function Do(n,e=0){return ge(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 d;if(o===0)d=re(n,a),a+=4,r+=re(n,a)+i,a+=4;else if(o===1)d=pt(n,a),a+=8,r+=pt(n,a)+i,a+=8;else return null;let u=[];a+=2;let f=xo(n,a);for(a+=2;--f>=0;){let l=re(n,a);a+=4;let m=(l&2147483648)>>>31,p=l&2147483647;if(m===1)throw new Error(\"sidx with reference_type `1` not yet implemented\");let h=re(n,a);a+=4,a+=4,u.push({time:d,duration:h,timescale:s,range:[r,r+p-1]}),d+=h,r+=p}return u}function Ei(n){let e=yi(n);if(e===null)return;let t=ge(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 au(n){let e=ge(n,1952868452);if(e===null)return;let t=1,r=hi(e,t);t+=3;let i=(r&1)>0,a=(r&2)>0;return(r&8)>0?(t+=4,i&&(t+=8),a&&(t+=4),re(e,t)):void 0}function _i(n){let e=wo(n);if(e.length===0)return;let t=0;for(let r of e){let i=ge(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=hi(i,a);a+=3;let d=(s&256)>0,u=0;if(!d&&(u=au(r),u===void 0))return;let f=(s&1)>0,l=(s&4)>0,m=(s&512)>0,p=(s&1024)>0,h=(s&2048)>0,b=re(i,a);a+=4,f&&(a+=4),l&&(a+=4);let g=b,y=0;for(;g-- >0;)d?(y+=re(i,a),a+=4):y+=u,m&&(a+=4),p&&(a+=4),h&&(a+=4);t+=y}return t}function mn(n){let e=Ti(n);if(e===null)return;let t=ge(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 Bo(n){let e=[],t=0;for(;t<n.length;){let r=Do(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:d}=di(r,o);o=s;let{end:u,string:f}=di(r,o);o=u;let l=re(r,o);o+=4;let m=re(r,o);o+=4;let p=re(r,o);o+=4;let h=re(r,o);o+=4;let b=r.subarray(o,i),g={schemeIdUri:d,value:f,timescale:l,presentationTimeDelta:m,eventDuration:p,id:h,messageData:b};e.push(g)}}if(e.length!==0)return e}function No(n){let e=bi(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=ge(t,1701733238),i=0;if(r===null?(i=28,r=ge(t,1701733217)):i=78,r===null)return null;let a=bi(r.subarray(i),[1936289382,1935894633,1952804451]);if(a===null||a.byteLength<24)return null;let o=a.subarray(8,24);return o.every(s=>s===0)?null:o}function ue(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,d)=>s===d||typeof s==\"number\"&&typeof d==\"number\"&&isNaN(s)&&isNaN(d);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}function ou(n,e){let{mimeType:t,codecs:r}=Uo(n),{mimeType:i,codecs:a}=Uo(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 su=7;function Uo(n){var i;let[e,...t]=n.split(\";\"),r=(i=j(t,a=>Oe(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(su),r[0]==='\"'&&(r=r.substring(1,r.length-1)),{mimeType:e,codecs:r}}var Lo=ou;function Ri(n,e){return typeof Array.prototype.flatMap==\"function\"?n.flatMap(e):n.reduce((t,r)=>{let i=e(r);return Array.isArray(i)?(t.push(...i),t):(t.push(i),t)},[])}function Pi(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function Fo(n){var t,r,i,a,o;let e=[];for(let s of n.periods){let d=[...(t=s.adaptations.video)!=null?t:[],...(r=s.adaptations.audio)!=null?r:[]];for(let u of d)if(u.supportStatus.hasCodecWithUndefinedSupport)for(let f of u.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 zo=[];function tt(n){ue(zo,n)||(console.warn(n),zo.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=du(e.adaptations,t,r),qo(this.adaptations.video)&&qo(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 j(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return Io(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 qo(n){return Array.isArray(n)?n.length===0:!0}function du(n,e,t){let r={};for(let[i,a]of Object.entries(n))v(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 d=0;d<i.length;d++){let u=i[d],f=ne(a,l=>l.id===u.id);if(f===-1){c.warn(\"manifest\",'ThumbnailTrack \"'+i[d].id+'\" not found when merging.');let[l]=i.splice(d,1);d--,r.removedThumbnailTracks.push({id:l.id})}else{let[l]=a.splice(f,1);u.mimeType=l.mimeType,u.height=l.height,u.width=l.width,u.horizontalTiles=l.horizontalTiles,u.verticalTiles=l.verticalTiles,u.start=l.start,u.end=l.end,u.tileDuration=l.tileDuration,u.cdnMetadata=l.cdnMetadata,t===0?u.index._replace(l.index):u.index._update(l.index),r.updatedThumbnailTracks.push({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})}}a.length>0&&(c.warn(\"manifest\",`${a.length} new Thumbnail tracks found when merging.`),r.addedThumbnailTracks.push(...a.map(d=>({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}))),n.thumbnailTracks.push(...a));let o=n.getAdaptations(),s=e.getAdaptations();for(let d=0;d<o.length;d++){let u=o[d],f=ne(s,l=>l.id===u.id);if(f===-1){c.warn(\"manifest\",'Adaptation \"'+o[d].id+'\" not found when merging.');let[l]=o.splice(d,1);d--,r.removedAdaptations.push({id:l.id,trackType:l.type})}else{let[l]=s.splice(f,1),m=[],p=[],h=[];r.updatedAdaptations.push({adaptation:u.id,trackType:u.type,updatedRepresentations:m,addedRepresentations:p,removedRepresentations:h});let b=u.representations,g=l.representations.slice();for(let y=0;y<b.length;y++){let T=b[y],R=ne(g,E=>E.id===T.id);if(R===-1){c.warn(\"manifest\",`Representation \"${b[y].id}\" not found when merging.`);let[E]=b.splice(y,1);y--,h.push(E.id)}else{let[E]=g.splice(R,1);m.push(T.getMetadataSnapshot()),T.cdnMetadata=E.cdnMetadata,t===0?T.index._replace(E.index):T.index._update(E.index)}}g.length>0&&(c.warn(\"manifest\",`${g.length} new Representations found when merging.`),u.representations.push(...g),p.push(...g.map(y=>y.getMetadataSnapshot())))}}if(s.length>0){c.warn(\"manifest\",`${s.length} new Adaptations found when merging.`);for(let d of s){let u=n.adaptations[d.type];u===void 0?n.adaptations[d.type]=[d]:u.push(d),r.addedAdaptations.push(d.getMetadataSnapshot())}}return r}function Wo(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,d=n[s];for(;d!==void 0&&d.id!==o.id;)s++,d=n[s];if(d!==void 0){let u=pn(d,o,0);t.updatedPeriods.push({period:{id:d.id,start:d.start,end:d.end,duration:d.duration,streamEvents:d.streamEvents},result:u});let f=e.slice(r,a),l=s-r,m=n.splice(r,l,...f);t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end}))),t.addedPeriods.push(...f.map(p=>p.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 Vo(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 d=e[s],u=-1;for(let f=o;f<n.length;f++)if(d.id===n[f].id){u=f;break}if(u<0){let f=-1;for(let p=o;p<n.length;p++)if(d.start<n[p].start){f=p;break}let l=f-o,m=n.splice(o,l,d);t.addedPeriods.push(d.getMetadataSnapshot()),t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end})))}else{if(u>o){c.warn(\"manifest\",\"old Periods not found in new when updating, removing\");let l=n.splice(o,u-o);t.removedPeriods.push(...l.map(m=>({id:m.id,start:m.start,end:m.end}))),u=o}let f=pn(n[u],d,0);t.updatedPeriods.push({period:K(n[u].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(d=>({id:d.id,start:d.start,end:d.end})))}return t}var uu=Me(),gn=class extends fe{constructor(e,t){var a;super();let{representationFilter:r,manifestUpdateUrl:i}=t;this.manifestFormat=0,this.id=uu(),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 bo(this,e)}getNextPeriod(e){return j(this.periods,t=>t.start>e)}getPeriodAfter(e){return yo(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return po(this)}getLivePosition(){return go(this)}getMaximumSafePosition(){return ho(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=lu(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(){tt(\"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){tt(\"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 tt(\"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 Fo(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=Wo(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=Vo(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 lu(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},d=e(s);d!==!1&&(a=!1),d!==o.decipherable&&(t.push(s),o.decipherable=d,d===!0?i.supportStatus.isDecipherable=!0:d===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 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 vr(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 vr(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 vr(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 ue(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 fu=.016666666666666666;function Go(n,e){return Math.abs(n-e)<fu}function Ko(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function mu(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function cu(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(Yo(t,r)){let i=Ko(t,r);n.splice(--e,2,i)}}return n}function vi(n,e){return n.end<=e.start}function Ho({start:n,end:e},t){return n<=t&&t<e}function jo(n,e){return Ho(n,e.start)||n.start<e.end&&e.end<n.end||Ho(e,n.start)}function Yo(n,e){return Go(e.start,n.end)||Go(e.end,n.start)}function Ci(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function pu(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 Qo(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 Cr(n,e){let t=pu(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=jo(t,i),o=Yo(t,i);if(a||o)t=Ko(t,i),n.splice(r--,1);else if(r===0){if(vi(t,n[0]))break}else if(vi(n[r-1],t)&&vi(t,i))break}return n.splice(r,0,t),cu(mu(n))}function gu(n,e){let t=[];for(let r=0;r<e.length;r++)jo(n,e[r])&&t.push(e[r]);return t}function Ar(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=gu(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let d=o[s];a.push({start:Math.max(i.start,d.start),end:Math.min(i.end,d.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let d=0;d<a.length;d++)a[d].start>s&&t.push({start:s,end:a[d].start}),s=a[d].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function xr({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(d=>{a=d.position.getWanted(),o=d.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&hu(n,a,o,t.getValue(),r.getValue(),i).catch(d=>{if(i.isCancelled()&&z.isCancellationError(d))return;let u=d instanceof Error?d.message:\"Unknown error\";c.error(\"Stream\",\"Could not run BufferGarbageCollector:\",u)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function hu(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:d}=Qo(t,e),u=()=>{if(isFinite(r)){for(let l of d)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 d)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})}};u(),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 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=>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 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 d,u,f,l,m,p,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 b=e.map(g=>`${g.start}-${g.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 g=e[b].start,y=e[b].end;if(y-g<a){c.warn(\"SI\",\"skipped range when synchronizing because it was too small\",{t:o,rangeStart:g,rangeEnd:y});continue}let T=r;for(;i!==void 0&&((d=i.bufferedEnd)!=null?d:i.end)-g<a;)i=t[++r];let R=null,E=r-T;if(E>0){let P=t[T+E-1];R={end:(u=P.bufferedEnd)!=null?u:P.end,precizeEnd:P.precizeEnd},c.debug(\"SI\",`${E} segments GCed.`,{t:o});let x=t.splice(T,E);for(let A of x)A.bufferedStart===void 0&&A.bufferedEnd===void 0&&A.status!==2&&this._bufferedHistory.addBufferedSegment(A.infos,null);r=T}if(i===void 0)return;if(y-((f=i.bufferedStart)!=null?f:i.start)>=a){if(Iu(i,g,R,o),r===t.length-1){Xo(i,y,o);return}i=t[++r];let P=(l=i.bufferedStart)!=null?l:i.start,x=(m=i.bufferedEnd)!=null?m:i.end,A=b<s-1?e[b+1].start:void 0;for(;i!==void 0&&!(y<P||y-P<a&&x-y>=a||A!==void 0&&y-P<x-A);){let k=t[r-1];k.bufferedEnd===void 0&&(i.precizeStart?k.bufferedEnd=i.start:k.infos.segment.complete?k.bufferedEnd=k.end:k.bufferedEnd=i.start,c.debug(\"SI\",\"calculating buffered end of contiguous segment\",{t:o,prevSegmentBufferedEnd:k.bufferedEnd,pse:k.end})),i.bufferedStart=k.bufferedEnd,i=t[++r],i!==void 0&&(P=(p=i.bufferedStart)!=null?p:i.start,x=(h=i.bufferedEnd)!=null?h:i.end)}}let C=t[r-1];C!==void 0&&Xo(C,y,o)}if(!v(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:b}=L.getCurrent(),g=F();for(let y=r;y<t.length;y++){let T=t[y];g-T.insertionTs>=b&&(c.debug(\"SI\",\"A segment at the end has been completely GCed\",He(T.infos)),T.bufferedStart===void 0&&T.bufferedEnd===void 0&&T.status!==2&&this._bufferedHistory.addBufferedSegment(T.infos,null),t.splice(y,1),y--)}}o!==void 0&&c.hasLevel(\"DEBUG\")&&c.debug(\"SI\",`current ${o} inventory timeline:\n`+bu(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},d,u){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:d?0:2,insertionTs:u,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=l.length-1;h>=0;h--){let b=l[h];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(h+1,0,m),h+=2;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,pss:l[h].start,ss:o,se:s}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,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(h,1,m),h+=1;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,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(h,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(h+1,0,m),b.end=m.start,b.bufferedEnd=void 0,b.precizeEnd=b.precizeEnd&&m.precizeStart,h+=2;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:l[h].start}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,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 g={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(h+1,0,m),l.splice(h+2,0,g);return}}let p=this._inventory[0];if(p===void 0){c.debug(\"SI\",\"first segment pushed\",{t:f,ss:o,se:s}),this._inventory.push(m);return}if(p.start>=s)c.debug(\"SI\",\"Segment pushed comes before all previous ones\",{t:f,ss:o,se:s,pss:p.start}),this._inventory.splice(0,0,m);else if(p.end<=s){for(c.debug(\"SI\",\"Segment pushed starts before and completely recovers the previous first one\",{t:f,ss:o,se:s,pss:p.start,pse:p.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:p.start,pse:p.end}),p.start=s,p.bufferedStart=void 0,p.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 d=i-1,u=d-o,f=t[d].end,l=t[d].bufferedEnd;u>0&&(this._inventory.splice(o+1,u),i-=u),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 Ai(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 $o(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 Iu(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&&Ai(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,Ai(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,Ai(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 Xo(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&&$o(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,$o(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 bu(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(d){let u=String.fromCharCode(r.length+65);return r.push({letter:u,periodId:d.period.id,representationId:d.representation.id,bitrate:d.representation.bitrate}),u}let s=\"\";for(let d of n)if(d.bufferedStart!==void 0&&d.bufferedEnd!==void 0){let u=d.infos.period.id,f=d.infos.representation.id,l=t[u],m;if(l===void 0)m=o(d.infos),t[u]={[f]:m};else{let p=l[f];p===void 0?(m=o(d.infos),l[f]=m):m=p}i===null?s+=`${d.bufferedStart.toFixed(2)}|${m}|`:a===m?i.bufferedEnd+e<d.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${m}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${m}|`,i=d,a=m}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(d=>{var u;s+=`\n[${d.letter}] P: ${d.periodId} || R: ${d.representationId}(${(u=d.bitrate)!=null?u:\"unknown bitrate\"})`}),s}function qt(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 Zo=yn;var Vt=class{constructor(){this._segmentInventory=new Zo}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var Sn=class extends Vt{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){Jo(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){Jo(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:d,appendWindow:u}=e.data;return c.debug(\"Stream\",\"now pushing\",He(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:d,appendWindow:u})}));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(e){try{c.debug(\"Stream\",\"Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose(e)}catch(t){c.debug(\"Stream\",`Failed to dispose a ${this.bufferType} SourceBufferInterface:`,t instanceof Error?t:\"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 Jo(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 Mr=Sn;var Tn=class extends Vt{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;Su(t.chunk);let r=this._sender.pushTextData(se(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 Su(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(!Tu(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 Tu(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&&(Eu=function(e){function t(r){}});var Eu;var es=Tn;var _u=[\"audio\",\"video\",\"text\"],En=class n{static isNative(e){return ts(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(ts(e)){if(!v(r))return r instanceof Mr&&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 Mr(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.slice().forEach(s=>s()),Ie(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 es(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,t){let r=this._initializedSegmentSinks[e];if(v(r)){c.warn(\"Stream\",\"Trying to dispose a SegmentSink that does not exist\",{bufferType:e});return}c.info(\"Stream\",\"Aborting SegmentSink\",{bufferType:e}),r.dispose(t),delete this._initializedSegmentSinks[e]}disposeAll(e){_u.forEach(t=>{this.getStatus(t).type===\"initialized\"&&this.disposeSegmentSink(t,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(J({},o),{infos:Ru(o.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function ts(n){return n===\"audio\"||n===\"video\"}function Ru(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var bt=En;var _n=class{constructor({drmSystemId:e,representation:t,notify:r}){if(this._hasSentEncryptionData=!1,this._representation=t,this._notify=r,e!==void 0){let i=t.getEncryptionData(e);i.length>0&&i.every(a=>a.keyIds!==void 0)&&(this._hasSentEncryptionData=!0,r(i))}}onNewProtectionData(e){for(let t of e)this._representation.addProtectionData(t.initDataType,t.keyId,t.initData);if(!this._hasSentEncryptionData){let t=this._representation.getAllEncryptionData();t.length>0&&(this._notify(t),this._hasSentEncryptionData=!0)}}};function xi(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,d=Pu(i,e);if(d===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 u=i[d];if(u.bufferedStart!==void 0&&u.bufferedStart>e.start&&(t===null||u.infos.segment.end<=t)){let l=u.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,l)!==!1?null:(c.debug(\"Stream\",\"current discontinuity encountered\",{bufferType:o.type,nextSegmentTime:u.bufferedStart,checkStartTime:e.start}),{start:void 0,end:l})}let f=vu(i,e,d+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 p=l.bufferedEnd,h=m.bufferedStart;return c.debug(\"Stream\",\"future discontinuity encountered\",{bufferType:o.type,discontinuityStart:p,discontinuityEnd:h}),{start:p,end:h}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let l=Cu(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 p=s.index.checkDiscontinuity(e.end);if(p!==null)return{start:m.bufferedEnd,end:p}}return null}}}return null}function Pu(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 vu(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 Cu(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 ki({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:d,representation:u}=e,f=Au(n,o,s),l=u.index.getSegments(a.start,a.end-a.start),m=n.filter(C=>!ns(C.infos,e,t,r)),p=Bu(m,a,i),{MINIMUM_SEGMENT_SIZE:h,MIN_BUFFER_AHEAD:b}=L.getCurrent(),g=!1,y=Math.min(1/60,h),T=!1,R=[];return{segmentsToLoad:l.filter(C=>{let P=K({segment:C},e);if(o.length>0&&o.some(B=>nt(P,B)))return!1;let{duration:x,time:A,end:k}=C;if(C.isInit)return!0;if(g)return R.push(C),!1;if(C.complete&&x<h||o.length>0&&o.some(B=>{if(B.period.id!==e.period.id||B.adaptation.id!==e.adaptation.id)return!1;let{segment:_}=B;if(_.time-y>A)return!1;if(_.complete){if(_.end+y<k)return!1}else if(Math.abs(A-_.time)>A)return!1;return!ns(B,P,t,r)}))return!1;for(let q of p){let B=q.infos.period.id===e.period.id;if(q.status===1&&B){let _=q.infos.segment;if(A-_.time>-y){if(_.complete){if(_.end-k>-y)return!1}else if(Math.abs(A-_.time)<y)return!1}}}let N=x*e.representation.bitrate;if(f-N<0&&(T=!0,A>a.start+b))return g=!0,R.push(C),!1;let D=i(P);if(D.length>1){let q=D[D.length-1],B=D[D.length-2];if(q.buffered===null&&B.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:d.type,representationId:u.id,segmentTime:C.time}),!1}for(let q=0;q<p.length;q++){let B=p[q];if(B.end+y>A){let _=B.start>A+y||xu(p,q).end<k-y;return _&&(f-=N),_}}return f-=N,!0}),segmentsOnHold:R,isBufferFull:T}}function Au(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 xu(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 ns(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:ku(n.representation,e.representation,r)}function ku(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 Mu(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 Ou(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 wu(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 Du(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 Bu(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],d=null;if(Mu(r,o,e.start)){if(d=t(r.infos),wu(d,r.bufferedStart))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the start\",{segmentStart:r.start,currentStartInBuffer:r.bufferedStart})}if(Ou(r,s,e.end)){if(d=d!=null?d:t(r.infos),Du(d,r.bufferedEnd))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the end\",{segmentEnd:r.end,currentEndInBuffer:r.bufferedEnd})}return!0})}function Rn(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 Mi(n,e,t,r,i,a,o){var A,k,N;let{representation:s}=n,d=(k=(A=t.getIsPaused())!=null?A:t.getReference().getValue().paused.pending)!=null?k:t.getReference().getValue().paused.last,u=(N=t.getPlaybackRate())!=null?N:t.getReference().getValue().speed,f=e;(d===void 0||u===void 0||d||u<=0)&&(f-=.1);let l=Nu(n,f,i),m=s.index.shouldRefresh(l.start,l.end),p=o.getPendingOperations().filter(D=>D.type===2).map(D=>D.value),h=o.getLastKnownInventory(),b=t.getCurrentTime();b===void 0&&(b=t.getReference().getValue().position.getWanted());let g=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:T,isBufferFull:R}=ki({content:n,bufferedSegments:h,currentPlaybackTime:b,fastSwitchThreshold:r,getBufferedHistory:g,neededRange:l,segmentsBeingPushed:p,maxBufferSize:a}),E=y.map(D=>({priority:Rn(D.time,f),segment:D})),C=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&E.length===0&&T.length===0,P=null;return p.length>0&&(P=Math.min(...p.map(D=>D.segment.time))),T.length>0&&(P=P!==null?Math.min(P,T[0].time):T[0].time),E.length>0&&(P=P!==null?Math.min(P,E[0].segment.time):E[0].segment.time),{imminentDiscontinuity:xi(n,l,P,C,h),hasFinishedLoading:C,neededSegments:E,isBufferFull:R,shouldRefreshManifest:m}}function Nu(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),d=o.index;!v(s)&&bt.isNative(n.adaptation.type)&&e>=s&&d.isInitialized()&&!d.isStillAwaitingFutureSegments()&&Uu(i,a,e)?r=s-1:r=e-.1;let u=r+t,f;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?f=!1:s===void 0?f=u>=a.end:s===null?f=!0:f=u>=s,{start:Math.max(r,a.start),end:Math.min(u,(l=a.end)!=null?l:1/0),hasReachedPeriodEnd:f}}function Uu(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 Pn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof oe)throw a;if(!(a instanceof xe)||!a.isBufferFull){let d=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new Z(\"BUFFER_APPEND_ERROR\",d,{tracks:[vt(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{c.warn(\"Stream\",\"Running garbage collector\");let d=Math.max(s-5,0),u=s+r.getValue()+12;if(d>0&&await e.removeBuffer(0,d),u<Number.MAX_VALUE&&await e.removeBuffer(u,Number.MAX_VALUE),await pi(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(d){if(d instanceof oe)throw d;let u=d instanceof Error?d.toString():\"Could not clean the buffer\";throw new Z(\"BUFFER_FULL_ERROR\",u,{tracks:[vt(t.inventoryInfos.adaptation)]})}}}async function Oi({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){let s=e.representation.getMimeTypeString(),d={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},u=K({segment:r,chunkSize:void 0,start:0,end:0},e),f=await Pn(n,i,{data:d,inventoryInfos:u},a,o);return{content:e,segment:r,buffered:f}}async function wi({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var P,x;if(i.chunkData===null)return null;let{chunkData:d,chunkInfos:u,chunkOffset:f,chunkSize:l,appendWindow:m}=i,p=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:h}=L.getCurrent(),b=[m[0]!==void 0?Math.max(0,m[0]-h.START):void 0,m[1]!==void 0?m[1]+h.END:void 0],g={initSegmentUniqueId:r,chunk:d,timestampOffset:f,appendWindow:b,codec:p},y=(P=u==null?void 0:u.time)!=null?P:a.time,T=(x=u==null?void 0:u.duration)!=null?x:a.duration,R=y+T;b[0]!==void 0&&(y=Math.max(y,b[0])),b[1]!==void 0&&(R=Math.min(R,b[1]));let E=K({segment:a,chunkSize:l,start:y,end:R},t),C=await Pn(n,o,{data:g,inventoryInfos:E},e,s);return{content:t,segment:a,buffered:C}}function Di({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:d,adaptation:u,representation:f}=n,{bufferGoal:l,maxBufferSize:m,drmSystemId:p,fastSwitchThreshold:h}=e,b=u.type,g=new z(\"RepresentationStream \"+b);g.linkToSignal(s);let y={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};g.signal.register(()=>{y.uniqueId!==null&&r.freeInitSegment(y.uniqueId)});let T=y.segment!==null;T||(y.isLoaded=!0);let R=new _n({drmSystemId:p,representation:f,notify:A=>o.encryptionDataEncountered(A.map(k=>K({content:n},k)))});if(g.isUsed())return;i.addEventListener(\"error\",A=>{g.signal.isCancelled()||(g.cancel(\"RepresentationStream: SegmentQueue err\"),o.error(A))},g.signal),i.addEventListener(\"parsedInitSegment\",P,g.signal),i.addEventListener(\"parsedMediaSegment\",P,g.signal),i.addEventListener(\"emptyQueue\",C,g.signal),i.addEventListener(\"requestRetry\",A=>{if(o.warning(A.error),g.signal.isCancelled())return;let k=A.segment,{index:N}=f;N.isSegmentStillAvailable(k)===!1?C():N.canBeOutOfSyncError(A.error,k)&&o.manifestMightBeOufOfSync()},g.signal),i.addEventListener(\"fullyLoadedSegment\",A=>{r.signalSegmentComplete(K({segment:A},n)).catch(x)},g.signal);let E=i.resetForContent(n,T,\"new RepresentationStream linked to SegmentQueue\");g.signal.register(A=>{i.stop(A.reason)}),t.listen(C,{includeLastObservation:!1,clearSignal:g.signal}),n.manifest.addEventListener(\"manifestUpdate\",C,g.signal),l.onUpdate(C,{emitCurrentValue:!1,clearSignal:g.signal}),m.onUpdate(C,{emitCurrentValue:!1,clearSignal:g.signal}),a.onUpdate(C,{emitCurrentValue:!1,clearSignal:g.signal}),C();return;function C(){if(g.isUsed())return;let A=t.getReference().getValue(),k=A.position.getWanted(),N=Mi(n,k,t,h.getValue(),l.getValue(),m.getValue(),r),{neededSegments:D}=N,q=null;if(f.index.isInitialized()){if(D.length>0&&!y.isLoaded&&y.segment!==null){let M=D[0].priority;q={segment:y.segment,priority:M}}}else if(y.segment===null)c.warn(\"Stream\",\"Uninitialized index without an initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else if(y.isLoaded)c.warn(\"Stream\",\"Uninitialized index with an already loaded initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else{let M=A.position.getWanted();q={segment:y.segment,priority:Rn(d.start,M)}}let B=a.getValue();if(B===null)E.setValue({initSegment:q,segmentQueue:D});else if(B.urgent){c.debug(\"Stream\",\"Urgent switch, terminate now.\",{bufferType:b,representationBitrate:n.representation.bitrate}),E.setValue({initSegment:null,segmentQueue:[]}),E.finish(),g.cancel(B.reason),o.terminating();return}else{let M=D[0],w=i.getRequestedInitSegment(),U=i.getRequestedMediaSegment(),H=U===null||M===void 0||U.id!==M.segment.id?[]:[M],$=w===null?null:q;if(E.setValue({initSegment:$,segmentQueue:H}),H.length===0&&$===null){c.debug(\"Stream\",\"No request left, terminate\",{bufferType:b,representationBitrate:n.representation.bitrate}),E.finish(),g.cancel(B.reason),o.terminating();return}}if(o.streamStatusUpdate({period:d,position:A.position.getWanted(),bufferType:b,imminentDiscontinuity:N.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:N.hasFinishedLoading,neededSegments:N.neededSegments}),g.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:_}=L.getCurrent();if(N.isBufferFull){let M=Math.max(0,k-_);M>0&&r.removeBuffer(0,M).catch(x)}N.shouldRefreshManifest&&o.needsManifestRefresh()}function P(A){if(R.onNewProtectionData(A.protectionData),A.segmentType===\"init\"){if(!f.index.isInitialized()&&A.segmentList!==void 0&&f.index.initialize(A.segmentList),y.isLoaded=!0,A.initializationData!==null){let k=f.uniqueId;y.uniqueId=k,r.declareInitSegment(k,A.initializationData),Oi({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:k,segment:A.segment,segmentData:A.initializationData,segmentSink:r},g.signal).then(N=>{N!==null&&o.addedSegment(N)}).catch(x)}C();return}else{let{inbandEvents:k,predictedSegments:N,needsManifestRefresh:D}=A;if(N!==void 0&&f.index.addPredictedSegments(N,A.segment),D===!0&&(o.needsManifestRefresh(),g.isUsed())||k!==void 0&&k.length>0&&(o.inbandEvent(k),g.isUsed()))return;let q=y.uniqueId;wi({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:q,parsedSegment:A,segment:A.segment,segmentSink:r},g.signal).then(B=>{B!==null&&o.addedSegment(B)}).catch(x)}}function x(A){g.isUsed()&&A instanceof oe||(c.warn(\"Stream\",\"Received fatal buffer error\",{bufferType:b,representationBitrate:n.representation.bitrate},A instanceof Error?A:null),g.cancel(\"RepresentationStream: fatal buffer err\"),o.error(A))}}var rs=Di;function Bi(n,e,t,r,i){var m,p,h,b;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let g of a)g.infos.period.id===n.id&&(g.infos.adaptation.id!==e.id||!ue(t.representationIds,g.infos.representation.id))&&It(o,{start:(m=g.bufferedStart)!=null?m:g.start,end:(p=g.bufferedEnd)!=null?p:g.end});let s=r.getPendingOperations();for(let g of s)if(g.type===0){let y=g.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!ue(t.representationIds,y.representation.id))){let T=y.segment.time,R=T+y.segment.duration;It(o,{start:T,end:R})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let g=i.getReadyState();if(g===void 0||g>1)return{type:\"needs-reload\",value:void 0}}let d=t.switchingMode===\"direct\",u=[],f=qt(a,n);if(f!==null&&(f.bufferedEnd===void 0||n.start-f.bufferedEnd<1)&&u.push({start:0,end:n.start+1}),!d){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:g}=L.getCurrent(),y=e.type,T=(h=g[y].before)!=null?h:0,R=(b=g[y].after)!=null?b:0,E=i.getCurrentTime();E===void 0&&(E=i.getReference().getValue().position.getPolled()),u.push({start:E-T,end:E+R})}if(n.end!==void 0){let g=Wt(a,n);g!==null&&(g.bufferedStart===void 0||g.bufferedStart-n.end<1)&&u.push({start:n.end-1,end:Number.MAX_VALUE})}let l=Ar(o,u);return l.length===0?{type:\"continue\",value:void 0}:d?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function Ni({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentQueueCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},d,u){let{manifest:f,period:l,adaptation:m}=e,p=new z(\"AdaptationStream \"+m.type);p.linkToSignal(u);let h=new Map,b=new X(null,p.signal),g,y=e.representations.getValue().representationIds,T=is(e.adaptation.representations,y),R=new X(T,p.signal),{estimates:E,callbacks:C}=r({manifest:f,period:l,adaptation:m},b,R,n,p.signal),P=new X(!1);n.listen(_=>{var w;let M=(w=_.canStream)!=null?w:!0;P.getValue()===M&&(c.debug(\"Stream\",\"isMediaSegmentQueueInterrupted updated to\",!M),P.setValue(!M))},{clearSignal:p.signal});let x=a.createSegmentQueue(m.type,{onRequestBegin:C.requestBegin,onRequestEnd:C.requestEnd,onProgress:C.requestProgress,onMetrics:C.metrics},P),A=new X(0);E.onUpdate(({bitrate:_,knownStableBitrate:M})=>{t.enableFastSwitching&&A.setValueIfChanged(M),!(_===void 0||_===g)&&(g=_,c.debug(\"Stream\",`new ${m.type} bitrate estimate received from ABR`,{bitrate:_}),d.bitrateEstimateChange({type:m.type,bitrate:_}))},{emitCurrentValue:!0,clearSignal:p.signal});let k;e.representations.onUpdate(_=>{k!==void 0&&k.cancel(\"locked representations changed\");let M=e.representations.getValue().representationIds,w=is(e.adaptation.representations,M);R.setValueIfChanged(w),k=new z(\"AdaptationStream: RepresentationStream Group \"+m.type),k.linkToSignal(p.signal),N(_,k.signal).catch(U=>{(k==null?void 0:k.isUsed())===!0&&z.isCancellationError(U)||(p.cancel(\"RepresentationStream err\"),d.error(U))})},{clearSignal:p.signal,emitCurrentValue:!0});return;async function N(_,M){let w=Bi(l,m,_,i,n);switch(w.type){case\"continue\":break;case\"needs-reload\":return rt(()=>{n.listen(()=>{if(M.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:U}=L.getCurrent(),H=U.bitrateSwitch;return d.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:H,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:M})});case\"flush-buffer\":case\"clean-buffer\":for(let U of w.value)if(await i.removeBuffer(U.start,U.end),M.isCancelled())return;if(w.type===\"flush-buffer\"&&(d.needsBufferFlush(),M.isCancelled()))return;break;default:Be(w)}D(M)}function D(_){let M=new z(\"AdaptationStream: RepresentationStream creation \"+m.type);M.linkToSignal(_);let{representation:w}=E.getValue();if(w===null)return;let U=new X(null,M.signal);E.onUpdate(V=>{if(!(V.representation===null||V.representation.id===w.id))return V.urgent?(c.info(\"Stream\",\"urgent Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:V.representation.bitrate}),U.setValue({urgent:!0,reason:\"Urgent Representation switch\"})):(c.info(\"Stream\",\"slow Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:V.representation.bitrate}),U.setValue({urgent:!1,reason:\"Non-urgent Representation switch\"}))},{clearSignal:M.signal,emitCurrentValue:!0});let H={type:m.type,adaptation:m,period:l,representation:w};if(b.setValue(w),_.isCancelled()||(d.representationChange(H),_.isCancelled()))return;let $={streamStatusUpdate:d.streamStatusUpdate,encryptionDataEncountered:d.encryptionDataEncountered,manifestMightBeOufOfSync:d.manifestMightBeOufOfSync,needsManifestRefresh:d.needsManifestRefresh,inbandEvent:d.inbandEvent,warning:d.warning,error(V){p.cancel(\"RepresentationStream err cb\"),d.error(V)},addedSegment(V){C.addedSegment(V)},terminating(){if(!M.isUsed())return M.cancel(\"RepresentationStream terminating\"),D(_)}};q(w,U,$,_)}function q(_,M,w,U){let H=!1,$=new z(`RepresentationStream-linked listeners in AdaptationStream - periodStart=${l.start} type=${m.type}`);$.linkToSignal(U);let V=tn(o,me=>B(_,me),$.signal),G=m.type===\"video\"?s:new X(1/0);c.info(\"Stream\",\"changing representation\",{bufferType:m.type,representationId:_.id,representationBitrate:_.bitrate});let Y=K({},w,{error(me){var ce;if(H){c.warn(\"Stream\",\"Ignoring RepresentationStream error\",me);return}H=!0;let le=pe(me,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(le.code!==\"BUFFER_FULL_ERROR\")w.error(me);else{c.warn(\"Stream\",\"received BUFFER_FULL_ERROR\",{bufferType:m.type,representationBitrate:_.bitrate});let Qe=o.getValue(),ae=((ce=h.get(_.id))!=null?ce:1)*.7;if(h.set(_.id,ae),ae<=.05||B(_,Qe)<=2){w.error(le);return}ln(4e3,$.signal).then(()=>q(_,M,w,U)).catch(O)}},terminating(){$.cancel(\"Representation terminating\"),w.terminating()}});rs({playbackObserver:n,content:{representation:_,adaptation:m,period:l,manifest:f},segmentSink:i,segmentQueue:x,terminate:M,options:{bufferGoal:V,maxBufferSize:G,drmSystemId:t.drmSystemId,fastSwitchThreshold:A}},Y,U),f.addEventListener(\"manifestUpdate\",me=>{for(let le of me.updatedPeriods)if(le.period.id===l.id){for(let ce of le.result.updatedAdaptations)if(ce.adaptation===m.id){for(let Qe of ce.removedRepresentations)if(Qe===_.id)return $.isUsed()?void 0:d.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:0,stayInPeriod:!0})}}else if(le.period.start>l.start)break},$.signal)}function B(_,M){let w=h.get(_.id),U=w!==void 0?w:1;return w===void 0&&h.set(_.id,U),U<1&&M===1/0?300*1e3*U:M*U}}function is(n,e){let t=n.filter(r=>ue(e,r.id)&&!r.shouldBeAvoided&&r.isPlayable()!==!1);return t.length>0?t:n.filter(r=>ue(e,r.id)&&r.isPlayable()!==!1)}var as=Ni;function Ui(n,e,t,r,i,a){var p,h,b,g;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!Lu(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:(p=y.bufferedStart)!=null?p:y.start,end:(h=y.bufferedEnd)!=null?h:y.end});let d=n.getPendingOperations();for(let y of d)if(y.type===0){let T=y.value.inventoryInfos;if(T.period.id===e.id&&T.adaptation.id!==t.id){let R=T.segment.time,E=R+T.segment.duration;It(s,{start:R,end:E})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let y=i.getReadyState();if(y===void 0||y>1)return{type:\"needs-reload\",value:void 0}}let u=r===\"direct\",f=[],l=qt(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!u){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:T}=L.getCurrent(),R=(b=T[y].before)!=null?b:0,E=(g=T[y].after)!=null?g:0,C=i.getCurrentTime();C===void 0&&(C=i.getReference().getValue().position.getPolled()),f.push({start:C-R,end:C+E})}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=Ar(s,f);return m.length===0?{type:\"continue\",value:void 0}:u&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function Lu(n,e){return n.representations.some(t=>t.isPlayable()===!0&&Lo(t.getMimeTypeString(),e))}function Li({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentQueueCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:d,maxVideoBufferSize:u},f,l){let{manifest:m,period:p}=e,h=new X(void 0,l);if(f.periodStreamReady({type:n,manifest:m,period:p,adaptationRef:h}),l.isCancelled())return;let b,g=!0;h.onUpdate(R=>{(async()=>{var B;if(R===void 0)return;let E=new z(\"PeriodStream: Adaptation choice \"+n);if(E.linkToSignal(l),b==null||b.cancel(\"PeriodStream: Adaptation update\"),b=E,R===null){c.info(\"Stream\",\"Set no Adaptation\",{periodStart:p.start,bufferType:n});let _=o.getStatus(n);if(_.type===\"initialized\"){if(c.info(\"Stream\",\"Clearing previous SegmentSink\",{periodStart:p.start,bufferType:n}),bt.isNative(n))return T(0,!0,E.signal);{let M=(B=p.end)!=null?B:1/0;if(p.start>M)c.warn(\"Stream\",\"Can't free buffer: period's start is after its end\",{periodStart:p.start,periodEnd:M,bufferType:n});else if(await _.value.removeBuffer(p.start,M),E.isUsed())return}}else if(_.type===\"uninitialized\"&&(o.disableSegmentSink(n),E.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:p}),E.isUsed()?void 0:os(r,d,n,{period:p},f,E.signal)}let C=p.adaptations[n],P=j(C!=null?C:[],_=>_.id===R.adaptationId);if(P===void 0){b.cancel(\"PeriodStream: Adaptation not found\"),c.warn(\"Stream\",\"Unfound chosen Adaptation choice\",{adaptationId:R.adaptationId});return}let{DELTA_POSITION_AFTER_RELOAD:x}=L.getCurrent(),A=!1,k;if(g)k=0;else if(R.relativeResumingPosition!==void 0)k=R.relativeResumingPosition;else switch(A=!0,n){case\"audio\":k=x.trackSwitch.audio;break;case\"video\":k=x.trackSwitch.video;break;default:k=x.trackSwitch.other;break}if(g=!1,bt.isNative(n)&&o.getStatus(n).type===\"disabled\")return T(k,!0,E.signal);m.addEventListener(\"manifestUpdate\",_=>{for(let M of _.updatedPeriods)if(M.period.id===p.id){for(let w of M.result.removedAdaptations)if(w.id===P.id)return T(k,!0,E.signal)}else if(M.period.start>p.start)break},b.signal);let{representations:N}=R;if(c.info(\"Stream\",\"Updating adaptation\",{bufferType:P.type,periodStart:p.start,adaptationId:P.id}),f.adaptationChange({type:n,adaptation:P,period:p}),E.isUsed())return;let D=Fu(o,n,P),q=Ui(D,p,P,R.switchingMode,r,s);if(q.type===\"needs-reload\")return T(k,!0,E.signal);if(await o.waitForUsableBuffers(E.signal),!E.isUsed()){if(q.type===\"flush-buffer\"||q.type===\"clean-buffer\"){for(let{start:_,end:M}of q.value)if(await D.removeBuffer(_,M),E.isUsed())return;if(q.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:k,relativePosHasBeenDefaulted:A}),E.isUsed()))return}t.get(D)(E.signal),y(P,N,D,E.signal)}})().catch(E=>{E instanceof oe||(b==null||b.cancel(\"PeriodStream err\"),f.error(E))})},{clearSignal:l,emitCurrentValue:!0});function y(R,E,C,P){let x=qu(r,R.type);as({content:{manifest:m,period:p,adaptation:R,representations:E},options:s,playbackObserver:x,representationEstimator:i,segmentSink:C,segmentQueueCreator:a,wantedBufferAhead:d,maxVideoBufferSize:u},se(J({},f),{error:A}),P);function A(k){if(!bt.isNative(n)){c.error(\"Stream\",`${n} Stream crashed. Aborting it.`,k instanceof Error?k:\"\"),o.disposeSegmentSink(n,\"AdaptationStream err\");let N=pe(k,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(N),P.isCancelled()?void 0:os(r,d,n,{period:p},f,P)}c.error(\"Stream\",`${n} Stream crashed. Stopping playback.`,k instanceof Error?k:\"\"),f.error(k)}}function T(R,E,C){rt(()=>{r.listen(()=>{C.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:p,timeOffset:R,stayInPeriod:E})},{includeLastObservation:!0,clearSignal:C})})}}function Fu(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=zu(t);return n.createSegmentSink(e,i)}function zu(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 qu(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new X(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let d=r.getValue(),u=d.buffered[e],f=u!==null?Cr(u,d.position.getWanted()):0;return K({},d,{bufferGap:f,buffered:u})}function s(){a.setValue(o())}})}function os(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(d,{emitCurrentValue:!1,clearSignal:a}),n.listen(d,{includeLastObservation:!1,clearSignal:a}),d();function d(){let u=n.getReference().getValue(),f=e.getValue(),l=u.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 ss=Li;function Or(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:d}=a;if(s===void 0||d===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 u=t[t.length-1];u!==void 0&&u.end===s?u.end=d:t.push({start:s,end:d})}for(let a of i){if(a.type!==0)continue;let o=a.value;e.some(d=>o.inventoryInfos.period.id===d.period.id&&o.inventoryInfos.adaptation.id===d.adaptation.id&&o.inventoryInfos.representation.id===d.representation.id)&&It(t,{start:o.inventoryInfos.start,end:o.inventoryInfos.end})}return t}function Fi(n,e,t,r,i,a,o,s){let{manifest:d,initialPeriod:u}=n,{maxBufferAhead:f,maxBufferBehind:l,wantedBufferAhead:m,maxVideoBufferSize:p}=a,{MINIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_AHEAD:b,MAXIMUM_MAX_BUFFER_BEHIND:g}=L.getCurrent(),y=new In(E=>{var A,k;let{bufferType:C}=E,P=(A=g[C])!=null?A:1/0,x=(k=b[C])!=null?k:1/0;return N=>{xr({segmentSink:E,playbackObserver:e,maxBufferBehind:tn(l,D=>Math.min(D,P),N),maxBufferAhead:tn(f,D=>{var B;let q=Math.max(D,(B=h[C])!=null?B:0);return Math.min(q,x)},N)},N)}});for(let E of r.getBufferTypes())T(E,u);function T(E,C){let P=new kt((q,B)=>q.start-B.start),x=!1,A=new z(\"StreamOrchestrator Streams for \"+E);return A.linkToSignal(s),e.listen(({position:q})=>{let B=q.getWanted();if(!x||!N(B))return;let _=()=>{var w;return(w=d.getPeriodForTime(B))!=null?w:d.getNextPeriod(B)},M=_();if(!(!v(M)&&P.has(M))){for(c.info(\"Stream\",\"Destroying all PeriodStreams due to out of bounds situation\",{bufferType:E,time:B}),x=!1;P.length()>0;){let w=P.get(P.length()-1);P.removeElement(w),o.periodStreamCleared({type:E,manifest:d,period:w})}if(A.cancel(\"PeriodStream is out of bounds\"),A=new z(\"StreamOrchestrator Streams for \"+E),A.linkToSignal(s),M=_(),M===void 0){c.warn(\"Stream\",\"The wanted position is not found in the Manifest.\"),x=!0;return}k(M)}},{clearSignal:s,includeLastObservation:!0}),d.addEventListener(\"decipherabilityUpdate\",q=>{s.isCancelled()||D(q).catch(B=>{s.isCancelled()||(A.cancel(\"decipherabilityUpdate event\"),o.error(B))})},s),k(C);function k(q){let B=se(J({},o),{waitingMediaSourceReload(_){let M=P.head();M===void 0||M.id!==_.period.id?o.lockedStream({bufferType:_.bufferType,period:_.period}):o.needsMediaSourceReload({timeOffset:_.timeOffset,minimumPosition:_.stayInPeriod?_.period.start:void 0,maximumPosition:_.stayInPeriod?_.period.end:void 0})},periodStreamReady(_){x=!0,P.add(_.period),o.periodStreamReady(_)},periodStreamCleared(_){P.removeElement(_.period),o.periodStreamCleared(_)},error(_){A.cancel(\"PeriodStream err callback\"),o.error(_)}});R(E,q,B,A.signal)}function N(q){let B=P.head(),_=P.last();return B===void 0||_===void 0?!0:B.start>q||(v(_.end)?1/0:_.end)<q}async function D(q){let B=r.getStatus(E),_=q.filter(V=>V.adaptation.type===E);if(_.length===0||B.type!==\"initialized\"||_.every(V=>V.representation.decipherable===!0))return;let M=B.value,w=_.filter(V=>V.representation.decipherable===void 0),U=_.filter(V=>V.representation.decipherable===!1),H=Or(M,U),$=Or(M,w);for(x=!1,c.info(\"Stream\",\"Destroying all PeriodStreams for decipherability matters\",{bufferType:E});P.length()>0;){let V=P.get(P.length()-1);P.removeElement(V),o.periodStreamCleared({type:E,manifest:d,period:V})}A.cancel(\"decipherability update\"),A=new z(\"StreamOrchestrator Streams for \"+E),A.linkToSignal(s);for(let{start:V,end:G}of[...H,...$]){if(s.isCancelled())return;if(V<G){if(s.isCancelled())return;await M.removeBuffer(V,G)}}rt(()=>{if(s.isCancelled())return;let V=e.getReference().getValue();if(ds(V,H)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(ds(V,$)&&(o.needsBufferFlush(),s.isCancelled()))return;let G=V.position.getWanted(),Y=d.getPeriodForTime(G);if(Y===void 0&&(Y=d.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=d.periods[d.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}k(Y)})}}function R(E,C,P,x){c.info(\"Stream\",\"Creating new PeriodStream\",{bufferType:E,periodStart:C.start});let A=null,k=new z(\"StreamOrchestrator current consecutive Streams \"+E);k.linkToSignal(x),e.listen(({position:_},M)=>{if(C.end!==void 0&&_.getWanted()>=C.end){let w=d.getPeriodAfter(C);if(C.containsTime(_.getWanted(),w))return;c.info(\"Stream\",\"Destroying PeriodStream as the current playhead moved above it\",{bufferType:E,periodStart:C.start,periodEnd:C.end,position:_.getWanted()}),M(),P.periodStreamCleared({type:E,manifest:d,period:C}),k.cancel(\"Position ahead of PeriodStream\")}},{clearSignal:x,includeLastObservation:!0});let N={bufferType:E,content:{manifest:d,period:C},garbageCollectors:y,maxVideoBufferSize:p,segmentQueueCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},D=se(J({},P),{streamStatusUpdate(_){if(_.hasFinishedLoading){let M=d.getPeriodAfter(C);M!==null&&q(M)}else A!==null&&(c.info(\"Stream\",\"Destroying next PeriodStream due to current one being active\",{bufferType:E,periodStart:C.start,nextPeriodStart:A.period.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"previous PeriodStream is active\"),A=null);P.streamStatusUpdate(_)},error(_){A!==null&&(A.canceller.cancel(\"previous PeriodStream err\"),A=null),k.cancel(\"PeriodStream err\"),P.error(_)}});ss(N,D,k.signal),B(k.signal);function q(_){if(A!==null){if(A.period.id===_.id)return;c.warn(\"Stream\",\"Creating next `PeriodStream` while one was already created.\",{bufferType:E,nextPeriodStart:_.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"PeriodStream recreation\")}let M=new z(\"StreamOrchestrator next PeriodStream \"+E);M.linkToSignal(x),A={canceller:M,period:_},R(E,_,P,A.canceller.signal)}function B(_){d.addEventListener(\"manifestUpdate\",M=>{for(let w of M.removedPeriods)if(w.id===C.id){if(d.periods.length>0&&d.periods[0].start<=w.start)return rt(()=>{if(!_.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(w.start>C.start)break;if(M.addedPeriods.length>0&&A!==null){let w=d.getPeriodAfter(C);(w===null||A.period.id!==w.id)&&(c.warn(\"Stream\",\"Destroying next PeriodStream due to new one being added\",{bufferType:E,nextPeriodStart:A.period.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"Next Period changed\"),A=null)}},_)}}}function ds(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=Fi;var ls=us;function zi(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 Wu(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function vn(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=Wu(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(\"EndOfStream current iteration\");i.linkToSignal(e);for(let a of r)vo(a,()=>{i.cancel(\"SourceBuffer update\"),vn(n,e)},i.signal);Co(t,()=>{i.cancel(\"SourceBuffer remove\"),vn(n,e)},i.signal)}function fs(n,e){let t=new z(\"EndOfStream\");t.linkToSignal(e),Ft(n,()=>{c.debug(\"mse\",\"MediaSource re-opened while end-of-stream is active\"),t.cancel(\"MediaSource re-opened\"),t=new z(\"EndOfStream\"),t.linkToSignal(e),vn(n,t.signal)},e),vn(n,t.signal)}function qi(){let{FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:n}=L.getCurrent();return n||ci.device===ci.DEVICES.PlayStation5}var Vu=365*24*3600,Cn=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(\"manual duration update\"),this._currentMediaSourceDurationUpdateCanceller=new z(\"MediaSource Duration Update\");let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Ku(r,i),o=new z(void 0);o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(\"MediaSource open status changed\"),!a.getValue())return;o=new z(void 0),o.linkToSignal(i);let d=Hu(r.sourceBuffers,o.signal),u=new z(void 0);return u.linkToSignal(o.signal),d.onUpdate(f=>{u.cancel(\"SourceBuffer status update\"),u=new z(void 0),u.linkToSignal(o.signal),!f&&cs(r,e,t,u.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(e){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(e!=null?e:\"stop MSDU\"),this._currentMediaSourceDurationUpdateCanceller=null)}};function Gu(n,e,t){let r=e;t||(r=qi()?1/0:ms(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=ms(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 Hu(n,e){if(n.length===0){let i=new X(!1);return i.finish(),i}let t=new X(!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 Ku(n,e){let t=new X(n.readyState===\"open\",e);return Ft(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 cs(n,e,t,r){if(Gu(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),cs(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function ms(n){return Math.max(Math.pow(2,32),n+Vu)}var An=class extends fe{constructor(e,t){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new z(\"MainMediaSourceInterface\"),v(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=v(i)?{type:\"media-source\",value:r}:{type:\"handle\",value:i},this._mediaSource=r,this.readyState=r.readyState,this._durationUpdater=new Cn(r),this._endOfStreamCanceller=null,Ft(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 Wi(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(e){this._durationUpdater.stopUpdating(e)}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new z(\"MainMediaSourceInterface EndOfStream\"),this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"mse\",\"end-of-stream order received.\"),fs(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"mse\",\"resume-stream order received.\"),this._endOfStreamCanceller.cancel(\"MediaSourceInterface stopEndOfStream\"),this._endOfStreamCanceller=null)}dispose(e){this.sourceBuffers.forEach(t=>t.dispose(e)),this._canceller.cancel(e!=null?e:\"MainMediaSourceInterface dispose\"),ju(this._mediaSource)}},Wi=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new z(\"MainSourceBufferInterface \"+e),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 Ci(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(e){try{this._sourceBuffer.abort()}catch(t){c.debug(\"mse\",\"Failed to abort SourceBuffer:\",t instanceof Error?t:\"Unknown Error\")}this._emptyCurrentQueue(e)}dispose(e){try{this._sourceBuffer.abort()}catch(t){}this._emptyCurrentQueue(e)}_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(Ci(this._sourceBuffer.buffered))}catch(t){for(let r of e)t instanceof Error&&t.name===\"InvalidStateError\"?r.resolve([]):r.reject(t)}this._performNextOperation()}_emptyCurrentQueue(e){let t=new oe(\"MainSourceBufferInterface queue \"+this.type,e);this._currentOperations.length>0&&(this._currentOperations.forEach(r=>{r.reject(t)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(r=>{r.reject(t)}),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],d=e.params[1],u=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],p=(r=d.appendWindow)!=null?r:[void 0,void 0],h=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],b=(a=d.timestampOffset)!=null?a:0,g=(o=m.params[1].timestampOffset)!=null?o:0;if(p[0]===h[0]&&p[1]===h[1]&&d.codec===m.params[1].codec&&b===g){let y=m.params[0],T;y instanceof ArrayBuffer?T=new Uint8Array(y):y instanceof Uint8Array?T=y:T=new Uint8Array(y.buffer),l.push(T),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:m.resolve,reject:m.reject})}else break}l.length>1&&(c.info(\"mse\",`: Merging ${l.length} segments together for perf`,{type:this.type}),u=At(...l).buffer)}try{this._appendBufferNow(u,d)}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,d]=e.params;c.debug(\"mse\",\"removing data from SourceBuffer\",{type:this.type,start:s,end:d});try{this._sourceBuffer.remove(s,d)}catch(u){let f=u instanceof Error?new xe(u.name,u.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\",{type:this.type,prevCodec:this.codec,newCodec:i}),zi(r,i)?this.codec=i:c.debug(\"mse\",\"could not update codec\",{type:this.type,prevCodec:this.codec,newCodec:i})),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"mse\",\"updating timestampOffset\",{type:this.type,codec:i,prevTimestampOffset:r.timestampOffset,newTimestampOffset:s}),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"mse\",\"re-setting `appendWindowStart`\",{type:this.type,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`\",{type:this.type,prevWindowEnd:r.appendWindowEnd,newWindowEnd:s}),r.appendWindowEnd=s}c.debug(\"mse\",\"setting `appendWindowStart`\",{type:this.type,appendWindowStart:o[0]}),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"mse\",\"re-setting `appendWindowEnd`\",{type:this.type,prevWindowStart:r.appendWindowStart}),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"mse\",\"setting `appendWindowEnd`\",{type:this.type,prevWindowEnd:r.appendWindowEnd,newWindowEnd:o[1]}),r.appendWindowEnd=o[1]),c.debug(\"mse\",\"pushing segment\",{type:this.type}),r.appendBuffer(e)}};function ju(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 Yu=Me(),wr=Me(),ps=1/0,xn=class extends fe{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new z(\"WorkerMediaSourceInterface\"),this.readyState=\"closed\",this._messageSender=r;let i=Yu();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 Vi(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(e){this.sourceBuffers.forEach(t=>t.dispose(e)),this._canceller.cancel(\"WorkerMediaSourceInterface dispose\"),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},Vi=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new z(\"WorkerSourceBufferInterface \"+e),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\",{type:this.type}):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new oe(\"Pending SBI Operation \"+this.type,\"SBI Failure\"):new xe(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"mse\",\"unknown SourceBuffer operation failed\",{type:this.type},r):(this._pendingOperations.delete(e),i.reject(r));let a=new oe(\"Queued SBI Operation \"+this.type,\"SBI failure\");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>=ps){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=wr();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>=ps){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=wr();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(e){this.abort(),this._canceller.cancel(e!=null?e:\"WorkerSourceBufferInterface dispose\")}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=wr();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=wr();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 Gi(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 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 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 gs=6e3,Qu=15e3,$u=3e3,Xu=1e3,Zu=9e3,Mn=class{constructor(e){this._levelsMap=Gi(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=gs,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 d=-1;for(let h=0;h<r.length;h++){let b=r[h];if(b===a)d=h;else if(b>a)break}if(d<0||r.length!==t.length){c.info(\"ABR\",\"Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let u;o!==void 0&&(u=s===0?o.score:o.score/s);let f=isFinite(i)?i:0,l=F();if(f<t[d]||u!==void 0&&u<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Zu){let g=this._blockRaiseDelay+$u;c.debug(\"ABR\",\"Incrementing blocking raise in BufferBasedChooser due to unstable quality\",{prevDelay:this._blockRaiseDelay,newDelay:g}),this._blockRaiseDelay=Math.min(g,Qu)}else{let g=this._blockRaiseDelay-Xu;c.debug(\"ABR\",\"Lowering quality in BufferBasedChooser\",{prevDelay:this._blockRaiseDelay,newDelay:g}),this._blockRaiseDelay=Math.max(gs,g)}this._lastUnsuitableQualityTimestamp=l;let b=ne(r,g=>g===a);for(let g=b-1;g>=0;g--)if(f>=t[g]){this._currentEstimate=r[g];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||u===void 0||u<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[d],p=(()=>{for(let h=d+1;h<t.length;h++)if(t[h]>m)return h})();if(p!==void 0){let h=t[p];if(i>=h){c.debug(\"ABR\",\"Raising quality in BufferBasedChooser\",{bitrate:r[p]}),this._currentEstimate=r[p];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function Ju(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 d=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(d>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 Dr(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 hs(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function el(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,d=isFinite(a)?a:0,u=s.getWanted()+d,f=Ju(n,u);if(f.length!==1)return;let l=f[0],m=F(),p=l.content.segment.duration*1.5;if(p=Math.min(p,3e3),p=Math.max(p,12e3),m-l.requestTimestamp<p)return;let h=l.progress.length>0?l.progress[l.progress.length-1]:void 0,b=Dr(l);if(h!==void 0&&b!==void 0){let C=hs(h,b);if((m-h.timestamp)/1e3<=C&&C-d/o>2500)return b}if(!l.content.segment.complete)return;let g=l.content.segment.duration,y=(m-l.requestTimestamp)/1e3,T=y<=(g*1.5+2)/o;if(v(t)||T)return;let R=g/y,E=t.bitrate*Math.min(.7,R);if(i===void 0||E<i)return E}function tl(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=j(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(a===void 0)return!0;let o=F(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,d=Dr(a);if(s===void 0||d===void 0)return!0;let u=hs(s,d);return(o-s.timestamp)/1e3>u*1.2?!0:u-r/n.speed>-1.5}var On=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,d=this._config,{bufferGap:u,position:f,duration:l}=e,m=isFinite(u)?u:0,{ABR_STARVATION_DURATION_DELTA:p}=L.getCurrent();return isNaN(l)||m+f.getWanted()<l-p?!this._inStarvationMode&&m<=d.starvationGap?(c.info(\"ABR\",\"enter starvation mode.\",{buffergap:m,enterStarvation:d.starvationGap}),this._inStarvationMode=!0):this._inStarvationMode&&m>=d.outOfStarvationGap&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m,outOfStarvation:d.starvationGap}),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m}),this._inStarvationMode=!1),this._inStarvationMode&&(s=el(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?d.starvationBitrateFactor:d.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?d.starvationBitrateFactor:d.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:tl(i,r,this._lowLatencyMode)}};var wn=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 Dn=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,d=this._lastAbrEstimate.representation;if(d===null)return null;if(i>d.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let u=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(u===void 0)return null;if(this._canGuessHigher(o,s,u)){let l=Is(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(d,i,u)&&(c.debug(\"ABR\",\"Guessed Representation validated\",{chosenBitrate:d.bitrate,otherAbrAlgosBitrate:i,scoreData:u==null?void 0:u.score,scoreConfidence:u==null?void 0:u.confidenceLevel}),this._lastMaintanableBitrate=d.bitrate,this._consecutiveWrongGuesses=0),r.id!==d.id)return d;if(this._shouldStopGuess(r,u,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=F()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),nl(e,r);if(u===void 0)return r;if(this._canGuessHigher(o,s,u)){let l=Is(e,r);if(l!==null)return l}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 d=o-s.requestTimestamp;if(s.content.segment.isInit){if(d>1e3)return!0}else{if(d>s.content.segment.duration*1e3+200)return!0;{let u=Dr(s);if(u!==void 0&&u<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 Is(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 nl(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 Bn=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 Hi(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 Ki(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,d)=>{var u,f;return((u=s.width)!=null?u:0)-((f=d.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 Nn=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 yr(this._currentRequests).filter(e=>!v(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Br(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 bs=new X(void 0);bs.finish();var ys=new X(1/0);ys.finish();function ji(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,d,u,f,l){var g,y,T;let{type:m}=s.adaptation,p=a(m),h=(g=t[m])!=null?g:0,b={limitResolution:(y=r.limitResolution[m])!=null?y:bs,throttleBitrate:(T=r.throttleBitrate[m])!=null?T:ys};return rl({bandwidthEstimator:p,context:s,currentRepresentation:d,filters:b,initialBitrate:h,playbackObserver:f,representations:u,lowLatencyMode:i},l)};function a(o){let s=e[o];if(v(s)){c.debug(\"ABR\",\"Creating new BandwidthEstimator\",{bufferType:o});let d=new Bn;return e[o]=d,d}return s}}function rl({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},d){let u=new kn,f=new On(i!=null?i:0,a),l=new Nn,m=O,p={metrics:T,requestBegin:R,requestProgress:E,requestEnd:C,addedSegment(P){m(P)}},h=new z(\"ABR \"+e.adaptation.type);h.linkToSignal(d);let b=g(s.getValue(),h.signal);return s.onUpdate(y,{clearSignal:d}),{estimates:b,callbacks:p};function g(P,x){if(P.length<=1)return new X({bitrate:void 0,representation:P[0],urgent:!0,knownStableBitrate:void 0});let A=!1,k=P.sort((U,H)=>U.bitrate-H.bitrate),N=new Mn(k.map(U=>U.bitrate)),D=new wn,q=new Dn(u,D),B=o.getReference().getValue(),_=new X(w());return o.listen(U=>{B=U,M()},{includeLastObservation:!1,clearSignal:x}),m=function(U){if(B===null)return;let{position:H,speed:$}=B,V=U.buffered,G=Cr(V,H.getWanted()),{representation:Y}=U.content,me=u.getEstimate(Y),le=Y.bitrate,ce={bufferGap:G,currentBitrate:le,currentScore:me,speed:$};N.onAddedSegment(ce),M()},x.register(()=>{m=O}),r.throttleBitrate.onUpdate(M,{clearSignal:x}),r.limitResolution.onUpdate(M,{clearSignal:x}),_;function M(){_.setValue(w())}function w(){let{bufferGap:U,position:H,maximumPosition:$}=B,V=r.limitResolution.getValue(),G=r.throttleBitrate.getValue(),Y=t.getValue(),me=il(k,V,G),le=l.getRequests(),{bandwidthEstimate:ce,bitrateChosen:Qe}=f.getBandwidthEstimate(B,n,Y,le,D.bandwidth),te=u.getLastStableRepresentation(),ae=te===null?void 0:te.bitrate/(B.speed>0?B.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:Xt,ABR_EXIT_BUFFER_BASED_ALGO:Zt}=L.getCurrent();A&&U<=Zt?A=!1:!A&&isFinite(U)&&U>=Xt&&(A=!0);let _e=Br(me,Qe),Jt=N.getLastEstimate(),ur=_e.bitrate,ut=null;A&&Jt!==void 0&&Jt>ur&&(ut=Br(me,Jt),ur=ut.bitrate);let lt=null;return a&&Y!==null&&e.manifest.isDynamic&&$-H.getWanted()<40&&(lt=q.getGuess(k,B,Y,ur,le)),lt!==null&&lt.bitrate>ur?(c.debug(\"ABR\",\"new guess-based estimate\",{bitrate:lt.bitrate,representation:lt.id}),D.update(lt,ce,2),{bitrate:ce,representation:lt,urgent:Y===null||lt.bitrate<Y.bitrate,knownStableBitrate:ae}):ut!==null?(c.debug(\"ABR\",\"new buffer-based estimate\",{bitrate:ut.bitrate,representation:ut.id}),D.update(ut,ce,0),{bitrate:ce,representation:ut,urgent:f.isUrgent(ut.bitrate,Y,le,B),knownStableBitrate:ae}):(c.debug(\"ABR\",\"new bandwidth estimate\",{bitrate:_e.bitrate,representation:_e.id}),D.update(_e,ce,1),{bitrate:ce,representation:_e,urgent:f.isUrgent(_e.bitrate,Y,le,B),knownStableBitrate:ae})}}function y(){let P=s.getValue();h.cancel(\"restart\"),h=new z(\"ABR \"+e.adaptation.type),h.linkToSignal(d),g(P,h.signal).onUpdate(function(k){b.setValue(k)},{clearSignal:h.signal,emitCurrentValue:!0})}function T(P){let{requestDuration:x,segmentDuration:A,size:k,content:N}=P;if(n.addSample(x,k),!N.segment.isInit){let{segment:D,representation:q}=N;if(A===void 0&&!D.complete)return;let B=A!=null?A:D.duration;u.addSample(q,x/1e3,B)}}function R(P){l.add(P)}function E(P){l.addProgress(P)}function C(P){l.remove(P.id)}}function il(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Hi(r,t)),e!==void 0&&(r=Ki(r,e)),r}var Ss=ji;function Nr(){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 al=/^(?:[a-z]+:)?\\/\\//i,ol=/^(?:([^:/?#]+):)?(?:\\/\\/([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Qi(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(al.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Qi(n.substring(0,t)):e+1}function Ts(n,e){let t=Ur(n),r=Ur(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=Ln(t.path),a=Ln(r.path),o;if(i===a)o=\"\";else{let d=i.split(\"/\");d.pop();let u=a.split(\"/\");for(;d.length>0&&u.length>0&&d[0]===u[0];)d.shift(),u.shift();for(;d.length>0;)d.shift(),u.unshift(\"..\");let f=u.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 sl(n,e){let t=Ur(n),r=Ur(e);if(Q(r.scheme))return Yi(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=Ln(r.path),Yi(i)):(r.path===\"\"?(i.path=t.path,Q(r.query)||(i.query=t.query)):Oe(r.path,\"/\")?i.path=Ln(r.path):i.path=Ln(ul(t,r.path)),Yi(i))}var Un=new Map,dl=200;function Ur(n){var r,i,a,o,s;if(Un.has(n))return Un.get(n);let e=n.match(ol),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:\"\"},Un.size>=dl&&Un.clear(),Un.set(n,t),t}function Yi(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 Ln(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 ul(n,e){if(Q(n.authority)&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function Fn(...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:\"\",d=sl(o,s),u=e.slice(2);return Fn(d,...u)}}var ll=4,zn=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Nr(),this._contentId=(r=e.contentId)!=null?r:Nr(),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(\"CmcdDataBuilder start\"),this._canceller=new z(\"CMCD monitoring\"),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(\"CmcdDataBuilder stop\"),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,d,u;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=Ts(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=(u=(d=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?d:t.position.getWanted())!=null?u: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*ll/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=(u,f)=>{this._typePreference===0?t[f]+=u:r+=u},a=(u,f)=>{let l=e[u];if(l!==void 0){let m=`${u}=${String(l)},`;i(m,f)}},o=(u,f)=>{if(e[u]===!0){let l=`${u},`;i(l,f)}},s=(u,f)=>{let l=e[u];if(l!==void 0){let m=`\"${l.replace(\"\\\\\",\"\\\\\\\\\").replace('\"','\\\\\"')}\"`,p=`${u}=${m},`;i(p,f)}},d=(u,f)=>{let l=e[u];if(l!==void 0){let m=`${u}=${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\"),d(\"ot\",\"object\"),a(\"pr\",\"session\"),a(\"rtp\",\"status\"),d(\"sf\",\"session\"),s(\"sid\",\"session\"),d(\"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 Es=zn;var qn=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=_s(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=_s(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 _s(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 de?new Xe(\"PIPELINE_LOAD_ERROR\",n):pe(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function fl(n){return n instanceof de?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 Wn(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:d}=r;n!==null&&n.length===0&&c.warn(\"utils\",\"No CDN given to `scheduleRequestWithCdns`.\");let u=new Map,f=l();if(f===void 0)throw new Error(\"No CDN to request\");return m(f);function l(){if(n===null){let g=u.get(null);return g!==void 0&&g.isBlacklisted?void 0:null}else{if(e===null)return b(n);{let g=e.getCdnPreferenceForResource(n);return b(g)}}}async function m(g){try{return await t(g,i)}catch(y){if(z.isCancellationError(y))throw y;g!==null&&e!==null&&e.downgradeCdn(g);let T=u.get(g);if(T===void 0?(T={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},u.set(g,T)):T.errorCounter++,!fl(y))return T.blockedUntil=void 0,T.isBlacklisted=!0,p(y);if(T.errorCounter>s)T.blockedUntil=void 0,T.isBlacklisted=!0;else{let R=T.errorCounter,E=Math.min(a*Math.pow(2,R-1),o),C=Pi(E);T.blockedUntil=F()+C}return p(y)}}async function p(g){let y=l();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw g;if(d(g),i.isCancelled())throw i.cancellationError;return h(y,g)}function h(g,y){let T=u.get(g);if(T===void 0||T.blockedUntil===void 0)return m(g);let R=F(),E=T.blockedUntil-R;if(E<=0)return m(g);let C=new z(\"Request Backoff\"),P=C.linkToSignal(i);return new Promise((x,A)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let D=l();if(i.isCancelled())throw i.cancellationError;if(D===void 0)return N(y);D!==g&&(C.cancel(\"new prioritized CDN\"),h(D,y).then(k,N))},C.signal),ln(E,C.signal).then(()=>m(g).then(k,N),O);function k(D){P(),x(D)}function N(D){P(),A(D)}})}function b(g){var T;if(u.size===0)return g[0];let y=F();return(T=g.filter(R=>{var E;return((E=u.get(R))==null?void 0:E.isBlacklisted)!==!0}).reduce((R,E)=>{var P;let C=(P=u.get(E))==null?void 0:P.blockedUntil;return C!==void 0&&C<=y&&(C=void 0),R===void 0?[E,C]:R[1]===void 0?R:C===void 0?[E,void 0]:C<R[1]?[E,C]:R},void 0))==null?void 0:T[0]}}function $i(n,e,t){return Wn(null,null,n,e,t)}var Vn=class extends fe{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(\"ManifestFetcher\"),this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(e){this._canceller.cancel(e!=null?e:\"ManifestFetcher dispose\"),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 u;let t=this._canceller.signal,r=this._settings,i=this._transportName,a=this._pipelines,o=e!=null?e:(u=this._manifestUrls)==null?void 0:u[0],s=this._getBackoffSetting(f=>{this.trigger(\"warning\",Le(f))});try{let f=await d(o);return{parse:l=>this._parseLoadedManifest(f,l,o)}}catch(f){throw Le(f)}function d(f){var g;let{loadManifest:l}=a,m=r.requestTimeout===void 0?L.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,p=r.connectionTimeout===void 0?L.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;m<0&&(m=void 0),p<0&&(p=void 0);let h={timeout:m,connectionTimeout:p,cmcdPayload:(g=r.cmcdDataBuilder)==null?void 0:g.getCmcdDataForManifest(i)};return $i(()=>l(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 b;let i=F(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:d}=e,u=this._getBackoffSetting(g=>{this.trigger(\"warning\",Le(g))}),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 g=this._pipelines.parseManifest(e,l,p,a,m);if(ml(g)){let{manifest:y}=await g;return h(y)}else return h(g.manifest)}catch(g){throw pe(g,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(g){try{return await $i(g,u,a)}catch(y){throw Le(y)}}function p(g){for(let y of g){if(a.isCancelled())return;let T=pe(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",T)}}function h(g){let y=F()-i;return c.info(\"MF\",`Manifest parsed in ${y}ms`),{manifest:g,sendingTime:s,receivedTime:d,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,d=a?i.LOW_LATENCY:i.REGULAR,u=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:d,maxRetry:u}}_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,d=!1;this._consecutiveUnsafeMode>0?d=this._consecutiveUnsafeMode<a:s!==void 0&&(d=s>=o);let u=t===void 0?0:F()-t,f=Math.max(this._settings.minimumManifestUpdateInterval-u,0),l=new z(\"ManifestFetcher refresh handling\");if(l.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:p,delay:h,canUseUnsafeMode:b}=m,g=b&&d,y=t===void 0?0:F()-t,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=setTimeout(()=>{l.cancel(\"manifest request timeout\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:p,unsafeMode:g})},Math.max((h!=null?h:0)-y,T));l.signal.register(()=>{clearTimeout(R)})},e.expired!==null){let m=setTimeout(()=>{var p;(p=e.expired)==null||p.then(()=>{l.cancel(\"manifest expiration\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})},O)},f);l.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-u,p;s===void 0?p=m:e.lifetime<3&&s>=100?(p=Math.min(Math.max(3e3-u,Math.max(m,0)+s),m*6),c.info(\"MF\",\"Manifest update rythm is too frequent. Postponing next request.\",{regularRefreshDelay:m,newRefreshDelay:p})):s>=e.lifetime*1e3/10?(p=Math.min(Math.max(m,0)+s,m*6),c.info(\"MF\",\"Manifest took too long to parse. Postponing next request\",{regularRefreshDelay:m,newRefreshDelay:p})):p=m;let h=setTimeout(()=>{l.cancel(\"manifest request timeout\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})},Math.max(p,f));l.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(d=>d.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(d=>{this._isRefreshPending=!1;let{manifest:u,sendingTime:f,parsingTime:l}=d,m=F();if(a)e.replace(u);else try{e.update(u)}catch(h){let b=h instanceof Error?h.message:\"unknown error\";c.warn(\"MF\",`Attempt to update Manifest failed: ${b}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:g}=L.getCurrent(),y=f===void 0?0:F()-f,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=O,E=setTimeout(()=>{R(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(g-y,T));R=this._canceller.signal.register(()=>{clearTimeout(E)});return}let p=F()-m;this._recursivelyRefreshManifest(e,{sendingTime:f,parsingTime:l,updatingTime:p})}).catch(d=>{this._isRefreshPending=!1,this._onFatalError(d)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose(\"ManifestFetcher fatal err\"))}};function ml(n){return n instanceof Promise}var Xi=Vn;function Zi(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=u=>e(r,a,u),d=n.create(s,i,a,o);return t.set(d,s),d},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 Ji=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}},Rs=Ji;var cl=Me();function ea({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},d=ue([\"audio\",\"video\"],n)?new Rs:void 0,{loadSegment:u,parseSegment:f}=e;return async function(m,p,h){var H,$,V;let{segment:b,adaptation:g,representation:y,manifest:T,period:R}=m,E=He(m),C=cl(),P,x=[],A=0,k=!1,N={segment:b,type:g.type,language:g.language,isLive:T.isLive,periodStart:R.start,periodEnd:R.end,mimeType:y.mimeType,codecs:y.codecs[0],manifestPublishTime:T.publishTime},D={onProgress(G){var Y;P===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:C}))},onNewChunk(G){p.onChunk(M(G,!0))}},q=d!==void 0?d.get(m):null;if(q!==null)return c.debug(\"SF\",\"Found wanted segment in cache\",E),p.onChunk(M(q,!1)),Promise.resolve();c.debug(\"SF\",\"Beginning request\",E),(H=i.onRequestBegin)==null||H.call(i,{requestTimestamp:F(),id:C,content:m}),h.register(B);try{let G=await Wn(m.representation.cdnMetadata,t,_,K({onRetry:w},a),h);if(G.resultType===\"segment-loaded\"){let Y=G.resultData.responseData;d!==void 0&&d.add(m,G.resultData.responseData),p.onChunk(M(Y,!1))}else G.resultType===\"segment-created\"&&p.onChunk(M(G.resultData,!1));c.debug(\"SF\",\"Segment request ended with success\",E),p.onAllChunksReceived(),G.resultType!==\"segment-created\"?(P=G.resultData,U()):P=null,h.isCancelled()||($=i.onRequestEnd)==null||$.call(i,{id:C}),h.deregister(B)}catch(G){throw h.deregister(B),P=null,G instanceof oe?(c.debug(\"SF\",\"Segment request aborted\",E),G):(c.debug(\"SF\",\"Segment request failed\",E),(V=i.onRequestEnd)==null||V.call(i,{id:C}),Le(G))}function B(){var G;P===void 0&&(c.debug(\"SF\",\"Segment request cancelled\",E),P=null,(G=i.onRequestEnd)==null||G.call(i,{id:C}))}function _(G){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(m),u(G,N,s,h,D)}function M(G,Y){x.push(!1);let me=x.length-1;return function(ce){let Qe={data:G,isChunked:Y};try{let te=f(Qe,N,ce);return x[me]||(A=A!==void 0&&te.segmentType===\"media\"&&te.chunkInfos!==null&&te.chunkInfos.duration!==void 0?A+te.chunkInfos.duration:void 0,x[me]=!0,U()),te}catch(te){throw pe(te,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function w(G){p.onRetry(Le(G))}function U(){var G;k||!v(P)&&P.size!==void 0&&P.requestDuration!==void 0&&x.length>0&&x.every(Y=>Y)&&(k=!0,(G=i.onMetrics)==null||G.call(i,{size:P.size,requestDuration:P.requestDuration,content:m,segmentDuration:A}))}}}function Ps({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:d}=L.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?d.LOW_LATENCY:d.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var Gn=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,r){var s;(s=this._currentContentInfo)==null||s.currentCanceller.cancel(r!=null?r:\"SegmentQueue reset\");let i=new X({initSegment:null,segmentQueue:[]}),a=new z(\"SegmentQueue \"+e.adaptation.type);a.signal.register(()=>{i.finish()});let o={content:e,downloadQueue:i,initSegmentInfoRef:t?new X(void 0):new X(null),currentCanceller:a,initSegmentRequest:null,mediaSegmentRequest:null,mediaSegmentAwaitingInitMetadata:null};return this._currentContentInfo=o,this.isMediaSegmentQueueInterrupted.onUpdate(d=>{d||(c.debug(\"SF\",\"Media segment can be loaded again, restarting queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"interrupt end\"))},{clearSignal:a.signal}),i.onUpdate(d=>{let{segmentQueue:u}=d;if(u.length>0&&u[0].segment.id===o.mediaSegmentAwaitingInitMetadata)return;let f=o.mediaSegmentRequest;if(u.length===0){if(f===null)return;c.debug(\"SF\",\"no more media segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"media segment queue empty\");return}else if(f===null){c.debug(\"SF\",\"Media segments now need to be requested. Starting queue.\",{type:e.adaptation.type,queueLength:u.length}),this._restartMediaSegmentDownloadingQueue(o,\"media segment queue start\");return}else{let l=u[0];if(f.segment.id!==l.segment.id){c.debug(\"SF\",\"Next media segment changed, cancelling previous\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"next media segment changed\");return}f.priority!==l.priority&&(c.debug(\"SF\",\"Priority of next media segment changed, updating\",{type:e.adaptation.type,prevPriority:f.priority,newPriority:l.priority}),this._segmentFetcher.updatePriority(f.request,l.priority));return}},{emitCurrentValue:!0,clearSignal:a.signal}),i.onUpdate(d=>{var f;let u=o.initSegmentRequest;if(d.initSegment!==null&&u!==null){d.initSegment.priority!==u.priority&&this._segmentFetcher.updatePriority(u.request,d.initSegment.priority);return}else if(((f=d.initSegment)==null?void 0:f.segment.id)===(u==null?void 0:u.segment.id))return;d.initSegment===null&&c.debug(\"SF\",\"no more init segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartInitSegmentDownloadingQueue(o,d.initSegment,\"init segment queue empty\")},{emitCurrentValue:!0,clearSignal:a.signal}),i}stop(e){var t;(t=this._currentContentInfo)==null||t.currentCanceller.cancel(e!=null?e:\"SegmentQueue stop\"),this._currentContentInfo=null}_restartMediaSegmentDownloadingQueue(e,t){e.mediaSegmentRequest!==null&&e.mediaSegmentRequest.canceller.cancel(t!=null?t:\"SegmentQueue media restart\");let{downloadQueue:r,content:i,initSegmentInfoRef:a,currentCanceller:o}=e,s=()=>{var E;if(this.isMediaSegmentQueueInterrupted.getValue()){c.debug(\"SF\",\"Segment fetching postponed because it cannot stream now.\");return}let{segmentQueue:d}=r.getValue(),u=d[0];if(o!==null&&o.isUsed()){e.mediaSegmentRequest=null;return}if(u===void 0){e.mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let f=new z(\"SegmentQueue media segments queue \"+i.adaptation.type),l=o===null?O:f.linkToSignal(o.signal),{segment:m,priority:p}=u,h=K({segment:m,nextSegment:(E=d[1])==null?void 0:E.segment},i),b=!1,g=!1;f.signal.register(()=>{e.mediaSegmentRequest=null,!b&&(e.mediaSegmentAwaitingInitMetadata===m.id&&(e.mediaSegmentAwaitingInitMetadata=null),b=!0,g=!1)});let y=C=>{Ie(C.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",K({},C,{segment:m}))},T=()=>{let C=r.getValue().segmentQueue;if(C.length===0){b=!0,this.trigger(\"emptyQueue\",null);return}else C[0].segment.id===m.id&&C.shift();b=!0,s()},R=this._segmentFetcher.createRequest(h,p,{onRetry:C=>{this.trigger(\"requestRetry\",{segment:m,error:C})},beforeInterrupted(){c.info(\"SF\",\"segment request interrupted temporarly.\",{segmentId:m.id,segmentTime:m.time})},onChunk:C=>{let P=a.getValue();P!==void 0?y(C(P!=null?P:void 0)):(g=!0,a.waitUntilDefined(x=>{y(C(x!=null?x:void 0))},{clearSignal:f.signal}))},onAllChunksReceived:()=>{g?(e.mediaSegmentAwaitingInitMetadata=m.id,a.waitUntilDefined(()=>{e.mediaSegmentAwaitingInitMetadata=null,g=!1,this.trigger(\"fullyLoadedSegment\",m)},{clearSignal:f.signal})):this.trigger(\"fullyLoadedSegment\",m)},beforeEnded:()=>{l(),e.mediaSegmentRequest=null,g?a.waitUntilDefined(T,{clearSignal:f.signal}):T()}},f.signal);R.catch(C=>{l(),b||(b=!0,this.stop(\"request err\"),this.trigger(\"error\",C))}),e.mediaSegmentRequest={segment:m,priority:p,request:R,canceller:f}};s()}_restartInitSegmentDownloadingQueue(e,t,r){let{content:i,initSegmentInfoRef:a}=e;if(e.initSegmentRequest!==null&&e.initSegmentRequest.canceller.cancel(r!=null?r:\"SegmentQueue init restart\"),t===null)return;let o=new z(\"SegmentQueue init segment \"+i.adaptation.type),s=e.currentCanceller===null?O:o.linkToSignal(e.currentCanceller.signal),{segment:d,priority:u}=t,f=K({segment:d,nextSegment:void 0},i),l=!1,m=this._segmentFetcher.createRequest(f,u,{onRetry:p=>{this.trigger(\"requestRetry\",{segment:d,error:p})},beforeInterrupted:()=>{c.info(\"SF\",\"init segment request interrupted temporarly.\",{segmentId:d.id})},beforeEnded:()=>{s(),e.initSegmentRequest=null,l=!0},onChunk:p=>{var b;let h=p(void 0);Ie(h.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",K({},h,{segment:d})),h.segmentType===\"init\"&&a.setValue((b=h.initTimescale)!=null?b:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",d)}},o.signal);m.catch(p=>{s(),l||(l=!0,this.stop(\"request err\"),this.trigger(\"error\",p))}),o.signal.register(()=>{e.initSegmentRequest=null,!l&&(l=!0)}),e.initSegmentRequest={segment:d,priority:u,request:m,canceller:o}}};var Kn=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"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 u=()=>{p(),this._endTask(a)},f=h=>{r.beforeEnded(),u(),o(h)},l=h=>{u(),s(h)},m=new z(void 0),p=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 oe||l(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=Hn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=Hn(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=Hn(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=Hn(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=Hn(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(\"TaskPrioritizer interrupt\")}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function Hn(n,e){return ne(e,t=>t.taskFn===n)}var jn=class{constructor(e,t,r,i){let{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=L.getCurrent();this._transport=e,this._prioritizer=new Kn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=t,this._backoffOptions=i,this._cmcdDataBuilder=r}createSegmentQueue(e,t,r){let i=Ps(this._backoffOptions),a=this._transport[e],o=ea({bufferType:e,pipeline:a,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:i}),s=Zi(this._prioritizer,o);return new Gn(s,r)}};var ta=jn;function na(n,e){let{loadThumbnail:t}=n,r=[];return async function(a,o){o.register(E);let{segment:s,track:d}=a,u,f=j(r,({thumbnailContext:x})=>x.period.id===a.period.id&&x.track.id===a.track.id&&x.segment.id===a.segment.id);if(f!==void 0){c.debug(\"Thumbnails\",\"Requesting same thumbnail than the pending one\",{time:a.segment.time}),u=f,u.referenceCount++;let x;try{x=await u.promise}catch(A){throw o.deregister(E),A}if(o.deregister(E),o.isCancelled())throw o.cancellationError;return R(x)}let l=pl({}),m;l.connectionTimeout===void 0||l.connectionTimeout<0?m=void 0:m=l.connectionTimeout;let p={timeout:l.requestTimeout<0?void 0:l.requestTimeout,connectionTimeout:m,cmcdPayload:void 0},h=new z(\"Thumbnail request\"),b=T();u={thumbnailContext:a,promise:b,referenceCount:1},r.push(u);let g=()=>{let x=r.indexOf(u);x>=0&&r.splice(x,1)},y;try{y=await b}catch(x){throw g(),o.deregister(E),x}if(g(),o.deregister(E),o.isCancelled())throw o.cancellationError;return R(y);async function T(){c.debug(\"Thumbnails\",\"Beginning thumbnail request\",{time:s.time});try{let x=await Wn(d.cdnMetadata,e,C,K({onRetry:P},l),h.signal);return c.debug(\"Thumbnails\",\"Thumbnail request ended with success\",{time:s.time}),x}catch(x){throw x instanceof oe?(c.debug(\"Thumbnails\",\"Thumbnail request aborted\",{time:s.time}),x):(c.debug(\"Thumbnails\",\"Thumbnail request failed\",{time:s.time}),Le(x))}}function R(x){try{return n.parseThumbnail(x.responseData,{thumbnail:s,thumbnailTrack:d})}catch(A){throw pe(A,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}function E(){c.debug(\"Thumbnails\",\"Thumbnail request cancelled\",{time:s.time});let x=r.indexOf(u);x<0||(r[x].referenceCount--,r[x].referenceCount<=0&&(h.cancel(\"Thumbnail request aborted\"),r.splice(x,1)))}function C(x){return t(x,s,p,o)}function P(x){let A=Le(x);c.warn(\"Thumbnails\",\"Thumbnail request retry \",{time:s.time},A)}}}function pl({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 Yn=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(\"WorkerTextDisplayerInterface reset\")}stop(e){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue(e)}_resetCurrentQueue(e){let t=new oe(\"WorkerTextDisplayerInterface queue\",e!=null?e:\"reset\");this._queues.pushTextData.forEach(r=>{r.reject(t)}),this._queues.pushTextData.length=0,this._queues.remove.forEach(r=>{r.reject(t)}),this._queues.remove.length=0}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.remove.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}};var vs=6,ra=4e3,Lr=6e3,gl=6e4,Gt=class{constructor(e){this._segmentSinksStore=e,this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=null,this._lastFlushAttempt=null,this._lastSegmentInfo={audio:[],video:[]}}onNewObservation(e){var g,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:d,fullyLoaded:u}=e,f=e.position.getPolled(),l=Cs(e.bufferGap);if(!(d!==null||o===1&&(l>=vs||u)))return this._decipherabilityFreezeStartingTimestamp=null,null;let p=(y=(g=d==null?void 0:d.timestamp)!=null?g:s==null?void 0:s.timestamp)!=null?y:null;if(c.info(\"Freeze\",\"Freeze detected\",{freezeStart:p,timeFrozen:t-(p!=null?p:t)}),this._lastFlushAttempt!==null&&t-this._lastFlushAttempt.timestamp<a.MAXIMUM&&t-this._lastFlushAttempt.timestamp>=a.MINIMUM&&Math.abs(f-this._lastFlushAttempt.position)<a.POSITION_DELTA){let T=this._getStrategyIfFlushingFails(f);return this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Lr,T}let b=this._checkForDecipherabilityRelatedFreeze(e,t);return b!==null?b:p!==null&&t-p>r?(this._lastFlushAttempt={timestamp:t,position:f+i},c.debug(\"Freeze\",\"Trying to flush to un-freeze\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Lr,{type:\"flush\",value:{relativeSeek:i}}):null}_checkForDecipherabilityRelatedFreeze(e,t){let{readyState:r,rebuffering:i,freezing:a,fullyLoaded:o}=e,s=Cs(e.bufferGap),d=i!==null&&t-i.timestamp>ra,{hasUndecipherableData:u,hasEncryptedData:f}=hl(this._segmentSinksStore);if(u===!0)return c.warn(\"Freeze\",\"we have undecipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Lr,{type:\"reload\",value:null};let l=a!==null&&t-a.timestamp>ra;return(d||l)&&(s>=vs||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>ra&&f&&u===!1?(c.warn(\"Freeze\",\"we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Lr,{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 d=i.length-2;d>=0;d--){let u=i[d];if(u.segment===null){s=u;break}else if(u.segment.infos.representation.uniqueId!==o.infos.representation.uniqueId&&a.timestamp-u.timestamp<5e3){s=u;break}else u.segment.start===o.start&&e-u.position<3e3&&(a=u)}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 d=t-gl,u;for(u=0;u<this._lastSegmentInfo[o].length&&!(this._lastSegmentInfo[o][u].timestamp>d);u++);u>0&&this._lastSegmentInfo[o].splice(0,u)}}};function hl(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 Cs(n){return n!==void 0&&isFinite(n)?n:0}var Qn=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,d,u,f,l,m;for(let p of this._refs.keys())(t=(e=this._refs.get(p))==null?void 0:e.audio)==null||t.trackReference.finish(),(i=(r=this._refs.get(p))==null?void 0:r.audio)==null||i.representations.finish(),(o=(a=this._refs.get(p))==null?void 0:a.video)==null||o.trackReference.finish(),(d=(s=this._refs.get(p))==null?void 0:s.video)==null||d.representations.finish(),(f=(u=this._refs.get(p))==null?void 0:u.text)==null||f.trackReference.finish(),(m=(l=this._refs.get(p))==null?void 0:l.text)==null||m.representations.finish();this._refs=new Map}addTrackSetter(e,t,r){var s,d;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(),(d=i[t])==null||d.representations.finish());let a=r.getValue(),o;v(a)?o=new X({representationIds:[],switchingMode:\"lazy\"}):(o=new X(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):(v(r)?(i.representations=new X({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new X(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)}};function ve(n){return pe(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}function As(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 xs(n){var t,r;if(v(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 d=`${s.mimeType};codecs=\"${s.codecs[0]}\"`;if(e.has(d))s.isCodecSupportedInWebWorker=e.get(d);else{let u=mt.isTypeSupported(d);s.isCodecSupportedInWebWorker=u,e.set(d,u)}}}}function ks(n,e){var a,o,s,d,u,f,l;let t,r,i;return typeof((a=n.representationFilter)==null?void 0:a.fn)==\"function\"?i=n.representationFilter.fn:typeof((o=n.representationFilter)==null?void 0:o.eval)==\"string\"?i=So(n.representationFilter.eval):typeof((s=n.representationFilter)==null?void 0:s.workerId)==\"string\"&&(i=e.representationFilters.get(n.representationFilter.workerId)),typeof((d=n.manifestLoader)==null?void 0:d.fn)==\"function\"?t=n.manifestLoader.fn:typeof((u=n.manifestLoader)==null?void 0:u.workerId)==\"string\"&&(t=e.manifestLoaders.get(n.manifestLoader.workerId)),typeof((f=n.segmentLoader)==null?void 0:f.fn)==\"function\"?r=n.segmentLoader.fn:typeof((l=n.segmentLoader)==null?void 0:l.workerId)==\"string\"&&(r=e.segmentLoaders.get(n.segmentLoader.workerId)),{manifestLoader:t,segmentLoader:r,representationFilter:i}}var Ms=Me(),Ht=class{constructor({hasVideo:e}){this._currentContent=null,this._currentMediaSourceCanceller=new z(\"ContentPreparer MediaSource\"),this._hasVideo=e;let t=new z(\"ContentPreparer\");this._contentCanceller=t}initializeNewContent(e,t,r,i){return new Promise((a,o)=>{var w,U;this.disposeCurrentContent(\"new init\");let s=this._contentCanceller,d=new z(\"ContentPreparer MediaSource\");this._currentMediaSourceCanceller=d,d.linkToSignal(s.signal);let{contentId:u,url:f,hasText:l,transportOptions:m,useMseInWorker:p,enableRepresentationAvoidance:h,transport:b}=t,g=null,y=ke.transports[b];if(typeof y!=\"function\"){o(new Error(`transport \"${b}\" not supported. Did you add the corresponding feature?`));return}let T=y(J(J({},m),ks(m,i))),R=t.cmcd===void 0?null:new Es(t.cmcd),E=new Xi(f===void 0?void 0:[f],T,J({cmcdDataBuilder:R},t.manifestRetryOptions)),C=Ss({initialBitrates:{audio:(w=t.initialAudioBitrate)!=null?w:0,video:(U=t.initialVideoBitrate)!=null?U:0},lowLatencyMode:m.lowLatencyMode,throttlers:r}),P=d.signal.register(H=>{o(H)}),x=new qn(s.signal),A=new ta(T,x,R,t.segmentRetryOptions),k=na(T.thumbnails,x),N=new Qn,[D,q,B]=Os(e,u,{useMseInWorker:p,hasVideo:this._hasVideo,hasText:l},d.signal),_=new Gt(q);this._currentContent={cmcdDataBuilder:R,contentId:u,enableRepresentationAvoidance:h,freezeResolver:_,mediaSource:D,manifest:null,manifestFetcher:E,representationEstimator:C,segmentSinksStore:q,segmentQueueCreator:A,fetchThumbnailData:k,coreTextSender:B,trackChoiceSetter:N,useMseInWorker:p},D.addEventListener(\"mediaSourceOpen\",function(){M()},d.signal),s.signal.register(H=>{E.dispose(H.reason)}),E.addEventListener(\"warning\",H=>{e({type:\"warning\",contentId:u,value:ve(H)})},s.signal),E.addEventListener(\"manifestReady\",H=>{if(g!==null){c.warn(\"Core\",\"Multiple `manifestReady` events, ignoring\");return}g=H,this._currentContent!==null&&(this._currentContent.manifest=g),M()},d.signal),E.addEventListener(\"error\",H=>{e({type:\"error\",contentId:u,value:ve(H)}),o(H)},s.signal),E.start();function M(){g===null||D.readyState===\"closed\"||d.isUsed()||(xs(g),g.addEventListener(\"manifestUpdate\",H=>{g!==null&&e({type:\"manifest-update\",contentId:u,value:{manifest:g,updates:H}})},s.signal),P(),a(g))}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(\"ContentPreparer MediaSource reload\"),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new z(\"ContentPreparer MediaSource\");let[t,r,i]=Os(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(e){this._contentCanceller.cancel(e),this._contentCanceller=new z(\"ContentPreparer\")}};function Os(n,e,t,r){let i;if(t.useMseInWorker){let d=new An(Ms());i=d;let u,f=d.handle;if(f.type===\"handle\")u={type:\"handle\",value:f.value};else{let l=URL.createObjectURL(f.value);u={type:\"url\",value:l},r.register(()=>{URL.revokeObjectURL(l)})}n({type:\"attach-media-source\",contentId:e,value:u,mediaSourceId:i.id},[f.value])}else i=new xn(Ms(),e,n);let a=t.hasText?new Yn(e,n):null,{hasVideo:o}=t,s=new bt(i,o,a);return r.register(d=>{s.disposeAll(d.reason),a==null||a.stop(d.reason),i.dispose(d.reason)}),[i,s,a]}var $n=class extends fe{constructor(e,t,r){super(),this._canceller=new z(\"Boundaries Observation\"),this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new ia(e);ue(this._allBufferTypes,\"video\")||i.updateLastVideoAdaptation(null),ue(this._allBufferTypes,\"audio\")||i.updateLastAudioAdaptation(null),this._maximumPositionCalculator=i;let a=this._canceller.signal;rt(()=>{t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let d=new Z(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",d)}else if(s>i.getMaximumAvailablePosition()){let d=new Z(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",d)}},{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(e){this.removeEventListener(),this._canceller.cancel(e!=null?e:\"ContentTimeBoundariesObserver dispose\")}_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(d=>d.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)}},ia=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=Fr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Fr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Fr(this._lastAudioAdaptation),t=Fr(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=zr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=zr(this._lastAudioAdaptation))!=null?t:void 0;{let r=zr(this._lastAudioAdaptation),i=zr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};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.getLastAvailablePosition();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function zr(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 aa(n,e,t,r,i,a){a.register(d=>{e.interruptDurationSetting(d.reason)});let o=new $n(n,t,r.getBufferTypes());a.register(d=>{o.dispose(d.reason)}),o.addEventListener(\"warning\",d=>i.onWarning(d)),o.addEventListener(\"periodChange\",d=>i.onPeriodChanged(d)),o.addEventListener(\"endingPositionChange\",d=>{e.setDuration(d.endingPosition,d.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 oa(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 sa(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,d=>d.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(void 0).signal)}function da(n,e,t){let{DEFAULT_WANTED_BUFFER_AHEAD:r,DEFAULT_MAX_VIDEO_BUFFER_SIZE:i,DEFAULT_MAX_BUFFER_AHEAD:a,DEFAULT_MAX_BUFFER_BEHIND:o}=L.getCurrent(),s={wantedBufferAhead:new X(r),maxVideoBufferSize:new X(i),maxBufferAhead:new X(a),maxBufferBehind:new X(o),limitVideoResolution:new X({height:void 0,width:void 0,pixelRatio:1}),throttleVideoBitrate:new X(1/0)},d=!1,u=new Ht({hasVideo:!0}),f=null,l=null;n(m=>{var h,b;c.debug(\"Core\",\"received message\",{name:m.data.type});let p=m.data;switch(p.type){case\"init\":{if(Ie(!d),d=!0,io(p.value),ws(p.value.logLevel,p.value.logFormat,p.value.sendBackLogs),!v(p.value.dashWasmUrl)){let g=ke.dashParsers.wasm;g===null?c.error(\"Core\",\"Could not initialize DASH_WASM parser: DASH_WASM feature not added\"):g.isCompatible()?g.initialize({wasmUrl:p.value.dashWasmUrl}).catch(y=>{let T=y instanceof Error?y.toString():\"Unknown Error\";c.error(\"Core\",\"Could not initialize DASH_WASM parser\",T)}):c.warn(\"Core\",\"Could not initialize DASH_WASM parser: Browser not compatible\")}p.value.hasVideo||(u.disposeCurrentContent(\"Received Init msg\"),u=new Ht({hasVideo:p.value.hasVideo})),e({type:\"init-success\",value:null})}break;case\"log-level-update\":ws(p.value.logLevel,p.value.logFormat,p.value.sendBackLogs);break;case\"prepare\":Il(e,u,p.value,s,t);break;case\"start\":{let g=u.getCurrentContent();if(p.contentId!==(g==null?void 0:g.contentId))return;f==null||f.stop(),l==null||l.finish();let y=new X(K(p.value.initialObservation,{position:new xt(...p.value.initialObservation.position)}));l=y,f=yl(e,p.value,u,y,s);break}case\"observation\":{let g=u.getCurrentContent();if(p.contentId!==(g==null?void 0:g.contentId))return;let y=p.value,{buffered:T}=y,R=oa(g.mediaSource,null);R.audio!==null&&(T.audio=R.audio),R.video!==null&&(T.video=R.video),l==null||l.setValue(K(y,{position:new xt(...p.value.position)}));break}case\"ref-update\":bl(p,s);break;case\"stop\":if(p.contentId!==((h=u.getCurrentContent())==null?void 0:h.contentId))return;u.disposeCurrentContent(\"StopContent message\"),f==null||f.stop(),f=null,l==null||l.finish(),l=null;break;case\"ms-reload\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;f==null||f.signalMediaSourceReload()}break;case\"sb-success\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;let{sourceBuffers:y}=g.mediaSource,T=j(y,R=>R.type===p.sourceBufferType);if(T===void 0){c.info(\"Core\",\"Success for an unknown SourceBuffer\",{sourceBufferType:p.sourceBufferType});return}if(T.onOperationSuccess===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:p.sourceBufferType});return}T.onOperationSuccess(p.operationId,p.value.buffered);break}case\"sb-error\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;let{sourceBuffers:y}=g.mediaSource,T=j(y,R=>R.type===p.sourceBufferType);if(T===void 0){c.info(\"Core\",\"Error for an unknown SourceBuffer\",{sourceBufferType:p.sourceBufferType});return}if(T.onOperationFailure===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:p.sourceBufferType});return}T.onOperationFailure(p.operationId,p.value);break}case\"media-source-ready-state-change\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;if(g.mediaSource.onMediaSourceReadyStateChanged===void 0){c.warn(\"Core\",\"A MediaSourceInterface with MSE performed a cross-thread operation\");return}g.mediaSource.onMediaSourceReadyStateChanged(p.value);break}case\"decipherability-update\":{if(p.contentId!==((b=u.getCurrentContent())==null?void 0:b.contentId))return;let g=u.getCurrentContent();if(g===null||g.manifest===null)return;let y=p.value;g.manifest.updateRepresentationsDeciperability(T=>{for(let R of y)if(T.representation.uniqueId===R.representationUniqueId)return R.decipherable;return T.representation.decipherable});break}case\"codec-support-update\":{let g=u.getCurrentContent();if(g===null||g.manifest===null)return;let y=p.value;try{let T=g.manifest.updateCodecSupport(y);T!==null&&e({type:\"warning\",contentId:g.contentId,value:ve(T)})}catch(T){e({type:\"error\",contentId:g.contentId,value:ve(T)})}break}case\"urls-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.manifestFetcher.updateContentUrls(p.value.urls,p.value.refreshNow);break}case\"track-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.trackChoiceSetter.setTrack(p.value.periodId,p.value.bufferType,p.value.choice);break}case\"rep-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.trackChoiceSetter.updateRepresentations(p.value.periodId,p.value.adaptationId,p.value.bufferType,p.value.choice);break}case\"add-text-success\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}g.coreTextSender.onPushedTrackSuccess(p.value.ranges);break}case\"push-text-error\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}g.coreTextSender.onPushedTrackError(new Error(p.value.message));break}case\"remove-text-success\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}g.coreTextSender.onRemoveSuccess(p.value.ranges);break}case\"remove-text-error\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}g.coreTextSender.onRemoveError(new Error(p.value.message));break}case\"pull-segment-sink-store-infos\":{Sl(e,u,p.value.requestId);break}case\"thumbnail-request\":{El(e,u,p);break}case\"config-update\":{L.update(p.value);break}case\"app-defined\":break;default:Be(p)}})}function Il(n,e,t,r,i){e.initializeNewContent(n,t,{limitResolution:{video:r.limitVideoResolution},throttleBitrate:{video:r.throttleVideoBitrate}},i).then(a=>{n({type:\"manifest-ready\",contentId:t.contentId,value:{manifest:a}})},a=>{n({type:\"error\",contentId:t.contentId,value:ve(a)})})}function bl(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 yl(n,e,t,r,i){c.debug(\"Core\",\"Loading pepared content.\");let a=new z(\"Start Content Worker\"),o=null;return s(e.initialTime),{signalMediaSourceReload:()=>u(),stop:()=>{a.cancel(\"ContentHandle stop\")}};function s(f){var B;o==null||o.cancel(\"Reloading content worker\"),o=new z(\"(Re)Loading Content Worker\"),o.linkToSignal(a.signal);let l=new Map,m=t.getCurrentContent();if(m===null||m.manifest===null){let _=new Ee(\"NONE\",\"Loading content when none is prepared\");throw n({type:\"error\",contentId:void 0,value:ve(_)}),_}let{contentId:p,cmcdDataBuilder:h,enableRepresentationAvoidance:b,manifest:g,mediaSource:y,representationEstimator:T,segmentSinksStore:R,segmentQueueCreator:E}=m,{drmSystemId:C,enableFastSwitching:P,onCodecSwitch:x}=e;r.onUpdate(_=>{As(_,R);let M=m.freezeResolver.onNewObservation(_);M!==null&&Tl(n,M,{contentId:p,manifest:g,handleMediaSourceReload:d,enableRepresentationAvoidance:b})},{clearSignal:o.signal});let A=(B=g.getPeriodForTime(f))!=null?B:g.getNextPeriod(f);if(A===void 0){let _=new Z(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");throw n({type:\"error\",contentId:p,value:ve(_)}),_}let k=new hn(r,p,n,o.signal);h==null||h.startMonitoringPlayback(k),o.signal.register(()=>{h==null||h.stopMonitoringPlayback()});let N=aa(g,y,k,R,{onWarning:_=>n({type:\"warning\",contentId:p,value:ve(_)}),onPeriodChanged:_=>{n({type:\"active-period-changed\",contentId:p,value:{periodId:_.id}})}},o.signal);ls({initialPeriod:A,manifest:g},k,T,R,E,{wantedBufferAhead:i.wantedBufferAhead,maxVideoBufferSize:i.maxVideoBufferSize,maxBufferAhead:i.maxBufferAhead,maxBufferBehind:i.maxBufferBehind,drmSystemId:C,enableFastSwitching:P,onCodecSwitch:x},D(),o.signal);function D(){return{needsBufferFlush(_){n({type:\"needs-buffer-flush\",contentId:p,value:_})},streamStatusUpdate(_){q(_),g.isLastPeriodKnown&&_.period.id===g.periods[g.periods.length-1].id&&(_.hasFinishedLoading||_.isEmptyStream?N.onLastSegmentFinishedLoading(_.bufferType):N.onLastSegmentLoadingResume(_.bufferType))},needsManifestRefresh(){t.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:_}=L.getCurrent();t.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:_})},lockedStream(_){n({type:\"locked-stream\",contentId:p,value:{periodId:_.period.id,bufferType:_.bufferType}})},adaptationChange(_){var M,w;n({type:\"adaptation-changed\",contentId:p,value:{adaptationId:(w=(M=_.adaptation)==null?void 0:M.id)!=null?w:null,periodId:_.period.id,type:_.type}}),N.onAdaptationChange(_.type,_.period,_.adaptation)},representationChange(_){var M,w;N.onRepresentationChange(_.type,_.period),!(o===null||o.signal.isCancelled())&&n({type:\"representation-changed\",contentId:p,value:{adaptationId:_.adaptation.id,representationId:(w=(M=_.representation)==null?void 0:M.id)!=null?w:null,periodId:_.period.id,type:_.type}})},inbandEvent(_){n({type:\"inband-event\",contentId:p,value:_})},warning(_){n({type:\"warning\",contentId:p,value:ve(_)})},periodStreamReady(_){m!==null&&(m.trackChoiceSetter.addTrackSetter(_.period.id,_.type,_.adaptationRef),n({type:\"period-stream-ready\",contentId:p,value:{periodId:_.period.id,bufferType:_.type}}))},periodStreamCleared(_){if(m===null)return;let M=l.get(_.period);M!==void 0&&(M.delete(_.type),M.size===0&&l.delete(_.period)),N.onPeriodCleared(_.type,_.period),m.trackChoiceSetter.removeTrackSetter(_.period.id,_.type),n({type:\"period-stream-cleared\",contentId:p,value:{periodId:_.period.id,bufferType:_.type}})},bitrateEstimateChange(_){var M;m!==null&&((M=m.cmcdDataBuilder)==null||M.updateThroughput(_.type,_.bitrate)),n({type:\"bitrate-estimate-change\",contentId:p,value:{bitrate:_.bitrate,bufferType:_.type}})},needsMediaSourceReload(_){d(_)},needsDecipherabilityFlush(){n({type:\"needs-decipherability-flush\",contentId:p,value:null})},encryptionDataEncountered(_){for(let M of _){let w=M.content,U=J({},w);U.manifest instanceof ht&&(U.manifest=U.manifest.getMetadataSnapshot()),U.period instanceof gt&&(U.period=U.period.getMetadataSnapshot()),U.adaptation instanceof ft&&(U.adaptation=U.adaptation.getMetadataSnapshot()),U.representation instanceof un&&(U.representation=U.representation.getMetadataSnapshot()),n({type:\"encryption-data-encountered\",contentId:p,value:{keyIds:M.keyIds,values:M.values,content:U,type:M.type}})}},error(_){n({type:\"error\",contentId:p,value:ve(_)})}}}function q(_){let{imminentDiscontinuity:M}=_,w=l.get(_.period),U=w==null?void 0:w.get(_.bufferType);if(U!==void 0){if(U.discontinuity===null){if(M===null)return}else if(M!==null&&U.discontinuity.start===M.start&&U.discontinuity.end===M.end)return}w===void 0&&(w=new Map,l.set(_.period,w));let H={periodId:_.period.id,bufferType:_.bufferType,discontinuity:_.imminentDiscontinuity,position:_.position};w.set(_.bufferType,H),n({type:\"discontinuity-update\",contentId:p,value:H})}}function d(f){var m;o!==null&&(o.cancel(\"WorkerMain MediaSource reload\"),o=null);let l=(m=t.getCurrentContent())==null?void 0:m.mediaSource.id;if(l===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:l,value:f},[]),u()}function u(){var p;let l=r.getValue().position.getWanted();o!==null&&(o.cancel(\"MediaSource reload\"),o=null);let m=(p=t.getCurrentContent())==null?void 0:p.contentId;t.reloadMediaSource(n).then(()=>{c.info(\"Core\",\"MediaSource Reloaded, loading content again\",{newInitialTime:l}),s(l)},h=>{if(z.isCancellationError(h)){c.info(\"Core\",\"A reloading operation was cancelled\");return}n({type:\"error\",contentId:m,value:ve(h)})})}}function ws(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 Sl(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 Tl(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 El(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\"));sa(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 Ds=da;var _l=new Rt,qr=_l;var Rl=\"<\",Pl=60,Bs=\">\",Wr=62,ua=45,Ns=47,vl=33,Us=39,Ls=34,la=91,Cl=93,Al=`\\r\n\t>/= `;function fa(n,e={}){var m,p;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=(p=e.attrName)!=null?p:\"id\",a=[];(t=l())!==-1;)t=n.lastIndexOf(\"<\",t),t!==-1&&a.push(u()),n=n.substring(t),t=0;else a=o(\"\");return e.filter!==void 0&&(a=Fs(a,e.filter)),a;function o(h){let b=[];for(;n[t]!==void 0;)if(n.charCodeAt(t)===Pl){if(n.charCodeAt(t+1)===Ns){let y=t+2;if(t=n.indexOf(Bs,t),n.substring(y,t).indexOf(h)===-1){let R=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(R.length-1)+`\nColumn: `+(R[R.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),b}else if(n.charCodeAt(t+1)===vl){if(n.charCodeAt(t+2)===ua){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===Wr&&n.charCodeAt(t-1)===ua&&n.charCodeAt(t-2)===ua);)t=n.indexOf(Bs,t+1);t===-1&&(t=n.length),r&&b.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?(b.push(n.substring(t+9)),t=n.length):(b.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let T=!1;for(;(n.charCodeAt(t)!==Wr||T)&&n[t]!==void 0;)n.charCodeAt(t)===la?T=!0:T&&n.charCodeAt(t)===Cl&&(T=!1),t++;b.push(n.substring(y,t))}t++;continue}let g=u();b.push(g),g.tagName[0]===\"?\"&&(b.push(...g.children),g.children=[])}else{let g=s();if(i)g.length>0&&b.push(g);else{let y=g.trim();y.length>0&&b.push(y)}t++}return b}function s(){let h=t;return t=n.indexOf(Rl,t)-1,t===-2&&(t=n.length),n.slice(h,t+1)}function d(){let h=t;for(;Al.indexOf(n[t])===-1&&n[t]!==void 0;)t++;return n.slice(h,t)}function u(){let h=t;t++;let b=d(),g={},y=[];for(;n.charCodeAt(t)!==Wr&&n[t]!==void 0;){let T=n.charCodeAt(t);if(T>64&&T<91||T>96&&T<123){let R=d(),E=n.charCodeAt(t);for(;!isNaN(E)&&E!==Us&&E!==Ls&&!(E>64&&E<91||E>96&&E<123)&&E!==Wr;)t++,E=n.charCodeAt(t);let C;E===Us||E===Ls?C=f():(C=null,t--),g[R]=C===null?null:zs(C)}t++}return n.charCodeAt(t-1)!==Ns?(t++,y=o(b)):t++,{tagName:b,attributes:g,children:y,posStart:h,posEnd:t}}function f(){let h=n[t],b=t+1;return t=n.indexOf(h,b),n.slice(b,t)}function l(){let h=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return h!==null?h.index:-1}}function Fs(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=Fs(a.children,e,t+1,(Q(r)?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function Vr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+Vr(t),e=e.trim()}),e}else return typeof n==\"object\"?Vr(n.children):\" \"+zs(n)}function zs(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 v(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 qs(n,e,t){return[n*t,(n+e)*t]}function xl(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 Ws(n,e,t){let{timeline:r}=n,i=Ce(e,n);if(i<0)return null;let a=xl(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 d=s.start,u=Fe(o,s,t);return i>=u&&i<d?Je(d,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 kl(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 kl(String(n),i)}}function ze(n,e,t){return Ml(n,e,t)}function Ml(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 Gr(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 Ol(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function Xn(n,e,t,r,i,a){var T;let o=r.getEstimatedMaximumPosition((T=n.availabilityTimeOffset)!=null?T:0),s=Math.min(e+t,o!=null?o:1/0),d=Ce(e,n),u=Ce(s,n),{timeline:f,timescale:l,segmentUrlTemplate:m,startNumber:p,endNumber:h}=n,b=p!=null?p:1,g=[],y=f.length;for(let R=0;R<y;R++){let E=f[R],{duration:C,start:P,range:x}=E,A;o===void 0?A=i:A=Math.min(o*l,i!=null?i:1/0);let k=ma(E,f[R+1],A),N=n.availabilityTimeComplete!==!1||R!==y-1&&k!==0,D=Ol(P,C,d),q=P+D*C;for(;q<u&&D<=k;){let B=b+D;if(h!==void 0&&B>h)break;let _=m===null?null:Gr(q,B)(m),M=q-n.indexTimeOffset,w=C;M<0&&(w=C+M,M=0);let U={id:String(q),time:M/l,end:(M+w)/l,duration:w/l,isInit:!1,range:x,timescale:1,url:_,number:B,timestampOffset:-(n.indexTimeOffset/l),complete:N,privateInfos:{isEMSGWhitelisted:a}};g.push(U),D++,q=P+D*C}if(q>=u||(b+=k+1,h!==void 0&&b>h))return g}return g}function wl(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,b,g,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,d=(h=e.timescale)!=null?h:1,f=((b=e.presentationTimeOffset)!=null?b:0)-r*d,l=((g=e.initialization)==null?void 0:g.media)===void 0?null:ze(e.initialization.media,a,o),m=e.media===void 0?null:ze(e.media,a,o),p;e.initialization!==void 0?p=e.initialization.range:e.indexRange!==void 0&&(p=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:f,initialization:{url:l,range:p},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:d},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 Xn(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++)wl(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 p,h,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 d=(p=e.presentationTimeOffset)!=null?p:0,u=(h=e.timescale)!=null?h:1,f=d-r*u,l=((b=e.initialization)==null?void 0:b.media)===void 0?null:ze(e.initialization.media,a,o),m=e.list.map(g=>({url:g.media===void 0?null:ze(g.media,a,o),mediaRange:g.mediaRange}));this._index={list:m,timescale:u,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,d=e-this._periodStart,[u,f]=qs(d,t,o),l=Math.min(a.length-1,Math.floor(f/i)),m=[],p=Math.floor(u/i);for(;p<=l;){let h=a[p].mediaRange,b=a[p].url,g=p*s+this._periodStart,y={id:String(p),time:g,isInit:!1,range:h,duration:s,timescale:1,end:g+s,url:b,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(y),p++}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,T,R;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:d,representationBitrate:u,isEMSGWhitelisted:f}=t,l=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(T=e.presentationTimeOffset)!=null?T:0,p=s*l,h=m-p;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let b=((R=e.initialization)==null?void 0:R.media)===void 0?null:ze(e.initialization.media,d,u),g=e.media===void 0?null:ze(e.media,d,u);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:h,initialization:v(e.initialization)?void 0:{url:b,range:e.initialization.range},url:g,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:d}=r,u=this._periodStart*s,f=this._scaledRelativePeriodEnd,l=e*s-u,m=(e+t)*s-u,p=this._getFirstSegmentStart(),h=this._getLastSegmentStart();if(v(p)||v(h))return[];let b=Math.max(p,l),g=Math.min(h,m);if(g+i<=b)return[];let y=[],T=a!=null?a:1,R=Math.floor(b/i);for(let E=R*i;E<=g;E+=i){let C=R+T;if(o!==void 0&&C>o)return y;let P=!v(f)&&E+i>f?f-E:i,x=E+u,A=E+this._index.presentationTimeOffset,k=d===null?null:Gr(A,C)(d),N={id:String(C),number:C,time:x/s,end:(x+P)/s,duration:P/s,timescale:1,isInit:!1,scaledDuration:P/s,url:k,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(N),R++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return v(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(v(e))return e;let t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,t!=null?t:1/0)/this._index.timescale+this._periodStart}getEnd(){if(!this._isDynamic)return this.getLastAvailablePosition();let e=this._estimateRelativeScaledEnd();if(e===void 0)return;let{timescale:t}=this._index;return(e+this._periodStart*t)/t}awaitSegmentBetween(e,t){if(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,d=this._getLastSegmentStart();if(v(d)){let l=this._estimateRelativeScaledEnd();return l===void 0?s+i>=0:s+i>=0&&o<l-i}let u=d+this._index.duration,f=this._estimateRelativeScaledEnd();return f===void 0?s>u-i:s>u-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=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 l=Math.ceil(this._scaledRelativePeriodEnd/e);return r!==void 0&&r-i+1<l&&(l=r-i+1),(l-1)*e}let d=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(d===void 0)return;let u=(d-this._periodStart)*t;if(u<0)return null;let f=Math.floor(u/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,d=Math.ceil(s/e);r!==void 0&&r-i+1<d&&(d=r-i+1);let u=(d-1)*e,f=L.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-u>f||d<2?u:(d-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 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 h=(r-m.start)/m.duration-1;if(h%1===0&&m.duration===e[0].duration){let b=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=b,!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 d=o.start+o.duration*(o.repeatCount+1),u=s.start+s.duration*(s.repeatCount+1);return d>=u?(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 Zn(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 Jn(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 yt(n){let e=[];for(let r=0;r<n.length;r++)e.push(Jn(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=Zn(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=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 d=o.attributes.d,u=v(d)?null:parseInt(d,10);if(u===null||Number.isNaN(u))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 h=t-s;if(h%u===0&&h/u<=l)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/u,prevSegmentsIdx:0,newElementsIdx:a}}s+=u*(l+1)}else s+=u;if(a++,a>=e.length)return null;o=e[a];let m=o.attributes.t,p=v(m)?null:parseInt(m,10);if(p!==null){if(Number.isNaN(p))return null;s=p}if(s===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(s>i)return null}}}function Ia(n,e){var b;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,d=e.length-r+i-1;if(d>=n.length)return c.info(\"dash\",'Cannot perform \"based\" update. New timeline too short'),yt(n);let u=e.slice(r);if(a>0){let g=u[0];g.start+=g.duration*a,u[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=u[u.length-1],l=Jn(n[d]),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.'),yt(n);l.repeatCount!==void 0&&l.repeatCount>f.repeatCount&&(f.repeatCount=l.repeatCount);let p=[],h=[];for(let g=d+1;g<n.length;g++)h.push(Jn(n[g]));for(let g=0;g<h.length;g++){let y=h[g],T=p[p.length-1]===void 0?f:p[p.length-1],R=h[g+1]===void 0?null:h[g+1],E=Zn(y,T,R);E!==null&&p.push(E)}return u.concat(p)}var er=class n{constructor(e,t){var E,C,P,x,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:d,representationBitrate:u,periodStart:f,periodEnd:l,isEMSGWhitelisted:m}=t,p=(E=e.timescale)!=null?E:1,h=(C=e.presentationTimeOffset)!=null?C:0,b=f*p,g=h-b;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(P=t.receivedTime)!=null?P: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=(x=e.timelineParser)!=null?x:null;let y=((A=e.initialization)==null?void 0:A.media)===void 0?null:ze(e.initialization.media,d,u),T=e.media===void 0?null:ze(e.media,d,u),R;i===void 0&&r===void 0?R=1/0:R=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:R,indexRange:e.indexRange,indexTimeOffset:g,initialization:v(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:T,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:ba(e.timeline,e.startNumber,e.endNumber),timescale:p},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()),Xn(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=Hr(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 u,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=Hr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(u=this._scaledPeriodEnd)!=null?u:1/0)+a>=Math.min(o,(f=this._scaledPeriodEnd)!=null?f:1/0))return!1;let d=Ce(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],p=Fe(l,null,this._scaledPeriodEnd)+a;if(d<p+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:d-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()),Dl(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),Ws({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=Hr(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(v(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),d=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-d),o.push(s),o}}}return n}function Dl(n,e,t,r){let i=Hr(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 u=(s-o.start)/o.duration-1;return u%1===0&&u<=i.newRepeatCount}}return!1}function Hr(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 u=Ce(r,n)-a.start,f=Math.floor(u/a.duration);return Ie(f>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:f-1,end:a.start+f*a.duration}}}}return null}var Kr=er;var tr=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 jr(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 Yr(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=Yr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=Yr(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 Qr(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=Qr(r);if(s===void 0)return;a=s}if(i!==void 0){let s=Qr(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 nr=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:v(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(!v(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||v(e.availabilityStartTime)?0:e.availabilityStartTime;else{let u=t[t.length-1];if(!v(u)&&!v(u.periodEnd))a=u.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 d=v(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:d})}),t}function Bl(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 d of s)d.id===a&&(d.trickModeTracks===void 0&&(d.trickModeTracks=[]),d.trickModeTracks.push(r))}}}var Vs=Bl;var Nl=[\"subtitle\",\"caption\"];function Ca(n,e){var s,d,u,f;let t=(f=j((s=n.children.essentialProperties)!=null?s:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\"))!=null?f:j((u=(d=e!=null?e:n.children.representations[0])==null?void 0:d.children.essentialProperties)!=null?u:[],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 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=v(n.children.roles)?null:n.children.roles;function a(s,d){let u=s.split(\"/\")[0];if(ue(Lt,u))return u;if(s===\"application/ttml+xml\")return\"text\";if(s===\"application/mp4\")return d!==null&&j(d,f=>f.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&ue(Nl,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 d=e[s],{mimeType:u,codecs:f}=d.attributes;if(u!==void 0){let l=a(u,i);if(l!==void 0)return l}if(f!==void 0){let l=o(f);if(l!==void 0)return l}}}var Ul=/[, ]+/g;function Gs(n){return Q(n)?n.trim().replace(Ul,\", \"):\"\"}function Hs(n){let[e,t,r,i,a,o,s,d]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let u,f,l;if((i!==void 0&&i===\"10\"||i===\"12\")&&(u=parseInt(i,10)),s!==void 0&&(s===\"16\"?f=\"pq\":s===\"18\"&&(f=\"hlg\")),o!==void 0&&d!==void 0&&o===\"09\"&&d===\"09\"&&(l=\"rec2020\"),!(u===void 0||f===void 0))return{colorDepth:u,eotf:f,colorSpace:l}}function xa(n,e){var h,b,g;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:d,inbandEventStreams:u,isLastPeriod:f}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:d,isEMSGWhitelisted:y=>u===void 0?!1:u.some(({schemeIdUri:T})=>T===y.schemeIdUri),isLastPeriod:f,manifestBoundsCalculator:r,isDynamic:i,periodEnd:a,periodStart:o,receivedTime:s,representationBitrate:n.attributes.bitrate,representationId:n.attributes.id},p;if(n.children.segmentBase!==void 0){let{segmentBase:y}=n.children;p=new Mt(y,m)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;p=new Ot(y,m)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let y=e.parentSegmentTemplates.slice(),T=n.children.segmentTemplate;T!==void 0&&y.push(T);let R=K({},...y);(R.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((h=R.availabilityTimeOffset)!=null?h:0)+((b=e.availabilityTimeOffset)!=null?b:0)),(R.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(g=R.availabilityTimeComplete)!=null?g:e.availabilityTimeComplete),p=Kr.isTimelineIndexArgument(R)?new Kr(R,m):new wt(R,m)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:T}=y;p=new Mt(T,m)}else if(y.segmentList!==void 0){let{segmentList:T}=y;p=new Ot(T,m)}else p=new wt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return p}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 d=t[s],u=Fn(o.url,d.url);r.push({url:u,serviceLocation:(i=d.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Ll(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 Fl({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 Hs(i)}function ka(n,e,t){var i,a,o,s,d,u,f;let r=[];for(let l of n){let m=l.attributes.id!==void 0?l.attributes.id:String(l.attributes.bitrate)+(l.attributes.height!==void 0?`-${l.attributes.height}`:\"\")+(l.attributes.width!==void 0?`-${l.attributes.width}`:\"\")+(l.attributes.mimeType!==void 0?`-${l.attributes.mimeType}`:\"\")+(l.attributes.codecs!==void 0?`-${l.attributes.codecs}`:\"\");for(;r.some(k=>k.id===m);)m+=\"-dup\";let p=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(m))!=null?a:null,h=Ll(l,e),b=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,g;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(g=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((d=t.availabilityTimeOffset)!=null?d:0));let y=K({},t,{availabilityTimeOffset:g,availabilityTimeComplete:b,unsafelyBaseOnPreviousRepresentation:p,adaptation:e,inbandEventStreams:h}),T=xa(l,y),R;l.attributes.bitrate===void 0?(c.warn(\"dash\",\"No usable bitrate found in the Representation.\"),R=0):R=l.attributes.bitrate;let E=at(t.baseURLs,l.children.baseURLs),C=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(k=>({baseUrl:k.url,id:k.serviceLocation})),P={bitrate:R,cdnMetadata:C,index:T,id:m};l.children.supplementalProperties!==void 0&&j(l.children.supplementalProperties,k=>k.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&k.value===\"JOC\")!==void 0&&(P.isSpatialAudio=!0);let x;l.attributes.codecs!==void 0?x=l.attributes.codecs:e.attributes.codecs!==void 0&&(x=e.attributes.codecs),x!==void 0&&(x=x===\"mp4a.40.02\"?\"mp4a.40.2\":x,P.codecs=x);let A;l.attributes.supplementalCodecs!==void 0?A=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(A=e.attributes.supplementalCodecs),A!==void 0&&(P.supplementalCodecs=Gs(A)),l.attributes.frameRate!==void 0?P.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(P.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?P.height=l.attributes.height:e.attributes.height!==void 0&&(P.height=e.attributes.height),l.attributes.mimeType!==void 0?P.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(P.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?P.width=l.attributes.width:e.attributes.width!==void 0&&(P.width=e.attributes.width);{let k=[...(u=e.children.contentProtections)!=null?u:[],...(f=l.children.contentProtections)!=null?f:[]];for(let N of k)t.contentProtectionParser.add(P,N)}P.hdrInfo=Fl({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:x}),r.push(P)}return r}function zl(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 ql(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 Wl(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function Vl(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,d=s;return Q(n.attributes.language)&&(d+=`-${n.attributes.language}`),t===!0&&(d+=\"-cc\"),r===!0&&(d+=\"-cc\"),i===!0&&(d+=\"-ad\"),a===!0&&(d+=\"-si\"),o&&(d+=\"-trickMode\"),Q(n.attributes.contentType)&&(d+=`-${n.attributes.contentType}`),Q(n.attributes.codecs)&&(d+=`-${n.attributes.codecs}`),Q(n.attributes.mimeType)&&(d+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(d+=`-${String(n.attributes.frameRate)}`),d}function Gl(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=>Q(r))}return[]}function Ma(n,e){var d,u,f,l,m,p,h;let t={video:[],audio:[],text:[]},r=[],i=[],a={},o=[];for(let b=0;b<n.length;b++){let g=n[b],y=g.children,{essentialProperties:T,roles:R,label:E}=y,C=Array.isArray(R)&&R.some(ae=>ae.value===\"main\")&&R.some(ae=>ae.schemeIdUri===\"urn:mpeg:dash:role:2011\"),P=g.children.representations,x=(d=g.attributes.availabilityTimeComplete)!=null?d:e.availabilityTimeComplete,A;(g.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(A=((u=g.attributes.availabilityTimeOffset)!=null?u:0)+((f=e.availabilityTimeOffset)!=null?f:0));let k=Aa(g,P);if(k===void 0)continue;let N=(l=g.attributes.selectionPriority)!=null?l:1,D=g.attributes.id,q=Gl(g),B=[];e.segmentTemplate!==void 0&&B.push(e.segmentTemplate),g.children.segmentTemplate!==void 0&&B.push(g.children.segmentTemplate);let _={availabilityTimeComplete:x,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:B,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},M=Array.isArray(T)?j(T,ae=>ae.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,w=(m=M==null?void 0:M.value)==null?void 0:m.split(\" \"),U=w!==void 0,{accessibilities:H}=y,$;R!==void 0&&R.some(ae=>ae.value===\"dub\")&&($=!0);let V;k!==\"text\"?V=!1:V=ql(H,R);let G;k===\"text\"&&R!==void 0&&R.some(ae=>ae.value===\"forced-subtitle\"||ae.value===\"forced_subtitle\")&&(G=!0);let Y;k!==\"audio\"?Y=!1:H!==void 0&&(Y=H.some(zl));let me;k!==\"video\"?me=!1:H!==void 0&&(me=H.some(Wl));let le=Vl(g,{isAudioDescription:Y,isForcedSubtitle:G,isClosedCaption:V,isSignInterpreted:me,isTrickModeTrack:U,type:k});for(;ue(o,le);)le+=\"-dup\";let ce=le;o.push(le),_.unsafelyBaseOnPreviousAdaptation=(h=(p=e.unsafelyBaseOnPreviousPeriod)==null?void 0:p.getAdaptation(le))!=null?h:null;let Qe=ka(P,g,_);if(k===\"thumbnails\"){let ae=Hl(g,Qe);ae!==null&&r.push(...ae);continue}let te={id:le,representations:Qe,type:k,isTrickModeTrack:U};if(v(g.attributes.language)||(te.language=g.attributes.language),v(V)||(te.closedCaption=V),v(Y)||(te.audioDescription=Y),$===!0&&(te.isDub=!0),G!==void 0&&(te.forcedSubtitles=G),me===!0&&(te.isSignInterpreted=!0),E!==void 0&&(te.label=E),w!==void 0)i.push({adaptation:te,trickModeAttachedAdaptationIds:w});else{let ae=-1;for(let Xt of q){let Zt=a[Xt];if(Zt!==void 0&&Zt.newID!==ce&&ue(Zt.adaptationSetSwitchingIDs,D)){ae=ne(t[k],Jt=>Jt[0].id===Xt);let _e=t[k][ae];if(_e!==void 0&&_e[0].audioDescription===te.audioDescription&&_e[0].closedCaption===te.closedCaption&&_e[0].language===te.language){c.info(\"dash\",'merging \"switchable\" AdaptationSets',{originalID:D,id:Xt}),_e[0].representations.push(...te.representations),_e[1]={priority:Math.max(N,_e[1].priority),isMainAdaptation:C||_e[1].isMainAdaptation,indexInMpd:Math.min(b,_e[1].indexInMpd)};break}}}ae<0&&t[k].push([te,{priority:N,isMainAdaptation:C,indexInMpd:b}])}!v(D)&&v(a[D])&&(a[D]={newID:ce,adaptationSetSwitchingIDs:q})}let s=Lt.reduce((b,g)=>{let y=t[g];return y.length>0&&(y.sort(Ks),b[g]=y.map(([T])=>T)),b},{});return t.video.sort(Ks),Vs(s,i),{adaptations:s,thumbnailTracks:r}}function Hl(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 d=(r=o.index.getFirstAvailablePosition())!=null?r:void 0,u=(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:d,end:u,tileDuration:f===void 0?void 0:f/(s.horizontalTiles*s.verticalTiles)})}}return t}function Ks(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 Kl=Me();function Oa(n,e){var o,s,d,u,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&&!v(e.duration)&&a.setLastPosition(e.duration);for(let l=n.length-1;l>=0;l--){let m=l===n.length-1,p=n[l],h=e.xlinkInfos.get(p),b=at(e.baseURLs,p.children.baseURLs),{periodStart:g,periodDuration:y,periodEnd:T}=r[l],R;for(v(p.attributes.id)?(R=\"gen-dash-period-\"+Kl(),c.warn(\"dash\",\"No usable id found in the Period. Generating one.\",{periodId:R})):R=p.attributes.id;t.some(U=>U.id===R);)R+=\"-dup\";let E=h!==void 0?h.receivedTime:e.receivedTime,C=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(R))!=null?s:null,P=p.attributes.availabilityTimeComplete,x=p.attributes.availabilityTimeOffset,{manifestProfiles:A,contentProtectionParser:k}=e,{segmentTemplate:N}=p.children;k.addReferences((d=p.children.contentProtections)!=null?d:[]);let D={availabilityTimeComplete:P,availabilityTimeOffset:x,baseURLs:b,contentProtectionParser:k,manifestBoundsCalculator:a,end:T,isDynamic:i,isLastPeriod:m,manifestProfiles:A,receivedTime:E,segmentTemplate:N,start:g,unsafelyBaseOnPreviousPeriod:C},{adaptations:q,thumbnailTracks:B}=Ma(p.children.adaptations,D),_=((u=e.xmlNamespaces)!=null?u:[]).concat((f=p.attributes.namespaces)!=null?f:[]),M=Yl(p.children.eventStreams,g,_),w={id:R,start:g,end:T,duration:y,thumbnailTracks:B,adaptations:q,streamEvents:M};if(t.unshift(w),!a.lastPositionIsKnown()){let U=jl(q);if(!i)typeof U==\"number\"&&a.setLastPosition(U);else if(typeof U==\"number\"){let H=F()/1e3;a.setLastPosition(U,H)}else{let H=js(e,g);if(H!==void 0){let[$,V]=H;a.setLastPosition($,V)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=js(e,0);if(l!==void 0){let[m,p]=l;a.setLastPosition(m,p)}}return Pa(t)}function js(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=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 jl(n){let e=null,t=!0,r=yr(n).filter(a=>!v(a)),i=Ri(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let d=s.index.getLastAvailablePosition();d!==null&&(t=!1,typeof d==\"number\"&&(e=v(e)?d:Math.max(e,d)))}}if(v(e)){if(t)return null}else return e}function Yl(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:d=1}=o.attributes,u=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)/d+e,m=f.duration===void 0?void 0:l+f.duration/d,p,h;try{h={namespaces:u,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:Ge(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:d,element:p,xmlData:h}}})}}return r}function jt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(v(e.externalClockOffset)){let d=o.type===\"dynamic\",u=j(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!v(m.value)),f=!v(u)&&!v(u.value)?jr(u.value):void 0,l=!v(f)&&!isNaN(f)?f:void 0;if(!v(l)&&r!==!0)e.externalClockOffset=l;else if(d&&r!==!0){let m=Sa(n);if(!v(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(h){return h.success?(e.externalClockOffset=jr(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 d=0;d<a.periods.length;d++){let{xlinkHref:u,xlinkActuate:f}=a.periods[d].attributes;!v(u)&&f===\"onLoad\"&&s.push({index:d,ressource:u})}return s.length===0?Ql(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:d})=>d),continue:function(u){if(u.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let f=u.length-1;f>=0;f--){let l=s[f].index,{parsed:m,warnings:p,receivedTime:h,sendingTime:b,url:g}=u[f];p.length>0&&t.push(...p);for(let y of m)i.set(y,{receivedTime:h,sendingTime:b,url:g});a.periods.splice(l,1,...m)}return jt(n,e,t,r,i)}}}}function Ql(n,e,t,r){var _,M,w,U,H;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Qi(e.url))}]:[],d=at(s,i.baseURLs),u=Ra(a,e.referenceDateTime),f=a.timeShiftBufferDepth,l=a.maxSegmentDuration,{externalClockOffset:m,unsafelyBaseOnPreviousManifest:p}=e,{externalClockOffset:h}=e,b=new nr({availabilityStartTime:u,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:h}),g=new tr;g.addReferences((_=i.contentProtections)!=null?_:[]);let y={availabilityStartTime:u,baseURLs:d,clockOffset:m,contentProtectionParser:g,duration:a.duration,isDynamic:o,manifestBoundsCalculator:b,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,unsafelyBaseOnPreviousManifest:p,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},T=Oa(i.periods,y);g.finalize();let R=a.duration,E,C,P=null,x;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(E=a.minimumUpdatePeriod===0?L.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:A,maximumSafePosition:k,maximumUnsafePosition:N}=_a(T),D=F();if(o){let $;k!==void 0?$=k:h===void 0?(c.warn(\"dash\",\"use system clock to define maximum position\"),$=Date.now()/1e3-u):$=(F()+h)/1e3-u;let V=b.getEstimatedLiveEdge();V===void 0&&(N!==void 0?V=N:V=$),x={isLinear:!0,maximumSafePosition:$,livePosition:V,time:D},C=A,P=f!=null?f:null,P!==null&&(P+=l!=null?l:0),P!==null&&C!==void 0&&V-C>P&&(P=V-C)}else{C=A,C===void 0&&(C=(w=(M=T[0])==null?void 0:M.start)!=null?w:0);let $=R!=null?R:1/0;if(T[T.length-1]!==void 0){let V=T[T.length-1],G=(U=V.end)!=null?U:V.duration!==void 0?V.start+V.duration:void 0;G!==void 0&&G<$&&($=G)}k!==void 0&&k<$&&($=k),x={isLinear:!1,maximumSafePosition:$,livePosition:void 0,time:D}}let q=!o||n.attributes.minimumUpdatePeriod===void 0&&(((H=T[T.length-1])==null?void 0:H.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:u,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:q,periods:T,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:C,timeshiftDepth:P,maximumTimeData:x},lifetime:E,uris:v(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var $r=jt;var $l=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,Xl=/([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 Xr(n,e){let t=Date.parse(n);return isNaN(t)?[null,new De(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function Ke(n,e){if(!Q(n))return[0,new De(`\\`${e}\\` property is empty`)];let t=$l.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=Xl.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function Ys(n,e){try{return[_r(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(!v(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 Vr(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 Zl(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]=Ys(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 Jl(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=sn(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function st(n){let[e,t]=Zl(n.children),r=Jl(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(!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 Ba(n){let e={},t=[],r=Te(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:Dt,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function dt(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,d]=Ba(o);e.initialization=s,t=t.concat(d)}}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: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(!v(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 rr(n){let[e,t]=dt(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let d=a[s];if(typeof d!=\"string\"&&d.tagName===\"SegmentURL\"){let[u,f]=Na(d);i.push(u),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]=dt(n),r=t,i;for(let s=0;s<n.children.length;s++){let d=n.children[s];typeof d!=\"string\"&&d.tagName===\"SegmentTimeline\"&&(i=Ua(d))}let a=K({},e,{duration:e.duration,timelineParser:i}),o=Te(a,r);for(let s of Object.keys(n.attributes)){let d=n.attributes[s];if(!v(d))switch(s){case\"initialization\":v(a.initialization)&&(a.initialization={media:d});break;case\"index\":a.index=d;break;case\"availabilityTimeOffset\":o(d,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(d,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=d;break;case\"bitstreamSwitching\":o(d,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function ef(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]=dt(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=rr(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\":v(e.essentialProperties)?e.essentialProperties=[Se(a)]:e.essentialProperties.push(Se(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Se(a)]:e.supplementalProperties.push(Se(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function tf(n){let e={},t=[],r=Te(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: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 Qs(n){let[e,t]=ef(n.children),[r,i]=tf(n),a=t.concat(i);return[{children:e,attributes:r},a]}function nf(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\":v(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]=Qs(a);e.representations.push(o),s.length>0&&(r=r.concat(s));break}case\"Role\":v(e.roles)?e.roles=[Se(a)]:e.roles.push(Se(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Se(a)]:e.supplementalProperties.push(Se(a));break;case\"SegmentBase\":{let[o,s]=dt(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=rr(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 rf(n){let e={},t=[],r=Te(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: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 $s(n){let e=n.children,[t,r]=nf(e),[i,a]=rf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function af(n){let e={},t=[],r=Te(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: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 Xs(n,e){let[t,r]=af(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,d]=ie(a.attributes.presentationTime,\"presentationTime\");d!==null&&r.push(d),s!==null&&(o.presentationTime=s)}if(!v(a.attributes.duration)){let[s,d]=ie(a.attributes.duration,\"duration\");d!==null&&r.push(d),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 of(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let d=0;d<n.length;d++){let u=n[d];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":{let[f,l]=ot(u);f!==void 0&&t.push(f),o=o.concat(l);break}case\"AdaptationSet\":{let[f,l]=$s(u);r.push(f),o=o.concat(l);break}case\"EventStream\":{let[f,l]=Xs(u,e);s.push(f),o=o.concat(l);break}case\"SegmentTemplate\":{let[f,l]=Bt(u);i=f,l.length>0&&(o=o.concat(l));break}case\"ContentProtection\":{let[f,l]=st(u);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 sf(n){let e={},t=[],r=Te(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: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 Zr(n,e){let[t,r]=of(n.children,e),[i,a]=sf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function df(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let d=0;d<n.length;d++){let u=n[d];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":{let[f,l]=ot(u);f!==void 0&&t.push(f),s=s.concat(l);break}case\"Location\":r.push(St(u.children));break;case\"Period\":{let[f,l]=Zr(u,e);i.push(f),s=s.concat(l);break}case\"UTCTiming\":{let f=Se(u);a.push(f);break}case\"ContentProtection\":{let[f,l]=st(u);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 uf(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"profiles\":e.profiles=a;break;case\"type\":e.type=a;break;case\"availabilityStartTime\":r(a,{asKey:\"availabilityStartTime\",parser:Xr,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:Xr,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:Xr,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser: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 Zs(n,e){let[t,r]=df(n.children,e),[i,a]=uf(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]=Zs(r,n),o=$r(i,e,a);return s(o);function s(d){if(d.type===\"done\")return d;if(d.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[d.value.url],format:\"string\",continue(u){if(u.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let f=d.value.continue(u[0].responseData);return s(f)}}};if(d.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:d.value.xlinksUrls,format:\"string\",continue(u){let f=[];for(let m=0;m<u.length;m++){let{responseData:p,receivedTime:h,sendingTime:b,url:g}=u[m];if(!p.success)throw p.error;let y=\"<root>\"+p.data+\"</root>\",T=fa(y),R=T[T.length-1];if(R===void 0||typeof R==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let E=R.children,C=[],P=[];for(let x=0;x<E.length;x++){let A=E[x];if(typeof A==\"string\"||A.tagName!==\"Period\")continue;let[k,N]=Zr(A,y);P.push(...N),C.push(k)}f.push({url:g,receivedTime:h,sendingTime:b,parsed:C,warnings:P})}let l=d.value.continue(f);return s(l)}}};Be(d)}}var Js=La;var lf=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",ed=lf;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,d){switch(o){case 16:t.schemeIdUri=W(i,e.buffer,s,d);break;case 13:t.value=W(i,e.buffer,s,d);break;case 14:{let u=W(i,e.buffer,s,d);t.keyId=sn(u.replace(/-/g,\"\"));break}case 15:try{let u=W(i,e.buffer,s,d);r.cencPssh.push(_r(u))}catch(u){}break;case 78:t.ref=W(i,e.buffer,s,d);break;case 79:t.refId=W(i,e.buffer,s,d);break}}}function td(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 nd(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.label=W(t,e.buffer,a,o))}}function qe(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 rd(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 Jr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=rd(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 d=a;for(let u=0;u<o/24;u++)n.timeline.push({start:s.getFloat64(d,!0),duration:s.getFloat64(d+8,!0),repeatCount:s.getFloat64(d+16,!0)}),d+=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 id(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,qe(a,e));break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=qe(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=qe(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=Jr(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 ad(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 od(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=qe(a,e);t.pushParsers(i,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,td(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=qe(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=O,s=qe(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=id(a.children,e,t),s=ad(a.attributes,e);t.pushParsers(i,o,s);break}case 12:{let a={};n.roles===void 0&&(n.roles=[]),n.roles.push(a);let o=qe(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=qe(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=Jr(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,nd(n,e));break}default:t.pushParsers(i,O,O);break}}}function sd(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 dd(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=ff(o,e,r);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function ud(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 d={key:\"\",value:\"\"},u=a,f=s.getUint32(u);u+=4,d.key=W(t,e.buffer,u,f),u+=f;let l=s.getUint32(u);u+=4,d.value=W(t,e.buffer,u,l),n.namespaces===void 0?n.namespaces=[d]:n.namespaces.push(d);break}}}}function ff(n,e,t){let r=new TextDecoder;return function(a,o,s){let d=new DataView(e.buffer);switch(a){case 25:n.presentationTime=d.getFloat64(o,!0);break;case 1:n.duration=d.getFloat64(o,!0);break;case 0:n.id=W(r,e.buffer,o,s);break;case 69:{let u=d.getFloat64(o,!0),f=d.getFloat64(o+8,!0);n.eventStreamData=t.slice(u,f);break}}}}function ei(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=od(o.children,e,t),d=sd(o.attributes,e);t.pushParsers(a,s,d);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,d=Tt(o,e);t.pushParsers(a,s,d);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=dd(o.children,e,t,r),d=ud(o.attributes,e);t.pushParsers(a,s,d);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 ti(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:\"\"},d=new DataView(e.buffer),u=a,f=d.getUint32(u);u+=4,s.key=W(t,e.buffer,u,f),u+=f;let l=d.getUint32(u);u+=4,s.value=W(t,e.buffer,u,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}}function ld(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,d=Tt(o,e);t.pushParsers(a,s,d);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=ei(o.children,e,t,r),d=ti(o.attributes,e);t.pushParsers(a,s,d);break}case 3:{let o={};n.utcTimings.push(o);let s=O,d=qe(o,e);t.pushParsers(a,s,d);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 fd(n,e,t){let r,i=new TextDecoder;return function(o,s,d){switch(o){case 0:e.id=W(i,t.buffer,s,d);break;case 2:e.profiles=W(i,t.buffer,s,d);break;case 33:e.type=W(i,t.buffer,s,d);break;case 34:{let u=W(i,t.buffer,s,d);e.availabilityStartTime=new Date(u).getTime()/1e3;break}case 35:{let u=W(i,t.buffer,s,d);e.availabilityEndTime=new Date(u).getTime()/1e3;break}case 36:{let u=W(i,t.buffer,s,d);e.publishTime=new Date(u).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 u=W(i,t.buffer,s,d);n.locations.push(u);break}case 70:{let u={key:\"\",value:\"\"};r=new DataView(t.buffer);let f=s,l=r.getUint32(f);f+=4,u.key=W(i,t.buffer,f,l),f+=l;let m=r.getUint32(f);f+=4,u.value=W(i,t.buffer,f,m),e.namespaces===void 0?e.namespaces=[u]:e.namespaces.push(u);break}}}}function za(n,e,t,r){return function(a){switch(a){case 1:{n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=ld(n.mpd.children,e,t,r),s=fd(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break}default:t.pushParsers(a,O,O);break}}}function md(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=ei(o.children,e,t,r),d=ti(o.attributes,e);t.pushParsers(a,s,d);break}default:t.pushParsers(a,O,O);break}}}var ir=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 mf=15e3,ar=class{constructor(){this._parsersStack=new ir,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:u,onCustomEvent:m,onAttribute:l,readNext:p,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 d=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=d.catch(async h=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"dash\",\"Unable to call `instantiateStreaming` on WASM\",h instanceof Error?h:\"\");let b=await s;if(b.status<200||b.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(b.status));let g=await b.arrayBuffer();return WebAssembly.instantiate(g,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 b=h instanceof Error?h.toString():\"Unknown error\";throw c.warn(\"dash\",\"Could not create DASH-WASM parser:\",b),this.status=\"failure\",h}),this._initProm;function u(h){return t.childrenParser(h)}function f(h){return t.popIfCurrent(h)}function l(h,b,g){return t.attributeParser(h,b,g)}function m(h,b,g){let y=i._linearMemory,T=new Uint8Array(y.buffer,b,g);if(h===1){let R=r.decode(T);c.warn(\"dash\",\"WASM Error Event:\",R),i._warnings.push(new Error(R))}else if(h===0){let R=r.decode(T);c.warn(\"dash\",\"WASM Log Event:\",R)}}function p(h,b){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let g=i._linearMemory,{mpd:y,cursor:T}=i._mpdData,R=Math.min(b,mf,y.byteLength-T);return new Uint8Array(g.buffer,h,R).set(new Uint8Array(y,T,R)),i._mpdData.cursor+=R,R}}runWasmParser(e,t){let[r,i]=this._parseMpd(e);if(r===null)throw new Error(\"DASH Parser: Unknown error while parsing the MPD\");let a=$r(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return ed&&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(d){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,d}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=md(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:d,sendingTime:u,url:f}=r[o];if(!s.success)throw s.error;let[l,m]=this._parseXlink(s.data);i.push({url:f,receivedTime:d,sendingTime:u,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 Be(e)}};var cd=ar;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 d=0;d<e.length;d++){let u=e[d];u[1]===null?s+=u[0]:s+=`${u[0]}=${u[1]}`,d<e.length-1&&(s+=\"&\")}return r.length>0&&(s+=r),s}function qa(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-F(),d=!1,m={reject:b=>{var R,E;if(d||i.isCancelled())return;d=!0,i.deregister(h);let g=b,y=(R=g==null?void 0:g.message)!=null?R:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",T=new $e(y,(E=g==null?void 0:g.canRetry)!=null?E:!1,g==null?void 0:g.xhr);o(T)},resolve:b=>{if(d||i.isCancelled())return;d=!0,i.deregister(h);let g=b.receivingTime!==void 0?b.receivingTime-s:void 0,y=b.sendingTime!==void 0?b.sendingTime-s:void 0;a({responseData:b.data,size:b.size,requestDuration:b.duration,url:b.url,receivedTime:g,sendingTime:y})},fallback:()=>{d||i.isCancelled()||(d=!0,i.deregister(h),e(t,r,i).then(a,o))}},p=n({url:t,timeout:r.timeout,cmcdPayload:r.cmcdPayload},m);i.register(h);function h(b){d||(d=!0,typeof p==\"function\"&&p(),o(b))}})}function cf(n){return function(t,r,i){var s,d;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=((d=r.cmcdPayload)==null?void 0:d.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=cf(e),i=typeof n!=\"function\"?r:qa(n,r);return t!==null?t(i):i}function Va(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 ni(n){return(e,t,r,i,a)=>{return new Promise((s,d)=>{let u=new z(\"Segment integrity checks\"),f=u.linkToSignal(i);u.signal.register(d),n(e,t,r,u.signal,se(J({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(p){l(),u.cancel(\"Integrity check failed\"),d(p)}}})).then(m=>{if(l(),!u.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(p){d(p);return}s(m)}},m=>{l(),d(m)});function l(){u.signal.deregister(d),f()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||Ye(t.type,t.mimeType)!==\"mp4\"||Va(new Uint8Array(s),t.segment.isInit)}}}function pd(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,d=[\"</\",\"MPD\",\">\"];for(let u=d.length-1;u>=0;u--){let f=d[u];for(;pf(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,d=new DataView(o),u=[[60,47],[77,80,68],[62]];for(let f=u.length-1;f>=0;f--){let l=u[f];for(;gf(d.getUint8(s));)s--;for(let m=l.length-1;m>=0;m--){if(d.getUint8(s)!==l[m])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(!v(ee.Document)&&o instanceof ee.Document&&o.documentElement.nodeName!==\"MPD\")throw new Ee(\"INTEGRITY_ERROR\",\"MPD does not end with </MPD>\")}}}function pf(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function gf(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,d){var T;let{responseData:u}=i,f=a.externalClockOffset,l=(T=i.url)!=null?T:a.originalUrl,m=t!=null?t:f,h={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:m},b=ke.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.\"),g();{let R=yf(u);if(!Sf(R))return c.info(\"dash\",\"MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),g();if(b.wasm.status===\"initialized\"){c.debug(\"dash\",\"Running WASM MPD Parser.\");let E=b.wasm.runWasmParser(R,h);return y(E)}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\"),g();c.debug(\"dash\",\"Running WASM MPD Parser.\");let C=b.wasm.runWasmParser(R,h);return y(C)})}function g(){if(b.js!==null){let R=bf(u),E=b.js(R,h);return y(E)}else throw new Error(\"No MPD parser is imported\")}function y(R){if(R.type===\"done\")return R.value.warnings.length>0&&o(R.value.warnings),s.isCancelled()?Promise.reject(s.cancellationError):{manifest:new ht(R.value.parsed,n),url:l};let{value:E}=R,C=E.urls.map(P=>d(()=>{let x=L.getCurrent().DEFAULT_REQUEST_TIMEOUT,A=L.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return E.format===\"string\"?he({url:P,responseType:\"text\",timeout:x,connectionTimeout:A,cancelSignal:s}):he({url:P,responseType:\"arraybuffer\",timeout:x,connectionTimeout:A,cancelSignal:s})}).then(x=>{if(E.format===\"string\"){if(typeof x.responseData!=\"string\")throw new Error(\"External DASH resources should have been a string\");return K(x,{responseData:{success:!0,data:x.responseData}})}else{if(!(x.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return K(x,{responseData:{success:!0,data:x.responseData}})}},x=>{let A=pe(x,{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(C).then(P=>E.format===\"string\"?(hf(P),y(E.continue(P))):(If(P),y(E.continue(P))))}}}function hf(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 If(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 bf(n){if(n instanceof ArrayBuffer)return Ge(new Uint8Array(n));if(typeof n==\"string\")return n;if(!v(ee.Document)&&n instanceof ee.Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function yf(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return on(n).buffer;if(!v(ee.Document)&&n instanceof ee.Document)return on(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Sf(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:Fn(n.baseUrl,e.url)}function or(n,e,t,r,i){var u,f;let a=n;((u=t.cmcdPayload)==null?void 0:u.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(l=>({resultType:\"segment-loaded\",resultData:l}));if(e.indexRange===void 0)return he({url:a,headers:se(J({},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 he({url:a,headers:se(J({},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=he({url:a,headers:se(J({},o),{Range:We(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),d=he({url:a,headers:se(J({},o),{Range:We(e.indexRange)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([s,d]).then(([l,m])=>{let p=At(new Uint8Array(l.responseData),new Uint8Array(m.responseData)),h=Math.min(l.sendingTime,m.sendingTime),b=Math.max(l.receivedTime,m.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:a,responseData:p,size:l.size+m.size,requestDuration:b-h,sendingTime:h,receivedTime:b}}})}async function sr(n,e,t,r){let i=null;function a(s){let d=new Uint8Array(s.chunk),u=i!==null?At(i,d):d,f=Rr(u),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 gd(n,e,t,r,i,a){var m,p;if(e.segment.isInit)return or(n,e.segment,r,a,i);let o=((m=r.cmcdPayload)==null?void 0:m.type)===\"query\"?je(n,r.cmcdPayload.value):n,s=((p=r.cmcdPayload)==null?void 0:p.type)===\"headers\"?r.cmcdPayload.value:void 0,{segment:d}=e,u;d.range!==void 0?u=se(J({},s),{Range:We(d.range)}):s!==void 0&&(u=s);let f=Ye(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(nn())return sr(o,{headers:u,timeout:r.timeout,connectionTimeout:r.connectionTimeout},i,a);tt(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}return{resultType:\"segment-loaded\",resultData:await he({url:o,responseType:\"arraybuffer\",headers:u,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress})}}function Ha({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:ni(r);function r(i,a,o,s,d){let u=Nt(i,a.segment);return u===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?gd(u,a,n,o,d,s):new Promise((f,l)=>{let m=!1,y={reject:P=>{var N,D;if(m||s.isCancelled())return;m=!0,s.deregister(C);let x=P,A=(N=x==null?void 0:x.message)!=null?N:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",k=new $e(A,(D=x==null?void 0:x.canRetry)!=null?D:!1,x==null?void 0:x.xhr);l(k)},resolve:P=>{if(m||s.isCancelled())return;m=!0,s.deregister(C);let x;P.data instanceof Uint8Array?P.data.buffer instanceof ArrayBuffer?x=P.data:x=P.data.slice():x=P.data,f({resultType:\"segment-loaded\",resultData:{responseData:x,size:P.size,requestDuration:P.duration}})},progress:P=>{m||s.isCancelled()||d.onProgress({duration:P.duration,size:P.size,totalSize:P.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(C),gd(u,a,n,o,d,s).then(f,l))}},T;a.segment.range!==void 0&&(T=[a.segment.range],a.segment.indexRange!==void 0&&T.push(a.segment.indexRange));let R={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:T,trackType:a.type,url:u,cmcdPayload:o.cmcdPayload},E=e(R,y);s.register(C);function C(P){m||(m=!0,typeof E==\"function\"&&E(),l(P))}})}}var ja=408125543,hd=357149030,Tf=2807729,Ef=17545,_f=475249515,Rf=187,Pf=179,vf=183,Cf=241;function _t(n,e,t,[r,i]){let a=r;for(;a<i;){let o=xf(t,a);if(o===null)return null;let{value:s,length:d}=o,u=a+d,f=kf(t,u);if(f===null)return null;let{length:l,value:m}=f,p=u+l,h=p+m;if(s===n)return[p,h];if(e.length>0){for(let b=0;b<e.length;b++)if(s===e[b]){let g=e.slice(b+1,e.length);return _t(n,g,t,[p,h])}}a=h}return null}function ri(n,e){let t=_t(Tf,[ja,hd],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/Ka(n,t[0],r)}function Af(n,e){let t=_t(Ef,[ja,hd],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?Mf(n,t[0]):r===8?Of(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=ri(n,r);if(a===null)return null;let o=Af(n,r);if(o===null)return null;let s=_t(_f,[],n,[r,i]);if(s===null)return null;let d=[],u=s[0];for(;u<s[1];){let l=_t(Rf,[],n,[u,s[1]]);if(l===null)break;let m=_t(Pf,[],n,[l[0],l[1]]);if(m===null)return null;let p=Ka(n,m[0],m[1]-m[0]),h=_t(Cf,[vf],n,[l[0],l[1]]);if(h===null)return null;let b=Ka(n,h[0],h[1]-h[0])+r;d.push({time:p,rangeStart:b}),u=l[1]}let f=[];for(let l=0;l<d.length;l++){let m=d[l];l===d.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:d[l+1].time-m.time,range:[m.rangeStart,d[l+1].rangeStart-1]})}return f}function Id(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function xf(n,e){let t=Id(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 kf(n,e){let t=Id(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 Mf(n,e){return new DataView(n.buffer).getFloat32(e)}function Of(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 dr(n,e,t,r){let i=Ei(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=_i(n);if(a<0&&(o!==void 0&&(o+=a),a=0),e||!t.complete)return o===void 0&&c.warn(\"dash\",\"Chunked segments should indicate a duration through their trun boxes\"),{time:a/r,duration:o!==void 0?o/r:void 0};let s,d=t.duration*r,u=Math.min(r*.9,d/4);return o!==void 0&&Math.abs(o-d)<=u&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function wf(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=Ge(o),d=Date.parse(s);if(a===void 0||d===void 0||isNaN(d)||d>=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:wf(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function $a({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var R,E;let{segment:a,periodStart:o,periodEnd:s}=r,{data:d,isChunked:u}=t,f=[o,s];if(d===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=ko(d),m=Ye(r.type,r.mimeType),p=m===\"mp4\"||m===void 0,h=[];if(p){let C=Pr(l),P;a.isInit&&(P=(R=No(l))!=null?R:void 0),(C.length>0||P!==void 0)&&h.push({initDataType:\"cenc\",keyId:P,initData:C})}if(!a.isInit){let C=p?dr(l,u,a,i):null,P=(E=a.timestampOffset)!=null?E:0;if(p){let x=Bo(l);if(x!==void 0){let A=x.filter(N=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(N)),k=Qa(A,r.manifestPublishTime);if(k!==void 0){let{needsManifestRefresh:N,inbandEvents:D}=k;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:P,appendWindow:f,inbandEvents:D,protectionData:h,needsManifestRefresh:N}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:P,protectionData:h,appendWindow:f}}let{indexRange:b}=a,g;if(m===\"webm\")g=Ya(l,0);else if(p&&(g=fn(l,Array.isArray(b)?b[0]:0),n===!0&&g!==null&&g.length>0)){let C=g[g.length-1];Array.isArray(C.range)&&(C.range[1]=1/0)}let y;p?y=mn(l):m===\"webm\"&&(y=ri(l,0));let T=v(y)?void 0:y;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:h,initTimescale:T,segmentList:g!=null?g:void 0}}}function Xa({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:ni(t);async function t(r,i,a,o,s){var g,y;let{segment:d}=i,u=Nt(r,d);if(u===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(d.isInit)return or(u,d,a,o,s);let f=((g=a.cmcdPayload)==null?void 0:g.type)===\"query\"?je(u,a.cmcdPayload.value):u,l=((y=a.cmcdPayload)==null?void 0:y.type)===\"headers\"?a.cmcdPayload.value:void 0,m;d.range!==void 0?m=se(J({},l),{Range:We(d.range)}):l!==void 0&&(m=l);let p=Ye(i.type,i.mimeType),h=p===\"mp4\"||p===void 0;if(n&&h){if(nn())return sr(f,{headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout},s,o);tt(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}let b;return h?b=await he({url:f,responseType:\"arraybuffer\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}):b=await he({url:f,responseType:\"text\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}),{resultType:\"segment-loaded\",resultData:b}}}function Df(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 Bf(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 bd({segment:n,language:e,codecs:t},r,i,a,o){if(n.isInit)return null;let s,d;a===null?o?(s=n.time,d=n.end):c.warn(\"utils\",\"Unavailable time data for current text track.\"):(s=a.time,a.duration!==void 0?d=s+a.duration:!o&&n.complete&&(d=s+n.duration));let u=Df(t),f=Si(r),l=f!==null?Ge(f):\"\";return t===\"wvtt\"&&!Oe(l,\"WEBVTT\")&&!Oe(l,\"\\xFE\\xFFWEBVTT\")?{data:r,type:\"mp4vtt\",language:e,start:s,end:d,initTimescale:i!=null?i:null}:{data:l,type:u,language:e,start:s,end:d,initTimescale:i!=null?i:null}}function yd(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=Bf(n.codecs,n.mimeType);return{data:e,type:s,language:n.language,start:a,end:o,initTimescale:t!=null?t:null}}function Nf(n,e,t,r,i){var m;let{segment:a}=t,{isInit:o,indexRange:s}=a,d;if(typeof n==\"string\"?d=on(n):n instanceof Uint8Array?d=n:d=new Uint8Array(n),o){let p=fn(d,Array.isArray(s)?s[0]:0);if(i===!0&&p!==null&&p.length>0){let b=p[p.length-1];Array.isArray(b.range)&&(b.range[1]=1/0)}let h=mn(d);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:h,segmentList:p!=null?p:void 0}}let u=dr(d,e,a,r),f=bd(t,d,r,u,e),l=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:f,chunkSize:d.length,chunkInfos:u,chunkOffset:l,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Uf(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 d,u;if(typeof n!=\"string\"){let l=n instanceof Uint8Array?n:new Uint8Array(n);d=Ge(l),u=l.length}else d=n;return{segmentType:\"media\",chunkData:yd(r,d,e,t),chunkSize:u,chunkInfos:null,chunkOffset:s,protectionData:[],appendWindow:[i,a]}}function Za({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var l;let{periodStart:a,periodEnd:o,segment:s}=r,{data:d,isChunked:u}=t;if(d===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=Ye(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?Nf(d,u,r,i,n):Uf(d,i,u,r)}}async function Sd(n,e,t,r){var d,u;let i=Nt(n,e);if(i===null)return Promise.reject(new Error(\"Cannot load thumbnail: no URL\"));let a=((d=t.cmcdPayload)==null?void 0:d.type)===\"query\"?je(i,t.cmcdPayload.value):i,o=((u=t.cmcdPayload)==null?void 0:u.type)===\"headers\"?t.cmcdPayload.value:void 0,s;return e.range!==void 0?s=se(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 Td(n,e){var u;let{thumbnailTrack:t,thumbnail:r}=e,i=t.height/t.verticalTiles,a=t.width/t.horizontalTiles,o=[],s=(u=t.tileDuration)!=null?u:(r.end-r.time)/(t.horizontalTiles*t.verticalTiles),d=r.time;for(let f=0;f<t.verticalTiles;f++)for(let l=0;l<t.horizontalTiles;l++)o.push({start:d,end:d+s,offsetX:Math.round(l*a),offsetY:Math.round(f*i),height:Math.floor(i),width:Math.floor(a)}),d+=s;return{mimeType:t.mimeType,data:n,thumbnails:o}}function Ed(n){let e=Wa({customManifestLoader:n.manifestLoader},Lf()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?pd: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:Sd,parseThumbnail:Td}}}function Lf(){return ke.dashParsers.wasm!==null&&(ke.dashParsers.wasm.status===\"initialized\"||ke.dashParsers.wasm.status===\"initializing\")}var _d=Ed;function Ja(n){let e=new cd;ke.dashParsers.wasm=e,ke.dashParsers.js=Js,ke.transports.dash=_d,ee.onmessageerror=t=>{qr.error(\"Core\",\"Error when receiving message from main thread.\")},Ds(t=>{onmessage=t},Ff,n)}function Ff(n,e){zf(n),n.type!==\"log\"&&qr.debug(\"M<--C\",\"Sending message from worker\",{name:n.type}),e===void 0?postMessage(n):postMessage(n,e)}function zf(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=[])):qr.warn(\"Core\",\"the Manifest instance should be communicated to `sendMessage`.\"))}Ja({representationFilters:new Map,segmentLoaders:new Map,manifestLoaders:new Map});})();\n" + "})()"], { type: "application/javascript" });
4
+ var blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Ad=Object.defineProperty,xd=Object.defineProperties;var kd=Object.getOwnPropertyDescriptors;var ro=Object.getOwnPropertySymbols;var Md=Object.prototype.hasOwnProperty,Od=Object.prototype.propertyIsEnumerable;var io=(n,e,t)=>e in n?Ad(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,J=(n,e)=>{for(var t in e||(e={}))Md.call(e,t)&&io(n,t,e[t]);if(ro)for(var t of ro(e))Od.call(e,t)&&io(n,t,e[t]);return n},de=(n,e)=>xd(n,kd(e));var I={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var ao={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:\"native\",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:\"continue\",DEFAULT_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,FORCE_INITIAL_SEEK_TO_ZERO:!1},oo=ao;function Dd(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:Dd;function ai(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function Jt(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),Jt(i,t[r])}else K(n,{[r]:t[r]});return Jt(n,...e)}function v(n){return n==null}function O(){}var me=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=O;if(r!==void 0){if(r.isCancelled())return;i=r.register(()=>this.removeEventListener(e,t))}let a=this._listeners[e];Array.isArray(a)?a.push({cb:t,onRemove:i}):this._listeners[e]=[{cb:t,onRemove:i}]}removeEventListener(e,t){if(v(e)){for(let i of Object.keys(this._listeners)){let a=this._listeners[i];Array.isArray(a)&&a.forEach(o=>o.onRemove())}this._listeners={};return}let r=this._listeners[e];if(Array.isArray(r)){if(v(t)){r.forEach(i=>i.onRemove()),delete this._listeners[e];return}for(let i=0;i<r.length;i++)if(r[i].cb===t){r[i].onRemove(),r.splice(i,1);break}r.length===0&&delete this._listeners[e]}}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i.cb(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 me{constructor(){super(...arguments);this.updated=!1;this._config=oo}update(t){let r=Jt(this._config,t);this._config=r,this.updated=!0,this.trigger(\"update\",t)}getCurrent(){return this._config}},Bd=new oi,L=Bd;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 ie(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}var fr=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 O;let r=()=>{let o=ie(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 en(n,e,t){let r=new fr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var X=fr;var si=new X(0);function so({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;si.setValueIfChanged(r-t)}var Nd=typeof performance!=\"undefined\"?()=>performance.now()+si.getValue():()=>Date.now()+si.getValue(),F=Nd;var Ud=\"NONE\",tn=class extends me{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=Ud}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 d=F();console.log(String(d.toFixed(2)),\"[Init]\",`Local-Date: ${Date.now()}`)}this._currentFormat=o;let s=this._currentFormat===\"full\"?(d,u)=>(f,...l)=>{let m=F();return u(String(m.toFixed(2)),`[${d}]`,f+\":\",...l.map(g=>typeof g==\"object\"&&g!==null&&!(g instanceof Error)?uo(g):g))}:(d,u)=>(f,...l)=>u(f+\":\",...l.map(m=>typeof m==\"object\"&&m!==null&&!(m instanceof Error)?uo(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 d=u=>i>=this._levels[u]?(f,...l)=>r(u,f,l):O;this.error=d(\"ERROR\"),this.warn=d(\"WARNING\"),this.info=d(\"INFO\"),this.debug=d(\"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 uo(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 Ld=new tn,c=Ld;var mr=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var Fd=typeof window==\"undefined\"&&!mr,cr=Fd;var pr;mr?pr=self:cr?pr=global:pr=window;var te=pr;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}}},Pe={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var di=typeof Headers==\"function\"?Headers:null,gr=typeof AbortController==\"function\"?AbortController:null;function hr(n){var m,g;let e;if(!v(n.headers))if(v(di))e=n.headers;else{e=new di;let h=Object.keys(n.headers);for(let b=0;b<h.length;b++){let p=h[b];e.append(p,n.headers[p])}}c.debug(\"utils\",\"Fetch\",{url:n.url});let t=null,r=!1,i=!1,a=F(),o=v(gr)?null:new gr;function s(){if(v(o)){c.warn(\"utils\",\"Fetch: AbortController API not available.\");return}o.abort()}let d;n.timeout!==void 0&&(d=setTimeout(()=>{r=!0,u!==void 0&&clearTimeout(u),s()},n.timeout));let u;n.connectionTimeout!==void 0&&(u=setTimeout(()=>{i=!0,d!==void 0&&clearTimeout(d),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 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,l).then(h=>{if(u!==void 0&&clearTimeout(u),h.status>=300)throw c.warn(\"utils\",\"Fetch: Request HTTP Error\",{status:h.status,responseUrl:h.url}),new ue(h.url,h.status,Pe.ERROR_HTTP_CODE);if(v(h.body))throw new ue(h.url,h.status,Pe.PARSE_ERROR);let b=h.headers.get(\"Content-Length\"),p=!v(b)&&!isNaN(+b)?+b:void 0,y=h.body.getReader(),T=0;return R();async function R(){let E=await y.read();if(!E.done&&!v(E.value)){T+=E.value.byteLength;let C=F(),P={url:h.url,currentTime:C,duration:C-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:T,totalSize:p};return n.onData(P),R()}else if(E.done){d!==void 0&&clearTimeout(d),f();let C=F();return{requestDuration:C-a,receivedTime:C,sendingTime:a,size:T,status:h.status,url:h.url}}return R()}}).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,Pe.TIMEOUT)):i?(c.warn(\"utils\",\"Fetch: Request connection timed out.\",{url:n.url,connectionTimeout:n.connectionTimeout}),new ue(n.url,0,Pe.TIMEOUT)):h instanceof ue?h:(c.warn(\"utils\",\"Fetch: Request Error\",{error:h instanceof Error?h.toString():\"Unkwown Error\"}),new ue(n.url,0,Pe.ERROR_EVENT)))})}function nn(){let n=/\\[\\s*native\\s+code\\s*\\]/;return typeof te.fetch==\"function\"&&!v(gr)&&n.test(gr.toString())&&!v(di)}function Q(n){return typeof n==\"string\"&&n.length>0}var zd=\"json\";function rn(n){let e={url:n.url,headers:n.headers,responseType:v(n.responseType)?zd:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:d,timeout:u,connectionTimeout:f}=e,l=new XMLHttpRequest;l.open(\"GET\",o,!0);let m;u!==void 0&&(l.timeout=u,m=setTimeout(()=>{p(),r(new ue(o,l.status,Pe.TIMEOUT))},u+3e3));let g;if(f!==void 0&&(g=setTimeout(()=>{p(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new ue(o,l.status,Pe.TIMEOUT))},f)),l.responseType=d,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!v(s)){let y=s;for(let T in y)Object.prototype.hasOwnProperty.call(y,T)&&l.setRequestHeader(T,y[T])}let h=F(),b=null;if(a!==void 0&&(b=a.register(function(T){p(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(T)}),a.isCancelled()))return;if(l.onerror=function(){p(),r(new ue(o,l.status,Pe.ERROR_EVENT))},l.ontimeout=function(){p(),r(new ue(o,l.status,Pe.TIMEOUT))},f!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(g)}),i!==void 0&&(l.onprogress=function(T){let R=F();i({url:o,duration:R-h,sendingTime:h,currentTime:R,size:T.loaded,totalSize:T.total})}),l.onload=function(T){if(l.readyState===XMLHttpRequest.DONE)if(p(),l.status>=200&&l.status<300){let R=F(),E=l.response instanceof ArrayBuffer?l.response.byteLength:T.total,C=l.status,P=l.responseType,x=Q(l.responseURL)?l.responseURL:o,A;if(P===\"json\"?A=typeof l.response==\"object\"?l.response:Wd(l.responseText):A=l.response,v(A)){r(new ue(o,l.status,Pe.PARSE_ERROR));return}t({status:C,url:x,responseType:P,sendingTime:h,receivedTime:R,requestDuration:R-h,size:E,responseData:A})}else r(new ue(o,l.status,Pe.ERROR_HTTP_CODE))},c.hasLevel(\"DEBUG\")){let y=\"XHR GET \"+o;n.responseType!==void 0&&(y+=\" type=\"+n.responseType),u!==void 0&&(y+=\" to=\"+String(u/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)}l.send();function p(){m!==void 0&&clearTimeout(m),g!==void 0&&clearTimeout(g),b!==null&&b()}})}function Wd(n){try{return JSON.parse(n)}catch(e){return null}}var Ie=rn;var Rt=Pe,Ve={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=Ve.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=Ve.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=Ve.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(et(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=Ve.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 an||n instanceof Z||n instanceof _e||n instanceof Xe)&&Object.keys(Ve).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 ke=class n extends Error{constructor(e,t,r){super(t),Object.setPrototypeOf(this,n.prototype),this.name=\"SourceBufferError\",this.errorName=e,this.isBufferFull=r}serialize(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}}toString(){return`${this.errorName}: ${this.message}`}};var qd={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},monothread:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},lo=qd;var Me=lo;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 Vd={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\"},fo=Vd;var Gd={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\"},mo=Gd;function Hd(n){if(v(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=Kd(t);return Q(r)?r:n}function Kd(n){let e;switch(n.length){case 2:e=fo[n];break;case 3:e=mo[n];break}return e}var co=Hd;var po=co;function Ir(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 Oe(){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 be(n,e){if(I.DEV===I.CURRENT_ENV&&!n)throw new br(e===void 0?\"invalid assertion\":e)}function Be(n){throw new br(\"Unreachable path taken\")}var jd=typeof te==\"object\"&&typeof te.TextDecoder==\"function\",Yd=typeof te==\"object\"&&typeof te.TextEncoder==\"function\";function on(n){if(Yd)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 d=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(d),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let d=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(d),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 Qd(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 go(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Ge(n){if(jd)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=Qd(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\"+go(o,4):\"%\"+go(o,2)}}return decodeURIComponent(r)}function sn(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 ui(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:Ge(r)}}function li(n){return Object.keys(n).map(e=>n[e])}var Sr=typeof Object.values==\"function\"?Object.values:li;var Ut=[\"audio\",\"video\",\"text\"];function Io(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 bo(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 yo(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=F()-e.time;return e.maximumSafePosition+t/1e3}function So(n,e){if(e===void 0)return mi(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 To(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(fi(i,e,t))return i;t=i}}function Eo(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 fi(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 mi(n){let e=n.adaptations;return li(e).reduce((t,r)=>v(r)?t:t.concat(r),[])}function $d(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=>dn(a)===!0):n.representations).map(Jd),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function Xd(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 Zd(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>dn(s)===!0):i.representations).map(ho),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=>dn(i)===!0):n.representations).map(ho),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function Jd(n){let{id:e,bitrate:t,chosenCodec:r,isSpatialAudio:i,isSupported:a,decipherable:o}=n;return{id:e,bitrate:t,codec:r,isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function ho(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,chosenCodec:o,hdrInfo:s,isSupported:d,decipherable:u,contentProtections:f}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o,hdrInfo:s,isCodecSupported:d,decipherable:u,contentProtections:f!==void 0?{keyIds:f.keyIds}:void 0}}function Pt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:$d(n,!1)};case\"video\":return{type:\"video\",track:Zd(n,!1)};case\"text\":return{type:\"text\",track:Xd(n)}}}function dn(n){return n.decipherable===!1?!1:n.isSupported}function _o(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}var eu=Oe(),ci=class{constructor(e,t,r){var a,o,s,d;this.id=e.id,this.uniqueId=eu(),this.shouldBeAvoided=!1,this.bitrate=e.bitrate,this.baseCodecs=[],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\"){let u=!1;e.supplementalCodecs!==void 0&&(this.baseCodecs.push(e.supplementalCodecs),u=r.isSupported((a=this.mimeType)!=null?a:\"\",(o=e.supplementalCodecs)!=null?o:\"\",i),u===!0&&(c.debug(\"manifest\",\"supplementalCodec is supported as per the cache\",{codec:e.supplementalCodecs}),this.chosenCodec=e.supplementalCodecs)),e.codecs!==void 0&&this.baseCodecs.push(e.codecs),u===!1&&(u=r.isSupported((s=this.mimeType)!=null?s:\"\",(d=e.codecs)!=null?d:\"\",i),c.debug(\"manifest\",\"codec is supported as per the cache\",{codec:e.codecs}),this.chosenCodec=e.codecs),this.isSupported=u}else e.codecs!==void 0&&(this.baseCodecs.push(e.codecs),this.chosenCodec=e.codecs),this.isSupported=!0}refreshCodecSupport(e){var s,d;if(this.isSupported!==void 0)return;let t=this.contentProtections!==void 0,r=!1,i=(s=this.mimeType)!=null?s:\"\",a=(d=this.baseCodecs)!=null?d:[];a.length===0&&(a=[\"\"]);let o=!1;for(let u of a){if(r=e.isSupported(i,u,t),r===!0){c.debug(\"manifest\",\"codec is found to be supported\",{codec:u}),this.chosenCodec=u;break}r===void 0&&(o=!0)}r===!0?this.isSupported=!0:o?this.isSupported=void 0:this.isSupported=!1}getMimeTypeString(){var t;let e=this.chosenCodec;return e===void 0&&(c.warn(\"manifest\",\"Asked for mimetype string when codec support is yet unknown, attempting with first known linked codec\"),this.baseCodecs!==void 0&&(e=this.baseCodecs[0])),`${(t=this.mimeType)!=null?t:\"\"};codecs=\"${e!=null?e:\"\"}\"`}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 d=0;d<s.values.length;d++)if(s.values[d].systemId.toLowerCase()===e.toLowerCase())if(o)r[r.length-1].values.push(s.values[d]);else{let u=(i=this.contentProtections)==null?void 0:i.keyIds;r.push({type:s.type,keyIds:u,values:[s.values[d]]}),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 d of o)Ir(d,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 d=0;d<r.length;d++){let u=r[d],f;for(f=0;f<s.length;f++)if(u.systemId===s[f].systemId){if(Ir(u.data,s[f].data))break;c.warn(\"manifest\",\"different init data for the same system ID\",{systemId:u.systemId})}f===s.length&&(s.push(u),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}isPlayable(){return dn(this)}getMetadataSnapshot(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,baseCodecs:this.baseCodecs,chosenCodec:this.chosenCodec,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}}},un=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=po(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(u=>new n(u,t)));let s=e.representations,d=[];this.supportStatus={hasSupportedCodec:!1,hasCodecWithUndefinedSupport:!1,isDecipherable:!1};for(let u=0;u<s.length;u++){let f=new un(s[u],this.type,t),l=!0;if(!v(a)){let m={id:f.id,bitrate:f.bitrate,codecs:f.chosenCodec!==void 0?[f.chosenCodec]:f.baseCodecs,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?(d.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})`)}d.sort((u,f)=>u.bitrate-f.bitrate),this.representations=d,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 ye=te,Ro,Po,vo,Co,Ao,pi=(Ao=(Co=(vo=(Po=(Ro=ye==null?void 0:ye.MediaSource)!=null?Ro:ye==null?void 0:ye.MozMediaSource)!=null?Po:ye==null?void 0:ye.WebKitMediaSource)!=null?vo:ye==null?void 0:ye.MSMediaSource)!=null?Co:ye==null?void 0:ye.ManagedMediaSource)!=null?Ao:void 0,tu=pi!==void 0&&pi===(ye==null?void 0:ye.ManagedMediaSource),nu={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4},ru={MediaSource_:pi,isManagedMediaSource:tu,READY_STATES:nu},ln=ru;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},Se={DEVICES:Ne,BROWSERS:ct,browser:ct.Other,device:Ne.Other,isSamsungBrowser:!1};iu();function iu(){var n,e,t;cr||(typeof te.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?Se.browser=ct.Ie11:navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?Se.browser=ct.OtherIeOrEdgePreEdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?Se.browser=ct.EdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?Se.browser=ct.Firefox:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?Se.browser=ct.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=ct.SafariDesktop),/SamsungBrowser/.test(navigator.userAgent)&&(Se.isSamsungBrowser=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?Se.device=Ne.PlayStation4:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?Se.device=Ne.PlayStation5:/Tizen/.test(navigator.userAgent)?Se.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)?Se.device=Ne.WebOs2022:/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent)?Se.device=Ne.WebOs2021:Se.device=Ne.WebOsOther:navigator.userAgent.indexOf(\"NETTV\")!==-1&&navigator.userAgent.indexOf(\"Philips\")!==-1?Se.device=Ne.PhilipsNetTv:/[Pp]anasonic/.test(navigator.userAgent)?Se.device=Ne.Panasonic:navigator.userAgent.indexOf(\"Xbox\")!==-1?Se.device=Ne.Xbox:navigator.userAgent.indexOf(\"Model/a1-kstb40xx\")!==-1&&(Se.device=Ne.A1KStb40xx))}var Lt=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(d){n.deregister(o),a=!0,r(d)},function(d){n.deregister(o),a=!0,i(d)}),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 z=class{constructor(e){let[t,r]=au();this._isUsed=!1,this._trigger=t,this._taskName=e,this.signal=new hi(r)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(r=>{this.cancel(r.reason)});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=new se(this._taskName,e);this._trigger(t)}static isCancellationError(e){return e instanceof se}},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?(be(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(e,t){let r=e!==void 0?`\"${e}\" task cancelled.`:\"This task was cancelled.\";t!==void 0&&(r+=\" Reason: \"+t),super(r),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\",this.reason=t,e!==void 0&&c.debug(\"utils\",`task cancellation: \"${e}\"`+(t===void 0?\"\":` - Reason: \"${t}\"`))}};function au(){let n=O;return[function(t){n(t)},function(t){n=t}]}var ou=[\"\",\"webkit\",\"moz\",\"ms\"];function su(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 du(n,e){return e.filter(t=>su(n,t))[0]}function uu(n,e){return n.reduce((t,r)=>t.concat((e===void 0?ou:e).map(i=>i+r)),[])}function ve(n,e){let t,r=uu(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=du(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 d=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(d=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),d&&delete i[\"on\"+s]})})}}}var Rh=ve([\"loadedmetadata\"]),Ph=ve([\"timeupdate\"]),vh=ve([\"addtrack\"]),Ch=ve([\"removetrack\"]),Ft=ve([\"sourceopen\",\"webkitsourceopen\"]),Tr=ve([\"sourceclose\",\"webkitsourceclose\"]),Er=ve([\"sourceended\",\"webkitsourceended\"]),xo=ve([\"update\"]),ko=ve([\"removesourcebuffer\"]),Ah=ve([\"keymessage\",\"message\"]),xh=ve([\"keyadded\",\"ready\"]),kh=ve([\"keyerror\",\"error\"]),Mh=ve([\"keystatuseschange\"]),Oh=ve([\"seeking\"]),wh=ve([\"seeked\"]),Dh=ve([\"ended\"]);var Mo=[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 _r(n){if(n>=Mo.length)throw new Error(\"Unable to parse base64 string.\");let e=Mo[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function Rr(n){if(typeof Uint8Array.fromBase64==\"function\")return Uint8Array.fromBase64(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 d=0,u=0;d<a;d+=4,u+=3)s=_r(t.charCodeAt(d))<<18|_r(t.charCodeAt(d+1))<<12|_r(t.charCodeAt(d+2))<<6|_r(t.charCodeAt(d+3)),o[u]=s>>16,o[u+1]=s>>8&255,o[u+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 Oo(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 ee(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 wo(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)}function he(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=ee(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(ee(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function Pr(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=ee(n,i+e),o=e+i+a;if(o>n.length)break;let s=Ze(r,1835295092);if(s<0)break;let d=ee(n,s+e),u=e+s+d;if(u>n.length)break;let f=Math.max(o,u),l=n.subarray(e,f);t.push(l),e=f}return t.length===0?[null,r]:[t,r]}function bi(n,e){let t=n;for(let r of e){let i=ne(t,r);if(i===null)return null;t=i}return t}function ne(n,e){let t=tt(n,e);return t!==null?n.subarray(t[1],t[2]):null}function Do(n,e){let t=[],r=n;for(;;){let i=tt(r,e);if(i===null)return t;be(i[2]!==0&&r.length!==0),t.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}function tt(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=ee(n,o),o+=4,i=ee(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 yi(n){return[n>>>24&255,n>>>16&255,n>>>8&255,n&255].map(e=>String.fromCharCode(e)).join(\"\")}function vr(n){let e=ne(n,1836019574);if(e===null)return;let t=0;for(;t<e.length;){let r;try{r=tt(e.subarray(t),1953653099)}catch(a){let o=a instanceof Error?a:\"\";c.warn(\"isobmff\",\"Error while iterating trak boxes in ISOBMFF\",o);return}if(r===null)break;let i=ne(e.subarray(t),1953653099);i!==null&&lu(i),t+=r[2]}}function lu(n){let e=[1685480259,1685485123,1685485379],t=ne(n,1835297121);if(t===null)return;let r=ne(t,1835626086);if(r===null)return;let i=ne(r,1937007212);if(i===null)return;let a=ne(i,1937011556);if(a===null)return;let o=a.subarray(8),s=0;for(;s<o.length&&!(s+8>o.length);){let d=ee(o,s),u=ee(o,s+4);if(d<8||s+d>o.length)break;let f=o.subarray(s,s+d),l=fu(f);if(l===null){s+=d;continue}let m=f.subarray(l);for(let g of e){let h=0;for(;h<m.length;){let b;try{b=tt(m.subarray(h),g)}catch(y){let T=y instanceof Error?y:\"\";c.warn(\"isobmff\",\"Error while patching out dvcC/dvvC/dvwC from ISOBMFF\",T);break}if(b===null)break;c.hasLevel(\"DEBUG\")&&c.debug(\"isobmff\",`Found '${yi(g)}' inside '${yi(u)}', overwriting with 'free'`);let p=h+b[0]+4;m[p]=102,m[p+1]=114,m[p+2]=101,m[p+3]=101,h+=b[2]-b[0]}}s+=d}}function fu(n){for(let e=16;e+8<=n.length;e++){let t=ee(n,e);if(t<8||e+t>n.length)continue;let r=!0;for(let i=e+4;i<e+8;i++)if(n[i]<32||n[i]>126){r=!1;break}if(r)return e}return null}function mu(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function cu(n,e,t){return n.slice(e,t)}var Si=typeof Uint8Array.prototype.slice==\"function\"?cu:mu;function Cr(n){let e=0,t=ne(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=tt(t,1886614376)}catch(s){let d=s instanceof Error?s:\"\";return c.warn(\"isobmff\",\"Error while removing PSSH from ISOBMFF\",d),r}if(i===null)return r;let a=Si(t,i[0],i[2]),o=Bo(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 Bo(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=Si(n,t,t+16);return yr(r)}function Ti(n){let e=ne(n,1836019558);return e===null?null:ne(e,1953653094)}function No(n){return Do(n,1836019558).reduce((t,r)=>{let i=ne(r,1953653094);return i!==null&&t.push(i),t},[])}function Ei(n){return ne(n,1835295092)}function _i(n){let e=ne(n,1836019574);if(e===null)return null;let t=ne(e,1953653099);return t===null?null:ne(t,1835297121)}function Uo(n,e=0){return ne(n.subarray(e),1701671783)}function mn(n,e){let t=tt(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=ee(n,a);a+=4;let d;if(o===0)d=ee(n,a),a+=4,r+=ee(n,a)+i,a+=4;else if(o===1)d=pt(n,a),a+=8,r+=pt(n,a)+i,a+=8;else return null;let u=[];a+=2;let f=Oo(n,a);for(a+=2;--f>=0;){let l=ee(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 h=ee(n,a);a+=4,a+=4,u.push({time:d,duration:h,timescale:s,range:[r,r+g-1]}),d+=h,r+=g}return u}function Ri(n){let e=Ti(n);if(e===null)return;let t=ne(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return pt(t,4);if(r===0)return ee(t,4)}function pu(n){let e=ne(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),ee(e,t)):void 0}function Pi(n){let e=No(n);if(e.length===0)return;let t=0;for(let r of e){let i=ne(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 d=(s&256)>0,u=0;if(!d&&(u=pu(r),u===void 0))return;let f=(s&1)>0,l=(s&4)>0,m=(s&512)>0,g=(s&1024)>0,h=(s&2048)>0,b=ee(i,a);a+=4,f&&(a+=4),l&&(a+=4);let p=b,y=0;for(;p-- >0;)d?(y+=ee(i,a),a+=4):y+=u,m&&(a+=4),g&&(a+=4),h&&(a+=4);t+=y}return t}function cn(n){let e=_i(n);if(e===null)return;let t=ne(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return ee(t,r+16);if(i===0)return ee(t,r+8)}function Lo(n){let e=[],t=0;for(;t<n.length;){let r=Uo(n,t);if(r===null)break;let i=r.length;t+=i;let a=r[0];if(a!==0)c.warn(\"isobmff\",\"EMSG version \"+a.toString()+\" not supported.\");else{let o=4,{end:s,string:d}=ui(r,o);o=s;let{end:u,string:f}=ui(r,o);o=u;let l=ee(r,o);o+=4;let m=ee(r,o);o+=4;let g=ee(r,o);o+=4;let h=ee(r,o);o+=4;let b=r.subarray(o,i),p={schemeIdUri:d,value:f,timescale:l,presentationTimeDelta:m,eventDuration:g,id:h,messageData:b};e.push(p)}}if(e.length!==0)return e}function Fo(n){let e=bi(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=ne(t,1701733238),i=0;if(r===null?(i=28,r=ne(t,1701733217)):i=78,r===null)return null;let a=bi(r.subarray(i),[1936289382,1935894633,1952804451]);if(a===null||a.byteLength<24)return null;let o=a.subarray(8,24);return o.every(s=>s===0)?null:o}function le(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,d)=>s===d||typeof s==\"number\"&&typeof d==\"number\"&&isNaN(s)&&isNaN(d);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}function gu(n,e){let{mimeType:t,codecs:r}=zo(n),{mimeType:i,codecs:a}=zo(e);if(t!==i||r===\"\"||a===\"\")return!1;let o=r.split(\".\")[0];o=o===\"hev1\"?\"hvc1\":o;let s=a.split(\".\")[0];return s=s===\"hev1\"?\"hvc1\":s,o===s}var hu=7;function zo(n){var i;let[e,...t]=n.split(\";\"),r=(i=j(t,a=>he(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(hu),r[0]==='\"'&&(r=r.substring(1,r.length-1)),{mimeType:e,codecs:r}}var Wo=gu;function vi(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 Ci(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function qo(n){var t,r,i,a;let e=[];for(let o of n.periods){let s=[...(t=o.adaptations.video)!=null?t:[],...(r=o.adaptations.audio)!=null?r:[]];for(let d of s)if(d.supportStatus.hasCodecWithUndefinedSupport){for(let u of d.representations)if(u.isSupported===void 0)for(let f of(i=u.baseCodecs)!=null?i:[])e.push({mimeType:(a=u.mimeType)!=null?a:\"\",codec:f})}}return e}var Vo=[];function nt(n){le(Vo,n)||(console.warn(n),Vo.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 gt=class{constructor(e,t,r){if(this.id=e.id,this.adaptations=Iu(e.adaptations,t,r),Go(this.adaptations.video)&&Go(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 mi(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 So(this,e)}containsTime(e,t){return fi(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 Go(n){return Array.isArray(n)?n.length===0:!0}function Iu(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 d=0;d<i.length;d++){let u=i[d],f=ie(a,l=>l.id===u.id);if(f===-1){c.warn(\"manifest\",'ThumbnailTrack \"'+i[d].id+'\" not found when merging.');let[l]=i.splice(d,1);d--,r.removedThumbnailTracks.push({id:l.id})}else{let[l]=a.splice(f,1);u.mimeType=l.mimeType,u.height=l.height,u.width=l.width,u.horizontalTiles=l.horizontalTiles,u.verticalTiles=l.verticalTiles,u.start=l.start,u.end=l.end,u.tileDuration=l.tileDuration,u.cdnMetadata=l.cdnMetadata,t===0?u.index._replace(l.index):u.index._update(l.index),r.updatedThumbnailTracks.push({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})}}a.length>0&&(c.warn(\"manifest\",`${a.length} new Thumbnail tracks found when merging.`),r.addedThumbnailTracks.push(...a.map(d=>({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}))),n.thumbnailTracks.push(...a));let o=n.getAdaptations(),s=e.getAdaptations();for(let d=0;d<o.length;d++){let u=o[d],f=ie(s,l=>l.id===u.id);if(f===-1){c.warn(\"manifest\",'Adaptation \"'+o[d].id+'\" not found when merging.');let[l]=o.splice(d,1);d--,r.removedAdaptations.push({id:l.id,trackType:l.type})}else{let[l]=s.splice(f,1),m=[],g=[],h=[];r.updatedAdaptations.push({adaptation:u.id,trackType:u.type,updatedRepresentations:m,addedRepresentations:g,removedRepresentations:h});let b=u.representations,p=l.representations.slice();for(let y=0;y<b.length;y++){let T=b[y],R=ie(p,E=>E.id===T.id);if(R===-1){c.warn(\"manifest\",`Representation \"${b[y].id}\" not found when merging.`);let[E]=b.splice(y,1);y--,h.push(E.id)}else{let[E]=p.splice(R,1);m.push(T.getMetadataSnapshot()),T.cdnMetadata=E.cdnMetadata,t===0?T.index._replace(E.index):T.index._update(E.index)}}p.length>0&&(c.warn(\"manifest\",`${p.length} new Representations found when merging.`),u.representations.push(...p),g.push(...p.map(y=>y.getMetadataSnapshot())))}}if(s.length>0){c.warn(\"manifest\",`${s.length} new Adaptations found when merging.`);for(let d of s){let u=n.adaptations[d.type];u===void 0?n.adaptations[d.type]=[d]:u.push(d),r.addedAdaptations.push(d.getMetadataSnapshot())}}return r}function Ho(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,d=n[s];for(;d!==void 0&&d.id!==o.id;)s++,d=n[s];if(d!==void 0){let u=gn(d,o,0);t.updatedPeriods.push({period:{id:d.id,start:d.start,end:d.end,duration:d.duration,streamEvents:d.streamEvents},result:u});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 Ko(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=ie(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:K(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let d=e[s],u=-1;for(let f=o;f<n.length;f++)if(d.id===n[f].id){u=f;break}if(u<0){let f=-1;for(let g=o;g<n.length;g++)if(d.start<n[g].start){f=g;break}let l=f-o,m=n.splice(o,l,d);t.addedPeriods.push(d.getMetadataSnapshot()),t.removedPeriods.push(...m.map(g=>({id:g.id,start:g.start,end:g.end})))}else{if(u>o){c.warn(\"manifest\",\"old Periods not found in new when updating, removing\");let l=n.splice(o,u-o);t.removedPeriods.push(...l.map(m=>({id:m.id,start:m.start,end:m.end}))),u=o}let f=gn(n[u],d,0);t.updatedPeriods.push({period:K(n[u].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(d=>({id:d.id,start:d.start,end:d.end})))}return t}var bu=Oe(),hn=class extends me{constructor(e,t){var a;super();let{representationFilter:r,manifestUpdateUrl:i}=t;this.manifestFormat=0,this.id=bu(),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 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(Pt)}):null}getPeriod(e){return j(this.periods,t=>e===t.id)}getPeriodForTime(e){return To(this,e)}getNextPeriod(e){return j(this.periods,t=>t.start>e)}getPeriodAfter(e){return Eo(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return Io(this)}getLivePosition(){return bo(this)}getMaximumSafePosition(){return yo(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=yu(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 qo(this)}_performUpdate(e,t){this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime;let r;if(t===0)this.timeBounds=e.timeBounds,this.uris=e.uris,r=Ho(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=Ko(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 yu(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},d=e(s);d!==!1&&(a=!1),d!==o.decipherable&&(t.push(s),o.decipherable=d,d===!0?i.supportStatus.isDecipherable=!0:d===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 rt(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 ht=hn;var At=class{constructor(e,t){this._last=e,this._wanted=t}serialize(){return[this._last,this._wanted]}getPolled(){return this._last}getWanted(){var e;return(e=this._wanted)!=null?e:this._last}forceWantedPosition(e){this._wanted=e}isAwaitingFuturePosition(){return this._wanted!==null}};function Ar(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 Ar(this,i,t)}}}var In=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 Ar(this,e,this._cancelSignal)}};var it=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var xt=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 le(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 bn=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 Su=.016666666666666666;function jo(n,e){return Math.abs(n-e)<Su}function Qo(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function Tu(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function Eu(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(Xo(t,r)){let i=Qo(t,r);n.splice(--e,2,i)}}return n}function Ai(n,e){return n.end<=e.start}function Yo({start:n,end:e},t){return n<=t&&t<e}function $o(n,e){return Yo(n,e.start)||n.start<e.end&&e.end<n.end||Yo(e,n.start)}function Xo(n,e){return jo(e.start,n.end)||jo(e.end,n.start)}function xi(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function _u(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 Zo(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 xr(n,e){let t=_u(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=$o(t,i),o=Xo(t,i);if(a||o)t=Qo(t,i),n.splice(r--,1);else if(r===0){if(Ai(t,n[0]))break}else if(Ai(n[r-1],t)&&Ai(t,i))break}return n.splice(r,0,t),Eu(Tu(n))}function Ru(n,e){let t=[];for(let r=0;r<e.length;r++)$o(n,e[r])&&t.push(e[r]);return t}function kr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=Ru(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let d=o[s];a.push({start:Math.max(i.start,d.start),end:Math.min(i.end,d.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let d=0;d<a.length;d++)a[d].start>s&&t.push({start:s,end:a[d].start}),s=a[d].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function Mr({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(d=>{a=d.position.getWanted(),o=d.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&Pu(n,a,o,t.getValue(),r.getValue(),i).catch(d=>{if(i.isCancelled()&&z.isCancellationError(d))return;let u=d instanceof Error?d.message:\"Unknown error\";c.error(\"Stream\",\"Could not run BufferGarbageCollector:\",u)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function Pu(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:d}=Zo(t,e),u=()=>{if(isFinite(r)){for(let l of d)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 d)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})}};u(),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 yn=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=>rt(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 Sn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=L.getCurrent();this._inventory=[],this._bufferedHistory=new yn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var d,u,f,l,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 b=e.map(p=>`${p.start}-${p.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 p=e[b].start,y=e[b].end;if(y-p<a){c.warn(\"SI\",\"skipped range when synchronizing because it was too small\",{t:o,rangeStart:p,rangeEnd:y});continue}let T=r;for(;i!==void 0&&((d=i.bufferedEnd)!=null?d:i.end)-p<a;)i=t[++r];let R=null,E=r-T;if(E>0){let P=t[T+E-1];R={end:(u=P.bufferedEnd)!=null?u:P.end,precizeEnd:P.precizeEnd},c.debug(\"SI\",`${E} segments GCed.`,{t:o});let x=t.splice(T,E);for(let A of x)A.bufferedStart===void 0&&A.bufferedEnd===void 0&&A.status!==2&&this._bufferedHistory.addBufferedSegment(A.infos,null);r=T}if(i===void 0)return;if(y-((f=i.bufferedStart)!=null?f:i.start)>=a){if(vu(i,p,R,o),r===t.length-1){es(i,y,o);return}i=t[++r];let P=(l=i.bufferedStart)!=null?l:i.start,x=(m=i.bufferedEnd)!=null?m:i.end,A=b<s-1?e[b+1].start:void 0;for(;i!==void 0&&!(y<P||y-P<a&&x-y>=a||A!==void 0&&y-P<x-A);){let k=t[r-1];k.bufferedEnd===void 0&&(i.precizeStart?k.bufferedEnd=i.start:k.infos.segment.complete?k.bufferedEnd=k.end:k.bufferedEnd=i.start,c.debug(\"SI\",\"calculating buffered end of contiguous segment\",{t:o,prevSegmentBufferedEnd:k.bufferedEnd,pse:k.end})),i.bufferedStart=k.bufferedEnd,i=t[++r],i!==void 0&&(P=(g=i.bufferedStart)!=null?g:i.start,x=(h=i.bufferedEnd)!=null?h:i.end)}}let C=t[r-1];C!==void 0&&es(C,y,o)}if(!v(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:b}=L.getCurrent(),p=F();for(let y=r;y<t.length;y++){let T=t[y];p-T.insertionTs>=b&&(c.debug(\"SI\",\"A segment at the end has been completely GCed\",He(T.infos)),T.bufferedStart===void 0&&T.bufferedEnd===void 0&&T.status!==2&&this._bufferedHistory.addBufferedSegment(T.infos,null),t.splice(y,1),y--)}}o!==void 0&&c.hasLevel(\"DEBUG\")&&c.debug(\"SI\",`current ${o} inventory timeline:\n`+Cu(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},d,u){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:d?0:2,insertionTs:u,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=l.length-1;h>=0;h--){let b=l[h];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(h+1,0,m),h+=2;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,pss:l[h].start,ss:o,se:s}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,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(h,1,m),h+=1;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,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(h,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(h+1,0,m),b.end=m.start,b.bufferedEnd=void 0,b.precizeEnd=b.precizeEnd&&m.precizeStart,h+=2;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:l[h].start}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,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 p={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(h+1,0,m),l.splice(h+2,0,p);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(rt(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&&rt(t[i].infos,e);){let m=t[i].chunkSize;s!==void 0&&m!==void 0&&(s+=m),i++}let d=i-1,u=d-o,f=t[d].end,l=t[d].bufferedEnd;u>0&&(this._inventory.splice(o+1,u),i-=u),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 ki(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 Jo(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 vu(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&&ki(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,ki(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,ki(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 es(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&&Jo(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,Jo(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 Cu(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(d){let u=String.fromCharCode(r.length+65);return r.push({letter:u,periodId:d.period.id,representationId:d.representation.id,bitrate:d.representation.bitrate}),u}let s=\"\";for(let d of n)if(d.bufferedStart!==void 0&&d.bufferedEnd!==void 0){let u=d.infos.period.id,f=d.infos.representation.id,l=t[u],m;if(l===void 0)m=o(d.infos),t[u]={[f]:m};else{let g=l[f];g===void 0?(m=o(d.infos),l[f]=m):m=g}i===null?s+=`${d.bufferedStart.toFixed(2)}|${m}|`:a===m?i.bufferedEnd+e<d.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${m}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${m}|`,i=d,a=m}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(d=>{var u;s+=`\n[${d.letter}] P: ${d.periodId} || R: ${d.representationId}(${(u=d.bitrate)!=null?u:\"unknown bitrate\"})`}),s}function zt(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 ts=Sn;var qt=class{constructor(){this._segmentInventory=new ts}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var Tn=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){ns(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){ns(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:d,appendWindow:u}=e.data;return c.debug(\"Stream\",\"now pushing\",He(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:d,appendWindow:u})}));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(e){try{c.debug(\"Stream\",\"Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose(e)}catch(t){c.debug(\"Stream\",`Failed to dispose a ${this.bufferType} SourceBufferInterface:`,t instanceof Error?t:\"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 ns(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 wr=Tn;var En=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;xu(t.chunk);let r=this._sender.pushTextData(de(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 xu(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(!ku(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 ku(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&&(Mu=function(e){function t(r){}});var Mu;var rs=En;var Ou=[\"audio\",\"video\",\"text\"],_n=class n{static isNative(e){return is(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=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()),be(this._onNativeBufferAddedOrDisabled.length===0))}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(is(e)){if(!v(r))return r instanceof wr&&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 wr(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.slice().forEach(s=>s()),be(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 rs(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,t){let r=this._initializedSegmentSinks[e];if(v(r)){c.warn(\"Stream\",\"Trying to dispose a SegmentSink that does not exist\",{bufferType:e});return}c.info(\"Stream\",\"Aborting SegmentSink\",{bufferType:e}),r.dispose(t),delete this._initializedSegmentSinks[e]}disposeAll(e){Ou.forEach(t=>{this.getStatus(t).type===\"initialized\"&&this.disposeSegmentSink(t,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=>de(J({},o),{infos:wu(o.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function is(n){return n===\"audio\"||n===\"video\"}function wu(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var bt=_n;var Rn=class{constructor({drmSystemId:e,representation:t,notify:r}){if(this._hasSentEncryptionData=!1,this._representation=t,this._notify=r,e!==void 0){let i=t.getEncryptionData(e);i.length>0&&i.every(a=>a.keyIds!==void 0)&&(this._hasSentEncryptionData=!0,r(i))}}onNewProtectionData(e){for(let t of e)this._representation.addProtectionData(t.initDataType,t.keyId,t.initData);if(!this._hasSentEncryptionData){let t=this._representation.getAllEncryptionData();t.length>0&&(this._notify(t),this._hasSentEncryptionData=!0)}}};function Mi(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,d=Du(i,e);if(d===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 u=i[d];if(u.bufferedStart!==void 0&&u.bufferedStart>e.start&&(t===null||u.infos.segment.end<=t)){let l=u.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,l)!==!1?null:(c.debug(\"Stream\",\"current discontinuity encountered\",{bufferType:o.type,nextSegmentTime:u.bufferedStart,checkStartTime:e.start}),{start:void 0,end:l})}let f=Bu(i,e,d+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,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 l=Nu(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 Du(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 Bu(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 Nu(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 Oi({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:d,representation:u}=e,f=Uu(n,o,s),l=u.index.getSegments(a.start,a.end-a.start),m=n.filter(C=>!as(C.infos,e,t,r)),g=Gu(m,a,i),{MINIMUM_SEGMENT_SIZE:h,MIN_BUFFER_AHEAD:b}=L.getCurrent(),p=!1,y=Math.min(1/60,h),T=!1,R=[];return{segmentsToLoad:l.filter(C=>{let P=K({segment:C},e);if(o.length>0&&o.some(B=>rt(P,B)))return!1;let{duration:x,time:A,end:k}=C;if(C.isInit)return!0;if(p)return R.push(C),!1;if(C.complete&&x<h||o.length>0&&o.some(B=>{if(B.period.id!==e.period.id||B.adaptation.id!==e.adaptation.id)return!1;let{segment:_}=B;if(_.time-y>A)return!1;if(_.complete){if(_.end+y<k)return!1}else if(Math.abs(A-_.time)>A)return!1;return!as(B,P,t,r)}))return!1;for(let W of g){let B=W.infos.period.id===e.period.id;if(W.status===1&&B){let _=W.infos.segment;if(A-_.time>-y){if(_.complete){if(_.end-k>-y)return!1}else if(Math.abs(A-_.time)<y)return!1}}}let N=x*e.representation.bitrate;if(f-N<0&&(T=!0,A>a.start+b))return p=!0,R.push(C),!1;let D=i(P);if(D.length>1){let W=D[D.length-1],B=D[D.length-2];if(W.buffered===null&&B.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:d.type,representationId:u.id,segmentTime:C.time}),!1}for(let W=0;W<g.length;W++){let B=g[W];if(B.end+y>A){let _=B.start>A+y||Lu(g,W).end<k-y;return _&&(f-=N),_}}return f-=N,!0}),segmentsOnHold:R,isBufferFull:T}}function Uu(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 Lu(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 as(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:Fu(n.representation,e.representation,r)}function Fu(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 zu(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 Wu(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 qu(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 Vu(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 Gu(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],d=null;if(zu(r,o,e.start)){if(d=t(r.infos),qu(d,r.bufferedStart))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the start\",{segmentStart:r.start,currentStartInBuffer:r.bufferedStart})}if(Wu(r,s,e.end)){if(d=d!=null?d:t(r.infos),Vu(d,r.bufferedEnd))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the end\",{segmentEnd:r.end,currentEndInBuffer:r.bufferedEnd})}return!0})}function Pn(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 wi(n,e,t,r,i,a,o){var A,k,N;let{representation:s}=n,d=(k=(A=t.getIsPaused())!=null?A:t.getReference().getValue().paused.pending)!=null?k:t.getReference().getValue().paused.last,u=(N=t.getPlaybackRate())!=null?N:t.getReference().getValue().speed,f=e;(d===void 0||u===void 0||d||u<=0)&&(f-=.1);let l=Hu(n,f,i),m=s.index.shouldRefresh(l.start,l.end),g=o.getPendingOperations().filter(D=>D.type===2).map(D=>D.value),h=o.getLastKnownInventory(),b=t.getCurrentTime();b===void 0&&(b=t.getReference().getValue().position.getWanted());let p=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:T,isBufferFull:R}=Oi({content:n,bufferedSegments:h,currentPlaybackTime:b,fastSwitchThreshold:r,getBufferedHistory:p,neededRange:l,segmentsBeingPushed:g,maxBufferSize:a}),E=y.map(D=>({priority:Pn(D.time,f),segment:D})),C=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&E.length===0&&T.length===0,P=null;return g.length>0&&(P=Math.min(...g.map(D=>D.segment.time))),T.length>0&&(P=P!==null?Math.min(P,T[0].time):T[0].time),E.length>0&&(P=P!==null?Math.min(P,E[0].segment.time):E[0].segment.time),{imminentDiscontinuity:Mi(n,l,P,C,h),hasFinishedLoading:C,neededSegments:E,isBufferFull:R,shouldRefreshManifest:m}}function Hu(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),d=o.index;!v(s)&&bt.isNative(n.adaptation.type)&&e>=s&&d.isInitialized()&&!d.isStillAwaitingFutureSegments()&&Ku(i,a,e)?r=s-1:r=e-.1;let u=r+t,f;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?f=!1:s===void 0?f=u>=a.end:s===null?f=!0:f=u>=s,{start:Math.max(r,a.start),end:Math.min(u,(l=a.end)!=null?l:1/0),hasReachedPeriodEnd:f}}function Ku(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 vn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof se)throw a;if(!(a instanceof ke)||!a.isBufferFull){let d=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new Z(\"BUFFER_APPEND_ERROR\",d,{tracks:[Pt(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{c.warn(\"Stream\",\"Running garbage collector\");let d=Math.max(s-5,0),u=s+r.getValue()+12;if(d>0&&await e.removeBuffer(0,d),u<Number.MAX_VALUE&&await e.removeBuffer(u,Number.MAX_VALUE),await gi(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(d){if(d instanceof se)throw d;let u=d instanceof Error?d.toString():\"Could not clean the buffer\";throw new Z(\"BUFFER_FULL_ERROR\",u,{tracks:[Pt(t.inventoryInfos.adaptation)]})}}}async function Di({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){let s=e.representation.getMimeTypeString(),d={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},u=K({segment:r,chunkSize:void 0,start:0,end:0},e),f=await vn(n,i,{data:d,inventoryInfos:u},a,o);return{content:e,segment:r,buffered:f}}async function Bi({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var P,x;if(i.chunkData===null)return null;let{chunkData:d,chunkInfos:u,chunkOffset:f,chunkSize:l,appendWindow:m}=i,g=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:h}=L.getCurrent(),b=[m[0]!==void 0?Math.max(0,m[0]-h.START):void 0,m[1]!==void 0?m[1]+h.END:void 0],p={initSegmentUniqueId:r,chunk:d,timestampOffset:f,appendWindow:b,codec:g},y=(P=u==null?void 0:u.time)!=null?P:a.time,T=(x=u==null?void 0:u.duration)!=null?x:a.duration,R=y+T;b[0]!==void 0&&(y=Math.max(y,b[0])),b[1]!==void 0&&(R=Math.min(R,b[1]));let E=K({segment:a,chunkSize:l,start:y,end:R},t),C=await vn(n,o,{data:p,inventoryInfos:E},e,s);return{content:t,segment:a,buffered:C}}function Ni({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:d,adaptation:u,representation:f}=n,{bufferGoal:l,maxBufferSize:m,drmSystemId:g,fastSwitchThreshold:h}=e,b=u.type,p=new z(\"RepresentationStream \"+b);p.linkToSignal(s);let y={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};p.signal.register(()=>{y.uniqueId!==null&&r.freeInitSegment(y.uniqueId)});let T=y.segment!==null;T||(y.isLoaded=!0);let R=new Rn({drmSystemId:g,representation:f,notify:A=>o.encryptionDataEncountered(A.map(k=>K({content:n},k)))});if(p.isUsed())return;i.addEventListener(\"error\",A=>{p.signal.isCancelled()||(p.cancel(\"RepresentationStream: SegmentQueue err\"),o.error(A))},p.signal),i.addEventListener(\"parsedInitSegment\",P,p.signal),i.addEventListener(\"parsedMediaSegment\",P,p.signal),i.addEventListener(\"emptyQueue\",C,p.signal),i.addEventListener(\"requestRetry\",A=>{if(o.warning(A.error),p.signal.isCancelled())return;let k=A.segment,{index:N}=f;N.isSegmentStillAvailable(k)===!1?C():N.canBeOutOfSyncError(A.error,k)&&o.manifestMightBeOufOfSync()},p.signal),i.addEventListener(\"fullyLoadedSegment\",A=>{r.signalSegmentComplete(K({segment:A},n)).catch(x)},p.signal);let E=i.resetForContent(n,T,\"new RepresentationStream linked to SegmentQueue\");p.signal.register(A=>{i.stop(A.reason)}),t.listen(C,{includeLastObservation:!1,clearSignal:p.signal}),n.manifest.addEventListener(\"manifestUpdate\",C,p.signal),l.onUpdate(C,{emitCurrentValue:!1,clearSignal:p.signal}),m.onUpdate(C,{emitCurrentValue:!1,clearSignal:p.signal}),a.onUpdate(C,{emitCurrentValue:!1,clearSignal:p.signal}),C();return;function C(){if(p.isUsed())return;let A=t.getReference().getValue(),k=A.position.getWanted(),N=wi(n,k,t,h.getValue(),l.getValue(),m.getValue(),r),{neededSegments:D}=N,W=null;if(f.index.isInitialized()){if(D.length>0&&!y.isLoaded&&y.segment!==null){let M=D[0].priority;W={segment:y.segment,priority:M}}}else if(y.segment===null)c.warn(\"Stream\",\"Uninitialized index without an initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else if(y.isLoaded)c.warn(\"Stream\",\"Uninitialized index with an already loaded initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else{let M=A.position.getWanted();W={segment:y.segment,priority:Pn(d.start,M)}}let B=a.getValue();if(B===null)E.setValue({initSegment:W,segmentQueue:D});else if(B.urgent){c.debug(\"Stream\",\"Urgent switch, terminate now.\",{bufferType:b,representationBitrate:n.representation.bitrate}),E.setValue({initSegment:null,segmentQueue:[]}),E.finish(),p.cancel(B.reason),o.terminating();return}else{let M=D[0],w=i.getRequestedInitSegment(),U=i.getRequestedMediaSegment(),H=U===null||M===void 0||U.id!==M.segment.id?[]:[M],$=w===null?null:W;if(E.setValue({initSegment:$,segmentQueue:H}),H.length===0&&$===null){c.debug(\"Stream\",\"No request left, terminate\",{bufferType:b,representationBitrate:n.representation.bitrate}),E.finish(),p.cancel(B.reason),o.terminating();return}}if(o.streamStatusUpdate({period:d,position:A.position.getWanted(),bufferType:b,imminentDiscontinuity:N.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:N.hasFinishedLoading,neededSegments:N.neededSegments}),p.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:_}=L.getCurrent();if(N.isBufferFull){let M=Math.max(0,k-_);M>0&&r.removeBuffer(0,M).catch(x)}N.shouldRefreshManifest&&o.needsManifestRefresh()}function P(A){if(R.onNewProtectionData(A.protectionData),A.segmentType===\"init\"){if(!f.index.isInitialized()&&A.segmentList!==void 0&&f.index.initialize(A.segmentList),y.isLoaded=!0,A.initializationData!==null){let k=f.uniqueId;y.uniqueId=k,r.declareInitSegment(k,A.initializationData),Di({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:k,segment:A.segment,segmentData:A.initializationData,segmentSink:r},p.signal).then(N=>{N!==null&&o.addedSegment(N)}).catch(x)}C();return}else{let{inbandEvents:k,predictedSegments:N,needsManifestRefresh:D}=A;if(N!==void 0&&f.index.addPredictedSegments(N,A.segment),D===!0&&(o.needsManifestRefresh(),p.isUsed())||k!==void 0&&k.length>0&&(o.inbandEvent(k),p.isUsed()))return;let W=y.uniqueId;Bi({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:W,parsedSegment:A,segment:A.segment,segmentSink:r},p.signal).then(B=>{B!==null&&o.addedSegment(B)}).catch(x)}}function x(A){p.isUsed()&&A instanceof se||(c.warn(\"Stream\",\"Received fatal buffer error\",{bufferType:b,representationBitrate:n.representation.bitrate},A instanceof Error?A:null),p.cancel(\"RepresentationStream: fatal buffer err\"),o.error(A))}}var os=Ni;function Ui(n,e,t,r,i){var m,g,h,b;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let p of a)p.infos.period.id===n.id&&(p.infos.adaptation.id!==e.id||!le(t.representationIds,p.infos.representation.id))&&It(o,{start:(m=p.bufferedStart)!=null?m:p.start,end:(g=p.bufferedEnd)!=null?g:p.end});let s=r.getPendingOperations();for(let p of s)if(p.type===0){let y=p.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!le(t.representationIds,y.representation.id))){let T=y.segment.time,R=T+y.segment.duration;It(o,{start:T,end:R})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let p=i.getReadyState();if(p===void 0||p>1)return{type:\"needs-reload\",value:void 0}}let d=t.switchingMode===\"direct\",u=[],f=zt(a,n);if(f!==null&&(f.bufferedEnd===void 0||n.start-f.bufferedEnd<1)&&u.push({start:0,end:n.start+1}),!d){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:p}=L.getCurrent(),y=e.type,T=(h=p[y].before)!=null?h:0,R=(b=p[y].after)!=null?b:0,E=i.getCurrentTime();E===void 0&&(E=i.getReference().getValue().position.getPolled()),u.push({start:E-T,end:E+R})}if(n.end!==void 0){let p=Wt(a,n);p!==null&&(p.bufferedStart===void 0||p.bufferedStart-n.end<1)&&u.push({start:n.end-1,end:Number.MAX_VALUE})}let l=kr(o,u);return l.length===0?{type:\"continue\",value:void 0}:d?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function Li({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentQueueCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},d,u){let{manifest:f,period:l,adaptation:m}=e,g=new z(\"AdaptationStream \"+m.type);g.linkToSignal(u);let h=new Map,b=new X(null,g.signal),p,y=e.representations.getValue().representationIds,T=ss(e.adaptation.representations,y),R=new X(T,g.signal),{estimates:E,callbacks:C}=r({manifest:f,period:l,adaptation:m},b,R,n,g.signal),P=new X(!1);n.listen(_=>{var w;let M=(w=_.canStream)!=null?w:!0;P.getValue()===M&&(c.debug(\"Stream\",\"isMediaSegmentQueueInterrupted updated to\",!M),P.setValue(!M))},{clearSignal:g.signal});let x=a.createSegmentQueue(m.type,{onRequestBegin:C.requestBegin,onRequestEnd:C.requestEnd,onProgress:C.requestProgress,onMetrics:C.metrics},P),A=new X(0);E.onUpdate(({bitrate:_,knownStableBitrate:M})=>{t.enableFastSwitching&&A.setValueIfChanged(M),!(_===void 0||_===p)&&(p=_,c.debug(\"Stream\",`new ${m.type} bitrate estimate received from ABR`,{bitrate:_}),d.bitrateEstimateChange({type:m.type,bitrate:_}))},{emitCurrentValue:!0,clearSignal:g.signal});let k;e.representations.onUpdate(_=>{k!==void 0&&k.cancel(\"locked representations changed\");let M=e.representations.getValue().representationIds,w=ss(e.adaptation.representations,M);R.setValueIfChanged(w),k=new z(\"AdaptationStream: RepresentationStream Group \"+m.type),k.linkToSignal(g.signal),N(_,k.signal).catch(U=>{(k==null?void 0:k.isUsed())===!0&&z.isCancellationError(U)||(g.cancel(\"RepresentationStream err\"),d.error(U))})},{clearSignal:g.signal,emitCurrentValue:!0});return;async function N(_,M){let w=Ui(l,m,_,i,n);switch(w.type){case\"continue\":break;case\"needs-reload\":return it(()=>{n.listen(()=>{if(M.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:U}=L.getCurrent(),H=U.bitrateSwitch;return d.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:H,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:M})});case\"flush-buffer\":case\"clean-buffer\":for(let U of w.value)if(await i.removeBuffer(U.start,U.end),M.isCancelled())return;if(w.type===\"flush-buffer\"&&(d.needsBufferFlush(),M.isCancelled()))return;break;default:Be(w)}D(M)}function D(_){let M=new z(\"AdaptationStream: RepresentationStream creation \"+m.type);M.linkToSignal(_);let{representation:w}=E.getValue();if(w===null)return;let U=new X(null,M.signal);E.onUpdate(V=>{if(!(V.representation===null||V.representation.id===w.id))return V.urgent?(c.info(\"Stream\",\"urgent Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:V.representation.bitrate}),U.setValue({urgent:!0,reason:\"Urgent Representation switch\"})):(c.info(\"Stream\",\"slow Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:V.representation.bitrate}),U.setValue({urgent:!1,reason:\"Non-urgent Representation switch\"}))},{clearSignal:M.signal,emitCurrentValue:!0});let H={type:m.type,adaptation:m,period:l,representation:w};if(b.setValue(w),_.isCancelled()||(d.representationChange(H),_.isCancelled()))return;let $={streamStatusUpdate:d.streamStatusUpdate,encryptionDataEncountered:d.encryptionDataEncountered,manifestMightBeOufOfSync:d.manifestMightBeOufOfSync,needsManifestRefresh:d.needsManifestRefresh,inbandEvent:d.inbandEvent,warning:d.warning,error(V){g.cancel(\"RepresentationStream err cb\"),d.error(V)},addedSegment(V){C.addedSegment(V)},terminating(){if(!M.isUsed())return M.cancel(\"RepresentationStream terminating\"),D(_)}};W(w,U,$,_)}function W(_,M,w,U){let H=!1,$=new z(`RepresentationStream-linked listeners in AdaptationStream - periodStart=${l.start} type=${m.type}`);$.linkToSignal(U);let V=en(o,ce=>B(_,ce),$.signal),G=m.type===\"video\"?s:new X(1/0);c.info(\"Stream\",\"changing representation\",{bufferType:m.type,representationId:_.id,representationBitrate:_.bitrate});let Y=K({},w,{error(ce){var pe;if(H){c.warn(\"Stream\",\"Ignoring RepresentationStream error\",ce);return}H=!0;let fe=ge(ce,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(fe.code!==\"BUFFER_FULL_ERROR\")w.error(ce);else{c.warn(\"Stream\",\"received BUFFER_FULL_ERROR\",{bufferType:m.type,representationBitrate:_.bitrate});let Qe=o.getValue(),oe=((pe=h.get(_.id))!=null?pe:1)*.7;if(h.set(_.id,oe),oe<=.05||B(_,Qe)<=2){w.error(fe);return}fn(4e3,$.signal).then(()=>W(_,M,w,U)).catch(O)}},terminating(){$.cancel(\"Representation terminating\"),w.terminating()}});os({playbackObserver:n,content:{representation:_,adaptation:m,period:l,manifest:f},segmentSink:i,segmentQueue:x,terminate:M,options:{bufferGoal:V,maxBufferSize:G,drmSystemId:t.drmSystemId,fastSwitchThreshold:A}},Y,U),f.addEventListener(\"manifestUpdate\",ce=>{for(let fe of ce.updatedPeriods)if(fe.period.id===l.id){for(let pe of fe.result.updatedAdaptations)if(pe.adaptation===m.id){for(let Qe of pe.removedRepresentations)if(Qe===_.id)return $.isUsed()?void 0:d.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:0,stayInPeriod:!0})}}else if(fe.period.start>l.start)break},$.signal)}function B(_,M){let w=h.get(_.id),U=w!==void 0?w:1;return w===void 0&&h.set(_.id,U),U<1&&M===1/0?300*1e3*U:M*U}}function ss(n,e){let t=n.filter(r=>le(e,r.id)&&!r.shouldBeAvoided&&r.isPlayable()!==!1);return t.length>0?t:n.filter(r=>le(e,r.id)&&r.isPlayable()!==!1)}var ds=Li;function Fi(n,e,t,r,i,a){var g,h,b,p;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!ju(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 d=n.getPendingOperations();for(let y of d)if(y.type===0){let T=y.value.inventoryInfos;if(T.period.id===e.id&&T.adaptation.id!==t.id){let R=T.segment.time,E=R+T.segment.duration;It(s,{start:R,end:E})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let y=i.getReadyState();if(y===void 0||y>1)return{type:\"needs-reload\",value:void 0}}let u=r===\"direct\",f=[],l=zt(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!u){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:T}=L.getCurrent(),R=(b=T[y].before)!=null?b:0,E=(p=T[y].after)!=null?p:0,C=i.getCurrentTime();C===void 0&&(C=i.getReference().getValue().position.getPolled()),f.push({start:C-R,end:C+E})}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=kr(s,f);return m.length===0?{type:\"continue\",value:void 0}:u&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function ju(n,e){return n.representations.some(t=>t.isPlayable()===!0&&Wo(t.getMimeTypeString(),e))}function zi({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentQueueCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:d,maxVideoBufferSize:u},f,l){let{manifest:m,period:g}=e,h=new X(void 0,l);if(f.periodStreamReady({type:n,manifest:m,period:g,adaptationRef:h}),l.isCancelled())return;let b,p=!0;h.onUpdate(R=>{(async()=>{var B;if(R===void 0)return;let E=new z(\"PeriodStream: Adaptation choice \"+n);if(E.linkToSignal(l),b==null||b.cancel(\"PeriodStream: Adaptation update\"),b=E,R===null){c.info(\"Stream\",\"Set no Adaptation\",{periodStart:g.start,bufferType:n});let _=o.getStatus(n);if(_.type===\"initialized\"){if(c.info(\"Stream\",\"Clearing previous SegmentSink\",{periodStart:g.start,bufferType:n}),bt.isNative(n))return T(0,!0,E.signal);{let M=(B=g.end)!=null?B:1/0;if(g.start>M)c.warn(\"Stream\",\"Can't free buffer: period's start is after its end\",{periodStart:g.start,periodEnd:M,bufferType:n});else if(await _.value.removeBuffer(g.start,M),E.isUsed())return}}else if(_.type===\"uninitialized\"&&(o.disableSegmentSink(n),E.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:g}),E.isUsed()?void 0:us(r,d,n,{period:g},f,E.signal)}let C=g.adaptations[n],P=j(C!=null?C:[],_=>_.id===R.adaptationId);if(P===void 0){b.cancel(\"PeriodStream: Adaptation not found\"),c.warn(\"Stream\",\"Unfound chosen Adaptation choice\",{adaptationId:R.adaptationId});return}let{DELTA_POSITION_AFTER_RELOAD:x}=L.getCurrent(),A=!1,k;if(p)k=0;else if(R.relativeResumingPosition!==void 0)k=R.relativeResumingPosition;else switch(A=!0,n){case\"audio\":k=x.trackSwitch.audio;break;case\"video\":k=x.trackSwitch.video;break;default:k=x.trackSwitch.other;break}if(p=!1,bt.isNative(n)&&o.getStatus(n).type===\"disabled\")return T(k,!0,E.signal);m.addEventListener(\"manifestUpdate\",_=>{for(let M of _.updatedPeriods)if(M.period.id===g.id){for(let w of M.result.removedAdaptations)if(w.id===P.id)return T(k,!0,E.signal)}else if(M.period.start>g.start)break},b.signal);let{representations:N}=R;if(c.info(\"Stream\",\"Updating adaptation\",{bufferType:P.type,periodStart:g.start,adaptationId:P.id}),f.adaptationChange({type:n,adaptation:P,period:g}),E.isUsed())return;let D=Yu(o,n,P),W=Fi(D,g,P,R.switchingMode,r,s);if(W.type===\"needs-reload\")return T(k,!0,E.signal);if(await o.waitForUsableBuffers(E.signal),!E.isUsed()){if(W.type===\"flush-buffer\"||W.type===\"clean-buffer\"){for(let{start:_,end:M}of W.value)if(await D.removeBuffer(_,M),E.isUsed())return;if(W.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:k,relativePosHasBeenDefaulted:A}),E.isUsed()))return}t.get(D)(E.signal),y(P,N,D,E.signal)}})().catch(E=>{E instanceof se||(b==null||b.cancel(\"PeriodStream err\"),f.error(E))})},{clearSignal:l,emitCurrentValue:!0});function y(R,E,C,P){let x=$u(r,R.type);ds({content:{manifest:m,period:g,adaptation:R,representations:E},options:s,playbackObserver:x,representationEstimator:i,segmentSink:C,segmentQueueCreator:a,wantedBufferAhead:d,maxVideoBufferSize:u},de(J({},f),{error:A}),P);function A(k){if(!bt.isNative(n)){c.error(\"Stream\",`${n} Stream crashed. Aborting it.`,k instanceof Error?k:\"\"),o.disposeSegmentSink(n,\"AdaptationStream err\");let N=ge(k,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(N),P.isCancelled()?void 0:us(r,d,n,{period:g},f,P)}c.error(\"Stream\",`${n} Stream crashed. Stopping playback.`,k instanceof Error?k:\"\"),f.error(k)}}function T(R,E,C){it(()=>{r.listen(()=>{C.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:g,timeOffset:R,stayInPeriod:E})},{includeLastObservation:!0,clearSignal:C})})}}function Yu(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=Qu(t);return n.createSegmentSink(e,i)}function Qu(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 $u(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new X(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let d=r.getValue(),u=d.buffered[e],f=u!==null?xr(u,d.position.getWanted()):0;return K({},d,{bufferGap:f,buffered:u})}function s(){a.setValue(o())}})}function us(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(d,{emitCurrentValue:!1,clearSignal:a}),n.listen(d,{includeLastObservation:!1,clearSignal:a}),d();function d(){let u=n.getReference().getValue(),f=e.getValue(),l=u.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 ls=zi;function Dr(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:d}=a;if(s===void 0||d===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 u=t[t.length-1];u!==void 0&&u.end===s?u.end=d:t.push({start:s,end:d})}for(let a of i){if(a.type!==0)continue;let o=a.value;e.some(d=>o.inventoryInfos.period.id===d.period.id&&o.inventoryInfos.adaptation.id===d.adaptation.id&&o.inventoryInfos.representation.id===d.representation.id)&&It(t,{start:o.inventoryInfos.start,end:o.inventoryInfos.end})}return t}function Wi(n,e,t,r,i,a,o,s){let{manifest:d,initialPeriod:u}=n,{maxBufferAhead:f,maxBufferBehind:l,wantedBufferAhead:m,maxVideoBufferSize:g}=a,{MINIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_AHEAD:b,MAXIMUM_MAX_BUFFER_BEHIND:p}=L.getCurrent(),y=new bn(E=>{var A,k;let{bufferType:C}=E,P=(A=p[C])!=null?A:1/0,x=(k=b[C])!=null?k:1/0;return N=>{Mr({segmentSink:E,playbackObserver:e,maxBufferBehind:en(l,D=>Math.min(D,P),N),maxBufferAhead:en(f,D=>{var B;let W=Math.max(D,(B=h[C])!=null?B:0);return Math.min(W,x)},N)},N)}});for(let E of r.getBufferTypes())T(E,u);function T(E,C){let P=new xt((W,B)=>W.start-B.start),x=!1,A=new z(\"StreamOrchestrator Streams for \"+E);return A.linkToSignal(s),e.listen(({position:W})=>{let B=W.getWanted();if(!x||!N(B))return;let _=()=>{var w;return(w=d.getPeriodForTime(B))!=null?w:d.getNextPeriod(B)},M=_();if(!(!v(M)&&P.has(M))){for(c.info(\"Stream\",\"Destroying all PeriodStreams due to out of bounds situation\",{bufferType:E,time:B}),x=!1;P.length()>0;){let w=P.get(P.length()-1);P.removeElement(w),o.periodStreamCleared({type:E,manifest:d,period:w})}if(A.cancel(\"PeriodStream is out of bounds\"),A=new z(\"StreamOrchestrator Streams for \"+E),A.linkToSignal(s),M=_(),M===void 0){c.warn(\"Stream\",\"The wanted position is not found in the Manifest.\"),x=!0;return}k(M)}},{clearSignal:s,includeLastObservation:!0}),d.addEventListener(\"decipherabilityUpdate\",W=>{s.isCancelled()||D(W).catch(B=>{s.isCancelled()||(A.cancel(\"decipherabilityUpdate event\"),o.error(B))})},s),k(C);function k(W){let B=de(J({},o),{waitingMediaSourceReload(_){let M=P.head();M===void 0||M.id!==_.period.id?o.lockedStream({bufferType:_.bufferType,period:_.period}):o.needsMediaSourceReload({timeOffset:_.timeOffset,minimumPosition:_.stayInPeriod?_.period.start:void 0,maximumPosition:_.stayInPeriod?_.period.end:void 0})},periodStreamReady(_){x=!0,P.add(_.period),o.periodStreamReady(_)},periodStreamCleared(_){P.removeElement(_.period),o.periodStreamCleared(_)},error(_){A.cancel(\"PeriodStream err callback\"),o.error(_)}});R(E,W,B,A.signal)}function N(W){let B=P.head(),_=P.last();return B===void 0||_===void 0?!0:B.start>W||(v(_.end)?1/0:_.end)<W}async function D(W){let B=r.getStatus(E),_=W.filter(V=>V.adaptation.type===E);if(_.length===0||B.type!==\"initialized\"||_.every(V=>V.representation.decipherable===!0))return;let M=B.value,w=_.filter(V=>V.representation.decipherable===void 0),U=_.filter(V=>V.representation.decipherable===!1),H=Dr(M,U),$=Dr(M,w);for(x=!1,c.info(\"Stream\",\"Destroying all PeriodStreams for decipherability matters\",{bufferType:E});P.length()>0;){let V=P.get(P.length()-1);P.removeElement(V),o.periodStreamCleared({type:E,manifest:d,period:V})}A.cancel(\"decipherability update\"),A=new z(\"StreamOrchestrator Streams for \"+E),A.linkToSignal(s);for(let{start:V,end:G}of[...H,...$]){if(s.isCancelled())return;if(V<G){if(s.isCancelled())return;await M.removeBuffer(V,G)}}it(()=>{if(s.isCancelled())return;let V=e.getReference().getValue();if(fs(V,H)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(fs(V,$)&&(o.needsBufferFlush(),s.isCancelled()))return;let G=V.position.getWanted(),Y=d.getPeriodForTime(G);if(Y===void 0&&(Y=d.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=d.periods[d.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}k(Y)})}}function R(E,C,P,x){c.info(\"Stream\",\"Creating new PeriodStream\",{bufferType:E,periodStart:C.start});let A=null,k=new z(\"StreamOrchestrator current consecutive Streams \"+E);k.linkToSignal(x),e.listen(({position:_},M)=>{if(C.end!==void 0&&_.getWanted()>=C.end){let w=d.getPeriodAfter(C);if(C.containsTime(_.getWanted(),w))return;c.info(\"Stream\",\"Destroying PeriodStream as the current playhead moved above it\",{bufferType:E,periodStart:C.start,periodEnd:C.end,position:_.getWanted()}),M(),P.periodStreamCleared({type:E,manifest:d,period:C}),k.cancel(\"Position ahead of PeriodStream\")}},{clearSignal:x,includeLastObservation:!0});let N={bufferType:E,content:{manifest:d,period:C},garbageCollectors:y,maxVideoBufferSize:g,segmentQueueCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},D=de(J({},P),{streamStatusUpdate(_){if(_.hasFinishedLoading){let M=d.getPeriodAfter(C);M!==null&&W(M)}else A!==null&&(c.info(\"Stream\",\"Destroying next PeriodStream due to current one being active\",{bufferType:E,periodStart:C.start,nextPeriodStart:A.period.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"previous PeriodStream is active\"),A=null);P.streamStatusUpdate(_)},error(_){A!==null&&(A.canceller.cancel(\"previous PeriodStream err\"),A=null),k.cancel(\"PeriodStream err\"),P.error(_)}});ls(N,D,k.signal),B(k.signal);function W(_){if(A!==null){if(A.period.id===_.id)return;c.warn(\"Stream\",\"Creating next `PeriodStream` while one was already created.\",{bufferType:E,nextPeriodStart:_.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"PeriodStream recreation\")}let M=new z(\"StreamOrchestrator next PeriodStream \"+E);M.linkToSignal(x),A={canceller:M,period:_},R(E,_,P,A.canceller.signal)}function B(_){d.addEventListener(\"manifestUpdate\",M=>{for(let w of M.removedPeriods)if(w.id===C.id){if(d.periods.length>0&&d.periods[0].start<=w.start)return it(()=>{if(!_.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(w.start>C.start)break;if(M.addedPeriods.length>0&&A!==null){let w=d.getPeriodAfter(C);(w===null||A.period.id!==w.id)&&(c.warn(\"Stream\",\"Destroying next PeriodStream due to new one being added\",{bufferType:E,nextPeriodStart:A.period.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"Next Period changed\"),A=null)}},_)}}}function fs(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 ms=Wi;var cs=ms;function qi(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 Xu(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Cn(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=Xu(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(\"EndOfStream current iteration\");i.linkToSignal(e);for(let a of r)xo(a,()=>{i.cancel(\"SourceBuffer update\"),Cn(n,e)},i.signal);ko(t,()=>{i.cancel(\"SourceBuffer remove\"),Cn(n,e)},i.signal)}function ps(n,e){let t=new z(\"EndOfStream\");t.linkToSignal(e),Ft(n,()=>{c.debug(\"mse\",\"MediaSource re-opened while end-of-stream is active\"),t.cancel(\"MediaSource re-opened\"),t=new z(\"EndOfStream\"),t.linkToSignal(e),Cn(n,t.signal)},e),Cn(n,t.signal)}function Vi(){let{FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:n}=L.getCurrent();return n||Lt.device===Lt.DEVICES.PlayStation5}var Zu=365*24*3600,An=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(\"manual duration update\"),this._currentMediaSourceDurationUpdateCanceller=new z(\"MediaSource Duration Update\");let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=tl(r,i),o=new z(void 0);o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(\"MediaSource open status changed\"),!a.getValue())return;o=new z(void 0),o.linkToSignal(i);let d=el(r.sourceBuffers,o.signal),u=new z(void 0);return u.linkToSignal(o.signal),d.onUpdate(f=>{u.cancel(\"SourceBuffer status update\"),u=new z(void 0),u.linkToSignal(o.signal),!f&&hs(r,e,t,u.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(e){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(e!=null?e:\"stop MSDU\"),this._currentMediaSourceDurationUpdateCanceller=null)}};function Ju(n,e,t){let r=e;t||(r=Vi()?1/0:gs(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=gs(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 el(n,e){if(n.length===0){let i=new X(!1);return i.finish(),i}let t=new X(!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 tl(n,e){let t=new X(n.readyState===\"open\",e);return Ft(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),Er(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),Tr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function hs(n,e,t,r){if(Ju(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),hs(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function gs(n){return Math.max(Math.pow(2,32),n+Zu)}var xn=class extends me{constructor(e,t){super(),this.id=e,this.sourceBuffers=[],this._canceller=new z(\"MainMediaSourceInterface\");let{MediaSource_:r}=ln;if(v(r))throw new Z(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"mse\",\"Creating MediaSource\");let i=t!==void 0?new t:new r,a=i.handle;this.handle=v(a)?{type:\"media-source\",value:i}:{type:\"handle\",value:a},this._mediaSource=i,this.readyState=i.readyState,this._durationUpdater=new An(i),this._endOfStreamCanceller=null,Ft(i,()=>{this.readyState=i.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),Er(i,()=>{this.readyState=i.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),Tr(i,()=>{this.readyState=i.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 Gi(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(e){this._durationUpdater.stopUpdating(e)}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new z(\"MainMediaSourceInterface EndOfStream\"),this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"mse\",\"end-of-stream order received.\"),ps(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"mse\",\"resume-stream order received.\"),this._endOfStreamCanceller.cancel(\"MediaSourceInterface stopEndOfStream\"),this._endOfStreamCanceller=null)}dispose(e){this.sourceBuffers.forEach(t=>t.dispose(e)),this._canceller.cancel(e!=null?e:\"MainMediaSourceInterface dispose\"),nl(this._mediaSource)}},Gi=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new z(\"MainSourceBufferInterface \"+e),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 xi(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(e){try{this._sourceBuffer.abort()}catch(t){c.debug(\"mse\",\"Failed to abort SourceBuffer:\",t instanceof Error?t:\"Unknown Error\")}this._emptyCurrentQueue(e)}dispose(e){try{this._sourceBuffer.abort()}catch(t){}this._emptyCurrentQueue(e)}_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 ke(t.name,t.message,t.name===\"QuotaExceededError\");for(let a of r)a.reject(i)}}_onUpdateEnd(){let e=this._currentOperations;this._currentOperations=[];try{for(let t of e)t.resolve(xi(this._sourceBuffer.buffered))}catch(t){for(let r of e)t instanceof Error&&t.name===\"InvalidStateError\"?r.resolve([]):r.reject(t)}this._performNextOperation()}_emptyCurrentQueue(e){let t=new se(\"MainSourceBufferInterface queue \"+this.type,e);this._currentOperations.length>0&&(this._currentOperations.forEach(r=>{r.reject(t)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(r=>{r.reject(t)}),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],d=e.params[1],u=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=d.appendWindow)!=null?r:[void 0,void 0],h=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],b=(a=d.timestampOffset)!=null?a:0,p=(o=m.params[1].timestampOffset)!=null?o:0;if(g[0]===h[0]&&g[1]===h[1]&&d.codec===m.params[1].codec&&b===p){let y=m.params[0],T;y instanceof ArrayBuffer?T=new Uint8Array(y):y instanceof Uint8Array?T=y:T=new Uint8Array(y.buffer),l.push(T),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:m.resolve,reject:m.reject})}else break}l.length>1&&(c.info(\"mse\",`: Merging ${l.length} segments together for perf`,{type:this.type}),u=Ct(...l).buffer)}try{this._appendBufferNow(u,d)}catch(f){let l=f instanceof Error?new ke(f.name,f.message,f.name===\"QuotaExceededError\"):new ke(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(m=>{m.reject(l)}),this._currentOperations=[],this._performNextOperation()}}else{this._currentOperations=[e];let[s,d]=e.params;c.debug(\"mse\",\"removing data from SourceBuffer\",{type:this.type,start:s,end:d});try{this._sourceBuffer.remove(s,d)}catch(u){let f=u instanceof Error?new ke(u.name,u.message,!1):new ke(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(f),this._currentOperations.forEach(l=>{l.reject(f)}),this._currentOperations=[],this._performNextOperation()}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(c.debug(\"mse\",\"updating codec\",{type:this.type,prevCodec:this.codec,newCodec:i}),qi(r,i)?this.codec=i:c.debug(\"mse\",\"could not update codec\",{type:this.type,prevCodec:this.codec,newCodec:i})),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"mse\",\"updating timestampOffset\",{type:this.type,codec:i,prevTimestampOffset:r.timestampOffset,newTimestampOffset:s}),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"mse\",\"re-setting `appendWindowStart`\",{type:this.type,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`\",{type:this.type,prevWindowEnd:r.appendWindowEnd,newWindowEnd:s}),r.appendWindowEnd=s}c.debug(\"mse\",\"setting `appendWindowStart`\",{type:this.type,appendWindowStart:o[0]}),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"mse\",\"re-setting `appendWindowEnd`\",{type:this.type,prevWindowStart:r.appendWindowStart}),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"mse\",\"setting `appendWindowEnd`\",{type:this.type,prevWindowEnd:r.appendWindowEnd,newWindowEnd:o[1]}),r.appendWindowEnd=o[1]),c.debug(\"mse\",\"pushing segment\",{type:this.type}),r.appendBuffer(e)}};function nl(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 rl=Oe(),Br=Oe(),Is=1/0,kn=class extends me{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new z(\"WorkerMediaSourceInterface\"),this.readyState=\"closed\",this._messageSender=r;let i=rl();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 Hi(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(e){this.sourceBuffers.forEach(t=>t.dispose(e)),this._canceller.cancel(\"WorkerMediaSourceInterface dispose\"),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},Hi=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new z(\"WorkerSourceBufferInterface \"+e),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\",{type:this.type}):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new se(\"Pending SBI Operation \"+this.type,\"SBI Failure\"):new ke(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"mse\",\"unknown SourceBuffer operation failed\",{type:this.type},r):(this._pendingOperations.delete(e),i.reject(r));let a=new se(\"Queued SBI Operation \"+this.type,\"SBI failure\");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>=Is){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=Br();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>=Is){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=Br();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(e){this.abort(),this._canceller.cancel(e!=null?e:\"WorkerSourceBufferInterface dispose\")}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=Br();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=Br();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 Ki(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 Mn=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 bs=6e3,il=15e3,al=3e3,ol=1e3,sl=9e3,On=class{constructor(e){this._levelsMap=Ki(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=bs,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 d=-1;for(let h=0;h<r.length;h++){let b=r[h];if(b===a)d=h;else if(b>a)break}if(d<0||r.length!==t.length){c.info(\"ABR\",\"Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let u;o!==void 0&&(u=s===0?o.score:o.score/s);let f=isFinite(i)?i:0,l=F();if(f<t[d]||u!==void 0&&u<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+sl){let p=this._blockRaiseDelay+al;c.debug(\"ABR\",\"Incrementing blocking raise in BufferBasedChooser due to unstable quality\",{prevDelay:this._blockRaiseDelay,newDelay:p}),this._blockRaiseDelay=Math.min(p,il)}else{let p=this._blockRaiseDelay-ol;c.debug(\"ABR\",\"Lowering quality in BufferBasedChooser\",{prevDelay:this._blockRaiseDelay,newDelay:p}),this._blockRaiseDelay=Math.max(bs,p)}this._lastUnsuitableQualityTimestamp=l;let b=ie(r,p=>p===a);for(let p=b-1;p>=0;p--)if(f>=t[p]){this._currentEstimate=r[p];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||u===void 0||u<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[d],g=(()=>{for(let h=d+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 dl(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 d=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(d>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 Nr(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 ys(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function ul(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,d=isFinite(a)?a:0,u=s.getWanted()+d,f=dl(n,u);if(f.length!==1)return;let l=f[0],m=F(),g=l.content.segment.duration*1.5;if(g=Math.min(g,3e3),g=Math.max(g,12e3),m-l.requestTimestamp<g)return;let h=l.progress.length>0?l.progress[l.progress.length-1]:void 0,b=Nr(l);if(h!==void 0&&b!==void 0){let C=ys(h,b);if((m-h.timestamp)/1e3<=C&&C-d/o>2500)return b}if(!l.content.segment.complete)return;let p=l.content.segment.duration,y=(m-l.requestTimestamp)/1e3,T=y<=(p*1.5+2)/o;if(v(t)||T)return;let R=p/y,E=t.bitrate*Math.min(.7,R);if(i===void 0||E<i)return E}function ll(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=j(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(a===void 0)return!0;let o=F(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,d=Nr(a);if(s===void 0||d===void 0)return!0;let u=ys(s,d);return(o-s.timestamp)/1e3>u*1.2?!0:u-r/n.speed>-1.5}var wn=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,d=this._config,{bufferGap:u,position:f,duration:l}=e,m=isFinite(u)?u:0,{ABR_STARVATION_DURATION_DELTA:g}=L.getCurrent();return isNaN(l)||m+f.getWanted()<l-g?!this._inStarvationMode&&m<=d.starvationGap?(c.info(\"ABR\",\"enter starvation mode.\",{buffergap:m,enterStarvation:d.starvationGap}),this._inStarvationMode=!0):this._inStarvationMode&&m>=d.outOfStarvationGap&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m,outOfStarvation:d.starvationGap}),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m}),this._inStarvationMode=!1),this._inStarvationMode&&(s=ul(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?d.starvationBitrateFactor:d.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?d.starvationBitrateFactor:d.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:ll(i,r,this._lowLatencyMode)}};var Dn=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 Bn=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,d=this._lastAbrEstimate.representation;if(d===null)return null;if(i>d.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let u=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(u===void 0)return null;if(this._canGuessHigher(o,s,u)){let l=Ss(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(d,i,u)&&(c.debug(\"ABR\",\"Guessed Representation validated\",{chosenBitrate:d.bitrate,otherAbrAlgosBitrate:i,scoreData:u==null?void 0:u.score,scoreConfidence:u==null?void 0:u.confidenceLevel}),this._lastMaintanableBitrate=d.bitrate,this._consecutiveWrongGuesses=0),r.id!==d.id)return d;if(this._shouldStopGuess(r,u,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=F()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),fl(e,r);if(u===void 0)return r;if(this._canGuessHigher(o,s,u)){let l=Ss(e,r);if(l!==null)return l}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 d=o-s.requestTimestamp;if(s.content.segment.isInit){if(d>1e3)return!0}else{if(d>s.content.segment.duration*1e3+200)return!0;{let u=Nr(s);if(u!==void 0&&u<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 Ss(n,e){let t=n.length,r=ie(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 fl(n,e){let t=ie(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 Nn=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 ji(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=ie(n,a=>a.bitrate>r);return i===-1?n:n.slice(0,i)}function Yi(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,d)=>{var u,f;return((u=s.width)!=null?u:0)-((f=d.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 Un=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 Sr(this._currentRequests).filter(e=>!v(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Ur(n,e){let t=ie(n,r=>r.bitrate>e);return t===-1?n[n.length-1]:t===0?n[0]:n[t-1]}var Ts=new X(void 0);Ts.finish();var Es=new X(1/0);Es.finish();function Qi(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,d,u,f,l){var p,y,T;let{type:m}=s.adaptation,g=a(m),h=(p=t[m])!=null?p:0,b={limitResolution:(y=r.limitResolution[m])!=null?y:Ts,throttleBitrate:(T=r.throttleBitrate[m])!=null?T:Es};return ml({bandwidthEstimator:g,context:s,currentRepresentation:d,filters:b,initialBitrate:h,playbackObserver:f,representations:u,lowLatencyMode:i},l)};function a(o){let s=e[o];if(v(s)){c.debug(\"ABR\",\"Creating new BandwidthEstimator\",{bufferType:o});let d=new Nn;return e[o]=d,d}return s}}function ml({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},d){let u=new Mn,f=new wn(i!=null?i:0,a),l=new Un,m=O,g={metrics:T,requestBegin:R,requestProgress:E,requestEnd:C,addedSegment(P){m(P)}},h=new z(\"ABR \"+e.adaptation.type);h.linkToSignal(d);let b=p(s.getValue(),h.signal);return s.onUpdate(y,{clearSignal:d}),{estimates:b,callbacks:g};function p(P,x){if(P.length<=1)return new X({bitrate:void 0,representation:P[0],urgent:!0,knownStableBitrate:void 0});let A=!1,k=P.sort((U,H)=>U.bitrate-H.bitrate),N=new On(k.map(U=>U.bitrate)),D=new Dn,W=new Bn(u,D),B=o.getReference().getValue(),_=new X(w());return o.listen(U=>{B=U,M()},{includeLastObservation:!1,clearSignal:x}),m=function(U){if(B===null)return;let{position:H,speed:$}=B,V=U.buffered,G=xr(V,H.getWanted()),{representation:Y}=U.content,ce=u.getEstimate(Y),fe=Y.bitrate,pe={bufferGap:G,currentBitrate:fe,currentScore:ce,speed:$};N.onAddedSegment(pe),M()},x.register(()=>{m=O}),r.throttleBitrate.onUpdate(M,{clearSignal:x}),r.limitResolution.onUpdate(M,{clearSignal:x}),_;function M(){_.setValue(w())}function w(){let{bufferGap:U,position:H,maximumPosition:$}=B,V=r.limitResolution.getValue(),G=r.throttleBitrate.getValue(),Y=t.getValue(),ce=cl(k,V,G),fe=l.getRequests(),{bandwidthEstimate:pe,bitrateChosen:Qe}=f.getBandwidthEstimate(B,n,Y,fe,D.bandwidth),re=u.getLastStableRepresentation(),oe=re===null?void 0:re.bitrate/(B.speed>0?B.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:$t,ABR_EXIT_BUFFER_BASED_ALGO:Xt}=L.getCurrent();A&&U<=Xt?A=!1:!A&&isFinite(U)&&U>=$t&&(A=!0);let Re=Ur(ce,Qe),Zt=N.getLastEstimate(),lr=Re.bitrate,lt=null;A&&Zt!==void 0&&Zt>lr&&(lt=Ur(ce,Zt),lr=lt.bitrate);let ft=null;return a&&Y!==null&&e.manifest.isDynamic&&$-H.getWanted()<40&&(ft=W.getGuess(k,B,Y,lr,fe)),ft!==null&&ft.bitrate>lr?(c.debug(\"ABR\",\"new guess-based estimate\",{bitrate:ft.bitrate,representation:ft.id}),D.update(ft,pe,2),{bitrate:pe,representation:ft,urgent:Y===null||ft.bitrate<Y.bitrate,knownStableBitrate:oe}):lt!==null?(c.debug(\"ABR\",\"new buffer-based estimate\",{bitrate:lt.bitrate,representation:lt.id}),D.update(lt,pe,0),{bitrate:pe,representation:lt,urgent:f.isUrgent(lt.bitrate,Y,fe,B),knownStableBitrate:oe}):(c.debug(\"ABR\",\"new bandwidth estimate\",{bitrate:Re.bitrate,representation:Re.id}),D.update(Re,pe,1),{bitrate:pe,representation:Re,urgent:f.isUrgent(Re.bitrate,Y,fe,B),knownStableBitrate:oe})}}function y(){let P=s.getValue();h.cancel(\"restart\"),h=new z(\"ABR \"+e.adaptation.type),h.linkToSignal(d),p(P,h.signal).onUpdate(function(k){b.setValue(k)},{clearSignal:h.signal,emitCurrentValue:!0})}function T(P){let{requestDuration:x,segmentDuration:A,size:k,content:N}=P;if(n.addSample(x,k),!N.segment.isInit){let{segment:D,representation:W}=N;if(A===void 0&&!D.complete)return;let B=A!=null?A:D.duration;u.addSample(W,x/1e3,B)}}function R(P){l.add(P)}function E(P){l.addProgress(P)}function C(P){l.remove(P.id)}}function cl(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=ji(r,t)),e!==void 0&&(r=Yi(r,e)),r}var _s=Qi;function Lr(){var t;if(typeof((t=te.crypto)==null?void 0:t.randomUUID)==\"function\")return te.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 pl=/^(?:[a-z]+:)?\\/\\//i,gl=/^(?:([^:/?#]+):)?(?:\\/\\/([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Xi(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(pl.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Xi(n.substring(0,t)):e+1}function Rs(n,e){let t=Fr(n),r=Fr(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=Fn(t.path),a=Fn(r.path),o;if(i===a)o=\"\";else{let d=i.split(\"/\");d.pop();let u=a.split(\"/\");for(;d.length>0&&u.length>0&&d[0]===u[0];)d.shift(),u.shift();for(;d.length>0;)d.shift(),u.unshift(\"..\");let f=u.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 hl(n,e){let t=Fr(n),r=Fr(e);if(Q(r.scheme))return $i(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=Fn(r.path),$i(i)):(r.path===\"\"?(i.path=t.path,Q(r.query)||(i.query=t.query)):he(r.path,\"/\")?i.path=Fn(r.path):i.path=Fn(bl(t,r.path)),$i(i))}var Ln=new Map,Il=200;function Fr(n){var r,i,a,o,s;if(Ln.has(n))return Ln.get(n);let e=n.match(gl),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:\"\"},Ln.size>=Il&&Ln.clear(),Ln.set(n,t),t}function $i(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 Fn(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 bl(n,e){if(Q(n.authority)&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function zn(...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:\"\",d=hl(o,s),u=e.slice(2);return zn(d,...u)}}var yl=4,Wn=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Lr(),this._contentId=(r=e.contentId)!=null?r:Lr(),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(\"CmcdDataBuilder start\"),this._canceller=new z(\"CMCD monitoring\"),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(\"CmcdDataBuilder stop\"),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,d,u;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=(u=(d=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?d:t.position.getWanted())!=null?u: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*yl/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=(u,f)=>{this._typePreference===0?t[f]+=u:r+=u},a=(u,f)=>{let l=e[u];if(l!==void 0){let m=`${u}=${String(l)},`;i(m,f)}},o=(u,f)=>{if(e[u]===!0){let l=`${u},`;i(l,f)}},s=(u,f)=>{let l=e[u];if(l!==void 0){let m=`\"${l.replace(\"\\\\\",\"\\\\\\\\\").replace('\"','\\\\\"')}\"`,g=`${u}=${m},`;i(g,f)}},d=(u,f)=>{let l=e[u];if(l!==void 0){let m=`${u}=${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\"),d(\"ot\",\"object\"),a(\"pr\",\"session\"),a(\"rtp\",\"status\"),d(\"sf\",\"session\"),s(\"sid\",\"session\"),d(\"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 Ps=Wn;var qn=class extends me{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=vs(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=vs(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 vs(n,e){return n.length===0?-1:e.id!==void 0?ie(n,t=>t.id===e.id):ie(n,t=>t.baseUrl===e.baseUrl)}function Le(n){return n instanceof ue?new Xe(\"PIPELINE_LOAD_ERROR\",n):ge(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function Sl(n){return n instanceof ue?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 $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:Nt(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:d}=r;n!==null&&n.length===0&&c.warn(\"utils\",\"No CDN given to `scheduleRequestWithCdns`.\");let u=new Map,f=l();if(f===void 0)throw new Error(\"No CDN to request\");return m(f);function l(){if(n===null){let p=u.get(null);return p!==void 0&&p.isBlacklisted?void 0:null}else{if(e===null)return b(n);{let p=e.getCdnPreferenceForResource(n);return b(p)}}}async function m(p){try{return await t(p,i)}catch(y){if(z.isCancellationError(y))throw y;p!==null&&e!==null&&e.downgradeCdn(p);let T=u.get(p);if(T===void 0?(T={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},u.set(p,T)):T.errorCounter++,!Sl(y))return T.blockedUntil=void 0,T.isBlacklisted=!0,g(y);if(T.errorCounter>s)T.blockedUntil=void 0,T.isBlacklisted=!0;else{let R=T.errorCounter,E=Math.min(a*Math.pow(2,R-1),o),C=Ci(E);T.blockedUntil=F()+C}return g(y)}}async function g(p){let y=l();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw p;if(d(p),i.isCancelled())throw i.cancellationError;return h(y,p)}function h(p,y){let T=u.get(p);if(T===void 0||T.blockedUntil===void 0)return m(p);let R=F(),E=T.blockedUntil-R;if(E<=0)return m(p);let C=new z(\"Request Backoff\"),P=C.linkToSignal(i);return new Promise((x,A)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let D=l();if(i.isCancelled())throw i.cancellationError;if(D===void 0)return N(y);D!==p&&(C.cancel(\"new prioritized CDN\"),h(D,y).then(k,N))},C.signal),fn(E,C.signal).then(()=>m(p).then(k,N),O);function k(D){P(),x(D)}function N(D){P(),A(D)}})}function b(p){var T;if(u.size===0)return p[0];let y=F();return(T=p.filter(R=>{var E;return((E=u.get(R))==null?void 0:E.isBlacklisted)!==!0}).reduce((R,E)=>{var P;let C=(P=u.get(E))==null?void 0:P.blockedUntil;return C!==void 0&&C<=y&&(C=void 0),R===void 0?[E,C]:R[1]===void 0?R:C===void 0?[E,void 0]:C<R[1]?[E,C]:R},void 0))==null?void 0:T[0]}}function Zi(n,e,t){return Vn(null,null,n,e,t)}var Gn=class extends me{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(\"ManifestFetcher\"),this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(e){this._canceller.cancel(e!=null?e:\"ManifestFetcher dispose\"),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 u;let t=this._canceller.signal,r=this._settings,i=this._transportName,a=this._pipelines,o=e!=null?e:(u=this._manifestUrls)==null?void 0:u[0],s=this._getBackoffSetting(f=>{this.trigger(\"warning\",Le(f))});try{let f=await d(o);return{parse:l=>this._parseLoadedManifest(f,l,o)}}catch(f){throw Le(f)}function d(f){var p;let{loadManifest:l}=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:(p=r.cmcdDataBuilder)==null?void 0:p.getCmcdDataForManifest(i)};return Zi(()=>l(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 b;let i=F(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:d}=e,u=this._getBackoffSetting(p=>{this.trigger(\"warning\",Le(p))}),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 p=this._pipelines.parseManifest(e,l,g,a,m);if(Tl(p)){let{manifest:y}=await p;return h(y)}else return h(p.manifest)}catch(p){throw ge(p,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(p){try{return await Zi(p,u,a)}catch(y){throw Le(y)}}function g(p){for(let y of p){if(a.isCancelled())return;let T=ge(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",T)}}function h(p){let y=F()-i;return c.info(\"MF\",`Manifest parsed in ${y}ms`),{manifest:p,sendingTime:s,receivedTime:d,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,d=a?i.LOW_LATENCY:i.REGULAR,u=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:d,maxRetry:u}}_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,d=!1;this._consecutiveUnsafeMode>0?d=this._consecutiveUnsafeMode<a:s!==void 0&&(d=s>=o);let u=t===void 0?0:F()-t,f=Math.max(this._settings.minimumManifestUpdateInterval-u,0),l=new z(\"ManifestFetcher refresh handling\");if(l.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:g,delay:h,canUseUnsafeMode:b}=m,p=b&&d,y=t===void 0?0:F()-t,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=setTimeout(()=>{l.cancel(\"manifest request timeout\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:g,unsafeMode:p})},Math.max((h!=null?h:0)-y,T));l.signal.register(()=>{clearTimeout(R)})},e.expired!==null){let m=setTimeout(()=>{var g;(g=e.expired)==null||g.then(()=>{l.cancel(\"manifest expiration\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})},O)},f);l.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-u,g;s===void 0?g=m:e.lifetime<3&&s>=100?(g=Math.min(Math.max(3e3-u,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(()=>{l.cancel(\"manifest request timeout\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})},Math.max(g,f));l.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(d=>d.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(d=>{this._isRefreshPending=!1;let{manifest:u,sendingTime:f,parsingTime:l}=d,m=F();if(a)e.replace(u);else try{e.update(u)}catch(h){let b=h instanceof Error?h.message:\"unknown error\";c.warn(\"MF\",`Attempt to update Manifest failed: ${b}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:p}=L.getCurrent(),y=f===void 0?0:F()-f,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=O,E=setTimeout(()=>{R(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(p-y,T));R=this._canceller.signal.register(()=>{clearTimeout(E)});return}let g=F()-m;this._recursivelyRefreshManifest(e,{sendingTime:f,parsingTime:l,updatingTime:g})}).catch(d=>{this._isRefreshPending=!1,this._onFatalError(d)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose(\"ManifestFetcher fatal err\"))}};function Tl(n){return n instanceof Promise}var Ji=Gn;function ea(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=u=>e(r,a,u),d=n.create(s,i,a,o);return t.set(d,s),d},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 ta=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}},Cs=ta;var El=Oe();function na({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},d=le([\"audio\",\"video\"],n)?new Cs:void 0,{loadSegment:u,parseSegment:f}=e;return async function(m,g,h){var H,$,V;let{segment:b,adaptation:p,representation:y,manifest:T,period:R}=m,E=He(m),C=El(),P,x=[],A=0,k=!1,N={segment:b,type:p.type,language:p.language,isLive:T.isLive,periodStart:R.start,periodEnd:R.end,mimeType:y.mimeType,baseCodecs:y.baseCodecs,chosenCodec:y.chosenCodec,manifestPublishTime:T.publishTime},D={onProgress(G){var Y;P===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:C}))},onNewChunk(G){g.onChunk(M(G,!0))}},W=d!==void 0?d.get(m):null;if(W!==null)return c.debug(\"SF\",\"Found wanted segment in cache\",E),g.onChunk(M(W,!1)),Promise.resolve();c.debug(\"SF\",\"Beginning request\",E),(H=i.onRequestBegin)==null||H.call(i,{requestTimestamp:F(),id:C,content:m}),h.register(B);try{let G=await Vn(m.representation.cdnMetadata,t,_,K({onRetry:w},a),h);if(G.resultType===\"segment-loaded\"){let Y=G.resultData.responseData;d!==void 0&&d.add(m,G.resultData.responseData),g.onChunk(M(Y,!1))}else G.resultType===\"segment-created\"&&g.onChunk(M(G.resultData,!1));c.debug(\"SF\",\"Segment request ended with success\",E),g.onAllChunksReceived(),G.resultType!==\"segment-created\"?(P=G.resultData,U()):P=null,h.isCancelled()||($=i.onRequestEnd)==null||$.call(i,{id:C}),h.deregister(B)}catch(G){throw h.deregister(B),P=null,G instanceof se?(c.debug(\"SF\",\"Segment request aborted\",E),G):(c.debug(\"SF\",\"Segment request failed\",E),(V=i.onRequestEnd)==null||V.call(i,{id:C}),Le(G))}function B(){var G;P===void 0&&(c.debug(\"SF\",\"Segment request cancelled\",E),P=null,(G=i.onRequestEnd)==null||G.call(i,{id:C}))}function _(G){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(m),u(G,N,s,h,D)}function M(G,Y){x.push(!1);let ce=x.length-1;return function(pe){let Qe={data:G,isChunked:Y};try{let re=f(Qe,N,pe);return x[ce]||(A=A!==void 0&&re.segmentType===\"media\"&&re.chunkInfos!==null&&re.chunkInfos.duration!==void 0?A+re.chunkInfos.duration:void 0,x[ce]=!0,U()),re}catch(re){throw ge(re,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function w(G){g.onRetry(Le(G))}function U(){var G;k||!v(P)&&P.size!==void 0&&P.requestDuration!==void 0&&x.length>0&&x.every(Y=>Y)&&(k=!0,(G=i.onMetrics)==null||G.call(i,{size:P.size,requestDuration:P.requestDuration,content:m,segmentDuration:A}))}}}function As({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:d}=L.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?d.LOW_LATENCY:d.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var Hn=class extends me{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,r){var s;(s=this._currentContentInfo)==null||s.currentCanceller.cancel(r!=null?r:\"SegmentQueue reset\");let i=new X({initSegment:null,segmentQueue:[]}),a=new z(\"SegmentQueue \"+e.adaptation.type);a.signal.register(()=>{i.finish()});let o={content:e,downloadQueue:i,initSegmentInfoRef:t?new X(void 0):new X(null),currentCanceller:a,initSegmentRequest:null,mediaSegmentRequest:null,mediaSegmentAwaitingInitMetadata:null};return this._currentContentInfo=o,this.isMediaSegmentQueueInterrupted.onUpdate(d=>{d||(c.debug(\"SF\",\"Media segment can be loaded again, restarting queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"interrupt end\"))},{clearSignal:a.signal}),i.onUpdate(d=>{let{segmentQueue:u}=d;if(u.length>0&&u[0].segment.id===o.mediaSegmentAwaitingInitMetadata)return;let f=o.mediaSegmentRequest;if(u.length===0){if(f===null)return;c.debug(\"SF\",\"no more media segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"media segment queue empty\");return}else if(f===null){c.debug(\"SF\",\"Media segments now need to be requested. Starting queue.\",{type:e.adaptation.type,queueLength:u.length}),this._restartMediaSegmentDownloadingQueue(o,\"media segment queue start\");return}else{let l=u[0];if(f.segment.id!==l.segment.id){c.debug(\"SF\",\"Next media segment changed, cancelling previous\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"next media segment changed\");return}f.priority!==l.priority&&(c.debug(\"SF\",\"Priority of next media segment changed, updating\",{type:e.adaptation.type,prevPriority:f.priority,newPriority:l.priority}),this._segmentFetcher.updatePriority(f.request,l.priority));return}},{emitCurrentValue:!0,clearSignal:a.signal}),i.onUpdate(d=>{var f;let u=o.initSegmentRequest;if(d.initSegment!==null&&u!==null){d.initSegment.priority!==u.priority&&this._segmentFetcher.updatePriority(u.request,d.initSegment.priority);return}else if(((f=d.initSegment)==null?void 0:f.segment.id)===(u==null?void 0:u.segment.id))return;d.initSegment===null&&c.debug(\"SF\",\"no more init segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartInitSegmentDownloadingQueue(o,d.initSegment,\"init segment queue empty\")},{emitCurrentValue:!0,clearSignal:a.signal}),i}stop(e){var t;(t=this._currentContentInfo)==null||t.currentCanceller.cancel(e!=null?e:\"SegmentQueue stop\"),this._currentContentInfo=null}_restartMediaSegmentDownloadingQueue(e,t){e.mediaSegmentRequest!==null&&e.mediaSegmentRequest.canceller.cancel(t!=null?t:\"SegmentQueue media restart\");let{downloadQueue:r,content:i,initSegmentInfoRef:a,currentCanceller:o}=e,s=()=>{var E;if(this.isMediaSegmentQueueInterrupted.getValue()){c.debug(\"SF\",\"Segment fetching postponed because it cannot stream now.\");return}let{segmentQueue:d}=r.getValue(),u=d[0];if(o!==null&&o.isUsed()){e.mediaSegmentRequest=null;return}if(u===void 0){e.mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let f=new z(\"SegmentQueue media segments queue \"+i.adaptation.type),l=o===null?O:f.linkToSignal(o.signal),{segment:m,priority:g}=u,h=K({segment:m,nextSegment:(E=d[1])==null?void 0:E.segment},i),b=!1,p=!1;f.signal.register(()=>{e.mediaSegmentRequest=null,!b&&(e.mediaSegmentAwaitingInitMetadata===m.id&&(e.mediaSegmentAwaitingInitMetadata=null),b=!0,p=!1)});let y=C=>{be(C.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",K({},C,{segment:m}))},T=()=>{let C=r.getValue().segmentQueue;if(C.length===0){b=!0,this.trigger(\"emptyQueue\",null);return}else C[0].segment.id===m.id&&C.shift();b=!0,s()},R=this._segmentFetcher.createRequest(h,g,{onRetry:C=>{this.trigger(\"requestRetry\",{segment:m,error:C})},beforeInterrupted(){c.info(\"SF\",\"segment request interrupted temporarly.\",{segmentId:m.id,segmentTime:m.time})},onChunk:C=>{let P=a.getValue();P!==void 0?y(C(P!=null?P:void 0)):(p=!0,a.waitUntilDefined(x=>{y(C(x!=null?x:void 0))},{clearSignal:f.signal}))},onAllChunksReceived:()=>{p?(e.mediaSegmentAwaitingInitMetadata=m.id,a.waitUntilDefined(()=>{e.mediaSegmentAwaitingInitMetadata=null,p=!1,this.trigger(\"fullyLoadedSegment\",m)},{clearSignal:f.signal})):this.trigger(\"fullyLoadedSegment\",m)},beforeEnded:()=>{l(),e.mediaSegmentRequest=null,p?a.waitUntilDefined(T,{clearSignal:f.signal}):T()}},f.signal);R.catch(C=>{l(),b||(b=!0,this.stop(\"request err\"),this.trigger(\"error\",C))}),e.mediaSegmentRequest={segment:m,priority:g,request:R,canceller:f}};s()}_restartInitSegmentDownloadingQueue(e,t,r){let{content:i,initSegmentInfoRef:a}=e;if(e.initSegmentRequest!==null&&e.initSegmentRequest.canceller.cancel(r!=null?r:\"SegmentQueue init restart\"),t===null)return;let o=new z(\"SegmentQueue init segment \"+i.adaptation.type),s=e.currentCanceller===null?O:o.linkToSignal(e.currentCanceller.signal),{segment:d,priority:u}=t,f=K({segment:d,nextSegment:void 0},i),l=!1,m=this._segmentFetcher.createRequest(f,u,{onRetry:g=>{this.trigger(\"requestRetry\",{segment:d,error:g})},beforeInterrupted:()=>{c.info(\"SF\",\"init segment request interrupted temporarly.\",{segmentId:d.id})},beforeEnded:()=>{s(),e.initSegmentRequest=null,l=!0},onChunk:g=>{var b;let h=g(void 0);be(h.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",K({},h,{segment:d})),h.segmentType===\"init\"&&a.setValue((b=h.initTimescale)!=null?b:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",d)}},o.signal);m.catch(g=>{s(),l||(l=!0,this.stop(\"request err\"),this.trigger(\"error\",g))}),o.signal.register(()=>{e.initSegmentRequest=null,!l&&(l=!0)}),e.initSegmentRequest={segment:d,priority:u,request:m,canceller:o}}};var jn=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 u=()=>{g(),this._endTask(a)},f=h=>{r.beforeEnded(),u(),o(h)},l=h=>{u(),s(h)},m=new z(void 0),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||l(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=Kn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=Kn(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=Kn(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=Kn(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=Kn(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(\"TaskPrioritizer interrupt\")}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function Kn(n,e){return ie(e,t=>t.taskFn===n)}var Yn=class{constructor(e,t,r,i){let{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=L.getCurrent();this._transport=e,this._prioritizer=new jn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=t,this._backoffOptions=i,this._cmcdDataBuilder=r}createSegmentQueue(e,t,r){let i=As(this._backoffOptions),a=this._transport[e],o=na({bufferType:e,pipeline:a,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:i}),s=ea(this._prioritizer,o);return new Hn(s,r)}};var ra=Yn;function ia(n,e){let{loadThumbnail:t}=n,r=[];return async function(a,o){o.register(E);let{segment:s,track:d}=a,u,f=j(r,({thumbnailContext:x})=>x.period.id===a.period.id&&x.track.id===a.track.id&&x.segment.id===a.segment.id);if(f!==void 0){c.debug(\"Thumbnails\",\"Requesting same thumbnail than the pending one\",{time:a.segment.time}),u=f,u.referenceCount++;let x;try{x=await u.promise}catch(A){throw o.deregister(E),A}if(o.deregister(E),o.isCancelled())throw o.cancellationError;return R(x)}let l=_l({}),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},h=new z(\"Thumbnail request\"),b=T();u={thumbnailContext:a,promise:b,referenceCount:1},r.push(u);let p=()=>{let x=r.indexOf(u);x>=0&&r.splice(x,1)},y;try{y=await b}catch(x){throw p(),o.deregister(E),x}if(p(),o.deregister(E),o.isCancelled())throw o.cancellationError;return R(y);async function T(){c.debug(\"Thumbnails\",\"Beginning thumbnail request\",{time:s.time});try{let x=await Vn(d.cdnMetadata,e,C,K({onRetry:P},l),h.signal);return c.debug(\"Thumbnails\",\"Thumbnail request ended with success\",{time:s.time}),x}catch(x){throw x instanceof se?(c.debug(\"Thumbnails\",\"Thumbnail request aborted\",{time:s.time}),x):(c.debug(\"Thumbnails\",\"Thumbnail request failed\",{time:s.time}),Le(x))}}function R(x){try{return n.parseThumbnail(x.responseData,{thumbnail:s,thumbnailTrack:d})}catch(A){throw ge(A,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}function E(){c.debug(\"Thumbnails\",\"Thumbnail request cancelled\",{time:s.time});let x=r.indexOf(u);x<0||(r[x].referenceCount--,r[x].referenceCount<=0&&(h.cancel(\"Thumbnail request aborted\"),r.splice(x,1)))}function C(x){return t(x,s,g,o)}function P(x){let A=Le(x);c.warn(\"Thumbnails\",\"Thumbnail request retry \",{time:s.time},A)}}}function _l({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 Qn=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(\"WorkerTextDisplayerInterface reset\")}stop(e){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue(e)}_resetCurrentQueue(e){let t=new se(\"WorkerTextDisplayerInterface queue\",e!=null?e:\"reset\");this._queues.pushTextData.forEach(r=>{r.reject(t)}),this._queues.pushTextData.length=0,this._queues.remove.forEach(r=>{r.reject(t)}),this._queues.remove.length=0}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.remove.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}};var xs=6,aa=4e3,zr=6e3,Rl=6e4,Vt=class{constructor(e){this._segmentSinksStore=e,this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=null,this._lastFlushAttempt=null,this._lastSegmentInfo={audio:[],video:[]}}onNewObservation(e){var p,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:d,fullyLoaded:u}=e,f=e.position.getPolled(),l=ks(e.bufferGap);if(!(d!==null||o===1&&(l>=xs||u)))return this._decipherabilityFreezeStartingTimestamp=null,null;let g=(y=(p=d==null?void 0:d.timestamp)!=null?p: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 T=this._getStrategyIfFlushingFails(f);return this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+zr,T}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+zr,{type:\"flush\",value:{relativeSeek:i}}):null}_checkForDecipherabilityRelatedFreeze(e,t){let{readyState:r,rebuffering:i,freezing:a,fullyLoaded:o}=e,s=ks(e.bufferGap),d=i!==null&&t-i.timestamp>aa,{hasUndecipherableData:u,hasEncryptedData:f}=Pl(this._segmentSinksStore);if(u===!0)return c.warn(\"Freeze\",\"we have undecipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+zr,{type:\"reload\",value:null};let l=a!==null&&t-a.timestamp>aa;return(d||l)&&(s>=xs||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>aa&&f&&u===!1?(c.warn(\"Freeze\",\"we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+zr,{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 d=i.length-2;d>=0;d--){let u=i[d];if(u.segment===null){s=u;break}else if(u.segment.infos.representation.uniqueId!==o.infos.representation.uniqueId&&a.timestamp-u.timestamp<5e3){s=u;break}else u.segment.start===o.start&&e-u.position<3e3&&(a=u)}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 d=t-Rl,u;for(u=0;u<this._lastSegmentInfo[o].length&&!(this._lastSegmentInfo[o][u].timestamp>d);u++);u>0&&this._lastSegmentInfo[o].splice(0,u)}}};function Pl(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 ks(n){return n!==void 0&&isFinite(n)?n:0}var $n=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,d,u,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(),(d=(s=this._refs.get(g))==null?void 0:s.video)==null||d.representations.finish(),(f=(u=this._refs.get(g))==null?void 0:u.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,d;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(),(d=i[t])==null||d.representations.finish());let a=r.getValue(),o;v(a)?o=new X({representationIds:[],switchingMode:\"lazy\"}):(o=new X(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):(v(r)?(i.representations=new X({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new X(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)}};function Ce(n){return ge(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}function Ms(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 Os(n){var t,r;if(v(ln.MediaSource_))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 d=s.getMimeTypeString();if(e.has(d))s.isCodecSupportedInWebWorker=e.get(d);else{let u=ln.MediaSource_.isTypeSupported(d);s.isCodecSupportedInWebWorker=u,e.set(d,u)}}}}function ws(n,e){var a,o,s,d,u,f,l;let t,r,i;return typeof((a=n.representationFilter)==null?void 0:a.fn)==\"function\"?i=n.representationFilter.fn:typeof((o=n.representationFilter)==null?void 0:o.eval)==\"string\"?i=_o(n.representationFilter.eval):typeof((s=n.representationFilter)==null?void 0:s.workerId)==\"string\"&&(i=e.representationFilters.get(n.representationFilter.workerId)),typeof((d=n.manifestLoader)==null?void 0:d.fn)==\"function\"?t=n.manifestLoader.fn:typeof((u=n.manifestLoader)==null?void 0:u.workerId)==\"string\"&&(t=e.manifestLoaders.get(n.manifestLoader.workerId)),typeof((f=n.segmentLoader)==null?void 0:f.fn)==\"function\"?r=n.segmentLoader.fn:typeof((l=n.segmentLoader)==null?void 0:l.workerId)==\"string\"&&(r=e.segmentLoaders.get(n.segmentLoader.workerId)),{manifestLoader:t,segmentLoader:r,representationFilter:i}}var Ds=Oe(),Gt=class{constructor({hasVideo:e}){this._currentContent=null,this._currentMediaSourceCanceller=new z(\"ContentPreparer MediaSource\"),this._hasVideo=e;let t=new z(\"ContentPreparer\");this._contentCanceller=t}initializeNewContent(e,t,r,i){return new Promise((a,o)=>{var w,U;this.disposeCurrentContent(\"new init\");let s=this._contentCanceller,d=new z(\"ContentPreparer MediaSource\");this._currentMediaSourceCanceller=d,d.linkToSignal(s.signal);let{contentId:u,url:f,hasText:l,transportOptions:m,useMseInWorker:g,enableRepresentationAvoidance:h,transport:b}=t,p=null,y=Me.transports[b];if(typeof y!=\"function\"){o(new Error(`transport \"${b}\" not supported. Did you add the corresponding feature?`));return}let T=y(J(J({},m),ws(m,i))),R=t.cmcd===void 0?null:new Ps(t.cmcd),E=new Ji(f===void 0?void 0:[f],T,J({cmcdDataBuilder:R},t.manifestRetryOptions)),C=_s({initialBitrates:{audio:(w=t.initialAudioBitrate)!=null?w:0,video:(U=t.initialVideoBitrate)!=null?U:0},lowLatencyMode:m.lowLatencyMode,throttlers:r}),P=d.signal.register(H=>{o(H)}),x=new qn(s.signal),A=new ra(T,x,R,t.segmentRetryOptions),k=ia(T.thumbnails,x),N=new $n,[D,W,B]=Bs(e,u,{useMseInWorker:g,hasVideo:this._hasVideo,hasText:l},d.signal),_=new Vt(W);this._currentContent={cmcdDataBuilder:R,contentId:u,enableRepresentationAvoidance:h,freezeResolver:_,mediaSource:D,manifest:null,manifestFetcher:E,representationEstimator:C,segmentSinksStore:W,segmentQueueCreator:A,fetchThumbnailData:k,coreTextSender:B,trackChoiceSetter:N,useMseInWorker:g},D.addEventListener(\"mediaSourceOpen\",function(){M()},d.signal),s.signal.register(H=>{E.dispose(H.reason)}),E.addEventListener(\"warning\",H=>{e({type:\"warning\",contentId:u,value:Ce(H)})},s.signal),E.addEventListener(\"manifestReady\",H=>{if(p!==null){c.warn(\"Core\",\"Multiple `manifestReady` events, ignoring\");return}p=H,this._currentContent!==null&&(this._currentContent.manifest=p),M()},d.signal),E.addEventListener(\"error\",H=>{e({type:\"error\",contentId:u,value:Ce(H)}),o(H)},s.signal),E.start();function M(){p===null||D.readyState===\"closed\"||d.isUsed()||(Os(p),p.addEventListener(\"manifestUpdate\",H=>{p!==null&&e({type:\"manifest-update\",contentId:u,value:{manifest:p,updates:H}})},s.signal),P(),a(p))}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(\"ContentPreparer MediaSource reload\"),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new z(\"ContentPreparer MediaSource\");let[t,r,i]=Bs(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 Vt(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(e){this._contentCanceller.cancel(e),this._contentCanceller=new z(\"ContentPreparer\")}};function Bs(n,e,t,r){let i;if(t.useMseInWorker){let d=new xn(Ds());i=d;let u,f=d.handle;if(f.type===\"handle\")u={type:\"handle\",value:f.value};else{let l=URL.createObjectURL(f.value);u={type:\"url\",value:l},r.register(()=>{URL.revokeObjectURL(l)})}n({type:\"attach-media-source\",contentId:e,value:u,mediaSourceId:i.id},[f.value])}else i=new kn(Ds(),e,n);let a=t.hasText?new Qn(e,n):null,{hasVideo:o}=t,s=new bt(i,o,a);return r.register(d=>{s.disposeAll(d.reason),a==null||a.stop(d.reason),i.dispose(d.reason)}),[i,s,a]}var Xn=class extends me{constructor(e,t,r){super(),this._canceller=new z(\"Boundaries Observation\"),this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new oa(e);le(this._allBufferTypes,\"video\")||i.updateLastVideoAdaptation(null),le(this._allBufferTypes,\"audio\")||i.updateLastAudioAdaptation(null),this._maximumPositionCalculator=i;let a=this._canceller.signal;it(()=>{t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let d=new Z(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",d)}else if(s>i.getMaximumAvailablePosition()){let d=new Z(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",d)}},{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(e){this.removeEventListener(),this._canceller.cancel(e!=null?e:\"ContentTimeBoundariesObserver dispose\")}_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(d=>d.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 xt((r,i)=>r.start-i.start),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t}_checkEndOfStream(){if(!this._manifest.isLastPeriodKnown)return;this._allBufferTypes.every(t=>{let r=this._activeStreams.get(t);return r!==void 0&&r.hasFinishedLoadingLastPeriod})?this.trigger(\"endOfStream\",null):this.trigger(\"resumeStream\",null)}},oa=class{constructor(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}updateLastAudioAdaptation(e){this._lastAudioAdaptation=e}updateLastVideoAdaptation(e){this._lastVideoAdaptation=e}getMaximumAvailablePosition(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)return this._manifest.getMaximumSafePosition();if(this._lastAudioAdaptation===null){if(this._lastVideoAdaptation===null)return this._manifest.getMaximumSafePosition();{let e=Wr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Wr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Wr(this._lastAudioAdaptation),t=Wr(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=qr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=qr(this._lastAudioAdaptation))!=null?t:void 0;{let r=qr(this._lastAudioAdaptation),i=qr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Wr(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 qr(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 sa(n,e,t,r,i,a){a.register(d=>{e.interruptDurationSetting(d.reason)});let o=new Xn(n,t,r.getBufferTypes());a.register(d=>{o.dispose(d.reason)}),o.addEventListener(\"warning\",d=>i.onWarning(d)),o.addEventListener(\"periodChange\",d=>i.onPeriodChanged(d)),o.addEventListener(\"endingPositionChange\",d=>{e.setDuration(d.endingPosition,d.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 da(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=j(n.sourceBuffers,s=>s.type===\"audio\"),i=j(n.sourceBuffers,s=>s.type===\"video\"),a=r==null?void 0:r.getBuffered();a!==void 0&&(t.audio=a);let o=i==null?void 0:i.getBuffered();return o!==void 0&&(t.video=o),t}async function ua(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,d=>d.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(void 0).signal)}function la(n,e,t){let{DEFAULT_WANTED_BUFFER_AHEAD:r,DEFAULT_MAX_VIDEO_BUFFER_SIZE:i,DEFAULT_MAX_BUFFER_AHEAD:a,DEFAULT_MAX_BUFFER_BEHIND:o}=L.getCurrent(),s={wantedBufferAhead:new X(r),maxVideoBufferSize:new X(i),maxBufferAhead:new X(a),maxBufferBehind:new X(o),limitVideoResolution:new X({height:void 0,width:void 0,pixelRatio:1}),throttleVideoBitrate:new X(1/0)},d=!1,u=new Gt({hasVideo:!0}),f=null,l=null;n(m=>{var h,b;c.debug(\"Core\",\"received message\",{name:m.data.type});let g=m.data;switch(g.type){case\"init\":{if(be(!d),d=!0,so(g.value),Ns(g.value.logLevel,g.value.logFormat,g.value.sendBackLogs),!v(g.value.dashWasmUrl)){let p=Me.dashParsers.wasm;p===null?c.error(\"Core\",\"Could not initialize DASH_WASM parser: DASH_WASM feature not added\"):p.isCompatible()?p.initialize({wasmUrl:g.value.dashWasmUrl}).catch(y=>{let T=y instanceof Error?y.toString():\"Unknown Error\";c.error(\"Core\",\"Could not initialize DASH_WASM parser\",T)}):c.warn(\"Core\",\"Could not initialize DASH_WASM parser: Browser not compatible\")}g.value.hasVideo||(u.disposeCurrentContent(\"Received Init msg\"),u=new Gt({hasVideo:g.value.hasVideo})),e({type:\"init-success\",value:null})}break;case\"log-level-update\":Ns(g.value.logLevel,g.value.logFormat,g.value.sendBackLogs);break;case\"prepare\":vl(e,u,g.value,s,t);break;case\"start\":{let p=u.getCurrentContent();if(g.contentId!==(p==null?void 0:p.contentId))return;f==null||f.stop(),l==null||l.finish();let y=new X(K(g.value.initialObservation,{position:new At(...g.value.initialObservation.position)}));l=y,f=Al(e,g.value,u,y,s);break}case\"observation\":{let p=u.getCurrentContent();if(g.contentId!==(p==null?void 0:p.contentId))return;let y=g.value,{buffered:T}=y,R=da(p.mediaSource,null);R.audio!==null&&(T.audio=R.audio),R.video!==null&&(T.video=R.video),l==null||l.setValue(K(y,{position:new At(...g.value.position)}));break}case\"ref-update\":Cl(g,s);break;case\"stop\":if(g.contentId!==((h=u.getCurrentContent())==null?void 0:h.contentId))return;u.disposeCurrentContent(\"StopContent message\"),f==null||f.stop(),f=null,l==null||l.finish(),l=null;break;case\"ms-reload\":{let p=u.getCurrentContent();if(g.mediaSourceId!==(p==null?void 0:p.mediaSource.id))return;f==null||f.signalMediaSourceReload()}break;case\"sb-success\":{let p=u.getCurrentContent();if(g.mediaSourceId!==(p==null?void 0:p.mediaSource.id))return;let{sourceBuffers:y}=p.mediaSource,T=j(y,R=>R.type===g.sourceBufferType);if(T===void 0){c.info(\"Core\",\"Success for an unknown SourceBuffer\",{sourceBufferType:g.sourceBufferType});return}if(T.onOperationSuccess===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:g.sourceBufferType});return}T.onOperationSuccess(g.operationId,g.value.buffered);break}case\"sb-error\":{let p=u.getCurrentContent();if(g.mediaSourceId!==(p==null?void 0:p.mediaSource.id))return;let{sourceBuffers:y}=p.mediaSource,T=j(y,R=>R.type===g.sourceBufferType);if(T===void 0){c.info(\"Core\",\"Error for an unknown SourceBuffer\",{sourceBufferType:g.sourceBufferType});return}if(T.onOperationFailure===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:g.sourceBufferType});return}T.onOperationFailure(g.operationId,g.value);break}case\"media-source-ready-state-change\":{let p=u.getCurrentContent();if(g.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(g.value);break}case\"decipherability-update\":{if(g.contentId!==((b=u.getCurrentContent())==null?void 0:b.contentId))return;let p=u.getCurrentContent();if(p===null||p.manifest===null)return;let y=g.value;p.manifest.updateRepresentationsDeciperability(T=>{for(let R of y)if(T.representation.uniqueId===R.representationUniqueId)return R.decipherable;return T.representation.decipherable});break}case\"codec-support-update\":{let p=u.getCurrentContent();if(p===null||p.manifest===null)return;let y=g.value;try{let T=p.manifest.updateCodecSupport(y);T!==null&&e({type:\"warning\",contentId:p.contentId,value:Ce(T)})}catch(T){e({type:\"error\",contentId:p.contentId,value:Ce(T)})}break}case\"urls-update\":{let p=u.getCurrentContent();if(p===null||p.contentId!==g.contentId)return;p.manifestFetcher.updateContentUrls(g.value.urls,g.value.refreshNow);break}case\"track-update\":{let p=u.getCurrentContent();if(p===null||p.contentId!==g.contentId)return;p.trackChoiceSetter.setTrack(g.value.periodId,g.value.bufferType,g.value.choice);break}case\"rep-update\":{let p=u.getCurrentContent();if(p===null||p.contentId!==g.contentId)return;p.trackChoiceSetter.updateRepresentations(g.value.periodId,g.value.adaptationId,g.value.bufferType,g.value.choice);break}case\"add-text-success\":{let p=u.getCurrentContent();if(p===null||p.contentId!==g.contentId)return;if(p.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}p.coreTextSender.onPushedTrackSuccess(g.value.ranges);break}case\"push-text-error\":{let p=u.getCurrentContent();if(p===null||p.contentId!==g.contentId)return;if(p.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}p.coreTextSender.onPushedTrackError(new Error(g.value.message));break}case\"remove-text-success\":{let p=u.getCurrentContent();if(p===null||p.contentId!==g.contentId)return;if(p.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}p.coreTextSender.onRemoveSuccess(g.value.ranges);break}case\"remove-text-error\":{let p=u.getCurrentContent();if(p===null||p.contentId!==g.contentId)return;if(p.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}p.coreTextSender.onRemoveError(new Error(g.value.message));break}case\"pull-segment-sink-store-infos\":{xl(e,u,g.value.requestId);break}case\"thumbnail-request\":{Ml(e,u,g);break}case\"config-update\":{L.update(g.value);break}case\"app-defined\":break;default:Be(g)}})}function vl(n,e,t,r,i){e.initializeNewContent(n,t,{limitResolution:{video:r.limitVideoResolution},throttleBitrate:{video:r.throttleVideoBitrate}},i).then(a=>{n({type:\"manifest-ready\",contentId:t.contentId,value:{manifest:a}})},a=>{n({type:\"error\",contentId:t.contentId,value:Ce(a)})})}function Cl(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 Al(n,e,t,r,i){c.debug(\"Core\",\"Loading pepared content.\");let a=new z(\"Start Content Worker\"),o=null;return s(e.initialTime),{signalMediaSourceReload:()=>u(),stop:()=>{a.cancel(\"ContentHandle stop\")}};function s(f){var B;o==null||o.cancel(\"Reloading content worker\"),o=new z(\"(Re)Loading Content Worker\"),o.linkToSignal(a.signal);let l=new Map,m=t.getCurrentContent();if(m===null||m.manifest===null){let _=new _e(\"NONE\",\"Loading content when none is prepared\");throw n({type:\"error\",contentId:void 0,value:Ce(_)}),_}let{contentId:g,cmcdDataBuilder:h,enableRepresentationAvoidance:b,manifest:p,mediaSource:y,representationEstimator:T,segmentSinksStore:R,segmentQueueCreator:E}=m,{drmSystemId:C,enableFastSwitching:P,onCodecSwitch:x}=e;r.onUpdate(_=>{Ms(_,R);let M=m.freezeResolver.onNewObservation(_);M!==null&&kl(n,M,{contentId:g,manifest:p,handleMediaSourceReload:d,enableRepresentationAvoidance:b})},{clearSignal:o.signal});let A=(B=p.getPeriodForTime(f))!=null?B:p.getNextPeriod(f);if(A===void 0){let _=new Z(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");throw n({type:\"error\",contentId:g,value:Ce(_)}),_}let k=new In(r,g,n,o.signal);h==null||h.startMonitoringPlayback(k),o.signal.register(()=>{h==null||h.stopMonitoringPlayback()});let N=sa(p,y,k,R,{onWarning:_=>n({type:\"warning\",contentId:g,value:Ce(_)}),onPeriodChanged:_=>{n({type:\"active-period-changed\",contentId:g,value:{periodId:_.id}})}},o.signal);cs({initialPeriod:A,manifest:p},k,T,R,E,{wantedBufferAhead:i.wantedBufferAhead,maxVideoBufferSize:i.maxVideoBufferSize,maxBufferAhead:i.maxBufferAhead,maxBufferBehind:i.maxBufferBehind,drmSystemId:C,enableFastSwitching:P,onCodecSwitch:x},D(),o.signal);function D(){return{needsBufferFlush(_){n({type:\"needs-buffer-flush\",contentId:g,value:_})},streamStatusUpdate(_){W(_),p.isLastPeriodKnown&&_.period.id===p.periods[p.periods.length-1].id&&(_.hasFinishedLoading||_.isEmptyStream?N.onLastSegmentFinishedLoading(_.bufferType):N.onLastSegmentLoadingResume(_.bufferType))},needsManifestRefresh(){t.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:_}=L.getCurrent();t.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:_})},lockedStream(_){n({type:\"locked-stream\",contentId:g,value:{periodId:_.period.id,bufferType:_.bufferType}})},adaptationChange(_){var M,w;n({type:\"adaptation-changed\",contentId:g,value:{adaptationId:(w=(M=_.adaptation)==null?void 0:M.id)!=null?w:null,periodId:_.period.id,type:_.type}}),N.onAdaptationChange(_.type,_.period,_.adaptation)},representationChange(_){var M,w;N.onRepresentationChange(_.type,_.period),!(o===null||o.signal.isCancelled())&&n({type:\"representation-changed\",contentId:g,value:{adaptationId:_.adaptation.id,representationId:(w=(M=_.representation)==null?void 0:M.id)!=null?w:null,periodId:_.period.id,type:_.type}})},inbandEvent(_){n({type:\"inband-event\",contentId:g,value:_})},warning(_){n({type:\"warning\",contentId:g,value:Ce(_)})},periodStreamReady(_){m!==null&&(m.trackChoiceSetter.addTrackSetter(_.period.id,_.type,_.adaptationRef),n({type:\"period-stream-ready\",contentId:g,value:{periodId:_.period.id,bufferType:_.type}}))},periodStreamCleared(_){if(m===null)return;let M=l.get(_.period);M!==void 0&&(M.delete(_.type),M.size===0&&l.delete(_.period)),N.onPeriodCleared(_.type,_.period),m.trackChoiceSetter.removeTrackSetter(_.period.id,_.type),n({type:\"period-stream-cleared\",contentId:g,value:{periodId:_.period.id,bufferType:_.type}})},bitrateEstimateChange(_){var M;m!==null&&((M=m.cmcdDataBuilder)==null||M.updateThroughput(_.type,_.bitrate)),n({type:\"bitrate-estimate-change\",contentId:g,value:{bitrate:_.bitrate,bufferType:_.type}})},needsMediaSourceReload(_){d(_)},needsDecipherabilityFlush(){n({type:\"needs-decipherability-flush\",contentId:g,value:null})},encryptionDataEncountered(_){for(let M of _){let w=M.content,U=J({},w);U.manifest instanceof ht&&(U.manifest=U.manifest.getMetadataSnapshot()),U.period instanceof gt&&(U.period=U.period.getMetadataSnapshot()),U.adaptation instanceof mt&&(U.adaptation=U.adaptation.getMetadataSnapshot()),U.representation instanceof un&&(U.representation=U.representation.getMetadataSnapshot()),n({type:\"encryption-data-encountered\",contentId:g,value:{keyIds:M.keyIds,values:M.values,content:U,type:M.type}})}},error(_){n({type:\"error\",contentId:g,value:Ce(_)})}}}function W(_){let{imminentDiscontinuity:M}=_,w=l.get(_.period),U=w==null?void 0:w.get(_.bufferType);if(U!==void 0){if(U.discontinuity===null){if(M===null)return}else if(M!==null&&U.discontinuity.start===M.start&&U.discontinuity.end===M.end)return}w===void 0&&(w=new Map,l.set(_.period,w));let H={periodId:_.period.id,bufferType:_.bufferType,discontinuity:_.imminentDiscontinuity,position:_.position};w.set(_.bufferType,H),n({type:\"discontinuity-update\",contentId:g,value:H})}}function d(f){var m;o!==null&&(o.cancel(\"WorkerMain MediaSource reload\"),o=null);let l=(m=t.getCurrentContent())==null?void 0:m.mediaSource.id;if(l===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:l,value:f},[]),u()}function u(){var g;let l=r.getValue().position.getWanted();o!==null&&(o.cancel(\"MediaSource reload\"),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:l}),s(l)},h=>{if(z.isCancellationError(h)){c.info(\"Core\",\"A reloading operation was cancelled\");return}n({type:\"error\",contentId:m,value:Ce(h)})})}}function Ns(n,e,t){t?c.setLevel(n,\"standard\",(r,i,a)=>{let o=a.map(s=>s instanceof Error?Ce(s):s);postMessage({type:\"log\",value:{namespace:i,logLevel:r,logs:o}})}):c.setLevel(n,e)}function xl(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 kl(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 Ml(n,e,t){let r=e.getCurrentContent(),i=a=>{n({type:\"thumbnail-response\",contentId:t.contentId,value:{status:\"error\",requestId:t.value.requestId,error:Ce(a)}})};if(r===null||r.manifest===null||r.contentId!==t.contentId)return i(new Error(\"Content changed\"));ua(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 Us=la;var Ol=\"<\",wl=60,Ls=\">\",Vr=62,fa=45,Fs=47,Dl=33,zs=39,Ws=34,ma=91,Bl=93,Nl=`\\r\n\t>/= `;function ca(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(u()),n=n.substring(t),t=0;else a=o(\"\");return e.filter!==void 0&&(a=qs(a,e.filter)),a;function o(h){let b=[];for(;n[t]!==void 0;)if(n.charCodeAt(t)===wl){if(n.charCodeAt(t+1)===Fs){let y=t+2;if(t=n.indexOf(Ls,t),n.substring(y,t).indexOf(h)===-1){let R=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(R.length-1)+`\nColumn: `+(R[R.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),b}else if(n.charCodeAt(t+1)===Dl){if(n.charCodeAt(t+2)===fa){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===Vr&&n.charCodeAt(t-1)===fa&&n.charCodeAt(t-2)===fa);)t=n.indexOf(Ls,t+1);t===-1&&(t=n.length),r&&b.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===ma&&n.charCodeAt(t+8)===ma&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(b.push(n.substring(t+9)),t=n.length):(b.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let T=!1;for(;(n.charCodeAt(t)!==Vr||T)&&n[t]!==void 0;)n.charCodeAt(t)===ma?T=!0:T&&n.charCodeAt(t)===Bl&&(T=!1),t++;b.push(n.substring(y,t))}t++;continue}let p=u();b.push(p),p.tagName[0]===\"?\"&&(b.push(...p.children),p.children=[])}else{let p=s();if(i)p.length>0&&b.push(p);else{let y=p.trim();y.length>0&&b.push(y)}t++}return b}function s(){let h=t;return t=n.indexOf(Ol,t)-1,t===-2&&(t=n.length),n.slice(h,t+1)}function d(){let h=t;for(;Nl.indexOf(n[t])===-1&&n[t]!==void 0;)t++;return n.slice(h,t)}function u(){let h=t;t++;let b=d(),p={},y=[];for(;n.charCodeAt(t)!==Vr&&n[t]!==void 0;){let T=n.charCodeAt(t);if(T>64&&T<91||T>96&&T<123){let R=d(),E=n.charCodeAt(t);for(;!isNaN(E)&&E!==zs&&E!==Ws&&!(E>64&&E<91||E>96&&E<123)&&E!==Vr;)t++,E=n.charCodeAt(t);let C;E===zs||E===Ws?C=f():(C=null,t--),p[R]=C===null?null:Vs(C)}t++}return n.charCodeAt(t-1)!==Fs?(t++,y=o(b)):t++,{tagName:b,attributes:p,children:y,posStart:h,posEnd:t}}function f(){let h=n[t],b=t+1;return t=n.indexOf(h,b),n.slice(b,t)}function l(){let h=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return h!==null?h.index:-1}}function qs(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=qs(a.children,e,t+1,(Q(r)?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function Gr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+Gr(t),e=e.trim()}),e}else return typeof n==\"object\"?Gr(n.children):\" \"+Vs(n)}function Vs(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 pa(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 Fe(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=pa(n,e,t);return r+(a+1)*i}function Ae(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 Gs(n,e,t){return[n*t,(n+e)*t]}function Ul(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 Hs(n,e,t){let{timeline:r}=n,i=Ae(e,n);if(i<0)return null;let a=Ul(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 d=s.start,u=Fe(o,s,t);return i>=u&&i<d?Je(d,n):null}function at(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 Ll(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function ga(n){return(e,t,r)=>{let i=Q(r)?parseInt(r,10):1;return Ll(String(n),i)}}function ze(n,e,t){return Fl(n,e,t)}function Fl(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(%0(\\d+)d)?\\$/g,ga(t===void 0?0:t))}function Hr(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 ga(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 ga(n)(i,a,o)})}}function zl(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function Zn(n,e,t,r,i,a){var T;let o=r.getEstimatedMaximumPosition((T=n.availabilityTimeOffset)!=null?T:0),s=Math.min(e+t,o!=null?o:1/0),d=Ae(e,n),u=Ae(s,n),{timeline:f,timescale:l,segmentUrlTemplate:m,startNumber:g,endNumber:h}=n,b=g!=null?g:1,p=[],y=f.length;for(let R=0;R<y;R++){let E=f[R],{duration:C,start:P,range:x}=E,A;o===void 0?A=i:A=Math.min(o*l,i!=null?i:1/0);let k=pa(E,f[R+1],A),N=n.availabilityTimeComplete!==!1||R!==y-1&&k!==0,D=zl(P,C,d),W=P+D*C;for(;W<u&&D<=k;){let B=b+D;if(h!==void 0&&B>h)break;let _=m===null?null:Hr(W,B)(m),M=W-n.indexTimeOffset,w=C;M<0&&(w=C+M,M=0);let U={id:String(W),time:M/l,end:(M+w)/l,duration:w/l,isInit:!1,range:x,timescale:1,url:_,number:B,timestampOffset:-(n.indexTimeOffset/l),complete:N,privateInfos:{isEMSGWhitelisted:a}};p.push(U),D++,W=P+D*C}if(W>=u||(b+=k+1,h!==void 0&&b>h))return p}return p}function Wl(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 kt=class{constructor(e,t){var h,b,p,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,d=(h=e.timescale)!=null?h:1,f=((b=e.presentationTimeOffset)!=null?b:0)-r*d,l=((p=e.initialization)==null?void 0:p.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:l,range:g},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:d},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Ae(r,this._index),this._scaledPeriodEnd=v(i)?void 0:Ae(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return at(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return Zn(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++)Wl(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 Mt=class{constructor(e,t){var g,h,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 d=(g=e.presentationTimeOffset)!=null?g:0,u=(h=e.timescale)!=null?h:1,f=d-r*u,l=((b=e.initialization)==null?void 0:b.media)===void 0?null:ze(e.initialization.media,a,o),m=e.list.map(p=>({url:p.media===void 0?null:ze(p.media,a,o),mediaRange:p.mediaRange}));this._index={list:m,timescale:u,duration:e.duration,indexTimeOffset:f,indexRange:e.indexRange,initialization:v(e.initialization)?void 0:{url:l,range:e.initialization.range}}}getInitSegment(){let e=at(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,d=e-this._periodStart,[u,f]=Gs(d,t,o),l=Math.min(a.length-1,Math.floor(f/i)),m=[],g=Math.floor(u/i);for(;g<=l;){let h=a[g].mediaRange,b=a[g].url,p=g*s+this._periodStart,y={id:String(g),time:p,isInit:!1,range:h,duration:s,timescale:1,end:p+s,url:b,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(y),g++}return m}shouldRefresh(e,t){return!1}getFirstAvailablePosition(){return this._periodStart}getLastAvailablePosition(){var i;let e=this._index,{duration:t,list:r}=e;return Math.min(r.length*t/e.timescale+this._periodStart,(i=this._periodEnd)!=null?i:1/0)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return!0}initialize(){c.error(\"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 Ht(n){return L.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var Ot=class{constructor(e,t){var y,T,R;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:d,representationBitrate:u,isEMSGWhitelisted:f}=t,l=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(T=e.presentationTimeOffset)!=null?T:0,g=s*l,h=m-g;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let b=((R=e.initialization)==null?void 0:R.media)===void 0?null:ze(e.initialization.media,d,u),p=e.media===void 0?null:ze(e.media,d,u);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:h,initialization:v(e.initialization)?void 0:{url:b,range:e.initialization.range},url:p,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 at(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:d}=r,u=this._periodStart*s,f=this._scaledRelativePeriodEnd,l=e*s-u,m=(e+t)*s-u,g=this._getFirstSegmentStart(),h=this._getLastSegmentStart();if(v(g)||v(h))return[];let b=Math.max(g,l),p=Math.min(h,m);if(p+i<=b)return[];let y=[],T=a!=null?a:1,R=Math.floor(b/i);for(let E=R*i;E<=p;E+=i){let C=R+T;if(o!==void 0&&C>o)return y;let P=!v(f)&&E+i>f?f-E:i,x=E+u,A=E+this._index.presentationTimeOffset,k=d===null?null:Hr(A,C)(d),N={id:String(C),number:C,time:x/s,end:(x+P)/s,duration:P/s,timescale:1,isInit:!1,scaledDuration:P/s,url:k,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(N),R++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return v(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(v(e))return e;let t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,t!=null?t:1/0)/this._index.timescale+this._periodStart}getEnd(){if(!this._isDynamic)return this.getLastAvailablePosition();let e=this._estimateRelativeScaledEnd();if(e===void 0)return;let{timescale:t}=this._index;return(e+this._periodStart*t)/t}awaitSegmentBetween(e,t){if(be(e<=t),!this._isDynamic)return!1;let{timescale:r}=this._index,i=Ht(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,d=this._getLastSegmentStart();if(v(d)){let l=this._estimateRelativeScaledEnd();return l===void 0?s+i>=0:s+i>=0&&o<l-i}let u=d+this._index.duration,f=this._estimateRelativeScaledEnd();return f===void 0?s>u-i:s>u-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=Ht(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 d=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(d===void 0)return;let u=(d-this._periodStart)*t;if(u<0)return null;let f=Math.floor(u/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,d=Math.ceil(s/e);r!==void 0&&r-i+1<d&&(d=r-i+1);let u=(d-1)*e,f=L.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-u>f||d<2?u:(d-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 ha(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 Ia(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 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 h=(r-m.start)/m.duration-1;if(h%1===0&&m.duration===e[0].duration){let b=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=b,!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 d=o.start+o.duration*(o.repeatCount+1),u=s.start+s.duration*(s.repeatCount+1);return d>=u?(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 Jn(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 er(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 yt(n){let e=[];for(let r=0;r<n.length;r++)e.push(er(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=Jn(i,a,o);s!==null&&t.push(s)}return t}function ba(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 d=o.attributes.d,u=v(d)?null:parseInt(d,10);if(u===null||Number.isNaN(u))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 h=t-s;if(h%u===0&&h/u<=l)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/u,prevSegmentsIdx:0,newElementsIdx:a}}s+=u*(l+1)}else s+=u;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 ya(n,e){var b;let t=ba(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,d=e.length-r+i-1;if(d>=n.length)return c.info(\"dash\",'Cannot perform \"based\" update. New timeline too short'),yt(n);let u=e.slice(r);if(a>0){let p=u[0];p.start+=p.duration*a,u[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=u[u.length-1],l=er(n[d]),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.'),yt(n);l.repeatCount!==void 0&&l.repeatCount>f.repeatCount&&(f.repeatCount=l.repeatCount);let g=[],h=[];for(let p=d+1;p<n.length;p++)h.push(er(n[p]));for(let p=0;p<h.length;p++){let y=h[p],T=g[g.length-1]===void 0?f:g[g.length-1],R=h[p+1]===void 0?null:h[p+1],E=Jn(y,T,R);E!==null&&g.push(E)}return u.concat(g)}var tr=class n{constructor(e,t){var E,C,P,x,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:d,representationBitrate:u,periodStart:f,periodEnd:l,isEMSGWhitelisted:m}=t,g=(E=e.timescale)!=null?E:1,h=(C=e.presentationTimeOffset)!=null?C:0,b=f*g,p=h-b;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(P=t.receivedTime)!=null?P: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=(x=e.timelineParser)!=null?x:null;let y=((A=e.initialization)==null?void 0:A.media)===void 0?null:ze(e.initialization.media,d,u),T=e.media===void 0?null:ze(e.media,d,u),R;i===void 0&&r===void 0?R=1/0:R=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:R,indexRange:e.indexRange,indexTimeOffset:p,initialization:v(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:T,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:Sa(e.timeline,e.startNumber,e.endNumber),timescale:g},this._scaledPeriodStart=Ae(f,this._index),this._scaledPeriodEnd=l===void 0?void 0:Ae(l,this._index)}getInitSegment(){return at(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),Zn(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=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 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 u,f;if(be(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=Ht(r),o=Ae(t,this._index),s=Kr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(u=this._scaledPeriodEnd)!=null?u:1/0)+a>=Math.min(o,(f=this._scaledPeriodEnd)!=null?f:1/0))return!1;let d=Ae(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],g=Fe(l,null,this._scaledPeriodEnd)+a;if(d<g+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:d-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()),ql(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),Hs({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()),Ia(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&&Ae(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Ht(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 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(v(e))return;let t=Ae(e,this._index),r=ha(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 Sa(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,Sa(ya(e,r),this._index.startNumber,this._index.endNumber)}};function Sa(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),d=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-d),o.push(s),o}}}return n}function ql(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 u=(s-o.start)/o.duration-1;return u%1===0&&u<=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: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 u=Ae(r,n)-a.start,f=Math.floor(u/a.duration);return be(f>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:f-1,end:a.start+f*a.duration}}}}return null}var jr=tr;var nr=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 Ta(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\"),Ta(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),Ta(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function Ta(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 Yr(n){let e=Date.parse(n)-F();if(isNaN(e)){c.warn(\"dash\",\"Invalid clock received\",{clock:n});return}return e}function Ea(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 Qr(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 _a(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=Qr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=Qr(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 $r(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 Ra(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=$r(r);if(s===void 0)return;a=s}if(i!==void 0){let s=$r(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 Pa(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=Ra(n),t=_a(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var rr=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 va(n,e){return n.type!==\"dynamic\"?0:v(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function Ca(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 Aa(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 u=t[t.length-1];if(!v(u)&&!v(u.periodEnd))a=u.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 d=v(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:d})}),t}function Vl(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 d of s)d.id===a&&(d.trickModeTracks===void 0&&(d.trickModeTracks=[]),d.trickModeTracks.push(r))}}}var Ks=Vl;var Gl=[\"subtitle\",\"caption\"];function xa(n,e){var s,d,u,f;let t=(f=j((s=n.children.essentialProperties)!=null?s:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\"))!=null?f:j((u=(d=e!=null?e:n.children.representations[0])==null?void 0:d.children.essentialProperties)!=null?u:[],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 ka(n,e){if(n.attributes.contentType===\"image\")return xa(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=v(n.children.roles)?null:n.children.roles;function a(s,d){let u=s.split(\"/\")[0];if(le(Ut,u))return u;if(s===\"application/ttml+xml\")return\"text\";if(s===\"application/mp4\")return d!==null&&j(d,f=>f.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&le(Gl,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 d=e[s],{mimeType:u,codecs:f}=d.attributes;if(u!==void 0){let l=a(u,i);if(l!==void 0)return l}if(f!==void 0){let l=o(f);if(l!==void 0)return l}}}var Hl=/[, ]+/g;function js(n){return Q(n)?n.trim().replace(Hl,\", \"):\"\"}function Ys(n){let[e,t,r,i,a,o,s,d]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let u,f,l;if((i!==void 0&&i===\"10\"||i===\"12\")&&(u=parseInt(i,10)),s!==void 0&&(s===\"16\"?f=\"pq\":s===\"18\"&&(f=\"hlg\")),o!==void 0&&d!==void 0&&o===\"09\"&&d===\"09\"&&(l=\"rec2020\"),!(u===void 0||f===void 0))return{colorDepth:u,eotf:f,colorSpace:l}}function Ma(n,e){var h,b,p;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:d,inbandEventStreams:u,isLastPeriod:f}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:d,isEMSGWhitelisted:y=>u===void 0?!1:u.some(({schemeIdUri:T})=>T===y.schemeIdUri),isLastPeriod:f,manifestBoundsCalculator:r,isDynamic:i,periodEnd:a,periodStart:o,receivedTime:s,representationBitrate:n.attributes.bitrate,representationId:n.attributes.id},g;if(n.children.segmentBase!==void 0){let{segmentBase:y}=n.children;g=new kt(y,m)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;g=new Mt(y,m)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let y=e.parentSegmentTemplates.slice(),T=n.children.segmentTemplate;T!==void 0&&y.push(T);let R=K({},...y);(R.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((h=R.availabilityTimeOffset)!=null?h:0)+((b=e.availabilityTimeOffset)!=null?b:0)),(R.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(p=R.availabilityTimeComplete)!=null?p:e.availabilityTimeComplete),g=jr.isTimelineIndexArgument(R)?new jr(R,m):new Ot(R,m)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:T}=y;g=new kt(T,m)}else if(y.segmentList!==void 0){let{segmentList:T}=y;g=new Mt(T,m)}else g=new Ot({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return g}function ot(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 d=t[s],u=zn(o.url,d.url);r.push({url:u,serviceLocation:(i=d.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Kl(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 jl({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 Ys(i)}function Oa(n,e,t){var i,a,o,s,d,u,f;let r=[];for(let l of n){let m=l.attributes.id!==void 0?l.attributes.id:String(l.attributes.bitrate)+(l.attributes.height!==void 0?`-${l.attributes.height}`:\"\")+(l.attributes.width!==void 0?`-${l.attributes.width}`:\"\")+(l.attributes.mimeType!==void 0?`-${l.attributes.mimeType}`:\"\")+(l.attributes.codecs!==void 0?`-${l.attributes.codecs}`:\"\");for(;r.some(k=>k.id===m);)m+=\"-dup\";let g=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(m))!=null?a:null,h=Kl(l,e),b=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,p;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(p=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((d=t.availabilityTimeOffset)!=null?d:0));let y=K({},t,{availabilityTimeOffset:p,availabilityTimeComplete:b,unsafelyBaseOnPreviousRepresentation:g,adaptation:e,inbandEventStreams:h}),T=Ma(l,y),R;l.attributes.bitrate===void 0?(c.warn(\"dash\",\"No usable bitrate found in the Representation.\"),R=0):R=l.attributes.bitrate;let E=ot(t.baseURLs,l.children.baseURLs),C=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(k=>({baseUrl:k.url,id:k.serviceLocation})),P={bitrate:R,cdnMetadata:C,index:T,id:m};l.children.supplementalProperties!==void 0&&j(l.children.supplementalProperties,k=>k.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&k.value===\"JOC\")!==void 0&&(P.isSpatialAudio=!0);let x;l.attributes.codecs!==void 0?x=l.attributes.codecs:e.attributes.codecs!==void 0&&(x=e.attributes.codecs),x!==void 0&&(x=x===\"mp4a.40.02\"?\"mp4a.40.2\":x,P.codecs=x);let A;l.attributes.supplementalCodecs!==void 0?A=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(A=e.attributes.supplementalCodecs),A!==void 0&&(P.supplementalCodecs=js(A)),l.attributes.frameRate!==void 0?P.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(P.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?P.height=l.attributes.height:e.attributes.height!==void 0&&(P.height=e.attributes.height),l.attributes.mimeType!==void 0?P.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(P.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?P.width=l.attributes.width:e.attributes.width!==void 0&&(P.width=e.attributes.width);{let k=[...(u=e.children.contentProtections)!=null?u:[],...(f=l.children.contentProtections)!=null?f:[]];for(let N of k)t.contentProtectionParser.add(P,N)}P.hdrInfo=jl({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:x}),r.push(P)}return r}function Yl(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 Ql(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 $l(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function Xl(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,d=s;return Q(n.attributes.language)&&(d+=`-${n.attributes.language}`),t===!0&&(d+=\"-cc\"),r===!0&&(d+=\"-cc\"),i===!0&&(d+=\"-ad\"),a===!0&&(d+=\"-si\"),o&&(d+=\"-trickMode\"),Q(n.attributes.contentType)&&(d+=`-${n.attributes.contentType}`),Q(n.attributes.codecs)&&(d+=`-${n.attributes.codecs}`),Q(n.attributes.mimeType)&&(d+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(d+=`-${String(n.attributes.frameRate)}`),d}function Zl(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=>Q(r))}return[]}function wa(n,e){var d,u,f,l,m,g,h;let t={video:[],audio:[],text:[]},r=[],i=[],a={},o=[];for(let b=0;b<n.length;b++){let p=n[b],y=p.children,{essentialProperties:T,roles:R,label:E}=y,C=Array.isArray(R)&&R.some(oe=>oe.value===\"main\")&&R.some(oe=>oe.schemeIdUri===\"urn:mpeg:dash:role:2011\"),P=p.children.representations,x=(d=p.attributes.availabilityTimeComplete)!=null?d:e.availabilityTimeComplete,A;(p.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(A=((u=p.attributes.availabilityTimeOffset)!=null?u:0)+((f=e.availabilityTimeOffset)!=null?f:0));let k=ka(p,P);if(k===void 0)continue;let N=(l=p.attributes.selectionPriority)!=null?l:1,D=p.attributes.id,W=Zl(p),B=[];e.segmentTemplate!==void 0&&B.push(e.segmentTemplate),p.children.segmentTemplate!==void 0&&B.push(p.children.segmentTemplate);let _={availabilityTimeComplete:x,availabilityTimeOffset:A,baseURLs:ot(e.baseURLs,y.baseURLs),contentProtectionParser:e.contentProtectionParser,manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:B,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},M=Array.isArray(T)?j(T,oe=>oe.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,w=(m=M==null?void 0:M.value)==null?void 0:m.split(\" \"),U=w!==void 0,{accessibilities:H}=y,$;R!==void 0&&R.some(oe=>oe.value===\"dub\")&&($=!0);let V;k!==\"text\"?V=!1:V=Ql(H,R);let G;k===\"text\"&&R!==void 0&&R.some(oe=>oe.value===\"forced-subtitle\"||oe.value===\"forced_subtitle\")&&(G=!0);let Y;k!==\"audio\"?Y=!1:H!==void 0&&(Y=H.some(Yl));let ce;k!==\"video\"?ce=!1:H!==void 0&&(ce=H.some($l));let fe=Xl(p,{isAudioDescription:Y,isForcedSubtitle:G,isClosedCaption:V,isSignInterpreted:ce,isTrickModeTrack:U,type:k});for(;le(o,fe);)fe+=\"-dup\";let pe=fe;o.push(fe),_.unsafelyBaseOnPreviousAdaptation=(h=(g=e.unsafelyBaseOnPreviousPeriod)==null?void 0:g.getAdaptation(fe))!=null?h:null;let Qe=Oa(P,p,_);if(k===\"thumbnails\"){let oe=Jl(p,Qe);oe!==null&&r.push(...oe);continue}let re={id:fe,representations:Qe,type:k,isTrickModeTrack:U};if(v(p.attributes.language)||(re.language=p.attributes.language),v(V)||(re.closedCaption=V),v(Y)||(re.audioDescription=Y),$===!0&&(re.isDub=!0),G!==void 0&&(re.forcedSubtitles=G),ce===!0&&(re.isSignInterpreted=!0),E!==void 0&&(re.label=E),w!==void 0)i.push({adaptation:re,trickModeAttachedAdaptationIds:w});else{let oe=-1;for(let $t of W){let Xt=a[$t];if(Xt!==void 0&&Xt.newID!==pe&&le(Xt.adaptationSetSwitchingIDs,D)){oe=ie(t[k],Zt=>Zt[0].id===$t);let Re=t[k][oe];if(Re!==void 0&&Re[0].audioDescription===re.audioDescription&&Re[0].closedCaption===re.closedCaption&&Re[0].language===re.language){c.info(\"dash\",'merging \"switchable\" AdaptationSets',{originalID:D,id:$t}),Re[0].representations.push(...re.representations),Re[1]={priority:Math.max(N,Re[1].priority),isMainAdaptation:C||Re[1].isMainAdaptation,indexInMpd:Math.min(b,Re[1].indexInMpd)};break}}}oe<0&&t[k].push([re,{priority:N,isMainAdaptation:C,indexInMpd:b}])}!v(D)&&v(a[D])&&(a[D]={newID:pe,adaptationSetSwitchingIDs:W})}let s=Ut.reduce((b,p)=>{let y=t[p];return y.length>0&&(y.sort(Qs),b[p]=y.map(([T])=>T)),b},{});return t.video.sort(Qs),Ks(s,i),{adaptations:s,thumbnailTracks:r}}function Jl(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=xa(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 d=(r=o.index.getFirstAvailablePosition())!=null?r:void 0,u=(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:d,end:u,tileDuration:f===void 0?void 0:f/(s.horizontalTiles*s.verticalTiles)})}}return t}function Qs(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 ef=Oe();function Da(n,e){var o,s,d,u,f;let t=[],r=Aa(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],h=e.xlinkInfos.get(g),b=ot(e.baseURLs,g.children.baseURLs),{periodStart:p,periodDuration:y,periodEnd:T}=r[l],R;for(v(g.attributes.id)?(R=\"gen-dash-period-\"+ef(),c.warn(\"dash\",\"No usable id found in the Period. Generating one.\",{periodId:R})):R=g.attributes.id;t.some(U=>U.id===R);)R+=\"-dup\";let E=h!==void 0?h.receivedTime:e.receivedTime,C=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(R))!=null?s:null,P=g.attributes.availabilityTimeComplete,x=g.attributes.availabilityTimeOffset,{manifestProfiles:A,contentProtectionParser:k}=e,{segmentTemplate:N}=g.children;k.addReferences((d=g.children.contentProtections)!=null?d:[]);let D={availabilityTimeComplete:P,availabilityTimeOffset:x,baseURLs:b,contentProtectionParser:k,manifestBoundsCalculator:a,end:T,isDynamic:i,isLastPeriod:m,manifestProfiles:A,receivedTime:E,segmentTemplate:N,start:p,unsafelyBaseOnPreviousPeriod:C},{adaptations:W,thumbnailTracks:B}=wa(g.children.adaptations,D),_=((u=e.xmlNamespaces)!=null?u:[]).concat((f=g.attributes.namespaces)!=null?f:[]),M=nf(g.children.eventStreams,p,_),w={id:R,start:p,end:T,duration:y,thumbnailTracks:B,adaptations:W,streamEvents:M};if(t.unshift(w),!a.lastPositionIsKnown()){let U=tf(W);if(!i)typeof U==\"number\"&&a.setLastPosition(U);else if(typeof U==\"number\"){let H=F()/1e3;a.setLastPosition(U,H)}else{let H=$s(e,p);if(H!==void 0){let[$,V]=H;a.setLastPosition($,V)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=$s(e,0);if(l!==void 0){let[m,g]=l;a.setLastPosition(m,g)}}return Ca(t)}function $s(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=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 tf(n){let e=null,t=!0,r=Sr(n).filter(a=>!v(a)),i=vi(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let d=s.index.getLastAvailablePosition();d!==null&&(t=!1,typeof d==\"number\"&&(e=v(e)?d:Math.max(e,d)))}}if(v(e)){if(t)return null}else return e}function nf(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:d=1}=o.attributes,u=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)/d+e,m=f.duration===void 0?void 0:l+f.duration/d,g,h;try{h={namespaces:u,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:Ge(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:d,element:g,xmlData:h}}})}}return r}function Kt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(v(e.externalClockOffset)){let d=o.type===\"dynamic\",u=j(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!v(m.value)),f=!v(u)&&!v(u.value)?Yr(u.value):void 0,l=!v(f)&&!isNaN(f)?f:void 0;if(!v(l)&&r!==!0)e.externalClockOffset=l;else if(d&&r!==!0){let m=Ea(n);if(!v(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(h){return h.success?(e.externalClockOffset=Yr(h.data),Kt(n,e,t,!0)):(t.push(h.error),c.warn(\"dash\",\"Error on fetching the clock ressource\",h.error),Kt(n,e,t,!0))}}}}}let s=[];for(let d=0;d<a.periods.length;d++){let{xlinkHref:u,xlinkActuate:f}=a.periods[d].attributes;!v(u)&&f===\"onLoad\"&&s.push({index:d,ressource:u})}return s.length===0?rf(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:d})=>d),continue:function(u){if(u.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let f=u.length-1;f>=0;f--){let l=s[f].index,{parsed:m,warnings:g,receivedTime:h,sendingTime:b,url:p}=u[f];g.length>0&&t.push(...g);for(let y of m)i.set(y,{receivedTime:h,sendingTime:b,url:p});a.periods.splice(l,1,...m)}return Kt(n,e,t,r,i)}}}}function rf(n,e,t,r){var _,M,w,U,H;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Xi(e.url))}]:[],d=ot(s,i.baseURLs),u=va(a,e.referenceDateTime),f=a.timeShiftBufferDepth,l=a.maxSegmentDuration,{externalClockOffset:m,unsafelyBaseOnPreviousManifest:g}=e,{externalClockOffset:h}=e,b=new rr({availabilityStartTime:u,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:h}),p=new nr;p.addReferences((_=i.contentProtections)!=null?_:[]);let y={availabilityStartTime:u,baseURLs:d,clockOffset:m,contentProtectionParser:p,duration:a.duration,isDynamic:o,manifestBoundsCalculator:b,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,unsafelyBaseOnPreviousManifest:g,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},T=Da(i.periods,y);p.finalize();let R=a.duration,E,C,P=null,x;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(E=a.minimumUpdatePeriod===0?L.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:A,maximumSafePosition:k,maximumUnsafePosition:N}=Pa(T),D=F();if(o){let $;k!==void 0?$=k:h===void 0?(c.warn(\"dash\",\"use system clock to define maximum position\"),$=Date.now()/1e3-u):$=(F()+h)/1e3-u;let V=b.getEstimatedLiveEdge();V===void 0&&(N!==void 0?V=N:V=$),x={isLinear:!0,maximumSafePosition:$,livePosition:V,time:D},C=A,P=f!=null?f:null,P!==null&&(P+=l!=null?l:0),P!==null&&C!==void 0&&V-C>P&&(P=V-C)}else{C=A,C===void 0&&(C=(w=(M=T[0])==null?void 0:M.start)!=null?w:0);let $=R!=null?R:1/0;if(T[T.length-1]!==void 0){let V=T[T.length-1],G=(U=V.end)!=null?U:V.duration!==void 0?V.start+V.duration:void 0;G!==void 0&&G<$&&($=G)}k!==void 0&&k<$&&($=k),x={isLinear:!1,maximumSafePosition:$,livePosition:void 0,time:D}}let W=!o||n.attributes.minimumUpdatePeriod===void 0&&(((H=T[T.length-1])==null?void 0:H.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:u,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:W,periods:T,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:C,timeshiftDepth:P,maximumTimeData:x},lifetime:E,uris:v(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var Xr=Kt;var af=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,of=/([0-9]+)-([0-9]+)/;function xe(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new De(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ae(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 Ba(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 Zr(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=af.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 wt(n,e){let t=of.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function Xs(n,e){try{return[Rr(n),null]}catch(t){return[null,new De(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function jt(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 De=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\"}};function St(n){return Gr(n)}function st(n){let e=typeof n==\"string\"?n:St(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function sf(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]=Xs(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 df(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=sn(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function dt(n){let[e,t]=sf(n.children),r=df(n);return[{children:e,attributes:r},t]}function Na(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 Ua(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:wt,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,d]=Ua(o);e.initialization=s,t=t.concat(d)}}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:wt,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:xe,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:xe,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 La(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:wt,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:wt,dashName:\"mediaRange\"});break}}return[e,t]}function ir(n){let[e,t]=ut(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let d=a[s];if(typeof d!=\"string\"&&d.tagName===\"SegmentURL\"){let[u,f]=La(d);i.push(u),r=r.concat(f)}}return[K(e,{list:i}),r]}function Fa(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 Dt(n){let[e,t]=ut(n),r=t,i;for(let s=0;s<n.children.length;s++){let d=n.children[s];typeof d!=\"string\"&&d.tagName===\"SegmentTimeline\"&&(i=Fa(d))}let a=K({},e,{duration:e.duration,timelineParser:i}),o=Ee(a,r);for(let s of Object.keys(n.attributes)){let d=n.attributes[s];if(!v(d))switch(s){case\"initialization\":v(a.initialization)&&(a.initialization={media:d});break;case\"index\":a.index=d;break;case\"availabilityTimeOffset\":o(d,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(d,{asKey:\"availabilityTimeComplete\",parser:xe,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=d;break;case\"bitstreamSwitching\":o(d,{asKey:\"bitstreamSwitching\",parser:xe,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function uf(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]=st(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]=ir(a);r=r.concat(s),e.segmentList=o;break}case\"SegmentTemplate\":{let[o,s]=Dt(a);r=r.concat(s),e.segmentTemplate=o;break}case\"ContentProtection\":{let[o,s]=dt(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 lf(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:xe,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:jt,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:xe,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new De(\"No bitrate found on a Representation\")),[e,t]}function Zs(n){let[e,t]=uf(n.children),[r,i]=lf(n),a=t.concat(i);return[{children:e,attributes:r},a]}function ff(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]=st(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break}case\"ContentComponent\":e.contentComponent=Na(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=St(a.children);o!=null&&(e.label=o);break}case\"Representation\":{let[o,s]=Zs(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]=ir(a);e.segmentList=o,s.length>0&&(r=r.concat(s));break}case\"SegmentTemplate\":{let[o,s]=Dt(a);e.segmentTemplate=o,s.length>0&&(r=r.concat(s));break}case\"ContentProtection\":{let[o,s]=dt(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 mf(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:jt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:jt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ae,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:Ba,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:Ba,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:xe,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:xe,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:jt,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:xe,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function Js(n){let e=n.children,[t,r]=ff(e),[i,a]=mf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function cf(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:he(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function ed(n,e){let[t,r]=cf(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,d]=ae(a.attributes.presentationTime,\"presentationTime\");d!==null&&r.push(d),s!==null&&(o.presentationTime=s)}if(!v(a.attributes.duration)){let[s,d]=ae(a.attributes.duration,\"duration\");d!==null&&r.push(d),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 pf(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let d=0;d<n.length;d++){let u=n[d];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":{let[f,l]=st(u);f!==void 0&&t.push(f),o=o.concat(l);break}case\"AdaptationSet\":{let[f,l]=Js(u);r.push(f),o=o.concat(l);break}case\"EventStream\":{let[f,l]=ed(u,e);s.push(f),o=o.concat(l);break}case\"SegmentTemplate\":{let[f,l]=Dt(u);i=f,l.length>0&&(o=o.concat(l));break}case\"ContentProtection\":{let[f,l]=dt(u);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 gf(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:Ke,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:Ke,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:xe,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:he(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Jr(n,e){let[t,r]=pf(n.children,e),[i,a]=gf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function hf(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let d=0;d<n.length;d++){let u=n[d];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":{let[f,l]=st(u);f!==void 0&&t.push(f),s=s.concat(l);break}case\"Location\":r.push(St(u.children));break;case\"Period\":{let[f,l]=Jr(u,e);i.push(f),s=s.concat(l);break}case\"UTCTiming\":{let f=Te(u);a.push(f);break}case\"ContentProtection\":{let[f,l]=dt(u);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 If(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:Zr,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:Zr,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:Zr,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:he(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function td(n,e){let[t,r]=hf(n.children,e),[i,a]=If(n),o=r.concat(a);return[{children:t,attributes:i},o]}function za(n,e){let t=ca(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]=td(r,n),o=Xr(i,e,a);return s(o);function s(d){if(d.type===\"done\")return d;if(d.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[d.value.url],format:\"string\",continue(u){if(u.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let f=d.value.continue(u[0].responseData);return s(f)}}};if(d.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:d.value.xlinksUrls,format:\"string\",continue(u){let f=[];for(let m=0;m<u.length;m++){let{responseData:g,receivedTime:h,sendingTime:b,url:p}=u[m];if(!g.success)throw g.error;let y=\"<root>\"+g.data+\"</root>\",T=ca(y),R=T[T.length-1];if(R===void 0||typeof R==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let E=R.children,C=[],P=[];for(let x=0;x<E.length;x++){let A=E[x];if(typeof A==\"string\"||A.tagName!==\"Period\")continue;let[k,N]=Jr(A,y);P.push(...N),C.push(k)}f.push({url:p,receivedTime:h,sendingTime:b,parsed:C,warnings:P})}let l=d.value.continue(f);return s(l)}}};Be(d)}}var nd=za;var bf=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",rd=bf;function q(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function Wa(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=q(t,e.buffer,a,o))}}function Et(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,d){switch(o){case 16:t.schemeIdUri=q(i,e.buffer,s,d);break;case 13:t.value=q(i,e.buffer,s,d);break;case 14:{let u=q(i,e.buffer,s,d);t.keyId=sn(u.replace(/-/g,\"\"));break}case 15:try{let u=q(i,e.buffer,s,d);r.cencPssh.push(Rr(u))}catch(u){}break;case 78:t.ref=q(i,e.buffer,s,d);break;case 79:t.refId=q(i,e.buffer,s,d);break}}}function id(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=q(t,e.buffer,a,o);break;case 60:n.language=q(t,e.buffer,a,o);break;case 61:n.contentType=q(t,e.buffer,a,o);break;case 62:n.par=q(t,e.buffer,a,o);break}}}function ad(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.label=q(t,e.buffer,a,o))}}function We(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=q(t,e.buffer,a,o);break;case 17:n.value=q(t,e.buffer,a,o);break}}}function Yt(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=q(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 od(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=q(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=q(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 ei(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=od(a,e);t.pushParsers(i,O,o);break}default:t.pushParsers(i,O,O);break}}}function Qt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let d=a;for(let u=0;u<o/24;u++)n.timeline.push({start:s.getFloat64(d,!0),duration:s.getFloat64(d+8,!0),repeatCount:s.getFloat64(d+16,!0)}),d+=24;break}case 67:n.initialization={media:q(t,e.buffer,a,o)};break;case 28:n.index=q(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=q(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 sd(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,We(a,e));break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=We(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=We(a,e);t.pushParsers(i,O,o);break}case 17:{let a={};n.segmentBase=a;let o=Yt(a,e);t.pushParsers(i,O,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=ei(a,e,t),s=Yt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,O,Qt(a,e));break}default:t.pushParsers(i,O,O);break}}}function dd(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=q(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=q(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=q(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=q(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=q(t,e.buffer,a,o);break;case 2:n.profiles=q(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=q(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 ud(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=We(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,id(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=We(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=We(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=sd(a.children,e,t),s=dd(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=We(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=We(a,e);t.pushParsers(i,O,o);break}case 17:{let a={};n.segmentBase=a;let o=Yt(a,e);t.pushParsers(i,O,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=ei(a,e,t),s=Yt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,O,Qt(a,e));break}case 21:{t.pushParsers(i,O,ad(n,e));break}default:t.pushParsers(i,O,O);break}}}function ld(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=q(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=q(t,e.buffer,a,o);break;case 61:n.contentType=q(t,e.buffer,a,o);break;case 62:n.par=q(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=Wa(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=Wa(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=q(t,e.buffer,a,o);break;case 4:n.codecs=q(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=q(t,e.buffer,a,o);break;case 2:n.profiles=q(t,e.buffer,a,o);break;case 12:n.segmentProfiles=q(t,e.buffer,a,o);break;case 11:n.mimeType=q(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 fd(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=yf(o,e,r);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function md(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=q(t,e.buffer,a,o);break;case 17:n.value=q(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:{let d={key:\"\",value:\"\"},u=a,f=s.getUint32(u);u+=4,d.key=q(t,e.buffer,u,f),u+=f;let l=s.getUint32(u);u+=4,d.value=q(t,e.buffer,u,l),n.namespaces===void 0?n.namespaces=[d]:n.namespaces.push(d);break}}}}function yf(n,e,t){let r=new TextDecoder;return function(a,o,s){let d=new DataView(e.buffer);switch(a){case 25:n.presentationTime=d.getFloat64(o,!0);break;case 1:n.duration=d.getFloat64(o,!0);break;case 0:n.id=q(r,e.buffer,o,s);break;case 69:{let u=d.getFloat64(o,!0),f=d.getFloat64(o+8,!0);n.eventStreamData=t.slice(u,f);break}}}}function ti(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=ud(o.children,e,t),d=ld(o.attributes,e);t.pushParsers(a,s,d);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,d=Tt(o,e);t.pushParsers(a,s,d);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=fd(o.children,e,t,r),d=md(o.attributes,e);t.pushParsers(a,s,d);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,O,Qt(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 ni(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=q(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=q(t,e.buffer,a,o);break;case 47:n.xlinkActuate=q(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:\"\"},d=new DataView(e.buffer),u=a,f=d.getUint32(u);u+=4,s.key=q(t,e.buffer,u,f),u+=f;let l=d.getUint32(u);u+=4,s.value=q(t,e.buffer,u,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}}function cd(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,d=Tt(o,e);t.pushParsers(a,s,d);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=ti(o.children,e,t,r),d=ni(o.attributes,e);t.pushParsers(a,s,d);break}case 3:{let o={};n.utcTimings.push(o);let s=O,d=We(o,e);t.pushParsers(a,s,d);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 pd(n,e,t){let r,i=new TextDecoder;return function(o,s,d){switch(o){case 0:e.id=q(i,t.buffer,s,d);break;case 2:e.profiles=q(i,t.buffer,s,d);break;case 33:e.type=q(i,t.buffer,s,d);break;case 34:{let u=q(i,t.buffer,s,d);e.availabilityStartTime=new Date(u).getTime()/1e3;break}case 35:{let u=q(i,t.buffer,s,d);e.availabilityEndTime=new Date(u).getTime()/1e3;break}case 36:{let u=q(i,t.buffer,s,d);e.publishTime=new Date(u).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 u=q(i,t.buffer,s,d);n.locations.push(u);break}case 70:{let u={key:\"\",value:\"\"};r=new DataView(t.buffer);let f=s,l=r.getUint32(f);f+=4,u.key=q(i,t.buffer,f,l),f+=l;let m=r.getUint32(f);f+=4,u.value=q(i,t.buffer,f,m),e.namespaces===void 0?e.namespaces=[u]:e.namespaces.push(u);break}}}}function qa(n,e,t,r){return function(a){switch(a){case 1:{n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=cd(n.mpd.children,e,t,r),s=pd(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break}default:t.pushParsers(a,O,O);break}}}function gd(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=ti(o.children,e,t,r),d=ni(o.attributes,e);t.pushParsers(a,s,d);break}default:t.pushParsers(a,O,O);break}}}var ar=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 Sf=15e3,or=class{constructor(){this._parsersStack=new ar,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:u,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 d=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=d.catch(async h=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"dash\",\"Unable to call `instantiateStreaming` on WASM\",h instanceof Error?h:\"\");let b=await s;if(b.status<200||b.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(b.status));let p=await b.arrayBuffer();return WebAssembly.instantiate(p,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 b=h instanceof Error?h.toString():\"Unknown error\";throw c.warn(\"dash\",\"Could not create DASH-WASM parser:\",b),this.status=\"failure\",h}),this._initProm;function u(h){return t.childrenParser(h)}function f(h){return t.popIfCurrent(h)}function l(h,b,p){return t.attributeParser(h,b,p)}function m(h,b,p){let y=i._linearMemory,T=new Uint8Array(y.buffer,b,p);if(h===1){let R=r.decode(T);c.warn(\"dash\",\"WASM Error Event:\",R),i._warnings.push(new Error(R))}else if(h===0){let R=r.decode(T);c.warn(\"dash\",\"WASM Log Event:\",R)}}function g(h,b){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let p=i._linearMemory,{mpd:y,cursor:T}=i._mpdData,R=Math.min(b,Sf,y.byteLength-T);return new Uint8Array(p.buffer,h,R).set(new Uint8Array(y,T,R)),i._mpdData.cursor+=R,R}}runWasmParser(e,t){let[r,i]=this._parseMpd(e);if(r===null)throw new Error(\"DASH Parser: Unknown error while parsing the MPD\");let a=Xr(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return rd&&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=qa(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,O),this._warnings=[];try{this._instance.instance.exports.parse()}catch(d){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,d}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=gd(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:d,sendingTime:u,url:f}=r[o];if(!s.success)throw s.error;let[l,m]=this._parseXlink(s.data);i.push({url:f,receivedTime:d,sendingTime:u,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 Be(e)}};var hd=or;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 d=0;d<e.length;d++){let u=e[d];u[1]===null?s+=u[0]:s+=`${u[0]}=${u[1]}`,d<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(),d=!1,m={reject:b=>{var R,E;if(d||i.isCancelled())return;d=!0,i.deregister(h);let p=b,y=(R=p==null?void 0:p.message)!=null?R:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",T=new $e(y,(E=p==null?void 0:p.canRetry)!=null?E:!1,p==null?void 0:p.xhr);o(T)},resolve:b=>{if(d||i.isCancelled())return;d=!0,i.deregister(h);let p=b.receivingTime!==void 0?b.receivingTime-s:void 0,y=b.sendingTime!==void 0?b.sendingTime-s:void 0;a({responseData:b.data,size:b.size,requestDuration:b.duration,url:b.url,receivedTime:p,sendingTime:y})},fallback:()=>{d||i.isCancelled()||(d=!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(b){d||(d=!0,typeof g==\"function\"&&g(),o(b))}})}function Tf(n){return function(t,r,i){var s,d;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=((d=r.cmcdPayload)==null?void 0:d.type)===\"headers\"?r.cmcdPayload.value:void 0;switch(n){case\"arraybuffer\":return Ie({url:a,headers:o,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return Ie({url:a,headers:o,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return Ie({url:a,headers:o,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:Be(n)}}}function Ga({customManifestLoader:n},e,t){let r=Tf(e),i=typeof n!=\"function\"?r:Va(n,r);return t!==null?t(i):i}function Ha(n,e){if(e){if(Ze(n,1718909296)<0)throw new _e(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Ze(n,1836019574)<0)throw new _e(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Ze(n,1836019558)<0)throw new _e(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Ze(n,1835295092)<0)throw new _e(\"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 ri(n){return(e,t,r,i,a)=>{return new Promise((s,d)=>{let u=new z(\"Segment integrity checks\"),f=u.linkToSignal(i);u.signal.register(d),n(e,t,r,u.signal,de(J({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(g){l(),u.cancel(\"Integrity check failed\"),d(g)}}})).then(m=>{if(l(),!u.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(g){d(g);return}s(m)}},m=>{l(),d(m)});function l(){u.signal.deregister(d),f()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||Ye(t.type,t.mimeType)!==\"mp4\"||Ha(new Uint8Array(s),t.segment.isInit)}}}function Id(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,d=[\"</\",\"MPD\",\">\"];for(let u=d.length-1;u>=0;u--){let f=d[u];for(;Ef(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,d=new DataView(o),u=[[60,47],[77,80,68],[62]];for(let f=u.length-1;f>=0;f--){let l=u[f];for(;_f(d.getUint8(s));)s--;for(let m=l.length-1;m>=0;m--){if(d.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 Ef(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function _f(n){return n===32||n===9||n===13||n===10}function Ka(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,d){var T;let{responseData:u}=i,f=a.externalClockOffset,l=(T=i.url)!=null?T:a.originalUrl,m=t!=null?t:f,h={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:m},b=Me.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.\"),p();{let R=Cf(u);if(!Af(R))return c.info(\"dash\",\"MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),p();if(b.wasm.status===\"initialized\"){c.debug(\"dash\",\"Running WASM MPD Parser.\");let E=b.wasm.runWasmParser(R,h);return y(E)}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\"),p();c.debug(\"dash\",\"Running WASM MPD Parser.\");let C=b.wasm.runWasmParser(R,h);return y(C)})}function p(){if(b.js!==null){let R=vf(u),E=b.js(R,h);return y(E)}else throw new Error(\"No MPD parser is imported\")}function y(R){if(R.type===\"done\")return R.value.warnings.length>0&&o(R.value.warnings),s.isCancelled()?Promise.reject(s.cancellationError):{manifest:new ht(R.value.parsed,n),url:l};let{value:E}=R,C=E.urls.map(P=>d(()=>{let x=L.getCurrent().DEFAULT_REQUEST_TIMEOUT,A=L.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return E.format===\"string\"?Ie({url:P,responseType:\"text\",timeout:x,connectionTimeout:A,cancelSignal:s}):Ie({url:P,responseType:\"arraybuffer\",timeout:x,connectionTimeout:A,cancelSignal:s})}).then(x=>{if(E.format===\"string\"){if(typeof x.responseData!=\"string\")throw new Error(\"External DASH resources should have been a string\");return K(x,{responseData:{success:!0,data:x.responseData}})}else{if(!(x.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return K(x,{responseData:{success:!0,data:x.responseData}})}},x=>{let A=ge(x,{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(C).then(P=>E.format===\"string\"?(Rf(P),y(E.continue(P))):(Pf(P),y(E.continue(P))))}}}function Rf(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 Pf(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 vf(n){if(n instanceof ArrayBuffer)return Ge(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 Cf(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return on(n).buffer;if(!v(te.Document)&&n instanceof te.Document)return on(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Af(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 qe([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function Bt(n,e){return n===null?null:e.url===null?n.baseUrl:zn(n.baseUrl,e.url)}function sr(n,e,t,r,i){var u,f;let a=n;((u=t.cmcdPayload)==null?void 0:u.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 Ie({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 Ie({url:a,headers:de(J({},o),{Range:qe(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 Ie({url:a,headers:de(J({},o),{Range:qe([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=Ie({url:a,headers:de(J({},o),{Range:qe(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),d=Ie({url:a,headers:de(J({},o),{Range:qe(e.indexRange)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([s,d]).then(([l,m])=>{let g=Ct(new Uint8Array(l.responseData),new Uint8Array(m.responseData)),h=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-h,sendingTime:h,receivedTime:b}}})}async function dr(n,e,t,r){let i=null;function a(s){let d=new Uint8Array(s.chunk),u=i!==null?Ct(i,d):d,f=Pr(u),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 hr({url:n,headers:e.headers,onData:a,timeout:e.timeout,connectionTimeout:e.connectionTimeout,cancelSignal:r})}}async function bd(n,e,t,r,i,a){var m,g;if(e.segment.isInit)return sr(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:d}=e,u;d.range!==void 0?u=de(J({},s),{Range:qe(d.range)}):s!==void 0&&(u=s);let f=Ye(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(nn())return dr(o,{headers:u,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 Ie({url:o,responseType:\"arraybuffer\",headers:u,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress})}}function ja({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:ri(r);function r(i,a,o,s,d){let u=Bt(i,a.segment);return u===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?bd(u,a,n,o,d,s):new Promise((f,l)=>{let m=!1,y={reject:P=>{var N,D;if(m||s.isCancelled())return;m=!0,s.deregister(C);let x=P,A=(N=x==null?void 0:x.message)!=null?N:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",k=new $e(A,(D=x==null?void 0:x.canRetry)!=null?D:!1,x==null?void 0:x.xhr);l(k)},resolve:P=>{if(m||s.isCancelled())return;m=!0,s.deregister(C);let x;P.data instanceof Uint8Array?P.data.buffer instanceof ArrayBuffer?x=P.data:x=P.data.slice():x=P.data,f({resultType:\"segment-loaded\",resultData:{responseData:x,size:P.size,requestDuration:P.duration}})},progress:P=>{m||s.isCancelled()||d.onProgress({duration:P.duration,size:P.size,totalSize:P.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(C),bd(u,a,n,o,d,s).then(f,l))}},T;a.segment.range!==void 0&&(T=[a.segment.range],a.segment.indexRange!==void 0&&T.push(a.segment.indexRange));let R={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:T,trackType:a.type,url:u,cmcdPayload:o.cmcdPayload},E=e(R,y);s.register(C);function C(P){m||(m=!0,typeof E==\"function\"&&E(),l(P))}})}}function yd(){if(Lt.browser!==Lt.BROWSERS.Other)return c.warn(\"utils\",\"getChromeVersion: Can't access Chrome version. Not a Chrome browser.\"),null;let n=navigator.userAgent.match(/Chrome\\/(\\d+)/);return n!==null?parseInt(n[1],10):null}function Ya(n,e){let t=yd();return t===null||t>=94||!n.some(i=>he(i,\"dvh1\")||he(i,\"dvhe\"))?!1:e!==void 0&&!he(e,\"dvh1\")&&!he(e,\"dvhe\")}var $a=408125543,Sd=357149030,xf=2807729,kf=17545,Mf=475249515,Of=187,wf=179,Df=183,Bf=241;function _t(n,e,t,[r,i]){let a=r;for(;a<i;){let o=Uf(t,a);if(o===null)return null;let{value:s,length:d}=o,u=a+d,f=Lf(t,u);if(f===null)return null;let{length:l,value:m}=f,g=u+l,h=g+m;if(s===n)return[g,h];if(e.length>0){for(let b=0;b<e.length;b++)if(s===e[b]){let p=e.slice(b+1,e.length);return _t(n,p,t,[g,h])}}a=h}return null}function ii(n,e){let t=_t(xf,[$a,Sd],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/Qa(n,t[0],r)}function Nf(n,e){let t=_t(kf,[$a,Sd],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?Ff(n,t[0]):r===8?zf(n,t[0]):null}function Xa(n,e){let t=_t($a,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=ii(n,r);if(a===null)return null;let o=Nf(n,r);if(o===null)return null;let s=_t(Mf,[],n,[r,i]);if(s===null)return null;let d=[],u=s[0];for(;u<s[1];){let l=_t(Of,[],n,[u,s[1]]);if(l===null)break;let m=_t(wf,[],n,[l[0],l[1]]);if(m===null)return null;let g=Qa(n,m[0],m[1]-m[0]),h=_t(Bf,[Df],n,[l[0],l[1]]);if(h===null)return null;let b=Qa(n,h[0],h[1]-h[0])+r;d.push({time:g,rangeStart:b}),u=l[1]}let f=[];for(let l=0;l<d.length;l++){let m=d[l];l===d.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:d[l+1].time-m.time,range:[m.rangeStart,d[l+1].rangeStart-1]})}return f}function Td(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function Uf(n,e){let t=Td(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 Lf(n,e){let t=Td(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 Ff(n,e){return new DataView(n.buffer).getFloat32(e)}function zf(n,e){return new DataView(n.buffer).getFloat64(e)}function Qa(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 ur(n,e,t,r){let i=Ri(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=Pi(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,d=t.duration*r,u=Math.min(r*.9,d/4);return o!==void 0&&Math.abs(o-d)<=u&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function Wf(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=Ge(o),d=Date.parse(s);if(a===void 0||d===void 0||isNaN(d)||d>=a)return!0}return!1}function Za(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:Wf(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function Ja({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var R,E;let{segment:a,periodStart:o,periodEnd:s}=r,{data:d,isChunked:u}=t,f=[o,s];if(d===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=wo(d),m=Ye(r.type,r.mimeType),g=m===\"mp4\"||m===void 0,h=[];if(g){let C=Cr(l),P;a.isInit&&(P=(R=Fo(l))!=null?R:void 0),(C.length>0||P!==void 0)&&h.push({initDataType:\"cenc\",keyId:P,initData:C})}if(!a.isInit){let C=g?ur(l,u,a,i):null,P=(E=a.timestampOffset)!=null?E:0;if(g){let x=Lo(l);if(x!==void 0){let A=x.filter(N=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(N)),k=Za(A,r.manifestPublishTime);if(k!==void 0){let{needsManifestRefresh:N,inbandEvents:D}=k;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:P,appendWindow:f,inbandEvents:D,protectionData:h,needsManifestRefresh:N}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:P,protectionData:h,appendWindow:f}}let{indexRange:b}=a,p;if(m===\"webm\")p=Xa(l,0);else if(g&&(Ya(r.baseCodecs,r.chosenCodec)&&(c.debug(\"dash\",\"patching out Dolby Vision metadata from segment\"),vr(l)),p=mn(l,Array.isArray(b)?b[0]:0),n===!0&&p!==null&&p.length>0)){let C=p[p.length-1];Array.isArray(C.range)&&(C.range[1]=1/0)}let y;g?y=cn(l):m===\"webm\"&&(y=ii(l,0));let T=v(y)?void 0:y;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:h,initTimescale:T,segmentList:p!=null?p:void 0}}}function eo({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:ri(t);async function t(r,i,a,o,s){var p,y;let{segment:d}=i,u=Bt(r,d);if(u===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(d.isInit)return sr(u,d,a,o,s);let f=((p=a.cmcdPayload)==null?void 0:p.type)===\"query\"?je(u,a.cmcdPayload.value):u,l=((y=a.cmcdPayload)==null?void 0:y.type)===\"headers\"?a.cmcdPayload.value:void 0,m;d.range!==void 0?m=de(J({},l),{Range:qe(d.range)}):l!==void 0&&(m=l);let g=Ye(i.type,i.mimeType),h=g===\"mp4\"||g===void 0;if(n&&h){if(nn())return dr(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 b;return h?b=await Ie({url:f,responseType:\"arraybuffer\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}):b=await Ie({url:f,responseType:\"text\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}),{resultType:\"segment-loaded\",resultData:b}}}function qf(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 Vf(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 Ed({segment:n,language:e,codecs:t},r,i,a,o){if(n.isInit)return null;let s,d;a===null?o?(s=n.time,d=n.end):c.warn(\"utils\",\"Unavailable time data for current text track.\"):(s=a.time,a.duration!==void 0?d=s+a.duration:!o&&n.complete&&(d=s+n.duration));let u=qf(t),f=Ei(r),l=f!==null?Ge(f):\"\";return t===\"wvtt\"&&!he(l,\"WEBVTT\")&&!he(l,\"\\xFE\\xFFWEBVTT\")?{data:r,type:\"mp4vtt\",language:e,start:s,end:d,initTimescale:i!=null?i:null}:{data:l,type:u,language:e,start:s,end:d,initTimescale:i!=null?i:null}}function _d(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=Vf(n.chosenCodec,n.mimeType);return{data:e,type:s,language:n.language,start:a,end:o,initTimescale:t!=null?t:null}}function Gf(n,e,t,r,i){var m;let{segment:a}=t,{isInit:o,indexRange:s}=a,d;if(typeof n==\"string\"?d=on(n):n instanceof Uint8Array?d=n:d=new Uint8Array(n),o){let g=mn(d,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 h=cn(d);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:h,segmentList:g!=null?g:void 0}}let u=ur(d,e,a,r),f=Ed({segment:t.segment,codecs:t.chosenCodec,language:t.language},d,r,u,e),l=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:f,chunkSize:d.length,chunkInfos:u,chunkOffset:l,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Hf(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 d,u;if(typeof n!=\"string\"){let l=n instanceof Uint8Array?n:new Uint8Array(n);d=Ge(l),u=l.length}else d=n;return{segmentType:\"media\",chunkData:_d(r,d,e,t),chunkSize:u,chunkInfos:null,chunkOffset:s,protectionData:[],appendWindow:[i,a]}}function to({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var l;let{periodStart:a,periodEnd:o,segment:s}=r,{data:d,isChunked:u}=t;if(d===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=Ye(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?Gf(d,u,r,i,n):Hf(d,i,u,r)}}async function Rd(n,e,t,r){var d,u;let i=Bt(n,e);if(i===null)return Promise.reject(new Error(\"Cannot load thumbnail: no URL\"));let a=((d=t.cmcdPayload)==null?void 0:d.type)===\"query\"?je(i,t.cmcdPayload.value):i,o=((u=t.cmcdPayload)==null?void 0:u.type)===\"headers\"?t.cmcdPayload.value:void 0,s;return e.range!==void 0?s=de(J({},o),{Range:qe(e.range)}):o!==void 0&&(s=o),rn({url:a,responseType:\"arraybuffer\",headers:s,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r})}function Pd(n,e){var u;let{thumbnailTrack:t,thumbnail:r}=e,i=t.height/t.verticalTiles,a=t.width/t.horizontalTiles,o=[],s=(u=t.tileDuration)!=null?u:(r.end-r.time)/(t.horizontalTiles*t.verticalTiles),d=r.time;for(let f=0;f<t.verticalTiles;f++)for(let l=0;l<t.horizontalTiles;l++)o.push({start:d,end:d+s,offsetX:Math.round(l*a),offsetY:Math.round(f*i),height:Math.floor(i),width:Math.floor(a)}),d+=s;return{mimeType:t.mimeType,data:n,thumbnails:o}}function vd(n){let e=Ga({customManifestLoader:n.manifestLoader},Kf()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?Id:null),t=Ka(n),r=ja(n),i=Ja(n),a=eo(n),o=to(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:Rd,parseThumbnail:Pd}}}function Kf(){return Me.dashParsers.wasm!==null&&(Me.dashParsers.wasm.status===\"initialized\"||Me.dashParsers.wasm.status===\"initializing\")}var Cd=vd;function no(n){let e=new hd;Me.dashParsers.wasm=e,Me.dashParsers.js=nd,Me.transports.dash=Cd,te.onmessageerror=t=>{c.error(\"Core\",\"Error when receiving message from main thread.\")},Us(t=>{onmessage=t},jf,n)}function jf(n,e){Yf(n),n.type!==\"log\"&&c.debug(\"M<--C\",\"Sending message from worker\",{name:n.type}),e===void 0?postMessage(n):postMessage(n,e)}function Yf(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=[])):c.warn(\"Core\",\"the Manifest instance should be communicated to `sendMessage`.\"))}no({representationFilters:new Map,segmentLoaders:new Map,manifestLoaders:new Map});})();\n" + "})()"], { type: "application/javascript" });
5
5
  exports.EMBEDDED_WORKER = blob;
6
6
  exports.default = blob;