@tarojs/components 3.6.1 → 3.6.2-canary.1

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 (1254) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/helper-db78e01a.js +0 -2
  3. package/dist/cjs/hls-67cbc62d.js +0 -2
  4. package/dist/cjs/index-dfd8638f.js +0 -2
  5. package/dist/cjs/index-e1b469cd.js +0 -2
  6. package/dist/cjs/index-f9d21cc5.js +0 -2
  7. package/dist/cjs/index.cjs.js +0 -2
  8. package/dist/cjs/intersection-observer-dc4cfcef.js +0 -2
  9. package/dist/cjs/loader.cjs.js +1 -3
  10. package/dist/cjs/taro-ad-core.cjs.entry.js +0 -2
  11. package/dist/cjs/taro-ad-custom-core.cjs.entry.js +0 -2
  12. package/dist/cjs/taro-animation-video-core.cjs.entry.js +0 -2
  13. package/dist/cjs/taro-animation-view-core.cjs.entry.js +0 -2
  14. package/dist/cjs/taro-ar-camera-core.cjs.entry.js +0 -2
  15. package/dist/cjs/taro-audio-core.cjs.entry.js +0 -2
  16. package/dist/cjs/taro-aweme-data-core.cjs.entry.js +0 -2
  17. package/dist/cjs/taro-block-core.cjs.entry.js +0 -2
  18. package/dist/cjs/taro-button-core.cjs.entry.js +0 -2
  19. package/dist/cjs/taro-camera-core.cjs.entry.js +0 -2
  20. package/dist/cjs/taro-canvas-core.cjs.entry.js +0 -2
  21. package/dist/cjs/taro-channel-live-core.cjs.entry.js +21 -0
  22. package/dist/cjs/taro-channel-video-core.cjs.entry.js +21 -0
  23. package/dist/cjs/taro-checkbox-core_2.cjs.entry.js +0 -2
  24. package/dist/cjs/taro-comment-detail-core.cjs.entry.js +0 -2
  25. package/dist/cjs/taro-comment-list-core.cjs.entry.js +0 -2
  26. package/dist/cjs/taro-components.cjs.js +1 -3
  27. package/dist/cjs/taro-contact-button-core.cjs.entry.js +0 -2
  28. package/dist/cjs/taro-cover-image-core.cjs.entry.js +0 -2
  29. package/dist/cjs/taro-cover-view-core.cjs.entry.js +0 -2
  30. package/dist/cjs/taro-custom-wrapper-core.cjs.entry.js +0 -2
  31. package/dist/cjs/taro-editor-core.cjs.entry.js +0 -2
  32. package/dist/cjs/taro-follow-swan-core.cjs.entry.js +0 -2
  33. package/dist/cjs/taro-form-core.cjs.entry.js +0 -2
  34. package/dist/cjs/taro-functional-page-navigator-core.cjs.entry.js +0 -2
  35. package/dist/cjs/taro-grid-view-core.cjs.entry.js +21 -0
  36. package/dist/cjs/taro-icon-core.cjs.entry.js +0 -2
  37. package/dist/cjs/taro-image-core.cjs.entry.js +0 -2
  38. package/dist/cjs/taro-inline-payment-panel-core.cjs.entry.js +0 -2
  39. package/dist/cjs/taro-input-core.cjs.entry.js +0 -2
  40. package/dist/cjs/taro-keyboard-accessory-core.cjs.entry.js +0 -2
  41. package/dist/cjs/taro-label-core.cjs.entry.js +0 -2
  42. package/dist/cjs/taro-lifestyle-core.cjs.entry.js +0 -2
  43. package/dist/cjs/taro-like-core.cjs.entry.js +0 -2
  44. package/dist/cjs/taro-list-view-core.cjs.entry.js +21 -0
  45. package/dist/cjs/taro-live-player-core.cjs.entry.js +0 -2
  46. package/dist/cjs/taro-live-pusher-core.cjs.entry.js +0 -2
  47. package/dist/cjs/taro-login-core.cjs.entry.js +0 -2
  48. package/dist/cjs/taro-lottie-core.cjs.entry.js +0 -2
  49. package/dist/cjs/taro-map-core.cjs.entry.js +0 -2
  50. package/dist/cjs/taro-match-media-core.cjs.entry.js +0 -2
  51. package/dist/cjs/taro-movable-area-core_2.cjs.entry.js +0 -2
  52. package/dist/cjs/taro-native-slot-core.cjs.entry.js +0 -2
  53. package/dist/cjs/taro-navigation-bar-core.cjs.entry.js +0 -2
  54. package/dist/cjs/taro-navigator-core.cjs.entry.js +1 -3
  55. package/dist/cjs/taro-official-account-core.cjs.entry.js +0 -2
  56. package/dist/cjs/taro-open-data-core.cjs.entry.js +0 -2
  57. package/dist/cjs/taro-page-container-core.cjs.entry.js +0 -2
  58. package/dist/cjs/taro-page-meta-core.cjs.entry.js +0 -2
  59. package/dist/cjs/taro-picker-core_2.cjs.entry.js +3 -5
  60. package/dist/cjs/taro-picker-view-column-core_2.cjs.entry.js +0 -2
  61. package/dist/cjs/taro-progress-core.cjs.entry.js +0 -2
  62. package/dist/cjs/taro-pull-to-refresh.cjs.entry.js +0 -2
  63. package/dist/cjs/taro-radio-core_2.cjs.entry.js +0 -2
  64. package/dist/cjs/taro-rich-text-core.cjs.entry.js +0 -2
  65. package/dist/cjs/taro-root-portal-core.cjs.entry.js +0 -2
  66. package/dist/cjs/taro-rtc-room-core.cjs.entry.js +0 -2
  67. package/dist/cjs/taro-rtc-room-item-core.cjs.entry.js +0 -2
  68. package/dist/cjs/taro-scroll-view-core.cjs.entry.js +0 -2
  69. package/dist/cjs/taro-share-element-core.cjs.entry.js +0 -2
  70. package/dist/cjs/taro-slider-core.cjs.entry.js +0 -2
  71. package/dist/cjs/taro-slot-core.cjs.entry.js +0 -2
  72. package/dist/cjs/taro-sticky-header-core.cjs.entry.js +21 -0
  73. package/dist/cjs/taro-sticky-section-core.cjs.entry.js +21 -0
  74. package/dist/cjs/taro-swiper-core_2.cjs.entry.js +0 -2
  75. package/dist/cjs/taro-switch-core.cjs.entry.js +0 -2
  76. package/dist/cjs/taro-tab-item-core.cjs.entry.js +0 -2
  77. package/dist/cjs/taro-tabbar.cjs.entry.js +0 -2
  78. package/dist/cjs/taro-tabs-core.cjs.entry.js +0 -2
  79. package/dist/cjs/taro-text-core.cjs.entry.js +0 -2
  80. package/dist/cjs/taro-textarea-core.cjs.entry.js +11 -3
  81. package/dist/cjs/taro-video-control_3.cjs.entry.js +3 -3
  82. package/dist/cjs/taro-view-core.cjs.entry.js +0 -2
  83. package/dist/cjs/taro-voip-room-core.cjs.entry.js +0 -2
  84. package/dist/cjs/taro-web-view-core.cjs.entry.js +0 -2
  85. package/dist/collection/collection-manifest.json +6 -0
  86. package/dist/collection/components/ad/ad.js +0 -1
  87. package/dist/collection/components/ad-custom/ad-custom.js +0 -1
  88. package/dist/collection/components/animation-video/animation-video.js +0 -1
  89. package/dist/collection/components/animation-view/animation-view.js +0 -1
  90. package/dist/collection/components/ar-camera/ar-camera.js +0 -1
  91. package/dist/collection/components/audio/audio.js +0 -1
  92. package/dist/collection/components/aweme-data/aweme-data.js +0 -1
  93. package/dist/collection/components/block/block.js +0 -1
  94. package/dist/collection/components/button/button.js +0 -1
  95. package/dist/collection/components/camera/camera.js +0 -1
  96. package/dist/collection/components/canvas/canvas.js +0 -1
  97. package/dist/collection/components/channel-live/channel-live.js +11 -0
  98. package/dist/collection/components/channel-video/channel-video.js +11 -0
  99. package/dist/collection/components/checkbox/checkbox-group.js +0 -1
  100. package/dist/collection/components/checkbox/checkbox.js +0 -1
  101. package/dist/collection/components/comment/comment-detail.js +0 -1
  102. package/dist/collection/components/comment/comment-list.js +0 -1
  103. package/dist/collection/components/contact-button/contact-button.js +0 -1
  104. package/dist/collection/components/cover-image/cover-image.js +0 -1
  105. package/dist/collection/components/cover-view/cover-view.js +0 -1
  106. package/dist/collection/components/custom-wrapper/custom-wrapper.js +0 -1
  107. package/dist/collection/components/editor/editor.js +0 -1
  108. package/dist/collection/components/follow-swan/follow-swan.js +0 -1
  109. package/dist/collection/components/form/form.js +0 -1
  110. package/dist/collection/components/functional-page-navigator/functional-page-navigator.js +0 -1
  111. package/dist/collection/components/grid-view/grid-view.js +11 -0
  112. package/dist/collection/components/icon/icon.js +0 -1
  113. package/dist/collection/components/image/image.js +0 -1
  114. package/dist/collection/components/inline-payment-panel/inline-payment-panel.js +0 -1
  115. package/dist/collection/components/input/input.js +0 -1
  116. package/dist/collection/components/keyboard-accessory/keyboard-accessory.js +0 -1
  117. package/dist/collection/components/label/label.js +0 -1
  118. package/dist/collection/components/lifestyle/lifestyle.js +0 -1
  119. package/dist/collection/components/like/like.js +0 -1
  120. package/dist/collection/components/list-view/list-view.js +11 -0
  121. package/dist/collection/components/live-player/live-player.js +0 -1
  122. package/dist/collection/components/live-pusher/live-pusher.js +0 -1
  123. package/dist/collection/components/login/login.js +0 -1
  124. package/dist/collection/components/lottie/lottie.js +0 -1
  125. package/dist/collection/components/map/map.js +0 -1
  126. package/dist/collection/components/match-media/match-media.js +0 -1
  127. package/dist/collection/components/movable-area/movable-area.js +0 -1
  128. package/dist/collection/components/movable-area/movable-view.js +0 -1
  129. package/dist/collection/components/navigation-bar/navigation-bar.js +0 -1
  130. package/dist/collection/components/navigator/navigator.js +1 -2
  131. package/dist/collection/components/official-account/official-account.js +0 -1
  132. package/dist/collection/components/open-data/open-data.js +0 -1
  133. package/dist/collection/components/page-container/page-container.js +0 -1
  134. package/dist/collection/components/page-meta/page-meta.js +0 -1
  135. package/dist/collection/components/picker/constant.js +0 -1
  136. package/dist/collection/components/picker/picker-group.js +18 -7
  137. package/dist/collection/components/picker/picker.js +0 -1
  138. package/dist/collection/components/picker/utils.js +0 -1
  139. package/dist/collection/components/picker-view/picker-view-column.js +0 -1
  140. package/dist/collection/components/picker-view/picker-view.js +0 -1
  141. package/dist/collection/components/progress/progress.js +0 -1
  142. package/dist/collection/components/pull-to-refresh/pull-to-refresh.js +0 -1
  143. package/dist/collection/components/radio/radio-group.js +0 -1
  144. package/dist/collection/components/radio/radio.js +0 -1
  145. package/dist/collection/components/rich-text/rich-text.js +0 -1
  146. package/dist/collection/components/root-portal/root-portal.js +0 -1
  147. package/dist/collection/components/rtc-room/rtc-room-item.js +0 -1
  148. package/dist/collection/components/rtc-room/rtc-room.js +0 -1
  149. package/dist/collection/components/scroll-view/scroll-view.js +0 -1
  150. package/dist/collection/components/share-element/share-element.js +0 -1
  151. package/dist/collection/components/slider/slider.js +0 -1
  152. package/dist/collection/components/slot/native-slot.js +0 -1
  153. package/dist/collection/components/slot/slot.js +0 -1
  154. package/dist/collection/components/sticky-header/sticky-header.js +11 -0
  155. package/dist/collection/components/sticky-section/sticky-section.js +11 -0
  156. package/dist/collection/components/swiper/swiper-item.js +0 -1
  157. package/dist/collection/components/swiper/swiper.js +0 -1
  158. package/dist/collection/components/switch/switch.js +0 -1
  159. package/dist/collection/components/tabbar/tabbar-item.js +0 -1
  160. package/dist/collection/components/tabbar/tabbar.js +0 -1
  161. package/dist/collection/components/tabs/tab-item.js +0 -1
  162. package/dist/collection/components/tabs/tabs.js +0 -1
  163. package/dist/collection/components/text/text.js +0 -1
  164. package/dist/collection/components/textarea/textarea.js +16 -4
  165. package/dist/collection/components/video/utils.js +0 -1
  166. package/dist/collection/components/video/video-control.js +0 -1
  167. package/dist/collection/components/video/video-danmu.js +0 -1
  168. package/dist/collection/components/video/video.js +3 -2
  169. package/dist/collection/components/view/view.js +0 -1
  170. package/dist/collection/components/voip-room/voip-room.js +0 -1
  171. package/dist/collection/components/web-view/web-view.js +0 -1
  172. package/dist/collection/index.js +0 -1
  173. package/dist/collection/utils/helper.js +0 -1
  174. package/dist/collection/utils/index.js +0 -1
  175. package/dist/collection/utils/style.js +0 -1
  176. package/dist/collection/utils/url.js +0 -1
  177. package/dist/components/helper.js +0 -2
  178. package/dist/components/hls.js +0 -2
  179. package/dist/components/index.d.ts +6 -0
  180. package/dist/components/index.js +6 -2
  181. package/dist/components/index2.js +0 -2
  182. package/dist/components/index3.js +0 -2
  183. package/dist/components/intersection-observer.js +0 -2
  184. package/dist/components/picker-group.js +3 -5
  185. package/dist/components/taro-ad-core.js +0 -2
  186. package/dist/components/taro-ad-custom-core.js +0 -2
  187. package/dist/components/taro-animation-video-core.js +0 -2
  188. package/dist/components/taro-animation-view-core.js +0 -2
  189. package/dist/components/taro-ar-camera-core.js +0 -2
  190. package/dist/components/taro-audio-core.js +0 -2
  191. package/dist/components/taro-aweme-data-core.js +0 -2
  192. package/dist/components/taro-block-core.js +0 -2
  193. package/dist/components/taro-button-core.js +0 -2
  194. package/dist/components/taro-camera-core.js +0 -2
  195. package/dist/components/taro-canvas-core.js +0 -2
  196. package/dist/components/taro-channel-live-core.d.ts +11 -0
  197. package/dist/components/taro-channel-live-core.js +33 -0
  198. package/dist/components/taro-channel-video-core.d.ts +11 -0
  199. package/dist/components/taro-channel-video-core.js +33 -0
  200. package/dist/components/taro-checkbox-core.js +0 -2
  201. package/dist/components/taro-checkbox-group-core.js +0 -2
  202. package/dist/components/taro-comment-detail-core.js +0 -2
  203. package/dist/components/taro-comment-list-core.js +0 -2
  204. package/dist/components/taro-contact-button-core.js +0 -2
  205. package/dist/components/taro-cover-image-core.js +0 -2
  206. package/dist/components/taro-cover-view-core.js +0 -2
  207. package/dist/components/taro-custom-wrapper-core.js +0 -2
  208. package/dist/components/taro-editor-core.js +0 -2
  209. package/dist/components/taro-follow-swan-core.js +0 -2
  210. package/dist/components/taro-form-core.js +0 -2
  211. package/dist/components/taro-functional-page-navigator-core.js +0 -2
  212. package/dist/components/taro-grid-view-core.d.ts +11 -0
  213. package/dist/components/taro-grid-view-core.js +33 -0
  214. package/dist/components/taro-icon-core.js +0 -2
  215. package/dist/components/taro-image-core.js +0 -2
  216. package/dist/components/taro-inline-payment-panel-core.js +0 -2
  217. package/dist/components/taro-input-core.js +0 -2
  218. package/dist/components/taro-keyboard-accessory-core.js +0 -2
  219. package/dist/components/taro-label-core.js +0 -2
  220. package/dist/components/taro-lifestyle-core.js +0 -2
  221. package/dist/components/taro-like-core.js +0 -2
  222. package/dist/components/taro-list-view-core.d.ts +11 -0
  223. package/dist/components/taro-list-view-core.js +33 -0
  224. package/dist/components/taro-live-player-core.js +0 -2
  225. package/dist/components/taro-live-pusher-core.js +0 -2
  226. package/dist/components/taro-login-core.js +0 -2
  227. package/dist/components/taro-lottie-core.js +0 -2
  228. package/dist/components/taro-map-core.js +0 -2
  229. package/dist/components/taro-match-media-core.js +0 -2
  230. package/dist/components/taro-movable-area-core.js +0 -2
  231. package/dist/components/taro-movable-view-core.js +0 -2
  232. package/dist/components/taro-native-slot-core.js +0 -2
  233. package/dist/components/taro-navigation-bar-core.js +0 -2
  234. package/dist/components/taro-navigator-core.js +1 -3
  235. package/dist/components/taro-official-account-core.js +0 -2
  236. package/dist/components/taro-open-data-core.js +0 -2
  237. package/dist/components/taro-page-container-core.js +0 -2
  238. package/dist/components/taro-page-meta-core.js +0 -2
  239. package/dist/components/taro-picker-core.js +0 -2
  240. package/dist/components/taro-picker-group.js +0 -2
  241. package/dist/components/taro-picker-view-column-core.js +0 -2
  242. package/dist/components/taro-picker-view-core.js +0 -2
  243. package/dist/components/taro-progress-core.js +0 -2
  244. package/dist/components/taro-pull-to-refresh.js +0 -2
  245. package/dist/components/taro-radio-core.js +0 -2
  246. package/dist/components/taro-radio-group-core.js +0 -2
  247. package/dist/components/taro-rich-text-core.js +0 -2
  248. package/dist/components/taro-root-portal-core.js +0 -2
  249. package/dist/components/taro-rtc-room-core.js +0 -2
  250. package/dist/components/taro-rtc-room-item-core.js +0 -2
  251. package/dist/components/taro-scroll-view-core.js +0 -2
  252. package/dist/components/taro-share-element-core.js +0 -2
  253. package/dist/components/taro-slider-core.js +0 -2
  254. package/dist/components/taro-slot-core.js +0 -2
  255. package/dist/components/taro-sticky-header-core.d.ts +11 -0
  256. package/dist/components/taro-sticky-header-core.js +33 -0
  257. package/dist/components/taro-sticky-section-core.d.ts +11 -0
  258. package/dist/components/taro-sticky-section-core.js +33 -0
  259. package/dist/components/taro-swiper-core.js +0 -2
  260. package/dist/components/taro-swiper-item-core.js +0 -2
  261. package/dist/components/taro-switch-core.js +0 -2
  262. package/dist/components/taro-tab-item-core.js +0 -2
  263. package/dist/components/taro-tabbar.js +0 -2
  264. package/dist/components/taro-tabs-core.js +0 -2
  265. package/dist/components/taro-text-core.js +0 -2
  266. package/dist/components/taro-textarea-core.js +12 -4
  267. package/dist/components/taro-video-control.js +0 -2
  268. package/dist/components/taro-video-core.js +3 -3
  269. package/dist/components/taro-video-danmu.js +0 -2
  270. package/dist/components/taro-view-core.js +0 -2
  271. package/dist/components/taro-voip-room-core.js +0 -2
  272. package/dist/components/taro-web-view-core.js +0 -2
  273. package/dist/components/video-control.js +0 -2
  274. package/dist/components/video-danmu.js +0 -2
  275. package/dist/esm/helper-3d0ecf0f.js +0 -2
  276. package/dist/esm/hls-221423a1.js +0 -2
  277. package/dist/esm/index-1d8e8acd.js +0 -2
  278. package/dist/esm/index-c948674f.js +0 -2
  279. package/dist/esm/index-d1b03e47.js +0 -2
  280. package/dist/esm/index.js +0 -2
  281. package/dist/esm/intersection-observer-8e4c7135.js +0 -2
  282. package/dist/esm/loader.js +1 -3
  283. package/dist/esm/taro-ad-core.entry.js +0 -2
  284. package/dist/esm/taro-ad-custom-core.entry.js +0 -2
  285. package/dist/esm/taro-animation-video-core.entry.js +0 -2
  286. package/dist/esm/taro-animation-view-core.entry.js +0 -2
  287. package/dist/esm/taro-ar-camera-core.entry.js +0 -2
  288. package/dist/esm/taro-audio-core.entry.js +0 -2
  289. package/dist/esm/taro-aweme-data-core.entry.js +0 -2
  290. package/dist/esm/taro-block-core.entry.js +0 -2
  291. package/dist/esm/taro-button-core.entry.js +0 -2
  292. package/dist/esm/taro-camera-core.entry.js +0 -2
  293. package/dist/esm/taro-canvas-core.entry.js +0 -2
  294. package/dist/esm/taro-channel-live-core.entry.js +17 -0
  295. package/dist/esm/taro-channel-video-core.entry.js +17 -0
  296. package/dist/esm/taro-checkbox-core_2.entry.js +0 -2
  297. package/dist/esm/taro-comment-detail-core.entry.js +0 -2
  298. package/dist/esm/taro-comment-list-core.entry.js +0 -2
  299. package/dist/esm/taro-components.js +1 -3
  300. package/dist/esm/taro-contact-button-core.entry.js +0 -2
  301. package/dist/esm/taro-cover-image-core.entry.js +0 -2
  302. package/dist/esm/taro-cover-view-core.entry.js +0 -2
  303. package/dist/esm/taro-custom-wrapper-core.entry.js +0 -2
  304. package/dist/esm/taro-editor-core.entry.js +0 -2
  305. package/dist/esm/taro-follow-swan-core.entry.js +0 -2
  306. package/dist/esm/taro-form-core.entry.js +0 -2
  307. package/dist/esm/taro-functional-page-navigator-core.entry.js +0 -2
  308. package/dist/esm/taro-grid-view-core.entry.js +17 -0
  309. package/dist/esm/taro-icon-core.entry.js +0 -2
  310. package/dist/esm/taro-image-core.entry.js +0 -2
  311. package/dist/esm/taro-inline-payment-panel-core.entry.js +0 -2
  312. package/dist/esm/taro-input-core.entry.js +0 -2
  313. package/dist/esm/taro-keyboard-accessory-core.entry.js +0 -2
  314. package/dist/esm/taro-label-core.entry.js +0 -2
  315. package/dist/esm/taro-lifestyle-core.entry.js +0 -2
  316. package/dist/esm/taro-like-core.entry.js +0 -2
  317. package/dist/esm/taro-list-view-core.entry.js +17 -0
  318. package/dist/esm/taro-live-player-core.entry.js +0 -2
  319. package/dist/esm/taro-live-pusher-core.entry.js +0 -2
  320. package/dist/esm/taro-login-core.entry.js +0 -2
  321. package/dist/esm/taro-lottie-core.entry.js +0 -2
  322. package/dist/esm/taro-map-core.entry.js +0 -2
  323. package/dist/esm/taro-match-media-core.entry.js +0 -2
  324. package/dist/esm/taro-movable-area-core_2.entry.js +0 -2
  325. package/dist/esm/taro-native-slot-core.entry.js +0 -2
  326. package/dist/esm/taro-navigation-bar-core.entry.js +0 -2
  327. package/dist/esm/taro-navigator-core.entry.js +1 -3
  328. package/dist/esm/taro-official-account-core.entry.js +0 -2
  329. package/dist/esm/taro-open-data-core.entry.js +0 -2
  330. package/dist/esm/taro-page-container-core.entry.js +0 -2
  331. package/dist/esm/taro-page-meta-core.entry.js +0 -2
  332. package/dist/esm/taro-picker-core_2.entry.js +3 -5
  333. package/dist/esm/taro-picker-view-column-core_2.entry.js +0 -2
  334. package/dist/esm/taro-progress-core.entry.js +0 -2
  335. package/dist/esm/taro-pull-to-refresh.entry.js +0 -2
  336. package/dist/esm/taro-radio-core_2.entry.js +0 -2
  337. package/dist/esm/taro-rich-text-core.entry.js +0 -2
  338. package/dist/esm/taro-root-portal-core.entry.js +0 -2
  339. package/dist/esm/taro-rtc-room-core.entry.js +0 -2
  340. package/dist/esm/taro-rtc-room-item-core.entry.js +0 -2
  341. package/dist/esm/taro-scroll-view-core.entry.js +0 -2
  342. package/dist/esm/taro-share-element-core.entry.js +0 -2
  343. package/dist/esm/taro-slider-core.entry.js +0 -2
  344. package/dist/esm/taro-slot-core.entry.js +0 -2
  345. package/dist/esm/taro-sticky-header-core.entry.js +17 -0
  346. package/dist/esm/taro-sticky-section-core.entry.js +17 -0
  347. package/dist/esm/taro-swiper-core_2.entry.js +0 -2
  348. package/dist/esm/taro-switch-core.entry.js +0 -2
  349. package/dist/esm/taro-tab-item-core.entry.js +0 -2
  350. package/dist/esm/taro-tabbar.entry.js +0 -2
  351. package/dist/esm/taro-tabs-core.entry.js +0 -2
  352. package/dist/esm/taro-text-core.entry.js +0 -2
  353. package/dist/esm/taro-textarea-core.entry.js +11 -3
  354. package/dist/esm/taro-video-control_3.entry.js +3 -3
  355. package/dist/esm/taro-view-core.entry.js +0 -2
  356. package/dist/esm/taro-voip-room-core.entry.js +0 -2
  357. package/dist/esm/taro-web-view-core.entry.js +0 -2
  358. package/dist/esm-es5/helper-3d0ecf0f.js +1 -2
  359. package/dist/esm-es5/hls-221423a1.js +1 -2
  360. package/dist/esm-es5/index-1d8e8acd.js +1 -2
  361. package/dist/esm-es5/index-c948674f.js +1 -2
  362. package/dist/esm-es5/index-d1b03e47.js +1 -2
  363. package/dist/esm-es5/index.js +0 -2
  364. package/dist/esm-es5/intersection-observer-8e4c7135.js +1 -2
  365. package/dist/esm-es5/loader.js +1 -2
  366. package/dist/esm-es5/taro-ad-core.entry.js +1 -2
  367. package/dist/esm-es5/taro-ad-custom-core.entry.js +1 -2
  368. package/dist/esm-es5/taro-animation-video-core.entry.js +1 -2
  369. package/dist/esm-es5/taro-animation-view-core.entry.js +1 -2
  370. package/dist/esm-es5/taro-ar-camera-core.entry.js +1 -2
  371. package/dist/esm-es5/taro-audio-core.entry.js +1 -2
  372. package/dist/esm-es5/taro-aweme-data-core.entry.js +1 -2
  373. package/dist/esm-es5/taro-block-core.entry.js +1 -2
  374. package/dist/esm-es5/taro-button-core.entry.js +1 -2
  375. package/dist/esm-es5/taro-camera-core.entry.js +1 -2
  376. package/dist/esm-es5/taro-canvas-core.entry.js +1 -2
  377. package/dist/esm-es5/taro-channel-live-core.entry.js +1 -0
  378. package/dist/esm-es5/taro-channel-video-core.entry.js +1 -0
  379. package/dist/esm-es5/taro-checkbox-core_2.entry.js +1 -2
  380. package/dist/esm-es5/taro-comment-detail-core.entry.js +1 -2
  381. package/dist/esm-es5/taro-comment-list-core.entry.js +1 -2
  382. package/dist/esm-es5/taro-components.js +1 -2
  383. package/dist/esm-es5/taro-contact-button-core.entry.js +1 -2
  384. package/dist/esm-es5/taro-cover-image-core.entry.js +1 -2
  385. package/dist/esm-es5/taro-cover-view-core.entry.js +1 -2
  386. package/dist/esm-es5/taro-custom-wrapper-core.entry.js +1 -2
  387. package/dist/esm-es5/taro-editor-core.entry.js +1 -2
  388. package/dist/esm-es5/taro-follow-swan-core.entry.js +1 -2
  389. package/dist/esm-es5/taro-form-core.entry.js +1 -2
  390. package/dist/esm-es5/taro-functional-page-navigator-core.entry.js +1 -2
  391. package/dist/esm-es5/taro-grid-view-core.entry.js +1 -0
  392. package/dist/esm-es5/taro-icon-core.entry.js +1 -2
  393. package/dist/esm-es5/taro-image-core.entry.js +1 -2
  394. package/dist/esm-es5/taro-inline-payment-panel-core.entry.js +1 -2
  395. package/dist/esm-es5/taro-input-core.entry.js +1 -2
  396. package/dist/esm-es5/taro-keyboard-accessory-core.entry.js +1 -2
  397. package/dist/esm-es5/taro-label-core.entry.js +1 -2
  398. package/dist/esm-es5/taro-lifestyle-core.entry.js +1 -2
  399. package/dist/esm-es5/taro-like-core.entry.js +1 -2
  400. package/dist/esm-es5/taro-list-view-core.entry.js +1 -0
  401. package/dist/esm-es5/taro-live-player-core.entry.js +1 -2
  402. package/dist/esm-es5/taro-live-pusher-core.entry.js +1 -2
  403. package/dist/esm-es5/taro-login-core.entry.js +1 -2
  404. package/dist/esm-es5/taro-lottie-core.entry.js +1 -2
  405. package/dist/esm-es5/taro-map-core.entry.js +1 -2
  406. package/dist/esm-es5/taro-match-media-core.entry.js +1 -2
  407. package/dist/esm-es5/taro-movable-area-core_2.entry.js +1 -2
  408. package/dist/esm-es5/taro-native-slot-core.entry.js +1 -2
  409. package/dist/esm-es5/taro-navigation-bar-core.entry.js +1 -2
  410. package/dist/esm-es5/taro-navigator-core.entry.js +1 -2
  411. package/dist/esm-es5/taro-official-account-core.entry.js +1 -2
  412. package/dist/esm-es5/taro-open-data-core.entry.js +1 -2
  413. package/dist/esm-es5/taro-page-container-core.entry.js +1 -2
  414. package/dist/esm-es5/taro-page-meta-core.entry.js +1 -2
  415. package/dist/esm-es5/taro-picker-core_2.entry.js +1 -2
  416. package/dist/esm-es5/taro-picker-view-column-core_2.entry.js +1 -2
  417. package/dist/esm-es5/taro-progress-core.entry.js +1 -2
  418. package/dist/esm-es5/taro-pull-to-refresh.entry.js +1 -2
  419. package/dist/esm-es5/taro-radio-core_2.entry.js +1 -2
  420. package/dist/esm-es5/taro-rich-text-core.entry.js +1 -2
  421. package/dist/esm-es5/taro-root-portal-core.entry.js +1 -2
  422. package/dist/esm-es5/taro-rtc-room-core.entry.js +1 -2
  423. package/dist/esm-es5/taro-rtc-room-item-core.entry.js +1 -2
  424. package/dist/esm-es5/taro-scroll-view-core.entry.js +1 -2
  425. package/dist/esm-es5/taro-share-element-core.entry.js +1 -2
  426. package/dist/esm-es5/taro-slider-core.entry.js +1 -2
  427. package/dist/esm-es5/taro-slot-core.entry.js +1 -2
  428. package/dist/esm-es5/taro-sticky-header-core.entry.js +1 -0
  429. package/dist/esm-es5/taro-sticky-section-core.entry.js +1 -0
  430. package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -2
  431. package/dist/esm-es5/taro-switch-core.entry.js +1 -2
  432. package/dist/esm-es5/taro-tab-item-core.entry.js +1 -2
  433. package/dist/esm-es5/taro-tabbar.entry.js +1 -2
  434. package/dist/esm-es5/taro-tabs-core.entry.js +1 -2
  435. package/dist/esm-es5/taro-text-core.entry.js +1 -2
  436. package/dist/esm-es5/taro-textarea-core.entry.js +1 -2
  437. package/dist/esm-es5/taro-video-control_3.entry.js +1 -2
  438. package/dist/esm-es5/taro-view-core.entry.js +1 -2
  439. package/dist/esm-es5/taro-voip-room-core.entry.js +1 -2
  440. package/dist/esm-es5/taro-web-view-core.entry.js +1 -2
  441. package/dist/taro-components/index.esm.js +0 -2
  442. package/dist/taro-components/p-02aa7366.system.entry.js +1 -0
  443. package/dist/taro-components/{p-0accc602.entry.js → p-0393ed55.entry.js} +1 -2
  444. package/dist/taro-components/p-058b9004.entry.js +1 -0
  445. package/dist/taro-components/{p-eb9adf17.entry.js → p-05bc0fce.entry.js} +1 -2
  446. package/dist/taro-components/p-05c757b7.entry.js +1 -0
  447. package/dist/taro-components/{p-76e6fbff.entry.js → p-07293238.entry.js} +1 -2
  448. package/dist/taro-components/p-0836fcd9.entry.js +1 -0
  449. package/dist/taro-components/p-087bf23a.system.entry.js +1 -2
  450. package/dist/taro-components/p-08bb8dfc.system.entry.js +1 -2
  451. package/dist/taro-components/p-0a165ad3.system.entry.js +1 -2
  452. package/dist/taro-components/p-0a9b984e.system.entry.js +1 -2
  453. package/dist/taro-components/p-0aaf66d2.entry.js +1 -0
  454. package/dist/taro-components/p-10046f1a.system.entry.js +1 -2
  455. package/dist/taro-components/p-10be7fb5.system.entry.js +1 -2
  456. package/dist/taro-components/{p-4a462c95.entry.js → p-11936d9a.entry.js} +1 -2
  457. package/dist/taro-components/{p-51caa3f3.entry.js → p-1249cb09.entry.js} +1 -2
  458. package/dist/taro-components/p-1385d50f.entry.js +1 -0
  459. package/dist/taro-components/p-1493866a.entry.js +1 -0
  460. package/dist/taro-components/p-15e45ed6.system.js +1 -2
  461. package/dist/taro-components/p-16e03200.entry.js +1 -0
  462. package/dist/taro-components/p-17302fe9.system.entry.js +1 -2
  463. package/dist/taro-components/p-1743a04b.system.js +1 -2
  464. package/dist/taro-components/p-1941d333.system.entry.js +1 -2
  465. package/dist/taro-components/p-1a0e1932.system.js +1 -2
  466. package/dist/taro-components/{p-386ae2b2.entry.js → p-1be83ed3.entry.js} +1 -2
  467. package/dist/taro-components/p-1c320250.system.entry.js +1 -2
  468. package/dist/taro-components/p-1c446c65.system.js +1 -2
  469. package/dist/taro-components/{p-19e87e18.entry.js → p-1e8c8ae1.entry.js} +1 -2
  470. package/dist/taro-components/p-2024e133.system.entry.js +1 -2
  471. package/dist/taro-components/{p-780870eb.entry.js → p-22dc57d4.entry.js} +1 -2
  472. package/dist/taro-components/{p-0faf45d5.entry.js → p-23cb8a7f.entry.js} +1 -2
  473. package/dist/taro-components/p-26889f3c.system.entry.js +1 -2
  474. package/dist/taro-components/p-27c4878c.entry.js +1 -0
  475. package/dist/taro-components/{p-4263c9d9.entry.js → p-2e28cb1c.entry.js} +1 -2
  476. package/dist/taro-components/p-2f7dba29.entry.js +1 -0
  477. package/dist/taro-components/p-30f32fa2.system.entry.js +1 -2
  478. package/dist/taro-components/p-30fe0e81.system.entry.js +1 -2
  479. package/dist/taro-components/p-33223303.system.entry.js +1 -2
  480. package/dist/taro-components/{p-955fbcfa.entry.js → p-369fb262.entry.js} +1 -2
  481. package/dist/taro-components/{p-a7789ed6.entry.js → p-38a51bd2.entry.js} +1 -2
  482. package/dist/taro-components/{p-7c6f0d5c.entry.js → p-38de410e.entry.js} +1 -2
  483. package/dist/taro-components/p-3b1d2d37.system.js +1 -2
  484. package/dist/taro-components/p-3c5ac930.entry.js +1 -0
  485. package/dist/taro-components/p-3c91f59b.entry.js +1 -0
  486. package/dist/taro-components/{p-908ddbb0.entry.js → p-3d60bd58.entry.js} +1 -2
  487. package/dist/taro-components/p-3e23fa46.system.entry.js +1 -0
  488. package/dist/taro-components/p-4086e546.system.entry.js +1 -2
  489. package/dist/taro-components/p-4190e20b.system.entry.js +1 -2
  490. package/dist/taro-components/{p-24c2fd23.entry.js → p-429a0f99.entry.js} +1 -2
  491. package/dist/taro-components/p-42bcb98a.entry.js +1 -0
  492. package/dist/taro-components/p-4402972b.system.entry.js +1 -0
  493. package/dist/taro-components/p-4514dc53.system.entry.js +1 -0
  494. package/dist/taro-components/p-4542b767.entry.js +1 -0
  495. package/dist/taro-components/p-46244579.system.entry.js +1 -2
  496. package/dist/taro-components/p-4915fdc1.system.entry.js +1 -2
  497. package/dist/taro-components/{p-de356b29.system.entry.js → p-491c6272.system.entry.js} +1 -2
  498. package/dist/taro-components/p-4b579316.entry.js +1 -0
  499. package/dist/taro-components/p-4d0da795.system.entry.js +1 -2
  500. package/dist/taro-components/p-4d390d17.entry.js +1 -0
  501. package/dist/taro-components/p-4d7182f4.system.entry.js +1 -0
  502. package/dist/taro-components/p-4e77bdea.entry.js +1 -0
  503. package/dist/taro-components/p-50ea2036.system.js +1 -2
  504. package/dist/taro-components/p-518146fd.system.entry.js +1 -2
  505. package/dist/taro-components/p-51b6fc09.system.entry.js +1 -2
  506. package/dist/taro-components/p-56da1da3.system.entry.js +1 -2
  507. package/dist/taro-components/p-58877ef2.system.entry.js +1 -2
  508. package/dist/taro-components/{p-c2ac8f08.entry.js → p-58b7e960.entry.js} +1 -2
  509. package/dist/taro-components/p-5931c82e.entry.js +1 -0
  510. package/dist/taro-components/p-59590806.system.entry.js +1 -2
  511. package/dist/taro-components/p-61f225ef.system.js +1 -2
  512. package/dist/taro-components/p-623b3eb6.system.entry.js +1 -2
  513. package/dist/taro-components/p-651586f8.system.entry.js +1 -2
  514. package/dist/taro-components/p-69f6784d.system.entry.js +1 -2
  515. package/dist/taro-components/p-69fa7272.system.entry.js +1 -2
  516. package/dist/taro-components/p-6a96da58.js +1 -2
  517. package/dist/taro-components/p-6dae898a.system.entry.js +1 -2
  518. package/dist/taro-components/{p-b39b973e.entry.js → p-6de6eb4e.entry.js} +1 -2
  519. package/dist/taro-components/p-6f048097.system.entry.js +1 -2
  520. package/dist/taro-components/p-6f214fc3.system.entry.js +1 -2
  521. package/dist/taro-components/p-72f327e1.js +1 -2
  522. package/dist/taro-components/p-736053bb.system.entry.js +1 -2
  523. package/dist/taro-components/{p-b4419d86.entry.js → p-7377a117.entry.js} +1 -2
  524. package/dist/taro-components/p-744a6b99.entry.js +1 -0
  525. package/dist/taro-components/p-74bf8246.system.entry.js +1 -2
  526. package/dist/taro-components/p-76724e58.js +2 -3
  527. package/dist/taro-components/p-7722f33f.entry.js +1 -0
  528. package/dist/taro-components/p-78c30850.system.entry.js +1 -2
  529. package/dist/taro-components/p-78e3ebb9.js +2 -3
  530. package/dist/taro-components/p-7c1fc8f5.system.entry.js +1 -0
  531. package/dist/taro-components/p-7db63e92.entry.js +1 -0
  532. package/dist/taro-components/p-7dd9c8da.system.entry.js +1 -2
  533. package/dist/taro-components/p-7df9de66.system.entry.js +1 -0
  534. package/dist/taro-components/p-8027e1c6.system.entry.js +1 -2
  535. package/dist/taro-components/p-80970d8f.entry.js +1 -0
  536. package/dist/taro-components/p-80f3d88d.entry.js +1 -0
  537. package/dist/taro-components/p-88d64daa.system.entry.js +1 -2
  538. package/dist/taro-components/p-895cd7c9.system.entry.js +1 -2
  539. package/dist/taro-components/{p-66b07ac0.entry.js → p-8b8a8e39.entry.js} +1 -2
  540. package/dist/taro-components/{p-281278cf.entry.js → p-8d037fc0.entry.js} +1 -2
  541. package/dist/taro-components/p-8d2101be.system.entry.js +1 -2
  542. package/dist/taro-components/p-8e5cc8fe.system.entry.js +1 -2
  543. package/dist/taro-components/p-8feeb7ce.entry.js +1 -0
  544. package/dist/taro-components/p-90e4274e.entry.js +1 -0
  545. package/dist/taro-components/{p-03d4de13.entry.js → p-9318da32.entry.js} +1 -2
  546. package/dist/taro-components/p-95f70aea.system.entry.js +1 -2
  547. package/dist/taro-components/p-97782cdd.system.entry.js +1 -2
  548. package/dist/taro-components/p-9d4fa0d3.system.entry.js +1 -2
  549. package/dist/taro-components/p-9df17ea6.entry.js +1 -0
  550. package/dist/taro-components/{p-c0bb8610.entry.js → p-a294e169.entry.js} +1 -2
  551. package/dist/taro-components/{p-e0e4a403.entry.js → p-a6d2e81b.entry.js} +1 -2
  552. package/dist/taro-components/{p-d61d3394.entry.js → p-a9b51167.entry.js} +1 -2
  553. package/dist/taro-components/p-ab84c88e.entry.js +1 -0
  554. package/dist/taro-components/p-acd9a9da.entry.js +1 -0
  555. package/dist/taro-components/p-ae3f1ed4.system.entry.js +1 -2
  556. package/dist/taro-components/{p-4bc85eb7.entry.js → p-ae8fd8c8.entry.js} +1 -2
  557. package/dist/taro-components/p-b1249ebb.system.entry.js +1 -2
  558. package/dist/taro-components/p-b16eddaa.entry.js +1 -0
  559. package/dist/taro-components/p-b1c972e2.system.entry.js +1 -2
  560. package/dist/taro-components/p-b2bb02d7.system.entry.js +1 -2
  561. package/dist/taro-components/p-bac3deb0.system.entry.js +1 -2
  562. package/dist/taro-components/{p-eb2a7609.entry.js → p-badfb3be.entry.js} +1 -2
  563. package/dist/taro-components/p-bba8c3a7.system.entry.js +1 -2
  564. package/dist/taro-components/p-bd5177d3.system.js +1 -2
  565. package/dist/taro-components/{p-c50087fd.entry.js → p-beba1657.entry.js} +1 -2
  566. package/dist/taro-components/p-c212b845.entry.js +1 -0
  567. package/dist/taro-components/p-c2391de5.entry.js +1 -0
  568. package/dist/taro-components/p-c2c498d9.entry.js +1 -0
  569. package/dist/taro-components/p-c33733b3.system.entry.js +1 -2
  570. package/dist/taro-components/{p-603ceecd.entry.js → p-c3d35ae5.entry.js} +1 -2
  571. package/dist/taro-components/p-c3d3eca2.entry.js +1 -0
  572. package/dist/taro-components/{p-c3e98fdf.entry.js → p-c4dd85b6.entry.js} +1 -2
  573. package/dist/taro-components/p-c4fdb669.system.entry.js +1 -2
  574. package/dist/taro-components/p-c586a796.system.entry.js +1 -2
  575. package/dist/taro-components/p-c6385fc2.system.entry.js +1 -2
  576. package/dist/taro-components/p-c6e6dab1.system.entry.js +1 -2
  577. package/dist/taro-components/p-c70dd956.system.entry.js +1 -2
  578. package/dist/taro-components/p-d3c7f87d.js +1 -2
  579. package/dist/taro-components/{p-fda82bc1.entry.js → p-d42e41ff.entry.js} +1 -2
  580. package/dist/taro-components/p-d5234e7e.js +92 -93
  581. package/dist/taro-components/{p-adc37a00.entry.js → p-d797cdc4.entry.js} +1 -2
  582. package/dist/taro-components/{p-0895120a.system.entry.js → p-da1f3d54.system.entry.js} +1 -2
  583. package/dist/taro-components/p-da5cdbf5.system.entry.js +1 -2
  584. package/dist/taro-components/{p-3f07f3d3.entry.js → p-dccf1ae9.entry.js} +1 -2
  585. package/dist/taro-components/p-de2d8e2e.system.entry.js +1 -2
  586. package/dist/taro-components/p-dfc405a5.entry.js +1 -0
  587. package/dist/taro-components/{p-09db02e6.entry.js → p-e2f2fbe5.entry.js} +1 -2
  588. package/dist/taro-components/p-e3f8265d.system.entry.js +1 -2
  589. package/dist/taro-components/p-e53feb03.system.entry.js +1 -2
  590. package/dist/taro-components/p-e753b776.entry.js +1 -0
  591. package/dist/taro-components/{p-a23a21e1.entry.js → p-e8b1ea64.entry.js} +1 -2
  592. package/dist/taro-components/{p-3bce88d9.entry.js → p-e9eeb060.entry.js} +1 -2
  593. package/dist/taro-components/p-ef7e7d73.system.entry.js +1 -2
  594. package/dist/taro-components/p-efa51030.system.entry.js +1 -2
  595. package/dist/taro-components/{p-7c1fec76.entry.js → p-efcfdb97.entry.js} +1 -2
  596. package/dist/taro-components/p-f44e975b.entry.js +1 -0
  597. package/dist/taro-components/p-f499c0a0.system.entry.js +1 -2
  598. package/dist/taro-components/{p-8425ff09.entry.js → p-f671ed7d.entry.js} +1 -2
  599. package/dist/taro-components/p-f9ac515e.system.entry.js +1 -2
  600. package/dist/taro-components/p-fa36fe8e.system.entry.js +1 -2
  601. package/dist/taro-components/{p-982e431d.entry.js → p-fb585037.entry.js} +1 -2
  602. package/dist/taro-components/p-fcdac6ec.system.entry.js +1 -2
  603. package/dist/taro-components/{p-6bb1fdf2.entry.js → p-fdecdc25.entry.js} +1 -2
  604. package/dist/taro-components/taro-components.esm.js +1 -2
  605. package/dist/types/components/channel-live/channel-live.d.ts +5 -0
  606. package/dist/types/components/channel-video/channel-video.d.ts +5 -0
  607. package/dist/types/components/grid-view/grid-view.d.ts +5 -0
  608. package/dist/types/components/list-view/list-view.d.ts +5 -0
  609. package/dist/types/components/picker/picker-group.d.ts +3 -3
  610. package/dist/types/components/sticky-header/sticky-header.d.ts +5 -0
  611. package/dist/types/components/sticky-section/sticky-section.d.ts +5 -0
  612. package/dist/types/components/textarea/textarea.d.ts +1 -0
  613. package/dist/types/components.d.ts +78 -0
  614. package/lib/react/components.d.ts +81 -75
  615. package/lib/react/components.js +82 -75
  616. package/lib/react/components.js.map +1 -1
  617. package/lib/react/helper.js +4 -1
  618. package/lib/react/helper.js.map +1 -1
  619. package/lib/react/index.js +1 -1
  620. package/lib/react/{interfaces-4f837811.d.ts → interfaces-f526f1a2.d.ts} +4 -0
  621. package/lib/react/react-component-lib/createComponent.d.ts +5 -1
  622. package/lib/react/react-component-lib/createComponent.js +6 -4
  623. package/lib/react/react-component-lib/createComponent.js.map +1 -1
  624. package/lib/react/react-component-lib/createOverlayComponent.d.ts +5 -1
  625. package/lib/react/react-component-lib/createOverlayComponent.js +1 -0
  626. package/lib/react/react-component-lib/createOverlayComponent.js.map +1 -1
  627. package/lib/react/react-component-lib/utils/attachProps.d.ts +2 -6
  628. package/lib/react/react-component-lib/utils/attachProps.js +41 -41
  629. package/lib/react/react-component-lib/utils/attachProps.js.map +1 -1
  630. package/lib/react/react-component-lib/utils/case.d.ts +4 -0
  631. package/lib/react/react-component-lib/utils/case.js +4 -0
  632. package/lib/react/react-component-lib/utils/case.js.map +1 -1
  633. package/lib/react/react-component-lib/utils/index.d.ts +5 -1
  634. package/lib/react/react-component-lib/utils/index.js +6 -4
  635. package/lib/react/react-component-lib/utils/index.js.map +1 -1
  636. package/lib/vue2/components-loader.d.ts +2 -0
  637. package/lib/vue2/components-loader.js +21 -0
  638. package/lib/vue2/components-loader.js.map +1 -0
  639. package/lib/vue2/components.d.ts +590 -356
  640. package/lib/vue2/components.js +313 -390
  641. package/lib/vue2/components.js.map +1 -1
  642. package/lib/vue2/index.d.ts +0 -2
  643. package/lib/vue2/index.js +1 -22
  644. package/lib/vue2/index.js.map +1 -1
  645. package/lib/vue2/vue-component-lib/utils.d.ts +7 -3
  646. package/lib/vue2/vue-component-lib/utils.js +42 -25
  647. package/lib/vue2/vue-component-lib/utils.js.map +1 -1
  648. package/lib/vue3/components-loader.d.ts +2 -0
  649. package/lib/vue3/components-loader.js +13 -0
  650. package/lib/vue3/components-loader.js.map +1 -0
  651. package/lib/vue3/components.d.ts +7 -1
  652. package/lib/vue3/components.js +83 -76
  653. package/lib/vue3/components.js.map +1 -1
  654. package/lib/vue3/index.d.ts +0 -2
  655. package/lib/vue3/index.js +1 -14
  656. package/lib/vue3/index.js.map +1 -1
  657. package/lib/vue3/vue-component-lib/utils.d.ts +13 -13
  658. package/lib/vue3/vue-component-lib/utils.js +35 -28
  659. package/lib/vue3/vue-component-lib/utils.js.map +1 -1
  660. package/package.json +11 -8
  661. package/types/Button.d.ts +12 -0
  662. package/types/ChannelVideo.d.ts +50 -0
  663. package/types/GridView.d.ts +42 -0
  664. package/types/ListView.d.ts +12 -0
  665. package/types/Map.d.ts +72 -8
  666. package/types/ScrollView.d.ts +52 -0
  667. package/types/StickyHeader.d.ts +12 -0
  668. package/types/StickySection.d.ts +18 -0
  669. package/types/Textarea.d.ts +2 -2
  670. package/types/index.d.ts +7 -0
  671. package/types/index.vue3.d.ts +32 -16
  672. package/dist/cjs/helper-db78e01a.js.map +0 -1
  673. package/dist/cjs/hls-67cbc62d.js.map +0 -1
  674. package/dist/cjs/index-dfd8638f.js.map +0 -1
  675. package/dist/cjs/index-e1b469cd.js.map +0 -1
  676. package/dist/cjs/index-f9d21cc5.js.map +0 -1
  677. package/dist/cjs/index.cjs.js.map +0 -1
  678. package/dist/cjs/intersection-observer-dc4cfcef.js.map +0 -1
  679. package/dist/cjs/loader.cjs.js.map +0 -1
  680. package/dist/cjs/taro-ad-core.cjs.entry.js.map +0 -1
  681. package/dist/cjs/taro-ad-custom-core.cjs.entry.js.map +0 -1
  682. package/dist/cjs/taro-animation-video-core.cjs.entry.js.map +0 -1
  683. package/dist/cjs/taro-animation-view-core.cjs.entry.js.map +0 -1
  684. package/dist/cjs/taro-ar-camera-core.cjs.entry.js.map +0 -1
  685. package/dist/cjs/taro-audio-core.cjs.entry.js.map +0 -1
  686. package/dist/cjs/taro-aweme-data-core.cjs.entry.js.map +0 -1
  687. package/dist/cjs/taro-block-core.cjs.entry.js.map +0 -1
  688. package/dist/cjs/taro-button-core.cjs.entry.js.map +0 -1
  689. package/dist/cjs/taro-camera-core.cjs.entry.js.map +0 -1
  690. package/dist/cjs/taro-canvas-core.cjs.entry.js.map +0 -1
  691. package/dist/cjs/taro-checkbox-core_2.cjs.entry.js.map +0 -1
  692. package/dist/cjs/taro-comment-detail-core.cjs.entry.js.map +0 -1
  693. package/dist/cjs/taro-comment-list-core.cjs.entry.js.map +0 -1
  694. package/dist/cjs/taro-components.cjs.js.map +0 -1
  695. package/dist/cjs/taro-contact-button-core.cjs.entry.js.map +0 -1
  696. package/dist/cjs/taro-cover-image-core.cjs.entry.js.map +0 -1
  697. package/dist/cjs/taro-cover-view-core.cjs.entry.js.map +0 -1
  698. package/dist/cjs/taro-custom-wrapper-core.cjs.entry.js.map +0 -1
  699. package/dist/cjs/taro-editor-core.cjs.entry.js.map +0 -1
  700. package/dist/cjs/taro-follow-swan-core.cjs.entry.js.map +0 -1
  701. package/dist/cjs/taro-form-core.cjs.entry.js.map +0 -1
  702. package/dist/cjs/taro-functional-page-navigator-core.cjs.entry.js.map +0 -1
  703. package/dist/cjs/taro-icon-core.cjs.entry.js.map +0 -1
  704. package/dist/cjs/taro-image-core.cjs.entry.js.map +0 -1
  705. package/dist/cjs/taro-inline-payment-panel-core.cjs.entry.js.map +0 -1
  706. package/dist/cjs/taro-input-core.cjs.entry.js.map +0 -1
  707. package/dist/cjs/taro-keyboard-accessory-core.cjs.entry.js.map +0 -1
  708. package/dist/cjs/taro-label-core.cjs.entry.js.map +0 -1
  709. package/dist/cjs/taro-lifestyle-core.cjs.entry.js.map +0 -1
  710. package/dist/cjs/taro-like-core.cjs.entry.js.map +0 -1
  711. package/dist/cjs/taro-live-player-core.cjs.entry.js.map +0 -1
  712. package/dist/cjs/taro-live-pusher-core.cjs.entry.js.map +0 -1
  713. package/dist/cjs/taro-login-core.cjs.entry.js.map +0 -1
  714. package/dist/cjs/taro-lottie-core.cjs.entry.js.map +0 -1
  715. package/dist/cjs/taro-map-core.cjs.entry.js.map +0 -1
  716. package/dist/cjs/taro-match-media-core.cjs.entry.js.map +0 -1
  717. package/dist/cjs/taro-movable-area-core_2.cjs.entry.js.map +0 -1
  718. package/dist/cjs/taro-native-slot-core.cjs.entry.js.map +0 -1
  719. package/dist/cjs/taro-navigation-bar-core.cjs.entry.js.map +0 -1
  720. package/dist/cjs/taro-navigator-core.cjs.entry.js.map +0 -1
  721. package/dist/cjs/taro-official-account-core.cjs.entry.js.map +0 -1
  722. package/dist/cjs/taro-open-data-core.cjs.entry.js.map +0 -1
  723. package/dist/cjs/taro-page-container-core.cjs.entry.js.map +0 -1
  724. package/dist/cjs/taro-page-meta-core.cjs.entry.js.map +0 -1
  725. package/dist/cjs/taro-picker-core_2.cjs.entry.js.map +0 -1
  726. package/dist/cjs/taro-picker-view-column-core_2.cjs.entry.js.map +0 -1
  727. package/dist/cjs/taro-progress-core.cjs.entry.js.map +0 -1
  728. package/dist/cjs/taro-pull-to-refresh.cjs.entry.js.map +0 -1
  729. package/dist/cjs/taro-radio-core_2.cjs.entry.js.map +0 -1
  730. package/dist/cjs/taro-rich-text-core.cjs.entry.js.map +0 -1
  731. package/dist/cjs/taro-root-portal-core.cjs.entry.js.map +0 -1
  732. package/dist/cjs/taro-rtc-room-core.cjs.entry.js.map +0 -1
  733. package/dist/cjs/taro-rtc-room-item-core.cjs.entry.js.map +0 -1
  734. package/dist/cjs/taro-scroll-view-core.cjs.entry.js.map +0 -1
  735. package/dist/cjs/taro-share-element-core.cjs.entry.js.map +0 -1
  736. package/dist/cjs/taro-slider-core.cjs.entry.js.map +0 -1
  737. package/dist/cjs/taro-slot-core.cjs.entry.js.map +0 -1
  738. package/dist/cjs/taro-swiper-core_2.cjs.entry.js.map +0 -1
  739. package/dist/cjs/taro-switch-core.cjs.entry.js.map +0 -1
  740. package/dist/cjs/taro-tab-item-core.cjs.entry.js.map +0 -1
  741. package/dist/cjs/taro-tabbar.cjs.entry.js.map +0 -1
  742. package/dist/cjs/taro-tabs-core.cjs.entry.js.map +0 -1
  743. package/dist/cjs/taro-text-core.cjs.entry.js.map +0 -1
  744. package/dist/cjs/taro-textarea-core.cjs.entry.js.map +0 -1
  745. package/dist/cjs/taro-video-control_3.cjs.entry.js.map +0 -1
  746. package/dist/cjs/taro-view-core.cjs.entry.js.map +0 -1
  747. package/dist/cjs/taro-voip-room-core.cjs.entry.js.map +0 -1
  748. package/dist/cjs/taro-web-view-core.cjs.entry.js.map +0 -1
  749. package/dist/collection/components/ad/ad.js.map +0 -1
  750. package/dist/collection/components/ad-custom/ad-custom.js.map +0 -1
  751. package/dist/collection/components/animation-video/animation-video.js.map +0 -1
  752. package/dist/collection/components/animation-view/animation-view.js.map +0 -1
  753. package/dist/collection/components/ar-camera/ar-camera.js.map +0 -1
  754. package/dist/collection/components/audio/audio.js.map +0 -1
  755. package/dist/collection/components/aweme-data/aweme-data.js.map +0 -1
  756. package/dist/collection/components/block/block.js.map +0 -1
  757. package/dist/collection/components/button/button.js.map +0 -1
  758. package/dist/collection/components/camera/camera.js.map +0 -1
  759. package/dist/collection/components/canvas/canvas.js.map +0 -1
  760. package/dist/collection/components/checkbox/checkbox-group.js.map +0 -1
  761. package/dist/collection/components/checkbox/checkbox.js.map +0 -1
  762. package/dist/collection/components/comment/comment-detail.js.map +0 -1
  763. package/dist/collection/components/comment/comment-list.js.map +0 -1
  764. package/dist/collection/components/contact-button/contact-button.js.map +0 -1
  765. package/dist/collection/components/cover-image/cover-image.js.map +0 -1
  766. package/dist/collection/components/cover-view/cover-view.js.map +0 -1
  767. package/dist/collection/components/custom-wrapper/custom-wrapper.js.map +0 -1
  768. package/dist/collection/components/editor/editor.js.map +0 -1
  769. package/dist/collection/components/follow-swan/follow-swan.js.map +0 -1
  770. package/dist/collection/components/form/form.js.map +0 -1
  771. package/dist/collection/components/functional-page-navigator/functional-page-navigator.js.map +0 -1
  772. package/dist/collection/components/icon/icon.js.map +0 -1
  773. package/dist/collection/components/image/image.js.map +0 -1
  774. package/dist/collection/components/inline-payment-panel/inline-payment-panel.js.map +0 -1
  775. package/dist/collection/components/input/input.js.map +0 -1
  776. package/dist/collection/components/keyboard-accessory/keyboard-accessory.js.map +0 -1
  777. package/dist/collection/components/label/label.js.map +0 -1
  778. package/dist/collection/components/lifestyle/lifestyle.js.map +0 -1
  779. package/dist/collection/components/like/like.js.map +0 -1
  780. package/dist/collection/components/live-player/live-player.js.map +0 -1
  781. package/dist/collection/components/live-pusher/live-pusher.js.map +0 -1
  782. package/dist/collection/components/login/login.js.map +0 -1
  783. package/dist/collection/components/lottie/lottie.js.map +0 -1
  784. package/dist/collection/components/map/map.js.map +0 -1
  785. package/dist/collection/components/match-media/match-media.js.map +0 -1
  786. package/dist/collection/components/movable-area/movable-area.js.map +0 -1
  787. package/dist/collection/components/movable-area/movable-view.js.map +0 -1
  788. package/dist/collection/components/navigation-bar/navigation-bar.js.map +0 -1
  789. package/dist/collection/components/navigator/navigator.js.map +0 -1
  790. package/dist/collection/components/official-account/official-account.js.map +0 -1
  791. package/dist/collection/components/open-data/open-data.js.map +0 -1
  792. package/dist/collection/components/page-container/page-container.js.map +0 -1
  793. package/dist/collection/components/page-meta/page-meta.js.map +0 -1
  794. package/dist/collection/components/picker/constant.js.map +0 -1
  795. package/dist/collection/components/picker/picker-group.js.map +0 -1
  796. package/dist/collection/components/picker/picker.js.map +0 -1
  797. package/dist/collection/components/picker/utils.js.map +0 -1
  798. package/dist/collection/components/picker-view/picker-view-column.js.map +0 -1
  799. package/dist/collection/components/picker-view/picker-view.js.map +0 -1
  800. package/dist/collection/components/progress/progress.js.map +0 -1
  801. package/dist/collection/components/pull-to-refresh/pull-to-refresh.js.map +0 -1
  802. package/dist/collection/components/radio/radio-group.js.map +0 -1
  803. package/dist/collection/components/radio/radio.js.map +0 -1
  804. package/dist/collection/components/rich-text/rich-text.js.map +0 -1
  805. package/dist/collection/components/root-portal/root-portal.js.map +0 -1
  806. package/dist/collection/components/rtc-room/rtc-room-item.js.map +0 -1
  807. package/dist/collection/components/rtc-room/rtc-room.js.map +0 -1
  808. package/dist/collection/components/scroll-view/scroll-view.js.map +0 -1
  809. package/dist/collection/components/share-element/share-element.js.map +0 -1
  810. package/dist/collection/components/slider/slider.js.map +0 -1
  811. package/dist/collection/components/slot/native-slot.js.map +0 -1
  812. package/dist/collection/components/slot/slot.js.map +0 -1
  813. package/dist/collection/components/swiper/swiper-item.js.map +0 -1
  814. package/dist/collection/components/swiper/swiper.js.map +0 -1
  815. package/dist/collection/components/switch/switch.js.map +0 -1
  816. package/dist/collection/components/tabbar/tabbar-item.js.map +0 -1
  817. package/dist/collection/components/tabbar/tabbar.js.map +0 -1
  818. package/dist/collection/components/tabs/tab-item.js.map +0 -1
  819. package/dist/collection/components/tabs/tabs.js.map +0 -1
  820. package/dist/collection/components/text/text.js.map +0 -1
  821. package/dist/collection/components/textarea/textarea.js.map +0 -1
  822. package/dist/collection/components/video/utils.js.map +0 -1
  823. package/dist/collection/components/video/video-control.js.map +0 -1
  824. package/dist/collection/components/video/video-danmu.js.map +0 -1
  825. package/dist/collection/components/video/video.js.map +0 -1
  826. package/dist/collection/components/view/view.js.map +0 -1
  827. package/dist/collection/components/voip-room/voip-room.js.map +0 -1
  828. package/dist/collection/components/web-view/web-view.js.map +0 -1
  829. package/dist/collection/index.js.map +0 -1
  830. package/dist/collection/utils/helper.js.map +0 -1
  831. package/dist/collection/utils/index.js.map +0 -1
  832. package/dist/collection/utils/style.js.map +0 -1
  833. package/dist/collection/utils/url.js.map +0 -1
  834. package/dist/components/helper.js.map +0 -1
  835. package/dist/components/hls.js.map +0 -1
  836. package/dist/components/index.js.map +0 -1
  837. package/dist/components/index2.js.map +0 -1
  838. package/dist/components/index3.js.map +0 -1
  839. package/dist/components/intersection-observer.js.map +0 -1
  840. package/dist/components/picker-group.js.map +0 -1
  841. package/dist/components/taro-ad-core.js.map +0 -1
  842. package/dist/components/taro-ad-custom-core.js.map +0 -1
  843. package/dist/components/taro-animation-video-core.js.map +0 -1
  844. package/dist/components/taro-animation-view-core.js.map +0 -1
  845. package/dist/components/taro-ar-camera-core.js.map +0 -1
  846. package/dist/components/taro-audio-core.js.map +0 -1
  847. package/dist/components/taro-aweme-data-core.js.map +0 -1
  848. package/dist/components/taro-block-core.js.map +0 -1
  849. package/dist/components/taro-button-core.js.map +0 -1
  850. package/dist/components/taro-camera-core.js.map +0 -1
  851. package/dist/components/taro-canvas-core.js.map +0 -1
  852. package/dist/components/taro-checkbox-core.js.map +0 -1
  853. package/dist/components/taro-checkbox-group-core.js.map +0 -1
  854. package/dist/components/taro-comment-detail-core.js.map +0 -1
  855. package/dist/components/taro-comment-list-core.js.map +0 -1
  856. package/dist/components/taro-contact-button-core.js.map +0 -1
  857. package/dist/components/taro-cover-image-core.js.map +0 -1
  858. package/dist/components/taro-cover-view-core.js.map +0 -1
  859. package/dist/components/taro-custom-wrapper-core.js.map +0 -1
  860. package/dist/components/taro-editor-core.js.map +0 -1
  861. package/dist/components/taro-follow-swan-core.js.map +0 -1
  862. package/dist/components/taro-form-core.js.map +0 -1
  863. package/dist/components/taro-functional-page-navigator-core.js.map +0 -1
  864. package/dist/components/taro-icon-core.js.map +0 -1
  865. package/dist/components/taro-image-core.js.map +0 -1
  866. package/dist/components/taro-inline-payment-panel-core.js.map +0 -1
  867. package/dist/components/taro-input-core.js.map +0 -1
  868. package/dist/components/taro-keyboard-accessory-core.js.map +0 -1
  869. package/dist/components/taro-label-core.js.map +0 -1
  870. package/dist/components/taro-lifestyle-core.js.map +0 -1
  871. package/dist/components/taro-like-core.js.map +0 -1
  872. package/dist/components/taro-live-player-core.js.map +0 -1
  873. package/dist/components/taro-live-pusher-core.js.map +0 -1
  874. package/dist/components/taro-login-core.js.map +0 -1
  875. package/dist/components/taro-lottie-core.js.map +0 -1
  876. package/dist/components/taro-map-core.js.map +0 -1
  877. package/dist/components/taro-match-media-core.js.map +0 -1
  878. package/dist/components/taro-movable-area-core.js.map +0 -1
  879. package/dist/components/taro-movable-view-core.js.map +0 -1
  880. package/dist/components/taro-native-slot-core.js.map +0 -1
  881. package/dist/components/taro-navigation-bar-core.js.map +0 -1
  882. package/dist/components/taro-navigator-core.js.map +0 -1
  883. package/dist/components/taro-official-account-core.js.map +0 -1
  884. package/dist/components/taro-open-data-core.js.map +0 -1
  885. package/dist/components/taro-page-container-core.js.map +0 -1
  886. package/dist/components/taro-page-meta-core.js.map +0 -1
  887. package/dist/components/taro-picker-core.js.map +0 -1
  888. package/dist/components/taro-picker-group.js.map +0 -1
  889. package/dist/components/taro-picker-view-column-core.js.map +0 -1
  890. package/dist/components/taro-picker-view-core.js.map +0 -1
  891. package/dist/components/taro-progress-core.js.map +0 -1
  892. package/dist/components/taro-pull-to-refresh.js.map +0 -1
  893. package/dist/components/taro-radio-core.js.map +0 -1
  894. package/dist/components/taro-radio-group-core.js.map +0 -1
  895. package/dist/components/taro-rich-text-core.js.map +0 -1
  896. package/dist/components/taro-root-portal-core.js.map +0 -1
  897. package/dist/components/taro-rtc-room-core.js.map +0 -1
  898. package/dist/components/taro-rtc-room-item-core.js.map +0 -1
  899. package/dist/components/taro-scroll-view-core.js.map +0 -1
  900. package/dist/components/taro-share-element-core.js.map +0 -1
  901. package/dist/components/taro-slider-core.js.map +0 -1
  902. package/dist/components/taro-slot-core.js.map +0 -1
  903. package/dist/components/taro-swiper-core.js.map +0 -1
  904. package/dist/components/taro-swiper-item-core.js.map +0 -1
  905. package/dist/components/taro-switch-core.js.map +0 -1
  906. package/dist/components/taro-tab-item-core.js.map +0 -1
  907. package/dist/components/taro-tabbar.js.map +0 -1
  908. package/dist/components/taro-tabs-core.js.map +0 -1
  909. package/dist/components/taro-text-core.js.map +0 -1
  910. package/dist/components/taro-textarea-core.js.map +0 -1
  911. package/dist/components/taro-video-control.js.map +0 -1
  912. package/dist/components/taro-video-core.js.map +0 -1
  913. package/dist/components/taro-video-danmu.js.map +0 -1
  914. package/dist/components/taro-view-core.js.map +0 -1
  915. package/dist/components/taro-voip-room-core.js.map +0 -1
  916. package/dist/components/taro-web-view-core.js.map +0 -1
  917. package/dist/components/video-control.js.map +0 -1
  918. package/dist/components/video-danmu.js.map +0 -1
  919. package/dist/esm/helper-3d0ecf0f.js.map +0 -1
  920. package/dist/esm/hls-221423a1.js.map +0 -1
  921. package/dist/esm/index-1d8e8acd.js.map +0 -1
  922. package/dist/esm/index-c948674f.js.map +0 -1
  923. package/dist/esm/index-d1b03e47.js.map +0 -1
  924. package/dist/esm/index.js.map +0 -1
  925. package/dist/esm/intersection-observer-8e4c7135.js.map +0 -1
  926. package/dist/esm/loader.js.map +0 -1
  927. package/dist/esm/taro-ad-core.entry.js.map +0 -1
  928. package/dist/esm/taro-ad-custom-core.entry.js.map +0 -1
  929. package/dist/esm/taro-animation-video-core.entry.js.map +0 -1
  930. package/dist/esm/taro-animation-view-core.entry.js.map +0 -1
  931. package/dist/esm/taro-ar-camera-core.entry.js.map +0 -1
  932. package/dist/esm/taro-audio-core.entry.js.map +0 -1
  933. package/dist/esm/taro-aweme-data-core.entry.js.map +0 -1
  934. package/dist/esm/taro-block-core.entry.js.map +0 -1
  935. package/dist/esm/taro-button-core.entry.js.map +0 -1
  936. package/dist/esm/taro-camera-core.entry.js.map +0 -1
  937. package/dist/esm/taro-canvas-core.entry.js.map +0 -1
  938. package/dist/esm/taro-checkbox-core_2.entry.js.map +0 -1
  939. package/dist/esm/taro-comment-detail-core.entry.js.map +0 -1
  940. package/dist/esm/taro-comment-list-core.entry.js.map +0 -1
  941. package/dist/esm/taro-components.js.map +0 -1
  942. package/dist/esm/taro-contact-button-core.entry.js.map +0 -1
  943. package/dist/esm/taro-cover-image-core.entry.js.map +0 -1
  944. package/dist/esm/taro-cover-view-core.entry.js.map +0 -1
  945. package/dist/esm/taro-custom-wrapper-core.entry.js.map +0 -1
  946. package/dist/esm/taro-editor-core.entry.js.map +0 -1
  947. package/dist/esm/taro-follow-swan-core.entry.js.map +0 -1
  948. package/dist/esm/taro-form-core.entry.js.map +0 -1
  949. package/dist/esm/taro-functional-page-navigator-core.entry.js.map +0 -1
  950. package/dist/esm/taro-icon-core.entry.js.map +0 -1
  951. package/dist/esm/taro-image-core.entry.js.map +0 -1
  952. package/dist/esm/taro-inline-payment-panel-core.entry.js.map +0 -1
  953. package/dist/esm/taro-input-core.entry.js.map +0 -1
  954. package/dist/esm/taro-keyboard-accessory-core.entry.js.map +0 -1
  955. package/dist/esm/taro-label-core.entry.js.map +0 -1
  956. package/dist/esm/taro-lifestyle-core.entry.js.map +0 -1
  957. package/dist/esm/taro-like-core.entry.js.map +0 -1
  958. package/dist/esm/taro-live-player-core.entry.js.map +0 -1
  959. package/dist/esm/taro-live-pusher-core.entry.js.map +0 -1
  960. package/dist/esm/taro-login-core.entry.js.map +0 -1
  961. package/dist/esm/taro-lottie-core.entry.js.map +0 -1
  962. package/dist/esm/taro-map-core.entry.js.map +0 -1
  963. package/dist/esm/taro-match-media-core.entry.js.map +0 -1
  964. package/dist/esm/taro-movable-area-core_2.entry.js.map +0 -1
  965. package/dist/esm/taro-native-slot-core.entry.js.map +0 -1
  966. package/dist/esm/taro-navigation-bar-core.entry.js.map +0 -1
  967. package/dist/esm/taro-navigator-core.entry.js.map +0 -1
  968. package/dist/esm/taro-official-account-core.entry.js.map +0 -1
  969. package/dist/esm/taro-open-data-core.entry.js.map +0 -1
  970. package/dist/esm/taro-page-container-core.entry.js.map +0 -1
  971. package/dist/esm/taro-page-meta-core.entry.js.map +0 -1
  972. package/dist/esm/taro-picker-core_2.entry.js.map +0 -1
  973. package/dist/esm/taro-picker-view-column-core_2.entry.js.map +0 -1
  974. package/dist/esm/taro-progress-core.entry.js.map +0 -1
  975. package/dist/esm/taro-pull-to-refresh.entry.js.map +0 -1
  976. package/dist/esm/taro-radio-core_2.entry.js.map +0 -1
  977. package/dist/esm/taro-rich-text-core.entry.js.map +0 -1
  978. package/dist/esm/taro-root-portal-core.entry.js.map +0 -1
  979. package/dist/esm/taro-rtc-room-core.entry.js.map +0 -1
  980. package/dist/esm/taro-rtc-room-item-core.entry.js.map +0 -1
  981. package/dist/esm/taro-scroll-view-core.entry.js.map +0 -1
  982. package/dist/esm/taro-share-element-core.entry.js.map +0 -1
  983. package/dist/esm/taro-slider-core.entry.js.map +0 -1
  984. package/dist/esm/taro-slot-core.entry.js.map +0 -1
  985. package/dist/esm/taro-swiper-core_2.entry.js.map +0 -1
  986. package/dist/esm/taro-switch-core.entry.js.map +0 -1
  987. package/dist/esm/taro-tab-item-core.entry.js.map +0 -1
  988. package/dist/esm/taro-tabbar.entry.js.map +0 -1
  989. package/dist/esm/taro-tabs-core.entry.js.map +0 -1
  990. package/dist/esm/taro-text-core.entry.js.map +0 -1
  991. package/dist/esm/taro-textarea-core.entry.js.map +0 -1
  992. package/dist/esm/taro-video-control_3.entry.js.map +0 -1
  993. package/dist/esm/taro-view-core.entry.js.map +0 -1
  994. package/dist/esm/taro-voip-room-core.entry.js.map +0 -1
  995. package/dist/esm/taro-web-view-core.entry.js.map +0 -1
  996. package/dist/esm-es5/helper-3d0ecf0f.js.map +0 -1
  997. package/dist/esm-es5/hls-221423a1.js.map +0 -1
  998. package/dist/esm-es5/index-1d8e8acd.js.map +0 -1
  999. package/dist/esm-es5/index-c948674f.js.map +0 -1
  1000. package/dist/esm-es5/index-d1b03e47.js.map +0 -1
  1001. package/dist/esm-es5/index.js.map +0 -1
  1002. package/dist/esm-es5/intersection-observer-8e4c7135.js.map +0 -1
  1003. package/dist/esm-es5/loader.js.map +0 -1
  1004. package/dist/esm-es5/taro-ad-core.entry.js.map +0 -1
  1005. package/dist/esm-es5/taro-ad-custom-core.entry.js.map +0 -1
  1006. package/dist/esm-es5/taro-animation-video-core.entry.js.map +0 -1
  1007. package/dist/esm-es5/taro-animation-view-core.entry.js.map +0 -1
  1008. package/dist/esm-es5/taro-ar-camera-core.entry.js.map +0 -1
  1009. package/dist/esm-es5/taro-audio-core.entry.js.map +0 -1
  1010. package/dist/esm-es5/taro-aweme-data-core.entry.js.map +0 -1
  1011. package/dist/esm-es5/taro-block-core.entry.js.map +0 -1
  1012. package/dist/esm-es5/taro-button-core.entry.js.map +0 -1
  1013. package/dist/esm-es5/taro-camera-core.entry.js.map +0 -1
  1014. package/dist/esm-es5/taro-canvas-core.entry.js.map +0 -1
  1015. package/dist/esm-es5/taro-checkbox-core_2.entry.js.map +0 -1
  1016. package/dist/esm-es5/taro-comment-detail-core.entry.js.map +0 -1
  1017. package/dist/esm-es5/taro-comment-list-core.entry.js.map +0 -1
  1018. package/dist/esm-es5/taro-components.js.map +0 -1
  1019. package/dist/esm-es5/taro-contact-button-core.entry.js.map +0 -1
  1020. package/dist/esm-es5/taro-cover-image-core.entry.js.map +0 -1
  1021. package/dist/esm-es5/taro-cover-view-core.entry.js.map +0 -1
  1022. package/dist/esm-es5/taro-custom-wrapper-core.entry.js.map +0 -1
  1023. package/dist/esm-es5/taro-editor-core.entry.js.map +0 -1
  1024. package/dist/esm-es5/taro-follow-swan-core.entry.js.map +0 -1
  1025. package/dist/esm-es5/taro-form-core.entry.js.map +0 -1
  1026. package/dist/esm-es5/taro-functional-page-navigator-core.entry.js.map +0 -1
  1027. package/dist/esm-es5/taro-icon-core.entry.js.map +0 -1
  1028. package/dist/esm-es5/taro-image-core.entry.js.map +0 -1
  1029. package/dist/esm-es5/taro-inline-payment-panel-core.entry.js.map +0 -1
  1030. package/dist/esm-es5/taro-input-core.entry.js.map +0 -1
  1031. package/dist/esm-es5/taro-keyboard-accessory-core.entry.js.map +0 -1
  1032. package/dist/esm-es5/taro-label-core.entry.js.map +0 -1
  1033. package/dist/esm-es5/taro-lifestyle-core.entry.js.map +0 -1
  1034. package/dist/esm-es5/taro-like-core.entry.js.map +0 -1
  1035. package/dist/esm-es5/taro-live-player-core.entry.js.map +0 -1
  1036. package/dist/esm-es5/taro-live-pusher-core.entry.js.map +0 -1
  1037. package/dist/esm-es5/taro-login-core.entry.js.map +0 -1
  1038. package/dist/esm-es5/taro-lottie-core.entry.js.map +0 -1
  1039. package/dist/esm-es5/taro-map-core.entry.js.map +0 -1
  1040. package/dist/esm-es5/taro-match-media-core.entry.js.map +0 -1
  1041. package/dist/esm-es5/taro-movable-area-core_2.entry.js.map +0 -1
  1042. package/dist/esm-es5/taro-native-slot-core.entry.js.map +0 -1
  1043. package/dist/esm-es5/taro-navigation-bar-core.entry.js.map +0 -1
  1044. package/dist/esm-es5/taro-navigator-core.entry.js.map +0 -1
  1045. package/dist/esm-es5/taro-official-account-core.entry.js.map +0 -1
  1046. package/dist/esm-es5/taro-open-data-core.entry.js.map +0 -1
  1047. package/dist/esm-es5/taro-page-container-core.entry.js.map +0 -1
  1048. package/dist/esm-es5/taro-page-meta-core.entry.js.map +0 -1
  1049. package/dist/esm-es5/taro-picker-core_2.entry.js.map +0 -1
  1050. package/dist/esm-es5/taro-picker-view-column-core_2.entry.js.map +0 -1
  1051. package/dist/esm-es5/taro-progress-core.entry.js.map +0 -1
  1052. package/dist/esm-es5/taro-pull-to-refresh.entry.js.map +0 -1
  1053. package/dist/esm-es5/taro-radio-core_2.entry.js.map +0 -1
  1054. package/dist/esm-es5/taro-rich-text-core.entry.js.map +0 -1
  1055. package/dist/esm-es5/taro-root-portal-core.entry.js.map +0 -1
  1056. package/dist/esm-es5/taro-rtc-room-core.entry.js.map +0 -1
  1057. package/dist/esm-es5/taro-rtc-room-item-core.entry.js.map +0 -1
  1058. package/dist/esm-es5/taro-scroll-view-core.entry.js.map +0 -1
  1059. package/dist/esm-es5/taro-share-element-core.entry.js.map +0 -1
  1060. package/dist/esm-es5/taro-slider-core.entry.js.map +0 -1
  1061. package/dist/esm-es5/taro-slot-core.entry.js.map +0 -1
  1062. package/dist/esm-es5/taro-swiper-core_2.entry.js.map +0 -1
  1063. package/dist/esm-es5/taro-switch-core.entry.js.map +0 -1
  1064. package/dist/esm-es5/taro-tab-item-core.entry.js.map +0 -1
  1065. package/dist/esm-es5/taro-tabbar.entry.js.map +0 -1
  1066. package/dist/esm-es5/taro-tabs-core.entry.js.map +0 -1
  1067. package/dist/esm-es5/taro-text-core.entry.js.map +0 -1
  1068. package/dist/esm-es5/taro-textarea-core.entry.js.map +0 -1
  1069. package/dist/esm-es5/taro-video-control_3.entry.js.map +0 -1
  1070. package/dist/esm-es5/taro-view-core.entry.js.map +0 -1
  1071. package/dist/esm-es5/taro-voip-room-core.entry.js.map +0 -1
  1072. package/dist/esm-es5/taro-web-view-core.entry.js.map +0 -1
  1073. package/dist/taro-components/index.esm.js.map +0 -1
  1074. package/dist/taro-components/p-020bcd8c.entry.js +0 -2
  1075. package/dist/taro-components/p-020bcd8c.entry.js.map +0 -1
  1076. package/dist/taro-components/p-03d4de13.entry.js.map +0 -1
  1077. package/dist/taro-components/p-05f3f84a.entry.js +0 -2
  1078. package/dist/taro-components/p-05f3f84a.entry.js.map +0 -1
  1079. package/dist/taro-components/p-087bf23a.system.entry.js.map +0 -1
  1080. package/dist/taro-components/p-0895120a.system.entry.js.map +0 -1
  1081. package/dist/taro-components/p-08bb8dfc.system.entry.js.map +0 -1
  1082. package/dist/taro-components/p-09db02e6.entry.js.map +0 -1
  1083. package/dist/taro-components/p-0a165ad3.system.entry.js.map +0 -1
  1084. package/dist/taro-components/p-0a9b984e.system.entry.js.map +0 -1
  1085. package/dist/taro-components/p-0accc602.entry.js.map +0 -1
  1086. package/dist/taro-components/p-0faf45d5.entry.js.map +0 -1
  1087. package/dist/taro-components/p-10046f1a.system.entry.js.map +0 -1
  1088. package/dist/taro-components/p-10be7fb5.system.entry.js.map +0 -1
  1089. package/dist/taro-components/p-15e45ed6.system.js.map +0 -1
  1090. package/dist/taro-components/p-17302fe9.system.entry.js.map +0 -1
  1091. package/dist/taro-components/p-1743a04b.system.js.map +0 -1
  1092. package/dist/taro-components/p-1941d333.system.entry.js.map +0 -1
  1093. package/dist/taro-components/p-19e87e18.entry.js.map +0 -1
  1094. package/dist/taro-components/p-1a0e1932.system.js.map +0 -1
  1095. package/dist/taro-components/p-1c320250.system.entry.js.map +0 -1
  1096. package/dist/taro-components/p-1c446c65.system.js.map +0 -1
  1097. package/dist/taro-components/p-2024e133.system.entry.js.map +0 -1
  1098. package/dist/taro-components/p-2049bdc4.entry.js +0 -2
  1099. package/dist/taro-components/p-2049bdc4.entry.js.map +0 -1
  1100. package/dist/taro-components/p-2357313b.entry.js +0 -2
  1101. package/dist/taro-components/p-2357313b.entry.js.map +0 -1
  1102. package/dist/taro-components/p-24c2fd23.entry.js.map +0 -1
  1103. package/dist/taro-components/p-26889f3c.system.entry.js.map +0 -1
  1104. package/dist/taro-components/p-281278cf.entry.js.map +0 -1
  1105. package/dist/taro-components/p-30f32fa2.system.entry.js.map +0 -1
  1106. package/dist/taro-components/p-30fe0e81.system.entry.js.map +0 -1
  1107. package/dist/taro-components/p-33223303.system.entry.js.map +0 -1
  1108. package/dist/taro-components/p-386ae2b2.entry.js.map +0 -1
  1109. package/dist/taro-components/p-3b1d2d37.system.js.map +0 -1
  1110. package/dist/taro-components/p-3bce88d9.entry.js.map +0 -1
  1111. package/dist/taro-components/p-3f07f3d3.entry.js.map +0 -1
  1112. package/dist/taro-components/p-4086e546.system.entry.js.map +0 -1
  1113. package/dist/taro-components/p-4190e20b.system.entry.js.map +0 -1
  1114. package/dist/taro-components/p-4263c9d9.entry.js.map +0 -1
  1115. package/dist/taro-components/p-46244579.system.entry.js.map +0 -1
  1116. package/dist/taro-components/p-4915fdc1.system.entry.js.map +0 -1
  1117. package/dist/taro-components/p-4a462c95.entry.js.map +0 -1
  1118. package/dist/taro-components/p-4bc85eb7.entry.js.map +0 -1
  1119. package/dist/taro-components/p-4d0da795.system.entry.js.map +0 -1
  1120. package/dist/taro-components/p-50ea2036.system.js.map +0 -1
  1121. package/dist/taro-components/p-518146fd.system.entry.js.map +0 -1
  1122. package/dist/taro-components/p-51b6fc09.system.entry.js.map +0 -1
  1123. package/dist/taro-components/p-51caa3f3.entry.js.map +0 -1
  1124. package/dist/taro-components/p-56da1da3.system.entry.js.map +0 -1
  1125. package/dist/taro-components/p-58877ef2.system.entry.js.map +0 -1
  1126. package/dist/taro-components/p-59590806.system.entry.js.map +0 -1
  1127. package/dist/taro-components/p-5d3acf86.entry.js +0 -2
  1128. package/dist/taro-components/p-5d3acf86.entry.js.map +0 -1
  1129. package/dist/taro-components/p-5f3c65f0.entry.js +0 -2
  1130. package/dist/taro-components/p-5f3c65f0.entry.js.map +0 -1
  1131. package/dist/taro-components/p-603ceecd.entry.js.map +0 -1
  1132. package/dist/taro-components/p-61f225ef.system.js.map +0 -1
  1133. package/dist/taro-components/p-623b3eb6.system.entry.js.map +0 -1
  1134. package/dist/taro-components/p-651586f8.system.entry.js.map +0 -1
  1135. package/dist/taro-components/p-663e27a0.entry.js +0 -2
  1136. package/dist/taro-components/p-663e27a0.entry.js.map +0 -1
  1137. package/dist/taro-components/p-66b07ac0.entry.js.map +0 -1
  1138. package/dist/taro-components/p-67c3a0ba.entry.js +0 -2
  1139. package/dist/taro-components/p-67c3a0ba.entry.js.map +0 -1
  1140. package/dist/taro-components/p-69f6784d.system.entry.js.map +0 -1
  1141. package/dist/taro-components/p-69fa7272.system.entry.js.map +0 -1
  1142. package/dist/taro-components/p-6a96da58.js.map +0 -1
  1143. package/dist/taro-components/p-6bb1fdf2.entry.js.map +0 -1
  1144. package/dist/taro-components/p-6dae898a.system.entry.js.map +0 -1
  1145. package/dist/taro-components/p-6f048097.system.entry.js.map +0 -1
  1146. package/dist/taro-components/p-6f214fc3.system.entry.js.map +0 -1
  1147. package/dist/taro-components/p-72f327e1.js.map +0 -1
  1148. package/dist/taro-components/p-736053bb.system.entry.js.map +0 -1
  1149. package/dist/taro-components/p-74bf8246.system.entry.js.map +0 -1
  1150. package/dist/taro-components/p-76724e58.js.map +0 -1
  1151. package/dist/taro-components/p-76e6fbff.entry.js.map +0 -1
  1152. package/dist/taro-components/p-780870eb.entry.js.map +0 -1
  1153. package/dist/taro-components/p-78c30850.system.entry.js.map +0 -1
  1154. package/dist/taro-components/p-78e3ebb9.js.map +0 -1
  1155. package/dist/taro-components/p-7a2f11dc.entry.js +0 -2
  1156. package/dist/taro-components/p-7a2f11dc.entry.js.map +0 -1
  1157. package/dist/taro-components/p-7c1fec76.entry.js.map +0 -1
  1158. package/dist/taro-components/p-7c6f0d5c.entry.js.map +0 -1
  1159. package/dist/taro-components/p-7dd9c8da.system.entry.js.map +0 -1
  1160. package/dist/taro-components/p-8027e1c6.system.entry.js.map +0 -1
  1161. package/dist/taro-components/p-828bd091.entry.js +0 -2
  1162. package/dist/taro-components/p-828bd091.entry.js.map +0 -1
  1163. package/dist/taro-components/p-8425ff09.entry.js.map +0 -1
  1164. package/dist/taro-components/p-8594d1e5.entry.js +0 -2
  1165. package/dist/taro-components/p-8594d1e5.entry.js.map +0 -1
  1166. package/dist/taro-components/p-8625c29c.entry.js +0 -2
  1167. package/dist/taro-components/p-8625c29c.entry.js.map +0 -1
  1168. package/dist/taro-components/p-88d64daa.system.entry.js.map +0 -1
  1169. package/dist/taro-components/p-88fbacdb.entry.js +0 -2
  1170. package/dist/taro-components/p-88fbacdb.entry.js.map +0 -1
  1171. package/dist/taro-components/p-895cd7c9.system.entry.js.map +0 -1
  1172. package/dist/taro-components/p-8d2101be.system.entry.js.map +0 -1
  1173. package/dist/taro-components/p-8e5cc8fe.system.entry.js.map +0 -1
  1174. package/dist/taro-components/p-908ddbb0.entry.js.map +0 -1
  1175. package/dist/taro-components/p-91f8cd40.entry.js +0 -2
  1176. package/dist/taro-components/p-91f8cd40.entry.js.map +0 -1
  1177. package/dist/taro-components/p-93ccd68a.entry.js +0 -2
  1178. package/dist/taro-components/p-93ccd68a.entry.js.map +0 -1
  1179. package/dist/taro-components/p-955fbcfa.entry.js.map +0 -1
  1180. package/dist/taro-components/p-95f70aea.system.entry.js.map +0 -1
  1181. package/dist/taro-components/p-97782cdd.system.entry.js.map +0 -1
  1182. package/dist/taro-components/p-982e431d.entry.js.map +0 -1
  1183. package/dist/taro-components/p-9bc9f3a0.entry.js +0 -2
  1184. package/dist/taro-components/p-9bc9f3a0.entry.js.map +0 -1
  1185. package/dist/taro-components/p-9d4fa0d3.system.entry.js.map +0 -1
  1186. package/dist/taro-components/p-a23a21e1.entry.js.map +0 -1
  1187. package/dist/taro-components/p-a7789ed6.entry.js.map +0 -1
  1188. package/dist/taro-components/p-adc37a00.entry.js.map +0 -1
  1189. package/dist/taro-components/p-ae3f1ed4.system.entry.js.map +0 -1
  1190. package/dist/taro-components/p-b1249ebb.system.entry.js.map +0 -1
  1191. package/dist/taro-components/p-b1c972e2.system.entry.js.map +0 -1
  1192. package/dist/taro-components/p-b2bb02d7.system.entry.js.map +0 -1
  1193. package/dist/taro-components/p-b313c11a.entry.js +0 -2
  1194. package/dist/taro-components/p-b313c11a.entry.js.map +0 -1
  1195. package/dist/taro-components/p-b39b973e.entry.js.map +0 -1
  1196. package/dist/taro-components/p-b4419d86.entry.js.map +0 -1
  1197. package/dist/taro-components/p-b8ba5d0a.entry.js +0 -2
  1198. package/dist/taro-components/p-b8ba5d0a.entry.js.map +0 -1
  1199. package/dist/taro-components/p-bac3deb0.system.entry.js.map +0 -1
  1200. package/dist/taro-components/p-bba8c3a7.system.entry.js.map +0 -1
  1201. package/dist/taro-components/p-bd5177d3.system.js.map +0 -1
  1202. package/dist/taro-components/p-c0bb8610.entry.js.map +0 -1
  1203. package/dist/taro-components/p-c1c0e16d.entry.js +0 -2
  1204. package/dist/taro-components/p-c1c0e16d.entry.js.map +0 -1
  1205. package/dist/taro-components/p-c2ac8f08.entry.js.map +0 -1
  1206. package/dist/taro-components/p-c33733b3.system.entry.js.map +0 -1
  1207. package/dist/taro-components/p-c3e98fdf.entry.js.map +0 -1
  1208. package/dist/taro-components/p-c4fdb669.system.entry.js.map +0 -1
  1209. package/dist/taro-components/p-c50087fd.entry.js.map +0 -1
  1210. package/dist/taro-components/p-c586a796.system.entry.js.map +0 -1
  1211. package/dist/taro-components/p-c6385fc2.system.entry.js.map +0 -1
  1212. package/dist/taro-components/p-c6e6dab1.system.entry.js.map +0 -1
  1213. package/dist/taro-components/p-c70dd956.system.entry.js.map +0 -1
  1214. package/dist/taro-components/p-d1d19ce9.entry.js +0 -2
  1215. package/dist/taro-components/p-d1d19ce9.entry.js.map +0 -1
  1216. package/dist/taro-components/p-d3c7f87d.js.map +0 -1
  1217. package/dist/taro-components/p-d5234e7e.js.map +0 -1
  1218. package/dist/taro-components/p-d562aae3.entry.js +0 -2
  1219. package/dist/taro-components/p-d562aae3.entry.js.map +0 -1
  1220. package/dist/taro-components/p-d61d3394.entry.js.map +0 -1
  1221. package/dist/taro-components/p-d621d190.entry.js +0 -2
  1222. package/dist/taro-components/p-d621d190.entry.js.map +0 -1
  1223. package/dist/taro-components/p-d8c8c63f.entry.js +0 -2
  1224. package/dist/taro-components/p-d8c8c63f.entry.js.map +0 -1
  1225. package/dist/taro-components/p-da5cdbf5.system.entry.js.map +0 -1
  1226. package/dist/taro-components/p-de2d8e2e.system.entry.js.map +0 -1
  1227. package/dist/taro-components/p-de356b29.system.entry.js.map +0 -1
  1228. package/dist/taro-components/p-e0e4a403.entry.js.map +0 -1
  1229. package/dist/taro-components/p-e3f8265d.system.entry.js.map +0 -1
  1230. package/dist/taro-components/p-e53feb03.system.entry.js.map +0 -1
  1231. package/dist/taro-components/p-e67165fd.entry.js +0 -2
  1232. package/dist/taro-components/p-e67165fd.entry.js.map +0 -1
  1233. package/dist/taro-components/p-eb2a7609.entry.js.map +0 -1
  1234. package/dist/taro-components/p-eb9adf17.entry.js.map +0 -1
  1235. package/dist/taro-components/p-ef4c1fd4.entry.js +0 -2
  1236. package/dist/taro-components/p-ef4c1fd4.entry.js.map +0 -1
  1237. package/dist/taro-components/p-ef7e7d73.system.entry.js.map +0 -1
  1238. package/dist/taro-components/p-efa51030.system.entry.js.map +0 -1
  1239. package/dist/taro-components/p-efe31b23.entry.js +0 -2
  1240. package/dist/taro-components/p-efe31b23.entry.js.map +0 -1
  1241. package/dist/taro-components/p-f034fb11.system.entry.js +0 -2
  1242. package/dist/taro-components/p-f034fb11.system.entry.js.map +0 -1
  1243. package/dist/taro-components/p-f499c0a0.system.entry.js.map +0 -1
  1244. package/dist/taro-components/p-f88f0f55.entry.js +0 -2
  1245. package/dist/taro-components/p-f88f0f55.entry.js.map +0 -1
  1246. package/dist/taro-components/p-f9ac515e.system.entry.js.map +0 -1
  1247. package/dist/taro-components/p-fa36fe8e.system.entry.js.map +0 -1
  1248. package/dist/taro-components/p-fcdac6ec.system.entry.js.map +0 -1
  1249. package/dist/taro-components/p-fda82bc1.entry.js.map +0 -1
  1250. package/dist/taro-components/p-fe58b450.entry.js +0 -2
  1251. package/dist/taro-components/p-fe58b450.entry.js.map +0 -1
  1252. package/dist/taro-components/p-fec6746d.entry.js +0 -2
  1253. package/dist/taro-components/p-fec6746d.entry.js.map +0 -1
  1254. package/dist/taro-components/taro-components.esm.js.map +0 -1
@@ -1,366 +1,365 @@
1
- import{g as t,a as i,b as r}from"./p-76724e58.js";var e=i((function(t,i){typeof window!=="undefined"&&function i(r,e){t.exports=e()}(r,(function(){return function(t){var i={};function r(e){if(i[e]){return i[e].exports}var n=i[e]={i:e,l:false,exports:{}};t[e].call(n.exports,n,n.exports,r);n.l=true;return n.exports}r.m=t;r.c=i;r.d=function(t,i,e){if(!r.o(t,i)){Object.defineProperty(t,i,{enumerable:true,get:e})}};r.r=function(t){if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(t,"__esModule",{value:true})};r.t=function(t,i){if(i&1)t=r(t);if(i&8)return t;if(i&4&&typeof t==="object"&&t&&t.__esModule)return t;var e=Object.create(null);r.r(e);Object.defineProperty(e,"default",{enumerable:true,value:t});if(i&2&&typeof t!="string")for(var n in t)r.d(e,n,function(i){return t[i]}.bind(null,n));return e};r.n=function(t){var i=t&&t.__esModule?function i(){return t["default"]}:function i(){return t};r.d(i,"a",i);return i};r.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)};r.p="/dist/";return r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
1
+ import{g as t,a as i,b as n}from"./p-76724e58.js";var r=i((function(t){var i;"undefined"!=typeof window&&(i=function(){return function(t){var i={};function n(r){if(i[r])return i[r].exports;var e=i[r]={i:r,l:!1,exports:{}};return t[r].call(e.exports,e,e.exports,n),e.l=!0,e.exports}return n.m=t,n.c=i,n.d=function(t,i,r){n.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,i){if(1&i&&(t=n(t)),8&i)return t;if(4&i&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&i&&"string"!=typeof t)for(var e in t)n.d(r,e,function(i){return t[i]}.bind(null,e));return r},n.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(i,"a",i),i},n.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},n.p="/dist/",n(n.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
2
2
  /*!*********************************************!*\
3
3
  !*** ./node_modules/eventemitter3/index.js ***!
4
4
  \*********************************************/
5
- /*! no static exports found */function(t,i,r){var e=Object.prototype.hasOwnProperty,n="~";function s(){}if(Object.create){s.prototype=Object.create(null);if(!(new s).__proto__)n=false}function a(t,i,r){this.fn=t;this.context=i;this.once=r||false}function u(t,i,r,e,s){if(typeof r!=="function"){throw new TypeError("The listener must be a function")}var u=new a(r,e||t,s),f=n?n+i:i;if(!t._events[f])t._events[f]=u,t._eventsCount++;else if(!t._events[f].fn)t._events[f].push(u);else t._events[f]=[t._events[f],u];return t}function f(t,i){if(--t._eventsCount===0)t._events=new s;else delete t._events[i]}function h(){this._events=new s;this._eventsCount=0}h.prototype.eventNames=function t(){var i=[],r,s;if(this._eventsCount===0)return i;for(s in r=this._events){if(e.call(r,s))i.push(n?s.slice(1):s)}if(Object.getOwnPropertySymbols){return i.concat(Object.getOwnPropertySymbols(r))}return i};h.prototype.listeners=function t(i){var r=n?n+i:i,e=this._events[r];if(!e)return[];if(e.fn)return[e.fn];for(var s=0,a=e.length,u=new Array(a);s<a;s++){u[s]=e[s].fn}return u};h.prototype.listenerCount=function t(i){var r=n?n+i:i,e=this._events[r];if(!e)return 0;if(e.fn)return 1;return e.length};h.prototype.emit=function t(i,r,e,s,a,u){var f=n?n+i:i;if(!this._events[f])return false;var h=this._events[f],o=arguments.length,v,l;if(h.fn){if(h.once)this.removeListener(i,h.fn,undefined,true);switch(o){case 1:return h.fn.call(h.context),true;case 2:return h.fn.call(h.context,r),true;case 3:return h.fn.call(h.context,r,e),true;case 4:return h.fn.call(h.context,r,e,s),true;case 5:return h.fn.call(h.context,r,e,s,a),true;case 6:return h.fn.call(h.context,r,e,s,a,u),true}for(l=1,v=new Array(o-1);l<o;l++){v[l-1]=arguments[l]}h.fn.apply(h.context,v)}else{var c=h.length,d;for(l=0;l<c;l++){if(h[l].once)this.removeListener(i,h[l].fn,undefined,true);switch(o){case 1:h[l].fn.call(h[l].context);break;case 2:h[l].fn.call(h[l].context,r);break;case 3:h[l].fn.call(h[l].context,r,e);break;case 4:h[l].fn.call(h[l].context,r,e,s);break;default:if(!v)for(d=1,v=new Array(o-1);d<o;d++){v[d-1]=arguments[d]}h[l].fn.apply(h[l].context,v)}}}return true};h.prototype.on=function t(i,r,e){return u(this,i,r,e,false)};h.prototype.once=function t(i,r,e){return u(this,i,r,e,true)};h.prototype.removeListener=function t(i,r,e,s){var a=n?n+i:i;if(!this._events[a])return this;if(!r){f(this,a);return this}var u=this._events[a];if(u.fn){if(u.fn===r&&(!s||u.once)&&(!e||u.context===e)){f(this,a)}}else{for(var h=0,o=[],v=u.length;h<v;h++){if(u[h].fn!==r||s&&!u[h].once||e&&u[h].context!==e){o.push(u[h])}}if(o.length)this._events[a]=o.length===1?o[0]:o;else f(this,a)}return this};h.prototype.removeAllListeners=function t(i){var r;if(i){r=n?n+i:i;if(this._events[r])f(this,r)}else{this._events=new s;this._eventsCount=0}return this};h.prototype.off=h.prototype.removeListener;h.prototype.addListener=h.prototype.on;h.prefixed=n;h.EventEmitter=h;{t.exports=h}},"./node_modules/url-toolkit/src/url-toolkit.js":
5
+ /*! no static exports found */function(t){var i=Object.prototype.hasOwnProperty,n="~";function r(){}function e(t,i,n){this.fn=t,this.context=i,this.once=n||!1}function s(t,i,r,s,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new e(r,s||t,a),h=n?n+i:i;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function a(t,i){0==--t._eventsCount?t._events=new r:delete t._events[i]}function o(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),o.prototype.eventNames=function(){var t,r,e=[];if(0===this._eventsCount)return e;for(r in t=this._events)i.call(t,r)&&e.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},o.prototype.listeners=function(t){var i=this._events[n?n+t:t];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,e=i.length,s=new Array(e);r<e;r++)s[r]=i[r].fn;return s},o.prototype.listenerCount=function(t){var i=this._events[n?n+t:t];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,i,r,e,s,a){var o=n?n+t:t;if(!this._events[o])return!1;var h,u,c=this._events[o],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,i),!0;case 3:return c.fn.call(c.context,i,r),!0;case 4:return c.fn.call(c.context,i,r,e),!0;case 5:return c.fn.call(c.context,i,r,e,s),!0;case 6:return c.fn.call(c.context,i,r,e,s,a),!0}for(u=1,h=new Array(f-1);u<f;u++)h[u-1]=arguments[u];c.fn.apply(c.context,h)}else{var l,v=c.length;for(u=0;u<v;u++)switch(c[u].once&&this.removeListener(t,c[u].fn,void 0,!0),f){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,i);break;case 3:c[u].fn.call(c[u].context,i,r);break;case 4:c[u].fn.call(c[u].context,i,r,e);break;default:if(!h)for(l=1,h=new Array(f-1);l<f;l++)h[l-1]=arguments[l];c[u].fn.apply(c[u].context,h)}}return!0},o.prototype.on=function(t,i,n){return s(this,t,i,n,!1)},o.prototype.once=function(t,i,n){return s(this,t,i,n,!0)},o.prototype.removeListener=function(t,i,r,e){var s=n?n+t:t;if(!this._events[s])return this;if(!i)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==i||e&&!o.once||r&&o.context!==r||a(this,s);else{for(var h=0,u=[],c=o.length;h<c;h++)(o[h].fn!==i||e&&!o[h].once||r&&o[h].context!==r)&&u.push(o[h]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},o.prototype.removeAllListeners=function(t){var i;return t?this._events[i=n?n+t:t]&&a(this,i):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o},"./node_modules/url-toolkit/src/url-toolkit.js":
6
6
  /*!*****************************************************!*\
7
7
  !*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
8
8
  \*****************************************************/
9
- /*! no static exports found */function(t,i,r){(function(i){var r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/;var e=/^([^\/?#]*)([^]*)$/;var n=/(?:\/|^)\.(?=\/)/g;var s=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g;var a={buildAbsoluteURL:function(t,i,r){r=r||{};t=t.trim();i=i.trim();if(!i){if(!r.alwaysNormalize){return t}var n=a.parseURL(t);if(!n){throw new Error("Error trying to parse base URL.")}n.path=a.normalizePath(n.path);return a.buildURLFromParts(n)}var s=a.parseURL(i);if(!s){throw new Error("Error trying to parse relative URL.")}if(s.scheme){if(!r.alwaysNormalize){return i}s.path=a.normalizePath(s.path);return a.buildURLFromParts(s)}var u=a.parseURL(t);if(!u){throw new Error("Error trying to parse base URL.")}if(!u.netLoc&&u.path&&u.path[0]!=="/"){var f=e.exec(u.path);u.netLoc=f[1];u.path=f[2]}if(u.netLoc&&!u.path){u.path="/"}var h={scheme:u.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc){h.netLoc=u.netLoc;if(s.path[0]!=="/"){if(!s.path){h.path=u.path;if(!s.params){h.params=u.params;if(!s.query){h.query=u.query}}}else{var o=u.path;var v=o.substring(0,o.lastIndexOf("/")+1)+s.path;h.path=a.normalizePath(v)}}}if(h.path===null){h.path=r.alwaysNormalize?a.normalizePath(s.path):s.path}return a.buildURLFromParts(h)},parseURL:function(t){var i=r.exec(t);if(!i){return null}return{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}},normalizePath:function(t){t=t.split("").reverse().join("").replace(n,"");while(t.length!==(t=t.replace(s,"")).length){}return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};t.exports=a})()},"./node_modules/webworkify-webpack/index.js":
9
+ /*! no static exports found */function(t){var i,n,r,e,s;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,n=/^([^\/?#]*)([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,e=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,t.exports=s={buildAbsoluteURL:function(t,i,r){if(r=r||{},t=t.trim(),!(i=i.trim())){if(!r.alwaysNormalize)return t;var e=s.parseURL(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=s.normalizePath(e.path),s.buildURLFromParts(e)}var a=s.parseURL(i);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):i;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var h=n.exec(o.path);o.netLoc=h[1],o.path=h[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var c=o.path,f=c.substring(0,c.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(f)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(t){var n=i.exec(t);return n?{scheme:n[1]||"",netLoc:n[2]||"",path:n[3]||"",params:n[4]||"",query:n[5]||"",fragment:n[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(e,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}}},"./node_modules/webworkify-webpack/index.js":
10
10
  /*!**************************************************!*\
11
11
  !*** ./node_modules/webworkify-webpack/index.js ***!
12
12
  \**************************************************/
13
- /*! no static exports found */function(t,i,r){function e(t){var i={};function r(e){if(i[e])return i[e].exports;var n=i[e]={i:e,l:false,exports:{}};t[e].call(n.exports,n,n.exports,r);n.l=true;return n.exports}r.m=t;r.c=i;r.i=function(t){return t};r.d=function(t,i,e){if(!r.o(t,i)){Object.defineProperty(t,i,{configurable:false,enumerable:true,get:e})}};r.r=function(t){Object.defineProperty(t,"__esModule",{value:true})};r.n=function(t){var i=t&&t.__esModule?function i(){return t["default"]}:function i(){return t};r.d(i,"a",i);return i};r.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)};r.p="/";r.oe=function(t){console.error(t);throw t};var e=r(r.s=ENTRY_MODULE);return e.default||e}var n="[\\.|\\-|\\+|\\w|/|@]+";var s="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+n+").*?\\)";function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function u(t){return!isNaN(1*t)}function f(t,i,e){var f={};f[e]=[];var h=i.toString();var o=h.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!o)return f;var v=o[1];var l=new RegExp("(\\\\n|\\W)"+a(v)+s,"g");var c;while(c=l.exec(h)){if(c[3]==="dll-reference")continue;f[e].push(c[3])}l=new RegExp("\\("+a(v)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+s,"g");while(c=l.exec(h)){if(!t[c[2]]){f[e].push(c[1]);t[c[2]]=r(c[1]).m}f[c[2]]=f[c[2]]||[];f[c[2]].push(c[4])}var d=Object.keys(f);for(var m=0;m<d.length;m++){for(var p=0;p<f[d[m]].length;p++){if(u(f[d[m]][p])){f[d[m]][p]=1*f[d[m]][p]}}}return f}function h(t){var i=Object.keys(t);return i.reduce((function(i,r){return i||t[r].length>0}),false)}function o(t,i){var r={main:[i]};var e={main:[]};var n={main:{}};while(h(r)){var s=Object.keys(r);for(var a=0;a<s.length;a++){var u=s[a];var o=r[u];var v=o.pop();n[u]=n[u]||{};if(n[u][v]||!t[u][v])continue;n[u][v]=true;e[u]=e[u]||[];e[u].push(v);var l=f(t,t[u][v],u);var c=Object.keys(l);for(var d=0;d<c.length;d++){r[c[d]]=r[c[d]]||[];r[c[d]]=r[c[d]].concat(l[c[d]])}}}return e}t.exports=function(t,i){i=i||{};var n={main:r.m};var s=i.all?{main:Object.keys(n.main)}:o(n,t);var a="";Object.keys(s).filter((function(t){return t!=="main"})).forEach((function(t){var i=0;while(s[t][i]){i++}s[t].push(i);n[t][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })";a=a+"var "+t+" = ("+e.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+s[t].map((function(i){return""+JSON.stringify(i)+": "+n[t][i].toString()})).join(",")+"});\n"}));a=a+"new (("+e.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+s.main.map((function(t){return""+JSON.stringify(t)+": "+n.main[t].toString()})).join(",")+"}))(self);";var u=new window.Blob([a],{type:"text/javascript"});if(i.bare){return u}var f=window.URL||window.webkitURL||window.mozURL||window.msURL;var h=f.createObjectURL(u);var v=new window.Worker(h);v.objectURL=h;return v}},"./src/config.ts":
13
+ /*! no static exports found */function(t,i,n){function r(t){var i={};function n(r){if(i[r])return i[r].exports;var e=i[r]={i:r,l:!1,exports:{}};return t[r].call(e.exports,e,e.exports,n),e.l=!0,e.exports}n.m=t,n.c=i,n.i=function(t){return t},n.d=function(t,i,r){n.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(i,"a",i),i},n.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},n.p="/",n.oe=function(t){throw console.error(t),t};var r=n(n.s=ENTRY_MODULE);return r.default||r}var e="[\\.|\\-|\\+|\\w|/|@]+",s="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+e+").*?\\)";function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(t,i,r){var o={};o[r]=[];var h=i.toString(),u=h.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return o;for(var c,f=u[1],l=new RegExp("(\\\\n|\\W)"+a(f)+s,"g");c=l.exec(h);)"dll-reference"!==c[3]&&o[r].push(c[3]);for(l=new RegExp("\\("+a(f)+'\\("(dll-reference\\s('+e+'))"\\)\\)'+s,"g");c=l.exec(h);)t[c[2]]||(o[r].push(c[1]),t[c[2]]=n(c[1]).m),o[c[2]]=o[c[2]]||[],o[c[2]].push(c[4]);for(var v=Object.keys(o),d=0;d<v.length;d++)for(var m=0;m<o[v[d]].length;m++)isNaN(1*o[v[d]][m])||(o[v[d]][m]=1*o[v[d]][m]);return o}function h(t){return Object.keys(t).reduce((function(i,n){return i||t[n].length>0}),!1)}t.exports=function(t,i){var e={main:n.m},s=(i=i||{}).all?{main:Object.keys(e.main)}:function(t,i){for(var n={main:[i]},r={main:[]},e={main:{}};h(n);)for(var s=Object.keys(n),a=0;a<s.length;a++){var u=s[a],c=n[u].pop();if(e[u]=e[u]||{},!e[u][c]&&t[u][c]){e[u][c]=!0,r[u]=r[u]||[],r[u].push(c);for(var f=o(t,t[u][c],u),l=Object.keys(f),v=0;v<l.length;v++)n[l[v]]=n[l[v]]||[],n[l[v]]=n[l[v]].concat(f[l[v]])}}return r}(e,t),a="";Object.keys(s).filter((function(t){return"main"!==t})).forEach((function(t){for(var i=0;s[t][i];)i++;s[t].push(i),e[t][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+t+" = ("+r.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+s[t].map((function(i){return JSON.stringify(i)+": "+e[t][i].toString()})).join(",")+"});\n"})),a=a+"new (("+r.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+s.main.map((function(t){return JSON.stringify(t)+": "+e.main[t].toString()})).join(",")+"}))(self);";var u=new window.Blob([a],{type:"text/javascript"});if(i.bare)return u;var c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(u),f=new window.Worker(c);return f.objectURL=c,f}},"./src/config.ts":
14
14
  /*!***********************!*\
15
15
  !*** ./src/config.ts ***!
16
16
  \***********************/
17
- /*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,i,r){r.r(i);r.d(i,"hlsDefaultConfig",(function(){return O}));r.d(i,"mergeConfig",(function(){return E}));r.d(i,"enableStreamingMode",(function(){return A}));var e=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts");var n=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts");var s=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts");var a=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts");var u=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts");var f=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts");var h=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts");var o=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts");var v=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts");var l=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts");var c=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts");var d=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts");var m=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts");var p=r(/*! ./utils/cues */"./src/utils/cues.ts");var g=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");var b=r(/*! ./utils/logger */"./src/utils/logger.ts");function y(){y=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return y.apply(this,arguments)}function w(t,i){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);if(i){e=e.filter((function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable}))}r.push.apply(r,e)}return r}function k(t){for(var i=1;i<arguments.length;i++){var r=arguments[i]!=null?arguments[i]:{};if(i%2){w(Object(r),true).forEach((function(i){T(t,i,r[i])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(t,Object.getOwnPropertyDescriptors(r))}else{w(Object(r)).forEach((function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(r,i))}))}}return t}function T(t,i,r){if(i in t){Object.defineProperty(t,i,{value:r,enumerable:true,configurable:true,writable:true})}else{t[i]=r}return t}var O=k(k({autoStartLoad:true,startPosition:-1,defaultAudioCodec:undefined,debug:false,capLevelOnFPSDrop:false,capLevelToPlayerSize: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,enableSoftwareAES:true,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:undefined,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:false,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:d["default"],fLoader:undefined,pLoader:undefined,xhrSetup:undefined,licenseXhrSetup:undefined,licenseResponseCallback:undefined,abrController:e["default"],bufferController:f["default"],capLevelController:o["default"],fpsController:v["default"],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,drmSystemOptions:{},requestMediaKeySystemAccessFunc:g["requestMediaKeySystemAccess"],testBandwidth:true,progressive:false,lowLatencyMode:true,cmcd:undefined},S()),{},{subtitleStreamController:a["SubtitleStreamController"],subtitleTrackController:u["default"],timelineController:h["TimelineController"],audioStreamController:n["default"],audioTrackController:s["default"],emeController:l["default"],cmcdController:c["default"]});function S(){return{cueHandler:p["default"],enableCEA708Captions:true,enableWebVTT:true,enableIMSC1:true,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:true}}function E(t,i){if((i.liveSyncDurationCount||i.liveMaxLatencyDurationCount)&&(i.liveSyncDuration||i.liveMaxLatencyDuration)){throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration")}if(i.liveMaxLatencyDurationCount!==undefined&&(i.liveSyncDurationCount===undefined||i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount)){throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"')}if(i.liveMaxLatencyDuration!==undefined&&(i.liveSyncDuration===undefined||i.liveMaxLatencyDuration<=i.liveSyncDuration)){throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"')}return y({},t,i)}function A(t){var i=t.loader;if(i!==m["default"]&&i!==d["default"]){b["logger"].log("[config]: Custom loader detected, cannot enable progressive streaming");t.progressive=false}else{var r=Object(m["fetchSupported"])();if(r){t.loader=m["default"];t.progressive=true;t.enableSoftwareAES=true;b["logger"].log("[config]: Progressive streaming enabled, using FetchLoader")}}}},"./src/controller/abr-controller.ts":
17
+ /*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,i,n){n.r(i),n.d(i,"hlsDefaultConfig",(function(){return O})),n.d(i,"mergeConfig",(function(){return S})),n.d(i,"enableStreamingMode",(function(){return E}));var r=n(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),e=n(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),s=n(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),a=n(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=n(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),h=n(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=n(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),c=n(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),f=n(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),l=n(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),v=n(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),d=n(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),m=n(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),p=n(/*! ./utils/cues */"./src/utils/cues.ts"),g=n(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),b=n(/*! ./utils/logger */"./src/utils/logger.ts");function y(){return y=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y.apply(this,arguments)}function w(t,i){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);i&&(r=r.filter((function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable}))),n.push.apply(n,r)}return n}function k(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?w(Object(n),!0).forEach((function(i){T(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))}))}return t}function T(t,i,n){return i in t?Object.defineProperty(t,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[i]=n,t}var O=k(k({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:d.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:r.default,bufferController:h.default,capLevelController:c.default,fpsController:f.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:g.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},{cueHandler:p.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:a.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:e.default,audioTrackController:s.default,emeController:l.default,cmcdController:v.default});function S(t,i){if((i.liveSyncDurationCount||i.liveMaxLatencyDurationCount)&&(i.liveSyncDuration||i.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==i.liveMaxLatencyDurationCount&&(void 0===i.liveSyncDurationCount||i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==i.liveMaxLatencyDuration&&(void 0===i.liveSyncDuration||i.liveMaxLatencyDuration<=i.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return y({},t,i)}function E(t){var i=t.loader;i!==m.default&&i!==d.default?(b.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):Object(m.fetchSupported)()&&(t.loader=m.default,t.progressive=!0,t.enableSoftwareAES=!0,b.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
18
18
  /*!******************************************!*\
19
19
  !*** ./src/controller/abr-controller.ts ***!
20
20
  \******************************************/
21
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts");var s=r(/*! ../events */"./src/events.ts");var a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var u=r(/*! ../errors */"./src/errors.ts");var f=r(/*! ../types/loader */"./src/types/loader.ts");var h=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function v(t,i,r){if(i)o(t.prototype,i);if(r)o(t,r);return t}var l=function(){function t(t){this.hls=void 0;this.lastLoadedFragLevel=0;this._nextAutoLevel=-1;this.timer=void 0;this.onCheck=this._abandonRulesCheck.bind(this);this.fragCurrent=null;this.partCurrent=null;this.bitrateTestDelay=0;this.bwEstimator=void 0;this.hls=t;var i=t.config;this.bwEstimator=new n["default"](i.abrEwmaSlowVoD,i.abrEwmaFastVoD,i.abrEwmaDefaultEstimate);this.registerListeners()}var i=t.prototype;i.registerListeners=function t(){var i=this.hls;i.on(s["Events"].FRAG_LOADING,this.onFragLoading,this);i.on(s["Events"].FRAG_LOADED,this.onFragLoaded,this);i.on(s["Events"].FRAG_BUFFERED,this.onFragBuffered,this);i.on(s["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(s["Events"].ERROR,this.onError,this)};i.unregisterListeners=function t(){var i=this.hls;i.off(s["Events"].FRAG_LOADING,this.onFragLoading,this);i.off(s["Events"].FRAG_LOADED,this.onFragLoaded,this);i.off(s["Events"].FRAG_BUFFERED,this.onFragBuffered,this);i.off(s["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(s["Events"].ERROR,this.onError,this)};i.destroy=function t(){this.unregisterListeners();this.clearTimer();this.hls=this.onCheck=null;this.fragCurrent=this.partCurrent=null};i.onFragLoading=function t(i,r){var e=r.frag;if(e.type===f["PlaylistLevelType"].MAIN){if(!this.timer){var n;this.fragCurrent=e;this.partCurrent=(n=r.part)!=null?n:null;this.timer=self.setInterval(this.onCheck,100)}}};i.onLevelLoaded=function t(i,r){var e=this.hls.config;if(r.details.live){this.bwEstimator.update(e.abrEwmaSlowLive,e.abrEwmaFastLive)}else{this.bwEstimator.update(e.abrEwmaSlowVoD,e.abrEwmaFastVoD)}};i._abandonRulesCheck=function t(){var i=this.fragCurrent,r=this.partCurrent,n=this.hls;var u=n.autoLevelEnabled,f=n.config,o=n.media;if(!i||!o){return}var v=r?r.stats:i.stats;var l=r?r.duration:i.duration;if(v.aborted){h["logger"].warn("frag loader destroy or aborted, disarm abandonRules");this.clearTimer();this._nextAutoLevel=-1;return}if(!u||o.paused||!o.playbackRate||!o.readyState){return}var c=performance.now()-v.loading.start;var d=Math.abs(o.playbackRate);if(c<=500*l/d){return}var m=n.levels,p=n.minAutoLevel;var g=m[i.level];var b=v.total||Math.max(v.loaded,Math.round(l*g.maxBitrate/8));var y=Math.max(1,v.bwEstimate?v.bwEstimate/8:v.loaded*1e3/c);var w=(b-v.loaded)/y;var k=o.currentTime;var T=(a["BufferHelper"].bufferInfo(o,k,f.maxBufferHole).end-k)/d;if(T>=2*l/d||w<=T){return}var O=Number.POSITIVE_INFINITY;var S;for(S=i.level-1;S>p;S--){var E=m[S].maxBitrate;O=l*E/(8*.8*y);if(O<T){break}}if(O>=w){return}var A=this.bwEstimator.getEstimate();h["logger"].warn("Fragment "+i.sn+(r?" part "+r.index:"")+" of level "+i.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+S+"\n Current BW estimate: "+(Object(e["isFiniteNumber"])(A)?(A/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+w.toFixed(3)+" s\n Estimated load time for the next fragment: "+O.toFixed(3)+" s\n Time to underbuffer: "+T.toFixed(3)+" s");n.nextLoadLevel=S;this.bwEstimator.sample(c,v.loaded);this.clearTimer();if(i.loader){this.fragCurrent=this.partCurrent=null;i.loader.abort()}n.trigger(s["Events"].FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:r,stats:v})};i.onFragLoaded=function t(i,r){var n=r.frag,a=r.part;if(n.type===f["PlaylistLevelType"].MAIN&&Object(e["isFiniteNumber"])(n.sn)){var u=a?a.stats:n.stats;var h=a?a.duration:n.duration;this.clearTimer();this.lastLoadedFragLevel=n.level;this._nextAutoLevel=-1;if(this.hls.config.abrMaxWithRealBitrate){var o=this.hls.levels[n.level];var v=(o.loaded?o.loaded.bytes:0)+u.loaded;var l=(o.loaded?o.loaded.duration:0)+h;o.loaded={bytes:v,duration:l};o.realBitrate=Math.round(8*v/l)}if(n.bitrateTest){var c={stats:u,frag:n,part:a,id:n.type};this.onFragBuffered(s["Events"].FRAG_BUFFERED,c);n.bitrateTest=false}}};i.onFragBuffered=function t(i,r){var e=r.frag,n=r.part;var s=n?n.stats:e.stats;if(s.aborted){return}if(e.type!==f["PlaylistLevelType"].MAIN||e.sn==="initSegment"){return}var a=s.parsing.end-s.loading.start;this.bwEstimator.sample(a,s.loaded);s.bwEstimate=this.bwEstimator.getEstimate();if(e.bitrateTest){this.bitrateTestDelay=a/1e3}else{this.bitrateTestDelay=0}};i.onError=function t(i,r){switch(r.details){case u["ErrorDetails"].FRAG_LOAD_ERROR:case u["ErrorDetails"].FRAG_LOAD_TIMEOUT:this.clearTimer();break}};i.clearTimer=function t(){self.clearInterval(this.timer);this.timer=undefined};i.getNextABRAutoLevel=function t(){var i=this.fragCurrent,r=this.partCurrent,e=this.hls;var n=e.maxAutoLevel,s=e.config,u=e.minAutoLevel,f=e.media;var o=r?r.duration:i?i.duration:0;var v=f?f.currentTime:0;var l=f&&f.playbackRate!==0?Math.abs(f.playbackRate):1;var c=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate;var d=(a["BufferHelper"].bufferInfo(f,v,s.maxBufferHole).end-v)/l;var m=this.findBestLevel(c,u,n,d,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(m>=0){return m}h["logger"].trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var p=o?Math.min(o,s.maxStarvationDelay):s.maxStarvationDelay;var g=s.abrBandWidthFactor;var b=s.abrBandWidthUpFactor;if(!d){var y=this.bitrateTestDelay;if(y){var w=o?Math.min(o,s.maxLoadingDelay):s.maxLoadingDelay;p=w-y;h["logger"].trace("bitrate test took "+Math.round(1e3*y)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms");g=b=1}}m=this.findBestLevel(c,u,n,d+p,g,b);return Math.max(m,0)};i.findBestLevel=function t(i,r,e,n,s,a){var u;var f=this.fragCurrent,o=this.partCurrent,v=this.lastLoadedFragLevel;var l=this.hls.levels;var c=l[v];var d=!!(c!==null&&c!==void 0&&(u=c.details)!==null&&u!==void 0&&u.live);var m=c===null||c===void 0?void 0:c.codecSet;var p=o?o.duration:f?f.duration:0;for(var g=e;g>=r;g--){var b=l[g];if(!b||m&&b.codecSet!==m){continue}var y=b.details;var w=(o?y===null||y===void 0?void 0:y.partTarget:y===null||y===void 0?void 0:y.averagetargetduration)||p;var k=void 0;if(g<=v){k=s*i}else{k=a*i}var T=l[g].maxBitrate;var O=T*w/k;h["logger"].trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+g+"/"+Math.round(k)+"/"+T+"/"+w+"/"+n+"/"+O);if(k>T&&(!O||d&&!this.bitrateTestDelay||O<n)){return g}}return-1};v(t,[{key:"nextAutoLevel",get:function t(){var i=this._nextAutoLevel;var r=this.bwEstimator;if(i!==-1&&(!r||!r.canEstimate())){return i}var e=this.getNextABRAutoLevel();if(i!==-1){e=Math.min(i,e)}return e},set:function t(i){this._nextAutoLevel=i}}]);return t}();i["default"]=l},"./src/controller/audio-stream-controller.ts":
21
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),s=n(/*! ../events */"./src/events.ts"),a=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=n(/*! ../errors */"./src/errors.ts"),h=n(/*! ../types/loader */"./src/types/loader.ts"),u=n(/*! ../utils/logger */"./src/utils/logger.ts");function c(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var f=function(){function t(t){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var i=t.config;this.bwEstimator=new e.default(i.abrEwmaSlowVoD,i.abrEwmaFastVoD,i.abrEwmaDefaultEstimate),this.registerListeners()}var i,n,f=t.prototype;return f.registerListeners=function(){var t=this.hls;t.on(s.Events.FRAG_LOADING,this.onFragLoading,this),t.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(s.Events.FRAG_LOADING,this.onFragLoading,this),t.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},f.onFragLoading=function(t,i){var n,r=i.frag;r.type===h.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=r,this.partCurrent=null!=(n=i.part)?n:null,this.timer=self.setInterval(this.onCheck,100)))},f.onLevelLoaded=function(t,i){var n=this.hls.config;i.details.live?this.bwEstimator.update(n.abrEwmaSlowLive,n.abrEwmaFastLive):this.bwEstimator.update(n.abrEwmaSlowVoD,n.abrEwmaFastVoD)},f._abandonRulesCheck=function(){var t=this.fragCurrent,i=this.partCurrent,n=this.hls,e=n.autoLevelEnabled,o=n.config,h=n.media;if(t&&h){var c=i?i.stats:t.stats,f=i?i.duration:t.duration;if(c.aborted)return u.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(e&&!h.paused&&h.playbackRate&&h.readyState){var l=performance.now()-c.loading.start,v=Math.abs(h.playbackRate);if(!(l<=500*f/v)){var d=n.levels,m=n.minAutoLevel,p=c.total||Math.max(c.loaded,Math.round(f*d[t.level].maxBitrate/8)),g=Math.max(1,c.bwEstimate?c.bwEstimate/8:1e3*c.loaded/l),b=(p-c.loaded)/g,y=h.currentTime,w=(a.BufferHelper.bufferInfo(h,y,o.maxBufferHole).end-y)/v;if(!(w>=2*f/v||b<=w)){var k,T=Number.POSITIVE_INFINITY;for(k=t.level-1;k>m&&!((T=f*d[k].maxBitrate/(6.4*g))<w);k--);if(!(T>=b)){var O=this.bwEstimator.getEstimate();u.logger.warn("Fragment "+t.sn+(i?" part "+i.index:"")+" of level "+t.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+k+"\n Current BW estimate: "+(Object(r.isFiniteNumber)(O)?(O/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+b.toFixed(3)+" s\n Estimated load time for the next fragment: "+T.toFixed(3)+" s\n Time to underbuffer: "+w.toFixed(3)+" s"),n.nextLoadLevel=k,this.bwEstimator.sample(l,c.loaded),this.clearTimer(),t.loader&&(this.fragCurrent=this.partCurrent=null,t.loader.abort()),n.trigger(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:i,stats:c})}}}}}},f.onFragLoaded=function(t,i){var n=i.frag,e=i.part;if(n.type===h.PlaylistLevelType.MAIN&&Object(r.isFiniteNumber)(n.sn)){var a=e?e.stats:n.stats,o=e?e.duration:n.duration;if(this.clearTimer(),this.lastLoadedFragLevel=n.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[n.level],c=(u.loaded?u.loaded.bytes:0)+a.loaded,f=(u.loaded?u.loaded.duration:0)+o;u.loaded={bytes:c,duration:f},u.realBitrate=Math.round(8*c/f)}n.bitrateTest&&(this.onFragBuffered(s.Events.FRAG_BUFFERED,{stats:a,frag:n,part:e,id:n.type}),n.bitrateTest=!1)}},f.onFragBuffered=function(t,i){var n=i.frag,r=i.part,e=r?r.stats:n.stats;if(!e.aborted&&n.type===h.PlaylistLevelType.MAIN&&"initSegment"!==n.sn){var s=e.parsing.end-e.loading.start;this.bwEstimator.sample(s,e.loaded),e.bwEstimate=this.bwEstimator.getEstimate(),this.bitrateTestDelay=n.bitrateTest?s/1e3:0}},f.onError=function(t,i){switch(i.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},f.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},f.getNextABRAutoLevel=function(){var t=this.fragCurrent,i=this.partCurrent,n=this.hls,r=n.maxAutoLevel,e=n.config,s=n.minAutoLevel,o=n.media,h=i?i.duration:t?t.duration:0,c=o?o.currentTime:0,f=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,l=this.bwEstimator?this.bwEstimator.getEstimate():e.abrEwmaDefaultEstimate,v=(a.BufferHelper.bufferInfo(o,c,e.maxBufferHole).end-c)/f,d=this.findBestLevel(l,s,r,v,e.abrBandWidthFactor,e.abrBandWidthUpFactor);if(d>=0)return d;u.logger.trace((v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var m=h?Math.min(h,e.maxStarvationDelay):e.maxStarvationDelay,p=e.abrBandWidthFactor,g=e.abrBandWidthUpFactor;if(!v){var b=this.bitrateTestDelay;b&&(m=(h?Math.min(h,e.maxLoadingDelay):e.maxLoadingDelay)-b,u.logger.trace("bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),p=g=1)}return d=this.findBestLevel(l,s,r,v+m,p,g),Math.max(d,0)},f.findBestLevel=function(t,i,n,r,e,s){for(var a,o=this.fragCurrent,h=this.partCurrent,c=this.lastLoadedFragLevel,f=this.hls.levels,l=f[c],v=!(null==l||null===(a=l.details)||void 0===a||!a.live),d=null==l?void 0:l.codecSet,m=h?h.duration:o?o.duration:0,p=n;p>=i;p--){var g=f[p];if(g&&(!d||g.codecSet===d)){var b,y=g.details,w=(h?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||m,k=f[p].maxBitrate,T=k*w/(b=p<=c?e*t:s*t);if(u.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+p+"/"+Math.round(b)+"/"+k+"/"+w+"/"+r+"/"+T),b>k&&(!T||v&&!this.bitrateTestDelay||T<r))return p}}return-1},i=t,(n=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,i=this.bwEstimator;if(!(-1===t||i&&i.canEstimate()))return t;var n=this.getNextABRAutoLevel();return-1!==t&&(n=Math.min(t,n)),n},set:function(t){this._nextAutoLevel=t}}])&&c(i.prototype,n),t}();i.default=f},"./src/controller/audio-stream-controller.ts":
22
22
  /*!***************************************************!*\
23
23
  !*** ./src/controller/audio-stream-controller.ts ***!
24
24
  \***************************************************/
25
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts");var s=r(/*! ../events */"./src/events.ts");var a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var u=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var f=r(/*! ../types/level */"./src/types/level.ts");var h=r(/*! ../types/loader */"./src/types/loader.ts");var o=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var v=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");var l=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts");var c=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts");var d=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts");var m=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts");var p=r(/*! ../errors */"./src/errors.ts");var g=r(/*! ../utils/logger */"./src/utils/logger.ts");function b(){b=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return b.apply(this,arguments)}function y(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;w(t,i)}function w(t,i){w=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return w(t,i)}var k=100;var T=function(t){y(i,t);function i(i,r){var e;e=t.call(this,i,r,"[audio-stream-controller]")||this;e.videoBuffer=null;e.videoTrackCC=-1;e.waitingVideoCC=-1;e.audioSwitch=false;e.trackId=-1;e.waitingData=null;e.mainDetails=null;e.bufferFlushed=false;e._registerListeners();return e}var r=i.prototype;r.onHandlerDestroying=function t(){this._unregisterListeners();this.mainDetails=null};r._registerListeners=function t(){var i=this.hls;i.on(s["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(s["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(s["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(s["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(s["Events"].AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);i.on(s["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);i.on(s["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);i.on(s["Events"].ERROR,this.onError,this);i.on(s["Events"].BUFFER_RESET,this.onBufferReset,this);i.on(s["Events"].BUFFER_CREATED,this.onBufferCreated,this);i.on(s["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);i.on(s["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);i.on(s["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r._unregisterListeners=function t(){var i=this.hls;i.off(s["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(s["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(s["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(s["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(s["Events"].AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this);i.off(s["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);i.off(s["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);i.off(s["Events"].ERROR,this.onError,this);i.off(s["Events"].BUFFER_RESET,this.onBufferReset,this);i.off(s["Events"].BUFFER_CREATED,this.onBufferCreated,this);i.off(s["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);i.off(s["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);i.off(s["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r.onInitPtsFound=function t(i,r){var e=r.frag,s=r.id,a=r.initPTS;if(s==="main"){var u=e.cc;this.initPTS[e.cc]=a;this.log("InitPTS for cc: "+u+" found from main: "+a);this.videoTrackCC=u;if(this.state===n["State"].WAITING_INIT_PTS){this.tick()}}};r.startLoad=function t(i){if(!this.levels){this.startPosition=i;this.state=n["State"].STOPPED;return}var r=this.lastCurrentTime;this.stopLoad();this.setInterval(k);this.fragLoadError=0;if(r>0&&i===-1){this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3));this.state=n["State"].IDLE}else{this.loadedmetadata=false;this.state=n["State"].WAITING_TRACK}this.nextLoadPosition=this.startPosition=this.lastCurrentTime=i;this.tick()};r.doTick=function i(){switch(this.state){case n["State"].IDLE:this.doTickIdle();break;case n["State"].WAITING_TRACK:{var r;var e=this.levels,s=this.trackId;var u=e===null||e===void 0?void 0:(r=e[s])===null||r===void 0?void 0:r.details;if(u){if(this.waitForCdnTuneIn(u)){break}this.state=n["State"].WAITING_INIT_PTS}break}case n["State"].FRAG_LOADING_WAITING_RETRY:{var f;var h=performance.now();var o=this.retryDate;if(!o||h>=o||(f=this.media)!==null&&f!==void 0&&f.seeking){this.log("RetryDate reached, switch back to IDLE state");this.state=n["State"].IDLE}break}case n["State"].WAITING_INIT_PTS:{var v=this.waitingData;if(v){var l=v.frag,c=v.part,m=v.cache,p=v.complete;if(this.initPTS[l.cc]!==undefined){this.waitingData=null;this.waitingVideoCC=-1;this.state=n["State"].FRAG_LOADING;var b=m.flush();var y={frag:l,part:c,payload:b,networkDetails:null};this._handleFragmentLoadProgress(y);if(p){t.prototype._handleFragmentLoadComplete.call(this,y)}}else if(this.videoTrackCC!==this.waitingVideoCC){g["logger"].log("Waiting fragment cc ("+l.cc+") cancelled because video is at cc "+this.videoTrackCC);this.clearWaitingFragment()}else{var w=this.getLoadPosition();var k=a["BufferHelper"].bufferInfo(this.mediaBuffer,w,this.config.maxBufferHole);var T=Object(d["fragmentWithinToleranceTest"])(k.end,this.config.maxFragLookUpTolerance,l);if(T<0){g["logger"].log("Waiting fragment cc ("+l.cc+") @ "+l.start+" cancelled because another fragment at "+k.end+" is needed");this.clearWaitingFragment()}}}else{this.state=n["State"].IDLE}}}this.onTickEnd()};r.clearWaitingFragment=function t(){var i=this.waitingData;if(i){this.fragmentTracker.removeFragment(i.frag);this.waitingData=null;this.waitingVideoCC=-1;this.state=n["State"].IDLE}};r.onTickEnd=function t(){var i=this.media;if(!i||!i.readyState){return}var r=this.mediaBuffer?this.mediaBuffer:i;var e=r.buffered;if(!this.loadedmetadata&&e.length){this.loadedmetadata=true}this.lastCurrentTime=i.currentTime};r.doTickIdle=function t(){var i,r;var e=this.hls,a=this.levels,u=this.media,f=this.trackId;var v=e.config;if(!a||!a[f]){return}if(!u&&(this.startFragRequested||!v.startFragPrefetch)){return}var l=a[f];var c=l.details;if(!c||c.live&&this.levelLastLoaded!==f||this.waitForCdnTuneIn(c)){this.state=n["State"].WAITING_TRACK;return}if(this.bufferFlushed){this.bufferFlushed=false;this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,o["ElementaryStreamTypes"].AUDIO,h["PlaylistLevelType"].AUDIO)}var d=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,h["PlaylistLevelType"].AUDIO);if(d===null){return}var m=d.len;var p=this.getMaxBufferLength();var g=this.audioSwitch;if(m>=p&&!g){return}if(!g&&this._streamEnded(d,c)){e.trigger(s["Events"].BUFFER_EOS,{type:"audio"});this.state=n["State"].ENDED;return}var b=c.fragments;var y=b[0].start;var w=d.end;if(g){var k=this.getLoadPosition();w=k;if(c.PTSKnown&&k<y){if(d.end>y||d.nextStart){this.log("Alt audio track ahead of main track, seek to start of alt audio track");u.currentTime=y+.05}}}var T=this.getNextFragment(w,c);if(!T){this.bufferFlushed=true;return}if(((i=T.decryptdata)===null||i===void 0?void 0:i.keyFormat)==="identity"&&!((r=T.decryptdata)!==null&&r!==void 0&&r.key)){this.loadKey(T,c)}else{this.loadFragment(T,c,w)}};r.getMaxBufferLength=function i(){var r=t.prototype.getMaxBufferLength.call(this);var e=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,h["PlaylistLevelType"].MAIN);if(e===null){return r}return Math.max(r,e.len)};r.onMediaDetaching=function i(){this.videoBuffer=null;t.prototype.onMediaDetaching.call(this)};r.onAudioTracksUpdated=function t(i,r){var e=r.audioTracks;this.resetTransmuxer();this.levels=e.map((function(t){return new f["Level"](t)}))};r.onAudioTrackSwitching=function t(i,r){var e=!!r.url;this.trackId=r.id;var s=this.fragCurrent;if(s!==null&&s!==void 0&&s.loader){s.loader.abort()}this.fragCurrent=null;this.clearWaitingFragment();if(!e){this.resetTransmuxer()}else{this.setInterval(k)}if(e){this.audioSwitch=true;this.state=n["State"].IDLE}else{this.state=n["State"].STOPPED}this.tick()};r.onManifestLoading=function t(){this.mainDetails=null;this.fragmentTracker.removeAllFragments();this.startPosition=this.lastCurrentTime=0;this.bufferFlushed=false};r.onLevelLoaded=function t(i,r){this.mainDetails=r.details};r.onAudioTrackLoaded=function t(i,r){var e;var s=this.levels;var a=r.details,u=r.id;if(!s){this.warn("Audio tracks were reset while loading level "+u);return}this.log("Track "+u+" loaded ["+a.startSN+","+a.endSN+"],duration:"+a.totalduration);var f=s[u];var h=0;if(a.live||(e=f.details)!==null&&e!==void 0&&e.live){var o=this.mainDetails;if(!a.fragments[0]){a.deltaUpdateFailed=true}if(a.deltaUpdateFailed||!o){return}if(!f.details&&a.hasProgramDateTime&&o.hasProgramDateTime){Object(m["alignMediaPlaylistByPDT"])(a,o);h=a.fragments[0].start}else{h=this.alignPlaylists(a,f.details)}}f.details=a;this.levelLastLoaded=u;if(!this.startFragRequested&&(this.mainDetails||!a.live)){this.setStartPosition(f.details,h)}if(this.state===n["State"].WAITING_TRACK&&!this.waitForCdnTuneIn(a)){this.state=n["State"].IDLE}this.tick()};r._handleFragmentLoadProgress=function t(i){var r;var e=i.frag,s=i.part,a=i.payload;var u=this.config,f=this.trackId,o=this.levels;if(!o){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+e.sn+" of level "+e.level+" will not be buffered");return}var d=o[f];console.assert(d,"Audio track is defined on fragment load progress");var m=d.details;console.assert(m,"Audio track details are defined on fragment load progress");var p=u.defaultAudioCodec||d.audioCodec||"mp4a.40.2";var b=this.transmuxer;if(!b){b=this.transmuxer=new l["default"](this.hls,h["PlaylistLevelType"].AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this))}var y=this.initPTS[e.cc];var w=(r=e.initSegment)===null||r===void 0?void 0:r.data;if(y!==undefined){var k=false;var T=s?s.index:-1;var O=T!==-1;var S=new c["ChunkMetadata"](e.level,e.sn,e.stats.chunkCount,a.byteLength,T,O);b.push(a,w,p,"",e,s,m.totalduration,k,S,y)}else{g["logger"].log("Unknown video PTS for cc "+e.cc+", waiting for video PTS before demuxing audio frag "+e.sn+" of ["+m.startSN+" ,"+m.endSN+"],track "+f);var E=this.waitingData=this.waitingData||{frag:e,part:s,cache:new v["default"],complete:false},A=E.cache;A.push(new Uint8Array(a));this.waitingVideoCC=this.videoTrackCC;this.state=n["State"].WAITING_INIT_PTS}};r._handleFragmentLoadComplete=function i(r){if(this.waitingData){this.waitingData.complete=true;return}t.prototype._handleFragmentLoadComplete.call(this,r)};r.onBufferReset=function t(){this.mediaBuffer=this.videoBuffer=null;this.loadedmetadata=false};r.onBufferCreated=function t(i,r){var e=r.tracks.audio;if(e){this.mediaBuffer=e.buffer}if(r.tracks.video){this.videoBuffer=r.tracks.video.buffer}};r.onFragBuffered=function t(i,r){var e=r.frag,n=r.part;if(e.type!==h["PlaylistLevelType"].AUDIO){return}if(this.fragContextChanged(e)){this.warn("Fragment "+e.sn+(n?" p: "+n.index:"")+" of level "+e.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}if(e.sn!=="initSegment"){this.fragPrevious=e;if(this.audioSwitch){this.audioSwitch=false;this.hls.trigger(s["Events"].AUDIO_TRACK_SWITCHED,{id:this.trackId})}}this.fragBufferedComplete(e,n)};r.onError=function i(r,e){switch(e.details){case p["ErrorDetails"].FRAG_LOAD_ERROR:case p["ErrorDetails"].FRAG_LOAD_TIMEOUT:case p["ErrorDetails"].KEY_LOAD_ERROR:case p["ErrorDetails"].KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(h["PlaylistLevelType"].AUDIO,e);break;case p["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR:case p["ErrorDetails"].AUDIO_TRACK_LOAD_TIMEOUT:if(this.state!==n["State"].ERROR&&this.state!==n["State"].STOPPED){this.state=e.fatal?n["State"].ERROR:n["State"].IDLE;this.warn(e.details+" while loading frag, switching to "+this.state+" state")}break;case p["ErrorDetails"].BUFFER_FULL_ERROR:if(e.parent==="audio"&&(this.state===n["State"].PARSING||this.state===n["State"].PARSED)){var s=true;var a=this.getFwdBufferInfo(this.mediaBuffer,h["PlaylistLevelType"].AUDIO);if(a&&a.len>.5){s=!this.reduceMaxBufferLength(a.len)}if(s){this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer");this.fragCurrent=null;t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")}this.resetLoadingState()}break}};r.onBufferFlushed=function t(i,r){var e=r.type;if(e===o["ElementaryStreamTypes"].AUDIO){this.bufferFlushed=true}};r._handleTransmuxComplete=function t(i){var r;var e="audio";var a=this.hls;var u=i.remuxResult,f=i.chunkMeta;var h=this.getCurrentContext(f);if(!h){this.warn("The loading context changed while buffering fragment "+f.sn+" of level "+f.level+". This chunk will not be buffered.");this.resetLiveStartWhenNotLoaded(f.level);return}var v=h.frag,l=h.part;var c=u.audio,d=u.text,m=u.id3,p=u.initSegment;if(this.fragContextChanged(v)){return}this.state=n["State"].PARSING;if(this.audioSwitch&&c){this.completeAudioSwitch()}if(p!==null&&p!==void 0&&p.tracks){this._bufferInitSegment(p.tracks,v,f);a.trigger(s["Events"].FRAG_PARSING_INIT_SEGMENT,{frag:v,id:e,tracks:p.tracks})}if(c){var g=c.startPTS,y=c.endPTS,w=c.startDTS,k=c.endDTS;if(l){l.elementaryStreams[o["ElementaryStreamTypes"].AUDIO]={startPTS:g,endPTS:y,startDTS:w,endDTS:k}}v.setElementaryStreamInfo(o["ElementaryStreamTypes"].AUDIO,g,y,w,k);this.bufferFragmentData(c,v,l,f)}if(m!==null&&m!==void 0&&(r=m.samples)!==null&&r!==void 0&&r.length){var T=b({frag:v,id:e},m);a.trigger(s["Events"].FRAG_PARSING_METADATA,T)}if(d){var O=b({frag:v,id:e},d);a.trigger(s["Events"].FRAG_PARSING_USERDATA,O)}};r._bufferInitSegment=function t(i,r,e){if(this.state!==n["State"].PARSING){return}if(i.video){delete i.video}var a=i.audio;if(!a){return}a.levelCodec=a.codec;a.id="audio";this.log("Init audio buffer, container:"+a.container+", codecs[parsed]=["+a.codec+"]");this.hls.trigger(s["Events"].BUFFER_CODECS,i);var u=a.initSegment;if(u!==null&&u!==void 0&&u.byteLength){var f={type:"audio",frag:r,part:null,chunkMeta:e,parent:r.type,data:u};this.hls.trigger(s["Events"].BUFFER_APPENDING,f)}this.tick()};r.loadFragment=function i(r,s,a){var f=this.fragmentTracker.getState(r);this.fragCurrent=r;if(this.audioSwitch||f===u["FragmentState"].NOT_LOADED||f===u["FragmentState"].PARTIAL){if(r.sn==="initSegment"){this._loadInitSegment(r)}else if(s.live&&!Object(e["isFiniteNumber"])(this.initPTS[r.cc])){this.log("Waiting for video PTS in continuity counter "+r.cc+" of live stream before loading audio fragment "+r.sn+" of level "+this.trackId);this.state=n["State"].WAITING_INIT_PTS}else{this.startFragRequested=true;t.prototype.loadFragment.call(this,r,s,a)}}};r.completeAudioSwitch=function i(){var r=this.hls,e=this.media,n=this.trackId;if(e){this.log("Switching audio track : flushing all audio");t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")}this.audioSwitch=false;r.trigger(s["Events"].AUDIO_TRACK_SWITCHED,{id:n})};return i}(n["default"]);i["default"]=T},"./src/controller/audio-track-controller.ts":
25
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=n(/*! ../events */"./src/events.ts"),a=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=n(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),h=n(/*! ../types/level */"./src/types/level.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts"),c=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),f=n(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),l=n(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),v=n(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),d=n(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),m=n(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),p=n(/*! ../errors */"./src/errors.ts"),g=n(/*! ../utils/logger */"./src/utils/logger.ts");function b(){return b=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b.apply(this,arguments)}function y(t,i){return y=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},y(t,i)}var w=function(t){var i,n;function w(i,n){var r;return(r=t.call(this,i,n,"[audio-stream-controller]")||this).videoBuffer=null,r.videoTrackCC=-1,r.waitingVideoCC=-1,r.audioSwitch=!1,r.trackId=-1,r.waitingData=null,r.mainDetails=null,r.bufferFlushed=!1,r._registerListeners(),r}n=t,(i=w).prototype=Object.create(n.prototype),i.prototype.constructor=i,y(i,n);var k=w.prototype;return k.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},k._registerListeners=function(){var t=this.hls;t.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(s.Events.ERROR,this.onError,this),t.on(s.Events.BUFFER_RESET,this.onBufferReset,this),t.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},k._unregisterListeners=function(){var t=this.hls;t.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(s.Events.ERROR,this.onError,this),t.off(s.Events.BUFFER_RESET,this.onBufferReset,this),t.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},k.onInitPtsFound=function(t,i){var n=i.frag,r=i.initPTS;if("main"===i.id){var s=n.cc;this.initPTS[n.cc]=r,this.log("InitPTS for cc: "+s+" found from main: "+r),this.videoTrackCC=s,this.state===e.State.WAITING_INIT_PTS&&this.tick()}},k.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=e.State.STOPPED);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,i>0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),this.state=e.State.IDLE):(this.loadedmetadata=!1,this.state=e.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},k.doTick=function(){switch(this.state){case e.State.IDLE:this.doTickIdle();break;case e.State.WAITING_TRACK:var i,n=this.levels,r=null==n||null===(i=n[this.trackId])||void 0===i?void 0:i.details;if(r){if(this.waitForCdnTuneIn(r))break;this.state=e.State.WAITING_INIT_PTS}break;case e.State.FRAG_LOADING_WAITING_RETRY:var s,o=performance.now(),h=this.retryDate;(!h||o>=h||null!==(s=this.media)&&void 0!==s&&s.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=e.State.IDLE);break;case e.State.WAITING_INIT_PTS:var u=this.waitingData;if(u){var c=u.frag,f=u.part,l=u.cache,v=u.complete;if(void 0!==this.initPTS[c.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=e.State.FRAG_LOADING;var m={frag:c,part:f,payload:l.flush(),networkDetails:null};this._handleFragmentLoadProgress(m),v&&t.prototype._handleFragmentLoadComplete.call(this,m)}else if(this.videoTrackCC!==this.waitingVideoCC)g.logger.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var p=this.getLoadPosition(),b=a.BufferHelper.bufferInfo(this.mediaBuffer,p,this.config.maxBufferHole);Object(d.fragmentWithinToleranceTest)(b.end,this.config.maxFragLookUpTolerance,c)<0&&(g.logger.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+b.end+" is needed"),this.clearWaitingFragment())}}else this.state=e.State.IDLE}this.onTickEnd()},k.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=e.State.IDLE)},k.onTickEnd=function(){var t=this.media;t&&t.readyState&&(!this.loadedmetadata&&(this.mediaBuffer?this.mediaBuffer:t).buffered.length&&(this.loadedmetadata=!0),this.lastCurrentTime=t.currentTime)},k.doTickIdle=function(){var t,i,n=this.hls,r=this.levels,a=this.media,o=this.trackId;if(r&&r[o]&&(a||!this.startFragRequested&&n.config.startFragPrefetch)){var h=r[o].details;if(!h||h.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(h))this.state=e.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,c.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var f=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.AUDIO);if(null!==f){var l=f.len,v=this.getMaxBufferLength(),d=this.audioSwitch;if(!(l>=v)||d){if(!d&&this._streamEnded(f,h))return n.trigger(s.Events.BUFFER_EOS,{type:"audio"}),void(this.state=e.State.ENDED);var m=h.fragments[0].start,p=f.end;if(d){var g=this.getLoadPosition();p=g,h.PTSKnown&&g<m&&(f.end>m||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=m+.05)}var b=this.getNextFragment(p,h);b?"identity"!==(null===(t=b.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(i=b.decryptdata)&&void 0!==i&&i.key?this.loadFragment(b,h,p):this.loadKey(b,h):this.bufferFlushed=!0}}}}},k.getMaxBufferLength=function(){var i=t.prototype.getMaxBufferLength.call(this),n=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN);return null===n?i:Math.max(i,n.len)},k.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},k.onAudioTracksUpdated=function(t,i){var n=i.audioTracks;this.resetTransmuxer(),this.levels=n.map((function(t){return new h.Level(t)}))},k.onAudioTrackSwitching=function(t,i){var n=!!i.url;this.trackId=i.id;var r=this.fragCurrent;null!=r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),n?this.setInterval(100):this.resetTransmuxer(),n?(this.audioSwitch=!0,this.state=e.State.IDLE):this.state=e.State.STOPPED,this.tick()},k.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},k.onLevelLoaded=function(t,i){this.mainDetails=i.details},k.onAudioTrackLoaded=function(t,i){var n,r=this.levels,s=i.details,a=i.id;if(r){this.log("Track "+a+" loaded ["+s.startSN+","+s.endSN+"],duration:"+s.totalduration);var o=r[a],h=0;if(s.live||null!==(n=o.details)&&void 0!==n&&n.live){var u=this.mainDetails;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed||!u)return;!o.details&&s.hasProgramDateTime&&u.hasProgramDateTime?(Object(m.alignMediaPlaylistByPDT)(s,u),h=s.fragments[0].start):h=this.alignPlaylists(s,o.details)}o.details=s,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(o.details,h),this.state!==e.State.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=e.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+a)},k._handleFragmentLoadProgress=function(t){var i,n=t.frag,r=t.part,s=t.payload,a=this.config,o=this.trackId,h=this.levels;if(h){var c=h[o];console.assert(c,"Audio track is defined on fragment load progress");var d=c.details;console.assert(d,"Audio track details are defined on fragment load progress");var m=a.defaultAudioCodec||c.audioCodec||"mp4a.40.2",p=this.transmuxer;p||(p=this.transmuxer=new l.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var b=this.initPTS[n.cc],y=null===(i=n.initSegment)||void 0===i?void 0:i.data;if(void 0!==b){var w=r?r.index:-1,k=new v.ChunkMetadata(n.level,n.sn,n.stats.chunkCount,s.byteLength,w,-1!==w);p.push(s,y,m,"",n,r,d.totalduration,!1,k,b)}else g.logger.log("Unknown video PTS for cc "+n.cc+", waiting for video PTS before demuxing audio frag "+n.sn+" of ["+d.startSN+" ,"+d.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:n,part:r,cache:new f.default,complete:!1}).cache.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=e.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+n.sn+" of level "+n.level+" will not be buffered")},k._handleFragmentLoadComplete=function(i){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,i)},k.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},k.onBufferCreated=function(t,i){var n=i.tracks.audio;n&&(this.mediaBuffer=n.buffer),i.tracks.video&&(this.videoBuffer=i.tracks.video.buffer)},k.onFragBuffered=function(t,i){var n=i.frag,r=i.part;n.type===u.PlaylistLevelType.AUDIO&&(this.fragContextChanged(n)?this.warn("Fragment "+n.sn+(r?" p: "+r.index:"")+" of level "+n.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==n.sn&&(this.fragPrevious=n,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(n,r)))},k.onError=function(i,n){switch(n.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,n);break;case p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==e.State.ERROR&&this.state!==e.State.STOPPED&&(this.state=n.fatal?e.State.ERROR:e.State.IDLE,this.warn(n.details+" while loading frag, switching to "+this.state+" state"));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===n.parent&&(this.state===e.State.PARSING||this.state===e.State.PARSED)){var r=!0,s=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);s&&s.len>.5&&(r=!this.reduceMaxBufferLength(s.len)),r&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},k.onBufferFlushed=function(t,i){i.type===c.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},k._handleTransmuxComplete=function(t){var i,n="audio",r=this.hls,a=t.remuxResult,o=t.chunkMeta,h=this.getCurrentContext(o);if(!h)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(o.level);var u=h.frag,f=h.part,l=a.audio,v=a.text,d=a.id3,m=a.initSegment;if(!this.fragContextChanged(u)){if(this.state=e.State.PARSING,this.audioSwitch&&l&&this.completeAudioSwitch(),null!=m&&m.tracks&&(this._bufferInitSegment(m.tracks,u,o),r.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:n,tracks:m.tracks})),l){var p=l.startPTS,g=l.endPTS,y=l.startDTS,w=l.endDTS;f&&(f.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:p,endPTS:g,startDTS:y,endDTS:w}),u.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,p,g,y,w),this.bufferFragmentData(l,u,f,o)}if(null!=d&&null!==(i=d.samples)&&void 0!==i&&i.length){var k=b({frag:u,id:n},d);r.trigger(s.Events.FRAG_PARSING_METADATA,k)}if(v){var T=b({frag:u,id:n},v);r.trigger(s.Events.FRAG_PARSING_USERDATA,T)}}},k._bufferInitSegment=function(t,i,n){if(this.state===e.State.PARSING){t.video&&delete t.video;var r=t.audio;if(r){r.levelCodec=r.codec,r.id="audio",this.log("Init audio buffer, container:"+r.container+", codecs[parsed]=["+r.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t);var a=r.initSegment;null!=a&&a.byteLength&&this.hls.trigger(s.Events.BUFFER_APPENDING,{type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:a}),this.tick()}}},k.loadFragment=function(i,n,s){var a=this.fragmentTracker.getState(i);this.fragCurrent=i,(this.audioSwitch||a===o.FragmentState.NOT_LOADED||a===o.FragmentState.PARTIAL)&&("initSegment"===i.sn?this._loadInitSegment(i):n.live&&!Object(r.isFiniteNumber)(this.initPTS[i.cc])?(this.log("Waiting for video PTS in continuity counter "+i.cc+" of live stream before loading audio fragment "+i.sn+" of level "+this.trackId),this.state=e.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,n,s)))},k.completeAudioSwitch=function(){var i=this.hls,n=this.trackId;this.media&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,i.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:n})},w}(e.default);i.default=w},"./src/controller/audio-track-controller.ts":
26
26
  /*!**************************************************!*\
27
27
  !*** ./src/controller/audio-track-controller.ts ***!
28
28
  \**************************************************/
29
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts");var a=r(/*! ../types/loader */"./src/types/loader.ts");function u(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function f(t,i,r){if(i)u(t.prototype,i);if(r)u(t,r);return t}function h(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;o(t,i)}function o(t,i){o=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return o(t,i)}var v=function(t){h(i,t);function i(i){var r;r=t.call(this,i,"[audio-track-controller]")||this;r.tracks=[];r.groupId=null;r.tracksInGroup=[];r.trackId=-1;r.trackName="";r.selectDefaultTrack=true;r.registerListeners();return r}var r=i.prototype;r.registerListeners=function t(){var i=this.hls;i.on(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(e["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.on(e["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);i.on(e["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);i.on(e["Events"].ERROR,this.onError,this)};r.unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(e["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.off(e["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);i.off(e["Events"].AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this);i.off(e["Events"].ERROR,this.onError,this)};r.destroy=function i(){this.unregisterListeners();this.tracks.length=0;this.tracksInGroup.length=0;t.prototype.destroy.call(this)};r.onManifestLoading=function t(){this.tracks=[];this.groupId=null;this.tracksInGroup=[];this.trackId=-1;this.trackName="";this.selectDefaultTrack=true};r.onManifestParsed=function t(i,r){this.tracks=r.audioTracks||[]};r.onAudioTrackLoaded=function t(i,r){var e=r.id,n=r.details;var s=this.tracksInGroup[e];if(!s){this.warn("Invalid audio track id "+e);return}var a=s.details;s.details=r.details;this.log("audioTrack "+e+" loaded ["+n.startSN+"-"+n.endSN+"]");if(e===this.trackId){this.retryCount=0;this.playlistLoaded(e,r,a)}};r.onLevelLoading=function t(i,r){this.switchLevel(r.level)};r.onLevelSwitching=function t(i,r){this.switchLevel(r.level)};r.switchLevel=function t(i){var r=this.hls.levels[i];if(!(r!==null&&r!==void 0&&r.audioGroupIds)){return}var n=r.audioGroupIds[r.urlId];if(this.groupId!==n){this.groupId=n;var s=this.tracks.filter((function(t){return!n||t.groupId===n}));if(this.selectDefaultTrack&&!s.some((function(t){return t.default}))){this.selectDefaultTrack=false}this.tracksInGroup=s;var a={audioTracks:s};this.log("Updating audio tracks, "+s.length+' track(s) found in "'+n+'" group-id');this.hls.trigger(e["Events"].AUDIO_TRACKS_UPDATED,a);this.selectInitialTrack()}};r.onError=function i(r,e){t.prototype.onError.call(this,r,e);if(e.fatal||!e.context){return}if(e.context.type===a["PlaylistContextType"].AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId){this.retryLoadingOrFail(e)}};r.setAudioTrack=function t(i){var r=this.tracksInGroup;if(i<0||i>=r.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var n=r[this.trackId];this.log("Now switching to audio-track index "+i);var s=r[i];var a=s.id,u=s.groupId,f=u===void 0?"":u,h=s.name,o=s.type,v=s.url;this.trackId=i;this.trackName=h;this.selectDefaultTrack=false;this.hls.trigger(e["Events"].AUDIO_TRACK_SWITCHING,{id:a,groupId:f,name:h,type:o,url:v});if(s.details&&!s.details.live){return}var l=this.switchParams(s.url,n===null||n===void 0?void 0:n.details);this.loadPlaylist(l)};r.selectInitialTrack=function t(){var i=this.tracksInGroup;console.assert(i.length,"Initial audio track should be selected when tracks are known");var r=this.trackName;var s=this.findTrackId(r)||this.findTrackId();if(s!==-1){this.setAudioTrack(s)}else{this.warn("No track found for running audio group-ID: "+this.groupId);this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR,fatal:true})}};r.findTrackId=function t(i){var r=this.tracksInGroup;for(var e=0;e<r.length;e++){var n=r[e];if(!this.selectDefaultTrack||n.default){if(!i||i===n.name){return n.id}}}return-1};r.loadPlaylist=function t(i){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var n=r.id;var s=r.groupId;var a=r.url;if(i){try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}}this.log("loading audio-track playlist for id: "+n);this.clearTimer();this.hls.trigger(e["Events"].AUDIO_TRACK_LOADING,{url:a,id:n,groupId:s,deliveryDirectives:i||null})}};f(i,[{key:"audioTracks",get:function t(){return this.tracksInGroup}},{key:"audioTrack",get:function t(){return this.trackId},set:function t(i){this.selectDefaultTrack=false;this.setAudioTrack(i)}}]);return i}(s["default"]);i["default"]=v},"./src/controller/base-playlist-controller.ts":
29
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=n(/*! ../types/loader */"./src/types/loader.ts");function o(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,i){return h=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},h(t,i)}var u=function(t){var i,n;function s(i){var n;return(n=t.call(this,i,"[audio-track-controller]")||this).tracks=[],n.groupId=null,n.tracksInGroup=[],n.trackId=-1,n.trackName="",n.selectDefaultTrack=!0,n.registerListeners(),n}n=t,(i=s).prototype=Object.create(n.prototype),i.prototype.constructor=i,h(i,n);var u,c,f=s.prototype;return f.registerListeners=function(){var t=this.hls;t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(r.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(r.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(r.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(r.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,t.prototype.destroy.call(this)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},f.onManifestParsed=function(t,i){this.tracks=i.audioTracks||[]},f.onAudioTrackLoaded=function(t,i){var n=i.id,r=i.details,e=this.tracksInGroup[n];if(e){var s=e.details;e.details=i.details,this.log("audioTrack "+n+" loaded ["+r.startSN+"-"+r.endSN+"]"),n===this.trackId&&(this.retryCount=0,this.playlistLoaded(n,i,s))}else this.warn("Invalid audio track id "+n)},f.onLevelLoading=function(t,i){this.switchLevel(i.level)},f.onLevelSwitching=function(t,i){this.switchLevel(i.level)},f.switchLevel=function(t){var i=this.hls.levels[t];if(null!=i&&i.audioGroupIds){var n=i.audioGroupIds[i.urlId];if(this.groupId!==n){this.groupId=n;var e=this.tracks.filter((function(t){return!n||t.groupId===n}));this.selectDefaultTrack&&!e.some((function(t){return t.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=e;var s={audioTracks:e};this.log("Updating audio tracks, "+e.length+' track(s) found in "'+n+'" group-id'),this.hls.trigger(r.Events.AUDIO_TRACKS_UPDATED,s),this.selectInitialTrack()}}},f.onError=function(i,n){t.prototype.onError.call(this,i,n),!n.fatal&&n.context&&n.context.type===a.PlaylistContextType.AUDIO_TRACK&&n.context.id===this.trackId&&n.context.groupId===this.groupId&&this.retryLoadingOrFail(n)},f.setAudioTrack=function(t){var i=this.tracksInGroup;if(t<0||t>=i.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var n=i[this.trackId];this.log("Now switching to audio-track index "+t);var e=i[t],s=e.id,a=e.groupId,o=void 0===a?"":a,h=e.name,u=e.type,c=e.url;if(this.trackId=t,this.trackName=h,this.selectDefaultTrack=!1,this.hls.trigger(r.Events.AUDIO_TRACK_SWITCHING,{id:s,groupId:o,name:h,type:u,url:c}),!e.details||e.details.live){var f=this.switchParams(e.url,null==n?void 0:n.details);this.loadPlaylist(f)}}},f.selectInitialTrack=function(){console.assert(this.tracksInGroup.length,"Initial audio track should be selected when tracks are known");var t=this.findTrackId(this.trackName)||this.findTrackId();-1!==t?this.setAudioTrack(t):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},f.findTrackId=function(t){for(var i=this.tracksInGroup,n=0;n<i.length;n++){var r=i[n];if((!this.selectDefaultTrack||r.default)&&(!t||t===r.name))return r.id}return-1},f.loadPlaylist=function(t){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var n=i.id,e=i.groupId,s=i.url;if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("loading audio-track playlist for id: "+n),this.clearTimer(),this.hls.trigger(r.Events.AUDIO_TRACK_LOADING,{url:s,id:n,groupId:e,deliveryDirectives:t||null})}},u=s,(c=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}])&&o(u.prototype,c),s}(s.default);i.default=u},"./src/controller/base-playlist-controller.ts":
30
30
  /*!****************************************************!*\
31
31
  !*** ./src/controller/base-playlist-controller.ts ***!
32
32
  \****************************************************/
33
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return f}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../types/level */"./src/types/level.ts");var s=r(/*! ./level-helper */"./src/controller/level-helper.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=r(/*! ../errors */"./src/errors.ts");var f=function(){function t(t,i){this.hls=void 0;this.timer=-1;this.canLoad=false;this.retryCount=0;this.log=void 0;this.warn=void 0;this.log=a["logger"].log.bind(a["logger"],i+":");this.warn=a["logger"].warn.bind(a["logger"],i+":");this.hls=t}var i=t.prototype;i.destroy=function t(){this.clearTimer();this.hls=this.log=this.warn=null};i.onError=function t(i,r){if(r.fatal&&r.type===u["ErrorTypes"].NETWORK_ERROR){this.clearTimer()}};i.clearTimer=function t(){clearTimeout(this.timer);this.timer=-1};i.startLoad=function t(){this.canLoad=true;this.retryCount=0;this.loadPlaylist()};i.stopLoad=function t(){this.canLoad=false;this.clearTimer()};i.switchParams=function t(i,r){var s=r===null||r===void 0?void 0:r.renditionReports;if(s){for(var a=0;a<s.length;a++){var u=s[a];var f=""+u.URI;if(f===i.substr(-f.length)){var h=parseInt(u["LAST-MSN"]);var o=parseInt(u["LAST-PART"]);if(r&&this.hls.config.lowLatencyMode){var v=Math.min(r.age-r.partTarget,r.targetduration);if(o!==undefined&&v>r.partTarget){o+=1}}if(Object(e["isFiniteNumber"])(h)){return new n["HlsUrlParameters"](h,Object(e["isFiniteNumber"])(o)?o:undefined,n["HlsSkip"].No)}}}}};i.loadPlaylist=function t(i){};i.shouldLoadTrack=function t(i){return this.canLoad&&i&&!!i.url&&(!i.details||i.details.live)};i.playlistLoaded=function t(i,r,e){var n=this;var a=r.details,u=r.stats;var f=u.loading.end?Math.max(0,self.performance.now()-u.loading.end):0;a.advancedDateTime=Date.now()-f;if(a.live||e!==null&&e!==void 0&&e.live){a.reloaded(e);if(e){this.log("live playlist "+i+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED"))}if(e&&a.fragments.length>0){Object(s["mergeDetails"])(e,a)}if(!this.canLoad||!a.live){return}var h;var o=undefined;var v=undefined;if(a.canBlockReload&&a.endSN&&a.advanced){var l=this.hls.config.lowLatencyMode;var c=a.lastPartSn;var d=a.endSN;var m=a.lastPartIndex;var p=m!==-1;var g=c===d;var b=l?0:m;if(p){o=g?d+1:c;v=g?b:m+1}else{o=d+1}var y=a.age;var w=y+a.ageHeader;var k=Math.min(w-a.partTarget,a.targetduration*1.5);if(k>0){if(e&&k>e.tuneInGoal){this.warn("CDN Tune-in goal increased from: "+e.tuneInGoal+" to: "+k+" with playlist age: "+a.age);k=0}else{var T=Math.floor(k/a.targetduration);o+=T;if(v!==undefined){var O=Math.round(k%a.targetduration/a.partTarget);v+=O}this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+y.toFixed(2)+"s goal: "+k+" skip sn "+T+" to part "+v)}a.tuneInGoal=k}h=this.getDeliveryDirectives(a,r.deliveryDirectives,o,v);if(l||!g){this.loadPlaylist(h);return}}else{h=this.getDeliveryDirectives(a,r.deliveryDirectives,o,v)}var S=Object(s["computeReloadInterval"])(a,u);if(o!==undefined&&a.canBlockReload){S-=a.partTarget||1}this.log("reload live playlist "+i+" in "+Math.round(S)+" ms");this.timer=self.setTimeout((function(){return n.loadPlaylist(h)}),S)}else{this.clearTimer()}};i.getDeliveryDirectives=function t(i,r,e,s){var a=Object(n["getSkipValue"])(i,e);if(r!==null&&r!==void 0&&r.skip&&i.deltaUpdateFailed){e=r.msn;s=r.part;a=n["HlsSkip"].No}return new n["HlsUrlParameters"](e,s,a)};i.retryLoadingOrFail=function t(i){var r=this;var e=this.hls.config;var n=this.retryCount<e.levelLoadingMaxRetry;if(n){var s;this.retryCount++;if(i.details.indexOf("LoadTimeOut")>-1&&(s=i.context)!==null&&s!==void 0&&s.deliveryDirectives){this.warn("retry playlist loading #"+this.retryCount+' after "'+i.details+'"');this.loadPlaylist()}else{var a=Math.min(Math.pow(2,this.retryCount)*e.levelLoadingRetryDelay,e.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),a);this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+i.details+'"')}}else{this.warn('cannot recover from error "'+i.details+'"');this.clearTimer();i.fatal=true}return n};return t}()},"./src/controller/base-stream-controller.ts":
33
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return h}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../types/level */"./src/types/level.ts"),s=n(/*! ./level-helper */"./src/controller/level-helper.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ../errors */"./src/errors.ts"),h=function(){function t(t,i){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=a.logger.log.bind(a.logger,i+":"),this.warn=a.logger.warn.bind(a.logger,i+":"),this.hls=t}var i=t.prototype;return i.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},i.onError=function(t,i){i.fatal&&i.type===o.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},i.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},i.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},i.stopLoad=function(){this.canLoad=!1,this.clearTimer()},i.switchParams=function(t,i){var n=null==i?void 0:i.renditionReports;if(n)for(var s=0;s<n.length;s++){var a=n[s],o=""+a.URI;if(o===t.substr(-o.length)){var h=parseInt(a["LAST-MSN"]),u=parseInt(a["LAST-PART"]);if(i&&this.hls.config.lowLatencyMode){var c=Math.min(i.age-i.partTarget,i.targetduration);void 0!==u&&c>i.partTarget&&(u+=1)}if(Object(r.isFiniteNumber)(h))return new e.HlsUrlParameters(h,Object(r.isFiniteNumber)(u)?u:void 0,e.HlsSkip.No)}}},i.loadPlaylist=function(){},i.shouldLoadTrack=function(t){return this.canLoad&&t&&!!t.url&&(!t.details||t.details.live)},i.playlistLoaded=function(t,i,n){var r=this,e=i.details,a=i.stats,o=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(e.advancedDateTime=Date.now()-o,e.live||null!=n&&n.live){if(e.reloaded(n),n&&this.log("live playlist "+t+" "+(e.advanced?"REFRESHED "+e.lastPartSn+"-"+e.lastPartIndex:"MISSED")),n&&e.fragments.length>0&&Object(s.mergeDetails)(n,e),!this.canLoad||!e.live)return;var h,u=void 0,c=void 0;if(e.canBlockReload&&e.endSN&&e.advanced){var f=this.hls.config.lowLatencyMode,l=e.lastPartSn,v=e.endSN,d=e.lastPartIndex,m=l===v;-1!==d?(u=m?v+1:l,c=m?f?0:d:d+1):u=v+1;var p=e.age,g=Math.min(p+e.ageHeader-e.partTarget,1.5*e.targetduration);if(g>0){if(n&&g>n.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+n.tuneInGoal+" to: "+g+" with playlist age: "+e.age),g=0;else{var b=Math.floor(g/e.targetduration);u+=b,void 0!==c&&(c+=Math.round(g%e.targetduration/e.partTarget)),this.log("CDN Tune-in age: "+e.ageHeader+"s last advanced "+p.toFixed(2)+"s goal: "+g+" skip sn "+b+" to part "+c)}e.tuneInGoal=g}if(h=this.getDeliveryDirectives(e,i.deliveryDirectives,u,c),f||!m)return void this.loadPlaylist(h)}else h=this.getDeliveryDirectives(e,i.deliveryDirectives,u,c);var y=Object(s.computeReloadInterval)(e,a);void 0!==u&&e.canBlockReload&&(y-=e.partTarget||1),this.log("reload live playlist "+t+" in "+Math.round(y)+" ms"),this.timer=self.setTimeout((function(){return r.loadPlaylist(h)}),y)}else this.clearTimer()},i.getDeliveryDirectives=function(t,i,n,r){var s=Object(e.getSkipValue)(t,n);return null!=i&&i.skip&&t.deltaUpdateFailed&&(n=i.msn,r=i.part,s=e.HlsSkip.No),new e.HlsUrlParameters(n,r,s)},i.retryLoadingOrFail=function(t){var i,n=this,r=this.hls.config,e=this.retryCount<r.levelLoadingMaxRetry;if(e)if(this.retryCount++,t.details.indexOf("LoadTimeOut")>-1&&null!==(i=t.context)&&void 0!==i&&i.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+t.details+'"'),this.loadPlaylist();else{var s=Math.min(Math.pow(2,this.retryCount)*r.levelLoadingRetryDelay,r.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return n.loadPlaylist()}),s),this.warn("retry playlist loading #"+this.retryCount+" in "+s+' ms after "'+t.details+'"')}else this.warn('cannot recover from error "'+t.details+'"'),this.clearTimer(),t.fatal=!0;return e},t}()},"./src/controller/base-stream-controller.ts":
34
34
  /*!**************************************************!*\
35
35
  !*** ./src/controller/base-stream-controller.ts ***!
36
36
  \**************************************************/
37
- /*! exports provided: State, default */function(t,i,r){r.r(i);r.d(i,"State",(function(){return S}));r.d(i,"default",(function(){return E}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../task-loop */"./src/task-loop.ts");var s=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var u=r(/*! ../utils/logger */"./src/utils/logger.ts");var f=r(/*! ../events */"./src/events.ts");var h=r(/*! ../errors */"./src/errors.ts");var o=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts");var v=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var l=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts");var c=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts");var d=r(/*! ./level-helper */"./src/controller/level-helper.ts");var m=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts");var p=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts");var g=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts");var b=r(/*! ../types/loader */"./src/types/loader.ts");function y(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function w(t,i,r){if(i)y(t.prototype,i);if(r)y(t,r);return t}function k(t){if(t===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return t}function T(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;O(t,i)}function O(t,i){O=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return O(t,i)}var S={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",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};var E=function(t){T(i,t);function i(i,r,e){var n;n=t.call(this)||this;n.hls=void 0;n.fragPrevious=null;n.fragCurrent=null;n.fragmentTracker=void 0;n.transmuxer=null;n._state=S.STOPPED;n.media=void 0;n.mediaBuffer=void 0;n.config=void 0;n.bitrateTest=false;n.lastCurrentTime=0;n.nextLoadPosition=0;n.startPosition=0;n.loadedmetadata=false;n.fragLoadError=0;n.retryDate=0;n.levels=null;n.fragmentLoader=void 0;n.levelLastLoaded=null;n.startFragRequested=false;n.decrypter=void 0;n.initPTS=[];n.onvseeking=null;n.onvended=null;n.logPrefix="";n.log=void 0;n.warn=void 0;n.logPrefix=e;n.log=u["logger"].log.bind(u["logger"],e+":");n.warn=u["logger"].warn.bind(u["logger"],e+":");n.hls=i;n.fragmentLoader=new m["default"](i.config);n.fragmentTracker=r;n.config=i.config;n.decrypter=new p["default"](i,i.config);i.on(f["Events"].KEY_LOADED,n.onKeyLoaded,k(n));return n}var r=i.prototype;r.doTick=function t(){this.onTickEnd()};r.onTickEnd=function t(){};r.startLoad=function t(i){};r.stopLoad=function t(){this.fragmentLoader.abort();var i=this.fragCurrent;if(i){this.fragmentTracker.removeFragment(i)}this.resetTransmuxer();this.fragCurrent=null;this.fragPrevious=null;this.clearInterval();this.clearNextTick();this.state=S.STOPPED};r._streamEnded=function t(i,r){var e=this.fragCurrent,n=this.fragmentTracker;if(!r.live&&e&&e.sn>=r.endSN&&!i.nextStart){var u=r.partList;if(u!==null&&u!==void 0&&u.length){var f=u[u.length-1];var h=a["BufferHelper"].isBuffered(this.media,f.start+f.duration/2);return h}var o=n.getState(e);return o===s["FragmentState"].PARTIAL||o===s["FragmentState"].OK}return false};r.onMediaAttached=function t(i,r){var e=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this);this.onvended=this.onMediaEnded.bind(this);e.addEventListener("seeking",this.onvseeking);e.addEventListener("ended",this.onvended);var n=this.config;if(this.levels&&n.autoStartLoad&&this.state===S.STOPPED){this.startLoad(n.startPosition)}};r.onMediaDetaching=function t(){var i=this.media;if(i!==null&&i!==void 0&&i.ended){this.log("MSE detaching and video ended, reset startPosition");this.startPosition=this.lastCurrentTime=0}if(i){i.removeEventListener("seeking",this.onvseeking);i.removeEventListener("ended",this.onvended);this.onvseeking=this.onvended=null}this.media=this.mediaBuffer=null;this.loadedmetadata=false;this.fragmentTracker.removeAllFragments();this.stopLoad()};r.onMediaSeeking=function t(){var i=this.config,r=this.fragCurrent,n=this.media,s=this.mediaBuffer,u=this.state;var f=n?n.currentTime:0;var h=a["BufferHelper"].bufferInfo(s||n,f,i.maxBufferHole);this.log("media seeking to "+(Object(e["isFiniteNumber"])(f)?f.toFixed(3):f)+", state: "+u);if(u===S.ENDED){this.resetLoadingState()}else if(r&&!h.len){var o=i.maxFragLookUpTolerance;var v=r.start-o;var l=r.start+r.duration+o;var c=f>l;if(f<v||c){if(c&&r.loader){this.log("seeking outside of buffer while fragment load in progress, cancel fragment load");r.loader.abort()}this.resetLoadingState()}}if(n){this.lastCurrentTime=f}if(!this.loadedmetadata&&!h.len){this.nextLoadPosition=this.startPosition=f}this.tickImmediate()};r.onMediaEnded=function t(){this.startPosition=this.lastCurrentTime=0};r.onKeyLoaded=function t(i,r){if(this.state!==S.KEY_LOADING||r.frag!==this.fragCurrent||!this.levels){return}this.state=S.IDLE;var e=this.levels[r.frag.level].details;if(e){this.loadFragment(r.frag,e,r.frag.start)}};r.onHandlerDestroying=function i(){this.stopLoad();t.prototype.onHandlerDestroying.call(this)};r.onHandlerDestroyed=function i(){this.state=S.STOPPED;this.hls.off(f["Events"].KEY_LOADED,this.onKeyLoaded,this);if(this.fragmentLoader){this.fragmentLoader.destroy()}if(this.decrypter){this.decrypter.destroy()}this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null;t.prototype.onHandlerDestroyed.call(this)};r.loadKey=function t(i,r){this.log("Loading key for "+i.sn+" of ["+r.startSN+"-"+r.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+i.level);this.state=S.KEY_LOADING;this.fragCurrent=i;this.hls.trigger(f["Events"].KEY_LOADING,{frag:i})};r.loadFragment=function t(i,r,e){this._loadFragForPlayback(i,r,e)};r._loadFragForPlayback=function t(i,r,e){var n=this;var s=function t(r){if(n.fragContextChanged(i)){n.warn("Fragment "+i.sn+(r.part?" p: "+r.part.index:"")+" of level "+i.level+" was dropped during download.");n.fragmentTracker.removeFragment(i);return}i.stats.chunkCount++;n._handleFragmentLoadProgress(r)};this._doFragLoad(i,r,e,s).then((function(t){if(!t){return}n.fragLoadError=0;var r=n.state;if(n.fragContextChanged(i)){if(r===S.FRAG_LOADING||r===S.BACKTRACKING||!n.fragCurrent&&r===S.PARSING){n.fragmentTracker.removeFragment(i);n.state=S.IDLE}return}if("payload"in t){n.log("Loaded fragment "+i.sn+" of level "+i.level);n.hls.trigger(f["Events"].FRAG_LOADED,t);if(n.state===S.BACKTRACKING){n.fragmentTracker.backtrack(i,t);n.resetFragmentLoading(i);return}}n._handleFragmentLoadComplete(t)})).catch((function(t){n.warn(t);n.resetFragmentLoading(i)}))};r.flushMainBuffer=function t(i,r,e){if(e===void 0){e=null}if(!(i-r)){return}var n={startOffset:i,endOffset:r,type:e};this.fragLoadError=0;this.hls.trigger(f["Events"].BUFFER_FLUSHING,n)};r._loadInitSegment=function t(i){var r=this;this._doFragLoad(i).then((function(t){if(!t||r.fragContextChanged(i)||!r.levels){throw new Error("init load aborted")}return t})).then((function(t){var e=r.hls;var n=t.payload;var s=i.decryptdata;if(n&&n.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){var a=self.performance.now();return r.decrypter.webCryptoDecrypt(new Uint8Array(n),s.key.buffer,s.iv.buffer).then((function(r){var n=self.performance.now();e.trigger(f["Events"].FRAG_DECRYPTED,{frag:i,payload:r,stats:{tstart:a,tdecrypt:n}});t.payload=r;return t}))}return t})).then((function(t){var e=r.fragCurrent,n=r.hls,s=r.levels;if(!s){throw new Error("init load aborted, missing levels")}var a=s[i.level].details;console.assert(a,"Level details are defined when init segment is loaded");var u=i.stats;r.state=S.IDLE;r.fragLoadError=0;i.data=new Uint8Array(t.payload);u.parsing.start=u.buffering.start=self.performance.now();u.parsing.end=u.buffering.end=self.performance.now();if(t.frag===e){n.trigger(f["Events"].FRAG_BUFFERED,{stats:u,frag:e,part:null,id:i.type})}r.tick()})).catch((function(t){r.warn(t);r.resetFragmentLoading(i)}))};r.fragContextChanged=function t(i){var r=this.fragCurrent;return!i||!r||i.level!==r.level||i.sn!==r.sn||i.urlId!==r.urlId};r.fragBufferedComplete=function t(i,r){var e=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+i.type+" sn: "+i.sn+(r?" part: "+r.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+i.level+" "+g["default"].toString(a["BufferHelper"].getBuffered(e)));this.state=S.IDLE;this.tick()};r._handleFragmentLoadComplete=function t(i){var r=this.transmuxer;if(!r){return}var e=i.frag,n=i.part,s=i.partsLoaded;var a=!s||s.length===0||s.some((function(t){return!t}));var u=new o["ChunkMetadata"](e.level,e.sn,e.stats.chunkCount+1,0,n?n.index:-1,!a);r.flush(u)};r._handleFragmentLoadProgress=function t(i){};r._doFragLoad=function t(i,r,n,s){var a=this;if(n===void 0){n=null}if(!this.levels){throw new Error("frag load aborted, missing levels")}n=Math.max(i.start,n||0);if(this.config.lowLatencyMode&&r){var u=r.partList;if(u&&s){if(n>i.end&&r.fragmentHint){i=r.fragmentHint}var h=this.getNextPart(u,i,n);if(h>-1){var o=u[h];this.log("Loading part sn: "+i.sn+" p: "+o.index+" cc: "+i.cc+" of playlist ["+r.startSN+"-"+r.endSN+"] parts [0-"+h+"-"+(u.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+i.level+", target: "+parseFloat(n.toFixed(3)));this.nextLoadPosition=o.start+o.duration;this.state=S.FRAG_LOADING;this.hls.trigger(f["Events"].FRAG_LOADING,{frag:i,part:u[h],targetBufferTime:n});return this.doFragPartsLoad(i,u,h,s).catch((function(t){return a.handleFragLoadError(t)}))}else if(!i.url||this.loadedEndOfParts(u,n)){return Promise.resolve(null)}}}this.log("Loading fragment "+i.sn+" cc: "+i.cc+" "+(r?"of ["+r.startSN+"-"+r.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+i.level+", target: "+parseFloat(n.toFixed(3)));if(Object(e["isFiniteNumber"])(i.sn)&&!this.bitrateTest){this.nextLoadPosition=i.start+i.duration}this.state=S.FRAG_LOADING;this.hls.trigger(f["Events"].FRAG_LOADING,{frag:i,targetBufferTime:n});return this.fragmentLoader.load(i,s).catch((function(t){return a.handleFragLoadError(t)}))};r.doFragPartsLoad=function t(i,r,e,n){var s=this;return new Promise((function(t,a){var u=[];var h=function e(h){var o=r[h];s.fragmentLoader.loadPart(i,o,n).then((function(n){u[o.index]=n;var a=n.part;s.hls.trigger(f["Events"].FRAG_LOADED,n);var v=r[h+1];if(v&&v.fragment===i){e(h+1)}else{return t({frag:i,part:a,partsLoaded:u})}})).catch(a)};h(e)}))};r.handleFragLoadError=function t(i){var r=i.data;if(r&&r.details===h["ErrorDetails"].INTERNAL_ABORTED){this.handleFragLoadAborted(r.frag,r.part)}else{this.hls.trigger(f["Events"].ERROR,r)}return null};r._handleTransmuxerFlush=function t(i){var r=this.getCurrentContext(i);if(!r||this.state!==S.PARSING){if(!this.fragCurrent){this.state=S.IDLE}return}var e=r.frag,n=r.part,s=r.level;var a=self.performance.now();e.stats.parsing.end=a;if(n){n.stats.parsing.end=a}this.updateLevelTiming(e,n,s,i.partial)};r.getCurrentContext=function t(i){var r=this.levels;var e=i.level,n=i.sn,s=i.part;if(!r||!r[e]){this.warn("Levels object was unset while buffering fragment "+n+" of level "+e+". The current chunk will not be buffered.");return null}var a=r[e];var u=s>-1?Object(d["getPartWith"])(a,n,s):null;var f=u?u.fragment:Object(d["getFragmentWithSN"])(a,n,this.fragCurrent);if(!f){return null}return{frag:f,part:u,level:a}};r.bufferFragmentData=function t(i,r,e,n){if(!i||this.state!==S.PARSING){return}var s=i.data1,a=i.data2;var u=s;if(s&&a){u=Object(v["appendUint8Array"])(s,a)}if(!u||!u.length){return}var h={type:i.type,frag:r,part:e,chunkMeta:n,parent:r.type,data:u};this.hls.trigger(f["Events"].BUFFER_APPENDING,h);if(i.dropped&&i.independent&&!e){this.flushBufferGap(r)}};r.flushBufferGap=function t(i){var r=this.media;if(!r){return}if(!a["BufferHelper"].isBuffered(r,r.currentTime)){this.flushMainBuffer(0,i.start);return}var e=r.currentTime;var n=a["BufferHelper"].bufferInfo(r,e,0);var s=i.duration;var u=Math.min(this.config.maxFragLookUpTolerance*2,s*.25);var f=Math.max(Math.min(i.start-u,n.end-u),e+u);if(i.start-f>u){this.flushMainBuffer(f,i.start)}};r.getFwdBufferInfo=function t(i,r){var n=this.config;var s=this.getLoadPosition();if(!Object(e["isFiniteNumber"])(s)){return null}var u=a["BufferHelper"].bufferInfo(i,s,n.maxBufferHole);if(u.len===0&&u.nextStart!==undefined){var f=this.fragmentTracker.getBufferedFrag(s,r);if(f&&u.nextStart<f.end){return a["BufferHelper"].bufferInfo(i,s,Math.max(u.nextStart,n.maxBufferHole))}}return u};r.getMaxBufferLength=function t(i){var r=this.config;var e;if(i){e=Math.max(8*r.maxBufferSize/i,r.maxBufferLength)}else{e=r.maxBufferLength}return Math.min(e,r.maxMaxBufferLength)};r.reduceMaxBufferLength=function t(i){var r=this.config;var e=i||r.maxBufferLength;if(r.maxMaxBufferLength>=e){r.maxMaxBufferLength/=2;this.warn("Reduce max buffer length to "+r.maxMaxBufferLength+"s");return true}return false};r.getNextFragment=function t(i,r){var e,n;var s=r.fragments;var a=s.length;if(!a){return null}var u=this.config;var f=s[0].start;var h;if(r.live){var o=u.initialLiveManifestSize;if(a<o){this.warn("Not enough fragments to start playback (have: "+a+", need: "+o+")");return null}if(!r.PTSKnown&&!this.startFragRequested&&this.startPosition===-1){h=this.getInitialLiveFragment(r,s);this.startPosition=h?this.hls.liveSyncPosition||h.start:i}}else if(i<=f){h=s[0]}if(!h){var v=u.lowLatencyMode?r.partEnd:r.fragmentEnd;h=this.getFragmentAtPosition(i,v,r)}if((e=h)!==null&&e!==void 0&&e.initSegment&&!((n=h)!==null&&n!==void 0&&n.initSegment.data)&&!this.bitrateTest){h=h.initSegment}return h};r.getNextPart=function t(i,r,e){var n=-1;var s=false;var a=true;for(var u=0,f=i.length;u<f;u++){var h=i[u];a=a&&!h.independent;if(n>-1&&e<h.start){break}var o=h.loaded;if(!o&&(s||h.independent||a)&&h.fragment===r){n=u}s=o}return n};r.loadedEndOfParts=function t(i,r){var e=i[i.length-1];return e&&r>e.start&&e.loaded};r.getInitialLiveFragment=function t(i,r){var e=this.fragPrevious;var n=null;if(e){if(i.hasProgramDateTime){this.log("Live playlist, switching playlist, load frag with same PDT: "+e.programDateTime);n=Object(c["findFragmentByPDT"])(r,e.endProgramDateTime,this.config.maxFragLookUpTolerance)}if(!n){var s=e.sn+1;if(s>=i.startSN&&s<=i.endSN){var a=r[s-i.startSN];if(e.cc===a.cc){n=a;this.log("Live playlist, switching playlist, load frag with next SN: "+n.sn)}}if(!n){n=Object(c["findFragWithCC"])(r,e.cc);if(n){this.log("Live playlist, switching playlist, load frag with same CC: "+n.sn)}}}}else{var u=this.hls.liveSyncPosition;if(u!==null){n=this.getFragmentAtPosition(u,this.bitrateTest?i.fragmentEnd:i.edge,i)}}return n};r.getFragmentAtPosition=function t(i,r,e){var n=this.config,a=this.fragPrevious;var u=e.fragments,f=e.endSN;var h=e.fragmentHint;var o=n.maxFragLookUpTolerance;var v=!!(n.lowLatencyMode&&e.partList&&h);if(v&&h&&!this.bitrateTest){u=u.concat(h);f=h.sn}var l;if(i<r){var d=i>r-o?0:o;l=Object(c["findFragmentByPTS"])(a,u,i,d)}else{l=u[u.length-1]}if(l){var m=l.sn-e.startSN;var p=a&&l.level===a.level;var g=u[m+1];var b=this.fragmentTracker.getState(l);if(b===s["FragmentState"].BACKTRACKED){l=null;var y=m;while(u[y]&&this.fragmentTracker.getState(u[y])===s["FragmentState"].BACKTRACKED){if(!a){l=u[--y]}else{l=u[y--]}}if(!l){l=g}}else if(a&&l.sn===a.sn&&!v){if(p){if(l.sn<f&&this.fragmentTracker.getState(g)!==s["FragmentState"].OK){this.log("SN "+l.sn+" just loaded, load next one: "+g.sn);l=g}else{l=null}}}}return l};r.synchronizeToLiveEdge=function t(i){var r=this.config,e=this.media;if(!e){return}var n=this.hls.liveSyncPosition;var s=e.currentTime;var a=i.fragments[0].start;var u=i.edge;var f=s>=a-r.maxFragLookUpTolerance&&s<=u;if(n!==null&&e.duration>n&&(s<n||!f)){var h=r.liveMaxLatencyDuration!==undefined?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*i.targetduration;if(!f&&e.readyState<4||s<u-h){if(!this.loadedmetadata){this.nextLoadPosition=n}if(e.readyState){this.warn("Playback: "+s.toFixed(3)+" is located too far from the end of live sliding playlist: "+u+", reset currentTime to : "+n.toFixed(3));e.currentTime=n}}}};r.alignPlaylists=function t(i,r){var n=this.levels,s=this.levelLastLoaded,a=this.fragPrevious;var u=s!==null?n[s]:null;var f=i.fragments.length;if(!f){this.warn("No fragments in live playlist");return 0}var h=i.fragments[0].start;var o=!r;var v=i.alignedSliding&&Object(e["isFiniteNumber"])(h);if(o||!v&&!h){Object(l["alignStream"])(a,u,i);var c=i.fragments[0].start;this.log("Live playlist sliding: "+c.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+i.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+f);return c}return h};r.waitForCdnTuneIn=function t(i){var r=3;return i.live&&i.canBlockReload&&i.tuneInGoal>Math.max(i.partHoldBack,i.partTarget*r)};r.setStartPosition=function t(i,r){var n=this.startPosition;if(n<r){n=-1}if(n===-1||this.lastCurrentTime===-1){var s=i.startTimeOffset;if(Object(e["isFiniteNumber"])(s)){n=r+s;if(s<0){n+=i.totalduration}n=Math.min(Math.max(r,n),r+i.totalduration);this.log("Start time offset "+s+" found in playlist, adjust startPosition to "+n);this.startPosition=n}else if(i.live){n=this.hls.liveSyncPosition||r}else{this.startPosition=n=0}this.lastCurrentTime=n}this.nextLoadPosition=n};r.getLoadPosition=function t(){var i=this.media;var r=0;if(this.loadedmetadata&&i){r=i.currentTime}else if(this.nextLoadPosition){r=this.nextLoadPosition}return r};r.handleFragLoadAborted=function t(i,r){if(this.transmuxer&&i.sn!=="initSegment"&&i.stats.aborted){this.warn("Fragment "+i.sn+(r?" part"+r.index:"")+" of level "+i.level+" was aborted");this.resetFragmentLoading(i)}};r.resetFragmentLoading=function t(i){if(!this.fragCurrent||!this.fragContextChanged(i)){this.state=S.IDLE}};r.onFragmentOrKeyLoadError=function t(i,r){if(r.fatal){return}var e=r.frag;if(!e||e.type!==i){return}var n=this.fragCurrent;console.assert(n&&e.sn===n.sn&&e.level===n.level&&e.urlId===n.urlId,"Frag load error must match current frag to retry");var s=this.config;if(this.fragLoadError+1<=s.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(e.level)){return}var a=Math.min(Math.pow(2,this.fragLoadError)*s.fragLoadingRetryDelay,s.fragLoadingMaxRetryTimeout);this.warn("Fragment "+e.sn+" of "+i+" "+e.level+" failed to load, retrying in "+a+"ms");this.retryDate=self.performance.now()+a;this.fragLoadError++;this.state=S.FRAG_LOADING_WAITING_RETRY}else if(r.levelRetry){if(i===b["PlaylistLevelType"].AUDIO){this.fragCurrent=null}this.fragLoadError=0;this.state=S.IDLE}else{u["logger"].error(r.details+" reaches max retry, redispatch as fatal ...");r.fatal=true;this.hls.stopLoad();this.state=S.ERROR}};r.afterBufferFlushed=function t(i,r,e){if(!i){return}var n=a["BufferHelper"].getBuffered(i);this.fragmentTracker.detectEvictedFragments(r,n,e);if(this.state===S.ENDED){this.resetLoadingState()}};r.resetLoadingState=function t(){this.fragCurrent=null;this.fragPrevious=null;this.state=S.IDLE};r.resetLiveStartWhenNotLoaded=function t(i){if(!this.loadedmetadata){this.startFragRequested=false;var r=this.levels?this.levels[i].details:null;if(r!==null&&r!==void 0&&r.live){this.startPosition=-1;this.setStartPosition(r,0);this.resetLoadingState();return true}this.nextLoadPosition=this.startPosition}return false};r.updateLevelTiming=function t(i,r,e,n){var s=this;var a=e.details;console.assert(!!a,"level.details must be defined");var u=Object.keys(i.elementaryStreams).reduce((function(t,r){var u=i.elementaryStreams[r];if(u){var h=u.endPTS-u.startPTS;if(h<=0){s.warn("Could not parse fragment "+i.sn+" "+r+" duration reliably ("+h+") resetting transmuxer to fallback to playlist timing");s.resetTransmuxer();return t||false}var o=n?0:Object(d["updateFragPTSDTS"])(a,i,u.startPTS,u.endPTS,u.startDTS,u.endDTS);s.hls.trigger(f["Events"].LEVEL_PTS_UPDATED,{details:a,level:e,drift:o,type:r,frag:i,start:u.startPTS,end:u.endPTS});return true}return t}),false);if(u){this.state=S.PARSED;this.hls.trigger(f["Events"].FRAG_PARSED,{frag:i,part:r})}else{this.resetLoadingState()}};r.resetTransmuxer=function t(){if(this.transmuxer){this.transmuxer.destroy();this.transmuxer=null}};w(i,[{key:"state",get:function t(){return this._state},set:function t(i){var r=this._state;if(r!==i){this._state=i;this.log(r+"->"+i)}}}]);return i}(n["default"])},"./src/controller/buffer-controller.ts":
37
+ /*! exports provided: State, default */function(t,i,n){n.r(i),n.d(i,"State",(function(){return k})),n.d(i,"default",(function(){return T}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../task-loop */"./src/task-loop.ts"),s=n(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),a=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=n(/*! ../utils/logger */"./src/utils/logger.ts"),h=n(/*! ../events */"./src/events.ts"),u=n(/*! ../errors */"./src/errors.ts"),c=n(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=n(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),v=n(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),d=n(/*! ./level-helper */"./src/controller/level-helper.ts"),m=n(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),p=n(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),g=n(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),b=n(/*! ../types/loader */"./src/types/loader.ts");function y(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function w(t,i){return w=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},w(t,i)}var k={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",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},T=function(t){var i,n;function e(i,n,r){var e;return(e=t.call(this)||this).hls=void 0,e.fragPrevious=null,e.fragCurrent=null,e.fragmentTracker=void 0,e.transmuxer=null,e._state=k.STOPPED,e.media=void 0,e.mediaBuffer=void 0,e.config=void 0,e.bitrateTest=!1,e.lastCurrentTime=0,e.nextLoadPosition=0,e.startPosition=0,e.loadedmetadata=!1,e.fragLoadError=0,e.retryDate=0,e.levels=null,e.fragmentLoader=void 0,e.levelLastLoaded=null,e.startFragRequested=!1,e.decrypter=void 0,e.initPTS=[],e.onvseeking=null,e.onvended=null,e.logPrefix="",e.log=void 0,e.warn=void 0,e.logPrefix=r,e.log=o.logger.log.bind(o.logger,r+":"),e.warn=o.logger.warn.bind(o.logger,r+":"),e.hls=i,e.fragmentLoader=new m.default(i.config),e.fragmentTracker=n,e.config=i.config,e.decrypter=new p.default(i,i.config),i.on(h.Events.KEY_LOADED,e.onKeyLoaded,function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)),e}n=t,(i=e).prototype=Object.create(n.prototype),i.prototype.constructor=i,w(i,n);var T,O,S=e.prototype;return S.doTick=function(){this.onTickEnd()},S.onTickEnd=function(){},S.startLoad=function(){},S.stopLoad=function(){this.fragmentLoader.abort();var t=this.fragCurrent;t&&this.fragmentTracker.removeFragment(t),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=k.STOPPED},S._streamEnded=function(t,i){var n=this.fragCurrent,r=this.fragmentTracker;if(!i.live&&n&&n.sn>=i.endSN&&!t.nextStart){var e=i.partList;if(null!=e&&e.length){var o=e[e.length-1];return a.BufferHelper.isBuffered(this.media,o.start+o.duration/2)}var h=r.getState(n);return h===s.FragmentState.PARTIAL||h===s.FragmentState.OK}return!1},S.onMediaAttached=function(t,i){var n=this.media=this.mediaBuffer=i.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),n.addEventListener("seeking",this.onvseeking),n.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.state===k.STOPPED&&this.startLoad(r.startPosition)},S.onMediaDetaching=function(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},S.onMediaSeeking=function(){var t=this.config,i=this.fragCurrent,n=this.media,e=this.state,s=n?n.currentTime:0,o=a.BufferHelper.bufferInfo(this.mediaBuffer||n,s,t.maxBufferHole);if(this.log("media seeking to "+(Object(r.isFiniteNumber)(s)?s.toFixed(3):s)+", state: "+e),e===k.ENDED)this.resetLoadingState();else if(i&&!o.len){var h=t.maxFragLookUpTolerance,u=s>i.start+i.duration+h;(s<i.start-h||u)&&(u&&i.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.loader.abort()),this.resetLoadingState())}n&&(this.lastCurrentTime=s),this.loadedmetadata||o.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()},S.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},S.onKeyLoaded=function(t,i){if(this.state===k.KEY_LOADING&&i.frag===this.fragCurrent&&this.levels){this.state=k.IDLE;var n=this.levels[i.frag.level].details;n&&this.loadFragment(i.frag,n,i.frag.start)}},S.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},S.onHandlerDestroyed=function(){this.state=k.STOPPED,this.hls.off(h.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,t.prototype.onHandlerDestroyed.call(this)},S.loadKey=function(t,i){this.log("Loading key for "+t.sn+" of ["+i.startSN+"-"+i.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=k.KEY_LOADING,this.fragCurrent=t,this.hls.trigger(h.Events.KEY_LOADING,{frag:t})},S.loadFragment=function(t,i,n){this._loadFragForPlayback(t,i,n)},S._loadFragForPlayback=function(t,i,n){var r=this;this._doFragLoad(t,i,n,(function(i){if(r.fragContextChanged(t))return r.warn("Fragment "+t.sn+(i.part?" p: "+i.part.index:"")+" of level "+t.level+" was dropped during download."),void r.fragmentTracker.removeFragment(t);t.stats.chunkCount++,r._handleFragmentLoadProgress(i)})).then((function(i){if(i){r.fragLoadError=0;var n=r.state;if(!r.fragContextChanged(t))return"payload"in i&&(r.log("Loaded fragment "+t.sn+" of level "+t.level),r.hls.trigger(h.Events.FRAG_LOADED,i),r.state===k.BACKTRACKING)?(r.fragmentTracker.backtrack(t,i),void r.resetFragmentLoading(t)):void r._handleFragmentLoadComplete(i);(n===k.FRAG_LOADING||n===k.BACKTRACKING||!r.fragCurrent&&n===k.PARSING)&&(r.fragmentTracker.removeFragment(t),r.state=k.IDLE)}})).catch((function(i){r.warn(i),r.resetFragmentLoading(t)}))},S.flushMainBuffer=function(t,i,n){if(void 0===n&&(n=null),t-i){var r={startOffset:t,endOffset:i,type:n};this.fragLoadError=0,this.hls.trigger(h.Events.BUFFER_FLUSHING,r)}},S._loadInitSegment=function(t){var i=this;this._doFragLoad(t).then((function(n){if(!n||i.fragContextChanged(t)||!i.levels)throw new Error("init load aborted");return n})).then((function(n){var r=i.hls,e=n.payload,s=t.decryptdata;if(e&&e.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){var a=self.performance.now();return i.decrypter.webCryptoDecrypt(new Uint8Array(e),s.key.buffer,s.iv.buffer).then((function(i){var e=self.performance.now();return r.trigger(h.Events.FRAG_DECRYPTED,{frag:t,payload:i,stats:{tstart:a,tdecrypt:e}}),n.payload=i,n}))}return n})).then((function(n){var r=i.fragCurrent,e=i.hls,s=i.levels;if(!s)throw new Error("init load aborted, missing levels");console.assert(s[t.level].details,"Level details are defined when init segment is loaded");var a=t.stats;i.state=k.IDLE,i.fragLoadError=0,t.data=new Uint8Array(n.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),n.frag===r&&e.trigger(h.Events.FRAG_BUFFERED,{stats:a,frag:r,part:null,id:t.type}),i.tick()})).catch((function(n){i.warn(n),i.resetFragmentLoading(t)}))},S.fragContextChanged=function(t){var i=this.fragCurrent;return!t||!i||t.level!==i.level||t.sn!==i.sn||t.urlId!==i.urlId},S.fragBufferedComplete=function(t,i){this.log("Buffered "+t.type+" sn: "+t.sn+(i?" part: "+i.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level+" "+g.default.toString(a.BufferHelper.getBuffered(this.mediaBuffer?this.mediaBuffer:this.media))),this.state=k.IDLE,this.tick()},S._handleFragmentLoadComplete=function(t){var i=this.transmuxer;if(i){var n=t.frag,r=t.part,e=t.partsLoaded,s=!e||0===e.length||e.some((function(t){return!t})),a=new c.ChunkMetadata(n.level,n.sn,n.stats.chunkCount+1,0,r?r.index:-1,!s);i.flush(a)}},S._handleFragmentLoadProgress=function(){},S._doFragLoad=function(t,i,n,e){var s=this;if(void 0===n&&(n=null),!this.levels)throw new Error("frag load aborted, missing levels");if(n=Math.max(t.start,n||0),this.config.lowLatencyMode&&i){var a=i.partList;if(a&&e){n>t.end&&i.fragmentHint&&(t=i.fragmentHint);var o=this.getNextPart(a,t,n);if(o>-1){var u=a[o];return this.log("Loading part sn: "+t.sn+" p: "+u.index+" cc: "+t.cc+" of playlist ["+i.startSN+"-"+i.endSN+"] parts [0-"+o+"-"+(a.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(n.toFixed(3))),this.nextLoadPosition=u.start+u.duration,this.state=k.FRAG_LOADING,this.hls.trigger(h.Events.FRAG_LOADING,{frag:t,part:a[o],targetBufferTime:n}),this.doFragPartsLoad(t,a,o,e).catch((function(t){return s.handleFragLoadError(t)}))}if(!t.url||this.loadedEndOfParts(a,n))return Promise.resolve(null)}}return this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(i?"of ["+i.startSN+"-"+i.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(n.toFixed(3))),Object(r.isFiniteNumber)(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=k.FRAG_LOADING,this.hls.trigger(h.Events.FRAG_LOADING,{frag:t,targetBufferTime:n}),this.fragmentLoader.load(t,e).catch((function(t){return s.handleFragLoadError(t)}))},S.doFragPartsLoad=function(t,i,n,r){var e=this;return new Promise((function(s,a){var o=[];!function n(u){var c=i[u];e.fragmentLoader.loadPart(t,c,r).then((function(r){o[c.index]=r;var a=r.part;e.hls.trigger(h.Events.FRAG_LOADED,r);var f=i[u+1];if(!f||f.fragment!==t)return s({frag:t,part:a,partsLoaded:o});n(u+1)})).catch(a)}(n)}))},S.handleFragLoadError=function(t){var i=t.data;return i&&i.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(i.frag,i.part):this.hls.trigger(h.Events.ERROR,i),null},S._handleTransmuxerFlush=function(t){var i=this.getCurrentContext(t);if(i&&this.state===k.PARSING){var n=i.frag,r=i.part,e=i.level,s=self.performance.now();n.stats.parsing.end=s,r&&(r.stats.parsing.end=s),this.updateLevelTiming(n,r,e,t.partial)}else this.fragCurrent||(this.state=k.IDLE)},S.getCurrentContext=function(t){var i=this.levels,n=t.level,r=t.sn,e=t.part;if(!i||!i[n])return this.warn("Levels object was unset while buffering fragment "+r+" of level "+n+". The current chunk will not be buffered."),null;var s=i[n],a=e>-1?Object(d.getPartWith)(s,r,e):null,o=a?a.fragment:Object(d.getFragmentWithSN)(s,r,this.fragCurrent);return o?{frag:o,part:a,level:s}:null},S.bufferFragmentData=function(t,i,n,r){if(t&&this.state===k.PARSING){var e=t.data1,s=t.data2,a=e;e&&s&&(a=Object(f.appendUint8Array)(e,s)),a&&a.length&&(this.hls.trigger(h.Events.BUFFER_APPENDING,{type:t.type,frag:i,part:n,chunkMeta:r,parent:i.type,data:a}),t.dropped&&t.independent&&!n&&this.flushBufferGap(i))}},S.flushBufferGap=function(t){var i=this.media;if(i)if(a.BufferHelper.isBuffered(i,i.currentTime)){var n=i.currentTime,r=a.BufferHelper.bufferInfo(i,n,0),e=Math.min(2*this.config.maxFragLookUpTolerance,.25*t.duration),s=Math.max(Math.min(t.start-e,r.end-e),n+e);t.start-s>e&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},S.getFwdBufferInfo=function(t,i){var n=this.config,e=this.getLoadPosition();if(!Object(r.isFiniteNumber)(e))return null;var s=a.BufferHelper.bufferInfo(t,e,n.maxBufferHole);if(0===s.len&&void 0!==s.nextStart){var o=this.fragmentTracker.getBufferedFrag(e,i);if(o&&s.nextStart<o.end)return a.BufferHelper.bufferInfo(t,e,Math.max(s.nextStart,n.maxBufferHole))}return s},S.getMaxBufferLength=function(t){var i,n=this.config;return i=t?Math.max(8*n.maxBufferSize/t,n.maxBufferLength):n.maxBufferLength,Math.min(i,n.maxMaxBufferLength)},S.reduceMaxBufferLength=function(t){var i=this.config;return i.maxMaxBufferLength>=(t||i.maxBufferLength)&&(i.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+i.maxMaxBufferLength+"s"),!0)},S.getNextFragment=function(t,i){var n,r,e=i.fragments,s=e.length;if(!s)return null;var a,o=this.config,h=e[0].start;if(i.live){var u=o.initialLiveManifestSize;if(s<u)return this.warn("Not enough fragments to start playback (have: "+s+", need: "+u+")"),null;i.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(i,e),this.startPosition=a?this.hls.liveSyncPosition||a.start:t)}else t<=h&&(a=e[0]);return a||(a=this.getFragmentAtPosition(t,o.lowLatencyMode?i.partEnd:i.fragmentEnd,i)),null===(n=a)||void 0===n||!n.initSegment||null!==(r=a)&&void 0!==r&&r.initSegment.data||this.bitrateTest||(a=a.initSegment),a},S.getNextPart=function(t,i,n){for(var r=-1,e=!1,s=!0,a=0,o=t.length;a<o;a++){var h=t[a];if(s=s&&!h.independent,r>-1&&n<h.start)break;var u=h.loaded;!u&&(e||h.independent||s)&&h.fragment===i&&(r=a),e=u}return r},S.loadedEndOfParts=function(t,i){var n=t[t.length-1];return n&&i>n.start&&n.loaded},S.getInitialLiveFragment=function(t,i){var n=this.fragPrevious,r=null;if(n){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),r=Object(v.findFragmentByPDT)(i,n.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){var e=n.sn+1;if(e>=t.startSN&&e<=t.endSN){var s=i[e-t.startSN];n.cc===s.cc&&this.log("Live playlist, switching playlist, load frag with next SN: "+(r=s).sn)}r||(r=Object(v.findFragWithCC)(i,n.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+r.sn)}}else{var a=this.hls.liveSyncPosition;null!==a&&(r=this.getFragmentAtPosition(a,this.bitrateTest?t.fragmentEnd:t.edge,t))}return r},S.getFragmentAtPosition=function(t,i,n){var r,e=this.config,a=this.fragPrevious,o=n.fragments,h=n.endSN,u=n.fragmentHint,c=e.maxFragLookUpTolerance,f=!!(e.lowLatencyMode&&n.partList&&u);if(f&&u&&!this.bitrateTest&&(o=o.concat(u),h=u.sn),t<i){var l=t>i-c?0:c;r=Object(v.findFragmentByPTS)(a,o,t,l)}else r=o[o.length-1];if(r){var d=r.sn-n.startSN,m=a&&r.level===a.level,p=o[d+1];if(this.fragmentTracker.getState(r)===s.FragmentState.BACKTRACKED){r=null;for(var g=d;o[g]&&this.fragmentTracker.getState(o[g])===s.FragmentState.BACKTRACKED;)r=a?o[g--]:o[--g];r||(r=p)}else a&&r.sn===a.sn&&!f&&m&&(r.sn<h&&this.fragmentTracker.getState(p)!==s.FragmentState.OK?(this.log("SN "+r.sn+" just loaded, load next one: "+p.sn),r=p):r=null)}return r},S.synchronizeToLiveEdge=function(t){var i=this.config,n=this.media;if(n){var r=this.hls.liveSyncPosition,e=n.currentTime,s=t.edge,a=e>=t.fragments[0].start-i.maxFragLookUpTolerance&&e<=s;null!==r&&n.duration>r&&(e<r||!a)&&(!a&&n.readyState<4||e<s-(void 0!==i.liveMaxLatencyDuration?i.liveMaxLatencyDuration:i.liveMaxLatencyDurationCount*t.targetduration))&&(this.loadedmetadata||(this.nextLoadPosition=r),n.readyState&&(this.warn("Playback: "+e.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+r.toFixed(3)),n.currentTime=r))}},S.alignPlaylists=function(t,i){var n=this.levelLastLoaded,e=this.fragPrevious,s=null!==n?this.levels[n]:null,a=t.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;var o=t.fragments[0].start,h=!i,u=t.alignedSliding&&Object(r.isFiniteNumber)(o);if(h||!u&&!o){Object(l.alignStream)(e,s,t);var c=t.fragments[0].start;return this.log("Live playlist sliding: "+c.toFixed(2)+" start-sn: "+(i?i.startSN:"na")+"->"+t.startSN+" prev-sn: "+(e?e.sn:"na")+" fragments: "+a),c}return o},S.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},S.setStartPosition=function(t,i){var n=this.startPosition;if(n<i&&(n=-1),-1===n||-1===this.lastCurrentTime){var e=t.startTimeOffset;Object(r.isFiniteNumber)(e)?(n=i+e,e<0&&(n+=t.totalduration),n=Math.min(Math.max(i,n),i+t.totalduration),this.log("Start time offset "+e+" found in playlist, adjust startPosition to "+n),this.startPosition=n):t.live?n=this.hls.liveSyncPosition||i:this.startPosition=n=0,this.lastCurrentTime=n}this.nextLoadPosition=n},S.getLoadPosition=function(){var t=this.media,i=0;return this.loadedmetadata&&t?i=t.currentTime:this.nextLoadPosition&&(i=this.nextLoadPosition),i},S.handleFragLoadAborted=function(t,i){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(i?" part"+i.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},S.resetFragmentLoading=function(t){this.fragCurrent&&this.fragContextChanged(t)||(this.state=k.IDLE)},S.onFragmentOrKeyLoadError=function(t,i){if(!i.fatal){var n=i.frag;if(n&&n.type===t){var r=this.fragCurrent;console.assert(r&&n.sn===r.sn&&n.level===r.level&&n.urlId===r.urlId,"Frag load error must match current frag to retry");var e=this.config;if(this.fragLoadError+1<=e.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(n.level))return;var s=Math.min(Math.pow(2,this.fragLoadError)*e.fragLoadingRetryDelay,e.fragLoadingMaxRetryTimeout);this.warn("Fragment "+n.sn+" of "+t+" "+n.level+" failed to load, retrying in "+s+"ms"),this.retryDate=self.performance.now()+s,this.fragLoadError++,this.state=k.FRAG_LOADING_WAITING_RETRY}else i.levelRetry?(t===b.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=k.IDLE):(o.logger.error(i.details+" reaches max retry, redispatch as fatal ..."),i.fatal=!0,this.hls.stopLoad(),this.state=k.ERROR)}}},S.afterBufferFlushed=function(t,i,n){if(t){var r=a.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(i,r,n),this.state===k.ENDED&&this.resetLoadingState()}},S.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=k.IDLE},S.resetLiveStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var i=this.levels?this.levels[t].details:null;if(null!=i&&i.live)return this.startPosition=-1,this.setStartPosition(i,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},S.updateLevelTiming=function(t,i,n,r){var e=this,s=n.details;console.assert(!!s,"level.details must be defined"),Object.keys(t.elementaryStreams).reduce((function(i,a){var o=t.elementaryStreams[a];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return e.warn("Could not parse fragment "+t.sn+" "+a+" duration reliably ("+u+") resetting transmuxer to fallback to playlist timing"),e.resetTransmuxer(),i||!1;var c=r?0:Object(d.updateFragPTSDTS)(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return e.hls.trigger(h.Events.LEVEL_PTS_UPDATED,{details:s,level:n,drift:c,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return i}),!1)?(this.state=k.PARSED,this.hls.trigger(h.Events.FRAG_PARSED,{frag:t,part:i})):this.resetLoadingState()},S.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},T=e,(O=[{key:"state",get:function(){return this._state},set:function(t){var i=this._state;i!==t&&(this._state=t,this.log(i+"->"+t))}}])&&y(T.prototype,O),e}(e.default)},"./src/controller/buffer-controller.ts":
38
38
  /*!*********************************************!*\
39
39
  !*** ./src/controller/buffer-controller.ts ***!
40
40
  \*********************************************/
41
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return c}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ../errors */"./src/errors.ts");var u=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var f=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts");var h=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var o=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts");var v=Object(f["getMediaSource"])();var l=/([ha]vc.)(?:\.[^.,]+)+/;var c=function(){function t(t){var i=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.appendError=0;this.tracks={};this.pendingTracks={};this.sourceBuffer=void 0;this._onMediaSourceOpen=function(){var t=i.hls,r=i.media,e=i.mediaSource;s["logger"].log("[buffer-controller]: Media source opened");if(r){i.updateMediaElementDuration();t.trigger(n["Events"].MEDIA_ATTACHED,{media:r})}if(e){e.removeEventListener("sourceopen",i._onMediaSourceOpen)}i.checkPendingTracks()};this._onMediaSourceClose=function(){s["logger"].log("[buffer-controller]: Media source closed")};this._onMediaSourceEnded=function(){s["logger"].log("[buffer-controller]: Media source ended")};this.hls=t;this._initSourceBuffer();this.registerListeners()}var i=t.prototype;i.hasSourceTypes=function t(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0};i.destroy=function t(){this.unregisterListeners();this.details=null};i.registerListeners=function t(){var i=this.hls;i.on(n["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.on(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(n["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(n["Events"].BUFFER_RESET,this.onBufferReset,this);i.on(n["Events"].BUFFER_APPENDING,this.onBufferAppending,this);i.on(n["Events"].BUFFER_CODECS,this.onBufferCodecs,this);i.on(n["Events"].BUFFER_EOS,this.onBufferEos,this);i.on(n["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this);i.on(n["Events"].LEVEL_UPDATED,this.onLevelUpdated,this);i.on(n["Events"].FRAG_PARSED,this.onFragParsed,this);i.on(n["Events"].FRAG_CHANGED,this.onFragChanged,this)};i.unregisterListeners=function t(){var i=this.hls;i.off(n["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.off(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(n["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(n["Events"].BUFFER_RESET,this.onBufferReset,this);i.off(n["Events"].BUFFER_APPENDING,this.onBufferAppending,this);i.off(n["Events"].BUFFER_CODECS,this.onBufferCodecs,this);i.off(n["Events"].BUFFER_EOS,this.onBufferEos,this);i.off(n["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this);i.off(n["Events"].LEVEL_UPDATED,this.onLevelUpdated,this);i.off(n["Events"].FRAG_PARSED,this.onFragParsed,this);i.off(n["Events"].FRAG_CHANGED,this.onFragChanged,this)};i._initSourceBuffer=function t(){this.sourceBuffer={};this.operationQueue=new o["default"](this.sourceBuffer);this.listeners={audio:[],video:[],audiovideo:[]}};i.onManifestParsed=function t(i,r){var e=2;if(r.audio&&!r.video||!r.altAudio){e=1}this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=e;this.details=null;s["logger"].log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")};i.onMediaAttaching=function t(i,r){var e=this.media=r.media;if(e&&v){var n=this.mediaSource=new v;n.addEventListener("sourceopen",this._onMediaSourceOpen);n.addEventListener("sourceended",this._onMediaSourceEnded);n.addEventListener("sourceclose",this._onMediaSourceClose);e.src=self.URL.createObjectURL(n);this._objectUrl=e.src}};i.onMediaDetaching=function t(){var i=this.media,r=this.mediaSource,e=this._objectUrl;if(r){s["logger"].log("[buffer-controller]: media source detaching");if(r.readyState==="open"){try{r.endOfStream()}catch(t){s["logger"].warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}}this.onBufferReset();r.removeEventListener("sourceopen",this._onMediaSourceOpen);r.removeEventListener("sourceended",this._onMediaSourceEnded);r.removeEventListener("sourceclose",this._onMediaSourceClose);if(i){if(e){self.URL.revokeObjectURL(e)}if(i.src===e){i.removeAttribute("src");i.load()}else{s["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(n["Events"].MEDIA_DETACHED,undefined)};i.onBufferReset=function t(){var i=this;this.getSourceBufferTypes().forEach((function(t){var r=i.sourceBuffer[t];try{if(r){i.removeBufferListeners(t);if(i.mediaSource){i.mediaSource.removeSourceBuffer(r)}i.sourceBuffer[t]=undefined}}catch(i){s["logger"].warn("[buffer-controller]: Failed to reset the "+t+" buffer",i)}}));this._initSourceBuffer()};i.onBufferCodecs=function t(i,r){var e=this;var n=this.getSourceBufferTypes().length;Object.keys(r).forEach((function(t){if(n){var i=e.tracks[t];if(i&&typeof i.buffer.changeType==="function"){var s=r[t],a=s.codec,u=s.levelCodec,f=s.container;var h=(i.levelCodec||i.codec).replace(l,"$1");var o=(u||a).replace(l,"$1");if(h!==o){var v=f+";codecs="+(u||a);e.appendChangeType(t,v)}}}else{e.pendingTracks[t]=r[t]}}));if(n){return}this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0);if(this.mediaSource&&this.mediaSource.readyState==="open"){this.checkPendingTracks()}};i.appendChangeType=function t(i,r){var e=this;var n=this.operationQueue;var a={execute:function t(){var a=e.sourceBuffer[i];if(a){s["logger"].log("[buffer-controller]: changing "+i+" sourceBuffer type to "+r);a.changeType(r)}n.shiftAndExecuteNext(i)},onStart:function t(){},onComplete:function t(){},onError:function t(r){s["logger"].warn("[buffer-controller]: Failed to change "+i+" SourceBuffer type",r)}};n.append(a,i)};i.onBufferAppending=function t(i,r){var e=this;var f=this.hls,h=this.operationQueue,o=this.tracks;var v=r.data,l=r.type,c=r.frag,d=r.part,m=r.chunkMeta;var p=m.buffering[l];var g=self.performance.now();p.start=g;var b=c.stats.buffering;var y=d?d.stats.buffering:null;if(b.start===0){b.start=g}if(y&&y.start===0){y.start=g}var w=o.audio;var k=l==="audio"&&m.id===1&&(w===null||w===void 0?void 0:w.container)==="audio/mpeg";var T={execute:function t(){p.executeStart=self.performance.now();if(k){var i=e.sourceBuffer[l];if(i){var r=c.start-i.timestampOffset;if(Math.abs(r)>=.1){s["logger"].log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+c.start+" (delta: "+r+") sn: "+c.sn+")");i.timestampOffset=c.start}}}e.appendExecutor(v,l)},onStart:function t(){},onComplete:function t(){var i=self.performance.now();p.executeEnd=p.end=i;if(b.first===0){b.first=i}if(y&&y.first===0){y.first=i}var r=e.sourceBuffer;var s={};for(var a in r){s[a]=u["BufferHelper"].getBuffered(r[a])}e.appendError=0;e.hls.trigger(n["Events"].BUFFER_APPENDED,{type:l,frag:c,part:d,chunkMeta:m,parent:c.type,timeRanges:s})},onError:function t(i){s["logger"].error("[buffer-controller]: Error encountered while trying to append to the "+l+" SourceBuffer",i);var r={type:a["ErrorTypes"].MEDIA_ERROR,parent:c.type,details:a["ErrorDetails"].BUFFER_APPEND_ERROR,err:i,fatal:false};if(i.code===DOMException.QUOTA_EXCEEDED_ERR){r.details=a["ErrorDetails"].BUFFER_FULL_ERROR}else{e.appendError++;r.details=a["ErrorDetails"].BUFFER_APPEND_ERROR;if(e.appendError>f.config.appendErrorMaxRetry){s["logger"].error("[buffer-controller]: Failed "+f.config.appendErrorMaxRetry+" times to append segment in sourceBuffer");r.fatal=true}}f.trigger(n["Events"].ERROR,r)}};h.append(T,l)};i.onBufferFlushing=function t(i,r){var e=this;var a=this.operationQueue;var u=function t(i){return{execute:e.removeExecutor.bind(e,i,r.startOffset,r.endOffset),onStart:function t(){},onComplete:function t(){e.hls.trigger(n["Events"].BUFFER_FLUSHED,{type:i})},onError:function t(r){s["logger"].warn("[buffer-controller]: Failed to remove from "+i+" SourceBuffer",r)}}};if(r.type){a.append(u(r.type),r.type)}else{this.getSourceBufferTypes().forEach((function(t){a.append(u(t),t)}))}};i.onFragParsed=function t(i,r){var e=this;var a=r.frag,u=r.part;var f=[];var o=u?u.elementaryStreams:a.elementaryStreams;if(o[h["ElementaryStreamTypes"].AUDIOVIDEO]){f.push("audiovideo")}else{if(o[h["ElementaryStreamTypes"].AUDIO]){f.push("audio")}if(o[h["ElementaryStreamTypes"].VIDEO]){f.push("video")}}var v=function t(){var i=self.performance.now();a.stats.buffering.end=i;if(u){u.stats.buffering.end=i}var r=u?u.stats:a.stats;e.hls.trigger(n["Events"].FRAG_BUFFERED,{frag:a,part:u,stats:r,id:a.type})};if(f.length===0){s["logger"].warn("Fragments must have at least one ElementaryStreamType set. type: "+a.type+" level: "+a.level+" sn: "+a.sn)}this.blockBuffers(v,f)};i.onFragChanged=function t(i,r){this.flushBackBuffer()};i.onBufferEos=function t(i,r){var e=this;var n=this.getSourceBufferTypes().reduce((function(t,i){var n=e.sourceBuffer[i];if(!r.type||r.type===i){if(n&&!n.ended){n.ended=true;s["logger"].log("[buffer-controller]: "+i+" sourceBuffer now EOS")}}return t&&!!(!n||n.ended)}),true);if(n){this.blockBuffers((function(){var t=e.mediaSource;if(!t||t.readyState!=="open"){return}t.endOfStream()}))}};i.onLevelUpdated=function t(i,r){var e=r.details;if(!e.fragments.length){return}this.details=e;if(this.getSourceBufferTypes().length){this.blockBuffers(this.updateMediaElementDuration.bind(this))}else{this.updateMediaElementDuration()}};i.flushBackBuffer=function t(){var i=this.hls,r=this.details,s=this.media,a=this.sourceBuffer;if(!s||r===null){return}var f=this.getSourceBufferTypes();if(!f.length){return}var h=r.live&&i.config.liveBackBufferLength!==null?i.config.liveBackBufferLength:i.config.backBufferLength;if(!Object(e["isFiniteNumber"])(h)||h<0){return}var o=s.currentTime;var v=r.levelTargetDuration;var l=Math.max(h,v);var c=Math.floor(o/v)*v-l;f.forEach((function(t){var e=a[t];if(e){var s=u["BufferHelper"].getBuffered(e);if(s.length>0&&c>s.start(0)){i.trigger(n["Events"].BACK_BUFFER_REACHED,{bufferEnd:c});if(r.live){i.trigger(n["Events"].LIVE_BACK_BUFFER_REACHED,{bufferEnd:c})}i.trigger(n["Events"].BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:t})}}}))};i.updateMediaElementDuration=function t(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open"){return}var i=this.details,r=this.hls,n=this.media,a=this.mediaSource;var u=i.fragments[0].start+i.totalduration;var f=n.duration;var h=Object(e["isFiniteNumber"])(a.duration)?a.duration:0;if(i.live&&r.config.liveDurationInfinity){s["logger"].log("[buffer-controller]: Media Source duration is set to Infinity");a.duration=Infinity;this.updateSeekableRange(i)}else if(u>h&&u>f||!Object(e["isFiniteNumber"])(f)){s["logger"].log("[buffer-controller]: Updating Media Source duration to "+u.toFixed(3));a.duration=u}};i.updateSeekableRange=function t(i){var r=this.mediaSource;var e=i.fragments;var n=e.length;if(n&&i.live&&r!==null&&r!==void 0&&r.setLiveSeekableRange){var s=Math.max(0,e[0].start);var a=Math.max(s,s+i.totalduration);r.setLiveSeekableRange(s,a)}};i.checkPendingTracks=function t(){var i=this.bufferCodecEventsExpected,r=this.operationQueue,e=this.pendingTracks;var s=Object.keys(e).length;if(s&&!i||s===2){this.createSourceBuffers(e);this.pendingTracks={};var u=this.getSourceBufferTypes();if(u.length===0){this.hls.trigger(n["Events"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:true,reason:"could not create source buffer for media codec(s)"});return}u.forEach((function(t){r.executeNext(t)}))}};i.createSourceBuffers=function t(i){var r=this.sourceBuffer,e=this.mediaSource;if(!e){throw Error("createSourceBuffers called when mediaSource was null")}var u=0;for(var f in i){if(!r[f]){var h=i[f];if(!h){throw Error("source buffer exists for track "+f+", however track does not")}var o=h.levelCodec||h.codec;var v=h.container+";codecs="+o;s["logger"].log("[buffer-controller]: creating sourceBuffer("+v+")");try{var l=r[f]=e.addSourceBuffer(v);var c=f;this.addBufferListener(c,"updatestart",this._onSBUpdateStart);this.addBufferListener(c,"updateend",this._onSBUpdateEnd);this.addBufferListener(c,"error",this._onSBUpdateError);this.tracks[f]={buffer:l,codec:o,container:h.container,levelCodec:h.levelCodec,id:h.id};u++}catch(t){s["logger"].error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message);this.hls.trigger(n["Events"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].BUFFER_ADD_CODEC_ERROR,fatal:false,error:t,mimeType:v})}}}if(u){this.hls.trigger(n["Events"].BUFFER_CREATED,{tracks:this.tracks})}};i._onSBUpdateStart=function t(i){var r=this.operationQueue;var e=r.current(i);e.onStart()};i._onSBUpdateEnd=function t(i){var r=this.operationQueue;var e=r.current(i);e.onComplete();r.shiftAndExecuteNext(i)};i._onSBUpdateError=function t(i,r){s["logger"].error("[buffer-controller]: "+i+" SourceBuffer error",r);this.hls.trigger(n["Events"].ERROR,{type:a["ErrorTypes"].MEDIA_ERROR,details:a["ErrorDetails"].BUFFER_APPENDING_ERROR,fatal:false});var e=this.operationQueue.current(i);if(e){e.onError(r)}};i.removeExecutor=function t(i,r,n){var a=this.media,u=this.mediaSource,f=this.operationQueue,h=this.sourceBuffer;var o=h[i];if(!a||!u||!o){s["logger"].warn("[buffer-controller]: Attempting to remove from the "+i+" SourceBuffer, but it does not exist");f.shiftAndExecuteNext(i);return}var v=Object(e["isFiniteNumber"])(a.duration)?a.duration:Infinity;var l=Object(e["isFiniteNumber"])(u.duration)?u.duration:Infinity;var c=Math.max(0,r);var d=Math.min(n,v,l);if(d>c){s["logger"].log("[buffer-controller]: Removing ["+c+","+d+"] from the "+i+" SourceBuffer");console.assert(!o.updating,i+" sourceBuffer must not be updating");o.remove(c,d)}else{f.shiftAndExecuteNext(i)}};i.appendExecutor=function t(i,r){var e=this.operationQueue,n=this.sourceBuffer;var a=n[r];if(!a){s["logger"].warn("[buffer-controller]: Attempting to append to the "+r+" SourceBuffer, but it does not exist");e.shiftAndExecuteNext(r);return}a.ended=false;console.assert(!a.updating,r+" sourceBuffer must not be updating");a.appendBuffer(i)};i.blockBuffers=function t(i,r){var e=this;if(r===void 0){r=this.getSourceBufferTypes()}if(!r.length){s["logger"].log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist");return}var n=this.operationQueue;var a=r.map((function(t){return n.appendBlocker(t)}));Promise.all(a).then((function(){i();r.forEach((function(t){var i=e.sourceBuffer[t];if(!i||!i.updating){n.shiftAndExecuteNext(t)}}))}))};i.getSourceBufferTypes=function t(){return Object.keys(this.sourceBuffer)};i.addBufferListener=function t(i,r,e){var n=this.sourceBuffer[i];if(!n){return}var s=e.bind(this,i);this.listeners[i].push({event:r,listener:s});n.addEventListener(r,s)};i.removeBufferListeners=function t(i){var r=this.sourceBuffer[i];if(!r){return}this.listeners[i].forEach((function(t){r.removeEventListener(t.event,t.listener)}))};return t}()},"./src/controller/buffer-operation-queue.ts":
41
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return v}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! ../errors */"./src/errors.ts"),o=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),h=n(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=n(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),f=Object(h.getMediaSource)(),l=/([ha]vc.)(?:\.[^.,]+)+/,v=function(){function t(t){var i=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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=i.hls,n=i.media,r=i.mediaSource;s.logger.log("[buffer-controller]: Media source opened"),n&&(i.updateMediaElementDuration(),t.trigger(e.Events.MEDIA_ATTACHED,{media:n})),r&&r.removeEventListener("sourceopen",i._onMediaSourceOpen),i.checkPendingTracks()},this._onMediaSourceClose=function(){s.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){s.logger.log("[buffer-controller]: Media source ended")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var i=t.prototype;return i.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},i.destroy=function(){this.unregisterListeners(),this.details=null},i.registerListeners=function(){var t=this.hls;t.on(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(e.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(e.Events.BUFFER_RESET,this.onBufferReset,this),t.on(e.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(e.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(e.Events.BUFFER_EOS,this.onBufferEos,this),t.on(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(e.Events.FRAG_PARSED,this.onFragParsed,this),t.on(e.Events.FRAG_CHANGED,this.onFragChanged,this)},i.unregisterListeners=function(){var t=this.hls;t.off(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(e.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(e.Events.BUFFER_RESET,this.onBufferReset,this),t.off(e.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(e.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(e.Events.BUFFER_EOS,this.onBufferEos,this),t.off(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(e.Events.FRAG_PARSED,this.onFragParsed,this),t.off(e.Events.FRAG_CHANGED,this.onFragChanged,this)},i._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new c.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},i.onManifestParsed=function(t,i){var n=2;(i.audio&&!i.video||!i.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,this.details=null,s.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},i.onMediaAttaching=function(t,i){var n=this.media=i.media;if(n&&f){var r=this.mediaSource=new f;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(r),this._objectUrl=n.src}},i.onMediaDetaching=function(){var t=this.media,i=this.mediaSource,n=this._objectUrl;if(i){if(s.logger.log("[buffer-controller]: media source detaching"),"open"===i.readyState)try{i.endOfStream()}catch(t){s.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(n&&self.URL.revokeObjectURL(n),t.src===n?(t.removeAttribute("src"),t.load()):s.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(e.Events.MEDIA_DETACHED,void 0)},i.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(i){var n=t.sourceBuffer[i];try{n&&(t.removeBufferListeners(i),t.mediaSource&&t.mediaSource.removeSourceBuffer(n),t.sourceBuffer[i]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+i+" buffer",t)}})),this._initSourceBuffer()},i.onBufferCodecs=function(t,i){var n=this,r=this.getSourceBufferTypes().length;Object.keys(i).forEach((function(t){if(r){var e=n.tracks[t];if(e&&"function"==typeof e.buffer.changeType){var s=i[t],a=s.codec,o=s.levelCodec,h=s.container;(e.levelCodec||e.codec).replace(l,"$1")!==(o||a).replace(l,"$1")&&n.appendChangeType(t,h+";codecs="+(o||a))}}else n.pendingTracks[t]=i[t]})),r||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},i.appendChangeType=function(t,i){var n=this,r=this.operationQueue,e={execute:function(){var e=n.sourceBuffer[t];e&&(s.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+i),e.changeType(i)),r.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(i){s.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",i)}};r.append(e,t)},i.onBufferAppending=function(t,i){var n=this,r=this.hls,h=this.operationQueue,u=this.tracks,c=i.data,f=i.type,l=i.frag,v=i.part,d=i.chunkMeta,m=d.buffering[f],p=self.performance.now();m.start=p;var g=l.stats.buffering,b=v?v.stats.buffering:null;0===g.start&&(g.start=p),b&&0===b.start&&(b.start=p);var y=u.audio,w="audio"===f&&1===d.id&&"audio/mpeg"===(null==y?void 0:y.container),k={execute:function(){if(m.executeStart=self.performance.now(),w){var t=n.sourceBuffer[f];if(t){var i=l.start-t.timestampOffset;Math.abs(i)>=.1&&(s.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+l.start+" (delta: "+i+") sn: "+l.sn+")"),t.timestampOffset=l.start)}}n.appendExecutor(c,f)},onStart:function(){},onComplete:function(){var t=self.performance.now();m.executeEnd=m.end=t,0===g.first&&(g.first=t),b&&0===b.first&&(b.first=t);var i=n.sourceBuffer,r={};for(var s in i)r[s]=o.BufferHelper.getBuffered(i[s]);n.appendError=0,n.hls.trigger(e.Events.BUFFER_APPENDED,{type:f,frag:l,part:v,chunkMeta:d,parent:l.type,timeRanges:r})},onError:function(t){s.logger.error("[buffer-controller]: Error encountered while trying to append to the "+f+" SourceBuffer",t);var i={type:a.ErrorTypes.MEDIA_ERROR,parent:l.type,details:a.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?i.details=a.ErrorDetails.BUFFER_FULL_ERROR:(n.appendError++,i.details=a.ErrorDetails.BUFFER_APPEND_ERROR,n.appendError>r.config.appendErrorMaxRetry&&(s.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),i.fatal=!0)),r.trigger(e.Events.ERROR,i)}};h.append(k,f)},i.onBufferFlushing=function(t,i){var n=this,r=this.operationQueue,a=function(t){return{execute:n.removeExecutor.bind(n,t,i.startOffset,i.endOffset),onStart:function(){},onComplete:function(){n.hls.trigger(e.Events.BUFFER_FLUSHED,{type:t})},onError:function(i){s.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",i)}}};i.type?r.append(a(i.type),i.type):this.getSourceBufferTypes().forEach((function(t){r.append(a(t),t)}))},i.onFragParsed=function(t,i){var n=this,r=i.frag,a=i.part,o=[],h=a?a.elementaryStreams:r.elementaryStreams;h[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(h[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),h[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&s.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers((function(){var t=self.performance.now();r.stats.buffering.end=t,a&&(a.stats.buffering.end=t),n.hls.trigger(e.Events.FRAG_BUFFERED,{frag:r,part:a,stats:a?a.stats:r.stats,id:r.type})}),o)},i.onFragChanged=function(){this.flushBackBuffer()},i.onBufferEos=function(t,i){var n=this;this.getSourceBufferTypes().reduce((function(t,r){var e=n.sourceBuffer[r];return i.type&&i.type!==r||e&&!e.ended&&(e.ended=!0,s.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),t&&!(e&&!e.ended)}),!0)&&this.blockBuffers((function(){var t=n.mediaSource;t&&"open"===t.readyState&&t.endOfStream()}))},i.onLevelUpdated=function(t,i){var n=i.details;n.fragments.length&&(this.details=n,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},i.flushBackBuffer=function(){var t=this.hls,i=this.details,n=this.media,s=this.sourceBuffer;if(n&&null!==i){var a=this.getSourceBufferTypes();if(a.length){var h=i.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(r.isFiniteNumber)(h)&&!(h<0)){var u=n.currentTime,c=i.levelTargetDuration,f=Math.max(h,c),l=Math.floor(u/c)*c-f;a.forEach((function(n){var r=s[n];if(r){var a=o.BufferHelper.getBuffered(r);a.length>0&&l>a.start(0)&&(t.trigger(e.Events.BACK_BUFFER_REACHED,{bufferEnd:l}),i.live&&t.trigger(e.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:l}),t.trigger(e.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:l,type:n}))}}))}}}},i.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,i=this.hls,n=this.mediaSource,e=t.fragments[0].start+t.totalduration,a=this.media.duration,o=Object(r.isFiniteNumber)(n.duration)?n.duration:0;t.live&&i.config.liveDurationInfinity?(s.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(e>o&&e>a||!Object(r.isFiniteNumber)(a))&&(s.logger.log("[buffer-controller]: Updating Media Source duration to "+e.toFixed(3)),n.duration=e)}},i.updateSeekableRange=function(t){var i=this.mediaSource,n=t.fragments;if(n.length&&t.live&&null!=i&&i.setLiveSeekableRange){var r=Math.max(0,n[0].start),e=Math.max(r,r+t.totalduration);i.setLiveSeekableRange(r,e)}},i.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,i=this.operationQueue,n=this.pendingTracks,r=Object.keys(n).length;if(r&&!t||2===r){this.createSourceBuffers(n),this.pendingTracks={};var s=this.getSourceBufferTypes();if(0===s.length)return void this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});s.forEach((function(t){i.executeNext(t)}))}},i.createSourceBuffers=function(t){var i=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");var r=0;for(var o in t)if(!i[o]){var h=t[o];if(!h)throw Error("source buffer exists for track "+o+", however track does not");var u=h.levelCodec||h.codec,c=h.container+";codecs="+u;s.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var f=i[o]=n.addSourceBuffer(c),l=o;this.addBufferListener(l,"updatestart",this._onSBUpdateStart),this.addBufferListener(l,"updateend",this._onSBUpdateEnd),this.addBufferListener(l,"error",this._onSBUpdateError),this.tracks[o]={buffer:f,codec:u,container:h.container,levelCodec:h.levelCodec,id:h.id},r++}catch(t){s.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:c})}}r&&this.hls.trigger(e.Events.BUFFER_CREATED,{tracks:this.tracks})},i._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},i._onSBUpdateEnd=function(t){var i=this.operationQueue;i.current(t).onComplete(),i.shiftAndExecuteNext(t)},i._onSBUpdateError=function(t,i){s.logger.error("[buffer-controller]: "+t+" SourceBuffer error",i),this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var n=this.operationQueue.current(t);n&&n.onError(i)},i.removeExecutor=function(t,i,n){var e=this.media,a=this.mediaSource,o=this.operationQueue,h=this.sourceBuffer[t];if(!e||!a||!h)return s.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(t);var u=Object(r.isFiniteNumber)(e.duration)?e.duration:1/0,c=Object(r.isFiniteNumber)(a.duration)?a.duration:1/0,f=Math.max(0,i),l=Math.min(n,u,c);l>f?(s.logger.log("[buffer-controller]: Removing ["+f+","+l+"] from the "+t+" SourceBuffer"),console.assert(!h.updating,t+" sourceBuffer must not be updating"),h.remove(f,l)):o.shiftAndExecuteNext(t)},i.appendExecutor=function(t,i){var n=this.operationQueue,r=this.sourceBuffer[i];if(!r)return s.logger.warn("[buffer-controller]: Attempting to append to the "+i+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(i);r.ended=!1,console.assert(!r.updating,i+" sourceBuffer must not be updating"),r.appendBuffer(t)},i.blockBuffers=function(t,i){var n=this;if(void 0===i&&(i=this.getSourceBufferTypes()),i.length){var r=this.operationQueue,e=i.map((function(t){return r.appendBlocker(t)}));Promise.all(e).then((function(){t(),i.forEach((function(t){var i=n.sourceBuffer[t];i&&i.updating||r.shiftAndExecuteNext(t)}))}))}else s.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist")},i.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},i.addBufferListener=function(t,i,n){var r=this.sourceBuffer[t];if(r){var e=n.bind(this,t);this.listeners[t].push({event:i,listener:e}),r.addEventListener(i,e)}},i.removeBufferListeners=function(t){var i=this.sourceBuffer[t];i&&this.listeners[t].forEach((function(t){i.removeEventListener(t.event,t.listener)}))},t}()},"./src/controller/buffer-operation-queue.ts":
42
42
  /*!**************************************************!*\
43
43
  !*** ./src/controller/buffer-operation-queue.ts ***!
44
44
  \**************************************************/
45
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return n}));var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n=function(){function t(t){this.buffers=void 0;this.queues={video:[],audio:[],audiovideo:[]};this.buffers=t}var i=t.prototype;i.append=function t(i,r){var e=this.queues[r];e.push(i);if(e.length===1&&this.buffers[r]){this.executeNext(r)}};i.insertAbort=function t(i,r){var e=this.queues[r];e.unshift(i);this.executeNext(r)};i.appendBlocker=function t(i){var r;var e=new Promise((function(t){r=t}));var n={execute:r,onStart:function t(){},onComplete:function t(){},onError:function t(){}};this.append(n,i);return e};i.executeNext=function t(i){var r=this.buffers,n=this.queues;var s=r[i];var a=n[i];if(a.length){var u=a[0];try{u.execute()}catch(t){e["logger"].warn("[buffer-operation-queue]: Unhandled exception executing the current operation");u.onError(t);if(!s||!s.updating){a.shift();this.executeNext(i)}}}};i.shiftAndExecuteNext=function t(i){this.queues[i].shift();this.executeNext(i)};i.current=function t(i){return this.queues[i][0]};return t}()},"./src/controller/cap-level-controller.ts":
45
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return e}));var r=n(/*! ../utils/logger */"./src/utils/logger.ts"),e=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var i=t.prototype;return i.append=function(t,i){var n=this.queues[i];n.push(t),1===n.length&&this.buffers[i]&&this.executeNext(i)},i.insertAbort=function(t,i){this.queues[i].unshift(t),this.executeNext(i)},i.appendBlocker=function(t){var i,n=new Promise((function(t){i=t}));return this.append({execute:i,onStart:function(){},onComplete:function(){},onError:function(){}},t),n},i.executeNext=function(t){var i=this.buffers[t],n=this.queues[t];if(n.length){var e=n[0];try{e.execute()}catch(s){r.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),e.onError(s),i&&i.updating||(n.shift(),this.executeNext(t))}}},i.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},i.current=function(t){return this.queues[t][0]},t}()},"./src/controller/cap-level-controller.ts":
46
46
  /*!************************************************!*\
47
47
  !*** ./src/controller/cap-level-controller.ts ***!
48
48
  \************************************************/
49
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");function n(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function s(t,i,r){if(i)n(t.prototype,i);if(r)n(t,r);return t}var a=function(){function t(t){this.autoLevelCapping=void 0;this.firstLevel=void 0;this.media=void 0;this.restrictedLevels=void 0;this.timer=void 0;this.hls=void 0;this.streamController=void 0;this.clientRect=void 0;this.hls=t;this.autoLevelCapping=Number.POSITIVE_INFINITY;this.firstLevel=-1;this.media=null;this.restrictedLevels=[];this.timer=undefined;this.clientRect=null;this.registerListeners()}var i=t.prototype;i.setStreamController=function t(i){this.streamController=i};i.destroy=function t(){this.unregisterListener();if(this.hls.config.capLevelToPlayerSize){this.stopCapping()}this.media=null;this.clientRect=null;this.hls=this.streamController=null};i.registerListeners=function t(){var i=this.hls;i.on(e["Events"].FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this);i.on(e["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.on(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(e["Events"].BUFFER_CODECS,this.onBufferCodecs,this);i.on(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this)};i.unregisterListener=function t(){var i=this.hls;i.off(e["Events"].FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this);i.off(e["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.off(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(e["Events"].BUFFER_CODECS,this.onBufferCodecs,this);i.off(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this)};i.onFpsDropLevelCapping=function i(r,e){if(t.isLevelAllowed(e.droppedLevel,this.restrictedLevels)){this.restrictedLevels.push(e.droppedLevel)}};i.onMediaAttaching=function t(i,r){this.media=r.media instanceof HTMLVideoElement?r.media:null};i.onManifestParsed=function t(i,r){var e=this.hls;this.restrictedLevels=[];this.firstLevel=r.firstLevel;if(e.config.capLevelToPlayerSize&&r.video){this.startCapping()}};i.onBufferCodecs=function t(i,r){var e=this.hls;if(e.config.capLevelToPlayerSize&&r.video){this.startCapping()}};i.onMediaDetaching=function t(){this.stopCapping()};i.detectPlayerSize=function t(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var i=this.hls.levels;if(i.length){var r=this.hls;r.autoLevelCapping=this.getMaxLevel(i.length-1);if(r.autoLevelCapping>this.autoLevelCapping&&this.streamController){this.streamController.nextLevelSwitch()}this.autoLevelCapping=r.autoLevelCapping}}};i.getMaxLevel=function i(r){var e=this;var n=this.hls.levels;if(!n.length){return-1}var s=n.filter((function(i,n){return t.isLevelAllowed(n,e.restrictedLevels)&&n<=r}));this.clientRect=null;return t.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)};i.startCapping=function t(){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()};i.stopCapping=function t(){this.restrictedLevels=[];this.firstLevel=-1;this.autoLevelCapping=Number.POSITIVE_INFINITY;if(this.timer){self.clearInterval(this.timer);this.timer=undefined}};i.getDimensions=function t(){if(this.clientRect){return this.clientRect}var i=this.media;var r={width:0,height:0};if(i){var e=i.getBoundingClientRect();r.width=e.width;r.height=e.height;if(!r.width&&!r.height){r.width=e.right-e.left||i.width||0;r.height=e.bottom-e.top||i.height||0}}this.clientRect=r;return r};t.isLevelAllowed=function t(i,r){if(r===void 0){r=[]}return r.indexOf(i)===-1};t.getMaxLevelByMediaSize=function t(i,r,e){if(!i||!i.length){return-1}var n=function t(i,r){if(!r){return true}return i.width!==r.width||i.height!==r.height};var s=i.length-1;for(var a=0;a<i.length;a+=1){var u=i[a];if((u.width>=r||u.height>=e)&&n(u,i[a+1])){s=a;break}}return s};s(t,[{key:"mediaWidth",get:function i(){return this.getDimensions().width*t.contentScaleFactor}},{key:"mediaHeight",get:function i(){return this.getDimensions().height*t.contentScaleFactor}}],[{key:"contentScaleFactor",get:function t(){var i=1;try{i=self.devicePixelRatio}catch(t){}return i}}]);return t}();i["default"]=a},"./src/controller/cmcd-controller.ts":
49
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts");function e(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=function(){function t(t){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var i,n,s,a=t.prototype;return a.setStreamController=function(t){this.streamController=t},a.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},a.registerListeners=function(){var t=this.hls;t.on(r.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},a.unregisterListener=function(){var t=this.hls;t.off(r.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},a.onFpsDropLevelCapping=function(i,n){t.isLevelAllowed(n.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(n.droppedLevel)},a.onMediaAttaching=function(t,i){this.media=i.media instanceof HTMLVideoElement?i.media:null},a.onManifestParsed=function(t,i){var n=this.hls;this.restrictedLevels=[],this.firstLevel=i.firstLevel,n.config.capLevelToPlayerSize&&i.video&&this.startCapping()},a.onBufferCodecs=function(t,i){this.hls.config.capLevelToPlayerSize&&i.video&&this.startCapping()},a.onMediaDetaching=function(){this.stopCapping()},a.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var i=this.hls;i.autoLevelCapping=this.getMaxLevel(t.length-1),i.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=i.autoLevelCapping}}},a.getMaxLevel=function(i){var n=this,r=this.hls.levels;if(!r.length)return-1;var e=r.filter((function(r,e){return t.isLevelAllowed(e,n.restrictedLevels)&&e<=i}));return this.clientRect=null,t.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},a.startCapping=function(){this.timer||(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())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},a.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,i={width:0,height:0};if(t){var n=t.getBoundingClientRect();i.width=n.width,i.height=n.height,i.width||i.height||(i.width=n.right-n.left||t.width||0,i.height=n.bottom-n.top||t.height||0)}return this.clientRect=i,i},t.isLevelAllowed=function(t,i){return void 0===i&&(i=[]),-1===i.indexOf(t)},t.getMaxLevelByMediaSize=function(t,i,n){if(!t||!t.length)return-1;for(var r,e,s=t.length-1,a=0;a<t.length;a+=1){var o=t[a];if((o.width>=i||o.height>=n)&&(r=o,!(e=t[a+1])||r.width!==e.width||r.height!==e.height)){s=a;break}}return s},i=t,s=[{key:"contentScaleFactor",get:function(){var t=1;try{t=self.devicePixelRatio}catch(t){}return t}}],(n=[{key:"mediaWidth",get:function(){return this.getDimensions().width*t.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*t.contentScaleFactor}}])&&e(i.prototype,n),s&&e(i,s),t}();i.default=s},"./src/controller/cmcd-controller.ts":
50
50
  /*!*******************************************!*\
51
51
  !*** ./src/controller/cmcd-controller.ts ***!
52
52
  \*******************************************/
53
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return c}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../types/cmcd */"./src/types/cmcd.ts");var s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");function u(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function f(t,i,r){if(i)u(t.prototype,i);if(r)u(t,r);return t}function h(t,i){var r=typeof Symbol!=="undefined"&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=o(t))||i&&t&&typeof t.length==="number"){if(r)t=r;var e=0;return function(){if(e>=t.length)return{done:true};return{done:false,value:t[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(t,i){if(!t)return;if(typeof t==="string")return v(t,i);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor)r=t.constructor.name;if(r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return v(t,i)}function v(t,i){if(i==null||i>t.length)i=t.length;for(var r=0,e=new Array(i);r<i;r++){e[r]=t[r]}return e}function l(){l=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return l.apply(this,arguments)}var c=function(){function t(i){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(t){try{r.apply(t,{ot:n["CMCDObjectType"].MANIFEST,su:!r.initialized})}catch(t){a["logger"].warn("Could not generate manifest CMCD data.",t)}};this.applyFragmentData=function(t){try{var i=t.frag;var e=r.hls.levels[i.level];var s=r.getObjectType(i);var u={d:i.duration*1e3,ot:s};if(s===n["CMCDObjectType"].VIDEO||s===n["CMCDObjectType"].AUDIO||s==n["CMCDObjectType"].MUXED){u.br=e.bitrate/1e3;u.tb=r.getTopBandwidth(s)/1e3;u.bl=r.getBufferLength(s)}r.apply(t,u)}catch(t){a["logger"].warn("Could not generate segment CMCD data.",t)}};this.hls=i;var e=this.config=i.config;var s=e.cmcd;if(s!=null){e.pLoader=this.createPlaylistLoader();e.fLoader=this.createFragmentLoader();this.sid=s.sessionId||t.uuid();this.cid=s.contentId;this.useHeaders=s.useHeaders===true;this.registerListeners()}}var i=t.prototype;i.registerListeners=function t(){var i=this.hls;i.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(e["Events"].MEDIA_DETACHED,this.onMediaDetached,this);i.on(e["Events"].BUFFER_CREATED,this.onBufferCreated,this)};i.unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(e["Events"].MEDIA_DETACHED,this.onMediaDetached,this);i.off(e["Events"].BUFFER_CREATED,this.onBufferCreated,this);this.onMediaDetached()};i.destroy=function t(){this.unregisterListeners();this.hls=this.config=this.audioBuffer=this.videoBuffer=null};i.onMediaAttached=function t(i,r){this.media=r.media;this.media.addEventListener("waiting",this.onWaiting);this.media.addEventListener("playing",this.onPlaying)};i.onMediaDetached=function t(){if(!this.media){return}this.media.removeEventListener("waiting",this.onWaiting);this.media.removeEventListener("playing",this.onPlaying);this.media=null};i.onBufferCreated=function t(i,r){var e,n;this.audioBuffer=(e=r.tracks.audio)===null||e===void 0?void 0:e.buffer;this.videoBuffer=(n=r.tracks.video)===null||n===void 0?void 0:n.buffer};i.createData=function t(){var i;return{v:n["CMCDVersion"],sf:n["CMCDStreamingFormat"].HLS,sid:this.sid,cid:this.cid,pr:(i=this.media)===null||i===void 0?void 0:i.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}};i.apply=function i(r,e){if(e===void 0){e={}}l(e,this.createData());var s=e.ot===n["CMCDObjectType"].INIT||e.ot===n["CMCDObjectType"].VIDEO||e.ot===n["CMCDObjectType"].MUXED;if(this.starved&&s){e.bs=true;e.su=true;this.starved=false}if(e.su==null){e.su=this.buffering}if(this.useHeaders){var a=t.toHeaders(e);if(!Object.keys(a).length){return}if(!r.headers){r.headers={}}l(r.headers,a)}else{var u=t.toQuery(e);if(!u){return}r.url=t.appendQueryToUri(r.url,u)}};i.getObjectType=function t(i){var r=i.type;if(r==="subtitle"){return n["CMCDObjectType"].TIMED_TEXT}if(i.sn==="initSegment"){return n["CMCDObjectType"].INIT}if(r==="audio"){return n["CMCDObjectType"].AUDIO}if(r==="main"){if(!this.hls.audioTracks.length){return n["CMCDObjectType"].MUXED}return n["CMCDObjectType"].VIDEO}return undefined};i.getTopBandwidth=function t(i){var r=0;var e;var s=this.hls;if(i===n["CMCDObjectType"].AUDIO){e=s.audioTracks}else{var a=s.maxAutoLevel;var u=a>-1?a+1:s.levels.length;e=s.levels.slice(0,u)}for(var f=h(e),o;!(o=f()).done;){var v=o.value;if(v.bitrate>r){r=v.bitrate}}return r>0?r:NaN};i.getBufferLength=function t(i){var r=this.hls.media;var e=i===n["CMCDObjectType"].AUDIO?this.audioBuffer:this.videoBuffer;if(!e||!r){return NaN}var a=s["BufferHelper"].bufferInfo(e,r.currentTime,this.config.maxBufferHole);return a.len*1e3};i.createPlaylistLoader=function t(){var i=this.config.pLoader;var r=this.applyPlaylistData;var e=i||this.config.loader;return function(){function t(t){this.loader=void 0;this.loader=new e(t)}var i=t.prototype;i.destroy=function t(){this.loader.destroy()};i.abort=function t(){this.loader.abort()};i.load=function t(i,e,n){r(i);this.loader.load(i,e,n)};f(t,[{key:"stats",get:function t(){return this.loader.stats}},{key:"context",get:function t(){return this.loader.context}}]);return t}()};i.createFragmentLoader=function t(){var i=this.config.fLoader;var r=this.applyFragmentData;var e=i||this.config.loader;return function(){function t(t){this.loader=void 0;this.loader=new e(t)}var i=t.prototype;i.destroy=function t(){this.loader.destroy()};i.abort=function t(){this.loader.abort()};i.load=function t(i,e,n){r(i);this.loader.load(i,e,n)};f(t,[{key:"stats",get:function t(){return this.loader.stats}},{key:"context",get:function t(){return this.loader.context}}]);return t}()};t.uuid=function t(){var i=URL.createObjectURL(new Blob);var t=i.toString();URL.revokeObjectURL(i);return t.substr(t.lastIndexOf("/")+1)};t.serialize=function t(i){var r=[];var e=function t(i){return!Number.isNaN(i)&&i!=null&&i!==""&&i!==false};var n=function t(i){return Math.round(i)};var s=function t(i){return n(i/100)*100};var a=function t(i){return encodeURIComponent(i)};var u={br:n,d:n,bl:s,dl:s,mtp:s,nor:a,rtp:s,tb:n};var f=Object.keys(i||{}).sort();for(var o=h(f),v;!(v=o()).done;){var l=v.value;var c=i[l];if(!e(c)){continue}if(l==="v"&&c===1){continue}if(l=="pr"&&c===1){continue}var d=u[l];if(d){c=d(c)}var m=typeof c;var p=void 0;if(l==="ot"||l==="sf"||l==="st"){p=l+"="+c}else if(m==="boolean"){p=l}else if(m==="number"){p=l+"="+c}else{p=l+"="+JSON.stringify(c)}r.push(p)}return r.join(",")};t.toHeaders=function i(r){var e=Object.keys(r);var n={};var s=["Object","Request","Session","Status"];var a=[{},{},{},{}];var u={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 f=0,h=e;f<h.length;f++){var o=h[f];var v=u[o]!=null?u[o]:1;a[v][o]=r[o]}for(var l=0;l<a.length;l++){var c=t.serialize(a[l]);if(c){n["CMCD-"+s[l]]=c}}return n};t.toQuery=function i(r){return"CMCD="+encodeURIComponent(t.serialize(r))};t.appendQueryToUri=function t(i,r){if(!r){return i}var e=i.includes("?")?"&":"?";return""+i+e+r};return t}()},"./src/controller/eme-controller.ts":
53
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return l}));var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../types/cmcd */"./src/types/cmcd.ts"),s=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts");function o(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,i,n){return i&&o(t.prototype,i),n&&o(t,n),t}function u(t,i){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,i){if(t){if("string"==typeof t)return c(t,i);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(t,i){(null==i||i>t.length)&&(i=t.length);for(var n=0,r=new Array(i);n<i;n++)r[n]=t[n];return r}function f(){return f=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f.apply(this,arguments)}var l=function(){function t(i){var n=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){n.initialized&&(n.starved=!0),n.buffering=!0},this.onPlaying=function(){n.initialized||(n.initialized=!0),n.buffering=!1},this.applyPlaylistData=function(t){try{n.apply(t,{ot:e.CMCDObjectType.MANIFEST,su:!n.initialized})}catch(t){a.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var i=t.frag,r=n.hls.levels[i.level],s=n.getObjectType(i),o={d:1e3*i.duration,ot:s};s!==e.CMCDObjectType.VIDEO&&s!==e.CMCDObjectType.AUDIO&&s!=e.CMCDObjectType.MUXED||(o.br=r.bitrate/1e3,o.tb=n.getTopBandwidth(s)/1e3,o.bl=n.getBufferLength(s)),n.apply(t,o)}catch(t){a.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=i;var r=this.config=i.config,s=r.cmcd;null!=s&&(r.pLoader=this.createPlaylistLoader(),r.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||t.uuid(),this.cid=s.contentId,this.useHeaders=!0===s.useHeaders,this.registerListeners())}var i=t.prototype;return i.registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.on(r.Events.BUFFER_CREATED,this.onBufferCreated,this)},i.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.off(r.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},i.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},i.onMediaAttached=function(t,i){this.media=i.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},i.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},i.onBufferCreated=function(t,i){var n,r;this.audioBuffer=null===(n=i.tracks.audio)||void 0===n?void 0:n.buffer,this.videoBuffer=null===(r=i.tracks.video)||void 0===r?void 0:r.buffer},i.createData=function(){var t;return{v:e.CMCDVersion,sf:e.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(t=this.media)||void 0===t?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},i.apply=function(i,n){if(void 0===n&&(n={}),f(n,this.createData()),this.starved&&(n.ot===e.CMCDObjectType.INIT||n.ot===e.CMCDObjectType.VIDEO||n.ot===e.CMCDObjectType.MUXED)&&(n.bs=!0,n.su=!0,this.starved=!1),null==n.su&&(n.su=this.buffering),this.useHeaders){var r=t.toHeaders(n);if(!Object.keys(r).length)return;i.headers||(i.headers={}),f(i.headers,r)}else{var s=t.toQuery(n);if(!s)return;i.url=t.appendQueryToUri(i.url,s)}},i.getObjectType=function(t){var i=t.type;return"subtitle"===i?e.CMCDObjectType.TIMED_TEXT:"initSegment"===t.sn?e.CMCDObjectType.INIT:"audio"===i?e.CMCDObjectType.AUDIO:"main"===i?this.hls.audioTracks.length?e.CMCDObjectType.VIDEO:e.CMCDObjectType.MUXED:void 0},i.getTopBandwidth=function(t){var i,n=0,r=this.hls;if(t===e.CMCDObjectType.AUDIO)i=r.audioTracks;else{var s=r.maxAutoLevel;i=r.levels.slice(0,s>-1?s+1:r.levels.length)}for(var a,o=u(i);!(a=o()).done;){var h=a.value;h.bitrate>n&&(n=h.bitrate)}return n>0?n:NaN},i.getBufferLength=function(t){var i=this.hls.media,n=t===e.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return n&&i?1e3*s.BufferHelper.bufferInfo(n,i.currentTime,this.config.maxBufferHole).len:NaN},i.createPlaylistLoader=function(){var t=this.applyPlaylistData,i=this.config.pLoader||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new i(t)}var r=n.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(i,n,r){t(i),this.loader.load(i,n,r)},h(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},i.createFragmentLoader=function(){var t=this.applyFragmentData,i=this.config.fLoader||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new i(t)}var r=n.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(i,n,r){t(i),this.loader.load(i,n,r)},h(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},t.uuid=function(){var t=URL.createObjectURL(new Blob),i=t.toString();return URL.revokeObjectURL(t),i.substr(i.lastIndexOf("/")+1)},t.serialize=function(t){for(var i,n=[],r=function(t){return!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t},e=function(t){return Math.round(t)},s=function(t){return 100*e(t/100)},a={br:e,d:e,bl:s,dl:s,mtp:s,nor:function(t){return encodeURIComponent(t)},rtp:s,tb:e},o=u(Object.keys(t||{}).sort());!(i=o()).done;){var h=i.value,c=t[h];if(r(c)&&!("v"===h&&1===c||"pr"==h&&1===c)){var f=a[h];f&&(c=f(c));var l,v=typeof c;l="ot"===h||"sf"===h||"st"===h?h+"="+c:"boolean"===v?h:"number"===v?h+"="+c:h+"="+JSON.stringify(c),n.push(l)}}return n.join(",")},t.toHeaders=function(i){for(var n={},r=["Object","Request","Session","Status"],e=[{},{},{},{}],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},a=0,o=Object.keys(i);a<o.length;a++){var h=o[a];e[null!=s[h]?s[h]:1][h]=i[h]}for(var u=0;u<e.length;u++){var c=t.serialize(e[u]);c&&(n["CMCD-"+r[u]]=c)}return n},t.toQuery=function(i){return"CMCD="+encodeURIComponent(t.serialize(i))},t.appendQueryToUri=function(t,i){if(!i)return t;var n=t.includes("?")?"&":"?";return""+t+n+i},t}()},"./src/controller/eme-controller.ts":
54
54
  /*!******************************************!*\
55
55
  !*** ./src/controller/eme-controller.ts ***!
56
56
  \******************************************/
57
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function u(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function f(t,i,r){if(i)u(t.prototype,i);if(r)u(t,r);return t}var h=3;var o=function t(i,r,e){var n={audioCapabilities:[],videoCapabilities:[]};i.forEach((function(t){n.audioCapabilities.push({contentType:'audio/mp4; codecs="'+t+'"',robustness:e.audioRobustness||""})}));r.forEach((function(t){n.videoCapabilities.push({contentType:'video/mp4; codecs="'+t+'"',robustness:e.videoRobustness||""})}));return[n]};var v=function t(i,r,e,n){switch(i){case a["KeySystems"].WIDEVINE:return o(r,e,n);default:throw new Error("Unknown key-system: "+i)}};var l=function(){function t(t){this.hls=void 0;this._widevineLicenseUrl=void 0;this._licenseXhrSetup=void 0;this._licenseResponseCallback=void 0;this._emeEnabled=void 0;this._requestMediaKeySystemAccess=void 0;this._drmSystemOptions=void 0;this._config=void 0;this._mediaKeysList=[];this._media=null;this._hasSetMediaKeys=false;this._requestLicenseFailureCount=0;this.mediaKeysPromise=null;this._onMediaEncrypted=this.onMediaEncrypted.bind(this);this.hls=t;this._config=t.config;this._widevineLicenseUrl=this._config.widevineLicenseUrl;this._licenseXhrSetup=this._config.licenseXhrSetup;this._licenseResponseCallback=this._config.licenseResponseCallback;this._emeEnabled=this._config.emeEnabled;this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc;this._drmSystemOptions=this._config.drmSystemOptions;this._registerListeners()}var i=t.prototype;i.destroy=function t(){this._unregisterListeners();this.hls=this._onMediaEncrypted=null;this._requestMediaKeySystemAccess=null};i._registerListeners=function t(){this.hls.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.on(e["Events"].MEDIA_DETACHED,this.onMediaDetached,this);this.hls.on(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this)};i._unregisterListeners=function t(){this.hls.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.off(e["Events"].MEDIA_DETACHED,this.onMediaDetached,this);this.hls.off(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this)};i.getLicenseServerUrl=function t(i){switch(i){case a["KeySystems"].WIDEVINE:if(!this._widevineLicenseUrl){break}return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+i+'"')};i._attemptKeySystemAccess=function t(i,r,e){var n=this;var a=v(i,r,e,this._drmSystemOptions);s["logger"].log("Requesting encrypted media key-system access");var u=this.requestMediaKeySystemAccess(i,a);this.mediaKeysPromise=u.then((function(t){return n._onMediaKeySystemAccessObtained(i,t)}));u.catch((function(t){s["logger"].error('Failed to obtain key-system "'+i+'" access:',t)}))};i._onMediaKeySystemAccessObtained=function t(i,r){var e=this;s["logger"].log('Access for key-system "'+i+'" obtained');var n={mediaKeysSessionInitialized:false,mediaKeySystemAccess:r,mediaKeySystemDomain:i};this._mediaKeysList.push(n);var a=Promise.resolve().then((function(){return r.createMediaKeys()})).then((function(t){n.mediaKeys=t;s["logger"].log('Media-keys created for key-system "'+i+'"');e._onMediaKeysCreated();return t}));a.catch((function(t){s["logger"].error("Failed to create media-keys:",t)}));return a};i._onMediaKeysCreated=function t(){var i=this;this._mediaKeysList.forEach((function(t){if(!t.mediaKeysSession){t.mediaKeysSession=t.mediaKeys.createSession();i._onNewMediaKeySession(t.mediaKeysSession)}}))};i._onNewMediaKeySession=function t(i){var r=this;s["logger"].log("New key-system session "+i.sessionId);i.addEventListener("message",(function(t){r._onKeySessionMessage(i,t.message)}),false)};i._onKeySessionMessage=function t(i,r){s["logger"].log("Got EME message event, creating license request");this._requestLicense(r,(function(t){s["logger"].log("Received license data (length: "+(t?t.byteLength:t)+"), updating key-session");i.update(t)}))};i.onMediaEncrypted=function t(i){var r=this;s["logger"].log('Media is encrypted using "'+i.initDataType+'" init data type');if(!this.mediaKeysPromise){s["logger"].error("Fatal: Media is encrypted but no CDM access or no keys have been requested");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_KEYS,fatal:true});return}var a=function t(e){if(!r._media){return}r._attemptSetMediaKeys(e);r._generateRequestWithPreferredKeySession(i.initDataType,i.initData)};this.mediaKeysPromise.then(a).catch(a)};i._attemptSetMediaKeys=function t(i){if(!this._media){throw new Error("Attempted to set mediaKeys without first attaching a media element")}if(!this._hasSetMediaKeys){var r=this._mediaKeysList[0];if(!r||!r.mediaKeys){s["logger"].error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_KEYS,fatal:true});return}s["logger"].log("Setting keys for encrypted media");this._media.setMediaKeys(r.mediaKeys);this._hasSetMediaKeys=true}};i._generateRequestWithPreferredKeySession=function t(i,r){var a=this;var u=this._mediaKeysList[0];if(!u){s["logger"].error("Fatal: Media is encrypted but not any key-system access has been obtained yet");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_ACCESS,fatal:true});return}if(u.mediaKeysSessionInitialized){s["logger"].warn("Key-Session already initialized but requested again");return}var f=u.mediaKeysSession;if(!f){s["logger"].error("Fatal: Media is encrypted but no key-session existing");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_SESSION,fatal:true});return}if(!r){s["logger"].warn("Fatal: initData required for generating a key session is null");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_INIT_DATA,fatal:true});return}s["logger"].log('Generating key-session request for "'+i+'" init data type');u.mediaKeysSessionInitialized=true;f.generateRequest(i,r).then((function(){s["logger"].debug("Key-session generation succeeded")})).catch((function(t){s["logger"].error("Error generating key-session request:",t);a.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_SESSION,fatal:false})}))};i._createLicenseXhr=function t(i,r,e){var n=new XMLHttpRequest;n.responseType="arraybuffer";n.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,n,i,r,e);var a=this._licenseXhrSetup;if(a){try{a.call(this.hls,n,i);a=undefined}catch(t){s["logger"].error(t)}}try{if(!n.readyState){n.open("POST",i,true)}if(a){a.call(this.hls,n,i)}}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return n};i._onLicenseRequestReadyStageChange=function t(i,r,a,u){switch(i.readyState){case 4:if(i.status===200){this._requestLicenseFailureCount=0;s["logger"].log("License request succeeded");var f=i.response;var o=this._licenseResponseCallback;if(o){try{f=o.call(this.hls,i,r)}catch(t){s["logger"].error(t)}}u(f)}else{s["logger"].error("License Request XHR failed ("+r+"). Status: "+i.status+" ("+i.statusText+")");this._requestLicenseFailureCount++;if(this._requestLicenseFailureCount>h){this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:true});return}var v=h-this._requestLicenseFailureCount+1;s["logger"].warn("Retrying license request, "+v+" attempts left");this._requestLicense(a,u)}break}};i._generateLicenseRequestChallenge=function t(i,r){switch(i.mediaKeySystemDomain){case a["KeySystems"].WIDEVINE:return r}throw new Error("unsupported key-system: "+i.mediaKeySystemDomain)};i._requestLicense=function t(i,r){s["logger"].log("Requesting content license for key-system");var a=this._mediaKeysList[0];if(!a){s["logger"].error("Fatal error: Media is encrypted but no key-system access has been obtained yet");this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_NO_ACCESS,fatal:true});return}try{var u=this.getLicenseServerUrl(a.mediaKeySystemDomain);var f=this._createLicenseXhr(u,i,r);s["logger"].log("Sending license request to URL: "+u);var h=this._generateLicenseRequestChallenge(a,i);f.send(h)}catch(t){s["logger"].error("Failure requesting DRM license: "+t);this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].KEY_SYSTEM_ERROR,details:n["ErrorDetails"].KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:true})}};i.onMediaAttached=function t(i,r){if(!this._emeEnabled){return}var e=r.media;this._media=e;e.addEventListener("encrypted",this._onMediaEncrypted)};i.onMediaDetached=function t(){var i=this._media;var r=this._mediaKeysList;if(!i){return}i.removeEventListener("encrypted",this._onMediaEncrypted);this._media=null;this._mediaKeysList=[];Promise.all(r.map((function(t){if(t.mediaKeysSession){return t.mediaKeysSession.close().catch((function(){}))}}))).then((function(){return i.setMediaKeys(null)})).catch((function(){}))};i.onManifestParsed=function t(i,r){if(!this._emeEnabled){return}var e=r.levels.map((function(t){return t.audioCodec})).filter((function(t){return!!t}));var n=r.levels.map((function(t){return t.videoCodec})).filter((function(t){return!!t}));this._attemptKeySystemAccess(a["KeySystems"].WIDEVINE,e,n)};f(t,[{key:"requestMediaKeySystemAccess",get:function t(){if(!this._requestMediaKeySystemAccess){throw new Error("No requestMediaKeySystemAccess function configured")}return this._requestMediaKeySystemAccess}}]);return t}();i["default"]=l},"./src/controller/fps-controller.ts":
57
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function o(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var h=function(){function t(t){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=t,this._config=t.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var i,n,h=t.prototype;return h.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},h._registerListeners=function(){this.hls.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this)},h._unregisterListeners=function(){this.hls.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this)},h.getLicenseServerUrl=function(t){switch(t){case a.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+t+'"')},h._attemptKeySystemAccess=function(t,i,n){var r=this,e=function(t,i,n,r){if(t===a.KeySystems.WIDEVINE)return function(t,i,n){var r={audioCapabilities:[],videoCapabilities:[]};return t.forEach((function(t){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+t+'"',robustness:n.audioRobustness||""})})),i.forEach((function(t){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+t+'"',robustness:n.videoRobustness||""})})),[r]}(i,n,r);throw new Error("Unknown key-system: "+t)}(t,i,n,this._drmSystemOptions);s.logger.log("Requesting encrypted media key-system access");var o=this.requestMediaKeySystemAccess(t,e);this.mediaKeysPromise=o.then((function(i){return r._onMediaKeySystemAccessObtained(t,i)})),o.catch((function(i){s.logger.error('Failed to obtain key-system "'+t+'" access:',i)}))},h._onMediaKeySystemAccessObtained=function(t,i){var n=this;s.logger.log('Access for key-system "'+t+'" obtained');var r={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:i,mediaKeySystemDomain:t};this._mediaKeysList.push(r);var e=Promise.resolve().then((function(){return i.createMediaKeys()})).then((function(i){return r.mediaKeys=i,s.logger.log('Media-keys created for key-system "'+t+'"'),n._onMediaKeysCreated(),i}));return e.catch((function(t){s.logger.error("Failed to create media-keys:",t)})),e},h._onMediaKeysCreated=function(){var t=this;this._mediaKeysList.forEach((function(i){i.mediaKeysSession||(i.mediaKeysSession=i.mediaKeys.createSession(),t._onNewMediaKeySession(i.mediaKeysSession))}))},h._onNewMediaKeySession=function(t){var i=this;s.logger.log("New key-system session "+t.sessionId),t.addEventListener("message",(function(n){i._onKeySessionMessage(t,n.message)}),!1)},h._onKeySessionMessage=function(t,i){s.logger.log("Got EME message event, creating license request"),this._requestLicense(i,(function(i){s.logger.log("Received license data (length: "+(i?i.byteLength:i)+"), updating key-session"),t.update(i)}))},h.onMediaEncrypted=function(t){var i=this;if(s.logger.log('Media is encrypted using "'+t.initDataType+'" init data type'),!this.mediaKeysPromise)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var n=function(n){i._media&&(i._attemptSetMediaKeys(n),i._generateRequestWithPreferredKeySession(t.initDataType,t.initData))};this.mediaKeysPromise.then(n).catch(n)},h._attemptSetMediaKeys=function(){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var t=this._mediaKeysList[0];if(!t||!t.mediaKeys)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});s.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0}},h._generateRequestWithPreferredKeySession=function(t,i){var n=this,a=this._mediaKeysList[0];if(!a)return s.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(a.mediaKeysSessionInitialized)s.logger.warn("Key-Session already initialized but requested again");else{var o=a.mediaKeysSession;if(!o)return s.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!i)return s.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});s.logger.log('Generating key-session request for "'+t+'" init data type'),a.mediaKeysSessionInitialized=!0,o.generateRequest(t,i).then((function(){s.logger.debug("Key-session generation succeeded")})).catch((function(t){s.logger.error("Error generating key-session request:",t),n.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},h._createLicenseXhr=function(t,i,n){var r=new XMLHttpRequest;r.responseType="arraybuffer",r.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,r,t,i,n);var e=this._licenseXhrSetup;if(e)try{e.call(this.hls,r,t),e=void 0}catch(t){s.logger.error(t)}try{r.readyState||r.open("POST",t,!0),e&&e.call(this.hls,r,t)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return r},h._onLicenseRequestReadyStageChange=function(t,i,n,a){if(4===t.readyState)if(200===t.status){this._requestLicenseFailureCount=0,s.logger.log("License request succeeded");var o=t.response,h=this._licenseResponseCallback;if(h)try{o=h.call(this.hls,t,i)}catch(t){s.logger.error(t)}a(o)}else{if(s.logger.error("License Request XHR failed ("+i+"). Status: "+t.status+" ("+t.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});s.logger.warn("Retrying license request, "+(3-this._requestLicenseFailureCount+1)+" attempts left"),this._requestLicense(n,a)}},h._generateLicenseRequestChallenge=function(t,i){if(t.mediaKeySystemDomain===a.KeySystems.WIDEVINE)return i;throw new Error("unsupported key-system: "+t.mediaKeySystemDomain)},h._requestLicense=function(t,i){s.logger.log("Requesting content license for key-system");var n=this._mediaKeysList[0];if(!n)return s.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var a=this.getLicenseServerUrl(n.mediaKeySystemDomain),o=this._createLicenseXhr(a,t,i);s.logger.log("Sending license request to URL: "+a);var h=this._generateLicenseRequestChallenge(n,t);o.send(h)}catch(t){s.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},h.onMediaAttached=function(t,i){if(this._emeEnabled){var n=i.media;this._media=n,n.addEventListener("encrypted",this._onMediaEncrypted)}},h.onMediaDetached=function(){var t=this._media,i=this._mediaKeysList;t&&(t.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(i.map((function(t){if(t.mediaKeysSession)return t.mediaKeysSession.close().catch((function(){}))}))).then((function(){return t.setMediaKeys(null)})).catch((function(){})))},h.onManifestParsed=function(t,i){if(this._emeEnabled){var n=i.levels.map((function(t){return t.audioCodec})).filter((function(t){return!!t})),r=i.levels.map((function(t){return t.videoCodec})).filter((function(t){return!!t}));this._attemptKeySystemAccess(a.KeySystems.WIDEVINE,n,r)}},i=t,(n=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&o(i.prototype,n),t}();i.default=h},"./src/controller/fps-controller.ts":
58
58
  /*!******************************************!*\
59
59
  !*** ./src/controller/fps-controller.ts ***!
60
60
  \******************************************/
61
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../utils/logger */"./src/utils/logger.ts");var s=function(){function t(t){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=t;this.registerListeners()}var i=t.prototype;i.setStreamController=function t(i){this.streamController=i};i.registerListeners=function t(){this.hls.on(e["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this)};i.unregisterListeners=function t(){this.hls.off(e["Events"].MEDIA_ATTACHING,this.onMediaAttaching)};i.destroy=function t(){if(this.timer){clearInterval(this.timer)}this.unregisterListeners();this.isVideoPlaybackQualityAvailable=false;this.media=null};i.onMediaAttaching=function t(i,r){var e=this.hls.config;if(e.capLevelOnFPSDrop){var n=r.media instanceof self.HTMLVideoElement?r.media:null;this.media=n;if(n&&typeof n.getVideoPlaybackQuality==="function"){this.isVideoPlaybackQualityAvailable=true}self.clearInterval(this.timer);this.timer=self.setInterval(this.checkFPSInterval.bind(this),e.fpsDroppedMonitoringPeriod)}};i.checkFPS=function t(i,r,s){var a=performance.now();if(r){if(this.lastTime){var u=a-this.lastTime;var f=s-this.lastDroppedFrames;var h=r-this.lastDecodedFrames;var o=1e3*f/u;var v=this.hls;v.trigger(e["Events"].FPS_DROP,{currentDropped:f,currentDecoded:h,totalDroppedFrames:s});if(o>0){if(f>v.config.fpsDroppedMonitoringThreshold*h){var l=v.currentLevel;n["logger"].warn("drop FPS ratio greater than max allowed value for currentLevel: "+l);if(l>0&&(v.autoLevelCapping===-1||v.autoLevelCapping>=l)){l=l-1;v.trigger(e["Events"].FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:v.currentLevel});v.autoLevelCapping=l;this.streamController.nextLevelSwitch()}}}}this.lastTime=a;this.lastDroppedFrames=s;this.lastDecodedFrames=r}};i.checkFPSInterval=function t(){var i=this.media;if(i){if(this.isVideoPlaybackQualityAvailable){var r=i.getVideoPlaybackQuality();this.checkFPS(i,r.totalVideoFrames,r.droppedVideoFrames)}else{this.checkFPS(i,i.webkitDecodedFrameCount,i.webkitDroppedFrameCount)}}};return t}();i["default"]=s},"./src/controller/fragment-finders.ts":
61
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function t(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var i=t.prototype;return i.setStreamController=function(t){this.streamController=t},i.registerListeners=function(){this.hls.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},i.unregisterListeners=function(){this.hls.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching)},i.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},i.onMediaAttaching=function(t,i){var n=this.hls.config;if(n.capLevelOnFPSDrop){var r=i.media instanceof self.HTMLVideoElement?i.media:null;this.media=r,r&&"function"==typeof r.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),n.fpsDroppedMonitoringPeriod)}},i.checkFPS=function(t,i,n){var s=performance.now();if(i){if(this.lastTime){var a=n-this.lastDroppedFrames,o=i-this.lastDecodedFrames,h=1e3*a/(s-this.lastTime),u=this.hls;if(u.trigger(r.Events.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:n}),h>0&&a>u.config.fpsDroppedMonitoringThreshold*o){var c=u.currentLevel;e.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=c)&&(u.trigger(r.Events.FPS_DROP_LEVEL_CAPPING,{level:c-=1,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=n,this.lastDecodedFrames=i}},i.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var i=t.getVideoPlaybackQuality();this.checkFPS(t,i.totalVideoFrames,i.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}();i.default=s},"./src/controller/fragment-finders.ts":
62
62
  /*!********************************************!*\
63
63
  !*** ./src/controller/fragment-finders.ts ***!
64
64
  \********************************************/
65
- /*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(t,i,r){r.r(i);r.d(i,"findFragmentByPDT",(function(){return s}));r.d(i,"findFragmentByPTS",(function(){return a}));r.d(i,"fragmentWithinToleranceTest",(function(){return u}));r.d(i,"pdtWithinToleranceTest",(function(){return f}));r.d(i,"findFragWithCC",(function(){return h}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function s(t,i,r){if(i===null||!Array.isArray(t)||!t.length||!Object(e["isFiniteNumber"])(i)){return null}var n=t[0].programDateTime;if(i<(n||0)){return null}var s=t[t.length-1].endProgramDateTime;if(i>=(s||0)){return null}r=r||0;for(var a=0;a<t.length;++a){var u=t[a];if(f(i,r,u)){return u}}return null}function a(t,i,r,e){if(r===void 0){r=0}if(e===void 0){e=0}var s=null;if(t){s=i[t.sn-i[0].sn+1]||null}else if(r===0&&i[0].start===0){s=i[0]}if(s&&u(r,e,s)===0){return s}var a=n["default"].search(i,u.bind(null,r,e));if(a){return a}return s}function u(t,i,r){if(t===void 0){t=0}if(i===void 0){i=0}var e=Math.min(i,r.duration+(r.deltaPTS?r.deltaPTS:0));if(r.start+r.duration-e<=t){return 1}else if(r.start-e>t&&r.start){return-1}return 0}function f(t,i,r){var e=Math.min(i,r.duration+(r.deltaPTS?r.deltaPTS:0))*1e3;var n=r.endProgramDateTime||0;return n-e>t}function h(t,i){return n["default"].search(t,(function(t){if(t.cc<i){return 1}else if(t.cc>i){return-1}else{return 0}}))}},"./src/controller/fragment-tracker.ts":
65
+ /*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(t,i,n){n.r(i),n.d(i,"findFragmentByPDT",(function(){return s})),n.d(i,"findFragmentByPTS",(function(){return a})),n.d(i,"fragmentWithinToleranceTest",(function(){return o})),n.d(i,"pdtWithinToleranceTest",(function(){return h})),n.d(i,"findFragWithCC",(function(){return u}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function s(t,i,n){if(null===i||!Array.isArray(t)||!t.length||!Object(r.isFiniteNumber)(i))return null;if(i<(t[0].programDateTime||0))return null;if(i>=(t[t.length-1].endProgramDateTime||0))return null;n=n||0;for(var e=0;e<t.length;++e){var s=t[e];if(h(i,n,s))return s}return null}function a(t,i,n,r){void 0===n&&(n=0),void 0===r&&(r=0);var s=null;return t?s=i[t.sn-i[0].sn+1]||null:0===n&&0===i[0].start&&(s=i[0]),s&&0===o(n,r,s)?s:e.default.search(i,o.bind(null,n,r))||s}function o(t,i,n){void 0===t&&(t=0),void 0===i&&(i=0);var r=Math.min(i,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-r<=t?1:n.start-r>t&&n.start?-1:0}function h(t,i,n){var r=1e3*Math.min(i,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-r>t}function u(t,i){return e.default.search(t,(function(t){return t.cc<i?1:t.cc>i?-1:0}))}},"./src/controller/fragment-tracker.ts":
66
66
  /*!********************************************!*\
67
67
  !*** ./src/controller/fragment-tracker.ts ***!
68
68
  \********************************************/
69
- /*! exports provided: FragmentState, FragmentTracker */function(t,i,r){r.r(i);r.d(i,"FragmentState",(function(){return s}));r.d(i,"FragmentTracker",(function(){return a}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../types/loader */"./src/types/loader.ts");var s;(function(t){t["NOT_LOADED"]="NOT_LOADED";t["BACKTRACKED"]="BACKTRACKED";t["APPENDING"]="APPENDING";t["PARTIAL"]="PARTIAL";t["OK"]="OK"})(s||(s={}));var a=function(){function t(t){this.activeFragment=null;this.activeParts=null;this.fragments=Object.create(null);this.timeRanges=Object.create(null);this.bufferPadding=.2;this.hls=void 0;this.hls=t;this._registerListeners()}var i=t.prototype;i._registerListeners=function t(){var i=this.hls;i.on(e["Events"].BUFFER_APPENDED,this.onBufferAppended,this);i.on(e["Events"].FRAG_BUFFERED,this.onFragBuffered,this);i.on(e["Events"].FRAG_LOADED,this.onFragLoaded,this)};i._unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].BUFFER_APPENDED,this.onBufferAppended,this);i.off(e["Events"].FRAG_BUFFERED,this.onFragBuffered,this);i.off(e["Events"].FRAG_LOADED,this.onFragLoaded,this)};i.destroy=function t(){this._unregisterListeners();this.fragments=this.timeRanges=null};i.getAppendedFrag=function t(i,r){if(r===n["PlaylistLevelType"].MAIN){var e=this.activeFragment,s=this.activeParts;if(!e){return null}if(s){for(var a=s.length;a--;){var u=s[a];var f=u?u.end:e.appendedPTS;if(u.start<=i&&f!==undefined&&i<=f){if(a>9){this.activeParts=s.slice(a-9)}return u}}}else if(e.start<=i&&e.appendedPTS!==undefined&&i<=e.appendedPTS){return e}}return this.getBufferedFrag(i,r)};i.getBufferedFrag=function t(i,r){var e=this.fragments;var n=Object.keys(e);for(var s=n.length;s--;){var a=e[n[s]];if((a===null||a===void 0?void 0:a.body.type)===r&&a.buffered){var u=a.body;if(u.start<=i&&i<=u.end){return u}}}return null};i.detectEvictedFragments=function t(i,r,e){var n=this;Object.keys(this.fragments).forEach((function(t){var s=n.fragments[t];if(!s){return}if(!s.buffered){if(s.body.type===e){n.removeFragment(s.body)}return}var a=s.range[i];if(!a){return}a.time.some((function(t){var i=!n.isTimeBuffered(t.startPTS,t.endPTS,r);if(i){n.removeFragment(s.body)}return i}))}))};i.detectPartialFragments=function t(i){var r=this;var e=this.timeRanges;var n=i.frag,s=i.part;if(!e||n.sn==="initSegment"){return}var a=f(n);var u=this.fragments[a];if(!u){return}Object.keys(e).forEach((function(t){var i=n.elementaryStreams[t];if(!i){return}var a=e[t];var f=s!==null||i.partial===true;u.range[t]=r.getBufferedTimes(n,s,f,a)}));u.backtrack=u.loaded=null;if(Object.keys(u.range).length){u.buffered=true}else{this.removeFragment(u.body)}};i.fragBuffered=function t(i){var r=f(i);var e=this.fragments[r];if(e){e.backtrack=e.loaded=null;e.buffered=true}};i.getBufferedTimes=function t(i,r,e,n){var s={time:[],partial:e};var a=r?r.start:i.start;var u=r?r.end:i.end;var f=i.minEndPTS||u;var h=i.maxStartPTS||a;for(var o=0;o<n.length;o++){var v=n.start(o)-this.bufferPadding;var l=n.end(o)+this.bufferPadding;if(h>=v&&f<=l){s.time.push({startPTS:Math.max(a,n.start(o)),endPTS:Math.min(u,n.end(o))});break}else if(a<l&&u>v){s.partial=true;s.time.push({startPTS:Math.max(a,n.start(o)),endPTS:Math.min(u,n.end(o))})}else if(u<=v){break}}return s};i.getPartialFragment=function t(i){var r=null;var e;var n;var s;var a=0;var f=this.bufferPadding,h=this.fragments;Object.keys(h).forEach((function(t){var o=h[t];if(!o){return}if(u(o)){n=o.body.start-f;s=o.body.end+f;if(i>=n&&i<=s){e=Math.min(i-n,s-i);if(a<=e){r=o.body;a=e}}}}));return r};i.getState=function t(i){var r=f(i);var e=this.fragments[r];if(e){if(!e.buffered){if(e.backtrack){return s.BACKTRACKED}return s.APPENDING}else if(u(e)){return s.PARTIAL}else{return s.OK}}return s.NOT_LOADED};i.backtrack=function t(i,r){var e=f(i);var n=this.fragments[e];if(!n||n.backtrack){return null}var t=n.backtrack=r?r:n.loaded;n.loaded=null;return t};i.getBacktrackData=function t(i){var r=f(i);var e=this.fragments[r];if(e){var n;var s=e.backtrack;if(s!==null&&s!==void 0&&(n=s.payload)!==null&&n!==void 0&&n.byteLength){return s}else{this.removeFragment(i)}}return null};i.isTimeBuffered=function t(i,r,e){var n;var s;for(var a=0;a<e.length;a++){n=e.start(a)-this.bufferPadding;s=e.end(a)+this.bufferPadding;if(i>=n&&r<=s){return true}if(r<=n){return false}}return false};i.onFragLoaded=function t(i,r){var e=r.frag,n=r.part;if(e.sn==="initSegment"||e.bitrateTest||n){return}var s=f(e);this.fragments[s]={body:e,loaded:r,backtrack:null,buffered:false,range:Object.create(null)}};i.onBufferAppended=function t(i,r){var e=this;var s=r.frag,a=r.part,u=r.timeRanges;if(s.type===n["PlaylistLevelType"].MAIN){this.activeFragment=s;if(a){var f=this.activeParts;if(!f){this.activeParts=f=[]}f.push(a)}else{this.activeParts=null}}this.timeRanges=u;Object.keys(u).forEach((function(t){var i=u[t];e.detectEvictedFragments(t,i);if(!a){for(var r=0;r<i.length;r++){s.appendedPTS=Math.max(i.end(r),s.appendedPTS||0)}}}))};i.onFragBuffered=function t(i,r){this.detectPartialFragments(r)};i.hasFragment=function t(i){var r=f(i);return!!this.fragments[r]};i.removeFragmentsInRange=function t(i,r,e){var n=this;Object.keys(this.fragments).forEach((function(t){var s=n.fragments[t];if(!s){return}if(s.buffered){var a=s.body;if(a.type===e&&a.start<r&&a.end>i){n.removeFragment(a)}}}))};i.removeFragment=function t(i){var r=f(i);i.stats.loaded=0;i.clearElementaryStreamInfo();delete this.fragments[r]};i.removeAllFragments=function t(){this.fragments=Object.create(null);this.activeFragment=null;this.activeParts=null};return t}();function u(t){var i,r;return t.buffered&&(((i=t.range.video)===null||i===void 0?void 0:i.partial)||((r=t.range.audio)===null||r===void 0?void 0:r.partial))}function f(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":
69
+ /*! exports provided: FragmentState, FragmentTracker */function(t,i,n){n.r(i),n.d(i,"FragmentState",(function(){return r})),n.d(i,"FragmentTracker",(function(){return a}));var r,e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../types/loader */"./src/types/loader.ts");!function(t){t.NOT_LOADED="NOT_LOADED",t.BACKTRACKED="BACKTRACKED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK"}(r||(r={}));var a=function(){function t(t){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=t,this._registerListeners()}var i=t.prototype;return i._registerListeners=function(){var t=this.hls;t.on(e.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.on(e.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this)},i._unregisterListeners=function(){var t=this.hls;t.off(e.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.off(e.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this)},i.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},i.getAppendedFrag=function(t,i){if(i===s.PlaylistLevelType.MAIN){var n=this.activeFragment,r=this.activeParts;if(!n)return null;if(r)for(var e=r.length;e--;){var a=r[e],o=a?a.end:n.appendedPTS;if(a.start<=t&&void 0!==o&&t<=o)return e>9&&(this.activeParts=r.slice(e-9)),a}else if(n.start<=t&&void 0!==n.appendedPTS&&t<=n.appendedPTS)return n}return this.getBufferedFrag(t,i)},i.getBufferedFrag=function(t,i){for(var n=this.fragments,r=Object.keys(n),e=r.length;e--;){var s=n[r[e]];if((null==s?void 0:s.body.type)===i&&s.buffered){var a=s.body;if(a.start<=t&&t<=a.end)return a}}return null},i.detectEvictedFragments=function(t,i,n){var r=this;Object.keys(this.fragments).forEach((function(e){var s=r.fragments[e];if(s)if(s.buffered){var a=s.range[t];a&&a.time.some((function(t){var n=!r.isTimeBuffered(t.startPTS,t.endPTS,i);return n&&r.removeFragment(s.body),n}))}else s.body.type===n&&r.removeFragment(s.body)}))},i.detectPartialFragments=function(t){var i=this,n=this.timeRanges,r=t.frag,e=t.part;if(n&&"initSegment"!==r.sn){var s=h(r),a=this.fragments[s];a&&(Object.keys(n).forEach((function(t){var s=r.elementaryStreams[t];s&&(a.range[t]=i.getBufferedTimes(r,e,null!==e||!0===s.partial,n[t]))})),a.backtrack=a.loaded=null,Object.keys(a.range).length?a.buffered=!0:this.removeFragment(a.body))}},i.fragBuffered=function(t){var i=h(t),n=this.fragments[i];n&&(n.backtrack=n.loaded=null,n.buffered=!0)},i.getBufferedTimes=function(t,i,n,r){for(var e={time:[],partial:n},s=i?i.start:t.start,a=i?i.end:t.end,o=t.minEndPTS||a,h=t.maxStartPTS||s,u=0;u<r.length;u++){var c=r.start(u)-this.bufferPadding,f=r.end(u)+this.bufferPadding;if(h>=c&&o<=f){e.time.push({startPTS:Math.max(s,r.start(u)),endPTS:Math.min(a,r.end(u))});break}if(s<f&&a>c)e.partial=!0,e.time.push({startPTS:Math.max(s,r.start(u)),endPTS:Math.min(a,r.end(u))});else if(a<=c)break}return e},i.getPartialFragment=function(t){var i,n,r,e=null,s=0,a=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach((function(u){var c=h[u];c&&o(c)&&(r=c.body.end+a,t>=(n=c.body.start-a)&&t<=r&&(i=Math.min(t-n,r-t),s<=i&&(e=c.body,s=i)))})),e},i.getState=function(t){var i=h(t),n=this.fragments[i];return n?n.buffered?o(n)?r.PARTIAL:r.OK:n.backtrack?r.BACKTRACKED:r.APPENDING:r.NOT_LOADED},i.backtrack=function(t,i){var n=h(t),r=this.fragments[n];if(!r||r.backtrack)return null;var e=r.backtrack=i||r.loaded;return r.loaded=null,e},i.getBacktrackData=function(t){var i=h(t),n=this.fragments[i];if(n){var r,e=n.backtrack;if(null!=e&&null!==(r=e.payload)&&void 0!==r&&r.byteLength)return e;this.removeFragment(t)}return null},i.isTimeBuffered=function(t,i,n){for(var r,e,s=0;s<n.length;s++){if(r=n.start(s)-this.bufferPadding,e=n.end(s)+this.bufferPadding,t>=r&&i<=e)return!0;if(i<=r)return!1}return!1},i.onFragLoaded=function(t,i){var n=i.frag;if("initSegment"!==n.sn&&!n.bitrateTest&&!i.part){var r=h(n);this.fragments[r]={body:n,loaded:i,backtrack:null,buffered:!1,range:Object.create(null)}}},i.onBufferAppended=function(t,i){var n=this,r=i.frag,e=i.part,a=i.timeRanges;if(r.type===s.PlaylistLevelType.MAIN)if(this.activeFragment=r,e){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(e)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach((function(t){var i=a[t];if(n.detectEvictedFragments(t,i),!e)for(var s=0;s<i.length;s++)r.appendedPTS=Math.max(i.end(s),r.appendedPTS||0)}))},i.onFragBuffered=function(t,i){this.detectPartialFragments(i)},i.hasFragment=function(t){var i=h(t);return!!this.fragments[i]},i.removeFragmentsInRange=function(t,i,n){var r=this;Object.keys(this.fragments).forEach((function(e){var s=r.fragments[e];if(s&&s.buffered){var a=s.body;a.type===n&&a.start<i&&a.end>t&&r.removeFragment(a)}}))},i.removeFragment=function(t){var i=h(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),delete this.fragments[i]},i.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},t}();function o(t){var i,n;return t.buffered&&((null===(i=t.range.video)||void 0===i?void 0:i.partial)||(null===(n=t.range.audio)||void 0===n?void 0:n.partial))}function h(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":
70
70
  /*!******************************************!*\
71
71
  !*** ./src/controller/gap-controller.ts ***!
72
72
  \******************************************/
73
- /*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(t,i,r){r.r(i);r.d(i,"STALL_MINIMUM_DURATION_MS",(function(){return u}));r.d(i,"MAX_START_GAP_JUMP",(function(){return f}));r.d(i,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return h}));r.d(i,"SKIP_BUFFER_RANGE_START",(function(){return o}));r.d(i,"default",(function(){return v}));var e=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../events */"./src/events.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=250;var f=2;var h=.1;var o=.05;var v=function(){function t(t,i,r,e){this.config=void 0;this.media=void 0;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=t;this.media=i;this.fragmentTracker=r;this.hls=e}var i=t.prototype;i.destroy=function t(){this.hls=this.fragmentTracker=this.media=null};i.poll=function t(i){var r=this.config,n=this.media,s=this.stalled;var h=n.currentTime,o=n.seeking;var v=this.seeking&&!o;var l=!this.seeking&&o;this.seeking=o;if(h!==i){this.moved=true;if(s!==null){if(this.stallReported){var c=self.performance.now()-s;a["logger"].warn("playback not stuck anymore @"+h+", after "+Math.round(c)+"ms");this.stallReported=false}this.stalled=null;this.nudgeRetry=0}return}if(l||v){this.stalled=null}if(n.paused||n.ended||n.playbackRate===0||!e["BufferHelper"].getBuffered(n).length){return}var d=e["BufferHelper"].bufferInfo(n,h,0);var m=d.len>0;var p=d.nextStart||0;if(!m&&!p){return}if(o){var g=d.len>f;var b=!p||p-h>f&&!this.fragmentTracker.getPartialFragment(h);if(g||b){return}this.moved=false}if(!this.moved&&this.stalled!==null){var y;var w=Math.max(p,d.start||0)-h;var k=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null;var T=k===null||k===void 0?void 0:(y=k.details)===null||y===void 0?void 0:y.live;var O=T?k.details.targetduration*2:f;if(w>0&&w<=O){this._trySkipBufferHole(null);return}}var S=self.performance.now();if(s===null){this.stalled=S;return}var E=S-s;if(!o&&E>=u){this._reportStall(d.len)}var A=e["BufferHelper"].bufferInfo(n,h,r.maxBufferHole);this._tryFixBufferStall(A,E)};i._tryFixBufferStall=function t(i,r){var e=this.config,n=this.fragmentTracker,s=this.media;var u=s.currentTime;var f=n.getPartialFragment(u);if(f){var h=this._trySkipBufferHole(f);if(h){return}}if(i.len>e.maxBufferHole&&r>e.highBufferWatchdogPeriod*1e3){a["logger"].warn("Trying to nudge playhead over buffer-hole");this.stalled=null;this._tryNudgeBuffer()}};i._reportStall=function t(i){var r=this.hls,e=this.media,u=this.stallReported;if(!u){this.stallReported=true;a["logger"].warn("Playback stalling at @"+e.currentTime+" due to low buffer (buffer="+i+")");r.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].BUFFER_STALLED_ERROR,fatal:false,buffer:i})}};i._trySkipBufferHole=function t(i){var r=this.config,u=this.hls,f=this.media;var v=f.currentTime;var l=0;var c=e["BufferHelper"].getBuffered(f);for(var d=0;d<c.length;d++){var m=c.start(d);if(v+r.maxBufferHole>=l&&v<m){var p=Math.max(m+o,f.currentTime+h);a["logger"].warn("skipping hole, adjusting currentTime from "+v+" to "+p);this.moved=true;this.stalled=null;f.currentTime=p;if(i){u.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].BUFFER_SEEK_OVER_HOLE,fatal:false,reason:"fragment loaded with buffer holes, seeking from "+v+" to "+p,frag:i})}return p}l=c.end(d)}return 0};i._tryNudgeBuffer=function t(){var i=this.config,r=this.hls,e=this.media;var u=e.currentTime;var f=(this.nudgeRetry||0)+1;this.nudgeRetry=f;if(f<i.nudgeMaxRetry){var h=u+f*i.nudgeOffset;a["logger"].warn("Nudging 'currentTime' from "+u+" to "+h);e.currentTime=h;r.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].BUFFER_NUDGE_ON_STALL,fatal:false})}else{a["logger"].error("Playhead still not moving while enough data buffered @"+u+" after "+i.nudgeMaxRetry+" nudges");r.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].BUFFER_STALLED_ERROR,fatal:true})}};return t}()},"./src/controller/id3-track-controller.ts":
73
+ /*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(t,i,n){n.r(i),n.d(i,"STALL_MINIMUM_DURATION_MS",(function(){return o})),n.d(i,"MAX_START_GAP_JUMP",(function(){return h})),n.d(i,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return u})),n.d(i,"SKIP_BUFFER_RANGE_START",(function(){return c})),n.d(i,"default",(function(){return f}));var r=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ../events */"./src/events.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,h=2,u=.1,c=.05,f=function(){function t(t,i,n,r){this.config=void 0,this.media=void 0,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=i,this.fragmentTracker=n,this.hls=r}var i=t.prototype;return i.destroy=function(){this.hls=this.fragmentTracker=this.media=null},i.poll=function(t){var i=this.config,n=this.media,e=this.stalled,s=n.currentTime,u=n.seeking,c=this.seeking&&!u,f=!this.seeking&&u;if(this.seeking=u,s===t){if((f||c)&&(this.stalled=null),!n.paused&&!n.ended&&0!==n.playbackRate&&r.BufferHelper.getBuffered(n).length){var l=r.BufferHelper.bufferInfo(n,s,0),v=l.nextStart||0;if(l.len>0||v){if(u){var d=l.len>h,m=!v||v-s>h&&!this.fragmentTracker.getPartialFragment(s);if(d||m)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var p,g=Math.max(v,l.start||0)-s,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,y=null==b||null===(p=b.details)||void 0===p?void 0:p.live;if(g>0&&g<=(y?2*b.details.targetduration:h))return void this._trySkipBufferHole(null)}var w=self.performance.now();if(null!==e){var k=w-e;!u&&k>=o&&this._reportStall(l.len);var T=r.BufferHelper.bufferInfo(n,s,i.maxBufferHole);this._tryFixBufferStall(T,k)}else this.stalled=w}}}else if(this.moved=!0,null!==e){if(this.stallReported){var O=self.performance.now()-e;a.logger.warn("playback not stuck anymore @"+s+", after "+Math.round(O)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},i._tryFixBufferStall=function(t,i){var n=this.config,r=this.fragmentTracker.getPartialFragment(this.media.currentTime);r&&this._trySkipBufferHole(r)||t.len>n.maxBufferHole&&i>1e3*n.highBufferWatchdogPeriod&&(a.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},i._reportStall=function(t){var i=this.hls,n=this.media;this.stallReported||(this.stallReported=!0,a.logger.warn("Playback stalling at @"+n.currentTime+" due to low buffer (buffer="+t+")"),i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t}))},i._trySkipBufferHole=function(t){for(var i=this.config,n=this.hls,o=this.media,h=o.currentTime,f=0,l=r.BufferHelper.getBuffered(o),v=0;v<l.length;v++){var d=l.start(v);if(h+i.maxBufferHole>=f&&h<d){var m=Math.max(d+c,o.currentTime+u);return a.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+m),this.moved=!0,this.stalled=null,o.currentTime=m,t&&n.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+m,frag:t}),m}f=l.end(v)}return 0},i._tryNudgeBuffer=function(){var t=this.config,i=this.hls,n=this.media,r=n.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<t.nudgeMaxRetry){var h=r+o*t.nudgeOffset;a.logger.warn("Nudging 'currentTime' from "+r+" to "+h),n.currentTime=h,i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else a.logger.error("Playhead still not moving while enough data buffered @"+r+" after "+t.nudgeMaxRetry+" nudges"),i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},t}()},"./src/controller/id3-track-controller.ts":
74
74
  /*!************************************************!*\
75
75
  !*** ./src/controller/id3-track-controller.ts ***!
76
76
  \************************************************/
77
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts");var s=r(/*! ../demux/id3 */"./src/demux/id3.ts");var a=.25;var u=function(){function t(t){this.hls=void 0;this.id3Track=null;this.media=null;this.hls=t;this._registerListeners()}var i=t.prototype;i.destroy=function t(){this._unregisterListeners()};i._registerListeners=function t(){var i=this.hls;i.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(e["Events"].FRAG_PARSING_METADATA,this.onFragParsingMetadata,this);i.on(e["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)};i._unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(e["Events"].FRAG_PARSING_METADATA,this.onFragParsingMetadata,this);i.off(e["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)};i.onMediaAttached=function t(i,r){this.media=r.media};i.onMediaDetaching=function t(){if(!this.id3Track){return}Object(n["clearCurrentCues"])(this.id3Track);this.id3Track=null;this.media=null};i.getID3Track=function t(i){if(!this.media){return}for(var r=0;r<i.length;r++){var e=i[r];if(e.kind==="metadata"&&e.label==="id3"){Object(n["sendAddTrackEvent"])(e,this.media);return e}}return this.media.addTextTrack("metadata","id3")};i.onFragParsingMetadata=function t(i,r){if(!this.media){return}var e=r.frag;var n=r.samples;if(!this.id3Track){this.id3Track=this.getID3Track(this.media.textTracks);this.id3Track.mode="hidden"}var u=self.WebKitDataCue||self.VTTCue||self.TextTrackCue;for(var f=0;f<n.length;f++){var h=s["getID3Frames"](n[f].data);if(h){var o=n[f].pts;var v=f<n.length-1?n[f+1].pts:e.end;var l=v-o;if(l<=0){v=o+a}for(var c=0;c<h.length;c++){var d=h[c];if(!s["isTimeStampFrame"](d)){var m=new u(o,v,"");m.value=d;this.id3Track.addCue(m)}}}}};i.onBufferFlushing=function t(i,r){var e=r.startOffset,s=r.endOffset,a=r.type;if(!a||a==="audio"){var u=this.id3Track;if(u){Object(n["removeCuesInRange"])(u,e,s)}}};return t}();i["default"]=u},"./src/controller/latency-controller.ts":
77
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=n(/*! ../demux/id3 */"./src/demux/id3.ts"),a=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=t,this._registerListeners()}var i=t.prototype;return i.destroy=function(){this._unregisterListeners()},i._registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.onMediaAttached=function(t,i){this.media=i.media},i.onMediaDetaching=function(){this.id3Track&&(Object(e.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},i.getID3Track=function(t){if(this.media){for(var i=0;i<t.length;i++){var n=t[i];if("metadata"===n.kind&&"id3"===n.label)return Object(e.sendAddTrackEvent)(n,this.media),n}return this.media.addTextTrack("metadata","id3")}},i.onFragParsingMetadata=function(t,i){if(this.media){var n=i.frag,r=i.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var e=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,a=0;a<r.length;a++){var o=s.getID3Frames(r[a].data);if(o){var h=r[a].pts,u=a<r.length-1?r[a+1].pts:n.end;u-h<=0&&(u=h+.25);for(var c=0;c<o.length;c++){var f=o[c];if(!s.isTimeStampFrame(f)){var l=new e(h,u,"");l.value=f,this.id3Track.addCue(l)}}}}}},i.onBufferFlushing=function(t,i){var n=i.startOffset,r=i.endOffset,s=i.type;if(!s||"audio"===s){var a=this.id3Track;a&&Object(e.removeCuesInRange)(a,n,r)}},t}();i.default=a},"./src/controller/latency-controller.ts":
78
78
  /*!**********************************************!*\
79
79
  !*** ./src/controller/latency-controller.ts ***!
80
80
  \**********************************************/
81
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return f}));var e=r(/*! ../errors */"./src/errors.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function u(t,i,r){if(i)a(t.prototype,i);if(r)a(t,r);return t}var f=function(){function t(t){var i=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 i.timeupdate()};this.hls=t;this.config=t.config;this.registerListeners()}var i=t.prototype;i.destroy=function t(){this.unregisterListeners();this.onMediaDetaching();this.levelDetails=null;this.hls=this.timeupdateHandler=null};i.registerListeners=function t(){this.hls.on(n["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);this.hls.on(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);this.hls.on(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);this.hls.on(n["Events"].LEVEL_UPDATED,this.onLevelUpdated,this);this.hls.on(n["Events"].ERROR,this.onError,this)};i.unregisterListeners=function t(){this.hls.off(n["Events"].MEDIA_ATTACHED,this.onMediaAttached);this.hls.off(n["Events"].MEDIA_DETACHING,this.onMediaDetaching);this.hls.off(n["Events"].MANIFEST_LOADING,this.onManifestLoading);this.hls.off(n["Events"].LEVEL_UPDATED,this.onLevelUpdated);this.hls.off(n["Events"].ERROR,this.onError)};i.onMediaAttached=function t(i,r){this.media=r.media;this.media.addEventListener("timeupdate",this.timeupdateHandler)};i.onMediaDetaching=function t(){if(this.media){this.media.removeEventListener("timeupdate",this.timeupdateHandler);this.media=null}};i.onManifestLoading=function t(){this.levelDetails=null;this._latency=null;this.stallCount=0};i.onLevelUpdated=function t(i,r){var e=r.details;this.levelDetails=e;if(e.advanced){this.timeupdate()}if(!e.live&&this.media){this.media.removeEventListener("timeupdate",this.timeupdateHandler)}};i.onError=function t(i,r){if(r.details!==e["ErrorDetails"].BUFFER_STALLED_ERROR){return}this.stallCount++;s["logger"].warn("[playback-rate-controller]: Stall detected, adjusting target latency")};i.timeupdate=function t(){var i=this.media,r=this.levelDetails;if(!i||!r){return}this.currentTime=i.currentTime;var e=this.computeLatency();if(e===null){return}this._latency=e;var n=this.config,s=n.lowLatencyMode,a=n.maxLiveSyncPlaybackRate;if(!s||a===1){return}var u=this.targetLatency;if(u===null){return}var f=e-u;var h=Math.min(this.maxLatency,u+r.targetduration);var o=f<h;if(r.live&&o&&f>.05&&this.forwardBufferLength>1){var v=Math.min(2,Math.max(1,a));var l=Math.round(2/(1+Math.exp(-.75*f-this.edgeStalled))*20)/20;i.playbackRate=Math.min(v,Math.max(1,l))}else if(i.playbackRate!==1&&i.playbackRate!==0){i.playbackRate=1}};i.estimateLiveEdge=function t(){var i=this.levelDetails;if(i===null){return null}return i.edge+i.age};i.computeLatency=function t(){var i=this.estimateLiveEdge();if(i===null){return null}return i-this.currentTime};u(t,[{key:"latency",get:function t(){return this._latency||0}},{key:"maxLatency",get:function t(){var i=this.config,r=this.levelDetails;if(i.liveMaxLatencyDuration!==undefined){return i.liveMaxLatencyDuration}return r?i.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function t(){var i=this.levelDetails;if(i===null){return null}var r=i.holdBack,e=i.partHoldBack,n=i.targetduration;var s=this.config,a=s.liveSyncDuration,u=s.liveSyncDurationCount,f=s.lowLatencyMode;var h=this.hls.userConfig;var o=f?e||r:r;if(h.liveSyncDuration||h.liveSyncDurationCount||o===0){o=a!==undefined?a:u*n}var v=n;var l=1;return o+Math.min(this.stallCount*l,v)}},{key:"liveSyncPosition",get:function t(){var i=this.estimateLiveEdge();var r=this.targetLatency;var e=this.levelDetails;if(i===null||r===null||e===null){return null}var n=e.edge;var s=i-r-this.edgeStalled;var a=n-e.totalduration;var u=n-(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.min(Math.max(a,s),u)}},{key:"drift",get:function t(){var i=this.levelDetails;if(i===null){return 1}return i.drift}},{key:"edgeStalled",get:function t(){var i=this.levelDetails;if(i===null){return 0}var r=(this.config.lowLatencyMode&&i.partTarget||i.targetduration)*3;return Math.max(i.age-r,0)}},{key:"forwardBufferLength",get:function t(){var i=this.media,r=this.levelDetails;if(!i||!r){return 0}var e=i.buffered.length;return e?i.buffered.end(e-1):r.edge-this.currentTime}}]);return t}()},"./src/controller/level-controller.ts":
81
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return o}));var r=n(/*! ../errors */"./src/errors.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var o=function(){function t(t){var i=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 i.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var i,n,o=t.prototype;return o.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},o.registerListeners=function(){this.hls.on(e.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(e.Events.ERROR,this.onError,this)},o.unregisterListeners=function(){this.hls.off(e.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(e.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(e.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(e.Events.ERROR,this.onError)},o.onMediaAttached=function(t,i){this.media=i.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},o.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},o.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},o.onLevelUpdated=function(t,i){var n=i.details;this.levelDetails=n,n.advanced&&this.timeupdate(),!n.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},o.onError=function(t,i){i.details===r.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,s.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},o.timeupdate=function(){var t=this.media,i=this.levelDetails;if(t&&i){this.currentTime=t.currentTime;var n=this.computeLatency();if(null!==n){this._latency=n;var r=this.config,e=r.maxLiveSyncPlaybackRate;if(r.lowLatencyMode&&1!==e){var s=this.targetLatency;if(null!==s){var a=n-s,o=Math.min(this.maxLatency,s+i.targetduration);if(i.live&&a<o&&a>.05&&this.forwardBufferLength>1){var h=Math.min(2,Math.max(1,e)),u=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;t.playbackRate=Math.min(h,Math.max(1,u))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},o.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},o.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},i=t,(n=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,i=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:i?t.liveMaxLatencyDurationCount*i.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var i=t.targetduration,n=this.config,r=n.liveSyncDuration,e=this.hls.userConfig,s=n.lowLatencyMode&&t.partHoldBack||t.holdBack;return(e.liveSyncDuration||e.liveSyncDurationCount||0===s)&&(s=void 0!==r?r:n.liveSyncDurationCount*i),s+Math.min(1*this.stallCount,i)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),i=this.targetLatency,n=this.levelDetails;if(null===t||null===i||null===n)return null;var r=n.edge,e=r-(this.config.lowLatencyMode&&n.partTarget||n.targetduration);return Math.min(Math.max(r-n.totalduration,t-i-this.edgeStalled),e)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;return null===t?0:Math.max(t.age-3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration),0)}},{key:"forwardBufferLength",get:function(){var t=this.media,i=this.levelDetails;if(!t||!i)return 0;var n=t.buffered.length;return n?t.buffered.end(n-1):i.edge-this.currentTime}}])&&a(i.prototype,n),t}()},"./src/controller/level-controller.ts":
82
82
  /*!********************************************!*\
83
83
  !*** ./src/controller/level-controller.ts ***!
84
84
  \********************************************/
85
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return p}));var e=r(/*! ../types/level */"./src/types/level.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../errors */"./src/errors.ts");var a=r(/*! ../utils/codecs */"./src/utils/codecs.ts");var u=r(/*! ./level-helper */"./src/controller/level-helper.ts");var f=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts");var h=r(/*! ../types/loader */"./src/types/loader.ts");function o(){o=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return o.apply(this,arguments)}function v(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function l(t,i,r){if(i)v(t.prototype,i);if(r)v(t,r);return t}function c(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;d(t,i)}function d(t,i){d=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return d(t,i)}var m=/chrome|firefox/.test(navigator.userAgent.toLowerCase());var p=function(t){c(i,t);function i(i){var r;r=t.call(this,i,"[level-controller]")||this;r._levels=[];r._firstLevel=-1;r._startLevel=void 0;r.currentLevelIndex=-1;r.manualLevelIndex=-1;r.onParsedComplete=void 0;r._registerListeners();return r}var r=i.prototype;r._registerListeners=function t(){var i=this.hls;i.on(n["Events"].MANIFEST_LOADED,this.onManifestLoaded,this);i.on(n["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(n["Events"].AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);i.on(n["Events"].FRAG_LOADED,this.onFragLoaded,this);i.on(n["Events"].ERROR,this.onError,this)};r._unregisterListeners=function t(){var i=this.hls;i.off(n["Events"].MANIFEST_LOADED,this.onManifestLoaded,this);i.off(n["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(n["Events"].AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);i.off(n["Events"].FRAG_LOADED,this.onFragLoaded,this);i.off(n["Events"].ERROR,this.onError,this)};r.destroy=function i(){this._unregisterListeners();this.manualLevelIndex=-1;this._levels.length=0;t.prototype.destroy.call(this)};r.startLoad=function i(){var r=this._levels;r.forEach((function(t){t.loadError=0}));t.prototype.startLoad.call(this)};r.onManifestLoaded=function t(i,r){var f=[];var h=[];var o=[];var v;var l={};var c;var d=false;var p=false;var g=false;r.levels.forEach((function(t){var i=t.attrs;d=d||!!(t.width&&t.height);p=p||!!t.videoCodec;g=g||!!t.audioCodec;if(m&&t.audioCodec&&t.audioCodec.indexOf("mp4a.40.34")!==-1){t.audioCodec=undefined}var r=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;c=l[r];if(!c){c=new e["Level"](t);l[r]=c;f.push(c)}else{c.url.push(t.url)}if(i){if(i.AUDIO){Object(u["addGroupId"])(c,"audio",i.AUDIO)}if(i.SUBTITLES){Object(u["addGroupId"])(c,"text",i.SUBTITLES)}}}));if((d||p)&&g){f=f.filter((function(t){var i=t.videoCodec,r=t.width,e=t.height;return!!i||!!(r&&e)}))}f=f.filter((function(t){var i=t.audioCodec,r=t.videoCodec;return(!i||Object(a["isCodecSupportedInMp4"])(i,"audio"))&&(!r||Object(a["isCodecSupportedInMp4"])(r,"video"))}));if(r.audioTracks){h=r.audioTracks.filter((function(t){return!t.audioCodec||Object(a["isCodecSupportedInMp4"])(t.audioCodec,"audio")}));Object(u["assignTrackIdsByGroup"])(h)}if(r.subtitles){o=r.subtitles;Object(u["assignTrackIdsByGroup"])(o)}if(f.length>0){v=f[0].bitrate;f.sort((function(t,i){return t.bitrate-i.bitrate}));this._levels=f;for(var b=0;b<f.length;b++){if(f[b].bitrate===v){this._firstLevel=b;this.log("manifest loaded, "+f.length+" level(s) found, first bitrate: "+v);break}}var y=g&&!p;var w={levels:f,audioTracks:h,subtitleTracks:o,firstLevel:this._firstLevel,stats:r.stats,audio:g,video:p,altAudio:!y&&h.some((function(t){return!!t.url}))};this.hls.trigger(n["Events"].MANIFEST_PARSED,w);if(this.hls.config.autoStartLoad||this.hls.forceStartLoad){this.hls.startLoad(this.hls.config.startPosition)}}else{this.hls.trigger(n["Events"].ERROR,{type:s["ErrorTypes"].MEDIA_ERROR,details:s["ErrorDetails"].MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:true,url:r.url,reason:"no level with compatible codecs found in manifest"})}};r.onError=function i(r,e){t.prototype.onError.call(this,r,e);if(e.fatal){return}var n=e.context;var a=this._levels[this.currentLevelIndex];if(n&&(n.type===h["PlaylistContextType"].AUDIO_TRACK&&a.audioGroupIds&&n.groupId===a.audioGroupIds[a.urlId]||n.type===h["PlaylistContextType"].SUBTITLE_TRACK&&a.textGroupIds&&n.groupId===a.textGroupIds[a.urlId])){this.redundantFailover(this.currentLevelIndex);return}var u=false;var f=true;var o;switch(e.details){case s["ErrorDetails"].FRAG_LOAD_ERROR:case s["ErrorDetails"].FRAG_LOAD_TIMEOUT:case s["ErrorDetails"].KEY_LOAD_ERROR:case s["ErrorDetails"].KEY_LOAD_TIMEOUT:if(e.frag){var v=this._levels[e.frag.level];if(v){v.fragmentError++;if(v.fragmentError>this.hls.config.fragLoadingMaxRetry){o=e.frag.level}}else{o=e.frag.level}}break;case s["ErrorDetails"].LEVEL_LOAD_ERROR:case s["ErrorDetails"].LEVEL_LOAD_TIMEOUT:if(n){if(n.deliveryDirectives){f=false}o=n.level}u=true;break;case s["ErrorDetails"].REMUX_ALLOC_ERROR:o=e.level;u=true;break}if(o!==undefined){this.recoverLevel(e,o,u,f)}};r.recoverLevel=function t(i,r,e,n){var s=i.details;var a=this._levels[r];a.loadError++;if(e){var u=this.retryLoadingOrFail(i);if(u){i.levelRetry=true}else{this.currentLevelIndex=-1;return}}if(n){var f=a.url.length;if(f>1&&a.loadError<f){i.levelRetry=true;this.redundantFailover(r)}else if(this.manualLevelIndex===-1){var h=r===0?this._levels.length-1:r-1;if(this.currentLevelIndex!==h&&this._levels[h].loadError===0){this.warn(s+": switch to "+h);i.levelRetry=true;this.hls.nextAutoLevel=h}}}};r.redundantFailover=function t(i){var r=this._levels[i];var e=r.url.length;if(e>1){var n=(r.urlId+1)%e;this.warn("Switching to redundant URL-id "+n);this._levels.forEach((function(t){t.urlId=n}));this.level=i}};r.onFragLoaded=function t(i,r){var e=r.frag;if(e!==undefined&&e.type===h["PlaylistLevelType"].MAIN){var n=this._levels[e.level];if(n!==undefined){n.fragmentError=0;n.loadError=0}}};r.onLevelLoaded=function t(i,r){var e;var n=r.level,s=r.details;var a=this._levels[n];if(!a){var u;this.warn("Invalid level index "+n);if((u=r.deliveryDirectives)!==null&&u!==void 0&&u.skip){s.deltaUpdateFailed=true}return}if(n===this.currentLevelIndex){if(a.fragmentError===0){a.loadError=0;this.retryCount=0}this.playlistLoaded(n,r,a.details)}else if((e=r.deliveryDirectives)!==null&&e!==void 0&&e.skip){s.deltaUpdateFailed=true}};r.onAudioTrackSwitched=function t(i,r){var e=this.hls.levels[this.currentLevelIndex];if(!e){return}if(e.audioGroupIds){var n=-1;var s=this.hls.audioTracks[r.id].groupId;for(var a=0;a<e.audioGroupIds.length;a++){if(e.audioGroupIds[a]===s){n=a;break}}if(n!==e.urlId){e.urlId=n;this.startLoad()}}};r.loadPlaylist=function t(i){var r=this.currentLevelIndex;var e=this._levels[r];if(this.canLoad&&e&&e.url.length>0){var s=e.urlId;var a=e.url[s];if(i){try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}}this.log("Attempt loading level index "+r+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+s+" "+a);this.clearTimer();this.hls.trigger(n["Events"].LEVEL_LOADING,{url:a,level:r,id:s,deliveryDirectives:i||null})}};r.removeLevel=function t(i,r){var e=function t(i,e){return e!==r};var s=this._levels.filter((function(t,n){if(n!==i){return true}if(t.url.length>1&&r!==undefined){t.url=t.url.filter(e);if(t.audioGroupIds){t.audioGroupIds=t.audioGroupIds.filter(e)}if(t.textGroupIds){t.textGroupIds=t.textGroupIds.filter(e)}t.urlId=0;return true}return false})).map((function(t,i){var r=t.details;if(r!==null&&r!==void 0&&r.fragments){r.fragments.forEach((function(t){t.level=i}))}return t}));this._levels=s;this.hls.trigger(n["Events"].LEVELS_UPDATED,{levels:s})};l(i,[{key:"levels",get:function t(){if(this._levels.length===0){return null}return this._levels}},{key:"level",get:function t(){return this.currentLevelIndex},set:function t(i){var r;var e=this._levels;if(e.length===0){return}if(this.currentLevelIndex===i&&(r=e[i])!==null&&r!==void 0&&r.details){return}if(i<0||i>=e.length){var a=i<0;this.hls.trigger(n["Events"].ERROR,{type:s["ErrorTypes"].OTHER_ERROR,details:s["ErrorDetails"].LEVEL_SWITCH_ERROR,level:i,fatal:a,reason:"invalid level idx"});if(a){return}i=Math.min(i,e.length-1)}this.clearTimer();var u=this.currentLevelIndex;var f=e[u];var h=e[i];this.log("switching to level "+i+" from "+u);this.currentLevelIndex=i;var v=o({},h,{level:i,maxBitrate:h.maxBitrate,uri:h.uri,urlId:h.urlId});delete v._urlId;this.hls.trigger(n["Events"].LEVEL_SWITCHING,v);var l=h.details;if(!l||l.live){var c=this.switchParams(h.uri,f===null||f===void 0?void 0:f.details);this.loadPlaylist(c)}}},{key:"manualLevel",get:function t(){return this.manualLevelIndex},set:function t(i){this.manualLevelIndex=i;if(this._startLevel===undefined){this._startLevel=i}if(i!==-1){this.level=i}}},{key:"firstLevel",get:function t(){return this._firstLevel},set:function t(i){this._firstLevel=i}},{key:"startLevel",get:function t(){if(this._startLevel===undefined){var i=this.hls.config.startLevel;if(i!==undefined){return i}else{return this._firstLevel}}else{return this._startLevel}},set:function t(i){this._startLevel=i}},{key:"nextLoadLevel",get:function t(){if(this.manualLevelIndex!==-1){return this.manualLevelIndex}else{return this.hls.nextAutoLevel}},set:function t(i){this.level=i;if(this.manualLevelIndex===-1){this.hls.nextAutoLevel=i}}}]);return i}(f["default"])},"./src/controller/level-helper.ts":
85
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return d}));var r=n(/*! ../types/level */"./src/types/level.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../errors */"./src/errors.ts"),a=n(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=n(/*! ./level-helper */"./src/controller/level-helper.ts"),h=n(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts");function c(){return c=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c.apply(this,arguments)}function f(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t,i){return l=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},l(t,i)}var v=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(t){var i,n;function h(i){var n;return(n=t.call(this,i,"[level-controller]")||this)._levels=[],n._firstLevel=-1,n._startLevel=void 0,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.onParsedComplete=void 0,n._registerListeners(),n}n=t,(i=h).prototype=Object.create(n.prototype),i.prototype.constructor=i,l(i,n);var d,m,p=h.prototype;return p._registerListeners=function(){var t=this.hls;t.on(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(e.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(e.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(e.Events.ERROR,this.onError,this)},p._unregisterListeners=function(){var t=this.hls;t.off(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(e.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(e.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(e.Events.ERROR,this.onError,this)},p.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},p.startLoad=function(){this._levels.forEach((function(t){t.loadError=0})),t.prototype.startLoad.call(this)},p.onManifestLoaded=function(t,i){var n,h,u=[],c=[],f=[],l={},d=!1,m=!1,p=!1;if(i.levels.forEach((function(t){var i=t.attrs;d=d||!(!t.width||!t.height),m=m||!!t.videoCodec,p=p||!!t.audioCodec,v&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0);var n=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;(h=l[n])?h.url.push(t.url):(h=new r.Level(t),l[n]=h,u.push(h)),i&&(i.AUDIO&&Object(o.addGroupId)(h,"audio",i.AUDIO),i.SUBTITLES&&Object(o.addGroupId)(h,"text",i.SUBTITLES))})),(d||m)&&p&&(u=u.filter((function(t){return!!t.videoCodec||!(!t.width||!t.height)}))),u=u.filter((function(t){var i=t.audioCodec,n=t.videoCodec;return(!i||Object(a.isCodecSupportedInMp4)(i,"audio"))&&(!n||Object(a.isCodecSupportedInMp4)(n,"video"))})),i.audioTracks&&(c=i.audioTracks.filter((function(t){return!t.audioCodec||Object(a.isCodecSupportedInMp4)(t.audioCodec,"audio")})),Object(o.assignTrackIdsByGroup)(c)),i.subtitles&&(f=i.subtitles,Object(o.assignTrackIdsByGroup)(f)),u.length>0){n=u[0].bitrate,u.sort((function(t,i){return t.bitrate-i.bitrate})),this._levels=u;for(var g=0;g<u.length;g++)if(u[g].bitrate===n){this._firstLevel=g,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+n);break}var b={levels:u,audioTracks:c,subtitleTracks:f,firstLevel:this._firstLevel,stats:i.stats,audio:p,video:m,altAudio:!(p&&!m)&&c.some((function(t){return!!t.url}))};this.hls.trigger(e.Events.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:i.url,reason:"no level with compatible codecs found in manifest"})},p.onError=function(i,n){if(t.prototype.onError.call(this,i,n),!n.fatal){var r=n.context,e=this._levels[this.currentLevelIndex];if(r&&(r.type===u.PlaylistContextType.AUDIO_TRACK&&e.audioGroupIds&&r.groupId===e.audioGroupIds[e.urlId]||r.type===u.PlaylistContextType.SUBTITLE_TRACK&&e.textGroupIds&&r.groupId===e.textGroupIds[e.urlId]))this.redundantFailover(this.currentLevelIndex);else{var a,o=!1,h=!0;switch(n.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:if(n.frag){var c=this._levels[n.frag.level];c?(c.fragmentError++,c.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=n.frag.level)):a=n.frag.level}break;case s.ErrorDetails.LEVEL_LOAD_ERROR:case s.ErrorDetails.LEVEL_LOAD_TIMEOUT:r&&(r.deliveryDirectives&&(h=!1),a=r.level),o=!0;break;case s.ErrorDetails.REMUX_ALLOC_ERROR:a=n.level,o=!0}void 0!==a&&this.recoverLevel(n,a,o,h)}}},p.recoverLevel=function(t,i,n,r){var e=t.details,s=this._levels[i];if(s.loadError++,n){if(!this.retryLoadingOrFail(t))return void(this.currentLevelIndex=-1);t.levelRetry=!0}if(r){var a=s.url.length;if(a>1&&s.loadError<a)t.levelRetry=!0,this.redundantFailover(i);else if(-1===this.manualLevelIndex){var o=0===i?this._levels.length-1:i-1;this.currentLevelIndex!==o&&0===this._levels[o].loadError&&(this.warn(e+": switch to "+o),t.levelRetry=!0,this.hls.nextAutoLevel=o)}}},p.redundantFailover=function(t){var i=this._levels[t],n=i.url.length;if(n>1){var r=(i.urlId+1)%n;this.warn("Switching to redundant URL-id "+r),this._levels.forEach((function(t){t.urlId=r})),this.level=t}},p.onFragLoaded=function(t,i){var n=i.frag;if(void 0!==n&&n.type===u.PlaylistLevelType.MAIN){var r=this._levels[n.level];void 0!==r&&(r.fragmentError=0,r.loadError=0)}},p.onLevelLoaded=function(t,i){var n,r,e=i.level,s=i.details,a=this._levels[e];if(!a)return this.warn("Invalid level index "+e),void(null!==(r=i.deliveryDirectives)&&void 0!==r&&r.skip&&(s.deltaUpdateFailed=!0));e===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(e,i,a.details)):null!==(n=i.deliveryDirectives)&&void 0!==n&&n.skip&&(s.deltaUpdateFailed=!0)},p.onAudioTrackSwitched=function(t,i){var n=this.hls.levels[this.currentLevelIndex];if(n&&n.audioGroupIds){for(var r=-1,e=this.hls.audioTracks[i.id].groupId,s=0;s<n.audioGroupIds.length;s++)if(n.audioGroupIds[s]===e){r=s;break}r!==n.urlId&&(n.urlId=r,this.startLoad())}},p.loadPlaylist=function(t){var i=this.currentLevelIndex,n=this._levels[i];if(this.canLoad&&n&&n.url.length>0){var r=n.urlId,s=n.url[r];if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Attempt loading level index "+i+(t?" at sn "+t.msn+" part "+t.part:"")+" with URL-id "+r+" "+s),this.clearTimer(),this.hls.trigger(e.Events.LEVEL_LOADING,{url:s,level:i,id:r,deliveryDirectives:t||null})}},p.removeLevel=function(t,i){var n=function(t,n){return n!==i},r=this._levels.filter((function(r,e){return e!==t||r.url.length>1&&void 0!==i&&(r.url=r.url.filter(n),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(n)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(n)),r.urlId=0,!0)})).map((function(t,i){var n=t.details;return null!=n&&n.fragments&&n.fragments.forEach((function(t){t.level=i})),t}));this._levels=r,this.hls.trigger(e.Events.LEVELS_UPDATED,{levels:r})},d=h,(m=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var i,n=this._levels;if(0!==n.length&&(this.currentLevelIndex!==t||null===(i=n[t])||void 0===i||!i.details)){if(t<0||t>=n.length){var r=t<0;if(this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:r,reason:"invalid level idx"}),r)return;t=Math.min(t,n.length-1)}this.clearTimer();var a=this.currentLevelIndex,o=n[a],h=n[t];this.log("switching to level "+t+" from "+a),this.currentLevelIndex=t;var u=c({},h,{level:t,maxBitrate:h.maxBitrate,uri:h.uri,urlId:h.urlId});delete u._urlId,this.hls.trigger(e.Events.LEVEL_SWITCHING,u);var f=h.details;if(!f||f.live){var l=this.switchParams(h.uri,null==o?void 0:o.details);this.loadPlaylist(l)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}])&&f(d.prototype,m),h}(h.default)},"./src/controller/level-helper.ts":
86
86
  /*!****************************************!*\
87
87
  !*** ./src/controller/level-helper.ts ***!
88
88
  \****************************************/
89
- /*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,i,r){r.r(i);r.d(i,"addGroupId",(function(){return s}));r.d(i,"assignTrackIdsByGroup",(function(){return a}));r.d(i,"updatePTS",(function(){return u}));r.d(i,"updateFragPTSDTS",(function(){return h}));r.d(i,"mergeDetails",(function(){return o}));r.d(i,"mapPartIntersection",(function(){return v}));r.d(i,"mapFragmentIntersection",(function(){return l}));r.d(i,"adjustSliding",(function(){return c}));r.d(i,"addSliding",(function(){return d}));r.d(i,"computeReloadInterval",(function(){return m}));r.d(i,"getFragmentWithSN",(function(){return p}));r.d(i,"getPartWith",(function(){return g}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../utils/logger */"./src/utils/logger.ts");function s(t,i,r){switch(i){case"audio":if(!t.audioGroupIds){t.audioGroupIds=[]}t.audioGroupIds.push(r);break;case"text":if(!t.textGroupIds){t.textGroupIds=[]}t.textGroupIds.push(r);break}}function a(t){var i={};t.forEach((function(t){var r=t.groupId||"";t.id=i[r]=i[r]||0;i[r]++}))}function u(t,i,r){var e=t[i];var n=t[r];f(e,n)}function f(t,i){var r=i.startPTS;if(Object(e["isFiniteNumber"])(r)){var n=0;var s;if(i.sn>t.sn){n=r-t.start;s=t}else{n=t.start-r;s=i}if(s.duration!==n){s.duration=n}}else if(i.sn>t.sn){var a=t.cc===i.cc;if(a&&t.minEndPTS){i.start=t.start+(t.minEndPTS-t.start)}else{i.start=t.start+t.duration}}else{i.start=Math.max(t.start-i.duration,0)}}function h(t,i,r,s,a,u){var h=s-r;if(h<=0){n["logger"].warn("Fragment should have a positive duration",i);s=r+i.duration;u=a+i.duration}var o=r;var v=s;var l=i.startPTS;var c=i.endPTS;if(Object(e["isFiniteNumber"])(l)){var d=Math.abs(l-r);if(!Object(e["isFiniteNumber"])(i.deltaPTS)){i.deltaPTS=d}else{i.deltaPTS=Math.max(d,i.deltaPTS)}o=Math.max(r,l);r=Math.min(r,l);a=Math.min(a,i.startDTS);v=Math.min(s,c);s=Math.max(s,c);u=Math.max(u,i.endDTS)}i.duration=s-r;var m=r-i.start;i.appendedPTS=s;i.start=i.startPTS=r;i.maxStartPTS=o;i.startDTS=a;i.endPTS=s;i.minEndPTS=v;i.endDTS=u;var p=i.sn;if(!t||p<t.startSN||p>t.endSN){return 0}var g;var b=p-t.startSN;var y=t.fragments;y[b]=i;for(g=b;g>0;g--){f(y[g],y[g-1])}for(g=b;g<y.length-1;g++){f(y[g],y[g+1])}if(t.fragmentHint){f(y[y.length-1],t.fragmentHint)}t.PTSKnown=t.alignedSliding=true;return m}function o(t,i){var r=null;var s=t.fragments;for(var a=s.length-1;a>=0;a--){var u=s[a].initSegment;if(u){r=u;break}}if(t.fragmentHint){delete t.fragmentHint.endPTS}var f=0;var o;l(t,i,(function(t,n){if(t.relurl){f=t.cc-n.cc}if(Object(e["isFiniteNumber"])(t.startPTS)&&Object(e["isFiniteNumber"])(t.endPTS)){n.start=n.startPTS=t.startPTS;n.startDTS=t.startDTS;n.appendedPTS=t.appendedPTS;n.maxStartPTS=t.maxStartPTS;n.endPTS=t.endPTS;n.endDTS=t.endDTS;n.minEndPTS=t.minEndPTS;n.duration=t.endPTS-t.startPTS;if(n.duration){o=n}i.PTSKnown=i.alignedSliding=true}n.elementaryStreams=t.elementaryStreams;n.loader=t.loader;n.stats=t.stats;n.urlId=t.urlId;if(t.initSegment){n.initSegment=t.initSegment;r=t.initSegment}}));if(r){var d=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;d.forEach((function(t){var i;if(!t.initSegment||t.initSegment.relurl===((i=r)===null||i===void 0?void 0:i.relurl)){t.initSegment=r}}))}if(i.skippedSegments){i.deltaUpdateFailed=i.fragments.some((function(t){return!t}));if(i.deltaUpdateFailed){n["logger"].warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var m=i.skippedSegments;m--;){i.fragments.shift()}i.startSN=i.fragments[0].sn;i.startCC=i.fragments[0].cc}}var p=i.fragments;if(f){n["logger"].warn("discontinuity sliding from playlist, take drift into account");for(var g=0;g<p.length;g++){p[g].cc+=f}}if(i.skippedSegments){i.startCC=i.fragments[0].cc}v(t.partList,i.partList,(function(t,i){i.elementaryStreams=t.elementaryStreams;i.stats=t.stats}));if(o){h(i,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS)}else{c(t,i)}if(p.length){i.totalduration=i.edge-p[0].start}i.driftStartTime=t.driftStartTime;i.driftStart=t.driftStart;var b=i.advancedDateTime;if(i.advanced&&b){var y=i.edge;if(!i.driftStart){i.driftStartTime=b;i.driftStart=y}i.driftEndTime=b;i.driftEnd=y}else{i.driftEndTime=t.driftEndTime;i.driftEnd=t.driftEnd;i.advancedDateTime=t.advancedDateTime}}function v(t,i,r){if(t&&i){var e=0;for(var n=0,s=t.length;n<=s;n++){var a=t[n];var u=i[n+e];if(a&&u&&a.index===u.index&&a.fragment.sn===u.fragment.sn){r(a,u)}else{e--}}}}function l(t,i,r){var e=i.skippedSegments;var n=Math.max(t.startSN,i.startSN)-i.startSN;var s=(t.fragmentHint?1:0)+(e?i.endSN:Math.min(t.endSN,i.endSN))-i.startSN;var a=i.startSN-t.startSN;var u=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;var f=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;for(var h=n;h<=s;h++){var o=f[a+h];var v=u[h];if(e&&!v&&h<e){v=i.fragments[h]=o}if(o&&v){r(o,v)}}}function c(t,i){var r=i.startSN+i.skippedSegments-t.startSN;var e=t.fragments;if(r<0||r>=e.length){return}d(i,e[r].start)}function d(t,i){if(i){var r=t.fragments;for(var e=t.skippedSegments;e<r.length;e++){r[e].start+=i}if(t.fragmentHint){t.fragmentHint.start+=i}}}function m(t,i){var r=1e3*t.levelTargetDuration;var e=r/2;var n=t.age;var s=n>0&&n<r*3;var a=i.loading.end-i.loading.start;var u;var f=t.availabilityDelay;if(t.updated===false){if(s){var h=333*t.misses;u=Math.max(Math.min(e,a*2),h);t.availabilityDelay=(t.availabilityDelay||0)+u}else{u=e}}else if(s){f=Math.min(f||r/2,n);t.availabilityDelay=f;u=f+r-n}else{u=r-a}return Math.round(u)}function p(t,i,r){if(!t||!t.details){return null}var e=t.details;var n=e.fragments[i-e.startSN];if(n){return n}n=e.fragmentHint;if(n&&n.sn===i){return n}if(i<e.startSN&&r&&r.sn===i){return r}return null}function g(t,i,r){if(!t||!t.details){return null}var e=t.details.partList;if(e){for(var n=e.length;n--;){var s=e[n];if(s.index===r&&s.fragment.sn===i){return s}}}return null}},"./src/controller/stream-controller.ts":
89
+ /*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,i,n){n.r(i),n.d(i,"addGroupId",(function(){return s})),n.d(i,"assignTrackIdsByGroup",(function(){return a})),n.d(i,"updatePTS",(function(){return o})),n.d(i,"updateFragPTSDTS",(function(){return u})),n.d(i,"mergeDetails",(function(){return c})),n.d(i,"mapPartIntersection",(function(){return f})),n.d(i,"mapFragmentIntersection",(function(){return l})),n.d(i,"adjustSliding",(function(){return v})),n.d(i,"addSliding",(function(){return d})),n.d(i,"computeReloadInterval",(function(){return m})),n.d(i,"getFragmentWithSN",(function(){return p})),n.d(i,"getPartWith",(function(){return g}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../utils/logger */"./src/utils/logger.ts");function s(t,i,n){switch(i){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(n);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(n)}}function a(t){var i={};t.forEach((function(t){var n=t.groupId||"";t.id=i[n]=i[n]||0,i[n]++}))}function o(t,i,n){h(t[i],t[n])}function h(t,i){var n=i.startPTS;if(Object(r.isFiniteNumber)(n)){var e,s=0;i.sn>t.sn?(s=n-t.start,e=t):(s=t.start-n,e=i),e.duration!==s&&(e.duration=s)}else i.start=i.sn>t.sn?t.cc===i.cc&&t.minEndPTS?t.start+(t.minEndPTS-t.start):t.start+t.duration:Math.max(t.start-i.duration,0)}function u(t,i,n,s,a,o){s-n<=0&&(e.logger.warn("Fragment should have a positive duration",i),s=n+i.duration,o=a+i.duration);var u=n,c=s,f=i.startPTS,l=i.endPTS;if(Object(r.isFiniteNumber)(f)){var v=Math.abs(f-n);i.deltaPTS=Object(r.isFiniteNumber)(i.deltaPTS)?Math.max(v,i.deltaPTS):v,u=Math.max(n,f),n=Math.min(n,f),a=Math.min(a,i.startDTS),c=Math.min(s,l),s=Math.max(s,l),o=Math.max(o,i.endDTS)}i.duration=s-n;var d=n-i.start;i.appendedPTS=s,i.start=i.startPTS=n,i.maxStartPTS=u,i.startDTS=a,i.endPTS=s,i.minEndPTS=c,i.endDTS=o;var m,p=i.sn;if(!t||p<t.startSN||p>t.endSN)return 0;var g=p-t.startSN,b=t.fragments;for(b[g]=i,m=g;m>0;m--)h(b[m],b[m-1]);for(m=g;m<b.length-1;m++)h(b[m],b[m+1]);return t.fragmentHint&&h(b[b.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,d}function c(t,i){for(var n=null,s=t.fragments,a=s.length-1;a>=0;a--){var o=s[a].initSegment;if(o){n=o;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var h,c=0;if(l(t,i,(function(t,e){t.relurl&&(c=t.cc-e.cc),Object(r.isFiniteNumber)(t.startPTS)&&Object(r.isFiniteNumber)(t.endPTS)&&(e.start=e.startPTS=t.startPTS,e.startDTS=t.startDTS,e.appendedPTS=t.appendedPTS,e.maxStartPTS=t.maxStartPTS,e.endPTS=t.endPTS,e.endDTS=t.endDTS,e.minEndPTS=t.minEndPTS,e.duration=t.endPTS-t.startPTS,e.duration&&(h=e),i.PTSKnown=i.alignedSliding=!0),e.elementaryStreams=t.elementaryStreams,e.loader=t.loader,e.stats=t.stats,e.urlId=t.urlId,t.initSegment&&(e.initSegment=t.initSegment,n=t.initSegment)})),n&&(i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments).forEach((function(t){var i;t.initSegment&&t.initSegment.relurl!==(null===(i=n)||void 0===i?void 0:i.relurl)||(t.initSegment=n)})),i.skippedSegments&&(i.deltaUpdateFailed=i.fragments.some((function(t){return!t})),i.deltaUpdateFailed)){e.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=i.skippedSegments;d--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}var m=i.fragments;if(c){e.logger.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<m.length;p++)m[p].cc+=c}i.skippedSegments&&(i.startCC=i.fragments[0].cc),f(t.partList,i.partList,(function(t,i){i.elementaryStreams=t.elementaryStreams,i.stats=t.stats})),h?u(i,h,h.startPTS,h.endPTS,h.startDTS,h.endDTS):v(t,i),m.length&&(i.totalduration=i.edge-m[0].start),i.driftStartTime=t.driftStartTime,i.driftStart=t.driftStart;var g=i.advancedDateTime;if(i.advanced&&g){var b=i.edge;i.driftStart||(i.driftStartTime=g,i.driftStart=b),i.driftEndTime=g,i.driftEnd=b}else i.driftEndTime=t.driftEndTime,i.driftEnd=t.driftEnd,i.advancedDateTime=t.advancedDateTime}function f(t,i,n){if(t&&i)for(var r=0,e=0,s=t.length;e<=s;e++){var a=t[e],o=i[e+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?n(a,o):r--}}function l(t,i,n){for(var r=i.skippedSegments,e=Math.max(t.startSN,i.startSN)-i.startSN,s=(t.fragmentHint?1:0)+(r?i.endSN:Math.min(t.endSN,i.endSN))-i.startSN,a=i.startSN-t.startSN,o=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,h=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e;u<=s;u++){var c=h[a+u],f=o[u];r&&!f&&u<r&&(f=i.fragments[u]=c),c&&f&&n(c,f)}}function v(t,i){var n=i.startSN+i.skippedSegments-t.startSN,r=t.fragments;n<0||n>=r.length||d(i,r[n].start)}function d(t,i){if(i){for(var n=t.fragments,r=t.skippedSegments;r<n.length;r++)n[r].start+=i;t.fragmentHint&&(t.fragmentHint.start+=i)}}function m(t,i){var n,r=1e3*t.levelTargetDuration,e=r/2,s=t.age,a=s>0&&s<3*r,o=i.loading.end-i.loading.start,h=t.availabilityDelay;if(!1===t.updated)if(a){var u=333*t.misses;n=Math.max(Math.min(e,2*o),u),t.availabilityDelay=(t.availabilityDelay||0)+n}else n=e;else a?(h=Math.min(h||r/2,s),t.availabilityDelay=h,n=h+r-s):n=r-o;return Math.round(n)}function p(t,i,n){if(!t||!t.details)return null;var r=t.details,e=r.fragments[i-r.startSN];return e||((e=r.fragmentHint)&&e.sn===i?e:i<r.startSN&&n&&n.sn===i?n:null)}function g(t,i,n){if(!t||!t.details)return null;var r=t.details.partList;if(r)for(var e=r.length;e--;){var s=r[e];if(s.index===n&&s.fragment.sn===i)return s}return null}},"./src/controller/stream-controller.ts":
90
90
  /*!*********************************************!*\
91
91
  !*** ./src/controller/stream-controller.ts ***!
92
92
  \*********************************************/
93
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return k}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts");var s=r(/*! ../is-supported */"./src/is-supported.ts");var a=r(/*! ../events */"./src/events.ts");var u=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var f=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var h=r(/*! ../types/loader */"./src/types/loader.ts");var o=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var v=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts");var l=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts");var c=r(/*! ./gap-controller */"./src/controller/gap-controller.ts");var d=r(/*! ../errors */"./src/errors.ts");var m=r(/*! ../utils/logger */"./src/utils/logger.ts");function p(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function g(t,i,r){if(i)p(t.prototype,i);if(r)p(t,r);return t}function b(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;y(t,i)}function y(t,i){y=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return y(t,i)}var w=100;var k=function(t){b(i,t);function i(i,r){var e;e=t.call(this,i,r,"[stream-controller]")||this;e.audioCodecSwap=false;e.gapController=null;e.level=-1;e._forceStartLoad=false;e.altAudio=false;e.audioOnly=false;e.fragPlaying=null;e.onvplaying=null;e.onvseeked=null;e.fragLastKbps=0;e.stalled=false;e.couldBacktrack=false;e.audioCodecSwitch=false;e.videoBuffer=null;e._registerListeners();return e}var r=i.prototype;r._registerListeners=function t(){var i=this.hls;i.on(a["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(a["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(a["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(a["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(a["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.on(a["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(a["Events"].FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this);i.on(a["Events"].ERROR,this.onError,this);i.on(a["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);i.on(a["Events"].AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);i.on(a["Events"].BUFFER_CREATED,this.onBufferCreated,this);i.on(a["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);i.on(a["Events"].LEVELS_UPDATED,this.onLevelsUpdated,this);i.on(a["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r._unregisterListeners=function t(){var i=this.hls;i.off(a["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(a["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(a["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(a["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(a["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(a["Events"].FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this);i.off(a["Events"].ERROR,this.onError,this);i.off(a["Events"].AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this);i.off(a["Events"].AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this);i.off(a["Events"].BUFFER_CREATED,this.onBufferCreated,this);i.off(a["Events"].BUFFER_FLUSHED,this.onBufferFlushed,this);i.off(a["Events"].LEVELS_UPDATED,this.onLevelsUpdated,this);i.off(a["Events"].FRAG_BUFFERED,this.onFragBuffered,this)};r.onHandlerDestroying=function t(){this._unregisterListeners();this.onMediaDetaching()};r.startLoad=function t(i){if(this.levels){var r=this.lastCurrentTime,e=this.hls;this.stopLoad();this.setInterval(w);this.level=-1;this.fragLoadError=0;if(!this.startFragRequested){var s=e.startLevel;if(s===-1){if(e.config.testBandwidth){s=0;this.bitrateTest=true}else{s=e.nextAutoLevel}}this.level=e.nextLoadLevel=s;this.loadedmetadata=false}if(r>0&&i===-1){this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3));i=r}this.state=n["State"].IDLE;this.nextLoadPosition=this.startPosition=this.lastCurrentTime=i;this.tick()}else{this._forceStartLoad=true;this.state=n["State"].STOPPED}};r.stopLoad=function i(){this._forceStartLoad=false;t.prototype.stopLoad.call(this)};r.doTick=function t(){switch(this.state){case n["State"].IDLE:this.doTickIdle();break;case n["State"].WAITING_LEVEL:{var i;var r=this.levels,e=this.level;var s=r===null||r===void 0?void 0:(i=r[e])===null||i===void 0?void 0:i.details;if(s&&(!s.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(s)){break}this.state=n["State"].IDLE;break}break}case n["State"].FRAG_LOADING_WAITING_RETRY:{var a;var u=self.performance.now();var f=this.retryDate;if(!f||u>=f||(a=this.media)!==null&&a!==void 0&&a.seeking){this.log("retryDate reached, switch back to IDLE state");this.state=n["State"].IDLE}}break}this.onTickEnd()};r.onTickEnd=function i(){t.prototype.onTickEnd.call(this);this.checkBuffer();this.checkFragmentChanged()};r.doTickIdle=function t(){var i,r;var e=this.hls,s=this.levelLastLoaded,u=this.levels,v=this.media;var l=e.config,c=e.nextLoadLevel;if(s===null||!v&&(this.startFragRequested||!l.startFragPrefetch)){return}if(this.altAudio&&this.audioOnly){return}if(!u||!u[c]){return}var d=u[c];this.level=e.nextLoadLevel=c;var m=d.details;if(!m||this.state===n["State"].WAITING_LEVEL||m.live&&this.levelLastLoaded!==c){this.state=n["State"].WAITING_LEVEL;return}var p=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:v,h["PlaylistLevelType"].MAIN);if(p===null){return}var g=p.len;var b=this.getMaxBufferLength(d.maxBitrate);if(g>=b){return}if(this._streamEnded(p,m)){var y={};if(this.altAudio){y.type="video"}this.hls.trigger(a["Events"].BUFFER_EOS,y);this.state=n["State"].ENDED;return}var w=p.end;var k=this.getNextFragment(w,m);if(this.couldBacktrack&&!this.fragPrevious&&k&&k.sn!=="initSegment"){var T=k.sn-m.startSN;if(T>1){k=m.fragments[T-1];this.fragmentTracker.removeFragment(k)}}if(k&&this.fragmentTracker.getState(k)===f["FragmentState"].OK&&this.nextLoadPosition>w){var O=this.audioOnly&&!this.altAudio?o["ElementaryStreamTypes"].AUDIO:o["ElementaryStreamTypes"].VIDEO;this.afterBufferFlushed(v,O,h["PlaylistLevelType"].MAIN);k=this.getNextFragment(this.nextLoadPosition,m)}if(!k){return}if(k.initSegment&&!k.initSegment.data&&!this.bitrateTest){k=k.initSegment}if(((i=k.decryptdata)===null||i===void 0?void 0:i.keyFormat)==="identity"&&!((r=k.decryptdata)!==null&&r!==void 0&&r.key)){this.loadKey(k,m)}else{this.loadFragment(k,m,w)}};r.loadFragment=function i(r,e,n){var s;var a=this.fragmentTracker.getState(r);this.fragCurrent=r;if(a===f["FragmentState"].BACKTRACKED){var u=this.fragmentTracker.getBacktrackData(r);if(u){this._handleFragmentLoadProgress(u);this._handleFragmentLoadComplete(u);return}else{a=f["FragmentState"].NOT_LOADED}}if(a===f["FragmentState"].NOT_LOADED||a===f["FragmentState"].PARTIAL){if(r.sn==="initSegment"){this._loadInitSegment(r)}else if(this.bitrateTest){r.bitrateTest=true;this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered");this._loadBitrateTestFrag(r)}else{this.startFragRequested=true;t.prototype.loadFragment.call(this,r,e,n)}}else if(a===f["FragmentState"].APPENDING){if(this.reduceMaxBufferLength(r.duration)){this.fragmentTracker.removeFragment(r)}}else if(((s=this.media)===null||s===void 0?void 0:s.buffered.length)===0){this.fragmentTracker.removeAllFragments()}};r.getAppendedFrag=function t(i){var r=this.fragmentTracker.getAppendedFrag(i,h["PlaylistLevelType"].MAIN);if(r&&"fragment"in r){return r.fragment}return r};r.getBufferedFrag=function t(i){return this.fragmentTracker.getBufferedFrag(i,h["PlaylistLevelType"].MAIN)};r.followingBufferedFrag=function t(i){if(i){return this.getBufferedFrag(i.end+.5)}return null};r.immediateLevelSwitch=function t(){this.abortCurrentFrag();this.flushMainBuffer(0,Number.POSITIVE_INFINITY)};r.nextLevelSwitch=function t(){var i=this.levels,r=this.media;if(r!==null&&r!==void 0&&r.readyState){var e;var n=this.getAppendedFrag(r.currentTime);if(n&&n.start>1){this.flushMainBuffer(0,n.start-1)}if(!r.paused&&i){var s=this.hls.nextLoadLevel;var a=i[s];var u=this.fragLastKbps;if(u&&this.fragCurrent){e=this.fragCurrent.duration*a.maxBitrate/(1e3*u)+1}else{e=0}}else{e=0}var f=this.getBufferedFrag(r.currentTime+e);if(f){var h=this.followingBufferedFrag(f);if(h){this.abortCurrentFrag();var o=h.maxStartPTS?h.maxStartPTS:h.start;var v=h.duration;var l=Math.max(f.end,o+Math.min(Math.max(v-this.config.maxFragLookUpTolerance,v*.5),v*.75));this.flushMainBuffer(l,Number.POSITIVE_INFINITY)}}}};r.abortCurrentFrag=function t(){var i=this.fragCurrent;this.fragCurrent=null;if(i!==null&&i!==void 0&&i.loader){i.loader.abort()}if(this.state===n["State"].KEY_LOADING){this.state=n["State"].IDLE}this.nextLoadPosition=this.getLoadPosition()};r.flushMainBuffer=function i(r,e){t.prototype.flushMainBuffer.call(this,r,e,this.altAudio?"video":null)};r.onMediaAttached=function i(r,e){t.prototype.onMediaAttached.call(this,r,e);var n=e.media;this.onvplaying=this.onMediaPlaying.bind(this);this.onvseeked=this.onMediaSeeked.bind(this);n.addEventListener("playing",this.onvplaying);n.addEventListener("seeked",this.onvseeked);this.gapController=new c["default"](this.config,n,this.fragmentTracker,this.hls)};r.onMediaDetaching=function i(){var r=this.media;if(r){r.removeEventListener("playing",this.onvplaying);r.removeEventListener("seeked",this.onvseeked);this.onvplaying=this.onvseeked=null;this.videoBuffer=null}this.fragPlaying=null;if(this.gapController){this.gapController.destroy();this.gapController=null}t.prototype.onMediaDetaching.call(this)};r.onMediaPlaying=function t(){this.tick()};r.onMediaSeeked=function t(){var i=this.media;var r=i?i.currentTime:null;if(Object(e["isFiniteNumber"])(r)){this.log("Media seeked to "+r.toFixed(3))}this.tick()};r.onManifestLoading=function t(){this.log("Trigger BUFFER_RESET");this.hls.trigger(a["Events"].BUFFER_RESET,undefined);this.fragmentTracker.removeAllFragments();this.couldBacktrack=this.stalled=false;this.startPosition=this.lastCurrentTime=0;this.fragPlaying=null};r.onManifestParsed=function t(i,r){var e=false;var n=false;var a;r.levels.forEach((function(t){a=t.audioCodec;if(a){if(a.indexOf("mp4a.40.2")!==-1){e=true}if(a.indexOf("mp4a.40.5")!==-1){n=true}}}));this.audioCodecSwitch=e&&n&&!Object(s["changeTypeSupported"])();if(this.audioCodecSwitch){this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC")}this.levels=r.levels;this.startFragRequested=false};r.onLevelLoading=function t(i,r){var e=this.levels;if(!e||this.state!==n["State"].IDLE){return}var s=e[r.level];if(!s.details||s.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(s.details)){this.state=n["State"].WAITING_LEVEL}};r.onLevelLoaded=function t(i,r){var e;var s=this.levels;var u=r.level;var f=r.details;var h=f.totalduration;if(!s){this.warn("Levels were reset while loading level "+u);return}this.log("Level "+u+" loaded ["+f.startSN+","+f.endSN+"], cc ["+f.startCC+", "+f.endCC+"] duration:"+h);var o=this.fragCurrent;if(o&&(this.state===n["State"].FRAG_LOADING||this.state===n["State"].FRAG_LOADING_WAITING_RETRY)){if(o.level!==r.level&&o.loader){this.state=n["State"].IDLE;o.loader.abort()}}var v=s[u];var l=0;if(f.live||(e=v.details)!==null&&e!==void 0&&e.live){if(!f.fragments[0]){f.deltaUpdateFailed=true}if(f.deltaUpdateFailed){return}l=this.alignPlaylists(f,v.details)}v.details=f;this.levelLastLoaded=u;this.hls.trigger(a["Events"].LEVEL_UPDATED,{details:f,level:u});if(this.state===n["State"].WAITING_LEVEL){if(this.waitForCdnTuneIn(f)){return}this.state=n["State"].IDLE}if(!this.startFragRequested){this.setStartPosition(f,l)}else if(f.live){this.synchronizeToLiveEdge(f)}this.tick()};r._handleFragmentLoadProgress=function t(i){var r;var e=i.frag,n=i.part,s=i.payload;var a=this.levels;if(!a){this.warn("Levels were reset while fragment load was in progress. Fragment "+e.sn+" of level "+e.level+" will not be buffered");return}var u=a[e.level];var f=u.details;if(!f){this.warn("Dropping fragment "+e.sn+" of level "+e.level+" after level details were reset");return}var o=u.videoCodec;var c=f.PTSKnown||!f.live;var d=(r=e.initSegment)===null||r===void 0?void 0:r.data;var m=this._getAudioCodec(u);var p=this.transmuxer=this.transmuxer||new v["default"](this.hls,h["PlaylistLevelType"].MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this));var g=n?n.index:-1;var b=g!==-1;var y=new l["ChunkMetadata"](e.level,e.sn,e.stats.chunkCount,s.byteLength,g,b);var w=this.initPTS[e.cc];p.push(s,d,m,o,e,n,f.totalduration,c,y,w)};r.onAudioTrackSwitching=function t(i,r){var e=this.altAudio;var n=!!r.url;var s=r.id;if(!n){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading");this.mediaBuffer=this.media;var u=this.fragCurrent;if(u!==null&&u!==void 0&&u.loader){this.log("Switching to main audio track, cancel main fragment load");u.loader.abort()}this.resetTransmuxer();this.resetLoadingState()}else if(this.audioOnly){this.resetTransmuxer()}var f=this.hls;if(e){f.trigger(a["Events"].BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}f.trigger(a["Events"].AUDIO_TRACK_SWITCHED,{id:s})}};r.onAudioTrackSwitched=function t(i,r){var e=r.id;var n=!!this.hls.audioTracks[e].url;if(n){var s=this.videoBuffer;if(s&&this.mediaBuffer!==s){this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading");this.mediaBuffer=s}}this.altAudio=n;this.tick()};r.onBufferCreated=function t(i,r){var e=r.tracks;var n;var s;var a=false;for(var u in e){var f=e[u];if(f.id==="main"){s=u;n=f;if(u==="video"){var h=e[u];if(h){this.videoBuffer=h.buffer}}}else{a=true}}if(a&&n){this.log("Alternate track found, use "+s+".buffered to schedule main fragment loading");this.mediaBuffer=n.buffer}else{this.mediaBuffer=this.media}};r.onFragBuffered=function t(i,r){var e=r.frag,s=r.part;if(e&&e.type!==h["PlaylistLevelType"].MAIN){return}if(this.fragContextChanged(e)){this.warn("Fragment "+e.sn+(s?" p: "+s.index:"")+" of level "+e.level+" finished buffering, but was aborted. state: "+this.state);if(this.state===n["State"].PARSED){this.state=n["State"].IDLE}return}var a=s?s.stats:e.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first));if(e.sn!=="initSegment"){this.fragPrevious=e}this.fragBufferedComplete(e,s)};r.onError=function t(i,r){switch(r.details){case d["ErrorDetails"].FRAG_LOAD_ERROR:case d["ErrorDetails"].FRAG_LOAD_TIMEOUT:case d["ErrorDetails"].KEY_LOAD_ERROR:case d["ErrorDetails"].KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(h["PlaylistLevelType"].MAIN,r);break;case d["ErrorDetails"].LEVEL_LOAD_ERROR:case d["ErrorDetails"].LEVEL_LOAD_TIMEOUT:if(this.state!==n["State"].ERROR){if(r.fatal){this.warn(""+r.details);this.state=n["State"].ERROR}else{if(!r.levelRetry&&this.state===n["State"].WAITING_LEVEL){this.state=n["State"].IDLE}}}break;case d["ErrorDetails"].BUFFER_FULL_ERROR:if(r.parent==="main"&&(this.state===n["State"].PARSING||this.state===n["State"].PARSED)){var e=true;var s=this.getFwdBufferInfo(this.media,h["PlaylistLevelType"].MAIN);if(s&&s.len>.5){e=!this.reduceMaxBufferLength(s.len)}if(e){this.warn("buffer full error also media.currentTime is not buffered, flush main");this.immediateLevelSwitch()}this.resetLoadingState()}break}};r.checkBuffer=function t(){var i=this.media,r=this.gapController;if(!i||!r||!i.readyState){return}var e=u["BufferHelper"].getBuffered(i);if(!this.loadedmetadata&&e.length){this.loadedmetadata=true;this.seekToStartPos()}else{r.poll(this.lastCurrentTime)}this.lastCurrentTime=i.currentTime};r.onFragLoadEmergencyAborted=function t(){this.state=n["State"].IDLE;if(!this.loadedmetadata){this.startFragRequested=false;this.nextLoadPosition=this.startPosition}this.tickImmediate()};r.onBufferFlushed=function t(i,r){var e=r.type;if(e!==o["ElementaryStreamTypes"].AUDIO||this.audioOnly&&!this.altAudio){var n=(e===o["ElementaryStreamTypes"].VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(n,e,h["PlaylistLevelType"].MAIN)}};r.onLevelsUpdated=function t(i,r){this.levels=r.levels};r.swapAudioCodec=function t(){this.audioCodecSwap=!this.audioCodecSwap};r.seekToStartPos=function t(){var i=this.media;var r=i.currentTime;var e=this.startPosition;if(e>=0&&r<e){if(i.seeking){m["logger"].log("could not seek to "+e+", already seeking at "+r);return}var n=u["BufferHelper"].getBuffered(i);var s=n.length?n.start(0):0;var a=s-e;if(a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)){m["logger"].log("adjusting start position by "+a+" to match buffer start");e+=a;this.startPosition=e}this.log("seek to target start position "+e+" from current time "+r);i.currentTime=e}};r._getAudioCodec=function t(i){var r=this.config.defaultAudioCodec||i.audioCodec;if(this.audioCodecSwap&&r){this.log("Swapping audio codec");if(r.indexOf("mp4a.40.5")!==-1){r="mp4a.40.2"}else{r="mp4a.40.5"}}return r};r._loadBitrateTestFrag=function t(i){var r=this;this._doFragLoad(i).then((function(t){var e=r.hls;if(!t||e.nextLoadLevel||r.fragContextChanged(i)){return}r.fragLoadError=0;r.state=n["State"].IDLE;r.startFragRequested=false;r.bitrateTest=false;var s=i.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now();e.trigger(a["Events"].FRAG_LOADED,t)}))};r._handleTransmuxComplete=function t(i){var r;var s="main";var u=this.hls;var f=i.remuxResult,h=i.chunkMeta;var v=this.getCurrentContext(h);if(!v){this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered.");this.resetLiveStartWhenNotLoaded(h.level);return}var l=v.frag,c=v.part,d=v.level;var m=f.video,p=f.text,g=f.id3,b=f.initSegment;var y=this.altAudio?undefined:f.audio;if(this.fragContextChanged(l)){return}this.state=n["State"].PARSING;if(b){if(b.tracks){this._bufferInitSegment(d,b.tracks,l,h);u.trigger(a["Events"].FRAG_PARSING_INIT_SEGMENT,{frag:l,id:s,tracks:b.tracks})}var w=b.initPTS;var k=b.timescale;if(Object(e["isFiniteNumber"])(w)){this.initPTS[l.cc]=w;u.trigger(a["Events"].INIT_PTS_FOUND,{frag:l,id:s,initPTS:w,timescale:k})}}if(m&&f.independent!==false){if(d.details){var T=m.startPTS,O=m.endPTS,S=m.startDTS,E=m.endDTS;if(c){c.elementaryStreams[m.type]={startPTS:T,endPTS:O,startDTS:S,endDTS:E}}else{if(m.firstKeyFrame&&m.independent){this.couldBacktrack=true}if(m.dropped&&m.independent){var A=this.getLoadPosition()+this.config.maxBufferHole;if(A<T){this.backtrack(l);return}l.setElementaryStreamInfo(m.type,l.start,O,l.start,E,true)}}l.setElementaryStreamInfo(m.type,T,O,S,E);this.bufferFragmentData(m,l,c,h)}}else if(f.independent===false){this.backtrack(l);return}if(y){var M=y.startPTS,x=y.endPTS,j=y.startDTS,D=y.endDTS;if(c){c.elementaryStreams[o["ElementaryStreamTypes"].AUDIO]={startPTS:M,endPTS:x,startDTS:j,endDTS:D}}l.setElementaryStreamInfo(o["ElementaryStreamTypes"].AUDIO,M,x,j,D);this.bufferFragmentData(y,l,c,h)}if(g!==null&&g!==void 0&&(r=g.samples)!==null&&r!==void 0&&r.length){var L={frag:l,id:s,samples:g.samples};u.trigger(a["Events"].FRAG_PARSING_METADATA,L)}if(p){var I={frag:l,id:s,samples:p.samples};u.trigger(a["Events"].FRAG_PARSING_USERDATA,I)}};r._bufferInitSegment=function t(i,r,e,s){var u=this;if(this.state!==n["State"].PARSING){return}this.audioOnly=!!r.audio&&!r.video;if(this.altAudio&&!this.audioOnly){delete r.audio}var f=r.audio,h=r.video,o=r.audiovideo;if(f){var v=i.audioCodec;var l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){if(v){if(v.indexOf("mp4a.40.5")!==-1){v="mp4a.40.2"}else{v="mp4a.40.5"}}if(f.metadata.channelCount!==1&&l.indexOf("firefox")===-1){v="mp4a.40.5"}}if(l.indexOf("android")!==-1&&f.container!=="audio/mpeg"){v="mp4a.40.2";this.log("Android: force audio codec to "+v)}if(i.audioCodec&&i.audioCodec!==v){this.log('Swapping manifest audio codec "'+i.audioCodec+'" for "'+v+'"')}f.levelCodec=v;f.id="main";this.log("Init audio buffer, container:"+f.container+", codecs[selected/level/parsed]=["+(v||"")+"/"+(i.audioCodec||"")+"/"+f.codec+"]")}if(h){h.levelCodec=i.videoCodec;h.id="main";this.log("Init video buffer, container:"+h.container+", codecs[level/parsed]=["+(i.videoCodec||"")+"/"+h.codec+"]")}if(o){this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+(i.attrs.CODECS||"")+"/"+o.codec+"]")}this.hls.trigger(a["Events"].BUFFER_CODECS,r);Object.keys(r).forEach((function(t){var i=r[t];var n=i.initSegment;if(n!==null&&n!==void 0&&n.byteLength){u.hls.trigger(a["Events"].BUFFER_APPENDING,{type:t,data:n,frag:e,part:null,chunkMeta:s,parent:e.type})}}));this.tick()};r.backtrack=function t(i){this.couldBacktrack=true;this.resetTransmuxer();this.flushBufferGap(i);var r=this.fragmentTracker.backtrack(i);this.fragPrevious=null;this.nextLoadPosition=i.start;if(r){this.resetFragmentLoading(i)}else{this.state=n["State"].BACKTRACKING}};r.checkFragmentChanged=function t(){var i=this.media;var r=null;if(i&&i.readyState>1&&i.seeking===false){var e=i.currentTime;if(u["BufferHelper"].isBuffered(i,e)){r=this.getAppendedFrag(e)}else if(u["BufferHelper"].isBuffered(i,e+.1)){r=this.getAppendedFrag(e+.1)}if(r){var n=this.fragPlaying;var s=r.level;if(!n||r.sn!==n.sn||n.level!==s||r.urlId!==n.urlId){this.hls.trigger(a["Events"].FRAG_CHANGED,{frag:r});if(!n||n.level!==s){this.hls.trigger(a["Events"].LEVEL_SWITCHED,{level:s})}this.fragPlaying=r}}}};g(i,[{key:"nextLevel",get:function t(){var i=this.nextBufferedFrag;if(i){return i.level}else{return-1}}},{key:"currentLevel",get:function t(){var i=this.media;if(i){var r=this.getAppendedFrag(i.currentTime);if(r){return r.level}}return-1}},{key:"nextBufferedFrag",get:function t(){var i=this.media;if(i){var r=this.getAppendedFrag(i.currentTime);return this.followingBufferedFrag(r)}else{return null}}},{key:"forceStartLoad",get:function t(){return this._forceStartLoad}}]);return i}(n["default"])},"./src/controller/subtitle-stream-controller.ts":
93
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return b}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=n(/*! ../is-supported */"./src/is-supported.ts"),a=n(/*! ../events */"./src/events.ts"),o=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),h=n(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts"),c=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),f=n(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),l=n(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),v=n(/*! ./gap-controller */"./src/controller/gap-controller.ts"),d=n(/*! ../errors */"./src/errors.ts"),m=n(/*! ../utils/logger */"./src/utils/logger.ts");function p(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function g(t,i){return g=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},g(t,i)}var b=function(t){var i,n;function b(i,n){var r;return(r=t.call(this,i,n,"[stream-controller]")||this).audioCodecSwap=!1,r.gapController=null,r.level=-1,r._forceStartLoad=!1,r.altAudio=!1,r.audioOnly=!1,r.fragPlaying=null,r.onvplaying=null,r.onvseeked=null,r.fragLastKbps=0,r.stalled=!1,r.couldBacktrack=!1,r.audioCodecSwitch=!1,r.videoBuffer=null,r._registerListeners(),r}n=t,(i=b).prototype=Object.create(n.prototype),i.prototype.constructor=i,g(i,n);var y,w,k=b.prototype;return k._registerListeners=function(){var t=this.hls;t.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(a.Events.ERROR,this.onError,this),t.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},k._unregisterListeners=function(){var t=this.hls;t.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(a.Events.ERROR,this.onError,this),t.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},k.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},k.startLoad=function(t){if(this.levels){var i=this.lastCurrentTime,n=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var r=n.startLevel;-1===r&&(n.config.testBandwidth?(r=0,this.bitrateTest=!0):r=n.nextAutoLevel),this.level=n.nextLoadLevel=r,this.loadedmetadata=!1}i>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),t=i),this.state=e.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=e.State.STOPPED},k.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},k.doTick=function(){switch(this.state){case e.State.IDLE:this.doTickIdle();break;case e.State.WAITING_LEVEL:var t,i=this.levels,n=null==i||null===(t=i[this.level])||void 0===t?void 0:t.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=e.State.IDLE;break}break;case e.State.FRAG_LOADING_WAITING_RETRY:var r,s=self.performance.now(),a=this.retryDate;(!a||s>=a||null!==(r=this.media)&&void 0!==r&&r.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=e.State.IDLE)}this.onTickEnd()},k.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},k.doTickIdle=function(){var t,i,n=this.hls,r=this.levels,s=this.media,o=n.nextLoadLevel;if(null!==this.levelLastLoaded&&(s||!this.startFragRequested&&n.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&r&&r[o]){var f=r[o];this.level=n.nextLoadLevel=o;var l=f.details;if(!l||this.state===e.State.WAITING_LEVEL||l.live&&this.levelLastLoaded!==o)this.state=e.State.WAITING_LEVEL;else{var v=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:s,u.PlaylistLevelType.MAIN);if(null!==v&&!(v.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(v,l)){var d={};return this.altAudio&&(d.type="video"),this.hls.trigger(a.Events.BUFFER_EOS,d),void(this.state=e.State.ENDED)}var m=v.end,p=this.getNextFragment(m,l);if(this.couldBacktrack&&!this.fragPrevious&&p&&"initSegment"!==p.sn){var g=p.sn-l.startSN;g>1&&this.fragmentTracker.removeFragment(p=l.fragments[g-1])}p&&this.fragmentTracker.getState(p)===h.FragmentState.OK&&this.nextLoadPosition>m&&(this.afterBufferFlushed(s,this.audioOnly&&!this.altAudio?c.ElementaryStreamTypes.AUDIO:c.ElementaryStreamTypes.VIDEO,u.PlaylistLevelType.MAIN),p=this.getNextFragment(this.nextLoadPosition,l)),p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),"identity"!==(null===(t=p.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(i=p.decryptdata)&&void 0!==i&&i.key?this.loadFragment(p,l,m):this.loadKey(p,l))}}}},k.loadFragment=function(i,n,r){var e,s=this.fragmentTracker.getState(i);if(this.fragCurrent=i,s===h.FragmentState.BACKTRACKED){var a=this.fragmentTracker.getBacktrackData(i);if(a)return this._handleFragmentLoadProgress(a),void this._handleFragmentLoadComplete(a);s=h.FragmentState.NOT_LOADED}s===h.FragmentState.NOT_LOADED||s===h.FragmentState.PARTIAL?"initSegment"===i.sn?this._loadInitSegment(i):this.bitrateTest?(i.bitrateTest=!0,this.log("Fragment "+i.sn+" of level "+i.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(i)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,n,r)):s===h.FragmentState.APPENDING?this.reduceMaxBufferLength(i.duration)&&this.fragmentTracker.removeFragment(i):0===(null===(e=this.media)||void 0===e?void 0:e.buffered.length)&&this.fragmentTracker.removeAllFragments()},k.getAppendedFrag=function(t){var i=this.fragmentTracker.getAppendedFrag(t,u.PlaylistLevelType.MAIN);return i&&"fragment"in i?i.fragment:i},k.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,u.PlaylistLevelType.MAIN)},k.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},k.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},k.nextLevelSwitch=function(){var t=this.levels,i=this.media;if(null!=i&&i.readyState){var n,r=this.getAppendedFrag(i.currentTime);if(r&&r.start>1&&this.flushMainBuffer(0,r.start-1),!i.paused&&t){var e=this.fragLastKbps;n=e&&this.fragCurrent?this.fragCurrent.duration*t[this.hls.nextLoadLevel].maxBitrate/(1e3*e)+1:0}else n=0;var s=this.getBufferedFrag(i.currentTime+n);if(s){var a=this.followingBufferedFrag(s);if(a){this.abortCurrentFrag();var o=a.duration,h=Math.max(s.end,(a.maxStartPTS?a.maxStartPTS:a.start)+Math.min(Math.max(o-this.config.maxFragLookUpTolerance,.5*o),.75*o));this.flushMainBuffer(h,Number.POSITIVE_INFINITY)}}}},k.abortCurrentFrag=function(){var t=this.fragCurrent;this.fragCurrent=null,null!=t&&t.loader&&t.loader.abort(),this.state===e.State.KEY_LOADING&&(this.state=e.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},k.flushMainBuffer=function(i,n){t.prototype.flushMainBuffer.call(this,i,n,this.altAudio?"video":null)},k.onMediaAttached=function(i,n){t.prototype.onMediaAttached.call(this,i,n);var r=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new v.default(this.config,r,this.fragmentTracker,this.hls)},k.onMediaDetaching=function(){var i=this.media;i&&(i.removeEventListener("playing",this.onvplaying),i.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},k.onMediaPlaying=function(){this.tick()},k.onMediaSeeked=function(){var t=this.media,i=t?t.currentTime:null;Object(r.isFiniteNumber)(i)&&this.log("Media seeked to "+i.toFixed(3)),this.tick()},k.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(a.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},k.onManifestParsed=function(t,i){var n,r=!1,e=!1;i.levels.forEach((function(t){(n=t.audioCodec)&&(-1!==n.indexOf("mp4a.40.2")&&(r=!0),-1!==n.indexOf("mp4a.40.5")&&(e=!0))})),this.audioCodecSwitch=r&&e&&!Object(s.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=i.levels,this.startFragRequested=!1},k.onLevelLoading=function(t,i){var n=this.levels;if(n&&this.state===e.State.IDLE){var r=n[i.level];(!r.details||r.details.live&&this.levelLastLoaded!==i.level||this.waitForCdnTuneIn(r.details))&&(this.state=e.State.WAITING_LEVEL)}},k.onLevelLoaded=function(t,i){var n,r=this.levels,s=i.level,o=i.details;if(r){this.log("Level "+s+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+o.totalduration);var h=this.fragCurrent;!h||this.state!==e.State.FRAG_LOADING&&this.state!==e.State.FRAG_LOADING_WAITING_RETRY||h.level!==i.level&&h.loader&&(this.state=e.State.IDLE,h.loader.abort());var u=r[s],c=0;if(o.live||null!==(n=u.details)&&void 0!==n&&n.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;c=this.alignPlaylists(o,u.details)}if(u.details=o,this.levelLastLoaded=s,this.hls.trigger(a.Events.LEVEL_UPDATED,{details:o,level:s}),this.state===e.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=e.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,c),this.tick()}else this.warn("Levels were reset while loading level "+s)},k._handleFragmentLoadProgress=function(t){var i,n=t.frag,r=t.part,e=t.payload,s=this.levels;if(s){var a=s[n.level],o=a.details;if(o){var h=a.videoCodec,c=o.PTSKnown||!o.live,v=null===(i=n.initSegment)||void 0===i?void 0:i.data,d=this._getAudioCodec(a),m=this.transmuxer=this.transmuxer||new f.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=r?r.index:-1,g=new l.ChunkMetadata(n.level,n.sn,n.stats.chunkCount,e.byteLength,p,-1!==p);m.push(e,v,d,h,n,r,o.totalduration,c,g,this.initPTS[n.cc])}else this.warn("Dropping fragment "+n.sn+" of level "+n.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+n.sn+" of level "+n.level+" will not be buffered")},k.onAudioTrackSwitching=function(t,i){var n=this.altAudio,r=i.id;if(!i.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var e=this.fragCurrent;null!=e&&e.loader&&(this.log("Switching to main audio track, cancel main fragment load"),e.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var s=this.hls;n&&s.trigger(a.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),s.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:r})}},k.onAudioTrackSwitched=function(t,i){var n=!!this.hls.audioTracks[i.id].url;if(n){var r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r)}this.altAudio=n,this.tick()},k.onBufferCreated=function(t,i){var n,r,e=i.tracks,s=!1;for(var a in e){var o=e[a];if("main"===o.id){if(r=a,n=o,"video"===a){var h=e[a];h&&(this.videoBuffer=h.buffer)}}else s=!0}s&&n?(this.log("Alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media},k.onFragBuffered=function(t,i){var n=i.frag,r=i.part;if(!n||n.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(n))return this.warn("Fragment "+n.sn+(r?" p: "+r.index:"")+" of level "+n.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===e.State.PARSED&&(this.state=e.State.IDLE));var s=r?r.stats:n.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==n.sn&&(this.fragPrevious=n),this.fragBufferedComplete(n,r)}},k.onError=function(t,i){switch(i.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,i);break;case d.ErrorDetails.LEVEL_LOAD_ERROR:case d.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==e.State.ERROR&&(i.fatal?(this.warn(""+i.details),this.state=e.State.ERROR):i.levelRetry||this.state!==e.State.WAITING_LEVEL||(this.state=e.State.IDLE));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if("main"===i.parent&&(this.state===e.State.PARSING||this.state===e.State.PARSED)){var n=!0,r=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);r&&r.len>.5&&(n=!this.reduceMaxBufferLength(r.len)),n&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},k.checkBuffer=function(){var t=this.media,i=this.gapController;if(t&&i&&t.readyState){var n=o.BufferHelper.getBuffered(t);!this.loadedmetadata&&n.length?(this.loadedmetadata=!0,this.seekToStartPos()):i.poll(this.lastCurrentTime),this.lastCurrentTime=t.currentTime}},k.onFragLoadEmergencyAborted=function(){this.state=e.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},k.onBufferFlushed=function(t,i){var n=i.type;(n!==c.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio)&&this.afterBufferFlushed((n===c.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media,n,u.PlaylistLevelType.MAIN)},k.onLevelsUpdated=function(t,i){this.levels=i.levels},k.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},k.seekToStartPos=function(){var t=this.media,i=t.currentTime,n=this.startPosition;if(n>=0&&i<n){if(t.seeking)return void m.logger.log("could not seek to "+n+", already seeking at "+i);var r=o.BufferHelper.getBuffered(t),e=(r.length?r.start(0):0)-n;e>0&&(e<this.config.maxBufferHole||e<this.config.maxFragLookUpTolerance)&&(m.logger.log("adjusting start position by "+e+" to match buffer start"),this.startPosition=n+=e),this.log("seek to target start position "+n+" from current time "+i),t.currentTime=n}},k._getAudioCodec=function(t){var i=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&i&&(this.log("Swapping audio codec"),i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),i},k._loadBitrateTestFrag=function(t){var i=this;this._doFragLoad(t).then((function(n){var r=i.hls;if(n&&!r.nextLoadLevel&&!i.fragContextChanged(t)){i.fragLoadError=0,i.state=e.State.IDLE,i.startFragRequested=!1,i.bitrateTest=!1;var s=t.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),r.trigger(a.Events.FRAG_LOADED,n)}}))},k._handleTransmuxComplete=function(t){var i,n="main",s=this.hls,o=t.remuxResult,h=t.chunkMeta,u=this.getCurrentContext(h);if(!u)return this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(h.level);var f=u.frag,l=u.part,v=u.level,d=o.video,m=o.text,p=o.id3,g=o.initSegment,b=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(f)){if(this.state=e.State.PARSING,g){g.tracks&&(this._bufferInitSegment(v,g.tracks,f,h),s.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:f,id:n,tracks:g.tracks}));var y=g.initPTS,w=g.timescale;Object(r.isFiniteNumber)(y)&&(this.initPTS[f.cc]=y,s.trigger(a.Events.INIT_PTS_FOUND,{frag:f,id:n,initPTS:y,timescale:w}))}if(d&&!1!==o.independent){if(v.details){var k=d.startPTS,T=d.endPTS,O=d.startDTS,S=d.endDTS;if(l)l.elementaryStreams[d.type]={startPTS:k,endPTS:T,startDTS:O,endDTS:S};else if(d.firstKeyFrame&&d.independent&&(this.couldBacktrack=!0),d.dropped&&d.independent){if(this.getLoadPosition()+this.config.maxBufferHole<k)return void this.backtrack(f);f.setElementaryStreamInfo(d.type,f.start,T,f.start,S,!0)}f.setElementaryStreamInfo(d.type,k,T,O,S),this.bufferFragmentData(d,f,l,h)}}else if(!1===o.independent)return void this.backtrack(f);if(b){var E=b.startPTS,A=b.endPTS,M=b.startDTS,x=b.endDTS;l&&(l.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:E,endPTS:A,startDTS:M,endDTS:x}),f.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,E,A,M,x),this.bufferFragmentData(b,f,l,h)}null!=p&&null!==(i=p.samples)&&void 0!==i&&i.length&&s.trigger(a.Events.FRAG_PARSING_METADATA,{frag:f,id:n,samples:p.samples}),m&&s.trigger(a.Events.FRAG_PARSING_USERDATA,{frag:f,id:n,samples:m.samples})}},k._bufferInitSegment=function(t,i,n,r){var s=this;if(this.state===e.State.PARSING){this.audioOnly=!!i.audio&&!i.video,this.altAudio&&!this.audioOnly&&delete i.audio;var o=i.audio,h=i.video,u=i.audiovideo;if(o){var c=t.audioCodec,f=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=-1!==c.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===f.indexOf("firefox")&&(c="mp4a.40.5")),-1!==f.indexOf("android")&&"audio/mpeg"!==o.container&&this.log("Android: force audio codec to "+(c="mp4a.40.2")),t.audioCodec&&t.audioCodec!==c&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+c+'"'),o.levelCodec=c,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(t.audioCodec||"")+"/"+o.codec+"]")}h&&(h.levelCodec=t.videoCodec,h.id="main",this.log("Init video buffer, container:"+h.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+h.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,i),Object.keys(i).forEach((function(t){var e=i[t].initSegment;null!=e&&e.byteLength&&s.hls.trigger(a.Events.BUFFER_APPENDING,{type:t,data:e,frag:n,part:null,chunkMeta:r,parent:n.type})})),this.tick()}},k.backtrack=function(t){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(t);var i=this.fragmentTracker.backtrack(t);this.fragPrevious=null,this.nextLoadPosition=t.start,i?this.resetFragmentLoading(t):this.state=e.State.BACKTRACKING},k.checkFragmentChanged=function(){var t=this.media,i=null;if(t&&t.readyState>1&&!1===t.seeking){var n=t.currentTime;if(o.BufferHelper.isBuffered(t,n)?i=this.getAppendedFrag(n):o.BufferHelper.isBuffered(t,n+.1)&&(i=this.getAppendedFrag(n+.1)),i){var r=this.fragPlaying,e=i.level;r&&i.sn===r.sn&&r.level===e&&i.urlId===r.urlId||(this.hls.trigger(a.Events.FRAG_CHANGED,{frag:i}),r&&r.level===e||this.hls.trigger(a.Events.LEVEL_SWITCHED,{level:e}),this.fragPlaying=i)}}},y=b,(w=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentLevel",get:function(){var t=this.media;if(t){var i=this.getAppendedFrag(t.currentTime);if(i)return i.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;if(t){var i=this.getAppendedFrag(t.currentTime);return this.followingBufferedFrag(i)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&p(y.prototype,w),b}(e.default)},"./src/controller/subtitle-stream-controller.ts":
94
94
  /*!******************************************************!*\
95
95
  !*** ./src/controller/subtitle-stream-controller.ts ***!
96
96
  \******************************************************/
97
- /*! exports provided: SubtitleStreamController */function(t,i,r){r.r(i);r.d(i,"SubtitleStreamController",(function(){return g}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts");var s=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts");var a=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts");var u=r(/*! ./level-helper */"./src/controller/level-helper.ts");var f=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts");var h=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts");var o=r(/*! ../types/loader */"./src/types/loader.ts");var v=r(/*! ../types/level */"./src/types/level.ts");function l(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function c(t,i,r){if(i)l(t.prototype,i);if(r)l(t,r);return t}function d(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;m(t,i)}function m(t,i){m=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return m(t,i)}var p=500;var g=function(t){d(i,t);function i(i,r){var e;e=t.call(this,i,r,"[subtitle-stream-controller]")||this;e.levels=[];e.currentTrackId=-1;e.tracksBuffered=[];e.mainDetails=null;e._registerListeners();return e}var r=i.prototype;r.onHandlerDestroying=function t(){this._unregisterListeners();this.mainDetails=null};r._registerListeners=function t(){var i=this.hls;i.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(e["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.on(e["Events"].ERROR,this.onError,this);i.on(e["Events"].SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);i.on(e["Events"].SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this);i.on(e["Events"].SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);i.on(e["Events"].SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this);i.on(e["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)};r._unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(e["Events"].LEVEL_LOADED,this.onLevelLoaded,this);i.off(e["Events"].ERROR,this.onError,this);i.off(e["Events"].SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);i.off(e["Events"].SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this);i.off(e["Events"].SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);i.off(e["Events"].SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this);i.off(e["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)};r.startLoad=function t(){this.stopLoad();this.state=h["State"].IDLE;this.setInterval(p);this.tick()};r.onManifestLoading=function t(){this.mainDetails=null;this.fragmentTracker.removeAllFragments()};r.onLevelLoaded=function t(i,r){this.mainDetails=r.details};r.onSubtitleFragProcessed=function t(i,r){var e=r.frag,n=r.success;this.fragPrevious=e;this.state=h["State"].IDLE;if(!n){return}var s=this.tracksBuffered[this.currentTrackId];if(!s){return}var a;var u=e.start;for(var f=0;f<s.length;f++){if(u>=s[f].start&&u<=s[f].end){a=s[f];break}}var o=e.start+e.duration;if(a){a.end=o}else{a={start:u,end:o};s.push(a)}this.fragmentTracker.fragBuffered(e)};r.onBufferFlushing=function t(i,r){var e=r.startOffset,n=r.endOffset;if(e===0&&n!==Number.POSITIVE_INFINITY){var s=this.currentTrackId,a=this.levels;if(!a.length||!a[s]||!a[s].details){return}var u=a[s].details;var f=u.targetduration;var h=n-f;if(h<=0){return}r.endOffsetSubtitles=Math.max(0,h);this.tracksBuffered.forEach((function(t){for(var i=0;i<t.length;){if(t[i].end<=h){t.shift();continue}else if(t[i].start<h){t[i].start=h}else{break}i++}}));this.fragmentTracker.removeFragmentsInRange(e,h,o["PlaylistLevelType"].SUBTITLE)}};r.onError=function t(i,r){var e;var n=r.frag;if(!n||n.type!==o["PlaylistLevelType"].SUBTITLE){return}if((e=this.fragCurrent)!==null&&e!==void 0&&e.loader){this.fragCurrent.loader.abort()}this.state=h["State"].IDLE};r.onSubtitleTracksUpdated=function t(i,r){var e=this;var n=r.subtitleTracks;this.tracksBuffered=[];this.levels=n.map((function(t){return new v["Level"](t)}));this.fragmentTracker.removeAllFragments();this.fragPrevious=null;this.levels.forEach((function(t){e.tracksBuffered[t.id]=[]}));this.mediaBuffer=null};r.onSubtitleTrackSwitch=function t(i,r){this.currentTrackId=r.id;if(!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var e=this.levels[this.currentTrackId];if(e!==null&&e!==void 0&&e.details){this.mediaBuffer=this.mediaBufferTimeRanges}else{this.mediaBuffer=null}if(e){this.setInterval(p)}};r.onSubtitleTrackLoaded=function t(i,r){var e;var n=r.details,f=r.id;var o=this.currentTrackId,v=this.levels;if(!v.length){return}var l=v[o];if(f>=v.length||f!==o||!l){return}this.mediaBuffer=this.mediaBufferTimeRanges;if(n.live||(e=l.details)!==null&&e!==void 0&&e.live){var c=this.mainDetails;if(n.deltaUpdateFailed||!c){return}var d=c.fragments[0];if(!l.details){if(n.hasProgramDateTime&&c.hasProgramDateTime){Object(a["alignMediaPlaylistByPDT"])(n,c)}else if(d){Object(u["addSliding"])(n,d.start)}}else{var m=this.alignPlaylists(n,l.details);if(m===0&&d){Object(u["addSliding"])(n,d.start)}}}l.details=n;this.levelLastLoaded=f;this.tick();if(n.live&&!this.fragCurrent&&this.media&&this.state===h["State"].IDLE){var p=Object(s["findFragmentByPTS"])(null,n.fragments,this.media.currentTime,0);if(!p){this.warn("Subtitle playlist not aligned with playback");l.details=undefined}}};r._handleFragmentLoadComplete=function t(i){var r=i.frag,n=i.payload;var s=r.decryptdata;var a=this.hls;if(this.fragContextChanged(r)){return}if(n&&n.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){var u=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(n),s.key.buffer,s.iv.buffer).then((function(t){var i=performance.now();a.trigger(e["Events"].FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:u,tdecrypt:i}})}))}};r.doTick=function t(){if(!this.media){this.state=h["State"].IDLE;return}if(this.state===h["State"].IDLE){var i;var r=this.currentTrackId,e=this.levels;if(!e.length||!e[r]||!e[r].details){return}var a=e[r].details;var u=a.targetduration;var o=this.config,v=this.media;var l=n["BufferHelper"].bufferedInfo(this.mediaBufferTimeRanges,v.currentTime-u,o.maxBufferHole);var c=l.end,d=l.len;var m=this.getMaxBufferLength()+u;if(d>m){return}console.assert(a,"Subtitle track details are defined on idle subtitle stream controller tick");var p=a.fragments;var g=p.length;var b=a.edge;var y;var w=this.fragPrevious;if(c<b){var k=o.maxFragLookUpTolerance;y=Object(s["findFragmentByPTS"])(w,p,c,k);if(!y&&w&&w.start<p[0].start){y=p[0]}}else{y=p[g-1]}if((i=y)!==null&&i!==void 0&&i.encrypted){this.loadKey(y,a)}else if(y&&this.fragmentTracker.getState(y)===f["FragmentState"].NOT_LOADED){this.loadFragment(y,a,c)}}};r.loadFragment=function i(r,e,n){this.fragCurrent=r;t.prototype.loadFragment.call(this,r,e,n)};c(i,[{key:"mediaBufferTimeRanges",get:function t(){return this.tracksBuffered[this.currentTrackId]||[]}}]);return i}(h["default"])},"./src/controller/subtitle-track-controller.ts":
97
+ /*! exports provided: SubtitleStreamController */function(t,i,n){n.r(i),n.d(i,"SubtitleStreamController",(function(){return d}));var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=n(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),a=n(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),o=n(/*! ./level-helper */"./src/controller/level-helper.ts"),h=n(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=n(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),c=n(/*! ../types/loader */"./src/types/loader.ts"),f=n(/*! ../types/level */"./src/types/level.ts");function l(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function v(t,i){return v=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},v(t,i)}var d=function(t){var i,n;function d(i,n){var r;return(r=t.call(this,i,n,"[subtitle-stream-controller]")||this).levels=[],r.currentTrackId=-1,r.tracksBuffered=[],r.mainDetails=null,r._registerListeners(),r}n=t,(i=d).prototype=Object.create(n.prototype),i.prototype.constructor=i,v(i,n);var m,p,g=d.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(r.Events.ERROR,this.onError,this),t.on(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(r.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(r.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g._unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(r.Events.ERROR,this.onError,this),t.off(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(r.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(r.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g.startLoad=function(){this.stopLoad(),this.state=u.State.IDLE,this.setInterval(500),this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},g.onLevelLoaded=function(t,i){this.mainDetails=i.details},g.onSubtitleFragProcessed=function(t,i){var n=i.frag,r=i.success;if(this.fragPrevious=n,this.state=u.State.IDLE,r){var e=this.tracksBuffered[this.currentTrackId];if(e){for(var s,a=n.start,o=0;o<e.length;o++)if(a>=e[o].start&&a<=e[o].end){s=e[o];break}var h=n.start+n.duration;s?s.end=h:e.push(s={start:a,end:h}),this.fragmentTracker.fragBuffered(n)}}},g.onBufferFlushing=function(t,i){var n=i.startOffset,r=i.endOffset;if(0===n&&r!==Number.POSITIVE_INFINITY){var e=this.currentTrackId,s=this.levels;if(!s.length||!s[e]||!s[e].details)return;var a=r-s[e].details.targetduration;if(a<=0)return;i.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach((function(t){for(var i=0;i<t.length;)if(t[i].end<=a)t.shift();else{if(!(t[i].start<a))break;t[i].start=a,i++}})),this.fragmentTracker.removeFragmentsInRange(n,a,c.PlaylistLevelType.SUBTITLE)}},g.onError=function(t,i){var n,r=i.frag;r&&r.type===c.PlaylistLevelType.SUBTITLE&&(null!==(n=this.fragCurrent)&&void 0!==n&&n.loader&&this.fragCurrent.loader.abort(),this.state=u.State.IDLE)},g.onSubtitleTracksUpdated=function(t,i){var n=this,r=i.subtitleTracks;this.tracksBuffered=[],this.levels=r.map((function(t){return new f.Level(t)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(t){n.tracksBuffered[t.id]=[]})),this.mediaBuffer=null},g.onSubtitleTrackSwitch=function(t,i){if(this.currentTrackId=i.id,this.levels.length&&-1!==this.currentTrackId){var n=this.levels[this.currentTrackId];this.mediaBuffer=null!=n&&n.details?this.mediaBufferTimeRanges:null,n&&this.setInterval(500)}else this.clearInterval()},g.onSubtitleTrackLoaded=function(t,i){var n,r=i.details,e=i.id,h=this.currentTrackId,c=this.levels;if(c.length){var f=c[h];if(!(e>=c.length||e!==h)&&f){if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||null!==(n=f.details)&&void 0!==n&&n.live){var l=this.mainDetails;if(r.deltaUpdateFailed||!l)return;var v=l.fragments[0];f.details?0===this.alignPlaylists(r,f.details)&&v&&Object(o.addSliding)(r,v.start):r.hasProgramDateTime&&l.hasProgramDateTime?Object(a.alignMediaPlaylistByPDT)(r,l):v&&Object(o.addSliding)(r,v.start)}f.details=r,this.levelLastLoaded=e,this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===u.State.IDLE&&(Object(s.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}}},g._handleFragmentLoadComplete=function(t){var i=t.frag,n=t.payload,e=i.decryptdata,s=this.hls;if(!this.fragContextChanged(i)&&n&&n.byteLength>0&&e&&e.key&&e.iv&&"AES-128"===e.method){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(n),e.key.buffer,e.iv.buffer).then((function(t){var n=performance.now();s.trigger(r.Events.FRAG_DECRYPTED,{frag:i,payload:t,stats:{tstart:a,tdecrypt:n}})}))}},g.doTick=function(){if(this.media){if(this.state===u.State.IDLE){var t,i=this.currentTrackId,n=this.levels;if(!n.length||!n[i]||!n[i].details)return;var r=n[i].details,a=r.targetduration,o=this.config,c=e.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,this.media.currentTime-a,o.maxBufferHole),f=c.end;if(c.len>this.getMaxBufferLength()+a)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var l,v=r.fragments,d=v.length,m=this.fragPrevious;if(f<r.edge){var p=o.maxFragLookUpTolerance;!(l=Object(s.findFragmentByPTS)(m,v,f,p))&&m&&m.start<v[0].start&&(l=v[0])}else l=v[d-1];null!==(t=l)&&void 0!==t&&t.encrypted?this.loadKey(l,r):l&&this.fragmentTracker.getState(l)===h.FragmentState.NOT_LOADED&&this.loadFragment(l,r,f)}}else this.state=u.State.IDLE},g.loadFragment=function(i,n,r){this.fragCurrent=i,t.prototype.loadFragment.call(this,i,n,r)},m=d,(p=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&l(m.prototype,p),d}(u.default)},"./src/controller/subtitle-track-controller.ts":
98
98
  /*!*****************************************************!*\
99
99
  !*** ./src/controller/subtitle-track-controller.ts ***!
100
100
  \*****************************************************/
101
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts");var s=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts");var a=r(/*! ../types/loader */"./src/types/loader.ts");function u(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function f(t,i,r){if(i)u(t.prototype,i);if(r)u(t,r);return t}function h(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;o(t,i)}function o(t,i){o=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return o(t,i)}var v=function(t){h(i,t);function i(i){var r;r=t.call(this,i,"[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}var r=i.prototype;r.destroy=function i(){this.unregisterListeners();this.tracks.length=0;this.tracksInGroup.length=0;this.trackChangeListener=this.asyncPollTrackChange=null;t.prototype.destroy.call(this)};r.registerListeners=function t(){var i=this.hls;i.on(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.on(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.on(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.on(e["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.on(e["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);i.on(e["Events"].SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);i.on(e["Events"].ERROR,this.onError,this)};r.unregisterListeners=function t(){var i=this.hls;i.off(e["Events"].MEDIA_ATTACHED,this.onMediaAttached,this);i.off(e["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(e["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(e["Events"].MANIFEST_PARSED,this.onManifestParsed,this);i.off(e["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.off(e["Events"].LEVEL_SWITCHING,this.onLevelSwitching,this);i.off(e["Events"].SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this);i.off(e["Events"].ERROR,this.onError,this)};r.onMediaAttached=function t(i,r){this.media=r.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)}};r.pollTrackChange=function t(i){self.clearInterval(this.subtitlePollingInterval);this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,i)};r.onMediaDetaching=function t(){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 i=l(this.media.textTracks);i.forEach((function(t){Object(n["clearCurrentCues"])(t)}));this.subtitleTrack=-1;this.media=null};r.onManifestLoading=function t(){this.tracks=[];this.groupId=null;this.tracksInGroup=[];this.trackId=-1;this.selectDefaultTrack=true};r.onManifestParsed=function t(i,r){this.tracks=r.subtitleTracks};r.onSubtitleTrackLoaded=function t(i,r){var e=r.id,n=r.details;var s=this.trackId;var a=this.tracksInGroup[s];if(!a){this.warn("Invalid subtitle track id "+e);return}var u=a.details;a.details=r.details;this.log("subtitle track "+e+" loaded ["+n.startSN+"-"+n.endSN+"]");if(e===this.trackId){this.retryCount=0;this.playlistLoaded(e,r,u)}};r.onLevelLoading=function t(i,r){this.switchLevel(r.level)};r.onLevelSwitching=function t(i,r){this.switchLevel(r.level)};r.switchLevel=function t(i){var r=this.hls.levels[i];if(!(r!==null&&r!==void 0&&r.textGroupIds)){return}var n=r.textGroupIds[r.urlId];if(this.groupId!==n){var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:undefined;var a=this.tracks.filter((function(t){return!n||t.groupId===n}));this.tracksInGroup=a;var u=this.findTrackId(s===null||s===void 0?void 0:s.name)||this.findTrackId();this.groupId=n;var f={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+n+'" group-id');this.hls.trigger(e["Events"].SUBTITLE_TRACKS_UPDATED,f);if(u!==-1){this.setSubtitleTrack(u,s)}}};r.findTrackId=function t(i){var r=this.tracksInGroup;for(var e=0;e<r.length;e++){var n=r[e];if(!this.selectDefaultTrack||n.default){if(!i||i===n.name){return n.id}}}return-1};r.onError=function i(r,e){t.prototype.onError.call(this,r,e);if(e.fatal||!e.context){return}if(e.context.type===a["PlaylistContextType"].SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId){this.retryLoadingOrFail(e)}};r.loadPlaylist=function t(i){var r=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(r)){var n=r.id;var s=r.groupId;var a=r.url;if(i){try{a=i.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}}this.log("Loading subtitle playlist for id "+n);this.hls.trigger(e["Events"].SUBTITLE_TRACK_LOADING,{url:a,id:n,groupId:s,deliveryDirectives:i||null})}};r.toggleTrackModes=function t(i){var r=this;var e=this.media,n=this.subtitleDisplay,s=this.trackId;if(!e){return}var a=l(e.textTracks);var u=a.filter((function(t){return t.groupId===r.groupId}));if(i===-1){[].slice.call(a).forEach((function(t){t.mode="disabled"}))}else{var f=u[s];if(f){f.mode="disabled"}}var h=u[i];if(h){h.mode=n?"showing":"hidden"}};r.setSubtitleTrack=function t(i,r){var n;var s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=i;return}if(this.trackId!==i){this.toggleTrackModes(i)}if(this.trackId===i&&(i===-1||(n=s[i])!==null&&n!==void 0&&n.details)||i<-1||i>=s.length){return}this.clearTimer();var a=s[i];this.log("Switching to subtitle track "+i);this.trackId=i;if(a){var u=a.id,f=a.groupId,h=f===void 0?"":f,o=a.name,v=a.type,l=a.url;this.hls.trigger(e["Events"].SUBTITLE_TRACK_SWITCH,{id:u,groupId:h,name:o,type:v,url:l});var c=this.switchParams(a.url,r===null||r===void 0?void 0:r.details);this.loadPlaylist(c)}else{this.hls.trigger(e["Events"].SUBTITLE_TRACK_SWITCH,{id:i})}};r.onTextTracksChanged=function t(){if(!this.useTextTrackPolling){self.clearInterval(this.subtitlePollingInterval)}if(!this.media||!this.hls.config.renderTextTracksNatively){return}var i=-1;var r=l(this.media.textTracks);for(var e=0;e<r.length;e++){if(r[e].mode==="hidden"){i=e}else if(r[e].mode==="showing"){i=e;break}}if(this.subtitleTrack!==i){this.subtitleTrack=i}};f(i,[{key:"subtitleTracks",get:function t(){return this.tracksInGroup}},{key:"subtitleTrack",get:function t(){return this.trackId},set:function t(i){this.selectDefaultTrack=false;var r=this.tracksInGroup?this.tracksInGroup[this.trackId]:undefined;this.setSubtitleTrack(i,r)}}]);return i}(s["default"]);function l(t){var i=[];for(var r=0;r<t.length;r++){var e=t[r];if(e.kind==="subtitles"&&e.label){i.push(t[r])}}return i}i["default"]=v},"./src/controller/timeline-controller.ts":
101
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=n(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=n(/*! ../types/loader */"./src/types/loader.ts");function o(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,i){return h=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},h(t,i)}var u=function(t){var i,n;function s(i){var n;return(n=t.call(this,i,"[subtitle-track-controller]")||this).media=null,n.tracks=[],n.groupId=null,n.tracksInGroup=[],n.trackId=-1,n.selectDefaultTrack=!0,n.queuedDefaultTrack=-1,n.trackChangeListener=function(){return n.onTextTracksChanged()},n.asyncPollTrackChange=function(){return n.pollTrackChange(0)},n.useTextTrackPolling=!1,n.subtitlePollingInterval=-1,n.subtitleDisplay=!0,n.registerListeners(),n}n=t,(i=s).prototype=Object.create(n.prototype),i.prototype.constructor=i,h(i,n);var u,f,l=s.prototype;return l.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},l.registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(r.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(r.Events.ERROR,this.onError,this)},l.onMediaAttached=function(t,i){this.media=i.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},l.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},l.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),c(this.media.textTracks).forEach((function(t){Object(e.clearCurrentCues)(t)})),this.subtitleTrack=-1,this.media=null)},l.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},l.onManifestParsed=function(t,i){this.tracks=i.subtitleTracks},l.onSubtitleTrackLoaded=function(t,i){var n=i.id,r=i.details,e=this.tracksInGroup[this.trackId];if(e){var s=e.details;e.details=i.details,this.log("subtitle track "+n+" loaded ["+r.startSN+"-"+r.endSN+"]"),n===this.trackId&&(this.retryCount=0,this.playlistLoaded(n,i,s))}else this.warn("Invalid subtitle track id "+n)},l.onLevelLoading=function(t,i){this.switchLevel(i.level)},l.onLevelSwitching=function(t,i){this.switchLevel(i.level)},l.switchLevel=function(t){var i=this.hls.levels[t];if(null!=i&&i.textGroupIds){var n=i.textGroupIds[i.urlId];if(this.groupId!==n){var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,s=this.tracks.filter((function(t){return!n||t.groupId===n}));this.tracksInGroup=s;var a=this.findTrackId(null==e?void 0:e.name)||this.findTrackId();this.groupId=n;var o={subtitleTracks:s};this.log("Updating subtitle tracks, "+s.length+' track(s) found in "'+n+'" group-id'),this.hls.trigger(r.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==a&&this.setSubtitleTrack(a,e)}}},l.findTrackId=function(t){for(var i=this.tracksInGroup,n=0;n<i.length;n++){var r=i[n];if((!this.selectDefaultTrack||r.default)&&(!t||t===r.name))return r.id}return-1},l.onError=function(i,n){t.prototype.onError.call(this,i,n),!n.fatal&&n.context&&n.context.type===a.PlaylistContextType.SUBTITLE_TRACK&&n.context.id===this.trackId&&n.context.groupId===this.groupId&&this.retryLoadingOrFail(n)},l.loadPlaylist=function(t){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var n=i.id,e=i.groupId,s=i.url;if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+n),this.hls.trigger(r.Events.SUBTITLE_TRACK_LOADING,{url:s,id:n,groupId:e,deliveryDirectives:t||null})}},l.toggleTrackModes=function(t){var i=this,n=this.media,r=this.subtitleDisplay,e=this.trackId;if(n){var s=c(n.textTracks),a=s.filter((function(t){return t.groupId===i.groupId}));if(-1===t)[].slice.call(s).forEach((function(t){t.mode="disabled"}));else{var o=a[e];o&&(o.mode="disabled")}var h=a[t];h&&(h.mode=r?"showing":"hidden")}},l.setSubtitleTrack=function(t,i){var n,e=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!==(n=e[t])&&void 0!==n&&n.details)||t<-1||t>=e.length)){this.clearTimer();var s=e[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,s){var a=s.groupId;this.hls.trigger(r.Events.SUBTITLE_TRACK_SWITCH,{id:s.id,groupId:void 0===a?"":a,name:s.name,type:s.type,url:s.url});var o=this.switchParams(s.url,null==i?void 0:i.details);this.loadPlaylist(o)}else this.hls.trigger(r.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},l.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,i=c(this.media.textTracks),n=0;n<i.length;n++)if("hidden"===i[n].mode)t=n;else if("showing"===i[n].mode){t=n;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},u=s,(f=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setSubtitleTrack(t,this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0)}}])&&o(u.prototype,f),s}(s.default);function c(t){for(var i=[],n=0;n<t.length;n++){var r=t[n];"subtitles"===r.kind&&r.label&&i.push(t[n])}return i}i.default=u},"./src/controller/timeline-controller.ts":
102
102
  /*!***********************************************!*\
103
103
  !*** ./src/controller/timeline-controller.ts ***!
104
104
  \***********************************************/
105
- /*! exports provided: TimelineController */function(t,i,r){r.r(i);r.d(i,"TimelineController",(function(){return l}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts");var a=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts");var u=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts");var f=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts");var h=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts");var o=r(/*! ../types/loader */"./src/types/loader.ts");var v=r(/*! ../utils/logger */"./src/utils/logger.ts");var l=function(){function t(t){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.timescale=[];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=m();this.captionsProperties=void 0;this.hls=t;this.config=t.config;this.Cues=t.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 i=new a["default"](this,"textTrack1");var r=new a["default"](this,"textTrack2");var e=new a["default"](this,"textTrack3");var u=new a["default"](this,"textTrack4");this.cea608Parser1=new s["default"](1,i,r);this.cea608Parser2=new s["default"](3,e,u)}t.on(n["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);t.on(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);t.on(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);t.on(n["Events"].MANIFEST_LOADED,this.onManifestLoaded,this);t.on(n["Events"].SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);t.on(n["Events"].FRAG_LOADING,this.onFragLoading,this);t.on(n["Events"].FRAG_LOADED,this.onFragLoaded,this);t.on(n["Events"].FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this);t.on(n["Events"].FRAG_DECRYPTED,this.onFragDecrypted,this);t.on(n["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);t.on(n["Events"].SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this);t.on(n["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this)}var i=t.prototype;i.destroy=function t(){var i=this.hls;i.off(n["Events"].MEDIA_ATTACHING,this.onMediaAttaching,this);i.off(n["Events"].MEDIA_DETACHING,this.onMediaDetaching,this);i.off(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(n["Events"].MANIFEST_LOADED,this.onManifestLoaded,this);i.off(n["Events"].SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this);i.off(n["Events"].FRAG_LOADING,this.onFragLoading,this);i.off(n["Events"].FRAG_LOADED,this.onFragLoaded,this);i.off(n["Events"].FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this);i.off(n["Events"].FRAG_DECRYPTED,this.onFragDecrypted,this);i.off(n["Events"].INIT_PTS_FOUND,this.onInitPtsFound,this);i.off(n["Events"].SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this);i.off(n["Events"].BUFFER_FLUSHING,this.onBufferFlushing,this);this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null};i.addCues=function t(i,r,e,s,a){var u=false;for(var f=a.length;f--;){var h=a[f];var o=d(h[0],h[1],r,e);if(o>=0){h[0]=Math.min(h[0],r);h[1]=Math.max(h[1],e);u=true;if(o/(e-r)>.5){return}}}if(!u){a.push([r,e])}if(this.config.renderTextTracksNatively){var v=this.captionsTracks[i];this.Cues.newCue(v,r,e,s)}else{var l=this.Cues.newCue(null,r,e,s);this.hls.trigger(n["Events"].CUES_PARSED,{type:"captions",cues:l,track:i})}};i.onInitPtsFound=function t(i,r){var e=this;var s=r.frag,a=r.id,u=r.initPTS,f=r.timescale;var h=this.unparsedVttFrags;if(a==="main"){this.initPTS[s.cc]=u;this.timescale[s.cc]=f}if(h.length){this.unparsedVttFrags=[];h.forEach((function(t){e.onFragLoaded(n["Events"].FRAG_LOADED,t)}))}};i.getExistingTrack=function t(i){var r=this.media;if(r){for(var e=0;e<r.textTracks.length;e++){var n=r.textTracks[e];if(n[i]){return n}}}return null};i.createCaptionsTrack=function t(i){if(this.config.renderTextTracksNatively){this.createNativeTrack(i)}else{this.createNonNativeTrack(i)}};i.createNativeTrack=function t(i){if(this.captionsTracks[i]){return}var r=this.captionsProperties,e=this.captionsTracks,n=this.media;var s=r[i],a=s.label,u=s.languageCode;var h=this.getExistingTrack(i);if(!h){var o=this.createTextTrack("captions",a,u);if(o){o[i]=true;e[i]=o}}else{e[i]=h;Object(f["clearCurrentCues"])(e[i]);Object(f["sendAddTrackEvent"])(e[i],n)}};i.createNonNativeTrack=function t(i){if(this.nonNativeCaptionsTracks[i]){return}var r=this.captionsProperties[i];if(!r){return}var e=r.label;var s={_id:i,label:e,kind:"captions",default:r.media?!!r.media.default:false,closedCaptions:r.media};this.nonNativeCaptionsTracks[i]=s;this.hls.trigger(n["Events"].NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})};i.createTextTrack=function t(i,r,e){var n=this.media;if(!n){return}return n.addTextTrack(i,r,e)};i.onMediaAttaching=function t(i,r){this.media=r.media;this._cleanTracks()};i.onMediaDetaching=function t(){var i=this.captionsTracks;Object.keys(i).forEach((function(t){Object(f["clearCurrentCues"])(i[t]);delete i[t]}));this.nonNativeCaptionsTracks={}};i.onManifestLoading=function t(){this.lastSn=-1;this.lastPartIndex=-1;this.prevCC=-1;this.vttCCs=m();this._cleanTracks();this.tracks=[];this.captionsTracks={};this.nonNativeCaptionsTracks={};this.textTracks=[];this.unparsedVttFrags=this.unparsedVttFrags||[];this.initPTS=[];this.timescale=[];if(this.cea608Parser1&&this.cea608Parser2){this.cea608Parser1.reset();this.cea608Parser2.reset()}};i._cleanTracks=function t(){var i=this.media;if(!i){return}var r=i.textTracks;if(r){for(var e=0;e<r.length;e++){Object(f["clearCurrentCues"])(r[e])}}};i.onSubtitleTracksUpdated=function t(i,r){var e=this;this.textTracks=[];var s=r.subtitleTracks||[];var a=s.some((function(t){return t.textCodec===h["IMSC1_CODEC"]}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var u=this.tracks&&s&&this.tracks.length===s.length;this.tracks=s||[];if(this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,i){var r;if(i<o.length){var n=null;for(var s=0;s<o.length;s++){if(c(o[s],t)){n=o[s];break}}if(n){r=n}}if(r){Object(f["clearCurrentCues"])(r)}else{r=e.createTextTrack("subtitles",t.name,t.lang);if(r){r.mode="disabled"}}if(r){r.groupId=t.groupId;e.textTracks.push(r)}}))}else if(!u&&this.tracks&&this.tracks.length){var v=this.tracks.map((function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}}));this.hls.trigger(n["Events"].NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:v})}}};i.onManifestLoaded=function t(i,r){var e=this;if(this.config.enableCEA708Captions&&r.captions){r.captions.forEach((function(t){var i=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(!i){return}var r="textTrack"+i[1];var n=e.captionsProperties[r];if(!n){return}n.label=t.name;if(t.lang){n.languageCode=t.lang}n.media=t}))}};i.onFragLoading=function t(i,r){var e=this.cea608Parser1,n=this.cea608Parser2,s=this.lastSn,a=this.lastPartIndex;if(!this.enabled||!(e&&n)){return}if(r.frag.type===o["PlaylistLevelType"].MAIN){var u,f;var h=r.frag.sn;var v=(u=r===null||r===void 0?void 0:(f=r.part)===null||f===void 0?void 0:f.index)!=null?u:-1;if(!(h===s+1||h===s&&v===a+1)){e.reset();n.reset()}this.lastSn=h;this.lastPartIndex=v}};i.onFragLoaded=function t(i,r){var s=r.frag,a=r.payload;var u=this.initPTS,f=this.unparsedVttFrags;if(s.type===o["PlaylistLevelType"].SUBTITLE){if(a.byteLength){if(!Object(e["isFiniteNumber"])(u[s.cc])){f.push(r);if(u.length){this.hls.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:false,frag:s,error:new Error("Missing initial subtitle PTS")})}return}var v=s.decryptdata;var l="stats"in r;if(v==null||v.key==null||v.method!=="AES-128"||l){var c=this.tracks[s.level];var d=this.vttCCs;if(!d[s.cc]){d[s.cc]={start:s.start,prevCC:this.prevCC,new:true};this.prevCC=s.cc}if(c&&c.textCodec===h["IMSC1_CODEC"]){this._parseIMSC1(s,a)}else{this._parseVTTs(s,a,d)}}}else{this.hls.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:false,frag:s,error:new Error("Empty subtitle payload")})}}};i._parseIMSC1=function t(i,r){var e=this;var s=this.hls;Object(h["parseIMSC1"])(r,this.initPTS[i.cc],this.timescale[i.cc],(function(t){e._appendCues(t,i.level);s.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:true,frag:i})}),(function(t){v["logger"].log("Failed to parse IMSC1: "+t);s.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:t})}))};i._parseVTTs=function t(i,r,e){var s=this;var a=this.hls;Object(u["parseWebVTT"])(r,this.initPTS[i.cc],this.timescale[i.cc],e,i.cc,i.start,(function(t){s._appendCues(t,i.level);a.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:true,frag:i})}),(function(t){s._fallbackToIMSC1(i,r);v["logger"].log("Failed to parse VTT cue: "+t);a.trigger(n["Events"].SUBTITLE_FRAG_PROCESSED,{success:false,frag:i,error:t})}))};i._fallbackToIMSC1=function t(i,r){var e=this;var n=this.tracks[i.level];if(!n.textCodec){Object(h["parseIMSC1"])(r,this.initPTS[i.cc],this.timescale[i.cc],(function(){n.textCodec=h["IMSC1_CODEC"];e._parseIMSC1(i,r)}),(function(){n.textCodec="wvtt"}))}};i._appendCues=function t(i,r){var e=this.hls;if(this.config.renderTextTracksNatively){var s=this.textTracks[r];if(s.mode==="disabled"){return}i.forEach((function(t){return Object(f["addCueToTrack"])(s,t)}))}else{var a=this.tracks[r];var u=a.default?"default":"subtitles"+r;e.trigger(n["Events"].CUES_PARSED,{type:"subtitles",cues:i,track:u})}};i.onFragDecrypted=function t(i,r){var s=r.frag;if(s.type===o["PlaylistLevelType"].SUBTITLE){if(!Object(e["isFiniteNumber"])(this.initPTS[s.cc])){this.unparsedVttFrags.push(r);return}this.onFragLoaded(n["Events"].FRAG_LOADED,r)}};i.onSubtitleTracksCleared=function t(){this.tracks=[];this.captionsTracks={}};i.onFragParsingUserdata=function t(i,r){var e=this.cea608Parser1,n=this.cea608Parser2;if(!this.enabled||!(e&&n)){return}for(var s=0;s<r.samples.length;s++){var a=r.samples[s].bytes;if(a){var u=this.extractCea608Data(a);e.addData(r.samples[s].pts,u[0]);n.addData(r.samples[s].pts,u[1])}}};i.onBufferFlushing=function t(i,r){var e=r.startOffset,n=r.endOffset,s=r.endOffsetSubtitles,a=r.type;var u=this.media;if(!u||u.currentTime<n){return}if(!a||a==="video"){var h=this.captionsTracks;Object.keys(h).forEach((function(t){return Object(f["removeCuesInRange"])(h[t],e,n)}))}if(this.config.renderTextTracksNatively){if(e===0&&s!==undefined){var o=this.textTracks;Object.keys(o).forEach((function(t){return Object(f["removeCuesInRange"])(o[t],e,s)}))}}};i.extractCea608Data=function t(i){var r=i[0]&31;var e=2;var n=[[],[]];for(var s=0;s<r;s++){var a=i[e++];var u=127&i[e++];var f=127&i[e++];var h=(4&a)!==0;var o=3&a;if(u===0&&f===0){continue}if(h){if(o===0||o===1){n[o].push(u);n[o].push(f)}}}return n};return t}();function c(t,i){return t&&t.label===i.name&&!(t.textTrack1||t.textTrack2)}function d(t,i,r,e){return Math.min(i,e)-Math.max(t,r)}function m(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:false}}}},"./src/crypt/aes-crypto.ts":
105
+ /*! exports provided: TimelineController */function(t,i,n){n.r(i),n.d(i,"TimelineController",(function(){return l}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),a=n(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=n(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),h=n(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=n(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),c=n(/*! ../types/loader */"./src/types/loader.ts"),f=n(/*! ../utils/logger */"./src/utils/logger.ts"),l=function(){function t(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],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={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},this.config.enableCEA708Captions){var i=new a.default(this,"textTrack1"),n=new a.default(this,"textTrack2"),r=new a.default(this,"textTrack3"),o=new a.default(this,"textTrack4");this.cea608Parser1=new s.default(1,i,n),this.cea608Parser2=new s.default(3,r,o)}t.on(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(e.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(e.Events.FRAG_LOADING,this.onFragLoading,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(e.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(e.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(e.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(e.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var i=t.prototype;return i.destroy=function(){var t=this.hls;t.off(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(e.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(e.Events.FRAG_LOADING,this.onFragLoading,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(e.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(e.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(e.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(e.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},i.addCues=function(t,i,n,r,s){for(var a,o,h=!1,u=s.length;u--;){var c=s[u],f=(a=c[0],o=i,Math.min(c[1],n)-Math.max(a,o));if(f>=0&&(c[0]=Math.min(c[0],i),c[1]=Math.max(c[1],n),h=!0,f/(n-i)>.5))return}if(h||s.push([i,n]),this.config.renderTextTracksNatively)this.Cues.newCue(this.captionsTracks[t],i,n,r);else{var l=this.Cues.newCue(null,i,n,r);this.hls.trigger(e.Events.CUES_PARSED,{type:"captions",cues:l,track:t})}},i.onInitPtsFound=function(t,i){var n=this,r=i.frag,s=i.timescale,a=this.unparsedVttFrags;"main"===i.id&&(this.initPTS[r.cc]=i.initPTS,this.timescale[r.cc]=s),a.length&&(this.unparsedVttFrags=[],a.forEach((function(t){n.onFragLoaded(e.Events.FRAG_LOADED,t)})))},i.getExistingTrack=function(t){var i=this.media;if(i)for(var n=0;n<i.textTracks.length;n++){var r=i.textTracks[n];if(r[t])return r}return null},i.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},i.createNativeTrack=function(t){if(!this.captionsTracks[t]){var i=this.captionsTracks,n=this.media,r=this.captionsProperties[t],e=r.label,s=r.languageCode,a=this.getExistingTrack(t);if(a)i[t]=a,Object(h.clearCurrentCues)(i[t]),Object(h.sendAddTrackEvent)(i[t],n);else{var o=this.createTextTrack("captions",e,s);o&&(o[t]=!0,i[t]=o)}}},i.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var i=this.captionsProperties[t];if(i){var n={_id:t,label:i.label,kind:"captions",default:!!i.media&&!!i.media.default,closedCaptions:i.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}}},i.createTextTrack=function(t,i,n){var r=this.media;if(r)return r.addTextTrack(t,i,n)},i.onMediaAttaching=function(t,i){this.media=i.media,this._cleanTracks()},i.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach((function(i){Object(h.clearCurrentCues)(t[i]),delete t[i]})),this.nonNativeCaptionsTracks={}},i.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},i._cleanTracks=function(){var t=this.media;if(t){var i=t.textTracks;if(i)for(var n=0;n<i.length;n++)Object(h.clearCurrentCues)(i[n])}},i.onSubtitleTracksUpdated=function(t,i){var n=this;this.textTracks=[];var r=i.subtitleTracks||[],s=r.some((function(t){return t.textCodec===u.IMSC1_CODEC}));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){var a=this.tracks&&r&&this.tracks.length===r.length;if(this.tracks=r||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,i){var r;if(i<o.length){for(var e=null,s=0;s<o.length;s++)if(v(o[s],t)){e=o[s];break}e&&(r=e)}r?Object(h.clearCurrentCues)(r):(r=n.createTextTrack("subtitles",t.name,t.lang))&&(r.mode="disabled"),r&&(r.groupId=t.groupId,n.textTracks.push(r))}))}else if(!a&&this.tracks&&this.tracks.length){var c=this.tracks.map((function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}}));this.hls.trigger(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},i.onManifestLoaded=function(t,i){var n=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach((function(t){var i=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(i){var r=n.captionsProperties["textTrack"+i[1]];r&&(r.label=t.name,t.lang&&(r.languageCode=t.lang),r.media=t)}}))},i.onFragLoading=function(t,i){var n=this.cea608Parser1,r=this.cea608Parser2,e=this.lastSn;if(this.enabled&&n&&r&&i.frag.type===c.PlaylistLevelType.MAIN){var s,a,o=i.frag.sn,h=null!=(s=null==i||null===(a=i.part)||void 0===a?void 0:a.index)?s:-1;o===e+1||o===e&&h===this.lastPartIndex+1||(n.reset(),r.reset()),this.lastSn=o,this.lastPartIndex=h}},i.onFragLoaded=function(t,i){var n=i.frag,s=i.payload,a=this.initPTS,o=this.unparsedVttFrags;if(n.type===c.PlaylistLevelType.SUBTITLE)if(s.byteLength){if(!Object(r.isFiniteNumber)(a[n.cc]))return o.push(i),void(a.length&&this.hls.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Missing initial subtitle PTS")}));var h=n.decryptdata;if(null==h||null==h.key||"AES-128"!==h.method||"stats"in i){var f=this.tracks[n.level],l=this.vttCCs;l[n.cc]||(l[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc),f&&f.textCodec===u.IMSC1_CODEC?this._parseIMSC1(n,s):this._parseVTTs(n,s,l)}}else this.hls.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Empty subtitle payload")})},i._parseIMSC1=function(t,i){var n=this,r=this.hls;Object(u.parseIMSC1)(i,this.initPTS[t.cc],this.timescale[t.cc],(function(i){n._appendCues(i,t.level),r.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(i){f.logger.log("Failed to parse IMSC1: "+i),r.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:i})}))},i._parseVTTs=function(t,i,n){var r=this,s=this.hls;Object(o.parseWebVTT)(i,this.initPTS[t.cc],this.timescale[t.cc],n,t.cc,t.start,(function(i){r._appendCues(i,t.level),s.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(n){r._fallbackToIMSC1(t,i),f.logger.log("Failed to parse VTT cue: "+n),s.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:n})}))},i._fallbackToIMSC1=function(t,i){var n=this,r=this.tracks[t.level];r.textCodec||Object(u.parseIMSC1)(i,this.initPTS[t.cc],this.timescale[t.cc],(function(){r.textCodec=u.IMSC1_CODEC,n._parseIMSC1(t,i)}),(function(){r.textCodec="wvtt"}))},i._appendCues=function(t,i){var n=this.hls;if(this.config.renderTextTracksNatively){var r=this.textTracks[i];if("disabled"===r.mode)return;t.forEach((function(t){return Object(h.addCueToTrack)(r,t)}))}else n.trigger(e.Events.CUES_PARSED,{type:"subtitles",cues:t,track:this.tracks[i].default?"default":"subtitles"+i})},i.onFragDecrypted=function(t,i){var n=i.frag;if(n.type===c.PlaylistLevelType.SUBTITLE){if(!Object(r.isFiniteNumber)(this.initPTS[n.cc]))return void this.unparsedVttFrags.push(i);this.onFragLoaded(e.Events.FRAG_LOADED,i)}},i.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},i.onFragParsingUserdata=function(t,i){var n=this.cea608Parser1,r=this.cea608Parser2;if(this.enabled&&n&&r)for(var e=0;e<i.samples.length;e++){var s=i.samples[e].bytes;if(s){var a=this.extractCea608Data(s);n.addData(i.samples[e].pts,a[0]),r.addData(i.samples[e].pts,a[1])}}},i.onBufferFlushing=function(t,i){var n=i.startOffset,r=i.endOffset,e=i.endOffsetSubtitles,s=i.type,a=this.media;if(a&&!(a.currentTime<r)){if(!s||"video"===s){var o=this.captionsTracks;Object.keys(o).forEach((function(t){return Object(h.removeCuesInRange)(o[t],n,r)}))}if(this.config.renderTextTracksNatively&&0===n&&void 0!==e){var u=this.textTracks;Object.keys(u).forEach((function(t){return Object(h.removeCuesInRange)(u[t],n,e)}))}}},i.extractCea608Data=function(t){for(var i=31&t[0],n=2,r=[[],[]],e=0;e<i;e++){var s=t[n++],a=127&t[n++],o=127&t[n++],h=3&s;0===a&&0===o||0!=(4&s)&&(0!==h&&1!==h||(r[h].push(a),r[h].push(o)))}return r},t}();function v(t,i){return t&&t.label===i.name&&!(t.textTrack1||t.textTrack2)}},"./src/crypt/aes-crypto.ts":
106
106
  /*!*********************************!*\
107
107
  !*** ./src/crypt/aes-crypto.ts ***!
108
108
  \*********************************/
109
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(t,i){this.subtle=void 0;this.aesIV=void 0;this.subtle=t;this.aesIV=i}var i=t.prototype;i.decrypt=function t(i,r){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},r,i)};return t}()},"./src/crypt/aes-decryptor.ts":
109
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(t,i){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=i}return t.prototype.decrypt=function(t,i){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},i,t)},t}()},"./src/crypt/aes-decryptor.ts":
110
110
  /*!************************************!*\
111
111
  !*** ./src/crypt/aes-decryptor.ts ***!
112
112
  \************************************/
113
- /*! exports provided: removePadding, default */function(t,i,r){r.r(i);r.d(i,"removePadding",(function(){return n}));r.d(i,"default",(function(){return s}));var e=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function n(t){var i=t.byteLength;var r=i&&new DataView(t.buffer).getUint8(i-1);if(r){return Object(e["sliceUint8"])(t,0,i-r)}return t}var s=function(){function t(){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()}var i=t.prototype;i.uint8ArrayToUint32Array_=function t(i){var r=new DataView(i);var e=new Uint32Array(4);for(var n=0;n<4;n++){e[n]=r.getUint32(n*4)}return e};i.initTable=function t(){var i=this.sBox;var r=this.invSBox;var e=this.subMix;var n=e[0];var s=e[1];var a=e[2];var u=e[3];var f=this.invSubMix;var h=f[0];var o=f[1];var v=f[2];var l=f[3];var c=new Uint32Array(256);var d=0;var m=0;var p=0;for(p=0;p<256;p++){if(p<128){c[p]=p<<1}else{c[p]=p<<1^283}}for(p=0;p<256;p++){var g=m^m<<1^m<<2^m<<3^m<<4;g=g>>>8^g&255^99;i[d]=g;r[g]=d;var b=c[d];var y=c[b];var w=c[y];var k=c[g]*257^g*16843008;n[d]=k<<24|k>>>8;s[d]=k<<16|k>>>16;a[d]=k<<8|k>>>24;u[d]=k;k=w*16843009^y*65537^b*257^d*16843008;h[g]=k<<24|k>>>8;o[g]=k<<16|k>>>16;v[g]=k<<8|k>>>24;l[g]=k;if(!d){d=m=1}else{d=b^c[c[c[w^b]]];m^=c[c[m]]}}};i.expandKey=function t(i){var r=this.uint8ArrayToUint32Array_(i);var e=true;var n=0;while(n<r.length&&e){e=r[n]===this.key[n];n++}if(e){return}this.key=r;var s=this.keySize=r.length;if(s!==4&&s!==6&&s!==8){throw new Error("Invalid aes key size="+s)}var a=this.ksRows=(s+6+1)*4;var u;var f;var h=this.keySchedule=new Uint32Array(a);var o=this.invKeySchedule=new Uint32Array(a);var v=this.sBox;var l=this.rcon;var c=this.invSubMix;var d=c[0];var m=c[1];var p=c[2];var g=c[3];var b;var y;for(u=0;u<a;u++){if(u<s){b=h[u]=r[u];continue}y=b;if(u%s===0){y=y<<8|y>>>24;y=v[y>>>24]<<24|v[y>>>16&255]<<16|v[y>>>8&255]<<8|v[y&255];y^=l[u/s|0]<<24}else if(s>6&&u%s===4){y=v[y>>>24]<<24|v[y>>>16&255]<<16|v[y>>>8&255]<<8|v[y&255]}h[u]=b=(h[u-s]^y)>>>0}for(f=0;f<a;f++){u=a-f;if(f&3){y=h[u]}else{y=h[u-4]}if(f<4||u<=4){o[f]=y}else{o[f]=d[v[y>>>24]]^m[v[y>>>16&255]]^p[v[y>>>8&255]]^g[v[y&255]]}o[f]=o[f]>>>0}};i.networkToHostOrderSwap=function t(i){return i<<24|(i&65280)<<8|(i&16711680)>>8|i>>>24};i.decrypt=function t(i,r,e){var n=this.keySize+6;var s=this.invKeySchedule;var a=this.invSBox;var u=this.invSubMix;var f=u[0];var h=u[1];var o=u[2];var v=u[3];var l=this.uint8ArrayToUint32Array_(e);var c=l[0];var d=l[1];var m=l[2];var p=l[3];var g=new Int32Array(i);var b=new Int32Array(g.length);var y,w,k,T;var O,S,E,A;var M,x,j,D;var L,I;var C=this.networkToHostOrderSwap;while(r<g.length){M=C(g[r]);x=C(g[r+1]);j=C(g[r+2]);D=C(g[r+3]);O=M^s[0];S=D^s[1];E=j^s[2];A=x^s[3];L=4;for(I=1;I<n;I++){y=f[O>>>24]^h[S>>16&255]^o[E>>8&255]^v[A&255]^s[L];w=f[S>>>24]^h[E>>16&255]^o[A>>8&255]^v[O&255]^s[L+1];k=f[E>>>24]^h[A>>16&255]^o[O>>8&255]^v[S&255]^s[L+2];T=f[A>>>24]^h[O>>16&255]^o[S>>8&255]^v[E&255]^s[L+3];O=y;S=w;E=k;A=T;L=L+4}y=a[O>>>24]<<24^a[S>>16&255]<<16^a[E>>8&255]<<8^a[A&255]^s[L];w=a[S>>>24]<<24^a[E>>16&255]<<16^a[A>>8&255]<<8^a[O&255]^s[L+1];k=a[E>>>24]<<24^a[A>>16&255]<<16^a[O>>8&255]<<8^a[S&255]^s[L+2];T=a[A>>>24]<<24^a[O>>16&255]<<16^a[S>>8&255]<<8^a[E&255]^s[L+3];b[r]=C(y^c);b[r+1]=C(T^d);b[r+2]=C(k^m);b[r+3]=C(w^p);c=M;d=x;m=j;p=D;r=r+4}return b.buffer};return t}()},"./src/crypt/decrypter.ts":
113
+ /*! exports provided: removePadding, default */function(t,i,n){n.r(i),n.d(i,"removePadding",(function(){return e})),n.d(i,"default",(function(){return s}));var r=n(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function e(t){var i=t.byteLength,n=i&&new DataView(t.buffer).getUint8(i-1);return n?Object(r.sliceUint8)(t,0,i-n):t}var s=function(){function t(){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()}var i=t.prototype;return i.uint8ArrayToUint32Array_=function(t){for(var i=new DataView(t),n=new Uint32Array(4),r=0;r<4;r++)n[r]=i.getUint32(4*r);return n},i.initTable=function(){var t=this.sBox,i=this.invSBox,n=this.subMix,r=n[0],e=n[1],s=n[2],a=n[3],o=this.invSubMix,h=o[0],u=o[1],c=o[2],f=o[3],l=new Uint32Array(256),v=0,d=0,m=0;for(m=0;m<256;m++)l[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var p=d^d<<1^d<<2^d<<3^d<<4;t[v]=p=p>>>8^255&p^99,i[p]=v;var g=l[v],b=l[g],y=l[b],w=257*l[p]^16843008*p;r[v]=w<<24|w>>>8,e[v]=w<<16|w>>>16,s[v]=w<<8|w>>>24,a[v]=w,h[p]=(w=16843009*y^65537*b^257*g^16843008*v)<<24|w>>>8,u[p]=w<<16|w>>>16,c[p]=w<<8|w>>>24,f[p]=w,v?(v=g^l[l[l[y^g]]],d^=l[l[d]]):v=d=1}},i.expandKey=function(t){for(var i=this.uint8ArrayToUint32Array_(t),n=!0,r=0;r<i.length&&n;)n=i[r]===this.key[r],r++;if(!n){this.key=i;var e=this.keySize=i.length;if(4!==e&&6!==e&&8!==e)throw new Error("Invalid aes key size="+e);var s,a,o,h,u=this.ksRows=4*(e+6+1),c=this.keySchedule=new Uint32Array(u),f=this.invKeySchedule=new Uint32Array(u),l=this.sBox,v=this.rcon,d=this.invSubMix,m=d[0],p=d[1],g=d[2],b=d[3];for(s=0;s<u;s++)s<e?o=c[s]=i[s]:(h=o,s%e==0?(h=l[(h=h<<8|h>>>24)>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[255&h],h^=v[s/e|0]<<24):e>6&&s%e==4&&(h=l[h>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[255&h]),c[s]=o=(c[s-e]^h)>>>0);for(a=0;a<u;a++)s=u-a,h=3&a?c[s]:c[s-4],f[a]=a<4||s<=4?h:m[l[h>>>24]]^p[l[h>>>16&255]]^g[l[h>>>8&255]]^b[l[255&h]],f[a]=f[a]>>>0}},i.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},i.decrypt=function(t,i,n){for(var r,e,s,a,o,h,u,c,f,l,v,d,m,p=this.keySize+6,g=this.invKeySchedule,b=this.invSBox,y=this.invSubMix,w=y[0],k=y[1],T=y[2],O=y[3],S=this.uint8ArrayToUint32Array_(n),E=S[0],A=S[1],M=S[2],x=S[3],j=new Int32Array(t),D=new Int32Array(j.length),L=this.networkToHostOrderSwap;i<j.length;){for(c=L(j[i]),f=L(j[i+1]),l=L(j[i+2]),v=L(j[i+3]),a=c^g[0],o=v^g[1],h=l^g[2],u=f^g[3],d=4,m=1;m<p;m++)r=w[o>>>24]^k[h>>16&255]^T[u>>8&255]^O[255&a]^g[d+1],e=w[h>>>24]^k[u>>16&255]^T[a>>8&255]^O[255&o]^g[d+2],s=w[u>>>24]^k[a>>16&255]^T[o>>8&255]^O[255&h]^g[d+3],a=w[a>>>24]^k[o>>16&255]^T[h>>8&255]^O[255&u]^g[d],o=r,h=e,u=s,d+=4;r=b[o>>>24]<<24^b[h>>16&255]<<16^b[u>>8&255]<<8^b[255&a]^g[d+1],e=b[h>>>24]<<24^b[u>>16&255]<<16^b[a>>8&255]<<8^b[255&o]^g[d+2],s=b[u>>>24]<<24^b[a>>16&255]<<16^b[o>>8&255]<<8^b[255&h]^g[d+3],D[i]=L(b[a>>>24]<<24^b[o>>16&255]<<16^b[h>>8&255]<<8^b[255&u]^g[d]^E),D[i+1]=L(s^A),D[i+2]=L(e^M),D[i+3]=L(r^x),E=c,A=f,M=l,x=v,i+=4}return D.buffer},t}()},"./src/crypt/decrypter.ts":
114
114
  /*!********************************!*\
115
115
  !*** ./src/crypt/decrypter.ts ***!
116
116
  \********************************/
117
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return o}));var e=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts");var n=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts");var s=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var f=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");var h=16;var o=function(){function t(t,i,r){var e=r===void 0?{}:r,n=e.removePKCS7Padding,s=n===void 0?true:n;this.logEnabled=true;this.observer=void 0;this.config=void 0;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.observer=t;this.config=i;this.removePKCS7Padding=s;if(s){try{var a=self.crypto;if(a){this.subtle=a.subtle||a.webkitSubtle}}catch(t){}}if(this.subtle===null){this.config.enableSoftwareAES=true}}var i=t.prototype;i.destroy=function t(){this.observer=null};i.isSync=function t(){return this.config.enableSoftwareAES};i.flush=function t(){var i=this.currentResult;if(!i){this.reset();return}var r=new Uint8Array(i);this.reset();if(this.removePKCS7Padding){return Object(s["removePadding"])(r)}return r};i.reset=function t(){this.currentResult=null;this.currentIV=null;this.remainderData=null;if(this.softwareDecrypter){this.softwareDecrypter=null}};i.decrypt=function t(i,r,e,n){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(i),r,e);var s=this.flush();if(s){n(s.buffer)}}else{this.webCryptoDecrypt(new Uint8Array(i),r,e).then(n)}};i.softwareDecrypt=function t(i,r,e){var n=this.currentIV,a=this.currentResult,h=this.remainderData;this.logOnce("JS AES decrypt");if(h){i=Object(u["appendUint8Array"])(h,i);this.remainderData=null}var o=this.getValidChunk(i);if(!o.length){return null}if(n){e=n}var v=this.softwareDecrypter;if(!v){v=this.softwareDecrypter=new s["default"]}v.expandKey(r);var l=a;this.currentResult=v.decrypt(o.buffer,0,e);this.currentIV=Object(f["sliceUint8"])(o,-16).buffer;if(!l){return null}return l};i.webCryptoDecrypt=function t(i,r,s){var a=this;var u=this.subtle;if(this.key!==r||!this.fastAesKey){this.key=r;this.fastAesKey=new n["default"](u,r)}return this.fastAesKey.expandKey().then((function(t){if(!u){return Promise.reject(new Error("web crypto not initialized"))}var r=new e["default"](u,s);return r.decrypt(i.buffer,t)})).catch((function(t){return a.onWebCryptoError(t,i,r,s)}))};i.onWebCryptoError=function t(i,r,e,n){a["logger"].warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",i);this.config.enableSoftwareAES=true;this.logEnabled=true;return this.softwareDecrypt(r,e,n)};i.getValidChunk=function t(i){var r=i;var e=i.length-i.length%h;if(e!==i.length){r=Object(f["sliceUint8"])(i,0,e);this.remainderData=Object(f["sliceUint8"])(i,e)}return r};i.logOnce=function t(i){if(!this.logEnabled){return}a["logger"].log("[decrypter.ts]: "+i);this.logEnabled=false};return t}()},"./src/crypt/fast-aes-key.ts":
117
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return u}));var r=n(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),e=n(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),s=n(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=n(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function t(t,i,n){var r=(void 0===n?{}:n).removePKCS7Padding,e=void 0===r||r;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,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.observer=t,this.config=i,this.removePKCS7Padding=e,e)try{var s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch(t){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var i=t.prototype;return i.destroy=function(){this.observer=null},i.isSync=function(){return this.config.enableSoftwareAES},i.flush=function(){var t=this.currentResult;if(t){var i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Object(s.removePadding)(i):i}this.reset()},i.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},i.decrypt=function(t,i,n,r){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(t),i,n);var e=this.flush();e&&r(e.buffer)}else this.webCryptoDecrypt(new Uint8Array(t),i,n).then(r)},i.softwareDecrypt=function(t,i,n){var r=this.currentIV,e=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(t=Object(o.appendUint8Array)(a,t),this.remainderData=null);var u=this.getValidChunk(t);if(!u.length)return null;r&&(n=r);var c=this.softwareDecrypter;c||(c=this.softwareDecrypter=new s.default),c.expandKey(i);var f=e;return this.currentResult=c.decrypt(u.buffer,0,n),this.currentIV=Object(h.sliceUint8)(u,-16).buffer,f||null},i.webCryptoDecrypt=function(t,i,n){var s=this,a=this.subtle;return this.key===i&&this.fastAesKey||(this.key=i,this.fastAesKey=new e.default(a,i)),this.fastAesKey.expandKey().then((function(i){return a?new r.default(a,n).decrypt(t.buffer,i):Promise.reject(new Error("web crypto not initialized"))})).catch((function(r){return s.onWebCryptoError(r,t,i,n)}))},i.onWebCryptoError=function(t,i,n,r){return a.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",t),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(i,n,r)},i.getValidChunk=function(t){var i=t,n=t.length-t.length%16;return n!==t.length&&(i=Object(h.sliceUint8)(t,0,n),this.remainderData=Object(h.sliceUint8)(t,n)),i},i.logOnce=function(t){this.logEnabled&&(a.logger.log("[decrypter.ts]: "+t),this.logEnabled=!1)},t}()},"./src/crypt/fast-aes-key.ts":
118
118
  /*!***********************************!*\
119
119
  !*** ./src/crypt/fast-aes-key.ts ***!
120
120
  \***********************************/
121
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(t,i){this.subtle=void 0;this.key=void 0;this.subtle=t;this.key=i}var i=t.prototype;i.expandKey=function t(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},false,["encrypt","decrypt"])};return t}()},"./src/demux/aacdemuxer.ts":
121
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(t,i){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=i}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}()},"./src/demux/aacdemuxer.ts":
122
122
  /*!*********************************!*\
123
123
  !*** ./src/demux/aacdemuxer.ts ***!
124
124
  \*********************************/
125
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts");var n=r(/*! ./adts */"./src/demux/adts.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ../demux/id3 */"./src/demux/id3.ts");function u(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;f(t,i)}function f(t,i){f=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return f(t,i)}var h=function(t){u(i,t);function i(i,r){var e;e=t.call(this)||this;e.observer=void 0;e.config=void 0;e.observer=i;e.config=r;return e}var r=i.prototype;r.resetInitSegment=function i(r,e,n){t.prototype.resetInitSegment.call(this,r,e,n);this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:true,samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}};i.probe=function t(i){if(!i){return false}var r=a["getID3Data"](i,0)||[];var e=r.length;for(var u=i.length;e<u;e++){if(n["probe"](i,e)){s["logger"].log("ADTS sync word found !");return true}}return false};r.canParse=function t(i,r){return n["canParse"](i,r)};r.appendFrame=function t(i,r,e){n["initTrackConfig"](i,this.observer,r,e,i.manifestCodec);var s=n["appendFrame"](i,r,e,this.initPTS,this.frameIndex);if(s&&s.missing===0){return s}};return i}(e["default"]);h.minProbeByteLength=9;i["default"]=h},"./src/demux/adts.ts":
125
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),e=n(/*! ./adts */"./src/demux/adts.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! ../demux/id3 */"./src/demux/id3.ts");function o(t,i){return o=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},o(t,i)}var h=function(t){var i,n;function r(i,n){var r;return(r=t.call(this)||this).observer=void 0,r.config=void 0,r.observer=i,r.config=n,r}n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,o(i,n);var h=r.prototype;return h.resetInitSegment=function(i,n,r){t.prototype.resetInitSegment.call(this,i,n,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:i,duration:r,inputTimeScale:9e4,dropped:0}},r.probe=function(t){if(!t)return!1;for(var i=(a.getID3Data(t,0)||[]).length,n=t.length;i<n;i++)if(e.probe(t,i))return s.logger.log("ADTS sync word found !"),!0;return!1},h.canParse=function(t,i){return e.canParse(t,i)},h.appendFrame=function(t,i,n){e.initTrackConfig(t,this.observer,i,n,t.manifestCodec);var r=e.appendFrame(t,i,n,this.initPTS,this.frameIndex);if(r&&0===r.missing)return r},r}(r.default);h.minProbeByteLength=9,i.default=h},"./src/demux/adts.ts":
126
126
  /*!***************************!*\
127
127
  !*** ./src/demux/adts.ts ***!
128
128
  \***************************/
129
- /*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(t,i,r){r.r(i);r.d(i,"getAudioConfig",(function(){return a}));r.d(i,"isHeaderPattern",(function(){return u}));r.d(i,"getHeaderLength",(function(){return f}));r.d(i,"getFullFrameLength",(function(){return h}));r.d(i,"canGetFrameLength",(function(){return o}));r.d(i,"isHeader",(function(){return v}));r.d(i,"canParse",(function(){return l}));r.d(i,"probe",(function(){return c}));r.d(i,"initTrackConfig",(function(){return d}));r.d(i,"getFrameDuration",(function(){return m}));r.d(i,"parseFrameHeader",(function(){return p}));r.d(i,"appendFrame",(function(){return g}));var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../events */"./src/events.ts");function a(t,i,r,a){var u;var f;var h;var o;var v=navigator.userAgent.toLowerCase();var l=a;var c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=((i[r+2]&192)>>>6)+1;var d=(i[r+2]&60)>>>2;if(d>c.length-1){t.trigger(s["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].FRAG_PARSING_ERROR,fatal:true,reason:"invalid ADTS sampling index:"+d});return}h=(i[r+2]&1)<<2;h|=(i[r+3]&192)>>>6;e["logger"].log("manifest codec:"+a+", ADTS type:"+u+", samplingIndex:"+d);if(/firefox/i.test(v)){if(d>=6){u=5;o=new Array(4);f=d-3}else{u=2;o=new Array(2);f=d}}else if(v.indexOf("android")!==-1){u=2;o=new Array(2);f=d}else{u=5;o=new Array(4);if(a&&(a.indexOf("mp4a.40.29")!==-1||a.indexOf("mp4a.40.5")!==-1)||!a&&d>=6){f=d-3}else{if(a&&a.indexOf("mp4a.40.2")!==-1&&(d>=6&&h===1||/vivaldi/i.test(v))||!a&&h===1){u=2;o=new Array(2)}f=d}}o[0]=u<<3;o[0]|=(d&14)>>1;o[1]|=(d&1)<<7;o[1]|=h<<3;if(u===5){o[1]|=(f&14)>>1;o[2]=(f&1)<<7;o[2]|=2<<2;o[3]=0}return{config:o,samplerate:c[d],channelCount:h,codec:"mp4a.40."+u,manifestCodec:l}}function u(t,i){return t[i]===255&&(t[i+1]&246)===240}function f(t,i){return t[i+1]&1?7:9}function h(t,i){return(t[i+3]&3)<<11|t[i+4]<<3|(t[i+5]&224)>>>5}function o(t,i){return i+5<t.length}function v(t,i){return i+1<t.length&&u(t,i)}function l(t,i){return o(t,i)&&u(t,i)&&h(t,i)<=t.length-i}function c(t,i){if(v(t,i)){var r=f(t,i);if(i+r>=t.length){return false}var e=h(t,i);if(e<=r){return false}var n=i+e;return n===t.length||v(t,n)}return false}function d(t,i,r,n,s){if(!t.samplerate){var u=a(i,r,n,s);if(!u){return}t.config=u.config;t.samplerate=u.samplerate;t.channelCount=u.channelCount;t.codec=u.codec;t.manifestCodec=u.manifestCodec;e["logger"].log("parsed codec:"+t.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function m(t){return 1024*9e4/t}function p(t,i,r,e,n){var s=f(t,i);var a=h(t,i);a-=s;if(a>0){var u=r+e*n;return{headerLength:s,frameLength:a,stamp:u}}}function g(t,i,r,e,n){var s=m(t.samplerate);var a=p(i,r,e,n,s);if(a){var u=a.frameLength,f=a.headerLength,h=a.stamp;var o=f+u;var v=Math.max(0,r+o-i.length);var l;if(v){l=new Uint8Array(o-f);l.set(i.subarray(r+f,i.length),0)}else{l=i.subarray(r+f,r+o)}var c={unit:l,pts:h};if(!v){t.samples.push(c)}return{sample:c,length:o,missing:v}}}},"./src/demux/base-audio-demuxer.ts":
129
+ /*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(t,i,n){n.r(i),n.d(i,"getAudioConfig",(function(){return a})),n.d(i,"isHeaderPattern",(function(){return o})),n.d(i,"getHeaderLength",(function(){return h})),n.d(i,"getFullFrameLength",(function(){return u})),n.d(i,"canGetFrameLength",(function(){return c})),n.d(i,"isHeader",(function(){return f})),n.d(i,"canParse",(function(){return l})),n.d(i,"probe",(function(){return v})),n.d(i,"initTrackConfig",(function(){return d})),n.d(i,"getFrameDuration",(function(){return m})),n.d(i,"parseFrameHeader",(function(){return p})),n.d(i,"appendFrame",(function(){return g}));var r=n(/*! ../utils/logger */"./src/utils/logger.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ../events */"./src/events.ts");function a(t,i,n,a){var o,h,u,c,f=navigator.userAgent.toLowerCase(),l=a,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&i[n+2])>>>6);var d=(60&i[n+2])>>>2;if(!(d>v.length-1))return u=(1&i[n+2])<<2,u|=(192&i[n+3])>>>6,r.logger.log("manifest codec:"+a+", ADTS type:"+o+", samplingIndex:"+d),/firefox/i.test(f)?d>=6?(o=5,c=new Array(4),h=d-3):(o=2,c=new Array(2),h=d):-1!==f.indexOf("android")?(o=2,c=new Array(2),h=d):(o=5,c=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&d>=6?h=d-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(d>=6&&1===u||/vivaldi/i.test(f))||!a&&1===u)&&(o=2,c=new Array(2)),h=d)),c[0]=o<<3,c[0]|=(14&d)>>1,c[1]|=(1&d)<<7,c[1]|=u<<3,5===o&&(c[1]|=(14&h)>>1,c[2]=(1&h)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:v[d],channelCount:u,codec:"mp4a.40."+o,manifestCodec:l};t.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}function o(t,i){return 255===t[i]&&240==(246&t[i+1])}function h(t,i){return 1&t[i+1]?7:9}function u(t,i){return(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>>5}function c(t,i){return i+5<t.length}function f(t,i){return i+1<t.length&&o(t,i)}function l(t,i){return c(t,i)&&o(t,i)&&u(t,i)<=t.length-i}function v(t,i){if(f(t,i)){var n=h(t,i);if(i+n>=t.length)return!1;var r=u(t,i);if(r<=n)return!1;var e=i+r;return e===t.length||f(t,e)}return!1}function d(t,i,n,e,s){if(!t.samplerate){var o=a(i,n,e,s);if(!o)return;t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,r.logger.log("parsed codec:"+t.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function m(t){return 9216e4/t}function p(t,i,n,r,e){var s=h(t,i),a=u(t,i);if((a-=s)>0)return{headerLength:s,frameLength:a,stamp:n+r*e}}function g(t,i,n,r,e){var s=p(i,n,r,e,m(t.samplerate));if(s){var a,o=s.headerLength,h=s.stamp,u=o+s.frameLength,c=Math.max(0,n+u-i.length);c?(a=new Uint8Array(u-o)).set(i.subarray(n+o,i.length),0):a=i.subarray(n+o,n+u);var f={unit:a,pts:h};return c||t.samples.push(f),{sample:f,length:u,missing:c}}}},"./src/demux/base-audio-demuxer.ts":
130
130
  /*!*****************************************!*\
131
131
  !*** ./src/demux/base-audio-demuxer.ts ***!
132
132
  \*****************************************/
133
- /*! exports provided: initPTSFn, default */function(t,i,r){r.r(i);r.d(i,"initPTSFn",(function(){return h}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../demux/id3 */"./src/demux/id3.ts");var s=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts");var a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var u=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");var f=function(){function t(){this._audioTrack=void 0;this._id3Track=void 0;this.frameIndex=0;this.cachedData=null;this.initPTS=null}var i=t.prototype;i.resetInitSegment=function t(i,r,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}};i.resetTimeStamp=function t(){};i.resetContiguity=function t(){};i.canParse=function t(i,r){return false};i.appendFrame=function t(i,r,e){};i.demux=function t(i,r){if(this.cachedData){i=Object(a["appendUint8Array"])(this.cachedData,i);this.cachedData=null}var e=n["getID3Data"](i,0);var f=e?e.length:0;var o;var v;var l=this._audioTrack;var c=this._id3Track;var d=e?n["getTimeStamp"](e):undefined;var m=i.length;if(this.frameIndex===0||this.initPTS===null){this.initPTS=h(d,r)}if(e&&e.length>0){c.samples.push({pts:this.initPTS,dts:this.initPTS,data:e})}v=this.initPTS;while(f<m){if(this.canParse(i,f)){var p=this.appendFrame(l,i,f);if(p){this.frameIndex++;v=p.sample.pts;f+=p.length;o=f}else{f=m}}else if(n["canParse"](i,f)){e=n["getID3Data"](i,f);c.samples.push({pts:v,dts:v,data:e});f+=e.length;o=f}else{f++}if(f===m&&o!==m){var g=Object(u["sliceUint8"])(i,o);if(this.cachedData){this.cachedData=Object(a["appendUint8Array"])(this.cachedData,g)}else{this.cachedData=g}}}return{audioTrack:l,avcTrack:Object(s["dummyTrack"])(),id3Track:c,textTrack:Object(s["dummyTrack"])()}};i.demuxSampleAes=function t(i,r,e){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))};i.flush=function t(i){var r=this.cachedData;if(r){this.cachedData=null;this.demux(r,0)}this.frameIndex=0;return{audioTrack:this._audioTrack,avcTrack:Object(s["dummyTrack"])(),id3Track:this._id3Track,textTrack:Object(s["dummyTrack"])()}};i.destroy=function t(){};return t}();var h=function t(i,r){return Object(e["isFiniteNumber"])(i)?i*90:r*9e4};i["default"]=f},"./src/demux/chunk-cache.ts":
133
+ /*! exports provided: initPTSFn, default */function(t,i,n){n.r(i),n.d(i,"initPTSFn",(function(){return u}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../demux/id3 */"./src/demux/id3.ts"),s=n(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),a=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),o=n(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),h=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var i=t.prototype;return i.resetInitSegment=function(){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},i.resetTimeStamp=function(){},i.resetContiguity=function(){},i.canParse=function(){return!1},i.appendFrame=function(){},i.demux=function(t,i){this.cachedData&&(t=Object(a.appendUint8Array)(this.cachedData,t),this.cachedData=null);var n,r,h=e.getID3Data(t,0),c=h?h.length:0,f=this._audioTrack,l=this._id3Track,v=h?e.getTimeStamp(h):void 0,d=t.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=u(v,i)),h&&h.length>0&&l.samples.push({pts:this.initPTS,dts:this.initPTS,data:h}),r=this.initPTS;c<d;){if(this.canParse(t,c)){var m=this.appendFrame(f,t,c);m?(this.frameIndex++,r=m.sample.pts,n=c+=m.length):c=d}else e.canParse(t,c)?(h=e.getID3Data(t,c),l.samples.push({pts:r,dts:r,data:h}),n=c+=h.length):c++;if(c===d&&n!==d){var p=Object(o.sliceUint8)(t,n);this.cachedData=this.cachedData?Object(a.appendUint8Array)(this.cachedData,p):p}}return{audioTrack:f,avcTrack:Object(s.dummyTrack)(),id3Track:l,textTrack:Object(s.dummyTrack)()}},i.demuxSampleAes=function(){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},i.flush=function(){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(s.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(s.dummyTrack)()}},i.destroy=function(){},t}(),u=function(t,i){return Object(r.isFiniteNumber)(t)?90*t:9e4*i};i.default=h},"./src/demux/chunk-cache.ts":
134
134
  /*!**********************************!*\
135
135
  !*** ./src/demux/chunk-cache.ts ***!
136
136
  \**********************************/
137
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(){this.chunks=[];this.dataLength=0}var i=t.prototype;i.push=function t(i){this.chunks.push(i);this.dataLength+=i.length};i.flush=function t(){var i=this.chunks,r=this.dataLength;var e;if(!i.length){return new Uint8Array(0)}else if(i.length===1){e=i[0]}else{e=n(i,r)}this.reset();return e};i.reset=function t(){this.chunks.length=0;this.dataLength=0};return t}();function n(t,i){var r=new Uint8Array(i);var e=0;for(var n=0;n<t.length;n++){var s=t[n];r.set(s,e);e+=s.length}return r}},"./src/demux/dummy-demuxed-track.ts":
137
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(){this.chunks=[],this.dataLength=0}var i=t.prototype;return i.push=function(t){this.chunks.push(t),this.dataLength+=t.length},i.flush=function(){var t,i=this.chunks;return i.length?(t=1===i.length?i[0]:function(t,i){for(var n=new Uint8Array(i),r=0,e=0;e<t.length;e++){var s=t[e];n.set(s,r),r+=s.length}return n}(i,this.dataLength),this.reset(),t):new Uint8Array(0)},i.reset=function(){this.chunks.length=0,this.dataLength=0},t}()},"./src/demux/dummy-demuxed-track.ts":
138
138
  /*!******************************************!*\
139
139
  !*** ./src/demux/dummy-demuxed-track.ts ***!
140
140
  \******************************************/
141
- /*! exports provided: dummyTrack */function(t,i,r){r.r(i);r.d(i,"dummyTrack",(function(){return e}));function e(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":
141
+ /*! exports provided: dummyTrack */function(t,i,n){function r(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}n.r(i),n.d(i,"dummyTrack",(function(){return r}))},"./src/demux/exp-golomb.ts":
142
142
  /*!*********************************!*\
143
143
  !*** ./src/demux/exp-golomb.ts ***!
144
144
  \*********************************/
145
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n=function(){function t(t){this.data=void 0;this.bytesAvailable=void 0;this.word=void 0;this.bitsAvailable=void 0;this.data=t;this.bytesAvailable=t.byteLength;this.word=0;this.bitsAvailable=0}var i=t.prototype;i.loadWord=function t(){var i=this.data;var r=this.bytesAvailable;var e=i.byteLength-r;var n=new Uint8Array(4);var s=Math.min(4,r);if(s===0){throw new Error("no bytes available")}n.set(i.subarray(e,e+s));this.word=new DataView(n.buffer).getUint32(0);this.bitsAvailable=s*8;this.bytesAvailable-=s};i.skipBits=function t(i){var r;if(this.bitsAvailable>i){this.word<<=i;this.bitsAvailable-=i}else{i-=this.bitsAvailable;r=i>>3;i-=r>>3;this.bytesAvailable-=r;this.loadWord();this.word<<=i;this.bitsAvailable-=i}};i.readBits=function t(i){var r=Math.min(this.bitsAvailable,i);var n=this.word>>>32-r;if(i>32){e["logger"].error("Cannot read more than 32 bits at a time")}this.bitsAvailable-=r;if(this.bitsAvailable>0){this.word<<=r}else if(this.bytesAvailable>0){this.loadWord()}r=i-r;if(r>0&&this.bitsAvailable){return n<<r|this.readBits(r)}else{return n}};i.skipLZ=function t(){var i;for(i=0;i<this.bitsAvailable;++i){if((this.word&2147483648>>>i)!==0){this.word<<=i;this.bitsAvailable-=i;return i}}this.loadWord();return i+this.skipLZ()};i.skipUEG=function t(){this.skipBits(1+this.skipLZ())};i.skipEG=function t(){this.skipBits(1+this.skipLZ())};i.readUEG=function t(){var i=this.skipLZ();return this.readBits(i+1)-1};i.readEG=function t(){var i=this.readUEG();if(1&i){return 1+i>>>1}else{return-1*(i>>>1)}};i.readBoolean=function t(){return this.readBits(1)===1};i.readUByte=function t(){return this.readBits(8)};i.readUShort=function t(){return this.readBits(16)};i.readUInt=function t(){return this.readBits(32)};i.skipScalingList=function t(i){var r=8;var e=8;var n;for(var s=0;s<i;s++){if(e!==0){n=this.readEG();e=(r+n+256)%256}r=e===0?r:e}};i.readSPS=function t(){var i=0;var r=0;var e=0;var n=0;var s;var a;var u;var f=this.readUByte.bind(this);var h=this.readBits.bind(this);var o=this.readUEG.bind(this);var v=this.readBoolean.bind(this);var l=this.skipBits.bind(this);var c=this.skipEG.bind(this);var d=this.skipUEG.bind(this);var m=this.skipScalingList.bind(this);f();var p=f();h(5);l(3);f();d();if(p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128){var g=o();if(g===3){l(1)}d();d();l(1);if(v()){a=g!==3?8:12;for(u=0;u<a;u++){if(v()){if(u<6){m(16)}else{m(64)}}}}}d();var b=o();if(b===0){o()}else if(b===1){l(1);c();c();s=o();for(u=0;u<s;u++){c()}}d();l(1);var y=o();var w=o();var k=h(1);if(k===0){l(1)}l(1);if(v()){i=o();r=o();e=o();n=o()}var T=[1,1];if(v()){if(v()){var O=f();switch(O){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:{T=[f()<<8|f(),f()<<8|f()];break}}}}return{width:Math.ceil((y+1)*16-i*2-r*2),height:(2-k)*(w+1)*16-(k?2:4)*(e+n),pixelRatio:T}};i.readSliceType=function t(){this.readUByte();this.readUEG();return this.readUEG()};return t}();i["default"]=n},"./src/demux/id3.ts":
145
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../utils/logger */"./src/utils/logger.ts");i.default=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var i=t.prototype;return i.loadWord=function(){var t=this.data,i=this.bytesAvailable,n=t.byteLength-i,r=new Uint8Array(4),e=Math.min(4,i);if(0===e)throw new Error("no bytes available");r.set(t.subarray(n,n+e)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e},i.skipBits=function(t){var i;this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(i=t>>3)>>3,this.bytesAvailable-=i,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},i.readBits=function(t){var i=Math.min(this.bitsAvailable,t),n=this.word>>>32-i;return t>32&&r.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=i,this.bitsAvailable>0?this.word<<=i:this.bytesAvailable>0&&this.loadWord(),(i=t-i)>0&&this.bitsAvailable?n<<i|this.readBits(i):n},i.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},i.skipUEG=function(){this.skipBits(1+this.skipLZ())},i.skipEG=function(){this.skipBits(1+this.skipLZ())},i.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},i.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},i.readBoolean=function(){return 1===this.readBits(1)},i.readUByte=function(){return this.readBits(8)},i.readUShort=function(){return this.readBits(16)},i.readUInt=function(){return this.readBits(32)},i.skipScalingList=function(t){for(var i=8,n=8,r=0;r<t;r++)0!==n&&(n=(i+this.readEG()+256)%256),i=0===n?i:n},i.readSPS=function(){var t,i,n,r=0,e=0,s=0,a=0,o=this.readUByte.bind(this),h=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),f=this.skipBits.bind(this),l=this.skipEG.bind(this),v=this.skipUEG.bind(this),d=this.skipScalingList.bind(this);o();var m=o();if(h(5),f(3),o(),v(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){var p=u();if(3===p&&f(1),v(),v(),f(1),c())for(i=3!==p?8:12,n=0;n<i;n++)c()&&d(n<6?16:64)}v();var g=u();if(0===g)u();else if(1===g)for(f(1),l(),l(),t=u(),n=0;n<t;n++)l();v(),f(1);var b=u(),y=u(),w=h(1);0===w&&f(1),f(1),c()&&(r=u(),e=u(),s=u(),a=u());var k=[1,1];if(c()&&c())switch(o()){case 1:k=[1,1];break;case 2:k=[12,11];break;case 3:k=[10,11];break;case 4:k=[16,11];break;case 5:k=[40,33];break;case 6:k=[24,11];break;case 7:k=[20,11];break;case 8:k=[32,11];break;case 9:k=[80,33];break;case 10:k=[18,11];break;case 11:k=[15,11];break;case 12:k=[64,33];break;case 13:k=[160,99];break;case 14:k=[4,3];break;case 15:k=[3,2];break;case 16:k=[2,1];break;case 255:k=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(b+1)-2*r-2*e),height:(2-w)*(y+1)*16-(w?2:4)*(s+a),pixelRatio:k}},i.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}()},"./src/demux/id3.ts":
146
146
  /*!**************************!*\
147
147
  !*** ./src/demux/id3.ts ***!
148
148
  \**************************/
149
- /*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(t,i,r){r.r(i);r.d(i,"isHeader",(function(){return e}));r.d(i,"isFooter",(function(){return n}));r.d(i,"getID3Data",(function(){return s}));r.d(i,"canParse",(function(){return u}));r.d(i,"getTimeStamp",(function(){return f}));r.d(i,"isTimeStampFrame",(function(){return h}));r.d(i,"getID3Frames",(function(){return v}));r.d(i,"decodeFrame",(function(){return l}));r.d(i,"utf8ArrayToStr",(function(){return g}));r.d(i,"testables",(function(){return b}));var e=function t(i,r){if(r+10<=i.length){if(i[r]===73&&i[r+1]===68&&i[r+2]===51){if(i[r+3]<255&&i[r+4]<255){if(i[r+6]<128&&i[r+7]<128&&i[r+8]<128&&i[r+9]<128){return true}}}}return false};var n=function t(i,r){if(r+10<=i.length){if(i[r]===51&&i[r+1]===68&&i[r+2]===73){if(i[r+3]<255&&i[r+4]<255){if(i[r+6]<128&&i[r+7]<128&&i[r+8]<128&&i[r+9]<128){return true}}}}return false};var s=function t(i,r){var s=r;var u=0;while(e(i,r)){u+=10;var f=a(i,r+6);u+=f;if(n(i,r+10)){u+=10}r+=u}if(u>0){return i.subarray(s,s+u)}return undefined};var a=function t(i,r){var e=0;e=(i[r]&127)<<21;e|=(i[r+1]&127)<<14;e|=(i[r+2]&127)<<7;e|=i[r+3]&127;return e};var u=function t(i,r){return e(i,r)&&a(i,r+6)+10<=i.length-r};var f=function t(i){var r=v(i);for(var e=0;e<r.length;e++){var n=r[e];if(h(n)){return p(n)}}return undefined};var h=function t(i){return i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp"};var o=function t(i){var r=String.fromCharCode(i[0],i[1],i[2],i[3]);var e=a(i,4);var n=10;return{type:r,size:e,data:i.subarray(n,n+e)}};var v=function t(i){var r=0;var s=[];while(e(i,r)){var u=a(i,r+6);r+=10;var f=r+u;while(r+8<f){var h=o(i.subarray(r));var v=l(h);if(v){s.push(v)}r+=h.size+10}if(n(i,r)){r+=10}}return s};var l=function t(i){if(i.type==="PRIV"){return c(i)}else if(i.type[0]==="W"){return m(i)}return d(i)};var c=function t(i){if(i.size<2){return undefined}var r=g(i.data,true);var e=new Uint8Array(i.data.subarray(r.length+1));return{key:i.type,info:r,data:e.buffer}};var d=function t(i){if(i.size<2){return undefined}if(i.type==="TXXX"){var r=1;var e=g(i.data.subarray(r),true);r+=e.length+1;var n=g(i.data.subarray(r));return{key:i.type,info:e,data:n}}var s=g(i.data.subarray(1));return{key:i.type,data:s}};var m=function t(i){if(i.type==="WXXX"){if(i.size<2){return undefined}var r=1;var e=g(i.data.subarray(r),true);r+=e.length+1;var n=g(i.data.subarray(r));return{key:i.type,info:e,data:n}}var s=g(i.data);return{key:i.type,data:s}};var p=function t(i){if(i.data.byteLength===8){var r=new Uint8Array(i.data);var e=r[3]&1;var n=(r[4]<<23)+(r[5]<<15)+(r[6]<<7)+r[7];n/=45;if(e){n+=47721858.84}return Math.round(n)}return undefined};var g=function t(i,r){if(r===void 0){r=false}var e=w();if(e){var n=e.decode(i);if(r){var s=n.indexOf("\0");return s!==-1?n.substring(0,s):n}return n.replace(/\0/g,"")}var a=i.length;var u;var f;var h;var o="";var v=0;while(v<a){u=i[v++];if(u===0&&r){return o}else if(u===0||u===3){continue}switch(u>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(u);break;case 12:case 13:f=i[v++];o+=String.fromCharCode((u&31)<<6|f&63);break;case 14:f=i[v++];h=i[v++];o+=String.fromCharCode((u&15)<<12|(f&63)<<6|(h&63)<<0);break}}return o};var b={decodeTextFrame:d};var y;function w(){if(!y&&typeof self.TextDecoder!=="undefined"){y=new self.TextDecoder("utf-8")}return y}},"./src/demux/mp3demuxer.ts":
149
+ /*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(t,i,n){n.r(i),n.d(i,"isHeader",(function(){return e})),n.d(i,"isFooter",(function(){return s})),n.d(i,"getID3Data",(function(){return a})),n.d(i,"canParse",(function(){return h})),n.d(i,"getTimeStamp",(function(){return u})),n.d(i,"isTimeStampFrame",(function(){return c})),n.d(i,"getID3Frames",(function(){return l})),n.d(i,"decodeFrame",(function(){return v})),n.d(i,"utf8ArrayToStr",(function(){return b})),n.d(i,"testables",(function(){return y}));var r,e=function(t,i){return i+10<=t.length&&73===t[i]&&68===t[i+1]&&51===t[i+2]&&t[i+3]<255&&t[i+4]<255&&t[i+6]<128&&t[i+7]<128&&t[i+8]<128&&t[i+9]<128},s=function(t,i){return i+10<=t.length&&51===t[i]&&68===t[i+1]&&73===t[i+2]&&t[i+3]<255&&t[i+4]<255&&t[i+6]<128&&t[i+7]<128&&t[i+8]<128&&t[i+9]<128},a=function(t,i){for(var n=i,r=0;e(t,i);)r+=10,r+=o(t,i+6),s(t,i+10)&&(r+=10),i+=r;if(r>0)return t.subarray(n,n+r)},o=function(t,i){var n=0;return n=(127&t[i])<<21,n|=(127&t[i+1])<<14,(n|=(127&t[i+2])<<7)|127&t[i+3]},h=function(t,i){return e(t,i)&&o(t,i+6)+10<=t.length-i},u=function(t){for(var i=l(t),n=0;n<i.length;n++){var r=i[n];if(c(r))return g(r)}},c=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},f=function(t){var i=String.fromCharCode(t[0],t[1],t[2],t[3]),n=o(t,4);return{type:i,size:n,data:t.subarray(10,10+n)}},l=function(t){for(var i=0,n=[];e(t,i);){for(var r=o(t,i+6),a=(i+=10)+r;i+8<a;){var h=f(t.subarray(i)),u=v(h);u&&n.push(u),i+=h.size+10}s(t,i)&&(i+=10)}return n},v=function(t){return"PRIV"===t.type?d(t):"W"===t.type[0]?p(t):m(t)},d=function(t){if(!(t.size<2)){var i=b(t.data,!0),n=new Uint8Array(t.data.subarray(i.length+1));return{key:t.type,info:i,data:n.buffer}}},m=function(t){if(!(t.size<2)){if("TXXX"===t.type){var i=1,n=b(t.data.subarray(i),!0),r=b(t.data.subarray(i+=n.length+1));return{key:t.type,info:n,data:r}}var e=b(t.data.subarray(1));return{key:t.type,data:e}}},p=function(t){if("WXXX"===t.type){if(t.size<2)return;var i=1,n=b(t.data.subarray(i),!0),r=b(t.data.subarray(i+=n.length+1));return{key:t.type,info:n,data:r}}var e=b(t.data);return{key:t.type,data:e}},g=function(t){if(8===t.data.byteLength){var i=new Uint8Array(t.data),n=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return n/=45,1&i[3]&&(n+=47721858.84),Math.round(n)}},b=function(t,i){void 0===i&&(i=!1);var n=w();if(n){var r=n.decode(t);if(i){var e=r.indexOf("\0");return-1!==e?r.substring(0,e):r}return r.replace(/\0/g,"")}for(var s,a,o,h=t.length,u="",c=0;c<h;){if(0===(s=t[c++])&&i)return u;if(0!==s&&3!==s)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:a=t[c++],u+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=t[c++],o=t[c++],u+=String.fromCharCode((15&s)<<12|(63&a)<<6|(63&o)<<0)}}return u},y={decodeTextFrame:m};function w(){return r||void 0===self.TextDecoder||(r=new self.TextDecoder("utf-8")),r}},"./src/demux/mp3demuxer.ts":
150
150
  /*!*********************************!*\
151
151
  !*** ./src/demux/mp3demuxer.ts ***!
152
152
  \*********************************/
153
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts");var n=r(/*! ../demux/id3 */"./src/demux/id3.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function u(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;f(t,i)}function f(t,i){f=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return f(t,i)}var h=function(t){u(i,t);function i(){return t.apply(this,arguments)||this}var r=i.prototype;r.resetInitSegment=function i(r,e,n){t.prototype.resetInitSegment.call(this,r,e,n);this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:false,samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}};i.probe=function t(i){if(!i){return false}var r=n["getID3Data"](i,0)||[];var e=r.length;for(var u=i.length;e<u;e++){if(a["probe"](i,e)){s["logger"].log("MPEG Audio sync word found !");return true}}return false};r.canParse=function t(i,r){return a["canParse"](i,r)};r.appendFrame=function t(i,r,e){if(this.initPTS===null){return}return a["appendFrame"](i,r,e,this.initPTS,this.frameIndex)};return i}(e["default"]);h.minProbeByteLength=4;i["default"]=h},"./src/demux/mp4demuxer.ts":
153
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),e=n(/*! ../demux/id3 */"./src/demux/id3.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(t,i){return o=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},o(t,i)}var h=function(t){var i,n;function r(){return t.apply(this,arguments)||this}n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,o(i,n);var h=r.prototype;return h.resetInitSegment=function(i,n,r){t.prototype.resetInitSegment.call(this,i,n,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:i,duration:r,inputTimeScale:9e4,dropped:0}},r.probe=function(t){if(!t)return!1;for(var i=(e.getID3Data(t,0)||[]).length,n=t.length;i<n;i++)if(a.probe(t,i))return s.logger.log("MPEG Audio sync word found !"),!0;return!1},h.canParse=function(t,i){return a.canParse(t,i)},h.appendFrame=function(t,i,n){if(null!==this.initPTS)return a.appendFrame(t,i,n,this.initPTS,this.frameIndex)},r}(r.default);h.minProbeByteLength=4,i.default=h},"./src/demux/mp4demuxer.ts":
154
154
  /*!*********************************!*\
155
155
  !*** ./src/demux/mp4demuxer.ts ***!
156
156
  \*********************************/
157
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var n=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts");var s=function(){function t(t,i){this.remainderData=null;this.config=void 0;this.config=i}var i=t.prototype;i.resetTimeStamp=function t(){};i.resetInitSegment=function t(){};i.resetContiguity=function t(){};t.probe=function t(i){return Object(e["findBox"])({data:i,start:0,end:Math.min(i.length,16384)},["moof"]).length>0};i.demux=function t(i){var r=i;var s=Object(n["dummyTrack"])();if(this.config.progressive){if(this.remainderData){r=Object(e["appendUint8Array"])(this.remainderData,i)}var a=Object(e["segmentValidRange"])(r);this.remainderData=a.remainder;s.samples=a.valid||new Uint8Array}else{s.samples=r}return{audioTrack:Object(n["dummyTrack"])(),avcTrack:s,id3Track:Object(n["dummyTrack"])(),textTrack:Object(n["dummyTrack"])()}};i.flush=function t(){var i=Object(n["dummyTrack"])();i.samples=this.remainderData||new Uint8Array;this.remainderData=null;return{audioTrack:Object(n["dummyTrack"])(),avcTrack:i,id3Track:Object(n["dummyTrack"])(),textTrack:Object(n["dummyTrack"])()}};i.demuxSampleAes=function t(i,r,e){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))};i.destroy=function t(){};return t}();s.minProbeByteLength=1024;i["default"]=s},"./src/demux/mpegaudio.ts":
157
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),e=n(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),s=function(){function t(t,i){this.remainderData=null,this.config=void 0,this.config=i}var i=t.prototype;return i.resetTimeStamp=function(){},i.resetInitSegment=function(){},i.resetContiguity=function(){},t.probe=function(t){return Object(r.findBox)({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},i.demux=function(t){var i=t,n=Object(e.dummyTrack)();if(this.config.progressive){this.remainderData&&(i=Object(r.appendUint8Array)(this.remainderData,t));var s=Object(r.segmentValidRange)(i);this.remainderData=s.remainder,n.samples=s.valid||new Uint8Array}else n.samples=i;return{audioTrack:Object(e.dummyTrack)(),avcTrack:n,id3Track:Object(e.dummyTrack)(),textTrack:Object(e.dummyTrack)()}},i.flush=function(){var t=Object(e.dummyTrack)();return t.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(e.dummyTrack)(),avcTrack:t,id3Track:Object(e.dummyTrack)(),textTrack:Object(e.dummyTrack)()}},i.demuxSampleAes=function(){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},i.destroy=function(){},t}();s.minProbeByteLength=1024,i.default=s},"./src/demux/mpegaudio.ts":
158
158
  /*!********************************!*\
159
159
  !*** ./src/demux/mpegaudio.ts ***!
160
160
  \********************************/
161
- /*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(t,i,r){r.r(i);r.d(i,"appendFrame",(function(){return f}));r.d(i,"parseHeader",(function(){return h}));r.d(i,"isHeaderPattern",(function(){return o}));r.d(i,"isHeader",(function(){return v}));r.d(i,"canParse",(function(){return l}));r.d(i,"probe",(function(){return c}));var e=null;var n=[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 s=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3];var a=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]];var u=[0,1,1,4];function f(t,i,r,e,n){if(r+24>i.length){return}var s=h(i,r);if(s&&r+s.frameLength<=i.length){var a=s.samplesPerFrame*9e4/s.sampleRate;var u=e+n*a;var f={unit:i.subarray(r,r+s.frameLength),pts:u,dts:u};t.config=[];t.channelCount=s.channelCount;t.samplerate=s.sampleRate;t.samples.push(f);return{sample:f,length:s.frameLength,missing:0}}}function h(t,i){var r=t[i+1]>>3&3;var f=t[i+1]>>1&3;var h=t[i+2]>>4&15;var o=t[i+2]>>2&3;if(r!==1&&h!==0&&h!==15&&o!==3){var v=t[i+2]>>1&1;var l=t[i+3]>>6;var c=r===3?3-f:f===3?3:4;var d=n[c*14+h-1]*1e3;var m=r===3?0:r===2?1:2;var p=s[m*3+o];var g=l===3?1:2;var b=a[r][f];var y=u[f];var w=b*8*y;var k=Math.floor(b*d/p+v)*y;if(e===null){var T=navigator.userAgent||"";var O=T.match(/Chrome\/(\d+)/i);e=O?parseInt(O[1]):0}var S=!!e&&e<=87;if(S&&f===2&&d>=224e3&&l===0){t[i+3]=t[i+3]|128}return{sampleRate:p,channelCount:g,frameLength:k,samplesPerFrame:w}}}function o(t,i){return t[i]===255&&(t[i+1]&224)===224&&(t[i+1]&6)!==0}function v(t,i){return i+1<t.length&&o(t,i)}function l(t,i){var r=4;return o(t,i)&&r<=t.length-i}function c(t,i){if(i+1<t.length&&o(t,i)){var r=4;var e=h(t,i);var n=r;if(e!==null&&e!==void 0&&e.frameLength){n=e.frameLength}var s=i+n;return s===t.length||v(t,s)}return false}},"./src/demux/sample-aes.ts":
161
+ /*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(t,i,n){n.r(i),n.d(i,"appendFrame",(function(){return h})),n.d(i,"parseHeader",(function(){return u})),n.d(i,"isHeaderPattern",(function(){return c})),n.d(i,"isHeader",(function(){return f})),n.d(i,"canParse",(function(){return l})),n.d(i,"probe",(function(){return v}));var r=null,e=[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],s=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],a=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function h(t,i,n,r,e){if(!(n+24>i.length)){var s=u(i,n);if(s&&n+s.frameLength<=i.length){var a=r+e*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:i.subarray(n,n+s.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=s.channelCount,t.samplerate=s.sampleRate,t.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}}function u(t,i){var n=t[i+1]>>3&3,h=t[i+1]>>1&3,u=t[i+2]>>4&15,c=t[i+2]>>2&3;if(1!==n&&0!==u&&15!==u&&3!==c){var f=t[i+3]>>6,l=1e3*e[14*(3===n?3-h:3===h?3:4)+u-1],v=s[3*(3===n?0:2===n?1:2)+c],d=3===f?1:2,m=a[n][h],p=o[h],g=8*m*p,b=Math.floor(m*l/v+(t[i+2]>>1&1))*p;if(null===r){var y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);r=y?parseInt(y[1]):0}return!!r&&r<=87&&2===h&&l>=224e3&&0===f&&(t[i+3]=128|t[i+3]),{sampleRate:v,channelCount:d,frameLength:b,samplesPerFrame:g}}}function c(t,i){return 255===t[i]&&224==(224&t[i+1])&&0!=(6&t[i+1])}function f(t,i){return i+1<t.length&&c(t,i)}function l(t,i){return c(t,i)&&4<=t.length-i}function v(t,i){if(i+1<t.length&&c(t,i)){var n=u(t,i),r=4;null!=n&&n.frameLength&&(r=n.frameLength);var e=i+r;return e===t.length||f(t,e)}return!1}},"./src/demux/sample-aes.ts":
162
162
  /*!*********************************!*\
163
163
  !*** ./src/demux/sample-aes.ts ***!
164
164
  \*********************************/
165
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts");var n=r(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts");var s=function(){function t(t,i,r){this.keyData=void 0;this.decrypter=void 0;this.keyData=r;this.decrypter=new e["default"](t,i,{removePKCS7Padding:false})}var i=t.prototype;i.decryptBuffer=function t(i,r){this.decrypter.decrypt(i,this.keyData.key.buffer,this.keyData.iv.buffer,r)};i.decryptAacSample=function t(i,r,e,n){var s=i[r].unit;var a=s.subarray(16,s.length-s.length%16);var u=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);var f=this;this.decryptBuffer(u,(function(t){var a=new Uint8Array(t);s.set(a,16);if(!n){f.decryptAacSamples(i,r+1,e)}}))};i.decryptAacSamples=function t(i,r,e){for(;;r++){if(r>=i.length){e();return}if(i[r].unit.length<32){continue}var n=this.decrypter.isSync();this.decryptAacSample(i,r,e,n);if(!n){return}}};i.getAvcEncryptedData=function t(i){var r=Math.floor((i.length-48)/160)*16+16;var e=new Int8Array(r);var n=0;for(var s=32;s<i.length-16;s+=160,n+=16){e.set(i.subarray(s,s+16),n)}return e};i.getAvcDecryptedUnit=function t(i,r){var e=new Uint8Array(r);var n=0;for(var s=32;s<i.length-16;s+=160,n+=16){i.set(e.subarray(n,n+16),s)}return i};i.decryptAvcSample=function t(i,r,e,s,a,u){var f=Object(n["discardEPB"])(a.data);var h=this.getAvcEncryptedData(f);var o=this;this.decryptBuffer(h.buffer,(function(t){a.data=o.getAvcDecryptedUnit(f,t);if(!u){o.decryptAvcSamples(i,r,e+1,s)}}))};i.decryptAvcSamples=function t(i,r,e,n){if(i instanceof Uint8Array){throw new Error("Cannot decrypt samples of type Uint8Array")}for(;;r++,e=0){if(r>=i.length){n();return}var s=i[r].units;for(;;e++){if(e>=s.length){break}var a=s[e];if(a.data.length<=48||a.type!==1&&a.type!==5){continue}var u=this.decrypter.isSync();this.decryptAvcSample(i,r,e,n,a,u);if(!u){return}}}};return t}();i["default"]=s},"./src/demux/transmuxer-interface.ts":
165
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),e=n(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts");i.default=function(){function t(t,i,n){this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new r.default(t,i,{removePKCS7Padding:!1})}var i=t.prototype;return i.decryptBuffer=function(t,i){this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,i)},i.decryptAacSample=function(t,i,n,r){var e=t[i].unit,s=e.subarray(16,e.length-e.length%16),a=s.buffer.slice(s.byteOffset,s.byteOffset+s.length),o=this;this.decryptBuffer(a,(function(s){var a=new Uint8Array(s);e.set(a,16),r||o.decryptAacSamples(t,i+1,n)}))},i.decryptAacSamples=function(t,i,n){for(;;i++){if(i>=t.length)return void n();if(!(t[i].unit.length<32)){var r=this.decrypter.isSync();if(this.decryptAacSample(t,i,n,r),!r)return}}},i.getAvcEncryptedData=function(t){for(var i=16*Math.floor((t.length-48)/160)+16,n=new Int8Array(i),r=0,e=32;e<t.length-16;e+=160,r+=16)n.set(t.subarray(e,e+16),r);return n},i.getAvcDecryptedUnit=function(t,i){for(var n=new Uint8Array(i),r=0,e=32;e<t.length-16;e+=160,r+=16)t.set(n.subarray(r,r+16),e);return t},i.decryptAvcSample=function(t,i,n,r,s,a){var o=Object(e.discardEPB)(s.data),h=this.getAvcEncryptedData(o),u=this;this.decryptBuffer(h.buffer,(function(e){s.data=u.getAvcDecryptedUnit(o,e),a||u.decryptAvcSamples(t,i,n+1,r)}))},i.decryptAvcSamples=function(t,i,n,r){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;i++,n=0){if(i>=t.length)return void r();for(var e=t[i].units;!(n>=e.length);n++){var s=e[n];if(!(s.data.length<=48||1!==s.type&&5!==s.type)){var a=this.decrypter.isSync();if(this.decryptAvcSample(t,i,n,r,s,a),!a)return}}}},t}()},"./src/demux/transmuxer-interface.ts":
166
166
  /*!*******************************************!*\
167
167
  !*** ./src/demux/transmuxer-interface.ts ***!
168
168
  \*******************************************/
169
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return v}));var e=r(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=r(/*! ../errors */"./src/errors.ts");var f=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts");var h=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");var o=Object(f["getMediaSource"])()||{isTypeSupported:function t(){return false}};var v=function(){function t(t,i,r,f){var v=this;this.hls=void 0;this.id=void 0;this.observer=void 0;this.frag=null;this.part=null;this.worker=void 0;this.onwmsg=void 0;this.transmuxer=null;this.onTransmuxComplete=void 0;this.onFlush=void 0;this.hls=t;this.id=i;this.onTransmuxComplete=r;this.onFlush=f;var l=t.config;var c=function i(r,e){e=e||{};e.frag=v.frag;e.id=v.id;t.trigger(r,e)};this.observer=new h["EventEmitter"];this.observer.on(n["Events"].FRAG_DECRYPTED,c);this.observer.on(n["Events"].ERROR,c);var d={mp4:o.isTypeSupported("video/mp4"),mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"')};var m=navigator.vendor;if(l.enableWorker&&typeof Worker!=="undefined"){a["logger"].log("demuxing in webworker");var p;try{p=this.worker=e(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts");this.onwmsg=this.onWorkerMessage.bind(this);p.addEventListener("message",this.onwmsg);p.onerror=function(i){t.trigger(n["Events"].ERROR,{type:u["ErrorTypes"].OTHER_ERROR,details:u["ErrorDetails"].INTERNAL_EXCEPTION,fatal:true,event:"demuxerWorker",error:new Error(i.message+" ("+i.filename+":"+i.lineno+")")})};p.postMessage({cmd:"init",typeSupported:d,vendor:m,id:i,config:JSON.stringify(l)})}catch(t){a["logger"].warn("Error in worker:",t);a["logger"].error("Error while initializing DemuxerWorker, fallback to inline");if(p){self.URL.revokeObjectURL(p.objectURL)}this.transmuxer=new s["default"](this.observer,d,l,m,i);this.worker=null}}else{this.transmuxer=new s["default"](this.observer,d,l,m,i)}}var i=t.prototype;i.destroy=function t(){var i=this.worker;if(i){i.removeEventListener("message",this.onwmsg);i.terminate();this.worker=null}else{var r=this.transmuxer;if(r){r.destroy();this.transmuxer=null}}var e=this.observer;if(e){e.removeAllListeners()}this.observer=null};i.push=function t(i,r,e,n,u,f,h,o,v,l){var c,d,m=this;v.transmuxing.start=self.performance.now();var p=this.transmuxer,g=this.worker;var b=f?f.start:u.start;var y=u.decryptdata;var w=this.frag;var k=!(w&&u.cc===w.cc);var T=!(w&&v.level===w.level);var O=w?v.sn-w.sn:-1;var S=this.part?v.part-this.part.index:1;var E=!T&&(O===1||O===0&&S===1);var A=self.performance.now();if(T||O||u.stats.parsing.start===0){u.stats.parsing.start=A}if(f&&(S||!E)){f.stats.parsing.start=A}var M=!(w&&((c=u.initSegment)===null||c===void 0?void 0:c.url)===((d=w.initSegment)===null||d===void 0?void 0:d.url));var x=new s["TransmuxState"](k,E,o,T,b,M);if(!E||k||M){a["logger"].log("[transmuxer-interface, "+u.type+"]: Starting new transmux session for sn: "+v.sn+" p: "+v.part+" level: "+v.level+" id: "+v.id+"\n discontinuity: "+k+"\n trackSwitch: "+T+"\n contiguous: "+E+"\n accurateTimeOffset: "+o+"\n timeOffset: "+b+"\n initSegmentChange: "+M);var j=new s["TransmuxConfig"](e,n,r,h,l);this.configureTransmuxer(j)}this.frag=u;this.part=f;if(g){g.postMessage({cmd:"demux",data:i,decryptdata:y,chunkMeta:v,state:x},i instanceof ArrayBuffer?[i]:[])}else if(p){var D=p.push(i,y,v,x);if(Object(s["isPromise"])(D)){D.then((function(t){m.handleTransmuxComplete(t)}))}else{this.handleTransmuxComplete(D)}}};i.flush=function t(i){var r=this;i.transmuxing.start=self.performance.now();var e=this.transmuxer,n=this.worker;if(n){n.postMessage({cmd:"flush",chunkMeta:i})}else if(e){var a=e.flush(i);if(Object(s["isPromise"])(a)){a.then((function(t){r.handleFlushResult(t,i)}))}else{this.handleFlushResult(a,i)}}};i.handleFlushResult=function t(i,r){var e=this;i.forEach((function(t){e.handleTransmuxComplete(t)}));this.onFlush(r)};i.onWorkerMessage=function t(i){var r=i.data;var e=this.hls;switch(r.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(r.data);break}case"flush":{this.onFlush(r.data);break}default:{r.data=r.data||{};r.data.frag=this.frag;r.data.id=this.id;e.trigger(r.event,r.data);break}}};i.configureTransmuxer=function t(i){var r=this.worker,e=this.transmuxer;if(r){r.postMessage({cmd:"configure",config:i})}else if(e){e.configure(i)}};i.handleTransmuxComplete=function t(i){i.chunkMeta.transmuxing.end=self.performance.now();this.onTransmuxComplete(i)};return t}()},"./src/demux/transmuxer-worker.ts":
169
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return f}));var r=n(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ../errors */"./src/errors.ts"),h=n(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=n(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),c=Object(h.getMediaSource)()||{isTypeSupported:function(){return!1}},f=function(){function t(t,i,n,h){var f=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=t,this.id=i,this.onTransmuxComplete=n,this.onFlush=h;var l=t.config,v=function(i,n){(n=n||{}).frag=f.frag,n.id=f.id,t.trigger(i,n)};this.observer=new u.EventEmitter,this.observer.on(e.Events.FRAG_DECRYPTED,v),this.observer.on(e.Events.ERROR,v);var d={mp4:c.isTypeSupported("video/mp4"),mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"')},m=navigator.vendor;if(l.enableWorker&&"undefined"!=typeof Worker){var p;a.logger.log("demuxing in webworker");try{p=this.worker=r(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(i){t.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(i.message+" ("+i.filename+":"+i.lineno+")")})},p.postMessage({cmd:"init",typeSupported:d,vendor:m,id:i,config:JSON.stringify(l)})}catch(t){a.logger.warn("Error in worker:",t),a.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new s.default(this.observer,d,l,m,i),this.worker=null}}else this.transmuxer=new s.default(this.observer,d,l,m,i)}var i=t.prototype;return i.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null;else{var i=this.transmuxer;i&&(i.destroy(),this.transmuxer=null)}var n=this.observer;n&&n.removeAllListeners(),this.observer=null},i.push=function(t,i,n,r,e,o,h,u,c,f){var l,v,d=this;c.transmuxing.start=self.performance.now();var m=this.transmuxer,p=this.worker,g=o?o.start:e.start,b=e.decryptdata,y=this.frag,w=!(y&&e.cc===y.cc),k=!(y&&c.level===y.level),T=y?c.sn-y.sn:-1,O=this.part?c.part-this.part.index:1,S=!k&&(1===T||0===T&&1===O),E=self.performance.now();(k||T||0===e.stats.parsing.start)&&(e.stats.parsing.start=E),!o||!O&&S||(o.stats.parsing.start=E);var A=!(y&&(null===(l=e.initSegment)||void 0===l?void 0:l.url)===(null===(v=y.initSegment)||void 0===v?void 0:v.url)),M=new s.TransmuxState(w,S,u,k,g,A);if(!S||w||A){a.logger.log("[transmuxer-interface, "+e.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+"\n discontinuity: "+w+"\n trackSwitch: "+k+"\n contiguous: "+S+"\n accurateTimeOffset: "+u+"\n timeOffset: "+g+"\n initSegmentChange: "+A);var x=new s.TransmuxConfig(n,r,i,h,f);this.configureTransmuxer(x)}if(this.frag=e,this.part=o,p)p.postMessage({cmd:"demux",data:t,decryptdata:b,chunkMeta:c,state:M},t instanceof ArrayBuffer?[t]:[]);else if(m){var j=m.push(t,b,c,M);Object(s.isPromise)(j)?j.then((function(t){d.handleTransmuxComplete(t)})):this.handleTransmuxComplete(j)}},i.flush=function(t){var i=this;t.transmuxing.start=self.performance.now();var n=this.transmuxer,r=this.worker;if(r)r.postMessage({cmd:"flush",chunkMeta:t});else if(n){var e=n.flush(t);Object(s.isPromise)(e)?e.then((function(n){i.handleFlushResult(n,t)})):this.handleFlushResult(e,t)}},i.handleFlushResult=function(t,i){var n=this;t.forEach((function(t){n.handleTransmuxComplete(t)})),this.onFlush(i)},i.onWorkerMessage=function(t){var i=t.data,n=this.hls;switch(i.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(i.data);break;case"flush":this.onFlush(i.data);break;default:i.data=i.data||{},i.data.frag=this.frag,i.data.id=this.id,n.trigger(i.event,i.data)}},i.configureTransmuxer=function(t){var i=this.worker,n=this.transmuxer;i?i.postMessage({cmd:"configure",config:t}):n&&n.configure(t)},i.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},t}()},"./src/demux/transmuxer-worker.ts":
170
170
  /*!****************************************!*\
171
171
  !*** ./src/demux/transmuxer-worker.ts ***!
172
172
  \****************************************/
173
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return u}));var e=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function u(t){var i=new a["EventEmitter"];var r=function i(r,e){t.postMessage({event:r,data:e})};i.on(n["Events"].FRAG_DECRYPTED,r);i.on(n["Events"].ERROR,r);t.addEventListener("message",(function(n){var a=n.data;switch(a.cmd){case"init":{var u=JSON.parse(a.config);t.transmuxer=new e["default"](i,a.typeSupported,u,a.vendor,a.id);Object(s["enableLogs"])(u.debug);r("init",null);break}case"configure":{t.transmuxer.configure(a.config);break}case"demux":{var h=t.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);if(Object(e["isPromise"])(h)){h.then((function(i){f(t,i)}))}else{f(t,h)}break}case"flush":{var v=a.chunkMeta;var l=t.transmuxer.flush(v);if(Object(e["isPromise"])(l)){l.then((function(i){o(t,i,v)}))}else{o(t,l,v)}break}}}))}function f(t,i){if(v(i.remuxResult)){return}var r=[];var e=i.remuxResult,n=e.audio,s=e.video;if(n){h(r,n)}if(s){h(r,s)}t.postMessage({event:"transmuxComplete",data:i},r)}function h(t,i){if(i.data1){t.push(i.data1.buffer)}if(i.data2){t.push(i.data2.buffer)}}function o(t,i,r){i.forEach((function(i){f(t,i)}));t.postMessage({event:"flush",data:r})}function v(t){return!t.audio&&!t.video&&!t.text&&!t.id3&&!t.initSegment}},"./src/demux/transmuxer.ts":
173
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return o}));var r=n(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function o(t){var i=new a.EventEmitter,n=function(i,n){t.postMessage({event:i,data:n})};i.on(e.Events.FRAG_DECRYPTED,n),i.on(e.Events.ERROR,n),t.addEventListener("message",(function(e){var a=e.data;switch(a.cmd){case"init":var o=JSON.parse(a.config);t.transmuxer=new r.default(i,a.typeSupported,o,a.vendor,a.id),Object(s.enableLogs)(o.debug),n("init",null);break;case"configure":t.transmuxer.configure(a.config);break;case"demux":var u=t.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(r.isPromise)(u)?u.then((function(i){h(t,i)})):h(t,u);break;case"flush":var f=a.chunkMeta,l=t.transmuxer.flush(f);Object(r.isPromise)(l)?l.then((function(i){c(t,i,f)})):c(t,l,f)}}))}function h(t,i){if((n=i.remuxResult).audio||n.video||n.text||n.id3||n.initSegment){var n,r=[],e=i.remuxResult,s=e.audio,a=e.video;s&&u(r,s),a&&u(r,a),t.postMessage({event:"transmuxComplete",data:i},r)}}function u(t,i){i.data1&&t.push(i.data1.buffer),i.data2&&t.push(i.data2.buffer)}function c(t,i,n){i.forEach((function(i){h(t,i)})),t.postMessage({event:"flush",data:n})}},"./src/demux/transmuxer.ts":
174
174
  /*!*********************************!*\
175
175
  !*** ./src/demux/transmuxer.ts ***!
176
176
  \*********************************/
177
- /*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,i,r){r.r(i);r.d(i,"default",(function(){return b}));r.d(i,"isPromise",(function(){return k}));r.d(i,"TransmuxConfig",(function(){return T}));r.d(i,"TransmuxState",(function(){return O}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts");var a=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts");var u=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts");var f=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts");var h=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts");var o=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts");var v=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts");var l=r(/*! ./chunk-cache */"./src/demux/chunk-cache.ts");var c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var d=r(/*! ../utils/logger */"./src/utils/logger.ts");var m;try{m=self.performance.now.bind(self.performance)}catch(t){d["logger"].debug("Unable to use Performance API on this environment");m=self.Date.now}var p=[{demux:f["default"],remux:o["default"]},{demux:u["default"],remux:v["default"]},{demux:a["default"],remux:o["default"]},{demux:h["default"],remux:o["default"]}];var g=1024;p.forEach((function(t){var i=t.demux;g=Math.max(g,i.minProbeByteLength)}));var b=function(){function t(t,i,r,e,n){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.cache=new l["default"];this.observer=t;this.typeSupported=i;this.config=r;this.vendor=e;this.id=n}var i=t.prototype;i.configure=function t(i){this.transmuxConfig=i;if(this.decrypter){this.decrypter.reset()}};i.push=function t(i,r,e,n){var s=this;var a=e.transmuxing;a.executeStart=m();var u=new Uint8Array(i);var f=this.cache,h=this.config,o=this.currentTransmuxState,v=this.transmuxConfig;if(n){this.currentTransmuxState=n}var l=y(u,r);if(l&&l.method==="AES-128"){var d=this.getDecrypter();if(h.enableSoftwareAES){var p=d.softwareDecrypt(u,l.key.buffer,l.iv.buffer);if(!p){a.executeEnd=m();return w(e)}u=new Uint8Array(p)}else{this.decryptionPromise=d.webCryptoDecrypt(u,l.key.buffer,l.iv.buffer).then((function(t){var i=s.push(t,null,e);s.decryptionPromise=null;return i}));return this.decryptionPromise}}var g=n||o,b=g.contiguous,k=g.discontinuity,T=g.trackSwitch,O=g.accurateTimeOffset,S=g.timeOffset,E=g.initSegmentChange;var A=v.audioCodec,M=v.videoCodec,x=v.defaultInitPts,j=v.duration,D=v.initSegmentData;if(k||T||E){this.resetInitSegment(D,A,M,j)}if(k||E){this.resetInitialTimestamp(x)}if(!b){this.resetContiguity()}if(this.needsProbing(u,k,T)){if(f.dataLength){var L=f.flush();u=Object(c["appendUint8Array"])(L,u)}this.configureTransmuxer(u,v)}var I=this.transmux(u,l,S,O,e);var C=this.currentTransmuxState;C.contiguous=true;C.discontinuity=false;C.trackSwitch=false;a.executeEnd=m();return I};i.flush=function t(i){var r=this;var s=i.transmuxing;s.executeStart=m();var a=this.decrypter,u=this.cache,f=this.currentTransmuxState,h=this.decryptionPromise;if(h){return h.then((function(){return r.flush(i)}))}var o=[];var v=f.timeOffset;if(a){var l=a.flush();if(l){o.push(this.push(l,null,i))}}var c=u.dataLength;u.reset();var d=this.demuxer,p=this.remuxer;if(!d||!p){if(c>=g){this.observer.emit(e["Events"].ERROR,e["Events"].ERROR,{type:n["ErrorTypes"].MEDIA_ERROR,details:n["ErrorDetails"].FRAG_PARSING_ERROR,fatal:true,reason:"no demux matching with content found"})}s.executeEnd=m();return[w(i)]}var b=d.flush(v);if(k(b)){return b.then((function(t){r.flushRemux(o,t,i);return o}))}this.flushRemux(o,b,i);return o};i.flushRemux=function t(i,r,e){var n=r.audioTrack,s=r.avcTrack,a=r.id3Track,u=r.textTrack;var f=this.currentTransmuxState,h=f.accurateTimeOffset,o=f.timeOffset;d["logger"].log("[transmuxer.ts]: Flushed fragment "+e.sn+(e.part>-1?" p: "+e.part:"")+" of level "+e.level);var v=this.remuxer.remux(n,s,a,u,o,h,true,this.id);i.push({remuxResult:v,chunkMeta:e});e.transmuxing.executeEnd=m()};i.resetInitialTimestamp=function t(i){var r=this.demuxer,e=this.remuxer;if(!r||!e){return}r.resetTimeStamp(i);e.resetTimeStamp(i)};i.resetContiguity=function t(){var i=this.demuxer,r=this.remuxer;if(!i||!r){return}i.resetContiguity();r.resetNextTimestamp()};i.resetInitSegment=function t(i,r,e,n){var s=this.demuxer,a=this.remuxer;if(!s||!a){return}s.resetInitSegment(r,e,n);a.resetInitSegment(i,r,e)};i.destroy=function t(){if(this.demuxer){this.demuxer.destroy();this.demuxer=undefined}if(this.remuxer){this.remuxer.destroy();this.remuxer=undefined}};i.transmux=function t(i,r,e,n,s){var a;if(r&&r.method==="SAMPLE-AES"){a=this.transmuxSampleAes(i,r,e,n,s)}else{a=this.transmuxUnencrypted(i,e,n,s)}return a};i.transmuxUnencrypted=function t(i,r,e,n){var s=this.demuxer.demux(i,r,false,!this.config.progressive),a=s.audioTrack,u=s.avcTrack,f=s.id3Track,h=s.textTrack;var o=this.remuxer.remux(a,u,f,h,r,e,false,this.id);return{remuxResult:o,chunkMeta:n}};i.transmuxSampleAes=function t(i,r,e,n,s){var a=this;return this.demuxer.demuxSampleAes(i,r,e).then((function(t){var i=a.remuxer.remux(t.audioTrack,t.avcTrack,t.id3Track,t.textTrack,e,n,false,a.id);return{remuxResult:i,chunkMeta:s}}))};i.configureTransmuxer=function t(i,r){var e=this.config,n=this.observer,s=this.typeSupported,a=this.vendor;var f=r.audioCodec,h=r.defaultInitPts,o=r.duration,l=r.initSegmentData,c=r.videoCodec;var m;for(var g=0,b=p.length;g<b;g++){if(p[g].demux.probe(i)){m=p[g];break}}if(!m){d["logger"].warn("Failed to find demuxer by probing frag, treating as mp4 passthrough");m={demux:u["default"],remux:v["default"]}}var y=this.demuxer;var w=this.remuxer;var k=m.remux;var T=m.demux;if(!w||!(w instanceof k)){this.remuxer=new k(n,e,s,a)}if(!y||!(y instanceof T)){this.demuxer=new T(n,e,s);this.probe=T.probe}this.resetInitSegment(l,f,c,o);this.resetInitialTimestamp(h)};i.needsProbing=function t(i,r,e){return!this.demuxer||!this.remuxer||r||e};i.getDecrypter=function t(){var i=this.decrypter;if(!i){i=this.decrypter=new s["default"](this.observer,this.config)}return i};return t}();function y(t,i){var r=null;if(t.byteLength>0&&i!=null&&i.key!=null&&i.iv!==null&&i.method!=null){r=i}return r}var w=function t(i){return{remuxResult:{},chunkMeta:i}};function k(t){return"then"in t&&t.then instanceof Function}var T=function t(i,r,e,n,s){this.audioCodec=void 0;this.videoCodec=void 0;this.initSegmentData=void 0;this.duration=void 0;this.defaultInitPts=void 0;this.audioCodec=i;this.videoCodec=r;this.initSegmentData=e;this.duration=n;this.defaultInitPts=s};var O=function t(i,r,e,n,s,a){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=i;this.contiguous=r;this.accurateTimeOffset=e;this.trackSwitch=n;this.timeOffset=s;this.initSegmentChange=a}},"./src/demux/tsdemuxer.ts":
177
+ /*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,i,n){n.r(i),n.d(i,"default",(function(){return b})),n.d(i,"isPromise",(function(){return w})),n.d(i,"TransmuxConfig",(function(){return k})),n.d(i,"TransmuxState",(function(){return T}));var r,e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../errors */"./src/errors.ts"),a=n(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=n(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),h=n(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=n(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),c=n(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),f=n(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=n(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),v=n(/*! ./chunk-cache */"./src/demux/chunk-cache.ts"),d=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),m=n(/*! ../utils/logger */"./src/utils/logger.ts");try{r=self.performance.now.bind(self.performance)}catch(t){m.logger.debug("Unable to use Performance API on this environment"),r=self.Date.now}var p=[{demux:u.default,remux:f.default},{demux:h.default,remux:l.default},{demux:o.default,remux:f.default},{demux:c.default,remux:f.default}],g=1024;p.forEach((function(t){g=Math.max(g,t.demux.minProbeByteLength)}));var b=function(){function t(t,i,n,r,e){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.cache=new v.default,this.observer=t,this.typeSupported=i,this.config=n,this.vendor=r,this.id=e}var i=t.prototype;return i.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},i.push=function(t,i,n,e){var s=this,a=n.transmuxing;a.executeStart=r();var o=new Uint8Array(t),h=this.cache,u=this.config,c=this.currentTransmuxState,f=this.transmuxConfig;e&&(this.currentTransmuxState=e);var l=function(t,i){var n=null;return t.byteLength>0&&null!=i&&null!=i.key&&null!==i.iv&&null!=i.method&&(n=i),n}(o,i);if(l&&"AES-128"===l.method){var v=this.getDecrypter();if(!u.enableSoftwareAES)return this.decryptionPromise=v.webCryptoDecrypt(o,l.key.buffer,l.iv.buffer).then((function(t){var i=s.push(t,null,n);return s.decryptionPromise=null,i})),this.decryptionPromise;var m=v.softwareDecrypt(o,l.key.buffer,l.iv.buffer);if(!m)return a.executeEnd=r(),y(n);o=new Uint8Array(m)}var p=e||c,g=p.contiguous,b=p.discontinuity,w=p.trackSwitch,k=p.accurateTimeOffset,T=p.timeOffset,O=p.initSegmentChange,S=f.defaultInitPts;if((b||w||O)&&this.resetInitSegment(f.initSegmentData,f.audioCodec,f.videoCodec,f.duration),(b||O)&&this.resetInitialTimestamp(S),g||this.resetContiguity(),this.needsProbing(o,b,w)){if(h.dataLength){var E=h.flush();o=Object(d.appendUint8Array)(E,o)}this.configureTransmuxer(o,f)}var A=this.transmux(o,l,T,k,n),M=this.currentTransmuxState;return M.contiguous=!0,M.discontinuity=!1,M.trackSwitch=!1,a.executeEnd=r(),A},i.flush=function(t){var i=this,n=t.transmuxing;n.executeStart=r();var a=this.decrypter,o=this.cache,h=this.currentTransmuxState,u=this.decryptionPromise;if(u)return u.then((function(){return i.flush(t)}));var c=[],f=h.timeOffset;if(a){var l=a.flush();l&&c.push(this.push(l,null,t))}var v=o.dataLength;o.reset();var d=this.demuxer;if(!d||!this.remuxer)return v>=g&&this.observer.emit(e.Events.ERROR,e.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),n.executeEnd=r(),[y(t)];var m=d.flush(f);return w(m)?m.then((function(n){return i.flushRemux(c,n,t),c})):(this.flushRemux(c,m,t),c)},i.flushRemux=function(t,i,n){var e=i.audioTrack,s=i.avcTrack,a=i.id3Track,o=i.textTrack,h=this.currentTransmuxState,u=h.accurateTimeOffset,c=h.timeOffset;m.logger.log("[transmuxer.ts]: Flushed fragment "+n.sn+(n.part>-1?" p: "+n.part:"")+" of level "+n.level);var f=this.remuxer.remux(e,s,a,o,c,u,!0,this.id);t.push({remuxResult:f,chunkMeta:n}),n.transmuxing.executeEnd=r()},i.resetInitialTimestamp=function(t){var i=this.demuxer,n=this.remuxer;i&&n&&(i.resetTimeStamp(t),n.resetTimeStamp(t))},i.resetContiguity=function(){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetContiguity(),i.resetNextTimestamp())},i.resetInitSegment=function(t,i,n,r){var e=this.demuxer,s=this.remuxer;e&&s&&(e.resetInitSegment(i,n,r),s.resetInitSegment(t,i,n))},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(t,i,n,r,e){return i&&"SAMPLE-AES"===i.method?this.transmuxSampleAes(t,i,n,r,e):this.transmuxUnencrypted(t,n,r,e)},i.transmuxUnencrypted=function(t,i,n,r){var e=this.demuxer.demux(t,i,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(e.audioTrack,e.avcTrack,e.id3Track,e.textTrack,i,n,!1,this.id),chunkMeta:r}},i.transmuxSampleAes=function(t,i,n,r,e){var s=this;return this.demuxer.demuxSampleAes(t,i,n).then((function(t){return{remuxResult:s.remuxer.remux(t.audioTrack,t.avcTrack,t.id3Track,t.textTrack,n,r,!1,s.id),chunkMeta:e}}))},i.configureTransmuxer=function(t,i){for(var n,r=this.config,e=this.observer,s=this.typeSupported,a=this.vendor,o=i.audioCodec,u=i.defaultInitPts,c=i.duration,f=i.initSegmentData,v=i.videoCodec,d=0,g=p.length;d<g;d++)if(p[d].demux.probe(t)){n=p[d];break}n||(m.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),n={demux:h.default,remux:l.default});var b=this.demuxer,y=this.remuxer,w=n.remux,k=n.demux;y&&y instanceof w||(this.remuxer=new w(e,r,s,a)),b&&b instanceof k||(this.demuxer=new k(e,r,s),this.probe=k.probe),this.resetInitSegment(f,o,v,c),this.resetInitialTimestamp(u)},i.needsProbing=function(t,i,n){return!this.demuxer||!this.remuxer||i||n},i.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new a.default(this.observer,this.config)),t},t}(),y=function(t){return{remuxResult:{},chunkMeta:t}};function w(t){return"then"in t&&t.then instanceof Function}var k=function(t,i,n,r,e){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=i,this.initSegmentData=n,this.duration=r,this.defaultInitPts=e},T=function(t,i,n,r,e,s){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=t,this.contiguous=i,this.accurateTimeOffset=n,this.trackSwitch=r,this.timeOffset=e,this.initSegmentChange=s}},"./src/demux/tsdemuxer.ts":
178
178
  /*!********************************!*\
179
179
  !*** ./src/demux/tsdemuxer.ts ***!
180
180
  \********************************/
181
- /*! exports provided: discardEPB, default */function(t,i,r){r.r(i);r.d(i,"discardEPB",(function(){return w}));var e=r(/*! ./adts */"./src/demux/adts.ts");var n=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");var s=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts");var a=r(/*! ./id3 */"./src/demux/id3.ts");var u=r(/*! ./sample-aes */"./src/demux/sample-aes.ts");var f=r(/*! ../events */"./src/events.ts");var h=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var o=r(/*! ../utils/logger */"./src/utils/logger.ts");var v=r(/*! ../errors */"./src/errors.ts");var l={video:1,audio:2,id3:3,text:4};var c=function(){function t(t,i,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.aacLastPTS=null;this._initPTS=null;this._initDTS=null;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=t;this.config=i;this.typeSupported=r}t.probe=function i(r){var e=t.syncOffset(r);if(e<0){return false}else{if(e){o["logger"].warn("MPEG2-TS detected but first sync word found @ offset "+e+", junk ahead ?")}return true}};t.syncOffset=function t(i){var r=Math.min(1e3,i.length-3*188);var e=0;while(e<r){if(i[e]===71&&i[e+188]===71&&i[e+2*188]===71){return e}else{e++}}return-1};t.createTrack=function t(i,r){return{container:i==="video"||i==="audio"?"video/mp2t":undefined,type:i,id:l[i],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:i==="audio"?r:undefined}};var i=t.prototype;i.resetInitSegment=function i(r,e,n){this.pmtParsed=false;this._pmtId=-1;this._avcTrack=t.createTrack("video",n);this._audioTrack=t.createTrack("audio",n);this._id3Track=t.createTrack("id3",n);this._txtTrack=t.createTrack("text",n);this._audioTrack.isAAC=true;this.aacOverFlow=null;this.aacLastPTS=null;this.avcSample=null;this.audioCodec=r;this.videoCodec=e;this._duration=n};i.resetTimeStamp=function t(){};i.resetContiguity=function t(){var i=this._audioTrack,r=this._avcTrack,e=this._id3Track;if(i){i.pesData=null}if(r){r.pesData=null}if(e){e.pesData=null}this.aacOverFlow=null;this.aacLastPTS=null};i.demux=function i(r,e,n,s){if(n===void 0){n=false}if(s===void 0){s=false}if(!n){this.sampleAes=null}var a;var u=this._avcTrack;var l=this._audioTrack;var c=this._id3Track;var d=u.pid;var b=u.pesData;var y=l.pid;var w=c.pid;var k=l.pesData;var T=c.pesData;var O=false;var S=this.pmtParsed;var E=this._pmtId;var A=r.length;if(this.remainderData){r=Object(h["appendUint8Array"])(this.remainderData,r);A=r.length;this.remainderData=null}if(A<188&&!s){this.remainderData=r;return{audioTrack:l,avcTrack:u,id3Track:c,textTrack:this._txtTrack}}var M=Math.max(0,t.syncOffset(r));A-=(A+M)%188;if(A<r.byteLength&&!s){this.remainderData=new Uint8Array(r.buffer,A,r.buffer.byteLength-A)}var x=0;for(var j=M;j<A;j+=188){if(r[j]===71){var D=!!(r[j+1]&64);var L=((r[j+1]&31)<<8)+r[j+2];var I=(r[j+3]&48)>>4;var C=void 0;if(I>1){C=j+5+r[j+4];if(C===j+188){continue}}else{C=j+4}switch(L){case d:if(D){if(b&&(a=g(b))){this.parseAVCPES(a,false)}b={data:[],size:0}}if(b){b.data.push(r.subarray(C,j+188));b.size+=j+188-C}break;case y:if(D){if(k&&(a=g(k))){if(l.isAAC){this.parseAACPES(a)}else{this.parseMPEGPES(a)}}k={data:[],size:0}}if(k){k.data.push(r.subarray(C,j+188));k.size+=j+188-C}break;case w:if(D){if(T&&(a=g(T))){this.parseID3PES(a)}T={data:[],size:0}}if(T){T.data.push(r.subarray(C,j+188));T.size+=j+188-C}break;case 0:if(D){C+=r[C]+1}E=this._pmtId=m(r,C);break;case E:{if(D){C+=r[C]+1}var R=p(r,C,this.typeSupported.mpeg===true||this.typeSupported.mp3===true,n);d=R.avc;if(d>0){u.pid=d}y=R.audio;if(y>0){l.pid=y;l.isAAC=R.isAAC}w=R.id3;if(w>0){c.pid=w}if(O&&!S){o["logger"].log("reparse from beginning");O=false;j=M-188}S=this.pmtParsed=true;break}case 17:case 8191:break;default:O=true;break}}else{x++}}if(x>0){this.observer.emit(f["Events"].ERROR,f["Events"].ERROR,{type:v["ErrorTypes"].MEDIA_ERROR,details:v["ErrorDetails"].FRAG_PARSING_ERROR,fatal:false,reason:"Found "+x+" TS packet/s that do not start with 0x47"})}u.pesData=b;l.pesData=k;c.pesData=T;var P={audioTrack:l,avcTrack:u,id3Track:c,textTrack:this._txtTrack};if(s){this.extractRemainingSamples(P)}return P};i.flush=function t(){var i=this.remainderData;this.remainderData=null;var r;if(i){r=this.demux(i,-1,false,true)}else{r={audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track}}this.extractRemainingSamples(r);if(this.sampleAes){return this.decrypt(r,this.sampleAes)}return r};i.extractRemainingSamples=function t(i){var r=i.audioTrack,e=i.avcTrack,n=i.id3Track;var s=e.pesData;var a=r.pesData;var u=n.pesData;var f;if(s&&(f=g(s))){this.parseAVCPES(f,true);e.pesData=null}else{e.pesData=s}if(a&&(f=g(a))){if(r.isAAC){this.parseAACPES(f)}else{this.parseMPEGPES(f)}r.pesData=null}else{if(a!==null&&a!==void 0&&a.size){o["logger"].log("last AAC PES packet truncated,might overlap between fragments")}r.pesData=a}if(u&&(f=g(u))){this.parseID3PES(f);n.pesData=null}else{n.pesData=u}};i.demuxSampleAes=function t(i,r,e){var n=this.demux(i,e,true,!this.config.progressive);var s=this.sampleAes=new u["default"](this.observer,this.config,r);return this.decrypt(n,s)};i.decrypt=function t(i,r){return new Promise((function(t){var e=i.audioTrack,n=i.avcTrack;if(e.samples&&e.isAAC){r.decryptAacSamples(e.samples,0,(function(){if(n.samples){r.decryptAvcSamples(n.samples,0,0,(function(){t(i)}))}else{t(i)}}))}else if(n.samples){r.decryptAvcSamples(n.samples,0,0,(function(){t(i)}))}}))};i.destroy=function t(){this._initPTS=this._initDTS=null;this._duration=0};i.parseAVCPES=function t(i,r){var e=this;var n=this._avcTrack;var u=this.parseAVCNALu(i.data);var f=this.avcSample;var h;var o=false;i.data=null;if(f&&u.length&&!n.audFound){b(f,n);f=this.avcSample=d(false,i.pts,i.dts,"")}u.forEach((function(t){switch(t.type){case 1:{h=true;if(!f){f=e.avcSample=d(true,i.pts,i.dts,"")}f.frame=true;var r=t.data;if(o&&r.length>4){var u=new s["default"](r).readSliceType();if(u===2||u===4||u===7||u===9){f.key=true}}break}case 5:h=true;if(!f){f=e.avcSample=d(true,i.pts,i.dts,"")}f.key=true;f.frame=true;break;case 6:{h=true;var v=new s["default"](w(t.data));v.readUByte();var l=0;var c=0;var m=false;var p=0;while(!m&&v.bytesAvailable>1){l=0;do{p=v.readUByte();l+=p}while(p===255);c=0;do{p=v.readUByte();c+=p}while(p===255);if(l===4&&v.bytesAvailable!==0){m=true;var g=v.readUByte();if(g===181){var k=v.readUShort();if(k===49){var T=v.readUInt();if(T===1195456820){var O=v.readUByte();if(O===3){var S=v.readUByte();var E=v.readUByte();var A=31&S;var M=[S,E];for(var x=0;x<A;x++){M.push(v.readUByte());M.push(v.readUByte());M.push(v.readUByte())}y(e._txtTrack.samples,{type:3,pts:i.pts,bytes:M})}}}}}else if(l===5&&v.bytesAvailable!==0){m=true;if(c>16){var j=[];for(var D=0;D<16;D++){j.push(v.readUByte().toString(16));if(D===3||D===5||D===7||D===9){j.push("-")}}var L=c-16;var I=new Uint8Array(L);for(var C=0;C<L;C++){I[C]=v.readUByte()}y(e._txtTrack.samples,{pts:i.pts,payloadType:l,uuid:j.join(""),userData:Object(a["utf8ArrayToStr"])(I),userDataBytes:I})}}else if(c<v.bytesAvailable){for(var R=0;R<c;R++){v.readUByte()}}}break}case 7:h=true;o=true;if(!n.sps){var P=new s["default"](t.data);var U=P.readSPS();n.width=U.width;n.height=U.height;n.pixelRatio=U.pixelRatio;n.sps=[t.data];n.duration=e._duration;var N=t.data.subarray(1,4);var F="avc1.";for(var B=0;B<3;B++){var _=N[B].toString(16);if(_.length<2){_="0"+_}F+=_}n.codec=F}break;case 8:h=true;if(!n.pps){n.pps=[t.data]}break;case 9:h=false;n.audFound=true;if(f){b(f,n)}f=e.avcSample=d(false,i.pts,i.dts,"");break;case 12:h=false;break;default:h=false;if(f){f.debug+="unknown NAL "+t.type+" "}break}if(f&&h){var X=f.units;X.push(t)}}));if(r&&f){b(f,n);this.avcSample=null}};i.getLastNalUnit=function t(){var i;var r=this.avcSample;var e;if(!r||r.units.length===0){var n=this._avcTrack.samples;r=n[n.length-1]}if((i=r)!==null&&i!==void 0&&i.units){var s=r.units;e=s[s.length-1]}return e};i.parseAVCNALu=function t(i){var r=i.byteLength;var e=this._avcTrack;var n=e.naluState||0;var s=n;var a=[];var u=0;var f;var h;var o;var v=-1;var l=0;if(n===-1){v=0;l=i[0]&31;n=0;u=1}while(u<r){f=i[u++];if(!n){n=f?0:1;continue}if(n===1){n=f?0:2;continue}if(!f){n=3}else if(f===1){if(v>=0){var c={data:i.subarray(v,u-n-1),type:l};a.push(c)}else{var d=this.getLastNalUnit();if(d){if(s&&u<=4-s){if(d.state){d.data=d.data.subarray(0,d.data.byteLength-s)}}h=u-n-1;if(h>0){var m=new Uint8Array(d.data.byteLength+h);m.set(d.data,0);m.set(i.subarray(0,h),d.data.byteLength);d.data=m;d.state=0}}}if(u<r){o=i[u]&31;v=u;l=o;n=0}else{n=-1}}else{n=0}}if(v>=0&&n>=0){var p={data:i.subarray(v,r),type:l,state:n};a.push(p)}if(a.length===0){var g=this.getLastNalUnit();if(g){var b=new Uint8Array(g.data.byteLength+i.byteLength);b.set(g.data,0);b.set(i,g.data.byteLength);g.data=b}}e.naluState=n;return a};i.parseAACPES=function t(i){var r=0;var n=this._audioTrack;var s=this.aacOverFlow;var a=i.data;if(s){this.aacOverFlow=null;var u=s.sample.unit.byteLength;var h=Math.min(s.missing,u);var l=u-h;s.sample.unit.set(a.subarray(0,h),l);n.samples.push(s.sample);r=s.missing}var c;var d;for(c=r,d=a.length;c<d-1;c++){if(e["isHeader"](a,c)){break}}if(c!==r){var m;var p;if(c<d-1){m="AAC PES did not start with ADTS header,offset:"+c;p=false}else{m="no ADTS header found in AAC PES";p=true}o["logger"].warn("parsing error:"+m);this.observer.emit(f["Events"].ERROR,f["Events"].ERROR,{type:v["ErrorTypes"].MEDIA_ERROR,details:v["ErrorDetails"].FRAG_PARSING_ERROR,fatal:p,reason:m});if(p){return}}e["initTrackConfig"](n,this.observer,a,c,this.audioCodec);var g;if(i.pts!==undefined){g=i.pts}else if(s){var b=e["getFrameDuration"](n.samplerate);g=s.sample.pts+b}else{o["logger"].warn("[tsdemuxer]: AAC PES unknown PTS");return}var y=0;while(c<d){if(e["isHeader"](a,c)){if(c+5<d){var w=e["appendFrame"](n,a,c,g,y);if(w){if(w.missing){this.aacOverFlow=w}else{c+=w.length;y++;continue}}}break}else{c++}}};i.parseMPEGPES=function t(i){var r=i.data;var e=r.length;var s=0;var a=0;var u=i.pts;if(u===undefined){o["logger"].warn("[tsdemuxer]: MPEG PES unknown PTS");return}while(a<e){if(n["isHeader"](r,a)){var f=n["appendFrame"](this._audioTrack,r,a,u,s);if(f){a+=f.length;s++}else{break}}else{a++}}};i.parseID3PES=function t(i){if(i.pts===undefined){o["logger"].warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(i)};return t}();c.minProbeByteLength=188;function d(t,i,r,e){return{key:t,frame:false,pts:i,dts:r,units:[],debug:e,length:0}}function m(t,i){return(t[i+10]&31)<<8|t[i+11]}function p(t,i,r,e){var n={audio:-1,avc:-1,id3:-1,isAAC:true};var s=(t[i+1]&15)<<8|t[i+2];var a=i+3+s-4;var u=(t[i+10]&15)<<8|t[i+11];i+=12+u;while(i<a){var f=(t[i+1]&31)<<8|t[i+2];switch(t[i]){case 207:if(!e){o["logger"].log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:if(n.audio===-1){n.audio=f}break;case 21:if(n.id3===-1){n.id3=f}break;case 219:if(!e){o["logger"].log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:if(n.avc===-1){n.avc=f}break;case 3:case 4:if(!r){o["logger"].log("MPEG audio found, not supported in this browser")}else if(n.audio===-1){n.audio=f;n.isAAC=false}break;case 36:o["logger"].warn("Unsupported HEVC stream type found");break}i+=((t[i+3]&15)<<8|t[i+4])+5}return n}function g(t){var i=0;var r;var e;var n;var s;var a;var u=t.data;if(!t||t.size===0){return null}while(u[0].length<19&&u.length>1){var f=new Uint8Array(u[0].length+u[1].length);f.set(u[0]);f.set(u[1],u[0].length);u[0]=f;u.splice(1,1)}r=u[0];var h=(r[0]<<16)+(r[1]<<8)+r[2];if(h===1){e=(r[4]<<8)+r[5];if(e&&e>t.size-6){return null}var v=r[7];if(v&192){s=(r[9]&14)*536870912+(r[10]&255)*4194304+(r[11]&254)*16384+(r[12]&255)*128+(r[13]&254)/2;if(v&64){a=(r[14]&14)*536870912+(r[15]&255)*4194304+(r[16]&254)*16384+(r[17]&255)*128+(r[18]&254)/2;if(s-a>60*9e4){o["logger"].warn(Math.round((s-a)/9e4)+"s delta between PTS and DTS, align them");s=a}}else{a=s}}n=r[8];var l=n+9;if(t.size<=l){return null}t.size-=l;var c=new Uint8Array(t.size);for(var d=0,m=u.length;d<m;d++){r=u[d];var p=r.byteLength;if(l){if(l>p){l-=p;continue}else{r=r.subarray(l);p-=l;l=0}}c.set(r,i);i+=p}if(e){e-=n+3}return{data:c,pts:s,dts:a,len:e}}return null}function b(t,i){if(t.units.length&&t.frame){if(t.pts===undefined){var r=i.samples;var e=r.length;if(e){var n=r[e-1];t.pts=n.pts;t.dts=n.dts}else{i.dropped++;return}}i.samples.push(t)}if(t.debug.length){o["logger"].log(t.pts+"/"+t.dts+":"+t.debug)}}function y(t,i){var r=t.length;if(r>0){if(i.pts>=t[r-1].pts){t.push(i)}else{for(var e=r-1;e>=0;e--){if(i.pts<t[e].pts){t.splice(e,0,i);break}}}}else{t.push(i)}}function w(t){var i=t.byteLength;var r=[];var e=1;while(e<i-2){if(t[e]===0&&t[e+1]===0&&t[e+2]===3){r.push(e+2);e+=2}else{e++}}if(r.length===0){return t}var n=i-r.length;var s=new Uint8Array(n);var a=0;for(e=0;e<n;a++,e++){if(a===r[0]){a++;r.shift()}s[e]=t[a]}return s}i["default"]=c},"./src/errors.ts":
181
+ /*! exports provided: discardEPB, default */function(t,i,n){n.r(i),n.d(i,"discardEPB",(function(){return w}));var r=n(/*! ./adts */"./src/demux/adts.ts"),e=n(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),s=n(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),a=n(/*! ./id3 */"./src/demux/id3.ts"),o=n(/*! ./sample-aes */"./src/demux/sample-aes.ts"),h=n(/*! ../events */"./src/events.ts"),u=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),c=n(/*! ../utils/logger */"./src/utils/logger.ts"),f=n(/*! ../errors */"./src/errors.ts"),l={video:1,audio:2,id3:3,text:4},v=function(){function t(t,i,n){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this.aacLastPTS=null,this._initPTS=null,this._initDTS=null,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=t,this.config=i,this.typeSupported=n}t.probe=function(i){var n=t.syncOffset(i);return!(n<0||(n&&c.logger.warn("MPEG2-TS detected but first sync word found @ offset "+n+", junk ahead ?"),0))},t.syncOffset=function(t){for(var i=Math.min(1e3,t.length-564),n=0;n<i;){if(71===t[n]&&71===t[n+188]&&71===t[n+376])return n;n++}return-1},t.createTrack=function(t,i){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:l[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?i:void 0}};var i=t.prototype;return i.resetInitSegment=function(i,n,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video",r),this._audioTrack=t.createTrack("audio",r),this._id3Track=t.createTrack("id3",r),this._txtTrack=t.createTrack("text",r),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=i,this.videoCodec=n,this._duration=r},i.resetTimeStamp=function(){},i.resetContiguity=function(){var t=this._audioTrack,i=this._avcTrack,n=this._id3Track;t&&(t.pesData=null),i&&(i.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},i.demux=function(i,n,r,e){var s;void 0===r&&(r=!1),void 0===e&&(e=!1),r||(this.sampleAes=null);var a=this._avcTrack,o=this._audioTrack,l=this._id3Track,v=a.pid,d=a.pesData,b=o.pid,y=l.pid,w=o.pesData,k=l.pesData,T=!1,O=this.pmtParsed,S=this._pmtId,E=i.length;if(this.remainderData&&(E=(i=Object(u.appendUint8Array)(this.remainderData,i)).length,this.remainderData=null),E<188&&!e)return this.remainderData=i,{audioTrack:o,avcTrack:a,id3Track:l,textTrack:this._txtTrack};var A=Math.max(0,t.syncOffset(i));(E-=(E+A)%188)<i.byteLength&&!e&&(this.remainderData=new Uint8Array(i.buffer,E,i.buffer.byteLength-E));for(var M=0,x=A;x<E;x+=188)if(71===i[x]){var j=!!(64&i[x+1]),D=((31&i[x+1])<<8)+i[x+2],L=void 0;if((48&i[x+3])>>4>1){if((L=x+5+i[x+4])===x+188)continue}else L=x+4;switch(D){case v:j&&(d&&(s=g(d))&&this.parseAVCPES(s,!1),d={data:[],size:0}),d&&(d.data.push(i.subarray(L,x+188)),d.size+=x+188-L);break;case b:j&&(w&&(s=g(w))&&(o.isAAC?this.parseAACPES(s):this.parseMPEGPES(s)),w={data:[],size:0}),w&&(w.data.push(i.subarray(L,x+188)),w.size+=x+188-L);break;case y:j&&(k&&(s=g(k))&&this.parseID3PES(s),k={data:[],size:0}),k&&(k.data.push(i.subarray(L,x+188)),k.size+=x+188-L);break;case 0:j&&(L+=i[L]+1),S=this._pmtId=m(i,L);break;case S:j&&(L+=i[L]+1);var I=p(i,L,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,r);(v=I.avc)>0&&(a.pid=v),(b=I.audio)>0&&(o.pid=b,o.isAAC=I.isAAC),(y=I.id3)>0&&(l.pid=y),T&&!O&&(c.logger.log("reparse from beginning"),T=!1,x=A-188),O=this.pmtParsed=!0;break;case 17:case 8191:break;default:T=!0}}else M++;M>0&&this.observer.emit(h.Events.ERROR,h.Events.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+M+" TS packet/s that do not start with 0x47"}),a.pesData=d,o.pesData=w,l.pesData=k;var C={audioTrack:o,avcTrack:a,id3Track:l,textTrack:this._txtTrack};return e&&this.extractRemainingSamples(C),C},i.flush=function(){var t,i=this.remainderData;return this.remainderData=null,t=i?this.demux(i,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},i.extractRemainingSamples=function(t){var i,n=t.audioTrack,r=t.avcTrack,e=t.id3Track,s=r.pesData,a=n.pesData,o=e.pesData;s&&(i=g(s))?(this.parseAVCPES(i,!0),r.pesData=null):r.pesData=s,a&&(i=g(a))?(n.isAAC?this.parseAACPES(i):this.parseMPEGPES(i),n.pesData=null):(null!=a&&a.size&&c.logger.log("last AAC PES packet truncated,might overlap between fragments"),n.pesData=a),o&&(i=g(o))?(this.parseID3PES(i),e.pesData=null):e.pesData=o},i.demuxSampleAes=function(t,i,n){var r=this.demux(t,n,!0,!this.config.progressive),e=this.sampleAes=new o.default(this.observer,this.config,i);return this.decrypt(r,e)},i.decrypt=function(t,i){return new Promise((function(n){var r=t.audioTrack,e=t.avcTrack;r.samples&&r.isAAC?i.decryptAacSamples(r.samples,0,(function(){e.samples?i.decryptAvcSamples(e.samples,0,0,(function(){n(t)})):n(t)})):e.samples&&i.decryptAvcSamples(e.samples,0,0,(function(){n(t)}))}))},i.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},i.parseAVCPES=function(t,i){var n,r=this,e=this._avcTrack,o=this.parseAVCNALu(t.data),h=this.avcSample,u=!1;t.data=null,h&&o.length&&!e.audFound&&(b(h,e),h=this.avcSample=d(!1,t.pts,t.dts,"")),o.forEach((function(i){switch(i.type){case 1:n=!0,h||(h=r.avcSample=d(!0,t.pts,t.dts,"")),h.frame=!0;var o=i.data;if(u&&o.length>4){var c=new s.default(o).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(h.key=!0)}break;case 5:n=!0,h||(h=r.avcSample=d(!0,t.pts,t.dts,"")),h.key=!0,h.frame=!0;break;case 6:n=!0;var f=new s.default(w(i.data));f.readUByte();for(var l=0,v=0,m=!1,p=0;!m&&f.bytesAvailable>1;){l=0;do{l+=p=f.readUByte()}while(255===p);v=0;do{v+=p=f.readUByte()}while(255===p);if(4===l&&0!==f.bytesAvailable){if(m=!0,181===f.readUByte()&&49===f.readUShort()&&1195456820===f.readUInt()&&3===f.readUByte()){for(var g=f.readUByte(),k=31&g,T=[g,f.readUByte()],O=0;O<k;O++)T.push(f.readUByte()),T.push(f.readUByte()),T.push(f.readUByte());y(r._txtTrack.samples,{type:3,pts:t.pts,bytes:T})}}else if(5===l&&0!==f.bytesAvailable){if(m=!0,v>16){for(var S=[],E=0;E<16;E++)S.push(f.readUByte().toString(16)),3!==E&&5!==E&&7!==E&&9!==E||S.push("-");for(var A=v-16,M=new Uint8Array(A),x=0;x<A;x++)M[x]=f.readUByte();y(r._txtTrack.samples,{pts:t.pts,payloadType:l,uuid:S.join(""),userData:Object(a.utf8ArrayToStr)(M),userDataBytes:M})}}else if(v<f.bytesAvailable)for(var j=0;j<v;j++)f.readUByte()}break;case 7:if(n=!0,u=!0,!e.sps){var D=new s.default(i.data).readSPS();e.width=D.width,e.height=D.height,e.pixelRatio=D.pixelRatio,e.sps=[i.data],e.duration=r._duration;for(var L=i.data.subarray(1,4),I="avc1.",C=0;C<3;C++){var R=L[C].toString(16);R.length<2&&(R="0"+R),I+=R}e.codec=I}break;case 8:n=!0,e.pps||(e.pps=[i.data]);break;case 9:n=!1,e.audFound=!0,h&&b(h,e),h=r.avcSample=d(!1,t.pts,t.dts,"");break;case 12:n=!1;break;default:n=!1,h&&(h.debug+="unknown NAL "+i.type+" ")}h&&n&&h.units.push(i)})),i&&h&&(b(h,e),this.avcSample=null)},i.getLastNalUnit=function(){var t,i,n=this.avcSample;if(!n||0===n.units.length){var r=this._avcTrack.samples;n=r[r.length-1]}if(null!==(t=n)&&void 0!==t&&t.units){var e=n.units;i=e[e.length-1]}return i},i.parseAVCNALu=function(t){var i,n,r=t.byteLength,e=this._avcTrack,s=e.naluState||0,a=s,o=[],h=0,u=-1,c=0;for(-1===s&&(u=0,c=31&t[0],s=0,h=1);h<r;)if(i=t[h++],s)if(1!==s)if(i)if(1===i){if(u>=0){var f={data:t.subarray(u,h-s-1),type:c};o.push(f)}else{var l=this.getLastNalUnit();if(l&&(a&&h<=4-a&&l.state&&(l.data=l.data.subarray(0,l.data.byteLength-a)),(n=h-s-1)>0)){var v=new Uint8Array(l.data.byteLength+n);v.set(l.data,0),v.set(t.subarray(0,n),l.data.byteLength),l.data=v,l.state=0}}h<r?(u=h,c=31&t[h],s=0):s=-1}else s=0;else s=3;else s=i?0:2;else s=i?0:1;if(u>=0&&s>=0){var d={data:t.subarray(u,r),type:c,state:s};o.push(d)}if(0===o.length){var m=this.getLastNalUnit();if(m){var p=new Uint8Array(m.data.byteLength+t.byteLength);p.set(m.data,0),p.set(t,m.data.byteLength),m.data=p}}return e.naluState=s,o},i.parseAACPES=function(t){var i,n,e,s,a,o=0,u=this._audioTrack,l=this.aacOverFlow,v=t.data;if(l){this.aacOverFlow=null;var d=l.sample.unit.byteLength,m=Math.min(l.missing,d),p=d-m;l.sample.unit.set(v.subarray(0,m),p),u.samples.push(l.sample),o=l.missing}for(i=o,n=v.length;i<n-1&&!r.isHeader(v,i);i++);if(i===o||(i<n-1?(e="AAC PES did not start with ADTS header,offset:"+i,s=!1):(e="no ADTS header found in AAC PES",s=!0),c.logger.warn("parsing error:"+e),this.observer.emit(h.Events.ERROR,h.Events.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:s,reason:e}),!s)){if(r.initTrackConfig(u,this.observer,v,i,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!l)return void c.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var g=r.getFrameDuration(u.samplerate);a=l.sample.pts+g}for(var b=0;i<n;){if(r.isHeader(v,i)){if(i+5<n){var y=r.appendFrame(u,v,i,a,b);if(y){if(!y.missing){i+=y.length,b++;continue}this.aacOverFlow=y}}break}i++}}},i.parseMPEGPES=function(t){var i=t.data,n=i.length,r=0,s=0,a=t.pts;if(void 0!==a)for(;s<n;)if(e.isHeader(i,s)){var o=e.appendFrame(this._audioTrack,i,s,a,r);if(!o)break;s+=o.length,r++}else s++;else c.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},i.parseID3PES=function(t){void 0!==t.pts?this._id3Track.samples.push(t):c.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function d(t,i,n,r){return{key:t,frame:!1,pts:i,dts:n,units:[],debug:r,length:0}}function m(t,i){return(31&t[i+10])<<8|t[i+11]}function p(t,i,n,r){var e={audio:-1,avc:-1,id3:-1,isAAC:!0},s=i+3+((15&t[i+1])<<8|t[i+2])-4;for(i+=12+((15&t[i+10])<<8|t[i+11]);i<s;){var a=(31&t[i+1])<<8|t[i+2];switch(t[i]){case 207:if(!r){c.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===e.audio&&(e.audio=a);break;case 21:-1===e.id3&&(e.id3=a);break;case 219:if(!r){c.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===e.avc&&(e.avc=a);break;case 3:case 4:n?-1===e.audio&&(e.audio=a,e.isAAC=!1):c.logger.log("MPEG audio found, not supported in this browser");break;case 36:c.logger.warn("Unsupported HEVC stream type found")}i+=5+((15&t[i+3])<<8|t[i+4])}return e}function g(t){var i,n,r,e,s,a=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;){var h=new Uint8Array(o[0].length+o[1].length);h.set(o[0]),h.set(o[1],o[0].length),o[0]=h,o.splice(1,1)}if(1===((i=o[0])[0]<<16)+(i[1]<<8)+i[2]){if((n=(i[4]<<8)+i[5])&&n>t.size-6)return null;var u=i[7];192&u&&(e=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&u?e-(s=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>54e5&&(c.logger.warn(Math.round((e-s)/9e4)+"s delta between PTS and DTS, align them"),e=s):s=e);var f=(r=i[8])+9;if(t.size<=f)return null;t.size-=f;for(var l=new Uint8Array(t.size),v=0,d=o.length;v<d;v++){var m=(i=o[v]).byteLength;if(f){if(f>m){f-=m;continue}i=i.subarray(f),m-=f,f=0}l.set(i,a),a+=m}return n&&(n-=r+3),{data:l,pts:e,dts:s,len:n}}return null}function b(t,i){if(t.units.length&&t.frame){if(void 0===t.pts){var n=i.samples,r=n.length;if(!r)return void i.dropped++;var e=n[r-1];t.pts=e.pts,t.dts=e.dts}i.samples.push(t)}t.debug.length&&c.logger.log(t.pts+"/"+t.dts+":"+t.debug)}function y(t,i){var n=t.length;if(n>0){if(i.pts>=t[n-1].pts)t.push(i);else for(var r=n-1;r>=0;r--)if(i.pts<t[r].pts){t.splice(r,0,i);break}}else t.push(i)}function w(t){for(var i=t.byteLength,n=[],r=1;r<i-2;)0===t[r]&&0===t[r+1]&&3===t[r+2]?(n.push(r+2),r+=2):r++;if(0===n.length)return t;var e=i-n.length,s=new Uint8Array(e),a=0;for(r=0;r<e;a++,r++)a===n[0]&&(a++,n.shift()),s[r]=t[a];return s}v.minProbeByteLength=188,i.default=v},"./src/errors.ts":
182
182
  /*!***********************!*\
183
183
  !*** ./src/errors.ts ***!
184
184
  \***********************/
185
- /*! exports provided: ErrorTypes, ErrorDetails */function(t,i,r){r.r(i);r.d(i,"ErrorTypes",(function(){return e}));r.d(i,"ErrorDetails",(function(){return n}));var e;(function(t){t["NETWORK_ERROR"]="networkError";t["MEDIA_ERROR"]="mediaError";t["KEY_SYSTEM_ERROR"]="keySystemError";t["MUX_ERROR"]="muxError";t["OTHER_ERROR"]="otherError"})(e||(e={}));var n;(function(t){t["KEY_SYSTEM_NO_KEYS"]="keySystemNoKeys";t["KEY_SYSTEM_NO_ACCESS"]="keySystemNoAccess";t["KEY_SYSTEM_NO_SESSION"]="keySystemNoSession";t["KEY_SYSTEM_LICENSE_REQUEST_FAILED"]="keySystemLicenseRequestFailed";t["KEY_SYSTEM_NO_INIT_DATA"]="keySystemNoInitData";t["MANIFEST_LOAD_ERROR"]="manifestLoadError";t["MANIFEST_LOAD_TIMEOUT"]="manifestLoadTimeOut";t["MANIFEST_PARSING_ERROR"]="manifestParsingError";t["MANIFEST_INCOMPATIBLE_CODECS_ERROR"]="manifestIncompatibleCodecsError";t["LEVEL_EMPTY_ERROR"]="levelEmptyError";t["LEVEL_LOAD_ERROR"]="levelLoadError";t["LEVEL_LOAD_TIMEOUT"]="levelLoadTimeOut";t["LEVEL_SWITCH_ERROR"]="levelSwitchError";t["AUDIO_TRACK_LOAD_ERROR"]="audioTrackLoadError";t["AUDIO_TRACK_LOAD_TIMEOUT"]="audioTrackLoadTimeOut";t["SUBTITLE_LOAD_ERROR"]="subtitleTrackLoadError";t["SUBTITLE_TRACK_LOAD_TIMEOUT"]="subtitleTrackLoadTimeOut";t["FRAG_LOAD_ERROR"]="fragLoadError";t["FRAG_LOAD_TIMEOUT"]="fragLoadTimeOut";t["FRAG_DECRYPT_ERROR"]="fragDecryptError";t["FRAG_PARSING_ERROR"]="fragParsingError";t["REMUX_ALLOC_ERROR"]="remuxAllocError";t["KEY_LOAD_ERROR"]="keyLoadError";t["KEY_LOAD_TIMEOUT"]="keyLoadTimeOut";t["BUFFER_ADD_CODEC_ERROR"]="bufferAddCodecError";t["BUFFER_INCOMPATIBLE_CODECS_ERROR"]="bufferIncompatibleCodecsError";t["BUFFER_APPEND_ERROR"]="bufferAppendError";t["BUFFER_APPENDING_ERROR"]="bufferAppendingError";t["BUFFER_STALLED_ERROR"]="bufferStalledError";t["BUFFER_FULL_ERROR"]="bufferFullError";t["BUFFER_SEEK_OVER_HOLE"]="bufferSeekOverHole";t["BUFFER_NUDGE_ON_STALL"]="bufferNudgeOnStall";t["INTERNAL_EXCEPTION"]="internalException";t["INTERNAL_ABORTED"]="aborted";t["UNKNOWN"]="unknown"})(n||(n={}))},"./src/events.ts":
185
+ /*! exports provided: ErrorTypes, ErrorDetails */function(t,i,n){var r,e;n.r(i),n.d(i,"ErrorTypes",(function(){return r})),n.d(i,"ErrorDetails",(function(){return e})),function(t){t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError"}(r||(r={})),function(t){t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown"}(e||(e={}))},"./src/events.ts":
186
186
  /*!***********************!*\
187
187
  !*** ./src/events.ts ***!
188
188
  \***********************/
189
- /*! exports provided: Events */function(t,i,r){r.r(i);r.d(i,"Events",(function(){return e}));var e;(function(t){t["MEDIA_ATTACHING"]="hlsMediaAttaching";t["MEDIA_ATTACHED"]="hlsMediaAttached";t["MEDIA_DETACHING"]="hlsMediaDetaching";t["MEDIA_DETACHED"]="hlsMediaDetached";t["BUFFER_RESET"]="hlsBufferReset";t["BUFFER_CODECS"]="hlsBufferCodecs";t["BUFFER_CREATED"]="hlsBufferCreated";t["BUFFER_APPENDING"]="hlsBufferAppending";t["BUFFER_APPENDED"]="hlsBufferAppended";t["BUFFER_EOS"]="hlsBufferEos";t["BUFFER_FLUSHING"]="hlsBufferFlushing";t["BUFFER_FLUSHED"]="hlsBufferFlushed";t["MANIFEST_LOADING"]="hlsManifestLoading";t["MANIFEST_LOADED"]="hlsManifestLoaded";t["MANIFEST_PARSED"]="hlsManifestParsed";t["LEVEL_SWITCHING"]="hlsLevelSwitching";t["LEVEL_SWITCHED"]="hlsLevelSwitched";t["LEVEL_LOADING"]="hlsLevelLoading";t["LEVEL_LOADED"]="hlsLevelLoaded";t["LEVEL_UPDATED"]="hlsLevelUpdated";t["LEVEL_PTS_UPDATED"]="hlsLevelPtsUpdated";t["LEVELS_UPDATED"]="hlsLevelsUpdated";t["AUDIO_TRACKS_UPDATED"]="hlsAudioTracksUpdated";t["AUDIO_TRACK_SWITCHING"]="hlsAudioTrackSwitching";t["AUDIO_TRACK_SWITCHED"]="hlsAudioTrackSwitched";t["AUDIO_TRACK_LOADING"]="hlsAudioTrackLoading";t["AUDIO_TRACK_LOADED"]="hlsAudioTrackLoaded";t["SUBTITLE_TRACKS_UPDATED"]="hlsSubtitleTracksUpdated";t["SUBTITLE_TRACKS_CLEARED"]="hlsSubtitleTracksCleared";t["SUBTITLE_TRACK_SWITCH"]="hlsSubtitleTrackSwitch";t["SUBTITLE_TRACK_LOADING"]="hlsSubtitleTrackLoading";t["SUBTITLE_TRACK_LOADED"]="hlsSubtitleTrackLoaded";t["SUBTITLE_FRAG_PROCESSED"]="hlsSubtitleFragProcessed";t["CUES_PARSED"]="hlsCuesParsed";t["NON_NATIVE_TEXT_TRACKS_FOUND"]="hlsNonNativeTextTracksFound";t["INIT_PTS_FOUND"]="hlsInitPtsFound";t["FRAG_LOADING"]="hlsFragLoading";t["FRAG_LOAD_EMERGENCY_ABORTED"]="hlsFragLoadEmergencyAborted";t["FRAG_LOADED"]="hlsFragLoaded";t["FRAG_DECRYPTED"]="hlsFragDecrypted";t["FRAG_PARSING_INIT_SEGMENT"]="hlsFragParsingInitSegment";t["FRAG_PARSING_USERDATA"]="hlsFragParsingUserdata";t["FRAG_PARSING_METADATA"]="hlsFragParsingMetadata";t["FRAG_PARSED"]="hlsFragParsed";t["FRAG_BUFFERED"]="hlsFragBuffered";t["FRAG_CHANGED"]="hlsFragChanged";t["FPS_DROP"]="hlsFpsDrop";t["FPS_DROP_LEVEL_CAPPING"]="hlsFpsDropLevelCapping";t["ERROR"]="hlsError";t["DESTROYING"]="hlsDestroying";t["KEY_LOADING"]="hlsKeyLoading";t["KEY_LOADED"]="hlsKeyLoaded";t["LIVE_BACK_BUFFER_REACHED"]="hlsLiveBackBufferReached";t["BACK_BUFFER_REACHED"]="hlsBackBufferReached"})(e||(e={}))},"./src/hls.ts":
189
+ /*! exports provided: Events */function(t,i,n){var r;n.r(i),n.d(i,"Events",(function(){return r})),function(t){t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached"}(r||(r={}))},"./src/hls.ts":
190
190
  /*!********************!*\
191
191
  !*** ./src/hls.ts ***!
192
192
  \********************/
193
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return y}));var e=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");var n=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts");var s=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts");var a=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts");var u=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts");var f=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts");var h=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts");var o=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts");var v=r(/*! ./is-supported */"./src/is-supported.ts");var l=r(/*! ./utils/logger */"./src/utils/logger.ts");var c=r(/*! ./config */"./src/config.ts");var d=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");var m=r(/*! ./events */"./src/events.ts");var p=r(/*! ./errors */"./src/errors.ts");function g(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function b(t,i,r){if(i)g(t.prototype,i);if(r)g(t,r);return t}var y=function(){t.isSupported=function t(){return Object(v["isSupported"])()};function t(i){if(i===void 0){i={}}this.config=void 0;this.userConfig=void 0;this.coreComponents=void 0;this.networkControllers=void 0;this._emitter=new d["EventEmitter"];this._autoLevelCapping=void 0;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;var r=this.config=Object(c["mergeConfig"])(t.DefaultConfig,i);this.userConfig=i;Object(l["enableLogs"])(r.debug);this._autoLevelCapping=-1;if(r.progressive){Object(c["enableStreamingMode"])(r)}var e=r.abrController,v=r.bufferController,m=r.capLevelController,p=r.fpsController;var g=this.abrController=new e(this);var b=this.bufferController=new v(this);var y=this.capLevelController=new m(this);var w=new p(this);var k=new n["default"](this);var T=new s["default"](this);var O=new a["default"](this);var S=this.levelController=new f["default"](this);var E=new h["FragmentTracker"](this);var A=this.streamController=new o["default"](this,E);y.setStreamController(A);w.setStreamController(A);var M=[S,A];this.networkControllers=M;var x=[k,T,g,b,y,w,O,E];this.audioTrackController=this.createController(r.audioTrackController,null,M);this.createController(r.audioStreamController,E,M);this.subtitleTrackController=this.createController(r.subtitleTrackController,null,M);this.createController(r.subtitleStreamController,E,M);this.createController(r.timelineController,null,x);this.emeController=this.createController(r.emeController,null,x);this.cmcdController=this.createController(r.cmcdController,null,x);this.latencyController=this.createController(u["default"],null,x);this.coreComponents=x}var i=t.prototype;i.createController=function t(i,r,e){if(i){var n=r?new i(this,r):new i(this);if(e){e.push(n)}return n}return null};i.on=function t(i,r,e){if(e===void 0){e=this}this._emitter.on(i,r,e)};i.once=function t(i,r,e){if(e===void 0){e=this}this._emitter.once(i,r,e)};i.removeAllListeners=function t(i){this._emitter.removeAllListeners(i)};i.off=function t(i,r,e,n){if(e===void 0){e=this}this._emitter.off(i,r,e,n)};i.listeners=function t(i){return this._emitter.listeners(i)};i.emit=function t(i,r,e){return this._emitter.emit(i,r,e)};i.trigger=function t(i,r){if(this.config.debug){return this.emit(i,i,r)}else{try{return this.emit(i,i,r)}catch(t){l["logger"].error("An internal error happened while handling event "+i+'. Error message: "'+t.message+'". Here is a stacktrace:',t);this.trigger(m["Events"].ERROR,{type:p["ErrorTypes"].OTHER_ERROR,details:p["ErrorDetails"].INTERNAL_EXCEPTION,fatal:false,event:i,error:t})}}return false};i.listenerCount=function t(i){return this._emitter.listenerCount(i)};i.destroy=function t(){l["logger"].log("destroy");this.trigger(m["Events"].DESTROYING,undefined);this.detachMedia();this.removeAllListeners();this._autoLevelCapping=-1;this.url=null;this.networkControllers.forEach((function(t){return t.destroy()}));this.networkControllers.length=0;this.coreComponents.forEach((function(t){return t.destroy()}));this.coreComponents.length=0};i.attachMedia=function t(i){l["logger"].log("attachMedia");this._media=i;this.trigger(m["Events"].MEDIA_ATTACHING,{media:i})};i.detachMedia=function t(){l["logger"].log("detachMedia");this.trigger(m["Events"].MEDIA_DETACHING,undefined);this._media=null};i.loadSource=function t(i){this.stopLoad();var r=this.media;var n=this.url;var s=this.url=e["buildAbsoluteURL"](self.location.href,i,{alwaysNormalize:true});l["logger"].log("loadSource:"+s);if(r&&n&&n!==s&&this.bufferController.hasSourceTypes()){this.detachMedia();this.attachMedia(r)}this.trigger(m["Events"].MANIFEST_LOADING,{url:i})};i.startLoad=function t(i){if(i===void 0){i=-1}l["logger"].log("startLoad("+i+")");this.networkControllers.forEach((function(t){t.startLoad(i)}))};i.stopLoad=function t(){l["logger"].log("stopLoad");this.networkControllers.forEach((function(t){t.stopLoad()}))};i.swapAudioCodec=function t(){l["logger"].log("swapAudioCodec");this.streamController.swapAudioCodec()};i.recoverMediaError=function t(){l["logger"].log("recoverMediaError");var i=this._media;this.detachMedia();if(i){this.attachMedia(i)}};i.removeLevel=function t(i,r){if(r===void 0){r=0}this.levelController.removeLevel(i,r)};b(t,[{key:"levels",get:function t(){var i=this.levelController.levels;return i?i:[]}},{key:"currentLevel",get:function t(){return this.streamController.currentLevel},set:function t(i){l["logger"].log("set currentLevel:"+i);this.loadLevel=i;this.abrController.clearTimer();this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function t(){return this.streamController.nextLevel},set:function t(i){l["logger"].log("set nextLevel:"+i);this.levelController.manualLevel=i;this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function t(){return this.levelController.level},set:function t(i){l["logger"].log("set loadLevel:"+i);this.levelController.manualLevel=i}},{key:"nextLoadLevel",get:function t(){return this.levelController.nextLoadLevel},set:function t(i){this.levelController.nextLoadLevel=i}},{key:"firstLevel",get:function t(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function t(i){l["logger"].log("set firstLevel:"+i);this.levelController.firstLevel=i}},{key:"startLevel",get:function t(){return this.levelController.startLevel},set:function t(i){l["logger"].log("set startLevel:"+i);if(i!==-1){i=Math.max(i,this.minAutoLevel)}this.levelController.startLevel=i}},{key:"capLevelToPlayerSize",get:function t(){return this.config.capLevelToPlayerSize},set:function t(i){var r=!!i;if(r!==this.config.capLevelToPlayerSize){if(r){this.capLevelController.startCapping()}else{this.capLevelController.stopCapping();this.autoLevelCapping=-1;this.streamController.nextLevelSwitch()}this.config.capLevelToPlayerSize=r}}},{key:"autoLevelCapping",get:function t(){return this._autoLevelCapping},set:function t(i){if(this._autoLevelCapping!==i){l["logger"].log("set autoLevelCapping:"+i);this._autoLevelCapping=i}}},{key:"bandwidthEstimate",get:function t(){var i=this.abrController.bwEstimator;if(!i){return NaN}return i.getEstimate()}},{key:"autoLevelEnabled",get:function t(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function t(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function t(){var i=this.levels,r=this.config.minAutoBitrate;if(!i)return 0;var e=i.length;for(var n=0;n<e;n++){if(i[n].maxBitrate>r){return n}}return 0}},{key:"maxAutoLevel",get:function t(){var i=this.levels,r=this.autoLevelCapping;var e;if(r===-1&&i&&i.length){e=i.length-1}else{e=r}return e}},{key:"nextAutoLevel",get:function t(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function t(i){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,i)}},{key:"audioTracks",get:function t(){var i=this.audioTrackController;return i?i.audioTracks:[]}},{key:"audioTrack",get:function t(){var i=this.audioTrackController;return i?i.audioTrack:-1},set:function t(i){var r=this.audioTrackController;if(r){r.audioTrack=i}}},{key:"subtitleTracks",get:function t(){var i=this.subtitleTrackController;return i?i.subtitleTracks:[]}},{key:"subtitleTrack",get:function t(){var i=this.subtitleTrackController;return i?i.subtitleTrack:-1},set:function t(i){var r=this.subtitleTrackController;if(r){r.subtitleTrack=i}}},{key:"media",get:function t(){return this._media}},{key:"subtitleDisplay",get:function t(){var i=this.subtitleTrackController;return i?i.subtitleDisplay:false},set:function t(i){var r=this.subtitleTrackController;if(r){r.subtitleDisplay=i}}},{key:"lowLatencyMode",get:function t(){return this.config.lowLatencyMode},set:function t(i){this.config.lowLatencyMode=i}},{key:"liveSyncPosition",get:function t(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function t(){return this.latencyController.latency}},{key:"maxLatency",get:function t(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function t(){return this.latencyController.targetLatency}},{key:"drift",get:function t(){return this.latencyController.drift}},{key:"forceStartLoad",get:function t(){return this.streamController.forceStartLoad}}],[{key:"version",get:function t(){return"1.1.5"}},{key:"Events",get:function t(){return m["Events"]}},{key:"ErrorTypes",get:function t(){return p["ErrorTypes"]}},{key:"ErrorDetails",get:function t(){return p["ErrorDetails"]}},{key:"DefaultConfig",get:function i(){if(!t.defaultConfig){return c["hlsDefaultConfig"]}return t.defaultConfig},set:function i(r){t.defaultConfig=r}}]);return t}();y.defaultConfig=void 0},"./src/is-supported.ts":
193
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return b}));var r=n(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),e=n(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),s=n(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),a=n(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),o=n(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),h=n(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),u=n(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),c=n(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),f=n(/*! ./is-supported */"./src/is-supported.ts"),l=n(/*! ./utils/logger */"./src/utils/logger.ts"),v=n(/*! ./config */"./src/config.ts"),d=n(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),m=n(/*! ./events */"./src/events.ts"),p=n(/*! ./errors */"./src/errors.ts");function g(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var b=function(){function t(i){void 0===i&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new d.EventEmitter,this._autoLevelCapping=void 0,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;var n=this.config=Object(v.mergeConfig)(t.DefaultConfig,i);this.userConfig=i,Object(l.enableLogs)(n.debug),this._autoLevelCapping=-1,n.progressive&&Object(v.enableStreamingMode)(n);var r=n.bufferController,f=n.capLevelController,m=n.fpsController,p=this.abrController=new(0,n.abrController)(this),g=this.bufferController=new r(this),b=this.capLevelController=new f(this),y=new m(this),w=new e.default(this),k=new s.default(this),T=new a.default(this),O=this.levelController=new h.default(this),S=new u.FragmentTracker(this),E=this.streamController=new c.default(this,S);b.setStreamController(E),y.setStreamController(E);var A=[O,E];this.networkControllers=A;var M=[w,k,p,g,b,y,T,S];this.audioTrackController=this.createController(n.audioTrackController,null,A),this.createController(n.audioStreamController,S,A),this.subtitleTrackController=this.createController(n.subtitleTrackController,null,A),this.createController(n.subtitleStreamController,S,A),this.createController(n.timelineController,null,M),this.emeController=this.createController(n.emeController,null,M),this.cmcdController=this.createController(n.cmcdController,null,M),this.latencyController=this.createController(o.default,null,M),this.coreComponents=M}t.isSupported=function(){return Object(f.isSupported)()};var i,n,b,y=t.prototype;return y.createController=function(t,i,n){if(t){var r=i?new t(this,i):new t(this);return n&&n.push(r),r}return null},y.on=function(t,i,n){void 0===n&&(n=this),this._emitter.on(t,i,n)},y.once=function(t,i,n){void 0===n&&(n=this),this._emitter.once(t,i,n)},y.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},y.off=function(t,i,n,r){void 0===n&&(n=this),this._emitter.off(t,i,n,r)},y.listeners=function(t){return this._emitter.listeners(t)},y.emit=function(t,i,n){return this._emitter.emit(t,i,n)},y.trigger=function(t,i){if(this.config.debug)return this.emit(t,t,i);try{return this.emit(t,t,i)}catch(i){l.logger.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(m.Events.ERROR,{type:p.ErrorTypes.OTHER_ERROR,details:p.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1},y.listenerCount=function(t){return this._emitter.listenerCount(t)},y.destroy=function(){l.logger.log("destroy"),this.trigger(m.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0},y.attachMedia=function(t){l.logger.log("attachMedia"),this._media=t,this.trigger(m.Events.MEDIA_ATTACHING,{media:t})},y.detachMedia=function(){l.logger.log("detachMedia"),this.trigger(m.Events.MEDIA_DETACHING,void 0),this._media=null},y.loadSource=function(t){this.stopLoad();var i=this.media,n=this.url,e=this.url=r.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});l.logger.log("loadSource:"+e),i&&n&&n!==e&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(i)),this.trigger(m.Events.MANIFEST_LOADING,{url:t})},y.startLoad=function(t){void 0===t&&(t=-1),l.logger.log("startLoad("+t+")"),this.networkControllers.forEach((function(i){i.startLoad(t)}))},y.stopLoad=function(){l.logger.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},y.swapAudioCodec=function(){l.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},y.recoverMediaError=function(){l.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},y.removeLevel=function(t,i){void 0===i&&(i=0),this.levelController.removeLevel(t,i)},i=t,b=[{key:"version",get:function(){return"1.1.5"}},{key:"Events",get:function(){return m.Events}},{key:"ErrorTypes",get:function(){return p.ErrorTypes}},{key:"ErrorDetails",get:function(){return p.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:v.hlsDefaultConfig},set:function(i){t.defaultConfig=i}}],(n=[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){l.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){l.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){l.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){l.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){l.logger.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var i=!!t;i!==this.config.capLevelToPlayerSize&&(i?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=i)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(l.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,i=this.config.minAutoBitrate;if(!t)return 0;for(var n=t.length,r=0;r<n;r++)if(t[r].maxBitrate>i)return r;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,i=this.autoLevelCapping;return-1===i&&t&&t.length?t.length-1:i}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var i=this.audioTrackController;i&&(i.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var i=this.subtitleTrackController;i&&(i.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var i=this.subtitleTrackController;i&&(i.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&g(i.prototype,n),b&&g(i,b),t}();b.defaultConfig=void 0},"./src/is-supported.ts":
194
194
  /*!*****************************!*\
195
195
  !*** ./src/is-supported.ts ***!
196
196
  \*****************************/
197
- /*! exports provided: isSupported, changeTypeSupported */function(t,i,r){r.r(i);r.d(i,"isSupported",(function(){return s}));r.d(i,"changeTypeSupported",(function(){return a}));var e=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var t=Object(e["getMediaSource"])();if(!t){return false}var i=n();var r=t&&typeof t.isTypeSupported==="function"&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"');var s=!i||i.prototype&&typeof i.prototype.appendBuffer==="function"&&typeof i.prototype.remove==="function";return!!r&&!!s}function a(){var t;var i=n();return typeof(i===null||i===void 0?void 0:(t=i.prototype)===null||t===void 0?void 0:t.changeType)==="function"}},"./src/loader/fragment-loader.ts":
197
+ /*! exports provided: isSupported, changeTypeSupported */function(t,i,n){n.r(i),n.d(i,"isSupported",(function(){return s})),n.d(i,"changeTypeSupported",(function(){return a}));var r=n(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function e(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var t=Object(r.getMediaSource)();if(!t)return!1;var i=e();return!(!t||"function"!=typeof t.isTypeSupported||!t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')||i&&(!i.prototype||"function"!=typeof i.prototype.appendBuffer||"function"!=typeof i.prototype.remove))}function a(){var t,i=e();return"function"==typeof(null==i||null===(t=i.prototype)||void 0===t?void 0:t.changeType)}},"./src/loader/fragment-loader.ts":
198
198
  /*!***************************************!*\
199
199
  !*** ./src/loader/fragment-loader.ts ***!
200
200
  \***************************************/
201
- /*! exports provided: default, LoadError */function(t,i,r){r.r(i);r.d(i,"default",(function(){return c}));r.d(i,"LoadError",(function(){return m}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../errors */"./src/errors.ts");function s(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;o(t,i)}function a(t){var i=typeof Map==="function"?new Map:undefined;a=function t(r){if(r===null||!h(r))return r;if(typeof r!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof i!=="undefined"){if(i.has(r))return i.get(r);i.set(r,e)}function e(){return u(r,arguments,v(this).constructor)}e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});return o(e,r)};return a(t)}function u(t,i,r){if(f()){u=Reflect.construct}else{u=function t(i,r,e){var n=[null];n.push.apply(n,r);var s=Function.bind.apply(i,n);var a=new s;if(e)o(a,e.prototype);return a}}return u.apply(null,arguments)}function f(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));return true}catch(t){return false}}function h(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function o(t,i){o=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return o(t,i)}function v(t){v=Object.setPrototypeOf?Object.getPrototypeOf:function t(i){return i.__proto__||Object.getPrototypeOf(i)};return v(t)}var l=Math.pow(2,17);var c=function(){function t(t){this.config=void 0;this.loader=null;this.partLoadTimeout=-1;this.config=t}var i=t.prototype;i.destroy=function t(){if(this.loader){this.loader.destroy();this.loader=null}};i.abort=function t(){if(this.loader){this.loader.abort()}};i.load=function t(i,r){var e=this;var s=i.url;if(!s){return Promise.reject(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_ERROR,fatal:false,frag:i,networkDetails:null},"Fragment does not have a "+(s?"part list":"url")))}this.abort();var a=this.config;var u=a.fLoader;var f=a.loader;return new Promise((function(t,s){if(e.loader){e.loader.destroy()}var h=e.loader=i.loader=u?new u(a):new f(a);var o=d(i);var v={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:l};i.stats=h.stats;h.load(o,v,{onSuccess:function r(n,s,a,u){e.resetLoader(i,h);t({frag:i,part:null,payload:n.data,networkDetails:u})},onError:function t(r,a,u){e.resetLoader(i,h);s(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_ERROR,fatal:false,frag:i,response:r,networkDetails:u}))},onAbort:function t(r,a,u){e.resetLoader(i,h);s(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].INTERNAL_ABORTED,fatal:false,frag:i,networkDetails:u}))},onTimeout:function t(r,a,u){e.resetLoader(i,h);s(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_TIMEOUT,fatal:false,frag:i,networkDetails:u}))},onProgress:function t(e,n,s,a){if(r){r({frag:i,part:null,payload:s,networkDetails:a})}}})}))};i.loadPart=function t(i,r,e){var s=this;this.abort();var a=this.config;var u=a.fLoader;var f=a.loader;return new Promise((function(t,h){if(s.loader){s.loader.destroy()}var o=s.loader=i.loader=u?new u(a):new f(a);var v=d(i,r);var c={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:l};r.stats=o.stats;o.load(v,c,{onSuccess:function n(a,u,f,h){s.resetLoader(i,o);s.updateStatsFromPart(i,r);var v={frag:i,part:r,payload:a.data,networkDetails:h};e(v);t(v)},onError:function t(e,a,u){s.resetLoader(i,o);h(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_ERROR,fatal:false,frag:i,part:r,response:e,networkDetails:u}))},onAbort:function t(e,a,u){i.stats.aborted=r.stats.aborted;s.resetLoader(i,o);h(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].INTERNAL_ABORTED,fatal:false,frag:i,part:r,networkDetails:u}))},onTimeout:function t(e,a,u){s.resetLoader(i,o);h(new m({type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].FRAG_LOAD_TIMEOUT,fatal:false,frag:i,part:r,networkDetails:u}))}})}))};i.updateStatsFromPart=function t(i,r){var e=i.stats;var n=r.stats;var s=n.total;e.loaded+=n.loaded;if(s){var a=Math.round(i.duration/r.duration);var u=Math.min(Math.round(e.loaded/s),a);var f=a-u;var h=f*Math.round(e.loaded/u);e.total=e.loaded+h}else{e.total=Math.max(e.loaded,e.total)}var o=e.loading;var v=n.loading;if(o.start){o.first+=v.first-v.start}else{o.start=v.start;o.first=v.first}o.end=v.end};i.resetLoader=function t(i,r){i.loader=null;if(this.loader===r){self.clearTimeout(this.partLoadTimeout);this.loader=null}r.destroy()};return t}();function d(t,i){if(i===void 0){i=null}var r=i||t;var n={frag:t,part:i,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0};var s=r.byteRangeStartOffset;var a=r.byteRangeEndOffset;if(Object(e["isFiniteNumber"])(s)&&Object(e["isFiniteNumber"])(a)){n.rangeStart=s;n.rangeEnd=a}return n}var m=function(t){s(i,t);function i(i){var r;for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++){n[s-1]=arguments[s]}r=t.call.apply(t,[this].concat(n))||this;r.data=void 0;r.data=i;return r}return i}(a(Error))},"./src/loader/fragment.ts":
201
+ /*! exports provided: default, LoadError */function(t,i,n){n.r(i),n.d(i,"default",(function(){return f})),n.d(i,"LoadError",(function(){return v}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../errors */"./src/errors.ts");function s(t){var i="function"==typeof Map?new Map:void 0;return s=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,n)}function n(){return a(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,t)},s(t)}function a(t,i,n){return a=o()?Reflect.construct:function(t,i,n){var r=[null];r.push.apply(r,i);var e=new(Function.bind.apply(t,r));return n&&h(e,n.prototype),e},a.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t,i){return h=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},h(t,i)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}var c=Math.pow(2,17),f=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var i=t.prototype;return i.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},i.abort=function(){this.loader&&this.loader.abort()},i.load=function(t,i){var n=this,r=t.url;if(!r)return Promise.reject(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(r,h){n.loader&&n.loader.destroy();var u=n.loader=t.loader=a?new a(s):new o(s),f=l(t),d={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:c};t.stats=u.stats,u.load(f,d,{onSuccess:function(i,e,s,a){n.resetLoader(t,u),r({frag:t,part:null,payload:i.data,networkDetails:a})},onError:function(i,r,s){n.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:i,networkDetails:s}))},onAbort:function(i,r,s){n.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:s}))},onTimeout:function(i,r,s){n.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:s}))},onProgress:function(n,r,e,s){i&&i({frag:t,part:null,payload:e,networkDetails:s})}})}))},i.loadPart=function(t,i,n){var r=this;this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(h,u){r.loader&&r.loader.destroy();var f=r.loader=t.loader=a?new a(s):new o(s),d=l(t,i),m={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:c};i.stats=f.stats,f.load(d,m,{onSuccess:function(e,s,a,o){r.resetLoader(t,f),r.updateStatsFromPart(t,i);var u={frag:t,part:i,payload:e.data,networkDetails:o};n(u),h(u)},onError:function(n,s,a){r.resetLoader(t,f),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:i,response:n,networkDetails:a}))},onAbort:function(n,s,a){t.stats.aborted=i.stats.aborted,r.resetLoader(t,f),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:i,networkDetails:a}))},onTimeout:function(n,s,a){r.resetLoader(t,f),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:i,networkDetails:a}))}})}))},i.updateStatsFromPart=function(t,i){var n=t.stats,r=i.stats,e=r.total;if(n.loaded+=r.loaded,e){var s=Math.round(t.duration/i.duration),a=Math.min(Math.round(n.loaded/e),s),o=(s-a)*Math.round(n.loaded/a);n.total=n.loaded+o}else n.total=Math.max(n.loaded,n.total);var h=n.loading,u=r.loading;h.start?h.first+=u.first-u.start:(h.start=u.start,h.first=u.first),h.end=u.end},i.resetLoader=function(t,i){t.loader=null,this.loader===i&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),i.destroy()},t}();function l(t,i){void 0===i&&(i=null);var n=i||t,e={frag:t,part:i,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},s=n.byteRangeStartOffset,a=n.byteRangeEndOffset;return Object(r.isFiniteNumber)(s)&&Object(r.isFiniteNumber)(a)&&(e.rangeStart=s,e.rangeEnd=a),e}var v=function(t){var i,n;function r(i){for(var n,r=arguments.length,e=new Array(r>1?r-1:0),s=1;s<r;s++)e[s-1]=arguments[s];return(n=t.call.apply(t,[this].concat(e))||this).data=void 0,n.data=i,n}return n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,h(i,n),r}(s(Error))},"./src/loader/fragment.ts":
202
202
  /*!********************************!*\
203
203
  !*** ./src/loader/fragment.ts ***!
204
204
  \********************************/
205
- /*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(t,i,r){r.r(i);r.d(i,"ElementaryStreamTypes",(function(){return l}));r.d(i,"BaseSegment",(function(){return c}));r.d(i,"Fragment",(function(){return d}));r.d(i,"Part",(function(){return m}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=r(/*! ./level-key */"./src/loader/level-key.ts");var u=r(/*! ./load-stats */"./src/loader/load-stats.ts");function f(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;h(t,i)}function h(t,i){h=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return h(t,i)}function o(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function v(t,i,r){if(i)o(t.prototype,i);if(r)o(t,r);return t}var l;(function(t){t["AUDIO"]="audio";t["VIDEO"]="video";t["AUDIOVIDEO"]="audiovideo"})(l||(l={}));var c=function(){function t(t){var i;this._byteRange=null;this._url=null;this.baseurl=void 0;this.relurl=void 0;this.elementaryStreams=(i={},i[l.AUDIO]=null,i[l.VIDEO]=null,i[l.AUDIOVIDEO]=null,i);this.baseurl=t}var i=t.prototype;i.setByteRange=function t(i,r){var e=i.split("@",2);var n=[];if(e.length===1){n[0]=r?r.byteRangeEndOffset:0}else{n[0]=parseInt(e[1])}n[1]=parseInt(e[0])+n[0];this._byteRange=n};v(t,[{key:"byteRange",get:function t(){if(!this._byteRange){return[]}return this._byteRange}},{key:"byteRangeStartOffset",get:function t(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function t(){return this.byteRange[1]}},{key:"url",get:function t(){if(!this._url&&this.baseurl&&this.relurl){this._url=Object(n["buildAbsoluteURL"])(this.baseurl,this.relurl,{alwaysNormalize:true})}return this._url||""},set:function t(i){this._url=i}}]);return t}();var d=function(t){f(i,t);function i(i,r){var e;e=t.call(this,r)||this;e._decryptdata=null;e.rawProgramDateTime=null;e.programDateTime=null;e.tagList=[];e.duration=0;e.sn=0;e.levelkey=void 0;e.type=void 0;e.loader=null;e.level=-1;e.cc=0;e.startPTS=void 0;e.endPTS=void 0;e.appendedPTS=void 0;e.startDTS=void 0;e.endDTS=void 0;e.start=0;e.deltaPTS=void 0;e.maxStartPTS=void 0;e.minEndPTS=void 0;e.stats=new u["LoadStats"];e.urlId=0;e.data=void 0;e.bitrateTest=false;e.title=null;e.initSegment=null;e.type=i;return e}var r=i.prototype;r.createInitializationVector=function t(i){var r=new Uint8Array(16);for(var e=12;e<16;e++){r[e]=i>>8*(15-e)&255}return r};r.setDecryptDataFromLevelKey=function t(i,r){var e=i;if((i===null||i===void 0?void 0:i.method)==="AES-128"&&i.uri&&!i.iv){e=a["LevelKey"].fromURI(i.uri);e.method=i.method;e.iv=this.createInitializationVector(r);e.keyFormat="identity"}return e};r.setElementaryStreamInfo=function t(i,r,e,n,s,a){if(a===void 0){a=false}var u=this.elementaryStreams;var f=u[i];if(!f){u[i]={startPTS:r,endPTS:e,startDTS:n,endDTS:s,partial:a};return}f.startPTS=Math.min(f.startPTS,r);f.endPTS=Math.max(f.endPTS,e);f.startDTS=Math.min(f.startDTS,n);f.endDTS=Math.max(f.endDTS,s)};r.clearElementaryStreamInfo=function t(){var i=this.elementaryStreams;i[l.AUDIO]=null;i[l.VIDEO]=null;i[l.AUDIOVIDEO]=null};v(i,[{key:"decryptdata",get:function t(){if(!this.levelkey&&!this._decryptdata){return null}if(!this._decryptdata&&this.levelkey){var i=this.sn;if(typeof i!=="number"){if(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv){s["logger"].warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue')}i=0}this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function t(){return this.start+this.duration}},{key:"endProgramDateTime",get:function t(){if(this.programDateTime===null){return null}if(!Object(e["isFiniteNumber"])(this.programDateTime)){return null}var i=!Object(e["isFiniteNumber"])(this.duration)?0:this.duration;return this.programDateTime+i*1e3}},{key:"encrypted",get:function t(){var i;if((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri){return true}return false}}]);return i}(c);var m=function(t){f(i,t);function i(i,r,e,n,s){var a;a=t.call(this,e)||this;a.fragOffset=0;a.duration=0;a.gap=false;a.independent=false;a.relurl=void 0;a.fragment=void 0;a.index=void 0;a.stats=new u["LoadStats"];a.duration=i.decimalFloatingPoint("DURATION");a.gap=i.bool("GAP");a.independent=i.bool("INDEPENDENT");a.relurl=i.enumeratedString("URI");a.fragment=r;a.index=n;var f=i.enumeratedString("BYTERANGE");if(f){a.setByteRange(f,s)}if(s){a.fragOffset=s.fragOffset+s.duration}return a}v(i,[{key:"start",get:function t(){return this.fragment.start+this.fragOffset}},{key:"end",get:function t(){return this.start+this.duration}},{key:"loaded",get:function t(){var i=this.elementaryStreams;return!!(i.audio||i.video||i.audiovideo)}}]);return i}(c)},"./src/loader/key-loader.ts":
205
+ /*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(t,i,n){n.r(i),n.d(i,"ElementaryStreamTypes",(function(){return r})),n.d(i,"BaseSegment",(function(){return v})),n.d(i,"Fragment",(function(){return d})),n.d(i,"Part",(function(){return m}));var r,e=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),s=n(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ./level-key */"./src/loader/level-key.ts"),h=n(/*! ./load-stats */"./src/loader/load-stats.ts");function u(t,i){t.prototype=Object.create(i.prototype),t.prototype.constructor=t,c(t,i)}function c(t,i){return c=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},c(t,i)}function f(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t,i,n){return i&&f(t.prototype,i),n&&f(t,n),t}!function(t){t.AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo"}(r||(r={}));var v=function(){function t(t){var i;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((i={})[r.AUDIO]=null,i[r.VIDEO]=null,i[r.AUDIOVIDEO]=null,i),this.baseurl=t}return t.prototype.setByteRange=function(t,i){var n=t.split("@",2),r=[];r[0]=1===n.length?i?i.byteRangeEndOffset:0:parseInt(n[1]),r[1]=parseInt(n[0])+r[0],this._byteRange=r},l(t,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(s.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),d=function(t){function i(i,n){var r;return(r=t.call(this,n)||this)._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new h.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=i,r}u(i,t);var n=i.prototype;return n.createInitializationVector=function(t){for(var i=new Uint8Array(16),n=12;n<16;n++)i[n]=t>>8*(15-n)&255;return i},n.setDecryptDataFromLevelKey=function(t,i){var n=t;return"AES-128"===(null==t?void 0:t.method)&&t.uri&&!t.iv&&((n=o.LevelKey.fromURI(t.uri)).method=t.method,n.iv=this.createInitializationVector(i),n.keyFormat="identity"),n},n.setElementaryStreamInfo=function(t,i,n,r,e,s){void 0===s&&(s=!1);var a=this.elementaryStreams,o=a[t];o?(o.startPTS=Math.min(o.startPTS,i),o.endPTS=Math.max(o.endPTS,n),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,e)):a[t]={startPTS:i,endPTS:n,startDTS:r,endDTS:e,partial:s}},n.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[r.AUDIO]=null,t[r.VIDEO]=null,t[r.AUDIOVIDEO]=null},l(i,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var t=this.sn;"number"!=typeof t&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&a.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),t=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,t)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(e.isFiniteNumber)(this.programDateTime))return null;var t=Object(e.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;return!(null===(t=this.decryptdata)||void 0===t||!t.keyFormat||!this.decryptdata.uri)}}]),i}(v),m=function(t){function i(i,n,r,e,s){var a;(a=t.call(this,r)||this).fragOffset=0,a.duration=0,a.gap=!1,a.independent=!1,a.relurl=void 0,a.fragment=void 0,a.index=void 0,a.stats=new h.LoadStats,a.duration=i.decimalFloatingPoint("DURATION"),a.gap=i.bool("GAP"),a.independent=i.bool("INDEPENDENT"),a.relurl=i.enumeratedString("URI"),a.fragment=n,a.index=e;var o=i.enumeratedString("BYTERANGE");return o&&a.setByteRange(o,s),s&&(a.fragOffset=s.fragOffset+s.duration),a}return u(i,t),l(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),i}(v)},"./src/loader/key-loader.ts":
206
206
  /*!**********************************!*\
207
207
  !*** ./src/loader/key-loader.ts ***!
208
208
  \**********************************/
209
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return a}));var e=r(/*! ../events */"./src/events.ts");var n=r(/*! ../errors */"./src/errors.ts");var s=r(/*! ../utils/logger */"./src/utils/logger.ts");var a=function(){function t(t){this.hls=void 0;this.loaders={};this.decryptkey=null;this.decrypturl=null;this.hls=t;this._registerListeners()}var i=t.prototype;i._registerListeners=function t(){this.hls.on(e["Events"].KEY_LOADING,this.onKeyLoading,this)};i._unregisterListeners=function t(){this.hls.off(e["Events"].KEY_LOADING,this.onKeyLoading)};i.destroy=function t(){this._unregisterListeners();for(var i in this.loaders){var r=this.loaders[i];if(r){r.destroy()}}this.loaders={}};i.onKeyLoading=function t(i,r){var n=r.frag;var a=n.type;var u=this.loaders[a];if(!n.decryptdata){s["logger"].warn("Missing decryption data on fragment in onKeyLoading");return}var f=n.decryptdata.uri;if(f!==this.decrypturl||this.decryptkey===null){var h=this.hls.config;if(u){s["logger"].warn("abort previous key loader for type:"+a);u.abort()}if(!f){s["logger"].warn("key uri is falsy");return}var o=h.loader;var v=n.loader=this.loaders[a]=new o(h);this.decrypturl=f;this.decryptkey=null;var l={url:f,frag:n,responseType:"arraybuffer"};var c={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0};var d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(l,c,d)}else if(this.decryptkey){n.decryptdata.key=this.decryptkey;this.hls.trigger(e["Events"].KEY_LOADED,{frag:n})}};i.loadsuccess=function t(i,r,n){var a=n.frag;if(!a.decryptdata){s["logger"].error("after key load, decryptdata unset");return}this.decryptkey=a.decryptdata.key=new Uint8Array(i.data);a.loader=null;delete this.loaders[a.type];this.hls.trigger(e["Events"].KEY_LOADED,{frag:a})};i.loaderror=function t(i,r){var s=r.frag;var a=s.loader;if(a){a.abort()}delete this.loaders[s.type];this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].KEY_LOAD_ERROR,fatal:false,frag:s,response:i})};i.loadtimeout=function t(i,r){var s=r.frag;var a=s.loader;if(a){a.abort()}delete this.loaders[s.type];this.hls.trigger(e["Events"].ERROR,{type:n["ErrorTypes"].NETWORK_ERROR,details:n["ErrorDetails"].KEY_LOAD_TIMEOUT,fatal:false,frag:s})};return t}()},"./src/loader/level-details.ts":
209
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return a}));var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function t(t){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=t,this._registerListeners()}var i=t.prototype;return i._registerListeners=function(){this.hls.on(r.Events.KEY_LOADING,this.onKeyLoading,this)},i._unregisterListeners=function(){this.hls.off(r.Events.KEY_LOADING,this.onKeyLoading)},i.destroy=function(){for(var t in this._unregisterListeners(),this.loaders){var i=this.loaders[t];i&&i.destroy()}this.loaders={}},i.onKeyLoading=function(t,i){var n=i.frag,e=n.type,a=this.loaders[e];if(n.decryptdata){var o=n.decryptdata.uri;if(o!==this.decrypturl||null===this.decryptkey){var h=this.hls.config;if(a&&(s.logger.warn("abort previous key loader for type:"+e),a.abort()),!o)return void s.logger.warn("key uri is falsy");var u=n.loader=this.loaders[e]=new(0,h.loader)(h);this.decrypturl=o,this.decryptkey=null;var c={url:o,frag:n,responseType:"arraybuffer"},f={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(c,f,l)}else this.decryptkey&&(n.decryptdata.key=this.decryptkey,this.hls.trigger(r.Events.KEY_LOADED,{frag:n}))}else s.logger.warn("Missing decryption data on fragment in onKeyLoading")},i.loadsuccess=function(t,i,n){var e=n.frag;e.decryptdata?(this.decryptkey=e.decryptdata.key=new Uint8Array(t.data),e.loader=null,delete this.loaders[e.type],this.hls.trigger(r.Events.KEY_LOADED,{frag:e})):s.logger.error("after key load, decryptdata unset")},i.loaderror=function(t,i){var n=i.frag,s=n.loader;s&&s.abort(),delete this.loaders[n.type],this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:n,response:t})},i.loadtimeout=function(t,i){var n=i.frag,s=n.loader;s&&s.abort(),delete this.loaders[n.type],this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:n})},t}()},"./src/loader/level-details.ts":
210
210
  /*!*************************************!*\
211
211
  !*** ./src/loader/level-details.ts ***!
212
212
  \*************************************/
213
- /*! exports provided: LevelDetails */function(t,i,r){r.r(i);r.d(i,"LevelDetails",(function(){return u}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function n(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function s(t,i,r){if(i)n(t.prototype,i);if(r)n(t,r);return t}var a=10;var u=function(){function t(t){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.live=true;this.ageHeader=0;this.advancedDateTime=void 0;this.updated=true;this.advanced=true;this.availabilityDelay=void 0;this.misses=0;this.needSidxRanges=false;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.fragments=[];this.url=t}var i=t.prototype;i.reloaded=function t(i){if(!i){this.advanced=true;this.updated=true;return}var r=this.lastPartSn-i.lastPartSn;var e=this.lastPartIndex-i.lastPartIndex;this.updated=this.endSN!==i.endSN||!!e||!!r;this.advanced=this.endSN>i.endSN||r>0||r===0&&e>0;if(this.updated||this.advanced){this.misses=Math.floor(i.misses*.6)}else{this.misses=i.misses+1}this.availabilityDelay=i.availabilityDelay};s(t,[{key:"hasProgramDateTime",get:function t(){if(this.fragments.length){return Object(e["isFiniteNumber"])(this.fragments[this.fragments.length-1].programDateTime)}return false}},{key:"levelTargetDuration",get:function t(){return this.averagetargetduration||this.targetduration||a}},{key:"drift",get:function t(){var i=this.driftEndTime-this.driftStartTime;if(i>0){var r=this.driftEnd-this.driftStart;return r*1e3/i}return 1}},{key:"edge",get:function t(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function t(){var i;if((i=this.partList)!==null&&i!==void 0&&i.length){return this.partList[this.partList.length-1].end}return this.fragmentEnd}},{key:"fragmentEnd",get:function t(){var i;if((i=this.fragments)!==null&&i!==void 0&&i.length){return this.fragments[this.fragments.length-1].end}return 0}},{key:"age",get:function t(){if(this.advancedDateTime){return Math.max(Date.now()-this.advancedDateTime,0)/1e3}return 0}},{key:"lastPartIndex",get:function t(){var i;if((i=this.partList)!==null&&i!==void 0&&i.length){return this.partList[this.partList.length-1].index}return-1}},{key:"lastPartSn",get:function t(){var i;if((i=this.partList)!==null&&i!==void 0&&i.length){return this.partList[this.partList.length-1].fragment.sn}return this.endSN}}]);return t}()},"./src/loader/level-key.ts":
213
+ /*! exports provided: LevelDetails */function(t,i,n){n.r(i),n.d(i,"LevelDetails",(function(){return s}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function e(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,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=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,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.fragments=[],this.url=t}var i,n;return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var i=this.lastPartSn-t.lastPartSn,n=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!n||!!i,this.advanced=this.endSN>t.endSN||i>0||0===i&&n>0,this.misses=this.updated||this.advanced?Math.floor(.6*t.misses):t.misses+1,this.availabilityDelay=t.availabilityDelay},i=t,(n=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(r.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!==(t=this.fragments)&&void 0!==t&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&e(i.prototype,n),t}()},"./src/loader/level-key.ts":
214
214
  /*!*********************************!*\
215
215
  !*** ./src/loader/level-key.ts ***!
216
216
  \*********************************/
217
- /*! exports provided: LevelKey */function(t,i,r){r.r(i);r.d(i,"LevelKey",(function(){return a}));var e=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function n(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function s(t,i,r){if(i)n(t.prototype,i);if(r)n(t,r);return t}var a=function(){t.fromURL=function i(r,e){return new t(r,e)};t.fromURI=function i(r){return new t(r)};function t(t,i){this._uri=null;this.method=null;this.keyFormat=null;this.keyFormatVersions=null;this.keyID=null;this.key=null;this.iv=null;if(i){this._uri=Object(e["buildAbsoluteURL"])(t,i,{alwaysNormalize:true})}else{this._uri=t}}s(t,[{key:"uri",get:function t(){return this._uri}}]);return t}()},"./src/loader/load-stats.ts":
217
+ /*! exports provided: LevelKey */function(t,i,n){n.r(i),n.d(i,"LevelKey",(function(){return s}));var r=n(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function e(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=function(){function t(t,i){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=i?Object(r.buildAbsoluteURL)(t,i,{alwaysNormalize:!0}):t}var i,n;return t.fromURL=function(i,n){return new t(i,n)},t.fromURI=function(i){return new t(i)},i=t,(n=[{key:"uri",get:function(){return this._uri}}])&&e(i.prototype,n),t}()},"./src/loader/load-stats.ts":
218
218
  /*!**********************************!*\
219
219
  !*** ./src/loader/load-stats.ts ***!
220
220
  \**********************************/
221
- /*! exports provided: LoadStats */function(t,i,r){r.r(i);r.d(i,"LoadStats",(function(){return e}));var e=function t(){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}}},"./src/loader/m3u8-parser.ts":
221
+ /*! exports provided: LoadStats */function(t,i,n){n.r(i),n.d(i,"LoadStats",(function(){return r}));var r=function(){this.aborted=!1,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}}},"./src/loader/m3u8-parser.ts":
222
222
  /*!***********************************!*\
223
223
  !*** ./src/loader/m3u8-parser.ts ***!
224
224
  \***********************************/
225
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return g}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");var s=r(/*! ./fragment */"./src/loader/fragment.ts");var a=r(/*! ./level-details */"./src/loader/level-details.ts");var u=r(/*! ./level-key */"./src/loader/level-key.ts");var f=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");var h=r(/*! ../utils/logger */"./src/utils/logger.ts");var o=r(/*! ../utils/codecs */"./src/utils/codecs.ts");var v=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g;var l=/#EXT-X-MEDIA:(.*)/g;var c=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 d=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));var m=/\.(mp4|m4s|m4v|m4a)$/i;function p(t){var i,r;return m.test((i=(r=n["parseURL"](t))===null||r===void 0?void 0:r.path)!=null?i:"")}var g=function(){function t(){}t.findGroup=function t(i,r){for(var e=0;e<i.length;e++){var n=i[e];if(n.id===r){return n}}};t.convertAVC1ToAVCOTI=function t(i){var r=i.split(".");if(r.length>2){var e=r.shift()+".";e+=parseInt(r.shift()).toString(16);e+=("000"+parseInt(r.shift()).toString(16)).substr(-4);return e}return i};t.resolve=function t(i,r){return n["buildAbsoluteURL"](r,i,{alwaysNormalize:true})};t.parseMasterPlaylist=function i(r,e){var n=[];var s={};var a=false;v.lastIndex=0;var u;while((u=v.exec(r))!=null){if(u[1]){var h=new f["AttrList"](u[1]);var o={attrs:h,bitrate:h.decimalInteger("AVERAGE-BANDWIDTH")||h.decimalInteger("BANDWIDTH"),name:h.NAME,url:t.resolve(u[2],e)};var l=h.decimalResolution("RESOLUTION");if(l){o.width=l.width;o.height=l.height}b((h.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),o);if(o.videoCodec&&o.videoCodec.indexOf("avc1")!==-1){o.videoCodec=t.convertAVC1ToAVCOTI(o.videoCodec)}n.push(o)}else if(u[3]){var c=new f["AttrList"](u[3]);if(c["DATA-ID"]){a=true;s[c["DATA-ID"]]=c}}}return{levels:n,sessionData:a?s:null}};t.parseMasterPlaylistMedia=function i(r,e,n,s){if(s===void 0){s=[]}var a;var u=[];var h=0;l.lastIndex=0;while((a=l.exec(r))!==null){var o=new f["AttrList"](a[1]);if(o.TYPE===n){var v={attrs:o,bitrate:0,id:h++,groupId:o["GROUP-ID"],instreamId:o["INSTREAM-ID"],name:o.NAME||o.LANGUAGE||"",type:n,default:o.bool("DEFAULT"),autoselect:o.bool("AUTOSELECT"),forced:o.bool("FORCED"),lang:o.LANGUAGE,url:o.URI?t.resolve(o.URI,e):""};if(s.length){var c=t.findGroup(s,v.groupId)||s[0];y(v,c,"audioCodec");y(v,c,"textCodec")}u.push(v)}}return u};t.parseLevelPlaylist=function t(i,r,n,o,v){var l=new a["LevelDetails"](r);var m=l.fragments;var g=null;var b=0;var y=0;var T=0;var O=0;var S=null;var E=new s["Fragment"](o,r);var A;var M;var x;var j=-1;var D=false;c.lastIndex=0;l.m3u8=i;while((A=c.exec(i))!==null){if(D){D=false;E=new s["Fragment"](o,r);E.start=T;E.sn=b;E.cc=O;E.level=n;if(g){E.initSegment=g;E.rawProgramDateTime=g.rawProgramDateTime}}var L=A[1];if(L){E.duration=parseFloat(L);var I=(" "+A[2]).slice(1);E.title=I||null;E.tagList.push(I?["INF",L,I]:["INF",L])}else if(A[3]){if(Object(e["isFiniteNumber"])(E.duration)){E.start=T;if(x){E.levelkey=x}E.sn=b;E.level=n;E.cc=O;E.urlId=v;m.push(E);E.relurl=(" "+A[3]).slice(1);k(E,S);S=E;T+=E.duration;b++;y=0;D=true}}else if(A[4]){var C=(" "+A[4]).slice(1);if(S){E.setByteRange(C,S)}else{E.setByteRange(C)}}else if(A[5]){E.rawProgramDateTime=(" "+A[5]).slice(1);E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]);if(j===-1){j=m.length}}else{A=A[0].match(d);if(!A){h["logger"].warn("No matches on slow regex match for level playlist!");continue}for(M=1;M<A.length;M++){if(typeof A[M]!=="undefined"){break}}var R=(" "+A[M]).slice(1);var P=(" "+A[M+1]).slice(1);var U=A[M+2]?(" "+A[M+2]).slice(1):"";switch(R){case"PLAYLIST-TYPE":l.type=P.toUpperCase();break;case"MEDIA-SEQUENCE":b=l.startSN=parseInt(P);break;case"SKIP":{var N=new f["AttrList"](P);var F=N.decimalInteger("SKIPPED-SEGMENTS");if(Object(e["isFiniteNumber"])(F)){l.skippedSegments=F;for(var B=F;B--;){m.unshift(null)}b+=F}var _=N.enumeratedString("RECENTLY-REMOVED-DATERANGES");if(_){l.recentlyRemovedDateranges=_.split("\t")}break}case"TARGETDURATION":l.targetduration=parseFloat(P);break;case"VERSION":l.version=parseInt(P);break;case"EXTM3U":break;case"ENDLIST":l.live=false;break;case"#":if(P||U){E.tagList.push(U?[P,U]:[P])}break;case"DIS":O++;case"GAP":E.tagList.push([R]);break;case"BITRATE":E.tagList.push([R,P]);break;case"DISCONTINUITY-SEQ":O=parseInt(P);break;case"KEY":{var X;var G=new f["AttrList"](P);var W=G.enumeratedString("METHOD");var K=G.URI;var H=G.hexadecimalInteger("IV");var V=G.enumeratedString("KEYFORMATVERSIONS");var q=G.enumeratedString("KEYID");var z=(X=G.enumeratedString("KEYFORMAT"))!=null?X:"identity";var Y=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Y.indexOf(z)>-1){h["logger"].warn("Keyformat "+z+" is not supported from the manifest");continue}else if(z!=="identity"){continue}if(W){x=u["LevelKey"].fromURL(r,K);if(K&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(W)>=0){x.method=W;x.keyFormat=z;if(q){x.keyID=q}if(V){x.keyFormatVersions=V}x.iv=H}}break}case"START":{var $=new f["AttrList"](P);var J=$.decimalFloatingPoint("TIME-OFFSET");if(Object(e["isFiniteNumber"])(J)){l.startTimeOffset=J}break}case"MAP":{var Q=new f["AttrList"](P);E.relurl=Q.URI;if(Q.BYTERANGE){E.setByteRange(Q.BYTERANGE)}E.level=n;E.sn="initSegment";if(x){E.levelkey=x}E.initSegment=null;g=E;D=true;break}case"SERVER-CONTROL":{var Z=new f["AttrList"](P);l.canBlockReload=Z.bool("CAN-BLOCK-RELOAD");l.canSkipUntil=Z.optionalFloat("CAN-SKIP-UNTIL",0);l.canSkipDateRanges=l.canSkipUntil>0&&Z.bool("CAN-SKIP-DATERANGES");l.partHoldBack=Z.optionalFloat("PART-HOLD-BACK",0);l.holdBack=Z.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var tt=new f["AttrList"](P);l.partTarget=tt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var it=l.partList;if(!it){it=l.partList=[]}var rt=y>0?it[it.length-1]:undefined;var et=y++;var nt=new s["Part"](new f["AttrList"](P),E,r,et,rt);it.push(nt);E.duration+=nt.duration;break}case"PRELOAD-HINT":{var st=new f["AttrList"](P);l.preloadHint=st;break}case"RENDITION-REPORT":{var at=new f["AttrList"](P);l.renditionReports=l.renditionReports||[];l.renditionReports.push(at);break}default:h["logger"].warn("line parsed but not handled: "+A);break}}}if(S&&!S.relurl){m.pop();T-=S.duration;if(l.partList){l.fragmentHint=S}}else if(l.partList){k(E,S);E.cc=O;l.fragmentHint=E}var ut=m.length;var ft=m[0];var ht=m[ut-1];T+=l.skippedSegments*l.targetduration;if(T>0&&ut&&ht){l.averagetargetduration=T/ut;var ot=ht.sn;l.endSN=ot!=="initSegment"?ot:0;if(ft){l.startCC=ft.cc;if(!ft.initSegment){if(l.fragments.every((function(t){return t.relurl&&p(t.relurl)}))){h["logger"].warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX");E=new s["Fragment"](o,r);E.relurl=ht.relurl;E.level=n;E.sn="initSegment";ft.initSegment=E;l.needSidxRanges=true}}}}else{l.endSN=0;l.startCC=0}if(l.fragmentHint){T+=l.fragmentHint.duration}l.totalduration=T;l.endCC=O;if(j>0){w(m,j)}return l};return t}();function b(t,i){["video","audio","text"].forEach((function(r){var e=t.filter((function(t){return Object(o["isCodecType"])(t,r)}));if(e.length){var n=e.filter((function(t){return t.lastIndexOf("avc1",0)===0||t.lastIndexOf("mp4a",0)===0}));i[r+"Codec"]=n.length>0?n[0]:e[0];t=t.filter((function(t){return e.indexOf(t)===-1}))}}));i.unknownCodecs=t}function y(t,i,r){var e=i[r];if(e){t[r]=e}}function w(t,i){var r=t[i];for(var e=i;e--;){var n=t[e];if(!n){return}n.programDateTime=r.programDateTime-n.duration*1e3;r=n}}function k(t,i){if(t.rawProgramDateTime){t.programDateTime=Date.parse(t.rawProgramDateTime)}else if(i!==null&&i!==void 0&&i.programDateTime){t.programDateTime=i.endProgramDateTime}if(!Object(e["isFiniteNumber"])(t.programDateTime)){t.programDateTime=null;t.rawProgramDateTime=null}}},"./src/loader/playlist-loader.ts":
225
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return p}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=n(/*! ./fragment */"./src/loader/fragment.ts"),a=n(/*! ./level-details */"./src/loader/level-details.ts"),o=n(/*! ./level-key */"./src/loader/level-key.ts"),h=n(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),u=n(/*! ../utils/logger */"./src/utils/logger.ts"),c=n(/*! ../utils/codecs */"./src/utils/codecs.ts"),f=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,l=/#EXT-X-MEDIA:(.*)/g,v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),d=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),m=/\.(mp4|m4s|m4v|m4a)$/i,p=function(){function t(){}return t.findGroup=function(t,i){for(var n=0;n<t.length;n++){var r=t[n];if(r.id===i)return r}},t.convertAVC1ToAVCOTI=function(t){var i=t.split(".");if(i.length>2){var n=i.shift()+".";return(n+=parseInt(i.shift()).toString(16))+("000"+parseInt(i.shift()).toString(16)).substr(-4)}return t},t.resolve=function(t,i){return e.buildAbsoluteURL(i,t,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(i,n){var r,e=[],s={},a=!1;for(f.lastIndex=0;null!=(r=f.exec(i));)if(r[1]){var o=new h.AttrList(r[1]),u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(r[2],n)},c=o.decimalResolution("RESOLUTION");c&&(u.width=c.width,u.height=c.height),g((o.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=t.convertAVC1ToAVCOTI(u.videoCodec)),e.push(u)}else if(r[3]){var l=new h.AttrList(r[3]);l["DATA-ID"]&&(a=!0,s[l["DATA-ID"]]=l)}return{levels:e,sessionData:a?s:null}},t.parseMasterPlaylistMedia=function(i,n,r,e){var s;void 0===e&&(e=[]);var a=[],o=0;for(l.lastIndex=0;null!==(s=l.exec(i));){var u=new h.AttrList(s[1]);if(u.TYPE===r){var c={attrs:u,bitrate:0,id:o++,groupId:u["GROUP-ID"],instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:r,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?t.resolve(u.URI,n):""};if(e.length){var f=t.findGroup(e,c.groupId)||e[0];b(c,f,"audioCodec"),b(c,f,"textCodec")}a.push(c)}}return a},t.parseLevelPlaylist=function(t,i,n,c,f){var l,p,g,b=new a.LevelDetails(i),w=b.fragments,k=null,T=0,O=0,S=0,E=0,A=null,M=new s.Fragment(c,i),x=-1,j=!1;for(v.lastIndex=0,b.m3u8=t;null!==(l=v.exec(t));){j&&(j=!1,(M=new s.Fragment(c,i)).start=S,M.sn=T,M.cc=E,M.level=n,k&&(M.initSegment=k,M.rawProgramDateTime=k.rawProgramDateTime));var D=l[1];if(D){M.duration=parseFloat(D);var L=(" "+l[2]).slice(1);M.title=L||null,M.tagList.push(L?["INF",D,L]:["INF",D])}else if(l[3])Object(r.isFiniteNumber)(M.duration)&&(M.start=S,g&&(M.levelkey=g),M.sn=T,M.level=n,M.cc=E,M.urlId=f,w.push(M),M.relurl=(" "+l[3]).slice(1),y(M,A),A=M,S+=M.duration,T++,O=0,j=!0);else if(l[4]){var I=(" "+l[4]).slice(1);A?M.setByteRange(I,A):M.setByteRange(I)}else if(l[5])M.rawProgramDateTime=(" "+l[5]).slice(1),M.tagList.push(["PROGRAM-DATE-TIME",M.rawProgramDateTime]),-1===x&&(x=w.length);else{if(!(l=l[0].match(d))){u.logger.warn("No matches on slow regex match for level playlist!");continue}for(p=1;p<l.length&&void 0===l[p];p++);var C=(" "+l[p]).slice(1),R=(" "+l[p+1]).slice(1),P=l[p+2]?(" "+l[p+2]).slice(1):"";switch(C){case"PLAYLIST-TYPE":b.type=R.toUpperCase();break;case"MEDIA-SEQUENCE":T=b.startSN=parseInt(R);break;case"SKIP":var U=new h.AttrList(R),N=U.decimalInteger("SKIPPED-SEGMENTS");if(Object(r.isFiniteNumber)(N)){b.skippedSegments=N;for(var F=N;F--;)w.unshift(null);T+=N}var B=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(b.recentlyRemovedDateranges=B.split("\t"));break;case"TARGETDURATION":b.targetduration=parseFloat(R);break;case"VERSION":b.version=parseInt(R);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(R||P)&&M.tagList.push(P?[R,P]:[R]);break;case"DIS":E++;case"GAP":M.tagList.push([C]);break;case"BITRATE":M.tagList.push([C,R]);break;case"DISCONTINUITY-SEQ":E=parseInt(R);break;case"KEY":var _,X=new h.AttrList(R),G=X.enumeratedString("METHOD"),W=X.URI,K=X.hexadecimalInteger("IV"),H=X.enumeratedString("KEYFORMATVERSIONS"),V=X.enumeratedString("KEYID"),q=null!=(_=X.enumeratedString("KEYFORMAT"))?_:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(q)>-1){u.logger.warn("Keyformat "+q+" is not supported from the manifest");continue}if("identity"!==q)continue;G&&(g=o.LevelKey.fromURL(i,W),W&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(G)>=0&&(g.method=G,g.keyFormat=q,V&&(g.keyID=V),H&&(g.keyFormatVersions=H),g.iv=K));break;case"START":var z=new h.AttrList(R).decimalFloatingPoint("TIME-OFFSET");Object(r.isFiniteNumber)(z)&&(b.startTimeOffset=z);break;case"MAP":var Y=new h.AttrList(R);M.relurl=Y.URI,Y.BYTERANGE&&M.setByteRange(Y.BYTERANGE),M.level=n,M.sn="initSegment",g&&(M.levelkey=g),M.initSegment=null,k=M,j=!0;break;case"SERVER-CONTROL":var $=new h.AttrList(R);b.canBlockReload=$.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=$.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&$.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=$.optionalFloat("PART-HOLD-BACK",0),b.holdBack=$.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var J=new h.AttrList(R);b.partTarget=J.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=b.partList;Q||(Q=b.partList=[]);var Z=O>0?Q[Q.length-1]:void 0,tt=O++,it=new s.Part(new h.AttrList(R),M,i,tt,Z);Q.push(it),M.duration+=it.duration;break;case"PRELOAD-HINT":var nt=new h.AttrList(R);b.preloadHint=nt;break;case"RENDITION-REPORT":var rt=new h.AttrList(R);b.renditionReports=b.renditionReports||[],b.renditionReports.push(rt);break;default:u.logger.warn("line parsed but not handled: "+l)}}}A&&!A.relurl?(w.pop(),S-=A.duration,b.partList&&(b.fragmentHint=A)):b.partList&&(y(M,A),M.cc=E,b.fragmentHint=M);var et=w.length,st=w[0],at=w[et-1];if((S+=b.skippedSegments*b.targetduration)>0&&et&&at){b.averagetargetduration=S/et;var ot=at.sn;b.endSN="initSegment"!==ot?ot:0,st&&(b.startCC=st.cc,st.initSegment||b.fragments.every((function(t){return t.relurl&&m.test(null!=(i=null===(n=e.parseURL(t.relurl))||void 0===n?void 0:n.path)?i:"");var i,n}))&&(u.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(M=new s.Fragment(c,i)).relurl=at.relurl,M.level=n,M.sn="initSegment",st.initSegment=M,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(S+=b.fragmentHint.duration),b.totalduration=S,b.endCC=E,x>0&&function(t,i){for(var n=t[i],r=i;r--;){var e=t[r];if(!e)return;e.programDateTime=n.programDateTime-1e3*e.duration,n=e}}(w,x),b},t}();function g(t,i){["video","audio","text"].forEach((function(n){var r=t.filter((function(t){return Object(c.isCodecType)(t,n)}));if(r.length){var e=r.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));i[n+"Codec"]=e.length>0?e[0]:r[0],t=t.filter((function(t){return-1===r.indexOf(t)}))}})),i.unknownCodecs=t}function b(t,i,n){var r=i[n];r&&(t[n]=r)}function y(t,i){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=i&&i.programDateTime&&(t.programDateTime=i.endProgramDateTime),Object(r.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":
226
226
  /*!***************************************!*\
227
227
  !*** ./src/loader/playlist-loader.ts ***!
228
228
  \***************************************/
229
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../events */"./src/events.ts");var s=r(/*! ../errors */"./src/errors.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var f=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts");var h=r(/*! ../types/loader */"./src/types/loader.ts");var o=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function v(t){var i=t.type;switch(i){case h["PlaylistContextType"].AUDIO_TRACK:return h["PlaylistLevelType"].AUDIO;case h["PlaylistContextType"].SUBTITLE_TRACK:return h["PlaylistLevelType"].SUBTITLE;default:return h["PlaylistLevelType"].MAIN}}function l(t,i){var r=t.url;if(r===undefined||r.indexOf("data:")===0){r=i.url}return r}var c=function(){function t(t){this.hls=void 0;this.loaders=Object.create(null);this.hls=t;this.registerListeners()}var i=t.prototype;i.registerListeners=function t(){var i=this.hls;i.on(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.on(n["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.on(n["Events"].AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this);i.on(n["Events"].SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)};i.unregisterListeners=function t(){var i=this.hls;i.off(n["Events"].MANIFEST_LOADING,this.onManifestLoading,this);i.off(n["Events"].LEVEL_LOADING,this.onLevelLoading,this);i.off(n["Events"].AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this);i.off(n["Events"].SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)};i.createInternalLoader=function t(i){var r=this.hls.config;var e=r.pLoader;var n=r.loader;var s=e||n;var a=new s(r);i.loader=a;this.loaders[i.type]=a;return a};i.getInternalLoader=function t(i){return this.loaders[i.type]};i.resetInternalLoader=function t(i){if(this.loaders[i]){delete this.loaders[i]}};i.destroyInternalLoaders=function t(){for(var i in this.loaders){var r=this.loaders[i];if(r){r.destroy()}this.resetInternalLoader(i)}};i.destroy=function t(){this.unregisterListeners();this.destroyInternalLoaders()};i.onManifestLoading=function t(i,r){var e=r.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:h["PlaylistContextType"].MANIFEST,url:e,deliveryDirectives:null})};i.onLevelLoading=function t(i,r){var e=r.id,n=r.level,s=r.url,a=r.deliveryDirectives;this.load({id:e,groupId:null,level:n,responseType:"text",type:h["PlaylistContextType"].LEVEL,url:s,deliveryDirectives:a})};i.onAudioTrackLoading=function t(i,r){var e=r.id,n=r.groupId,s=r.url,a=r.deliveryDirectives;this.load({id:e,groupId:n,level:null,responseType:"text",type:h["PlaylistContextType"].AUDIO_TRACK,url:s,deliveryDirectives:a})};i.onSubtitleTrackLoading=function t(i,r){var e=r.id,n=r.groupId,s=r.url,a=r.deliveryDirectives;this.load({id:e,groupId:n,level:null,responseType:"text",type:h["PlaylistContextType"].SUBTITLE_TRACK,url:s,deliveryDirectives:a})};i.load=function t(i){var r;var e=this.hls.config;var n=this.getInternalLoader(i);if(n){var s=n.context;if(s&&s.url===i.url){a["logger"].trace("[playlist-loader]: playlist request ongoing");return}a["logger"].log("[playlist-loader]: aborting previous loader for type: "+i.type);n.abort()}var u;var f;var o;var v;switch(i.type){case h["PlaylistContextType"].MANIFEST:u=e.manifestLoadingMaxRetry;f=e.manifestLoadingTimeOut;o=e.manifestLoadingRetryDelay;v=e.manifestLoadingMaxRetryTimeout;break;case h["PlaylistContextType"].LEVEL:case h["PlaylistContextType"].AUDIO_TRACK:case h["PlaylistContextType"].SUBTITLE_TRACK:u=0;f=e.levelLoadingTimeOut;break;default:u=e.levelLoadingMaxRetry;f=e.levelLoadingTimeOut;o=e.levelLoadingRetryDelay;v=e.levelLoadingMaxRetryTimeout;break}n=this.createInternalLoader(i);if((r=i.deliveryDirectives)!==null&&r!==void 0&&r.part){var l;if(i.type===h["PlaylistContextType"].LEVEL&&i.level!==null){l=this.hls.levels[i.level].details}else if(i.type===h["PlaylistContextType"].AUDIO_TRACK&&i.id!==null){l=this.hls.audioTracks[i.id].details}else if(i.type===h["PlaylistContextType"].SUBTITLE_TRACK&&i.id!==null){l=this.hls.subtitleTracks[i.id].details}if(l){var c=l.partTarget;var d=l.targetduration;if(c&&d){f=Math.min(Math.max(c*3,d*.8)*1e3,f)}}}var m={timeout:f,maxRetry:u,retryDelay:o,maxRetryDelay:v,highWaterMark:0};var p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};n.load(i,m,p)};i.loadsuccess=function t(i,r,e,n){if(n===void 0){n=null}if(e.isSidxRequest){this.handleSidxRequest(i,e);this.handlePlaylistLoaded(i,r,e,n);return}this.resetInternalLoader(e.type);var s=i.data;if(s.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(i,e,"no EXTM3U delimiter",n);return}r.parsing.start=performance.now();if(s.indexOf("#EXTINF:")>0||s.indexOf("#EXT-X-TARGETDURATION:")>0){this.handleTrackOrLevelPlaylist(i,r,e,n)}else{this.handleMasterPlaylist(i,r,e,n)}};i.loaderror=function t(i,r,e){if(e===void 0){e=null}this.handleNetworkError(r,e,false,i)};i.loadtimeout=function t(i,r,e){if(e===void 0){e=null}this.handleNetworkError(r,e,true)};i.handleMasterPlaylist=function t(i,r,e,s){var u=this.hls;var h=i.data;var v=l(i,e);var c=f["default"].parseMasterPlaylist(h,v),d=c.levels,m=c.sessionData;if(!d.length){this.handleManifestParsingError(i,e,"no level found in manifest",s);return}var p=d.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}}));var g=d.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}}));var b=f["default"].parseMasterPlaylistMedia(h,v,"AUDIO",p);var y=f["default"].parseMasterPlaylistMedia(h,v,"SUBTITLES",g);var w=f["default"].parseMasterPlaylistMedia(h,v,"CLOSED-CAPTIONS");if(b.length){var k=b.some((function(t){return!t.url}));if(!k&&d[0].audioCodec&&!d[0].attrs.AUDIO){a["logger"].log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one");b.unshift({type:"main",name:"main",default:false,autoselect:false,forced:false,id:-1,attrs:new o["AttrList"]({}),bitrate:0,url:""})}}u.trigger(n["Events"].MANIFEST_LOADED,{levels:d,audioTracks:b,subtitles:y,captions:w,url:v,stats:r,networkDetails:s,sessionData:m})};i.handleTrackOrLevelPlaylist=function t(i,r,a,u){var c=this.hls;var d=a.id,m=a.level,p=a.type;var g=l(i,a);var b=Object(e["isFiniteNumber"])(d)?d:0;var y=Object(e["isFiniteNumber"])(m)?m:b;var w=v(a);var k=f["default"].parseLevelPlaylist(i.data,g,y,w,b);if(!k.fragments.length){c.trigger(n["Events"].ERROR,{type:s["ErrorTypes"].NETWORK_ERROR,details:s["ErrorDetails"].LEVEL_EMPTY_ERROR,fatal:false,url:g,reason:"no fragments found in level",level:typeof a.level==="number"?a.level:undefined});return}if(p===h["PlaylistContextType"].MANIFEST){var T={attrs:new o["AttrList"]({}),bitrate:0,details:k,name:"",url:g};c.trigger(n["Events"].MANIFEST_LOADED,{levels:[T],audioTracks:[],url:g,stats:r,networkDetails:u,sessionData:null})}r.parsing.end=performance.now();if(k.needSidxRanges){var O;var S=(O=k.fragments[0].initSegment)===null||O===void 0?void 0:O.url;this.load({url:S,isSidxRequest:true,type:p,level:m,levelDetails:k,id:d,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}a.levelDetails=k;this.handlePlaylistLoaded(i,r,a,u)};i.handleSidxRequest=function t(i,r){var e=Object(u["parseSegmentIndex"])(new Uint8Array(i.data));if(!e){return}var n=e.references;var s=r.levelDetails;n.forEach((function(t,i){var r=t.info;var n=s.fragments[i];if(n.byteRange.length===0){n.setByteRange(String(1+r.end-r.start)+"@"+String(r.start))}if(n.initSegment){n.initSegment.setByteRange(String(e.moovEndOffset)+"@0")}}))};i.handleManifestParsingError=function t(i,r,e,a){this.hls.trigger(n["Events"].ERROR,{type:s["ErrorTypes"].NETWORK_ERROR,details:s["ErrorDetails"].MANIFEST_PARSING_ERROR,fatal:r.type===h["PlaylistContextType"].MANIFEST,url:i.url,reason:e,response:i,context:r,networkDetails:a})};i.handleNetworkError=function t(i,r,e,u){if(e===void 0){e=false}a["logger"].warn("[playlist-loader]: A network "+(e?"timeout":"error")+" occurred while loading "+i.type+" level: "+i.level+" id: "+i.id+' group-id: "'+i.groupId+'"');var f=s["ErrorDetails"].UNKNOWN;var o=false;var v=this.getInternalLoader(i);switch(i.type){case h["PlaylistContextType"].MANIFEST:f=e?s["ErrorDetails"].MANIFEST_LOAD_TIMEOUT:s["ErrorDetails"].MANIFEST_LOAD_ERROR;o=true;break;case h["PlaylistContextType"].LEVEL:f=e?s["ErrorDetails"].LEVEL_LOAD_TIMEOUT:s["ErrorDetails"].LEVEL_LOAD_ERROR;o=false;break;case h["PlaylistContextType"].AUDIO_TRACK:f=e?s["ErrorDetails"].AUDIO_TRACK_LOAD_TIMEOUT:s["ErrorDetails"].AUDIO_TRACK_LOAD_ERROR;o=false;break;case h["PlaylistContextType"].SUBTITLE_TRACK:f=e?s["ErrorDetails"].SUBTITLE_TRACK_LOAD_TIMEOUT:s["ErrorDetails"].SUBTITLE_LOAD_ERROR;o=false;break}if(v){this.resetInternalLoader(i.type)}var l={type:s["ErrorTypes"].NETWORK_ERROR,details:f,fatal:o,url:i.url,loader:v,context:i,networkDetails:r};if(u){l.response=u}this.hls.trigger(n["Events"].ERROR,l)};i.handlePlaylistLoaded=function t(i,r,e,s){var a=e.type,u=e.level,f=e.id,o=e.groupId,v=e.loader,l=e.levelDetails,c=e.deliveryDirectives;if(!(l!==null&&l!==void 0&&l.targetduration)){this.handleManifestParsingError(i,e,"invalid target duration",s);return}if(!v){return}if(l.live){if(v.getCacheAge){l.ageHeader=v.getCacheAge()||0}if(!v.getCacheAge||isNaN(l.ageHeader)){l.ageHeader=0}}switch(a){case h["PlaylistContextType"].MANIFEST:case h["PlaylistContextType"].LEVEL:this.hls.trigger(n["Events"].LEVEL_LOADED,{details:l,level:u||0,id:f||0,stats:r,networkDetails:s,deliveryDirectives:c});break;case h["PlaylistContextType"].AUDIO_TRACK:this.hls.trigger(n["Events"].AUDIO_TRACK_LOADED,{details:l,id:f||0,groupId:o||"",stats:r,networkDetails:s,deliveryDirectives:c});break;case h["PlaylistContextType"].SUBTITLE_TRACK:this.hls.trigger(n["Events"].SUBTITLE_TRACK_LOADED,{details:l,id:f||0,groupId:o||"",stats:r,networkDetails:s,deliveryDirectives:c});break}};return t}();i["default"]=c},"./src/polyfills/number.ts":
229
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../errors */"./src/errors.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=n(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts"),c=n(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function f(t,i){var n=t.url;return void 0!==n&&0!==n.indexOf("data:")||(n=i.url),n}var l=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.hls=t,this.registerListeners()}var i=t.prototype;return i.registerListeners=function(){var t=this.hls;t.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(e.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(e.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(e.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},i.unregisterListeners=function(){var t=this.hls;t.off(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(e.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(e.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(e.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},i.createInternalLoader=function(t){var i=this.hls.config,n=new(i.pLoader||i.loader)(i);return t.loader=n,this.loaders[t.type]=n,n},i.getInternalLoader=function(t){return this.loaders[t.type]},i.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},i.destroyInternalLoaders=function(){for(var t in this.loaders){var i=this.loaders[t];i&&i.destroy(),this.resetInternalLoader(t)}},i.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},i.onManifestLoading=function(t,i){this.load({id:null,groupId:null,level:0,responseType:"text",type:u.PlaylistContextType.MANIFEST,url:i.url,deliveryDirectives:null})},i.onLevelLoading=function(t,i){this.load({id:i.id,groupId:null,level:i.level,responseType:"text",type:u.PlaylistContextType.LEVEL,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.onAudioTrackLoading=function(t,i){this.load({id:i.id,groupId:i.groupId,level:null,responseType:"text",type:u.PlaylistContextType.AUDIO_TRACK,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.onSubtitleTrackLoading=function(t,i){this.load({id:i.id,groupId:i.groupId,level:null,responseType:"text",type:u.PlaylistContextType.SUBTITLE_TRACK,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.load=function(t){var i,n,r,e,s,o,h=this.hls.config,c=this.getInternalLoader(t);if(c){var f=c.context;if(f&&f.url===t.url)return void a.logger.trace("[playlist-loader]: playlist request ongoing");a.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),c.abort()}switch(t.type){case u.PlaylistContextType.MANIFEST:n=h.manifestLoadingMaxRetry,r=h.manifestLoadingTimeOut,e=h.manifestLoadingRetryDelay,s=h.manifestLoadingMaxRetryTimeout;break;case u.PlaylistContextType.LEVEL:case u.PlaylistContextType.AUDIO_TRACK:case u.PlaylistContextType.SUBTITLE_TRACK:n=0,r=h.levelLoadingTimeOut;break;default:n=h.levelLoadingMaxRetry,r=h.levelLoadingTimeOut,e=h.levelLoadingRetryDelay,s=h.levelLoadingMaxRetryTimeout}if(c=this.createInternalLoader(t),null!==(i=t.deliveryDirectives)&&void 0!==i&&i.part&&(t.type===u.PlaylistContextType.LEVEL&&null!==t.level?o=this.hls.levels[t.level].details:t.type===u.PlaylistContextType.AUDIO_TRACK&&null!==t.id?o=this.hls.audioTracks[t.id].details:t.type===u.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(o=this.hls.subtitleTracks[t.id].details),o)){var l=o.partTarget,v=o.targetduration;l&&v&&(r=Math.min(1e3*Math.max(3*l,.8*v),r))}var d={timeout:r,maxRetry:n,retryDelay:e,maxRetryDelay:s,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(t,d,m)},i.loadsuccess=function(t,i,n,r){if(void 0===r&&(r=null),n.isSidxRequest)return this.handleSidxRequest(t,n),void this.handlePlaylistLoaded(t,i,n,r);this.resetInternalLoader(n.type);var e=t.data;0===e.indexOf("#EXTM3U")?(i.parsing.start=performance.now(),e.indexOf("#EXTINF:")>0||e.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,i,n,r):this.handleMasterPlaylist(t,i,n,r)):this.handleManifestParsingError(t,n,"no EXTM3U delimiter",r)},i.loaderror=function(t,i,n){void 0===n&&(n=null),this.handleNetworkError(i,n,!1,t)},i.loadtimeout=function(t,i,n){void 0===n&&(n=null),this.handleNetworkError(i,n,!0)},i.handleMasterPlaylist=function(t,i,n,r){var s=this.hls,o=t.data,u=f(t,n),l=h.default.parseMasterPlaylist(o,u),v=l.levels,d=l.sessionData;if(v.length){var m=v.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),p=v.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),g=h.default.parseMasterPlaylistMedia(o,u,"AUDIO",m),b=h.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",p),y=h.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");g.length&&(g.some((function(t){return!t.url}))||!v[0].audioCodec||v[0].attrs.AUDIO||(a.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new c.AttrList({}),bitrate:0,url:""}))),s.trigger(e.Events.MANIFEST_LOADED,{levels:v,audioTracks:g,subtitles:b,captions:y,url:u,stats:i,networkDetails:r,sessionData:d})}else this.handleManifestParsingError(t,n,"no level found in manifest",r)},i.handleTrackOrLevelPlaylist=function(t,i,n,a){var o=this.hls,l=n.id,v=n.level,d=n.type,m=f(t,n),p=Object(r.isFiniteNumber)(l)?l:0,g=Object(r.isFiniteNumber)(v)?v:p,b=function(t){switch(t.type){case u.PlaylistContextType.AUDIO_TRACK:return u.PlaylistLevelType.AUDIO;case u.PlaylistContextType.SUBTITLE_TRACK:return u.PlaylistLevelType.SUBTITLE;default:return u.PlaylistLevelType.MAIN}}(n),y=h.default.parseLevelPlaylist(t.data,m,g,b,p);if(y.fragments.length){if(d===u.PlaylistContextType.MANIFEST){var w={attrs:new c.AttrList({}),bitrate:0,details:y,name:"",url:m};o.trigger(e.Events.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:m,stats:i,networkDetails:a,sessionData:null})}if(i.parsing.end=performance.now(),y.needSidxRanges){var k,T=null===(k=y.fragments[0].initSegment)||void 0===k?void 0:k.url;this.load({url:T,isSidxRequest:!0,type:d,level:v,levelDetails:y,id:l,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else n.levelDetails=y,this.handlePlaylistLoaded(t,i,n,a)}else o.trigger(e.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:m,reason:"no fragments found in level",level:"number"==typeof n.level?n.level:void 0})},i.handleSidxRequest=function(t,i){var n=Object(o.parseSegmentIndex)(new Uint8Array(t.data));if(n){var r=i.levelDetails;n.references.forEach((function(t,i){var e=t.info,s=r.fragments[i];0===s.byteRange.length&&s.setByteRange(String(1+e.end-e.start)+"@"+String(e.start)),s.initSegment&&s.initSegment.setByteRange(String(n.moovEndOffset)+"@0")}))}},i.handleManifestParsingError=function(t,i,n,r){this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:i.type===u.PlaylistContextType.MANIFEST,url:t.url,reason:n,response:t,context:i,networkDetails:r})},i.handleNetworkError=function(t,i,n,r){void 0===n&&(n=!1),a.logger.warn("[playlist-loader]: A network "+(n?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var o=s.ErrorDetails.UNKNOWN,h=!1,c=this.getInternalLoader(t);switch(t.type){case u.PlaylistContextType.MANIFEST:o=n?s.ErrorDetails.MANIFEST_LOAD_TIMEOUT:s.ErrorDetails.MANIFEST_LOAD_ERROR,h=!0;break;case u.PlaylistContextType.LEVEL:o=n?s.ErrorDetails.LEVEL_LOAD_TIMEOUT:s.ErrorDetails.LEVEL_LOAD_ERROR,h=!1;break;case u.PlaylistContextType.AUDIO_TRACK:o=n?s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case u.PlaylistContextType.SUBTITLE_TRACK:o=n?s.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:s.ErrorDetails.SUBTITLE_LOAD_ERROR,h=!1}c&&this.resetInternalLoader(t.type);var f={type:s.ErrorTypes.NETWORK_ERROR,details:o,fatal:h,url:t.url,loader:c,context:t,networkDetails:i};r&&(f.response=r),this.hls.trigger(e.Events.ERROR,f)},i.handlePlaylistLoaded=function(t,i,n,r){var s=n.type,a=n.level,o=n.id,h=n.groupId,c=n.loader,f=n.levelDetails,l=n.deliveryDirectives;if(null!=f&&f.targetduration){if(c)switch(f.live&&(c.getCacheAge&&(f.ageHeader=c.getCacheAge()||0),c.getCacheAge&&!isNaN(f.ageHeader)||(f.ageHeader=0)),s){case u.PlaylistContextType.MANIFEST:case u.PlaylistContextType.LEVEL:this.hls.trigger(e.Events.LEVEL_LOADED,{details:f,level:a||0,id:o||0,stats:i,networkDetails:r,deliveryDirectives:l});break;case u.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(e.Events.AUDIO_TRACK_LOADED,{details:f,id:o||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:l});break;case u.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(e.Events.SUBTITLE_TRACK_LOADED,{details:f,id:o||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:l})}}else this.handleManifestParsingError(t,n,"invalid target duration",r)},t}();i.default=l},"./src/polyfills/number.ts":
230
230
  /*!*********************************!*\
231
231
  !*** ./src/polyfills/number.ts ***!
232
232
  \*********************************/
233
- /*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(t,i,r){r.r(i);r.d(i,"isFiniteNumber",(function(){return e}));r.d(i,"MAX_SAFE_INTEGER",(function(){return n}));var e=Number.isFinite||function(t){return typeof t==="number"&&isFinite(t)};var n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
233
+ /*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(t,i,n){n.r(i),n.d(i,"isFiniteNumber",(function(){return r})),n.d(i,"MAX_SAFE_INTEGER",(function(){return e}));var r=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},e=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
234
234
  /*!*********************************!*\
235
235
  !*** ./src/remux/aac-helper.ts ***!
236
236
  \*********************************/
237
- /*! exports provided: default */function(t,i,r){r.r(i);var e=function(){function t(){}t.getSilentFrame=function t(i,r){switch(i){case"mp4a.40.2":if(r===1){return new Uint8Array([0,200,0,128,35,128])}else if(r===2){return new Uint8Array([33,0,73,144,2,25,0,35,128])}else if(r===3){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142])}else if(r===4){return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56])}else if(r===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(r===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(r===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(r===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(r===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 t}();i["default"]=e},"./src/remux/mp4-generator.ts":
237
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default=function(){function t(){}return t.getSilentFrame=function(t,i){if("mp4a.40.2"===t){if(1===i)return new Uint8Array([0,200,0,128,35,128]);if(2===i)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===i)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])}else{if(1===i)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]);if(2===i)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]);if(3===i)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])}},t}()},"./src/remux/mp4-generator.ts":
238
238
  /*!************************************!*\
239
239
  !*** ./src/remux/mp4-generator.ts ***!
240
240
  \************************************/
241
- /*! exports provided: default */function(t,i,r){r.r(i);var e=Math.pow(2,32)-1;var n=function(){function t(){}t.init=function i(){t.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 r;for(r in t.types){if(t.types.hasOwnProperty(r)){t.types[r]=[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3)]}}var e=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 n=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]);t.HDLR_TYPES={video:e,audio:n};var s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]);var a=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=a;t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]);t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]);t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var u=new Uint8Array([105,115,111,109]);var f=new Uint8Array([97,118,99,49]);var h=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,u,h,u,f);t.DINF=t.box(t.types.dinf,t.box(t.types.dref,s))};t.box=function t(i){var r=8;for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++){n[s-1]=arguments[s]}var a=n.length;var u=a;while(a--){r+=n[a].byteLength}var f=new Uint8Array(r);f[0]=r>>24&255;f[1]=r>>16&255;f[2]=r>>8&255;f[3]=r&255;f.set(i,4);for(a=0,r=8;a<u;a++){f.set(n[a],r);r+=n[a].byteLength}return f};t.hdlr=function i(r){return t.box(t.types.hdlr,t.HDLR_TYPES[r])};t.mdat=function i(r){return t.box(t.types.mdat,r)};t.mdhd=function i(r,n){n*=r;var s=Math.floor(n/(e+1));var a=Math.floor(n%(e+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,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,s>>24,s>>16&255,s>>8&255,s&255,a>>24,a>>16&255,a>>8&255,a&255,85,196,0,0]))};t.mdia=function i(r){return t.box(t.types.mdia,t.mdhd(r.timescale,r.duration),t.hdlr(r.type),t.minf(r))};t.mfhd=function i(r){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255]))};t.minf=function i(r){if(r.type==="audio"){return t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(r))}else{return t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(r))}};t.moof=function i(r,e,n){return t.box(t.types.moof,t.mfhd(r),t.traf(n,e))};t.moov=function i(r){var e=r.length;var n=[];while(e--){n[e]=t.trak(r[e])}return t.box.apply(null,[t.types.moov,t.mvhd(r[0].timescale,r[0].duration)].concat(n).concat(t.mvex(r)))};t.mvex=function i(r){var e=r.length;var n=[];while(e--){n[e]=t.trex(r[e])}return t.box.apply(null,[t.types.mvex].concat(n))};t.mvhd=function i(r,n){n*=r;var s=Math.floor(n/(e+1));var a=Math.floor(n%(e+1));var u=new Uint8Array([1,0,0,0,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,s>>24,s>>16&255,s>>8&255,s&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 t.box(t.types.mvhd,u)};t.sdtp=function i(r){var e=r.samples||[];var n=new Uint8Array(4+e.length);var s;var a;for(s=0;s<e.length;s++){a=e[s].flags;n[s+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy}return t.box(t.types.sdtp,n)};t.stbl=function i(r){return t.box(t.types.stbl,t.stsd(r),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))};t.avc1=function i(r){var e=[];var n=[];var s;var a;var u;for(s=0;s<r.sps.length;s++){a=r.sps[s];u=a.byteLength;e.push(u>>>8&255);e.push(u&255);e=e.concat(Array.prototype.slice.call(a))}for(s=0;s<r.pps.length;s++){a=r.pps[s];u=a.byteLength;n.push(u>>>8&255);n.push(u&255);n=n.concat(Array.prototype.slice.call(a))}var f=t.box(t.types.avcC,new Uint8Array([1,e[3],e[4],e[5],252|3,224|r.sps.length].concat(e).concat([r.pps.length]).concat(n)));var h=r.width;var o=r.height;var v=r.pixelRatio[0];var l=r.pixelRatio[1];return t.box(t.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,h>>8&255,h&255,o>>8&255,o&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]),f,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([v>>24,v>>16&255,v>>8&255,v&255,l>>24,l>>16&255,l>>8&255,l&255])))};t.esds=function t(i){var r=i.config.length;return new Uint8Array([0,0,0,0,3,23+r,0,1,0,4,15+r,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([r]).concat(i.config).concat([6,1,2]))};t.mp4a=function i(r){var e=r.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),t.box(t.types.esds,t.esds(r)))};t.mp3=function i(r){var e=r.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))};t.stsd=function i(r){if(r.type==="audio"){if(!r.isAAC&&r.codec==="mp3"){return t.box(t.types.stsd,t.STSD,t.mp3(r))}return t.box(t.types.stsd,t.STSD,t.mp4a(r))}else{return t.box(t.types.stsd,t.STSD,t.avc1(r))}};t.tkhd=function i(r){var n=r.id;var s=r.duration*r.timescale;var a=r.width;var u=r.height;var f=Math.floor(s/(e+1));var h=Math.floor(s%(e+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,n&255,0,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,h>>24,h>>16&255,h>>8&255,h&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,u>>8&255,u&255,0,0]))};t.traf=function i(r,n){var s=t.sdtp(r);var a=r.id;var u=Math.floor(n/(e+1));var f=Math.floor(n%(e+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,u>>24,u>>16&255,u>>8&255,u&255,f>>24,f>>16&255,f>>8&255,f&255])),t.trun(r,s.length+16+20+8+16+8+8),s)};t.trak=function i(r){r.duration=r.duration||4294967295;return t.box(t.types.trak,t.tkhd(r),t.mdia(r))};t.trex=function i(r){var e=r.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))};t.trun=function i(r,e){var n=r.samples||[];var s=n.length;var a=12+16*s;var u=new Uint8Array(a);var f;var h;var o;var v;var l;var c;e+=8+a;u.set([0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0);for(f=0;f<s;f++){h=n[f];o=h.duration;v=h.size;l=h.flags;c=h.cts;u.set([o>>>24&255,o>>>16&255,o>>>8&255,o&255,v>>>24&255,v>>>16&255,v>>>8&255,v&255,l.isLeading<<2|l.dependsOn,l.isDependedOn<<6|l.hasRedundancy<<4|l.paddingValue<<1|l.isNonSync,l.degradPrio&240<<8,l.degradPrio&15,c>>>24&255,c>>>16&255,c>>>8&255,c&255],12+16*f)}return t.box(t.types.trun,u)};t.initSegment=function i(r){if(!t.types){t.init()}var e=t.moov(r);var n=new Uint8Array(t.FTYP.byteLength+e.byteLength);n.set(t.FTYP);n.set(e,t.FTYP.byteLength);return n};return t}();n.types=void 0;n.HDLR_TYPES=void 0;n.STTS=void 0;n.STSC=void 0;n.STCO=void 0;n.STSZ=void 0;n.VMHD=void 0;n.SMHD=void 0;n.STSD=void 0;n.FTYP=void 0;n.DINF=void 0;i["default"]=n},"./src/remux/mp4-remuxer.ts":
241
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=Math.pow(2,32)-1,e=function(){function t(){}return t.init=function(){var i;for(i in t.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:[]})t.types.hasOwnProperty(i)&&(t.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var n=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]),r=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]);t.HDLR_TYPES={video:n,audio:r};var e=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=s,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),h=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,a,h,a,o),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,e))},t.box=function(t){for(var i=8,n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];for(var s=r.length,a=s;s--;)i+=r[s].byteLength;var o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=255&i,o.set(t,4),s=0,i=8;s<a;s++)o.set(r[s],i),i+=r[s].byteLength;return o},t.hdlr=function(i){return t.box(t.types.hdlr,t.HDLR_TYPES[i])},t.mdat=function(i){return t.box(t.types.mdat,i)},t.mdhd=function(i,n){n*=i;var e=Math.floor(n/(r+1)),s=Math.floor(n%(r+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,e>>24,e>>16&255,e>>8&255,255&e,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))},t.mdia=function(i){return t.box(t.types.mdia,t.mdhd(i.timescale,i.duration),t.hdlr(i.type),t.minf(i))},t.mfhd=function(i){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]))},t.minf=function(i){return t.box(t.types.minf,"audio"===i.type?t.box(t.types.smhd,t.SMHD):t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(i))},t.moof=function(i,n,r){return t.box(t.types.moof,t.mfhd(i),t.traf(r,n))},t.moov=function(i){for(var n=i.length,r=[];n--;)r[n]=t.trak(i[n]);return t.box.apply(null,[t.types.moov,t.mvhd(i[0].timescale,i[0].duration)].concat(r).concat(t.mvex(i)))},t.mvex=function(i){for(var n=i.length,r=[];n--;)r[n]=t.trex(i[n]);return t.box.apply(null,[t.types.mvex].concat(r))},t.mvhd=function(i,n){n*=i;var e=Math.floor(n/(r+1)),s=Math.floor(n%(r+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,e>>24,e>>16&255,e>>8&255,255&e,s>>24,s>>16&255,s>>8&255,255&s,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 t.box(t.types.mvhd,a)},t.sdtp=function(i){var n,r,e=i.samples||[],s=new Uint8Array(4+e.length);for(n=0;n<e.length;n++)s[n+4]=(r=e[n].flags).dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return t.box(t.types.sdtp,s)},t.stbl=function(i){return t.box(t.types.stbl,t.stsd(i),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(i){var n,r,e,s=[],a=[];for(n=0;n<i.sps.length;n++)s.push((e=(r=i.sps[n]).byteLength)>>>8&255),s.push(255&e),s=s.concat(Array.prototype.slice.call(r));for(n=0;n<i.pps.length;n++)a.push((e=(r=i.pps[n]).byteLength)>>>8&255),a.push(255&e),a=a.concat(Array.prototype.slice.call(r));var o=t.box(t.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|i.sps.length].concat(s).concat([i.pps.length]).concat(a))),h=i.width,u=i.height,c=i.pixelRatio[0],f=i.pixelRatio[1];return t.box(t.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,h>>8&255,255&h,u>>8&255,255&u,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,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,f>>24,f>>16&255,f>>8&255,255&f])))},t.esds=function(t){var i=t.config.length;return new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t.config).concat([6,1,2]))},t.mp4a=function(i){var n=i.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,n>>8&255,255&n,0,0]),t.box(t.types.esds,t.esds(i)))},t.mp3=function(i){var n=i.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,n>>8&255,255&n,0,0]))},t.stsd=function(i){return t.box(t.types.stsd,t.STSD,"audio"===i.type?i.isAAC||"mp3"!==i.codec?t.mp4a(i):t.mp3(i):t.avc1(i))},t.tkhd=function(i){var n=i.id,e=i.duration*i.timescale,s=i.width,a=i.height,o=Math.floor(e/(r+1)),h=Math.floor(e%(r+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,h>>24,h>>16&255,h>>8&255,255&h,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,s>>8&255,255&s,0,0,a>>8&255,255&a,0,0]))},t.traf=function(i,n){var e=t.sdtp(i),s=i.id,a=Math.floor(n/(r+1)),o=Math.floor(n%(r+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o])),t.trun(i,e.length+16+20+8+16+8+8),e)},t.trak=function(i){return i.duration=i.duration||4294967295,t.box(t.types.trak,t.tkhd(i),t.mdia(i))},t.trex=function(i){var n=i.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(i,n){var r,e,s,a,o,h,u=i.samples||[],c=u.length,f=12+16*c,l=new Uint8Array(f);for(l.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,(n+=8+f)>>>24&255,n>>>16&255,n>>>8&255,255&n],0),r=0;r<c;r++)l.set([(s=(e=u[r]).duration)>>>24&255,s>>>16&255,s>>>8&255,255&s,(a=e.size)>>>24&255,a>>>16&255,a>>>8&255,255&a,(o=e.flags).isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,(h=e.cts)>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*r);return t.box(t.types.trun,l)},t.initSegment=function(i){t.types||t.init();var n=t.moov(i),r=new Uint8Array(t.FTYP.byteLength+n.byteLength);return r.set(t.FTYP),r.set(n,t.FTYP.byteLength),r},t}();e.types=void 0,e.HDLR_TYPES=void 0,e.STTS=void 0,e.STSC=void 0,e.STCO=void 0,e.STSZ=void 0,e.VMHD=void 0,e.SMHD=void 0,e.STSD=void 0,e.FTYP=void 0,e.DINF=void 0,i.default=e},"./src/remux/mp4-remuxer.ts":
242
242
  /*!**********************************!*\
243
243
  !*** ./src/remux/mp4-remuxer.ts ***!
244
244
  \**********************************/
245
- /*! exports provided: default, normalizePts */function(t,i,r){r.r(i);r.d(i,"default",(function(){return b}));r.d(i,"normalizePts",(function(){return y}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./aac-helper */"./src/remux/aac-helper.ts");var s=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts");var a=r(/*! ../events */"./src/events.ts");var u=r(/*! ../errors */"./src/errors.ts");var f=r(/*! ../utils/logger */"./src/utils/logger.ts");var h=r(/*! ../types/loader */"./src/types/loader.ts");var o=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function v(){v=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return v.apply(this,arguments)}var l=10*1e3;var c=1024;var d=1152;var m=null;var p=null;var g=false;var b=function(){function t(t,i,r,e){this.observer=void 0;this.config=void 0;this.typeSupported=void 0;this.ISGenerated=false;this._initPTS=void 0;this._initDTS=void 0;this.nextAvcDts=null;this.nextAudioPts=null;this.isAudioContiguous=false;this.isVideoContiguous=false;this.observer=t;this.config=i;this.typeSupported=r;this.ISGenerated=false;if(m===null){var n=navigator.userAgent||"";var s=n.match(/Chrome\/(\d+)/i);m=s?parseInt(s[1]):0}if(p===null){var a=navigator.userAgent.match(/Safari\/(\d+)/i);p=a?parseInt(a[1]):0}g=!!m&&m<75||!!p&&p<600}var i=t.prototype;i.destroy=function t(){};i.resetTimeStamp=function t(i){f["logger"].log("[mp4-remuxer]: initPTS & initDTS reset");this._initPTS=this._initDTS=i};i.resetNextTimestamp=function t(){f["logger"].log("[mp4-remuxer]: reset next timestamp");this.isVideoContiguous=false;this.isAudioContiguous=false};i.resetInitSegment=function t(){f["logger"].log("[mp4-remuxer]: ISGenerated flag reset");this.ISGenerated=false};i.getVideoStartPts=function t(i){var r=false;var e=i.reduce((function(t,i){var e=i.pts-t;if(e<-4294967296){r=true;return y(t,i.pts)}else if(e>0){return t}else{return i.pts}}),i[0].pts);if(r){f["logger"].debug("PTS rollover detected")}return e};i.remux=function t(i,r,e,n,s,a,u,o){var v;var l;var c;var d;var m;var p;var g=s;var b=s;var k=i.pid>-1;var T=r.pid>-1;var O=r.samples.length;var S=i.samples.length>0;var E=O>1;var A=(!k||S)&&(!T||E)||this.ISGenerated||u;if(A){if(!this.ISGenerated){c=this.generateIS(i,r,s)}var M=this.isVideoContiguous;var x=-1;if(E){x=w(r.samples);if(!M&&this.config.forceKeyFrameOnDiscontinuity){p=true;if(x>0){f["logger"].warn("[mp4-remuxer]: Dropped "+x+" out of "+O+" video samples due to a missing keyframe");var j=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(x);r.dropped+=x;b+=(r.samples[0].pts-j)/(r.timescale||9e4)}else if(x===-1){f["logger"].warn("[mp4-remuxer]: No keyframe found out of "+O+" video samples");p=false}}}if(this.ISGenerated){if(S&&E){var D=this.getVideoStartPts(r.samples);var L=y(i.samples[0].pts,D)-D;var I=L/r.inputTimeScale;g+=Math.max(0,I);b+=Math.max(0,-I)}if(S){if(!i.samplerate){f["logger"].warn("[mp4-remuxer]: regenerate InitSegment as audio detected");c=this.generateIS(i,r,s)}l=this.remuxAudio(i,g,this.isAudioContiguous,a,T||E||o===h["PlaylistLevelType"].AUDIO?b:undefined);if(E){var C=l?l.endPTS-l.startPTS:0;if(!r.inputTimeScale){f["logger"].warn("[mp4-remuxer]: regenerate InitSegment as video detected");c=this.generateIS(i,r,s)}v=this.remuxVideo(r,b,M,C)}}else if(E){v=this.remuxVideo(r,b,M,0)}if(v){v.firstKeyFrame=x;v.independent=x!==-1}}}if(this.ISGenerated){if(e.samples.length){m=this.remuxID3(e,s)}if(n.samples.length){d=this.remuxText(n,s)}}return{audio:l,video:v,initSegment:c,independent:p,text:d,id3:m}};i.generateIS=function t(i,r,n){var a=i.samples;var u=r.samples;var f=this.typeSupported;var h={};var o=!Object(e["isFiniteNumber"])(this._initPTS);var v="audio/mp4";var l;var c;var d;if(o){l=c=Infinity}if(i.config&&a.length){i.timescale=i.samplerate;if(!i.isAAC){if(f.mpeg){v="audio/mpeg";i.codec=""}else if(f.mp3){i.codec="mp3"}}h.audio={id:"audio",container:v,codec:i.codec,initSegment:!i.isAAC&&f.mpeg?new Uint8Array(0):s["default"].initSegment([i]),metadata:{channelCount:i.channelCount}};if(o){d=i.inputTimeScale;l=c=a[0].pts-Math.round(d*n)}}if(r.sps&&r.pps&&u.length){r.timescale=r.inputTimeScale;h.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:s["default"].initSegment([r]),metadata:{width:r.width,height:r.height}};if(o){d=r.inputTimeScale;var m=this.getVideoStartPts(u);var p=Math.round(d*n);c=Math.min(c,y(u[0].dts,m)-p);l=Math.min(l,m-p)}}if(Object.keys(h).length){this.ISGenerated=true;if(o){this._initPTS=l;this._initDTS=c}return{tracks:h,initPTS:l,timescale:d}}};i.remuxVideo=function t(i,r,e,n){var h=i.inputTimeScale;var l=i.samples;var c=[];var d=l.length;var p=this._initPTS;var b=this.nextAvcDts;var w=8;var T;var O;var S;var E=Number.POSITIVE_INFINITY;var A=Number.NEGATIVE_INFINITY;var M=0;var x=false;if(!e||b===null){var j=r*h;var D=l[0].pts-y(l[0].dts,l[0].pts);b=j-D}for(var L=0;L<d;L++){var I=l[L];I.pts=y(I.pts-p,b);I.dts=y(I.dts-p,b);if(I.dts>I.pts){var C=9e4*.2;M=Math.max(Math.min(M,I.pts-I.dts),-1*C)}if(I.dts<l[L>0?L-1:L].dts){x=true}}if(x){l.sort((function(t,i){var r=t.dts-i.dts;var e=t.pts-i.pts;return r||e}))}O=l[0].dts;S=l[l.length-1].dts;var R=Math.round((S-O)/(d-1));if(M<0){if(M<R*-2){f["logger"].warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(o["toMsFromMpegTsClock"])(-R,true)+" ms");var P=M;for(var U=0;U<d;U++){l[U].dts=P=Math.max(P,l[U].pts-R);l[U].pts=Math.max(P,l[U].pts)}}else{f["logger"].warn("PTS < DTS detected in video samples, shifting DTS by "+Object(o["toMsFromMpegTsClock"])(M,true)+" ms to overcome this issue");for(var N=0;N<d;N++){l[N].dts=l[N].dts+M}}O=l[0].dts}if(e){var F=O-b;var B=F>R;var _=F<-1;if(B||_){if(B){f["logger"].warn("AVC: "+Object(o["toMsFromMpegTsClock"])(F,true)+" ms ("+F+"dts) hole between fragments detected, filling it")}else{f["logger"].warn("AVC: "+Object(o["toMsFromMpegTsClock"])(-F,true)+" ms ("+F+"dts) overlapping between fragments detected")}O=b;var X=l[0].pts-F;l[0].dts=O;l[0].pts=X;f["logger"].log("Video: First PTS/DTS adjusted: "+Object(o["toMsFromMpegTsClock"])(X,true)+"/"+Object(o["toMsFromMpegTsClock"])(O,true)+", delta: "+Object(o["toMsFromMpegTsClock"])(F,true)+" ms")}}if(g){O=Math.max(0,O)}var G=0;var W=0;for(var K=0;K<d;K++){var H=l[K];var V=H.units;var q=V.length;var z=0;for(var Y=0;Y<q;Y++){z+=V[Y].data.length}W+=z;G+=q;H.length=z;H.dts=Math.max(H.dts,O);H.pts=Math.max(H.pts,H.dts,0);E=Math.min(H.pts,E);A=Math.max(H.pts,A)}S=l[d-1].dts;var $=W+4*G+8;var J;try{J=new Uint8Array($)}catch(t){this.observer.emit(a["Events"].ERROR,a["Events"].ERROR,{type:u["ErrorTypes"].MUX_ERROR,details:u["ErrorDetails"].REMUX_ALLOC_ERROR,fatal:false,bytes:$,reason:"fail allocating video mdat "+$});return}var Q=new DataView(J.buffer);Q.setUint32(0,$);J.set(s["default"].types.mdat,4);for(var Z=0;Z<d;Z++){var tt=l[Z];var it=tt.units;var rt=0;for(var et=0,nt=it.length;et<nt;et++){var st=it[et];var at=st.data;var ut=st.data.byteLength;Q.setUint32(w,ut);w+=4;J.set(at,w);w+=ut;rt+=4+ut}if(Z<d-1){T=l[Z+1].dts-tt.dts}else{var ft=this.config;var ht=tt.dts-l[Z>0?Z-1:Z].dts;if(ft.stretchShortVideoTrack&&this.nextAudioPts!==null){var ot=Math.floor(ft.maxBufferHole*h);var vt=(n?E+n*h:this.nextAudioPts)-tt.pts;if(vt>ot){T=vt-ht;if(T<0){T=ht}f["logger"].log("[mp4-remuxer]: It is approximately "+vt/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")}else{T=ht}}else{T=ht}}var lt=Math.round(tt.pts-tt.dts);c.push(new k(tt.key,T,rt,lt))}if(c.length&&m&&m<70){var ct=c[0].flags;ct.dependsOn=2;ct.isNonSync=0}console.assert(T!==undefined,"mp4SampleDuration must be computed");this.nextAvcDts=b=S+T;this.isVideoContiguous=true;var dt=s["default"].moof(i.sequenceNumber++,O,v({},i,{samples:c}));var mt="video";var pt={data1:dt,data2:J,startPTS:E/h,endPTS:(A+T)/h,startDTS:O/h,endDTS:b/h,type:mt,hasAudio:false,hasVideo:true,nb:c.length,dropped:i.dropped};i.samples=[];i.dropped=0;console.assert(J.length,"MDAT length must not be zero");return pt};i.remuxAudio=function t(i,r,e,h,o){var m=i.inputTimeScale;var p=i.samplerate?i.samplerate:m;var g=m/p;var b=i.isAAC?c:d;var w=b*g;var T=this._initPTS;var O=!i.isAAC&&this.typeSupported.mpeg;var S=[];var E=i.samples;var A=O?0:8;var M=this.nextAudioPts||-1;var x=r*m;this.isAudioContiguous=e=e||E.length&&M>0&&(h&&Math.abs(x-M)<9e3||Math.abs(y(E[0].pts-T,x)-M)<20*w);E.forEach((function(t){t.pts=y(t.pts-T,x)}));if(!e||M<0){E=E.filter((function(t){return t.pts>=0}));if(!E.length){return}if(o===0){M=0}else if(h){M=Math.max(0,x)}else{M=E[0].pts}}if(i.isAAC){var j=o!==undefined;var D=this.config.maxAudioFramesDrift;for(var L=0,I=M;L<E.length;L++){var C=E[L];var R=C.pts;var P=R-I;var U=Math.abs(1e3*P/m);if(P<=-D*w&&j){if(L===0){f["logger"].warn("Audio frame @ "+(R/m).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*P/m)+" ms.");this.nextAudioPts=M=I=R}}else if(P>=D*w&&U<l&&j){var N=Math.round(P/w);I=R-N*w;if(I<0){N--;I+=w}if(L===0){this.nextAudioPts=M=I}f["logger"].warn("[mp4-remuxer]: Injecting "+N+" audio frame @ "+(I/m).toFixed(3)+"s due to "+Math.round(1e3*P/m)+" ms gap.");for(var F=0;F<N;F++){var B=Math.max(I,0);var _=n["default"].getSilentFrame(i.manifestCodec||i.codec,i.channelCount);if(!_){f["logger"].log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead.");_=C.unit.subarray()}E.splice(L,0,{unit:_,pts:B});I+=w;L++}}C.pts=I;I+=w}}var X=null;var G=null;var W;var K=0;var H=E.length;while(H--){K+=E[H].unit.byteLength}for(var V=0,q=E.length;V<q;V++){var z=E[V];var Y=z.unit;var $=z.pts;if(G!==null){var J=S[V-1];J.duration=Math.round(($-G)/g)}else{if(e&&i.isAAC){$=M}X=$;if(K>0){K+=A;try{W=new Uint8Array(K)}catch(t){this.observer.emit(a["Events"].ERROR,a["Events"].ERROR,{type:u["ErrorTypes"].MUX_ERROR,details:u["ErrorDetails"].REMUX_ALLOC_ERROR,fatal:false,bytes:K,reason:"fail allocating audio mdat "+K});return}if(!O){var Q=new DataView(W.buffer);Q.setUint32(0,K);W.set(s["default"].types.mdat,4)}}else{return}}W.set(Y,A);var Z=Y.byteLength;A+=Z;S.push(new k(true,b,Z,0));G=$}var tt=S.length;if(!tt){return}var it=S[S.length-1];this.nextAudioPts=M=G+g*it.duration;var rt=O?new Uint8Array(0):s["default"].moof(i.sequenceNumber++,X/g,v({},i,{samples:S}));i.samples=[];var et=X/m;var nt=M/m;var st="audio";var at={data1:rt,data2:W,startPTS:et,endPTS:nt,startDTS:et,endDTS:nt,type:st,hasAudio:true,hasVideo:false,nb:tt};this.isAudioContiguous=true;console.assert(W.length,"MDAT length must not be zero");return at};i.remuxEmptyAudio=function t(i,r,e,s){var a=i.inputTimeScale;var u=i.samplerate?i.samplerate:a;var h=a/u;var o=this.nextAudioPts;var v=(o!==null?o:s.startDTS*a)+this._initDTS;var l=s.endDTS*a+this._initDTS;var d=h*c;var m=Math.ceil((l-v)/d);var p=n["default"].getSilentFrame(i.manifestCodec||i.codec,i.channelCount);f["logger"].warn("[mp4-remuxer]: remux empty Audio");if(!p){f["logger"].trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}var g=[];for(var b=0;b<m;b++){var y=v+b*d;g.push({unit:p,pts:y,dts:y})}i.samples=g;return this.remuxAudio(i,r,e,false)};i.remuxID3=function t(i,r){var e=i.samples.length;if(!e){return}var n=i.inputTimeScale;var s=this._initPTS;var a=this._initDTS;for(var u=0;u<e;u++){var f=i.samples[u];f.pts=y(f.pts-s,r*n)/n;f.dts=y(f.dts-a,r*n)/n}var h=i.samples;i.samples=[];return{samples:h}};i.remuxText=function t(i,r){var e=i.samples.length;if(!e){return}var n=i.inputTimeScale;var s=this._initPTS;for(var a=0;a<e;a++){var u=i.samples[a];u.pts=y(u.pts-s,r*n)/n}i.samples.sort((function(t,i){return t.pts-i.pts}));var f=i.samples;i.samples=[];return{samples:f}};return t}();function y(t,i){var r;if(i===null){return t}if(i<t){r=-8589934592}else{r=8589934592}while(Math.abs(t-i)>4294967296){t+=r}return t}function w(t){for(var i=0;i<t.length;i++){if(t[i].key){return i}}return-1}var k=function t(i,r,e,n){this.size=void 0;this.duration=void 0;this.cts=void 0;this.flags=void 0;this.duration=r;this.size=e;this.cts=n;this.flags=new T(i)};var T=function t(i){this.isLeading=0;this.isDependedOn=0;this.hasRedundancy=0;this.degradPrio=0;this.dependsOn=1;this.isNonSync=1;this.dependsOn=i?2:1;this.isNonSync=i?0:1}},"./src/remux/passthrough-remuxer.ts":
245
+ /*! exports provided: default, normalizePts */function(t,i,n){n.r(i),n.d(i,"default",(function(){return m})),n.d(i,"normalizePts",(function(){return p}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./aac-helper */"./src/remux/aac-helper.ts"),s=n(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),a=n(/*! ../events */"./src/events.ts"),o=n(/*! ../errors */"./src/errors.ts"),h=n(/*! ../utils/logger */"./src/utils/logger.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts"),c=n(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function f(){return f=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f.apply(this,arguments)}var l=null,v=null,d=!1,m=function(){function t(t,i,n){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=i,this.typeSupported=n,this.ISGenerated=!1,null===l){var r=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);l=r?parseInt(r[1]):0}if(null===v){var e=navigator.userAgent.match(/Safari\/(\d+)/i);v=e?parseInt(e[1]):0}d=!!l&&l<75||!!v&&v<600}var i=t.prototype;return i.destroy=function(){},i.resetTimeStamp=function(t){h.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},i.resetNextTimestamp=function(){h.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},i.resetInitSegment=function(){h.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},i.getVideoStartPts=function(t){var i=!1,n=t.reduce((function(t,n){var r=n.pts-t;return r<-4294967296?(i=!0,p(t,n.pts)):r>0?t:n.pts}),t[0].pts);return i&&h.logger.debug("PTS rollover detected"),n},i.remux=function(t,i,n,r,e,s,a,o){var c,f,l,v,d,m,g=e,b=e,y=i.pid>-1,w=i.samples.length,k=t.samples.length>0,T=w>1;if((!(t.pid>-1)||k)&&(!y||T)||this.ISGenerated||a){this.ISGenerated||(l=this.generateIS(t,i,e));var O=this.isVideoContiguous,S=-1;if(T&&(S=function(t){for(var i=0;i<t.length;i++)if(t[i].key)return i;return-1}(i.samples),!O&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,S>0){h.logger.warn("[mp4-remuxer]: Dropped "+S+" out of "+w+" video samples due to a missing keyframe");var E=this.getVideoStartPts(i.samples);i.samples=i.samples.slice(S),i.dropped+=S,b+=(i.samples[0].pts-E)/(i.timescale||9e4)}else-1===S&&(h.logger.warn("[mp4-remuxer]: No keyframe found out of "+w+" video samples"),m=!1);if(this.ISGenerated){if(k&&T){var A=this.getVideoStartPts(i.samples),M=(p(t.samples[0].pts,A)-A)/i.inputTimeScale;g+=Math.max(0,M),b+=Math.max(0,-M)}if(k){if(t.samplerate||(h.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),l=this.generateIS(t,i,e)),f=this.remuxAudio(t,g,this.isAudioContiguous,s,y||T||o===u.PlaylistLevelType.AUDIO?b:void 0),T){var x=f?f.endPTS-f.startPTS:0;i.inputTimeScale||(h.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),l=this.generateIS(t,i,e)),c=this.remuxVideo(i,b,O,x)}}else T&&(c=this.remuxVideo(i,b,O,0));c&&(c.firstKeyFrame=S,c.independent=-1!==S)}}return this.ISGenerated&&(n.samples.length&&(d=this.remuxID3(n,e)),r.samples.length&&(v=this.remuxText(r,e))),{audio:f,video:c,initSegment:l,independent:m,text:v,id3:d}},i.generateIS=function(t,i,n){var e,a,o,h=t.samples,u=i.samples,c=this.typeSupported,f={},l=!Object(r.isFiniteNumber)(this._initPTS),v="audio/mp4";if(l&&(e=a=1/0),t.config&&h.length&&(t.timescale=t.samplerate,t.isAAC||(c.mpeg?(v="audio/mpeg",t.codec=""):c.mp3&&(t.codec="mp3")),f.audio={id:"audio",container:v,codec:t.codec,initSegment:!t.isAAC&&c.mpeg?new Uint8Array(0):s.default.initSegment([t]),metadata:{channelCount:t.channelCount}},l&&(o=t.inputTimeScale,e=a=h[0].pts-Math.round(o*n))),i.sps&&i.pps&&u.length&&(i.timescale=i.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:i.codec,initSegment:s.default.initSegment([i]),metadata:{width:i.width,height:i.height}},l)){o=i.inputTimeScale;var d=this.getVideoStartPts(u),m=Math.round(o*n);a=Math.min(a,p(u[0].dts,d)-m),e=Math.min(e,d-m)}if(Object.keys(f).length)return this.ISGenerated=!0,l&&(this._initPTS=e,this._initDTS=a),{tracks:f,initPTS:e,timescale:o}},i.remuxVideo=function(t,i,n,r){var e,u,v,m=t.inputTimeScale,b=t.samples,y=[],w=b.length,k=this._initPTS,T=this.nextAvcDts,O=8,S=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,A=0,M=!1;n&&null!==T||(T=i*m-(b[0].pts-p(b[0].dts,b[0].pts)));for(var x=0;x<w;x++){var j=b[x];j.pts=p(j.pts-k,T),j.dts=p(j.dts-k,T),j.dts>j.pts&&(A=Math.max(Math.min(A,j.pts-j.dts),-18e3)),j.dts<b[x>0?x-1:x].dts&&(M=!0)}M&&b.sort((function(t,i){return t.dts-i.dts||t.pts-i.pts})),u=b[0].dts,v=b[b.length-1].dts;var D=Math.round((v-u)/(w-1));if(A<0){if(A<-2*D){h.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(c.toMsFromMpegTsClock)(-D,!0)+" ms");for(var L=A,I=0;I<w;I++)b[I].dts=L=Math.max(L,b[I].pts-D),b[I].pts=Math.max(L,b[I].pts)}else{h.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(c.toMsFromMpegTsClock)(A,!0)+" ms to overcome this issue");for(var C=0;C<w;C++)b[C].dts=b[C].dts+A}u=b[0].dts}if(n){var R=u-T,P=R>D;if(P||R<-1){h.logger.warn(P?"AVC: "+Object(c.toMsFromMpegTsClock)(R,!0)+" ms ("+R+"dts) hole between fragments detected, filling it":"AVC: "+Object(c.toMsFromMpegTsClock)(-R,!0)+" ms ("+R+"dts) overlapping between fragments detected");var U=b[0].pts-R;b[0].dts=u=T,b[0].pts=U,h.logger.log("Video: First PTS/DTS adjusted: "+Object(c.toMsFromMpegTsClock)(U,!0)+"/"+Object(c.toMsFromMpegTsClock)(u,!0)+", delta: "+Object(c.toMsFromMpegTsClock)(R,!0)+" ms")}}d&&(u=Math.max(0,u));for(var N=0,F=0,B=0;B<w;B++){for(var _=b[B],X=_.units,G=X.length,W=0,K=0;K<G;K++)W+=X[K].data.length;F+=W,N+=G,_.length=W,_.dts=Math.max(_.dts,u),_.pts=Math.max(_.pts,_.dts,0),S=Math.min(_.pts,S),E=Math.max(_.pts,E)}v=b[w-1].dts;var H,V=F+4*N+8;try{H=new Uint8Array(V)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:V,reason:"fail allocating video mdat "+V})}var q=new DataView(H.buffer);q.setUint32(0,V),H.set(s.default.types.mdat,4);for(var z=0;z<w;z++){for(var Y=b[z],$=Y.units,J=0,Q=0,Z=$.length;Q<Z;Q++){var tt=$[Q],it=tt.data,nt=tt.data.byteLength;q.setUint32(O,nt),H.set(it,O+=4),O+=nt,J+=4+nt}if(z<w-1)e=b[z+1].dts-Y.dts;else{var rt=this.config,et=Y.dts-b[z>0?z-1:z].dts;if(rt.stretchShortVideoTrack&&null!==this.nextAudioPts){var st=Math.floor(rt.maxBufferHole*m),at=(r?S+r*m:this.nextAudioPts)-Y.pts;at>st?((e=at-et)<0&&(e=et),h.logger.log("[mp4-remuxer]: It is approximately "+at/90+" ms to the next segment; using duration "+e/90+" ms for the last video frame.")):e=et}else e=et}var ot=Math.round(Y.pts-Y.dts);y.push(new g(Y.key,e,J,ot))}if(y.length&&l&&l<70){var ht=y[0].flags;ht.dependsOn=2,ht.isNonSync=0}console.assert(void 0!==e,"mp4SampleDuration must be computed"),this.nextAvcDts=T=v+e,this.isVideoContiguous=!0;var ut={data1:s.default.moof(t.sequenceNumber++,u,f({},t,{samples:y})),data2:H,startPTS:S/m,endPTS:(E+e)/m,startDTS:u/m,endDTS:T/m,type:"video",hasAudio:!1,hasVideo:!0,nb:y.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(H.length,"MDAT length must not be zero"),ut},i.remuxAudio=function(t,i,n,r,u){var c=t.inputTimeScale,l=c/(t.samplerate?t.samplerate:c),v=t.isAAC?1024:1152,d=v*l,m=this._initPTS,b=!t.isAAC&&this.typeSupported.mpeg,y=[],w=t.samples,k=b?0:8,T=this.nextAudioPts||-1,O=i*c;if(this.isAudioContiguous=n=n||w.length&&T>0&&(r&&Math.abs(O-T)<9e3||Math.abs(p(w[0].pts-m,O)-T)<20*d),w.forEach((function(t){t.pts=p(t.pts-m,O)})),!n||T<0){if(w=w.filter((function(t){return t.pts>=0})),!w.length)return;T=0===u?0:r?Math.max(0,O):w[0].pts}if(t.isAAC)for(var S=void 0!==u,E=this.config.maxAudioFramesDrift,A=0,M=T;A<w.length;A++){var x=w[A],j=x.pts,D=j-M,L=Math.abs(1e3*D/c);if(D<=-E*d&&S)0===A&&(h.logger.warn("Audio frame @ "+(j/c).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*D/c)+" ms."),this.nextAudioPts=T=M=j);else if(D>=E*d&&L<1e4&&S){var I=Math.round(D/d);(M=j-I*d)<0&&(I--,M+=d),0===A&&(this.nextAudioPts=T=M),h.logger.warn("[mp4-remuxer]: Injecting "+I+" audio frame @ "+(M/c).toFixed(3)+"s due to "+Math.round(1e3*D/c)+" ms gap.");for(var C=0;C<I;C++){var R=Math.max(M,0),P=e.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);P||(h.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=x.unit.subarray()),w.splice(A,0,{unit:P,pts:R}),M+=d,A++}}x.pts=M,M+=d}for(var U,N=null,F=null,B=0,_=w.length;_--;)B+=w[_].unit.byteLength;for(var X=0,G=w.length;X<G;X++){var W=w[X],K=W.unit,H=W.pts;if(null!==F)y[X-1].duration=Math.round((H-F)/l);else{if(n&&t.isAAC&&(H=T),N=H,!(B>0))return;B+=k;try{U=new Uint8Array(B)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:B,reason:"fail allocating audio mdat "+B})}b||(new DataView(U.buffer).setUint32(0,B),U.set(s.default.types.mdat,4))}U.set(K,k);var V=K.byteLength;k+=V,y.push(new g(!0,v,V,0)),F=H}var q=y.length;if(q){this.nextAudioPts=T=F+l*y[y.length-1].duration;var z=b?new Uint8Array(0):s.default.moof(t.sequenceNumber++,N/l,f({},t,{samples:y}));t.samples=[];var Y=N/c,$=T/c,J={data1:z,data2:U,startPTS:Y,endPTS:$,startDTS:Y,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,console.assert(U.length,"MDAT length must not be zero"),J}},i.remuxEmptyAudio=function(t,i,n,r){var s=t.inputTimeScale,a=this.nextAudioPts,o=(null!==a?a:r.startDTS*s)+this._initDTS,u=s/(t.samplerate?t.samplerate:s)*1024,c=Math.ceil((r.endDTS*s+this._initDTS-o)/u),f=e.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(h.logger.warn("[mp4-remuxer]: remux empty Audio"),f){for(var l=[],v=0;v<c;v++){var d=o+v*u;l.push({unit:f,pts:d,dts:d})}return t.samples=l,this.remuxAudio(t,i,n,!1)}h.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},i.remuxID3=function(t,i){var n=t.samples.length;if(n){for(var r=t.inputTimeScale,e=this._initPTS,s=this._initDTS,a=0;a<n;a++){var o=t.samples[a];o.pts=p(o.pts-e,i*r)/r,o.dts=p(o.dts-s,i*r)/r}var h=t.samples;return t.samples=[],{samples:h}}},i.remuxText=function(t,i){var n=t.samples.length;if(n){for(var r=t.inputTimeScale,e=this._initPTS,s=0;s<n;s++){var a=t.samples[s];a.pts=p(a.pts-e,i*r)/r}t.samples.sort((function(t,i){return t.pts-i.pts}));var o=t.samples;return t.samples=[],{samples:o}}},t}();function p(t,i){var n;if(null===i)return t;for(n=i<t?-8589934592:8589934592;Math.abs(t-i)>4294967296;)t+=n;return t}var g=function(t,i,n,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=n,this.cts=r,this.flags=new b(t)},b=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":
246
246
  /*!******************************************!*\
247
247
  !*** ./src/remux/passthrough-remuxer.ts ***!
248
248
  \******************************************/
249
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");var s=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var a=r(/*! ../utils/logger */"./src/utils/logger.ts");var u=function(){function t(){this.emitInitSegment=false;this.audioCodec=void 0;this.videoCodec=void 0;this.initData=void 0;this.initPTS=void 0;this.initTracks=void 0;this.lastEndDTS=null}var i=t.prototype;i.destroy=function t(){};i.resetTimeStamp=function t(i){this.initPTS=i;this.lastEndDTS=null};i.resetNextTimestamp=function t(){this.lastEndDTS=null};i.resetInitSegment=function t(i,r,e){this.audioCodec=r;this.videoCodec=e;this.generateInitSegment(i);this.emitInitSegment=true};i.generateInitSegment=function t(i){var r=this.audioCodec,e=this.videoCodec;if(!i||!i.byteLength){this.initTracks=undefined;this.initData=undefined;return}var u=this.initData=Object(n["parseInitSegment"])(i);if(!r){r=h(u.audio,s["ElementaryStreamTypes"].AUDIO)}if(!e){e=h(u.video,s["ElementaryStreamTypes"].VIDEO)}var f={};if(u.audio&&u.video){f.audiovideo={container:"video/mp4",codec:r+","+e,initSegment:i,id:"main"}}else if(u.audio){f.audio={container:"audio/mp4",codec:r,initSegment:i,id:"audio"}}else if(u.video){f.video={container:"video/mp4",codec:e,initSegment:i,id:"main"}}else{a["logger"].warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes.")}this.initTracks=f};i.remux=function t(i,r,s,u,h){var o=this.initPTS,v=this.lastEndDTS;var l={audio:undefined,video:undefined,text:u,id3:s,initSegment:undefined};if(!Object(e["isFiniteNumber"])(v)){v=this.lastEndDTS=h||0}var c=r.samples;if(!c||!c.length){return l}var d={initPTS:undefined,timescale:1};var m=this.initData;if(!m||!m.length){this.generateInitSegment(c);m=this.initData}if(!m||!m.length){a["logger"].warn("[passthrough-remuxer.ts]: Failed to generate initSegment.");return l}if(this.emitInitSegment){d.tracks=this.initTracks;this.emitInitSegment=false}if(!Object(e["isFiniteNumber"])(o)){this.initPTS=d.initPTS=o=f(m,c,v)}var p=Object(n["getDuration"])(c,m);var g=v;var b=p+g;Object(n["offsetStartDTS"])(m,c,o);if(p>0){this.lastEndDTS=b}else{a["logger"].warn("Duration parsed from mp4 should be greater than zero");this.resetNextTimestamp()}var y=!!m.audio;var w=!!m.video;var k="";if(y){k+="audio"}if(w){k+="video"}var T={data1:c,startPTS:g,startDTS:g,endPTS:b,endDTS:b,type:k,hasAudio:y,hasVideo:w,nb:1,dropped:0};l.audio=T.type==="audio"?T:undefined;l.video=T.type!=="audio"?T:undefined;l.text=u;l.id3=s;l.initSegment=d;return l};return t}();var f=function t(i,r,e){return Object(n["getStartDTS"])(i,r)-e};function h(t,i){var r=t===null||t===void 0?void 0:t.codec;if(r&&r.length>4){return r}if(r==="hvc1"){return"hvc1.1.c.L120.90"}if(r==="av01"){return"av01.0.04M.08"}if(r==="avc1"||i===s["ElementaryStreamTypes"].VIDEO){return"avc1.42e01e"}return"mp4a.40.5"}i["default"]=u},"./src/task-loop.ts":
249
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=function(){function t(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var i=t.prototype;return i.destroy=function(){},i.resetTimeStamp=function(t){this.initPTS=t,this.lastEndDTS=null},i.resetNextTimestamp=function(){this.lastEndDTS=null},i.resetInitSegment=function(t,i,n){this.audioCodec=i,this.videoCodec=n,this.generateInitSegment(t),this.emitInitSegment=!0},i.generateInitSegment=function(t){var i=this.audioCodec,n=this.videoCodec;if(!t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var r=this.initData=Object(e.parseInitSegment)(t);i||(i=u(r.audio,s.ElementaryStreamTypes.AUDIO)),n||(n=u(r.video,s.ElementaryStreamTypes.VIDEO));var o={};r.audio&&r.video?o.audiovideo={container:"video/mp4",codec:i+","+n,initSegment:t,id:"main"}:r.audio?o.audio={container:"audio/mp4",codec:i,initSegment:t,id:"audio"}:r.video?o.video={container:"video/mp4",codec:n,initSegment:t,id:"main"}:a.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},i.remux=function(t,i,n,s,o){var u=this.initPTS,c=this.lastEndDTS,f={audio:void 0,video:void 0,text:s,id3:n,initSegment:void 0};Object(r.isFiniteNumber)(c)||(c=this.lastEndDTS=o||0);var l=i.samples;if(!l||!l.length)return f;var v={initPTS:void 0,timescale:1},d=this.initData;if(d&&d.length||(this.generateInitSegment(l),d=this.initData),!d||!d.length)return a.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1),Object(r.isFiniteNumber)(u)||(this.initPTS=v.initPTS=u=h(d,l,c));var m=Object(e.getDuration)(l,d),p=c,g=m+p;Object(e.offsetStartDTS)(d,l,u),m>0?this.lastEndDTS=g:(a.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var b=!!d.audio,y=!!d.video,w="";b&&(w+="audio"),y&&(w+="video");var k={data1:l,startPTS:p,startDTS:p,endPTS:g,endDTS:g,type:w,hasAudio:b,hasVideo:y,nb:1,dropped:0};return f.audio="audio"===k.type?k:void 0,f.video="audio"!==k.type?k:void 0,f.text=s,f.id3=n,f.initSegment=v,f},t}(),h=function(t,i,n){return Object(e.getStartDTS)(t,i)-n};function u(t,i){var n=null==t?void 0:t.codec;return n&&n.length>4?n:"hvc1"===n?"hvc1.1.c.L120.90":"av01"===n?"av01.0.04M.08":"avc1"===n||i===s.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}i.default=o},"./src/task-loop.ts":
250
250
  /*!**************************!*\
251
251
  !*** ./src/task-loop.ts ***!
252
252
  \**************************/
253
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(){this._boundTick=void 0;this._tickTimer=null;this._tickInterval=null;this._tickCallCount=0;this._boundTick=this.tick.bind(this)}var i=t.prototype;i.destroy=function t(){this.onHandlerDestroying();this.onHandlerDestroyed()};i.onHandlerDestroying=function t(){this.clearNextTick();this.clearInterval()};i.onHandlerDestroyed=function t(){};i.hasInterval=function t(){return!!this._tickInterval};i.hasNextTick=function t(){return!!this._tickTimer};i.setInterval=function t(i){if(!this._tickInterval){this._tickInterval=self.setInterval(this._boundTick,i);return true}return false};i.clearInterval=function t(){if(this._tickInterval){self.clearInterval(this._tickInterval);this._tickInterval=null;return true}return false};i.clearNextTick=function t(){if(this._tickTimer){self.clearTimeout(this._tickTimer);this._tickTimer=null;return true}return false};i.tick=function t(){this._tickCallCount++;if(this._tickCallCount===1){this.doTick();if(this._tickCallCount>1){this.tickImmediate()}this._tickCallCount=0}};i.tickImmediate=function t(){this.clearNextTick();this._tickTimer=self.setTimeout(this._boundTick,0)};i.doTick=function t(){};return t}()},"./src/types/cmcd.ts":
253
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var i=t.prototype;return i.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.onHandlerDestroyed=function(){},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(t){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,t),!0)},i.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},i.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},i.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){},t}()},"./src/types/cmcd.ts":
254
254
  /*!***************************!*\
255
255
  !*** ./src/types/cmcd.ts ***!
256
256
  \***************************/
257
- /*! exports provided: CMCDVersion, CMCDObjectType, CMCDStreamingFormat, CMCDStreamType */function(t,i,r){r.r(i);r.d(i,"CMCDVersion",(function(){return e}));r.d(i,"CMCDObjectType",(function(){return n}));r.d(i,"CMCDStreamingFormat",(function(){return s}));r.d(i,"CMCDStreamType",(function(){return a}));var e=1;var n;(function(t){t["MANIFEST"]="m";t["AUDIO"]="a";t["VIDEO"]="v";t["MUXED"]="av";t["INIT"]="i";t["CAPTION"]="c";t["TIMED_TEXT"]="tt";t["KEY"]="k";t["OTHER"]="o"})(n||(n={}));var s;(function(t){t["DASH"]="d";t["HLS"]="h";t["SMOOTH"]="s";t["OTHER"]="o"})(s||(s={}));var a;(function(t){t["VOD"]="v";t["LIVE"]="l"})(a||(a={}))},"./src/types/level.ts":
257
+ /*! exports provided: CMCDVersion, CMCDObjectType, CMCDStreamingFormat, CMCDStreamType */function(t,i,n){n.r(i),n.d(i,"CMCDVersion",(function(){return a})),n.d(i,"CMCDObjectType",(function(){return r})),n.d(i,"CMCDStreamingFormat",(function(){return e})),n.d(i,"CMCDStreamType",(function(){return s}));var r,e,s,a=1;!function(t){t.MANIFEST="m",t.AUDIO="a",t.VIDEO="v",t.MUXED="av",t.INIT="i",t.CAPTION="c",t.TIMED_TEXT="tt",t.KEY="k",t.OTHER="o"}(r||(r={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(e||(e={})),function(t){t.VOD="v",t.LIVE="l"}(s||(s={}))},"./src/types/level.ts":
258
258
  /*!****************************!*\
259
259
  !*** ./src/types/level.ts ***!
260
260
  \****************************/
261
- /*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(t,i,r){r.r(i);r.d(i,"HlsSkip",(function(){return s}));r.d(i,"getSkipValue",(function(){return a}));r.d(i,"HlsUrlParameters",(function(){return u}));r.d(i,"Level",(function(){return f}));function e(t,i){for(var r=0;r<i.length;r++){var e=i[r];e.enumerable=e.enumerable||false;e.configurable=true;if("value"in e)e.writable=true;Object.defineProperty(t,e.key,e)}}function n(t,i,r){if(i)e(t.prototype,i);if(r)e(t,r);return t}var s;(function(t){t["No"]="";t["Yes"]="YES";t["v2"]="v2"})(s||(s={}));function a(t,i){var r=t.canSkipUntil,e=t.canSkipDateRanges,n=t.endSN;var a=i!==undefined?i-n:0;if(r&&a<r){if(e){return s.v2}return s.Yes}return s.No}var u=function(){function t(t,i,r){this.msn=void 0;this.part=void 0;this.skip=void 0;this.msn=t;this.part=i;this.skip=r}var i=t.prototype;i.addDirectives=function t(i){var r=new self.URL(i);if(this.msn!==undefined){r.searchParams.set("_HLS_msn",this.msn.toString())}if(this.part!==undefined){r.searchParams.set("_HLS_part",this.part.toString())}if(this.skip){r.searchParams.set("_HLS_skip",this.skip)}return r.toString()};return t}();var f=function(){function t(t){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=[t.url];this.attrs=t.attrs;this.bitrate=t.bitrate;if(t.details){this.details=t.details}this.id=t.id||0;this.name=t.name;this.width=t.width||0;this.height=t.height||0;this.audioCodec=t.audioCodec;this.videoCodec=t.videoCodec;this.unknownCodecs=t.unknownCodecs;this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}n(t,[{key:"maxBitrate",get:function t(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function t(){return this.url[this._urlId]||""}},{key:"urlId",get:function t(){return this._urlId},set:function t(i){var r=i%this.url.length;if(this._urlId!==r){this.details=undefined;this._urlId=r}}}]);return t}()},"./src/types/loader.ts":
261
+ /*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(t,i,n){function r(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var e;function s(t,i){var n=t.canSkipUntil;return n&&(void 0!==i?i-t.endSN:0)<n?t.canSkipDateRanges?e.v2:e.Yes:e.No}n.r(i),n.d(i,"HlsSkip",(function(){return e})),n.d(i,"getSkipValue",(function(){return s})),n.d(i,"HlsUrlParameters",(function(){return a})),n.d(i,"Level",(function(){return o})),function(t){t.No="",t.Yes="YES",t.v2="v2"}(e||(e={}));var a=function(){function t(t,i,n){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=i,this.skip=n}return t.prototype.addDirectives=function(t){var i=new self.URL(t);return void 0!==this.msn&&i.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&i.searchParams.set("_HLS_part",this.part.toString()),this.skip&&i.searchParams.set("_HLS_skip",this.skip),i.toString()},t}(),o=function(){function t(t){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=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}var i,n;return i=t,(n=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var i=t%this.url.length;this._urlId!==i&&(this.details=void 0,this._urlId=i)}}])&&r(i.prototype,n),t}()},"./src/types/loader.ts":
262
262
  /*!*****************************!*\
263
263
  !*** ./src/types/loader.ts ***!
264
264
  \*****************************/
265
- /*! exports provided: PlaylistContextType, PlaylistLevelType */function(t,i,r){r.r(i);r.d(i,"PlaylistContextType",(function(){return e}));r.d(i,"PlaylistLevelType",(function(){return n}));var e;(function(t){t["MANIFEST"]="manifest";t["LEVEL"]="level";t["AUDIO_TRACK"]="audioTrack";t["SUBTITLE_TRACK"]="subtitleTrack"})(e||(e={}));var n;(function(t){t["MAIN"]="main";t["AUDIO"]="audio";t["SUBTITLE"]="subtitle"})(n||(n={}))},"./src/types/transmuxer.ts":
265
+ /*! exports provided: PlaylistContextType, PlaylistLevelType */function(t,i,n){var r,e;n.r(i),n.d(i,"PlaylistContextType",(function(){return r})),n.d(i,"PlaylistLevelType",(function(){return e})),function(t){t.MANIFEST="manifest",t.LEVEL="level",t.AUDIO_TRACK="audioTrack",t.SUBTITLE_TRACK="subtitleTrack"}(r||(r={})),function(t){t.MAIN="main",t.AUDIO="audio",t.SUBTITLE="subtitle"}(e||(e={}))},"./src/types/transmuxer.ts":
266
266
  /*!*********************************!*\
267
267
  !*** ./src/types/transmuxer.ts ***!
268
268
  \*********************************/
269
- /*! exports provided: ChunkMetadata */function(t,i,r){r.r(i);r.d(i,"ChunkMetadata",(function(){return e}));var e=function t(i,r,e,s,a,u){if(s===void 0){s=0}if(a===void 0){a=-1}if(u===void 0){u=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=n();this.buffering={audio:n(),video:n(),audiovideo:n()};this.level=i;this.sn=r;this.id=e;this.size=s;this.part=a;this.partial=u};function n(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":
269
+ /*! exports provided: ChunkMetadata */function(t,i,n){n.r(i),n.d(i,"ChunkMetadata",(function(){return r}));var r=function(t,i,n,r,e,s){void 0===r&&(r=0),void 0===e&&(e=-1),void 0===s&&(s=!1),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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=i,this.id=n,this.size=r,this.part=e,this.partial=s}},"./src/utils/attr-list.ts":
270
270
  /*!********************************!*\
271
271
  !*** ./src/utils/attr-list.ts ***!
272
272
  \********************************/
273
- /*! exports provided: AttrList */function(t,i,r){r.r(i);r.d(i,"AttrList",(function(){return s}));var e=/^(\d+)x(\d+)$/;var n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g;var s=function(){function t(i){if(typeof i==="string"){i=t.parseAttrList(i)}for(var r in i){if(i.hasOwnProperty(r)){this[r]=i[r]}}}var i=t.prototype;i.decimalInteger=function t(i){var r=parseInt(this[i],10);if(r>Number.MAX_SAFE_INTEGER){return Infinity}return r};i.hexadecimalInteger=function t(i){if(this[i]){var r=(this[i]||"0x").slice(2);r=(r.length&1?"0":"")+r;var e=new Uint8Array(r.length/2);for(var n=0;n<r.length/2;n++){e[n]=parseInt(r.slice(n*2,n*2+2),16)}return e}else{return null}};i.hexadecimalIntegerAsNumber=function t(i){var r=parseInt(this[i],16);if(r>Number.MAX_SAFE_INTEGER){return Infinity}return r};i.decimalFloatingPoint=function t(i){return parseFloat(this[i])};i.optionalFloat=function t(i,r){var e=this[i];return e?parseFloat(e):r};i.enumeratedString=function t(i){return this[i]};i.bool=function t(i){return this[i]==="YES"};i.decimalResolution=function t(i){var r=e.exec(this[i]);if(r===null){return undefined}return{width:parseInt(r[1],10),height:parseInt(r[2],10)}};t.parseAttrList=function t(i){var r;var e={};var s='"';n.lastIndex=0;while((r=n.exec(i))!==null){var a=r[2];if(a.indexOf(s)===0&&a.lastIndexOf(s)===a.length-1){a=a.slice(1,-1)}e[r[1]]=a}return e};return t}()},"./src/utils/binary-search.ts":
273
+ /*! exports provided: AttrList */function(t,i,n){n.r(i),n.d(i,"AttrList",(function(){return s}));var r=/^(\d+)x(\d+)$/,e=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,s=function(){function t(i){for(var n in"string"==typeof i&&(i=t.parseAttrList(i)),i)i.hasOwnProperty(n)&&(this[n]=i[n])}var i=t.prototype;return i.decimalInteger=function(t){var i=parseInt(this[t],10);return i>Number.MAX_SAFE_INTEGER?1/0:i},i.hexadecimalInteger=function(t){if(this[t]){var i=(this[t]||"0x").slice(2);i=(1&i.length?"0":"")+i;for(var n=new Uint8Array(i.length/2),r=0;r<i.length/2;r++)n[r]=parseInt(i.slice(2*r,2*r+2),16);return n}return null},i.hexadecimalIntegerAsNumber=function(t){var i=parseInt(this[t],16);return i>Number.MAX_SAFE_INTEGER?1/0:i},i.decimalFloatingPoint=function(t){return parseFloat(this[t])},i.optionalFloat=function(t,i){var n=this[t];return n?parseFloat(n):i},i.enumeratedString=function(t){return this[t]},i.bool=function(t){return"YES"===this[t]},i.decimalResolution=function(t){var i=r.exec(this[t]);if(null!==i)return{width:parseInt(i[1],10),height:parseInt(i[2],10)}},t.parseAttrList=function(t){var i,n={};for(e.lastIndex=0;null!==(i=e.exec(t));){var r=i[2];0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1&&(r=r.slice(1,-1)),n[i[1]]=r}return n},t}()},"./src/utils/binary-search.ts":
274
274
  /*!************************************!*\
275
275
  !*** ./src/utils/binary-search.ts ***!
276
276
  \************************************/
277
- /*! exports provided: default */function(t,i,r){r.r(i);var e={search:function t(i,r){var e=0;var n=i.length-1;var s=null;var a=null;while(e<=n){s=(e+n)/2|0;a=i[s];var u=r(a);if(u>0){e=s+1}else if(u<0){n=s-1}else{return a}}return null}};i["default"]=e},"./src/utils/buffer-helper.ts":
277
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default={search:function(t,i){for(var n=0,r=t.length-1,e=null,s=null;n<=r;){var a=i(s=t[e=(n+r)/2|0]);if(a>0)n=e+1;else{if(!(a<0))return s;r=e-1}}return null}}},"./src/utils/buffer-helper.ts":
278
278
  /*!************************************!*\
279
279
  !*** ./src/utils/buffer-helper.ts ***!
280
280
  \************************************/
281
- /*! exports provided: BufferHelper */function(t,i,r){r.r(i);r.d(i,"BufferHelper",(function(){return s}));var e=r(/*! ./logger */"./src/utils/logger.ts");var n={length:0,start:function t(){return 0},end:function t(){return 0}};var s=function(){function t(){}t.isBuffered=function i(r,e){try{if(r){var n=t.getBuffered(r);for(var s=0;s<n.length;s++){if(e>=n.start(s)&&e<=n.end(s)){return true}}}}catch(t){}return false};t.bufferInfo=function i(r,e,n){try{if(r){var s=t.getBuffered(r);var a=[];var u;for(u=0;u<s.length;u++){a.push({start:s.start(u),end:s.end(u)})}return this.bufferedInfo(a,e,n)}}catch(t){}return{len:0,start:e,end:e,nextStart:undefined}};t.bufferedInfo=function t(i,r,e){r=Math.max(0,r);i.sort((function(t,i){var r=t.start-i.start;if(r){return r}else{return i.end-t.end}}));var n=[];if(e){for(var s=0;s<i.length;s++){var a=n.length;if(a){var u=n[a-1].end;if(i[s].start-u<e){if(i[s].end>u){n[a-1].end=i[s].end}}else{n.push(i[s])}}else{n.push(i[s])}}}else{n=i}var f=0;var h;var o=r;var v=r;for(var l=0;l<n.length;l++){var c=n[l].start;var d=n[l].end;if(r+e>=c&&r<d){o=c;v=d;f=v-r}else if(r+e<c){h=c;break}}return{len:f,start:o||0,end:v||0,nextStart:h}};t.getBuffered=function t(i){try{return i.buffered}catch(t){e["logger"].log("failed to get media.buffered",t);return n}};return t}()},"./src/utils/cea-608-parser.ts":
281
+ /*! exports provided: BufferHelper */function(t,i,n){n.r(i),n.d(i,"BufferHelper",(function(){return s}));var r=n(/*! ./logger */"./src/utils/logger.ts"),e={length:0,start:function(){return 0},end:function(){return 0}},s=function(){function t(){}return t.isBuffered=function(i,n){try{if(i)for(var r=t.getBuffered(i),e=0;e<r.length;e++)if(n>=r.start(e)&&n<=r.end(e))return!0}catch(t){}return!1},t.bufferInfo=function(i,n,r){try{if(i){var e,s=t.getBuffered(i),a=[];for(e=0;e<s.length;e++)a.push({start:s.start(e),end:s.end(e)});return this.bufferedInfo(a,n,r)}}catch(t){}return{len:0,start:n,end:n,nextStart:void 0}},t.bufferedInfo=function(t,i,n){i=Math.max(0,i),t.sort((function(t,i){return t.start-i.start||i.end-t.end}));var r=[];if(n)for(var e=0;e<t.length;e++){var s=r.length;if(s){var a=r[s-1].end;t[e].start-a<n?t[e].end>a&&(r[s-1].end=t[e].end):r.push(t[e])}else r.push(t[e])}else r=t;for(var o,h=0,u=i,c=i,f=0;f<r.length;f++){var l=r[f].start,v=r[f].end;if(i+n>=l&&i<v)u=l,h=(c=v)-i;else if(i+n<l){o=l;break}}return{len:h,start:u||0,end:c||0,nextStart:o}},t.getBuffered=function(t){try{return t.buffered}catch(t){return r.logger.log("failed to get media.buffered",t),e}},t}()},"./src/utils/cea-608-parser.ts":
282
282
  /*!*************************************!*\
283
283
  !*** ./src/utils/cea-608-parser.ts ***!
284
284
  \*************************************/
285
- /*! exports provided: Row, CaptionScreen, default */function(t,i,r){r.r(i);r.d(i,"Row",(function(){return b}));r.d(i,"CaptionScreen",(function(){return y}));var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n={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 s=function t(i){var r=i;if(n.hasOwnProperty(i)){r=n[i]}return String.fromCharCode(r)};var a=15;var u=100;var f={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14};var h={17:2,18:4,21:6,22:8,23:10,19:13,20:15};var o={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14};var v={25:2,26:4,29:6,30:8,31:10,27:13,28:15};var l=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];var c;(function(t){t[t["ERROR"]=0]="ERROR";t[t["TEXT"]=1]="TEXT";t[t["WARNING"]=2]="WARNING";t[t["INFO"]=2]="INFO";t[t["DEBUG"]=3]="DEBUG";t[t["DATA"]=3]="DATA"})(c||(c={}));var d=function(){function t(){this.time=null;this.verboseLevel=c.ERROR}var i=t.prototype;i.log=function t(i,r){if(this.verboseLevel>=i){e["logger"].log(this.time+" ["+i+"] "+r)}};return t}();var m=function t(i){var r=[];for(var e=0;e<i.length;e++){r.push(i[e].toString(16))}return r};var p=function(){function t(t,i,r,e,n){this.foreground=void 0;this.underline=void 0;this.italics=void 0;this.background=void 0;this.flash=void 0;this.foreground=t||"white";this.underline=i||false;this.italics=r||false;this.background=e||"black";this.flash=n||false}var i=t.prototype;i.reset=function t(){this.foreground="white";this.underline=false;this.italics=false;this.background="black";this.flash=false};i.setStyles=function t(i){var r=["foreground","underline","italics","background","flash"];for(var e=0;e<r.length;e++){var n=r[e];if(i.hasOwnProperty(n)){this[n]=i[n]}}};i.isDefault=function t(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash};i.equals=function t(i){return this.foreground===i.foreground&&this.underline===i.underline&&this.italics===i.italics&&this.background===i.background&&this.flash===i.flash};i.copy=function t(i){this.foreground=i.foreground;this.underline=i.underline;this.italics=i.italics;this.background=i.background;this.flash=i.flash};i.toString=function t(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash};return t}();var g=function(){function t(t,i,r,e,n,s){this.uchar=void 0;this.penState=void 0;this.uchar=t||" ";this.penState=new p(i,r,e,n,s)}var i=t.prototype;i.reset=function t(){this.uchar=" ";this.penState.reset()};i.setChar=function t(i,r){this.uchar=i;this.penState.copy(r)};i.setPenState=function t(i){this.penState.copy(i)};i.equals=function t(i){return this.uchar===i.uchar&&this.penState.equals(i.penState)};i.copy=function t(i){this.uchar=i.uchar;this.penState.copy(i.penState)};i.isEmpty=function t(){return this.uchar===" "&&this.penState.isDefault()};return t}();var b=function(){function t(t){this.chars=void 0;this.pos=void 0;this.currPenState=void 0;this.cueStartTime=void 0;this.logger=void 0;this.chars=[];for(var i=0;i<u;i++){this.chars.push(new g)}this.logger=t;this.pos=0;this.currPenState=new p}var i=t.prototype;i.equals=function t(i){var r=true;for(var e=0;e<u;e++){if(!this.chars[e].equals(i.chars[e])){r=false;break}}return r};i.copy=function t(i){for(var r=0;r<u;r++){this.chars[r].copy(i.chars[r])}};i.isEmpty=function t(){var i=true;for(var r=0;r<u;r++){if(!this.chars[r].isEmpty()){i=false;break}}return i};i.setCursor=function t(i){if(this.pos!==i){this.pos=i}if(this.pos<0){this.logger.log(c.DEBUG,"Negative cursor position "+this.pos);this.pos=0}else if(this.pos>u){this.logger.log(c.DEBUG,"Too large cursor position "+this.pos);this.pos=u}};i.moveCursor=function t(i){var r=this.pos+i;if(i>1){for(var e=this.pos+1;e<r+1;e++){this.chars[e].setPenState(this.currPenState)}}this.setCursor(r)};i.backSpace=function t(){this.moveCursor(-1);this.chars[this.pos].setChar(" ",this.currPenState)};i.insertChar=function t(i){if(i>=144){this.backSpace()}var r=s(i);if(this.pos>=u){this.logger.log(c.ERROR,"Cannot insert "+i.toString(16)+" ("+r+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(r,this.currPenState);this.moveCursor(1)};i.clearFromPos=function t(i){var r;for(r=i;r<u;r++){this.chars[r].reset()}};i.clear=function t(){this.clearFromPos(0);this.pos=0;this.currPenState.reset()};i.clearToEndOfRow=function t(){this.clearFromPos(this.pos)};i.getTextString=function t(){var i=[];var r=true;for(var e=0;e<u;e++){var n=this.chars[e].uchar;if(n!==" "){r=false}i.push(n)}if(r){return""}else{return i.join("")}};i.setPenStyles=function t(i){this.currPenState.setStyles(i);var r=this.chars[this.pos];r.setPenState(this.currPenState)};return t}();var y=function(){function t(t){this.rows=void 0;this.currRow=void 0;this.nrRollUpRows=void 0;this.lastOutputScreen=void 0;this.logger=void 0;this.rows=[];for(var i=0;i<a;i++){this.rows.push(new b(t))}this.logger=t;this.currRow=a-1;this.nrRollUpRows=null;this.lastOutputScreen=null;this.reset()}var i=t.prototype;i.reset=function t(){for(var i=0;i<a;i++){this.rows[i].clear()}this.currRow=a-1};i.equals=function t(i){var r=true;for(var e=0;e<a;e++){if(!this.rows[e].equals(i.rows[e])){r=false;break}}return r};i.copy=function t(i){for(var r=0;r<a;r++){this.rows[r].copy(i.rows[r])}};i.isEmpty=function t(){var i=true;for(var r=0;r<a;r++){if(!this.rows[r].isEmpty()){i=false;break}}return i};i.backSpace=function t(){var i=this.rows[this.currRow];i.backSpace()};i.clearToEndOfRow=function t(){var i=this.rows[this.currRow];i.clearToEndOfRow()};i.insertChar=function t(i){var r=this.rows[this.currRow];r.insertChar(i)};i.setPen=function t(i){var r=this.rows[this.currRow];r.setPenStyles(i)};i.moveCursor=function t(i){var r=this.rows[this.currRow];r.moveCursor(i)};i.setCursor=function t(i){this.logger.log(c.INFO,"setCursor: "+i);var r=this.rows[this.currRow];r.setCursor(i)};i.setPAC=function t(i){this.logger.log(c.INFO,"pacData = "+JSON.stringify(i));var r=i.row-1;if(this.nrRollUpRows&&r<this.nrRollUpRows-1){r=this.nrRollUpRows-1}if(this.nrRollUpRows&&this.currRow!==r){for(var e=0;e<a;e++){this.rows[e].clear()}var n=this.currRow+1-this.nrRollUpRows;var s=this.lastOutputScreen;if(s){var u=s.rows[n].cueStartTime;var f=this.logger.time;if(u&&f!==null&&u<f){for(var h=0;h<this.nrRollUpRows;h++){this.rows[r-this.nrRollUpRows+h+1].copy(s.rows[n+h])}}}}this.currRow=r;var o=this.rows[this.currRow];if(i.indent!==null){var v=i.indent;var l=Math.max(v-1,0);o.setCursor(i.indent);i.color=o.chars[l].penState.foreground}var d={foreground:i.color,underline:i.underline,italics:i.italics,background:"black",flash:false};this.setPen(d)};i.setBkgData=function t(i){this.logger.log(c.INFO,"bkgData = "+JSON.stringify(i));this.backSpace();this.setPen(i);this.insertChar(32)};i.setRollUpRows=function t(i){this.nrRollUpRows=i};i.rollUp=function t(){if(this.nrRollUpRows===null){this.logger.log(c.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(c.TEXT,this.getDisplayText());var i=this.currRow+1-this.nrRollUpRows;var r=this.rows.splice(i,1)[0];r.clear();this.rows.splice(this.currRow,0,r);this.logger.log(c.INFO,"Rolling up")};i.getDisplayText=function t(i){i=i||false;var r=[];var e="";var n=-1;for(var s=0;s<a;s++){var u=this.rows[s].getTextString();if(u){n=s+1;if(i){r.push("Row "+n+": '"+u+"'")}else{r.push(u.trim())}}}if(r.length>0){if(i){e="["+r.join(" | ")+"]"}else{e=r.join("\n")}}return e};i.getTextAndFormat=function t(){return this.rows};return t}();var w=function(){function t(t,i,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=t;this.outputFilter=i;this.mode=null;this.verbose=0;this.displayedMemory=new y(r);this.nonDisplayedMemory=new y(r);this.lastOutputScreen=new y(r);this.currRollUpRow=this.displayedMemory.rows[a-1];this.writeScreen=this.displayedMemory;this.mode=null;this.cueStartTime=null;this.logger=r}var i=t.prototype;i.reset=function t(){this.mode=null;this.displayedMemory.reset();this.nonDisplayedMemory.reset();this.lastOutputScreen.reset();this.outputFilter.reset();this.currRollUpRow=this.displayedMemory.rows[a-1];this.writeScreen=this.displayedMemory;this.mode=null;this.cueStartTime=null};i.getHandler=function t(){return this.outputFilter};i.setHandler=function t(i){this.outputFilter=i};i.setPAC=function t(i){this.writeScreen.setPAC(i)};i.setBkgData=function t(i){this.writeScreen.setBkgData(i)};i.setMode=function t(i){if(i===this.mode){return}this.mode=i;this.logger.log(c.INFO,"MODE="+i);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=i};i.insertChars=function t(i){for(var r=0;r<i.length;r++){this.writeScreen.insertChar(i[r])}var e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(c.INFO,e+": "+this.writeScreen.getDisplayText(true));if(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP"){this.logger.log(c.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(true));this.outputDataUpdate()}};i.ccRCL=function t(){this.logger.log(c.INFO,"RCL - Resume Caption Loading");this.setMode("MODE_POP-ON")};i.ccBS=function t(){this.logger.log(c.INFO,"BS - BackSpace");if(this.mode==="MODE_TEXT"){return}this.writeScreen.backSpace();if(this.writeScreen===this.displayedMemory){this.outputDataUpdate()}};i.ccAOF=function t(){};i.ccAON=function t(){};i.ccDER=function t(){this.logger.log(c.INFO,"DER- Delete to End of Row");this.writeScreen.clearToEndOfRow();this.outputDataUpdate()};i.ccRU=function t(i){this.logger.log(c.INFO,"RU("+i+") - Roll Up");this.writeScreen=this.displayedMemory;this.setMode("MODE_ROLL-UP");this.writeScreen.setRollUpRows(i)};i.ccFON=function t(){this.logger.log(c.INFO,"FON - Flash On");this.writeScreen.setPen({flash:true})};i.ccRDC=function t(){this.logger.log(c.INFO,"RDC - Resume Direct Captioning");this.setMode("MODE_PAINT-ON")};i.ccTR=function t(){this.logger.log(c.INFO,"TR");this.setMode("MODE_TEXT")};i.ccRTD=function t(){this.logger.log(c.INFO,"RTD");this.setMode("MODE_TEXT")};i.ccEDM=function t(){this.logger.log(c.INFO,"EDM - Erase Displayed Memory");this.displayedMemory.reset();this.outputDataUpdate(true)};i.ccCR=function t(){this.logger.log(c.INFO,"CR - Carriage Return");this.writeScreen.rollUp();this.outputDataUpdate(true)};i.ccENM=function t(){this.logger.log(c.INFO,"ENM - Erase Non-displayed Memory");this.nonDisplayedMemory.reset()};i.ccEOC=function t(){this.logger.log(c.INFO,"EOC - End Of Caption");if(this.mode==="MODE_POP-ON"){var i=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory;this.nonDisplayedMemory=i;this.writeScreen=this.nonDisplayedMemory;this.logger.log(c.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(true)};i.ccTO=function t(i){this.logger.log(c.INFO,"TO("+i+") - Tab Offset");this.writeScreen.moveCursor(i)};i.ccMIDROW=function t(i){var r={flash:false};r.underline=i%2===1;r.italics=i>=46;if(!r.italics){var e=Math.floor(i/2)-16;var n=["white","green","blue","cyan","red","yellow","magenta"];r.foreground=n[e]}else{r.foreground="white"}this.logger.log(c.INFO,"MIDROW: "+JSON.stringify(r));this.writeScreen.setPen(r)};i.outputDataUpdate=function t(i){if(i===void 0){i=false}var r=this.logger.time;if(r===null){return}if(this.outputFilter){if(this.cueStartTime===null&&!this.displayedMemory.isEmpty()){this.cueStartTime=r}else{if(!this.displayedMemory.equals(this.lastOutputScreen)){this.outputFilter.newCue(this.cueStartTime,r,this.lastOutputScreen);if(i&&this.outputFilter.dispatchCue){this.outputFilter.dispatchCue()}this.cueStartTime=this.displayedMemory.isEmpty()?null:r}}this.lastOutputScreen.copy(this.displayedMemory)}};i.cueSplitAtTime=function t(i){if(this.outputFilter){if(!this.displayedMemory.isEmpty()){if(this.outputFilter.newCue){this.outputFilter.newCue(this.cueStartTime,i,this.displayedMemory)}this.cueStartTime=i}}};return t}();var k=function(){function t(t,i,r){this.channels=void 0;this.currentChannel=0;this.cmdHistory=void 0;this.logger=void 0;var e=new d;this.channels=[null,new w(t,i,e),new w(t+1,r,e)];this.cmdHistory=S();this.logger=e}var i=t.prototype;i.getHandler=function t(i){return this.channels[i].getHandler()};i.setHandler=function t(i,r){this.channels[i].setHandler(r)};i.addData=function t(i,r){var e;var n;var s;var a=false;this.logger.time=i;for(var u=0;u<r.length;u+=2){n=r[u]&127;s=r[u+1]&127;if(n===0&&s===0){continue}else{this.logger.log(c.DATA,"["+m([r[u],r[u+1]])+"] -> ("+m([n,s])+")")}e=this.parseCmd(n,s);if(!e){e=this.parseMidrow(n,s)}if(!e){e=this.parsePAC(n,s)}if(!e){e=this.parseBackgroundAttributes(n,s)}if(!e){a=this.parseChars(n,s);if(a){var f=this.currentChannel;if(f&&f>0){var h=this.channels[f];h.insertChars(a)}else{this.logger.log(c.WARNING,"No channel found yet. TEXT-MODE?")}}}if(!e&&!a){this.logger.log(c.WARNING,"Couldn't parse cleaned data "+m([n,s])+" orig: "+m([r[u],r[u+1]]))}}};i.parseCmd=function t(i,r){var e=this.cmdHistory;var n=(i===20||i===28||i===21||i===29)&&r>=32&&r<=47;var s=(i===23||i===31)&&r>=33&&r<=35;if(!(n||s)){return false}if(O(i,r,e)){T(null,null,e);this.logger.log(c.DEBUG,"Repeated command ("+m([i,r])+") is dropped");return true}var a=i===20||i===21||i===23?1:2;var u=this.channels[a];if(i===20||i===21||i===28||i===29){if(r===32){u.ccRCL()}else if(r===33){u.ccBS()}else if(r===34){u.ccAOF()}else if(r===35){u.ccAON()}else if(r===36){u.ccDER()}else if(r===37){u.ccRU(2)}else if(r===38){u.ccRU(3)}else if(r===39){u.ccRU(4)}else if(r===40){u.ccFON()}else if(r===41){u.ccRDC()}else if(r===42){u.ccTR()}else if(r===43){u.ccRTD()}else if(r===44){u.ccEDM()}else if(r===45){u.ccCR()}else if(r===46){u.ccENM()}else if(r===47){u.ccEOC()}}else{u.ccTO(r-32)}T(i,r,e);this.currentChannel=a;return true};i.parseMidrow=function t(i,r){var e=0;if((i===17||i===25)&&r>=32&&r<=47){if(i===17){e=1}else{e=2}if(e!==this.currentChannel){this.logger.log(c.ERROR,"Mismatch channel in midrow parsing");return false}var n=this.channels[e];if(!n){return false}n.ccMIDROW(r);this.logger.log(c.DEBUG,"MIDROW ("+m([i,r])+")");return true}return false};i.parsePAC=function t(i,r){var e;var n=this.cmdHistory;var s=(i>=17&&i<=23||i>=25&&i<=31)&&r>=64&&r<=127;var a=(i===16||i===24)&&r>=64&&r<=95;if(!(s||a)){return false}if(O(i,r,n)){T(null,null,n);return true}var u=i<=23?1:2;if(r>=64&&r<=95){e=u===1?f[i]:o[i]}else{e=u===1?h[i]:v[i]}var l=this.channels[u];if(!l){return false}l.setPAC(this.interpretPAC(e,r));T(i,r,n);this.currentChannel=u;return true};i.interpretPAC=function t(i,r){var e;var n={color:null,italics:false,indent:null,underline:false,row:i};if(r>95){e=r-96}else{e=r-64}n.underline=(e&1)===1;if(e<=13){n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(e/2)]}else if(e<=15){n.italics=true;n.color="white"}else{n.indent=Math.floor((e-16)/2)*4}return n};i.parseChars=function t(i,r){var e;var n=null;var a=null;if(i>=25){e=2;a=i-8}else{e=1;a=i}if(a>=17&&a<=19){var u;if(a===17){u=r+80}else if(a===18){u=r+112}else{u=r+144}this.logger.log(c.INFO,"Special char '"+s(u)+"' in channel "+e);n=[u]}else if(i>=32&&i<=127){n=r===0?[i]:[i,r]}if(n){var f=m(n);this.logger.log(c.DEBUG,"Char codes = "+f.join(","));T(i,r,this.cmdHistory)}return n};i.parseBackgroundAttributes=function t(i,r){var e=(i===16||i===24)&&r>=32&&r<=47;var n=(i===23||i===31)&&r>=45&&r<=47;if(!(e||n)){return false}var s;var a={};if(i===16||i===24){s=Math.floor((r-32)/2);a.background=l[s];if(r%2===1){a.background=a.background+"_semi"}}else if(r===45){a.background="transparent"}else{a.foreground="black";if(r===47){a.underline=true}}var u=i<=23?1:2;var f=this.channels[u];f.setBkgData(a);T(i,r,this.cmdHistory);return true};i.reset=function t(){for(var i=0;i<Object.keys(this.channels).length;i++){var r=this.channels[i];if(r){r.reset()}}this.cmdHistory=S()};i.cueSplitAtTime=function t(i){for(var r=0;r<this.channels.length;r++){var e=this.channels[r];if(e){e.cueSplitAtTime(i)}}};return t}();function T(t,i,r){r.a=t;r.b=i}function O(t,i,r){return r.a===t&&r.b===i}function S(){return{a:null,b:null}}i["default"]=k},"./src/utils/codecs.ts":
285
+ /*! exports provided: Row, CaptionScreen, default */function(t,i,n){n.r(i),n.d(i,"Row",(function(){return b})),n.d(i,"CaptionScreen",(function(){return y}));var r,e=n(/*! ../utils/logger */"./src/utils/logger.ts"),s={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},a=function(t){var i=t;return s.hasOwnProperty(t)&&(i=s[t]),String.fromCharCode(i)},o=15,h=100,u={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},c={17:2,18:4,21:6,22:8,23:10,19:13,20:15},f={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},l={25:2,26:4,29:6,30:8,31:10,27:13,28:15},v=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"}(r||(r={}));var d=function(){function t(){this.time=null,this.verboseLevel=r.ERROR}return t.prototype.log=function(t,i){this.verboseLevel>=t&&e.logger.log(this.time+" ["+t+"] "+i)},t}(),m=function(t){for(var i=[],n=0;n<t.length;n++)i.push(t[n].toString(16));return i},p=function(){function t(t,i,n,r,e){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=i||!1,this.italics=n||!1,this.background=r||"black",this.flash=e||!1}var i=t.prototype;return i.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},i.setStyles=function(t){for(var i=["foreground","underline","italics","background","flash"],n=0;n<i.length;n++){var r=i[n];t.hasOwnProperty(r)&&(this[r]=t[r])}},i.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},i.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},i.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},i.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),g=function(){function t(t,i,n,r,e,s){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new p(i,n,r,e,s)}var i=t.prototype;return i.reset=function(){this.uchar=" ",this.penState.reset()},i.setChar=function(t,i){this.uchar=t,this.penState.copy(i)},i.setPenState=function(t){this.penState.copy(t)},i.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},i.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},i.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},t}(),b=function(){function t(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var i=0;i<h;i++)this.chars.push(new g);this.logger=t,this.pos=0,this.currPenState=new p}var i=t.prototype;return i.equals=function(t){for(var i=!0,n=0;n<h;n++)if(!this.chars[n].equals(t.chars[n])){i=!1;break}return i},i.copy=function(t){for(var i=0;i<h;i++)this.chars[i].copy(t.chars[i])},i.isEmpty=function(){for(var t=!0,i=0;i<h;i++)if(!this.chars[i].isEmpty()){t=!1;break}return t},i.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(r.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>h&&(this.logger.log(r.DEBUG,"Too large cursor position "+this.pos),this.pos=h)},i.moveCursor=function(t){var i=this.pos+t;if(t>1)for(var n=this.pos+1;n<i+1;n++)this.chars[n].setPenState(this.currPenState);this.setCursor(i)},i.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},i.insertChar=function(t){t>=144&&this.backSpace();var i=a(t);this.pos>=h?this.logger.log(r.ERROR,"Cannot insert "+t.toString(16)+" ("+i+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},i.clearFromPos=function(t){var i;for(i=t;i<h;i++)this.chars[i].reset()},i.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},i.clearToEndOfRow=function(){this.clearFromPos(this.pos)},i.getTextString=function(){for(var t=[],i=!0,n=0;n<h;n++){var r=this.chars[n].uchar;" "!==r&&(i=!1),t.push(r)}return i?"":t.join("")},i.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),y=function(){function t(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var i=0;i<o;i++)this.rows.push(new b(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var i=t.prototype;return i.reset=function(){for(var t=0;t<o;t++)this.rows[t].clear();this.currRow=14},i.equals=function(t){for(var i=!0,n=0;n<o;n++)if(!this.rows[n].equals(t.rows[n])){i=!1;break}return i},i.copy=function(t){for(var i=0;i<o;i++)this.rows[i].copy(t.rows[i])},i.isEmpty=function(){for(var t=!0,i=0;i<o;i++)if(!this.rows[i].isEmpty()){t=!1;break}return t},i.backSpace=function(){this.rows[this.currRow].backSpace()},i.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},i.insertChar=function(t){this.rows[this.currRow].insertChar(t)},i.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},i.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},i.setCursor=function(t){this.logger.log(r.INFO,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},i.setPAC=function(t){this.logger.log(r.INFO,"pacData = "+JSON.stringify(t));var i=t.row-1;if(this.nrRollUpRows&&i<this.nrRollUpRows-1&&(i=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==i){for(var n=0;n<o;n++)this.rows[n].clear();var e=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){var a=s.rows[e].cueStartTime,h=this.logger.time;if(a&&null!==h&&a<h)for(var u=0;u<this.nrRollUpRows;u++)this.rows[i-this.nrRollUpRows+u+1].copy(s.rows[e+u])}}this.currRow=i;var c=this.rows[this.currRow];if(null!==t.indent){var f=Math.max(t.indent-1,0);c.setCursor(t.indent),t.color=c.chars[f].penState.foreground}this.setPen({foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1})},i.setBkgData=function(t){this.logger.log(r.INFO,"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)},i.setRollUpRows=function(t){this.nrRollUpRows=t},i.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(r.TEXT,this.getDisplayText());var t=this.rows.splice(this.currRow+1-this.nrRollUpRows,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(r.INFO,"Rolling up")}else this.logger.log(r.DEBUG,"roll_up but nrRollUpRows not set yet")},i.getDisplayText=function(t){t=t||!1;for(var i=[],n="",r=0;r<o;r++){var e=this.rows[r].getTextString();e&&i.push(t?"Row "+(r+1)+": '"+e+"'":e.trim())}return i.length>0&&(n=t?"["+i.join(" | ")+"]":i.join("\n")),n},i.getTextAndFormat=function(){return this.rows},t}(),w=function(){function t(t,i,n){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=t,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new y(n),this.nonDisplayedMemory=new y(n),this.lastOutputScreen=new y(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}var i=t.prototype;return i.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},i.getHandler=function(){return this.outputFilter},i.setHandler=function(t){this.outputFilter=t},i.setPAC=function(t){this.writeScreen.setPAC(t)},i.setBkgData=function(t){this.writeScreen.setBkgData(t)},i.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(r.INFO,"MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},i.insertChars=function(t){for(var i=0;i<t.length;i++)this.writeScreen.insertChar(t[i]);this.logger.log(r.INFO,(this.writeScreen===this.displayedMemory?"DISP":"NON_DISP")+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(r.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},i.ccRCL=function(){this.logger.log(r.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},i.ccBS=function(){this.logger.log(r.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},i.ccAOF=function(){},i.ccAON=function(){},i.ccDER=function(){this.logger.log(r.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},i.ccRU=function(t){this.logger.log(r.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},i.ccFON=function(){this.logger.log(r.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},i.ccRDC=function(){this.logger.log(r.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},i.ccTR=function(){this.logger.log(r.INFO,"TR"),this.setMode("MODE_TEXT")},i.ccRTD=function(){this.logger.log(r.INFO,"RTD"),this.setMode("MODE_TEXT")},i.ccEDM=function(){this.logger.log(r.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},i.ccCR=function(){this.logger.log(r.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},i.ccENM=function(){this.logger.log(r.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},i.ccEOC=function(){if(this.logger.log(r.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(r.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},i.ccTO=function(t){this.logger.log(r.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},i.ccMIDROW=function(t){var i={flash:!1};if(i.underline=t%2==1,i.italics=t>=46,i.italics)i.foreground="white";else{var n=Math.floor(t/2)-16;i.foreground=["white","green","blue","cyan","red","yellow","magenta"][n]}this.logger.log(r.INFO,"MIDROW: "+JSON.stringify(i)),this.writeScreen.setPen(i)},i.outputDataUpdate=function(t){void 0===t&&(t=!1);var i=this.logger.time;null!==i&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,i,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:i):this.cueStartTime=i,this.lastOutputScreen.copy(this.displayedMemory))},i.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}();function k(t,i,n){n.a=t,n.b=i}function T(t,i,n){return n.a===t&&n.b===i}i.default=function(){function t(t,i,n){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var r=new d;this.channels=[null,new w(t,i,r),new w(t+1,n,r)],this.cmdHistory={a:null,b:null},this.logger=r}var i=t.prototype;return i.getHandler=function(t){return this.channels[t].getHandler()},i.setHandler=function(t,i){this.channels[t].setHandler(i)},i.addData=function(t,i){var n,e,s,a=!1;this.logger.time=t;for(var o=0;o<i.length;o+=2)if(s=127&i[o+1],0!=(e=127&i[o])||0!==s){if(this.logger.log(r.DATA,"["+m([i[o],i[o+1]])+"] -> ("+m([e,s])+")"),(n=this.parseCmd(e,s))||(n=this.parseMidrow(e,s)),n||(n=this.parsePAC(e,s)),n||(n=this.parseBackgroundAttributes(e,s)),!n&&(a=this.parseChars(e,s))){var h=this.currentChannel;h&&h>0?this.channels[h].insertChars(a):this.logger.log(r.WARNING,"No channel found yet. TEXT-MODE?")}n||a||this.logger.log(r.WARNING,"Couldn't parse cleaned data "+m([e,s])+" orig: "+m([i[o],i[o+1]]))}},i.parseCmd=function(t,i){var n=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&i>=32&&i<=47||(23===t||31===t)&&i>=33&&i<=35))return!1;if(T(t,i,n))return k(null,null,n),this.logger.log(r.DEBUG,"Repeated command ("+m([t,i])+") is dropped"),!0;var e=20===t||21===t||23===t?1:2,s=this.channels[e];return 20===t||21===t||28===t||29===t?32===i?s.ccRCL():33===i?s.ccBS():34===i?s.ccAOF():35===i?s.ccAON():36===i?s.ccDER():37===i?s.ccRU(2):38===i?s.ccRU(3):39===i?s.ccRU(4):40===i?s.ccFON():41===i?s.ccRDC():42===i?s.ccTR():43===i?s.ccRTD():44===i?s.ccEDM():45===i?s.ccCR():46===i?s.ccENM():47===i&&s.ccEOC():s.ccTO(i-32),k(t,i,n),this.currentChannel=e,!0},i.parseMidrow=function(t,i){var n=0;if((17===t||25===t)&&i>=32&&i<=47){if((n=17===t?1:2)!==this.currentChannel)return this.logger.log(r.ERROR,"Mismatch channel in midrow parsing"),!1;var e=this.channels[n];return!!e&&(e.ccMIDROW(i),this.logger.log(r.DEBUG,"MIDROW ("+m([t,i])+")"),!0)}return!1},i.parsePAC=function(t,i){var n=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&i>=64&&i<=127||(16===t||24===t)&&i>=64&&i<=95))return!1;if(T(t,i,n))return k(null,null,n),!0;var r=t<=23?1:2,e=this.channels[r];return!!e&&(e.setPAC(this.interpretPAC(i>=64&&i<=95?1===r?u[t]:f[t]:1===r?c[t]:l[t],i)),k(t,i,n),this.currentChannel=r,!0)},i.interpretPAC=function(t,i){var n,r={color:null,italics:!1,indent:null,underline:!1,row:t};return r.underline=1==(1&(n=i>95?i-96:i-64)),n<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(n/2)]:n<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((n-16)/2),r},i.parseChars=function(t,i){var n,e,s=null,o=null;if(t>=25?(n=2,o=t-8):(n=1,o=t),o>=17&&o<=19?(this.logger.log(r.INFO,"Special char '"+a(e=17===o?i+80:18===o?i+112:i+144)+"' in channel "+n),s=[e]):t>=32&&t<=127&&(s=0===i?[t]:[t,i]),s){var h=m(s);this.logger.log(r.DEBUG,"Char codes = "+h.join(",")),k(t,i,this.cmdHistory)}return s},i.parseBackgroundAttributes=function(t,i){var n;if(!((16===t||24===t)&&i>=32&&i<=47||(23===t||31===t)&&i>=45&&i<=47))return!1;var r={};return 16===t||24===t?(n=Math.floor((i-32)/2),r.background=v[n],i%2==1&&(r.background=r.background+"_semi")):45===i?r.background="transparent":(r.foreground="black",47===i&&(r.underline=!0)),this.channels[t<=23?1:2].setBkgData(r),k(t,i,this.cmdHistory),!0},i.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var i=this.channels[t];i&&i.reset()}this.cmdHistory={a:null,b:null}},i.cueSplitAtTime=function(t){for(var i=0;i<this.channels.length;i++){var n=this.channels[i];n&&n.cueSplitAtTime(t)}},t}()},"./src/utils/codecs.ts":
286
286
  /*!*****************************!*\
287
287
  !*** ./src/utils/codecs.ts ***!
288
288
  \*****************************/
289
- /*! exports provided: isCodecType, isCodecSupportedInMp4 */function(t,i,r){r.r(i);r.d(i,"isCodecType",(function(){return n}));r.d(i,"isCodecSupportedInMp4",(function(){return s}));var e={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,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,dvav: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}};function n(t,i){var r=e[i];return!!r&&r[t.slice(0,4)]===true}function s(t,i){return MediaSource.isTypeSupported((i||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
289
+ /*! exports provided: isCodecType, isCodecSupportedInMp4 */function(t,i,n){n.r(i),n.d(i,"isCodecType",(function(){return e})),n.d(i,"isCodecSupportedInMp4",(function(){return s}));var r={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function e(t,i){var n=r[i];return!!n&&!0===n[t.slice(0,4)]}function s(t,i){return MediaSource.isTypeSupported((i||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
290
290
  /*!***************************!*\
291
291
  !*** ./src/utils/cues.ts ***!
292
292
  \***************************/
293
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ./vttparser */"./src/utils/vttparser.ts");var n=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");var s=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts");var a=/\s/;var u={newCue:function t(i,r,u,f){var h=[];var o;var v;var l;var c;var d;var m=self.VTTCue||self.TextTrackCue;for(var p=0;p<f.rows.length;p++){o=f.rows[p];l=true;c=0;d="";if(!o.isEmpty()){for(var g=0;g<o.chars.length;g++){if(a.test(o.chars[g].uchar)&&l){c++}else{d+=o.chars[g].uchar;l=false}}o.cueStartTime=r;if(r===u){u+=1e-4}if(c>=16){c--}else{c++}var b=Object(e["fixLineBreaks"])(d.trim());var y=Object(n["generateCueId"])(r,u,b);if(!i||!i.cues||!i.cues.getCueById(y)){v=new m(r,u,b);v.id=y;v.line=p+1;v.align="left";v.position=10+Math.min(80,Math.floor(c*8/32)*10);h.push(v)}}}if(i&&h.length){h.sort((function(t,i){if(t.line==="auto"||i.line==="auto"){return 0}if(t.line>8&&i.line>8){return i.line-t.line}return t.line-i.line}));h.forEach((function(t){return Object(s["addCueToTrack"])(i,t)}))}return h}};i["default"]=u},"./src/utils/discontinuities.ts":
293
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./vttparser */"./src/utils/vttparser.ts"),e=n(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),s=n(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),a=/\s/;i.default={newCue:function(t,i,n,o){for(var h,u,c,f,l,v=[],d=self.VTTCue||self.TextTrackCue,m=0;m<o.rows.length;m++)if(c=!0,f=0,l="",!(h=o.rows[m]).isEmpty()){for(var p=0;p<h.chars.length;p++)a.test(h.chars[p].uchar)&&c?f++:(l+=h.chars[p].uchar,c=!1);h.cueStartTime=i,i===n&&(n+=1e-4),f>=16?f--:f++;var g=Object(r.fixLineBreaks)(l.trim()),b=Object(e.generateCueId)(i,n,g);t&&t.cues&&t.cues.getCueById(b)||((u=new d(i,n,g)).id=b,u.line=m+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*f/32)),v.push(u))}return t&&v.length&&(v.sort((function(t,i){return"auto"===t.line||"auto"===i.line?0:t.line>8&&i.line>8?i.line-t.line:t.line-i.line})),v.forEach((function(i){return Object(s.addCueToTrack)(t,i)}))),v}}},"./src/utils/discontinuities.ts":
294
294
  /*!**************************************!*\
295
295
  !*** ./src/utils/discontinuities.ts ***!
296
296
  \**************************************/
297
- /*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT, alignFragmentByPDTDelta, alignMediaPlaylistByPDT */function(t,i,r){r.r(i);r.d(i,"findFirstFragWithCC",(function(){return a}));r.d(i,"shouldAlignOnDiscontinuities",(function(){return u}));r.d(i,"findDiscontinuousReferenceFrag",(function(){return f}));r.d(i,"adjustSlidingStart",(function(){return o}));r.d(i,"alignStream",(function(){return v}));r.d(i,"alignPDT",(function(){return c}));r.d(i,"alignFragmentByPDTDelta",(function(){return d}));r.d(i,"alignMediaPlaylistByPDT",(function(){return m}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./logger */"./src/utils/logger.ts");var s=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function a(t,i){var r=null;for(var e=0,n=t.length;e<n;e++){var s=t[e];if(s&&s.cc===i){r=s;break}}return r}function u(t,i,r){if(i.details){if(r.endCC>r.startCC||t&&t.cc<r.startCC){return true}}return false}function f(t,i){var r=t.fragments;var e=i.fragments;if(!e.length||!r.length){n["logger"].log("No fragments to align");return}var s=a(r,e[0].cc);if(!s||s&&!s.startPTS){n["logger"].log("No frag in previous level to align on");return}return s}function h(t,i){if(t){var r=t.start+i;t.start=t.startPTS=r;t.endPTS=r+t.duration}}function o(t,i){var r=i.fragments;for(var e=0,n=r.length;e<n;e++){h(r[e],t)}if(i.fragmentHint){h(i.fragmentHint,t)}i.alignedSliding=true}function v(t,i,r){if(!i){return}l(t,r,i);if(!r.alignedSliding&&i.details){c(r,i.details)}if(!r.alignedSliding&&i.details&&!r.skippedSegments){Object(s["adjustSliding"])(i.details,r)}}function l(t,i,r){if(u(t,r,i)){var s=f(r.details,i);if(s&&Object(e["isFiniteNumber"])(s.start)){n["logger"].log("Adjusting PTS using last level due to CC increase within current level "+i.url);o(s.start,i)}}}function c(t,i){if(!i.fragments.length||!t.hasProgramDateTime||!i.hasProgramDateTime){return}var r=i.fragments[0].programDateTime;var s=t.fragments[0].programDateTime;var a=(s-r)/1e3+i.fragments[0].start;if(a&&Object(e["isFiniteNumber"])(a)){n["logger"].log("Adjusting PTS using programDateTime delta "+(s-r)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" ");o(a,t)}}function d(t,i){var r=t.programDateTime;if(!r)return;var e=(r-i)/1e3;t.start=t.startPTS=e;t.endPTS=e+t.duration}function m(t,i){if(!i.fragments.length||!t.hasProgramDateTime||!i.hasProgramDateTime){return}var r=i.fragments[0].programDateTime;var e=i.fragments[0].start;var n=r-e*1e3;t.fragments.forEach((function(t){d(t,n)}));if(t.fragmentHint){d(t.fragmentHint,n)}t.alignedSliding=true}},"./src/utils/ewma-bandwidth-estimator.ts":
297
+ /*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT, alignFragmentByPDTDelta, alignMediaPlaylistByPDT */function(t,i,n){n.r(i),n.d(i,"findFirstFragWithCC",(function(){return a})),n.d(i,"shouldAlignOnDiscontinuities",(function(){return o})),n.d(i,"findDiscontinuousReferenceFrag",(function(){return h})),n.d(i,"adjustSlidingStart",(function(){return c})),n.d(i,"alignStream",(function(){return f})),n.d(i,"alignPDT",(function(){return l})),n.d(i,"alignFragmentByPDTDelta",(function(){return v})),n.d(i,"alignMediaPlaylistByPDT",(function(){return d}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./logger */"./src/utils/logger.ts"),s=n(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function a(t,i){for(var n=null,r=0,e=t.length;r<e;r++){var s=t[r];if(s&&s.cc===i){n=s;break}}return n}function o(t,i,n){return!(!i.details||!(n.endCC>n.startCC||t&&t.cc<n.startCC))}function h(t,i){var n=t.fragments,r=i.fragments;if(r.length&&n.length){var s=a(n,r[0].cc);if(s&&(!s||s.startPTS))return s;e.logger.log("No frag in previous level to align on")}else e.logger.log("No fragments to align")}function u(t,i){if(t){var n=t.start+i;t.start=t.startPTS=n,t.endPTS=n+t.duration}}function c(t,i){for(var n=i.fragments,r=0,e=n.length;r<e;r++)u(n[r],t);i.fragmentHint&&u(i.fragmentHint,t),i.alignedSliding=!0}function f(t,i,n){i&&(function(t,i,n){if(o(t,n,i)){var s=h(n.details,i);s&&Object(r.isFiniteNumber)(s.start)&&(e.logger.log("Adjusting PTS using last level due to CC increase within current level "+i.url),c(s.start,i))}}(t,n,i),!n.alignedSliding&&i.details&&l(n,i.details),n.alignedSliding||!i.details||n.skippedSegments||Object(s.adjustSliding)(i.details,n))}function l(t,i){if(i.fragments.length&&t.hasProgramDateTime&&i.hasProgramDateTime){var n=i.fragments[0].programDateTime,s=t.fragments[0].programDateTime,a=(s-n)/1e3+i.fragments[0].start;a&&Object(r.isFiniteNumber)(a)&&(e.logger.log("Adjusting PTS using programDateTime delta "+(s-n)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" "),c(a,t))}}function v(t,i){var n=t.programDateTime;if(n){var r=(n-i)/1e3;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function d(t,i){if(i.fragments.length&&t.hasProgramDateTime&&i.hasProgramDateTime){var n=i.fragments[0].programDateTime-1e3*i.fragments[0].start;t.fragments.forEach((function(t){v(t,n)})),t.fragmentHint&&v(t.fragmentHint,n),t.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":
298
298
  /*!***********************************************!*\
299
299
  !*** ./src/utils/ewma-bandwidth-estimator.ts ***!
300
300
  \***********************************************/
301
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../utils/ewma */"./src/utils/ewma.ts");var n=function(){function t(t,i,r){this.defaultEstimate_=void 0;this.minWeight_=void 0;this.minDelayMs_=void 0;this.slow_=void 0;this.fast_=void 0;this.defaultEstimate_=r;this.minWeight_=.001;this.minDelayMs_=50;this.slow_=new e["default"](t);this.fast_=new e["default"](i)}var i=t.prototype;i.update=function t(i,r){var n=this.slow_,s=this.fast_;if(this.slow_.halfLife!==i){this.slow_=new e["default"](i,n.getEstimate(),n.getTotalWeight())}if(this.fast_.halfLife!==r){this.fast_=new e["default"](r,s.getEstimate(),s.getTotalWeight())}};i.sample=function t(i,r){i=Math.max(i,this.minDelayMs_);var e=8*r;var n=i/1e3;var s=e/n;this.fast_.sample(n,s);this.slow_.sample(n,s)};i.canEstimate=function t(){var i=this.fast_;return i&&i.getTotalWeight()>=this.minWeight_};i.getEstimate=function t(){if(this.canEstimate()){return Math.min(this.fast_.getEstimate(),this.slow_.getEstimate())}else{return this.defaultEstimate_}};i.destroy=function t(){};return t}();i["default"]=n},"./src/utils/ewma.ts":
301
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../utils/ewma */"./src/utils/ewma.ts");i.default=function(){function t(t,i,n){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new r.default(t),this.fast_=new r.default(i)}var i=t.prototype;return i.update=function(t,i){var n=this.slow_,e=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new r.default(t,n.getEstimate(),n.getTotalWeight())),this.fast_.halfLife!==i&&(this.fast_=new r.default(i,e.getEstimate(),e.getTotalWeight()))},i.sample=function(t,i){var n=(t=Math.max(t,this.minDelayMs_))/1e3,r=8*i/n;this.fast_.sample(n,r),this.slow_.sample(n,r)},i.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},i.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},i.destroy=function(){},t}()},"./src/utils/ewma.ts":
302
302
  /*!***************************!*\
303
303
  !*** ./src/utils/ewma.ts ***!
304
304
  \***************************/
305
- /*! exports provided: default */function(t,i,r){r.r(i);var e=function(){function t(t,i,r){if(i===void 0){i=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=t;this.alpha_=t?Math.exp(Math.log(.5)/t):0;this.estimate_=i;this.totalWeight_=r}var i=t.prototype;i.sample=function t(i,r){var e=Math.pow(this.alpha_,i);this.estimate_=r*(1-e)+e*this.estimate_;this.totalWeight_+=i};i.getTotalWeight=function t(){return this.totalWeight_};i.getEstimate=function t(){if(this.alpha_){var i=1-Math.pow(this.alpha_,this.totalWeight_);if(i){return this.estimate_/i}}return this.estimate_};return t}();i["default"]=e},"./src/utils/fetch-loader.ts":
305
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default=function(){function t(t,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=i,this.totalWeight_=n}var i=t.prototype;return i.sample=function(t,i){var n=Math.pow(this.alpha_,t);this.estimate_=i*(1-n)+n*this.estimate_,this.totalWeight_+=t},i.getTotalWeight=function(){return this.totalWeight_},i.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}()},"./src/utils/fetch-loader.ts":
306
306
  /*!***********************************!*\
307
307
  !*** ./src/utils/fetch-loader.ts ***!
308
308
  \***********************************/
309
- /*! exports provided: fetchSupported, default */function(t,i,r){r.r(i);r.d(i,"fetchSupported",(function(){return d}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts");var s=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function a(t,i){t.prototype=Object.create(i.prototype);t.prototype.constructor=t;v(t,i)}function u(t){var i=typeof Map==="function"?new Map:undefined;u=function t(r){if(r===null||!o(r))return r;if(typeof r!=="function"){throw new TypeError("Super expression must either be null or a function")}if(typeof i!=="undefined"){if(i.has(r))return i.get(r);i.set(r,e)}function e(){return f(r,arguments,l(this).constructor)}e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});return v(e,r)};return u(t)}function f(t,i,r){if(h()){f=Reflect.construct}else{f=function t(i,r,e){var n=[null];n.push.apply(n,r);var s=Function.bind.apply(i,n);var a=new s;if(e)v(a,e.prototype);return a}}return f.apply(null,arguments)}function h(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));return true}catch(t){return false}}function o(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function v(t,i){v=Object.setPrototypeOf||function t(i,r){i.__proto__=r;return i};return v(t,i)}function l(t){l=Object.setPrototypeOf?Object.getPrototypeOf:function t(i){return i.__proto__||Object.getPrototypeOf(i)};return l(t)}function c(){c=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return c.apply(this,arguments)}function d(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request){try{new self.ReadableStream({});return true}catch(t){}}return false}var m=function(){function t(t){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=t.fetchSetup||g;this.controller=new self.AbortController;this.stats=new n["LoadStats"]}var i=t.prototype;i.destroy=function t(){this.loader=this.callbacks=null;this.abortInternal()};i.abortInternal=function t(){var i=this.response;if(!i||!i.ok){this.stats.aborted=true;this.controller.abort()}};i.abort=function t(){var i;this.abortInternal();if((i=this.callbacks)!==null&&i!==void 0&&i.onAbort){this.callbacks.onAbort(this.stats,this.context,this.response)}};i.load=function t(i,r,n){var s=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 u=p(i,this.controller.signal);var f=n.onProgress;var h=i.responseType==="arraybuffer";var o=h?"byteLength":"length";this.context=i;this.config=r;this.callbacks=n;this.request=this.fetchSetup(i,u);self.clearTimeout(this.requestTimeout);this.requestTimeout=self.setTimeout((function(){s.abortInternal();n.onTimeout(a,i,s.response)}),r.timeout);self.fetch(this.request).then((function(t){s.response=s.loader=t;if(!t.ok){var n=t.status,u=t.statusText;throw new b(u||"fetch, bad network response",n,t)}a.loading.first=Math.max(self.performance.now(),a.loading.start);a.total=parseInt(t.headers.get("Content-Length")||"0");if(f&&Object(e["isFiniteNumber"])(r.highWaterMark)){return s.loadProgressively(t,a,i,r.highWaterMark,f)}if(h){return t.arrayBuffer()}return t.text()})).then((function(t){var u=s.response;self.clearTimeout(s.requestTimeout);a.loading.end=Math.max(self.performance.now(),a.loading.first);a.loaded=a.total=t[o];var h={url:u.url,data:t};if(f&&!Object(e["isFiniteNumber"])(r.highWaterMark)){f(a,i,t,u)}n.onSuccess(h,a,i,u)})).catch((function(t){self.clearTimeout(s.requestTimeout);if(a.aborted){return}var r=t.code||0;n.onError({code:r,text:t.message},i,t.details)}))};i.getCacheAge=function t(){var i=null;if(this.response){var r=this.response.headers.get("age");i=r?parseFloat(r):null}return i};i.loadProgressively=function t(i,r,e,n,a){if(n===void 0){n=0}var u=new s["default"];var f=i.body.getReader();var h=function t(){return f.read().then((function(s){if(s.done){if(u.dataLength){a(r,e,u.flush(),i)}return Promise.resolve(new ArrayBuffer(0))}var f=s.value;var h=f.length;r.loaded+=h;if(h<n||u.dataLength){u.push(f);if(u.dataLength>=n){a(r,e,u.flush(),i)}}else{a(r,e,f,i)}return t()})).catch((function(){return Promise.reject()}))};return h()};return t}();function p(t,i){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:i,headers:new self.Headers(c({},t.headers))};if(t.rangeEnd){r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1))}return r}function g(t,i){return new self.Request(t.url,i)}var b=function(t){a(i,t);function i(i,r,e){var n;n=t.call(this,i)||this;n.code=void 0;n.details=void 0;n.code=r;n.details=e;return n}return i}(u(Error));i["default"]=m},"./src/utils/imsc1-ttml-parser.ts":
309
+ /*! exports provided: fetchSupported, default */function(t,i,n){n.r(i),n.d(i,"fetchSupported",(function(){return l}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=n(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function a(t){var i="function"==typeof Map?new Map:void 0;return a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,n)}function n(){return o(t,arguments,c(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,t)},a(t)}function o(t,i,n){return o=h()?Reflect.construct:function(t,i,n){var r=[null];r.push.apply(r,i);var e=new(Function.bind.apply(t,r));return n&&u(e,n.prototype),e},o.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,i){return u=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},u(t,i)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function f(){return f=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f.apply(this,arguments)}function l(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}var v=function(){function t(t){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=t.fetchSetup||d,this.controller=new self.AbortController,this.stats=new e.LoadStats}var i=t.prototype;return i.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},i.abortInternal=function(){var t=this.response;t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},i.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},i.load=function(t,i,n){var e=this,s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();var a=function(t,i){var n={method:"GET",mode:"cors",credentials:"same-origin",signal:i,headers:new self.Headers(f({},t.headers))};return t.rangeEnd&&n.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),n}(t,this.controller.signal),o=n.onProgress,h="arraybuffer"===t.responseType,u=h?"byteLength":"length";this.context=t,this.config=i,this.callbacks=n,this.request=this.fetchSetup(t,a),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){e.abortInternal(),n.onTimeout(s,t,e.response)}),i.timeout),self.fetch(this.request).then((function(n){if(e.response=e.loader=n,!n.ok)throw new m(n.statusText||"fetch, bad network response",n.status,n);return s.loading.first=Math.max(self.performance.now(),s.loading.start),s.total=parseInt(n.headers.get("Content-Length")||"0"),o&&Object(r.isFiniteNumber)(i.highWaterMark)?e.loadProgressively(n,s,t,i.highWaterMark,o):h?n.arrayBuffer():n.text()})).then((function(a){var h=e.response;self.clearTimeout(e.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first),s.loaded=s.total=a[u];var c={url:h.url,data:a};o&&!Object(r.isFiniteNumber)(i.highWaterMark)&&o(s,t,a,h),n.onSuccess(c,s,t,h)})).catch((function(i){self.clearTimeout(e.requestTimeout),s.aborted||n.onError({code:i.code||0,text:i.message},t,i.details)}))},i.getCacheAge=function(){var t=null;if(this.response){var i=this.response.headers.get("age");t=i?parseFloat(i):null}return t},i.loadProgressively=function(t,i,n,r,e){void 0===r&&(r=0);var a=new s.default,o=t.body.getReader();return function s(){return o.read().then((function(o){if(o.done)return a.dataLength&&e(i,n,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var h=o.value,u=h.length;return i.loaded+=u,u<r||a.dataLength?(a.push(h),a.dataLength>=r&&e(i,n,a.flush(),t)):e(i,n,h,t),s()})).catch((function(){return Promise.reject()}))}()},t}();function d(t,i){return new self.Request(t.url,i)}var m=function(t){var i,n;function r(i,n,r){var e;return(e=t.call(this,i)||this).code=void 0,e.details=void 0,e.code=n,e.details=r,e}return n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,u(i,n),r}(a(Error));i.default=v},"./src/utils/imsc1-ttml-parser.ts":
310
310
  /*!****************************************!*\
311
311
  !*** ./src/utils/imsc1-ttml-parser.ts ***!
312
312
  \****************************************/
313
- /*! exports provided: IMSC1_CODEC, parseIMSC1 */function(t,i,r){r.r(i);r.d(i,"IMSC1_CODEC",(function(){return o}));r.d(i,"parseIMSC1",(function(){return d}));var e=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts");var n=r(/*! ./vttparser */"./src/utils/vttparser.ts");var s=r(/*! ./vttcue */"./src/utils/vttcue.ts");var a=r(/*! ../demux/id3 */"./src/demux/id3.ts");var u=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts");var f=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function h(){h=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var e in r){if(Object.prototype.hasOwnProperty.call(r,e)){t[e]=r[e]}}}return t};return h.apply(this,arguments)}var o="stpp.ttml.im1t";var v=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/;var l=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/;var c={left:"start",center:"center",right:"end",start:"start",end:"end"};function d(t,i,r,n,s){var f=Object(e["findBox"])(new Uint8Array(t),["mdat"]);if(f.length===0){s(new Error("Could not parse IMSC1 mdat"));return}var h=f[0];var o=Object(a["utf8ArrayToStr"])(new Uint8Array(t,h.start,h.end-h.start));var v=Object(u["toTimescaleFromScale"])(i,1,r);try{n(m(o,v))}catch(t){s(t)}}function m(t,i){var r=new DOMParser;var e=r.parseFromString(t,"text/xml");var n=e.getElementsByTagName("tt")[0];if(!n){throw new Error("Invalid ttml")}var a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0};var u=Object.keys(a).reduce((function(t,i){t[i]=n.getAttribute("ttp:"+i)||a[i];return t}),{});var o=n.getAttribute("xml:space")!=="preserve";var v=g(p(n,"styling","style"));var l=g(p(n,"layout","region"));var d=p(n,"body","[begin]");return[].map.call(d,(function(t){var r=b(t,o);if(!r||!t.hasAttribute("begin")){return null}var e=T(t.getAttribute("begin"),u);var n=T(t.getAttribute("dur"),u);var a=T(t.getAttribute("end"),u);if(e===null){throw k(t)}if(a===null){if(n===null){throw k(t)}a=e+n}var d=new s["default"](e-i,a-i,r);d.id=Object(f["generateCueId"])(d.startTime,d.endTime,d.text);var m=l[t.getAttribute("region")];var p=v[t.getAttribute("style")];d.position=10;d.size=80;var g=y(m,p);var w=g.textAlign;if(w){var O=c[w];if(O){d.lineAlign=O}d.align=w}h(d,g);return d})).filter((function(t){return t!==null}))}function p(t,i,r){var e=t.getElementsByTagName(i)[0];if(e){return[].slice.call(e.querySelectorAll(r))}return[]}function g(t){return t.reduce((function(t,i){var r=i.getAttribute("xml:id");if(r){t[r]=i}return t}),{})}function b(t,i){return[].slice.call(t.childNodes).reduce((function(t,r,e){var n;if(r.nodeName==="br"&&e){return t+"\n"}if((n=r.childNodes)!==null&&n!==void 0&&n.length){return b(r,i)}else if(i){return t+r.textContent.trim().replace(/\s+/g," ")}return t+r.textContent}),"")}function y(t,i){var r="http://www.w3.org/ns/ttml#styling";var e=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return e.reduce((function(e,n){var s=w(i,r,n)||w(t,r,n);if(s){e[n]=s}return e}),{})}function w(t,i,r){return t.hasAttributeNS(i,r)?t.getAttributeNS(i,r):null}function k(t){return new Error("Could not parse ttml timestamp "+t)}function T(t,i){if(!t){return null}var r=Object(n["parseTimeStamp"])(t);if(r===null){if(v.test(t)){r=O(t,i)}else if(l.test(t)){r=S(t,i)}}return r}function O(t,i){var r=v.exec(t);var e=(r[4]|0)+(r[5]|0)/i.subFrameRate;return(r[1]|0)*3600+(r[2]|0)*60+(r[3]|0)+e/i.frameRate}function S(t,i){var r=l.exec(t);var e=Number(r[1]);var n=r[2];switch(n){case"h":return e*3600;case"m":return e*60;case"ms":return e*1e3;case"f":return e/i.frameRate;case"t":return e/i.tickRate}return e}},"./src/utils/logger.ts":
313
+ /*! exports provided: IMSC1_CODEC, parseIMSC1 */function(t,i,n){n.r(i),n.d(i,"IMSC1_CODEC",(function(){return c})),n.d(i,"parseIMSC1",(function(){return d}));var r=n(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),e=n(/*! ./vttparser */"./src/utils/vttparser.ts"),s=n(/*! ./vttcue */"./src/utils/vttcue.ts"),a=n(/*! ../demux/id3 */"./src/demux/id3.ts"),o=n(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),h=n(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return u=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},u.apply(this,arguments)}var c="stpp.ttml.im1t",f=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,l=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,v={left:"start",center:"center",right:"end",start:"start",end:"end"};function d(t,i,n,e,c){var f=Object(r.findBox)(new Uint8Array(t),["mdat"]);if(0!==f.length){var l=f[0],d=Object(a.utf8ArrayToStr)(new Uint8Array(t,l.start,l.end-l.start)),k=Object(o.toTimescaleFromScale)(i,1,n);try{e(function(t,i){var n=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");var r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},e=Object.keys(r).reduce((function(t,i){return t[i]=n.getAttribute("ttp:"+i)||r[i],t}),{}),a="preserve"!==n.getAttribute("xml:space"),o=p(m(n,"styling","style")),c=p(m(n,"layout","region")),f=m(n,"body","[begin]");return[].map.call(f,(function(t){var n=g(t,a);if(!n||!t.hasAttribute("begin"))return null;var r=w(t.getAttribute("begin"),e),f=w(t.getAttribute("dur"),e),l=w(t.getAttribute("end"),e);if(null===r)throw y(t);if(null===l){if(null===f)throw y(t);l=r+f}var d=new s.default(r-i,l-i,n);d.id=Object(h.generateCueId)(d.startTime,d.endTime,d.text);var m=c[t.getAttribute("region")],p=o[t.getAttribute("style")];d.position=10,d.size=80;var k=function(t,i){var n="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(r,e){var s=b(i,n,e)||b(t,n,e);return s&&(r[e]=s),r}),{})}(m,p),T=k.textAlign;if(T){var O=v[T];O&&(d.lineAlign=O),d.align=T}return u(d,k),d})).filter((function(t){return null!==t}))}(d,k))}catch(t){c(t)}}else c(new Error("Could not parse IMSC1 mdat"))}function m(t,i,n){var r=t.getElementsByTagName(i)[0];return r?[].slice.call(r.querySelectorAll(n)):[]}function p(t){return t.reduce((function(t,i){var n=i.getAttribute("xml:id");return n&&(t[n]=i),t}),{})}function g(t,i){return[].slice.call(t.childNodes).reduce((function(t,n,r){var e;return"br"===n.nodeName&&r?t+"\n":null!==(e=n.childNodes)&&void 0!==e&&e.length?g(n,i):i?t+n.textContent.trim().replace(/\s+/g," "):t+n.textContent}),"")}function b(t,i,n){return t.hasAttributeNS(i,n)?t.getAttributeNS(i,n):null}function y(t){return new Error("Could not parse ttml timestamp "+t)}function w(t,i){if(!t)return null;var n=Object(e.parseTimeStamp)(t);return null===n&&(f.test(t)?n=function(t,i){var n=f.exec(t);return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+((0|n[4])+(0|n[5])/i.subFrameRate)/i.frameRate}(t,i):l.test(t)&&(n=function(t,i){var n=l.exec(t),r=Number(n[1]);switch(n[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/i.frameRate;case"t":return r/i.tickRate}return r}(t,i))),n}},"./src/utils/logger.ts":
314
314
  /*!*****************************!*\
315
315
  !*** ./src/utils/logger.ts ***!
316
316
  \*****************************/
317
- /*! exports provided: enableLogs, logger */function(t,i,r){r.r(i);r.d(i,"enableLogs",(function(){return f}));r.d(i,"logger",(function(){return h}));var e=function t(){};var n={trace:e,debug:e,log:e,warn:e,info:e,error:e};var s=n;function a(t){var i=self.console[t];if(i){return i.bind(self.console,"["+t+"] >")}return e}function u(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),e=1;e<i;e++){r[e-1]=arguments[e]}r.forEach((function(i){s[i]=t[i]?t[i].bind(t):a(i)}))}function f(t){if(self.console&&t===true||typeof t==="object"){u(t,"debug","log","info","warn","error");try{s.log()}catch(t){s=n}}else{s=n}}var h=s},"./src/utils/mediakeys-helper.ts":
317
+ /*! exports provided: enableLogs, logger */function(t,i,n){n.r(i),n.d(i,"enableLogs",(function(){return o})),n.d(i,"logger",(function(){return h}));var r=function(){},e={trace:r,debug:r,log:r,warn:r,info:r,error:r},s=e;function a(t){var i=self.console[t];return i?i.bind(self.console,"["+t+"] >"):r}function o(t){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];n.forEach((function(i){s[i]=t[i]?t[i].bind(t):a(i)}))}(t,"debug","log","info","warn","error");try{s.log()}catch(t){s=e}}else s=e}var h=e},"./src/utils/mediakeys-helper.ts":
318
318
  /*!***************************************!*\
319
319
  !*** ./src/utils/mediakeys-helper.ts ***!
320
320
  \***************************************/
321
- /*! exports provided: KeySystems, requestMediaKeySystemAccess */function(t,i,r){r.r(i);r.d(i,"KeySystems",(function(){return e}));r.d(i,"requestMediaKeySystemAccess",(function(){return n}));var e;(function(t){t["WIDEVINE"]="com.widevine.alpha";t["PLAYREADY"]="com.microsoft.playready"})(e||(e={}));var n=function(){if(typeof self!=="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess){return self.navigator.requestMediaKeySystemAccess.bind(self.navigator)}else{return null}}()},"./src/utils/mediasource-helper.ts":
321
+ /*! exports provided: KeySystems, requestMediaKeySystemAccess */function(t,i,n){var r;n.r(i),n.d(i,"KeySystems",(function(){return r})),n.d(i,"requestMediaKeySystemAccess",(function(){return e})),function(t){t.WIDEVINE="com.widevine.alpha",t.PLAYREADY="com.microsoft.playready"}(r||(r={}));var e="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":
322
322
  /*!*****************************************!*\
323
323
  !*** ./src/utils/mediasource-helper.ts ***!
324
324
  \*****************************************/
325
- /*! exports provided: getMediaSource */function(t,i,r){r.r(i);r.d(i,"getMediaSource",(function(){return e}));function e(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":
325
+ /*! exports provided: getMediaSource */function(t,i,n){function r(){return self.MediaSource||self.WebKitMediaSource}n.r(i),n.d(i,"getMediaSource",(function(){return r}))},"./src/utils/mp4-tools.ts":
326
326
  /*!********************************!*\
327
327
  !*** ./src/utils/mp4-tools.ts ***!
328
328
  \********************************/
329
- /*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(t,i,r){r.r(i);r.d(i,"bin2str",(function(){return u}));r.d(i,"readUint16",(function(){return f}));r.d(i,"readUint32",(function(){return h}));r.d(i,"writeUint32",(function(){return o}));r.d(i,"findBox",(function(){return v}));r.d(i,"parseSegmentIndex",(function(){return l}));r.d(i,"parseInitSegment",(function(){return c}));r.d(i,"getStartDTS",(function(){return d}));r.d(i,"getDuration",(function(){return m}));r.d(i,"computeRawDurationFromSamples",(function(){return p}));r.d(i,"offsetStartDTS",(function(){return g}));r.d(i,"segmentValidRange",(function(){return b}));r.d(i,"appendUint8Array",(function(){return y}));var e=r(/*! ./typed-array */"./src/utils/typed-array.ts");var n=r(/*! ../loader/fragment */"./src/loader/fragment.ts");var s=Math.pow(2,32)-1;var a=[].push;function u(t){return String.fromCharCode.apply(null,t)}function f(t,i){if("data"in t){i+=t.start;t=t.data}var r=t[i]<<8|t[i+1];return r<0?65536+r:r}function h(t,i){if("data"in t){i+=t.start;t=t.data}var r=t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3];return r<0?4294967296+r:r}function o(t,i,r){if("data"in t){i+=t.start;t=t.data}t[i]=r>>24;t[i+1]=r>>16&255;t[i+2]=r>>8&255;t[i+3]=r&255}function v(t,i){var r=[];if(!i.length){return r}var e;var n;var s;if("data"in t){e=t.data;n=t.start;s=t.end}else{e=t;n=0;s=e.byteLength}for(var f=n;f<s;){var o=h(e,f);var l=u(e.subarray(f+4,f+8));var c=o>1?f+o:s;if(l===i[0]){if(i.length===1){r.push({data:e,start:f+8,end:c})}else{var d=v({data:e,start:f+8,end:c},i.slice(1));if(d.length){a.apply(r,d)}}}f=c}return r}function l(t){var i=v(t,["moov"]);var r=i[0];var e=r?r.end:null;var n=v(t,["sidx"]);if(!n||!n[0]){return null}var s=[];var a=n[0];var u=a.data[0];var o=u===0?8:16;var l=h(a,o);o+=4;var c=0;var d=0;if(u===0){o+=8}else{o+=16}o+=2;var m=a.end+d;var p=f(a,o);o+=2;for(var g=0;g<p;g++){var b=o;var y=h(a,b);b+=4;var w=y&2147483647;var k=(y&2147483648)>>>31;if(k===1){console.warn("SIDX has hierarchical references (not supported)");return null}var T=h(a,b);b+=4;s.push({referenceSize:w,subsegmentDuration:T,info:{duration:T/l,start:m,end:m+w-1}});m+=w;b+=4;o=b}return{earliestPresentationTime:c,timescale:l,version:u,referencesCount:p,references:s,moovEndOffset:e}}function c(t){var i=[];var r=v(t,["moov","trak"]);for(var e=0;e<r.length;e++){var s=r[e];var a=v(s,["tkhd"])[0];if(a){var f=a.data[a.start];var o=f===0?12:20;var l=h(a,o);var c=v(s,["mdia","mdhd"])[0];if(c){f=c.data[c.start];o=f===0?12:20;var d=h(c,o);var m=v(s,["mdia","hdlr"])[0];if(m){var p=u(m.data.subarray(m.start+8,m.start+12));var g={soun:n["ElementaryStreamTypes"].AUDIO,vide:n["ElementaryStreamTypes"].VIDEO}[p];if(g){var b=v(s,["mdia","minf","stbl","stsd"])[0];var y=void 0;if(b){y=u(b.data.subarray(b.start+12,b.start+16))}i[l]={timescale:d,type:g};i[g]={timescale:d,id:l,codec:y}}}}}}var w=v(t,["moov","mvex","trex"]);w.forEach((function(t){var r=h(t,4);var e=i[r];if(e){e.default={duration:h(t,12),flags:h(t,20)}}}));return i}function d(t,i){return v(i,["moof","traf"]).reduce((function(i,r){var e=v(r,["tfdt"])[0];var n=e.data[e.start];var s=v(r,["tfhd"]).reduce((function(i,r){var s=h(r,4);var a=t[s];if(a){var u=h(e,4);if(n===1){u*=Math.pow(2,32);u+=h(e,8)}var f=a.timescale||9e4;var o=u/f;if(isFinite(o)&&(i===null||o<i)){return o}}return i}),null);if(s!==null&&isFinite(s)&&(i===null||s<i)){return s}return i}),null)||0}function m(t,i){var r=0;var e=0;var s=0;var a=v(t,["moof","traf"]);for(var u=0;u<a.length;u++){var f=a[u];var o=v(f,["tfhd"])[0];var c=h(o,4);var d=i[c];if(!d){continue}var m=d.default;var g=h(o,0)|(m===null||m===void 0?void 0:m.flags);var b=m===null||m===void 0?void 0:m.duration;if(g&8){if(g&2){b=h(o,12)}else{b=h(o,8)}}var y=d.timescale||9e4;var w=v(f,["trun"]);for(var k=0;k<w.length;k++){r=p(w[k]);if(!r&&b){var T=h(w[k],4);r=b*T}if(d.type===n["ElementaryStreamTypes"].VIDEO){e+=r/y}else if(d.type===n["ElementaryStreamTypes"].AUDIO){s+=r/y}}}if(e===0&&s===0){var O=l(t);if(O!==null&&O!==void 0&&O.references){return O.references.reduce((function(t,i){return t+i.info.duration||0}),0)}}if(e){return e}return s}function p(t){var i=h(t,0);var r=8;if(i&1){r+=4}if(i&4){r+=4}var e=0;var n=h(t,4);for(var s=0;s<n;s++){if(i&256){var a=h(t,r);e+=a;r+=4}if(i&512){r+=4}if(i&1024){r+=4}if(i&2048){r+=4}}return e}function g(t,i,r){v(i,["moof","traf"]).forEach((function(i){v(i,["tfhd"]).forEach((function(e){var n=h(e,4);var a=t[n];if(!a){return}var u=a.timescale||9e4;v(i,["tfdt"]).forEach((function(t){var i=t.data[t.start];var e=h(t,4);if(i===0){o(t,4,e-r*u)}else{e*=Math.pow(2,32);e+=h(t,8);e-=r*u;e=Math.max(e,0);var n=Math.floor(e/(s+1));var a=Math.floor(e%(s+1));o(t,4,n);o(t,8,a)}}))}))}))}function b(t){var i={valid:null,remainder:null};var r=v(t,["moof"]);if(!r){return i}else if(r.length<2){i.remainder=t;return i}var n=r[r.length-1];i.valid=Object(e["sliceUint8"])(t,0,n.start-8);i.remainder=Object(e["sliceUint8"])(t,n.start-8);return i}function y(t,i){var r=new Uint8Array(t.length+i.length);r.set(t);r.set(i,t.length);return r}},"./src/utils/output-filter.ts":
329
+ /*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(t,i,n){n.r(i),n.d(i,"bin2str",(function(){return o})),n.d(i,"readUint16",(function(){return h})),n.d(i,"readUint32",(function(){return u})),n.d(i,"writeUint32",(function(){return c})),n.d(i,"findBox",(function(){return f})),n.d(i,"parseSegmentIndex",(function(){return l})),n.d(i,"parseInitSegment",(function(){return v})),n.d(i,"getStartDTS",(function(){return d})),n.d(i,"getDuration",(function(){return m})),n.d(i,"computeRawDurationFromSamples",(function(){return p})),n.d(i,"offsetStartDTS",(function(){return g})),n.d(i,"segmentValidRange",(function(){return b})),n.d(i,"appendUint8Array",(function(){return y}));var r=n(/*! ./typed-array */"./src/utils/typed-array.ts"),e=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),s=Math.pow(2,32)-1,a=[].push;function o(t){return String.fromCharCode.apply(null,t)}function h(t,i){"data"in t&&(i+=t.start,t=t.data);var n=t[i]<<8|t[i+1];return n<0?65536+n:n}function u(t,i){"data"in t&&(i+=t.start,t=t.data);var n=t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3];return n<0?4294967296+n:n}function c(t,i,n){"data"in t&&(i+=t.start,t=t.data),t[i]=n>>24,t[i+1]=n>>16&255,t[i+2]=n>>8&255,t[i+3]=255&n}function f(t,i){var n,r,e,s=[];if(!i.length)return s;"data"in t?(n=t.data,r=t.start,e=t.end):(r=0,e=(n=t).byteLength);for(var h=r;h<e;){var c=u(n,h),l=c>1?h+c:e;if(o(n.subarray(h+4,h+8))===i[0])if(1===i.length)s.push({data:n,start:h+8,end:l});else{var v=f({data:n,start:h+8,end:l},i.slice(1));v.length&&a.apply(s,v)}h=l}return s}function l(t){var i=f(t,["moov"])[0],n=i?i.end:null,r=f(t,["sidx"]);if(!r||!r[0])return null;var e=[],s=r[0],a=s.data[0],o=0===a?8:16,c=u(s,o);o+=4,o+=0===a?8:16;var l=s.end+0,v=h(s,o+=2);o+=2;for(var d=0;d<v;d++){var m=o,p=u(s,m);m+=4;var g=2147483647&p;if(1==(2147483648&p)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var b=u(s,m);m+=4,e.push({referenceSize:g,subsegmentDuration:b,info:{duration:b/c,start:l,end:l+g-1}}),l+=g,o=m+=4}return{earliestPresentationTime:0,timescale:c,version:a,referencesCount:v,references:e,moovEndOffset:n}}function v(t){for(var i=[],n=f(t,["moov","trak"]),r=0;r<n.length;r++){var s=n[r],a=f(s,["tkhd"])[0];if(a){var h=a.data[a.start],c=0===h?12:20,l=u(a,c),v=f(s,["mdia","mdhd"])[0];if(v){var d=u(v,c=0===(h=v.data[v.start])?12:20),m=f(s,["mdia","hdlr"])[0];if(m){var p=o(m.data.subarray(m.start+8,m.start+12)),g={soun:e.ElementaryStreamTypes.AUDIO,vide:e.ElementaryStreamTypes.VIDEO}[p];if(g){var b=f(s,["mdia","minf","stbl","stsd"])[0],y=void 0;b&&(y=o(b.data.subarray(b.start+12,b.start+16))),i[l]={timescale:d,type:g},i[g]={timescale:d,id:l,codec:y}}}}}}return f(t,["moov","mvex","trex"]).forEach((function(t){var n=u(t,4),r=i[n];r&&(r.default={duration:u(t,12),flags:u(t,20)})})),i}function d(t,i){return f(i,["moof","traf"]).reduce((function(i,n){var r=f(n,["tfdt"])[0],e=r.data[r.start],s=f(n,["tfhd"]).reduce((function(i,n){var s=u(n,4),a=t[s];if(a){var o=u(r,4);1===e&&(o*=Math.pow(2,32),o+=u(r,8));var h=o/(a.timescale||9e4);if(isFinite(h)&&(null===i||h<i))return h}return i}),null);return null!==s&&isFinite(s)&&(null===i||s<i)?s:i}),null)||0}function m(t,i){for(var n=0,r=0,s=0,a=f(t,["moof","traf"]),o=0;o<a.length;o++){var h=a[o],c=f(h,["tfhd"])[0],v=i[u(c,4)];if(v){var d=v.default,m=u(c,0)|(null==d?void 0:d.flags),g=null==d?void 0:d.duration;8&m&&(g=u(c,2&m?12:8));for(var b=v.timescale||9e4,y=f(h,["trun"]),w=0;w<y.length;w++)!(n=p(y[w]))&&g&&(n=g*u(y[w],4)),v.type===e.ElementaryStreamTypes.VIDEO?r+=n/b:v.type===e.ElementaryStreamTypes.AUDIO&&(s+=n/b)}}if(0===r&&0===s){var k=l(t);if(null!=k&&k.references)return k.references.reduce((function(t,i){return t+i.info.duration||0}),0)}return r||s}function p(t){var i=u(t,0),n=8;1&i&&(n+=4),4&i&&(n+=4);for(var r=0,e=u(t,4),s=0;s<e;s++)256&i&&(r+=u(t,n),n+=4),512&i&&(n+=4),1024&i&&(n+=4),2048&i&&(n+=4);return r}function g(t,i,n){f(i,["moof","traf"]).forEach((function(i){f(i,["tfhd"]).forEach((function(r){var e=u(r,4),a=t[e];if(a){var o=a.timescale||9e4;f(i,["tfdt"]).forEach((function(t){var i=t.data[t.start],r=u(t,4);if(0===i)c(t,4,r-n*o);else{r*=Math.pow(2,32),r+=u(t,8),r-=n*o,r=Math.max(r,0);var e=Math.floor(r/(s+1)),a=Math.floor(r%(s+1));c(t,4,e),c(t,8,a)}}))}}))}))}function b(t){var i={valid:null,remainder:null},n=f(t,["moof"]);if(!n)return i;if(n.length<2)return i.remainder=t,i;var e=n[n.length-1];return i.valid=Object(r.sliceUint8)(t,0,e.start-8),i.remainder=Object(r.sliceUint8)(t,e.start-8),i}function y(t,i){var n=new Uint8Array(t.length+i.length);return n.set(t),n.set(i,t.length),n}},"./src/utils/output-filter.ts":
330
330
  /*!************************************!*\
331
331
  !*** ./src/utils/output-filter.ts ***!
332
332
  \************************************/
333
- /*! exports provided: default */function(t,i,r){r.r(i);r.d(i,"default",(function(){return e}));var e=function(){function t(t,i){this.timelineController=void 0;this.cueRanges=[];this.trackName=void 0;this.startTime=null;this.endTime=null;this.screen=null;this.timelineController=t;this.trackName=i}var i=t.prototype;i.dispatchCue=function t(){if(this.startTime===null){return}this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges);this.startTime=null};i.newCue=function t(i,r,e){if(this.startTime===null||this.startTime>i){this.startTime=i}this.endTime=r;this.screen=e;this.timelineController.createCaptionsTrack(this.trackName)};i.reset=function t(){this.cueRanges=[];this.startTime=null};return t}()},"./src/utils/texttrack-utils.ts":
333
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(t,i){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=i}var i=t.prototype;return i.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},i.newCue=function(t,i,n){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=i,this.screen=n,this.timelineController.createCaptionsTrack(this.trackName)},i.reset=function(){this.cueRanges=[],this.startTime=null},t}()},"./src/utils/texttrack-utils.ts":
334
334
  /*!**************************************!*\
335
335
  !*** ./src/utils/texttrack-utils.ts ***!
336
336
  \**************************************/
337
- /*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(t,i,r){r.r(i);r.d(i,"sendAddTrackEvent",(function(){return n}));r.d(i,"addCueToTrack",(function(){return s}));r.d(i,"clearCurrentCues",(function(){return a}));r.d(i,"removeCuesInRange",(function(){return u}));r.d(i,"getCuesInRange",(function(){return h}));var e=r(/*! ./logger */"./src/utils/logger.ts");function n(t,i){var r;try{r=new Event("addtrack")}catch(t){r=document.createEvent("Event");r.initEvent("addtrack",false,false)}r.track=t;i.dispatchEvent(r)}function s(t,i){var r=t.mode;if(r==="disabled"){t.mode="hidden"}if(t.cues&&!t.cues.getCueById(i.id)){try{t.addCue(i);if(!t.cues.getCueById(i.id)){throw new Error("addCue is failed for: "+i)}}catch(r){e["logger"].debug("[texttrack-utils]: "+r);var n=new self.TextTrackCue(i.startTime,i.endTime,i.text);n.id=i.id;t.addCue(n)}}if(r==="disabled"){t.mode=r}}function a(t){var i=t.mode;if(i==="disabled"){t.mode="hidden"}if(t.cues){for(var r=t.cues.length;r--;){t.removeCue(t.cues[r])}}if(i==="disabled"){t.mode=i}}function u(t,i,r){var e=t.mode;if(e==="disabled"){t.mode="hidden"}if(t.cues&&t.cues.length>0){var n=h(t.cues,i,r);for(var s=0;s<n.length;s++){t.removeCue(n[s])}}if(e==="disabled"){t.mode=e}}function f(t,i){if(i<t[0].startTime){return 0}var r=t.length-1;if(i>t[r].endTime){return-1}var e=0;var n=r;while(e<=n){var s=Math.floor((n+e)/2);if(i<t[s].startTime){n=s-1}else if(i>t[s].startTime&&e<r){e=s+1}else{return s}}return t[e].startTime-i<i-t[n].startTime?e:n}function h(t,i,r){var e=[];var n=f(t,i);if(n>-1){for(var s=n,a=t.length;s<a;s++){var u=t[s];if(u.startTime>=i&&u.endTime<=r){e.push(u)}else if(u.startTime>r){return e}}}return e}},"./src/utils/time-ranges.ts":
337
+ /*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(t,i,n){n.r(i),n.d(i,"sendAddTrackEvent",(function(){return e})),n.d(i,"addCueToTrack",(function(){return s})),n.d(i,"clearCurrentCues",(function(){return a})),n.d(i,"removeCuesInRange",(function(){return o})),n.d(i,"getCuesInRange",(function(){return h}));var r=n(/*! ./logger */"./src/utils/logger.ts");function e(t,i){var n;try{n=new Event("addtrack")}catch(t){(n=document.createEvent("Event")).initEvent("addtrack",!1,!1)}n.track=t,i.dispatchEvent(n)}function s(t,i){var n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(i.id))try{if(t.addCue(i),!t.cues.getCueById(i.id))throw new Error("addCue is failed for: "+i)}catch(n){r.logger.debug("[texttrack-utils]: "+n);var e=new self.TextTrackCue(i.startTime,i.endTime,i.text);e.id=i.id,t.addCue(e)}"disabled"===n&&(t.mode=n)}function a(t){var i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues)for(var n=t.cues.length;n--;)t.removeCue(t.cues[n]);"disabled"===i&&(t.mode=i)}function o(t,i,n){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var e=h(t.cues,i,n),s=0;s<e.length;s++)t.removeCue(e[s]);"disabled"===r&&(t.mode=r)}function h(t,i,n){var r=[],e=function(t,i){if(i<t[0].startTime)return 0;var n=t.length-1;if(i>t[n].endTime)return-1;for(var r=0,e=n;r<=e;){var s=Math.floor((e+r)/2);if(i<t[s].startTime)e=s-1;else{if(!(i>t[s].startTime&&r<n))return s;r=s+1}}return t[r].startTime-i<i-t[e].startTime?r:e}(t,i);if(e>-1)for(var s=e,a=t.length;s<a;s++){var o=t[s];if(o.startTime>=i&&o.endTime<=n)r.push(o);else if(o.startTime>n)return r}return r}},"./src/utils/time-ranges.ts":
338
338
  /*!**********************************!*\
339
339
  !*** ./src/utils/time-ranges.ts ***!
340
340
  \**********************************/
341
- /*! exports provided: default */function(t,i,r){r.r(i);var e={toString:function t(i){var r="";var e=i.length;for(var n=0;n<e;n++){r+="["+i.start(n).toFixed(3)+","+i.end(n).toFixed(3)+"]"}return r}};i["default"]=e},"./src/utils/timescale-conversion.ts":
341
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default={toString:function(t){for(var i="",n=t.length,r=0;r<n;r++)i+="["+t.start(r).toFixed(3)+","+t.end(r).toFixed(3)+"]";return i}}},"./src/utils/timescale-conversion.ts":
342
342
  /*!*******************************************!*\
343
343
  !*** ./src/utils/timescale-conversion.ts ***!
344
344
  \*******************************************/
345
- /*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(t,i,r){r.r(i);r.d(i,"toTimescaleFromBase",(function(){return n}));r.d(i,"toTimescaleFromScale",(function(){return s}));r.d(i,"toMsFromMpegTsClock",(function(){return a}));r.d(i,"toMpegTsClockFromTimescale",(function(){return u}));var e=9e4;function n(t,i,r,e){if(r===void 0){r=1}if(e===void 0){e=false}var n=t*i*r;return e?Math.round(n):n}function s(t,i,r,e){if(r===void 0){r=1}if(e===void 0){e=false}return n(t,i,1/r,e)}function a(t,i){if(i===void 0){i=false}return n(t,1e3,1/e,i)}function u(t,i){if(i===void 0){i=1}return n(t,e,1/i)}},"./src/utils/typed-array.ts":
345
+ /*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(t,i,n){function r(t,i,n,r){void 0===n&&(n=1),void 0===r&&(r=!1);var e=t*i*n;return r?Math.round(e):e}function e(t,i,n,e){return void 0===n&&(n=1),void 0===e&&(e=!1),r(t,i,1/n,e)}function s(t,i){return void 0===i&&(i=!1),r(t,1e3,1/9e4,i)}function a(t,i){return void 0===i&&(i=1),r(t,9e4,1/i)}n.r(i),n.d(i,"toTimescaleFromBase",(function(){return r})),n.d(i,"toTimescaleFromScale",(function(){return e})),n.d(i,"toMsFromMpegTsClock",(function(){return s})),n.d(i,"toMpegTsClockFromTimescale",(function(){return a}))},"./src/utils/typed-array.ts":
346
346
  /*!**********************************!*\
347
347
  !*** ./src/utils/typed-array.ts ***!
348
348
  \**********************************/
349
- /*! exports provided: sliceUint8 */function(t,i,r){r.r(i);r.d(i,"sliceUint8",(function(){return e}));function e(t,i,r){return Uint8Array.prototype.slice?t.slice(i,r):new Uint8Array(Array.prototype.slice.call(t,i,r))}},"./src/utils/vttcue.ts":
349
+ /*! exports provided: sliceUint8 */function(t,i,n){function r(t,i,n){return Uint8Array.prototype.slice?t.slice(i,n):new Uint8Array(Array.prototype.slice.call(t,i,n))}n.r(i),n.d(i,"sliceUint8",(function(){return r}))},"./src/utils/vttcue.ts":
350
350
  /*!*****************************!*\
351
351
  !*** ./src/utils/vttcue.ts ***!
352
352
  \*****************************/
353
- /*! exports provided: default */function(t,i,r){r.r(i);i["default"]=function(){if(typeof self!=="undefined"&&self.VTTCue){return self.VTTCue}var t=["","lr","rl"];var i=["start","middle","end","left","right"];function r(t,i){if(typeof i!=="string"){return false}if(!Array.isArray(t)){return false}var r=i.toLowerCase();if(~t.indexOf(r)){return r}return false}function e(i){return r(t,i)}function n(t){return r(i,t)}function s(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),e=1;e<i;e++){r[e-1]=arguments[e]}var n=1;for(;n<arguments.length;n++){var s=arguments[n];for(var a in s){t[a]=s[a]}}return t}function a(t,i,r){var a=this;var u={enumerable:true};a.hasBeenReset=false;var f="";var h=false;var o=t;var v=i;var l=r;var c=null;var d="";var m=true;var p="auto";var g="start";var b=50;var y="middle";var w=50;var k="middle";Object.defineProperty(a,"id",s({},u,{get:function t(){return f},set:function t(i){f=""+i}}));Object.defineProperty(a,"pauseOnExit",s({},u,{get:function t(){return h},set:function t(i){h=!!i}}));Object.defineProperty(a,"startTime",s({},u,{get:function t(){return o},set:function t(i){if(typeof i!=="number"){throw new TypeError("Start time must be set to a number.")}o=i;this.hasBeenReset=true}}));Object.defineProperty(a,"endTime",s({},u,{get:function t(){return v},set:function t(i){if(typeof i!=="number"){throw new TypeError("End time must be set to a number.")}v=i;this.hasBeenReset=true}}));Object.defineProperty(a,"text",s({},u,{get:function t(){return l},set:function t(i){l=""+i;this.hasBeenReset=true}}));Object.defineProperty(a,"region",s({},u,{get:function t(){return c},set:function t(i){c=i;this.hasBeenReset=true}}));Object.defineProperty(a,"vertical",s({},u,{get:function t(){return d},set:function t(i){var r=e(i);if(r===false){throw new SyntaxError("An invalid or illegal string was specified.")}d=r;this.hasBeenReset=true}}));Object.defineProperty(a,"snapToLines",s({},u,{get:function t(){return m},set:function t(i){m=!!i;this.hasBeenReset=true}}));Object.defineProperty(a,"line",s({},u,{get:function t(){return p},set:function t(i){if(typeof i!=="number"&&i!=="auto"){throw new SyntaxError("An invalid number or illegal string was specified.")}p=i;this.hasBeenReset=true}}));Object.defineProperty(a,"lineAlign",s({},u,{get:function t(){return g},set:function t(i){var r=n(i);if(!r){throw new SyntaxError("An invalid or illegal string was specified.")}g=r;this.hasBeenReset=true}}));Object.defineProperty(a,"position",s({},u,{get:function t(){return b},set:function t(i){if(i<0||i>100){throw new Error("Position must be between 0 and 100.")}b=i;this.hasBeenReset=true}}));Object.defineProperty(a,"positionAlign",s({},u,{get:function t(){return y},set:function t(i){var r=n(i);if(!r){throw new SyntaxError("An invalid or illegal string was specified.")}y=r;this.hasBeenReset=true}}));Object.defineProperty(a,"size",s({},u,{get:function t(){return w},set:function t(i){if(i<0||i>100){throw new Error("Size must be between 0 and 100.")}w=i;this.hasBeenReset=true}}));Object.defineProperty(a,"align",s({},u,{get:function t(){return k},set:function t(i){var r=n(i);if(!r){throw new SyntaxError("An invalid or illegal string was specified.")}k=r;this.hasBeenReset=true}}));a.displayState=undefined}a.prototype.getCueAsHTML=function(){var t=self.WebVTT;return t.convertCueToDOMTree(self,this.text)};return a}()},"./src/utils/vttparser.ts":
353
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],i=["start","middle","end","left","right"];function n(t,i){if("string"!=typeof i)return!1;if(!Array.isArray(t))return!1;var n=i.toLowerCase();return!!~t.indexOf(n)&&n}function r(t){return n(i,t)}function e(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var a in s)t[a]=s[a]}return t}function s(i,s,a){var o=this,h={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,f=i,l=s,v=a,d=null,m="",p=!0,g="auto",b="start",y=50,w="middle",k=50,T="middle";Object.defineProperty(o,"id",e({},h,{get:function(){return u},set:function(t){u=""+t}})),Object.defineProperty(o,"pauseOnExit",e({},h,{get:function(){return c},set:function(t){c=!!t}})),Object.defineProperty(o,"startTime",e({},h,{get:function(){return f},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");f=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",e({},h,{get:function(){return l},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");l=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",e({},h,{get:function(){return v},set:function(t){v=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",e({},h,{get:function(){return d},set:function(t){d=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",e({},h,{get:function(){return m},set:function(i){var r=function(i){return n(t,i)}(i);if(!1===r)throw new SyntaxError("An invalid or illegal string was specified.");m=r,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",e({},h,{get:function(){return p},set:function(t){p=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",e({},h,{get:function(){return g},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");g=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",e({},h,{get:function(){return b},set:function(t){var i=r(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");b=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",e({},h,{get:function(){return y},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",e({},h,{get:function(){return w},set:function(t){var i=r(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");w=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",e({},h,{get:function(){return k},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");k=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",e({},h,{get:function(){return T},set:function(t){var i=r(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");T=i,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}()},"./src/utils/vttparser.ts":
354
354
  /*!********************************!*\
355
355
  !*** ./src/utils/vttparser.ts ***!
356
356
  \********************************/
357
- /*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(t,i,r){r.r(i);r.d(i,"parseTimeStamp",(function(){return s}));r.d(i,"fixLineBreaks",(function(){return v}));r.d(i,"VTTParser",(function(){return l}));var e=r(/*! ./vttcue */"./src/utils/vttcue.ts");var n=function(){function t(){}var i=t.prototype;i.decode=function t(i,r){if(!i){return""}if(typeof i!=="string"){throw new Error("Error - expected string data.")}return decodeURIComponent(encodeURIComponent(i))};return t}();function s(t){function i(t,i,r,e){return(t|0)*3600+(i|0)*60+(r|0)+parseFloat(e||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);if(!r){return null}if(parseFloat(r[2])>59){return i(r[2],r[3],0,r[4])}return i(r[1],r[2],r[3],r[4])}var a=function(){function t(){this.values=Object.create(null)}var i=t.prototype;i.set=function t(i,r){if(!this.get(i)&&r!==""){this.values[i]=r}};i.get=function t(i,r,e){if(e){return this.has(i)?this.values[i]:r[e]}return this.has(i)?this.values[i]:r};i.has=function t(i){return i in this.values};i.alt=function t(i,r,e){for(var n=0;n<e.length;++n){if(r===e[n]){this.set(i,r);break}}};i.integer=function t(i,r){if(/^-?\d+$/.test(r)){this.set(i,parseInt(r,10))}};i.percent=function t(i,r){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(r)){var t=parseFloat(r);if(t>=0&&t<=100){this.set(i,t);return true}}return false};return t}();function u(t,i,r,e){var n=e?t.split(e):[t];for(var s in n){if(typeof n[s]!=="string"){continue}var a=n[s].split(r);if(a.length!==2){continue}var u=a[0];var f=a[1];i(u,f)}}var f=new e["default"](0,0,"");var h=f.align==="middle"?"middle":"center";function o(t,i,r){var e=t;function n(){var i=s(t);if(i===null){throw new Error("Malformed timestamp: "+e)}t=t.replace(/^[^\sa-zA-Z-]+/,"");return i}function o(t,i){var e=new a;u(t,(function(t,i){var n;switch(t){case"region":for(var s=r.length-1;s>=0;s--){if(r[s].id===i){e.set(t,r[s].region);break}}break;case"vertical":e.alt(t,i,["rl","lr"]);break;case"line":n=i.split(",");e.integer(t,n[0]);if(e.percent(t,n[0])){e.set("snapToLines",false)}e.alt(t,n[0],["auto"]);if(n.length===2){e.alt("lineAlign",n[1],["start",h,"end"])}break;case"position":n=i.split(",");e.percent(t,n[0]);if(n.length===2){e.alt("positionAlign",n[1],["start",h,"end","line-left","line-right","auto"])}break;case"size":e.percent(t,i);break;case"align":e.alt(t,i,["start",h,"end","left","right"]);break}}),/:/,/\s/);i.region=e.get("region",null);i.vertical=e.get("vertical","");var n=e.get("line","auto");if(n==="auto"&&f.line===-1){n=-1}i.line=n;i.lineAlign=e.get("lineAlign","start");i.snapToLines=e.get("snapToLines",true);i.size=e.get("size",100);i.align=e.get("align",h);var s=e.get("position","auto");if(s==="auto"&&f.position===50){s=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50}i.position=s}function v(){t=t.replace(/^\s+/,"")}v();i.startTime=n();v();if(t.substr(0,3)!=="--\x3e"){throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+e)}t=t.substr(3);v();i.endTime=n();v();o(t,i)}function v(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var l=function(){function t(){this.state="INITIAL";this.buffer="";this.decoder=new n;this.regionList=[];this.cue=null;this.oncue=void 0;this.onparsingerror=void 0;this.onflush=void 0}var i=t.prototype;i.parse=function t(i){var r=this;if(i){r.buffer+=r.decoder.decode(i,{stream:true})}function n(){var t=r.buffer;var i=0;t=v(t);while(i<t.length&&t[i]!=="\r"&&t[i]!=="\n"){++i}var e=t.substr(0,i);if(t[i]==="\r"){++i}if(t[i]==="\n"){++i}r.buffer=t.substr(i);return e}function s(t){u(t,(function(t,i){}),/:/)}try{var a="";if(r.state==="INITIAL"){if(!/\r\n|\n/.test(r.buffer)){return this}a=n();var f=a.match(/^()?WEBVTT([ \t].*)?$/);if(!f||!f[0]){throw new Error("Malformed WebVTT signature.")}r.state="HEADER"}var h=false;while(r.buffer){if(!/\r\n|\n/.test(r.buffer)){return this}if(!h){a=n()}else{h=false}switch(r.state){case"HEADER":if(/:/.test(a)){s(a)}else if(!a){r.state="ID"}continue;case"NOTE":if(!a){r.state="ID"}continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){r.state="NOTE";break}if(!a){continue}r.cue=new e["default"](0,0,"");r.state="CUE";if(a.indexOf("--\x3e")===-1){r.cue.id=a;continue}case"CUE":if(!r.cue){r.state="BADCUE";continue}try{o(a,r.cue,r.regionList)}catch(t){r.cue=null;r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":{var l=a.indexOf("--\x3e")!==-1;if(!a||l&&(h=true)){if(r.oncue&&r.cue){r.oncue(r.cue)}r.cue=null;r.state="ID";continue}if(r.cue===null){continue}if(r.cue.text){r.cue.text+="\n"}r.cue.text+=a}continue;case"BADCUE":if(!a){r.state="ID"}}}}catch(t){if(r.state==="CUETEXT"&&r.cue&&r.oncue){r.oncue(r.cue)}r.cue=null;r.state=r.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this};i.flush=function t(){var i=this;try{if(i.cue||i.state==="HEADER"){i.buffer+="\n\n";i.parse()}if(i.state==="INITIAL"||i.state==="BADWEBVTT"){throw new Error("Malformed WebVTT signature.")}}catch(t){if(i.onparsingerror){i.onparsingerror(t)}}if(i.onflush){i.onflush()}return this};return t}()},"./src/utils/webvtt-parser.ts":
357
+ /*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(t,i,n){n.r(i),n.d(i,"parseTimeStamp",(function(){return s})),n.d(i,"fixLineBreaks",(function(){return f})),n.d(i,"VTTParser",(function(){return l}));var r=n(/*! ./vttcue */"./src/utils/vttcue.ts"),e=function(){function t(){}return t.prototype.decode=function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function s(t){function i(t,i,n,r){return 3600*(0|t)+60*(0|i)+(0|n)+parseFloat(r||0)}var n=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return n?parseFloat(n[2])>59?i(n[2],n[3],0,n[4]):i(n[1],n[2],n[3],n[4]):null}var a=function(){function t(){this.values=Object.create(null)}var i=t.prototype;return i.set=function(t,i){this.get(t)||""===i||(this.values[t]=i)},i.get=function(t,i,n){return n?this.has(t)?this.values[t]:i[n]:this.has(t)?this.values[t]:i},i.has=function(t){return t in this.values},i.alt=function(t,i,n){for(var r=0;r<n.length;++r)if(i===n[r]){this.set(t,i);break}},i.integer=function(t,i){/^-?\d+$/.test(i)&&this.set(t,parseInt(i,10))},i.percent=function(t,i){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(i)){var n=parseFloat(i);if(n>=0&&n<=100)return this.set(t,n),!0}return!1},t}();function o(t,i,n,r){var e=r?t.split(r):[t];for(var s in e)if("string"==typeof e[s]){var a=e[s].split(n);2===a.length&&i(a[0],a[1])}}var h=new r.default(0,0,""),u="middle"===h.align?"middle":"center";function c(t,i,n){var r=t;function e(){var i=s(t);if(null===i)throw new Error("Malformed timestamp: "+r);return t=t.replace(/^[^\sa-zA-Z-]+/,""),i}function c(){t=t.replace(/^\s+/,"")}if(c(),i.startTime=e(),c(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);t=t.substr(3),c(),i.endTime=e(),c(),function(t,i){var r=new a;o(t,(function(t,i){var e;switch(t){case"region":for(var s=n.length-1;s>=0;s--)if(n[s].id===i){r.set(t,n[s].region);break}break;case"vertical":r.alt(t,i,["rl","lr"]);break;case"line":e=i.split(","),r.integer(t,e[0]),r.percent(t,e[0])&&r.set("snapToLines",!1),r.alt(t,e[0],["auto"]),2===e.length&&r.alt("lineAlign",e[1],["start",u,"end"]);break;case"position":e=i.split(","),r.percent(t,e[0]),2===e.length&&r.alt("positionAlign",e[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,i);break;case"align":r.alt(t,i,["start",u,"end","left","right"])}}),/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var e=r.get("line","auto");"auto"===e&&-1===h.line&&(e=-1),i.line=e,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",u);var s=r.get("position","auto");"auto"===s&&50===h.position&&(s="start"===i.align||"left"===i.align?0:"end"===i.align||"right"===i.align?100:50),i.position=s}(t,i)}function f(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var l=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new e,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var i=t.prototype;return i.parse=function(t){var i=this;function n(){var t=i.buffer,n=0;for(t=f(t);n<t.length&&"\r"!==t[n]&&"\n"!==t[n];)++n;var r=t.substr(0,n);return"\r"===t[n]&&++n,"\n"===t[n]&&++n,i.buffer=t.substr(n),r}t&&(i.buffer+=i.decoder.decode(t,{stream:!0}));try{var e="";if("INITIAL"===i.state){if(!/\r\n|\n/.test(i.buffer))return this;var s=(e=n()).match(/^()?WEBVTT([ \t].*)?$/);if(!s||!s[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var a=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(a?a=!1:e=n(),i.state){case"HEADER":/:/.test(e)?o(e,(function(){}),/:/):e||(i.state="ID");continue;case"NOTE":e||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){i.state="NOTE";break}if(!e)continue;if(i.cue=new r.default(0,0,""),i.state="CUE",-1===e.indexOf("--\x3e")){i.cue.id=e;continue}case"CUE":if(!i.cue){i.state="BADCUE";continue}try{c(e,i.cue,i.regionList)}catch(t){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var h=-1!==e.indexOf("--\x3e");if(!e||h&&(a=!0)){i.oncue&&i.cue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}if(null===i.cue)continue;i.cue.text&&(i.cue.text+="\n"),i.cue.text+=e;continue;case"BADCUE":e||(i.state="ID")}}}catch(t){"CUETEXT"===i.state&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state="INITIAL"===i.state?"BADWEBVTT":"BADCUE"}return this},i.flush=function(){var t=this;try{if((t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(i){t.onparsingerror&&t.onparsingerror(i)}return t.onflush&&t.onflush(),this},t}()},"./src/utils/webvtt-parser.ts":
358
358
  /*!************************************!*\
359
359
  !*** ./src/utils/webvtt-parser.ts ***!
360
360
  \************************************/
361
- /*! exports provided: generateCueId, parseWebVTT */function(t,i,r){r.r(i);r.d(i,"generateCueId",(function(){return l}));r.d(i,"parseWebVTT",(function(){return d}));var e=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");var n=r(/*! ./vttparser */"./src/utils/vttparser.ts");var s=r(/*! ../demux/id3 */"./src/demux/id3.ts");var a=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts");var u=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts");var f=/\r\n|\n\r|\n|\r/g;var h=function t(i,r,e){if(e===void 0){e=0}return i.substr(e,r.length)===r};var o=function t(i){var r=parseInt(i.substr(-3));var n=parseInt(i.substr(-6,2));var s=parseInt(i.substr(-9,2));var a=i.length>9?parseInt(i.substr(0,i.indexOf(":"))):0;if(!Object(e["isFiniteNumber"])(r)||!Object(e["isFiniteNumber"])(n)||!Object(e["isFiniteNumber"])(s)||!Object(e["isFiniteNumber"])(a)){throw Error("Malformed X-TIMESTAMP-MAP: Local:"+i)}r+=1e3*n;r+=60*1e3*s;r+=60*60*1e3*a;return r};var v=function t(i){var t=5381;var r=i.length;while(r){t=t*33^i.charCodeAt(--r)}return(t>>>0).toString()};function l(t,i,r){return v(t.toString())+v(i.toString())+v(r)}var c=function t(i,r,e){var n=i[r];var s=i[n.prevCC];if(!s||!s.new&&n.new){i.ccOffset=i.presentationOffset=n.start;n.new=false;return}while((a=s)!==null&&a!==void 0&&a.new){var a;i.ccOffset+=n.start-s.start;n.new=false;n=s;s=i[n.prevCC]}i.presentationOffset=e};function d(t,i,r,e,v,d,m,p){var g=new n["VTTParser"];var b=Object(s["utf8ArrayToStr"])(new Uint8Array(t)).trim().replace(f,"\n").split("\n");var y=[];var w=Object(a["toMpegTsClockFromTimescale"])(i,r);var k="00:00.000";var T=0;var O=0;var S;var E=true;var A=false;g.oncue=function(t){var i=e[v];var r=e.ccOffset;var n=(T-w)/9e4;if(i!==null&&i!==void 0&&i.new){if(O!==undefined){r=e.ccOffset=i.start}else{c(e,v,n)}}if(n){r=n-e.presentationOffset}if(A){var s=t.endTime-t.startTime;var a=Object(u["normalizePts"])((t.startTime+r-O)*9e4,d*9e4)/9e4;t.startTime=a;t.endTime=a+s}var f=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(f));if(!t.id){t.id=l(t.startTime,t.endTime,f)}if(t.endTime>0){y.push(t)}};g.onparsingerror=function(t){S=t};g.onflush=function(){if(S){p(S);return}m(y)};b.forEach((function(t){if(E){if(h(t,"X-TIMESTAMP-MAP=")){E=false;A=true;t.substr(16).split(",").forEach((function(t){if(h(t,"LOCAL:")){k=t.substr(6)}else if(h(t,"MPEGTS:")){T=parseInt(t.substr(7))}}));try{O=o(k)/1e3}catch(t){A=false;S=t}return}else if(t===""){E=false}}g.parse(t+"\n")}));g.flush()}},"./src/utils/xhr-loader.ts":
361
+ /*! exports provided: generateCueId, parseWebVTT */function(t,i,n){n.r(i),n.d(i,"generateCueId",(function(){return f})),n.d(i,"parseWebVTT",(function(){return l}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./vttparser */"./src/utils/vttparser.ts"),s=n(/*! ../demux/id3 */"./src/demux/id3.ts"),a=n(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=n(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),h=/\r\n|\n\r|\n|\r/g,u=function(t,i,n){return void 0===n&&(n=0),t.substr(n,i.length)===i},c=function(t){for(var i=5381,n=t.length;n;)i=33*i^t.charCodeAt(--n);return(i>>>0).toString()};function f(t,i,n){return c(t.toString())+c(i.toString())+c(n)}function l(t,i,n,c,l,v,d,m){var p,g=new e.VTTParser,b=Object(s.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(h,"\n").split("\n"),y=[],w=Object(a.toMpegTsClockFromTimescale)(i,n),k="00:00.000",T=0,O=0,S=!0,E=!1;g.oncue=function(t){var i=c[l],n=c.ccOffset,r=(T-w)/9e4;if(null!=i&&i.new&&(void 0!==O?n=c.ccOffset=i.start:function(t,i,n){var r=t[i],e=t[r.prevCC];if(!e||!e.new&&r.new)return t.ccOffset=t.presentationOffset=r.start,void(r.new=!1);for(;null!==(s=e)&&void 0!==s&&s.new;){var s;t.ccOffset+=r.start-e.start,r.new=!1,e=t[(r=e).prevCC]}t.presentationOffset=n}(c,l,r)),r&&(n=r-c.presentationOffset),E){var e=t.endTime-t.startTime,s=Object(o.normalizePts)(9e4*(t.startTime+n-O),9e4*v)/9e4;t.startTime=s,t.endTime=s+e}var a=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(a)),t.id||(t.id=f(t.startTime,t.endTime,a)),t.endTime>0&&y.push(t)},g.onparsingerror=function(t){p=t},g.onflush=function(){p?m(p):d(y)},b.forEach((function(t){if(S){if(u(t,"X-TIMESTAMP-MAP=")){S=!1,E=!0,t.substr(16).split(",").forEach((function(t){u(t,"LOCAL:")?k=t.substr(6):u(t,"MPEGTS:")&&(T=parseInt(t.substr(7)))}));try{O=function(t){var i=parseInt(t.substr(-3)),n=parseInt(t.substr(-6,2)),e=parseInt(t.substr(-9,2)),s=t.length>9?parseInt(t.substr(0,t.indexOf(":"))):0;if(!(Object(r.isFiniteNumber)(i)&&Object(r.isFiniteNumber)(n)&&Object(r.isFiniteNumber)(e)&&Object(r.isFiniteNumber)(s)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return i+=1e3*n,(i+=6e4*e)+36e5*s}(k)/1e3}catch(t){E=!1,p=t}return}""===t&&(S=!1)}g.parse(t+"\n")})),g.flush()}},"./src/utils/xhr-loader.ts":
362
362
  /*!*********************************!*\
363
363
  !*** ./src/utils/xhr-loader.ts ***!
364
364
  \*********************************/
365
- /*! exports provided: default */function(t,i,r){r.r(i);var e=r(/*! ../utils/logger */"./src/utils/logger.ts");var n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts");var s=/^age:\s*[\d.]+\s*$/m;var a=function(){function t(t){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=t?t.xhrSetup:null;this.stats=new n["LoadStats"];this.retryDelay=0}var i=t.prototype;i.destroy=function t(){this.callbacks=null;this.abortInternal();this.loader=null;this.config=null};i.abortInternal=function t(){var i=this.loader;self.clearTimeout(this.requestTimeout);self.clearTimeout(this.retryTimeout);if(i){i.onreadystatechange=null;i.onprogress=null;if(i.readyState!==4){this.stats.aborted=true;i.abort()}}};i.abort=function t(){var i;this.abortInternal();if((i=this.callbacks)!==null&&i!==void 0&&i.onAbort){this.callbacks.onAbort(this.stats,this.context,this.loader)}};i.load=function t(i,r,e){if(this.stats.loading.start){throw new Error("Loader can only be used once.")}this.stats.loading.start=self.performance.now();this.context=i;this.config=r;this.callbacks=e;this.retryDelay=r.retryDelay;this.loadInternal()};i.loadInternal=function t(){var i=this.config,r=this.context;if(!i){return}var e=this.loader=new self.XMLHttpRequest;var n=this.stats;n.loading.first=0;n.loaded=0;var s=this.xhrSetup;try{if(s){try{s(e,r.url)}catch(t){e.open("GET",r.url,true);s(e,r.url)}}if(!e.readyState){e.open("GET",r.url,true)}var a=this.context.headers;if(a){for(var u in a){e.setRequestHeader(u,a[u])}}}catch(t){this.callbacks.onError({code:e.status,text:t.message},r,e);return}if(r.rangeEnd){e.setRequestHeader("Range","bytes="+r.rangeStart+"-"+(r.rangeEnd-1))}e.onreadystatechange=this.readystatechange.bind(this);e.onprogress=this.loadprogress.bind(this);e.responseType=r.responseType;self.clearTimeout(this.requestTimeout);this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout);e.send()};i.readystatechange=function t(){var i=this.context,r=this.loader,n=this.stats;if(!i||!r){return}var s=r.readyState;var a=this.config;if(n.aborted){return}if(s>=2){self.clearTimeout(this.requestTimeout);if(n.loading.first===0){n.loading.first=Math.max(self.performance.now(),n.loading.start)}if(s===4){r.onreadystatechange=null;r.onprogress=null;var u=r.status;if(u>=200&&u<300){n.loading.end=Math.max(self.performance.now(),n.loading.first);var f;var h;if(i.responseType==="arraybuffer"){f=r.response;h=f.byteLength}else{f=r.responseText;h=f.length}n.loaded=n.total=h;if(!this.callbacks){return}var o=this.callbacks.onProgress;if(o){o(n,i,f,r)}if(!this.callbacks){return}var v={url:r.responseURL,data:f};this.callbacks.onSuccess(v,n,i,r)}else{if(n.retry>=a.maxRetry||u>=400&&u<499){e["logger"].error(u+" while loading "+i.url);this.callbacks.onError({code:u,text:r.statusText},i,r)}else{e["logger"].warn(u+" while loading "+i.url+", retrying in "+this.retryDelay+"...");this.abortInternal();this.loader=null;self.clearTimeout(this.retryTimeout);this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay);this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay);n.retry++}}}else{self.clearTimeout(this.requestTimeout);this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}}};i.loadtimeout=function t(){e["logger"].warn("timeout while loading "+this.context.url);var i=this.callbacks;if(i){this.abortInternal();i.onTimeout(this.stats,this.context,this.loader)}};i.loadprogress=function t(i){var r=this.stats;r.loaded=i.loaded;if(i.lengthComputable){r.total=i.total}};i.getCacheAge=function t(){var i=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var r=this.loader.getResponseHeader("age");i=r?parseFloat(r):null}return i};return t}();i["default"]=a}})["default"]}))}));const n=t(e);const s=Object.freeze(Object.assign(Object.create(null),e,{default:n}));export{s as h};
366
- //# sourceMappingURL=p-d5234e7e.js.map
365
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../utils/logger */"./src/utils/logger.ts"),e=n(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m;i.default=function(){function t(t){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=t?t.xhrSetup:null,this.stats=new e.LoadStats,this.retryDelay=0}var i=t.prototype;return i.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},i.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},i.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},i.load=function(t,i,n){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=i,this.callbacks=n,this.retryDelay=i.retryDelay,this.loadInternal()},i.loadInternal=function(){var t=this.config,i=this.context;if(t){var n=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0;var e=this.xhrSetup;try{if(e)try{e(n,i.url)}catch(t){n.open("GET",i.url,!0),e(n,i.url)}n.readyState||n.open("GET",i.url,!0);var s=this.context.headers;if(s)for(var a in s)n.setRequestHeader(a,s[a])}catch(t){return void this.callbacks.onError({code:n.status,text:t.message},i,n)}i.rangeEnd&&n.setRequestHeader("Range","bytes="+i.rangeStart+"-"+(i.rangeEnd-1)),n.onreadystatechange=this.readystatechange.bind(this),n.onprogress=this.loadprogress.bind(this),n.responseType=i.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),n.send()}},i.readystatechange=function(){var t=this.context,i=this.loader,n=this.stats;if(t&&i){var e=i.readyState,s=this.config;if(!n.aborted&&e>=2)if(self.clearTimeout(this.requestTimeout),0===n.loading.first&&(n.loading.first=Math.max(self.performance.now(),n.loading.start)),4===e){i.onreadystatechange=null,i.onprogress=null;var a=i.status;if(a>=200&&a<300){var o,h;if(n.loading.end=Math.max(self.performance.now(),n.loading.first),h="arraybuffer"===t.responseType?(o=i.response).byteLength:(o=i.responseText).length,n.loaded=n.total=h,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(n,t,o,i),!this.callbacks)return;this.callbacks.onSuccess({url:i.responseURL,data:o},n,t,i)}else n.retry>=s.maxRetry||a>=400&&a<499?(r.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:i.statusText},t,i)):(r.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),n.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},i.loadtimeout=function(){r.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},i.loadprogress=function(t){var i=this.stats;i.loaded=t.loaded,t.lengthComputable&&(i.total=t.total)},i.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var i=this.loader.getResponseHeader("age");t=i?parseFloat(i):null}return t},t}()}}).default},t.exports=i())}));const e=t(r),s=Object.freeze(Object.assign(Object.create(null),r,{default:e}));export{s as h}