@tarojs/components 4.0.0-beta.1 → 4.0.0-beta.3

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 (585) hide show
  1. package/LICENSE +14 -0
  2. package/dist/cjs/{index-5a8221ec.js → index-dbbe9dde.js} +3 -0
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/taro-ad-core.cjs.entry.js +1 -1
  5. package/dist/cjs/taro-ad-custom-core.cjs.entry.js +1 -1
  6. package/dist/cjs/taro-animation-video-core.cjs.entry.js +1 -1
  7. package/dist/cjs/taro-animation-view-core.cjs.entry.js +1 -1
  8. package/dist/cjs/taro-ar-camera-core.cjs.entry.js +1 -1
  9. package/dist/cjs/taro-audio-core.cjs.entry.js +2 -2
  10. package/dist/cjs/taro-aweme-data-core.cjs.entry.js +1 -1
  11. package/dist/cjs/taro-block-core.cjs.entry.js +1 -1
  12. package/dist/cjs/taro-button-core.cjs.entry.js +3 -3
  13. package/dist/cjs/taro-camera-core.cjs.entry.js +1 -1
  14. package/dist/cjs/taro-canvas-core.cjs.entry.js +2 -2
  15. package/dist/cjs/taro-channel-live-core.cjs.entry.js +1 -1
  16. package/dist/cjs/taro-channel-video-core.cjs.entry.js +1 -1
  17. package/dist/cjs/taro-checkbox-core_2.cjs.entry.js +2 -2
  18. package/dist/cjs/taro-comment-detail-core.cjs.entry.js +1 -1
  19. package/dist/cjs/taro-comment-list-core.cjs.entry.js +1 -1
  20. package/dist/cjs/taro-components.cjs.js +2 -2
  21. package/dist/cjs/taro-contact-button-core.cjs.entry.js +1 -1
  22. package/dist/cjs/taro-cover-image-core.cjs.entry.js +2 -2
  23. package/dist/cjs/taro-cover-view-core.cjs.entry.js +2 -2
  24. package/dist/cjs/taro-custom-wrapper-core.cjs.entry.js +1 -1
  25. package/dist/cjs/taro-editor-core.cjs.entry.js +1 -1
  26. package/dist/cjs/taro-follow-swan-core.cjs.entry.js +1 -1
  27. package/dist/cjs/taro-form-core.cjs.entry.js +1 -1
  28. package/dist/cjs/taro-functional-page-navigator-core.cjs.entry.js +1 -1
  29. package/dist/cjs/taro-grid-view-core.cjs.entry.js +1 -1
  30. package/dist/cjs/taro-icon-core.cjs.entry.js +5 -2
  31. package/dist/cjs/taro-image-core.cjs.entry.js +7 -6
  32. package/dist/cjs/taro-inline-payment-panel-core.cjs.entry.js +1 -1
  33. package/dist/cjs/taro-input-core.cjs.entry.js +2 -2
  34. package/dist/cjs/taro-keyboard-accessory-core.cjs.entry.js +1 -1
  35. package/dist/cjs/taro-label-core.cjs.entry.js +1 -1
  36. package/dist/cjs/taro-lifestyle-core.cjs.entry.js +1 -1
  37. package/dist/cjs/taro-like-core.cjs.entry.js +1 -1
  38. package/dist/cjs/taro-list-view-core.cjs.entry.js +1 -1
  39. package/dist/cjs/taro-live-player-core.cjs.entry.js +1 -1
  40. package/dist/cjs/taro-live-pusher-core.cjs.entry.js +1 -1
  41. package/dist/cjs/taro-login-core.cjs.entry.js +1 -1
  42. package/dist/cjs/taro-lottie-core.cjs.entry.js +1 -1
  43. package/dist/cjs/taro-map-core.cjs.entry.js +1 -1
  44. package/dist/cjs/taro-match-media-core.cjs.entry.js +1 -1
  45. package/dist/cjs/taro-movable-area-core_2.cjs.entry.js +4 -4
  46. package/dist/cjs/taro-native-slot-core.cjs.entry.js +1 -1
  47. package/dist/cjs/taro-navigation-bar-core.cjs.entry.js +1 -1
  48. package/dist/cjs/taro-navigator-core.cjs.entry.js +2 -2
  49. package/dist/cjs/taro-official-account-core.cjs.entry.js +1 -1
  50. package/dist/cjs/taro-open-data-core.cjs.entry.js +1 -1
  51. package/dist/cjs/taro-page-container-core.cjs.entry.js +1 -1
  52. package/dist/cjs/taro-page-meta-core.cjs.entry.js +1 -1
  53. package/dist/cjs/taro-picker-core_2.cjs.entry.js +3 -3
  54. package/dist/cjs/taro-picker-view-column-core_2.cjs.entry.js +4 -4
  55. package/dist/cjs/taro-progress-core.cjs.entry.js +4 -1
  56. package/dist/cjs/taro-pull-to-refresh-core.cjs.entry.js +3 -3
  57. package/dist/cjs/taro-radio-core_2.cjs.entry.js +1 -1
  58. package/dist/cjs/taro-rich-text-core.cjs.entry.js +2 -2
  59. package/dist/cjs/taro-root-portal-core.cjs.entry.js +1 -1
  60. package/dist/cjs/taro-rtc-room-core.cjs.entry.js +1 -1
  61. package/dist/cjs/taro-rtc-room-item-core.cjs.entry.js +1 -1
  62. package/dist/cjs/taro-scroll-view-core.cjs.entry.js +3 -3
  63. package/dist/cjs/taro-share-element-core.cjs.entry.js +1 -1
  64. package/dist/cjs/taro-slider-core.cjs.entry.js +4 -1
  65. package/dist/cjs/taro-slot-core.cjs.entry.js +1 -1
  66. package/dist/cjs/taro-snapshot-core.cjs.entry.js +1 -1
  67. package/dist/cjs/taro-sticky-header-core.cjs.entry.js +1 -1
  68. package/dist/cjs/taro-sticky-section-core.cjs.entry.js +1 -1
  69. package/dist/cjs/taro-swiper-core_2.cjs.entry.js +19 -9863
  70. package/dist/cjs/taro-switch-core.cjs.entry.js +13 -12
  71. package/dist/cjs/taro-tab-item-core.cjs.entry.js +1 -1
  72. package/dist/cjs/taro-tabbar.cjs.entry.js +14 -86
  73. package/dist/cjs/taro-tabs-core.cjs.entry.js +1 -1
  74. package/dist/cjs/taro-text-core.cjs.entry.js +2 -2
  75. package/dist/cjs/taro-textarea-core.cjs.entry.js +12 -3
  76. package/dist/cjs/taro-video-control_3.cjs.entry.js +25 -5
  77. package/dist/cjs/taro-view-core.cjs.entry.js +3 -3
  78. package/dist/cjs/taro-voip-room-core.cjs.entry.js +1 -1
  79. package/dist/cjs/taro-web-view-core.cjs.entry.js +2 -2
  80. package/dist/collection/components/audio/style/index.css +1 -4
  81. package/dist/collection/components/button/style/index.css +1 -160
  82. package/dist/collection/components/canvas/style/index.css +1 -6
  83. package/dist/collection/components/checkbox/style/index.css +1 -39
  84. package/dist/collection/components/cover-image/style/index.css +1 -5
  85. package/dist/collection/components/cover-view/style/cover-view.css +1 -3
  86. package/dist/collection/components/icon/icon.js +10 -0
  87. package/dist/collection/components/icon/style/index.css +1 -0
  88. package/dist/collection/components/image/image.js +4 -3
  89. package/dist/collection/components/image/style/index.css +1 -73
  90. package/dist/collection/components/input/input.js +2 -2
  91. package/dist/collection/components/input/style/index.css +1 -0
  92. package/dist/collection/components/movable-area/area.css +1 -6
  93. package/dist/collection/components/movable-area/view.css +1 -8
  94. package/dist/collection/components/navigator/style/index.css +1 -3
  95. package/dist/collection/components/picker/style/index.css +1 -4
  96. package/dist/collection/components/picker-view/style/column.css +1 -12
  97. package/dist/collection/components/picker-view/style/index.css +1 -28
  98. package/dist/collection/components/progress/progress.js +10 -0
  99. package/dist/collection/components/progress/style/index.css +1 -0
  100. package/dist/collection/components/pull-to-refresh/style/index.css +1 -52
  101. package/dist/collection/components/rich-text/style/index.css +1 -16
  102. package/dist/collection/components/scroll-view/style/index.css +1 -17
  103. package/dist/collection/components/slider/slider.js +10 -0
  104. package/dist/collection/components/slider/style/index.css +1 -0
  105. package/dist/collection/components/swiper/style/index.css +2 -19
  106. package/dist/collection/components/switch/style/index.css +1 -10
  107. package/dist/collection/components/switch/switch.js +12 -12
  108. package/dist/collection/components/tabbar/style/index.css +1 -53
  109. package/dist/collection/components/tabbar/tabbar.js +1 -1
  110. package/dist/collection/components/text/style/index.css +1 -26
  111. package/dist/collection/components/textarea/style/index.css +1 -22
  112. package/dist/collection/components/textarea/textarea.js +11 -0
  113. package/dist/collection/components/video/style/index.css +1 -327
  114. package/dist/collection/components/view/style/index.css +1 -9
  115. package/dist/collection/components/web-view/style/index.css +1 -12
  116. package/dist/components/taro-audio-core.js +1 -1
  117. package/dist/components/taro-button-core.js +1 -1
  118. package/dist/components/taro-canvas-core.js +1 -1
  119. package/dist/components/taro-checkbox-core.js +1 -1
  120. package/dist/components/taro-cover-image-core.js +1 -1
  121. package/dist/components/taro-icon-core.js +3 -0
  122. package/dist/components/taro-image-core.js +5 -4
  123. package/dist/components/taro-input-core.js +1 -1
  124. package/dist/components/taro-movable-area-core.js +1 -1
  125. package/dist/components/taro-movable-view-core.js +1 -1
  126. package/dist/components/taro-picker-core.js +1 -1
  127. package/dist/components/taro-picker-view-column-core.js +1 -1
  128. package/dist/components/taro-picker-view-core.js +1 -1
  129. package/dist/components/taro-progress-core.js +3 -0
  130. package/dist/components/taro-pull-to-refresh-core.js +1 -1
  131. package/dist/components/taro-rich-text-core.js +1 -1
  132. package/dist/components/taro-scroll-view-core.js +1 -1
  133. package/dist/components/taro-slider-core.js +3 -0
  134. package/dist/components/taro-swiper-core.js +5 -9853
  135. package/dist/components/taro-switch-core.js +13 -13
  136. package/dist/components/taro-tabbar.js +3 -76
  137. package/dist/components/taro-text-core.js +1 -1
  138. package/dist/components/taro-textarea-core.js +11 -2
  139. package/dist/components/taro-video-core.js +2 -2
  140. package/dist/components/taro-view-core.js +1 -1
  141. package/dist/components/taro-web-view-core.js +1 -1
  142. package/dist/esm/{index-6bb77c5f.js → index-486e187e.js} +3 -1
  143. package/dist/esm/loader.js +3 -3
  144. package/dist/esm/taro-ad-core.entry.js +1 -1
  145. package/dist/esm/taro-ad-custom-core.entry.js +1 -1
  146. package/dist/esm/taro-animation-video-core.entry.js +1 -1
  147. package/dist/esm/taro-animation-view-core.entry.js +1 -1
  148. package/dist/esm/taro-ar-camera-core.entry.js +1 -1
  149. package/dist/esm/taro-audio-core.entry.js +2 -2
  150. package/dist/esm/taro-aweme-data-core.entry.js +1 -1
  151. package/dist/esm/taro-block-core.entry.js +1 -1
  152. package/dist/esm/taro-button-core.entry.js +3 -3
  153. package/dist/esm/taro-camera-core.entry.js +1 -1
  154. package/dist/esm/taro-canvas-core.entry.js +2 -2
  155. package/dist/esm/taro-channel-live-core.entry.js +1 -1
  156. package/dist/esm/taro-channel-video-core.entry.js +1 -1
  157. package/dist/esm/taro-checkbox-core_2.entry.js +2 -2
  158. package/dist/esm/taro-comment-detail-core.entry.js +1 -1
  159. package/dist/esm/taro-comment-list-core.entry.js +1 -1
  160. package/dist/esm/taro-components.js +3 -3
  161. package/dist/esm/taro-contact-button-core.entry.js +1 -1
  162. package/dist/esm/taro-cover-image-core.entry.js +2 -2
  163. package/dist/esm/taro-cover-view-core.entry.js +2 -2
  164. package/dist/esm/taro-custom-wrapper-core.entry.js +1 -1
  165. package/dist/esm/taro-editor-core.entry.js +1 -1
  166. package/dist/esm/taro-follow-swan-core.entry.js +1 -1
  167. package/dist/esm/taro-form-core.entry.js +1 -1
  168. package/dist/esm/taro-functional-page-navigator-core.entry.js +1 -1
  169. package/dist/esm/taro-grid-view-core.entry.js +1 -1
  170. package/dist/esm/taro-icon-core.entry.js +5 -2
  171. package/dist/esm/taro-image-core.entry.js +7 -6
  172. package/dist/esm/taro-inline-payment-panel-core.entry.js +1 -1
  173. package/dist/esm/taro-input-core.entry.js +2 -2
  174. package/dist/esm/taro-keyboard-accessory-core.entry.js +1 -1
  175. package/dist/esm/taro-label-core.entry.js +1 -1
  176. package/dist/esm/taro-lifestyle-core.entry.js +1 -1
  177. package/dist/esm/taro-like-core.entry.js +1 -1
  178. package/dist/esm/taro-list-view-core.entry.js +1 -1
  179. package/dist/esm/taro-live-player-core.entry.js +1 -1
  180. package/dist/esm/taro-live-pusher-core.entry.js +1 -1
  181. package/dist/esm/taro-login-core.entry.js +1 -1
  182. package/dist/esm/taro-lottie-core.entry.js +1 -1
  183. package/dist/esm/taro-map-core.entry.js +1 -1
  184. package/dist/esm/taro-match-media-core.entry.js +1 -1
  185. package/dist/esm/taro-movable-area-core_2.entry.js +4 -4
  186. package/dist/esm/taro-native-slot-core.entry.js +1 -1
  187. package/dist/esm/taro-navigation-bar-core.entry.js +1 -1
  188. package/dist/esm/taro-navigator-core.entry.js +2 -2
  189. package/dist/esm/taro-official-account-core.entry.js +1 -1
  190. package/dist/esm/taro-open-data-core.entry.js +1 -1
  191. package/dist/esm/taro-page-container-core.entry.js +1 -1
  192. package/dist/esm/taro-page-meta-core.entry.js +1 -1
  193. package/dist/esm/taro-picker-core_2.entry.js +3 -3
  194. package/dist/esm/taro-picker-view-column-core_2.entry.js +4 -4
  195. package/dist/esm/taro-progress-core.entry.js +4 -1
  196. package/dist/esm/taro-pull-to-refresh-core.entry.js +3 -3
  197. package/dist/esm/taro-radio-core_2.entry.js +1 -1
  198. package/dist/esm/taro-rich-text-core.entry.js +2 -2
  199. package/dist/esm/taro-root-portal-core.entry.js +1 -1
  200. package/dist/esm/taro-rtc-room-core.entry.js +1 -1
  201. package/dist/esm/taro-rtc-room-item-core.entry.js +1 -1
  202. package/dist/esm/taro-scroll-view-core.entry.js +3 -3
  203. package/dist/esm/taro-share-element-core.entry.js +1 -1
  204. package/dist/esm/taro-slider-core.entry.js +4 -1
  205. package/dist/esm/taro-slot-core.entry.js +1 -1
  206. package/dist/esm/taro-snapshot-core.entry.js +1 -1
  207. package/dist/esm/taro-sticky-header-core.entry.js +1 -1
  208. package/dist/esm/taro-sticky-section-core.entry.js +1 -1
  209. package/dist/esm/taro-swiper-core_2.entry.js +5 -9853
  210. package/dist/esm/taro-switch-core.entry.js +13 -12
  211. package/dist/esm/taro-tab-item-core.entry.js +1 -1
  212. package/dist/esm/taro-tabbar.entry.js +5 -78
  213. package/dist/esm/taro-tabs-core.entry.js +1 -1
  214. package/dist/esm/taro-text-core.entry.js +2 -2
  215. package/dist/esm/taro-textarea-core.entry.js +12 -3
  216. package/dist/esm/taro-video-control_3.entry.js +4 -4
  217. package/dist/esm/taro-view-core.entry.js +3 -3
  218. package/dist/esm/taro-voip-room-core.entry.js +1 -1
  219. package/dist/esm/taro-web-view-core.entry.js +2 -2
  220. package/dist/esm-es5/index-486e187e.js +2 -0
  221. package/dist/esm-es5/loader.js +1 -1
  222. package/dist/esm-es5/taro-ad-core.entry.js +1 -1
  223. package/dist/esm-es5/taro-ad-custom-core.entry.js +1 -1
  224. package/dist/esm-es5/taro-animation-video-core.entry.js +1 -1
  225. package/dist/esm-es5/taro-animation-view-core.entry.js +1 -1
  226. package/dist/esm-es5/taro-ar-camera-core.entry.js +1 -1
  227. package/dist/esm-es5/taro-audio-core.entry.js +1 -1
  228. package/dist/esm-es5/taro-aweme-data-core.entry.js +1 -1
  229. package/dist/esm-es5/taro-block-core.entry.js +1 -1
  230. package/dist/esm-es5/taro-button-core.entry.js +1 -1
  231. package/dist/esm-es5/taro-camera-core.entry.js +1 -1
  232. package/dist/esm-es5/taro-canvas-core.entry.js +1 -1
  233. package/dist/esm-es5/taro-channel-live-core.entry.js +1 -1
  234. package/dist/esm-es5/taro-channel-video-core.entry.js +1 -1
  235. package/dist/esm-es5/taro-checkbox-core_2.entry.js +1 -1
  236. package/dist/esm-es5/taro-comment-detail-core.entry.js +1 -1
  237. package/dist/esm-es5/taro-comment-list-core.entry.js +1 -1
  238. package/dist/esm-es5/taro-components.js +1 -1
  239. package/dist/esm-es5/taro-contact-button-core.entry.js +1 -1
  240. package/dist/esm-es5/taro-cover-image-core.entry.js +1 -1
  241. package/dist/esm-es5/taro-cover-view-core.entry.js +1 -1
  242. package/dist/esm-es5/taro-custom-wrapper-core.entry.js +1 -1
  243. package/dist/esm-es5/taro-editor-core.entry.js +1 -1
  244. package/dist/esm-es5/taro-follow-swan-core.entry.js +1 -1
  245. package/dist/esm-es5/taro-form-core.entry.js +1 -1
  246. package/dist/esm-es5/taro-functional-page-navigator-core.entry.js +1 -1
  247. package/dist/esm-es5/taro-grid-view-core.entry.js +1 -1
  248. package/dist/esm-es5/taro-icon-core.entry.js +1 -1
  249. package/dist/esm-es5/taro-image-core.entry.js +1 -1
  250. package/dist/esm-es5/taro-inline-payment-panel-core.entry.js +1 -1
  251. package/dist/esm-es5/taro-input-core.entry.js +1 -1
  252. package/dist/esm-es5/taro-keyboard-accessory-core.entry.js +1 -1
  253. package/dist/esm-es5/taro-label-core.entry.js +1 -1
  254. package/dist/esm-es5/taro-lifestyle-core.entry.js +1 -1
  255. package/dist/esm-es5/taro-like-core.entry.js +1 -1
  256. package/dist/esm-es5/taro-list-view-core.entry.js +1 -1
  257. package/dist/esm-es5/taro-live-player-core.entry.js +1 -1
  258. package/dist/esm-es5/taro-live-pusher-core.entry.js +1 -1
  259. package/dist/esm-es5/taro-login-core.entry.js +1 -1
  260. package/dist/esm-es5/taro-lottie-core.entry.js +1 -1
  261. package/dist/esm-es5/taro-map-core.entry.js +1 -1
  262. package/dist/esm-es5/taro-match-media-core.entry.js +1 -1
  263. package/dist/esm-es5/taro-movable-area-core_2.entry.js +1 -1
  264. package/dist/esm-es5/taro-native-slot-core.entry.js +1 -1
  265. package/dist/esm-es5/taro-navigation-bar-core.entry.js +1 -1
  266. package/dist/esm-es5/taro-navigator-core.entry.js +1 -1
  267. package/dist/esm-es5/taro-official-account-core.entry.js +1 -1
  268. package/dist/esm-es5/taro-open-data-core.entry.js +1 -1
  269. package/dist/esm-es5/taro-page-container-core.entry.js +1 -1
  270. package/dist/esm-es5/taro-page-meta-core.entry.js +1 -1
  271. package/dist/esm-es5/taro-picker-core_2.entry.js +1 -1
  272. package/dist/esm-es5/taro-picker-view-column-core_2.entry.js +1 -1
  273. package/dist/esm-es5/taro-progress-core.entry.js +1 -1
  274. package/dist/esm-es5/taro-pull-to-refresh-core.entry.js +1 -1
  275. package/dist/esm-es5/taro-radio-core_2.entry.js +1 -1
  276. package/dist/esm-es5/taro-rich-text-core.entry.js +1 -1
  277. package/dist/esm-es5/taro-root-portal-core.entry.js +1 -1
  278. package/dist/esm-es5/taro-rtc-room-core.entry.js +1 -1
  279. package/dist/esm-es5/taro-rtc-room-item-core.entry.js +1 -1
  280. package/dist/esm-es5/taro-scroll-view-core.entry.js +1 -1
  281. package/dist/esm-es5/taro-share-element-core.entry.js +1 -1
  282. package/dist/esm-es5/taro-slider-core.entry.js +1 -1
  283. package/dist/esm-es5/taro-slot-core.entry.js +1 -1
  284. package/dist/esm-es5/taro-snapshot-core.entry.js +1 -1
  285. package/dist/esm-es5/taro-sticky-header-core.entry.js +1 -1
  286. package/dist/esm-es5/taro-sticky-section-core.entry.js +1 -1
  287. package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
  288. package/dist/esm-es5/taro-switch-core.entry.js +1 -1
  289. package/dist/esm-es5/taro-tab-item-core.entry.js +1 -1
  290. package/dist/esm-es5/taro-tabbar.entry.js +1 -1
  291. package/dist/esm-es5/taro-tabs-core.entry.js +1 -1
  292. package/dist/esm-es5/taro-text-core.entry.js +1 -1
  293. package/dist/esm-es5/taro-textarea-core.entry.js +1 -1
  294. package/dist/esm-es5/taro-video-control_3.entry.js +1 -1
  295. package/dist/esm-es5/taro-view-core.entry.js +1 -1
  296. package/dist/esm-es5/taro-voip-room-core.entry.js +1 -1
  297. package/dist/esm-es5/taro-web-view-core.entry.js +1 -1
  298. package/dist/taro-components/{p-23f15c7b.entry.js → p-00d05751.entry.js} +1 -1
  299. package/dist/taro-components/{p-635fe530.system.entry.js → p-014534ca.system.entry.js} +1 -1
  300. package/dist/taro-components/{p-03538d40.system.entry.js → p-015b3025.system.entry.js} +1 -1
  301. package/dist/taro-components/{p-c3c69a95.system.entry.js → p-02dd30fa.system.entry.js} +1 -1
  302. package/dist/taro-components/{p-8d797863.system.entry.js → p-040f15f2.system.entry.js} +1 -1
  303. package/dist/taro-components/p-06cf6b18.system.entry.js +1 -0
  304. package/dist/taro-components/{p-dea67974.system.entry.js → p-07e94301.system.entry.js} +1 -1
  305. package/dist/taro-components/{p-680ba5a1.system.entry.js → p-0cf04b3d.system.entry.js} +1 -1
  306. package/dist/taro-components/p-0e3d8ada.entry.js +1 -0
  307. package/dist/taro-components/p-101f49dd.entry.js +1 -0
  308. package/dist/taro-components/{p-3aaf0fb7.system.entry.js → p-10d3c795.system.entry.js} +1 -1
  309. package/dist/taro-components/{p-4ff6ad99.system.entry.js → p-114f89d6.system.entry.js} +1 -1
  310. package/dist/taro-components/p-1182efdd.system.entry.js +1 -0
  311. package/dist/taro-components/{p-2713fc1a.entry.js → p-128f9eb0.entry.js} +1 -1
  312. package/dist/taro-components/p-16954dd6.entry.js +1 -0
  313. package/dist/taro-components/p-170ce205.system.entry.js +1 -0
  314. package/dist/taro-components/{p-aa1ea71b.system.entry.js → p-1b42ba7e.system.entry.js} +1 -1
  315. package/dist/taro-components/p-1ced140d.entry.js +1 -0
  316. package/dist/taro-components/p-1d25f4e3.entry.js +1 -0
  317. package/dist/taro-components/{p-b4e3f72e.system.entry.js → p-1e3d7899.system.entry.js} +1 -1
  318. package/dist/taro-components/{p-25fffbbe.system.entry.js → p-1ee83d63.system.entry.js} +1 -1
  319. package/dist/taro-components/{p-3d7626a9.system.entry.js → p-2059cbc0.system.entry.js} +1 -1
  320. package/dist/taro-components/{p-32b41faa.system.entry.js → p-205a0692.system.entry.js} +1 -1
  321. package/dist/taro-components/{p-d86ce035.system.entry.js → p-25bbf4aa.system.entry.js} +1 -1
  322. package/dist/taro-components/{p-c968ea43.system.entry.js → p-26545e4e.system.entry.js} +1 -1
  323. package/dist/taro-components/{p-d8f78d99.system.entry.js → p-28bf8423.system.entry.js} +1 -1
  324. package/dist/taro-components/{p-72d7fae0.system.entry.js → p-290fd78b.system.entry.js} +1 -1
  325. package/dist/taro-components/p-2bbdbe9c.system.entry.js +1 -0
  326. package/dist/taro-components/{p-1c1d9be8.entry.js → p-2d6d4850.entry.js} +1 -1
  327. package/dist/taro-components/{p-0780df27.entry.js → p-2dea35fd.entry.js} +1 -1
  328. package/dist/taro-components/p-2f403f7f.entry.js +1 -0
  329. package/dist/taro-components/p-2f683899.entry.js +1 -0
  330. package/dist/taro-components/{p-139d64f1.entry.js → p-30623371.entry.js} +1 -1
  331. package/dist/taro-components/{p-fdccd9b3.system.entry.js → p-34933f34.system.entry.js} +1 -1
  332. package/dist/taro-components/{p-346162b4.system.entry.js → p-352b6b6b.system.entry.js} +1 -1
  333. package/dist/taro-components/{p-e7232d54.system.entry.js → p-35e96af8.system.entry.js} +1 -1
  334. package/dist/taro-components/{p-7de7d96c.entry.js → p-37593ce7.entry.js} +1 -1
  335. package/dist/taro-components/{p-175edd50.entry.js → p-387f300a.entry.js} +1 -1
  336. package/dist/taro-components/p-3afbae36.entry.js +1 -0
  337. package/dist/taro-components/p-3bd04d38.entry.js +1 -0
  338. package/dist/taro-components/{p-6e1f0e6d.system.entry.js → p-3ca9aa19.system.entry.js} +1 -1
  339. package/dist/taro-components/{p-810b9a86.system.entry.js → p-3d76b46e.system.entry.js} +1 -1
  340. package/dist/taro-components/p-3dadbe4c.system.entry.js +1 -0
  341. package/dist/taro-components/{p-1ac9622e.entry.js → p-3e9bf572.entry.js} +1 -1
  342. package/dist/taro-components/p-4408d796.entry.js +1 -0
  343. package/dist/taro-components/{p-222573ad.entry.js → p-445810cb.entry.js} +1 -1
  344. package/dist/taro-components/p-449f60fa.entry.js +1 -0
  345. package/dist/taro-components/p-46661961.entry.js +1 -0
  346. package/dist/taro-components/{p-c7679d57.entry.js → p-48e5ddaa.entry.js} +1 -1
  347. package/dist/taro-components/{p-20e38f24.entry.js → p-4928ee37.entry.js} +1 -1
  348. package/dist/taro-components/p-4cbd26dd.entry.js +1 -0
  349. package/dist/taro-components/p-4e4ac1fe.system.entry.js +1 -0
  350. package/dist/taro-components/{p-8c93f3e0.entry.js → p-4e4cc6ab.entry.js} +1 -1
  351. package/dist/taro-components/{p-6d1e33e1.system.entry.js → p-50e1ba06.system.entry.js} +1 -1
  352. package/dist/taro-components/{p-a7ecb97a.entry.js → p-510a69b3.entry.js} +1 -1
  353. package/dist/taro-components/p-5307637c.system.entry.js +1 -0
  354. package/dist/taro-components/{p-1d3ed211.system.entry.js → p-54941baf.system.entry.js} +1 -1
  355. package/dist/taro-components/{p-fbc2b53e.entry.js → p-55be4215.entry.js} +1 -1
  356. package/dist/taro-components/{p-3708575b.system.entry.js → p-578f19ea.system.entry.js} +1 -1
  357. package/dist/taro-components/{p-abd51173.system.entry.js → p-581e844d.system.entry.js} +1 -1
  358. package/dist/taro-components/{p-7ad33036.system.entry.js → p-5a1bb2d3.system.entry.js} +1 -1
  359. package/dist/taro-components/p-5bb60b5e.entry.js +1 -0
  360. package/dist/taro-components/p-600d9210.entry.js +1 -0
  361. package/dist/taro-components/p-6066e633.entry.js +1 -0
  362. package/dist/taro-components/p-61cb688a.entry.js +1 -0
  363. package/dist/taro-components/{p-747bdbaa.system.entry.js → p-6229bb7d.system.entry.js} +1 -1
  364. package/dist/taro-components/p-64f5abce.entry.js +1 -0
  365. package/dist/taro-components/p-67ff5a50.system.entry.js +1 -0
  366. package/dist/taro-components/{p-b2ad9709.entry.js → p-69e747dc.entry.js} +1 -1
  367. package/dist/taro-components/{p-cdd48677.system.js → p-6bbb639a.system.js} +2 -2
  368. package/dist/taro-components/{p-e769cea4.system.entry.js → p-6cf765b7.system.entry.js} +1 -1
  369. package/dist/taro-components/{p-eab8a6b0.entry.js → p-6e9d509a.entry.js} +1 -1
  370. package/dist/taro-components/p-6f027b85.entry.js +1 -0
  371. package/dist/taro-components/{p-d81577b8.system.entry.js → p-72b954ce.system.entry.js} +1 -1
  372. package/dist/taro-components/p-74129eac.entry.js +1 -0
  373. package/dist/taro-components/{p-c2259653.system.entry.js → p-74b1be20.system.entry.js} +1 -1
  374. package/dist/taro-components/{p-46a9adcf.system.entry.js → p-758e3319.system.entry.js} +1 -1
  375. package/dist/taro-components/{p-9c566d7d.system.entry.js → p-75b927b4.system.entry.js} +1 -1
  376. package/dist/taro-components/{p-79b675c8.entry.js → p-764cd497.entry.js} +1 -1
  377. package/dist/taro-components/{p-028ad016.system.entry.js → p-7b6f6526.system.entry.js} +1 -1
  378. package/dist/taro-components/p-7bd1345f.entry.js +1 -0
  379. package/dist/taro-components/{p-1411cd2e.system.entry.js → p-7cecf08e.system.entry.js} +1 -1
  380. package/dist/taro-components/{p-58d410c6.system.entry.js → p-7f084a29.system.entry.js} +1 -1
  381. package/dist/taro-components/{p-1eb875d0.system.entry.js → p-80106cc2.system.entry.js} +1 -1
  382. package/dist/taro-components/p-80278124.entry.js +1 -0
  383. package/dist/taro-components/p-83699a53.entry.js +1 -0
  384. package/dist/taro-components/{p-b94dcfbe.entry.js → p-846aa5ec.entry.js} +1 -1
  385. package/dist/taro-components/p-861834ce.entry.js +1 -0
  386. package/dist/taro-components/{p-f232cf02.entry.js → p-870e0d9d.entry.js} +1 -1
  387. package/dist/taro-components/{p-70c81b7e.entry.js → p-87422c88.entry.js} +1 -1
  388. package/dist/taro-components/{p-bbbe728b.system.entry.js → p-88c5f0eb.system.entry.js} +1 -1
  389. package/dist/taro-components/{p-f43ba9ed.entry.js → p-8b70fd1d.entry.js} +1 -1
  390. package/dist/taro-components/p-8d437a7f.entry.js +1 -0
  391. package/dist/taro-components/{p-475f9ed3.system.entry.js → p-8df92f90.system.entry.js} +1 -1
  392. package/dist/taro-components/p-8e45a207.system.entry.js +1 -0
  393. package/dist/taro-components/p-92daad3f.system.entry.js +1 -0
  394. package/dist/taro-components/{p-443fe754.system.entry.js → p-940d41e9.system.entry.js} +1 -1
  395. package/dist/taro-components/p-95058ee1.entry.js +1 -0
  396. package/dist/taro-components/p-95e88e0f.entry.js +1 -0
  397. package/dist/taro-components/{p-9f5ebe09.system.entry.js → p-9623f19c.system.entry.js} +1 -1
  398. package/dist/taro-components/{p-6f45f110.entry.js → p-970623a1.entry.js} +1 -1
  399. package/dist/taro-components/p-9890bb7b.entry.js +1 -0
  400. package/dist/taro-components/{p-7e90dfef.js → p-98b1fc13.js} +2 -2
  401. package/dist/taro-components/{p-67dcb636.system.entry.js → p-9937cf08.system.entry.js} +1 -1
  402. package/dist/taro-components/{p-3967311b.system.entry.js → p-9a5bfa2a.system.entry.js} +1 -1
  403. package/dist/taro-components/{p-fff30a48.entry.js → p-9b4e5578.entry.js} +1 -1
  404. package/dist/taro-components/p-9e138188.entry.js +1 -0
  405. package/dist/taro-components/p-a17b1a7e.entry.js +1 -0
  406. package/dist/taro-components/p-a197cbae.system.entry.js +1 -0
  407. package/dist/taro-components/p-a2a70581.system.entry.js +1 -0
  408. package/dist/taro-components/{p-35160fd2.entry.js → p-a61e195b.entry.js} +1 -1
  409. package/dist/taro-components/p-a972aa1d.system.js +1 -0
  410. package/dist/taro-components/{p-deff0bb8.entry.js → p-ae128150.entry.js} +1 -1
  411. package/dist/taro-components/{p-039e15a4.system.entry.js → p-b04cdd9a.system.entry.js} +1 -1
  412. package/dist/taro-components/p-b317674b.entry.js +1 -0
  413. package/dist/taro-components/p-b6694eb3.system.entry.js +1 -0
  414. package/dist/taro-components/{p-edb9e04e.system.entry.js → p-b8858af9.system.entry.js} +1 -1
  415. package/dist/taro-components/p-b8e2465a.entry.js +1 -0
  416. package/dist/taro-components/{p-2339a4d3.entry.js → p-b9f19e77.entry.js} +1 -1
  417. package/dist/taro-components/{p-4cc2e06e.entry.js → p-ba195b39.entry.js} +1 -1
  418. package/dist/taro-components/{p-0b6e9013.system.entry.js → p-ba50342b.system.entry.js} +1 -1
  419. package/dist/taro-components/{p-f8970571.entry.js → p-bb712e32.entry.js} +1 -1
  420. package/dist/taro-components/p-bb87373d.entry.js +1 -0
  421. package/dist/taro-components/{p-8b604d50.entry.js → p-bba220a9.entry.js} +1 -1
  422. package/dist/taro-components/{p-6d7165eb.system.entry.js → p-bcf5d78a.system.entry.js} +1 -1
  423. package/dist/taro-components/p-bdd7b5a9.entry.js +1 -0
  424. package/dist/taro-components/p-bdee068b.system.entry.js +1 -0
  425. package/dist/taro-components/p-bf0d2c21.system.entry.js +1 -0
  426. package/dist/taro-components/{p-6c48d884.entry.js → p-c0f710ae.entry.js} +1 -1
  427. package/dist/taro-components/p-c11fcb25.system.entry.js +1 -0
  428. package/dist/taro-components/p-caba17c6.system.entry.js +1 -0
  429. package/dist/taro-components/{p-1f88349b.entry.js → p-cbc19d63.entry.js} +1 -1
  430. package/dist/taro-components/{p-7dee8f07.system.entry.js → p-d03136d7.system.entry.js} +1 -1
  431. package/dist/taro-components/p-d36f8c4f.entry.js +1 -0
  432. package/dist/taro-components/p-d60b66c2.entry.js +1 -0
  433. package/dist/taro-components/{p-178cb282.system.entry.js → p-d78ab2de.system.entry.js} +1 -1
  434. package/dist/taro-components/{p-cd34c92e.system.entry.js → p-dbb47d14.system.entry.js} +1 -1
  435. package/dist/taro-components/p-dc6db06e.system.entry.js +1 -0
  436. package/dist/taro-components/p-dc98486d.entry.js +1 -0
  437. package/dist/taro-components/p-dca5e9ee.entry.js +1 -0
  438. package/dist/taro-components/{p-e487b8b4.system.entry.js → p-de3e1cee.system.entry.js} +1 -1
  439. package/dist/taro-components/p-e09e8b51.system.entry.js +1 -0
  440. package/dist/taro-components/{p-1c95795d.entry.js → p-e1c2e636.entry.js} +1 -1
  441. package/dist/taro-components/{p-48c52124.entry.js → p-e25c2a22.entry.js} +1 -1
  442. package/dist/taro-components/{p-345cb56f.entry.js → p-e26c787b.entry.js} +1 -1
  443. package/dist/taro-components/p-e457a83a.system.entry.js +1 -0
  444. package/dist/taro-components/{p-aae38fe8.entry.js → p-e7d82e00.entry.js} +1 -1
  445. package/dist/taro-components/{p-f094089c.system.entry.js → p-ebf38559.system.entry.js} +1 -1
  446. package/dist/taro-components/p-eeb6aeb5.system.entry.js +1 -0
  447. package/dist/taro-components/p-ef0aff29.entry.js +1 -0
  448. package/dist/taro-components/{p-feddde29.system.entry.js → p-f554428f.system.entry.js} +1 -1
  449. package/dist/taro-components/p-fd1d75db.entry.js +1 -0
  450. package/dist/taro-components/{p-18ea7e10.system.entry.js → p-ff7dfc5c.system.entry.js} +1 -1
  451. package/dist/taro-components/taro-components.css +1 -5
  452. package/dist/taro-components/taro-components.esm.js +1 -1
  453. package/dist/taro-components/taro-components.js +1 -1
  454. package/dist/types/components/switch/switch.d.ts +3 -3
  455. package/dist/types/components/textarea/textarea.d.ts +1 -0
  456. package/lib/react/react-component-lib/createComponent.js +3 -2
  457. package/lib/react/react-component-lib/createComponent.js.map +1 -1
  458. package/lib/react/react-component-lib/createOverlayComponent.js +1 -1
  459. package/lib/react/react-component-lib/utils/attachProps.d.ts +16 -7
  460. package/lib/react/react-component-lib/utils/attachProps.js +85 -9
  461. package/lib/react/react-component-lib/utils/attachProps.js.map +1 -1
  462. package/lib/react/react-component-lib/utils/index.js +1 -1
  463. package/lib/vue2/components-loader.js +1 -1
  464. package/package.json +12 -10
  465. package/types/Audio.d.ts +11 -11
  466. package/types/Button.d.ts +9 -9
  467. package/types/Canvas.d.ts +11 -11
  468. package/types/Checkbox.d.ts +8 -8
  469. package/types/CheckboxGroup.d.ts +3 -3
  470. package/types/CoverImage.d.ts +4 -4
  471. package/types/CoverView.d.ts +1 -1
  472. package/types/CustomWrapper.d.ts +1 -1
  473. package/types/Form.d.ts +4 -4
  474. package/types/Icon.d.ts +4 -4
  475. package/types/Image.d.ts +8 -8
  476. package/types/Input.d.ts +21 -17
  477. package/types/Label.d.ts +2 -2
  478. package/types/MovableArea.d.ts +2 -2
  479. package/types/MovableView.d.ts +18 -18
  480. package/types/NativeSlot.d.ts +1 -1
  481. package/types/Navigator.d.ts +8 -8
  482. package/types/Picker.d.ts +44 -28
  483. package/types/PickerView.d.ts +5 -1
  484. package/types/PickerViewColumn.d.ts +1 -1
  485. package/types/Progress.d.ts +13 -13
  486. package/types/Radio.d.ts +7 -7
  487. package/types/RadioGroup.d.ts +2 -2
  488. package/types/RichText.d.ts +5 -5
  489. package/types/ScrollView.d.ts +13 -13
  490. package/types/Slider.d.ts +18 -14
  491. package/types/Slot.d.ts +1 -1
  492. package/types/Swiper.d.ts +17 -17
  493. package/types/SwiperItem.d.ts +2 -2
  494. package/types/Switch.d.ts +11 -7
  495. package/types/Text.d.ts +4 -4
  496. package/types/Textarea.d.ts +17 -13
  497. package/types/Video.d.ts +30 -30
  498. package/types/View.d.ts +4 -4
  499. package/types/WebView.d.ts +4 -4
  500. package/types/common.d.ts +6 -1
  501. package/dist/cjs/hls-dfcad743.js +0 -25797
  502. package/dist/cjs/intersection-observer-dc4cfcef.js +0 -728
  503. package/dist/collection/components/input/index.css +0 -12
  504. package/dist/components/hls.js +0 -25795
  505. package/dist/components/intersection-observer.js +0 -726
  506. package/dist/esm/hls-268fc25b.js +0 -25795
  507. package/dist/esm/intersection-observer-8e4c7135.js +0 -726
  508. package/dist/esm-es5/hls-268fc25b.js +0 -1
  509. package/dist/esm-es5/index-6bb77c5f.js +0 -2
  510. package/dist/esm-es5/intersection-observer-8e4c7135.js +0 -1
  511. package/dist/taro-components/p-00113225.system.entry.js +0 -1
  512. package/dist/taro-components/p-0030841b.system.js +0 -1
  513. package/dist/taro-components/p-0910d414.entry.js +0 -1
  514. package/dist/taro-components/p-0e37fb54.entry.js +0 -1
  515. package/dist/taro-components/p-11c962b9.entry.js +0 -1
  516. package/dist/taro-components/p-1f36cd5f.entry.js +0 -1
  517. package/dist/taro-components/p-2145dccb.entry.js +0 -1
  518. package/dist/taro-components/p-215881b4.entry.js +0 -1
  519. package/dist/taro-components/p-277892fe.system.entry.js +0 -1
  520. package/dist/taro-components/p-27c756c5.system.entry.js +0 -1
  521. package/dist/taro-components/p-2aff4cdb.entry.js +0 -1
  522. package/dist/taro-components/p-2e2487bf.system.entry.js +0 -1
  523. package/dist/taro-components/p-332dc867.entry.js +0 -1
  524. package/dist/taro-components/p-333305e3.entry.js +0 -1
  525. package/dist/taro-components/p-37edf3f6.entry.js +0 -1
  526. package/dist/taro-components/p-3ad92100.system.entry.js +0 -1
  527. package/dist/taro-components/p-3b1d2d37.system.js +0 -1
  528. package/dist/taro-components/p-3cd71da3.system.entry.js +0 -1
  529. package/dist/taro-components/p-401743f9.system.entry.js +0 -1
  530. package/dist/taro-components/p-4aeb3859.system.entry.js +0 -1
  531. package/dist/taro-components/p-4d609ebb.system.entry.js +0 -1
  532. package/dist/taro-components/p-4d89b685.entry.js +0 -1
  533. package/dist/taro-components/p-527c55ca.entry.js +0 -1
  534. package/dist/taro-components/p-550c350a.entry.js +0 -1
  535. package/dist/taro-components/p-5b028f1b.js +0 -1
  536. package/dist/taro-components/p-619b9fe5.system.entry.js +0 -1
  537. package/dist/taro-components/p-6df6fd58.entry.js +0 -1
  538. package/dist/taro-components/p-6f5e162d.entry.js +0 -1
  539. package/dist/taro-components/p-70bd0541.entry.js +0 -1
  540. package/dist/taro-components/p-728b6f8f.system.entry.js +0 -1
  541. package/dist/taro-components/p-72f327e1.js +0 -1
  542. package/dist/taro-components/p-7b39971e.system.entry.js +0 -1
  543. package/dist/taro-components/p-7ba17143.entry.js +0 -1
  544. package/dist/taro-components/p-7be1f603.entry.js +0 -1
  545. package/dist/taro-components/p-817b319c.system.entry.js +0 -1
  546. package/dist/taro-components/p-907d2fe0.entry.js +0 -1
  547. package/dist/taro-components/p-93a3d6ee.entry.js +0 -1
  548. package/dist/taro-components/p-9c91aee3.system.entry.js +0 -1
  549. package/dist/taro-components/p-9e788d33.entry.js +0 -1
  550. package/dist/taro-components/p-9feeee0f.system.entry.js +0 -1
  551. package/dist/taro-components/p-a3dad439.entry.js +0 -1
  552. package/dist/taro-components/p-a4ea7a51.system.entry.js +0 -1
  553. package/dist/taro-components/p-a54735cb.entry.js +0 -1
  554. package/dist/taro-components/p-a5adbf15.system.entry.js +0 -1
  555. package/dist/taro-components/p-a744e7aa.entry.js +0 -1
  556. package/dist/taro-components/p-b1977132.entry.js +0 -1
  557. package/dist/taro-components/p-b3780eab.system.entry.js +0 -1
  558. package/dist/taro-components/p-b69bcd43.entry.js +0 -1
  559. package/dist/taro-components/p-b9c2a210.system.entry.js +0 -1
  560. package/dist/taro-components/p-bb454378.entry.js +0 -1
  561. package/dist/taro-components/p-bd6574cf.entry.js +0 -1
  562. package/dist/taro-components/p-bfea77f9.entry.js +0 -1
  563. package/dist/taro-components/p-c0a59843.entry.js +0 -1
  564. package/dist/taro-components/p-cb21f4f1.entry.js +0 -1
  565. package/dist/taro-components/p-cd0f3444.entry.js +0 -1
  566. package/dist/taro-components/p-d42968e9.system.entry.js +0 -1
  567. package/dist/taro-components/p-d55f870d.entry.js +0 -1
  568. package/dist/taro-components/p-daabfc6e.entry.js +0 -1
  569. package/dist/taro-components/p-dda03c84.entry.js +0 -1
  570. package/dist/taro-components/p-e6e3c1d7.entry.js +0 -1
  571. package/dist/taro-components/p-e82e16a1.entry.js +0 -1
  572. package/dist/taro-components/p-ee4da4db.system.js +0 -1
  573. package/dist/taro-components/p-f003caad.entry.js +0 -1
  574. package/dist/taro-components/p-f111303f.entry.js +0 -1
  575. package/dist/taro-components/p-f75d094e.system.entry.js +0 -1
  576. package/dist/taro-components/p-fbec1f96.entry.js +0 -1
  577. package/lib/react/node_modules/.pnpm/tslib@2.6.2/node_modules/tslib/tslib.es6.js +0 -373
  578. package/lib/react/node_modules/.pnpm/tslib@2.6.2/node_modules/tslib/tslib.es6.js.map +0 -1
  579. /package/dist/cjs/{index-b8c435ee.js → index-f6805218.js} +0 -0
  580. /package/dist/esm/{index-a74b6944.js → index-c3e4004b.js} +0 -0
  581. /package/dist/esm-es5/{index-a74b6944.js → index-c3e4004b.js} +0 -0
  582. /package/dist/taro-components/{p-34de4101.system.js → p-2ec68968.system.js} +0 -0
  583. /package/dist/taro-components/{p-19f218e6.js → p-de951a46.js} +0 -0
  584. /package/lib/vue2/node_modules/.pnpm/{vue-fragment@1.6.0_vue@2.7.15 → registry.npmjs.org_vue-fragment@1.6.0_vue@2.7.14}/node_modules/vue-fragment/dist/vue-fragment.esm.js +0 -0
  585. /package/lib/vue2/node_modules/.pnpm/{vue-fragment@1.6.0_vue@2.7.15 → registry.npmjs.org_vue-fragment@1.6.0_vue@2.7.14}/node_modules/vue-fragment/dist/vue-fragment.esm.js.map +0 -0
@@ -1 +0,0 @@
1
- var __extends=this&&this.__extends||function(){var e=function(t,r){e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r))e[r]=t[r]};return e(t,r)};return function(t,r){if(typeof r!=="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function i(){this.constructor=t}t.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}}();var __spreadArray=this&&this.__spreadArray||function(e,t,r){if(r||arguments.length===2)for(var i=0,a=t.length,n;i<a;i++){if(n||!(i in t)){if(!n)n=Array.prototype.slice.call(t,0,i);n[i]=t[i]}}return e.concat(n||Array.prototype.slice.call(t))};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var urlToolkit={exports:{}};(function(e,t){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;var i=/^(?=([^\/?#]*))\1([^]*)$/;var a=/(?:\/|^)\.(?=\/)/g;var n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g;var s={buildAbsoluteURL:function(e,t,r){r=r||{};e=e.trim();t=t.trim();if(!t){if(!r.alwaysNormalize){return e}var a=s.parseURL(e);if(!a){throw new Error("Error trying to parse base URL.")}a.path=s.normalizePath(a.path);return s.buildURLFromParts(a)}var n=s.parseURL(t);if(!n){throw new Error("Error trying to parse relative URL.")}if(n.scheme){if(!r.alwaysNormalize){return t}n.path=s.normalizePath(n.path);return s.buildURLFromParts(n)}var o=s.parseURL(e);if(!o){throw new Error("Error trying to parse base URL.")}if(!o.netLoc&&o.path&&o.path[0]!=="/"){var l=i.exec(o.path);o.netLoc=l[1];o.path=l[2]}if(o.netLoc&&!o.path){o.path="/"}var u={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc){u.netLoc=o.netLoc;if(n.path[0]!=="/"){if(!n.path){u.path=o.path;if(!n.params){u.params=o.params;if(!n.query){u.query=o.query}}}else{var f=o.path;var c=f.substring(0,f.lastIndexOf("/")+1)+n.path;u.path=s.normalizePath(c)}}}if(u.path===null){u.path=r.alwaysNormalize?s.normalizePath(n.path):n.path}return s.buildURLFromParts(u)},parseURL:function(e){var t=r.exec(e);if(!t){return null}return{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}},normalizePath:function(e){e=e.split("").reverse().join("").replace(a,"");while(e.length!==(e=e.replace(n,"")).length){}return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=s})()})(urlToolkit);var urlToolkitExports=urlToolkit.exports;function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){t=_toPropertyKey(t);if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function _extends(){_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(Object.prototype.hasOwnProperty.call(r,i)){e[i]=r[i]}}}return e};return _extends.apply(this,arguments)}function _toPrimitive(e,t){if(typeof e!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==undefined){var i=r.call(e,t||"default");if(typeof i!=="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return typeof t==="symbol"?t:String(t)}var isFiniteNumber=Number.isFinite||function(e){return typeof e==="number"&&isFinite(e)};var isSafeInteger=Number.isSafeInteger||function(e){return typeof e==="number"&&Math.abs(e)<=MAX_SAFE_INTEGER};var MAX_SAFE_INTEGER=Number.MAX_SAFE_INTEGER||9007199254740991;var Events=function(e){e["MEDIA_ATTACHING"]="hlsMediaAttaching";e["MEDIA_ATTACHED"]="hlsMediaAttached";e["MEDIA_DETACHING"]="hlsMediaDetaching";e["MEDIA_DETACHED"]="hlsMediaDetached";e["BUFFER_RESET"]="hlsBufferReset";e["BUFFER_CODECS"]="hlsBufferCodecs";e["BUFFER_CREATED"]="hlsBufferCreated";e["BUFFER_APPENDING"]="hlsBufferAppending";e["BUFFER_APPENDED"]="hlsBufferAppended";e["BUFFER_EOS"]="hlsBufferEos";e["BUFFER_FLUSHING"]="hlsBufferFlushing";e["BUFFER_FLUSHED"]="hlsBufferFlushed";e["MANIFEST_LOADING"]="hlsManifestLoading";e["MANIFEST_LOADED"]="hlsManifestLoaded";e["MANIFEST_PARSED"]="hlsManifestParsed";e["LEVEL_SWITCHING"]="hlsLevelSwitching";e["LEVEL_SWITCHED"]="hlsLevelSwitched";e["LEVEL_LOADING"]="hlsLevelLoading";e["LEVEL_LOADED"]="hlsLevelLoaded";e["LEVEL_UPDATED"]="hlsLevelUpdated";e["LEVEL_PTS_UPDATED"]="hlsLevelPtsUpdated";e["LEVELS_UPDATED"]="hlsLevelsUpdated";e["AUDIO_TRACKS_UPDATED"]="hlsAudioTracksUpdated";e["AUDIO_TRACK_SWITCHING"]="hlsAudioTrackSwitching";e["AUDIO_TRACK_SWITCHED"]="hlsAudioTrackSwitched";e["AUDIO_TRACK_LOADING"]="hlsAudioTrackLoading";e["AUDIO_TRACK_LOADED"]="hlsAudioTrackLoaded";e["SUBTITLE_TRACKS_UPDATED"]="hlsSubtitleTracksUpdated";e["SUBTITLE_TRACKS_CLEARED"]="hlsSubtitleTracksCleared";e["SUBTITLE_TRACK_SWITCH"]="hlsSubtitleTrackSwitch";e["SUBTITLE_TRACK_LOADING"]="hlsSubtitleTrackLoading";e["SUBTITLE_TRACK_LOADED"]="hlsSubtitleTrackLoaded";e["SUBTITLE_FRAG_PROCESSED"]="hlsSubtitleFragProcessed";e["CUES_PARSED"]="hlsCuesParsed";e["NON_NATIVE_TEXT_TRACKS_FOUND"]="hlsNonNativeTextTracksFound";e["INIT_PTS_FOUND"]="hlsInitPtsFound";e["FRAG_LOADING"]="hlsFragLoading";e["FRAG_LOAD_EMERGENCY_ABORTED"]="hlsFragLoadEmergencyAborted";e["FRAG_LOADED"]="hlsFragLoaded";e["FRAG_DECRYPTED"]="hlsFragDecrypted";e["FRAG_PARSING_INIT_SEGMENT"]="hlsFragParsingInitSegment";e["FRAG_PARSING_USERDATA"]="hlsFragParsingUserdata";e["FRAG_PARSING_METADATA"]="hlsFragParsingMetadata";e["FRAG_PARSED"]="hlsFragParsed";e["FRAG_BUFFERED"]="hlsFragBuffered";e["FRAG_CHANGED"]="hlsFragChanged";e["FPS_DROP"]="hlsFpsDrop";e["FPS_DROP_LEVEL_CAPPING"]="hlsFpsDropLevelCapping";e["ERROR"]="hlsError";e["DESTROYING"]="hlsDestroying";e["KEY_LOADING"]="hlsKeyLoading";e["KEY_LOADED"]="hlsKeyLoaded";e["LIVE_BACK_BUFFER_REACHED"]="hlsLiveBackBufferReached";e["BACK_BUFFER_REACHED"]="hlsBackBufferReached";return e}({});var ErrorTypes=function(e){e["NETWORK_ERROR"]="networkError";e["MEDIA_ERROR"]="mediaError";e["KEY_SYSTEM_ERROR"]="keySystemError";e["MUX_ERROR"]="muxError";e["OTHER_ERROR"]="otherError";return e}({});var ErrorDetails=function(e){e["KEY_SYSTEM_NO_KEYS"]="keySystemNoKeys";e["KEY_SYSTEM_NO_ACCESS"]="keySystemNoAccess";e["KEY_SYSTEM_NO_SESSION"]="keySystemNoSession";e["KEY_SYSTEM_NO_CONFIGURED_LICENSE"]="keySystemNoConfiguredLicense";e["KEY_SYSTEM_LICENSE_REQUEST_FAILED"]="keySystemLicenseRequestFailed";e["KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED"]="keySystemServerCertificateRequestFailed";e["KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED"]="keySystemServerCertificateUpdateFailed";e["KEY_SYSTEM_SESSION_UPDATE_FAILED"]="keySystemSessionUpdateFailed";e["KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED"]="keySystemStatusOutputRestricted";e["KEY_SYSTEM_STATUS_INTERNAL_ERROR"]="keySystemStatusInternalError";e["MANIFEST_LOAD_ERROR"]="manifestLoadError";e["MANIFEST_LOAD_TIMEOUT"]="manifestLoadTimeOut";e["MANIFEST_PARSING_ERROR"]="manifestParsingError";e["MANIFEST_INCOMPATIBLE_CODECS_ERROR"]="manifestIncompatibleCodecsError";e["LEVEL_EMPTY_ERROR"]="levelEmptyError";e["LEVEL_LOAD_ERROR"]="levelLoadError";e["LEVEL_LOAD_TIMEOUT"]="levelLoadTimeOut";e["LEVEL_PARSING_ERROR"]="levelParsingError";e["LEVEL_SWITCH_ERROR"]="levelSwitchError";e["AUDIO_TRACK_LOAD_ERROR"]="audioTrackLoadError";e["AUDIO_TRACK_LOAD_TIMEOUT"]="audioTrackLoadTimeOut";e["SUBTITLE_LOAD_ERROR"]="subtitleTrackLoadError";e["SUBTITLE_TRACK_LOAD_TIMEOUT"]="subtitleTrackLoadTimeOut";e["FRAG_LOAD_ERROR"]="fragLoadError";e["FRAG_LOAD_TIMEOUT"]="fragLoadTimeOut";e["FRAG_DECRYPT_ERROR"]="fragDecryptError";e["FRAG_PARSING_ERROR"]="fragParsingError";e["FRAG_GAP"]="fragGap";e["REMUX_ALLOC_ERROR"]="remuxAllocError";e["KEY_LOAD_ERROR"]="keyLoadError";e["KEY_LOAD_TIMEOUT"]="keyLoadTimeOut";e["BUFFER_ADD_CODEC_ERROR"]="bufferAddCodecError";e["BUFFER_INCOMPATIBLE_CODECS_ERROR"]="bufferIncompatibleCodecsError";e["BUFFER_APPEND_ERROR"]="bufferAppendError";e["BUFFER_APPENDING_ERROR"]="bufferAppendingError";e["BUFFER_STALLED_ERROR"]="bufferStalledError";e["BUFFER_FULL_ERROR"]="bufferFullError";e["BUFFER_SEEK_OVER_HOLE"]="bufferSeekOverHole";e["BUFFER_NUDGE_ON_STALL"]="bufferNudgeOnStall";e["INTERNAL_EXCEPTION"]="internalException";e["INTERNAL_ABORTED"]="aborted";e["UNKNOWN"]="unknown";return e}({});var noop=function e(){};var fakeLogger={trace:noop,debug:noop,log:noop,warn:noop,info:noop,error:noop};var exportedLogger=fakeLogger;function consolePrintFn(e){var t=self.console[e];if(t){return t.bind(self.console,"[".concat(e,"] >"))}return noop}function exportLoggerFunctions(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}t.forEach((function(t){exportedLogger[t]=e[t]?e[t].bind(e):consolePrintFn(t)}))}function enableLogs(e,t){if(self.console&&e===true||typeof e==="object"){exportLoggerFunctions(e,"debug","log","info","warn","error");try{exportedLogger.log('Debug logs enabled for "'.concat(t,'" in hls.js version ').concat("1.4.13"))}catch(e){exportedLogger=fakeLogger}}else{exportedLogger=fakeLogger}}var logger=exportedLogger;var DECIMAL_RESOLUTION_REGEX=/^(\d+)x(\d+)$/;var ATTR_LIST_REGEX=/(.+?)=(".*?"|.*?)(?:,|$)/g;var AttrList=function(){function e(t){if(typeof t==="string"){t=e.parseAttrList(t)}for(var r in t){if(t.hasOwnProperty(r)){if(r.substring(0,2)==="X-"){this.clientAttrs=this.clientAttrs||[];this.clientAttrs.push(r)}this[r]=t[r]}}}e.prototype.decimalInteger=function(e){var t=parseInt(this[e],10);if(t>Number.MAX_SAFE_INTEGER){return Infinity}return t};e.prototype.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;var r=new Uint8Array(t.length/2);for(var i=0;i<t.length/2;i++){r[i]=parseInt(t.slice(i*2,i*2+2),16)}return r}else{return null}};e.prototype.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);if(t>Number.MAX_SAFE_INTEGER){return Infinity}return t};e.prototype.decimalFloatingPoint=function(e){return parseFloat(this[e])};e.prototype.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t};e.prototype.enumeratedString=function(e){return this[e]};e.prototype.bool=function(e){return this[e]==="YES"};e.prototype.decimalResolution=function(e){var t=DECIMAL_RESOLUTION_REGEX.exec(this[e]);if(t===null){return undefined}return{width:parseInt(t[1],10),height:parseInt(t[2],10)}};e.parseAttrList=function(e){var t;var r={};var i='"';ATTR_LIST_REGEX.lastIndex=0;while((t=ATTR_LIST_REGEX.exec(e))!==null){var a=t[2];if(a.indexOf(i)===0&&a.lastIndexOf(i)===a.length-1){a=a.slice(1,-1)}var n=t[1].trim();r[n]=a}return r};return e}();function isDateRangeCueAttribute(e){return e!=="ID"&&e!=="CLASS"&&e!=="START-DATE"&&e!=="DURATION"&&e!=="END-DATE"&&e!=="END-ON-NEXT"}function isSCTE35Attribute(e){return e==="SCTE35-OUT"||e==="SCTE35-IN"}var DateRange=function(){function e(e,t){this.attr=void 0;this._startDate=void 0;this._endDate=void 0;this._badValueForSameId=void 0;if(t){var r=t.attr;for(var i in r){if(Object.prototype.hasOwnProperty.call(e,i)&&e[i]!==r[i]){logger.warn('DATERANGE tag attribute: "'.concat(i,'" does not match for tags with ID: "').concat(e.ID,'"'));this._badValueForSameId=i;break}}e=_extends(new AttrList({}),r,e)}this.attr=e;this._startDate=new Date(e["START-DATE"]);if("END-DATE"in this.attr){var a=new Date(this.attr["END-DATE"]);if(isFiniteNumber(a.getTime())){this._endDate=a}}}Object.defineProperty(e.prototype,"id",{get:function(){return this.attr.ID},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"class",{get:function(){return this.attr.CLASS},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"startDate",{get:function(){return this._startDate},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"endDate",{get:function(){if(this._endDate){return this._endDate}var e=this.duration;if(e!==null){return new Date(this._startDate.getTime()+e*1e3)}return null},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"duration",{get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(isFiniteNumber(e)){return e}}else if(this._endDate){return(this._endDate.getTime()-this._startDate.getTime())/1e3}return null},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"plannedDuration",{get:function(){if("PLANNED-DURATION"in this.attr){return this.attr.decimalFloatingPoint("PLANNED-DURATION")}return null},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"endOnNext",{get:function(){return this.attr.bool("END-ON-NEXT")},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"isValid",{get:function(){return!!this.id&&!this._badValueForSameId&&isFiniteNumber(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)},enumerable:false,configurable:true});return e}();var LoadStats=function(){function e(){this.aborted=false;this.loaded=0;this.retry=0;this.total=0;this.chunkCount=0;this.bwEstimate=0;this.loading={start:0,first:0,end:0};this.parsing={start:0,end:0};this.buffering={start:0,first:0,end:0}}return e}();var ElementaryStreamTypes={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};var BaseSegment=function(){function e(e){var t;this._byteRange=null;this._url=null;this.baseurl=void 0;this.relurl=void 0;this.elementaryStreams=(t={},t[ElementaryStreamTypes.AUDIO]=null,t[ElementaryStreamTypes.VIDEO]=null,t[ElementaryStreamTypes.AUDIOVIDEO]=null,t);this.baseurl=e}e.prototype.setByteRange=function(e,t){var r=e.split("@",2);var i=[];if(r.length===1){i[0]=t?t.byteRangeEndOffset:0}else{i[0]=parseInt(r[1])}i[1]=parseInt(r[0])+i[0];this._byteRange=i};Object.defineProperty(e.prototype,"byteRange",{get:function(){if(!this._byteRange){return[]}return this._byteRange},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"byteRangeStartOffset",{get:function(){return this.byteRange[0]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"byteRangeEndOffset",{get:function(){return this.byteRange[1]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"url",{get:function(){if(!this._url&&this.baseurl&&this.relurl){this._url=urlToolkitExports.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:true})}return this._url||""},set:function(e){this._url=e},enumerable:false,configurable:true});return e}();var Fragment=function(e){__extends(t,e);function t(t,r){var i=e.call(this,r)||this;i._decryptdata=null;i.rawProgramDateTime=null;i.programDateTime=null;i.tagList=[];i.duration=0;i.sn=0;i.levelkeys=void 0;i.type=void 0;i.loader=null;i.keyLoader=null;i.level=-1;i.cc=0;i.startPTS=void 0;i.endPTS=void 0;i.startDTS=void 0;i.endDTS=void 0;i.start=0;i.deltaPTS=void 0;i.maxStartPTS=void 0;i.minEndPTS=void 0;i.stats=new LoadStats;i.urlId=0;i.data=void 0;i.bitrateTest=false;i.title=null;i.initSegment=null;i.endList=void 0;i.gap=void 0;i.type=t;return i}Object.defineProperty(t.prototype,"decryptdata",{get:function(){var e=this.levelkeys;if(!e&&!this._decryptdata){return null}if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t){this._decryptdata=t.getDecryptData(this.sn)}else{var r=Object.keys(this.levelkeys);if(r.length===1){return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}}return this._decryptdata},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"end",{get:function(){return this.start+this.duration},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"endProgramDateTime",{get:function(){if(this.programDateTime===null){return null}if(!isFiniteNumber(this.programDateTime)){return null}var e=!isFiniteNumber(this.duration)?0:this.duration;return this.programDateTime+e*1e3},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"encrypted",{get:function(){var e;if((e=this._decryptdata)!=null&&e.encrypted){return true}else if(this.levelkeys){var t=Object.keys(this.levelkeys);var r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted){return true}}return false},enumerable:false,configurable:true});t.prototype.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];if(t&&!this._decryptdata){this._decryptdata=t.getDecryptData(this.sn)}}};t.prototype.abortRequests=function(){var e,t;(e=this.loader)==null?void 0:e.abort();(t=this.keyLoader)==null?void 0:t.abort()};t.prototype.setElementaryStreamInfo=function(e,t,r,i,a,n){if(n===void 0){n=false}var s=this.elementaryStreams;var o=s[e];if(!o){s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:a,partial:n};return}o.startPTS=Math.min(o.startPTS,t);o.endPTS=Math.max(o.endPTS,r);o.startDTS=Math.min(o.startDTS,i);o.endDTS=Math.max(o.endDTS,a)};t.prototype.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[ElementaryStreamTypes.AUDIO]=null;e[ElementaryStreamTypes.VIDEO]=null;e[ElementaryStreamTypes.AUDIOVIDEO]=null};return t}(BaseSegment);var Part=function(e){__extends(t,e);function t(t,r,i,a,n){var s=e.call(this,i)||this;s.fragOffset=0;s.duration=0;s.gap=false;s.independent=false;s.relurl=void 0;s.fragment=void 0;s.index=void 0;s.stats=new LoadStats;s.duration=t.decimalFloatingPoint("DURATION");s.gap=t.bool("GAP");s.independent=t.bool("INDEPENDENT");s.relurl=t.enumeratedString("URI");s.fragment=r;s.index=a;var o=t.enumeratedString("BYTERANGE");if(o){s.setByteRange(o,n)}if(n){s.fragOffset=n.fragOffset+n.duration}return s}Object.defineProperty(t.prototype,"start",{get:function(){return this.fragment.start+this.fragOffset},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"end",{get:function(){return this.start+this.duration},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"loaded",{get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)},enumerable:false,configurable:true});return t}(BaseSegment);var DEFAULT_TARGET_DURATION=10;var LevelDetails=function(){function e(e){this.PTSKnown=false;this.alignedSliding=false;this.averagetargetduration=void 0;this.endCC=0;this.endSN=0;this.fragments=void 0;this.fragmentHint=void 0;this.partList=null;this.dateRanges=void 0;this.live=true;this.ageHeader=0;this.advancedDateTime=void 0;this.updated=true;this.advanced=true;this.availabilityDelay=void 0;this.misses=0;this.startCC=0;this.startSN=0;this.startTimeOffset=null;this.targetduration=0;this.totalduration=0;this.type=null;this.url=void 0;this.m3u8="";this.version=null;this.canBlockReload=false;this.canSkipUntil=0;this.canSkipDateRanges=false;this.skippedSegments=0;this.recentlyRemovedDateranges=void 0;this.partHoldBack=0;this.holdBack=0;this.partTarget=0;this.preloadHint=void 0;this.renditionReports=void 0;this.tuneInGoal=0;this.deltaUpdateFailed=void 0;this.driftStartTime=0;this.driftEndTime=0;this.driftStart=0;this.driftEnd=0;this.encryptedFragments=void 0;this.playlistParsingError=null;this.variableList=null;this.hasVariableRefs=false;this.fragments=[];this.encryptedFragments=[];this.dateRanges={};this.url=e}e.prototype.reloaded=function(e){if(!e){this.advanced=true;this.updated=true;return}var t=this.lastPartSn-e.lastPartSn;var r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live;this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0;if(this.updated||this.advanced){this.misses=Math.floor(e.misses*.6)}else{this.misses=e.misses+1}this.availabilityDelay=e.availabilityDelay};Object.defineProperty(e.prototype,"hasProgramDateTime",{get:function(){if(this.fragments.length){return isFiniteNumber(this.fragments[this.fragments.length-1].programDateTime)}return false},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"levelTargetDuration",{get:function(){return this.averagetargetduration||this.targetduration||DEFAULT_TARGET_DURATION},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"drift",{get:function(){var e=this.driftEndTime-this.driftStartTime;if(e>0){var t=this.driftEnd-this.driftStart;return t*1e3/e}return 1},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"edge",{get:function(){return this.partEnd||this.fragmentEnd},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"partEnd",{get:function(){var e;if((e=this.partList)!=null&&e.length){return this.partList[this.partList.length-1].end}return this.fragmentEnd},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"fragmentEnd",{get:function(){var e;if((e=this.fragments)!=null&&e.length){return this.fragments[this.fragments.length-1].end}return 0},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"age",{get:function(){if(this.advancedDateTime){return Math.max(Date.now()-this.advancedDateTime,0)/1e3}return 0},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"lastPartIndex",{get:function(){var e;if((e=this.partList)!=null&&e.length){return this.partList[this.partList.length-1].index}return-1},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"lastPartSn",{get:function(){var e;if((e=this.partList)!=null&&e.length){return this.partList[this.partList.length-1].fragment.sn}return this.endSN},enumerable:false,configurable:true});return e}();function base64Decode(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function getKeyIdBytes(e){var t=strToUtf8array(e).subarray(0,16);var r=new Uint8Array(16);r.set(t,16-t.length);return r}function changeEndianness(e){var t=function e(t,r,i){var a=t[r];t[r]=t[i];t[i]=a};t(e,0,3);t(e,1,2);t(e,4,5);t(e,6,7)}function convertDataUriToArrayBytes(e){var t=e.split(":");var r=null;if(t[0]==="data"&&t.length===2){var i=t[1].split(";");var a=i[i.length-1].split(",");if(a.length===2){var n=a[0]==="base64";var s=a[1];if(n){i.splice(-1,1);r=base64Decode(s)}else{r=getKeyIdBytes(s)}}}return r}function strToUtf8array(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}var KeySystems={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"};var KeySystemFormats={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function keySystemFormatToKeySystemDomain(e){switch(e){case KeySystemFormats.FAIRPLAY:return KeySystems.FAIRPLAY;case KeySystemFormats.PLAYREADY:return KeySystems.PLAYREADY;case KeySystemFormats.WIDEVINE:return KeySystems.WIDEVINE;case KeySystemFormats.CLEARKEY:return KeySystems.CLEARKEY}}var KeySystemIds={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function keySystemIdToKeySystemDomain(e){if(e===KeySystemIds.WIDEVINE){return KeySystems.WIDEVINE}}function keySystemDomainToKeySystemFormat(e){switch(e){case KeySystems.FAIRPLAY:return KeySystemFormats.FAIRPLAY;case KeySystems.PLAYREADY:return KeySystemFormats.PLAYREADY;case KeySystems.WIDEVINE:return KeySystemFormats.WIDEVINE;case KeySystems.CLEARKEY:return KeySystemFormats.CLEARKEY}}function getKeySystemsForConfig(e){var t=e.drmSystems,r=e.widevineLicenseUrl;var i=t?[KeySystems.FAIRPLAY,KeySystems.WIDEVINE,KeySystems.PLAYREADY,KeySystems.CLEARKEY].filter((function(e){return!!t[e]})):[];if(!i[KeySystems.WIDEVINE]&&r){i.push(KeySystems.WIDEVINE)}return i}var requestMediaKeySystemAccess=function(){if(typeof self!=="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess){return self.navigator.requestMediaKeySystemAccess.bind(self.navigator)}else{return null}}();function getSupportedMediaKeySystemConfigurations(e,t,r,i){var a;switch(e){case KeySystems.FAIRPLAY:a=["cenc","sinf"];break;case KeySystems.WIDEVINE:case KeySystems.PLAYREADY:a=["cenc"];break;case KeySystems.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return createMediaKeySystemConfigurations(a,t,r,i)}function createMediaKeySystemConfigurations(e,t,r,i){var a={initDataTypes:e,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map((function(e){return{contentType:'audio/mp4; codecs="'.concat(e,'"'),robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:r.map((function(e){return{contentType:'video/mp4; codecs="'.concat(e,'"'),robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))};return[a]}function sliceUint8(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}var isHeader$2=function(e,t){if(t+10<=e.length){if(e[t]===73&&e[t+1]===68&&e[t+2]===51){if(e[t+3]<255&&e[t+4]<255){if(e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128){return true}}}}return false};var isFooter=function(e,t){if(t+10<=e.length){if(e[t]===51&&e[t+1]===68&&e[t+2]===73){if(e[t+3]<255&&e[t+4]<255){if(e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128){return true}}}}return false};var getID3Data=function(e,t){var r=t;var i=0;while(isHeader$2(e,t)){i+=10;var a=readSize(e,t+6);i+=a;if(isFooter(e,t+10)){i+=10}t+=i}if(i>0){return e.subarray(r,r+i)}return undefined};var readSize=function(e,t){var r=0;r=(e[t]&127)<<21;r|=(e[t+1]&127)<<14;r|=(e[t+2]&127)<<7;r|=e[t+3]&127;return r};var canParse$2=function(e,t){return isHeader$2(e,t)&&readSize(e,t+6)+10<=e.length-t};var getTimeStamp=function(e){var t=getID3Frames(e);for(var r=0;r<t.length;r++){var i=t[r];if(isTimeStampFrame(i)){return readTimeStamp(i)}}return undefined};var isTimeStampFrame=function(e){return e&&e.key==="PRIV"&&e.info==="com.apple.streaming.transportStreamTimestamp"};var getFrameData=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]);var r=readSize(e,4);var i=10;return{type:t,size:r,data:e.subarray(i,i+r)}};var getID3Frames=function(e){var t=0;var r=[];while(isHeader$2(e,t)){var i=readSize(e,t+6);t+=10;var a=t+i;while(t+8<a){var n=getFrameData(e.subarray(t));var s=decodeFrame(n);if(s){r.push(s)}t+=n.size+10}if(isFooter(e,t)){t+=10}}return r};var decodeFrame=function(e){if(e.type==="PRIV"){return decodePrivFrame(e)}else if(e.type[0]==="W"){return decodeURLFrame(e)}return decodeTextFrame(e)};var decodePrivFrame=function(e){if(e.size<2){return undefined}var t=utf8ArrayToStr(e.data,true);var r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}};var decodeTextFrame=function(e){if(e.size<2){return undefined}if(e.type==="TXXX"){var t=1;var r=utf8ArrayToStr(e.data.subarray(t),true);t+=r.length+1;var i=utf8ArrayToStr(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=utf8ArrayToStr(e.data.subarray(1));return{key:e.type,data:a}};var decodeURLFrame=function(e){if(e.type==="WXXX"){if(e.size<2){return undefined}var t=1;var r=utf8ArrayToStr(e.data.subarray(t),true);t+=r.length+1;var i=utf8ArrayToStr(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=utf8ArrayToStr(e.data);return{key:e.type,data:a}};var readTimeStamp=function(e){if(e.data.byteLength===8){var t=new Uint8Array(e.data);var r=t[3]&1;var i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];i/=45;if(r){i+=47721858.84}return Math.round(i)}return undefined};var utf8ArrayToStr=function(e,t){if(t===void 0){t=false}var r=getTextDecoder();if(r){var i=r.decode(e);if(t){var a=i.indexOf("\0");return a!==-1?i.substring(0,a):i}return i.replace(/\0/g,"")}var n=e.length;var s;var o;var l;var u="";var f=0;while(f<n){s=e[f++];if(s===0&&t){return u}else if(s===0||s===3){continue}switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(s);break;case 12:case 13:o=e[f++];u+=String.fromCharCode((s&31)<<6|o&63);break;case 14:o=e[f++];l=e[f++];u+=String.fromCharCode((s&15)<<12|(o&63)<<6|(l&63)<<0);break}}return u};var decoder;function getTextDecoder(){if(!decoder&&typeof self.TextDecoder!=="undefined"){decoder=new self.TextDecoder("utf-8")}return decoder}var Hex={hexDump:function(e){var t="";for(var r=0;r<e.length;r++){var i=e[r].toString(16);if(i.length<2){i="0"+i}t+=i}return t}};var UINT32_MAX$1=Math.pow(2,32)-1;var push=[].push;var RemuxerTrackIdConfig={video:1,audio:2,id3:3,text:4};function bin2str(e){return String.fromCharCode.apply(null,e)}function readUint16(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function readUint32(e,t){var r=readSint32(e,t);return r<0?4294967296+r:r}function readSint32(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function writeUint32(e,t,r){e[t]=r>>24;e[t+1]=r>>16&255;e[t+2]=r>>8&255;e[t+3]=r&255}function findBox(e,t){var r=[];if(!t.length){return r}var i=e.byteLength;for(var a=0;a<i;){var n=readUint32(e,a);var s=bin2str(e.subarray(a+4,a+8));var o=n>1?a+n:i;if(s===t[0]){if(t.length===1){r.push(e.subarray(a+8,o))}else{var l=findBox(e.subarray(a+8,o),t.slice(1));if(l.length){push.apply(r,l)}}}a=o}return r}function parseSegmentIndex(e){var t=[];var r=e[0];var i=8;var a=readUint32(e,i);i+=4;var n=0;var s=0;if(r===0){i+=8}else{i+=16}i+=2;var o=e.length+s;var l=readUint16(e,i);i+=2;for(var u=0;u<l;u++){var f=i;var c=readUint32(e,f);f+=4;var d=c&2147483647;var h=(c&2147483648)>>>31;if(h===1){logger.warn("SIDX has hierarchical references (not supported)");return null}var v=readUint32(e,f);f+=4;t.push({referenceSize:d,subsegmentDuration:v,info:{duration:v/a,start:o,end:o+d-1}});o+=d;f+=4;i=f}return{earliestPresentationTime:n,timescale:a,version:r,referencesCount:l,references:t}}function parseInitSegment(e){var t=[];var r=findBox(e,["moov","trak"]);for(var i=0;i<r.length;i++){var a=r[i];var n=findBox(a,["tkhd"])[0];if(n){var s=n[0];var o=s===0?12:20;var l=readUint32(n,o);var u=findBox(a,["mdia","mdhd"])[0];if(u){s=u[0];o=s===0?12:20;var f=readUint32(u,o);var c=findBox(a,["mdia","hdlr"])[0];if(c){var d=bin2str(c.subarray(8,12));var h={soun:ElementaryStreamTypes.AUDIO,vide:ElementaryStreamTypes.VIDEO}[d];if(h){var v=findBox(a,["mdia","minf","stbl","stsd"])[0];var p=void 0;if(v){p=bin2str(v.subarray(12,16))}t[l]={timescale:f,type:h};t[h]={timescale:f,id:l,codec:p}}}}}}var g=findBox(e,["moov","mvex","trex"]);g.forEach((function(e){var r=readUint32(e,4);var i=t[r];if(i){i.default={duration:readUint32(e,12),flags:readUint32(e,20)}}}));return t}function patchEncyptionData(e,t){if(!e||!t){return e}var r=t.keyId;if(r&&t.isCommonEncryption){var i=findBox(e,["moov","trak"]);i.forEach((function(e){var t=findBox(e,["mdia","minf","stbl","stsd"])[0];var i=t.subarray(8);var a=findBox(i,["enca"]);var n=a.length>0;if(!n){a=findBox(i,["encv"])}a.forEach((function(e){var t=n?e.subarray(28):e.subarray(78);var i=findBox(t,["sinf"]);i.forEach((function(e){var t=parseSinf(e);if(t){var i=t.subarray(8,24);if(!i.some((function(e){return e!==0}))){logger.log("[eme] Patching keyId in 'enc".concat(n?"a":"v",">sinf>>tenc' box: ").concat(Hex.hexDump(i)," -> ").concat(Hex.hexDump(r)));t.set(r,8)}}}))}))}))}return e}function parseSinf(e){var t=findBox(e,["schm"])[0];if(t){var r=bin2str(t.subarray(4,8));if(r==="cbcs"||r==="cenc"){return findBox(e,["schi","tenc"])[0]}}logger.error("[eme] missing 'schm' box");return null}function getStartDTS(e,t){return findBox(t,["moof","traf"]).reduce((function(t,r){var i=findBox(r,["tfdt"])[0];var a=i[0];var n=findBox(r,["tfhd"]).reduce((function(t,r){var n=readUint32(r,4);var s=e[n];if(s){var o=readUint32(i,4);if(a===1){if(o===UINT32_MAX$1){logger.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time");return t}o*=UINT32_MAX$1+1;o+=readUint32(i,8)}var l=s.timescale||9e4;var u=o/l;if(isFiniteNumber(u)&&(t===null||u<t)){return u}}return t}),null);if(n!==null&&isFiniteNumber(n)&&(t===null||n<t)){return n}return t}),null)}function getDuration(e,t){var r=0;var i=0;var a=0;var n=findBox(e,["moof","traf"]);for(var s=0;s<n.length;s++){var o=n[s];var l=findBox(o,["tfhd"])[0];var u=readUint32(l,4);var f=t[u];if(!f){continue}var c=f.default;var d=readUint32(l,0)|(c==null?void 0:c.flags);var h=c==null?void 0:c.duration;if(d&8){if(d&2){h=readUint32(l,12)}else{h=readUint32(l,8)}}var v=f.timescale||9e4;var p=findBox(o,["trun"]);for(var g=0;g<p.length;g++){r=computeRawDurationFromSamples(p[g]);if(!r&&h){var m=readUint32(p[g],4);r=h*m}if(f.type===ElementaryStreamTypes.VIDEO){i+=r/v}else if(f.type===ElementaryStreamTypes.AUDIO){a+=r/v}}}if(i===0&&a===0){var y=0;var E=findBox(e,["sidx"]);for(var s=0;s<E.length;s++){var T=parseSegmentIndex(E[s]);if(T!=null&&T.references){y+=T.references.reduce((function(e,t){return e+t.info.duration||0}),0)}}return y}if(i){return i}return a}function computeRawDurationFromSamples(e){var t=readUint32(e,0);var r=8;if(t&1){r+=4}if(t&4){r+=4}var i=0;var a=readUint32(e,4);for(var n=0;n<a;n++){if(t&256){var s=readUint32(e,r);i+=s;r+=4}if(t&512){r+=4}if(t&1024){r+=4}if(t&2048){r+=4}}return i}function offsetStartDTS(e,t,r){findBox(t,["moof","traf"]).forEach((function(t){findBox(t,["tfhd"]).forEach((function(i){var a=readUint32(i,4);var n=e[a];if(!n){return}var s=n.timescale||9e4;findBox(t,["tfdt"]).forEach((function(e){var t=e[0];var i=readUint32(e,4);if(t===0){i-=r*s;i=Math.max(i,0);writeUint32(e,4,i)}else{i*=Math.pow(2,32);i+=readUint32(e,8);i-=r*s;i=Math.max(i,0);var a=Math.floor(i/(UINT32_MAX$1+1));var n=Math.floor(i%(UINT32_MAX$1+1));writeUint32(e,4,a);writeUint32(e,8,n)}}))}))}))}function segmentValidRange(e){var t={valid:null,remainder:null};var r=findBox(e,["moof"]);if(!r){return t}else if(r.length<2){t.remainder=e;return t}var i=r[r.length-1];t.valid=sliceUint8(e,0,i.byteOffset-8);t.remainder=sliceUint8(e,i.byteOffset-8);return t}function appendUint8Array(e,t){var r=new Uint8Array(e.length+t.length);r.set(e);r.set(t,e.length);return r}function parseSamples(e,t){var r=[];var i=t.samples;var a=t.timescale;var n=t.id;var s=false;var o=findBox(i,["moof"]);o.map((function(o){var l=o.byteOffset-8;var u=findBox(o,["traf"]);u.map((function(o){var u=findBox(o,["tfdt"]).map((function(e){var t=e[0];var r=readUint32(e,4);if(t===1){r*=Math.pow(2,32);r+=readUint32(e,8)}return r/a}))[0];if(u!==undefined){e=u}return findBox(o,["tfhd"]).map((function(u){var f=readUint32(u,4);var c=readUint32(u,0)&16777215;var d=(c&1)!==0;var h=(c&2)!==0;var v=(c&8)!==0;var p=0;var g=(c&16)!==0;var m=0;var y=(c&32)!==0;var E=8;if(f===n){if(d){E+=8}if(h){E+=4}if(v){p=readUint32(u,E);E+=4}if(g){m=readUint32(u,E);E+=4}if(y){E+=4}if(t.type==="video"){s=isHEVC(t.codec)}findBox(o,["trun"]).map((function(n){var o=n[0];var u=readUint32(n,0)&16777215;var f=(u&1)!==0;var c=0;var d=(u&4)!==0;var h=(u&256)!==0;var v=0;var g=(u&512)!==0;var y=0;var E=(u&1024)!==0;var T=(u&2048)!==0;var S=0;var A=readUint32(n,4);var L=8;if(f){c=readUint32(n,L);L+=4}if(d){L+=4}var b=c+l;for(var R=0;R<A;R++){if(h){v=readUint32(n,L);L+=4}else{v=p}if(g){y=readUint32(n,L);L+=4}else{y=m}if(E){L+=4}if(T){if(o===0){S=readUint32(n,L)}else{S=readSint32(n,L)}L+=4}if(t.type===ElementaryStreamTypes.VIDEO){var D=0;while(D<y){var I=readUint32(i,b);b+=4;if(isSEIMessage(s,i[b])){var C=i.subarray(b,b+I);parseSEIMessageFromNALu(C,s?2:1,e+S/a,r)}b+=I;D+=I+4}}e+=v/a}}))}}))}))}));return r}function isHEVC(e){if(!e){return false}var t=e.indexOf(".");var r=t<0?e:e.substring(0,t);return r==="hvc1"||r==="hev1"||r==="dvh1"||r==="dvhe"}function isSEIMessage(e,t){if(e){var r=t>>1&63;return r===39||r===40}else{var r=t&31;return r===6}}function parseSEIMessageFromNALu(e,t,r,i){var a=discardEPB(e);var n=0;n+=t;var s=0;var o=0;var l=false;var u=0;while(n<a.length){s=0;do{if(n>=a.length){break}u=a[n++];s+=u}while(u===255);o=0;do{if(n>=a.length){break}u=a[n++];o+=u}while(u===255);var f=a.length-n;if(!l&&s===4&&n<a.length){l=true;var c=a[n++];if(c===181){var d=readUint16(a,n);n+=2;if(d===49){var h=readUint32(a,n);n+=4;if(h===1195456820){var v=a[n++];if(v===3){var p=a[n++];var g=31&p;var m=64&p;var y=m?2+g*3:0;var E=new Uint8Array(y);if(m){E[0]=p;for(var T=1;T<y;T++){E[T]=a[n++]}}i.push({type:v,payloadType:s,pts:r,bytes:E})}}}}}else if(s===5&&o<f){l=true;if(o>16){var S=[];for(var T=0;T<16;T++){var A=a[n++].toString(16);S.push(A.length==1?"0"+A:A);if(T===3||T===5||T===7||T===9){S.push("-")}}var L=o-16;var b=new Uint8Array(L);for(var T=0;T<L;T++){b[T]=a[n++]}i.push({payloadType:s,pts:r,uuid:S.join(""),userData:utf8ArrayToStr(b),userDataBytes:b})}}else if(o<f){n+=o}else if(o>f){break}}}function discardEPB(e){var t=e.byteLength;var r=[];var i=1;while(i<t-2){if(e[i]===0&&e[i+1]===0&&e[i+2]===3){r.push(i+2);i+=2}else{i++}}if(r.length===0){return e}var a=t-r.length;var n=new Uint8Array(a);var s=0;for(i=0;i<a;s++,i++){if(s===r[0]){s++;r.shift()}n[i]=e[s]}return n}function parseEmsg(e){var t=e[0];var r="";var i="";var a=0;var n=0;var s=0;var o=0;var l=0;var u=0;if(t===0){while(bin2str(e.subarray(u,u+1))!=="\0"){r+=bin2str(e.subarray(u,u+1));u+=1}r+=bin2str(e.subarray(u,u+1));u+=1;while(bin2str(e.subarray(u,u+1))!=="\0"){i+=bin2str(e.subarray(u,u+1));u+=1}i+=bin2str(e.subarray(u,u+1));u+=1;a=readUint32(e,12);n=readUint32(e,16);o=readUint32(e,20);l=readUint32(e,24);u=28}else if(t===1){u+=4;a=readUint32(e,u);u+=4;var f=readUint32(e,u);u+=4;var c=readUint32(e,u);u+=4;s=Math.pow(2,32)*f+c;if(!isSafeInteger(s)){s=Number.MAX_SAFE_INTEGER;logger.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")}o=readUint32(e,u);u+=4;l=readUint32(e,u);u+=4;while(bin2str(e.subarray(u,u+1))!=="\0"){r+=bin2str(e.subarray(u,u+1));u+=1}r+=bin2str(e.subarray(u,u+1));u+=1;while(bin2str(e.subarray(u,u+1))!=="\0"){i+=bin2str(e.subarray(u,u+1));u+=1}i+=bin2str(e.subarray(u,u+1));u+=1}var d=e.subarray(u,e.byteLength);return{schemeIdUri:r,value:i,timeScale:a,presentationTime:s,presentationTimeDelta:n,eventDuration:o,id:l,payload:d}}function mp4Box(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}var i=t.length;var a=8;var n=i;while(n--){a+=t[n].byteLength}var s=new Uint8Array(a);s[0]=a>>24&255;s[1]=a>>16&255;s[2]=a>>8&255;s[3]=a&255;s.set(e,4);for(n=0,a=8;n<i;n++){s.set(t[n],a);a+=t[n].byteLength}return s}function mp4pssh(e,t,r){if(e.byteLength!==16){throw new RangeError("Invalid system id")}var i;var a;if(t){i=1;a=new Uint8Array(t.length*16);for(var n=0;n<t.length;n++){var s=t[n];if(s.byteLength!==16){throw new RangeError("Invalid key")}a.set(s,n*16)}}else{i=0;a=new Uint8Array}var o;if(i>0){o=new Uint8Array(4);if(t.length>0){new DataView(o.buffer).setUint32(0,t.length,false)}}else{o=new Uint8Array}var l=new Uint8Array(4);if(r&&r.byteLength>0){new DataView(l.buffer).setUint32(0,r.byteLength,false)}return mp4Box([112,115,115,104],new Uint8Array([i,0,0,0]),e,o,a,l,r||new Uint8Array)}function parsePssh(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32){return null}var t={version:0,systemId:"",kids:null,data:null};var r=new DataView(e);var i=r.getUint32(0);if(e.byteLength!==i&&i>44){return null}var a=r.getUint32(4);if(a!==1886614376){return null}t.version=r.getUint32(8)>>>24;if(t.version>1){return null}t.systemId=Hex.hexDump(new Uint8Array(e,12,16));var n=r.getUint32(28);if(t.version===0){if(i-32<n){return null}t.data=new Uint8Array(e,32,n)}else if(t.version===1){t.kids=[];for(var s=0;s<n;s++){t.kids.push(new Uint8Array(e,32+s*16,16))}}return t}var keyUriToKeyIdMap={};var LevelKey=function(){function e(e,t,r,i,a){if(i===void 0){i=[1]}if(a===void 0){a=null}this.uri=void 0;this.method=void 0;this.keyFormat=void 0;this.keyFormatVersions=void 0;this.encrypted=void 0;this.isCommonEncryption=void 0;this.iv=null;this.key=null;this.keyId=null;this.pssh=null;this.method=e;this.uri=t;this.keyFormat=r;this.keyFormatVersions=i;this.iv=a;this.encrypted=e?e!=="NONE":false;this.isCommonEncryption=this.encrypted&&e!=="AES-128"}e.clearKeyUriToKeyIdMap=function(){keyUriToKeyIdMap={}};e.prototype.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE"){return true}if(this.keyFormat==="identity"){return this.method==="SAMPLE-AES"}else{switch(this.keyFormat){case KeySystemFormats.FAIRPLAY:case KeySystemFormats.WIDEVINE:case KeySystemFormats.PLAYREADY:case KeySystemFormats.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}}return false};e.prototype.getDecryptData=function(t){if(!this.encrypted||!this.uri){return null}if(this.method==="AES-128"&&this.uri&&!this.iv){if(typeof t!=="number"){if(this.method==="AES-128"&&!this.iv){logger.warn('missing IV for initialization segment with method="'.concat(this.method,'" - compliance issue'))}t=0}var r=createInitializationVector(t);var i=new e(this.method,this.uri,"identity",this.keyFormatVersions,r);return i}var a=convertDataUriToArrayBytes(this.uri);if(a){switch(this.keyFormat){case KeySystemFormats.WIDEVINE:this.pssh=a;if(a.length>=22){this.keyId=a.subarray(a.length-22,a.length-6)}break;case KeySystemFormats.PLAYREADY:{var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=mp4pssh(n,null,a);var s=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2);var o=String.fromCharCode.apply(null,Array.from(s));var l=o.substring(o.indexOf("<"),o.length);var u=new DOMParser;var f=u.parseFromString(l,"text/xml");var c=f.getElementsByTagName("KID")[0];if(c){var d=c.childNodes[0]?c.childNodes[0].nodeValue:c.getAttribute("VALUE");if(d){var h=base64Decode(d).subarray(0,16);changeEndianness(h);this.keyId=h}}break}default:{var v=a.subarray(0,16);if(v.length!==16){var p=new Uint8Array(16);p.set(v,16-v.length);v=p}this.keyId=v;break}}}if(!this.keyId||this.keyId.byteLength!==16){var d=keyUriToKeyIdMap[this.uri];if(!d){var g=Object.keys(keyUriToKeyIdMap).length%Number.MAX_SAFE_INTEGER;d=new Uint8Array(16);var m=new DataView(d.buffer,12,4);m.setUint32(0,g);keyUriToKeyIdMap[this.uri]=d}this.keyId=d}return this};return e}();function createInitializationVector(e){var t=new Uint8Array(16);for(var r=12;r<16;r++){t[r]=e>>8*(15-r)&255}return t}var VARIABLE_REPLACEMENT_REGEX=/\{\$([a-zA-Z0-9-_]+)\}/g;function hasVariableReferences(e){return VARIABLE_REPLACEMENT_REGEX.test(e)}function substituteVariablesInAttributes(e,t,r){if(e.variableList!==null||e.hasVariableRefs){for(var i=r.length;i--;){var a=r[i];var n=t[a];if(n){t[a]=substituteVariables(e,n)}}}}function substituteVariables(e,t){if(e.variableList!==null||e.hasVariableRefs){var r=e.variableList;return t.replace(VARIABLE_REPLACEMENT_REGEX,(function(t){var i=t.substring(2,t.length-1);var a=r==null?void 0:r[i];if(a===undefined){e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'.concat(i,'"')));return t}return a}))}return t}function addVariableDefinition(e,t,r){var i=e.variableList;if(!i){e.variableList=i={}}var a;var n;if("QUERYPARAM"in t){a=t.QUERYPARAM;try{var s=new self.URL(r).searchParams;if(s.has(a)){n=s.get(a)}else{throw new Error('"'.concat(a,'" does not match any query parameter in URI: "').concat(r,'"'))}}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(t.message)))}}else{a=t.NAME;n=t.VALUE}if(a in i){e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'.concat(a,'"')))}else{i[a]=n||""}}function importVariableDefinition(e,t,r){var i=t.IMPORT;if(r&&i in r){var a=e.variableList;if(!a){e.variableList=a={}}a[i]=r[i]}else{e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'.concat(i,'"')))}}function getMediaSource(){if(typeof self==="undefined")return undefined;return self.MediaSource||self.WebKitMediaSource}var sampleEntryCodesISO={audio:{a3ds:true,"ac-3":true,"ac-4":true,alac:true,alaw:true,dra1:true,"dts+":true,"dts-":true,dtsc:true,dtse:true,dtsh:true,"ec-3":true,enca:true,g719:true,g726:true,m4ae:true,mha1:true,mha2:true,mhm1:true,mhm2:true,mlpa:true,mp4a:true,"raw ":true,Opus:true,opus:true,samr:true,sawb:true,sawp:true,sevc:true,sqcp:true,ssmv:true,twos:true,ulaw:true},video:{avc1:true,avc2:true,avc3:true,avc4:true,avcp:true,av01:true,drac:true,dva1:true,dvav:true,dvh1:true,dvhe:true,encv:true,hev1:true,hvc1:true,mjp2:true,mp4v:true,mvc1:true,mvc2:true,mvc3:true,mvc4:true,resv:true,rv60:true,s263:true,svc1:true,svc2:true,"vc-1":true,vp08:true,vp09:true},text:{stpp:true,wvtt:true}};var MediaSource$2=getMediaSource();function isCodecType(e,t){var r=sampleEntryCodesISO[t];return!!r&&r[e.slice(0,4)]===true}function isCodecSupportedInMp4(e,t){var r;return(r=MediaSource$2==null?void 0:MediaSource$2.isTypeSupported("".concat(t||"video",'/mp4;codecs="').concat(e,'"')))!=null?r:false}var MASTER_PLAYLIST_REGEX=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g;var MASTER_PLAYLIST_MEDIA_REGEX=/#EXT-X-MEDIA:(.*)/g;var IS_MEDIA_PLAYLIST=/^#EXT(?:INF|-X-TARGETDURATION):/m;var LEVEL_PLAYLIST_REGEX_FAST=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g");var LEVEL_PLAYLIST_REGEX_SLOW=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));var M3U8Parser=function(){function e(){}e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t){return i}}};e.convertAVC1ToAVCOTI=function(e){var t=e.split(".");if(t.length>2){var r=t.shift()+".";r+=parseInt(t.shift()).toString(16);r+=("000"+parseInt(t.shift()).toString(16)).slice(-4);return r}return e};e.resolve=function(e,t){return urlToolkitExports.buildAbsoluteURL(t,e,{alwaysNormalize:true})};e.isMediaPlaylist=function(e){return IS_MEDIA_PLAYLIST.test(e)};e.parseMasterPlaylist=function(t,r){var i=hasVariableReferences(t);var a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i};var n=[];MASTER_PLAYLIST_REGEX.lastIndex=0;var s;while((s=MASTER_PLAYLIST_REGEX.exec(t))!=null){if(s[1]){var o;var l=new AttrList(s[1]);{substituteVariablesInAttributes(a,l,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"])}var u=substituteVariables(a,s[2]);var f={attrs:l,bitrate:l.decimalInteger("AVERAGE-BANDWIDTH")||l.decimalInteger("BANDWIDTH"),name:l.NAME,url:e.resolve(u,r)};var c=l.decimalResolution("RESOLUTION");if(c){f.width=c.width;f.height=c.height}setCodecs((l.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),f);if(f.videoCodec&&f.videoCodec.indexOf("avc1")!==-1){f.videoCodec=e.convertAVC1ToAVCOTI(f.videoCodec)}if(!((o=f.unknownCodecs)!=null&&o.length)){n.push(f)}a.levels.push(f)}else if(s[3]){var d=s[3];var h=s[4];switch(d){case"SESSION-DATA":{var v=new AttrList(h);{substituteVariablesInAttributes(a,v,["DATA-ID","LANGUAGE","VALUE","URI"])}var p=v["DATA-ID"];if(p){if(a.sessionData===null){a.sessionData={}}a.sessionData[p]=v}break}case"SESSION-KEY":{var g=parseKey(h,r,a);if(g.encrypted&&g.isSupported()){if(a.sessionKeys===null){a.sessionKeys=[]}a.sessionKeys.push(g)}else{logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(h,'"'))}break}case"DEFINE":{{var m=new AttrList(h);substituteVariablesInAttributes(a,m,["NAME","VALUE","QUERYPARAM"]);addVariableDefinition(a,m,r)}break}case"CONTENT-STEERING":{var y=new AttrList(h);{substituteVariablesInAttributes(a,y,["SERVER-URI","PATHWAY-ID"])}a.contentSteering={uri:e.resolve(y["SERVER-URI"],r),pathwayId:y["PATHWAY-ID"]||"."};break}case"START":{a.startTimeOffset=parseStartTimeOffset(h);break}}}}var E=n.length>0&&n.length<a.levels.length;a.levels=E?n:a.levels;if(a.levels.length===0){a.playlistParsingError=new Error("no levels found in manifest")}return a};e.parseMasterPlaylistMedia=function(t,r,i){var a;var n={};var s=i.levels;var o={AUDIO:s.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:s.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]};var l=0;MASTER_PLAYLIST_MEDIA_REGEX.lastIndex=0;while((a=MASTER_PLAYLIST_MEDIA_REGEX.exec(t))!==null){var u=new AttrList(a[1]);var f=u.TYPE;if(f){var c=o[f];var d=n[f]||[];n[f]=d;{substituteVariablesInAttributes(i,u,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"])}var h={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:f,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?e.resolve(u.URI,r):""};if(c!=null&&c.length){var v=e.findGroup(c,h.groupId)||c[0];assignCodec(h,v,"audioCodec");assignCodec(h,v,"textCodec")}d.push(h)}}return n};e.parseLevelPlaylist=function(e,t,r,i,a,n){var s=new LevelDetails(t);var o=s.fragments;var l=null;var u=0;var f=0;var c=0;var d=0;var h=null;var v=new Fragment(i,t);var p;var g;var m;var y=-1;var E=false;LEVEL_PLAYLIST_REGEX_FAST.lastIndex=0;s.m3u8=e;s.hasVariableRefs=hasVariableReferences(e);while((p=LEVEL_PLAYLIST_REGEX_FAST.exec(e))!==null){if(E){E=false;v=new Fragment(i,t);v.start=c;v.sn=u;v.cc=d;v.level=r;if(l){v.initSegment=l;v.rawProgramDateTime=l.rawProgramDateTime;l.rawProgramDateTime=null}}var T=p[1];if(T){v.duration=parseFloat(T);var S=(" "+p[2]).slice(1);v.title=S||null;v.tagList.push(S?["INF",T,S]:["INF",T])}else if(p[3]){if(isFiniteNumber(v.duration)){v.start=c;if(m){setFragLevelKeys(v,m,s)}v.sn=u;v.level=r;v.cc=d;v.urlId=a;o.push(v);var A=(" "+p[3]).slice(1);v.relurl=substituteVariables(s,A);assignProgramDateTime(v,h);h=v;c+=v.duration;u++;f=0;E=true}}else if(p[4]){var L=(" "+p[4]).slice(1);if(h){v.setByteRange(L,h)}else{v.setByteRange(L)}}else if(p[5]){v.rawProgramDateTime=(" "+p[5]).slice(1);v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]);if(y===-1){y=o.length}}else{p=p[0].match(LEVEL_PLAYLIST_REGEX_SLOW);if(!p){logger.warn("No matches on slow regex match for level playlist!");continue}for(g=1;g<p.length;g++){if(typeof p[g]!=="undefined"){break}}var b=(" "+p[g]).slice(1);var R=(" "+p[g+1]).slice(1);var D=p[g+2]?(" "+p[g+2]).slice(1):"";switch(b){case"PLAYLIST-TYPE":s.type=R.toUpperCase();break;case"MEDIA-SEQUENCE":u=s.startSN=parseInt(R);break;case"SKIP":{var I=new AttrList(R);{substituteVariablesInAttributes(s,I,["RECENTLY-REMOVED-DATERANGES"])}var C=I.decimalInteger("SKIPPED-SEGMENTS");if(isFiniteNumber(C)){s.skippedSegments=C;for(var _=C;_--;){o.unshift(null)}u+=C}var k=I.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(k){s.recentlyRemovedDateranges=k.split("\t")}break}case"TARGETDURATION":s.targetduration=Math.max(parseInt(R),1);break;case"VERSION":s.version=parseInt(R);break;case"EXTM3U":break;case"ENDLIST":s.live=false;break;case"#":if(R||D){v.tagList.push(D?[R,D]:[R])}break;case"DISCONTINUITY":d++;v.tagList.push(["DIS"]);break;case"GAP":v.gap=true;v.tagList.push([b]);break;case"BITRATE":v.tagList.push([b,R]);break;case"DATERANGE":{var P=new AttrList(R);{substituteVariablesInAttributes(s,P,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]);substituteVariablesInAttributes(s,P,P.clientAttrs)}var w=new DateRange(P,s.dateRanges[P.ID]);if(w.isValid||s.skippedSegments){s.dateRanges[w.id]=w}else{logger.warn('Ignoring invalid DATERANGE tag: "'.concat(R,'"'))}v.tagList.push(["EXT-X-DATERANGE",R]);break}case"DEFINE":{{var F=new AttrList(R);substituteVariablesInAttributes(s,F,["NAME","VALUE","IMPORT","QUERYPARAM"]);if("IMPORT"in F){importVariableDefinition(s,F,n)}else{addVariableDefinition(s,F,t)}}break}case"DISCONTINUITY-SEQUENCE":d=parseInt(R);break;case"KEY":{var x=parseKey(R,t,s);if(x.isSupported()){if(x.method==="NONE"){m=undefined;break}if(!m){m={}}if(m[x.keyFormat]){m=_extends({},m)}m[x.keyFormat]=x}else{logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(R,'"'))}break}case"START":s.startTimeOffset=parseStartTimeOffset(R);break;case"MAP":{var O=new AttrList(R);{substituteVariablesInAttributes(s,O,["BYTERANGE","URI"])}if(v.duration){var M=new Fragment(i,t);setInitSegment(M,O,r,m);l=M;v.initSegment=l;if(l.rawProgramDateTime&&!v.rawProgramDateTime){v.rawProgramDateTime=l.rawProgramDateTime}}else{setInitSegment(v,O,r,m);l=v;E=true}break}case"SERVER-CONTROL":{var N=new AttrList(R);s.canBlockReload=N.bool("CAN-BLOCK-RELOAD");s.canSkipUntil=N.optionalFloat("CAN-SKIP-UNTIL",0);s.canSkipDateRanges=s.canSkipUntil>0&&N.bool("CAN-SKIP-DATERANGES");s.partHoldBack=N.optionalFloat("PART-HOLD-BACK",0);s.holdBack=N.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var U=new AttrList(R);s.partTarget=U.decimalFloatingPoint("PART-TARGET");break}case"PART":{var B=s.partList;if(!B){B=s.partList=[]}var G=f>0?B[B.length-1]:undefined;var K=f++;var H=new AttrList(R);{substituteVariablesInAttributes(s,H,["BYTERANGE","URI"])}var V=new Part(H,v,t,K,G);B.push(V);v.duration+=V.duration;break}case"PRELOAD-HINT":{var j=new AttrList(R);{substituteVariablesInAttributes(s,j,["URI"])}s.preloadHint=j;break}case"RENDITION-REPORT":{var W=new AttrList(R);{substituteVariablesInAttributes(s,W,["URI"])}s.renditionReports=s.renditionReports||[];s.renditionReports.push(W);break}default:logger.warn("line parsed but not handled: ".concat(p));break}}}if(h&&!h.relurl){o.pop();c-=h.duration;if(s.partList){s.fragmentHint=h}}else if(s.partList){assignProgramDateTime(v,h);v.cc=d;s.fragmentHint=v;if(m){setFragLevelKeys(v,m,s)}}var Y=o.length;var q=o[0];var X=o[Y-1];c+=s.skippedSegments*s.targetduration;if(c>0&&Y&&X){s.averagetargetduration=c/Y;var z=X.sn;s.endSN=z!=="initSegment"?z:0;if(!s.live){X.endList=true}if(q){s.startCC=q.cc}}else{s.endSN=0;s.startCC=0}if(s.fragmentHint){c+=s.fragmentHint.duration}s.totalduration=c;s.endCC=d;if(y>0){backfillProgramDateTimes(o,y)}return s};return e}();function parseKey(e,t,r){var i,a;var n=new AttrList(e);{substituteVariablesInAttributes(r,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"])}var s=(i=n.METHOD)!=null?i:"";var o=n.URI;var l=n.hexadecimalInteger("IV");var u=n.KEYFORMATVERSIONS;var f=(a=n.KEYFORMAT)!=null?a:"identity";if(o&&n.IV&&!l){logger.error("Invalid IV: ".concat(n.IV))}var c=o?M3U8Parser.resolve(o,t):"";var d=(u?u:"1").split("/").map(Number).filter(Number.isFinite);return new LevelKey(s,c,f,d,l)}function parseStartTimeOffset(e){var t=new AttrList(e);var r=t.decimalFloatingPoint("TIME-OFFSET");if(isFiniteNumber(r)){return r}return null}function setCodecs(e,t){["video","audio","text"].forEach((function(r){var i=e.filter((function(e){return isCodecType(e,r)}));if(i.length){var a=i.filter((function(e){return e.lastIndexOf("avc1",0)===0||e.lastIndexOf("mp4a",0)===0}));t["".concat(r,"Codec")]=a.length>0?a[0]:i[0];e=e.filter((function(e){return i.indexOf(e)===-1}))}}));t.unknownCodecs=e}function assignCodec(e,t,r){var i=t[r];if(i){e[r]=i}}function backfillProgramDateTimes(e,t){var r=e[t];for(var i=t;i--;){var a=e[i];if(!a){return}a.programDateTime=r.programDateTime-a.duration*1e3;r=a}}function assignProgramDateTime(e,t){if(e.rawProgramDateTime){e.programDateTime=Date.parse(e.rawProgramDateTime)}else if(t!=null&&t.programDateTime){e.programDateTime=t.endProgramDateTime}if(!isFiniteNumber(e.programDateTime)){e.programDateTime=null;e.rawProgramDateTime=null}}function setInitSegment(e,t,r,i){e.relurl=t.URI;if(t.BYTERANGE){e.setByteRange(t.BYTERANGE)}e.level=r;e.sn="initSegment";if(i){e.levelkeys=i}e.initSegment=null}function setFragLevelKeys(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;if((!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some((function(e){return t[e].isCommonEncryption}))){i.push(e)}}var PlaylistContextType={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"};var PlaylistLevelType={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function mapContextToLevelType(e){var t=e.type;switch(t){case PlaylistContextType.AUDIO_TRACK:return PlaylistLevelType.AUDIO;case PlaylistContextType.SUBTITLE_TRACK:return PlaylistLevelType.SUBTITLE;default:return PlaylistLevelType.MAIN}}function getResponseUrl(e,t){var r=e.url;if(r===undefined||r.indexOf("data:")===0){r=t.url}return r}var PlaylistLoader=function(){function e(e){this.hls=void 0;this.loaders=Object.create(null);this.variableList=null;this.hls=e;this.registerListeners()}e.prototype.startLoad=function(e){};e.prototype.stopLoad=function(){this.destroyInternalLoaders()};e.prototype.registerListeners=function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.LEVEL_LOADING,this.onLevelLoading,this);e.on(Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this);e.on(Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)};e.prototype.unregisterListeners=function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.LEVEL_LOADING,this.onLevelLoading,this);e.off(Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this);e.off(Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)};e.prototype.createInternalLoader=function(e){var t=this.hls.config;var r=t.pLoader;var i=t.loader;var a=r||i;var n=new a(t);this.loaders[e.type]=n;return n};e.prototype.getInternalLoader=function(e){return this.loaders[e.type]};e.prototype.resetInternalLoader=function(e){if(this.loaders[e]){delete this.loaders[e]}};e.prototype.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];if(t){t.destroy()}this.resetInternalLoader(e)}};e.prototype.destroy=function(){this.variableList=null;this.unregisterListeners();this.destroyInternalLoaders()};e.prototype.onManifestLoading=function(e,t){var r=t.url;this.variableList=null;this.load({id:null,level:0,responseType:"text",type:PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})};e.prototype.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.url,n=t.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:PlaylistContextType.LEVEL,url:a,deliveryDirectives:n})};e.prototype.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:n})};e.prototype.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:n})};e.prototype.load=function(e){var t=this;var r;var i=this.hls.config;var a=this.getInternalLoader(e);if(a){var n=a.context;if(n&&n.url===e.url){logger.trace("[playlist-loader]: playlist request ongoing");return}logger.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type));a.abort()}var s;if(e.type===PlaylistContextType.MANIFEST){s=i.manifestLoadPolicy.default}else{s=_extends({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null})}a=this.createInternalLoader(e);if((r=e.deliveryDirectives)!=null&&r.part){var o=void 0;if(e.type===PlaylistContextType.LEVEL&&e.level!==null){o=this.hls.levels[e.level].details}else if(e.type===PlaylistContextType.AUDIO_TRACK&&e.id!==null){o=this.hls.audioTracks[e.id].details}else if(e.type===PlaylistContextType.SUBTITLE_TRACK&&e.id!==null){o=this.hls.subtitleTracks[e.id].details}if(o){var l=o.partTarget;var u=o.targetduration;if(l&&u){var f=Math.max(l*3,u*.8)*1e3;s=_extends({},s,{maxTimeToFirstByteMs:Math.min(f,s.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,s.maxTimeToFirstByteMs)})}}}var c=s.errorRetry||s.timeoutRetry||{};var d={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0};var h={onSuccess:function(e,r,i,a){var n=t.getInternalLoader(i);t.resetInternalLoader(i.type);var s=e.data;if(s.indexOf("#EXTM3U")!==0){t.handleManifestParsingError(e,i,new Error("no EXTM3U delimiter"),a||null,r);return}r.parsing.start=performance.now();if(M3U8Parser.isMediaPlaylist(s)){t.handleTrackOrLevelPlaylist(e,r,i,a||null,n)}else{t.handleMasterPlaylist(e,r,i,a)}},onError:function(e,r,i,a){t.handleNetworkError(r,i,false,e,a)},onTimeout:function(e,r,i){t.handleNetworkError(r,i,true,undefined,e)}};a.load(e,d,h)};e.prototype.handleMasterPlaylist=function(e,t,r,i){var a=this.hls;var n=e.data;var s=getResponseUrl(e,r);var o=M3U8Parser.parseMasterPlaylist(n,s);if(o.playlistParsingError){this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);return}var l=o.contentSteering,u=o.levels,f=o.sessionData,c=o.sessionKeys,d=o.startTimeOffset,h=o.variableList;this.variableList=h;var v=M3U8Parser.parseMasterPlaylistMedia(n,s,o),p=v.AUDIO,g=p===void 0?[]:p,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];if(g.length){var E=g.some((function(e){return!e.url}));if(!E&&u[0].audioCodec&&!u[0].attrs.AUDIO){logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one");g.unshift({type:"main",name:"main",groupId:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new AttrList({}),bitrate:0,url:""})}}a.trigger(Events.MANIFEST_LOADED,{levels:u,audioTracks:g,subtitles:m,captions:y,contentSteering:l,url:s,stats:t,networkDetails:i,sessionData:f,sessionKeys:c,startTimeOffset:d,variableList:h})};e.prototype.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var n=this.hls;var s=r.id,o=r.level,l=r.type;var u=getResponseUrl(e,r);var f=isFiniteNumber(s)?s:0;var c=isFiniteNumber(o)?o:f;var d=mapContextToLevelType(r);var h=M3U8Parser.parseLevelPlaylist(e.data,u,c,d,f,this.variableList);if(l===PlaylistContextType.MANIFEST){var v={attrs:new AttrList({}),bitrate:0,details:h,name:"",url:u};n.trigger(Events.MANIFEST_LOADED,{levels:[v],audioTracks:[],url:u,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now();r.levelDetails=h;this.handlePlaylistLoaded(h,e,t,r,i,a)};e.prototype.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===PlaylistContextType.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})};e.prototype.handleNetworkError=function(e,t,r,i,a){if(r===void 0){r=false}var n="A network ".concat(r?"timeout":"error"+(i?" (status "+i.code+")":"")," occurred while loading ").concat(e.type);if(e.type===PlaylistContextType.LEVEL){n+=": ".concat(e.level," id: ").concat(e.id)}else if(e.type===PlaylistContextType.AUDIO_TRACK||e.type===PlaylistContextType.SUBTITLE_TRACK){n+=" id: ".concat(e.id,' group-id: "').concat(e.groupId,'"')}var s=new Error(n);logger.warn("[playlist-loader]: ".concat(n));var o=ErrorDetails.UNKNOWN;var l=false;var u=this.getInternalLoader(e);switch(e.type){case PlaylistContextType.MANIFEST:o=r?ErrorDetails.MANIFEST_LOAD_TIMEOUT:ErrorDetails.MANIFEST_LOAD_ERROR;l=true;break;case PlaylistContextType.LEVEL:o=r?ErrorDetails.LEVEL_LOAD_TIMEOUT:ErrorDetails.LEVEL_LOAD_ERROR;l=false;break;case PlaylistContextType.AUDIO_TRACK:o=r?ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:ErrorDetails.AUDIO_TRACK_LOAD_ERROR;l=false;break;case PlaylistContextType.SUBTITLE_TRACK:o=r?ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:ErrorDetails.SUBTITLE_LOAD_ERROR;l=false;break}if(u){this.resetInternalLoader(e.type)}var f={type:ErrorTypes.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:u,context:e,error:s,networkDetails:t,stats:a};if(i){var c=(t==null?void 0:t.url)||e.url;f.response=_objectSpread2({url:c,data:undefined},i)}this.hls.trigger(Events.ERROR,f)};e.prototype.handlePlaylistLoaded=function(e,t,r,i,a,n){var s=this.hls;var o=i.type,l=i.level,u=i.id,f=i.groupId,c=i.deliveryDirectives;var d=getResponseUrl(t,i);var h=mapContextToLevelType(i);var v=typeof i.level==="number"&&h===PlaylistLevelType.MAIN?l:undefined;if(!e.fragments.length){var p=new Error("No Segments found in Playlist");s.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.LEVEL_EMPTY_ERROR,fatal:false,url:d,error:p,reason:p.message,response:t,context:i,level:v,parent:h,networkDetails:a,stats:r});return}if(!e.targetduration){e.playlistParsingError=new Error("Missing Target Duration")}var g=e.playlistParsingError;if(g){s.trigger(Events.ERROR,{type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.LEVEL_PARSING_ERROR,fatal:false,url:d,error:g,reason:g.message,response:t,context:i,level:v,parent:h,networkDetails:a,stats:r});return}if(e.live&&n){if(n.getCacheAge){e.ageHeader=n.getCacheAge()||0}if(!n.getCacheAge||isNaN(e.ageHeader)){e.ageHeader=0}}switch(o){case PlaylistContextType.MANIFEST:case PlaylistContextType.LEVEL:s.trigger(Events.LEVEL_LOADED,{details:e,level:v||0,id:u||0,stats:r,networkDetails:a,deliveryDirectives:c});break;case PlaylistContextType.AUDIO_TRACK:s.trigger(Events.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:c});break;case PlaylistContextType.SUBTITLE_TRACK:s.trigger(Events.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:f||"",stats:r,networkDetails:a,deliveryDirectives:c});break}};return e}();function sendAddTrackEvent(e,t){var r;try{r=new Event("addtrack")}catch(e){r=document.createEvent("Event");r.initEvent("addtrack",false,false)}r.track=e;t.dispatchEvent(r)}function addCueToTrack(e,t){var r=e.mode;if(r==="disabled"){e.mode="hidden"}if(e.cues&&!e.cues.getCueById(t.id)){try{e.addCue(t);if(!e.cues.getCueById(t.id)){throw new Error("addCue is failed for: ".concat(t))}}catch(r){logger.debug("[texttrack-utils]: ".concat(r));try{var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id;e.addCue(i)}catch(e){logger.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(e))}}}if(r==="disabled"){e.mode=r}}function clearCurrentCues(e){var t=e.mode;if(t==="disabled"){e.mode="hidden"}if(e.cues){for(var r=e.cues.length;r--;){e.removeCue(e.cues[r])}}if(t==="disabled"){e.mode=t}}function removeCuesInRange(e,t,r,i){var a=e.mode;if(a==="disabled"){e.mode="hidden"}if(e.cues&&e.cues.length>0){var n=getCuesInRange(e.cues,t,r);for(var s=0;s<n.length;s++){if(!i||i(n[s])){e.removeCue(n[s])}}}if(a==="disabled"){e.mode=a}}function getFirstCueIndexAfterTime(e,t){if(t<e[0].startTime){return 0}var r=e.length-1;if(t>e[r].endTime){return-1}var i=0;var a=r;while(i<=a){var n=Math.floor((a+i)/2);if(t<e[n].startTime){a=n-1}else if(t>e[n].startTime&&i<r){i=n+1}else{return n}}return e[i].startTime-t<t-e[a].startTime?i:a}function getCuesInRange(e,t,r){var i=[];var a=getFirstCueIndexAfterTime(e,t);if(a>-1){for(var n=a,s=e.length;n<s;n++){var o=e[n];if(o.startTime>=t&&o.endTime<=r){i.push(o)}else if(o.startTime>r){return i}}}return i}var MetadataSchema={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};var MIN_CUE_DURATION=.25;function getCueClass(){if(typeof self==="undefined")return undefined;return self.VTTCue||self.TextTrackCue}function createCueWithDataFields(e,t,r,i,a){var n=new e(t,r,"");try{n.value=i;if(a){n.type=a}}catch(s){n=new e(t,r,JSON.stringify(a?_objectSpread2({type:a},i):i))}return n}var MAX_CUE_ENDTIME=function(){var e=getCueClass();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function dateRangeDateToTimelineSeconds(e,t){return e.getTime()/1e3-t}function hexToArrayBuffer(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var ID3TrackController=function(){function e(e){this.hls=void 0;this.id3Track=null;this.media=null;this.dateRangeCuesAppended={};this.hls=e;this._registerListeners()}e.prototype.destroy=function(){this._unregisterListeners();this.id3Track=null;this.media=null;this.dateRangeCuesAppended={};this.hls=null};e.prototype._registerListeners=function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this);e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this);e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this)};e.prototype._unregisterListeners=function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this);e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this);e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this)};e.prototype.onMediaAttached=function(e,t){this.media=t.media};e.prototype.onMediaDetaching=function(){if(!this.id3Track){return}clearCurrentCues(this.id3Track);this.id3Track=null;this.media=null;this.dateRangeCuesAppended={}};e.prototype.onManifestLoading=function(){this.dateRangeCuesAppended={}};e.prototype.createTrack=function(e){var t=this.getID3Track(e.textTracks);t.mode="hidden";return t};e.prototype.getID3Track=function(e){if(!this.media){return}for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3"){sendAddTrackEvent(r,this.media);return r}}return this.media.addTextTrack("metadata","id3")};e.prototype.onFragParsingMetadata=function(e,t){if(!this.media){return}var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(!i&&!a){return}var n=t.samples;if(!this.id3Track){this.id3Track=this.createTrack(this.media)}var s=getCueClass();if(!s){return}for(var o=0;o<n.length;o++){var l=n[o].type;if(l===MetadataSchema.emsg&&!i||!a){continue}var u=getID3Frames(n[o].data);if(u){var f=n[o].pts;var c=f+n[o].duration;if(c>MAX_CUE_ENDTIME){c=MAX_CUE_ENDTIME}var d=c-f;if(d<=0){c=f+MIN_CUE_DURATION}for(var h=0;h<u.length;h++){var v=u[h];if(!isTimeStampFrame(v)){this.updateId3CueEnds(f,l);var p=createCueWithDataFields(s,f,c,v,l);if(p){this.id3Track.addCue(p)}}}}}};e.prototype.updateId3CueEnds=function(e,t){var r;var i=(r=this.id3Track)==null?void 0:r.cues;if(i){for(var a=i.length;a--;){var n=i[a];if(n.type===t&&n.startTime<e&&n.endTime===MAX_CUE_ENDTIME){n.endTime=e}}}};e.prototype.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type;var n=this,s=n.id3Track,o=n.hls;if(!o){return}var l=o.config,u=l.enableEmsgMetadataCues,f=l.enableID3MetadataCues;if(s&&(u||f)){var c=void 0;if(a==="audio"){c=function(e){return e.type===MetadataSchema.audioId3&&f}}else if(a==="video"){c=function(e){return e.type===MetadataSchema.emsg&&u}}else{c=function(e){return e.type===MetadataSchema.audioId3&&f||e.type===MetadataSchema.emsg&&u}}removeCuesInRange(s,r,i,c)}};e.prototype.onLevelUpdated=function(e,t){var r=t.details;if(!this.media||!r.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues){return}var i=this,a=i.dateRangeCuesAppended,n=i.id3Track;var s=r.dateRanges;var o=Object.keys(s);if(n){var l=Object.keys(a).filter((function(e){return!o.includes(e)}));var u=function(e){var t=l[e];Object.keys(a[t].cues).forEach((function(e){n.removeCue(a[t].cues[e])}));delete a[t]};for(var f=l.length;f--;){u(f)}}var c=r.fragments[r.fragments.length-1];if(o.length===0||!isFiniteNumber(c==null?void 0:c.programDateTime)){return}if(!this.id3Track){this.id3Track=this.createTrack(this.media)}var d=c.programDateTime/1e3-c.start;var h=getCueClass();var v=function(e){var t=o[e];var r=s[t];var i=a[t];var n=(i==null?void 0:i.cues)||{};var l=(i==null?void 0:i.durationKnown)||false;var u=dateRangeDateToTimelineSeconds(r.startDate,d);var f=MAX_CUE_ENDTIME;var c=r.endDate;if(c){f=dateRangeDateToTimelineSeconds(c,d);l=true}else if(r.endOnNext&&!l){var v=o.reduce((function(e,t){var i=s[t];if(i.class===r.class&&i.id!==t&&i.startDate>r.startDate){e.push(i)}return e}),[]).sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()}))[0];if(v){f=dateRangeDateToTimelineSeconds(v.startDate,d);l=true}}var g=Object.keys(r.attr);for(var m=0;m<g.length;m++){var y=g[m];if(!isDateRangeCueAttribute(y)){continue}var E=n[y];if(E){if(l&&!i.durationKnown){E.endTime=f}}else if(h){var T=r.attr[y];if(isSCTE35Attribute(y)){T=hexToArrayBuffer(T)}var S=createCueWithDataFields(h,u,f,{key:y,data:T},MetadataSchema.dateRange);if(S){S.id=t;p.id3Track.addCue(S);n[y]=S}}}a[t]={cues:n,dateRange:r,durationKnown:l}};var p=this;for(var f=0;f<o.length;f++){v(f)}};return e}();var LatencyController=function(){function e(e){var t=this;this.hls=void 0;this.config=void 0;this.media=null;this.levelDetails=null;this.currentTime=0;this.stallCount=0;this._latency=null;this.timeupdateHandler=function(){return t.timeupdate()};this.hls=e;this.config=e.config;this.registerListeners()}Object.defineProperty(e.prototype,"latency",{get:function(){return this._latency||0},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"maxLatency",{get:function(){var e=this,t=e.config,r=e.levelDetails;if(t.liveMaxLatencyDuration!==undefined){return t.liveMaxLatencyDuration}return r?t.liveMaxLatencyDurationCount*r.targetduration:0},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"targetLatency",{get:function(){var e=this.levelDetails;if(e===null){return null}var t=e.holdBack,r=e.partHoldBack,i=e.targetduration;var a=this.config,n=a.liveSyncDuration,s=a.liveSyncDurationCount,o=a.lowLatencyMode;var l=this.hls.userConfig;var u=o?r||t:t;if(l.liveSyncDuration||l.liveSyncDurationCount||u===0){u=n!==undefined?n:s*i}var f=i;var c=1;return u+Math.min(this.stallCount*c,f)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"liveSyncPosition",{get:function(){var e=this.estimateLiveEdge();var t=this.targetLatency;var r=this.levelDetails;if(e===null||t===null||r===null){return null}var i=r.edge;var a=e-t-this.edgeStalled;var n=i-r.totalduration;var s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,a),s)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"drift",{get:function(){var e=this.levelDetails;if(e===null){return 1}return e.drift},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"edgeStalled",{get:function(){var e=this.levelDetails;if(e===null){return 0}var t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"forwardBufferLength",{get:function(){var e=this,t=e.media,r=e.levelDetails;if(!t||!r){return 0}var i=t.buffered.length;return(i?t.buffered.end(i-1):r.edge)-this.currentTime},enumerable:false,configurable:true});e.prototype.destroy=function(){this.unregisterListeners();this.onMediaDetaching();this.levelDetails=null;this.hls=this.timeupdateHandler=null};e.prototype.registerListeners=function(){this.hls.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this);this.hls.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);this.hls.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this);this.hls.on(Events.ERROR,this.onError,this)};e.prototype.unregisterListeners=function(){this.hls.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this);this.hls.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);this.hls.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this);this.hls.off(Events.ERROR,this.onError,this)};e.prototype.onMediaAttached=function(e,t){this.media=t.media;this.media.addEventListener("timeupdate",this.timeupdateHandler)};e.prototype.onMediaDetaching=function(){if(this.media){this.media.removeEventListener("timeupdate",this.timeupdateHandler);this.media=null}};e.prototype.onManifestLoading=function(){this.levelDetails=null;this._latency=null;this.stallCount=0};e.prototype.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r;if(r.advanced){this.timeupdate()}if(!r.live&&this.media){this.media.removeEventListener("timeupdate",this.timeupdateHandler)}};e.prototype.onError=function(e,t){var r;if(t.details!==ErrorDetails.BUFFER_STALLED_ERROR){return}this.stallCount++;if((r=this.levelDetails)!=null&&r.live){logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency")}};e.prototype.timeupdate=function(){var e=this,t=e.media,r=e.levelDetails;if(!t||!r){return}this.currentTime=t.currentTime;var i=this.computeLatency();if(i===null){return}this._latency=i;var a=this.config,n=a.lowLatencyMode,s=a.maxLiveSyncPlaybackRate;if(!n||s===1){return}var o=this.targetLatency;if(o===null){return}var l=i-o;var u=Math.min(this.maxLatency,o+r.targetduration);var f=l<u;if(r.live&&f&&l>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,s));var d=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;t.playbackRate=Math.min(c,Math.max(1,d))}else if(t.playbackRate!==1&&t.playbackRate!==0){t.playbackRate=1}};e.prototype.estimateLiveEdge=function(){var e=this.levelDetails;if(e===null){return null}return e.edge+e.age};e.prototype.computeLatency=function(){var e=this.estimateLiveEdge();if(e===null){return null}return e-this.currentTime};return e}();var HdcpLevels=["NONE","TYPE-0","TYPE-1",null];var HlsSkip={No:"",Yes:"YES",v2:"v2"};function getSkipValue(e,t){var r=e.canSkipUntil,i=e.canSkipDateRanges,a=e.endSN;var n=t!==undefined?t-a:0;if(r&&n<r){if(i){return HlsSkip.v2}return HlsSkip.Yes}return HlsSkip.No}var HlsUrlParameters=function(){function e(e,t,r){this.msn=void 0;this.part=void 0;this.skip=void 0;this.msn=e;this.part=t;this.skip=r}e.prototype.addDirectives=function(e){var t=new self.URL(e);if(this.msn!==undefined){t.searchParams.set("_HLS_msn",this.msn.toString())}if(this.part!==undefined){t.searchParams.set("_HLS_part",this.part.toString())}if(this.skip){t.searchParams.set("_HLS_skip",this.skip)}return t.href};return e}();var Level=function(){function e(e){this._attrs=void 0;this.audioCodec=void 0;this.bitrate=void 0;this.codecSet=void 0;this.height=void 0;this.id=void 0;this.name=void 0;this.videoCodec=void 0;this.width=void 0;this.unknownCodecs=void 0;this.audioGroupIds=void 0;this.details=void 0;this.fragmentError=0;this.loadError=0;this.loaded=void 0;this.realBitrate=0;this.textGroupIds=void 0;this.url=void 0;this._urlId=0;this.url=[e.url];this._attrs=[e.attrs];this.bitrate=e.bitrate;if(e.details){this.details=e.details}this.id=e.id||0;this.name=e.name;this.width=e.width||0;this.height=e.height||0;this.audioCodec=e.audioCodec;this.videoCodec=e.videoCodec;this.unknownCodecs=e.unknownCodecs;this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return e})).join(",").replace(/\.[^.,]+/g,"")}Object.defineProperty(e.prototype,"maxBitrate",{get:function(){return Math.max(this.realBitrate,this.bitrate)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"attrs",{get:function(){return this._attrs[this._urlId]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"pathwayId",{get:function(){return this.attrs["PATHWAY-ID"]||"."},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"uri",{get:function(){return this.url[this._urlId]||""},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"urlId",{get:function(){return this._urlId},set:function(e){var t=e%this.url.length;if(this._urlId!==t){this.fragmentError=0;this.loadError=0;this.details=undefined;this._urlId=t}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"audioGroupId",{get:function(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"textGroupId",{get:function(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]},enumerable:false,configurable:true});e.prototype.addFallback=function(e){this.url.push(e.url);this._attrs.push(e.attrs)};return e}();function updateFromToPTS(e,t){var r=t.startPTS;if(isFiniteNumber(r)){var i=0;var a=void 0;if(t.sn>e.sn){i=r-e.start;a=e}else{i=e.start-r;a=t}if(a.duration!==i){a.duration=i}}else if(t.sn>e.sn){var n=e.cc===t.cc;if(n&&e.minEndPTS){t.start=e.start+(e.minEndPTS-e.start)}else{t.start=e.start+e.duration}}else{t.start=Math.max(e.start-t.duration,0)}}function updateFragPTSDTS(e,t,r,i,a,n){var s=i-r;if(s<=0){logger.warn("Fragment should have a positive duration",t);i=r+t.duration;n=a+t.duration}var o=r;var l=i;var u=t.startPTS;var f=t.endPTS;if(isFiniteNumber(u)){var c=Math.abs(u-r);if(!isFiniteNumber(t.deltaPTS)){t.deltaPTS=c}else{t.deltaPTS=Math.max(c,t.deltaPTS)}o=Math.max(r,u);r=Math.min(r,u);a=Math.min(a,t.startDTS);l=Math.min(i,f);i=Math.max(i,f);n=Math.max(n,t.endDTS)}var d=r-t.start;if(t.start!==0){t.start=r}t.duration=i-t.start;t.startPTS=r;t.maxStartPTS=o;t.startDTS=a;t.endPTS=i;t.minEndPTS=l;t.endDTS=n;var h=t.sn;if(!e||h<e.startSN||h>e.endSN){return 0}var v;var p=h-e.startSN;var g=e.fragments;g[p]=t;for(v=p;v>0;v--){updateFromToPTS(g[v],g[v-1])}for(v=p;v<g.length-1;v++){updateFromToPTS(g[v],g[v+1])}if(e.fragmentHint){updateFromToPTS(g[g.length-1],e.fragmentHint)}e.PTSKnown=e.alignedSliding=true;return d}function mergeDetails(e,t){var r=null;var i=e.fragments;for(var a=i.length-1;a>=0;a--){var n=i[a].initSegment;if(n){r=n;break}}if(e.fragmentHint){delete e.fragmentHint.endPTS}var s=0;var o;mapFragmentIntersection(e,t,(function(e,i){if(e.relurl){s=e.cc-i.cc}if(isFiniteNumber(e.startPTS)&&isFiniteNumber(e.endPTS)){i.start=i.startPTS=e.startPTS;i.startDTS=e.startDTS;i.maxStartPTS=e.maxStartPTS;i.endPTS=e.endPTS;i.endDTS=e.endDTS;i.minEndPTS=e.minEndPTS;i.duration=e.endPTS-e.startPTS;if(i.duration){o=i}t.PTSKnown=t.alignedSliding=true}i.elementaryStreams=e.elementaryStreams;i.loader=e.loader;i.stats=e.stats;i.urlId=e.urlId;if(e.initSegment){i.initSegment=e.initSegment;r=e.initSegment}}));if(r){var l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;l.forEach((function(e){var t;if(!e.initSegment||e.initSegment.relurl===((t=r)==null?void 0:t.relurl)){e.initSegment=r}}))}if(t.skippedSegments){t.deltaUpdateFailed=t.fragments.some((function(e){return!e}));if(t.deltaUpdateFailed){logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var a=t.skippedSegments;a--;){t.fragments.shift()}t.startSN=t.fragments[0].sn;t.startCC=t.fragments[0].cc}else if(t.canSkipDateRanges){t.dateRanges=mergeDateRanges(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges)}}var u=t.fragments;if(s){logger.warn("discontinuity sliding from playlist, take drift into account");for(var a=0;a<u.length;a++){u[a].cc+=s}}if(t.skippedSegments){t.startCC=t.fragments[0].cc}mapPartIntersection(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams;t.stats=e.stats}));if(o){updateFragPTSDTS(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS)}else{adjustSliding(e,t)}if(u.length){t.totalduration=t.edge-u[0].start}t.driftStartTime=e.driftStartTime;t.driftStart=e.driftStart;var f=t.advancedDateTime;if(t.advanced&&f){var c=t.edge;if(!t.driftStart){t.driftStartTime=f;t.driftStart=c}t.driftEndTime=f;t.driftEnd=c}else{t.driftEndTime=e.driftEndTime;t.driftEnd=e.driftEnd;t.advancedDateTime=e.advancedDateTime}}function mergeDateRanges(e,t,r){var i=_extends({},e);if(r){r.forEach((function(e){delete i[e]}))}Object.keys(t).forEach((function(e){var r=new DateRange(t[e].attr,i[e]);if(r.isValid){i[e]=r}else{logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(JSON.stringify(t[e].attr),'"'))}}));return i}function mapPartIntersection(e,t,r){if(e&&t){var i=0;for(var a=0,n=e.length;a<=n;a++){var s=e[a];var o=t[a+i];if(s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn){r(s,o)}else{i--}}}}function mapFragmentIntersection(e,t,r){var i=t.skippedSegments;var a=Math.max(e.startSN,t.startSN)-t.startSN;var n=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN;var s=t.startSN-e.startSN;var o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;var l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(var u=a;u<=n;u++){var f=l[s+u];var c=o[u];if(i&&!c&&u<i){c=t.fragments[u]=f}if(f&&c){r(f,c)}}}function adjustSliding(e,t){var r=t.startSN+t.skippedSegments-e.startSN;var i=e.fragments;if(r<0||r>=i.length){return}addSliding(t,i[r].start)}function addSliding(e,t){if(t){var r=e.fragments;for(var i=e.skippedSegments;i<r.length;i++){r[i].start+=t}if(e.fragmentHint){e.fragmentHint.start+=t}}}function computeReloadInterval(e,t){if(t===void 0){t=Infinity}var r=1e3*e.targetduration;if(e.updated){var i=e.fragments;var a=4;if(i.length&&r*a>t){var n=i[i.length-1].duration*1e3;if(n<r){r=n}}}else{r/=2}return Math.round(r)}function getFragmentWithSN(e,t,r){if(!(e!=null&&e.details)){return null}var i=e.details;var a=i.fragments[t-i.startSN];if(a){return a}a=i.fragmentHint;if(a&&a.sn===t){return a}if(t<i.startSN&&r&&r.sn===t){return r}return null}function getPartWith(e,t,r){var i;if(!(e!=null&&e.details)){return null}return findPart((i=e.details)==null?void 0:i.partList,t,r)}function findPart(e,t,r){if(e){for(var i=e.length;i--;){var a=e[i];if(a.index===r&&a.fragment.sn===t){return a}}}return null}function isTimeoutError(e){switch(e.details){case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_TIMEOUT:case ErrorDetails.LEVEL_LOAD_TIMEOUT:case ErrorDetails.MANIFEST_LOAD_TIMEOUT:return true}return false}function getRetryConfig(e,t){var r=isTimeoutError(t);return e.default["".concat(r?"timeout":"error","Retry")]}function getRetryDelay(e,t){var r=e.backoff==="linear"?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function getLoaderConfigWithoutReties(e){return _objectSpread2(_objectSpread2({},e),{errorRetry:null,timeoutRetry:null})}function shouldRetry(e,t,r,i){return!!e&&t<e.maxNumRetry&&(retryForHttpStatus(i)||!!r)}function retryForHttpStatus(e){return e===0&&navigator.onLine===false||!!e&&(e<400||e>499)}var BinarySearch={search:function(e,t){var r=0;var i=e.length-1;var a=null;var n=null;while(r<=i){a=(r+i)/2|0;n=e[a];var s=t(n);if(s>0){r=a+1}else if(s<0){i=a-1}else{return n}}return null}};function findFragmentByPDT(e,t,r){if(t===null||!Array.isArray(e)||!e.length||!isFiniteNumber(t)){return null}var i=e[0].programDateTime;if(t<(i||0)){return null}var a=e[e.length-1].endProgramDateTime;if(t>=(a||0)){return null}r=r||0;for(var n=0;n<e.length;++n){var s=e[n];if(pdtWithinToleranceTest(t,r,s)){return s}}return null}function findFragmentByPTS(e,t,r,i){if(r===void 0){r=0}if(i===void 0){i=0}var a=null;if(e){a=t[e.sn-t[0].sn+1]||null}else if(r===0&&t[0].start===0){a=t[0]}if(a&&fragmentWithinToleranceTest(r,i,a)===0){return a}var n=BinarySearch.search(t,fragmentWithinToleranceTest.bind(null,r,i));if(n&&(n!==e||!a)){return n}return a}function fragmentWithinToleranceTest(e,t,r){if(e===void 0){e=0}if(t===void 0){t=0}if(r.start<=e&&r.start+r.duration>e){return 0}var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));if(r.start+r.duration-i<=e){return 1}else if(r.start-i>e&&r.start){return-1}return 0}function pdtWithinToleranceTest(e,t,r){var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0))*1e3;var a=r.endProgramDateTime||0;return a-i>e}function findFragWithCC(e,t){return BinarySearch.search(e,(function(e){if(e.cc<t){return 1}else if(e.cc>t){return-1}else{return 0}}))}var RENDITION_PENALTY_DURATION_MS=3e5;var NetworkErrorAction={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5};var ErrorActionFlags={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};var ErrorController=function(){function e(e){this.hls=void 0;this.playlistError=0;this.penalizedRenditions={};this.log=void 0;this.warn=void 0;this.error=void 0;this.hls=e;this.log=logger.log.bind(logger,"[info]:");this.warn=logger.warn.bind(logger,"[warning]:");this.error=logger.error.bind(logger,"[error]:");this.registerListeners()}e.prototype.registerListeners=function(){var e=this.hls;e.on(Events.ERROR,this.onError,this);e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this)};e.prototype.unregisterListeners=function(){var e=this.hls;if(!e){return}e.off(Events.ERROR,this.onError,this);e.off(Events.ERROR,this.onErrorOut,this);e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this)};e.prototype.destroy=function(){this.unregisterListeners();this.hls=null;this.penalizedRenditions={}};e.prototype.startLoad=function(e){this.playlistError=0};e.prototype.stopLoad=function(){};e.prototype.getVariantLevelIndex=function(e){return(e==null?void 0:e.type)===PlaylistLevelType.MAIN?e.level:this.hls.loadLevel};e.prototype.onManifestLoading=function(){this.playlistError=0;this.penalizedRenditions={}};e.prototype.onLevelUpdated=function(){this.playlistError=0};e.prototype.onError=function(e,t){var r,i;if(t.fatal){return}var a=this.hls;var n=t.context;switch(t.details){case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case ErrorDetails.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:NetworkErrorAction.DoNothing,flags:ErrorActionFlags.None};return}case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t);t.errorAction.action=NetworkErrorAction.SendAlternateToPenaltyBox;return}case ErrorDetails.LEVEL_EMPTY_ERROR:case ErrorDetails.LEVEL_PARSING_ERROR:{var s,o;var l=t.parent===PlaylistLevelType.MAIN?t.level:a.loadLevel;if(t.details===ErrorDetails.LEVEL_EMPTY_ERROR&&!!((s=t.context)!=null&&(o=s.levelDetails)!=null&&o.live)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l)}else{t.levelRetry=false;t.errorAction=this.getLevelSwitchAction(t,l)}}return;case ErrorDetails.LEVEL_LOAD_ERROR:case ErrorDetails.LEVEL_LOAD_TIMEOUT:if(typeof(n==null?void 0:n.level)==="number"){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)}return;case ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case ErrorDetails.SUBTITLE_LOAD_ERROR:case ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var u=a.levels[a.loadLevel];if(u&&(n.type===PlaylistContextType.AUDIO_TRACK&&n.groupId===u.audioGroupId||n.type===PlaylistContextType.SUBTITLE_TRACK&&n.groupId===u.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel);t.errorAction.action=NetworkErrorAction.SendAlternateToPenaltyBox;t.errorAction.flags=ErrorActionFlags.MoveAllAlternatesMatchingHost;return}}return;case ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var u=a.levels[a.loadLevel];var f=u==null?void 0:u.attrs["HDCP-LEVEL"];if(f){t.errorAction={action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.MoveAllAlternatesMatchingHDCP,hdcpLevel:f}}}return;case ErrorDetails.BUFFER_ADD_CODEC_ERROR:case ErrorDetails.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(i=t.level)!=null?i:a.loadLevel);return;case ErrorDetails.INTERNAL_EXCEPTION:case ErrorDetails.BUFFER_APPENDING_ERROR:case ErrorDetails.BUFFER_APPEND_ERROR:case ErrorDetails.BUFFER_FULL_ERROR:case ErrorDetails.LEVEL_SWITCH_ERROR:case ErrorDetails.BUFFER_STALLED_ERROR:case ErrorDetails.BUFFER_SEEK_OVER_HOLE:case ErrorDetails.BUFFER_NUDGE_ON_STALL:t.errorAction={action:NetworkErrorAction.DoNothing,flags:ErrorActionFlags.None};return}if(t.type===ErrorTypes.KEY_SYSTEM_ERROR){var l=this.getVariantLevelIndex(t.frag);t.levelRetry=false;t.errorAction=this.getLevelSwitchAction(t,l);return}};e.prototype.getPlaylistRetryOrSwitchAction=function(e,t){var r;var i=this.hls;var a=getRetryConfig(i.config.playlistLoadPolicy,e);var n=this.playlistError++;var s=(r=e.response)==null?void 0:r.code;var o=shouldRetry(a,n,isTimeoutError(e),s);if(o){return{action:NetworkErrorAction.RetryRequest,flags:ErrorActionFlags.None,retryConfig:a,retryCount:n}}var l=this.getLevelSwitchAction(e,t);if(a){l.retryConfig=a;l.retryCount=n}return l};e.prototype.getFragRetryOrSwitchAction=function(e){var t=this.hls;var r=this.getVariantLevelIndex(e.frag);var i=t.levels[r];var a=t.config,n=a.fragLoadPolicy,s=a.keyLoadPolicy;var o=getRetryConfig(e.details.startsWith("key")?s:n,e);var l=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(i){var u;if(e.details!==ErrorDetails.FRAG_GAP){i.fragmentError++}var f=(u=e.response)==null?void 0:u.code;var c=shouldRetry(o,l,isTimeoutError(e),f);if(c){return{action:NetworkErrorAction.RetryRequest,flags:ErrorActionFlags.None,retryConfig:o,retryCount:l}}}var d=this.getLevelSwitchAction(e,r);if(o){d.retryConfig=o;d.retryCount=l}return d};e.prototype.getLevelSwitchAction=function(e,t){var r=this.hls;if(t===null||t===undefined){t=r.loadLevel}var i=this.hls.levels[t];if(i){i.loadError++;if(r.autoLevelEnabled){var a,n;var s=-1;var o=r.levels,l=r.loadLevel,u=r.minAutoLevel,f=r.maxAutoLevel;var c=(a=e.frag)==null?void 0:a.type;var d=(n=e.context)!=null?n:{},h=d.type,v=d.groupId;for(var p=o.length;p--;){var g=(p+l)%o.length;if(g!==l&&g>=u&&g<=f&&o[g].loadError===0){var m=o[g];if(e.details===ErrorDetails.FRAG_GAP&&e.frag){var y=o[g].details;if(y){var E=findFragmentByPTS(e.frag,y.fragments,e.frag.start);if(E!=null&&E.gap){continue}}}else if(h===PlaylistContextType.AUDIO_TRACK&&v===m.audioGroupId||h===PlaylistContextType.SUBTITLE_TRACK&&v===m.textGroupId){continue}else if(c===PlaylistLevelType.AUDIO&&i.audioGroupId===m.audioGroupId||c===PlaylistLevelType.SUBTITLE&&i.textGroupId===m.textGroupId){continue}s=g;break}}if(s>-1&&r.loadLevel!==s){e.levelRetry=true;this.playlistError=0;return{action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.None,nextAutoLevel:s}}}}return{action:NetworkErrorAction.SendAlternateToPenaltyBox,flags:ErrorActionFlags.MoveAllAlternatesMatchingHost}};e.prototype.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case NetworkErrorAction.DoNothing:break;case NetworkErrorAction.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t);if(!t.errorAction.resolved&&t.details!==ErrorDetails.FRAG_GAP){t.fatal=true}break}if(t.fatal){this.hls.stopLoad();return}};e.prototype.sendAlternateToPenaltyBox=function(e){var t=this.hls;var r=e.errorAction;if(!r){return}var i=r.flags,a=r.hdcpLevel,n=r.nextAutoLevel;switch(i){case ErrorActionFlags.None:this.switchLevel(e,n);break;case ErrorActionFlags.MoveAllAlternatesMatchingHost:{if(!r.resolved){r.resolved=this.redundantFailover(e)}}break;case ErrorActionFlags.MoveAllAlternatesMatchingHDCP:if(a){t.maxHdcpLevel=HdcpLevels[HdcpLevels.indexOf(a)-1];r.resolved=true}this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'));break}if(!r.resolved){this.switchLevel(e,n)}};e.prototype.switchLevel=function(e,t){if(t!==undefined&&e.errorAction){this.warn("switching to level ".concat(t," after ").concat(e.details));this.hls.nextAutoLevel=t;e.errorAction.resolved=true;this.hls.nextLoadLevel=this.hls.nextAutoLevel}};e.prototype.redundantFailover=function(e){var t=this,r=t.hls,i=t.penalizedRenditions;var a=e.parent===PlaylistLevelType.MAIN?e.level:r.loadLevel;var n=r.levels[a];var s=n.url.length;var o=e.frag?e.frag.urlId:n.urlId;if(n.urlId===o&&(!e.frag||n.details)){this.penalizeRendition(n,e)}var l=function(t){var l=(o+t)%s;var f=i[l];if(!f||checkExpired(f,e,i[o])){u.warn("Switching to Redundant Stream ".concat(l+1,"/").concat(s,': "').concat(n.url[l],'" after ').concat(e.details));u.playlistError=0;r.levels.forEach((function(e){e.urlId=l}));r.nextLoadLevel=a;return{value:true}}};var u=this;for(var f=1;f<s;f++){var c=l(f);if(typeof c==="object")return c.value}return false};e.prototype.penalizeRendition=function(e,t){var r=this.penalizedRenditions;var i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:undefined};i.lastErrorPerfMs=performance.now();i.errors.push(t);i.details=e.details;r[e.urlId]=i};return e}();function checkExpired(e,t,r){if(performance.now()-e.lastErrorPerfMs>RENDITION_PENALTY_DURATION_MS){return true}var i=e.details;if(t.details===ErrorDetails.FRAG_GAP&&i&&t.frag){var a=t.frag.start;var n=findFragmentByPTS(null,i.fragments,a);if(n&&!n.gap){return true}}if(r&&e.errors.length<r.errors.length){var s=e.errors[e.errors.length-1];if(i&&s.frag&&t.frag&&Math.abs(s.frag.start-t.frag.start)>i.targetduration*3){return true}}return false}var BasePlaylistController=function(){function e(e,t){this.hls=void 0;this.timer=-1;this.requestScheduled=-1;this.canLoad=false;this.log=void 0;this.warn=void 0;this.log=logger.log.bind(logger,"".concat(t,":"));this.warn=logger.warn.bind(logger,"".concat(t,":"));this.hls=e}e.prototype.destroy=function(){this.clearTimer();this.hls=this.log=this.warn=null};e.prototype.clearTimer=function(){clearTimeout(this.timer);this.timer=-1};e.prototype.startLoad=function(){this.canLoad=true;this.requestScheduled=-1;this.loadPlaylist()};e.prototype.stopLoad=function(){this.canLoad=false;this.clearTimer()};e.prototype.switchParams=function(e,t){var r=t==null?void 0:t.renditionReports;if(r){var i=-1;for(var a=0;a<r.length;a++){var n=r[a];var s=void 0;try{s=new self.URL(n.URI,t.url).href}catch(e){logger.warn("Could not construct new URL for Rendition Report: ".concat(e));s=n.URI||""}if(s===e){i=a;break}else if(s===e.substring(0,s.length)){i=a}}if(i!==-1){var n=r[i];var o=parseInt(n["LAST-MSN"])||(t==null?void 0:t.lastPartSn);var l=parseInt(n["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var u=Math.min(t.age-t.partTarget,t.targetduration);if(l>=0&&u>t.partTarget){l+=1}}return new HlsUrlParameters(o,l>=0?l:undefined,HlsSkip.No)}}};e.prototype.loadPlaylist=function(e){if(this.requestScheduled===-1){this.requestScheduled=self.performance.now()}};e.prototype.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)};e.prototype.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)};e.prototype.playlistLoaded=function(e,t,r){var i=this;var a=t.details,n=t.stats;var s=self.performance.now();var o=n.loading.first?Math.max(0,s-n.loading.first):0;a.advancedDateTime=Date.now()-o;if(a.live||r!=null&&r.live){a.reloaded(r);if(r){this.log("live playlist ".concat(e," ").concat(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:a.updated?"UPDATED":"MISSED"))}if(r&&a.fragments.length>0){mergeDetails(r,a)}if(!this.canLoad||!a.live){return}var l;var u=undefined;var f=undefined;if(a.canBlockReload&&a.endSN&&a.advanced){var c=this.hls.config.lowLatencyMode;var d=a.lastPartSn;var h=a.endSN;var v=a.lastPartIndex;var p=v!==-1;var g=d===h;var m=c?0:v;if(p){u=g?h+1:d;f=g?m:v+1}else{u=h+1}var y=a.age;var E=y+a.ageHeader;var T=Math.min(E-a.partTarget,a.targetduration*1.5);if(T>0){if(r&&T>r.tuneInGoal){this.warn("CDN Tune-in goal increased from: ".concat(r.tuneInGoal," to: ").concat(T," with playlist age: ").concat(a.age));T=0}else{var S=Math.floor(T/a.targetduration);u+=S;if(f!==undefined){var A=Math.round(T%a.targetduration/a.partTarget);f+=A}this.log("CDN Tune-in age: ".concat(a.ageHeader,"s last advanced ").concat(y.toFixed(2),"s goal: ").concat(T," skip sn ").concat(S," to part ").concat(f))}a.tuneInGoal=T}l=this.getDeliveryDirectives(a,t.deliveryDirectives,u,f);if(c||!g){this.loadPlaylist(l);return}}else if(a.canBlockReload||a.canSkipUntil){l=this.getDeliveryDirectives(a,t.deliveryDirectives,u,f)}var L=this.hls.mainForwardBufferInfo;var b=L?L.end-L.len:0;var R=(a.edge-b)*1e3;var D=computeReloadInterval(a,R);if(a.updated&&s>this.requestScheduled+D){this.requestScheduled=n.loading.start}if(u!==undefined&&a.canBlockReload){this.requestScheduled=n.loading.first+D-(a.partTarget*1e3||1e3)}else if(this.requestScheduled===-1||this.requestScheduled+D<s){this.requestScheduled=s}else if(this.requestScheduled-s<=0){this.requestScheduled+=D}var I=this.requestScheduled-s;I=Math.max(0,I);this.log("reload live playlist ".concat(e," in ").concat(Math.round(I)," ms"));this.timer=self.setTimeout((function(){return i.loadPlaylist(l)}),I)}else{this.clearTimer()}};e.prototype.getDeliveryDirectives=function(e,t,r,i){var a=getSkipValue(e,r);if(t!=null&&t.skip&&e.deltaUpdateFailed){r=t.msn;i=t.part;a=HlsSkip.No}return new HlsUrlParameters(r,i,a)};e.prototype.checkRetry=function(e){var t=this;var r=e.details;var i=isTimeoutError(e);var a=e.errorAction;var n=a||{},s=n.action,o=n.retryCount,l=o===void 0?0:o,u=n.retryConfig;var f=!!a&&!!u&&(s===NetworkErrorAction.RetryRequest||!a.resolved&&s===NetworkErrorAction.SendAlternateToPenaltyBox);if(f){var c;this.requestScheduled=-1;if(l>=u.maxNumRetry){return false}if(i&&(c=e.context)!=null&&c.deliveryDirectives){this.warn("Retrying playlist loading ".concat(l+1,"/").concat(u.maxNumRetry,' after "').concat(r,'" without delivery-directives'));this.loadPlaylist()}else{var d=getRetryDelay(u,l);this.timer=self.setTimeout((function(){return t.loadPlaylist()}),d);this.warn("Retrying playlist loading ".concat(l+1,"/").concat(u.maxNumRetry,' after "').concat(r,'" in ').concat(d,"ms"))}e.levelRetry=true;a.resolved=true}return f};return e}();var chromeOrFirefox;var LevelController=function(e){__extends(t,e);function t(t,r){var i=e.call(this,t,"[level-controller]")||this;i._levels=[];i._firstLevel=-1;i._startLevel=void 0;i.currentLevel=null;i.currentLevelIndex=-1;i.manualLevelIndex=-1;i.steering=void 0;i.onParsedComplete=void 0;i.steering=r;i._registerListeners();return i}t.prototype._registerListeners=function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this);e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this);e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this);e.on(Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);e.on(Events.FRAG_LOADED,this.onFragLoaded,this);e.on(Events.ERROR,this.onError,this)};t.prototype._unregisterListeners=function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this);e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this);e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this);e.off(Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);e.off(Events.FRAG_LOADED,this.onFragLoaded,this);e.off(Events.ERROR,this.onError,this)};t.prototype.destroy=function(){this._unregisterListeners();this.steering=null;this.resetLevels();e.prototype.destroy.call(this)};t.prototype.startLoad=function(){var t=this._levels;t.forEach((function(e){e.loadError=0;e.fragmentError=0}));e.prototype.startLoad.call(this)};t.prototype.resetLevels=function(){this._startLevel=undefined;this.manualLevelIndex=-1;this.currentLevelIndex=-1;this.currentLevel=null;this._levels=[]};t.prototype.onManifestLoading=function(e,t){this.resetLevels()};t.prototype.onManifestLoaded=function(e,t){var r=[];var i={};var a;t.levels.forEach((function(e){var t;var n=e.attrs;if(((t=e.audioCodec)==null?void 0:t.indexOf("mp4a.40.34"))!==-1){chromeOrFirefox||(chromeOrFirefox=/chrome|firefox/i.test(navigator.userAgent));if(chromeOrFirefox){e.audioCodec=undefined}}var s=n.AUDIO,o=n.CODECS,l=n["FRAME-RATE"],u=n["PATHWAY-ID"],f=n.RESOLUTION,c=n.SUBTITLES;var d="".concat(u||".","-");var h="".concat(d).concat(e.bitrate,"-").concat(f,"-").concat(l,"-").concat(o);a=i[h];if(!a){a=new Level(e);i[h]=a;r.push(a)}else{a.addFallback(e)}addGroupId(a,"audio",s);addGroupId(a,"text",c)}));this.filterAndSortMediaOptions(r,t)};t.prototype.filterAndSortMediaOptions=function(e,t){var r=this;var i=[];var a=[];var n=false;var s=false;var o=false;var l=e.filter((function(e){var t=e.audioCodec,r=e.videoCodec,i=e.width,a=e.height,l=e.unknownCodecs;n||(n=!!(i&&a));s||(s=!!r);o||(o=!!t);return!(l!=null&&l.length)&&(!t||isCodecSupportedInMp4(t,"audio"))&&(!r||isCodecSupportedInMp4(r,"video"))}));if((n||s)&&o){l=l.filter((function(e){var t=e.videoCodec,r=e.width,i=e.height;return!!t||!!(r&&i)}))}if(l.length===0){Promise.resolve().then((function(){if(r.hls){var e=new Error("no level with compatible codecs found in manifest");r.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:t.url,error:e,reason:e.message})}}));return}if(t.audioTracks){i=t.audioTracks.filter((function(e){return!e.audioCodec||isCodecSupportedInMp4(e.audioCodec,"audio")}));assignTrackIdsByGroup(i)}if(t.subtitles){a=t.subtitles;assignTrackIdsByGroup(a)}var u=l.slice(0);l.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]){return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1}if(e.bitrate!==t.bitrate){return e.bitrate-t.bitrate}if(e.attrs["FRAME-RATE"]!==t.attrs["FRAME-RATE"]){return e.attrs.decimalFloatingPoint("FRAME-RATE")-t.attrs.decimalFloatingPoint("FRAME-RATE")}if(e.attrs.SCORE!==t.attrs.SCORE){return e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE")}if(n&&e.height!==t.height){return e.height-t.height}return 0}));var f=u[0];if(this.steering){l=this.steering.filterParsedLevels(l);if(l.length!==u.length){for(var c=0;c<u.length;c++){if(u[c].pathwayId===l[0].pathwayId){f=u[c];break}}}}this._levels=l;for(var c=0;c<l.length;c++){if(l[c]===f){this._firstLevel=c;this.log("manifest loaded, ".concat(l.length," level(s) found, first bitrate: ").concat(f.bitrate));break}}var d=o&&!s;var h={levels:l,audioTracks:i,subtitleTracks:a,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:s,altAudio:!d&&i.some((function(e){return!!e.url}))};this.hls.trigger(Events.MANIFEST_PARSED,h);if(this.hls.config.autoStartLoad||this.hls.forceStartLoad){this.hls.startLoad(this.hls.config.startPosition)}};Object.defineProperty(t.prototype,"levels",{get:function(){if(this._levels.length===0){return null}return this._levels},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"level",{get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(t.length===0){return}if(e<0||e>=t.length){var r=new Error("invalid level idx");var i=e<0;this.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message});if(i){return}e=Math.min(e,t.length-1)}var a=this.currentLevelIndex;var n=this.currentLevel;var s=n?n.attrs["PATHWAY-ID"]:undefined;var o=t[e];var l=o.attrs["PATHWAY-ID"];this.currentLevelIndex=e;this.currentLevel=o;if(a===e&&o.details&&n&&s===l){return}this.log("Switching to level ".concat(e).concat(l?" with Pathway "+l:""," from level ").concat(a).concat(s?" with Pathway "+s:""));var u=_extends({},o,{level:e,maxBitrate:o.maxBitrate,attrs:o.attrs,uri:o.uri,urlId:o.urlId});delete u._attrs;delete u._urlId;this.hls.trigger(Events.LEVEL_SWITCHING,u);var f=o.details;if(!f||f.live){var c=this.switchParams(o.uri,n==null?void 0:n.details);this.loadPlaylist(c)}},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"manualLevel",{get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e;if(this._startLevel===undefined){this._startLevel=e}if(e!==-1){this.level=e}},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"firstLevel",{get:function(){return this._firstLevel},set:function(e){this._firstLevel=e},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"startLevel",{get:function(){if(this._startLevel===undefined){var e=this.hls.config.startLevel;if(e!==undefined){return e}else{return this._firstLevel}}else{return this._startLevel}},set:function(e){this._startLevel=e},enumerable:false,configurable:true});t.prototype.onError=function(e,t){if(t.fatal||!t.context){return}if(t.context.type===PlaylistContextType.LEVEL&&t.context.level===this.level){this.checkRetry(t)}};t.prototype.onFragLoaded=function(e,t){var r=t.frag;if(r!==undefined&&r.type===PlaylistLevelType.MAIN){var i=this._levels[r.level];if(i!==undefined){i.loadError=0}}};t.prototype.onLevelLoaded=function(e,t){var r;var i=t.level,a=t.details;var n=this._levels[i];if(!n){var s;this.warn("Invalid level index ".concat(i));if((s=t.deliveryDirectives)!=null&&s.skip){a.deltaUpdateFailed=true}return}if(i===this.currentLevelIndex){if(n.fragmentError===0){n.loadError=0}this.playlistLoaded(i,t,n.details)}else if((r=t.deliveryDirectives)!=null&&r.skip){a.deltaUpdateFailed=true}};t.prototype.onAudioTrackSwitched=function(e,t){var r=this.currentLevel;if(!r){return}var i=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){var a=-1;for(var n=0;n<r.audioGroupIds.length;n++){if(r.audioGroupIds[n]===i){a=n;break}}if(a!==-1&&a!==r.urlId){r.urlId=a;if(this.canLoad){this.startLoad()}}}};t.prototype.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex;var i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.urlId;var n=i.uri;if(t){try{n=t.addDirectives(n)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(e))}}var s=i.attrs["PATHWAY-ID"];this.log("Loading level index ".concat(r).concat((t==null?void 0:t.msn)!==undefined?" at sn "+t.msn+" part "+t.part:""," with").concat(s?" Pathway "+s:""," URI ").concat(a+1,"/").concat(i.url.length," ").concat(n));this.clearTimer();this.hls.trigger(Events.LEVEL_LOADING,{url:n,level:r,id:a,deliveryDirectives:t||null})}};Object.defineProperty(t.prototype,"nextLoadLevel",{get:function(){if(this.manualLevelIndex!==-1){return this.manualLevelIndex}else{return this.hls.nextAutoLevel}},set:function(e){this.level=e;if(this.manualLevelIndex===-1){this.hls.nextAutoLevel=e}},enumerable:false,configurable:true});t.prototype.removeLevel=function(e,t){var r=this;var i=function(e,r){return r!==t};var a=this._levels.filter((function(a,n){if(n!==e){return true}if(a.url.length>1&&t!==undefined){a.url=a.url.filter(i);if(a.audioGroupIds){a.audioGroupIds=a.audioGroupIds.filter(i)}if(a.textGroupIds){a.textGroupIds=a.textGroupIds.filter(i)}a.urlId=0;return true}if(r.steering){r.steering.removeLevel(a)}return false}));this.hls.trigger(Events.LEVELS_UPDATED,{levels:a})};t.prototype.onLevelsUpdated=function(e,t){var r=t.levels;r.forEach((function(e,t){var r=e.details;if(r!=null&&r.fragments){r.fragments.forEach((function(e){e.level=t}))}}));this._levels=r};return t}(BasePlaylistController);function addGroupId(e,t,r){if(!r){return}if(t==="audio"){if(!e.audioGroupIds){e.audioGroupIds=[]}e.audioGroupIds[e.url.length-1]=r}else if(t==="text"){if(!e.textGroupIds){e.textGroupIds=[]}e.textGroupIds[e.url.length-1]=r}}function assignTrackIdsByGroup(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0;t[r]++}))}var FragmentState={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};var FragmentTracker=function(){function e(e){this.activePartLists=Object.create(null);this.endListFragments=Object.create(null);this.fragments=Object.create(null);this.timeRanges=Object.create(null);this.bufferPadding=.2;this.hls=void 0;this.hasGaps=false;this.hls=e;this._registerListeners()}e.prototype._registerListeners=function(){var e=this.hls;e.on(Events.BUFFER_APPENDED,this.onBufferAppended,this);e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this);e.on(Events.FRAG_LOADED,this.onFragLoaded,this)};e.prototype._unregisterListeners=function(){var e=this.hls;e.off(Events.BUFFER_APPENDED,this.onBufferAppended,this);e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this);e.off(Events.FRAG_LOADED,this.onFragLoaded,this)};e.prototype.destroy=function(){this._unregisterListeners();this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null};e.prototype.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r){for(var i=r.length;i--;){var a=r[i];if(!a){break}var n=a.end;if(a.start<=e&&n!==null&&e<=n){return a}}}return this.getBufferedFrag(e,t)};e.prototype.getBufferedFrag=function(e,t){var r=this.fragments;var i=Object.keys(r);for(var a=i.length;a--;){var n=r[i[a]];if((n==null?void 0:n.body.type)===t&&n.buffered){var s=n.body;if(s.start<=e&&e<=s.end){return s}}}return null};e.prototype.detectEvictedFragments=function(e,t,r,i){var a=this;if(this.timeRanges){this.timeRanges[e]=t}var n=(i==null?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(i){var s=a.fragments[i];if(!s){return}if(n>=s.body.sn){return}if(!s.buffered&&!s.loaded){if(s.body.type===r){a.removeFragment(s.body)}return}var o=s.range[e];if(!o){return}o.time.some((function(e){var r=!a.isTimeBuffered(e.startPTS,e.endPTS,t);if(r){a.removeFragment(s.body)}return r}))}))};e.prototype.detectPartialFragments=function(e){var t=this;var r=this.timeRanges;var i=e.frag,a=e.part;if(!r||i.sn==="initSegment"){return}var n=getFragmentKey(i);var s=this.fragments[n];if(!s||s.buffered&&i.gap){return}var o=!i.relurl;Object.keys(r).forEach((function(e){var n=i.elementaryStreams[e];if(!n){return}var l=r[e];var u=o||n.partial===true;s.range[e]=t.getBufferedTimes(i,a,u,l)}));s.loaded=null;if(Object.keys(s.range).length){s.buffered=true;var l=s.body.endList=i.endList||s.body.endList;if(l){this.endListFragments[s.body.type]=s}if(!isPartial(s)){this.removeParts(i.sn-1,i.type)}}else{this.removeFragment(s.body)}};e.prototype.removeParts=function(e,t){var r=this.activePartLists[t];if(!r){return}this.activePartLists[t]=r.filter((function(t){return t.fragment.sn>=e}))};e.prototype.fragBuffered=function(e,t){var r=getFragmentKey(e);var i=this.fragments[r];if(!i&&t){i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:false,range:Object.create(null)};if(e.gap){this.hasGaps=true}}if(i){i.loaded=null;i.buffered=true}};e.prototype.getBufferedTimes=function(e,t,r,i){var a={time:[],partial:r};var n=e.start;var s=e.end;var o=e.minEndPTS||s;var l=e.maxStartPTS||n;for(var u=0;u<i.length;u++){var f=i.start(u)-this.bufferPadding;var c=i.end(u)+this.bufferPadding;if(l>=f&&o<=c){a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))});break}else if(n<c&&s>f){a.partial=true;a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))})}else if(s<=f){break}}return a};e.prototype.getPartialFragment=function(e){var t=null;var r;var i;var a;var n=0;var s=this,o=s.bufferPadding,l=s.fragments;Object.keys(l).forEach((function(s){var u=l[s];if(!u){return}if(isPartial(u)){i=u.body.start-o;a=u.body.end+o;if(e>=i&&e<=a){r=Math.min(e-i,a-e);if(n<=r){t=u.body;n=r}}}}));return t};e.prototype.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==undefined&&(t.buffered||isPartial(t))};e.prototype.getState=function(e){var t=getFragmentKey(e);var r=this.fragments[t];if(r){if(!r.buffered){return FragmentState.APPENDING}else if(isPartial(r)){return FragmentState.PARTIAL}else{return FragmentState.OK}}return FragmentState.NOT_LOADED};e.prototype.isTimeBuffered=function(e,t,r){var i;var a;for(var n=0;n<r.length;n++){i=r.start(n)-this.bufferPadding;a=r.end(n)+this.bufferPadding;if(e>=i&&t<=a){return true}if(t<=i){return false}}return false};e.prototype.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if(r.sn==="initSegment"||r.bitrateTest){return}var a=i?null:t;var n=getFragmentKey(r);this.fragments[n]={body:r,appendedPTS:null,loaded:a,buffered:false,range:Object.create(null)}};e.prototype.onBufferAppended=function(e,t){var r=this;var i=t.frag,a=t.part,n=t.timeRanges;if(i.sn==="initSegment"){return}var s=i.type;if(a){var o=this.activePartLists[s];if(!o){this.activePartLists[s]=o=[]}o.push(a)}this.timeRanges=n;Object.keys(n).forEach((function(e){var t=n[e];r.detectEvictedFragments(e,t,s,a)}))};e.prototype.onFragBuffered=function(e,t){this.detectPartialFragments(t)};e.prototype.hasFragment=function(e){var t=getFragmentKey(e);return!!this.fragments[t]};e.prototype.hasParts=function(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)};e.prototype.removeFragmentsInRange=function(e,t,r,i,a){var n=this;if(i&&!this.hasGaps){return}Object.keys(this.fragments).forEach((function(s){var o=n.fragments[s];if(!o){return}var l=o.body;if(l.type!==r||i&&!l.gap){return}if(l.start<t&&l.end>e&&(o.buffered||a)){n.removeFragment(l)}}))};e.prototype.removeFragment=function(e){var t=getFragmentKey(e);e.stats.loaded=0;e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter((function(e){return e.fragment.sn!==i}))}delete this.fragments[t];if(e.endList){delete this.endListFragments[e.type]}};e.prototype.removeAllFragments=function(){this.fragments=Object.create(null);this.endListFragments=Object.create(null);this.activePartLists=Object.create(null);this.hasGaps=false};return e}();function isPartial(e){var t,r,i;return e.buffered&&(e.body.gap||((t=e.range.video)==null?void 0:t.partial)||((r=e.range.audio)==null?void 0:r.partial)||((i=e.range.audiovideo)==null?void 0:i.partial))}function getFragmentKey(e){return"".concat(e.type,"_").concat(e.level,"_").concat(e.urlId,"_").concat(e.sn)}var MIN_CHUNK_SIZE=Math.pow(2,17);var FragmentLoader=function(){function e(e){this.config=void 0;this.loader=null;this.partLoadTimeout=-1;this.config=e}e.prototype.destroy=function(){if(this.loader){this.loader.destroy();this.loader=null}};e.prototype.abort=function(){if(this.loader){this.loader.abort()}};e.prototype.load=function(e,t){var r=this;var i=e.url;if(!i){return Promise.reject(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:false,frag:e,error:new Error("Fragment does not have a ".concat(i?"part list":"url")),networkDetails:null}))}this.abort();var a=this.config;var n=a.fLoader;var s=a.loader;return new Promise((function(o,l){if(r.loader){r.loader.destroy()}if(e.gap){if(e.tagList.some((function(e){return e[0]==="GAP"}))){l(createGapLoadError(e));return}else{e.gap=false}}var u=r.loader=e.loader=n?new n(a):new s(a);var f=createLoaderContext(e);var c=getLoaderConfigWithoutReties(a.fragLoadPolicy.default);var d={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?Infinity:MIN_CHUNK_SIZE};e.stats=u.stats;u.load(f,d,{onSuccess:function(t,i,a,n){r.resetLoader(e,u);var s=t.data;if(a.resetIV&&e.decryptdata){e.decryptdata.iv=new Uint8Array(s.slice(0,16));s=s.slice(16)}o({frag:e,part:null,payload:s,networkDetails:n})},onError:function(t,a,n,s){r.resetLoader(e,u);l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:false,frag:e,response:_objectSpread2({url:i,data:undefined},t),error:new Error("HTTP Error ".concat(t.code," ").concat(t.text)),networkDetails:n,stats:s}))},onAbort:function(t,i,a){r.resetLoader(e,u);l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.INTERNAL_ABORTED,fatal:false,frag:e,error:new Error("Aborted"),networkDetails:a,stats:t}))},onTimeout:function(t,i,a){r.resetLoader(e,u);l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,error:new Error("Timeout after ".concat(d.timeout,"ms")),networkDetails:a,stats:t}))},onProgress:function(r,i,a,n){if(t){t({frag:e,part:null,payload:a,networkDetails:n})}}})}))};e.prototype.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config;var n=a.fLoader;var s=a.loader;return new Promise((function(o,l){if(i.loader){i.loader.destroy()}if(e.gap||t.gap){l(createGapLoadError(e,t));return}var u=i.loader=e.loader=n?new n(a):new s(a);var f=createLoaderContext(e,t);var c=getLoaderConfigWithoutReties(a.fragLoadPolicy.default);var d={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:MIN_CHUNK_SIZE};t.stats=u.stats;u.load(f,d,{onSuccess:function(a,n,s,l){i.resetLoader(e,u);i.updateStatsFromPart(e,t);var f={frag:e,part:t,payload:a.data,networkDetails:l};r(f);o(f)},onError:function(r,a,n,s){i.resetLoader(e,u);l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_ERROR,fatal:false,frag:e,part:t,response:_objectSpread2({url:f.url,data:undefined},r),error:new Error("HTTP Error ".concat(r.code," ").concat(r.text)),networkDetails:n,stats:s}))},onAbort:function(r,a,n){e.stats.aborted=t.stats.aborted;i.resetLoader(e,u);l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.INTERNAL_ABORTED,fatal:false,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:function(r,a,n){i.resetLoader(e,u);l(new LoadError({type:ErrorTypes.NETWORK_ERROR,details:ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:false,frag:e,part:t,error:new Error("Timeout after ".concat(d.timeout,"ms")),networkDetails:n,stats:r}))}})}))};e.prototype.updateStatsFromPart=function(e,t){var r=e.stats;var i=t.stats;var a=i.total;r.loaded+=i.loaded;if(a){var n=Math.round(e.duration/t.duration);var s=Math.min(Math.round(r.loaded/a),n);var o=n-s;var l=o*Math.round(r.loaded/s);r.total=r.loaded+l}else{r.total=Math.max(r.loaded,r.total)}var u=r.loading;var f=i.loading;if(u.start){u.first+=f.first-f.start}else{u.start=f.start;u.first=f.first}u.end=f.end};e.prototype.resetLoader=function(e,t){e.loader=null;if(this.loader===t){self.clearTimeout(this.partLoadTimeout);this.loader=null}t.destroy()};return e}();function createLoaderContext(e,t){if(t===void 0){t=null}var r=t||e;var i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0};var a=r.byteRangeStartOffset;var n=r.byteRangeEndOffset;if(isFiniteNumber(a)&&isFiniteNumber(n)){var s;var o=a;var l=n;if(e.sn==="initSegment"&&((s=e.decryptdata)==null?void 0:s.method)==="AES-128"){var u=n-a;if(u%16){l=n+(16-u%16)}if(a!==0){i.resetIV=true;o=a-16}}i.rangeStart=o;i.rangeEnd=l}return i}function createGapLoadError(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found"));var i={type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_GAP,fatal:false,frag:e,error:r,networkDetails:null};if(t){i.part=t}(t?t:e).stats.aborted=true;return new LoadError(i)}var LoadError=function(e){__extends(t,e);function t(t){var r=e.call(this,t.error.message)||this;r.data=void 0;r.data=t;return r}return t}(Error);var KeyLoader=function(){function e(e){this.config=void 0;this.keyUriToKeyInfo={};this.emeController=null;this.config=e}e.prototype.abort=function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type){return}r.abort()}}};e.prototype.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];if(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption){delete this.keyUriToKeyInfo[e]}}};e.prototype.destroy=function(){this.detach();for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;if(t){t.destroy()}}this.keyUriToKeyInfo={}};e.prototype.createKeyLoadError=function(e,t,r,i,a){if(t===void 0){t=ErrorDetails.KEY_LOAD_ERROR}return new LoadError({type:ErrorTypes.NETWORK_ERROR,details:t,fatal:false,frag:e,response:a,error:r,networkDetails:i})};e.prototype.loadClear=function(e,t){if(this.emeController&&this.config.emeEnabled){var r=e.sn,i=e.cc;var a=function(e){var a=t[e];if(i<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){n.emeController.selectKeySystemFormat(a).then((function(e){a.setKeyFormat(e)}));return"break"}};var n=this;for(var s=0;s<t.length;s++){var o=a(s);if(o==="break")break}}};e.prototype.load=function(e){var t=this;if(!e.decryptdata&&e.encrypted&&this.emeController){return this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)}))}return this.loadInternal(e)};e.prototype.loadInternal=function(e,t){var r,i;if(t){e.setKeyFormat(t)}var a=e.decryptdata;if(!a){var n=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,n))}var s=a.uri;if(!s){return Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(s,'"'))))}var o=this.keyUriToKeyInfo[s];if((r=o)!=null&&r.decryptdata.key){a.key=o.decryptdata.key;return Promise.resolve({frag:e,keyInfo:o})}if((i=o)!=null&&i.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case undefined:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then((function(t){a.key=t.keyInfo.decryptdata.key;return{frag:e,keyInfo:o}}))}}o=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null};switch(a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":if(a.keyFormat==="identity"){return this.loadKeyHTTP(o,e)}return this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,ErrorDetails.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(a.method,'"'))))}};e.prototype.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i){return(e.keyLoadPromise=i.then((function(t){e.mediaKeySessionContext=t;return r}))).catch((function(t){e.keyLoadPromise=null;throw t}))}}return Promise.resolve(r)};e.prototype.loadKeyHTTP=function(e,t){var r=this;var i=this.config;var a=i.loader;var n=new a(i);t.keyLoader=e.loader=n;return e.keyLoadPromise=new Promise((function(a,s){var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri};var l=i.keyLoadPolicy.default;var u={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};var f={onSuccess:function(e,t,i,n){var o=i.frag,l=i.keyInfo,u=i.url;if(!o.decryptdata||l!==r.keyUriToKeyInfo[u]){return s(r.createKeyLoadError(o,ErrorDetails.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n))}l.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data);o.keyLoader=null;l.loader=null;a({frag:o,keyInfo:l})},onError:function(e,i,a,n){r.resetLoader(i);s(r.createKeyLoadError(t,ErrorDetails.KEY_LOAD_ERROR,new Error("HTTP Error ".concat(e.code," loading key ").concat(e.text)),a,_objectSpread2({url:o.url,data:undefined},e)))},onTimeout:function(e,i,a){r.resetLoader(i);s(r.createKeyLoadError(t,ErrorDetails.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:function(e,i,a){r.resetLoader(i);s(r.createKeyLoadError(t,ErrorDetails.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};n.load(o,u,f)}))};e.prototype.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url;var a=r.loader;if(t.keyLoader===a){t.keyLoader=null;r.loader=null}delete this.keyUriToKeyInfo[i];if(a){a.destroy()}};return e}();var TaskLoop=function(){function e(){this._boundTick=void 0;this._tickTimer=null;this._tickInterval=null;this._tickCallCount=0;this._boundTick=this.tick.bind(this)}e.prototype.destroy=function(){this.onHandlerDestroying();this.onHandlerDestroyed()};e.prototype.onHandlerDestroying=function(){this.clearNextTick();this.clearInterval()};e.prototype.onHandlerDestroyed=function(){};e.prototype.hasInterval=function(){return!!this._tickInterval};e.prototype.hasNextTick=function(){return!!this._tickTimer};e.prototype.setInterval=function(e){if(!this._tickInterval){this._tickCallCount=0;this._tickInterval=self.setInterval(this._boundTick,e);return true}return false};e.prototype.clearInterval=function(){if(this._tickInterval){self.clearInterval(this._tickInterval);this._tickInterval=null;return true}return false};e.prototype.clearNextTick=function(){if(this._tickTimer){self.clearTimeout(this._tickTimer);this._tickTimer=null;return true}return false};e.prototype.tick=function(){this._tickCallCount++;if(this._tickCallCount===1){this.doTick();if(this._tickCallCount>1){this.tickImmediate()}this._tickCallCount=0}};e.prototype.tickImmediate=function(){this.clearNextTick();this._tickTimer=self.setTimeout(this._boundTick,0)};e.prototype.doTick=function(){};return e}();var noopBuffered={length:0,start:function(){return 0},end:function(){return 0}};var BufferHelper=function(){function e(){}e.isBuffered=function(t,r){try{if(t){var i=e.getBuffered(t);for(var a=0;a<i.length;a++){if(r>=i.start(a)&&r<=i.end(a)){return true}}}}catch(e){}return false};e.bufferInfo=function(t,r,i){try{if(t){var a=e.getBuffered(t);var n=[];var s=void 0;for(s=0;s<a.length;s++){n.push({start:a.start(s),end:a.end(s)})}return this.bufferedInfo(n,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:undefined}};e.bufferedInfo=function(e,t,r){t=Math.max(0,t);e.sort((function(e,t){var r=e.start-t.start;if(r){return r}else{return t.end-e.end}}));var i=[];if(r){for(var a=0;a<e.length;a++){var n=i.length;if(n){var s=i[n-1].end;if(e[a].start-s<r){if(e[a].end>s){i[n-1].end=e[a].end}}else{i.push(e[a])}}else{i.push(e[a])}}}else{i=e}var o=0;var l;var u=t;var f=t;for(var a=0;a<i.length;a++){var c=i[a].start;var d=i[a].end;if(t+r>=c&&t<d){u=c;f=d;o=f-t}else if(t+r<c){l=c;break}}return{len:o,start:u||0,end:f||0,nextStart:l}};e.getBuffered=function(e){try{return e.buffered}catch(e){logger.log("failed to get media.buffered",e);return noopBuffered}};return e}();var ChunkMetadata=function(){function e(e,t,r,i,a,n){if(i===void 0){i=0}if(a===void 0){a=-1}if(n===void 0){n=false}this.level=void 0;this.sn=void 0;this.part=void 0;this.id=void 0;this.size=void 0;this.partial=void 0;this.transmuxing=getNewPerformanceTiming();this.buffering={audio:getNewPerformanceTiming(),video:getNewPerformanceTiming(),audiovideo:getNewPerformanceTiming()};this.level=e;this.sn=t;this.id=r;this.size=i;this.part=a;this.partial=n}return e}();function getNewPerformanceTiming(){return{start:0,executeStart:0,executeEnd:0,end:0}}function findFirstFragWithCC(e,t){var r=null;for(var i=0,a=e.length;i<a;i++){var n=e[i];if(n&&n.cc===t){r=n;break}}return r}function shouldAlignOnDiscontinuities(e,t,r){if(t.details){if(r.endCC>r.startCC||e&&e.cc<r.startCC){return true}}return false}function findDiscontinuousReferenceFrag(e,t,r){if(r===void 0){r=0}var i=e.fragments;var a=t.fragments;if(!a.length||!i.length){logger.log("No fragments to align");return}var n=findFirstFragWithCC(i,a[0].cc);if(!n||n&&!n.startPTS){logger.log("No frag in previous level to align on");return}return n}function adjustFragmentStart(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r;e.endPTS=r+e.duration}}function adjustSlidingStart(e,t){var r=t.fragments;for(var i=0,a=r.length;i<a;i++){adjustFragmentStart(r[i],e)}if(t.fragmentHint){adjustFragmentStart(t.fragmentHint,e)}t.alignedSliding=true}function alignStream(e,t,r){if(!t){return}alignDiscontinuities(e,r,t);if(!r.alignedSliding&&t.details){alignPDT(r,t.details)}if(!r.alignedSliding&&t.details&&!r.skippedSegments){adjustSliding(t.details,r)}}function alignDiscontinuities(e,t,r){if(shouldAlignOnDiscontinuities(e,r,t)){var i=findDiscontinuousReferenceFrag(r.details,t);if(i&&isFiniteNumber(i.start)){logger.log("Adjusting PTS using last level due to CC increase within current level ".concat(t.url));adjustSlidingStart(i.start,t)}}}function alignPDT(e,t){if(!t.fragments.length||!e.hasProgramDateTime||!t.hasProgramDateTime){return}var r=t.fragments[0].programDateTime;var i=e.fragments[0].programDateTime;var a=(i-r)/1e3+t.fragments[0].start;if(a&&isFiniteNumber(a)){logger.log("Adjusting PTS using programDateTime delta ".concat(i-r,"ms, sliding:").concat(a.toFixed(3)," ").concat(e.url," "));adjustSlidingStart(a,e)}}function alignMediaPlaylistByPDT(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime){return}var r=e.fragments;var i=t.fragments;if(!r.length||!i.length){return}var a=Math.round(i.length/2)-1;var n=i[a];var s=findFirstFragWithCC(r,n.cc)||r[Math.round(r.length/2)-1];var o=n.programDateTime;var l=s.programDateTime;if(o===null||l===null){return}var u=(l-o)/1e3-(s.start-n.start);adjustSlidingStart(u,e)}var AESCrypto=function(){function e(e,t){this.subtle=void 0;this.aesIV=void 0;this.subtle=e;this.aesIV=t}e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)};return e}();var FastAESKey=function(){function e(e,t){this.subtle=void 0;this.key=void 0;this.subtle=e;this.key=t}e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},false,["encrypt","decrypt"])};return e}();function removePadding(e){var t=e.byteLength;var r=t&&new DataView(e.buffer).getUint8(t-1);if(r){return sliceUint8(e,0,t-r)}return e}var AESDecryptor=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54];this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)];this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)];this.sBox=new Uint32Array(256);this.invSBox=new Uint32Array(256);this.key=new Uint32Array(0);this.ksRows=0;this.keySize=0;this.keySchedule=void 0;this.invKeySchedule=void 0;this.initTable()}e.prototype.uint8ArrayToUint32Array_=function(e){var t=new DataView(e);var r=new Uint32Array(4);for(var i=0;i<4;i++){r[i]=t.getUint32(i*4)}return r};e.prototype.initTable=function(){var e=this.sBox;var t=this.invSBox;var r=this.subMix;var i=r[0];var a=r[1];var n=r[2];var s=r[3];var o=this.invSubMix;var l=o[0];var u=o[1];var f=o[2];var c=o[3];var d=new Uint32Array(256);var h=0;var v=0;var p=0;for(p=0;p<256;p++){if(p<128){d[p]=p<<1}else{d[p]=p<<1^283}}for(p=0;p<256;p++){var g=v^v<<1^v<<2^v<<3^v<<4;g=g>>>8^g&255^99;e[h]=g;t[g]=h;var m=d[h];var y=d[m];var E=d[y];var T=d[g]*257^g*16843008;i[h]=T<<24|T>>>8;a[h]=T<<16|T>>>16;n[h]=T<<8|T>>>24;s[h]=T;T=E*16843009^y*65537^m*257^h*16843008;l[g]=T<<24|T>>>8;u[g]=T<<16|T>>>16;f[g]=T<<8|T>>>24;c[g]=T;if(!h){h=v=1}else{h=m^d[d[d[E^m]]];v^=d[d[v]]}}};e.prototype.expandKey=function(e){var t=this.uint8ArrayToUint32Array_(e);var r=true;var i=0;while(i<t.length&&r){r=t[i]===this.key[i];i++}if(r){return}this.key=t;var a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8){throw new Error("Invalid aes key size="+a)}var n=this.ksRows=(a+6+1)*4;var s;var o;var l=this.keySchedule=new Uint32Array(n);var u=this.invKeySchedule=new Uint32Array(n);var f=this.sBox;var c=this.rcon;var d=this.invSubMix;var h=d[0];var v=d[1];var p=d[2];var g=d[3];var m;var y;for(s=0;s<n;s++){if(s<a){m=l[s]=t[s];continue}y=m;if(s%a===0){y=y<<8|y>>>24;y=f[y>>>24]<<24|f[y>>>16&255]<<16|f[y>>>8&255]<<8|f[y&255];y^=c[s/a|0]<<24}else if(a>6&&s%a===4){y=f[y>>>24]<<24|f[y>>>16&255]<<16|f[y>>>8&255]<<8|f[y&255]}l[s]=m=(l[s-a]^y)>>>0}for(o=0;o<n;o++){s=n-o;if(o&3){y=l[s]}else{y=l[s-4]}if(o<4||s<=4){u[o]=y}else{u[o]=h[f[y>>>24]]^v[f[y>>>16&255]]^p[f[y>>>8&255]]^g[f[y&255]]}u[o]=u[o]>>>0}};e.prototype.networkToHostOrderSwap=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24};e.prototype.decrypt=function(e,t,r){var i=this.keySize+6;var a=this.invKeySchedule;var n=this.invSBox;var s=this.invSubMix;var o=s[0];var l=s[1];var u=s[2];var f=s[3];var c=this.uint8ArrayToUint32Array_(r);var d=c[0];var h=c[1];var v=c[2];var p=c[3];var g=new Int32Array(e);var m=new Int32Array(g.length);var y,E,T,S;var A,L,b,R;var D,I,C,_;var k,P;var w=this.networkToHostOrderSwap;while(t<g.length){D=w(g[t]);I=w(g[t+1]);C=w(g[t+2]);_=w(g[t+3]);A=D^a[0];L=_^a[1];b=C^a[2];R=I^a[3];k=4;for(P=1;P<i;P++){y=o[A>>>24]^l[L>>16&255]^u[b>>8&255]^f[R&255]^a[k];E=o[L>>>24]^l[b>>16&255]^u[R>>8&255]^f[A&255]^a[k+1];T=o[b>>>24]^l[R>>16&255]^u[A>>8&255]^f[L&255]^a[k+2];S=o[R>>>24]^l[A>>16&255]^u[L>>8&255]^f[b&255]^a[k+3];A=y;L=E;b=T;R=S;k=k+4}y=n[A>>>24]<<24^n[L>>16&255]<<16^n[b>>8&255]<<8^n[R&255]^a[k];E=n[L>>>24]<<24^n[b>>16&255]<<16^n[R>>8&255]<<8^n[A&255]^a[k+1];T=n[b>>>24]<<24^n[R>>16&255]<<16^n[A>>8&255]<<8^n[L&255]^a[k+2];S=n[R>>>24]<<24^n[A>>16&255]<<16^n[L>>8&255]<<8^n[b&255]^a[k+3];m[t]=w(y^d);m[t+1]=w(S^h);m[t+2]=w(T^v);m[t+3]=w(E^p);d=D;h=I;v=C;p=_;t=t+4}return m.buffer};return e}();var CHUNK_SIZE=16;var Decrypter=function(){function e(e,t){var r=t===void 0?{}:t,i=r.removePKCS7Padding,a=i===void 0?true:i;this.logEnabled=true;this.removePKCS7Padding=void 0;this.subtle=null;this.softwareDecrypter=null;this.key=null;this.fastAesKey=null;this.remainderData=null;this.currentIV=null;this.currentResult=null;this.useSoftware=void 0;this.useSoftware=e.enableSoftwareAES;this.removePKCS7Padding=a;if(a){try{var n=self.crypto;if(n){this.subtle=n.subtle||n.webkitSubtle}}catch(e){}}if(this.subtle===null){this.useSoftware=true}}e.prototype.destroy=function(){this.subtle=null;this.softwareDecrypter=null;this.key=null;this.fastAesKey=null;this.remainderData=null;this.currentIV=null;this.currentResult=null};e.prototype.isSync=function(){return this.useSoftware};e.prototype.flush=function(){var e=this,t=e.currentResult,r=e.remainderData;if(!t||r){this.reset();return null}var i=new Uint8Array(t);this.reset();if(this.removePKCS7Padding){return removePadding(i)}return i};e.prototype.reset=function(){this.currentResult=null;this.currentIV=null;this.remainderData=null;if(this.softwareDecrypter){this.softwareDecrypter=null}};e.prototype.decrypt=function(e,t,r){var i=this;if(this.useSoftware){return new Promise((function(a,n){i.softwareDecrypt(new Uint8Array(e),t,r);var s=i.flush();if(s){a(s.buffer)}else{n(new Error("[softwareDecrypt] Failed to decrypt data"))}}))}return this.webCryptoDecrypt(new Uint8Array(e),t,r)};e.prototype.softwareDecrypt=function(e,t,r){var i=this,a=i.currentIV,n=i.currentResult,s=i.remainderData;this.logOnce("JS AES decrypt");if(s){e=appendUint8Array(s,e);this.remainderData=null}var o=this.getValidChunk(e);if(!o.length){return null}if(a){r=a}var l=this.softwareDecrypter;if(!l){l=this.softwareDecrypter=new AESDecryptor}l.expandKey(t);var u=n;this.currentResult=l.decrypt(o.buffer,0,r);this.currentIV=sliceUint8(o,-16).buffer;if(!u){return null}return u};e.prototype.webCryptoDecrypt=function(e,t,r){var i=this;var a=this.subtle;if(this.key!==t||!this.fastAesKey){this.key=t;this.fastAesKey=new FastAESKey(a,t)}return this.fastAesKey.expandKey().then((function(t){if(!a){return Promise.reject(new Error("web crypto not initialized"))}i.logOnce("WebCrypto AES decrypt");var n=new AESCrypto(a,new Uint8Array(r));return n.decrypt(e.buffer,t)})).catch((function(a){logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(a.name,": ").concat(a.message));return i.onWebCryptoError(e,t,r)}))};e.prototype.onWebCryptoError=function(e,t,r){this.useSoftware=true;this.logEnabled=true;this.softwareDecrypt(e,t,r);var i=this.flush();if(i){return i.buffer}throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")};e.prototype.getValidChunk=function(e){var t=e;var r=e.length-e.length%CHUNK_SIZE;if(r!==e.length){t=sliceUint8(e,0,r);this.remainderData=sliceUint8(e,r)}return t};e.prototype.logOnce=function(e){if(!this.logEnabled){return}logger.log("[decrypter]: ".concat(e));this.logEnabled=false};return e}();var TimeRanges={toString:function(e){var t="";var r=e.length;for(var i=0;i<r;i++){t+="[".concat(e.start(i).toFixed(3),"-").concat(e.end(i).toFixed(3),"]")}return t}};var State={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};var BaseStreamController=function(e){__extends(t,e);function t(t,r,i,a,n){var s=e.call(this)||this;s.hls=void 0;s.fragPrevious=null;s.fragCurrent=null;s.fragmentTracker=void 0;s.transmuxer=null;s._state=State.STOPPED;s.playlistType=void 0;s.media=null;s.mediaBuffer=null;s.config=void 0;s.bitrateTest=false;s.lastCurrentTime=0;s.nextLoadPosition=0;s.startPosition=0;s.startTimeOffset=null;s.loadedmetadata=false;s.retryDate=0;s.levels=null;s.fragmentLoader=void 0;s.keyLoader=void 0;s.levelLastLoaded=null;s.startFragRequested=false;s.decrypter=void 0;s.initPTS=[];s.onvseeking=null;s.onvended=null;s.logPrefix="";s.log=void 0;s.warn=void 0;s.playlistType=n;s.logPrefix=a;s.log=logger.log.bind(logger,"".concat(a,":"));s.warn=logger.warn.bind(logger,"".concat(a,":"));s.hls=t;s.fragmentLoader=new FragmentLoader(t.config);s.keyLoader=i;s.fragmentTracker=r;s.config=t.config;s.decrypter=new Decrypter(t.config);t.on(Events.MANIFEST_LOADED,s.onManifestLoaded,s);return s}t.prototype.doTick=function(){this.onTickEnd()};t.prototype.onTickEnd=function(){};t.prototype.startLoad=function(e){};t.prototype.stopLoad=function(){this.fragmentLoader.abort();this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;if(e!=null&&e.loader){e.abortRequests();this.fragmentTracker.removeFragment(e)}this.resetTransmuxer();this.fragCurrent=null;this.fragPrevious=null;this.clearInterval();this.clearNextTick();this.state=State.STOPPED};t.prototype._streamEnded=function(e,t){if(t.live||e.nextStart||!e.end||!this.media){return false}var r=t.partList;if(r!=null&&r.length){var i=r[r.length-1];var a=BufferHelper.isBuffered(this.media,i.start+i.duration/2);return a}var n=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)};t.prototype.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}};t.prototype.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this);this.onvended=this.onMediaEnded.bind(this);r.addEventListener("seeking",this.onvseeking);r.addEventListener("ended",this.onvended);var i=this.config;if(this.levels&&i.autoStartLoad&&this.state===State.STOPPED){this.startLoad(i.startPosition)}};t.prototype.onMediaDetaching=function(){var e=this.media;if(e!=null&&e.ended){this.log("MSE detaching and video ended, reset startPosition");this.startPosition=this.lastCurrentTime=0}if(e&&this.onvseeking&&this.onvended){e.removeEventListener("seeking",this.onvseeking);e.removeEventListener("ended",this.onvended);this.onvseeking=this.onvended=null}if(this.keyLoader){this.keyLoader.detach()}this.media=this.mediaBuffer=null;this.loadedmetadata=false;this.fragmentTracker.removeAllFragments();this.stopLoad()};t.prototype.onMediaSeeking=function(){var e=this,t=e.config,r=e.fragCurrent,i=e.media,a=e.mediaBuffer,n=e.state;var s=i?i.currentTime:0;var o=BufferHelper.bufferInfo(a?a:i,s,t.maxBufferHole);this.log("media seeking to ".concat(isFiniteNumber(s)?s.toFixed(3):s,", state: ").concat(n));if(this.state===State.ENDED){this.resetLoadingState()}else if(r){var l=t.maxFragLookUpTolerance;var u=r.start-l;var f=r.start+r.duration+l;if(!o.len||f<o.start||u>o.end){var c=s>f;if(s<u||c){if(c&&r.loader){this.log("seeking outside of buffer while fragment load in progress, cancel fragment load");r.abortRequests();this.resetLoadingState()}this.fragPrevious=null}}}if(i){this.fragmentTracker.removeFragmentsInRange(s,Infinity,this.playlistType,true);this.lastCurrentTime=s}if(!this.loadedmetadata&&!o.len){this.nextLoadPosition=this.startPosition=s}this.tickImmediate()};t.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0};t.prototype.onManifestLoaded=function(e,t){this.startTimeOffset=t.startTimeOffset;this.initPTS=[]};t.prototype.onHandlerDestroying=function(){this.stopLoad();e.prototype.onHandlerDestroying.call(this)};t.prototype.onHandlerDestroyed=function(){this.state=State.STOPPED;if(this.fragmentLoader){this.fragmentLoader.destroy()}if(this.keyLoader){this.keyLoader.destroy()}if(this.decrypter){this.decrypter.destroy()}this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null;e.prototype.onHandlerDestroyed.call(this)};t.prototype.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)};t.prototype._loadFragForPlayback=function(e,t,r){var i=this;var a=function(t){if(i.fragContextChanged(e)){i.warn("Fragment ".concat(e.sn).concat(t.part?" p: "+t.part.index:""," of level ").concat(e.level," was dropped during download."));i.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++;i._handleFragmentLoadProgress(t)};this._doFragLoad(e,t,r,a).then((function(t){if(!t){return}var r=i.state;if(i.fragContextChanged(e)){if(r===State.FRAG_LOADING||!i.fragCurrent&&r===State.PARSING){i.fragmentTracker.removeFragment(e);i.state=State.IDLE}return}if("payload"in t){i.log("Loaded fragment ".concat(e.sn," of level ").concat(e.level));i.hls.trigger(Events.FRAG_LOADED,t)}i._handleFragmentLoadComplete(t)})).catch((function(t){if(i.state===State.STOPPED||i.state===State.ERROR){return}i.warn(t);i.resetFragmentLoading(e)}))};t.prototype.clearTrackerIfNeeded=function(e){var t;var r=this.fragmentTracker;var i=r.getState(e);if(i===FragmentState.APPENDING){var a=e.type;var n=this.getFwdBufferInfo(this.mediaBuffer,a);var s=Math.max(e.duration,n?n.len:this.config.maxBufferLength);if(this.reduceMaxBufferLength(s)){r.removeFragment(e)}}else if(((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0){r.removeAllFragments()}else if(r.hasParts(e.type)){r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type});if(r.getState(e)===FragmentState.PARTIAL){r.removeFragment(e)}}};t.prototype.checkLiveUpdate=function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}if(!e.fragments[0]){e.deltaUpdateFailed=true}};t.prototype.flushMainBuffer=function(e,t,r){if(r===void 0){r=null}if(!(e-t)){return}var i={startOffset:e,endOffset:t,type:r};this.hls.trigger(Events.BUFFER_FLUSHING,i)};t.prototype._loadInitSegment=function(e,t){var r=this;this._doFragLoad(e,t).then((function(t){if(!t||r.fragContextChanged(e)||!r.levels){throw new Error("init load aborted")}return t})).then((function(t){var i=r.hls;var a=t.payload;var n=e.decryptdata;if(a&&a.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(a),n.key.buffer,n.iv.buffer).catch((function(t){i.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_DECRYPT_ERROR,fatal:false,error:t,reason:t.message,frag:e});throw t})).then((function(r){var a=self.performance.now();i.trigger(Events.FRAG_DECRYPTED,{frag:e,payload:r,stats:{tstart:s,tdecrypt:a}});t.payload=r;return t}))}return t})).then((function(i){var a=r,n=a.fragCurrent,s=a.hls,o=a.levels;if(!o){throw new Error("init load aborted, missing levels")}var l=e.stats;r.state=State.IDLE;t.fragmentError=0;e.data=new Uint8Array(i.payload);l.parsing.start=l.buffering.start=self.performance.now();l.parsing.end=l.buffering.end=self.performance.now();if(i.frag===n){s.trigger(Events.FRAG_BUFFERED,{stats:l,frag:n,part:null,id:e.type})}r.tick()})).catch((function(t){if(r.state===State.STOPPED||r.state===State.ERROR){return}r.warn(t);r.resetFragmentLoading(e)}))};t.prototype.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId};t.prototype.fragBufferedComplete=function(e,t){var r,i,a,n;var s=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered ".concat(e.type," sn: ").concat(e.sn).concat(t?" part: "+t.index:""," of ").concat(this.playlistType===PlaylistLevelType.MAIN?"level":"track"," ").concat(e.level," (frag:[").concat(((r=e.startPTS)!=null?r:NaN).toFixed(3),"-").concat(((i=e.endPTS)!=null?i:NaN).toFixed(3),"] > buffer:").concat(s?TimeRanges.toString(BufferHelper.getBuffered(s)):"(detached)",")"));this.state=State.IDLE;if(!s){return}if(!this.loadedmetadata&&e.type==PlaylistLevelType.MAIN&&s.buffered.length&&((a=this.fragCurrent)==null?void 0:a.sn)===((n=this.fragPrevious)==null?void 0:n.sn)){this.loadedmetadata=true;this.seekToStartPos()}this.tick()};t.prototype.seekToStartPos=function(){};t.prototype._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(!t){return}var r=e.frag,i=e.part,a=e.partsLoaded;var n=!a||a.length===0||a.some((function(e){return!e}));var s=new ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(s)};t.prototype._handleFragmentLoadProgress=function(e){};t.prototype._doFragLoad=function(e,t,r,i){var a=this;if(r===void 0){r=null}var n;var s=t==null?void 0:t.details;if(!this.levels||!s){throw new Error("frag load aborted, missing level".concat(s?"":" detail","s"))}var o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)){this.log("Loading key for ".concat(e.sn," of [").concat(s.startSN,"-").concat(s.endSN,"], ").concat(this.logPrefix==="[stream-controller]"?"level":"track"," ").concat(e.level));this.state=State.KEY_LOADING;this.fragCurrent=e;o=this.keyLoader.load(e).then((function(e){if(!a.fragContextChanged(e.frag)){a.hls.trigger(Events.KEY_LOADED,e);if(a.state===State.KEY_LOADING){a.state=State.IDLE}return e}}));this.hls.trigger(Events.KEY_LOADING,{frag:e});if(this.fragCurrent===null){o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))}}else if(!e.encrypted&&s.encryptedFragments.length){this.keyLoader.loadClear(e,s.encryptedFragments)}r=Math.max(e.start,r||0);if(this.config.lowLatencyMode&&e.sn!=="initSegment"){var l=s.partList;if(l&&i){if(r>e.end&&s.fragmentHint){e=s.fragmentHint}var u=this.getNextPart(l,e,r);if(u>-1){var f=l[u];this.log("Loading part sn: ".concat(e.sn," p: ").concat(f.index," cc: ").concat(e.cc," of playlist [").concat(s.startSN,"-").concat(s.endSN,"] parts [0-").concat(u,"-").concat(l.length-1,"] ").concat(this.logPrefix==="[stream-controller]"?"level":"track",": ").concat(e.level,", target: ").concat(parseFloat(r.toFixed(3))));this.nextLoadPosition=f.start+f.duration;this.state=State.FRAG_LOADING;var c=void 0;if(o){c=o.then((function(r){if(!r||a.fragContextChanged(r.frag)){return null}return a.doFragPartsLoad(e,f,t,i)})).catch((function(e){return a.handleFragLoadError(e)}))}else{c=this.doFragPartsLoad(e,f,t,i).catch((function(e){return a.handleFragLoadError(e)}))}this.hls.trigger(Events.FRAG_LOADING,{frag:e,part:f,targetBufferTime:r});if(this.fragCurrent===null){return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts"))}return c}else if(!e.url||this.loadedEndOfParts(l,r)){return Promise.resolve(null)}}}this.log("Loading fragment ".concat(e.sn," cc: ").concat(e.cc," ").concat(s?"of ["+s.startSN+"-"+s.endSN+"] ":"").concat(this.logPrefix==="[stream-controller]"?"level":"track",": ").concat(e.level,", target: ").concat(parseFloat(r.toFixed(3))));if(isFiniteNumber(e.sn)&&!this.bitrateTest){this.nextLoadPosition=e.start+e.duration}this.state=State.FRAG_LOADING;var d=this.config.progressive;var h;if(d&&o){h=o.then((function(t){if(!t||a.fragContextChanged(t==null?void 0:t.frag)){return null}return a.fragmentLoader.load(e,i)})).catch((function(e){return a.handleFragLoadError(e)}))}else{h=Promise.all([this.fragmentLoader.load(e,d?i:undefined),o]).then((function(e){var t=e[0];if(!d&&t&&i){i(t)}return t})).catch((function(e){return a.handleFragLoadError(e)}))}this.hls.trigger(Events.FRAG_LOADING,{frag:e,targetBufferTime:r});if(this.fragCurrent===null){return Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING"))}return h};t.prototype.doFragPartsLoad=function(e,t,r,i){var a=this;return new Promise((function(n,s){var o;var l=[];var u=(o=r.details)==null?void 0:o.partList;var f=function(t){a.fragmentLoader.loadPart(e,t,i).then((function(i){l[t.index]=i;var s=i.part;a.hls.trigger(Events.FRAG_LOADED,i);var o=getPartWith(r,e.sn,t.index+1)||findPart(u,e.sn,t.index+1);if(o){f(o)}else{return n({frag:e,part:s,partsLoaded:l})}})).catch(s)};f(t)}))};t.prototype.handleFragLoadError=function(e){if("data"in e){var t=e.data;if(e.data&&t.details===ErrorDetails.INTERNAL_ABORTED){this.handleFragLoadAborted(t.frag,t.part)}else{this.hls.trigger(Events.ERROR,t)}}else{this.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,err:e,error:e,fatal:true})}return null};t.prototype._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(!t||this.state!==State.PARSING){if(!this.fragCurrent&&this.state!==State.STOPPED&&this.state!==State.ERROR){this.state=State.IDLE}return}var r=t.frag,i=t.part,a=t.level;var n=self.performance.now();r.stats.parsing.end=n;if(i){i.stats.parsing.end=n}this.updateLevelTiming(r,i,a,e.partial)};t.prototype.getCurrentContext=function(e){var t=this,r=t.levels,i=t.fragCurrent;var a=e.level,n=e.sn,s=e.part;if(!(r!=null&&r[a])){this.warn("Levels object was unset while buffering fragment ".concat(n," of level ").concat(a,". The current chunk will not be buffered."));return null}var o=r[a];var l=s>-1?getPartWith(o,n,s):null;var u=l?l.fragment:getFragmentWithSN(o,n,i);if(!u){return null}if(i&&i!==u){u.stats=i.stats}return{frag:u,part:l,level:o}};t.prototype.bufferFragmentData=function(e,t,r,i,a){var n;if(!e||this.state!==State.PARSING){return}var s=e.data1,o=e.data2;var l=s;if(s&&o){l=appendUint8Array(s,o)}if(!((n=l)!=null&&n.length)){return}var u={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:l};this.hls.trigger(Events.BUFFER_APPENDING,u);if(e.dropped&&e.independent&&!r){if(a){return}this.flushBufferGap(t)}};t.prototype.flushBufferGap=function(e){var t=this.media;if(!t){return}if(!BufferHelper.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}var r=t.currentTime;var i=BufferHelper.bufferInfo(t,r,0);var a=e.duration;var n=Math.min(this.config.maxFragLookUpTolerance*2,a*.25);var s=Math.max(Math.min(e.start-n,i.end-n),r+n);if(e.start-s>n){this.flushMainBuffer(s,e.start)}};t.prototype.getFwdBufferInfo=function(e,t){var r=this.getLoadPosition();if(!isFiniteNumber(r)){return null}return this.getFwdBufferInfoAtPos(e,r,t)};t.prototype.getFwdBufferInfoAtPos=function(e,t,r){var i=this.config.maxBufferHole;var a=BufferHelper.bufferInfo(e,t,i);if(a.len===0&&a.nextStart!==undefined){var n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&a.nextStart<n.end){return BufferHelper.bufferInfo(e,t,Math.max(a.nextStart,i))}}return a};t.prototype.getMaxBufferLength=function(e){var t=this.config;var r;if(e){r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength)}else{r=t.maxBufferLength}return Math.min(r,t.maxMaxBufferLength)};t.prototype.reduceMaxBufferLength=function(e){var t=this.config;var r=e||t.maxBufferLength;if(t.maxMaxBufferLength>=r){t.maxMaxBufferLength/=2;this.warn("Reduce max buffer length to ".concat(t.maxMaxBufferLength,"s"));return true}return false};t.prototype.getAppendedFrag=function(e,t){if(t===void 0){t=PlaylistLevelType.MAIN}var r=this.fragmentTracker.getAppendedFrag(e,PlaylistLevelType.MAIN);if(r&&"fragment"in r){return r.fragment}return r};t.prototype.getNextFragment=function(e,t){var r=t.fragments;var i=r.length;if(!i){return null}var a=this.config;var n=r[0].start;var s;if(t.live){var o=a.initialLiveManifestSize;if(i<o){this.warn("Not enough fragments to start playback (have: ".concat(i,", need: ").concat(o,")"));return null}if(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1){s=this.getInitialLiveFragment(t,r);this.startPosition=s?this.hls.liveSyncPosition||s.start:e}}else if(e<=n){s=r[0]}if(!s){var l=a.lowLatencyMode?t.partEnd:t.fragmentEnd;s=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(s)};t.prototype.isLoopLoading=function(e,t){var r=this.fragmentTracker.getState(e);return(r===FragmentState.OK||r===FragmentState.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t};t.prototype.getNextFragmentLoopLoading=function(e,t,r,i,a){var n=e.gap;var s=this.getNextFragment(this.nextLoadPosition,t);if(s===null){return s}e=s;if(n&&e&&!e.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(o!==null&&r.len+o.len>=a){this.log('buffer full after gaps in "'.concat(i,'" playlist starting at sn: ').concat(e.sn));return null}}return e};t.prototype.mapToInitFragWhenRequired=function(e){if(e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest){return e.initSegment}return e};t.prototype.getNextPart=function(e,t,r){var i=-1;var a=false;var n=true;for(var s=0,o=e.length;s<o;s++){var l=e[s];n=n&&!l.independent;if(i>-1&&r<l.start){break}var u=l.loaded;if(u){i=-1}else if((a||l.independent||n)&&l.fragment===t){i=s}a=u}return i};t.prototype.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded};t.prototype.getInitialLiveFragment=function(e,t){var r=this.fragPrevious;var i=null;if(r){if(e.hasProgramDateTime){this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(r.programDateTime));i=findFragmentByPDT(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)}if(!i){var a=r.sn+1;if(a>=e.startSN&&a<=e.endSN){var n=t[a-e.startSN];if(r.cc===n.cc){i=n;this.log("Live playlist, switching playlist, load frag with next SN: ".concat(i.sn))}}if(!i){i=findFragWithCC(t,r.cc);if(i){this.log("Live playlist, switching playlist, load frag with same CC: ".concat(i.sn))}}}}else{var s=this.hls.liveSyncPosition;if(s!==null){i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e)}}return i};t.prototype.getFragmentAtPosition=function(e,t,r){var i=this.config;var a=this.fragPrevious;var n=r.fragments,s=r.endSN;var o=r.fragmentHint;var l=i.maxFragLookUpTolerance;var u=r.partList;var f=!!(i.lowLatencyMode&&u!=null&&u.length&&o);if(f&&o&&!this.bitrateTest){n=n.concat(o);s=o.sn}var c;if(e<t){var d=e>t-l?0:l;c=findFragmentByPTS(a,n,e,d)}else{c=n[n.length-1]}if(c){var h=c.sn-r.startSN;var v=this.fragmentTracker.getState(c);if(v===FragmentState.OK||v===FragmentState.PARTIAL&&c.gap){a=c}if(a&&c.sn===a.sn&&(!f||u[0].fragment.sn>c.sn)){var p=a&&c.level===a.level;if(p){var g=n[h+1];if(c.sn<s&&this.fragmentTracker.getState(g)!==FragmentState.OK){c=g}else{c=null}}}}return c};t.prototype.synchronizeToLiveEdge=function(e){var t=this,r=t.config,i=t.media;if(!i){return}var a=this.hls.liveSyncPosition;var n=i.currentTime;var s=e.fragments[0].start;var o=e.edge;var l=n>=s-r.maxFragLookUpTolerance&&n<=o;if(a!==null&&i.duration>a&&(n<a||!l)){var u=r.liveMaxLatencyDuration!==undefined?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*e.targetduration;if(!l&&i.readyState<4||n<o-u){if(!this.loadedmetadata){this.nextLoadPosition=a}if(i.readyState){this.warn("Playback: ".concat(n.toFixed(3)," is located too far from the end of live sliding playlist: ").concat(o,", reset currentTime to : ").concat(a.toFixed(3)));i.currentTime=a}}}};t.prototype.alignPlaylists=function(e,t){var r=this,i=r.levels,a=r.levelLastLoaded,n=r.fragPrevious;var s=a!==null?i[a]:null;var o=e.fragments.length;if(!o){this.warn("No fragments in live playlist");return 0}var l=e.fragments[0].start;var u=!t;var f=e.alignedSliding&&isFiniteNumber(l);if(u||!f&&!l){alignStream(n,s,e);var c=e.fragments[0].start;this.log("Live playlist sliding: ".concat(c.toFixed(2)," start-sn: ").concat(t?t.startSN:"na","->").concat(e.startSN," prev-sn: ").concat(n?n.sn:"na"," fragments: ").concat(o));return c}return l};t.prototype.waitForCdnTuneIn=function(e){var t=3;return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*t)};t.prototype.setStartPosition=function(e,t){var r=this.startPosition;if(r<t){r=-1}if(r===-1||this.lastCurrentTime===-1){var i=this.startTimeOffset!==null;var a=i?this.startTimeOffset:e.startTimeOffset;if(a!==null&&isFiniteNumber(a)){r=t+a;if(a<0){r+=e.totalduration}r=Math.min(Math.max(t,r),t+e.totalduration);this.log("Start time offset ".concat(a," found in ").concat(i?"multivariant":"media"," playlist, adjust startPosition to ").concat(r));this.startPosition=r}else if(e.live){r=this.hls.liveSyncPosition||t}else{this.startPosition=r=0}this.lastCurrentTime=r}this.nextLoadPosition=r};t.prototype.getLoadPosition=function(){var e=this.media;var t=0;if(this.loadedmetadata&&e){t=e.currentTime}else if(this.nextLoadPosition){t=this.nextLoadPosition}return t};t.prototype.handleFragLoadAborted=function(e,t){if(this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted){this.warn("Fragment ".concat(e.sn).concat(t?" part "+t.index:""," of level ").concat(e.level," was aborted"));this.resetFragmentLoading(e)}};t.prototype.resetFragmentLoading=function(e){if(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==State.FRAG_LOADING_WAITING_RETRY){this.state=State.IDLE}};t.prototype.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);if(r){t.frag=r.frag}}var i=t.frag;if(!i||i.type!==e||!this.levels){return}if(this.fragContextChanged(i)){var a;this.warn("Frag load error must match current frag to retry ".concat(i.url," > ").concat((a=this.fragCurrent)==null?void 0:a.url));return}var n=t.details===ErrorDetails.FRAG_GAP;if(n){this.fragmentTracker.fragBuffered(i,true)}var s=t.errorAction;var o=s||{},l=o.action,u=o.retryCount,f=u===void 0?0:u,c=o.retryConfig;if(s&&l===NetworkErrorAction.RetryRequest&&c){var d;this.resetStartWhenNotLoaded((d=this.levelLastLoaded)!=null?d:i.level);var h=getRetryDelay(c,f);this.warn("Fragment ".concat(i.sn," of ").concat(e," ").concat(i.level," errored with ").concat(t.details,", retrying loading ").concat(f+1,"/").concat(c.maxNumRetry," in ").concat(h,"ms"));s.resolved=true;this.retryDate=self.performance.now()+h;this.state=State.FRAG_LOADING_WAITING_RETRY}else if(c&&s){this.resetFragmentErrors(e);if(f<c.maxNumRetry){if(!n){s.resolved=true}}else{logger.warn("".concat(t.details," reached or exceeded max retry (").concat(f,")"))}}else if((s==null?void 0:s.action)===NetworkErrorAction.SendAlternateToPenaltyBox){this.state=State.WAITING_LEVEL}else{this.state=State.ERROR}this.tickImmediate()};t.prototype.reduceLengthAndFlushBuffer=function(e){if(this.state===State.PARSING||this.state===State.PARSED){var t=e.parent;var r=this.getFwdBufferInfo(this.mediaBuffer,t);var i=r&&r.len>.5;if(i){this.reduceMaxBufferLength(r.len)}var a=!i;if(a){this.warn("Buffer full error while media.currentTime is not buffered, flush ".concat(t," buffer"))}if(e.frag){this.fragmentTracker.removeFragment(e.frag);this.nextLoadPosition=e.frag.start}this.resetLoadingState();return a}return false};t.prototype.resetFragmentErrors=function(e){if(e===PlaylistLevelType.AUDIO){this.fragCurrent=null}if(!this.loadedmetadata){this.startFragRequested=false}if(this.state!==State.STOPPED){this.state=State.IDLE}};t.prototype.afterBufferFlushed=function(e,t,r){if(!e){return}var i=BufferHelper.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r);if(this.state===State.ENDED){this.resetLoadingState()}};t.prototype.resetLoadingState=function(){this.log("Reset loading state");this.fragCurrent=null;this.fragPrevious=null;this.state=State.IDLE};t.prototype.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=false;var t=this.levels?this.levels[e].details:null;if(t!=null&&t.live){this.startPosition=-1;this.setStartPosition(t,0);this.resetLoadingState()}else{this.nextLoadPosition=this.startPosition}}};t.prototype.resetWhenMissingContext=function(e){var t;this.warn("The loading context changed while buffering fragment ".concat(e.sn," of level ").concat(e.level,". This chunk will not be buffered."));this.removeUnbufferedFrags();this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level);this.resetLoadingState()};t.prototype.removeUnbufferedFrags=function(e){if(e===void 0){e=0}this.fragmentTracker.removeFragmentsInRange(e,Infinity,this.playlistType,false,true)};t.prototype.updateLevelTiming=function(e,t,r,i){var a=this;var n;var s=r.details;if(!s){this.warn("level.details undefined");return}var o=Object.keys(e.elementaryStreams).reduce((function(t,n){var o=e.elementaryStreams[n];if(o){var l=o.endPTS-o.startPTS;if(l<=0){a.warn("Could not parse fragment ".concat(e.sn," ").concat(n," duration reliably (").concat(l,")"));return t||false}var u=i?0:updateFragPTSDTS(s,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);a.hls.trigger(Events.LEVEL_PTS_UPDATED,{details:s,level:r,drift:u,type:n,frag:e,start:o.startPTS,end:o.endPTS});return true}return t}),false);if(o){r.fragmentError=0}else if(((n=this.transmuxer)==null?void 0:n.error)===null){var l=new Error("Found no media in fragment ".concat(e.sn," of level ").concat(e.level," resetting transmuxer to fallback to playlist timing"));if(r.fragmentError===0){r.fragmentError++;e.gap=true;this.fragmentTracker.removeFragment(e);this.fragmentTracker.fragBuffered(e,true)}this.warn(l.message);this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:false,error:l,frag:e,reason:"Found no media in msn ".concat(e.sn,' of level "').concat(r.url,'"')});if(!this.hls){return}this.resetTransmuxer()}this.state=State.PARSED;this.hls.trigger(Events.FRAG_PARSED,{frag:e,part:t})};t.prototype.resetTransmuxer=function(){if(this.transmuxer){this.transmuxer.destroy();this.transmuxer=null}};t.prototype.recoverWorkerError=function(e){if(e.event==="demuxerWorker"){var t,r,i;this.fragmentTracker.removeAllFragments();this.resetTransmuxer();this.resetStartWhenNotLoaded((t=(r=this.levelLastLoaded)!=null?r:(i=this.fragCurrent)==null?void 0:i.level)!=null?t:0);this.resetLoadingState()}};Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(e){var t=this._state;if(t!==e){this._state=e;this.log("".concat(t,"->").concat(e))}},enumerable:false,configurable:true});return t}(TaskLoop);function getSourceBuffer(){return self.SourceBuffer||self.WebKitSourceBuffer}function isSupported(){var e=getMediaSource();if(!e){return false}var t=getSourceBuffer();var r=e&&typeof e.isTypeSupported==="function"&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"');var i=!t||t.prototype&&typeof t.prototype.appendBuffer==="function"&&typeof t.prototype.remove==="function";return!!r&&!!i}function changeTypeSupported(){var e;var t=getSourceBuffer();return typeof(t==null?void 0:(e=t.prototype)==null?void 0:e.changeType)==="function"}function hasUMDWorker(){return typeof __HLS_WORKER_BUNDLE__==="function"}function injectWorker(){var e=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(".concat(__HLS_WORKER_BUNDLE__.toString(),")(true);")],{type:"text/javascript"});var t=self.URL.createObjectURL(e);var r=new self.Worker(t);return{worker:r,objectURL:t}}function loadWorker(e){var t=new self.URL(e,self.location.href).href;var r=new self.Worker(t);return{worker:r,scriptURL:t}}function dummyTrack(e,t){if(e===void 0){e=""}if(t===void 0){t=9e4}return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var BaseAudioDemuxer=function(){function e(){this._audioTrack=void 0;this._id3Track=void 0;this.frameIndex=0;this.cachedData=null;this.basePTS=null;this.initPTS=null;this.lastPTS=null}e.prototype.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}};e.prototype.resetTimeStamp=function(e){this.initPTS=e;this.resetContiguity()};e.prototype.resetContiguity=function(){this.basePTS=null;this.lastPTS=null;this.frameIndex=0};e.prototype.canParse=function(e,t){return false};e.prototype.appendFrame=function(e,t,r){};e.prototype.demux=function(e,t){if(this.cachedData){e=appendUint8Array(this.cachedData,e);this.cachedData=null}var r=getID3Data(e,0);var i=r?r.length:0;var a;var n=this._audioTrack;var s=this._id3Track;var o=r?getTimeStamp(r):undefined;var l=e.length;if(this.basePTS===null||this.frameIndex===0&&isFiniteNumber(o)){this.basePTS=initPTSFn(o,t,this.initPTS);this.lastPTS=this.basePTS}if(this.lastPTS===null){this.lastPTS=this.basePTS}if(r&&r.length>0){s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY})}while(i<l){if(this.canParse(e,i)){var u=this.appendFrame(n,e,i);if(u){this.frameIndex++;this.lastPTS=u.sample.pts;i+=u.length;a=i}else{i=l}}else if(canParse$2(e,i)){r=getID3Data(e,i);s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});i+=r.length;a=i}else{i++}if(i===l&&a!==l){var f=sliceUint8(e,a);if(this.cachedData){this.cachedData=appendUint8Array(this.cachedData,f)}else{this.cachedData=f}}}return{audioTrack:n,videoTrack:dummyTrack(),id3Track:s,textTrack:dummyTrack()}};e.prototype.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("[".concat(this,"] This demuxer does not support Sample-AES decryption")))};e.prototype.flush=function(e){var t=this.cachedData;if(t){this.cachedData=null;this.demux(t,0)}return{audioTrack:this._audioTrack,videoTrack:dummyTrack(),id3Track:this._id3Track,textTrack:dummyTrack()}};e.prototype.destroy=function(){};return e}();var initPTSFn=function(e,t,r){if(isFiniteNumber(e)){return e*90}var i=r?r.baseTime*9e4/r.timescale:0;return t*9e4+i};function getAudioConfig(e,t,r,i){var a;var n;var s;var o;var l=navigator.userAgent.toLowerCase();var u=i;var f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];a=((t[r+2]&192)>>>6)+1;var c=(t[r+2]&60)>>>2;if(c>f.length-1){e.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:true,reason:"invalid ADTS sampling index:".concat(c)});return}s=(t[r+2]&1)<<2;s|=(t[r+3]&192)>>>6;logger.log("manifest codec:".concat(i,", ADTS type:").concat(a,", samplingIndex:").concat(c));if(/firefox/i.test(l)){if(c>=6){a=5;o=new Array(4);n=c-3}else{a=2;o=new Array(2);n=c}}else if(l.indexOf("android")!==-1){a=2;o=new Array(2);n=c}else{a=5;o=new Array(4);if(i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&c>=6){n=c-3}else{if(i&&i.indexOf("mp4a.40.2")!==-1&&(c>=6&&s===1||/vivaldi/i.test(l))||!i&&s===1){a=2;o=new Array(2)}n=c}}o[0]=a<<3;o[0]|=(c&14)>>1;o[1]|=(c&1)<<7;o[1]|=s<<3;if(a===5){o[1]|=(n&14)>>1;o[2]=(n&1)<<7;o[2]|=2<<2;o[3]=0}return{config:o,samplerate:f[c],channelCount:s,codec:"mp4a.40."+a,manifestCodec:u}}function isHeaderPattern$1(e,t){return e[t]===255&&(e[t+1]&246)===240}function getHeaderLength(e,t){return e[t+1]&1?7:9}function getFullFrameLength(e,t){return(e[t+3]&3)<<11|e[t+4]<<3|(e[t+5]&224)>>>5}function canGetFrameLength(e,t){return t+5<e.length}function isHeader$1(e,t){return t+1<e.length&&isHeaderPattern$1(e,t)}function canParse$1(e,t){return canGetFrameLength(e,t)&&isHeaderPattern$1(e,t)&&getFullFrameLength(e,t)<=e.length-t}function probe$1(e,t){if(isHeader$1(e,t)){var r=getHeaderLength(e,t);if(t+r>=e.length){return false}var i=getFullFrameLength(e,t);if(i<=r){return false}var a=t+i;return a===e.length||isHeader$1(e,a)}return false}function initTrackConfig(e,t,r,i,a){if(!e.samplerate){var n=getAudioConfig(t,r,i,a);if(!n){return}e.config=n.config;e.samplerate=n.samplerate;e.channelCount=n.channelCount;e.codec=n.codec;e.manifestCodec=n.manifestCodec;logger.log("parsed codec:".concat(e.codec,", rate:").concat(n.samplerate,", channels:").concat(n.channelCount))}}function getFrameDuration(e){return 1024*9e4/e}function parseFrameHeader(e,t){var r=getHeaderLength(e,t);if(t+r<=e.length){var i=getFullFrameLength(e,t)-r;if(i>0){return{headerLength:r,frameLength:i}}}}function appendFrame$1(e,t,r,i,a){var n=getFrameDuration(e.samplerate);var s=i+a*n;var o=parseFrameHeader(t,r);var l;if(o){var u=o.frameLength,f=o.headerLength;var c=f+u;var d=Math.max(0,r+c-t.length);if(d){l=new Uint8Array(c-f);l.set(t.subarray(r+f,t.length),0)}else{l=t.subarray(r+f,r+c)}var h={unit:l,pts:s};if(!d){e.samples.push(h)}return{sample:h,length:c,missing:d}}var v=t.length-r;l=new Uint8Array(v);l.set(t.subarray(r,t.length),0);var p={unit:l,pts:s};return{sample:p,length:v,missing:-1}}var AACDemuxer=function(e){__extends(t,e);function t(t,r){var i=e.call(this)||this;i.observer=void 0;i.config=void 0;i.observer=t;i.config=r;return i}t.prototype.resetInitSegment=function(t,r,i,a){e.prototype.resetInitSegment.call(this,t,r,i,a);this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}};t.probe=function(e){if(!e){return false}var t=getID3Data(e,0)||[];var r=t.length;for(var i=e.length;r<i;r++){if(probe$1(e,r)){logger.log("ADTS sync word found !");return true}}return false};t.prototype.canParse=function(e,t){return canParse$1(e,t)};t.prototype.appendFrame=function(e,t,r){initTrackConfig(e,this.observer,t,r,e.manifestCodec);var i=appendFrame$1(e,t,r,this.basePTS,this.frameIndex);if(i&&i.missing===0){return i}};return t}(BaseAudioDemuxer);var emsgSchemePattern=/\/emsg[-/]ID3/i;var MP4Demuxer=function(){function e(e,t){this.remainderData=null;this.timeOffset=0;this.config=void 0;this.videoTrack=void 0;this.audioTrack=void 0;this.id3Track=void 0;this.txtTrack=void 0;this.config=t}e.prototype.resetTimeStamp=function(){};e.prototype.resetInitSegment=function(e,t,r,i){var a=this.videoTrack=dummyTrack("video",1);var n=this.audioTrack=dummyTrack("audio",1);var s=this.txtTrack=dummyTrack("text",1);this.id3Track=dummyTrack("id3",1);this.timeOffset=0;if(!(e!=null&&e.byteLength)){return}var o=parseInitSegment(e);if(o.video){var l=o.video,u=l.id,f=l.timescale,c=l.codec;a.id=u;a.timescale=s.timescale=f;a.codec=c}if(o.audio){var d=o.audio,u=d.id,f=d.timescale,c=d.codec;n.id=u;n.timescale=f;n.codec=c}s.id=RemuxerTrackIdConfig.text;a.sampleDuration=0;a.duration=n.duration=i};e.prototype.resetContiguity=function(){this.remainderData=null};e.probe=function(e){e=e.length>16384?e.subarray(0,16384):e;return findBox(e,["moof"]).length>0};e.prototype.demux=function(e,t){this.timeOffset=t;var r=e;var i=this.videoTrack;var a=this.txtTrack;if(this.config.progressive){if(this.remainderData){r=appendUint8Array(this.remainderData,e)}var n=segmentValidRange(r);this.remainderData=n.remainder;i.samples=n.valid||new Uint8Array}else{i.samples=r}var s=this.extractID3Track(i,t);a.samples=parseSamples(t,i);return{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}};e.prototype.flush=function(){var e=this.timeOffset;var t=this.videoTrack;var r=this.txtTrack;t.samples=this.remainderData||new Uint8Array;this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);r.samples=parseSamples(e,t);return{videoTrack:t,audioTrack:dummyTrack(),id3Track:i,textTrack:dummyTrack()}};e.prototype.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=findBox(e.samples,["emsg"]);if(i){i.forEach((function(e){var i=parseEmsg(e);if(emsgSchemePattern.test(i.schemeIdUri)){var a=isFiniteNumber(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale;var n=i.eventDuration===4294967295?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;if(n<=.001){n=Number.POSITIVE_INFINITY}var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:a,pts:a,type:MetadataSchema.emsg,duration:n})}}))}}return r};e.prototype.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))};e.prototype.destroy=function(){};return e}();var chromeVersion$1=null;var BitratesMap=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160];var SamplingRateMap=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3];var SamplesCoefficients=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]];var BytesInSlot=[0,1,1,4];function appendFrame(e,t,r,i,a){if(r+24>t.length){return}var n=parseHeader(t,r);if(n&&r+n.frameLength<=t.length){var s=n.samplesPerFrame*9e4/n.sampleRate;var o=i+a*s;var l={unit:t.subarray(r,r+n.frameLength),pts:o,dts:o};e.config=[];e.channelCount=n.channelCount;e.samplerate=n.sampleRate;e.samples.push(l);return{sample:l,length:n.frameLength,missing:0}}}function parseHeader(e,t){var r=e[t+1]>>3&3;var i=e[t+1]>>1&3;var a=e[t+2]>>4&15;var n=e[t+2]>>2&3;if(r!==1&&a!==0&&a!==15&&n!==3){var s=e[t+2]>>1&1;var o=e[t+3]>>6;var l=r===3?3-i:i===3?3:4;var u=BitratesMap[l*14+a-1]*1e3;var f=r===3?0:r===2?1:2;var c=SamplingRateMap[f*3+n];var d=o===3?1:2;var h=SamplesCoefficients[r][i];var v=BytesInSlot[i];var p=h*8*v;var g=Math.floor(h*u/c+s)*v;if(chromeVersion$1===null){var m=navigator.userAgent||"";var y=m.match(/Chrome\/(\d+)/i);chromeVersion$1=y?parseInt(y[1]):0}var E=!!chromeVersion$1&&chromeVersion$1<=87;if(E&&i===2&&u>=224e3&&o===0){e[t+3]=e[t+3]|128}return{sampleRate:c,channelCount:d,frameLength:g,samplesPerFrame:p}}}function isHeaderPattern(e,t){return e[t]===255&&(e[t+1]&224)===224&&(e[t+1]&6)!==0}function isHeader(e,t){return t+1<e.length&&isHeaderPattern(e,t)}function canParse(e,t){var r=4;return isHeaderPattern(e,t)&&r<=e.length-t}function probe(e,t){if(t+1<e.length&&isHeaderPattern(e,t)){var r=4;var i=parseHeader(e,t);var a=r;if(i!=null&&i.frameLength){a=i.frameLength}var n=t+a;return n===e.length||isHeader(e,n)}return false}var ExpGolomb=function(){function e(e){this.data=void 0;this.bytesAvailable=void 0;this.word=void 0;this.bitsAvailable=void 0;this.data=e;this.bytesAvailable=e.byteLength;this.word=0;this.bitsAvailable=0}e.prototype.loadWord=function(){var e=this.data;var t=this.bytesAvailable;var r=e.byteLength-t;var i=new Uint8Array(4);var a=Math.min(4,t);if(a===0){throw new Error("no bytes available")}i.set(e.subarray(r,r+a));this.word=new DataView(i.buffer).getUint32(0);this.bitsAvailable=a*8;this.bytesAvailable-=a};e.prototype.skipBits=function(e){var t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable);if(this.bitsAvailable>e){this.word<<=e;this.bitsAvailable-=e}else{e-=this.bitsAvailable;t=e>>3;e-=t<<3;this.bytesAvailable-=t;this.loadWord();this.word<<=e;this.bitsAvailable-=e}};e.prototype.readBits=function(e){var t=Math.min(this.bitsAvailable,e);var r=this.word>>>32-t;if(e>32){logger.error("Cannot read more than 32 bits at a time")}this.bitsAvailable-=t;if(this.bitsAvailable>0){this.word<<=t}else if(this.bytesAvailable>0){this.loadWord()}else{throw new Error("no bits available")}t=e-t;if(t>0&&this.bitsAvailable){return r<<t|this.readBits(t)}else{return r}};e.prototype.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e){if((this.word&2147483648>>>e)!==0){this.word<<=e;this.bitsAvailable-=e;return e}}this.loadWord();return e+this.skipLZ()};e.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())};e.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())};e.prototype.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1};e.prototype.readEG=function(){var e=this.readUEG();if(1&e){return 1+e>>>1}else{return-1*(e>>>1)}};e.prototype.readBoolean=function(){return this.readBits(1)===1};e.prototype.readUByte=function(){return this.readBits(8)};e.prototype.readUShort=function(){return this.readBits(16)};e.prototype.readUInt=function(){return this.readBits(32)};e.prototype.skipScalingList=function(e){var t=8;var r=8;var i;for(var a=0;a<e;a++){if(r!==0){i=this.readEG();r=(t+i+256)%256}t=r===0?t:r}};e.prototype.readSPS=function(){var e=0;var t=0;var r=0;var i=0;var a;var n;var s;var o=this.readUByte.bind(this);var l=this.readBits.bind(this);var u=this.readUEG.bind(this);var f=this.readBoolean.bind(this);var c=this.skipBits.bind(this);var d=this.skipEG.bind(this);var h=this.skipUEG.bind(this);var v=this.skipScalingList.bind(this);o();var p=o();l(5);c(3);o();h();if(p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128){var g=u();if(g===3){c(1)}h();h();c(1);if(f()){n=g!==3?8:12;for(s=0;s<n;s++){if(f()){if(s<6){v(16)}else{v(64)}}}}}h();var m=u();if(m===0){u()}else if(m===1){c(1);d();d();a=u();for(s=0;s<a;s++){d()}}h();c(1);var y=u();var E=u();var T=l(1);if(T===0){c(1)}c(1);if(f()){e=u();t=u();r=u();i=u()}var S=[1,1];if(f()){if(f()){var A=o();switch(A){case 1:S=[1,1];break;case 2:S=[12,11];break;case 3:S=[10,11];break;case 4:S=[16,11];break;case 5:S=[40,33];break;case 6:S=[24,11];break;case 7:S=[20,11];break;case 8:S=[32,11];break;case 9:S=[80,33];break;case 10:S=[18,11];break;case 11:S=[15,11];break;case 12:S=[64,33];break;case 13:S=[160,99];break;case 14:S=[4,3];break;case 15:S=[3,2];break;case 16:S=[2,1];break;case 255:{S=[o()<<8|o(),o()<<8|o()];break}}}}return{width:Math.ceil((y+1)*16-e*2-t*2),height:(2-T)*(E+1)*16-(T?2:4)*(r+i),pixelRatio:S}};e.prototype.readSliceType=function(){this.readUByte();this.readUEG();return this.readUEG()};return e}();var SampleAesDecrypter=function(){function e(e,t,r){this.keyData=void 0;this.decrypter=void 0;this.keyData=r;this.decrypter=new Decrypter(t,{removePKCS7Padding:false})}e.prototype.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)};e.prototype.decryptAacSample=function(e,t,r){var i=this;var a=e[t].unit;if(a.length<=16){return}var n=a.subarray(16,a.length-a.length%16);var s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then((function(n){var s=new Uint8Array(n);a.set(s,16);if(!i.decrypter.isSync()){i.decryptAacSamples(e,t+1,r)}}))};e.prototype.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length){r();return}if(e[t].unit.length<32){continue}this.decryptAacSample(e,t,r);if(!this.decrypter.isSync()){return}}};e.prototype.getAvcEncryptedData=function(e){var t=Math.floor((e.length-48)/160)*16+16;var r=new Int8Array(t);var i=0;for(var a=32;a<e.length-16;a+=160,i+=16){r.set(e.subarray(a,a+16),i)}return r};e.prototype.getAvcDecryptedUnit=function(e,t){var r=new Uint8Array(t);var i=0;for(var a=32;a<e.length-16;a+=160,i+=16){e.set(r.subarray(i,i+16),a)}return e};e.prototype.decryptAvcSample=function(e,t,r,i,a){var n=this;var s=discardEPB(a.data);var o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){a.data=n.getAvcDecryptedUnit(s,o);if(!n.decrypter.isSync()){n.decryptAvcSamples(e,t,r+1,i)}}))};e.prototype.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array){throw new Error("Cannot decrypt samples of type Uint8Array")}for(;;t++,r=0){if(t>=e.length){i();return}var a=e[t].units;for(;;r++){if(r>=a.length){break}var n=a[r];if(n.data.length<=48||n.type!==1&&n.type!==5){continue}this.decryptAvcSample(e,t,r,i,n);if(!this.decrypter.isSync()){return}}}};return e}();var PACKET_LENGTH=188;var TSDemuxer=function(){function e(e,t,r){this.observer=void 0;this.config=void 0;this.typeSupported=void 0;this.sampleAes=null;this.pmtParsed=false;this.audioCodec=void 0;this.videoCodec=void 0;this._duration=0;this._pmtId=-1;this._avcTrack=void 0;this._audioTrack=void 0;this._id3Track=void 0;this._txtTrack=void 0;this.aacOverFlow=null;this.avcSample=null;this.remainderData=null;this.observer=e;this.config=t;this.typeSupported=r}e.probe=function(t){var r=e.syncOffset(t);if(r>0){logger.warn("MPEG2-TS detected but first sync word found @ offset ".concat(r))}return r!==-1};e.syncOffset=function(e){var t=e.length;var r=Math.min(PACKET_LENGTH*5,e.length-PACKET_LENGTH)+1;var i=0;while(i<r){var a=false;var n=-1;var s=0;for(var o=i;o<t;o+=PACKET_LENGTH){if(e[o]===71){s++;if(n===-1){n=o;if(n!==0){r=Math.min(n+PACKET_LENGTH*99,e.length-PACKET_LENGTH)+1}}if(!a){a=parsePID(e,o)===0}if(a&&s>1&&(n===0&&s>2||o+PACKET_LENGTH>r)){return n}}else if(s){return-1}else{break}}i++}return-1};e.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":undefined,type:e,id:RemuxerTrackIdConfig[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:undefined}};e.prototype.resetInitSegment=function(t,r,i,a){this.pmtParsed=false;this._pmtId=-1;this._avcTrack=e.createTrack("video");this._audioTrack=e.createTrack("audio",a);this._id3Track=e.createTrack("id3");this._txtTrack=e.createTrack("text");this._audioTrack.segmentCodec="aac";this.aacOverFlow=null;this.avcSample=null;this.remainderData=null;this.audioCodec=r;this.videoCodec=i;this._duration=a};e.prototype.resetTimeStamp=function(){};e.prototype.resetContiguity=function(){var e=this,t=e._audioTrack,r=e._avcTrack,i=e._id3Track;if(t){t.pesData=null}if(r){r.pesData=null}if(i){i.pesData=null}this.aacOverFlow=null;this.avcSample=null;this.remainderData=null};e.prototype.demux=function(t,r,i,a){if(i===void 0){i=false}if(a===void 0){a=false}if(!i){this.sampleAes=null}var n;var s=this._avcTrack;var o=this._audioTrack;var l=this._id3Track;var u=this._txtTrack;var f=s.pid;var c=s.pesData;var d=o.pid;var h=l.pid;var v=o.pesData;var p=l.pesData;var g=null;var m=this.pmtParsed;var y=this._pmtId;var E=t.length;if(this.remainderData){t=appendUint8Array(this.remainderData,t);E=t.length;this.remainderData=null}if(E<PACKET_LENGTH&&!a){this.remainderData=t;return{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u}}var T=Math.max(0,e.syncOffset(t));E-=(E-T)%PACKET_LENGTH;if(E<t.byteLength&&!a){this.remainderData=new Uint8Array(t.buffer,E,t.buffer.byteLength-E)}var S=0;for(var A=T;A<E;A+=PACKET_LENGTH){if(t[A]===71){var L=!!(t[A+1]&64);var b=parsePID(t,A);var R=(t[A+3]&48)>>4;var D=void 0;if(R>1){D=A+5+t[A+4];if(D===A+PACKET_LENGTH){continue}}else{D=A+4}switch(b){case f:if(L){if(c&&(n=parsePES(c))){this.parseAVCPES(s,u,n,false)}c={data:[],size:0}}if(c){c.data.push(t.subarray(D,A+PACKET_LENGTH));c.size+=A+PACKET_LENGTH-D}break;case d:if(L){if(v&&(n=parsePES(v))){switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break}}v={data:[],size:0}}if(v){v.data.push(t.subarray(D,A+PACKET_LENGTH));v.size+=A+PACKET_LENGTH-D}break;case h:if(L){if(p&&(n=parsePES(p))){this.parseID3PES(l,n)}p={data:[],size:0}}if(p){p.data.push(t.subarray(D,A+PACKET_LENGTH));p.size+=A+PACKET_LENGTH-D}break;case 0:if(L){D+=t[D]+1}y=this._pmtId=parsePAT(t,D);break;case y:{if(L){D+=t[D]+1}var I=parsePMT(t,D,this.typeSupported,i);f=I.avc;if(f>0){s.pid=f}d=I.audio;if(d>0){o.pid=d;o.segmentCodec=I.segmentCodec}h=I.id3;if(h>0){l.pid=h}if(g!==null&&!m){logger.warn("MPEG-TS PMT found at ".concat(A," after unknown PID '").concat(g,"'. Backtracking to sync byte @").concat(T," to parse all TS packets."));g=null;A=T-188}m=this.pmtParsed=true;break}case 17:case 8191:break;default:g=b;break}}else{S++}}if(S>0){var C=new Error("Found ".concat(S," TS packet/s that do not start with 0x47"));this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:false,error:C,reason:C.message})}s.pesData=c;o.pesData=v;l.pesData=p;var _={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};if(a){this.extractRemainingSamples(_)}return _};e.prototype.flush=function(){var e=this.remainderData;this.remainderData=null;var t;if(e){t=this.demux(e,-1,false,true)}else{t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack}}this.extractRemainingSamples(t);if(this.sampleAes){return this.decrypt(t,this.sampleAes)}return t};e.prototype.extractRemainingSamples=function(e){var t=e.audioTrack,r=e.videoTrack,i=e.id3Track,a=e.textTrack;var n=r.pesData;var s=t.pesData;var o=i.pesData;var l;if(n&&(l=parsePES(n))){this.parseAVCPES(r,a,l,true);r.pesData=null}else{r.pesData=n}if(s&&(l=parsePES(s))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l);break}t.pesData=null}else{if(s!=null&&s.size){logger.log("last AAC PES packet truncated,might overlap between fragments")}t.pesData=s}if(o&&(l=parsePES(o))){this.parseID3PES(i,l);i.pesData=null}else{i.pesData=o}};e.prototype.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,true,!this.config.progressive);var a=this.sampleAes=new SampleAesDecrypter(this.observer,this.config,t);return this.decrypt(i,a)};e.prototype.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,a=e.videoTrack;if(i.samples&&i.segmentCodec==="aac"){t.decryptAacSamples(i.samples,0,(function(){if(a.samples){t.decryptAvcSamples(a.samples,0,0,(function(){r(e)}))}else{r(e)}}))}else if(a.samples){t.decryptAvcSamples(a.samples,0,0,(function(){r(e)}))}}))};e.prototype.destroy=function(){this._duration=0};e.prototype.parseAVCPES=function(e,t,r,i){var a=this;var n=this.parseAVCNALu(e,r.data);var s=this.avcSample;var o;var l=false;r.data=null;if(s&&n.length&&!e.audFound){pushAccessUnit(s,e);s=this.avcSample=createAVCSample(false,r.pts,r.dts,"")}n.forEach((function(i){var n;switch(i.type){case 1:{var u=false;o=true;var f=i.data;if(l&&f.length>4){var c=new ExpGolomb(f).readSliceType();if(c===2||c===4||c===7||c===9){u=true}}if(u){var d;if((d=s)!=null&&d.frame&&!s.key){pushAccessUnit(s,e);s=a.avcSample=null}}if(!s){s=a.avcSample=createAVCSample(true,r.pts,r.dts,"")}s.frame=true;s.key=u;break}case 5:o=true;if((n=s)!=null&&n.frame&&!s.key){pushAccessUnit(s,e);s=a.avcSample=null}if(!s){s=a.avcSample=createAVCSample(true,r.pts,r.dts,"")}s.key=true;s.frame=true;break;case 6:{o=true;parseSEIMessageFromNALu(i.data,1,r.pts,t.samples);break}case 7:o=true;l=true;if(!e.sps){var h=i.data;var v=new ExpGolomb(h);var p=v.readSPS();e.width=p.width;e.height=p.height;e.pixelRatio=p.pixelRatio;e.sps=[h];e.duration=a._duration;var g=h.subarray(1,4);var m="avc1.";for(var y=0;y<3;y++){var E=g[y].toString(16);if(E.length<2){E="0"+E}m+=E}e.codec=m}break;case 8:o=true;if(!e.pps){e.pps=[i.data]}break;case 9:o=false;e.audFound=true;if(s){pushAccessUnit(s,e)}s=a.avcSample=createAVCSample(false,r.pts,r.dts,"");break;case 12:o=true;break;default:o=false;if(s){s.debug+="unknown NAL "+i.type+" "}break}if(s&&o){var T=s.units;T.push(i)}}));if(i&&s){pushAccessUnit(s,e);this.avcSample=null}};e.prototype.getLastNalUnit=function(e){var t;var r=this.avcSample;var i;if(!r||r.units.length===0){r=e[e.length-1]}if((t=r)!=null&&t.units){var a=r.units;i=a[a.length-1]}return i};e.prototype.parseAVCNALu=function(e,t){var r=t.byteLength;var i=e.naluState||0;var a=i;var n=[];var s=0;var o;var l;var u;var f=-1;var c=0;if(i===-1){f=0;c=t[0]&31;i=0;s=1}while(s<r){o=t[s++];if(!i){i=o?0:1;continue}if(i===1){i=o?0:2;continue}if(!o){i=3}else if(o===1){if(f>=0){var d={data:t.subarray(f,s-i-1),type:c};n.push(d)}else{var h=this.getLastNalUnit(e.samples);if(h){if(a&&s<=4-a){if(h.state){h.data=h.data.subarray(0,h.data.byteLength-a)}}l=s-i-1;if(l>0){var v=new Uint8Array(h.data.byteLength+l);v.set(h.data,0);v.set(t.subarray(0,l),h.data.byteLength);h.data=v;h.state=0}}}if(s<r){u=t[s]&31;f=s;c=u;i=0}else{i=-1}}else{i=0}}if(f>=0&&i>=0){var d={data:t.subarray(f,r),type:c,state:i};n.push(d)}if(n.length===0){var h=this.getLastNalUnit(e.samples);if(h){var v=new Uint8Array(h.data.byteLength+t.byteLength);v.set(h.data,0);v.set(t,h.data.byteLength);h.data=v}}e.naluState=i;return n};e.prototype.parseAACPES=function(e,t){var r=0;var i=this.aacOverFlow;var a=t.data;if(i){this.aacOverFlow=null;var n=i.missing;var s=i.sample.unit.byteLength;if(n===-1){var o=new Uint8Array(s+a.byteLength);o.set(i.sample.unit,0);o.set(a,s);a=o}else{var l=s-n;i.sample.unit.set(a.subarray(0,n),l);e.samples.push(i.sample);r=i.missing}}var u;var f;for(u=r,f=a.length;u<f-1;u++){if(isHeader$1(a,u)){break}}if(u!==r){var c=void 0;var d=u<f-1;if(d){c="AAC PES did not start with ADTS header,offset:".concat(u)}else{c="No ADTS header found in AAC PES"}var h=new Error(c);logger.warn("parsing error: ".concat(c));this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:false,levelRetry:d,error:h,reason:c});if(!d){return}}initTrackConfig(e,this.observer,a,u,this.audioCodec);var v;if(t.pts!==undefined){v=t.pts}else if(i){var p=getFrameDuration(e.samplerate);v=i.sample.pts+p}else{logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}var g=0;var m;while(u<f){m=appendFrame$1(e,a,u,v,g);u+=m.length;if(!m.missing){g++;for(;u<f-1;u++){if(isHeader$1(a,u)){break}}}else{this.aacOverFlow=m;break}}};e.prototype.parseMPEGPES=function(e,t){var r=t.data;var i=r.length;var a=0;var n=0;var s=t.pts;if(s===undefined){logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}while(n<i){if(isHeader(r,n)){var o=appendFrame(e,r,n,s,a);if(o){n+=o.length;a++}else{break}}else{n++}}};e.prototype.parseID3PES=function(e,t){if(t.pts===undefined){logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=_extends({},t,{type:this._avcTrack?MetadataSchema.emsg:MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)};return e}();function createAVCSample(e,t,r,i){return{key:e,frame:false,pts:t,dts:r,units:[],debug:i,length:0}}function parsePID(e,t){return((e[t+1]&31)<<8)+e[t+2]}function parsePAT(e,t){return(e[t+10]&31)<<8|e[t+11]}function parsePMT(e,t,r,i){var a={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"};var n=(e[t+1]&15)<<8|e[t+2];var s=t+3+n-4;var o=(e[t+10]&15)<<8|e[t+11];t+=12+o;while(t<s){var l=parsePID(e,t);switch(e[t]){case 207:if(!i){logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:if(a.audio===-1){a.audio=l}break;case 21:if(a.id3===-1){a.id3=l}break;case 219:if(!i){logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:if(a.avc===-1){a.avc=l}break;case 3:case 4:if(r.mpeg!==true&&r.mp3!==true){logger.log("MPEG audio found, not supported in this browser")}else if(a.audio===-1){a.audio=l;a.segmentCodec="mp3"}break;case 36:logger.warn("Unsupported HEVC stream type found");break}t+=((e[t+3]&15)<<8|e[t+4])+5}return a}function parsePES(e){var t=0;var r;var i;var a;var n;var s;var o=e.data;if(!e||e.size===0){return null}while(o[0].length<19&&o.length>1){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]);l.set(o[1],o[0].length);o[0]=l;o.splice(1,1)}r=o[0];var u=(r[0]<<16)+(r[1]<<8)+r[2];if(u===1){i=(r[4]<<8)+r[5];if(i&&i>e.size-6){return null}var f=r[7];if(f&192){n=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2;if(f&64){s=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2;if(n-s>60*9e4){logger.warn("".concat(Math.round((n-s)/9e4),"s delta between PTS and DTS, align them"));n=s}}else{s=n}}a=r[8];var c=a+9;if(e.size<=c){return null}e.size-=c;var d=new Uint8Array(e.size);for(var h=0,v=o.length;h<v;h++){r=o[h];var p=r.byteLength;if(c){if(c>p){c-=p;continue}else{r=r.subarray(c);p-=c;c=0}}d.set(r,t);t+=p}if(i){i-=a+3}return{data:d,pts:n,dts:s,len:i}}return null}function pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===undefined){var r=t.samples;var i=r.length;if(i){var a=r[i-1];e.pts=a.pts;e.dts=a.dts}else{t.dropped++;return}}t.samples.push(e)}if(e.debug.length){logger.log(e.pts+"/"+e.dts+":"+e.debug)}}var MP3Demuxer=function(e){__extends(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}t.prototype.resetInitSegment=function(t,r,i,a){e.prototype.resetInitSegment.call(this,t,r,i,a);this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}};t.probe=function(e){if(!e){return false}var t=getID3Data(e,0)||[];var r=t.length;for(var i=e.length;r<i;r++){if(probe(e,r)){logger.log("MPEG Audio sync word found !");return true}}return false};t.prototype.canParse=function(e,t){return canParse(e,t)};t.prototype.appendFrame=function(e,t,r){if(this.basePTS===null){return}return appendFrame(e,t,r,this.basePTS,this.frameIndex)};return t}(BaseAudioDemuxer);var AAC=function(){function e(){}e.getSilentFrame=function(e,t){switch(e){case"mp4a.40.2":if(t===1){return new Uint8Array([0,200,0,128,35,128])}else if(t===2){return new Uint8Array([33,0,73,144,2,25,0,35,128])}else if(t===3){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142])}else if(t===4){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56])}else if(t===5){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56])}else if(t===6){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}break;default:if(t===1){return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}else if(t===2){return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}else if(t===3){return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}break}return undefined};return e}();var UINT32_MAX=Math.pow(2,32)-1;var MP4=function(){function e(){}e.init=function(){e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var t;for(t in e.types){if(e.types.hasOwnProperty(t)){e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]}}var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]);var i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);var n=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=n;e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]);e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]);e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]);var o=new Uint8Array([97,118,99,49]);var l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o);e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))};e.box=function(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}var i=8;var a=t.length;var n=a;while(a--){i+=t[a].byteLength}var s=new Uint8Array(i);s[0]=i>>24&255;s[1]=i>>16&255;s[2]=i>>8&255;s[3]=i&255;s.set(e,4);for(a=0,i=8;a<n;a++){s.set(t[a],i);i+=t[a].byteLength}return s};e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])};e.mdat=function(t){return e.box(e.types.mdat,t)};e.mdhd=function(t,r){r*=t;var i=Math.floor(r/(UINT32_MAX+1));var a=Math.floor(r%(UINT32_MAX+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,a>>24,a>>16&255,a>>8&255,a&255,85,196,0,0]))};e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))};e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))};e.minf=function(t){if(t.type==="audio"){return e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t))}else{return e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}};e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))};e.moov=function(t){var r=t.length;var i=[];while(r--){i[r]=e.trak(t[r])}return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))};e.mvex=function(t){var r=t.length;var i=[];while(r--){i[r]=e.trex(t[r])}return e.box.apply(null,__spreadArray([e.types.mvex],i,true))};e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(UINT32_MAX+1));var a=Math.floor(r%(UINT32_MAX+1));var n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,a>>24,a>>16&255,a>>8&255,a&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,n)};e.sdtp=function(t){var r=t.samples||[];var i=new Uint8Array(4+r.length);var a;var n;for(a=0;a<r.length;a++){n=r[a].flags;i[a+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy}return e.box(e.types.sdtp,i)};e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))};e.avc1=function(t){var r=[];var i=[];var a;var n;var s;for(a=0;a<t.sps.length;a++){n=t.sps[a];s=n.byteLength;r.push(s>>>8&255);r.push(s&255);r=r.concat(Array.prototype.slice.call(n))}for(a=0;a<t.pps.length;a++){n=t.pps[a];s=n.byteLength;i.push(s>>>8&255);i.push(s&255);i=i.concat(Array.prototype.slice.call(n))}var o=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],252|3,224|t.sps.length].concat(r).concat([t.pps.length]).concat(i)));var l=t.width;var u=t.height;var f=t.pixelRatio[0];var c=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,l&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([f>>24,f>>16&255,f>>8&255,f&255,c>>24,c>>16&255,c>>8&255,c&255])))};e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))};e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,r&255,0,0]),e.box(e.types.esds,e.esds(t)))};e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,r&255,0,0]))};e.stsd=function(t){if(t.type==="audio"){if(t.segmentCodec==="mp3"&&t.codec==="mp3"){return e.box(e.types.stsd,e.STSD,e.mp3(t))}return e.box(e.types.stsd,e.STSD,e.mp4a(t))}else{return e.box(e.types.stsd,e.STSD,e.avc1(t))}};e.tkhd=function(t){var r=t.id;var i=t.duration*t.timescale;var a=t.width;var n=t.height;var s=Math.floor(i/(UINT32_MAX+1));var o=Math.floor(i%(UINT32_MAX+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,r&255,0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255,o>>24,o>>16&255,o>>8&255,o&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,a&255,0,0,n>>8&255,n&255,0,0]))};e.traf=function(t,r){var i=e.sdtp(t);var a=t.id;var n=Math.floor(r/(UINT32_MAX+1));var s=Math.floor(r%(UINT32_MAX+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,s>>24,s>>16&255,s>>8&255,s&255])),e.trun(t,i.length+16+20+8+16+8+8),i)};e.trak=function(t){t.duration=t.duration||4294967295;return e.box(e.types.trak,e.tkhd(t),e.mdia(t))};e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))};e.trun=function(t,r){var i=t.samples||[];var a=i.length;var n=12+16*a;var s=new Uint8Array(n);var o;var l;var u;var f;var c;var d;r+=8+n;s.set([t.type==="video"?1:0,0,15,1,a>>>24&255,a>>>16&255,a>>>8&255,a&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255],0);for(o=0;o<a;o++){l=i[o];u=l.duration;f=l.size;c=l.flags;d=l.cts;s.set([u>>>24&255,u>>>16&255,u>>>8&255,u&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&240<<8,c.degradPrio&15,d>>>24&255,d>>>16&255,d>>>8&255,d&255],12+16*o)}return e.box(e.types.trun,s)};e.initSegment=function(t){if(!e.types){e.init()}var r=e.moov(t);var i=new Uint8Array(e.FTYP.byteLength+r.byteLength);i.set(e.FTYP);i.set(r,e.FTYP.byteLength);return i};return e}();MP4.types=void 0;MP4.HDLR_TYPES=void 0;MP4.STTS=void 0;MP4.STSC=void 0;MP4.STCO=void 0;MP4.STSZ=void 0;MP4.VMHD=void 0;MP4.SMHD=void 0;MP4.STSD=void 0;MP4.FTYP=void 0;MP4.DINF=void 0;var MPEG_TS_CLOCK_FREQ_HZ=9e4;function toTimescaleFromBase(e,t,r,i){if(r===void 0){r=1}if(i===void 0){i=false}var a=e*t*r;return i?Math.round(a):a}function toTimescaleFromScale(e,t,r,i){if(r===void 0){r=1}if(i===void 0){i=false}return toTimescaleFromBase(e,t,1/r,i)}function toMsFromMpegTsClock(e,t){if(t===void 0){t=false}return toTimescaleFromBase(e,1e3,1/MPEG_TS_CLOCK_FREQ_HZ,t)}function toMpegTsClockFromTimescale(e,t){if(t===void 0){t=1}return toTimescaleFromBase(e,MPEG_TS_CLOCK_FREQ_HZ,1/t)}var MAX_SILENT_FRAME_DURATION=10*1e3;var AAC_SAMPLES_PER_FRAME=1024;var MPEG_AUDIO_SAMPLE_PER_FRAME=1152;var chromeVersion=null;var safariWebkitVersion=null;var MP4Remuxer=function(){function e(e,t,r,i){if(i===void 0){i=""}this.observer=void 0;this.config=void 0;this.typeSupported=void 0;this.ISGenerated=false;this._initPTS=null;this._initDTS=null;this.nextAvcDts=null;this.nextAudioPts=null;this.videoSampleDuration=null;this.isAudioContiguous=false;this.isVideoContiguous=false;this.observer=e;this.config=t;this.typeSupported=r;this.ISGenerated=false;if(chromeVersion===null){var a=navigator.userAgent||"";var n=a.match(/Chrome\/(\d+)/i);chromeVersion=n?parseInt(n[1]):0}if(safariWebkitVersion===null){var n=navigator.userAgent.match(/Safari\/(\d+)/i);safariWebkitVersion=n?parseInt(n[1]):0}}e.prototype.destroy=function(){};e.prototype.resetTimeStamp=function(e){logger.log("[mp4-remuxer]: initPTS & initDTS reset");this._initPTS=this._initDTS=e};e.prototype.resetNextTimestamp=function(){logger.log("[mp4-remuxer]: reset next timestamp");this.isVideoContiguous=false;this.isAudioContiguous=false};e.prototype.resetInitSegment=function(){logger.log("[mp4-remuxer]: ISGenerated flag reset");this.ISGenerated=false};e.prototype.getVideoStartPts=function(e){var t=false;var r=e.reduce((function(e,r){var i=r.pts-e;if(i<-4294967296){t=true;return normalizePts(e,r.pts)}else if(i>0){return e}else{return r.pts}}),e[0].pts);if(t){logger.debug("PTS rollover detected")}return r};e.prototype.remux=function(e,t,r,i,a,n,s,o){var l;var u;var f;var c;var d;var h;var v=a;var p=a;var g=e.pid>-1;var m=t.pid>-1;var y=t.samples.length;var E=e.samples.length>0;var T=s&&y>0||y>1;var S=(!g||E)&&(!m||T)||this.ISGenerated||s;if(S){if(!this.ISGenerated){f=this.generateIS(e,t,a,n)}var A=this.isVideoContiguous;var L=-1;var b=void 0;if(T){L=findKeyframeIndex(t.samples);if(!A&&this.config.forceKeyFrameOnDiscontinuity){h=true;if(L>0){logger.warn("[mp4-remuxer]: Dropped ".concat(L," out of ").concat(y," video samples due to a missing keyframe"));var R=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(L);t.dropped+=L;p+=(t.samples[0].pts-R)/t.inputTimeScale;b=p}else if(L===-1){logger.warn("[mp4-remuxer]: No keyframe found out of ".concat(y," video samples"));h=false}}}if(this.ISGenerated){if(E&&T){var R=this.getVideoStartPts(t.samples);var D=normalizePts(e.samples[0].pts,R)-R;var I=D/t.inputTimeScale;v+=Math.max(0,I);p+=Math.max(0,-I)}if(E){if(!e.samplerate){logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected");f=this.generateIS(e,t,a,n)}u=this.remuxAudio(e,v,this.isAudioContiguous,n,m||T||o===PlaylistLevelType.AUDIO?p:undefined);if(T){var C=u?u.endPTS-u.startPTS:0;if(!t.inputTimeScale){logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected");f=this.generateIS(e,t,a,n)}l=this.remuxVideo(t,p,A,C)}}else if(T){l=this.remuxVideo(t,p,A,0)}if(l){l.firstKeyFrame=L;l.independent=L!==-1;l.firstKeyFramePTS=b}}}if(this.ISGenerated&&this._initPTS&&this._initDTS){if(r.samples.length){d=flushTextTrackMetadataCueSamples(r,a,this._initPTS,this._initDTS)}if(i.samples.length){c=flushTextTrackUserdataCueSamples(i,a,this._initPTS)}}return{audio:u,video:l,initSegment:f,independent:h,text:c,id3:d}};e.prototype.generateIS=function(e,t,r,i){var a=e.samples;var n=t.samples;var s=this.typeSupported;var o={};var l=this._initPTS;var u=!l||i;var f="audio/mp4";var c;var d;var h;if(u){c=d=Infinity}if(e.config&&a.length){e.timescale=e.samplerate;switch(e.segmentCodec){case"mp3":if(s.mpeg){f="audio/mpeg";e.codec=""}else if(s.mp3){e.codec="mp3"}break}o.audio={id:"audio",container:f,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&s.mpeg?new Uint8Array(0):MP4.initSegment([e]),metadata:{channelCount:e.channelCount}};if(u){h=e.inputTimeScale;if(!l||h!==l.timescale){c=d=a[0].pts-Math.round(h*r)}else{u=false}}}if(t.sps&&t.pps&&n.length){t.timescale=t.inputTimeScale;o.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:MP4.initSegment([t]),metadata:{width:t.width,height:t.height}};if(u){h=t.inputTimeScale;if(!l||h!==l.timescale){var v=this.getVideoStartPts(n);var p=Math.round(h*r);d=Math.min(d,normalizePts(n[0].dts,v)-p);c=Math.min(c,v-p)}else{u=false}}}if(Object.keys(o).length){this.ISGenerated=true;if(u){this._initPTS={baseTime:c,timescale:h};this._initDTS={baseTime:d,timescale:h}}else{c=h=undefined}return{tracks:o,initPTS:c,timescale:h}}};e.prototype.remuxVideo=function(e,t,r,i){var a=e.inputTimeScale;var n=e.samples;var s=[];var o=n.length;var l=this._initPTS;var u=this.nextAvcDts;var f=8;var c=this.videoSampleDuration;var d;var h;var v=Number.POSITIVE_INFINITY;var p=Number.NEGATIVE_INFINITY;var g=false;if(!r||u===null){var m=t*a;var y=n[0].pts-normalizePts(n[0].dts,n[0].pts);u=m-y}var E=l.baseTime*a/l.timescale;for(var T=0;T<o;T++){var S=n[T];S.pts=normalizePts(S.pts-E,u);S.dts=normalizePts(S.dts-E,u);if(S.dts<n[T>0?T-1:T].dts){g=true}}if(g){n.sort((function(e,t){var r=e.dts-t.dts;var i=e.pts-t.pts;return r||i}))}d=n[0].dts;h=n[n.length-1].dts;var A=h-d;var L=A?Math.round(A/(o-1)):c||e.inputTimeScale/30;if(r){var b=d-u;var R=b>L;var D=b<-1;if(R||D){if(R){logger.warn("AVC: ".concat(toMsFromMpegTsClock(b,true)," ms (").concat(b,"dts) hole between fragments detected, filling it"))}else{logger.warn("AVC: ".concat(toMsFromMpegTsClock(-b,true)," ms (").concat(b,"dts) overlapping between fragments detected"))}if(!D||u>=n[0].pts){d=u;var I=n[0].pts-b;n[0].dts=d;n[0].pts=I;logger.log("Video: First PTS/DTS adjusted: ".concat(toMsFromMpegTsClock(I,true),"/").concat(toMsFromMpegTsClock(d,true),", delta: ").concat(toMsFromMpegTsClock(b,true)," ms"))}}}d=Math.max(0,d);var C=0;var _=0;for(var T=0;T<o;T++){var S=n[T];var k=S.units;var P=k.length;var w=0;for(var F=0;F<P;F++){w+=k[F].data.length}_+=w;C+=P;S.length=w;S.dts=Math.max(S.dts,d);v=Math.min(S.pts,v);p=Math.max(S.pts,p)}h=n[o-1].dts;var x=_+4*C+8;var O;try{O=new Uint8Array(x)}catch(e){this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MUX_ERROR,details:ErrorDetails.REMUX_ALLOC_ERROR,fatal:false,error:e,bytes:x,reason:"fail allocating video mdat ".concat(x)});return}var M=new DataView(O.buffer);M.setUint32(0,x);O.set(MP4.types.mdat,4);var N=false;var U=Number.POSITIVE_INFINITY;var B=Number.POSITIVE_INFINITY;var G=Number.NEGATIVE_INFINITY;var K=Number.NEGATIVE_INFINITY;for(var T=0;T<o;T++){var H=n[T];var V=H.units;var j=0;for(var F=0,P=V.length;F<P;F++){var W=V[F];var Y=W.data;var q=W.data.byteLength;M.setUint32(f,q);f+=4;O.set(Y,f);f+=q;j+=4+q}var X=void 0;if(T<o-1){c=n[T+1].dts-H.dts;X=n[T+1].pts-H.pts}else{var z=this.config;var $=T>0?H.dts-n[T-1].dts:L;X=T>0?H.pts-n[T-1].pts:L;if(z.stretchShortVideoTrack&&this.nextAudioPts!==null){var Q=Math.floor(z.maxBufferHole*a);var Z=(i?v+i*a:this.nextAudioPts)-H.pts;if(Z>Q){c=Z-$;if(c<0){c=$}else{N=true}logger.log("[mp4-remuxer]: It is approximately ".concat(Z/90," ms to the next segment; using duration ").concat(c/90," ms for the last video frame."))}else{c=$}}else{c=$}}var J=Math.round(H.pts-H.dts);U=Math.min(U,c);G=Math.max(G,c);B=Math.min(B,X);K=Math.max(K,X);s.push(new Mp4Sample(H.key,c,j,J))}if(s.length){if(chromeVersion){if(chromeVersion<70){var ee=s[0].flags;ee.dependsOn=2;ee.isNonSync=0}}else if(safariWebkitVersion){if(K-B<G-U&&L/G<.025&&s[0].cts===0){logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");var te=d;for(var T=0,re=s.length;T<re;T++){var ie=te+s[T].duration;var m=te+s[T].cts;if(T<re-1){var ae=ie+s[T+1].cts;s[T].duration=ae-m}else{s[T].duration=T?s[T-1].duration:L}s[T].cts=0;te=ie}}}}c=N||!c?L:c;this.nextAvcDts=u=h+c;this.videoSampleDuration=c;this.isVideoContiguous=true;var ne=MP4.moof(e.sequenceNumber++,d,_extends({},e,{samples:s}));var se="video";var oe={data1:ne,data2:O,startPTS:v/a,endPTS:(p+c)/a,startDTS:d/a,endDTS:u/a,type:se,hasAudio:false,hasVideo:true,nb:s.length,dropped:e.dropped};e.samples=[];e.dropped=0;return oe};e.prototype.remuxAudio=function(e,t,r,i,a){var n=e.inputTimeScale;var s=e.samplerate?e.samplerate:n;var o=n/s;var l=e.segmentCodec==="aac"?AAC_SAMPLES_PER_FRAME:MPEG_AUDIO_SAMPLE_PER_FRAME;var u=l*o;var f=this._initPTS;var c=e.segmentCodec==="mp3"&&this.typeSupported.mpeg;var d=[];var h=a!==undefined;var v=e.samples;var p=c?0:8;var g=this.nextAudioPts||-1;var m=t*n;var y=f.baseTime*n/f.timescale;this.isAudioContiguous=r=r||v.length&&g>0&&(i&&Math.abs(m-g)<9e3||Math.abs(normalizePts(v[0].pts-y,m)-g)<20*u);v.forEach((function(e){e.pts=normalizePts(e.pts-y,m)}));if(!r||g<0){v=v.filter((function(e){return e.pts>=0}));if(!v.length){return}if(a===0){g=0}else if(i&&!h){g=Math.max(0,m)}else{g=v[0].pts}}if(e.segmentCodec==="aac"){var E=this.config.maxAudioFramesDrift;for(var T=0,S=g;T<v.length;T++){var A=v[T];var L=A.pts;var b=L-S;var R=Math.abs(1e3*b/n);if(b<=-E*u&&h){if(T===0){logger.warn("Audio frame @ ".concat((L/n).toFixed(3),"s overlaps nextAudioPts by ").concat(Math.round(1e3*b/n)," ms."));this.nextAudioPts=g=S=L}}else if(b>=E*u&&R<MAX_SILENT_FRAME_DURATION&&h){var D=Math.round(b/u);S=L-D*u;if(S<0){D--;S+=u}if(T===0){this.nextAudioPts=g=S}logger.warn("[mp4-remuxer]: Injecting ".concat(D," audio frame @ ").concat((S/n).toFixed(3),"s due to ").concat(Math.round(1e3*b/n)," ms gap."));for(var I=0;I<D;I++){var C=Math.max(S,0);var _=AAC.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(!_){logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead.");_=A.unit.subarray()}v.splice(T,0,{unit:_,pts:C});S+=u;T++}}A.pts=S;S+=u}}var k=null;var P=null;var w;var F=0;var x=v.length;while(x--){F+=v[x].unit.byteLength}for(var I=0,O=v.length;I<O;I++){var M=v[I];var N=M.unit;var L=M.pts;if(P!==null){var U=d[I-1];U.duration=Math.round((L-P)/o)}else{if(r&&e.segmentCodec==="aac"){L=g}k=L;if(F>0){F+=p;try{w=new Uint8Array(F)}catch(e){this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MUX_ERROR,details:ErrorDetails.REMUX_ALLOC_ERROR,fatal:false,error:e,bytes:F,reason:"fail allocating audio mdat ".concat(F)});return}if(!c){var B=new DataView(w.buffer);B.setUint32(0,F);w.set(MP4.types.mdat,4)}}else{return}}w.set(N,p);var G=N.byteLength;p+=G;d.push(new Mp4Sample(true,l,G,0));P=L}var K=d.length;if(!K){return}var H=d[d.length-1];this.nextAudioPts=g=P+o*H.duration;var V=c?new Uint8Array(0):MP4.moof(e.sequenceNumber++,k/o,_extends({},e,{samples:d}));e.samples=[];var j=k/n;var W=g/n;var Y="audio";var q={data1:V,data2:w,startPTS:j,endPTS:W,startDTS:j,endDTS:W,type:Y,hasAudio:true,hasVideo:false,nb:K};this.isAudioContiguous=true;return q};e.prototype.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale;var n=e.samplerate?e.samplerate:a;var s=a/n;var o=this.nextAudioPts;var l=this._initDTS;var u=l.baseTime*9e4/l.timescale;var f=(o!==null?o:i.startDTS*a)+u;var c=i.endDTS*a+u;var d=s*AAC_SAMPLES_PER_FRAME;var h=Math.ceil((c-f)/d);var v=AAC.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);logger.warn("[mp4-remuxer]: remux empty Audio");if(!v){logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}var p=[];for(var g=0;g<h;g++){var m=f+g*d;p.push({unit:v,pts:m,dts:m})}e.samples=p;return this.remuxAudio(e,t,r,false)};return e}();function normalizePts(e,t){var r;if(t===null){return e}if(t<e){r=-8589934592}else{r=8589934592}while(Math.abs(e-t)>4294967296){e+=r}return e}function findKeyframeIndex(e){for(var t=0;t<e.length;t++){if(e[t].key){return t}}return-1}function flushTextTrackMetadataCueSamples(e,t,r,i){var a=e.samples.length;if(!a){return}var n=e.inputTimeScale;for(var s=0;s<a;s++){var o=e.samples[s];o.pts=normalizePts(o.pts-r.baseTime*n/r.timescale,t*n)/n;o.dts=normalizePts(o.dts-i.baseTime*n/i.timescale,t*n)/n}var l=e.samples;e.samples=[];return{samples:l}}function flushTextTrackUserdataCueSamples(e,t,r){var i=e.samples.length;if(!i){return}var a=e.inputTimeScale;for(var n=0;n<i;n++){var s=e.samples[n];s.pts=normalizePts(s.pts-r.baseTime*a/r.timescale,t*a)/a}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;e.samples=[];return{samples:o}}var Mp4Sample=function(){function e(e,t,r,i){this.size=void 0;this.duration=void 0;this.cts=void 0;this.flags=void 0;this.duration=t;this.size=r;this.cts=i;this.flags=new Mp4SampleFlags(e)}return e}();var Mp4SampleFlags=function(){function e(e){this.isLeading=0;this.isDependedOn=0;this.hasRedundancy=0;this.degradPrio=0;this.dependsOn=1;this.isNonSync=1;this.dependsOn=e?2:1;this.isNonSync=e?0:1}return e}();var PassThroughRemuxer=function(){function e(){this.emitInitSegment=false;this.audioCodec=void 0;this.videoCodec=void 0;this.initData=void 0;this.initPTS=null;this.initTracks=void 0;this.lastEndTime=null}e.prototype.destroy=function(){};e.prototype.resetTimeStamp=function(e){this.initPTS=e;this.lastEndTime=null};e.prototype.resetNextTimestamp=function(){this.lastEndTime=null};e.prototype.resetInitSegment=function(e,t,r,i){this.audioCodec=t;this.videoCodec=r;this.generateInitSegment(patchEncyptionData(e,i));this.emitInitSegment=true};e.prototype.generateInitSegment=function(e){var t=this,r=t.audioCodec,i=t.videoCodec;if(!(e!=null&&e.byteLength)){this.initTracks=undefined;this.initData=undefined;return}var a=this.initData=parseInitSegment(e);if(!r){r=getParsedTrackCodec(a.audio,ElementaryStreamTypes.AUDIO)}if(!i){i=getParsedTrackCodec(a.video,ElementaryStreamTypes.VIDEO)}var n={};if(a.audio&&a.video){n.audiovideo={container:"video/mp4",codec:r+","+i,initSegment:e,id:"main"}}else if(a.audio){n.audio={container:"audio/mp4",codec:r,initSegment:e,id:"audio"}}else if(a.video){n.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}}else{logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes.")}this.initTracks=n};e.prototype.remux=function(e,t,r,i,a,n){var s,o;var l=this,u=l.initPTS,f=l.lastEndTime;var c={audio:undefined,video:undefined,text:i,id3:r,initSegment:undefined};if(!isFiniteNumber(f)){f=this.lastEndTime=a||0}var d=t.samples;if(!(d!=null&&d.length)){return c}var h={initPTS:undefined,timescale:1};var v=this.initData;if(!((s=v)!=null&&s.length)){this.generateInitSegment(d);v=this.initData}if(!((o=v)!=null&&o.length)){logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment.");return c}if(this.emitInitSegment){h.tracks=this.initTracks;this.emitInitSegment=false}var p=getDuration(d,v);var g=getStartDTS(v,d);var m=g===null?a:g;if(isInvalidInitPts(u,m,a,p)||h.timescale!==u.timescale&&n){h.initPTS=m-a;if(u&&u.timescale===1){logger.warn("Adjusting initPTS by ".concat(h.initPTS-u.baseTime))}this.initPTS=u={baseTime:h.initPTS,timescale:1}}var y=e?m-u.baseTime/u.timescale:f;var E=y+p;offsetStartDTS(v,d,u.baseTime/u.timescale);if(p>0){this.lastEndTime=E}else{logger.warn("Duration parsed from mp4 should be greater than zero");this.resetNextTimestamp()}var T=!!v.audio;var S=!!v.video;var A="";if(T){A+="audio"}if(S){A+="video"}var L={data1:d,startPTS:y,startDTS:y,endPTS:E,endDTS:E,type:A,hasAudio:T,hasVideo:S,nb:1,dropped:0};c.audio=L.type==="audio"?L:undefined;c.video=L.type!=="audio"?L:undefined;c.initSegment=h;c.id3=flushTextTrackMetadataCueSamples(r,a,u,u);if(i.samples.length){c.text=flushTextTrackUserdataCueSamples(i,a,u)}return c};return e}();function isInvalidInitPts(e,t,r,i){if(e===null){return true}var a=Math.max(i,1);var n=t-e.baseTime/e.timescale;return Math.abs(n-r)>a}function getParsedTrackCodec(e,t){var r=e==null?void 0:e.codec;if(r&&r.length>4){return r}if(r==="hvc1"||r==="hev1"){return"hvc1.1.6.L120.90"}if(r==="av01"){return"av01.0.04M.08"}if(r==="avc1"||t===ElementaryStreamTypes.VIDEO){return"avc1.42e01e"}return"mp4a.40.5"}var now;try{now=self.performance.now.bind(self.performance)}catch(e){logger.debug("Unable to use Performance API on this environment");now=typeof self!=="undefined"&&self.Date.now}var muxConfig=[{demux:MP4Demuxer,remux:PassThroughRemuxer},{demux:TSDemuxer,remux:MP4Remuxer},{demux:AACDemuxer,remux:MP4Remuxer},{demux:MP3Demuxer,remux:MP4Remuxer}];var Transmuxer=function(){function e(e,t,r,i,a){this.async=false;this.observer=void 0;this.typeSupported=void 0;this.config=void 0;this.vendor=void 0;this.id=void 0;this.demuxer=void 0;this.remuxer=void 0;this.decrypter=void 0;this.probe=void 0;this.decryptionPromise=null;this.transmuxConfig=void 0;this.currentTransmuxState=void 0;this.observer=e;this.typeSupported=t;this.config=r;this.vendor=i;this.id=a}e.prototype.configure=function(e){this.transmuxConfig=e;if(this.decrypter){this.decrypter.reset()}};e.prototype.push=function(e,t,r,i){var a=this;var n=r.transmuxing;n.executeStart=now();var s=new Uint8Array(e);var o=this,l=o.currentTransmuxState,u=o.transmuxConfig;if(i){this.currentTransmuxState=i}var f=i||l,c=f.contiguous,d=f.discontinuity,h=f.trackSwitch,v=f.accurateTimeOffset,p=f.timeOffset,g=f.initSegmentChange;var m=u.audioCodec,y=u.videoCodec,E=u.defaultInitPts,T=u.duration,S=u.initSegmentData;var A=getEncryptionType(s,t);if(A&&A.method==="AES-128"){var L=this.getDecrypter();if(L.isSync()){var b=L.softwareDecrypt(s,A.key.buffer,A.iv.buffer);var R=r.part>-1;if(R){b=L.flush()}if(!b){n.executeEnd=now();return emptyResult(r)}s=new Uint8Array(b)}else{this.decryptionPromise=L.webCryptoDecrypt(s,A.key.buffer,A.iv.buffer).then((function(e){var t=a.push(e,null,r);a.decryptionPromise=null;return t}));return this.decryptionPromise}}var D=this.needsProbing(d,h);if(D){var I=this.configureTransmuxer(s);if(I){logger.warn("[transmuxer] ".concat(I.message));this.observer.emit(Events.ERROR,Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,fatal:false,error:I,reason:I.message});n.executeEnd=now();return emptyResult(r)}}if(d||h||g||D){this.resetInitSegment(S,m,y,T,t)}if(d||g||D){this.resetInitialTimestamp(E)}if(!c){this.resetContiguity()}var C=this.transmux(s,A,p,v,r);var _=this.currentTransmuxState;_.contiguous=true;_.discontinuity=false;_.trackSwitch=false;n.executeEnd=now();return C};e.prototype.flush=function(e){var t=this;var r=e.transmuxing;r.executeStart=now();var i=this,a=i.decrypter,n=i.currentTransmuxState,s=i.decryptionPromise;if(s){return s.then((function(){return t.flush(e)}))}var o=[];var l=n.timeOffset;if(a){var u=a.flush();if(u){o.push(this.push(u,null,e))}}var f=this,c=f.demuxer,d=f.remuxer;if(!c||!d){r.executeEnd=now();return[emptyResult(e)]}var h=c.flush(l);if(isPromise(h)){return h.then((function(r){t.flushRemux(o,r,e);return o}))}this.flushRemux(o,h,e);return o};e.prototype.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,n=t.id3Track,s=t.textTrack;var o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;logger.log("[transmuxer.ts]: Flushed fragment ".concat(r.sn).concat(r.part>-1?" p: "+r.part:""," of level ").concat(r.level));var f=this.remuxer.remux(i,a,n,s,u,l,true,this.id);e.push({remuxResult:f,chunkMeta:r});r.transmuxing.executeEnd=now()};e.prototype.resetInitialTimestamp=function(e){var t=this,r=t.demuxer,i=t.remuxer;if(!r||!i){return}r.resetTimeStamp(e);i.resetTimeStamp(e)};e.prototype.resetContiguity=function(){var e=this,t=e.demuxer,r=e.remuxer;if(!t||!r){return}t.resetContiguity();r.resetNextTimestamp()};e.prototype.resetInitSegment=function(e,t,r,i,a){var n=this,s=n.demuxer,o=n.remuxer;if(!s||!o){return}s.resetInitSegment(e,t,r,i);o.resetInitSegment(e,t,r,a)};e.prototype.destroy=function(){if(this.demuxer){this.demuxer.destroy();this.demuxer=undefined}if(this.remuxer){this.remuxer.destroy();this.remuxer=undefined}};e.prototype.transmux=function(e,t,r,i,a){var n;if(t&&t.method==="SAMPLE-AES"){n=this.transmuxSampleAes(e,t,r,i,a)}else{n=this.transmuxUnencrypted(e,r,i,a)}return n};e.prototype.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,false,!this.config.progressive),n=a.audioTrack,s=a.videoTrack,o=a.id3Track,l=a.textTrack;var u=this.remuxer.remux(n,s,o,l,t,r,false,this.id);return{remuxResult:u,chunkMeta:i}};e.prototype.transmuxSampleAes=function(e,t,r,i,a){var n=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){var t=n.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,false,n.id);return{remuxResult:t,chunkMeta:a}}))};e.prototype.configureTransmuxer=function(e){var t=this,r=t.config,i=t.observer,a=t.typeSupported,n=t.vendor;var s;for(var o=0,l=muxConfig.length;o<l;o++){if(muxConfig[o].demux.probe(e)){s=muxConfig[o];break}}if(!s){return new Error("Failed to find demuxer by probing fragment data")}var u=this.demuxer;var f=this.remuxer;var c=s.remux;var d=s.demux;if(!f||!(f instanceof c)){this.remuxer=new c(i,r,a,n)}if(!u||!(u instanceof d)){this.demuxer=new d(i,r,a);this.probe=d.probe}};e.prototype.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t};e.prototype.getDecrypter=function(){var e=this.decrypter;if(!e){e=this.decrypter=new Decrypter(this.config)}return e};return e}();function getEncryptionType(e,t){var r=null;if(e.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null){r=t}return r}var emptyResult=function(e){return{remuxResult:{},chunkMeta:e}};function isPromise(e){return"then"in e&&e.then instanceof Function}var TransmuxConfig=function(){function e(e,t,r,i,a){this.audioCodec=void 0;this.videoCodec=void 0;this.initSegmentData=void 0;this.duration=void 0;this.defaultInitPts=void 0;this.audioCodec=e;this.videoCodec=t;this.initSegmentData=r;this.duration=i;this.defaultInitPts=a||null}return e}();var TransmuxState=function(){function e(e,t,r,i,a,n){this.discontinuity=void 0;this.contiguous=void 0;this.accurateTimeOffset=void 0;this.trackSwitch=void 0;this.timeOffset=void 0;this.initSegmentChange=void 0;this.discontinuity=e;this.contiguous=t;this.accurateTimeOffset=r;this.trackSwitch=i;this.timeOffset=a;this.initSegmentChange=n}return e}();var eventemitter3={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}if(Object.create){i.prototype=Object.create(null);if(!(new i).__proto__)r=false}function a(e,t,r){this.fn=e;this.context=t;this.once=r||false}function n(e,t,i,n,s){if(typeof i!=="function"){throw new TypeError("The listener must be a function")}var o=new a(i,n||e,s),l=r?r+t:t;if(!e._events[l])e._events[l]=o,e._eventsCount++;else if(!e._events[l].fn)e._events[l].push(o);else e._events[l]=[e._events[l],o];return e}function s(e,t){if(--e._eventsCount===0)e._events=new i;else delete e._events[t]}function o(){this._events=new i;this._eventsCount=0}o.prototype.eventNames=function e(){var i=[],a,n;if(this._eventsCount===0)return i;for(n in a=this._events){if(t.call(a,n))i.push(r?n.slice(1):n)}if(Object.getOwnPropertySymbols){return i.concat(Object.getOwnPropertySymbols(a))}return i};o.prototype.listeners=function e(t){var i=r?r+t:t,a=this._events[i];if(!a)return[];if(a.fn)return[a.fn];for(var n=0,s=a.length,o=new Array(s);n<s;n++){o[n]=a[n].fn}return o};o.prototype.listenerCount=function e(t){var i=r?r+t:t,a=this._events[i];if(!a)return 0;if(a.fn)return 1;return a.length};o.prototype.emit=function e(t,i,a,n,s,o){var l=r?r+t:t;if(!this._events[l])return false;var u=this._events[l],f=arguments.length,c,d;if(u.fn){if(u.once)this.removeListener(t,u.fn,undefined,true);switch(f){case 1:return u.fn.call(u.context),true;case 2:return u.fn.call(u.context,i),true;case 3:return u.fn.call(u.context,i,a),true;case 4:return u.fn.call(u.context,i,a,n),true;case 5:return u.fn.call(u.context,i,a,n,s),true;case 6:return u.fn.call(u.context,i,a,n,s,o),true}for(d=1,c=new Array(f-1);d<f;d++){c[d-1]=arguments[d]}u.fn.apply(u.context,c)}else{var h=u.length,v;for(d=0;d<h;d++){if(u[d].once)this.removeListener(t,u[d].fn,undefined,true);switch(f){case 1:u[d].fn.call(u[d].context);break;case 2:u[d].fn.call(u[d].context,i);break;case 3:u[d].fn.call(u[d].context,i,a);break;case 4:u[d].fn.call(u[d].context,i,a,n);break;default:if(!c)for(v=1,c=new Array(f-1);v<f;v++){c[v-1]=arguments[v]}u[d].fn.apply(u[d].context,c)}}}return true};o.prototype.on=function e(t,r,i){return n(this,t,r,i,false)};o.prototype.once=function e(t,r,i){return n(this,t,r,i,true)};o.prototype.removeListener=function e(t,i,a,n){var o=r?r+t:t;if(!this._events[o])return this;if(!i){s(this,o);return this}var l=this._events[o];if(l.fn){if(l.fn===i&&(!n||l.once)&&(!a||l.context===a)){s(this,o)}}else{for(var u=0,f=[],c=l.length;u<c;u++){if(l[u].fn!==i||n&&!l[u].once||a&&l[u].context!==a){f.push(l[u])}}if(f.length)this._events[o]=f.length===1?f[0]:f;else s(this,o)}return this};o.prototype.removeAllListeners=function e(t){var a;if(t){a=r?r+t:t;if(this._events[a])s(this,a)}else{this._events=new i;this._eventsCount=0}return this};o.prototype.off=o.prototype.removeListener;o.prototype.addListener=o.prototype.on;o.prefixed=r;o.EventEmitter=o;{e.exports=o}})(eventemitter3);var eventemitter3Exports=eventemitter3.exports;var EventEmitter=getDefaultExportFromCjs(eventemitter3Exports);var MediaSource$1=getMediaSource()||{isTypeSupported:function(){return false}};var TransmuxerInterface=function(){function e(e,t,r,i){var a=this;this.error=null;this.hls=void 0;this.id=void 0;this.observer=void 0;this.frag=null;this.part=null;this.useWorker=void 0;this.workerContext=null;this.onwmsg=void 0;this.transmuxer=null;this.onTransmuxComplete=void 0;this.onFlush=void 0;var n=e.config;this.hls=e;this.id=t;this.useWorker=!!n.enableWorker;this.onTransmuxComplete=r;this.onFlush=i;var s=function(e,t){t=t||{};t.frag=a.frag;t.id=a.id;if(e===Events.ERROR){a.error=t.error}a.hls.trigger(e,t)};this.observer=new EventEmitter;this.observer.on(Events.FRAG_DECRYPTED,s);this.observer.on(Events.ERROR,s);var o={mp4:MediaSource$1.isTypeSupported("video/mp4"),mpeg:MediaSource$1.isTypeSupported("audio/mpeg"),mp3:MediaSource$1.isTypeSupported('audio/mp4; codecs="mp3"')};var l=navigator.vendor;if(this.useWorker&&typeof Worker!=="undefined"){var u=n.workerPath||hasUMDWorker();if(u){try{if(n.workerPath){logger.log("loading Web Worker ".concat(n.workerPath,' for "').concat(t,'"'));this.workerContext=loadWorker(n.workerPath)}else{logger.log('injecting Web Worker for "'.concat(t,'"'));this.workerContext=injectWorker()}this.onwmsg=function(e){return a.onWorkerMessage(e)};var f=this.workerContext.worker;f.addEventListener("message",this.onwmsg);f.onerror=function(e){var r=new Error("".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")"));n.enableWorker=false;logger.warn('Error in "'.concat(t,'" Web Worker, fallback to inline'));a.hls.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,fatal:false,event:"demuxerWorker",error:r})};f.postMessage({cmd:"init",typeSupported:o,vendor:l,id:t,config:JSON.stringify(n)})}catch(e){logger.warn('Error setting up "'.concat(t,'" Web Worker, fallback to inline'),e);this.resetWorker();this.error=null;this.transmuxer=new Transmuxer(this.observer,o,n,l,t)}return}}this.transmuxer=new Transmuxer(this.observer,o,n,l,t)}e.prototype.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;if(r){self.URL.revokeObjectURL(r)}t.removeEventListener("message",this.onwmsg);t.onerror=null;t.terminate();this.workerContext=null}};e.prototype.destroy=function(){if(this.workerContext){this.resetWorker();this.onwmsg=undefined}else{var e=this.transmuxer;if(e){e.destroy();this.transmuxer=null}}var t=this.observer;if(t){t.removeAllListeners()}this.frag=null;this.observer=null;this.hls=null};e.prototype.push=function(e,t,r,i,a,n,s,o,l,u){var f=this;var c,d;l.transmuxing.start=self.performance.now();var h=this.transmuxer;var v=n?n.start:a.start;var p=a.decryptdata;var g=this.frag;var m=!(g&&a.cc===g.cc);var y=!(g&&l.level===g.level);var E=g?l.sn-g.sn:-1;var T=this.part?l.part-this.part.index:-1;var S=E===0&&l.id>1&&l.id===(g==null?void 0:g.stats.chunkCount);var A=!y&&(E===1||E===0&&(T===1||S&&T<=0));var L=self.performance.now();if(y||E||a.stats.parsing.start===0){a.stats.parsing.start=L}if(n&&(T||!A)){n.stats.parsing.start=L}var b=!(g&&((c=a.initSegment)==null?void 0:c.url)===((d=g.initSegment)==null?void 0:d.url));var R=new TransmuxState(m,A,o,y,v,b);if(!A||m||b){logger.log("[transmuxer-interface, ".concat(a.type,"]: Starting new transmux session for sn: ").concat(l.sn," p: ").concat(l.part," level: ").concat(l.level," id: ").concat(l.id,"\n discontinuity: ").concat(m,"\n trackSwitch: ").concat(y,"\n contiguous: ").concat(A,"\n accurateTimeOffset: ").concat(o,"\n timeOffset: ").concat(v,"\n initSegmentChange: ").concat(b));var D=new TransmuxConfig(r,i,t,s,u);this.configureTransmuxer(D)}this.frag=a;this.part=n;if(this.workerContext){this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:R},e instanceof ArrayBuffer?[e]:[])}else if(h){var I=h.push(e,p,l,R);if(isPromise(I)){h.async=true;I.then((function(e){f.handleTransmuxComplete(e)})).catch((function(e){f.transmuxerError(e,l,"transmuxer-interface push error")}))}else{h.async=false;this.handleTransmuxComplete(I)}}};e.prototype.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext){this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e})}else if(r){var i=r.flush(e);var a=isPromise(i);if(a||r.async){if(!isPromise(i)){i=Promise.resolve(i)}i.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")}))}else{this.handleFlushResult(i,e)}}};e.prototype.transmuxerError=function(e,t,r){if(!this.hls){return}this.error=e;this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,fatal:false,error:e,err:e,reason:r})};e.prototype.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)}));this.onFlush(t)};e.prototype.onWorkerMessage=function(e){var t=e.data;var r=this.hls;switch(t.event){case"init":{var i;var a=(i=this.workerContext)==null?void 0:i.objectURL;if(a){self.URL.revokeObjectURL(a)}break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":if(logger[t.data.logType]){logger[t.data.logType](t.data.message)}break;default:{t.data=t.data||{};t.data.frag=this.frag;t.data.id=this.id;r.trigger(t.event,t.data);break}}};e.prototype.configureTransmuxer=function(e){var t=this.transmuxer;if(this.workerContext){this.workerContext.worker.postMessage({cmd:"configure",config:e})}else if(t){t.configure(e)}};e.prototype.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now();this.onTransmuxComplete(e)};return e}();var STALL_MINIMUM_DURATION_MS=250;var MAX_START_GAP_JUMP=2;var SKIP_BUFFER_HOLE_STEP_SECONDS=.1;var SKIP_BUFFER_RANGE_START=.05;var GapController=function(){function e(e,t,r,i){this.config=void 0;this.media=null;this.fragmentTracker=void 0;this.hls=void 0;this.nudgeRetry=0;this.stallReported=false;this.stalled=null;this.moved=false;this.seeking=false;this.config=e;this.media=t;this.fragmentTracker=r;this.hls=i}e.prototype.destroy=function(){this.media=null;this.hls=this.fragmentTracker=null};e.prototype.poll=function(e,t){var r=this,i=r.config,a=r.media,n=r.stalled;if(a===null){return}var s=a.currentTime,o=a.seeking;var l=this.seeking&&!o;var u=!this.seeking&&o;this.seeking=o;if(s!==e){this.moved=true;if(n!==null){if(this.stallReported){var f=self.performance.now()-n;logger.warn("playback not stuck anymore @".concat(s,", after ").concat(Math.round(f),"ms"));this.stallReported=false}this.stalled=null;this.nudgeRetry=0}return}if(u||l){this.stalled=null;return}if(a.paused&&!o||a.ended||a.playbackRate===0||!BufferHelper.getBuffered(a).length){return}var c=BufferHelper.bufferInfo(a,s,0);var d=c.len>0;var h=c.nextStart||0;if(!d&&!h){return}if(o){var v=c.len>MAX_START_GAP_JUMP;var p=!h||t&&t.start<=s||h-s>MAX_START_GAP_JUMP&&!this.fragmentTracker.getPartialFragment(s);if(v||p){return}this.moved=false}if(!this.moved&&this.stalled!==null){var g;var m=Math.max(h,c.start||0)-s;var y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null;var E=y==null?void 0:(g=y.details)==null?void 0:g.live;var T=E?y.details.targetduration*2:MAX_START_GAP_JUMP;var S=this.fragmentTracker.getPartialFragment(s);if(m>0&&(m<=T||S)){this._trySkipBufferHole(S);return}}var A=self.performance.now();if(n===null){this.stalled=A;return}var L=A-n;if(!o&&L>=STALL_MINIMUM_DURATION_MS){this._reportStall(c);if(!this.media){return}}var b=BufferHelper.bufferInfo(a,s,i.maxBufferHole);this._tryFixBufferStall(b,L)};e.prototype._tryFixBufferStall=function(e,t){var r=this,i=r.config,a=r.fragmentTracker,n=r.media;if(n===null){return}var s=n.currentTime;var o=a.getPartialFragment(s);if(o){var l=this._trySkipBufferHole(o);if(l||!this.media){return}}if((e.len>i.maxBufferHole||e.nextStart&&e.nextStart-s<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3){logger.warn("Trying to nudge playhead over buffer-hole");this.stalled=null;this._tryNudgeBuffer()}};e.prototype._reportStall=function(e){var t=this,r=t.hls,i=t.media,a=t.stallReported;if(!a&&i){this.stallReported=true;var n=new Error("Playback stalling at @".concat(i.currentTime," due to low buffer (").concat(JSON.stringify(e),")"));logger.warn(n.message);r.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_STALLED_ERROR,fatal:false,error:n,buffer:e.len})}};e.prototype._trySkipBufferHole=function(e){var t=this,r=t.config,i=t.hls,a=t.media;if(a===null){return 0}var n=a.currentTime;var s=BufferHelper.bufferInfo(a,n,0);var o=n<s.start?s.start:s.nextStart;if(o){var l=s.len<=r.maxBufferHole;var u=s.len>0&&s.len<1&&a.readyState<3;var f=o-n;if(f>0&&(l||u)){if(f>r.maxBufferHole){var c=this.fragmentTracker;var d=false;if(n===0){var h=c.getAppendedFrag(0,PlaylistLevelType.MAIN);if(h&&o<h.end){d=true}}if(!d){var v=e||c.getAppendedFrag(n,PlaylistLevelType.MAIN);if(v){var p=false;var g=v.end;while(g<o){var m=c.getPartialFragment(g);if(m){g+=m.duration}else{p=true;break}}if(p){return 0}}}}var y=Math.max(o+SKIP_BUFFER_RANGE_START,n+SKIP_BUFFER_HOLE_STEP_SECONDS);logger.warn("skipping hole, adjusting currentTime from ".concat(n," to ").concat(y));this.moved=true;this.stalled=null;a.currentTime=y;if(e&&!e.gap){var E=new Error("fragment loaded with buffer holes, seeking from ".concat(n," to ").concat(y));i.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:false,error:E,reason:E.message,frag:e})}return y}}return 0};e.prototype._tryNudgeBuffer=function(){var e=this,t=e.config,r=e.hls,i=e.media,a=e.nudgeRetry;if(i===null){return}var n=i.currentTime;this.nudgeRetry++;if(a<t.nudgeMaxRetry){var s=n+(a+1)*t.nudgeOffset;var o=new Error("Nudging 'currentTime' from ".concat(n," to ").concat(s));logger.warn(o.message);i.currentTime=s;r.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_NUDGE_ON_STALL,error:o,fatal:false})}else{var o=new Error("Playhead still not moving while enough data buffered @".concat(n," after ").concat(t.nudgeMaxRetry," nudges"));logger.error(o.message);r.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_STALLED_ERROR,error:o,fatal:true})}};return e}();var TICK_INTERVAL$2=100;var StreamController=function(e){__extends(t,e);function t(t,r,i){var a=e.call(this,t,r,i,"[stream-controller]",PlaylistLevelType.MAIN)||this;a.audioCodecSwap=false;a.gapController=null;a.level=-1;a._forceStartLoad=false;a.altAudio=false;a.audioOnly=false;a.fragPlaying=null;a.onvplaying=null;a.onvseeked=null;a.fragLastKbps=0;a.couldBacktrack=false;a.backtrackFragment=null;a.audioCodecSwitch=false;a.videoBuffer=null;a._registerListeners();return a}t.prototype._registerListeners=function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.on(Events.LEVEL_LOADING,this.onLevelLoading,this);e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this);e.on(Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this);e.on(Events.ERROR,this.onError,this);e.on(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);e.on(Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);e.on(Events.BUFFER_CREATED,this.onBufferCreated,this);e.on(Events.BUFFER_FLUSHED,this.onBufferFlushed,this);e.on(Events.LEVELS_UPDATED,this.onLevelsUpdated,this);e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this)};t.prototype._unregisterListeners=function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this);e.off(Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this);e.off(Events.ERROR,this.onError,this);e.off(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);e.off(Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);e.off(Events.BUFFER_CREATED,this.onBufferCreated,this);e.off(Events.BUFFER_FLUSHED,this.onBufferFlushed,this);e.off(Events.LEVELS_UPDATED,this.onLevelsUpdated,this);e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this)};t.prototype.onHandlerDestroying=function(){this._unregisterListeners();this.onMediaDetaching()};t.prototype.startLoad=function(e){if(this.levels){var t=this,r=t.lastCurrentTime,i=t.hls;this.stopLoad();this.setInterval(TICK_INTERVAL$2);this.level=-1;if(!this.startFragRequested){var a=i.startLevel;if(a===-1){if(i.config.testBandwidth&&this.levels.length>1){a=0;this.bitrateTest=true}else{a=i.nextAutoLevel}}this.level=i.nextLoadLevel=a;this.loadedmetadata=false}if(r>0&&e===-1){this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3)));e=r}this.state=State.IDLE;this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e;this.tick()}else{this._forceStartLoad=true;this.state=State.STOPPED}};t.prototype.stopLoad=function(){this._forceStartLoad=false;e.prototype.stopLoad.call(this)};t.prototype.doTick=function(){switch(this.state){case State.WAITING_LEVEL:{var e;var t=this,r=t.levels,i=t.level;var a=r==null?void 0:(e=r[i])==null?void 0:e.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a)){break}this.state=State.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=State.IDLE;break}break}case State.FRAG_LOADING_WAITING_RETRY:{var n;var s=self.performance.now();var o=this.retryDate;if(!o||s>=o||(n=this.media)!=null&&n.seeking){this.resetStartWhenNotLoaded(this.level);this.state=State.IDLE}}break}if(this.state===State.IDLE){this.doTickIdle()}this.onTickEnd()};t.prototype.onTickEnd=function(){e.prototype.onTickEnd.call(this);this.checkBuffer();this.checkFragmentChanged()};t.prototype.doTickIdle=function(){var e=this,t=e.hls,r=e.levelLastLoaded,i=e.levels,a=e.media;var n=t.config,s=t.nextLoadLevel;if(r===null||!a&&(this.startFragRequested||!n.startFragPrefetch)){return}if(this.altAudio&&this.audioOnly){return}if(!(i!=null&&i[s])){return}var o=i[s];var l=this.getMainFwdBufferInfo();if(l===null){return}var u=this.getLevelDetails();if(u&&this._streamEnded(l,u)){var f={};if(this.altAudio){f.type="video"}this.hls.trigger(Events.BUFFER_EOS,f);this.state=State.ENDED;return}if(t.loadLevel!==s&&t.manualLevel===-1){this.log("Adapting to level ".concat(s," from level ").concat(this.level))}this.level=t.nextLoadLevel=s;var c=o.details;if(!c||this.state===State.WAITING_LEVEL||c.live&&this.levelLastLoaded!==s){this.level=s;this.state=State.WAITING_LEVEL;return}var d=l.len;var h=this.getMaxBufferLength(o.maxBitrate);if(d>=h){return}if(this.backtrackFragment&&this.backtrackFragment.start>l.end){this.backtrackFragment=null}var v=this.backtrackFragment?this.backtrackFragment.start:l.end;var p=this.getNextFragment(v,c);if(this.couldBacktrack&&!this.fragPrevious&&p&&p.sn!=="initSegment"&&this.fragmentTracker.getState(p)!==FragmentState.OK){var g;var m=((g=this.backtrackFragment)!=null?g:p).sn;var y=m-c.startSN;var E=c.fragments[y-1];if(E&&p.cc===E.cc){p=E;this.fragmentTracker.removeFragment(E)}}else if(this.backtrackFragment&&l.len){this.backtrackFragment=null}if(p&&this.isLoopLoading(p,v)){var T=p.gap;if(!T){var S=this.audioOnly&&!this.altAudio?ElementaryStreamTypes.AUDIO:ElementaryStreamTypes.VIDEO;var A=(S===ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;if(A){this.afterBufferFlushed(A,S,PlaylistLevelType.MAIN)}}p=this.getNextFragmentLoopLoading(p,c,l,PlaylistLevelType.MAIN,h)}if(!p){return}if(p.initSegment&&!p.initSegment.data&&!this.bitrateTest){p=p.initSegment}this.loadFragment(p,o,v)};t.prototype.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);this.fragCurrent=t;if(a===FragmentState.NOT_LOADED||a===FragmentState.PARTIAL){if(t.sn==="initSegment"){this._loadInitSegment(t,r)}else if(this.bitrateTest){this.log("Fragment ".concat(t.sn," of level ").concat(t.level," is being downloaded to test bitrate and will not be buffered"));this._loadBitrateTestFrag(t,r)}else{this.startFragRequested=true;e.prototype.loadFragment.call(this,t,r,i)}}else{this.clearTrackerIfNeeded(t)}};t.prototype.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,PlaylistLevelType.MAIN)};t.prototype.followingBufferedFrag=function(e){if(e){return this.getBufferedFrag(e.end+.5)}return null};t.prototype.immediateLevelSwitch=function(){this.abortCurrentFrag();this.flushMainBuffer(0,Number.POSITIVE_INFINITY)};t.prototype.nextLevelSwitch=function(){var e=this,t=e.levels,r=e.media;if(r!=null&&r.readyState){var i=void 0;var a=this.getAppendedFrag(r.currentTime);if(a&&a.start>1){this.flushMainBuffer(0,a.start-1)}var n=this.getLevelDetails();if(n!=null&&n.live){var s=this.getMainFwdBufferInfo();if(!s||s.len<n.targetduration*2){return}}if(!r.paused&&t){var o=this.hls.nextLoadLevel;var l=t[o];var u=this.fragLastKbps;if(u&&this.fragCurrent){i=this.fragCurrent.duration*l.maxBitrate/(1e3*u)+1}else{i=0}}else{i=0}var f=this.getBufferedFrag(r.currentTime+i);if(f){var c=this.followingBufferedFrag(f);if(c){this.abortCurrentFrag();var d=c.maxStartPTS?c.maxStartPTS:c.start;var h=c.duration;var v=Math.max(f.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*.5),h*.75));this.flushMainBuffer(v,Number.POSITIVE_INFINITY)}}}};t.prototype.abortCurrentFrag=function(){var e=this.fragCurrent;this.fragCurrent=null;this.backtrackFragment=null;if(e){e.abortRequests();this.fragmentTracker.removeFragment(e)}switch(this.state){case State.KEY_LOADING:case State.FRAG_LOADING:case State.FRAG_LOADING_WAITING_RETRY:case State.PARSING:case State.PARSED:this.state=State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()};t.prototype.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)};t.prototype.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this);this.onvseeked=this.onMediaSeeked.bind(this);i.addEventListener("playing",this.onvplaying);i.addEventListener("seeked",this.onvseeked);this.gapController=new GapController(this.config,i,this.fragmentTracker,this.hls)};t.prototype.onMediaDetaching=function(){var t=this.media;if(t&&this.onvplaying&&this.onvseeked){t.removeEventListener("playing",this.onvplaying);t.removeEventListener("seeked",this.onvseeked);this.onvplaying=this.onvseeked=null;this.videoBuffer=null}this.fragPlaying=null;if(this.gapController){this.gapController.destroy();this.gapController=null}e.prototype.onMediaDetaching.call(this)};t.prototype.onMediaPlaying=function(){this.tick()};t.prototype.onMediaSeeked=function(){var e=this.media;var t=e?e.currentTime:null;if(isFiniteNumber(t)){this.log("Media seeked to ".concat(t.toFixed(3)))}var r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn('Main forward buffer length on "seeked" event '.concat(r?r.len:"empty",")"));return}this.tick()};t.prototype.onManifestLoading=function(){this.log("Trigger BUFFER_RESET");this.hls.trigger(Events.BUFFER_RESET,undefined);this.fragmentTracker.removeAllFragments();this.couldBacktrack=false;this.startPosition=this.lastCurrentTime=0;this.levels=this.fragPlaying=this.backtrackFragment=null;this.altAudio=this.audioOnly=false};t.prototype.onManifestParsed=function(e,t){var r=false;var i=false;var a;t.levels.forEach((function(e){a=e.audioCodec;if(a){if(a.indexOf("mp4a.40.2")!==-1){r=true}if(a.indexOf("mp4a.40.5")!==-1){i=true}}}));this.audioCodecSwitch=r&&i&&!changeTypeSupported();if(this.audioCodecSwitch){this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC")}this.levels=t.levels;this.startFragRequested=false};t.prototype.onLevelLoading=function(e,t){var r=this.levels;if(!r||this.state!==State.IDLE){return}var i=r[t.level];if(!i.details||i.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(i.details)){this.state=State.WAITING_LEVEL}};t.prototype.onLevelLoaded=function(e,t){var r;var i=this.levels;var a=t.level;var n=t.details;var s=n.totalduration;if(!i){this.warn("Levels were reset while loading level ".concat(a));return}this.log("Level ".concat(a," loaded [").concat(n.startSN,",").concat(n.endSN,"]").concat(n.lastPartSn?"[part-".concat(n.lastPartSn,"-").concat(n.lastPartIndex,"]"):"",", cc [").concat(n.startCC,", ").concat(n.endCC,"] duration:").concat(s));var o=i[a];var l=this.fragCurrent;if(l&&(this.state===State.FRAG_LOADING||this.state===State.FRAG_LOADING_WAITING_RETRY)){if((l.level!==t.level||l.urlId!==o.urlId)&&l.loader){this.abortCurrentFrag()}}var u=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);if(n.deltaUpdateFailed){return}u=this.alignPlaylists(n,o.details)}o.details=n;this.levelLastLoaded=a;this.hls.trigger(Events.LEVEL_UPDATED,{details:n,level:a});if(this.state===State.WAITING_LEVEL){if(this.waitForCdnTuneIn(n)){return}this.state=State.IDLE}if(!this.startFragRequested){this.setStartPosition(n,u)}else if(n.live){this.synchronizeToLiveEdge(n)}this.tick()};t.prototype._handleFragmentLoadProgress=function(e){var t;var r=e.frag,i=e.part,a=e.payload;var n=this.levels;if(!n){this.warn("Levels were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ").concat(r.level," will not be buffered"));return}var s=n[r.level];var o=s.details;if(!o){this.warn("Dropping fragment ".concat(r.sn," of level ").concat(r.level," after level details were reset"));this.fragmentTracker.removeFragment(r);return}var l=s.videoCodec;var u=o.PTSKnown||!o.live;var f=(t=r.initSegment)==null?void 0:t.data;var c=this._getAudioCodec(s);var d=this.transmuxer=this.transmuxer||new TransmuxerInterface(this.hls,PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this));var h=i?i.index:-1;var v=h!==-1;var p=new ChunkMetadata(r.level,r.sn,r.stats.chunkCount,a.byteLength,h,v);var g=this.initPTS[r.cc];d.push(a,f,c,l,r,i,o.totalduration,u,p,g)};t.prototype.onAudioTrackSwitching=function(e,t){var r=this.altAudio;var i=!!t.url;if(!i){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading");this.mediaBuffer=this.media;var a=this.fragCurrent;if(a){this.log("Switching to main audio track, cancel main fragment load");a.abortRequests();this.fragmentTracker.removeFragment(a)}this.resetTransmuxer();this.resetLoadingState()}else if(this.audioOnly){this.resetTransmuxer()}var n=this.hls;if(r){n.trigger(Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});this.fragmentTracker.removeAllFragments()}n.trigger(Events.AUDIO_TRACK_SWITCHED,t)}};t.prototype.onAudioTrackSwitched=function(e,t){var r=t.id;var i=!!this.hls.audioTracks[r].url;if(i){var a=this.videoBuffer;if(a&&this.mediaBuffer!==a){this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading");this.mediaBuffer=a}}this.altAudio=i;this.tick()};t.prototype.onBufferCreated=function(e,t){var r=t.tracks;var i;var a;var n=false;for(var s in r){var o=r[s];if(o.id==="main"){a=s;i=o;if(s==="video"){var l=r[s];if(l){this.videoBuffer=l.buffer}}}else{n=true}}if(n&&i){this.log("Alternate track found, use ".concat(a,".buffered to schedule main fragment loading"));this.mediaBuffer=i.buffer}else{this.mediaBuffer=this.media}};t.prototype.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(r&&r.type!==PlaylistLevelType.MAIN){return}if(this.fragContextChanged(r)){this.warn("Fragment ".concat(r.sn).concat(i?" p: "+i.index:""," of level ").concat(r.level," finished buffering, but was aborted. state: ").concat(this.state));if(this.state===State.PARSED){this.state=State.IDLE}return}var a=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first));if(r.sn!=="initSegment"){this.fragPrevious=r}this.fragBufferedComplete(r,i)};t.prototype.onError=function(e,t){var r;if(t.fatal){this.state=State.ERROR;return}switch(t.details){case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_PARSING_ERROR:case ErrorDetails.FRAG_DECRYPT_ERROR:case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(PlaylistLevelType.MAIN,t);break;case ErrorDetails.LEVEL_LOAD_ERROR:case ErrorDetails.LEVEL_LOAD_TIMEOUT:case ErrorDetails.LEVEL_PARSING_ERROR:if(!t.levelRetry&&this.state===State.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===PlaylistContextType.LEVEL){this.state=State.IDLE}break;case ErrorDetails.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main"){return}if(this.reduceLengthAndFlushBuffer(t)){this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}break;case ErrorDetails.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}};t.prototype.checkBuffer=function(){var e=this,t=e.media,r=e.gapController;if(!t||!r||!t.readyState){return}if(this.loadedmetadata||!BufferHelper.getBuffered(t).length){var i=this.state!==State.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime};t.prototype.onFragLoadEmergencyAborted=function(){this.state=State.IDLE;if(!this.loadedmetadata){this.startFragRequested=false;this.nextLoadPosition=this.startPosition}this.tickImmediate()};t.prototype.onBufferFlushed=function(e,t){var r=t.type;if(r!==ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var i=(r===ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,PlaylistLevelType.MAIN)}};t.prototype.onLevelsUpdated=function(e,t){this.levels=t.levels};t.prototype.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap};t.prototype.seekToStartPos=function(){var e=this.media;if(!e){return}var t=e.currentTime;var r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log("could not seek to ".concat(r,", already seeking at ").concat(t));return}var i=BufferHelper.getBuffered(e);var a=i.length?i.start(0):0;var n=a-r;if(n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)){this.log("adjusting start position by ".concat(n," to match buffer start"));r+=n;this.startPosition=r}this.log("seek to target start position ".concat(r," from current time ").concat(t));e.currentTime=r}};t.prototype._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;if(this.audioCodecSwap&&t){this.log("Swapping audio codec");if(t.indexOf("mp4a.40.5")!==-1){t="mp4a.40.2"}else{t="mp4a.40.5"}}return t};t.prototype._loadBitrateTestFrag=function(e,t){var r=this;e.bitrateTest=true;this._doFragLoad(e,t).then((function(i){var a=r.hls;if(!i||r.fragContextChanged(e)){return}t.fragmentError=0;r.state=State.IDLE;r.startFragRequested=false;r.bitrateTest=false;var n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now();a.trigger(Events.FRAG_LOADED,i);e.bitrateTest=false}))};t.prototype._handleTransmuxComplete=function(e){var t;var r="main";var i=this.hls;var a=e.remuxResult,n=e.chunkMeta;var s=this.getCurrentContext(n);if(!s){this.resetWhenMissingContext(n);return}var o=s.frag,l=s.part,u=s.level;var f=a.video,c=a.text,d=a.id3,h=a.initSegment;var v=u.details;var p=this.altAudio?undefined:a.audio;if(this.fragContextChanged(o)){this.fragmentTracker.removeFragment(o);return}this.state=State.PARSING;if(h){if(h!=null&&h.tracks){var g=o.initSegment||o;this._bufferInitSegment(u,h.tracks,g,n);i.trigger(Events.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:h.tracks})}var m=h.initPTS;var y=h.timescale;if(isFiniteNumber(m)){this.initPTS[o.cc]={baseTime:m,timescale:y};i.trigger(Events.INIT_PTS_FOUND,{frag:o,id:r,initPTS:m,timescale:y})}}if(f&&v&&o.sn!=="initSegment"){var E=v.fragments[o.sn-1-v.startSN];var T=o.sn===v.startSN;var S=!E||o.cc>E.cc;if(a.independent!==false){var A=f.startPTS,L=f.endPTS,b=f.startDTS,R=f.endDTS;if(l){l.elementaryStreams[f.type]={startPTS:A,endPTS:L,startDTS:b,endDTS:R}}else{if(f.firstKeyFrame&&f.independent&&n.id===1&&!S){this.couldBacktrack=true}if(f.dropped&&f.independent){var D=this.getMainFwdBufferInfo();var I=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole;var C=f.firstKeyFramePTS?f.firstKeyFramePTS:A;if(!T&&I<C-this.config.maxBufferHole&&!S){this.backtrack(o);return}else if(S){o.gap=true}o.setElementaryStreamInfo(f.type,o.start,L,o.start,R,true)}}o.setElementaryStreamInfo(f.type,A,L,b,R);if(this.backtrackFragment){this.backtrackFragment=o}this.bufferFragmentData(f,o,l,n,T||S)}else if(T||S){o.gap=true}else{this.backtrack(o);return}}if(p){var A=p.startPTS,L=p.endPTS,b=p.startDTS,R=p.endDTS;if(l){l.elementaryStreams[ElementaryStreamTypes.AUDIO]={startPTS:A,endPTS:L,startDTS:b,endDTS:R}}o.setElementaryStreamInfo(ElementaryStreamTypes.AUDIO,A,L,b,R);this.bufferFragmentData(p,o,l,n)}if(v&&d!=null&&(t=d.samples)!=null&&t.length){var _={id:r,frag:o,details:v,samples:d.samples};i.trigger(Events.FRAG_PARSING_METADATA,_)}if(v&&c){var k={id:r,frag:o,details:v,samples:c.samples};i.trigger(Events.FRAG_PARSING_USERDATA,k)}};t.prototype._bufferInitSegment=function(e,t,r,i){var a=this;if(this.state!==State.PARSING){return}this.audioOnly=!!t.audio&&!t.video;if(this.altAudio&&!this.audioOnly){delete t.audio}var n=t.audio,s=t.video,o=t.audiovideo;if(n){var l=e.audioCodec;var u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){if(l){if(l.indexOf("mp4a.40.5")!==-1){l="mp4a.40.2"}else{l="mp4a.40.5"}}if(n.metadata.channelCount!==1&&u.indexOf("firefox")===-1){l="mp4a.40.5"}}if(u.indexOf("android")!==-1&&n.container!=="audio/mpeg"){l="mp4a.40.2";this.log("Android: force audio codec to ".concat(l))}if(e.audioCodec&&e.audioCodec!==l){this.log('Swapping manifest audio codec "'.concat(e.audioCodec,'" for "').concat(l,'"'))}n.levelCodec=l;n.id="main";this.log("Init audio buffer, container:".concat(n.container,", codecs[selected/level/parsed]=[").concat(l||"","/").concat(e.audioCodec||"","/").concat(n.codec,"]"))}if(s){s.levelCodec=e.videoCodec;s.id="main";this.log("Init video buffer, container:".concat(s.container,", codecs[level/parsed]=[").concat(e.videoCodec||"","/").concat(s.codec,"]"))}if(o){this.log("Init audiovideo buffer, container:".concat(o.container,", codecs[level/parsed]=[").concat(e.attrs.CODECS||"","/").concat(o.codec,"]"))}this.hls.trigger(Events.BUFFER_CODECS,t);Object.keys(t).forEach((function(e){var n=t[e];var s=n.initSegment;if(s!=null&&s.byteLength){a.hls.trigger(Events.BUFFER_APPENDING,{type:e,data:s,frag:r,part:null,chunkMeta:i,parent:r.type})}}));this.tick()};t.prototype.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,PlaylistLevelType.MAIN)};t.prototype.backtrack=function(e){this.couldBacktrack=true;this.backtrackFragment=e;this.resetTransmuxer();this.flushBufferGap(e);this.fragmentTracker.removeFragment(e);this.fragPrevious=null;this.nextLoadPosition=e.start;this.state=State.IDLE};t.prototype.checkFragmentChanged=function(){var e=this.media;var t=null;if(e&&e.readyState>1&&e.seeking===false){var r=e.currentTime;if(BufferHelper.isBuffered(e,r)){t=this.getAppendedFrag(r)}else if(BufferHelper.isBuffered(e,r+.1)){t=this.getAppendedFrag(r+.1)}if(t){this.backtrackFragment=null;var i=this.fragPlaying;var a=t.level;if(!i||t.sn!==i.sn||i.level!==a||t.urlId!==i.urlId){this.fragPlaying=t;this.hls.trigger(Events.FRAG_CHANGED,{frag:t});if(!i||i.level!==a){this.hls.trigger(Events.LEVEL_SWITCHED,{level:a})}}}}};Object.defineProperty(t.prototype,"nextLevel",{get:function(){var e=this.nextBufferedFrag;if(e){return e.level}return-1},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"currentFrag",{get:function(){var e=this.media;if(e){return this.fragPlaying||this.getAppendedFrag(e.currentTime)}return null},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"currentProgramDateTime",{get:function(){var e=this.media;if(e){var t=e.currentTime;var r=this.currentFrag;if(r&&isFiniteNumber(t)&&isFiniteNumber(r.programDateTime)){var i=r.programDateTime+(t-r.start)*1e3;return new Date(i)}}return null},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"currentLevel",{get:function(){var e=this.currentFrag;if(e){return e.level}return-1},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"nextBufferedFrag",{get:function(){var e=this.currentFrag;if(e){return this.followingBufferedFrag(e)}return null},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"forceStartLoad",{get:function(){return this._forceStartLoad},enumerable:false,configurable:true});return t}(BaseStreamController);var EWMA=function(){function e(e,t,r){if(t===void 0){t=0}if(r===void 0){r=0}this.halfLife=void 0;this.alpha_=void 0;this.estimate_=void 0;this.totalWeight_=void 0;this.halfLife=e;this.alpha_=e?Math.exp(Math.log(.5)/e):0;this.estimate_=t;this.totalWeight_=r}e.prototype.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_;this.totalWeight_+=e};e.prototype.getTotalWeight=function(){return this.totalWeight_};e.prototype.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e){return this.estimate_/e}}return this.estimate_};return e}();var EwmaBandWidthEstimator=function(){function e(e,t,r,i){if(i===void 0){i=100}this.defaultEstimate_=void 0;this.minWeight_=void 0;this.minDelayMs_=void 0;this.slow_=void 0;this.fast_=void 0;this.defaultTTFB_=void 0;this.ttfb_=void 0;this.defaultEstimate_=r;this.minWeight_=.001;this.minDelayMs_=50;this.slow_=new EWMA(e);this.fast_=new EWMA(t);this.defaultTTFB_=i;this.ttfb_=new EWMA(e)}e.prototype.update=function(e,t){var r=this,i=r.slow_,a=r.fast_,n=r.ttfb_;if(i.halfLife!==e){this.slow_=new EWMA(e,i.getEstimate(),i.getTotalWeight())}if(a.halfLife!==t){this.fast_=new EWMA(t,a.getEstimate(),a.getTotalWeight())}if(n.halfLife!==e){this.ttfb_=new EWMA(e,n.getEstimate(),n.getTotalWeight())}};e.prototype.sample=function(e,t){e=Math.max(e,this.minDelayMs_);var r=8*t;var i=e/1e3;var a=r/i;this.fast_.sample(i,a);this.slow_.sample(i,a)};e.prototype.sampleTTFB=function(e){var t=e/1e3;var r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))};e.prototype.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_};e.prototype.getEstimate=function(){if(this.canEstimate()){return Math.min(this.fast_.getEstimate(),this.slow_.getEstimate())}else{return this.defaultEstimate_}};e.prototype.getEstimateTTFB=function(){if(this.ttfb_.getTotalWeight()>=this.minWeight_){return this.ttfb_.getEstimate()}else{return this.defaultTTFB_}};e.prototype.destroy=function(){};return e}();var AbrController=function(){function e(e){this.hls=void 0;this.lastLevelLoadSec=0;this.lastLoadedFragLevel=0;this._nextAutoLevel=-1;this.timer=-1;this.onCheck=this._abandonRulesCheck.bind(this);this.fragCurrent=null;this.partCurrent=null;this.bitrateTestDelay=0;this.bwEstimator=void 0;this.hls=e;var t=e.config;this.bwEstimator=new EwmaBandWidthEstimator(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate);this.registerListeners()}e.prototype.registerListeners=function(){var e=this.hls;e.on(Events.FRAG_LOADING,this.onFragLoading,this);e.on(Events.FRAG_LOADED,this.onFragLoaded,this);e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this);e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this);e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this)};e.prototype.unregisterListeners=function(){var e=this.hls;e.off(Events.FRAG_LOADING,this.onFragLoading,this);e.off(Events.FRAG_LOADED,this.onFragLoaded,this);e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this);e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this);e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this)};e.prototype.destroy=function(){this.unregisterListeners();this.clearTimer();this.hls=this.onCheck=null;this.fragCurrent=this.partCurrent=null};e.prototype.onFragLoading=function(e,t){var r;var i=t.frag;if(this.ignoreFragment(i)){return}this.fragCurrent=i;this.partCurrent=(r=t.part)!=null?r:null;this.clearTimer();this.timer=self.setInterval(this.onCheck,100)};e.prototype.onLevelSwitching=function(e,t){this.clearTimer()};e.prototype.getTimeToLoadFrag=function(e,t,r,i){var a=e+r/t;var n=i?this.lastLevelLoadSec:0;return a+n};e.prototype.onLevelLoaded=function(e,t){var r=this.hls.config;var i=t.stats,a=i.total,n=i.bwEstimate;if(isFiniteNumber(a)&&isFiniteNumber(n)){this.lastLevelLoadSec=8*a/n}if(t.details.live){this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive)}else{this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}};e.prototype._abandonRulesCheck=function(){var e=this,t=e.fragCurrent,r=e.partCurrent,i=e.hls;var a=i.autoLevelEnabled,n=i.media;if(!t||!n){return}var s=performance.now();var o=r?r.stats:t.stats;var l=r?r.duration:t.duration;var u=s-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||t.level===0){this.clearTimer();this._nextAutoLevel=-1;return}if(!a||n.paused||!n.playbackRate||!n.readyState){return}var f=i.mainForwardBufferInfo;if(f===null){return}var c=this.bwEstimator.getEstimateTTFB();var d=Math.abs(n.playbackRate);if(u<=Math.max(c,1e3*(l/(d*2)))){return}var h=f.len/d;if(h>=2*l/d){return}var v=o.loading.first?o.loading.first-o.loading.start:-1;var p=o.loaded&&v>-1;var g=this.bwEstimator.getEstimate();var m=i.levels,y=i.minAutoLevel;var E=m[t.level];var T=o.total||Math.max(o.loaded,Math.round(l*E.maxBitrate/8));var S=u-v;if(S<1&&p){S=Math.min(u,o.loaded*8/g)}var A=p?o.loaded*1e3/S:0;var L=A?(T-o.loaded)/A:T*8/g+c/1e3;if(L<=h){return}var b=A?A*8:g;var R=Number.POSITIVE_INFINITY;var D;for(D=t.level-1;D>y;D--){var I=m[D].maxBitrate;R=this.getTimeToLoadFrag(c/1e3,b,l*I,!m[D].details);if(R<h){break}}if(R>=L){return}if(R>l*10){return}i.nextLoadLevel=D;if(p){this.bwEstimator.sample(u-Math.min(c,v),o.loaded)}else{this.bwEstimator.sampleTTFB(u)}this.clearTimer();logger.warn("[abr] Fragment ".concat(t.sn).concat(r?" part "+r.index:""," of level ").concat(t.level," is loading too slowly;\n Time to underbuffer: ").concat(h.toFixed(3)," s\n Estimated load time for current fragment: ").concat(L.toFixed(3)," s\n Estimated load time for down switch fragment: ").concat(R.toFixed(3)," s\n TTFB estimate: ").concat(v,"\n Current BW estimate: ").concat(isFiniteNumber(g)?(g/1024).toFixed(3):"Unknown"," Kb/s\n New BW estimate: ").concat((this.bwEstimator.getEstimate()/1024).toFixed(3)," Kb/s\n Aborting and switching to level ").concat(D));if(t.loader){this.fragCurrent=this.partCurrent=null;t.abortRequests()}i.trigger(Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:o})};e.prototype.onFragLoaded=function(e,t){var r=t.frag,i=t.part;var a=i?i.stats:r.stats;if(r.type===PlaylistLevelType.MAIN){this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start)}if(this.ignoreFragment(r)){return}this.clearTimer();this.lastLoadedFragLevel=r.level;this._nextAutoLevel=-1;if(this.hls.config.abrMaxWithRealBitrate){var n=i?i.duration:r.duration;var s=this.hls.levels[r.level];var o=(s.loaded?s.loaded.bytes:0)+a.loaded;var l=(s.loaded?s.loaded.duration:0)+n;s.loaded={bytes:o,duration:l};s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(Events.FRAG_BUFFERED,u);r.bitrateTest=false}};e.prototype.onFragBuffered=function(e,t){var r=t.frag,i=t.part;var a=i!=null&&i.stats.loaded?i.stats:r.stats;if(a.aborted){return}if(this.ignoreFragment(r)){return}var n=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,a.loaded);a.bwEstimate=this.bwEstimator.getEstimate();if(r.bitrateTest){this.bitrateTestDelay=n/1e3}else{this.bitrateTestDelay=0}};e.prototype.ignoreFragment=function(e){return e.type!==PlaylistLevelType.MAIN||e.sn==="initSegment"};e.prototype.clearTimer=function(){self.clearInterval(this.timer)};Object.defineProperty(e.prototype,"nextAutoLevel",{get:function(){var e=this._nextAutoLevel;var t=this.bwEstimator;if(e!==-1&&!t.canEstimate()){return e}var r=this.getNextABRAutoLevel();if(e!==-1){var i=this.hls.levels;if(i.length>Math.max(e,r)&&i[e].loadError<=i[r].loadError){return e}}if(e!==-1){r=Math.min(e,r)}return r},set:function(e){this._nextAutoLevel=e},enumerable:false,configurable:true});e.prototype.getNextABRAutoLevel=function(){var e=this,t=e.fragCurrent,r=e.partCurrent,i=e.hls;var a=i.maxAutoLevel,n=i.config,s=i.minAutoLevel,o=i.media;var l=r?r.duration:t?t.duration:0;var u=o&&o.playbackRate!==0?Math.abs(o.playbackRate):1;var f=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate;var c=i.mainForwardBufferInfo;var d=(c?c.len:0)/u;var h=this.findBestLevel(f,s,a,d,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(h>=0){return h}logger.trace("[abr] ".concat(d?"rebuffering expected":"buffer is empty",", finding optimal quality level"));var v=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay;var p=n.abrBandWidthFactor;var g=n.abrBandWidthUpFactor;if(!d){var m=this.bitrateTestDelay;if(m){var y=l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay;v=y-m;logger.trace("[abr] bitrate test took ".concat(Math.round(1e3*m),"ms, set first fragment max fetchDuration to ").concat(Math.round(1e3*v)," ms"));p=g=1}}h=this.findBestLevel(f,s,a,d+v,p,g);return Math.max(h,0)};e.prototype.findBestLevel=function(e,t,r,i,a,n){var s;var o=this,l=o.fragCurrent,u=o.partCurrent,f=o.lastLoadedFragLevel;var c=this.hls.levels;var d=c[f];var h=!!(d!=null&&(s=d.details)!=null&&s.live);var v=d==null?void 0:d.codecSet;var p=u?u.duration:l?l.duration:0;var g=this.bwEstimator.getEstimateTTFB()/1e3;var m=t;var y=-1;for(var E=r;E>=t;E--){var T=c[E];if(!T||v&&T.codecSet!==v){if(T){m=Math.min(E,m);y=Math.max(E,y)}continue}if(y!==-1){logger.trace("[abr] Skipped level(s) ".concat(m,"-").concat(y,' with CODECS:"').concat(c[y].attrs.CODECS,'"; not compatible with "').concat(d.attrs.CODECS,'"'))}var S=T.details;var A=(u?S==null?void 0:S.partTarget:S==null?void 0:S.averagetargetduration)||p;var L=void 0;if(E<=f){L=a*e}else{L=n*e}var b=c[E].maxBitrate;var R=this.getTimeToLoadFrag(g,L,b*A,S===undefined);logger.trace("[abr] level:".concat(E," adjustedbw-bitrate:").concat(Math.round(L-b)," avgDuration:").concat(A.toFixed(1)," maxFetchDuration:").concat(i.toFixed(1)," fetchDuration:").concat(R.toFixed(1)));if(L>b&&(R===0||!isFiniteNumber(R)||h&&!this.bitrateTestDelay||R<i)){return E}}return-1};return e}();var ChunkCache=function(){function e(){this.chunks=[];this.dataLength=0}e.prototype.push=function(e){this.chunks.push(e);this.dataLength+=e.length};e.prototype.flush=function(){var e=this,t=e.chunks,r=e.dataLength;var i;if(!t.length){return new Uint8Array(0)}else if(t.length===1){i=t[0]}else{i=concatUint8Arrays(t,r)}this.reset();return i};e.prototype.reset=function(){this.chunks.length=0;this.dataLength=0};return e}();function concatUint8Arrays(e,t){var r=new Uint8Array(t);var i=0;for(var a=0;a<e.length;a++){var n=e[a];r.set(n,i);i+=n.length}return r}var TICK_INTERVAL$1=100;var AudioStreamController=function(e){__extends(t,e);function t(t,r,i){var a=e.call(this,t,r,i,"[audio-stream-controller]",PlaylistLevelType.AUDIO)||this;a.videoBuffer=null;a.videoTrackCC=-1;a.waitingVideoCC=-1;a.bufferedTrack=null;a.switchingTrack=null;a.trackId=-1;a.waitingData=null;a.mainDetails=null;a.bufferFlushed=false;a.cachedTrackLoadedData=null;a._registerListeners();return a}t.prototype.onHandlerDestroying=function(){this._unregisterListeners();this.mainDetails=null;this.bufferedTrack=null;this.switchingTrack=null};t.prototype._registerListeners=function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this);e.on(Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);e.on(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);e.on(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);e.on(Events.ERROR,this.onError,this);e.on(Events.BUFFER_RESET,this.onBufferReset,this);e.on(Events.BUFFER_CREATED,this.onBufferCreated,this);e.on(Events.BUFFER_FLUSHED,this.onBufferFlushed,this);e.on(Events.INIT_PTS_FOUND,this.onInitPtsFound,this);e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this)};t.prototype._unregisterListeners=function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this);e.off(Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);e.off(Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);e.off(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);e.off(Events.ERROR,this.onError,this);e.off(Events.BUFFER_RESET,this.onBufferReset,this);e.off(Events.BUFFER_CREATED,this.onBufferCreated,this);e.off(Events.BUFFER_FLUSHED,this.onBufferFlushed,this);e.off(Events.INIT_PTS_FOUND,this.onInitPtsFound,this);e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this)};t.prototype.onInitPtsFound=function(e,t){var r=t.frag,i=t.id,a=t.initPTS,n=t.timescale;if(i==="main"){var s=r.cc;this.initPTS[r.cc]={baseTime:a,timescale:n};this.log("InitPTS for cc: ".concat(s," found from main: ").concat(a));this.videoTrackCC=s;if(this.state===State.WAITING_INIT_PTS){this.tick()}}};t.prototype.startLoad=function(e){if(!this.levels){this.startPosition=e;this.state=State.STOPPED;return}var t=this.lastCurrentTime;this.stopLoad();this.setInterval(TICK_INTERVAL$1);if(t>0&&e===-1){this.log("Override startPosition with lastCurrentTime @".concat(t.toFixed(3)));e=t;this.state=State.IDLE}else{this.loadedmetadata=false;this.state=State.WAITING_TRACK}this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e;this.tick()};t.prototype.doTick=function(){switch(this.state){case State.IDLE:this.doTickIdle();break;case State.WAITING_TRACK:{var t;var r=this,i=r.levels,a=r.trackId;var n=i==null?void 0:(t=i[a])==null?void 0:t.details;if(n){if(this.waitForCdnTuneIn(n)){break}this.state=State.WAITING_INIT_PTS}break}case State.FRAG_LOADING_WAITING_RETRY:{var s;var o=performance.now();var l=this.retryDate;if(!l||o>=l||(s=this.media)!=null&&s.seeking){this.log("RetryDate reached, switch back to IDLE state");this.resetStartWhenNotLoaded(this.trackId);this.state=State.IDLE}break}case State.WAITING_INIT_PTS:{var u=this.waitingData;if(u){var f=u.frag,c=u.part,d=u.cache,h=u.complete;if(this.initPTS[f.cc]!==undefined){this.waitingData=null;this.waitingVideoCC=-1;this.state=State.FRAG_LOADING;var v=d.flush();var p={frag:f,part:c,payload:v,networkDetails:null};this._handleFragmentLoadProgress(p);if(h){e.prototype._handleFragmentLoadComplete.call(this,p)}}else if(this.videoTrackCC!==this.waitingVideoCC){this.log("Waiting fragment cc (".concat(f.cc,") cancelled because video is at cc ").concat(this.videoTrackCC));this.clearWaitingFragment()}else{var g=this.getLoadPosition();var m=BufferHelper.bufferInfo(this.mediaBuffer,g,this.config.maxBufferHole);var y=fragmentWithinToleranceTest(m.end,this.config.maxFragLookUpTolerance,f);if(y<0){this.log("Waiting fragment cc (".concat(f.cc,") @ ").concat(f.start," cancelled because another fragment at ").concat(m.end," is needed"));this.clearWaitingFragment()}}}else{this.state=State.IDLE}}}this.onTickEnd()};t.prototype.clearWaitingFragment=function(){var e=this.waitingData;if(e){this.fragmentTracker.removeFragment(e.frag);this.waitingData=null;this.waitingVideoCC=-1;this.state=State.IDLE}};t.prototype.resetLoadingState=function(){this.clearWaitingFragment();e.prototype.resetLoadingState.call(this)};t.prototype.onTickEnd=function(){var e=this.media;if(!(e!=null&&e.readyState)){return}this.lastCurrentTime=e.currentTime};t.prototype.doTickIdle=function(){var e=this,t=e.hls,r=e.levels,i=e.media,a=e.trackId;var n=t.config;if(!(r!=null&&r[a])){return}if(!i&&(this.startFragRequested||!n.startFragPrefetch)){return}var s=r[a];var o=s.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=State.WAITING_TRACK;return}var l=this.mediaBuffer?this.mediaBuffer:this.media;if(this.bufferFlushed&&l){this.bufferFlushed=false;this.afterBufferFlushed(l,ElementaryStreamTypes.AUDIO,PlaylistLevelType.AUDIO)}var u=this.getFwdBufferInfo(l,PlaylistLevelType.AUDIO);if(u===null){return}var f=this,c=f.bufferedTrack,d=f.switchingTrack;if(!d&&this._streamEnded(u,o)){t.trigger(Events.BUFFER_EOS,{type:"audio"});this.state=State.ENDED;return}var h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,PlaylistLevelType.MAIN);var v=u.len;var p=this.getMaxBufferLength(h==null?void 0:h.len);if(v>=p&&!d){return}var g=o.fragments;var m=g[0].start;var y=u.end;if(d&&i){var E=this.getLoadPosition();if(c&&d.attrs!==c.attrs){y=E}if(o.PTSKnown&&E<m){if(u.end>m||u.nextStart){this.log("Alt audio track ahead of main track, seek to start of alt audio track");i.currentTime=m+.05}}}var T=this.getNextFragment(y,o);var S=false;if(T&&this.isLoopLoading(T,y)){S=!!T.gap;T=this.getNextFragmentLoopLoading(T,o,u,PlaylistLevelType.MAIN,p)}if(!T){this.bufferFlushed=true;return}var A=h&&T.start>h.end+o.targetduration;if(A||!(h!=null&&h.len)&&u.len){var L=this.getAppendedFrag(T.start,PlaylistLevelType.MAIN);if(L===null){return}S||(S=!!L.gap||!!A&&h.len===0);if(A&&!S||S&&u.nextStart&&u.nextStart<L.end){return}}this.loadFragment(T,s,y)};t.prototype.getMaxBufferLength=function(t){var r=e.prototype.getMaxBufferLength.call(this);if(!t){return r}return Math.min(Math.max(r,t),this.config.maxMaxBufferLength)};t.prototype.onMediaDetaching=function(){this.videoBuffer=null;e.prototype.onMediaDetaching.call(this)};t.prototype.onAudioTracksUpdated=function(e,t){var r=t.audioTracks;this.resetTransmuxer();this.levels=r.map((function(e){return new Level(e)}))};t.prototype.onAudioTrackSwitching=function(e,t){var r=!!t.url;this.trackId=t.id;var i=this.fragCurrent;if(i){i.abortRequests();this.removeUnbufferedFrags(i.start)}this.resetLoadingState();if(!r){this.resetTransmuxer()}else{this.setInterval(TICK_INTERVAL$1)}if(r){this.switchingTrack=t;this.state=State.IDLE}else{this.switchingTrack=null;this.bufferedTrack=t;this.state=State.STOPPED}this.tick()};t.prototype.onManifestLoading=function(){this.fragmentTracker.removeAllFragments();this.startPosition=this.lastCurrentTime=0;this.bufferFlushed=false;this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null;this.startFragRequested=false;this.trackId=this.videoTrackCC=this.waitingVideoCC=-1};t.prototype.onLevelLoaded=function(e,t){this.mainDetails=t.details;if(this.cachedTrackLoadedData!==null){this.hls.trigger(Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData);this.cachedTrackLoadedData=null}};t.prototype.onAudioTrackLoaded=function(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}var i=this.levels;var a=t.details,n=t.id;if(!i){this.warn("Audio tracks were reset while loading level ".concat(n));return}this.log("Track ".concat(n," loaded [").concat(a.startSN,",").concat(a.endSN,"]").concat(a.lastPartSn?"[part-".concat(a.lastPartSn,"-").concat(a.lastPartIndex,"]"):"",",duration:").concat(a.totalduration));var s=i[n];var o=0;if(a.live||(r=s.details)!=null&&r.live){this.checkLiveUpdate(a);var l=this.mainDetails;if(a.deltaUpdateFailed||!l){return}if(!s.details&&a.hasProgramDateTime&&l.hasProgramDateTime){alignMediaPlaylistByPDT(a,l);o=a.fragments[0].start}else{o=this.alignPlaylists(a,s.details)}}s.details=a;this.levelLastLoaded=n;if(!this.startFragRequested&&(this.mainDetails||!a.live)){this.setStartPosition(s.details,o)}if(this.state===State.WAITING_TRACK&&!this.waitForCdnTuneIn(a)){this.state=State.IDLE}this.tick()};t.prototype._handleFragmentLoadProgress=function(e){var t;var r=e.frag,i=e.part,a=e.payload;var n=this,s=n.config,o=n.trackId,l=n.levels;if(!l){this.warn("Audio tracks were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ").concat(r.level," will not be buffered"));return}var u=l[o];if(!u){this.warn("Audio track is undefined on fragment load progress");return}var f=u.details;if(!f){this.warn("Audio track details undefined on fragment load progress");this.removeUnbufferedFrags(r.start);return}var c=s.defaultAudioCodec||u.audioCodec||"mp4a.40.2";var d=this.transmuxer;if(!d){d=this.transmuxer=new TransmuxerInterface(this.hls,PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))}var h=this.initPTS[r.cc];var v=(t=r.initSegment)==null?void 0:t.data;if(h!==undefined){var p=false;var g=i?i.index:-1;var m=g!==-1;var y=new ChunkMetadata(r.level,r.sn,r.stats.chunkCount,a.byteLength,g,m);d.push(a,v,c,"",r,i,f.totalduration,p,y,h)}else{this.log("Unknown video PTS for cc ".concat(r.cc,", waiting for video PTS before demuxing audio frag ").concat(r.sn," of [").concat(f.startSN," ,").concat(f.endSN,"],track ").concat(o));var E=(this.waitingData=this.waitingData||{frag:r,part:i,cache:new ChunkCache,complete:false}).cache;E.push(new Uint8Array(a));this.waitingVideoCC=this.videoTrackCC;this.state=State.WAITING_INIT_PTS}};t.prototype._handleFragmentLoadComplete=function(t){if(this.waitingData){this.waitingData.complete=true;return}e.prototype._handleFragmentLoadComplete.call(this,t)};t.prototype.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null;this.loadedmetadata=false};t.prototype.onBufferCreated=function(e,t){var r=t.tracks.audio;if(r){this.mediaBuffer=r.buffer||null}if(t.tracks.video){this.videoBuffer=t.tracks.video.buffer||null}};t.prototype.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(r.type!==PlaylistLevelType.AUDIO){if(!this.loadedmetadata&&r.type===PlaylistLevelType.MAIN){var a=this.videoBuffer||this.media;if(a){var n=BufferHelper.getBuffered(a);if(n.length){this.loadedmetadata=true}}}return}if(this.fragContextChanged(r)){this.warn("Fragment ".concat(r.sn).concat(i?" p: "+i.index:""," of level ").concat(r.level," finished buffering, but was aborted. state: ").concat(this.state,", audioSwitch: ").concat(this.switchingTrack?this.switchingTrack.name:"false"));return}if(r.sn!=="initSegment"){this.fragPrevious=r;var s=this.switchingTrack;if(s){this.bufferedTrack=s;this.switchingTrack=null;this.hls.trigger(Events.AUDIO_TRACK_SWITCHED,_objectSpread2({},s))}}this.fragBufferedComplete(r,i)};t.prototype.onError=function(t,r){var i;if(r.fatal){this.state=State.ERROR;return}switch(r.details){case ErrorDetails.FRAG_GAP:case ErrorDetails.FRAG_PARSING_ERROR:case ErrorDetails.FRAG_DECRYPT_ERROR:case ErrorDetails.FRAG_LOAD_ERROR:case ErrorDetails.FRAG_LOAD_TIMEOUT:case ErrorDetails.KEY_LOAD_ERROR:case ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(PlaylistLevelType.AUDIO,r);break;case ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case ErrorDetails.LEVEL_PARSING_ERROR:if(!r.levelRetry&&this.state===State.WAITING_TRACK&&((i=r.context)==null?void 0:i.type)===PlaylistContextType.AUDIO_TRACK){this.state=State.IDLE}break;case ErrorDetails.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="audio"){return}if(this.reduceLengthAndFlushBuffer(r)){this.bufferedTrack=null;e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")}break;case ErrorDetails.INTERNAL_EXCEPTION:this.recoverWorkerError(r);break}};t.prototype.onBufferFlushed=function(e,t){var r=t.type;if(r===ElementaryStreamTypes.AUDIO){this.bufferFlushed=true;if(this.state===State.ENDED){this.state=State.IDLE}}};t.prototype._handleTransmuxComplete=function(e){var t;var r="audio";var i=this.hls;var a=e.remuxResult,n=e.chunkMeta;var s=this.getCurrentContext(n);if(!s){this.resetWhenMissingContext(n);return}var o=s.frag,l=s.part,u=s.level;var f=u.details;var c=a.audio,d=a.text,h=a.id3,v=a.initSegment;if(this.fragContextChanged(o)||!f){this.fragmentTracker.removeFragment(o);return}this.state=State.PARSING;if(this.switchingTrack&&c){this.completeAudioSwitch(this.switchingTrack)}if(v!=null&&v.tracks){var p=o.initSegment||o;this._bufferInitSegment(v.tracks,p,n);i.trigger(Events.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:r,tracks:v.tracks})}if(c){var g=c.startPTS,m=c.endPTS,y=c.startDTS,E=c.endDTS;if(l){l.elementaryStreams[ElementaryStreamTypes.AUDIO]={startPTS:g,endPTS:m,startDTS:y,endDTS:E}}o.setElementaryStreamInfo(ElementaryStreamTypes.AUDIO,g,m,y,E);this.bufferFragmentData(c,o,l,n)}if(h!=null&&(t=h.samples)!=null&&t.length){var T=_extends({id:r,frag:o,details:f},h);i.trigger(Events.FRAG_PARSING_METADATA,T)}if(d){var S=_extends({id:r,frag:o,details:f},d);i.trigger(Events.FRAG_PARSING_USERDATA,S)}};t.prototype._bufferInitSegment=function(e,t,r){if(this.state!==State.PARSING){return}if(e.video){delete e.video}var i=e.audio;if(!i){return}i.levelCodec=i.codec;i.id="audio";this.log("Init audio buffer, container:".concat(i.container,", codecs[parsed]=[").concat(i.codec,"]"));this.hls.trigger(Events.BUFFER_CODECS,e);var a=i.initSegment;if(a!=null&&a.byteLength){var n={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:a};this.hls.trigger(Events.BUFFER_APPENDING,n)}this.tick()};t.prototype.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);this.fragCurrent=t;if(this.switchingTrack||a===FragmentState.NOT_LOADED||a===FragmentState.PARTIAL){var n;if(t.sn==="initSegment"){this._loadInitSegment(t,r)}else if((n=r.details)!=null&&n.live&&!this.initPTS[t.cc]){this.log("Waiting for video PTS in continuity counter ".concat(t.cc," of live stream before loading audio fragment ").concat(t.sn," of level ").concat(this.trackId));this.state=State.WAITING_INIT_PTS}else{this.startFragRequested=true;e.prototype.loadFragment.call(this,t,r,i)}}else{this.clearTrackerIfNeeded(t)}};t.prototype.completeAudioSwitch=function(t){var r=this,i=r.hls,a=r.media,n=r.bufferedTrack;var s=n==null?void 0:n.attrs;var o=t.attrs;if(a&&s&&(s.CHANNELS!==o.CHANNELS||s.NAME!==o.NAME||s.LANGUAGE!==o.LANGUAGE)){this.log("Switching audio track : flushing all audio");e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")}this.bufferedTrack=t;this.switchingTrack=null;i.trigger(Events.AUDIO_TRACK_SWITCHED,_objectSpread2({},t))};return t}(BaseStreamController);var AudioTrackController=function(e){__extends(t,e);function t(t){var r=e.call(this,t,"[audio-track-controller]")||this;r.tracks=[];r.groupId=null;r.tracksInGroup=[];r.trackId=-1;r.currentTrack=null;r.selectDefaultTrack=true;r.registerListeners();return r}t.prototype.registerListeners=function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.on(Events.LEVEL_LOADING,this.onLevelLoading,this);e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this);e.on(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);e.on(Events.ERROR,this.onError,this)};t.prototype.unregisterListeners=function(){var e=this.hls;e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.off(Events.LEVEL_LOADING,this.onLevelLoading,this);e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this);e.off(Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);e.off(Events.ERROR,this.onError,this)};t.prototype.destroy=function(){this.unregisterListeners();this.tracks.length=0;this.tracksInGroup.length=0;this.currentTrack=null;e.prototype.destroy.call(this)};t.prototype.onManifestLoading=function(){this.tracks=[];this.groupId=null;this.tracksInGroup=[];this.trackId=-1;this.currentTrack=null;this.selectDefaultTrack=true};t.prototype.onManifestParsed=function(e,t){this.tracks=t.audioTracks||[]};t.prototype.onAudioTrackLoaded=function(e,t){var r=t.id,i=t.groupId,a=t.details;var n=this.tracksInGroup[r];if(!n||n.groupId!==i){this.warn("Track with id:".concat(r," and group:").concat(i," not found in active group ").concat(n.groupId));return}var s=n.details;n.details=t.details;this.log("audio-track ".concat(r,' "').concat(n.name,'" lang:').concat(n.lang," group:").concat(i," loaded [").concat(a.startSN,"-").concat(a.endSN,"]"));if(r===this.trackId){this.playlistLoaded(r,t,s)}};t.prototype.onLevelLoading=function(e,t){this.switchLevel(t.level)};t.prototype.onLevelSwitching=function(e,t){this.switchLevel(t.level)};t.prototype.switchLevel=function(e){var t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds)){return}var r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;var i=this.tracks.filter((function(e){return!r||e.groupId===r}));if(this.selectDefaultTrack&&!i.some((function(e){return e.default}))){this.selectDefaultTrack=false}this.tracksInGroup=i;var a={audioTracks:i};this.log("Updating audio tracks, ".concat(i.length," track(s) found in group:").concat(r));this.hls.trigger(Events.AUDIO_TRACKS_UPDATED,a);this.selectInitialTrack()}else if(this.shouldReloadPlaylist(this.currentTrack)){this.setAudioTrack(this.trackId)}};t.prototype.onError=function(e,t){if(t.fatal||!t.context){return}if(t.context.type===PlaylistContextType.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId){this.requestScheduled=-1;this.checkRetry(t)}};Object.defineProperty(t.prototype,"audioTracks",{get:function(){return this.tracksInGroup},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"audioTrack",{get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=false;this.setAudioTrack(e)},enumerable:false,configurable:true});t.prototype.setAudioTrack=function(e){var t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var r=this.currentTrack;var i=t[e];var a=i.groupId,n=i.name;this.log("Switching to audio-track ".concat(e,' "').concat(n,'" lang:').concat(i.lang," group:").concat(a));this.trackId=e;this.currentTrack=i;this.selectDefaultTrack=false;this.hls.trigger(Events.AUDIO_TRACK_SWITCHING,_objectSpread2({},i));if(i.details&&!i.details.live){return}var s=this.switchParams(i.url,r==null?void 0:r.details);this.loadPlaylist(s)};t.prototype.selectInitialTrack=function(){var e=this.tracksInGroup;var t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1){this.setAudioTrack(t)}else{var r=new Error("No track found for running audio group-ID: ".concat(this.groupId," track count: ").concat(e.length));this.warn(r.message);this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:true,error:r})}};t.prototype.findTrackId=function(e){var t=this.tracksInGroup;for(var r=0;r<t.length;r++){var i=t[r];if(!this.selectDefaultTrack||i.default){if(!e||e.attrs["STABLE-RENDITION-ID"]!==undefined&&e.attrs["STABLE-RENDITION-ID"]===i.attrs["STABLE-RENDITION-ID"]){return i.id}if(e.name===i.name&&e.lang===i.lang){return i.id}}}return-1};t.prototype.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id;var a=r.groupId;var n=r.url;if(t){try{n=t.addDirectives(n)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(e))}}this.log("loading audio-track playlist ".concat(i,' "').concat(r.name,'" lang:').concat(r.lang," group:").concat(a));this.clearTimer();this.hls.trigger(Events.AUDIO_TRACK_LOADING,{url:n,id:i,groupId:a,deliveryDirectives:t||null})}};return t}(BasePlaylistController);function subtitleOptionsIdentical(e,t){if(e.length!==t.length){return false}for(var r=0;r<e.length;r++){if(!subtitleAttributesIdentical(e[r].attrs,t[r].attrs)){return false}}return true}function subtitleAttributesIdentical(e,t){var r=e["STABLE-RENDITION-ID"];if(r){return r===t["STABLE-RENDITION-ID"]}return!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some((function(r){return e[r]!==t[r]}))}var TICK_INTERVAL=500;var SubtitleStreamController=function(e){__extends(t,e);function t(t,r,i){var a=e.call(this,t,r,i,"[subtitle-stream-controller]",PlaylistLevelType.SUBTITLE)||this;a.levels=[];a.currentTrackId=-1;a.tracksBuffered=[];a.mainDetails=null;a._registerListeners();return a}t.prototype.onHandlerDestroying=function(){this._unregisterListeners();this.mainDetails=null};t.prototype._registerListeners=function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.LEVEL_LOADED,this.onLevelLoaded,this);e.on(Events.ERROR,this.onError,this);e.on(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);e.on(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this);e.on(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);e.on(Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this);e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this);e.on(Events.FRAG_BUFFERED,this.onFragBuffered,this)};t.prototype._unregisterListeners=function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.LEVEL_LOADED,this.onLevelLoaded,this);e.off(Events.ERROR,this.onError,this);e.off(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);e.off(Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this);e.off(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);e.off(Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this);e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this);e.off(Events.FRAG_BUFFERED,this.onFragBuffered,this)};t.prototype.startLoad=function(e){this.stopLoad();this.state=State.IDLE;this.setInterval(TICK_INTERVAL);this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e;this.tick()};t.prototype.onManifestLoading=function(){this.mainDetails=null;this.fragmentTracker.removeAllFragments()};t.prototype.onMediaDetaching=function(){this.tracksBuffered=[];e.prototype.onMediaDetaching.call(this)};t.prototype.onLevelLoaded=function(e,t){this.mainDetails=t.details};t.prototype.onSubtitleFragProcessed=function(e,t){var r=t.frag,i=t.success;this.fragPrevious=r;this.state=State.IDLE;if(!i){return}var a=this.tracksBuffered[this.currentTrackId];if(!a){return}var n;var s=r.start;for(var o=0;o<a.length;o++){if(s>=a[o].start&&s<=a[o].end){n=a[o];break}}var l=r.start+r.duration;if(n){n.end=l}else{n={start:s,end:l};a.push(n)}this.fragmentTracker.fragBuffered(r)};t.prototype.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset;if(r===0&&i!==Number.POSITIVE_INFINITY){var a=i-1;if(a<=0){return}t.endOffsetSubtitles=Math.max(0,a);this.tracksBuffered.forEach((function(e){for(var t=0;t<e.length;){if(e[t].end<=a){e.shift();continue}else if(e[t].start<a){e[t].start=a}else{break}t++}}));this.fragmentTracker.removeFragmentsInRange(r,a,PlaylistLevelType.SUBTITLE)}};t.prototype.onFragBuffered=function(e,t){if(!this.loadedmetadata&&t.frag.type===PlaylistLevelType.MAIN){var r;if((r=this.media)!=null&&r.buffered.length){this.loadedmetadata=true}}};t.prototype.onError=function(e,t){var r=t.frag;if((r==null?void 0:r.type)===PlaylistLevelType.SUBTITLE){if(this.fragCurrent){this.fragCurrent.abortRequests()}if(this.state!==State.STOPPED){this.state=State.IDLE}}};t.prototype.onSubtitleTracksUpdated=function(e,t){var r=this;var i=t.subtitleTracks;if(subtitleOptionsIdentical(this.levels,i)){this.levels=i.map((function(e){return new Level(e)}));return}this.tracksBuffered=[];this.levels=i.map((function(e){var t=new Level(e);r.tracksBuffered[t.id]=[];return t}));this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,PlaylistLevelType.SUBTITLE);this.fragPrevious=null;this.mediaBuffer=null};t.prototype.onSubtitleTrackSwitch=function(e,t){this.currentTrackId=t.id;if(!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var r=this.levels[this.currentTrackId];if(r!=null&&r.details){this.mediaBuffer=this.mediaBufferTimeRanges}else{this.mediaBuffer=null}if(r){this.setInterval(TICK_INTERVAL)}};t.prototype.onSubtitleTrackLoaded=function(e,t){var r;var i=t.details,a=t.id;var n=this,s=n.currentTrackId,o=n.levels;if(!o.length){return}var l=o[s];if(a>=o.length||a!==s||!l){return}this.mediaBuffer=this.mediaBufferTimeRanges;var u=0;if(i.live||(r=l.details)!=null&&r.live){var f=this.mainDetails;if(i.deltaUpdateFailed||!f){return}var c=f.fragments[0];if(!l.details){if(i.hasProgramDateTime&&f.hasProgramDateTime){alignMediaPlaylistByPDT(i,f);u=i.fragments[0].start}else if(c){u=c.start;addSliding(i,u)}}else{u=this.alignPlaylists(i,l.details);if(u===0&&c){u=c.start;addSliding(i,u)}}}l.details=i;this.levelLastLoaded=a;if(!this.startFragRequested&&(this.mainDetails||!i.live)){this.setStartPosition(l.details,u)}this.tick();if(i.live&&!this.fragCurrent&&this.media&&this.state===State.IDLE){var d=findFragmentByPTS(null,i.fragments,this.media.currentTime,0);if(!d){this.warn("Subtitle playlist not aligned with playback");l.details=undefined}}};t.prototype._handleFragmentLoadComplete=function(e){var t=this;var r=e.frag,i=e.payload;var a=r.decryptdata;var n=this.hls;if(this.fragContextChanged(r)){return}if(i&&i.byteLength>0&&a&&a.key&&a.iv&&a.method==="AES-128"){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),a.key.buffer,a.iv.buffer).catch((function(e){n.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.FRAG_DECRYPT_ERROR,fatal:false,error:e,reason:e.message,frag:r});throw e})).then((function(e){var t=performance.now();n.trigger(Events.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){t.warn("".concat(e.name,": ").concat(e.message));t.state=State.IDLE}))}};t.prototype.doTick=function(){if(!this.media){this.state=State.IDLE;return}if(this.state===State.IDLE){var e=this,t=e.currentTrackId,r=e.levels;var i=r[t];if(!r.length||!i||!i.details){return}var a=this.config;var n=this.getLoadPosition();var s=BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,a.maxBufferHole);var o=s.end,l=s.len;var u=this.getFwdBufferInfo(this.media,PlaylistLevelType.MAIN);var f=i.details;var c=this.getMaxBufferLength(u==null?void 0:u.len)+f.levelTargetDuration;if(l>c){return}var d=f.fragments;var h=d.length;var v=f.edge;var p=null;var g=this.fragPrevious;if(o<v){var m=a.maxFragLookUpTolerance;var y=o>v-m?0:m;p=findFragmentByPTS(g,d,Math.max(d[0].start,o),y);if(!p&&g&&g.start<d[0].start){p=d[0]}}else{p=d[h-1]}if(!p){return}p=this.mapToInitFragWhenRequired(p);if(p.sn!=="initSegment"){var E=p.sn-f.startSN;var T=d[E-1];if(T&&T.cc===p.cc&&this.fragmentTracker.getState(T)===FragmentState.NOT_LOADED){p=T}}if(this.fragmentTracker.getState(p)===FragmentState.NOT_LOADED){this.loadFragment(p,i,o)}}};t.prototype.getMaxBufferLength=function(t){var r=e.prototype.getMaxBufferLength.call(this);if(!t){return r}return Math.max(r,t)};t.prototype.loadFragment=function(t,r,i){this.fragCurrent=t;if(t.sn==="initSegment"){this._loadInitSegment(t,r)}else{this.startFragRequested=true;e.prototype.loadFragment.call(this,t,r,i)}};Object.defineProperty(t.prototype,"mediaBufferTimeRanges",{get:function(){return new BufferableInstance(this.tracksBuffered[this.currentTrackId]||[])},enumerable:false,configurable:true});return t}(BaseStreamController);var BufferableInstance=function(){function e(e){this.buffered=void 0;var t=function(t,r,i){r=r>>>0;if(r>i-1){throw new DOMException("Failed to execute '".concat(t,"' on 'TimeRanges': The index provided (").concat(r,") is greater than the maximum bound (").concat(i,")"))}return e[r][t]};this.buffered={get length(){return e.length},end:function(r){return t("end",r,e.length)},start:function(r){return t("start",r,e.length)}}}return e}();var SubtitleTrackController=function(e){__extends(t,e);function t(t){var r=e.call(this,t,"[subtitle-track-controller]")||this;r.media=null;r.tracks=[];r.groupId=null;r.tracksInGroup=[];r.trackId=-1;r.selectDefaultTrack=true;r.queuedDefaultTrack=-1;r.trackChangeListener=function(){return r.onTextTracksChanged()};r.asyncPollTrackChange=function(){return r.pollTrackChange(0)};r.useTextTrackPolling=false;r.subtitlePollingInterval=-1;r._subtitleDisplay=true;r.registerListeners();return r}t.prototype.destroy=function(){this.unregisterListeners();this.tracks.length=0;this.tracksInGroup.length=0;this.trackChangeListener=this.asyncPollTrackChange=null;e.prototype.destroy.call(this)};Object.defineProperty(t.prototype,"subtitleDisplay",{get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e;if(this.trackId>-1){this.toggleTrackModes(this.trackId)}},enumerable:false,configurable:true});t.prototype.registerListeners=function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.on(Events.LEVEL_LOADING,this.onLevelLoading,this);e.on(Events.LEVEL_SWITCHING,this.onLevelSwitching,this);e.on(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);e.on(Events.ERROR,this.onError,this)};t.prototype.unregisterListeners=function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.off(Events.LEVEL_LOADING,this.onLevelLoading,this);e.off(Events.LEVEL_SWITCHING,this.onLevelSwitching,this);e.off(Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);e.off(Events.ERROR,this.onError,this)};t.prototype.onMediaAttached=function(e,t){this.media=t.media;if(!this.media){return}if(this.queuedDefaultTrack>-1){this.subtitleTrack=this.queuedDefaultTrack;this.queuedDefaultTrack=-1}this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks);if(this.useTextTrackPolling){this.pollTrackChange(500)}else{this.media.textTracks.addEventListener("change",this.asyncPollTrackChange)}};t.prototype.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval);this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)};t.prototype.onMediaDetaching=function(){if(!this.media){return}self.clearInterval(this.subtitlePollingInterval);if(!this.useTextTrackPolling){this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange)}if(this.trackId>-1){this.queuedDefaultTrack=this.trackId}var e=filterSubtitleTracks(this.media.textTracks);e.forEach((function(e){clearCurrentCues(e)}));this.subtitleTrack=-1;this.media=null};t.prototype.onManifestLoading=function(){this.tracks=[];this.groupId=null;this.tracksInGroup=[];this.trackId=-1;this.selectDefaultTrack=true};t.prototype.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks};t.prototype.onSubtitleTrackLoaded=function(e,t){var r=t.id,i=t.details;var a=this.trackId;var n=this.tracksInGroup[a];if(!n){this.warn("Invalid subtitle track id ".concat(r));return}var s=n.details;n.details=t.details;this.log("subtitle track ".concat(r," loaded [").concat(i.startSN,"-").concat(i.endSN,"]"));if(r===this.trackId){this.playlistLoaded(r,t,s)}};t.prototype.onLevelLoading=function(e,t){this.switchLevel(t.level)};t.prototype.onLevelSwitching=function(e,t){this.switchLevel(t.level)};t.prototype.switchLevel=function(e){var t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds)){return}var r=t.textGroupIds[t.urlId];var i=this.tracksInGroup?this.tracksInGroup[this.trackId]:undefined;if(this.groupId!==r){var a=this.tracks.filter((function(e){return!r||e.groupId===r}));this.tracksInGroup=a;var n=this.findTrackId(i==null?void 0:i.name)||this.findTrackId();this.groupId=r||null;var s={subtitleTracks:a};this.log("Updating subtitle tracks, ".concat(a.length,' track(s) found in "').concat(r,'" group-id'));this.hls.trigger(Events.SUBTITLE_TRACKS_UPDATED,s);if(n!==-1){this.setSubtitleTrack(n,i)}}else if(this.shouldReloadPlaylist(i)){this.setSubtitleTrack(this.trackId,i)}};t.prototype.findTrackId=function(e){var t=this.tracksInGroup;for(var r=0;r<t.length;r++){var i=t[r];if(!this.selectDefaultTrack||i.default){if(!e||e===i.name){return i.id}}}return-1};t.prototype.onError=function(e,t){if(t.fatal||!t.context){return}if(t.context.type===PlaylistContextType.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId){this.checkRetry(t)}};Object.defineProperty(t.prototype,"subtitleTracks",{get:function(){return this.tracksInGroup},enumerable:false,configurable:true});Object.defineProperty(t.prototype,"subtitleTrack",{get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=false;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:undefined;this.setSubtitleTrack(e,t)},enumerable:false,configurable:true});t.prototype.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id;var a=r.groupId;var n=r.url;if(t){try{n=t.addDirectives(n)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(e))}}this.log("Loading subtitle playlist for id ".concat(i));this.hls.trigger(Events.SUBTITLE_TRACK_LOADING,{url:n,id:i,groupId:a,deliveryDirectives:t||null})}};t.prototype.toggleTrackModes=function(e){var t=this;var r=this,i=r.media,a=r.trackId;if(!i){return}var n=filterSubtitleTracks(i.textTracks);var s=n.filter((function(e){return e.groupId===t.groupId}));if(e===-1){[].slice.call(n).forEach((function(e){e.mode="disabled"}))}else{var o=s[a];if(o){o.mode="disabled"}}var l=s[e];if(l){l.mode=this.subtitleDisplay?"showing":"hidden"}};t.prototype.setSubtitleTrack=function(e,t){var r;var i=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e){this.toggleTrackModes(e)}if(this.trackId===e&&(e===-1||(r=i[e])!=null&&r.details)||e<-1||e>=i.length){return}this.clearTimer();var a=i[e];this.log("Switching to subtitle-track ".concat(e)+(a?' "'.concat(a.name,'" lang:').concat(a.lang," group:").concat(a.groupId):""));this.trackId=e;if(a){var n=a.id,s=a.groupId,o=s===void 0?"":s,l=a.name,u=a.type,f=a.url;this.hls.trigger(Events.SUBTITLE_TRACK_SWITCH,{id:n,groupId:o,name:l,type:u,url:f});var c=this.switchParams(a.url,t==null?void 0:t.details);this.loadPlaylist(c)}else{this.hls.trigger(Events.SUBTITLE_TRACK_SWITCH,{id:e})}};t.prototype.onTextTracksChanged=function(){if(!this.useTextTrackPolling){self.clearInterval(this.subtitlePollingInterval)}if(!this.media||!this.hls.config.renderTextTracksNatively){return}var e=-1;var t=filterSubtitleTracks(this.media.textTracks);for(var r=0;r<t.length;r++){if(t[r].mode==="hidden"){e=r}else if(t[r].mode==="showing"){e=r;break}}if(this.subtitleTrack!==e){this.subtitleTrack=e}};return t}(BasePlaylistController);function filterSubtitleTracks(e){var t=[];for(var r=0;r<e.length;r++){var i=e[r];if((i.kind==="subtitles"||i.kind==="captions")&&i.label){t.push(e[r])}}return t}var BufferOperationQueue=function(){function e(e){this.buffers=void 0;this.queues={video:[],audio:[],audiovideo:[]};this.buffers=e}e.prototype.append=function(e,t){var r=this.queues[t];r.push(e);if(r.length===1&&this.buffers[t]){this.executeNext(t)}};e.prototype.insertAbort=function(e,t){var r=this.queues[t];r.unshift(e);this.executeNext(t)};e.prototype.appendBlocker=function(e){var t;var r=new Promise((function(e){t=e}));var i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};this.append(i,e);return r};e.prototype.executeNext=function(e){var t=this,r=t.buffers,i=t.queues;var a=r[e];var n=i[e];if(n.length){var s=n[0];try{s.execute()}catch(t){logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation");s.onError(t);if(!(a!=null&&a.updating)){n.shift();this.executeNext(e)}}}};e.prototype.shiftAndExecuteNext=function(e){this.queues[e].shift();this.executeNext(e)};e.prototype.current=function(e){return this.queues[e][0]};return e}();var MediaSource=getMediaSource();var VIDEO_CODEC_PROFILE_REPACE=/([ha]vc.)(?:\.[^.,]+)+/;var BufferController=function(){function e(e){var t=this;this.details=null;this._objectUrl=null;this.operationQueue=void 0;this.listeners=void 0;this.hls=void 0;this.bufferCodecEventsExpected=0;this._bufferCodecEventsTotal=0;this.media=null;this.mediaSource=null;this.lastMpegAudioChunk=null;this.appendError=0;this.tracks={};this.pendingTracks={};this.sourceBuffer=void 0;this._onMediaSourceOpen=function(){var e=t,r=e.media,i=e.mediaSource;logger.log("[buffer-controller]: Media source opened");if(r){r.removeEventListener("emptied",t._onMediaEmptied);t.updateMediaElementDuration();t.hls.trigger(Events.MEDIA_ATTACHED,{media:r})}if(i){i.removeEventListener("sourceopen",t._onMediaSourceOpen)}t.checkPendingTracks()};this._onMediaSourceClose=function(){logger.log("[buffer-controller]: Media source closed")};this._onMediaSourceEnded=function(){logger.log("[buffer-controller]: Media source ended")};this._onMediaEmptied=function(){var e=t,r=e.media,i=e._objectUrl;if(r&&r.src!==i){logger.error("Media element src was set while attaching MediaSource (".concat(i," > ").concat(r.src,")"))}};this.hls=e;this._initSourceBuffer();this.registerListeners()}e.prototype.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0};e.prototype.destroy=function(){this.unregisterListeners();this.details=null;this.lastMpegAudioChunk=null};e.prototype.registerListeners=function(){var e=this.hls;e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this);e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.on(Events.BUFFER_RESET,this.onBufferReset,this);e.on(Events.BUFFER_APPENDING,this.onBufferAppending,this);e.on(Events.BUFFER_CODECS,this.onBufferCodecs,this);e.on(Events.BUFFER_EOS,this.onBufferEos,this);e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this);e.on(Events.LEVEL_UPDATED,this.onLevelUpdated,this);e.on(Events.FRAG_PARSED,this.onFragParsed,this);e.on(Events.FRAG_CHANGED,this.onFragChanged,this)};e.prototype.unregisterListeners=function(){var e=this.hls;e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this);e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.off(Events.BUFFER_RESET,this.onBufferReset,this);e.off(Events.BUFFER_APPENDING,this.onBufferAppending,this);e.off(Events.BUFFER_CODECS,this.onBufferCodecs,this);e.off(Events.BUFFER_EOS,this.onBufferEos,this);e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this);e.off(Events.LEVEL_UPDATED,this.onLevelUpdated,this);e.off(Events.FRAG_PARSED,this.onFragParsed,this);e.off(Events.FRAG_CHANGED,this.onFragChanged,this)};e.prototype._initSourceBuffer=function(){this.sourceBuffer={};this.operationQueue=new BufferOperationQueue(this.sourceBuffer);this.listeners={audio:[],video:[],audiovideo:[]};this.lastMpegAudioChunk=null};e.prototype.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0;this.details=null};e.prototype.onManifestParsed=function(e,t){var r=2;if(t.audio&&!t.video||!t.altAudio||!true){r=1}this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r;logger.log("".concat(this.bufferCodecEventsExpected," bufferCodec event(s) expected"))};e.prototype.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&MediaSource){var i=this.mediaSource=new MediaSource;i.addEventListener("sourceopen",this._onMediaSourceOpen);i.addEventListener("sourceended",this._onMediaSourceEnded);i.addEventListener("sourceclose",this._onMediaSourceClose);r.src=self.URL.createObjectURL(i);this._objectUrl=r.src;r.addEventListener("emptied",this._onMediaEmptied)}};e.prototype.onMediaDetaching=function(){var e=this,t=e.media,r=e.mediaSource,i=e._objectUrl;if(r){logger.log("[buffer-controller]: media source detaching");if(r.readyState==="open"){try{r.endOfStream()}catch(e){logger.warn("[buffer-controller]: onMediaDetaching: ".concat(e.message," while calling endOfStream"))}}this.onBufferReset();r.removeEventListener("sourceopen",this._onMediaSourceOpen);r.removeEventListener("sourceended",this._onMediaSourceEnded);r.removeEventListener("sourceclose",this._onMediaSourceClose);if(t){t.removeEventListener("emptied",this._onMediaEmptied);if(i){self.URL.revokeObjectURL(i)}if(t.src===i){t.removeAttribute("src");t.load()}else{logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")}}this.mediaSource=null;this.media=null;this._objectUrl=null;this.bufferCodecEventsExpected=this._bufferCodecEventsTotal;this.pendingTracks={};this.tracks={}}this.hls.trigger(Events.MEDIA_DETACHED,undefined)};e.prototype.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){var r=e.sourceBuffer[t];try{if(r){e.removeBufferListeners(t);if(e.mediaSource){e.mediaSource.removeSourceBuffer(r)}e.sourceBuffer[t]=undefined}}catch(e){logger.warn("[buffer-controller]: Failed to reset the ".concat(t," buffer"),e)}}));this._initSourceBuffer()};e.prototype.onBufferCodecs=function(e,t){var r=this;var i=this.getSourceBufferTypes().length;Object.keys(t).forEach((function(e){if(i){var a=r.tracks[e];if(a&&typeof a.buffer.changeType==="function"){var n=t[e],s=n.id,o=n.codec,l=n.levelCodec,u=n.container,f=n.metadata;var c=(a.levelCodec||a.codec).replace(VIDEO_CODEC_PROFILE_REPACE,"$1");var d=(l||o).replace(VIDEO_CODEC_PROFILE_REPACE,"$1");if(c!==d){var h="".concat(u,";codecs=").concat(l||o);r.appendChangeType(e,h);logger.log("[buffer-controller]: switching codec ".concat(c," to ").concat(d));r.tracks[e]={buffer:a.buffer,codec:o,container:u,levelCodec:l,metadata:f,id:s}}}}else{r.pendingTracks[e]=t[e]}}));if(i){return}this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0);if(this.mediaSource&&this.mediaSource.readyState==="open"){this.checkPendingTracks()}};e.prototype.appendChangeType=function(e,t){var r=this;var i=this.operationQueue;var a={execute:function(){var a=r.sourceBuffer[e];if(a){logger.log("[buffer-controller]: changing ".concat(e," sourceBuffer type to ").concat(t));a.changeType(t)}i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){logger.warn("[buffer-controller]: Failed to change ".concat(e," SourceBuffer type"),t)}};i.append(a,e)};e.prototype.onBufferAppending=function(e,t){var r=this;var i=this,a=i.hls,n=i.operationQueue,s=i.tracks;var o=t.data,l=t.type,u=t.frag,f=t.part,c=t.chunkMeta;var d=c.buffering[l];var h=self.performance.now();d.start=h;var v=u.stats.buffering;var p=f?f.stats.buffering:null;if(v.start===0){v.start=h}if(p&&p.start===0){p.start=h}var g=s.audio;var m=false;if(l==="audio"&&(g==null?void 0:g.container)==="audio/mpeg"){m=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn;this.lastMpegAudioChunk=c}var y=u.start;var E={execute:function(){d.executeStart=self.performance.now();if(m){var e=r.sourceBuffer[l];if(e){var t=y-e.timestampOffset;if(Math.abs(t)>=.1){logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to ".concat(y," (delta: ").concat(t,") sn: ").concat(u.sn,")"));e.timestampOffset=y}}}r.appendExecutor(o,l)},onStart:function(){},onComplete:function(){var e=self.performance.now();d.executeEnd=d.end=e;if(v.first===0){v.first=e}if(p&&p.first===0){p.first=e}var t=r.sourceBuffer;var i={};for(var a in t){i[a]=BufferHelper.getBuffered(t[a])}r.appendError=0;r.hls.trigger(Events.BUFFER_APPENDED,{type:l,frag:u,part:f,chunkMeta:c,parent:u.type,timeRanges:i})},onError:function(e){logger.error("[buffer-controller]: Error encountered while trying to append to the ".concat(l," SourceBuffer"),e);var t={type:ErrorTypes.MEDIA_ERROR,parent:u.type,details:ErrorDetails.BUFFER_APPEND_ERROR,frag:u,part:f,chunkMeta:c,error:e,err:e,fatal:false};if(e.code===DOMException.QUOTA_EXCEEDED_ERR){t.details=ErrorDetails.BUFFER_FULL_ERROR}else{r.appendError++;t.details=ErrorDetails.BUFFER_APPEND_ERROR;if(r.appendError>a.config.appendErrorMaxRetry){logger.error("[buffer-controller]: Failed ".concat(a.config.appendErrorMaxRetry," times to append segment in sourceBuffer"));t.fatal=true}}a.trigger(Events.ERROR,t)}};n.append(E,l)};e.prototype.onBufferFlushing=function(e,t){var r=this;var i=this.operationQueue;var a=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(Events.BUFFER_FLUSHED,{type:e})},onError:function(t){logger.warn("[buffer-controller]: Failed to remove from ".concat(e," SourceBuffer"),t)}}};if(t.type){i.append(a(t.type),t.type)}else{this.getSourceBufferTypes().forEach((function(e){i.append(a(e),e)}))}};e.prototype.onFragParsed=function(e,t){var r=this;var i=t.frag,a=t.part;var n=[];var s=a?a.elementaryStreams:i.elementaryStreams;if(s[ElementaryStreamTypes.AUDIOVIDEO]){n.push("audiovideo")}else{if(s[ElementaryStreamTypes.AUDIO]){n.push("audio")}if(s[ElementaryStreamTypes.VIDEO]){n.push("video")}}var o=function(){var e=self.performance.now();i.stats.buffering.end=e;if(a){a.stats.buffering.end=e}var t=a?a.stats:i.stats;r.hls.trigger(Events.FRAG_BUFFERED,{frag:i,part:a,stats:t,id:i.type})};if(n.length===0){logger.warn("Fragments must have at least one ElementaryStreamType set. type: ".concat(i.type," level: ").concat(i.level," sn: ").concat(i.sn))}this.blockBuffers(o,n)};e.prototype.onFragChanged=function(e,t){this.flushBackBuffer()};e.prototype.onBufferEos=function(e,t){var r=this;var i=this.getSourceBufferTypes().reduce((function(e,i){var a=r.sourceBuffer[i];if(a&&(!t.type||t.type===i)){a.ending=true;if(!a.ended){a.ended=true;logger.log("[buffer-controller]: ".concat(i," sourceBuffer now EOS"))}}return e&&!!(!a||a.ended)}),true);if(i){logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()");this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(e){var t=r.sourceBuffer[e];if(t){t.ending=false}}));var e=r.mediaSource;if(!e||e.readyState!=="open"){if(e){logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ".concat(e.readyState))}return}logger.log("[buffer-controller]: Calling mediaSource.endOfStream()");e.endOfStream()}))}};e.prototype.onLevelUpdated=function(e,t){var r=t.details;if(!r.fragments.length){return}this.details=r;if(this.getSourceBufferTypes().length){this.blockBuffers(this.updateMediaElementDuration.bind(this))}else{this.updateMediaElementDuration()}};e.prototype.flushBackBuffer=function(){var e=this,t=e.hls,r=e.details,i=e.media,a=e.sourceBuffer;if(!i||r===null){return}var n=this.getSourceBufferTypes();if(!n.length){return}var s=r.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!isFiniteNumber(s)||s<0){return}var o=i.currentTime;var l=r.levelTargetDuration;var u=Math.max(s,l);var f=Math.floor(o/l)*l-u;n.forEach((function(e){var i=a[e];if(i){var n=BufferHelper.getBuffered(i);if(n.length>0&&f>n.start(0)){t.trigger(Events.BACK_BUFFER_REACHED,{bufferEnd:f});if(r.live){t.trigger(Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:f})}else if(i.ended&&n.end(n.length-1)-o<l*2){logger.info("[buffer-controller]: Cannot flush ".concat(e," back buffer while SourceBuffer is in ended state"));return}t.trigger(Events.BUFFER_FLUSHING,{startOffset:0,endOffset:f,type:e})}}}))};e.prototype.updateMediaElementDuration=function(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open"){return}var e=this,t=e.details,r=e.hls,i=e.media,a=e.mediaSource;var n=t.fragments[0].start+t.totalduration;var s=i.duration;var o=isFiniteNumber(a.duration)?a.duration:0;if(t.live&&r.config.liveDurationInfinity){logger.log("[buffer-controller]: Media Source duration is set to Infinity");a.duration=Infinity;this.updateSeekableRange(t)}else if(n>o&&n>s||!isFiniteNumber(s)){logger.log("[buffer-controller]: Updating Media Source duration to ".concat(n.toFixed(3)));a.duration=n}};e.prototype.updateSeekableRange=function(e){var t=this.mediaSource;var r=e.fragments;var i=r.length;if(i&&e.live&&t!=null&&t.setLiveSeekableRange){var a=Math.max(0,r[0].start);var n=Math.max(a,a+e.totalduration);t.setLiveSeekableRange(a,n)}};e.prototype.checkPendingTracks=function(){var e=this,t=e.bufferCodecEventsExpected,r=e.operationQueue,i=e.pendingTracks;var a=Object.keys(i).length;if(a&&!t||a===2){this.createSourceBuffers(i);this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length){this.hls.trigger(Events.BUFFER_CREATED,{tracks:this.tracks});n.forEach((function(e){r.executeNext(e)}))}else{var s=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:true,error:s,reason:s.message})}}};e.prototype.createSourceBuffers=function(e){var t=this,r=t.sourceBuffer,i=t.mediaSource;if(!i){throw Error("createSourceBuffers called when mediaSource was null")}for(var a in e){if(!r[a]){var n=e[a];if(!n){throw Error("source buffer exists for track ".concat(a,", however track does not"))}var s=n.levelCodec||n.codec;var o="".concat(n.container,";codecs=").concat(s);logger.log("[buffer-controller]: creating sourceBuffer(".concat(o,")"));try{var l=r[a]=i.addSourceBuffer(o);var u=a;this.addBufferListener(u,"updatestart",this._onSBUpdateStart);this.addBufferListener(u,"updateend",this._onSBUpdateEnd);this.addBufferListener(u,"error",this._onSBUpdateError);this.tracks[a]={buffer:l,codec:s,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(e){logger.error("[buffer-controller]: error while trying to add sourceBuffer: ".concat(e.message));this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:false,error:e,mimeType:o})}}}};e.prototype._onSBUpdateStart=function(e){var t=this.operationQueue;var r=t.current(e);r.onStart()};e.prototype._onSBUpdateEnd=function(e){var t=this.operationQueue;var r=t.current(e);r.onComplete();t.shiftAndExecuteNext(e)};e.prototype._onSBUpdateError=function(e,t){var r=new Error("".concat(e," SourceBuffer error"));logger.error("[buffer-controller]: ".concat(r),t);this.hls.trigger(Events.ERROR,{type:ErrorTypes.MEDIA_ERROR,details:ErrorDetails.BUFFER_APPENDING_ERROR,error:r,fatal:false});var i=this.operationQueue.current(e);if(i){i.onError(t)}};e.prototype.removeExecutor=function(e,t,r){var i=this,a=i.media,n=i.mediaSource,s=i.operationQueue,o=i.sourceBuffer;var l=o[e];if(!a||!n||!l){logger.warn("[buffer-controller]: Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist"));s.shiftAndExecuteNext(e);return}var u=isFiniteNumber(a.duration)?a.duration:Infinity;var f=isFiniteNumber(n.duration)?n.duration:Infinity;var c=Math.max(0,t);var d=Math.min(r,u,f);if(d>c&&!l.ending){l.ended=false;logger.log("[buffer-controller]: Removing [".concat(c,",").concat(d,"] from the ").concat(e," SourceBuffer"));l.remove(c,d)}else{s.shiftAndExecuteNext(e)}};e.prototype.appendExecutor=function(e,t){var r=this,i=r.operationQueue,a=r.sourceBuffer;var n=a[t];if(!n){logger.warn("[buffer-controller]: Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));i.shiftAndExecuteNext(t);return}n.ended=false;n.appendBuffer(e)};e.prototype.blockBuffers=function(e,t){var r=this;if(t===void 0){t=this.getSourceBufferTypes()}if(!t.length){logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist");Promise.resolve().then(e);return}var i=this.operationQueue;var a=t.map((function(e){return i.appendBlocker(e)}));Promise.all(a).then((function(){e();t.forEach((function(e){var t=r.sourceBuffer[e];if(!(t!=null&&t.updating)){i.shiftAndExecuteNext(e)}}))}))};e.prototype.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)};e.prototype.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(!i){return}var a=r.bind(this,e);this.listeners[e].push({event:t,listener:a});i.addEventListener(t,a)};e.prototype.removeBufferListeners=function(e){var t=this.sourceBuffer[e];if(!t){return}this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))};return e}();var specialCea608CharsCodes={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499};var getCharForByte=function e(t){var r=t;if(specialCea608CharsCodes.hasOwnProperty(t)){r=specialCea608CharsCodes[t]}return String.fromCharCode(r)};var NR_ROWS=15;var NR_COLS=100;var rowsLowCh1={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14};var rowsHighCh1={17:2,18:4,21:6,22:8,23:10,19:13,20:15};var rowsLowCh2={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14};var rowsHighCh2={25:2,26:4,29:6,30:8,31:10,27:13,28:15};var backgroundColors=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];var CaptionsLogger=function(){function e(){this.time=null;this.verboseLevel=0}e.prototype.log=function(e,t){if(this.verboseLevel>=e){var r=typeof t==="function"?t():t;logger.log("".concat(this.time," [").concat(e,"] ").concat(r))}};return e}();var numArrayToHexArray=function e(t){var r=[];for(var i=0;i<t.length;i++){r.push(t[i].toString(16))}return r};var PenState=function(){function e(e,t,r,i,a){this.foreground=void 0;this.underline=void 0;this.italics=void 0;this.background=void 0;this.flash=void 0;this.foreground=e||"white";this.underline=t||false;this.italics=r||false;this.background=i||"black";this.flash=a||false}e.prototype.reset=function(){this.foreground="white";this.underline=false;this.italics=false;this.background="black";this.flash=false};e.prototype.setStyles=function(e){var t=["foreground","underline","italics","background","flash"];for(var r=0;r<t.length;r++){var i=t[r];if(e.hasOwnProperty(i)){this[i]=e[i]}}};e.prototype.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash};e.prototype.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash};e.prototype.copy=function(e){this.foreground=e.foreground;this.underline=e.underline;this.italics=e.italics;this.background=e.background;this.flash=e.flash};e.prototype.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash};return e}();var StyledUnicodeChar=function(){function e(e,t,r,i,a,n){this.uchar=void 0;this.penState=void 0;this.uchar=e||" ";this.penState=new PenState(t,r,i,a,n)}e.prototype.reset=function(){this.uchar=" ";this.penState.reset()};e.prototype.setChar=function(e,t){this.uchar=e;this.penState.copy(t)};e.prototype.setPenState=function(e){this.penState.copy(e)};e.prototype.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)};e.prototype.copy=function(e){this.uchar=e.uchar;this.penState.copy(e.penState)};e.prototype.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()};return e}();var Row=function(){function e(e){this.chars=void 0;this.pos=void 0;this.currPenState=void 0;this.cueStartTime=void 0;this.logger=void 0;this.chars=[];for(var t=0;t<NR_COLS;t++){this.chars.push(new StyledUnicodeChar)}this.logger=e;this.pos=0;this.currPenState=new PenState}e.prototype.equals=function(e){var t=true;for(var r=0;r<NR_COLS;r++){if(!this.chars[r].equals(e.chars[r])){t=false;break}}return t};e.prototype.copy=function(e){for(var t=0;t<NR_COLS;t++){this.chars[t].copy(e.chars[t])}};e.prototype.isEmpty=function(){var e=true;for(var t=0;t<NR_COLS;t++){if(!this.chars[t].isEmpty()){e=false;break}}return e};e.prototype.setCursor=function(e){if(this.pos!==e){this.pos=e}if(this.pos<0){this.logger.log(3,"Negative cursor position "+this.pos);this.pos=0}else if(this.pos>NR_COLS){this.logger.log(3,"Too large cursor position "+this.pos);this.pos=NR_COLS}};e.prototype.moveCursor=function(e){var t=this.pos+e;if(e>1){for(var r=this.pos+1;r<t+1;r++){this.chars[r].setPenState(this.currPenState)}}this.setCursor(t)};e.prototype.backSpace=function(){this.moveCursor(-1);this.chars[this.pos].setChar(" ",this.currPenState)};e.prototype.insertChar=function(e){var t=this;if(e>=144){this.backSpace()}var r=getCharForByte(e);if(this.pos>=NR_COLS){this.logger.log(0,(function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"}));return}this.chars[this.pos].setChar(r,this.currPenState);this.moveCursor(1)};e.prototype.clearFromPos=function(e){var t;for(t=e;t<NR_COLS;t++){this.chars[t].reset()}};e.prototype.clear=function(){this.clearFromPos(0);this.pos=0;this.currPenState.reset()};e.prototype.clearToEndOfRow=function(){this.clearFromPos(this.pos)};e.prototype.getTextString=function(){var e=[];var t=true;for(var r=0;r<NR_COLS;r++){var i=this.chars[r].uchar;if(i!==" "){t=false}e.push(i)}if(t){return""}else{return e.join("")}};e.prototype.setPenStyles=function(e){this.currPenState.setStyles(e);var t=this.chars[this.pos];t.setPenState(this.currPenState)};return e}();var CaptionScreen=function(){function e(e){this.rows=void 0;this.currRow=void 0;this.nrRollUpRows=void 0;this.lastOutputScreen=void 0;this.logger=void 0;this.rows=[];for(var t=0;t<NR_ROWS;t++){this.rows.push(new Row(e))}this.logger=e;this.currRow=NR_ROWS-1;this.nrRollUpRows=null;this.lastOutputScreen=null;this.reset()}e.prototype.reset=function(){for(var e=0;e<NR_ROWS;e++){this.rows[e].clear()}this.currRow=NR_ROWS-1};e.prototype.equals=function(e){var t=true;for(var r=0;r<NR_ROWS;r++){if(!this.rows[r].equals(e.rows[r])){t=false;break}}return t};e.prototype.copy=function(e){for(var t=0;t<NR_ROWS;t++){this.rows[t].copy(e.rows[t])}};e.prototype.isEmpty=function(){var e=true;for(var t=0;t<NR_ROWS;t++){if(!this.rows[t].isEmpty()){e=false;break}}return e};e.prototype.backSpace=function(){var e=this.rows[this.currRow];e.backSpace()};e.prototype.clearToEndOfRow=function(){var e=this.rows[this.currRow];e.clearToEndOfRow()};e.prototype.insertChar=function(e){var t=this.rows[this.currRow];t.insertChar(e)};e.prototype.setPen=function(e){var t=this.rows[this.currRow];t.setPenStyles(e)};e.prototype.moveCursor=function(e){var t=this.rows[this.currRow];t.moveCursor(e)};e.prototype.setCursor=function(e){this.logger.log(2,"setCursor: "+e);var t=this.rows[this.currRow];t.setCursor(e)};e.prototype.setPAC=function(e){this.logger.log(2,(function(){return"pacData = "+JSON.stringify(e)}));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1){t=this.nrRollUpRows-1}if(this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<NR_ROWS;r++){this.rows[r].clear()}var i=this.currRow+1-this.nrRollUpRows;var a=this.lastOutputScreen;if(a){var n=a.rows[i].cueStartTime;var s=this.logger.time;if(n&&s!==null&&n<s){for(var r=0;r<this.nrRollUpRows;r++){this.rows[t-this.nrRollUpRows+r+1].copy(a.rows[i+r])}}}}this.currRow=t;var o=this.rows[this.currRow];if(e.indent!==null){var l=e.indent;var u=Math.max(l-1,0);o.setCursor(e.indent);e.color=o.chars[u].penState.foreground}var f={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:false};this.setPen(f)};e.prototype.setBkgData=function(e){this.logger.log(2,(function(){return"bkgData = "+JSON.stringify(e)}));this.backSpace();this.setPen(e);this.insertChar(32)};e.prototype.setRollUpRows=function(e){this.nrRollUpRows=e};e.prototype.rollUp=function(){var e=this;if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,(function(){return e.getDisplayText()}));var t=this.currRow+1-this.nrRollUpRows;var r=this.rows.splice(t,1)[0];r.clear();this.rows.splice(this.currRow,0,r);this.logger.log(2,"Rolling up")};e.prototype.getDisplayText=function(e){e=e||false;var t=[];var r="";var i=-1;for(var a=0;a<NR_ROWS;a++){var n=this.rows[a].getTextString();if(n){i=a+1;if(e){t.push("Row "+i+": '"+n+"'")}else{t.push(n.trim())}}}if(t.length>0){if(e){r="["+t.join(" | ")+"]"}else{r=t.join("\n")}}return r};e.prototype.getTextAndFormat=function(){return this.rows};return e}();var Cea608Channel=function(){function e(e,t,r){this.chNr=void 0;this.outputFilter=void 0;this.mode=void 0;this.verbose=void 0;this.displayedMemory=void 0;this.nonDisplayedMemory=void 0;this.lastOutputScreen=void 0;this.currRollUpRow=void 0;this.writeScreen=void 0;this.cueStartTime=void 0;this.logger=void 0;this.chNr=e;this.outputFilter=t;this.mode=null;this.verbose=0;this.displayedMemory=new CaptionScreen(r);this.nonDisplayedMemory=new CaptionScreen(r);this.lastOutputScreen=new CaptionScreen(r);this.currRollUpRow=this.displayedMemory.rows[NR_ROWS-1];this.writeScreen=this.displayedMemory;this.mode=null;this.cueStartTime=null;this.logger=r}e.prototype.reset=function(){this.mode=null;this.displayedMemory.reset();this.nonDisplayedMemory.reset();this.lastOutputScreen.reset();this.outputFilter.reset();this.currRollUpRow=this.displayedMemory.rows[NR_ROWS-1];this.writeScreen=this.displayedMemory;this.mode=null;this.cueStartTime=null};e.prototype.getHandler=function(){return this.outputFilter};e.prototype.setHandler=function(e){this.outputFilter=e};e.prototype.setPAC=function(e){this.writeScreen.setPAC(e)};e.prototype.setBkgData=function(e){this.writeScreen.setBkgData(e)};e.prototype.setMode=function(e){if(e===this.mode){return}this.mode=e;this.logger.log(2,(function(){return"MODE="+e}));if(this.mode==="MODE_POP-ON"){this.writeScreen=this.nonDisplayedMemory}else{this.writeScreen=this.displayedMemory;this.writeScreen.reset()}if(this.mode!=="MODE_ROLL-UP"){this.displayedMemory.nrRollUpRows=null;this.nonDisplayedMemory.nrRollUpRows=null}this.mode=e};e.prototype.insertChars=function(e){var t=this;for(var r=0;r<e.length;r++){this.writeScreen.insertChar(e[r])}var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return i+": "+t.writeScreen.getDisplayText(true)}));if(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP"){this.logger.log(1,(function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(true)}));this.outputDataUpdate()}};e.prototype.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading");this.setMode("MODE_POP-ON")};e.prototype.ccBS=function(){this.logger.log(2,"BS - BackSpace");if(this.mode==="MODE_TEXT"){return}this.writeScreen.backSpace();if(this.writeScreen===this.displayedMemory){this.outputDataUpdate()}};e.prototype.ccAOF=function(){};e.prototype.ccAON=function(){};e.prototype.ccDER=function(){this.logger.log(2,"DER- Delete to End of Row");this.writeScreen.clearToEndOfRow();this.outputDataUpdate()};e.prototype.ccRU=function(e){this.logger.log(2,"RU("+e+") - Roll Up");this.writeScreen=this.displayedMemory;this.setMode("MODE_ROLL-UP");this.writeScreen.setRollUpRows(e)};e.prototype.ccFON=function(){this.logger.log(2,"FON - Flash On");this.writeScreen.setPen({flash:true})};e.prototype.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning");this.setMode("MODE_PAINT-ON")};e.prototype.ccTR=function(){this.logger.log(2,"TR");this.setMode("MODE_TEXT")};e.prototype.ccRTD=function(){this.logger.log(2,"RTD");this.setMode("MODE_TEXT")};e.prototype.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory");this.displayedMemory.reset();this.outputDataUpdate(true)};e.prototype.ccCR=function(){this.logger.log(2,"CR - Carriage Return");this.writeScreen.rollUp();this.outputDataUpdate(true)};e.prototype.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory");this.nonDisplayedMemory.reset()};e.prototype.ccEOC=function(){var e=this;this.logger.log(2,"EOC - End Of Caption");if(this.mode==="MODE_POP-ON"){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory;this.nonDisplayedMemory=t;this.writeScreen=this.nonDisplayedMemory;this.logger.log(1,(function(){return"DISP: "+e.displayedMemory.getDisplayText()}))}this.outputDataUpdate(true)};e.prototype.ccTO=function(e){this.logger.log(2,"TO("+e+") - Tab Offset");this.writeScreen.moveCursor(e)};e.prototype.ccMIDROW=function(e){var t={flash:false};t.underline=e%2===1;t.italics=e>=46;if(!t.italics){var r=Math.floor(e/2)-16;var i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}else{t.foreground="white"}this.logger.log(2,"MIDROW: "+JSON.stringify(t));this.writeScreen.setPen(t)};e.prototype.outputDataUpdate=function(e){if(e===void 0){e=false}var t=this.logger.time;if(t===null){return}if(this.outputFilter){if(this.cueStartTime===null&&!this.displayedMemory.isEmpty()){this.cueStartTime=t}else{if(!this.displayedMemory.equals(this.lastOutputScreen)){this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen);if(e&&this.outputFilter.dispatchCue){this.outputFilter.dispatchCue()}this.cueStartTime=this.displayedMemory.isEmpty()?null:t}}this.lastOutputScreen.copy(this.displayedMemory)}};e.prototype.cueSplitAtTime=function(e){if(this.outputFilter){if(!this.displayedMemory.isEmpty()){if(this.outputFilter.newCue){this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory)}this.cueStartTime=e}}};return e}();var Cea608Parser=function(){function e(e,t,r){this.channels=void 0;this.currentChannel=0;this.cmdHistory=void 0;this.logger=void 0;var i=new CaptionsLogger;this.channels=[null,new Cea608Channel(e,t,i),new Cea608Channel(e+1,r,i)];this.cmdHistory=createCmdHistory();this.logger=i}e.prototype.getHandler=function(e){return this.channels[e].getHandler()};e.prototype.setHandler=function(e,t){this.channels[e].setHandler(t)};e.prototype.addData=function(e,t){var r;var i;var a;var n=false;this.logger.time=e;for(var s=0;s<t.length;s+=2){i=t[s]&127;a=t[s+1]&127;if(i===0&&a===0){continue}else{this.logger.log(3,"["+numArrayToHexArray([t[s],t[s+1]])+"] -> ("+numArrayToHexArray([i,a])+")")}r=this.parseCmd(i,a);if(!r){r=this.parseMidrow(i,a)}if(!r){r=this.parsePAC(i,a)}if(!r){r=this.parseBackgroundAttributes(i,a)}if(!r){n=this.parseChars(i,a);if(n){var o=this.currentChannel;if(o&&o>0){var l=this.channels[o];l.insertChars(n)}else{this.logger.log(2,"No channel found yet. TEXT-MODE?")}}}if(!r&&!n){this.logger.log(2,"Couldn't parse cleaned data "+numArrayToHexArray([i,a])+" orig: "+numArrayToHexArray([t[s],t[s+1]]))}}};e.prototype.parseCmd=function(e,t){var r=this.cmdHistory;var i=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47;var a=(e===23||e===31)&&t>=33&&t<=35;if(!(i||a)){return false}if(hasCmdRepeated(e,t,r)){setLastCmd(null,null,r);this.logger.log(3,"Repeated command ("+numArrayToHexArray([e,t])+") is dropped");return true}var n=e===20||e===21||e===23?1:2;var s=this.channels[n];if(e===20||e===21||e===28||e===29){if(t===32){s.ccRCL()}else if(t===33){s.ccBS()}else if(t===34){s.ccAOF()}else if(t===35){s.ccAON()}else if(t===36){s.ccDER()}else if(t===37){s.ccRU(2)}else if(t===38){s.ccRU(3)}else if(t===39){s.ccRU(4)}else if(t===40){s.ccFON()}else if(t===41){s.ccRDC()}else if(t===42){s.ccTR()}else if(t===43){s.ccRTD()}else if(t===44){s.ccEDM()}else if(t===45){s.ccCR()}else if(t===46){s.ccENM()}else if(t===47){s.ccEOC()}}else{s.ccTO(t-32)}setLastCmd(e,t,r);this.currentChannel=n;return true};e.prototype.parseMidrow=function(e,t){var r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17){r=1}else{r=2}if(r!==this.currentChannel){this.logger.log(0,"Mismatch channel in midrow parsing");return false}var i=this.channels[r];if(!i){return false}i.ccMIDROW(t);this.logger.log(3,"MIDROW ("+numArrayToHexArray([e,t])+")");return true}return false};e.prototype.parsePAC=function(e,t){var r;var i=this.cmdHistory;var a=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127;var n=(e===16||e===24)&&t>=64&&t<=95;if(!(a||n)){return false}if(hasCmdRepeated(e,t,i)){setLastCmd(null,null,i);return true}var s=e<=23?1:2;if(t>=64&&t<=95){r=s===1?rowsLowCh1[e]:rowsLowCh2[e]}else{r=s===1?rowsHighCh1[e]:rowsHighCh2[e]}var o=this.channels[s];if(!o){return false}o.setPAC(this.interpretPAC(r,t));setLastCmd(e,t,i);this.currentChannel=s;return true};e.prototype.interpretPAC=function(e,t){var r;var i={color:null,italics:false,indent:null,underline:false,row:e};if(t>95){r=t-96}else{r=t-64}i.underline=(r&1)===1;if(r<=13){i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]}else if(r<=15){i.italics=true;i.color="white"}else{i.indent=Math.floor((r-16)/2)*4}return i};e.prototype.parseChars=function(e,t){var r;var i=null;var a=null;if(e>=25){r=2;a=e-8}else{r=1;a=e}if(a>=17&&a<=19){var n=void 0;if(a===17){n=t+80}else if(a===18){n=t+112}else{n=t+144}this.logger.log(2,"Special char '"+getCharForByte(n)+"' in channel "+r);i=[n]}else if(e>=32&&e<=127){i=t===0?[e]:[e,t]}if(i){var s=numArrayToHexArray(i);this.logger.log(3,"Char codes = "+s.join(","));setLastCmd(e,t,this.cmdHistory)}return i};e.prototype.parseBackgroundAttributes=function(e,t){var r=(e===16||e===24)&&t>=32&&t<=47;var i=(e===23||e===31)&&t>=45&&t<=47;if(!(r||i)){return false}var a;var n={};if(e===16||e===24){a=Math.floor((t-32)/2);n.background=backgroundColors[a];if(t%2===1){n.background=n.background+"_semi"}}else if(t===45){n.background="transparent"}else{n.foreground="black";if(t===47){n.underline=true}}var s=e<=23?1:2;var o=this.channels[s];o.setBkgData(n);setLastCmd(e,t,this.cmdHistory);return true};e.prototype.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];if(t){t.reset()}}this.cmdHistory=createCmdHistory()};e.prototype.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];if(r){r.cueSplitAtTime(e)}}};return e}();function setLastCmd(e,t,r){r.a=e;r.b=t}function hasCmdRepeated(e,t,r){return r.a===e&&r.b===t}function createCmdHistory(){return{a:null,b:null}}var OutputFilter=function(){function e(e,t){this.timelineController=void 0;this.cueRanges=[];this.trackName=void 0;this.startTime=null;this.endTime=null;this.screen=null;this.timelineController=e;this.trackName=t}e.prototype.dispatchCue=function(){if(this.startTime===null){return}this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges);this.startTime=null};e.prototype.newCue=function(e,t,r){if(this.startTime===null||this.startTime>e){this.startTime=e}this.endTime=t;this.screen=r;this.timelineController.createCaptionsTrack(this.trackName)};e.prototype.reset=function(){this.cueRanges=[];this.startTime=null};return e}();var VTTCue=function(){if(typeof self!=="undefined"&&self.VTTCue){return self.VTTCue}var e=["","lr","rl"];var t=["start","middle","end","left","right"];function r(e,t){if(typeof t!=="string"){return false}if(!Array.isArray(e)){return false}var r=t.toLowerCase();if(~e.indexOf(r)){return r}return false}function i(t){return r(e,t)}function a(e){return r(t,e)}function n(e){var t=[];for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}var i=1;for(;i<arguments.length;i++){var a=arguments[i];for(var n in a){e[n]=a[n]}}return e}function s(e,t,r){var s=this;var o={enumerable:true};s.hasBeenReset=false;var l="";var u=false;var f=e;var c=t;var d=r;var h=null;var v="";var p=true;var g="auto";var m="start";var y=50;var E="middle";var T=50;var S="middle";Object.defineProperty(s,"id",n({},o,{get:function(){return l},set:function(e){l=""+e}}));Object.defineProperty(s,"pauseOnExit",n({},o,{get:function(){return u},set:function(e){u=!!e}}));Object.defineProperty(s,"startTime",n({},o,{get:function(){return f},set:function(e){if(typeof e!=="number"){throw new TypeError("Start time must be set to a number.")}f=e;this.hasBeenReset=true}}));Object.defineProperty(s,"endTime",n({},o,{get:function(){return c},set:function(e){if(typeof e!=="number"){throw new TypeError("End time must be set to a number.")}c=e;this.hasBeenReset=true}}));Object.defineProperty(s,"text",n({},o,{get:function(){return d},set:function(e){d=""+e;this.hasBeenReset=true}}));Object.defineProperty(s,"region",n({},o,{get:function(){return h},set:function(e){h=e;this.hasBeenReset=true}}));Object.defineProperty(s,"vertical",n({},o,{get:function(){return v},set:function(e){var t=i(e);if(t===false){throw new SyntaxError("An invalid or illegal string was specified.")}v=t;this.hasBeenReset=true}}));Object.defineProperty(s,"snapToLines",n({},o,{get:function(){return p},set:function(e){p=!!e;this.hasBeenReset=true}}));Object.defineProperty(s,"line",n({},o,{get:function(){return g},set:function(e){if(typeof e!=="number"&&e!=="auto"){throw new SyntaxError("An invalid number or illegal string was specified.")}g=e;this.hasBeenReset=true}}));Object.defineProperty(s,"lineAlign",n({},o,{get:function(){return m},set:function(e){var t=a(e);if(!t){throw new SyntaxError("An invalid or illegal string was specified.")}m=t;this.hasBeenReset=true}}));Object.defineProperty(s,"position",n({},o,{get:function(){return y},set:function(e){if(e<0||e>100){throw new Error("Position must be between 0 and 100.")}y=e;this.hasBeenReset=true}}));Object.defineProperty(s,"positionAlign",n({},o,{get:function(){return E},set:function(e){var t=a(e);if(!t){throw new SyntaxError("An invalid or illegal string was specified.")}E=t;this.hasBeenReset=true}}));Object.defineProperty(s,"size",n({},o,{get:function(){return T},set:function(e){if(e<0||e>100){throw new Error("Size must be between 0 and 100.")}T=e;this.hasBeenReset=true}}));Object.defineProperty(s,"align",n({},o,{get:function(){return S},set:function(e){var t=a(e);if(!t){throw new SyntaxError("An invalid or illegal string was specified.")}S=t;this.hasBeenReset=true}}));s.displayState=undefined}s.prototype.getCueAsHTML=function(){var e=self.WebVTT;return e.convertCueToDOMTree(self,this.text)};return s}();var StringDecoder=function(){function e(){}e.prototype.decode=function(e,t){if(!e){return""}if(typeof e!=="string"){throw new Error("Error - expected string data.")}return decodeURIComponent(encodeURIComponent(e))};return e}();function parseTimeStamp(e){function t(e,t,r,i){return(e|0)*3600+(t|0)*60+(r|0)+parseFloat(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);if(!r){return null}if(parseFloat(r[2])>59){return t(r[2],r[3],0,r[4])}return t(r[1],r[2],r[3],r[4])}var Settings=function(){function e(){this.values=Object.create(null)}e.prototype.set=function(e,t){if(!this.get(e)&&t!==""){this.values[e]=t}};e.prototype.get=function(e,t,r){if(r){return this.has(e)?this.values[e]:t[r]}return this.has(e)?this.values[e]:t};e.prototype.has=function(e){return e in this.values};e.prototype.alt=function(e,t,r){for(var i=0;i<r.length;++i){if(t===r[i]){this.set(e,t);break}}};e.prototype.integer=function(e,t){if(/^-?\d+$/.test(t)){this.set(e,parseInt(t,10))}};e.prototype.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100){this.set(e,r);return true}}return false};return e}();function parseOptions(e,t,r,i){var a=i?e.split(i):[e];for(var n in a){if(typeof a[n]!=="string"){continue}var s=a[n].split(r);if(s.length!==2){continue}var o=s[0];var l=s[1];t(o,l)}}var defaults=new VTTCue(0,0,"");var center=defaults.align==="middle"?"middle":"center";function parseCue(e,t,r){var i=e;function a(){var t=parseTimeStamp(e);if(t===null){throw new Error("Malformed timestamp: "+i)}e=e.replace(/^[^\sa-zA-Z-]+/,"");return t}function n(e,t){var i=new Settings;parseOptions(e,(function(e,t){var a;switch(e){case"region":for(var n=r.length-1;n>=0;n--){if(r[n].id===t){i.set(e,r[n].region);break}}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":a=t.split(",");i.integer(e,a[0]);if(i.percent(e,a[0])){i.set("snapToLines",false)}i.alt(e,a[0],["auto"]);if(a.length===2){i.alt("lineAlign",a[1],["start",center,"end"])}break;case"position":a=t.split(",");i.percent(e,a[0]);if(a.length===2){i.alt("positionAlign",a[1],["start",center,"end","line-left","line-right","auto"])}break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",center,"end","left","right"]);break}}),/:/,/\s/);t.region=i.get("region",null);t.vertical=i.get("vertical","");var a=i.get("line","auto");if(a==="auto"&&defaults.line===-1){a=-1}t.line=a;t.lineAlign=i.get("lineAlign","start");t.snapToLines=i.get("snapToLines",true);t.size=i.get("size",100);t.align=i.get("align",center);var n=i.get("position","auto");if(n==="auto"&&defaults.position===50){n=t.align==="start"||t.align==="left"?0:t.align==="end"||t.align==="right"?100:50}t.position=n}function s(){e=e.replace(/^\s+/,"")}s();t.startTime=a();s();if(e.slice(0,3)!=="--\x3e"){throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i)}e=e.slice(3);s();t.endTime=a();s();n(e,t)}function fixLineBreaks(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var VTTParser=function(){function e(){this.state="INITIAL";this.buffer="";this.decoder=new StringDecoder;this.regionList=[];this.cue=null;this.oncue=void 0;this.onparsingerror=void 0;this.onflush=void 0}e.prototype.parse=function(e){var t=this;if(e){t.buffer+=t.decoder.decode(e,{stream:true})}function r(){var e=t.buffer;var r=0;e=fixLineBreaks(e);while(r<e.length&&e[r]!=="\r"&&e[r]!=="\n"){++r}var i=e.slice(0,r);if(e[r]==="\r"){++r}if(e[r]==="\n"){++r}t.buffer=e.slice(r);return i}function i(e){parseOptions(e,(function(e,t){}),/:/)}try{var a="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer)){return this}a=r();var n=a.match(/^()?WEBVTT([ \t].*)?$/);if(!(n!=null&&n[0])){throw new Error("Malformed WebVTT signature.")}t.state="HEADER"}var s=false;while(t.buffer){if(!/\r\n|\n/.test(t.buffer)){return this}if(!s){a=r()}else{s=false}switch(t.state){case"HEADER":if(/:/.test(a)){i(a)}else if(!a){t.state="ID"}continue;case"NOTE":if(!a){t.state="ID"}continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a){continue}t.cue=new VTTCue(0,0,"");t.state="CUE";if(a.indexOf("--\x3e")===-1){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{parseCue(a,t.cue,t.regionList)}catch(e){t.cue=null;t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{var o=a.indexOf("--\x3e")!==-1;if(!a||o&&(s=true)){if(t.oncue&&t.cue){t.oncue(t.cue)}t.cue=null;t.state="ID";continue}if(t.cue===null){continue}if(t.cue.text){t.cue.text+="\n"}t.cue.text+=a}continue;case"BADCUE":if(!a){t.state="ID"}}}}catch(e){if(t.state==="CUETEXT"&&t.cue&&t.oncue){t.oncue(t.cue)}t.cue=null;t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this};e.prototype.flush=function(){var e=this;try{if(e.cue||e.state==="HEADER"){e.buffer+="\n\n";e.parse()}if(e.state==="INITIAL"||e.state==="BADWEBVTT"){throw new Error("Malformed WebVTT signature.")}}catch(t){if(e.onparsingerror){e.onparsingerror(t)}}if(e.onflush){e.onflush()}return this};return e}();var LINEBREAKS=/\r\n|\n\r|\n|\r/g;var startsWith=function e(t,r,i){if(i===void 0){i=0}return t.slice(i,i+r.length)===r};var cueString2millis=function e(t){var r=parseInt(t.slice(-3));var i=parseInt(t.slice(-6,-4));var a=parseInt(t.slice(-9,-7));var n=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!isFiniteNumber(r)||!isFiniteNumber(i)||!isFiniteNumber(a)||!isFiniteNumber(n)){throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(t))}r+=1e3*i;r+=60*1e3*a;r+=60*60*1e3*n;return r};var hash=function e(t){var r=5381;var i=t.length;while(i){r=r*33^t.charCodeAt(--i)}return(r>>>0).toString()};function generateCueId(e,t,r){return hash(e.toString())+hash(t.toString())+hash(r)}var calculateOffset=function e(t,r,i){var a=t[r];var n=t[a.prevCC];if(!n||!n.new&&a.new){t.ccOffset=t.presentationOffset=a.start;a.new=false;return}while((s=n)!=null&&s.new){var s;t.ccOffset+=a.start-n.start;a.new=false;a=n;n=t[a.prevCC]}t.presentationOffset=i};function parseWebVTT(e,t,r,i,a,n,s){var o=new VTTParser;var l=utf8ArrayToStr(new Uint8Array(e)).trim().replace(LINEBREAKS,"\n").split("\n");var u=[];var f=t?toMpegTsClockFromTimescale(t.baseTime,t.timescale):0;var c="00:00.000";var d=0;var h=0;var v;var p=true;o.oncue=function(e){var n=r[i];var s=r.ccOffset;var o=(d-f)/9e4;if(n!=null&&n.new){if(h!==undefined){s=r.ccOffset=n.start}else{calculateOffset(r,i,o)}}if(o){if(!t){v=new Error("Missing initPTS for VTT MPEGTS");return}s=o-r.presentationOffset}var l=e.endTime-e.startTime;var c=normalizePts((e.startTime+s-h)*9e4,a*9e4)/9e4;e.startTime=Math.max(c,0);e.endTime=Math.max(c+l,0);var p=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(p));if(!e.id){e.id=generateCueId(e.startTime,e.endTime,p)}if(e.endTime>0){u.push(e)}};o.onparsingerror=function(e){v=e};o.onflush=function(){if(v){s(v);return}n(u)};l.forEach((function(e){if(p){if(startsWith(e,"X-TIMESTAMP-MAP=")){p=false;e.slice(16).split(",").forEach((function(e){if(startsWith(e,"LOCAL:")){c=e.slice(6)}else if(startsWith(e,"MPEGTS:")){d=parseInt(e.slice(7))}}));try{h=cueString2millis(c)/1e3}catch(e){v=e}return}else if(e===""){p=false}}o.parse(e+"\n")}));o.flush()}var IMSC1_CODEC="stpp.ttml.im1t";var HMSF_REGEX=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/;var TIME_UNIT_REGEX=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/;var textAlignToLineAlign={left:"start",center:"center",right:"end",start:"start",end:"end"};function parseIMSC1(e,t,r,i){var a=findBox(new Uint8Array(e),["mdat"]);if(a.length===0){i(new Error("Could not parse IMSC1 mdat"));return}var n=a.map((function(e){return utf8ArrayToStr(e)}));var s=toTimescaleFromScale(t.baseTime,1,t.timescale);try{n.forEach((function(e){return r(parseTTML(e,s))}))}catch(e){i(e)}}function parseTTML(e,t){var r=new DOMParser;var i=r.parseFromString(e,"text/xml");var a=i.getElementsByTagName("tt")[0];if(!a){throw new Error("Invalid ttml")}var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0};var s=Object.keys(n).reduce((function(e,t){e[t]=a.getAttribute("ttp:".concat(t))||n[t];return e}),{});var o=a.getAttribute("xml:space")!=="preserve";var l=collectionToDictionary(getElementCollection(a,"styling","style"));var u=collectionToDictionary(getElementCollection(a,"layout","region"));var f=getElementCollection(a,"body","[begin]");return[].map.call(f,(function(e){var r=getTextContent(e,o);if(!r||!e.hasAttribute("begin")){return null}var i=parseTtmlTime(e.getAttribute("begin"),s);var a=parseTtmlTime(e.getAttribute("dur"),s);var n=parseTtmlTime(e.getAttribute("end"),s);if(i===null){throw timestampParsingError(e)}if(n===null){if(a===null){throw timestampParsingError(e)}n=i+a}var f=new VTTCue(i-t,n-t,r);f.id=generateCueId(f.startTime,f.endTime,f.text);var c=u[e.getAttribute("region")];var d=l[e.getAttribute("style")];var h=getTtmlStyles(c,d,l);var v=h.textAlign;if(v){var p=textAlignToLineAlign[v];if(p){f.lineAlign=p}f.align=v}_extends(f,h);return f})).filter((function(e){return e!==null}))}function getElementCollection(e,t,r){var i=e.getElementsByTagName(t)[0];if(i){return[].slice.call(i.querySelectorAll(r))}return[]}function collectionToDictionary(e){return e.reduce((function(e,t){var r=t.getAttribute("xml:id");if(r){e[r]=t}return e}),{})}function getTextContent(e,t){return[].slice.call(e.childNodes).reduce((function(e,r,i){var a;if(r.nodeName==="br"&&i){return e+"\n"}if((a=r.childNodes)!=null&&a.length){return getTextContent(r,t)}else if(t){return e+r.textContent.trim().replace(/\s+/g," ")}return e+r.textContent}),"")}function getTtmlStyles(e,t,r){var i="http://www.w3.org/ns/ttml#styling";var a=null;var n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];var s=e!=null&&e.hasAttribute("style")?e.getAttribute("style"):null;if(s&&r.hasOwnProperty(s)){a=r[s]}return n.reduce((function(r,n){var s=getAttributeNS(t,i,n)||getAttributeNS(e,i,n)||getAttributeNS(a,i,n);if(s){r[n]=s}return r}),{})}function getAttributeNS(e,t,r){if(!e){return null}return e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function timestampParsingError(e){return new Error("Could not parse ttml timestamp ".concat(e))}function parseTtmlTime(e,t){if(!e){return null}var r=parseTimeStamp(e);if(r===null){if(HMSF_REGEX.test(e)){r=parseHoursMinutesSecondsFrames(e,t)}else if(TIME_UNIT_REGEX.test(e)){r=parseTimeUnits(e,t)}}return r}function parseHoursMinutesSecondsFrames(e,t){var r=HMSF_REGEX.exec(e);var i=(r[4]|0)+(r[5]|0)/t.subFrameRate;return(r[1]|0)*3600+(r[2]|0)*60+(r[3]|0)+i/t.frameRate}function parseTimeUnits(e,t){var r=TIME_UNIT_REGEX.exec(e);var i=Number(r[1]);var a=r[2];switch(a){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}var TimelineController=function(){function e(e){this.hls=void 0;this.media=null;this.config=void 0;this.enabled=true;this.Cues=void 0;this.textTracks=[];this.tracks=[];this.initPTS=[];this.unparsedVttFrags=[];this.captionsTracks={};this.nonNativeCaptionsTracks={};this.cea608Parser1=void 0;this.cea608Parser2=void 0;this.lastSn=-1;this.lastPartIndex=-1;this.prevCC=-1;this.vttCCs=newVTTCCs();this.captionsProperties=void 0;this.hls=e;this.config=e.config;this.Cues=e.config.cueHandler;this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}};if(this.config.enableCEA708Captions){var t=new OutputFilter(this,"textTrack1");var r=new OutputFilter(this,"textTrack2");var i=new OutputFilter(this,"textTrack3");var a=new OutputFilter(this,"textTrack4");this.cea608Parser1=new Cea608Parser(1,t,r);this.cea608Parser2=new Cea608Parser(3,i,a)}e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this);e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this);e.on(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);e.on(Events.FRAG_LOADING,this.onFragLoading,this);e.on(Events.FRAG_LOADED,this.onFragLoaded,this);e.on(Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this);e.on(Events.FRAG_DECRYPTED,this.onFragDecrypted,this);e.on(Events.INIT_PTS_FOUND,this.onInitPtsFound,this);e.on(Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this);e.on(Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}e.prototype.destroy=function(){var e=this.hls;e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this);e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this);e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this);e.off(Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);e.off(Events.FRAG_LOADING,this.onFragLoading,this);e.off(Events.FRAG_LOADED,this.onFragLoaded,this);e.off(Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this);e.off(Events.FRAG_DECRYPTED,this.onFragDecrypted,this);e.off(Events.INIT_PTS_FOUND,this.onInitPtsFound,this);e.off(Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this);e.off(Events.BUFFER_FLUSHING,this.onBufferFlushing,this);this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null};e.prototype.addCues=function(e,t,r,i,a){var n=false;for(var s=a.length;s--;){var o=a[s];var l=intersection(o[0],o[1],t,r);if(l>=0){o[0]=Math.min(o[0],t);o[1]=Math.max(o[1],r);n=true;if(l/(r-t)>.5){return}}}if(!n){a.push([t,r])}if(this.config.renderTextTracksNatively){var u=this.captionsTracks[e];this.Cues.newCue(u,t,r,i)}else{var f=this.Cues.newCue(null,t,r,i);this.hls.trigger(Events.CUES_PARSED,{type:"captions",cues:f,track:e})}};e.prototype.onInitPtsFound=function(e,t){var r=this;var i=t.frag,a=t.id,n=t.initPTS,s=t.timescale;var o=this.unparsedVttFrags;if(a==="main"){this.initPTS[i.cc]={baseTime:n,timescale:s}}if(o.length){this.unparsedVttFrags=[];o.forEach((function(e){r.onFragLoaded(Events.FRAG_LOADED,e)}))}};e.prototype.getExistingTrack=function(e){var t=this.media;if(t){for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e]){return i}}}return null};e.prototype.createCaptionsTrack=function(e){if(this.config.renderTextTracksNatively){this.createNativeTrack(e)}else{this.createNonNativeTrack(e)}};e.prototype.createNativeTrack=function(e){if(this.captionsTracks[e]){return}var t=this,r=t.captionsProperties,i=t.captionsTracks,a=t.media;var n=r[e],s=n.label,o=n.languageCode;var l=this.getExistingTrack(e);if(!l){var u=this.createTextTrack("captions",s,o);if(u){u[e]=true;i[e]=u}}else{i[e]=l;clearCurrentCues(i[e]);sendAddTrackEvent(i[e],a)}};e.prototype.createNonNativeTrack=function(e){if(this.nonNativeCaptionsTracks[e]){return}var t=this.captionsProperties[e];if(!t){return}var r=t.label;var i={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:false,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i;this.hls.trigger(Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})};e.prototype.createTextTrack=function(e,t,r){var i=this.media;if(!i){return}return i.addTextTrack(e,t,r)};e.prototype.onMediaAttaching=function(e,t){this.media=t.media;this._cleanTracks()};e.prototype.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){clearCurrentCues(e[t]);delete e[t]}));this.nonNativeCaptionsTracks={}};e.prototype.onManifestLoading=function(){this.lastSn=-1;this.lastPartIndex=-1;this.prevCC=-1;this.vttCCs=newVTTCCs();this._cleanTracks();this.tracks=[];this.captionsTracks={};this.nonNativeCaptionsTracks={};this.textTracks=[];this.unparsedVttFrags=[];this.initPTS=[];if(this.cea608Parser1&&this.cea608Parser2){this.cea608Parser1.reset();this.cea608Parser2.reset()}};e.prototype._cleanTracks=function(){var e=this.media;if(!e){return}var t=e.textTracks;if(t){for(var r=0;r<t.length;r++){clearCurrentCues(t[r])}}};e.prototype.onSubtitleTracksUpdated=function(e,t){var r=this;var i=t.subtitleTracks||[];var a=i.some((function(e){return e.textCodec===IMSC1_CODEC}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var n=subtitleOptionsIdentical(this.tracks,i);if(n){this.tracks=i;return}this.textTracks=[];this.tracks=i;if(this.config.renderTextTracksNatively){var s=this.media?this.media.textTracks:null;this.tracks.forEach((function(e,t){var i;if(s&&t<s.length){var a=null;for(var n=0;n<s.length;n++){if(canReuseVttTextTrack(s[n],e)){a=s[n];break}}if(a){i=a}}if(i){clearCurrentCues(i)}else{var o=r._captionsOrSubtitlesFromCharacteristics(e);i=r.createTextTrack(o,e.name,e.lang);if(i){i.mode="disabled"}}if(i){i.groupId=e.groupId;r.textTracks.push(i)}}))}else if(this.tracks.length){var o=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}};e.prototype._captionsOrSubtitlesFromCharacteristics=function(e){if(e.attrs.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS);var r=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&r){return"captions"}}return"subtitles"};e.prototype.onManifestLoaded=function(e,t){var r=this;if(this.config.enableCEA708Captions&&t.captions){t.captions.forEach((function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t){return}var i="textTrack".concat(t[1]);var a=r.captionsProperties[i];if(!a){return}a.label=e.name;if(e.lang){a.languageCode=e.lang}a.media=e}))}};e.prototype.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]};e.prototype.onFragLoading=function(e,t){var r=this,i=r.cea608Parser1,a=r.cea608Parser2,n=r.lastSn,s=r.lastPartIndex;if(!this.enabled||!(i&&a)){return}if(t.frag.type===PlaylistLevelType.MAIN){var o,l;var u=t.frag.sn;var f=(o=t==null?void 0:(l=t.part)==null?void 0:l.index)!=null?o:-1;if(!(u===n+1||u===n&&f===s+1)){i.reset();a.reset()}this.lastSn=u;this.lastPartIndex=f}};e.prototype.onFragLoaded=function(e,t){var r=t.frag,i=t.payload;if(r.type===PlaylistLevelType.SUBTITLE){if(i.byteLength){var a=r.decryptdata;var n="stats"in t;if(a==null||!a.encrypted||n){var s=this.tracks[r.level];var o=this.vttCCs;if(!o[r.cc]){o[r.cc]={start:r.start,prevCC:this.prevCC,new:true};this.prevCC=r.cc}if(s&&s.textCodec===IMSC1_CODEC){this._parseIMSC1(r,i)}else{this._parseVTTs(t)}}}else{this.hls.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:false,frag:r,error:new Error("Empty subtitle payload")})}}};e.prototype._parseIMSC1=function(e,t){var r=this;var i=this.hls;parseIMSC1(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level);i.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:true,frag:e})}),(function(t){logger.log("Failed to parse IMSC1: ".concat(t));i.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:false,frag:e,error:t})}))};e.prototype._parseVTTs=function(e){var t=this;var r;var i=e.frag,a=e.payload;var n=this,s=n.initPTS,o=n.unparsedVttFrags;var l=s.length-1;if(!s[i.cc]&&l===-1){o.push(e);return}var u=this.hls;var f=(r=i.initSegment)!=null&&r.data?appendUint8Array(i.initSegment.data,new Uint8Array(a)):a;parseWebVTT(f,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(function(e){t._appendCues(e,i.level);u.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:true,frag:i})}),(function(r){var n=r.message==="Missing initPTS for VTT MPEGTS";if(n){o.push(e)}else{t._fallbackToIMSC1(i,a)}logger.log("Failed to parse VTT cue: ".concat(r));if(n&&l>i.cc){return}u.trigger(Events.SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:r})}))};e.prototype._fallbackToIMSC1=function(e,t){var r=this;var i=this.tracks[e.level];if(!i.textCodec){parseIMSC1(t,this.initPTS[e.cc],(function(){i.textCodec=IMSC1_CODEC;r._parseIMSC1(e,t)}),(function(){i.textCodec="wvtt"}))}};e.prototype._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||i.mode==="disabled"){return}e.forEach((function(e){return addCueToTrack(i,e)}))}else{var a=this.tracks[t];if(!a){return}var n=a.default?"default":"subtitles"+t;r.trigger(Events.CUES_PARSED,{type:"subtitles",cues:e,track:n})}};e.prototype.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===PlaylistLevelType.SUBTITLE){this.onFragLoaded(Events.FRAG_LOADED,t)}};e.prototype.onSubtitleTracksCleared=function(){this.tracks=[];this.captionsTracks={}};e.prototype.onFragParsingUserdata=function(e,t){var r=this,i=r.cea608Parser1,a=r.cea608Parser2;if(!this.enabled||!(i&&a)){return}var n=t.frag,s=t.samples;if(n.type===PlaylistLevelType.MAIN&&this.closedCaptionsForLevel(n)==="NONE"){return}for(var o=0;o<s.length;o++){var l=s[o].bytes;if(l){var u=this.extractCea608Data(l);i.addData(s[o].pts,u[0]);a.addData(s[o].pts,u[1])}}};e.prototype.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.endOffsetSubtitles,n=t.type;var s=this.media;if(!s||s.currentTime<i){return}if(!n||n==="video"){var o=this.captionsTracks;Object.keys(o).forEach((function(e){return removeCuesInRange(o[e],r,i)}))}if(this.config.renderTextTracksNatively){if(r===0&&a!==undefined){var l=this.textTracks;Object.keys(l).forEach((function(e){return removeCuesInRange(l[e],r,a)}))}}};e.prototype.extractCea608Data=function(e){var t=[[],[]];var r=e[0]&31;var i=2;for(var a=0;a<r;a++){var n=e[i++];var s=127&e[i++];var o=127&e[i++];if(s===0&&o===0){continue}var l=(4&n)!==0;if(l){var u=3&n;if(0===u||1===u){t[u].push(s);t[u].push(o)}}}return t};return e}();function canReuseVttTextTrack(e,t){return!!e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}function intersection(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}function newVTTCCs(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:true}}}var CapLevelController=function(){function e(e){this.hls=void 0;this.autoLevelCapping=void 0;this.firstLevel=void 0;this.media=void 0;this.restrictedLevels=void 0;this.timer=void 0;this.clientRect=void 0;this.streamController=void 0;this.hls=e;this.autoLevelCapping=Number.POSITIVE_INFINITY;this.firstLevel=-1;this.media=null;this.restrictedLevels=[];this.timer=undefined;this.clientRect=null;this.registerListeners()}e.prototype.setStreamController=function(e){this.streamController=e};e.prototype.destroy=function(){this.unregisterListener();if(this.hls.config.capLevelToPlayerSize){this.stopCapping()}this.media=null;this.clientRect=null;this.hls=this.streamController=null};e.prototype.registerListeners=function(){var e=this.hls;e.on(Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this);e.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this);e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.on(Events.BUFFER_CODECS,this.onBufferCodecs,this);e.on(Events.MEDIA_DETACHING,this.onMediaDetaching,this)};e.prototype.unregisterListener=function(){var e=this.hls;e.off(Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this);e.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this);e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.off(Events.BUFFER_CODECS,this.onBufferCodecs,this);e.off(Events.MEDIA_DETACHING,this.onMediaDetaching,this)};e.prototype.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];if(this.isLevelAllowed(r)){this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}};e.prototype.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null;this.clientRect=null};e.prototype.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[];this.firstLevel=t.firstLevel;if(r.config.capLevelToPlayerSize&&t.video){this.startCapping()}};e.prototype.onBufferCodecs=function(e,t){var r=this.hls;if(r.config.capLevelToPlayerSize&&t.video){this.startCapping()}};e.prototype.onMediaDetaching=function(){this.stopCapping()};e.prototype.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1);if(t.autoLevelCapping>this.autoLevelCapping&&this.streamController){this.streamController.nextLevelSwitch()}this.autoLevelCapping=t.autoLevelCapping}}};e.prototype.getMaxLevel=function(t){var r=this;var i=this.hls.levels;if(!i.length){return-1}var a=i.filter((function(e,i){return r.isLevelAllowed(e)&&i<=t}));this.clientRect=null;return e.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)};e.prototype.startCapping=function(){if(this.timer){return}this.autoLevelCapping=Number.POSITIVE_INFINITY;this.hls.firstLevel=this.getMaxLevel(this.firstLevel);self.clearInterval(this.timer);this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3);this.detectPlayerSize()};e.prototype.stopCapping=function(){this.restrictedLevels=[];this.firstLevel=-1;this.autoLevelCapping=Number.POSITIVE_INFINITY;if(this.timer){self.clearInterval(this.timer);this.timer=undefined}};e.prototype.getDimensions=function(){if(this.clientRect){return this.clientRect}var e=this.media;var t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width;t.height=r.height;if(!t.width&&!t.height){t.width=r.right-r.left||e.width||0;t.height=r.bottom-r.top||e.height||0}}this.clientRect=t;return t};Object.defineProperty(e.prototype,"mediaWidth",{get:function(){return this.getDimensions().width*this.contentScaleFactor},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"mediaHeight",{get:function(){return this.getDimensions().height*this.contentScaleFactor},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"contentScaleFactor",{get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio){try{e=self.devicePixelRatio}catch(e){}}return e},enumerable:false,configurable:true});e.prototype.isLevelAllowed=function(e){var t=this.restrictedLevels;return!t.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))};e.getMaxLevelByMediaSize=function(e,t,r){if(!(e!=null&&e.length)){return-1}var i=function(e,t){if(!t){return true}return e.width!==t.width||e.height!==t.height};var a=e.length-1;for(var n=0;n<e.length;n+=1){var s=e[n];if((s.width>=t||s.height>=r)&&i(s,e[n+1])){a=n;break}}return a};return e}();var FPSController=function(){function e(e){this.hls=void 0;this.isVideoPlaybackQualityAvailable=false;this.timer=void 0;this.media=null;this.lastTime=void 0;this.lastDroppedFrames=0;this.lastDecodedFrames=0;this.streamController=void 0;this.hls=e;this.registerListeners()}e.prototype.setStreamController=function(e){this.streamController=e};e.prototype.registerListeners=function(){this.hls.on(Events.MEDIA_ATTACHING,this.onMediaAttaching,this)};e.prototype.unregisterListeners=function(){this.hls.off(Events.MEDIA_ATTACHING,this.onMediaAttaching,this)};e.prototype.destroy=function(){if(this.timer){clearInterval(this.timer)}this.unregisterListeners();this.isVideoPlaybackQualityAvailable=false;this.media=null};e.prototype.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i;if(i&&typeof i.getVideoPlaybackQuality==="function"){this.isVideoPlaybackQualityAvailable=true}self.clearInterval(this.timer);this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}};e.prototype.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime;var n=r-this.lastDroppedFrames;var s=t-this.lastDecodedFrames;var o=1e3*n/a;var l=this.hls;l.trigger(Events.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r});if(o>0){if(n>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u);if(u>0&&(l.autoLevelCapping===-1||l.autoLevelCapping>=u)){u=u-1;l.trigger(Events.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel});l.autoLevelCapping=u;this.streamController.nextLevelSwitch()}}}}this.lastTime=i;this.lastDroppedFrames=r;this.lastDecodedFrames=t}};e.prototype.checkFPSInterval=function(){var e=this.media;if(e){if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else{this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}};return e}();var LOGGER_PREFIX="[eme]";var EMEController=function(){function e(t){this.hls=void 0;this.config=void 0;this.media=null;this.keyFormatPromise=null;this.keySystemAccessPromises={};this._requestLicenseFailureCount=0;this.mediaKeySessions=[];this.keyIdToKeySessionPromise={};this.setMediaKeysQueue=e.CDMCleanupPromise?[e.CDMCleanupPromise]:[];this.onMediaEncrypted=this._onMediaEncrypted.bind(this);this.onWaitingForKey=this._onWaitingForKey.bind(this);this.debug=logger.debug.bind(logger,LOGGER_PREFIX);this.log=logger.log.bind(logger,LOGGER_PREFIX);this.warn=logger.warn.bind(logger,LOGGER_PREFIX);this.error=logger.error.bind(logger,LOGGER_PREFIX);this.hls=t;this.config=t.config;this.registerListeners()}e.prototype.destroy=function(){this.unregisterListeners();this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null;e.licenseXhrSetup=e.licenseResponseCallback=undefined;e.drmSystems=e.drmSystemOptions={};this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null;this.config=null};e.prototype.registerListeners=function(){this.hls.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.on(Events.MEDIA_DETACHED,this.onMediaDetached,this);this.hls.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);this.hls.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this)};e.prototype.unregisterListeners=function(){this.hls.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.off(Events.MEDIA_DETACHED,this.onMediaDetached,this);this.hls.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);this.hls.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this)};e.prototype.getLicenseServerUrl=function(e){var t=this.config,r=t.drmSystems,i=t.widevineLicenseUrl;var a=r[e];if(a){return a.licenseUrl}if(e===KeySystems.WIDEVINE&&i){return i}throw new Error('no license server URL configured for key-system "'.concat(e,'"'))};e.prototype.getServerCertificateUrl=function(e){var t=this.config.drmSystems;var r=t[e];if(r){return r.serverCertificateUrl}else{this.log('No Server Certificate in config.drmSystems["'.concat(e,'"]'))}};e.prototype.attemptKeySystemAccess=function(e){var t=this;var r=this.hls.levels;var i=function(e,t,r){return!!e&&r.indexOf(e)===t};var a=r.map((function(e){return e.audioCodec})).filter(i);var n=r.map((function(e){return e.videoCodec})).filter(i);if(a.length+n.length===0){n.push("avc1.42e01e")}return new Promise((function(r,i){var s=function(e){var o=e.shift();t.getMediaKeysPromise(o,a,n).then((function(e){return r({keySystem:o,mediaKeys:e})})).catch((function(t){if(e.length){s(e)}else if(t instanceof EMEKeyError){i(t)}else{i(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:t,fatal:true},t.message))}}))};s(e)}))};e.prototype.requestMediaKeySystemAccess=function(e,t){var r=this.config.requestMediaKeySystemAccessFunc;if(!(typeof r==="function")){var i="Configured requestMediaKeySystemAccess is not a function ".concat(r);if(requestMediaKeySystemAccess===null&&self.location.protocol==="http:"){i="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)}return Promise.reject(new Error(i))}return r(e,t)};e.prototype.getMediaKeysPromise=function(e,t,r){var i=this;var a=getSupportedMediaKeySystemConfigurations(e,t,r,this.config.drmSystemOptions);var n=this.keySystemAccessPromises[e];var s=n==null?void 0:n.keySystemAccess;if(!s){this.log('Requesting encrypted media "'.concat(e,'" key-system access with config: ').concat(JSON.stringify(a)));s=this.requestMediaKeySystemAccess(e,a);var o=this.keySystemAccessPromises[e]={keySystemAccess:s};s.catch((function(t){i.log('Failed to obtain access to key-system "'.concat(e,'": ').concat(t))}));return s.then((function(t){i.log('Access for key-system "'.concat(t.keySystem,'" obtained'));var r=i.fetchServerCertificate(e);i.log('Create media-keys for "'.concat(e,'"'));o.mediaKeys=t.createMediaKeys().then((function(t){i.log('Media-keys created for "'.concat(e,'"'));return r.then((function(r){if(r){return i.setMediaKeysServerCertificate(t,e,r)}return t}))}));o.mediaKeys.catch((function(t){i.error('Failed to create media-keys for "'.concat(e,'"}: ').concat(t))}));return o.mediaKeys}))}return s.then((function(){return n.mediaKeys}))};e.prototype.createMediaKeySessionContext=function(e){var t=e.decryptdata,r=e.keySystem,i=e.mediaKeys;this.log('Creating key-system session "'.concat(r,'" keyId: ').concat(Hex.hexDump(t.keyId||[])));var a=i.createSession();var n={decryptdata:t,keySystem:r,mediaKeys:i,mediaKeysSession:a,keyStatus:"status-pending"};this.mediaKeySessions.push(n);return n};e.prototype.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e);var i=this.getKeyIdString(t);var a="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,a,t.pssh,"expired")}else{this.warn("Could not renew expired session. Missing pssh initData.")}this.removeSession(e)};e.prototype.getKeyIdString=function(e){if(!e){throw new Error("Could not read keyId of undefined decryptdata")}if(e.keyId===null){throw new Error("keyId is null")}return Hex.hexDump(e.keyId)};e.prototype.updateKeySession=function(e,t){var r;var i=e.mediaKeysSession;this.log('Updating key-session "'.concat(i.sessionId,'" for keyID ').concat(Hex.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[]),"\n } (data length: ").concat(t?t.byteLength:t,")"));return i.update(t)};e.prototype.selectKeySystemFormat=function(e){var t=Object.keys(e.levelkeys||{});if(!this.keyFormatPromise){this.log("Selecting key-system from fragment (sn: ".concat(e.sn," ").concat(e.type,": ").concat(e.level,") key formats ").concat(t.join(", ")));this.keyFormatPromise=this.getKeyFormatPromise(t)}return this.keyFormatPromise};e.prototype.getKeyFormatPromise=function(e){var t=this;return new Promise((function(r,i){var a=getKeySystemsForConfig(t.config);var n=e.map(keySystemFormatToKeySystemDomain).filter((function(e){return!!e&&a.indexOf(e)!==-1}));return t.getKeySystemSelectionPromise(n).then((function(e){var t=e.keySystem;var a=keySystemDomainToKeySystemFormat(t);if(a){r(a)}else{i(new Error('Unable to find format for key-system "'.concat(t,'"')))}})).catch(i)}))};e.prototype.loadKey=function(e){var t=this;var r=e.keyInfo.decryptdata;var i=this.getKeyIdString(r);var a="(keyId: ".concat(i,' format: "').concat(r.keyFormat,'" method: ').concat(r.method," uri: ").concat(r.uri,")");this.log("Starting session for key ".concat(a));var n=this.keyIdToKeySessionPromise[i];if(!n){n=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then((function(i){var n=i.keySystem,s=i.mediaKeys;t.throwIfDestroyed();t.log("Handle encrypted media sn: ".concat(e.frag.sn," ").concat(e.frag.type,": ").concat(e.frag.level," using key ").concat(a));return t.attemptSetMediaKeys(n,s).then((function(){t.throwIfDestroyed();var e=t.createMediaKeySessionContext({keySystem:n,mediaKeys:s,decryptdata:r});var i="cenc";return t.generateRequestWithPreferredKeySession(e,i,r.pssh,"playlist-key")}))}));n.catch((function(e){return t.handleError(e)}))}return n};e.prototype.throwIfDestroyed=function(e){if(e===void 0){e="Invalid state"}if(!this.hls){throw new Error("invalid state")}};e.prototype.handleError=function(e){if(!this.hls){return}this.error(e.message);if(e instanceof EMEKeyError){this.hls.trigger(Events.ERROR,e.data)}else{this.hls.trigger(Events.ERROR,{type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:true})}};e.prototype.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e);var r=this.keyIdToKeySessionPromise[t];if(!r){var i=keySystemFormatToKeySystemDomain(e.keyFormat);var a=i?[i]:getKeySystemsForConfig(this.config);return this.attemptKeySystemAccess(a)}return r};e.prototype.getKeySystemSelectionPromise=function(e){if(!e.length){e=getKeySystemsForConfig(this.config)}if(e.length===0){throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:true},"Missing key-system license configuration options ".concat(JSON.stringify({drmSystems:this.config.drmSystems})))}return this.attemptKeySystemAccess(e)};e.prototype._onMediaEncrypted=function(e){var t=this;var r=e.initDataType,i=e.initData;this.debug('"'.concat(e.type,'" event: init data type: "').concat(r,'"'));if(i===null){return}var a;var n;if(r==="sinf"&&this.config.drmSystems[KeySystems.FAIRPLAY]){var s=bin2str(new Uint8Array(i));try{var o=base64Decode(JSON.parse(s).sinf);var l=parseSinf(new Uint8Array(o));if(!l){return}a=l.subarray(8,24);n=KeySystems.FAIRPLAY}catch(e){this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var u=parsePssh(i);if(u===null){return}if(u.version===0&&u.systemId===KeySystemIds.WIDEVINE&&u.data){a=u.data.subarray(8,24)}n=keySystemIdToKeySystemDomain(u.systemId)}if(!n||!a){return}var f=Hex.hexDump(a);var c=this,d=c.keyIdToKeySessionPromise,h=c.mediaKeySessions;var v=d[f];var p=function(e){var n=h[e];var s=n.decryptdata;if(s.pssh||!s.keyId){return"continue"}var o=Hex.hexDump(s.keyId);if(f===o||s.uri.replace(/-/g,"").indexOf(f)!==-1){v=d[o];delete d[o];s.pssh=new Uint8Array(i);s.keyId=a;v=d[f]=v.then((function(){return t.generateRequestWithPreferredKeySession(n,r,i,"encrypted-event-key-match")}));return"break"}};for(var g=0;g<h.length;g++){var m=p(g);if(m==="break")break}if(!v){v=d[f]=this.getKeySystemSelectionPromise([n]).then((function(e){var n=e.keySystem,s=e.mediaKeys;var o;t.throwIfDestroyed();var l=new LevelKey("ISO-23001-7",f,(o=keySystemDomainToKeySystemFormat(n))!=null?o:"");l.pssh=new Uint8Array(i);l.keyId=a;return t.attemptSetMediaKeys(n,s).then((function(){t.throwIfDestroyed();var e=t.createMediaKeySessionContext({decryptdata:l,keySystem:n,mediaKeys:s});return t.generateRequestWithPreferredKeySession(e,r,i,"encrypted-event-no-match")}))}))}v.catch((function(e){return t.handleError(e)}))};e.prototype._onWaitingForKey=function(e){this.log('"'.concat(e.type,'" event'))};e.prototype.attemptSetMediaKeys=function(e,t){var r=this;var i=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'.concat(e,'"'));var a=Promise.all(i).then((function(){if(!r.media){throw new Error("Attempted to set mediaKeys without media element attached")}return r.media.setMediaKeys(t)}));this.setMediaKeysQueue.push(a);return a.then((function(){r.log('Media-keys set for "'.concat(e,'"'));i.push(a);r.setMediaKeysQueue=r.setMediaKeysQueue.filter((function(e){return i.indexOf(e)===-1}))}))};e.prototype.generateRequestWithPreferredKeySession=function(e,t,r,i){var a=this;var n,s;var o=(n=this.config.drmSystems)==null?void 0:(s=n[e.keySystem])==null?void 0:s.generateRequest;if(o){try{var l=o.call(this.hls,t,r,e);if(!l){throw new Error("Invalid response from configured generateRequest filter")}t=l.initDataType;r=e.decryptdata.pssh=l.initData?new Uint8Array(l.initData):null}catch(e){var u;this.warn(e.message);if((u=this.hls)!=null&&u.config.debug){throw e}}}if(r===null){this.log('Skipping key-session request for "'.concat(i,'" (no initData)'));return Promise.resolve(e)}var f=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'.concat(i,'": ').concat(f," (init data type: ").concat(t," length: ").concat(r?r.byteLength:null,")"));var c=new EventEmitter;e.mediaKeysSession.onmessage=function(t){var r=e.mediaKeysSession;if(!r){c.emit("error",new Error("invalid state"));return}var i=t.messageType,n=t.message;a.log('"'.concat(i,'" message event for session "').concat(r.sessionId,'" message size: ').concat(n.byteLength));if(i==="license-request"||i==="license-renewal"){a.renewLicense(e,n).catch((function(e){a.handleError(e);c.emit("error",e)}))}else if(i==="license-release"){if(e.keySystem===KeySystems.FAIRPLAY){a.updateKeySession(e,strToUtf8array("acknowledged"));a.removeSession(e)}}else{a.warn('unhandled media key message type "'.concat(i,'"'))}};e.mediaKeysSession.onkeystatuseschange=function(t){var r=e.mediaKeysSession;if(!r){c.emit("error",new Error("invalid state"));return}a.onKeyStatusChange(e);var i=e.keyStatus;c.emit("keyStatus",i);if(i==="expired"){a.warn("".concat(e.keySystem," expired for key ").concat(f));a.renewKeySession(e)}};var d=new Promise((function(e,t){c.on("error",t);c.on("keyStatus",(function(r){if(r.startsWith("usable")){e()}else if(r==="output-restricted"){t(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:false},"HDCP level output restricted"))}else if(r==="internal-error"){t(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:true},'key status changed to "'.concat(r,'"')))}else if(r==="expired"){t(new Error("key expired while generating request"))}else{a.warn('unhandled key status change "'.concat(r,'"'))}}))}));return e.mediaKeysSession.generateRequest(t,r).then((function(){var t;a.log('Request generated for key-session "'.concat((t=e.mediaKeysSession)==null?void 0:t.sessionId,'" keyId: ').concat(f))})).catch((function(e){throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_NO_SESSION,error:e,fatal:false},"Error generating key-session request: ".concat(e))})).then((function(){return d})).catch((function(t){c.removeAllListeners();a.removeSession(e);throw t})).then((function(){c.removeAllListeners();return e}))};e.prototype.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach((function(r,i){t.log('key status change "'.concat(r,'" for keyStatuses keyId: ').concat(Hex.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))," session keyId: ").concat(Hex.hexDump(new Uint8Array(e.decryptdata.keyId||[]))," uri: ").concat(e.decryptdata.uri));e.keyStatus=r}))};e.prototype.fetchServerCertificate=function(e){var t=this.config;var r=t.loader;var i=new r(t);var a=this.getServerCertificateUrl(e);if(!a){return Promise.resolve()}this.log('Fetching serverCertificate for "'.concat(e,'"'));return new Promise((function(r,n){var s={responseType:"arraybuffer",url:a};var o=t.certLoadPolicy.default;var l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0};var u={onSuccess:function(e,t,i,a){r(e.data)},onError:function(t,r,i,o){n(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:i,response:_objectSpread2({url:s.url,data:undefined},t)},'"'.concat(e,'" certificate request failed (').concat(a,"). Status: ").concat(t.code," (").concat(t.text,")")))},onTimeout:function(t,r,i){n(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:true,networkDetails:i,response:{url:s.url,data:undefined}},'"'.concat(e,'" certificate request timed out (').concat(a,")")))},onAbort:function(e,t,r){n(new Error("aborted"))}};i.load(s,l,u)}))};e.prototype.setMediaKeysServerCertificate=function(e,t,r){var i=this;return new Promise((function(a,n){e.setServerCertificate(r).then((function(n){i.log("setServerCertificate ".concat(n?"success":"not supported by CDM"," (").concat(r==null?void 0:r.byteLength,') on "').concat(t,'"'));a(e)})).catch((function(e){n(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:true},e.message))}))}))};e.prototype.renewLicense=function(e,t){var r=this;return this.requestLicense(e,new Uint8Array(t)).then((function(t){return r.updateKeySession(e,new Uint8Array(t)).catch((function(e){throw new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:true},e.message)}))}))};e.prototype.setupLicenseXHR=function(e,t,r,i){var a=this;var n=this.config.licenseXhrSetup;if(!n){e.open("POST",t,true);return Promise.resolve({xhr:e,licenseChallenge:i})}return Promise.resolve().then((function(){if(!r.decryptdata){throw new Error("Key removed")}return n.call(a.hls,e,t,r,i)})).catch((function(s){if(!r.decryptdata){throw s}e.open("POST",t,true);return n.call(a.hls,e,t,r,i)})).then((function(r){if(!e.readyState){e.open("POST",t,true)}var a=r?r:i;return{xhr:e,licenseChallenge:a}}))};e.prototype.requestLicense=function(e,t){var r=this;var i=this.config.keyLoadPolicy.default;return new Promise((function(a,n){var s=r.getLicenseServerUrl(e.keySystem);r.log("Sending license request to URL: ".concat(s));var o=new XMLHttpRequest;o.responseType="arraybuffer";o.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession){return n(new Error("invalid state"))}if(o.readyState===4){if(o.status===200){r._requestLicenseFailureCount=0;var l=o.response;r.log("License received ".concat(l instanceof ArrayBuffer?l.byteLength:l));var u=r.config.licenseResponseCallback;if(u){try{l=u.call(r.hls,o,s,e)}catch(e){r.error(e)}}a(l)}else{var f=i.errorRetry;var c=f?f.maxNumRetry:0;r._requestLicenseFailureCount++;if(r._requestLicenseFailureCount>c||o.status>=400&&o.status<500){n(new EMEKeyError({type:ErrorTypes.KEY_SYSTEM_ERROR,details:ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:true,networkDetails:o,response:{url:s,data:undefined,code:o.status,text:o.statusText}},"License Request XHR failed (".concat(s,"). Status: ").concat(o.status," (").concat(o.statusText,")")))}else{var d=c-r._requestLicenseFailureCount+1;r.warn("Retrying license request, ".concat(d," attempts left"));r.requestLicense(e,t).then(a,n)}}}};if(e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE){e.licenseXhr.abort()}e.licenseXhr=o;r.setupLicenseXHR(o,s,e,t).then((function(e){var t=e.xhr,r=e.licenseChallenge;t.send(r)}))}))};e.prototype.onMediaAttached=function(e,t){if(!this.config.emeEnabled){return}var r=t.media;this.media=r;r.addEventListener("encrypted",this.onMediaEncrypted);r.addEventListener("waitingforkey",this.onWaitingForKey)};e.prototype.onMediaDetached=function(){var t=this;var r=this.media;var i=this.mediaKeySessions;if(r){r.removeEventListener("encrypted",this.onMediaEncrypted);r.removeEventListener("waitingforkey",this.onWaitingForKey);this.media=null}this._requestLicenseFailureCount=0;this.setMediaKeysQueue=[];this.mediaKeySessions=[];this.keyIdToKeySessionPromise={};LevelKey.clearKeyUriToKeyIdMap();var a=i.length;e.CDMCleanupPromise=Promise.all(i.map((function(e){return t.removeSession(e)})).concat(r==null?void 0:r.setMediaKeys(null).catch((function(e){t.log("Could not clear media keys: ".concat(e,". media.src: ").concat(r==null?void 0:r.src))})))).then((function(){if(a){t.log("finished closing key sessions and clearing media keys");i.length=0}})).catch((function(e){t.log("Could not close sessions and clear media keys: ".concat(e,". media.src: ").concat(r==null?void 0:r.src))}))};e.prototype.onManifestLoading=function(){this.keyFormatPromise=null};e.prototype.onManifestLoaded=function(e,t){var r=t.sessionKeys;if(!r||!this.config.emeEnabled){return}if(!this.keyFormatPromise){var i=r.reduce((function(e,t){if(e.indexOf(t.keyFormat)===-1){e.push(t.keyFormat)}return e}),[]);this.log("Selecting key-system from session-keys ".concat(i.join(", ")));this.keyFormatPromise=this.getKeyFormatPromise(i)}};e.prototype.removeSession=function(e){var t=this;var r=e.mediaKeysSession,i=e.licenseXhr;if(r){this.log("Remove licenses and keys and close session ".concat(r.sessionId));r.onmessage=null;r.onkeystatuseschange=null;if(i&&i.readyState!==XMLHttpRequest.DONE){i.abort()}e.mediaKeysSession=e.decryptdata=e.licenseXhr=undefined;var a=this.mediaKeySessions.indexOf(e);if(a>-1){this.mediaKeySessions.splice(a,1)}return r.remove().catch((function(e){t.log("Could not remove session: ".concat(e))})).then((function(){return r.close()})).catch((function(e){t.log("Could not close session: ".concat(e))}))}};return e}();EMEController.CDMCleanupPromise=void 0;var EMEKeyError=function(e){__extends(t,e);function t(t,r){var i=e.call(this,r)||this;i.data=void 0;t.error||(t.error=new Error(r));i.data=t;t.err=t.error;return i}return t}(Error);var CMCDVersion=1;var CMCDObjectType={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};var CMCDStreamingFormatHLS="h";var CMCDController=function(){function e(t){var r=this;this.hls=void 0;this.config=void 0;this.media=void 0;this.sid=void 0;this.cid=void 0;this.useHeaders=false;this.initialized=false;this.starved=false;this.buffering=true;this.audioBuffer=void 0;this.videoBuffer=void 0;this.onWaiting=function(){if(r.initialized){r.starved=true}r.buffering=true};this.onPlaying=function(){if(!r.initialized){r.initialized=true}r.buffering=false};this.applyPlaylistData=function(e){try{r.apply(e,{ot:CMCDObjectType.MANIFEST,su:!r.initialized})}catch(e){logger.warn("Could not generate manifest CMCD data.",e)}};this.applyFragmentData=function(e){try{var t=e.frag;var i=r.hls.levels[t.level];var a=r.getObjectType(t);var n={d:t.duration*1e3,ot:a};if(a===CMCDObjectType.VIDEO||a===CMCDObjectType.AUDIO||a==CMCDObjectType.MUXED){n.br=i.bitrate/1e3;n.tb=r.getTopBandwidth(a)/1e3;n.bl=r.getBufferLength(a)}r.apply(e,n)}catch(e){logger.warn("Could not generate segment CMCD data.",e)}};this.hls=t;var i=this.config=t.config;var a=i.cmcd;if(a!=null){i.pLoader=this.createPlaylistLoader();i.fLoader=this.createFragmentLoader();this.sid=a.sessionId||e.uuid();this.cid=a.contentId;this.useHeaders=a.useHeaders===true;this.registerListeners()}}e.prototype.registerListeners=function(){var e=this.hls;e.on(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.on(Events.MEDIA_DETACHED,this.onMediaDetached,this);e.on(Events.BUFFER_CREATED,this.onBufferCreated,this)};e.prototype.unregisterListeners=function(){var e=this.hls;e.off(Events.MEDIA_ATTACHED,this.onMediaAttached,this);e.off(Events.MEDIA_DETACHED,this.onMediaDetached,this);e.off(Events.BUFFER_CREATED,this.onBufferCreated,this)};e.prototype.destroy=function(){this.unregisterListeners();this.onMediaDetached();this.hls=this.config=this.audioBuffer=this.videoBuffer=null};e.prototype.onMediaAttached=function(e,t){this.media=t.media;this.media.addEventListener("waiting",this.onWaiting);this.media.addEventListener("playing",this.onPlaying)};e.prototype.onMediaDetached=function(){if(!this.media){return}this.media.removeEventListener("waiting",this.onWaiting);this.media.removeEventListener("playing",this.onPlaying);this.media=null};e.prototype.onBufferCreated=function(e,t){var r,i;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer;this.videoBuffer=(i=t.tracks.video)==null?void 0:i.buffer};e.prototype.createData=function(){var e;return{v:CMCDVersion,sf:CMCDStreamingFormatHLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}};e.prototype.apply=function(t,r){if(r===void 0){r={}}_extends(r,this.createData());var i=r.ot===CMCDObjectType.INIT||r.ot===CMCDObjectType.VIDEO||r.ot===CMCDObjectType.MUXED;if(this.starved&&i){r.bs=true;r.su=true;this.starved=false}if(r.su==null){r.su=this.buffering}if(this.useHeaders){var a=e.toHeaders(r);if(!Object.keys(a).length){return}if(!t.headers){t.headers={}}_extends(t.headers,a)}else{var n=e.toQuery(r);if(!n){return}t.url=e.appendQueryToUri(t.url,n)}};e.prototype.getObjectType=function(e){var t=e.type;if(t==="subtitle"){return CMCDObjectType.TIMED_TEXT}if(e.sn==="initSegment"){return CMCDObjectType.INIT}if(t==="audio"){return CMCDObjectType.AUDIO}if(t==="main"){if(!this.hls.audioTracks.length){return CMCDObjectType.MUXED}return CMCDObjectType.VIDEO}return undefined};e.prototype.getTopBandwidth=function(e){var t=0;var r;var i=this.hls;if(e===CMCDObjectType.AUDIO){r=i.audioTracks}else{var a=i.maxAutoLevel;var n=a>-1?a+1:i.levels.length;r=i.levels.slice(0,n)}for(var s=0,o=r;s<o.length;s++){var l=o[s];if(l.bitrate>t){t=l.bitrate}}return t>0?t:NaN};e.prototype.getBufferLength=function(e){var t=this.hls.media;var r=e===CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!t){return NaN}var i=BufferHelper.bufferInfo(r,t.currentTime,this.config.maxBufferHole);return i.len*1e3};e.prototype.createPlaylistLoader=function(){var e=this.config.pLoader;var t=this.applyPlaylistData;var r=e||this.config.loader;return function(){function e(e){this.loader=void 0;this.loader=new r(e)}Object.defineProperty(e.prototype,"stats",{get:function(){return this.loader.stats},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"context",{get:function(){return this.loader.context},enumerable:false,configurable:true});e.prototype.destroy=function(){this.loader.destroy()};e.prototype.abort=function(){this.loader.abort()};e.prototype.load=function(e,r,i){t(e);this.loader.load(e,r,i)};return e}()};e.prototype.createFragmentLoader=function(){var e=this.config.fLoader;var t=this.applyFragmentData;var r=e||this.config.loader;return function(){function e(e){this.loader=void 0;this.loader=new r(e)}Object.defineProperty(e.prototype,"stats",{get:function(){return this.loader.stats},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"context",{get:function(){return this.loader.context},enumerable:false,configurable:true});e.prototype.destroy=function(){this.loader.destroy()};e.prototype.abort=function(){this.loader.abort()};e.prototype.load=function(e,r,i){t(e);this.loader.load(e,r,i)};return e}()};e.uuid=function(){var e=URL.createObjectURL(new Blob);var t=e.toString();URL.revokeObjectURL(e);return t.slice(t.lastIndexOf("/")+1)};e.serialize=function(e){var t=[];var r=function(e){return!Number.isNaN(e)&&e!=null&&e!==""&&e!==false};var i=function(e){return Math.round(e)};var a=function(e){return i(e/100)*100};var n=function(e){return encodeURIComponent(e)};var s={br:i,d:i,bl:a,dl:a,mtp:a,nor:n,rtp:a,tb:i};var o=Object.keys(e||{}).sort();for(var l=0,u=o;l<u.length;l++){var f=u[l];var c=e[f];if(!r(c)){continue}if(f==="v"&&c===1){continue}if(f=="pr"&&c===1){continue}var d=s[f];if(d){c=d(c)}var h=typeof c;var v=void 0;if(f==="ot"||f==="sf"||f==="st"){v="".concat(f,"=").concat(c)}else if(h==="boolean"){v=f}else if(h==="number"){v="".concat(f,"=").concat(c)}else{v="".concat(f,"=").concat(JSON.stringify(c))}t.push(v)}return t.join(",")};e.toHeaders=function(t){var r=Object.keys(t);var i={};var a=["Object","Request","Session","Status"];var n=[{},{},{},{}];var s={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(var o=0,l=r;o<l.length;o++){var u=l[o];var f=s[u]!=null?s[u]:1;n[f][u]=t[u]}for(var c=0;c<n.length;c++){var d=e.serialize(n[c]);if(d){i["CMCD-".concat(a[c])]=d}}return i};e.toQuery=function(t){return"CMCD=".concat(encodeURIComponent(e.serialize(t)))};e.appendQueryToUri=function(e,t){if(!t){return e}var r=e.includes("?")?"&":"?";return"".concat(e).concat(r).concat(t)};return e}();var PATHWAY_PENALTY_DURATION_MS=3e5;var ContentSteeringController=function(){function e(e){this.hls=void 0;this.log=void 0;this.loader=null;this.uri=null;this.pathwayId=".";this.pathwayPriority=null;this.timeToLoad=300;this.reloadTimer=-1;this.updated=0;this.started=false;this.enabled=true;this.levels=null;this.audioTracks=null;this.subtitleTracks=null;this.penalizedPathways={};this.hls=e;this.log=logger.log.bind(logger,"[content-steering]:");this.registerListeners()}e.prototype.registerListeners=function(){var e=this.hls;e.on(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.on(Events.MANIFEST_LOADED,this.onManifestLoaded,this);e.on(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.on(Events.ERROR,this.onError,this)};e.prototype.unregisterListeners=function(){var e=this.hls;if(!e){return}e.off(Events.MANIFEST_LOADING,this.onManifestLoading,this);e.off(Events.MANIFEST_LOADED,this.onManifestLoaded,this);e.off(Events.MANIFEST_PARSED,this.onManifestParsed,this);e.off(Events.ERROR,this.onError,this)};e.prototype.startLoad=function(){this.started=true;self.clearTimeout(this.reloadTimer);if(this.enabled&&this.uri){if(this.updated){var e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else{this.loadSteeringManifest(this.uri)}}};e.prototype.stopLoad=function(){this.started=false;if(this.loader){this.loader.destroy();this.loader=null}self.clearTimeout(this.reloadTimer)};e.prototype.destroy=function(){this.unregisterListeners();this.stopLoad();this.hls=null;this.levels=this.audioTracks=this.subtitleTracks=null};e.prototype.removeLevel=function(e){var t=this.levels;if(t){this.levels=t.filter((function(t){return t!==e}))}};e.prototype.onManifestLoading=function(){this.stopLoad();this.enabled=true;this.timeToLoad=300;this.updated=0;this.uri=null;this.pathwayId=".";this.levels=this.audioTracks=this.subtitleTracks=null};e.prototype.onManifestLoaded=function(e,t){var r=t.contentSteering;if(r===null){return}this.pathwayId=r.pathwayId;this.uri=r.uri;if(this.started){this.startLoad()}};e.prototype.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks;this.subtitleTracks=t.subtitleTracks};e.prototype.onError=function(e,t){var r=t.errorAction;if((r==null?void 0:r.action)===NetworkErrorAction.SendAlternateToPenaltyBox&&r.flags===ErrorActionFlags.MoveAllAlternatesMatchingHost){var i=this.pathwayPriority;var a=this.pathwayId;if(!this.penalizedPathways[a]){this.penalizedPathways[a]=performance.now()}if(!i&&this.levels){i=this.levels.reduce((function(e,t){if(e.indexOf(t.pathwayId)===-1){e.push(t.pathwayId)}return e}),[])}if(i&&i.length>1){this.updatePathwayPriority(i);r.resolved=this.pathwayId!==a}}};e.prototype.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "').concat(r,'"'));t=this.getLevelsForPathway(r);this.pathwayId=r}if(t.length!==e.length){this.log("Found ".concat(t.length,"/").concat(e.length,' levels in Pathway "').concat(this.pathwayId,'"'));return t}return e};e.prototype.getLevelsForPathway=function(e){if(this.levels===null){return[]}return this.levels.filter((function(t){return e===t.pathwayId}))};e.prototype.updatePathwayPriority=function(e){this.pathwayPriority=e;var t;var r=this.penalizedPathways;var i=performance.now();Object.keys(r).forEach((function(e){if(i-r[e]>PATHWAY_PENALTY_DURATION_MS){delete r[e]}}));for(var a=0;a<e.length;a++){var n=e[a];if(r[n]){continue}if(n===this.pathwayId){return}var s=this.hls.nextLoadLevel;var o=this.hls.levels[s];t=this.getLevelsForPathway(n);if(t.length>0){this.log('Setting Pathway to "'.concat(n,'"'));this.pathwayId=n;this.hls.trigger(Events.LEVELS_UPDATED,{levels:t});var l=this.hls.levels[s];if(o&&l&&this.levels){if(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate){this.log("Unstable Pathways change from bitrate ".concat(o.bitrate," to ").concat(l.bitrate))}this.hls.nextLoadLevel=s}break}}};e.prototype.clonePathways=function(e){var t=this;var r=this.levels;if(!r){return}var i={};var a={};e.forEach((function(e){var n=e.ID,s=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(r.some((function(e){return e.pathwayId===n}))){return}var l=t.getLevelsForPathway(s).map((function(e){var t=_extends({},e);t.details=undefined;t.url=performUriReplacement(e.uri,e.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o);var r=new AttrList(e.attrs);r["PATHWAY-ID"]=n;var s=r.AUDIO&&"".concat(r.AUDIO,"_clone_").concat(n);var l=r.SUBTITLES&&"".concat(r.SUBTITLES,"_clone_").concat(n);if(s){i[r.AUDIO]=s;r.AUDIO=s}if(l){a[r.SUBTITLES]=l;r.SUBTITLES=l}t.attrs=r;var u=new Level(t);addGroupId(u,"audio",s);addGroupId(u,"text",l);return u}));r.push.apply(r,l);cloneRenditionGroups(t.audioTracks,i,o,n);cloneRenditionGroups(t.subtitleTracks,a,o,n)}))};e.prototype.loadSteeringManifest=function(e){var t=this;var r=this.hls.config;var i=r.loader;if(this.loader){this.loader.destroy()}this.loader=new i(r);var a;try{a=new self.URL(e)}catch(t){this.enabled=false;this.log("Failed to parse Steering Manifest URI: ".concat(e));return}if(a.protocol!=="data:"){var n=(this.hls.bandwidthEstimate||r.abrEwmaDefaultEstimate)|0;a.searchParams.set("_HLS_pathway",this.pathwayId);a.searchParams.set("_HLS_throughput",""+n)}var s={responseType:"json",url:a.href};var o=r.steeringManifestLoadPolicy.default;var l=o.errorRetry||o.timeoutRetry||{};var u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0};var f={onSuccess:function(e,r,i,n){t.log('Loaded steering manifest: "'.concat(a,'"'));var s=e.data;if(s.VERSION!==1){t.log("Steering VERSION ".concat(s.VERSION," not supported!"));return}t.updated=performance.now();t.timeToLoad=s.TTL;var o=s["RELOAD-URI"],l=s["PATHWAY-CLONES"],u=s["PATHWAY-PRIORITY"];if(o){try{t.uri=new self.URL(o,a).href}catch(e){t.enabled=false;t.log("Failed to parse Steering Manifest RELOAD-URI: ".concat(o));return}}t.scheduleRefresh(t.uri||i.url);if(l){t.clonePathways(l)}if(u){t.updatePathwayPriority(u)}},onError:function(e,r,i,a){t.log("Error loading steering manifest: ".concat(e.code," ").concat(e.text," (").concat(r.url,")"));t.stopLoad();if(e.code===410){t.enabled=false;t.log("Steering manifest ".concat(r.url," no longer available"));return}var n=t.timeToLoad*1e3;if(e.code===429){var s=t.loader;if(typeof(s==null?void 0:s.getResponseHeader)==="function"){var o=s.getResponseHeader("Retry-After");if(o){n=parseFloat(o)*1e3}}t.log("Steering manifest ".concat(r.url," rate limited"));return}t.scheduleRefresh(t.uri||r.url,n)},onTimeout:function(e,r,i){t.log("Timeout loading steering manifest (".concat(r.url,")"));t.scheduleRefresh(t.uri||r.url)}};this.log("Requesting steering manifest: ".concat(a));this.loader.load(s,u,f)};e.prototype.scheduleRefresh=function(e,t){var r=this;if(t===void 0){t=this.timeToLoad*1e3}self.clearTimeout(this.reloadTimer);this.reloadTimer=self.setTimeout((function(){r.loadSteeringManifest(e)}),t)};return e}();function cloneRenditionGroups(e,t,r,i){if(!e){return}Object.keys(t).forEach((function(a){var n=e.filter((function(e){return e.groupId===a})).map((function(e){var n=_extends({},e);n.details=undefined;n.attrs=new AttrList(n.attrs);n.url=n.attrs.URI=performUriReplacement(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r);n.groupId=n.attrs["GROUP-ID"]=t[a];n.attrs["PATHWAY-ID"]=i;return n}));e.push.apply(e,n)}))}function performUriReplacement(e,t,r,i){var a=i,n=a.HOST,s=a.PARAMS,o=r,l=a[o];var u;if(t){u=l==null?void 0:l[t];if(u){e=u}}var f=new self.URL(e);if(n&&!u){f.host=n}if(s){Object.keys(s).sort().forEach((function(e){if(e){f.searchParams.set(e,s[e])}}))}return f.href}var AGE_HEADER_LINE_REGEX=/^age:\s*[\d.]+\s*$/im;var XhrLoader=function(){function e(e){this.xhrSetup=void 0;this.requestTimeout=void 0;this.retryTimeout=void 0;this.retryDelay=void 0;this.config=null;this.callbacks=null;this.context=void 0;this.loader=null;this.stats=void 0;this.xhrSetup=e?e.xhrSetup||null:null;this.stats=new LoadStats;this.retryDelay=0}e.prototype.destroy=function(){this.callbacks=null;this.abortInternal();this.loader=null;this.config=null};e.prototype.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout);self.clearTimeout(this.retryTimeout);if(e){e.onreadystatechange=null;e.onprogress=null;if(e.readyState!==4){this.stats.aborted=true;e.abort()}}};e.prototype.abort=function(){var e;this.abortInternal();if((e=this.callbacks)!=null&&e.onAbort){this.callbacks.onAbort(this.stats,this.context,this.loader)}};e.prototype.load=function(e,t,r){if(this.stats.loading.start){throw new Error("Loader can only be used once.")}this.stats.loading.start=self.performance.now();this.context=e;this.config=t;this.callbacks=r;this.loadInternal()};e.prototype.loadInternal=function(){var e=this;var t=this,r=t.config,i=t.context;if(!r){return}var a=this.loader=new self.XMLHttpRequest;var n=this.stats;n.loading.first=0;n.loaded=0;n.aborted=false;var s=this.xhrSetup;if(s){Promise.resolve().then((function(){if(e.stats.aborted)return;return s(a,i.url)})).catch((function(e){a.open("GET",i.url,true);return s(a,i.url)})).then((function(){if(e.stats.aborted)return;e.openAndSendXhr(a,i,r)})).catch((function(t){e.callbacks.onError({code:a.status,text:t.message},i,a,n);return}))}else{this.openAndSendXhr(a,i,r)}};e.prototype.openAndSendXhr=function(e,t,r){if(!e.readyState){e.open("GET",t.url,true)}var i=this.context.headers;var a=r.loadPolicy,n=a.maxTimeToFirstByteMs,s=a.maxLoadTimeMs;if(i){for(var o in i){e.setRequestHeader(o,i[o])}}if(t.rangeEnd){e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1))}e.onreadystatechange=this.readystatechange.bind(this);e.onprogress=this.loadprogress.bind(this);e.responseType=t.responseType;self.clearTimeout(this.requestTimeout);r.timeout=n&&isFiniteNumber(n)?n:s;this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout);e.send()};e.prototype.readystatechange=function(){var e=this,t=e.context,r=e.loader,i=e.stats;if(!t||!r){return}var a=r.readyState;var n=this.config;if(i.aborted){return}if(a>=2){if(i.loading.first===0){i.loading.first=Math.max(self.performance.now(),i.loading.start);if(n.timeout!==n.loadPolicy.maxLoadTimeMs){self.clearTimeout(this.requestTimeout);n.timeout=n.loadPolicy.maxLoadTimeMs;this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start))}}if(a===4){self.clearTimeout(this.requestTimeout);r.onreadystatechange=null;r.onprogress=null;var s=r.status;var o=r.responseType!=="text";if(s>=200&&s<300&&(o&&r.response||r.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);var l=o?r.response:r.responseText;var u=r.responseType==="arraybuffer"?l.byteLength:l.length;i.loaded=i.total=u;i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first);if(!this.callbacks){return}var f=this.callbacks.onProgress;if(f){f(i,t,l,r)}if(!this.callbacks){return}var c={url:r.responseURL,data:l,code:s};this.callbacks.onSuccess(c,i,t,r)}else{var d=n.loadPolicy.errorRetry;var h=i.retry;if(shouldRetry(d,h,false,s)){this.retry(d)}else{logger.error("".concat(s," while loading ").concat(t.url));this.callbacks.onError({code:s,text:r.statusText},t,r,i)}}}}};e.prototype.loadtimeout=function(){var e;var t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry;var r=this.stats.retry;if(shouldRetry(t,r,true)){this.retry(t)}else{logger.warn("timeout while loading ".concat(this.context.url));var i=this.callbacks;if(i){this.abortInternal();i.onTimeout(this.stats,this.context,this.loader)}}};e.prototype.retry=function(e){var t=this,r=t.context,i=t.stats;this.retryDelay=getRetryDelay(e,i.retry);i.retry++;logger.warn("".concat(status?"HTTP Status "+status:"Timeout"," while loading ").concat(r.url,", retrying ").concat(i.retry,"/").concat(e.maxNumRetry," in ").concat(this.retryDelay,"ms"));this.abortInternal();this.loader=null;self.clearTimeout(this.retryTimeout);this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)};e.prototype.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded;if(e.lengthComputable){t.total=e.total}};e.prototype.getCacheAge=function(){var e=null;if(this.loader&&AGE_HEADER_LINE_REGEX.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e};e.prototype.getResponseHeader=function(e){if(this.loader&&new RegExp("^".concat(e,":\\s*[\\d.]+\\s*$"),"im").test(this.loader.getAllResponseHeaders())){return this.loader.getResponseHeader(e)}return null};return e}();function fetchSupported(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request){try{new self.ReadableStream({});return true}catch(e){}}return false}var BYTERANGE=/(\d+)-(\d+)\/(\d+)/;var FetchLoader=function(){function e(e){this.fetchSetup=void 0;this.requestTimeout=void 0;this.request=void 0;this.response=void 0;this.controller=void 0;this.context=void 0;this.config=null;this.callbacks=null;this.stats=void 0;this.loader=null;this.fetchSetup=e.fetchSetup||getRequest;this.controller=new self.AbortController;this.stats=new LoadStats}e.prototype.destroy=function(){this.loader=this.callbacks=null;this.abortInternal()};e.prototype.abortInternal=function(){var e=this.response;if(!(e!=null&&e.ok)){this.stats.aborted=true;this.controller.abort()}};e.prototype.abort=function(){var e;this.abortInternal();if((e=this.callbacks)!=null&&e.onAbort){this.callbacks.onAbort(this.stats,this.context,this.response)}};e.prototype.load=function(e,t,r){var i=this;var a=this.stats;if(a.loading.start){throw new Error("Loader can only be used once.")}a.loading.start=self.performance.now();var n=getRequestParameters(e,this.controller.signal);var s=r.onProgress;var o=e.responseType==="arraybuffer";var l=o?"byteLength":"length";var u=t.loadPolicy,f=u.maxTimeToFirstByteMs,c=u.maxLoadTimeMs;this.context=e;this.config=t;this.callbacks=r;this.request=this.fetchSetup(e,n);self.clearTimeout(this.requestTimeout);t.timeout=f&&isFiniteNumber(f)?f:c;this.requestTimeout=self.setTimeout((function(){i.abortInternal();r.onTimeout(a,e,i.response)}),t.timeout);self.fetch(this.request).then((function(n){i.response=i.loader=n;var l=Math.max(self.performance.now(),a.loading.start);self.clearTimeout(i.requestTimeout);t.timeout=c;i.requestTimeout=self.setTimeout((function(){i.abortInternal();r.onTimeout(a,e,i.response)}),c-(l-a.loading.start));if(!n.ok){var u=n.status,f=n.statusText;throw new FetchError(f||"fetch, bad network response",u,n)}a.loading.first=l;a.total=getContentLength(n.headers)||a.total;if(s&&isFiniteNumber(t.highWaterMark)){return i.loadProgressively(n,a,e,t.highWaterMark,s)}if(o){return n.arrayBuffer()}if(e.responseType==="json"){return n.json()}return n.text()})).then((function(n){var o=i.response;self.clearTimeout(i.requestTimeout);a.loading.end=Math.max(self.performance.now(),a.loading.first);var u=n[l];if(u){a.loaded=a.total=u}var f={url:o.url,data:n,code:o.status};if(s&&!isFiniteNumber(t.highWaterMark)){s(a,e,n,o)}r.onSuccess(f,a,e,o)})).catch((function(t){self.clearTimeout(i.requestTimeout);if(a.aborted){return}var n=!t?0:t.code||0;var s=!t?null:t.message;r.onError({code:n,text:s},e,t?t.details:null,a)}))};e.prototype.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e};e.prototype.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null};e.prototype.loadProgressively=function(e,t,r,i,a){if(i===void 0){i=0}var n=new ChunkCache;var s=e.body.getReader();var o=function(){return s.read().then((function(s){if(s.done){if(n.dataLength){a(t,r,n.flush(),e)}return Promise.resolve(new ArrayBuffer(0))}var l=s.value;var u=l.length;t.loaded+=u;if(u<i||n.dataLength){n.push(l);if(n.dataLength>=i){a(t,r,n.flush(),e)}}else{a(t,r,l,e)}return o()})).catch((function(){return Promise.reject()}))};return o()};return e}();function getRequestParameters(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(_extends({},e.headers))};if(e.rangeEnd){r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1))}return r}function getByteRangeLength(e){var t=BYTERANGE.exec(e);if(t){return parseInt(t[2])-parseInt(t[1])+1}}function getContentLength(e){var t=e.get("Content-Range");if(t){var r=getByteRangeLength(t);if(isFiniteNumber(r)){return r}}var i=e.get("Content-Length");if(i){return parseInt(i)}}function getRequest(e,t){return new self.Request(e.url,t)}var FetchError=function(e){__extends(t,e);function t(t,r,i){var a=e.call(this,t)||this;a.code=void 0;a.details=void 0;a.code=r;a.details=i;return a}return t}(Error);var WHITESPACE_CHAR=/\s/;var Cues={newCue:function(e,t,r,i){var a=[];var n;var s;var o;var l;var u;var f=self.VTTCue||self.TextTrackCue;for(var c=0;c<i.rows.length;c++){n=i.rows[c];o=true;l=0;u="";if(!n.isEmpty()){var d;for(var h=0;h<n.chars.length;h++){if(WHITESPACE_CHAR.test(n.chars[h].uchar)&&o){l++}else{u+=n.chars[h].uchar;o=false}}n.cueStartTime=t;if(t===r){r+=1e-4}if(l>=16){l--}else{l++}var v=fixLineBreaks(u.trim());var p=generateCueId(t,r,v);if(!(e!=null&&(d=e.cues)!=null&&d.getCueById(p))){s=new f(t,r,v);s.id=p;s.line=c+1;s.align="left";s.position=10+Math.min(80,Math.floor(l*8/32)*10);a.push(s)}}}if(e&&a.length){a.sort((function(e,t){if(e.line==="auto"||t.line==="auto"){return 0}if(e.line>8&&t.line>8){return t.line-e.line}return e.line-t.line}));a.forEach((function(t){return addCueToTrack(e,t)}))}return a}};var defaultLoadPolicy={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null};var hlsDefaultConfig=_objectSpread2(_objectSpread2({autoStartLoad:true,startPosition:-1,defaultAudioCodec:undefined,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize:false,ignoreDevicePixelRatio:false,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:Infinity,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:Infinity,liveSyncDuration:undefined,liveMaxLatencyDuration:undefined,maxLiveSyncPlaybackRate:1,liveDurationInfinity:false,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:true,workerPath:null,enableSoftwareAES:true,startLevel:undefined,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:XhrLoader,fLoader:undefined,pLoader:undefined,xhrSetup:undefined,licenseXhrSetup:undefined,licenseResponseCallback:undefined,abrController:AbrController,bufferController:BufferController,capLevelController:CapLevelController,errorController:ErrorController,fpsController:FPSController,stretchShortVideoTrack:false,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:true,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:false,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:false,widevineLicenseUrl:undefined,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:requestMediaKeySystemAccess,testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:undefined,enableDateRangeMetadataCues:true,enableEmsgMetadataCues:true,enableID3MetadataCues:true,certLoadPolicy:{default:defaultLoadPolicy},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:Infinity,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},timelineConfig()),{},{subtitleStreamController:SubtitleStreamController,subtitleTrackController:SubtitleTrackController,timelineController:TimelineController,audioStreamController:AudioStreamController,audioTrackController:AudioTrackController,emeController:EMEController,cmcdController:CMCDController,contentSteeringController:ContentSteeringController});function timelineConfig(){return{cueHandler:Cues,enableWebVTT:true,enableIMSC1:true,enableCEA708Captions:true,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:true}}function mergeConfig(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration)){throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration")}if(t.liveMaxLatencyDurationCount!==undefined&&(t.liveSyncDurationCount===undefined||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount)){throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"')}if(t.liveMaxLatencyDuration!==undefined&&(t.liveSyncDuration===undefined||t.liveMaxLatencyDuration<=t.liveSyncDuration)){throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"')}var r=deepCpy(e);var i=["manifest","level","frag"];var a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];i.forEach((function(e){var i="".concat(e==="level"?"playlist":e,"LoadPolicy");var n=t[i]===undefined;var s=[];a.forEach((function(a){var o="".concat(e,"Loading").concat(a);var l=t[o];if(l!==undefined&&n){s.push(o);var u=r[i].default;t[i]={default:u};switch(a){case"TimeOut":u.maxLoadTimeMs=l;u.maxTimeToFirstByteMs=l;break;case"MaxRetry":u.errorRetry.maxNumRetry=l;u.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":u.errorRetry.retryDelayMs=l;u.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=l;u.timeoutRetry.maxRetryDelayMs=l;break}}}));if(s.length){logger.warn('hls.js config: "'.concat(s.join('", "'),'" setting(s) are deprecated, use "').concat(i,'": ').concat(JSON.stringify(t[i])))}}));return _objectSpread2(_objectSpread2({},r),t)}function deepCpy(e){if(e&&typeof e==="object"){if(Array.isArray(e)){return e.map(deepCpy)}return Object.keys(e).reduce((function(t,r){t[r]=deepCpy(e[r]);return t}),{})}return e}function enableStreamingMode(e){var t=e.loader;if(t!==FetchLoader&&t!==XhrLoader){logger.log("[config]: Custom loader detected, cannot enable progressive streaming");e.progressive=false}else{var r=fetchSupported();if(r){e.loader=FetchLoader;e.progressive=true;e.enableSoftwareAES=true;logger.log("[config]: Progressive streaming enabled, using FetchLoader")}}}var Hls=function(){function e(t){if(t===void 0){t={}}this.config=void 0;this.userConfig=void 0;this.coreComponents=void 0;this.networkControllers=void 0;this._emitter=new EventEmitter;this._autoLevelCapping=void 0;this._maxHdcpLevel=null;this.abrController=void 0;this.bufferController=void 0;this.capLevelController=void 0;this.latencyController=void 0;this.levelController=void 0;this.streamController=void 0;this.audioTrackController=void 0;this.subtitleTrackController=void 0;this.emeController=void 0;this.cmcdController=void 0;this._media=null;this.url=null;enableLogs(t.debug||false,"Hls instance");var r=this.config=mergeConfig(e.DefaultConfig,t);this.userConfig=t;this._autoLevelCapping=-1;if(r.progressive){enableStreamingMode(r)}var i=r.abrController,a=r.bufferController,n=r.capLevelController,s=r.errorController,o=r.fpsController;var l=new s(this);var u=this.abrController=new i(this);var f=this.bufferController=new a(this);var c=this.capLevelController=new n(this);var d=new o(this);var h=new PlaylistLoader(this);var v=new ID3TrackController(this);var p=r.contentSteeringController;var g=p?new p(this):null;var m=this.levelController=new LevelController(this,g);var y=new FragmentTracker(this);var E=new KeyLoader(this.config);var T=this.streamController=new StreamController(this,y,E);c.setStreamController(T);d.setStreamController(T);var S=[h,m,T];if(g){S.splice(1,0,g)}this.networkControllers=S;var A=[u,f,c,d,v,y];this.audioTrackController=this.createController(r.audioTrackController,S);var L=r.audioStreamController;if(L){S.push(new L(this,y,E))}this.subtitleTrackController=this.createController(r.subtitleTrackController,S);var b=r.subtitleStreamController;if(b){S.push(new b(this,y,E))}this.createController(r.timelineController,A);E.emeController=this.emeController=this.createController(r.emeController,A);this.cmcdController=this.createController(r.cmcdController,A);this.latencyController=this.createController(LatencyController,A);this.coreComponents=A;S.push(l);var R=l.onErrorOut;if(typeof R==="function"){this.on(Events.ERROR,R,l)}}Object.defineProperty(e,"version",{get:function(){return"1.4.13"},enumerable:false,configurable:true});e.isSupported=function(){return isSupported()};Object.defineProperty(e,"Events",{get:function(){return Events},enumerable:false,configurable:true});Object.defineProperty(e,"ErrorTypes",{get:function(){return ErrorTypes},enumerable:false,configurable:true});Object.defineProperty(e,"ErrorDetails",{get:function(){return ErrorDetails},enumerable:false,configurable:true});Object.defineProperty(e,"DefaultConfig",{get:function(){if(!e.defaultConfig){return hlsDefaultConfig}return e.defaultConfig},set:function(t){e.defaultConfig=t},enumerable:false,configurable:true});e.prototype.createController=function(e,t){if(e){var r=new e(this);if(t){t.push(r)}return r}return null};e.prototype.on=function(e,t,r){if(r===void 0){r=this}this._emitter.on(e,t,r)};e.prototype.once=function(e,t,r){if(r===void 0){r=this}this._emitter.once(e,t,r)};e.prototype.removeAllListeners=function(e){this._emitter.removeAllListeners(e)};e.prototype.off=function(e,t,r,i){if(r===void 0){r=this}this._emitter.off(e,t,r,i)};e.prototype.listeners=function(e){return this._emitter.listeners(e)};e.prototype.emit=function(e,t,r){return this._emitter.emit(e,t,r)};e.prototype.trigger=function(e,t){if(this.config.debug){return this.emit(e,e,t)}else{try{return this.emit(e,e,t)}catch(t){logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t);this.trigger(Events.ERROR,{type:ErrorTypes.OTHER_ERROR,details:ErrorDetails.INTERNAL_EXCEPTION,fatal:false,event:e,error:t})}}return false};e.prototype.listenerCount=function(e){return this._emitter.listenerCount(e)};e.prototype.destroy=function(){logger.log("destroy");this.trigger(Events.DESTROYING,undefined);this.detachMedia();this.removeAllListeners();this._autoLevelCapping=-1;this.url=null;this.networkControllers.forEach((function(e){return e.destroy()}));this.networkControllers.length=0;this.coreComponents.forEach((function(e){return e.destroy()}));this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=undefined;this.userConfig=null};e.prototype.attachMedia=function(e){logger.log("attachMedia");this._media=e;this.trigger(Events.MEDIA_ATTACHING,{media:e})};e.prototype.detachMedia=function(){logger.log("detachMedia");this.trigger(Events.MEDIA_DETACHING,undefined);this._media=null};e.prototype.loadSource=function(e){this.stopLoad();var t=this.media;var r=this.url;var i=this.url=urlToolkitExports.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:true});logger.log("loadSource:".concat(i));if(t&&r&&(r!==i||this.bufferController.hasSourceTypes())){this.detachMedia();this.attachMedia(t)}this.trigger(Events.MANIFEST_LOADING,{url:e})};e.prototype.startLoad=function(e){if(e===void 0){e=-1}logger.log("startLoad(".concat(e,")"));this.networkControllers.forEach((function(t){t.startLoad(e)}))};e.prototype.stopLoad=function(){logger.log("stopLoad");this.networkControllers.forEach((function(e){e.stopLoad()}))};e.prototype.swapAudioCodec=function(){logger.log("swapAudioCodec");this.streamController.swapAudioCodec()};e.prototype.recoverMediaError=function(){logger.log("recoverMediaError");var e=this._media;this.detachMedia();if(e){this.attachMedia(e)}};e.prototype.removeLevel=function(e,t){if(t===void 0){t=0}this.levelController.removeLevel(e,t)};Object.defineProperty(e.prototype,"levels",{get:function(){var e=this.levelController.levels;return e?e:[]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"currentLevel",{get:function(){return this.streamController.currentLevel},set:function(e){logger.log("set currentLevel:".concat(e));this.loadLevel=e;this.abrController.clearTimer();this.streamController.immediateLevelSwitch()},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"nextLevel",{get:function(){return this.streamController.nextLevel},set:function(e){logger.log("set nextLevel:".concat(e));this.levelController.manualLevel=e;this.streamController.nextLevelSwitch()},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"loadLevel",{get:function(){return this.levelController.level},set:function(e){logger.log("set loadLevel:".concat(e));this.levelController.manualLevel=e},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"nextLoadLevel",{get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"firstLevel",{get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){logger.log("set firstLevel:".concat(e));this.levelController.firstLevel=e},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"startLevel",{get:function(){return this.levelController.startLevel},set:function(e){logger.log("set startLevel:".concat(e));if(e!==-1){e=Math.max(e,this.minAutoLevel)}this.levelController.startLevel=e},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"capLevelToPlayerSize",{get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;if(t!==this.config.capLevelToPlayerSize){if(t){this.capLevelController.startCapping()}else{this.capLevelController.stopCapping();this.autoLevelCapping=-1;this.streamController.nextLevelSwitch()}this.config.capLevelToPlayerSize=t}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"autoLevelCapping",{get:function(){return this._autoLevelCapping},set:function(e){if(this._autoLevelCapping!==e){logger.log("set autoLevelCapping:".concat(e));this._autoLevelCapping=e}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"bandwidthEstimate",{get:function(){var e=this.abrController.bwEstimator;if(!e){return NaN}return e.getEstimate()},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"ttfbEstimate",{get:function(){var e=this.abrController.bwEstimator;if(!e){return NaN}return e.getEstimateTTFB()},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"maxHdcpLevel",{get:function(){return this._maxHdcpLevel},set:function(e){if(HdcpLevels.indexOf(e)>-1){this._maxHdcpLevel=e}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"autoLevelEnabled",{get:function(){return this.levelController.manualLevel===-1},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"manualLevel",{get:function(){return this.levelController.manualLevel},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"minAutoLevel",{get:function(){var e=this,t=e.levels,r=e.config.minAutoBitrate;if(!t)return 0;var i=t.length;for(var a=0;a<i;a++){if(t[a].maxBitrate>=r){return a}}return 0},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"maxAutoLevel",{get:function(){var e=this,t=e.levels,r=e.autoLevelCapping,i=e.maxHdcpLevel;var a;if(r===-1&&t&&t.length){a=t.length-1}else{a=r}if(i){for(var n=a;n--;){var s=t[n].attrs["HDCP-LEVEL"];if(s&&s<=i){return n}}}return a},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"nextAutoLevel",{get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"playingDate",{get:function(){return this.streamController.currentProgramDateTime},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"mainForwardBufferInfo",{get:function(){return this.streamController.getMainFwdBufferInfo()},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"audioTracks",{get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"audioTrack",{get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;if(t){t.audioTrack=e}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"subtitleTracks",{get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"subtitleTrack",{get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;if(t){t.subtitleTrack=e}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"media",{get:function(){return this._media},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"subtitleDisplay",{get:function(){var e=this.subtitleTrackController;return e?e.subtitleDisplay:false},set:function(e){var t=this.subtitleTrackController;if(t){t.subtitleDisplay=e}},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"lowLatencyMode",{get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"liveSyncPosition",{get:function(){return this.latencyController.liveSyncPosition},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"latency",{get:function(){return this.latencyController.latency},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"maxLatency",{get:function(){return this.latencyController.maxLatency},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"targetLatency",{get:function(){return this.latencyController.targetLatency},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"drift",{get:function(){return this.latencyController.drift},enumerable:false,configurable:true});Object.defineProperty(e.prototype,"forceStartLoad",{get:function(){return this.streamController.forceStartLoad},enumerable:false,configurable:true});return e}();Hls.defaultConfig=void 0;export default Hls;