luckyphoenix 1.0.5 → 1.0.6

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 (195) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -4
  3. package/alist-web/README.md +34 -0
  4. package/alist-web/assets/2fa-legacy.3350d44d.js +1 -0
  5. package/alist-web/assets/2fa.0dab7189.js +1 -0
  6. package/alist-web/assets/About-legacy.e1597551.js +1 -0
  7. package/alist-web/assets/About.11e2f3bb.js +1 -0
  8. package/alist-web/assets/AddOrEdit-legacy.2a02db88.js +1 -0
  9. package/alist-web/assets/AddOrEdit-legacy.432f6c0e.js +1 -0
  10. package/alist-web/assets/AddOrEdit-legacy.6ac6f516.js +1 -0
  11. package/alist-web/assets/AddOrEdit.79c069f9.js +1 -0
  12. package/alist-web/assets/AddOrEdit.e641a9bd.js +1 -0
  13. package/alist-web/assets/AddOrEdit.f0ec5bf9.js +1 -0
  14. package/alist-web/assets/Common-legacy.5144e9c0.js +1 -0
  15. package/alist-web/assets/Common.6eff9060.js +1 -0
  16. package/alist-web/assets/Copy-legacy.3d846482.js +1 -0
  17. package/alist-web/assets/Copy.d1980101.js +1 -0
  18. package/alist-web/assets/DeletePopover-legacy.1906395c.js +1 -0
  19. package/alist-web/assets/DeletePopover.f7887d88.js +1 -0
  20. package/alist-web/assets/File-legacy.889dd355.js +1 -0
  21. package/alist-web/assets/File.23490613.js +1 -0
  22. package/alist-web/assets/Folder-legacy.a4550db5.js +29 -0
  23. package/alist-web/assets/Folder.7e9202ae.js +179 -0
  24. package/alist-web/assets/Folder.b511ba9e.css +1 -0
  25. package/alist-web/assets/FolderTree-legacy.2cffdb64.js +1 -0
  26. package/alist-web/assets/FolderTree.3d6d889d.js +1 -0
  27. package/alist-web/assets/Grid-legacy.a63ef469.js +1 -0
  28. package/alist-web/assets/Grid.7759c684.js +1 -0
  29. package/alist-web/assets/GridItem-legacy.2300a556.js +1 -0
  30. package/alist-web/assets/GridItem.5502f946.js +1 -0
  31. package/alist-web/assets/ImageWithError-legacy.184872e5.js +1 -0
  32. package/alist-web/assets/ImageWithError.fbebe083.js +1 -0
  33. package/alist-web/assets/Images-legacy.47953965.js +1 -0
  34. package/alist-web/assets/Images.cc1e423a.js +1 -0
  35. package/alist-web/assets/Layout-legacy.bbe308ea.js +1 -0
  36. package/alist-web/assets/Layout.683e33e3.js +6 -0
  37. package/alist-web/assets/List-legacy.dc5a2a38.js +1 -0
  38. package/alist-web/assets/List.249d43e3.js +1 -0
  39. package/alist-web/assets/Messenger-legacy.15747cf4.js +1 -0
  40. package/alist-web/assets/Messenger.0de50ee8.js +1 -0
  41. package/alist-web/assets/Metas-legacy.9a37ad69.js +1 -0
  42. package/alist-web/assets/Metas.94282135.js +1 -0
  43. package/alist-web/assets/Other-legacy.1defd90b.js +1 -0
  44. package/alist-web/assets/Other.c698471d.js +1 -0
  45. package/alist-web/assets/PackageDownload-legacy.13e43bb9.js +1 -0
  46. package/alist-web/assets/PackageDownload.89e4ecc4.js +1 -0
  47. package/alist-web/assets/Paginator-legacy.6f9f1dcb.js +1 -0
  48. package/alist-web/assets/Paginator.758bcfa3.js +1 -0
  49. package/alist-web/assets/Password-legacy.5e5cbd20.js +1 -0
  50. package/alist-web/assets/Password.500d1886.js +1 -0
  51. package/alist-web/assets/Profile-legacy.ccf1ddd4.js +1 -0
  52. package/alist-web/assets/Profile.33671ffe.js +1 -0
  53. package/alist-web/assets/ResponsiveGrid-legacy.d58d4dfe.js +1 -0
  54. package/alist-web/assets/ResponsiveGrid.04e247e9.js +1 -0
  55. package/alist-web/assets/S3-legacy.fb41a1b8.js +1 -0
  56. package/alist-web/assets/S3.135ba8ad.js +1 -0
  57. package/alist-web/assets/SettingItem-legacy.51bf5808.js +1 -0
  58. package/alist-web/assets/SettingItem.d9757149.js +1 -0
  59. package/alist-web/assets/SourceHanSansCN-Bold.b5627435.woff2 +0 -0
  60. package/alist-web/assets/Storages-legacy.6fe86e3a.js +1 -0
  61. package/alist-web/assets/Storages.22e89c36.js +1 -0
  62. package/alist-web/assets/Tasks-legacy.bcf4e457.js +1 -0
  63. package/alist-web/assets/Tasks.f607862a.js +1 -0
  64. package/alist-web/assets/TimesNewRoman.d9fb32eb.ttf +0 -0
  65. package/alist-web/assets/Upload-legacy.7dd2be21.js +1 -0
  66. package/alist-web/assets/Upload-legacy.cb936202.js +1 -0
  67. package/alist-web/assets/Upload.4c54bcbf.js +1 -0
  68. package/alist-web/assets/Upload.d35bb47b.js +1 -0
  69. package/alist-web/assets/Users-legacy.b992a339.js +1 -0
  70. package/alist-web/assets/Users.7eb39296.js +1 -0
  71. package/alist-web/assets/Wether-legacy.66b7b0d3.js +1 -0
  72. package/alist-web/assets/Wether.f17d6a97.js +1 -0
  73. package/alist-web/assets/_commonjs-dynamic-modules-legacy.cf19cda3.js +1 -0
  74. package/alist-web/assets/_commonjs-dynamic-modules.30ae7933.js +1 -0
  75. package/alist-web/assets/aliyun_office-legacy.7e1c4ff6.js +1 -0
  76. package/alist-web/assets/aliyun_office.627eb2ac.js +1 -0
  77. package/alist-web/assets/aliyun_video-legacy.dfd303c5.js +1 -0
  78. package/alist-web/assets/aliyun_video.681fb5ee.js +1 -0
  79. package/alist-web/assets/asciinema-legacy.554330ec.js +1 -0
  80. package/alist-web/assets/asciinema.53412307.css +1 -0
  81. package/alist-web/assets/asciinema.a6e925e9.js +7 -0
  82. package/alist-web/assets/audio-legacy.d6ef56f6.js +1 -0
  83. package/alist-web/assets/audio.0cad5cce.js +154 -0
  84. package/alist-web/assets/audio.e5b5af14.css +1 -0
  85. package/alist-web/assets/backup-restore-legacy.f4c8daf0.js +1 -0
  86. package/alist-web/assets/backup-restore.db700ca0.js +1 -0
  87. package/alist-web/assets/entry-legacy.01f22349.js +1 -0
  88. package/alist-web/assets/entry-legacy.31390e6c.js +1 -0
  89. package/alist-web/assets/entry-legacy.5119e4e8.js +1 -0
  90. package/alist-web/assets/entry-legacy.d3b909f7.js +1 -0
  91. package/alist-web/assets/entry-legacy.e017de3e.js +1 -0
  92. package/alist-web/assets/entry-legacy.eec15c4b.js +1 -0
  93. package/alist-web/assets/entry-legacy.fa23a37d.js +1 -0
  94. package/alist-web/assets/entry.2eaf5bb3.js +5 -0
  95. package/alist-web/assets/entry.371138c7.js +7 -0
  96. package/alist-web/assets/entry.5c41c532.js +5 -0
  97. package/alist-web/assets/entry.6cce3889.js +5 -0
  98. package/alist-web/assets/entry.8acdb7f9.js +9 -0
  99. package/alist-web/assets/entry.abb9e6ed.js +5 -0
  100. package/alist-web/assets/entry.e83ea613.js +6 -0
  101. package/alist-web/assets/helper-legacy.646eb2d9.js +1 -0
  102. package/alist-web/assets/helper.d54883e3.js +1 -0
  103. package/alist-web/assets/hls-legacy.9e0f7edb.js +379 -0
  104. package/alist-web/assets/hls.1623c369.js +49 -0
  105. package/alist-web/assets/html-legacy.fa26963f.js +1 -0
  106. package/alist-web/assets/html.8b79f6ca.js +1 -0
  107. package/alist-web/assets/icon-legacy.2d7c0a16.js +1 -0
  108. package/alist-web/assets/icon.94f94d81.js +37 -0
  109. package/alist-web/assets/image-legacy.236a9cca.js +1 -0
  110. package/alist-web/assets/image.82ca8574.js +1 -0
  111. package/alist-web/assets/index-legacy.0bd3a7f2.js +1 -0
  112. package/alist-web/assets/index-legacy.40b50240.js +1 -0
  113. package/alist-web/assets/index-legacy.61172c95.js +1 -0
  114. package/alist-web/assets/index-legacy.840e3d82.js +18 -0
  115. package/alist-web/assets/index-legacy.91fe7355.js +1 -0
  116. package/alist-web/assets/index-legacy.a7c40fe3.js +22 -0
  117. package/alist-web/assets/index-legacy.d72e643a.js +1 -0
  118. package/alist-web/assets/index-legacy.efef9df2.js +1 -0
  119. package/alist-web/assets/index-legacy.fb7fb711.js +1 -0
  120. package/alist-web/assets/index.0adfc44b.js +1 -0
  121. package/alist-web/assets/index.26f5b473.js +14 -0
  122. package/alist-web/assets/index.72e3f724.js +1 -0
  123. package/alist-web/assets/index.7409b67a.js +1 -0
  124. package/alist-web/assets/index.952b63b2.js +1 -0
  125. package/alist-web/assets/index.afa471fc.js +1 -0
  126. package/alist-web/assets/index.c15f7469.js +2 -0
  127. package/alist-web/assets/index.c4c82a28.css +1 -0
  128. package/alist-web/assets/index.dcae211e.js +1 -0
  129. package/alist-web/assets/index.fae3cea4.js +333 -0
  130. package/alist-web/assets/indexes-legacy.2c89d2d8.js +1 -0
  131. package/alist-web/assets/indexes.9cb6f537.js +2 -0
  132. package/alist-web/assets/ipa-legacy.7a49e0e2.js +1 -0
  133. package/alist-web/assets/ipa.97543f5f.js +1 -0
  134. package/alist-web/assets/item_type-legacy.d1f1c701.js +1 -0
  135. package/alist-web/assets/item_type.be442da4.js +1 -0
  136. package/alist-web/assets/lg.22b72ba5.ttf +0 -0
  137. package/alist-web/assets/lg.f2fe1c00.svg +54 -0
  138. package/alist-web/assets/lg.fefc5c0d.woff +0 -0
  139. package/alist-web/assets/loading.298ad3ff.gif +0 -0
  140. package/alist-web/assets/markdown-legacy.164943d8.js +1 -0
  141. package/alist-web/assets/markdown.3a932f53.js +1 -0
  142. package/alist-web/assets/markdown_with_word_wrap-legacy.5e032546.js +1 -0
  143. package/alist-web/assets/markdown_with_word_wrap.0efe2540.js +1 -0
  144. package/alist-web/assets/offline_download-legacy.11c4744c.js +1 -0
  145. package/alist-web/assets/offline_download.940ca54b.js +1 -0
  146. package/alist-web/assets/plist-legacy.c76fc720.js +1 -0
  147. package/alist-web/assets/plist.3c9cbb1a.js +1 -0
  148. package/alist-web/assets/polyfills-legacy.5f28c7ae.js +1 -0
  149. package/alist-web/assets/subtitles-octopus-worker.62892886.wasm +0 -0
  150. package/alist-web/assets/subtitles-octopus-worker.f95f2186.js +1 -0
  151. package/alist-web/assets/text-editor-legacy.6e126724.js +1 -0
  152. package/alist-web/assets/text-editor.45600bb2.js +11 -0
  153. package/alist-web/assets/url-legacy.e95c5b8b.js +1 -0
  154. package/alist-web/assets/url.f7914d75.js +1 -0
  155. package/alist-web/assets/useTitle-legacy.e942225f.js +1 -0
  156. package/alist-web/assets/useTitle.630c0b7f.js +1 -0
  157. package/alist-web/assets/video-legacy.5198eeb8.js +135 -0
  158. package/alist-web/assets/video.afae2b68.js +9 -0
  159. package/alist-web/assets/video360-legacy.227ed7df.js +16 -0
  160. package/alist-web/assets/video360.c8385eb2.js +18 -0
  161. package/alist-web/assets/video360.f0192288.css +1 -0
  162. package/alist-web/assets/video_box-legacy.d60b6928.js +7 -0
  163. package/alist-web/assets/video_box.bfb0d4a5.js +18 -0
  164. package/alist-web/assets/webauthn-json.browser-ponyfill-legacy.8ddd819a.js +1 -0
  165. package/alist-web/assets/webauthn-json.browser-ponyfill.1c672167.js +1 -0
  166. package/alist-web/images/figplayer.webp +0 -0
  167. package/alist-web/images/fileball.webp +0 -0
  168. package/alist-web/images/iina.webp +0 -0
  169. package/alist-web/images/infuse.webp +0 -0
  170. package/alist-web/images/mxplayer-pro.webp +0 -0
  171. package/alist-web/images/mxplayer.webp +0 -0
  172. package/alist-web/images/nplayer.webp +0 -0
  173. package/alist-web/images/omniplayer.webp +0 -0
  174. package/alist-web/images/potplayer.webp +0 -0
  175. package/alist-web/images/vlc.webp +0 -0
  176. package/alist-web/index.html +81 -0
  177. package/alist-web/package.json +95 -0
  178. package/alist-web/static/epub.js/viewer.html +467 -0
  179. package/alist-web/static/manifest.json +13 -0
  180. package/alist-web/streamer/mitm.html +186 -0
  181. package/alist-web/streamer/sw.js +141 -0
  182. package/css/alist_skin_v2.css +410 -410
  183. package/css/alist_skin_v3.css +216 -218
  184. package/css/alist_wallpaper.css +49 -48
  185. package/css/colorful.css +65 -65
  186. package/css/font-awesome.css +10569 -10568
  187. package/css/lxgw-style.css +12 -6
  188. package/css/lxgwwenkai-bold.css +873 -873
  189. package/css/lxgwwenkai-light.css +873 -873
  190. package/css/lxgwwenkai-regular.css +873 -873
  191. package/css/lxgwwenkaimono-bold.css +873 -873
  192. package/css/lxgwwenkaimono-light.css +873 -873
  193. package/css/lxgwwenkaimono-regular.css +873 -873
  194. package/package.json +2 -2
  195. package/favicon.ico +0 -0
@@ -0,0 +1,49 @@
1
+ import{cU as Ke,cC as ke}from"./index.fae3cea4.js";import{c as we}from"./_commonjs-dynamic-modules.30ae7933.js";var We={exports:{}};/*!
2
+ * artplayer-plugin-danmuku.js v5.0.1
3
+ * Github: https://github.com/zhw2590582/ArtPlayer
4
+ * (c) 2017-2023 Harvey Zack
5
+ * Released under the MIT License.
6
+ */(function(ie,fe){(function(K,M,D,T,R){var O=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof ke<"u"?ke:{},b=typeof O[T]=="function"&&O[T],C=b.cache||{},I=typeof we=="function"&&we.bind(ie);function S(p,m){if(!C[p]){if(!K[p]){var v=typeof O[T]=="function"&&O[T];if(!m&&v)return v(p,!0);if(b)return b(p,!0);if(I&&typeof p=="string")return I(p);var f=new Error("Cannot find module '"+p+"'");throw f.code="MODULE_NOT_FOUND",f}e.resolve=function(a){var l=K[p][1][a];return l!=null?l:a},e.cache={};var r=C[p]=new S.Module(p);K[p][0].call(r.exports,e,r,r.exports,this)}return C[p].exports;function e(a){var l=e.resolve(a);return l===!1?{}:S(l)}}S.isParcelRequire=!0,S.Module=function(p){this.id=p,this.bundle=S,this.exports={}},S.modules=K,S.cache=C,S.parent=b,S.register=function(p,m){K[p]=[function(v,f){f.exports=m},{}]},Object.defineProperty(S,"root",{get:function(){return O[T]}}),O[T]=S;for(var g=0;g<M.length;g++)S(M[g]);if(D){var x=S(D);ie.exports=x}})({bgm6t:[function(K,M,D){var T=K("@parcel/transformer-js/src/esmodule-helpers.js");T.defineInteropFlag(D);var R=K("./danmuku"),O=T.interopDefault(R),b=K("./setting"),C=T.interopDefault(b),I=K("./heatmap"),S=T.interopDefault(I);function g(x){return p=>{(function(v){const{version:f,utils:{errorHandle:r}}=v.constructor,e=f.split(".").map(Number);r(e[0]+e[1]/100>=5,`Artplayer.js@${f} \u4E0D\u517C\u5BB9\u8BE5\u5F39\u5E55\u5E93\uFF0C\u8BF7\u66F4\u65B0\u5230 Artplayer.js@5.x.x \u7248\u672C\u4EE5\u4E0A`)})(p);const m=new O.default(p,x);return(0,C.default)(p,m),x.heatmap&&!p.option.isLive&&(0,S.default)(p,m,x.heatmap),{name:"artplayerPluginDanmuku",emit:m.emit.bind(m),load:m.load.bind(m),config:m.config.bind(m),hide:m.hide.bind(m),show:m.show.bind(m),reset:m.reset.bind(m),get option(){return m.option},get isHide(){return m.isHide},get isStop(){return m.isStop}}}}D.default=g,g.env="production",g.version="5.0.1",g.build="2023-05-03 11:57:31",typeof window<"u"&&(window.artplayerPluginDanmuku=g)},{"./danmuku":"4ns48","./setting":"lO8OT","./heatmap":"8AxLD","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"4ns48":[function(K,M,D){var T=K("@parcel/transformer-js/src/esmodule-helpers.js");T.defineInteropFlag(D);var R=K("./bilibili"),O=K("./getDanmuTop"),b=T.interopDefault(O);class C{constructor(S,g){const{constructor:x,template:p}=S;if(this.utils=x.utils,this.validator=x.validator,this.$danmuku=p.$danmuku,this.$player=p.$player,this.art=S,this.danmus=[],this.queue=[],this.option={},this.$refs=[],this.isStop=!1,this.isHide=!1,this.timer=null,this.config(g),this.option.useWorker)try{this.worker=new Worker(K("12ceab24749100d0"))}catch{}this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.reset=this.reset.bind(this),this.destroy=this.destroy.bind(this),S.on("video:play",this.start),S.on("video:playing",this.start),S.on("video:pause",this.stop),S.on("video:waiting",this.stop),S.on("resize",this.reset),S.on("destroy",this.destroy),this.load()}static get option(){return{danmuku:[],speed:5,margin:["2%","25%"],opacity:1,color:"#FFFFFF",mode:0,fontSize:25,filter:()=>!0,antiOverlap:!0,useWorker:!0,synchronousPlayback:!1,lockTime:5,maxLength:100,minWidth:200,maxWidth:400,mount:void 0,theme:"dark",heatmap:!1,beforeEmit:()=>!0}}static get scheme(){return{danmuku:"array|function|string",speed:"number",margin:"array",opacity:"number",color:"string",mode:"number",fontSize:"number|string",filter:"function",antiOverlap:"boolean",useWorker:"boolean",synchronousPlayback:"boolean",lockTime:"number",maxLength:"number",minWidth:"number",maxWidth:"number",mount:"undefined|htmldivelement",theme:"string",heatmap:"object|boolean",beforeEmit:"function"}}get isRotate(){return this.art.plugins.autoOrientation&&this.art.plugins.autoOrientation.state}get marginTop(){const{clamp:S}=this.utils,g=this.option.margin[0],{clientHeight:x}=this.$player;return typeof g=="number"?S(g,0,x):typeof g=="string"&&g.endsWith("%")?S(x*(parseFloat(g)/100),0,x):C.option.margin[0]}get marginBottom(){const{clamp:S}=this.utils,g=this.option.margin[1],{clientHeight:x}=this.$player;return typeof g=="number"?S(g,0,x):typeof g=="string"&&g.endsWith("%")?S(x*(parseFloat(g)/100),0,x):C.option.margin[1]}filter(S,g){return this.queue.filter(x=>x.$state===S).map(g)}getLeft(S){const g=S.getBoundingClientRect();return this.isRotate?g.top:g.left}getRef(){const S=this.$refs.pop();if(S)return S;const g=document.createElement("div");return g.style.cssText=`
7
+ user-select: none;
8
+ position: absolute;
9
+ white-space: pre;
10
+ pointer-events: none;
11
+ perspective: 500px;
12
+ display: inline-block;
13
+ will-change: transform;
14
+ font-weight: normal;
15
+ line-height: 1.125;
16
+ visibility: hidden;
17
+ font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;
18
+ text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px;
19
+ `,g}getReady(){const{currentTime:S}=this.art;return this.queue.filter(g=>g.$state==="ready"||g.$state==="wait"&&S+.1>=g.time&&g.time>=S-.1)}getEmits(){const S=[],{clientWidth:g}=this.$player,x=this.getLeft(this.$player);return this.filter("emit",p=>{const m=p.$ref.offsetTop,v=this.getLeft(p.$ref)-x,f=p.$ref.clientHeight,r=p.$ref.clientWidth,e=v+r,a=g-e,l=e/p.$restTime,h={};h.top=m,h.left=v,h.height=f,h.width=r,h.right=a,h.speed=l,h.distance=e,h.time=p.$restTime,h.mode=p.mode,S.push(h)}),S}getFontSize(S){const{clamp:g}=this.utils,{clientHeight:x}=this.$player;return typeof S=="number"?g(S,12,x):typeof S=="string"&&S.endsWith("%")?g(x*(parseFloat(S)/100),12,x):C.option.fontSize}postMessage(S={}){return new Promise(g=>{if(this.option.useWorker&&this.worker&&this.worker.postMessage)S.id=Date.now(),this.worker.postMessage(S),this.worker.onmessage=x=>{const{data:p}=x;p.id===S.id&&g(p)};else{const x=(0,b.default)(S);g({top:x})}})}async load(){try{typeof this.option.danmuku=="function"?this.danmus=await this.option.danmuku():typeof this.option.danmuku.then=="function"?this.danmus=await this.option.danmuku:typeof this.option.danmuku=="string"?this.danmus=await(0,R.bilibiliDanmuParseFromUrl)(this.option.danmuku):this.danmus=this.option.danmuku,this.utils.errorHandle(Array.isArray(this.danmus),"Danmuku need return an array as result"),this.art.emit("artplayerPluginDanmuku:loaded",this.danmus),this.queue=[],this.$danmuku.innerText="",this.danmus.forEach(S=>this.emit(S))}catch(S){throw this.art.emit("artplayerPluginDanmuku:error",S),S}return this}config(S){const{clamp:g}=this.utils;return this.option=Object.assign({},C.option,this.option,S),this.validator(this.option,C.scheme),this.option.speed=g(this.option.speed,1,10),this.option.opacity=g(this.option.opacity,0,1),this.option.lockTime=g(Math.floor(this.option.lockTime),0,60),this.option.maxLength=g(this.option.maxLength,0,500),this.option.minWidth=g(this.option.minWidth,0,500),this.option.maxWidth=g(this.option.maxWidth,0,1/0),S.fontSize&&(this.option.fontSize=this.getFontSize(this.option.fontSize),this.reset()),this.art.emit("artplayerPluginDanmuku:config",this.option),this}makeWait(S){S.$state="wait",S.$ref&&(S.$ref.style.visibility="hidden",S.$ref.style.marginLeft="0px",S.$ref.style.transform="translateX(0px)",S.$ref.style.transition="transform 0s linear 0s",this.$refs.push(S.$ref),S.$ref=null)}continue(){const{clientWidth:S}=this.$player;return this.filter("stop",g=>{switch(g.$state="emit",g.$lastStartTime=Date.now(),g.mode){case 0:{const x=S+g.$ref.clientWidth;g.$ref.style.transform=`translateX(${-x}px)`,g.$ref.style.transition=`transform ${g.$restTime}s linear 0s`;break}}}),this}suspend(){const{clientWidth:S}=this.$player;return this.filter("emit",g=>{switch(g.$state="stop",g.mode){case 0:{const x=S-(this.getLeft(g.$ref)-this.getLeft(this.$player));g.$ref.style.transform=`translateX(${-x}px)`,g.$ref.style.transition="transform 0s linear 0s";break}}}),this}reset(){return this.queue.forEach(S=>this.makeWait(S)),this}update(){return this.timer=window.requestAnimationFrame(async()=>{if(this.art.playing&&!this.isHide){this.filter("emit",p=>{const m=(Date.now()-p.$lastStartTime)/1e3;p.$restTime-=m,p.$lastStartTime=Date.now(),p.$restTime<=0&&this.makeWait(p)});const S=this.getReady(),{clientWidth:g,clientHeight:x}=this.$player;for(let p=0;p<S.length;p++){const m=S[p];m.$ref=this.getRef(),m.$ref.innerText=m.text,this.$danmuku.appendChild(m.$ref),m.$ref.style.left=`${g}px`,m.$ref.style.opacity=this.option.opacity,m.$ref.style.fontSize=`${this.option.fontSize}px`,m.$ref.style.color=m.color,m.$ref.style.border=m.border?`1px solid ${m.color}`:null,m.$ref.style.backgroundColor=m.border?"rgb(0 0 0 / 50%)":null,m.$ref.style.marginLeft="0px",m.$lastStartTime=Date.now(),m.$restTime=this.option.synchronousPlayback&&this.art.playbackRate?this.option.speed/Number(this.art.playbackRate):this.option.speed;const v={mode:m.mode,height:m.$ref.clientHeight,speed:(g+m.$ref.clientWidth)/m.$restTime},{top:f}=await this.postMessage({target:v,emits:this.getEmits(),antiOverlap:this.option.antiOverlap,clientWidth:g,clientHeight:x,marginBottom:this.marginBottom,marginTop:this.marginTop});if(m.$ref)if(this.isStop||f===void 0)m.$state="ready",this.$refs.push(m.$ref),m.$ref=null;else switch(m.$state="emit",m.$ref.style.visibility="visible",m.mode){case 0:{m.$ref.style.top=`${f}px`;const r=g+m.$ref.clientWidth;m.$ref.style.transform=`translateX(${-r}px)`,m.$ref.style.transition=`transform ${m.$restTime}s linear 0s`;break}case 1:m.$ref.style.left="50%",m.$ref.style.top=`${f}px`,m.$ref.style.marginLeft=`-${m.$ref.clientWidth/2}px`}}}this.isStop||this.update()}),this}stop(){return this.isStop=!0,this.suspend(),window.cancelAnimationFrame(this.timer),this.art.emit("artplayerPluginDanmuku:stop"),this}start(){return this.isStop=!1,this.continue(),this.update(),this.art.emit("artplayerPluginDanmuku:start"),this}show(){return this.isHide=!1,this.start(),this.$danmuku.style.display="block",this.art.emit("artplayerPluginDanmuku:show"),this}hide(){return this.isHide=!0,this.stop(),this.queue.forEach(S=>this.makeWait(S)),this.$danmuku.style.display="none",this.art.emit("artplayerPluginDanmuku:hide"),this}emit(S){return this.validator(S,{text:"string",mode:"number|undefined",color:"string|undefined",time:"number|undefined",border:"boolean|undefined"}),S.text.trim()&&this.option.filter(S)?(S.time?S.time=this.utils.clamp(S.time,0,1/0):S.time=this.art.currentTime+.5,S.mode===void 0&&(S.mode=this.option.mode),S.color===void 0&&(S.color=this.option.color),this.queue.push({...S,$state:"wait",$ref:null,$restTime:0,$lastStartTime:0}),this):this}destroy(){this.stop(),this.worker&&this.worker.terminate&&this.worker.terminate(),this.art.off("video:play",this.start),this.art.off("video:playing",this.start),this.art.off("video:pause",this.stop),this.art.off("video:waiting",this.stop),this.art.off("resize",this.reset),this.art.off("destroy",this.destroy),this.art.emit("artplayerPluginDanmuku:destroy")}}D.default=C},{"./bilibili":"f83sx","./getDanmuTop":"jPSuD","12ceab24749100d0":"fXq73","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],f83sx:[function(K,M,D){var T=K("@parcel/transformer-js/src/esmodule-helpers.js");function R(C){switch(C){case 1:case 2:case 3:default:return 0;case 4:case 5:return 1}}function O(C){if(typeof C!="string")return[];const I=C.matchAll(/<d (?:.*? )??p="(?<p>.+?)"(?: .*?)?>(?<text>.+?)<\/d>/gs);return Array.from(I).map(S=>{const g=S.groups.p.split(",");return g.length>=8?{text:S.groups.text.trim().replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&"),time:Number(g[0]),mode:R(Number(g[1])),fontSize:Number(g[2]),color:`#${Number(g[3]).toString(16)}`,timestamp:Number(g[4]),pool:Number(g[5]),userID:g[6],rowID:Number(g[7])}:null}).filter(Boolean)}function b(C){return fetch(C).then(I=>I.text()).then(I=>O(I))}T.defineInteropFlag(D),T.export(D,"getMode",()=>R),T.export(D,"bilibiliDanmuParseFromXml",()=>O),T.export(D,"bilibiliDanmuParseFromUrl",()=>b)},{"@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"9pCYc":[function(K,M,D){D.interopDefault=function(T){return T&&T.__esModule?T:{default:T}},D.defineInteropFlag=function(T){Object.defineProperty(T,"__esModule",{value:!0})},D.exportAll=function(T,R){return Object.keys(T).forEach(function(O){O==="default"||O==="__esModule"||R.hasOwnProperty(O)||Object.defineProperty(R,O,{enumerable:!0,get:function(){return T[O]}})}),R},D.export=function(T,R,O){Object.defineProperty(T,R,{enumerable:!0,get:O})}},{}],jPSuD:[function(K,M,D){K("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(D),D.default=function({target:T,emits:R,clientWidth:O,clientHeight:b,marginBottom:C,marginTop:I,antiOverlap:S}){const g=R.filter(p=>p.mode===T.mode&&p.top<=b-C).sort((p,m)=>p.top-m.top);if(g.length===0)return I;g.unshift({top:0,left:0,right:0,height:I,width:O,speed:0,distance:O}),g.push({top:b-C,left:0,right:0,height:C,width:O,speed:0,distance:O});for(let p=1;p<g.length;p+=1){const m=g[p],v=g[p-1],f=v.top+v.height;if(m.top-f>=T.height)return f}const x=[];for(let p=1;p<g.length-1;p+=1){const m=g[p];if(x.length){const v=x[x.length-1];v[0].top===m.top?v.push(m):x.push([m])}else x.push([m])}if(!S){switch(T.mode){case 0:x.sort((p,m)=>{const v=Math.min(...m.map(r=>r.right)),f=Math.min(...p.map(r=>r.right));return v*m.length-f*p.length});break;case 1:x.sort((p,m)=>{const v=Math.max(...m.map(f=>f.width));return Math.max(...p.map(f=>f.width))*p.length-v*m.length})}return x[0][0].top}switch(T.mode){case 0:{const p=x.find(m=>m.every(v=>O<v.distance?!1:T.speed<v.speed?!0:v.right/(T.speed-v.speed)>v.time));return p&&p[0]?p[0].top:void 0}case 1:return}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],fXq73:[function(K,M,D){M.exports="data:application/javascript,function%20getDanmuTop%28%7Btarget%3At%2Cemits%3Ae%2CclientWidth%3An%2CclientHeight%3Ai%2CmarginBottom%3As%2CmarginTop%3Ah%2CantiOverlap%3Ao%7D%29%7Bconst%20r%3De.filter%28%28e%3D%3Ee.mode%3D%3D%3Dt.mode%26%26e.top%3C%3Di-s%29%29.sort%28%28%28t%2Ce%29%3D%3Et.top-e.top%29%29%3Bif%280%3D%3D%3Dr.length%29return%20h%3Br.unshift%28%7Btop%3A0%2Cleft%3A0%2Cright%3A0%2Cheight%3Ah%2Cwidth%3An%2Cspeed%3A0%2Cdistance%3An%7D%29%2Cr.push%28%7Btop%3Ai-s%2Cleft%3A0%2Cright%3A0%2Cheight%3As%2Cwidth%3An%2Cspeed%3A0%2Cdistance%3An%7D%29%3Bfor%28let%20e%3D1%3Be%3Cr.length%3Be%2B%3D1%29%7Bconst%20n%3Dr%5Be%5D%2Ci%3Dr%5Be-1%5D%2Cs%3Di.top%2Bi.height%3Bif%28n.top-s%3E%3Dt.height%29return%20s%7Dconst%20p%3D%5B%5D%3Bfor%28let%20t%3D1%3Bt%3Cr.length-1%3Bt%2B%3D1%29%7Bconst%20e%3Dr%5Bt%5D%3Bif%28p.length%29%7Bconst%20t%3Dp%5Bp.length-1%5D%3Bt%5B0%5D.top%3D%3D%3De.top%3Ft.push%28e%29%3Ap.push%28%5Be%5D%29%7Delse%20p.push%28%5Be%5D%29%7Dif%28%21o%29%7Bswitch%28t.mode%29%7Bcase%200%3Ap.sort%28%28%28t%2Ce%29%3D%3E%7Bconst%20n%3DMath.min%28...e.map%28%28t%3D%3Et.right%29%29%29%2Ci%3DMath.min%28...t.map%28%28t%3D%3Et.right%29%29%29%3Breturn%20n%2ae.length-i%2at.length%7D%29%29%3Bbreak%3Bcase%201%3Ap.sort%28%28%28t%2Ce%29%3D%3E%7Bconst%20n%3DMath.max%28...e.map%28%28t%3D%3Et.width%29%29%29%3Breturn%20Math.max%28...t.map%28%28t%3D%3Et.width%29%29%29%2at.length-n%2ae.length%7D%29%29%7Dreturn%20p%5B0%5D%5B0%5D.top%7Dswitch%28t.mode%29%7Bcase%200%3A%7Bconst%20e%3Dp.find%28%28e%3D%3Ee.every%28%28e%3D%3E%7Bif%28n%3Ce.distance%29return%211%3Bif%28t.speed%3Ce.speed%29return%210%3Breturn%20e.right%2F%28t.speed-e.speed%29%3Ee.time%7D%29%29%29%29%3Breturn%20e%26%26e%5B0%5D%3Fe%5B0%5D.top%3Avoid%200%7Dcase%201%3Areturn%7D%7Donmessage%3Dt%3D%3E%7Bconst%7Bdata%3Ae%7D%3Dt%2Cn%3DgetDanmuTop%28e%29%3Bself.postMessage%28%7Btop%3An%2Cid%3Ae.id%7D%29%7D%3B"},{}],lO8OT:[function(K,M,D){var T=K("@parcel/transformer-js/src/esmodule-helpers.js");T.defineInteropFlag(D);var R=K("bundle-text:./style.less"),O=T.interopDefault(R),b=K("bundle-text:./img/danmu-on.svg"),C=T.interopDefault(b),I=K("bundle-text:./img/danmu-off.svg"),S=T.interopDefault(I),g=K("bundle-text:./img/danmu-config.svg"),x=T.interopDefault(g),p=K("bundle-text:./img/danmu-style.svg"),m=T.interopDefault(p);if(D.default=function(v,f){const{option:r}=f,{template:{$controlsCenter:e,$player:a},constructor:{SETTING_ITEM_WIDTH:l,utils:{removeClass:h,addClass:n,append:t,setStyle:i,tooltip:E,query:u,inverseClass:d,getIcon:c}}}=v;i(e,"display","flex");const o=c("danmu-on",C.default),s=c("danmu-off",S.default),y=c("danmu-config",x.default),L=c("danmu-style",m.default);(function(){const A=["#FE0302","#FF7204","#FFAA02","#FFD302","#FFFF00","#A0EE00","#00CD00","#019899","#4266BE","#89D5FF","#CC0273","#222222","#9B9B9B","#FFFFFF"].map(z=>`<div class="art-danmuku-style-panel-color${r.color===z?" art-current":""}" data-color="${z}" style="background-color:${z}"></div>`),P=t(e,`<div class="art-danmuku-emitter" style="max-width: ${r.maxWidth?`${r.maxWidth}px`:"100%"}"><div class="art-danmuku-left"><div class="art-danmuku-style"><div class="art-danmuku-style-panel"><div class="art-danmuku-style-panel-inner"><div class="art-danmuku-style-panel-title">\u6A21\u5F0F</div><div class="art-danmuku-style-panel-modes"><div class="art-danmuku-style-panel-mode art-current" data-mode="0">\u6EDA\u52A8</div><div class="art-danmuku-style-panel-mode" data-mode="1">\u9759\u6B62</div></div><div class="art-danmuku-style-panel-title">\u989C\u8272</div><div class="art-danmuku-style-panel-colors">${A.join("")}</div></div></div></div><input class="art-danmuku-input" maxlength="${r.maxLength}" placeholder="\u53D1\u4E2A\u5F39\u5E55\u89C1\u8BC1\u5F53\u4E0B" /></div><div class="art-danmuku-send">\u53D1\u9001</div></div>`),_=u(".art-danmuku-style",P),F=u(".art-danmuku-input",P),B=u(".art-danmuku-send",P),k=u(".art-danmuku-style-panel-inner",P),N=u(".art-danmuku-style-panel-modes",P),U=u(".art-danmuku-style-panel-colors",P),w=r.mount||t(a,'<div class="art-layer-danmuku-emitter"></div>');v.option.backdrop&&n(k,"art-backdrop-filter"),r.theme&&n(P,`art-danmuku-theme-${r.theme}`);let W=null,j=r.mode,H=r.color;function G(z){z<=0?(W=null,B.innerText="\u53D1\u9001",h(B,"art-disabled")):(B.innerText=z,W=setTimeout(()=>G(z-1),1e3))}function Y(){const z={mode:j,color:H,border:!0,text:F.value.trim()};W===null&&r.beforeEmit(z)&&(F.value="",f.emit(z),n(B,"art-disabled"),G(r.lockTime),v.emit("artplayerPluginDanmuku:emit",z))}function X(){e.clientWidth<r.minWidth?(t(w,P),i(w,"display","flex"),n(P,"art-danmuku-mount"),r.mount||i(a,"marginBottom","40px")):(t(e,P),i(w,"display","none"),h(P,"art-danmuku-mount"),r.mount||i(a,"marginBottom",null))}t(_,L),v.proxy(B,"click",Y),v.proxy(F,"keypress",z=>{z.key==="Enter"&&(z.preventDefault(),Y())}),v.proxy(N,"click",z=>{const{dataset:V}=z.target;V.mode&&(j=Number(V.mode),d(z.target,"art-current"))}),v.proxy(U,"click",z=>{const{dataset:V}=z.target;V.color&&(H=V.color,d(z.target,"art-current"))}),X(),v.on("resize",()=>{v.isInput||X()}),v.on("destroy",()=>{r.mount&&P.parentElement===r.mount&&r.mount.removeChild(P)})})(),v.controls.add({position:"right",name:"danmuku",click:function(){f.isHide?(f.show(),v.notice.show="\u5F39\u5E55\u663E\u793A",i(o,"display",null),i(s,"display","none")):(f.hide(),v.notice.show="\u5F39\u5E55\u9690\u85CF",i(o,"display","none"),i(s,"display",null))},mounted(A){t(A,o),t(A,s),E(A,"\u5F39\u5E55\u5F00\u5173"),i(s,"display","none"),v.on("artplayerPluginDanmuku:hide",()=>{i(o,"display","none"),i(s,"display",null)}),v.on("artplayerPluginDanmuku:show",()=>{i(o,"display",null),i(s,"display","none")})}}),v.setting.add({width:260,name:"danmuku",html:"\u5F39\u5E55\u8BBE\u7F6E",tooltip:"\u66F4\u591A",icon:y,selector:[{width:l,html:"\u64AD\u653E\u901F\u5EA6",icon:"",tooltip:"\u9002\u4E2D",selector:[{html:"\u6781\u6162",time:10},{html:"\u8F83\u6162",time:7.5},{default:!0,html:"\u9002\u4E2D",time:5},{html:"\u8F83\u5FEB",time:2.5},{html:"\u6781\u5FEB",time:1}],onSelect:function(A){return f.config({speed:A.time}),A.html}},{width:l,html:"\u5B57\u4F53\u5927\u5C0F",icon:"",tooltip:"\u9002\u4E2D",selector:[{html:"\u6781\u5C0F",fontSize:"4%"},{html:"\u8F83\u5C0F",fontSize:"5%"},{default:!0,html:"\u9002\u4E2D",fontSize:"6%"},{html:"\u8F83\u5927",fontSize:"7%"},{html:"\u6781\u5927",fontSize:"8%"}],onSelect:function(A){return f.config({fontSize:A.fontSize}),A.html}},{width:l,html:"\u4E0D\u900F\u660E\u5EA6",icon:"",tooltip:"100%",selector:[{default:!0,opacity:1,html:"100%"},{opacity:.75,html:"75%"},{opacity:.5,html:"50%"},{opacity:.25,html:"25%"},{opacity:0,html:"0%"}],onSelect:function(A){return f.config({opacity:A.opacity}),A.html}},{width:l,html:"\u663E\u793A\u8303\u56F4",icon:"",tooltip:"3/4",selector:[{html:"1/4",margin:[10,"75%"]},{html:"\u534A\u5C4F",margin:[10,"50%"]},{default:!0,html:"3/4",margin:[10,"25%"]},{html:"\u6EE1\u5C4F",margin:[10,10]}],onSelect:function(A){return f.config({margin:A.margin}),A.html}},{html:"\u5F39\u5E55\u9632\u91CD\u53E0",icon:"",tooltip:r.antiOverlap?"\u5F00\u542F":"\u5173\u95ED",switch:r.antiOverlap,onSwitch:A=>(f.config({antiOverlap:!A.switch}),A.tooltip=A.switch?"\u5173\u95ED":"\u5F00\u542F",!A.switch)},{html:"\u540C\u6B65\u89C6\u9891\u901F\u5EA6",icon:"",tooltip:r.synchronousPlayback?"\u5F00\u542F":"\u5173\u95ED",switch:r.synchronousPlayback,onSwitch:A=>(f.config({synchronousPlayback:!A.switch}),A.tooltip=A.switch?"\u5173\u95ED":"\u5F00\u542F",!A.switch)}]})},typeof document<"u"&&!document.getElementById("artplayer-plugin-danmuku")){const v=document.createElement("style");v.id="artplayer-plugin-danmuku",v.textContent=O.default,document.head.appendChild(v)}},{"bundle-text:./style.less":"hViDo","bundle-text:./img/danmu-on.svg":"4KfW9","bundle-text:./img/danmu-off.svg":"9UR3U","bundle-text:./img/danmu-config.svg":"4MPCW","bundle-text:./img/danmu-style.svg":"7lV5Q","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],hViDo:[function(K,M,D){M.exports='.art-danmuku-emitter{height:32px;width:100%;max-width:100%;background-color:#ffffff4d;border-radius:5px;font-size:12px;line-height:1;display:flex;position:relative}.art-danmuku-emitter .art-backdrop-filter{-webkit-backdrop-filter:saturate(180%)blur(20px);backdrop-filter:saturate(180%)blur(20px);background-color:#000000b3!important}.art-danmuku-emitter .art-danmuku-left{border-radius:3px 0 0 3px;flex:1;display:flex}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style{width:32px;justify-content:center;align-items:center;display:flex;position:relative}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel{z-index:999;width:200px;padding-bottom:10px;display:none;position:absolute;bottom:30px;left:-85px}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner{background-color:#000000e6;border-radius:3px;flex-direction:column;padding:10px 10px 0;display:flex}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner .art-danmuku-style-panel-title{margin-bottom:10px;font-size:13px}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner .art-danmuku-style-panel-modes{justify-content:space-between;margin-bottom:15px;display:flex}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner .art-danmuku-style-panel-modes .art-danmuku-style-panel-mode{width:47%;cursor:pointer;color:#fff;border:1px solid #fff;justify-content:center;padding:5px 0;display:flex}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner .art-danmuku-style-panel-modes .art-danmuku-style-panel-mode.art-current{background-color:#00a1d6;border:1px solid #00a1d6}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner .art-danmuku-style-panel-colors{flex-wrap:wrap;justify-content:space-between;gap:5px;margin-bottom:10px;display:flex}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner .art-danmuku-style-panel-colors .art-danmuku-style-panel-color{cursor:pointer;width:20px;height:20px;border:1px solid #fff}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner .art-danmuku-style-panel-colors .art-danmuku-style-panel-color.art-current{position:relative;box-shadow:0 0 2px #fff}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel .art-danmuku-style-panel-inner .art-danmuku-style-panel-colors .art-danmuku-style-panel-color.art-current:before{content:"";width:100%;height:100%;border:2px solid #000;position:absolute;inset:0}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style:hover .art-danmuku-style-panel{display:flex}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-icon{opacity:.75;cursor:pointer}.art-danmuku-emitter .art-danmuku-left .art-danmuku-style .art-icon:hover{opacity:1}.art-danmuku-emitter .art-danmuku-left .art-danmuku-input{width:100%;color:#fff;background-color:#0000;border:none;outline:none;flex:1;padding:0 10px 0 0;display:flex}.art-danmuku-emitter .art-danmuku-left .art-danmuku-input::placeholder,.art-danmuku-emitter .art-danmuku-left .art-danmuku-input::-webkit-input-placeholder{color:#ffffff80}.art-danmuku-emitter .art-danmuku-send{width:50px;cursor:pointer;background-color:#00a1d6;border-radius:0 5px 5px 0;justify-content:center;align-items:center;display:flex}.art-danmuku-emitter .art-danmuku-send:hover{background-color:#00b5e5}.art-danmuku-emitter .art-danmuku-send.art-disabled{opacity:.5;pointer-events:none}.art-danmuku-emitter.art-danmuku-mount{max-width:100%!important}.art-danmuku-emitter.art-danmuku-mount .art-danmuku-left .art-danmuku-style .art-danmuku-style-panel{left:0}.art-danmuku-emitter.art-danmuku-mount .art-danmuku-send{width:60px}.art-danmuku-emitter.art-danmuku-mount.art-danmuku-theme-light .art-danmuku-left{background:#f4f4f4;border:1px solid #dadada}.art-danmuku-emitter.art-danmuku-mount.art-danmuku-theme-light .art-danmuku-left .art-danmuku-style .art-icon svg{fill:#666}.art-danmuku-emitter.art-danmuku-mount.art-danmuku-theme-light .art-danmuku-left .art-danmuku-input{color:#000}.art-danmuku-emitter.art-danmuku-mount.art-danmuku-theme-light .art-danmuku-left .art-danmuku-input::placeholder,.art-danmuku-emitter.art-danmuku-mount.art-danmuku-theme-light .art-danmuku-left .art-danmuku-input::-webkit-input-placeholder{color:#00000080}.art-layer-danmuku-emitter{z-index:99;width:100%;position:absolute;bottom:-40px;left:0;right:0}'},{}],"4KfW9":[function(K,M,D){M.exports='<svg viewBox="0 0 1152 1024" width="22" height="22" xmlns="http://www.w3.org/2000/svg"><path fill="#fff" d="M311.467 661.333c0 4.267-4.267 8.534-8.534 12.8 0 4.267 0 4.267-4.266 8.534h-12.8c-4.267 0-8.534-4.267-17.067-8.534-8.533-8.533-17.067-8.533-25.6-8.533-8.533 0-12.8 4.267-17.067 12.8-4.266 12.8-8.533 21.333-4.266 29.867 4.266 8.533 12.8 17.066 25.6 21.333 17.066 8.533 34.133 17.067 46.933 17.067 12.8 0 21.333-4.267 34.133-8.534 8.534-4.266 17.067-17.066 25.6-29.866 8.534-12.8 12.8-34.134 17.067-55.467 4.267-21.333 4.267-51.2 4.267-85.333 0-12.8 0-21.334-4.267-29.867 0-8.533-4.267-12.8-8.533-17.067-4.267-4.266-8.534-8.533-12.8-8.533-4.267 0-12.8-4.267-21.334-4.267h-55.466s-4.267-4.266 0-8.533l4.266-38.4c0-4.267 0-8.533 4.267-8.533h46.933c17.067 0 25.6-4.267 34.134-12.8 8.533-8.534 12.8-21.334 12.8-42.667v-72.533c0-17.067-4.267-34.134-8.534-42.667-12.8-12.8-25.6-17.067-42.666-17.067H243.2c-8.533 0-17.067 0-21.333 4.267-4.267 8.533-4.267 12.8-4.267 25.6 0 8.533 0 17.067 4.267 21.333 4.266 4.267 12.8 8.534 21.333 8.534h64c4.267 0 8.533 0 8.533 4.266v34.134c0 8.533 0 12.8-4.266 12.8 0 0-4.267 4.266-8.534 4.266H268.8c-8.533 0-12.8 0-21.333 4.267-4.267 0-8.534 4.267-8.534 4.267-4.266 4.266-8.533 12.8-8.533 17.066 0 8.534-4.267 17.067-4.267 25.6l-8.533 72.534v29.866c0 8.534 4.267 12.8 8.533 17.067 4.267 4.267 8.534 4.267 17.067 8.533h68.267c4.266 0 8.533 0 8.533 4.267s4.267 8.533 4.267 17.067c0 21.333 0 42.666-4.267 55.466 0 8.534-4.267 21.334-8.533 25.6zM896 486.4c-93.867 0-174.933 51.2-217.6 123.733H571.733V576H640c21.333 0 34.133-4.267 42.667-12.8 8.533-8.533 12.8-21.333 12.8-42.667V358.4c0-21.333-4.267-34.133-12.8-42.667-8.534-8.533-21.334-12.8-42.667-12.8 0-4.266 4.267-4.266 4.267-8.533-4.267 0-4.267-4.267-4.267-4.267 4.267-12.8 8.533-21.333 4.267-25.6 0-8.533-4.267-12.8-12.8-21.333-8.534-4.267-17.067-4.267-21.334-4.267-8.533 4.267-12.8 8.534-21.333 21.334-4.267 8.533-8.533 12.8-12.8 21.333-4.267 8.533-8.533 12.8-12.8 21.333H512c-4.267-8.533-8.533-17.066-8.533-21.333-4.267-8.533-8.534-12.8-12.8-21.333-4.267-12.8-12.8-17.067-21.334-17.067s-17.066 0-25.6 8.533c-8.533 8.534-12.8 12.8-12.8 21.334s0 17.066 8.534 25.6l4.266 4.266L448 307.2c-17.067 0-29.867 4.267-38.4 12.8-8.533 4.267-12.8 21.333-12.8 38.4v157.867c0 21.333 4.267 34.133 12.8 42.666 8.533 8.534 21.333 12.8 42.667 12.8H512v34.134h-98.133c-12.8 0-21.334 0-25.6 4.266-4.267 4.267-8.534 8.534-8.534 21.334v17.066c0 4.267 4.267 8.534 4.267 8.534 4.267 0 4.267 4.266 8.533 4.266H512V716.8c0 12.8 4.267 21.333 8.533 25.6 4.267 4.267 12.8 8.533 21.334 8.533 12.8 0 21.333-4.266 25.6-8.533 4.266-4.267 4.266-12.8 4.266-25.6v-55.467H652.8c-8.533 25.6-12.8 51.2-12.8 76.8 0 140.8 115.2 256 256 256s256-115.2 256-256S1036.8 486.4 896 486.4zm-328.533-128h55.466c4.267 0 4.267 0 4.267 4.267V409.6h-59.733v-51.2zm0 102.4H627.2V512h-55.467v-51.2zM512 516.267h-55.467v-51.2H512v51.2zm0-102.4h-59.733V362.667H512v51.2zm384 499.2c-93.867 0-170.667-76.8-170.667-170.667S802.133 571.733 896 571.733s170.667 76.8 170.667 170.667S989.867 913.067 896 913.067z"/><path fill="#fff" d="M951.467 669.867 878.933 742.4l-29.866-25.6C832 699.733 806.4 704 789.333 721.067c-17.066 17.066-12.8 42.666 4.267 59.733l59.733 51.2c8.534 8.533 17.067 8.533 29.867 8.533s21.333-4.266 29.867-12.8l102.4-102.4c17.066-17.066 17.066-42.666 0-59.733-21.334-12.8-46.934-12.8-64 4.267zm-371.2 209.066H213.333c-72.533 0-128-55.466-128-119.466V230.4c0-64 55.467-119.467 128-119.467h512c72.534 0 128 55.467 128 119.467v140.8c0 25.6 17.067 42.667 42.667 42.667s42.667-17.067 42.667-42.667V230.4c0-115.2-93.867-204.8-213.334-204.8h-512C93.867 25.6 0 119.467 0 230.4v529.067c0 115.2 93.867 204.8 213.333 204.8h366.934c25.6 0 42.666-17.067 42.666-42.667s-21.333-42.667-42.666-42.667z"/></svg>'},{}],"9UR3U":[function(K,M,D){M.exports='<svg viewBox="0 0 1152 1024" width="22" height="22" xmlns="http://www.w3.org/2000/svg"><path fill="#fff" d="M311.296 661.504c0 4.096-4.096 8.704-8.704 12.8 0 4.096 0 4.096-4.096 8.704h-12.8c-4.096 0-8.704-4.096-16.896-8.704-8.704-8.704-16.896-8.704-25.6-8.704s-12.8 4.096-16.896 12.8c-4.096 12.8-8.704 21.504-4.096 29.696 4.096 8.704 12.8 16.896 25.6 21.504 16.896 8.704 34.304 16.896 47.104 16.896 12.8 0 21.504-4.096 34.304-8.704 8.704-4.096 16.896-16.896 25.6-29.696s12.8-34.304 16.896-55.296c4.096-21.504 4.096-51.2 4.096-85.504 0-12.8 0-21.504-4.096-29.696 0-8.704-4.096-12.8-8.704-16.896-4.096-4.096-8.704-8.704-12.8-8.704s-12.8-4.096-21.504-4.096h-55.808s-4.096-4.096 0-8.704l4.096-38.4c0-4.096 0-8.704 4.096-8.704h47.104c16.896 0 25.6-4.096 34.304-12.8s12.8-21.504 12.8-42.496v-72.704c0-16.896-4.096-34.304-8.704-42.496-12.8-12.8-25.6-16.896-42.496-16.896H243.2c-8.704 0-16.896 0-21.504 4.096-4.096 8.704-4.096 12.8-4.096 25.6 0 8.704 0 16.896 4.096 21.504 4.096 4.096 12.8 8.704 21.504 8.704h64c4.096 0 8.704 0 8.704 4.096v34.304c0 8.704 0 12.8-4.096 12.8 0 0-4.096 4.096-8.704 4.096H268.8c-8.704 0-12.8 0-21.504 4.096-4.096 0-8.704 4.096-8.704 4.096-4.096 4.096-8.704 12.8-8.704 16.896 0 8.704-4.096 16.896-4.096 25.6l-8.704 72.704v29.696c0 8.704 4.096 12.8 8.704 16.896s8.704 4.096 16.896 8.704h68.096c4.096 0 8.704 0 8.704 4.096s4.096 8.704 4.096 16.896c0 21.504 0 42.496-4.096 55.296.512 9.216-3.584 22.016-8.192 26.624zM896 486.4c-93.696 0-175.104 51.2-217.6 123.904H571.904V576H640c21.504 0 34.304-4.096 42.496-12.8 8.704-8.704 12.8-21.504 12.8-42.496V358.4c0-21.504-4.096-34.304-12.8-42.496-8.704-8.704-21.504-12.8-42.496-12.8 0-4.096 4.096-4.096 4.096-8.704-4.096 0-4.096-4.096-4.096-4.096 4.096-12.8 8.704-21.504 4.096-25.6 0-8.704-4.096-12.8-12.8-21.504-8.704-4.096-16.896-4.096-21.504-4.096-8.704 4.096-12.8 8.704-21.504 21.504-4.096 8.704-8.704 12.8-12.8 21.504s-8.704 12.8-12.8 21.504h-51.2c-4.096-8.704-8.704-16.896-8.704-21.504-4.096-8.704-8.704-12.8-12.8-21.504-4.096-12.8-12.8-16.896-21.504-16.896s-16.896 0-25.6 8.704-12.8 12.8-12.8 21.504 0 16.896 8.704 25.6l4.096 4.096 4.096 4.096c-16.896 0-29.696 4.096-38.4 12.8-8.704 4.096-12.8 21.504-12.8 38.4v157.696c0 21.504 4.096 34.304 12.8 42.496 8.704 8.704 21.504 12.8 42.496 12.8H512v34.304h-98.304c-12.8 0-21.504 0-25.6 4.096s-8.704 8.704-8.704 21.504v16.896c0 4.096 4.096 8.704 4.096 8.704 4.096 0 4.096 4.096 8.704 4.096H512V716.8c0 12.8 4.096 21.504 8.704 25.6 4.096 4.096 12.8 8.704 21.504 8.704 12.8 0 21.504-4.096 25.6-8.704 4.096-4.096 4.096-12.8 4.096-25.6v-55.296H652.8c-8.704 25.6-12.8 51.2-12.8 76.8 0 140.8 115.2 256 256 256s256-115.2 256-256S1036.8 486.4 896 486.4zm-328.704-128h55.296c4.096 0 4.096 0 4.096 4.096V409.6h-59.904v-51.2zm0 102.4H627.2V512h-55.296v-51.2h-4.608zM512 516.096h-55.296v-51.2H512v51.2zm0-102.4h-59.904v-51.2H512v51.2zm384 499.2c-93.696 0-170.496-76.8-170.496-170.496S802.304 571.904 896 571.904s170.496 76.8 170.496 170.496S989.696 912.896 896 912.896z"/><path fill="#fff" d="M580.096 879.104H213.504c-72.704 0-128-55.296-128-119.296V230.4c0-64 55.296-119.296 128-119.296h512c72.704 0 128 55.296 128 119.296v140.8c0 25.6 16.896 42.496 42.496 42.496s42.496-16.896 42.496-42.496V230.4c0-115.2-93.696-204.8-213.504-204.8h-512C93.696 25.6 0 119.296 0 230.4v528.896c0 115.2 93.696 204.8 213.504 204.8h367.104c25.6 0 42.496-16.896 42.496-42.496s-21.504-42.496-43.008-42.496zm171.52 10.752c-15.36-15.36-15.36-40.96 0-56.32l237.568-237.568c15.36-15.36 40.96-15.36 56.32 0s15.36 40.96 0 56.32L807.936 889.856c-15.36 15.36-40.448 15.36-56.32 0z"/></svg>'},{}],"4MPCW":[function(K,M,D){M.exports='<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22"><path d="M16.5 8c1.289 0 2.49.375 3.5 1.022V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h7.022A6.5 6.5 0 0 1 16.5 8zM7 13H5a1 1 0 0 1 0-2h2a1 1 0 0 1 0 2zm2-4H5a1 1 0 0 1 0-2h4a1 1 0 0 1 0 2z"/><path d="m20.587 13.696-.787-.131a3.503 3.503 0 0 0-.593-1.051l.301-.804a.46.46 0 0 0-.21-.56l-1.005-.581a.52.52 0 0 0-.656.113l-.499.607a3.53 3.53 0 0 0-1.276 0l-.499-.607a.52.52 0 0 0-.656-.113l-1.005.581a.46.46 0 0 0-.21.56l.301.804c-.254.31-.456.665-.593 1.051l-.787.131a.48.48 0 0 0-.413.465v1.209a.48.48 0 0 0 .413.465l.811.135c.144.382.353.733.614 1.038l-.292.78a.46.46 0 0 0 .21.56l1.005.581a.52.52 0 0 0 .656-.113l.515-.626a3.549 3.549 0 0 0 1.136 0l.515.626a.52.52 0 0 0 .656.113l1.005-.581a.46.46 0 0 0 .21-.56l-.292-.78c.261-.305.47-.656.614-1.038l.811-.135A.48.48 0 0 0 21 15.37v-1.209a.48.48 0 0 0-.413-.465zM16.5 16.057a1.29 1.29 0 1 1 .002-2.582 1.29 1.29 0 0 1-.002 2.582z"/></svg>'},{}],"7lV5Q":[function(K,M,D){M.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" width="24" height="24"><path d="M17 16H5c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1zM6.96 15c.39 0 .74-.24.89-.6l.65-1.6h5l.66 1.6c.15.36.5.6.89.6.69 0 1.15-.71.88-1.34l-3.88-8.97C11.87 4.27 11.46 4 11 4s-.87.27-1.05.69l-3.88 8.97c-.27.63.2 1.34.89 1.34zM11 5.98 12.87 11H9.13L11 5.98z"/></svg>'},{}],"8AxLD":[function(K,M,D){K("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(D);const T={map:(R,O,b,C,I)=>(R-O)*(I-C)/(b-O)+C,range(R,O,b){const C=Math.round(R/b)*b;return Array.from({length:Math.floor((O-R)/b)},(I,S)=>S*b+C)}};D.default=function(R,O,b){const{query:C}=R.constructor.utils;R.controls.add({name:"heatmap",position:"top",html:"",style:{position:"absolute",top:"-100px",left:"0px",right:"0px",height:"100px",width:"100%",pointerEvents:"none"},mounted(I){let S=null,g=null;function x(){if(S=null,g=null,I.innerHTML="",!O.danmus.length||!R.duration)return;const p={w:I.offsetWidth,h:I.offsetHeight},m={xMin:0,xMax:p.w,yMin:0,yMax:128,scale:.25,opacity:.2,minHeight:Math.floor(.05*p.h),sampling:Math.floor(p.w/100),smoothing:.2,flattening:.2};typeof b=="object"&&Object.assign(m,b);const v=[],f=R.duration/p.w;for(let i=0;i<=p.w;i+=m.sampling){const E=O.danmus.filter(({time:u})=>u>i*f&&u<=(i+m.sampling)*f).length;v.push([i,E])}const r=v[v.length-1],e=r[0],a=r[1];e!==p.w&&v.push([p.w,a]);const l=v.map(i=>i[1]),h=(Math.min(...l)+Math.max(...l))/2;for(let i=0;i<v.length;i++){const E=v[i],u=E[1];E[1]=u*(u>h?1+m.scale:1-m.scale)+m.minHeight}const n=(i,E,u,d)=>{const c=((L,A)=>{const P=A[0]-L[0],_=A[1]-L[1];return{length:Math.sqrt(Math.pow(P,2)+Math.pow(_,2)),angle:Math.atan2(_,P)}})(E||i,u||i),o=T.map(Math.cos(c.angle)*m.flattening,0,1,1,0),s=c.angle*o+(d?Math.PI:0),y=c.length*m.smoothing;return[i[0]+Math.cos(s)*y,i[1]+Math.sin(s)*y]},t=v.map(i=>[T.map(i[0],m.xMin,m.xMax,0,p.w),T.map(i[1],m.yMin,m.yMax,p.h,0)]).reduce((i,E,u,d)=>u===0?`M ${d[d.length-1][0]},${p.h} L ${E[0]},${p.h} L ${E[0]},${E[1]}`:`${i} ${((c,o,s)=>{const y=n(s[o-1],s[o-2],c),L=n(c,s[o-1],s[o+1],!0),A=o===s.length-1?" z":"";return`C ${y[0]},${y[1]} ${L[0]},${L[1]} ${c[0]},${c[1]}${A}`})(E,u,d)}`,"");I.innerHTML=`<svg viewBox="0 0 ${p.w} ${p.h}"><defs><linearGradient id="heatmap-solids" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" style="stop-color:var(--art-theme);stop-opacity:${m.opacity}" /><stop offset="0%" style="stop-color:var(--art-theme);stop-opacity:${m.opacity}" id="heatmap-start" /><stop offset="0%" style="stop-color:var(--art-progress-color);stop-opacity:1" id="heatmap-stop" /><stop offset="100%" style="stop-color:var(--art-progress-color);stop-opacity:1" /></linearGradient></defs><path fill="url(#heatmap-solids)" d="${t}"></path></svg>`,S=C("#heatmap-start",I),g=C("#heatmap-stop",I),S.setAttribute("offset",100*R.played+"%"),g.setAttribute("offset",100*R.played+"%")}R.on("video:timeupdate",()=>{S&&g&&(S.setAttribute("offset",100*R.played+"%"),g.setAttribute("offset",100*R.played+"%"))}),R.on("setBar",(p,m)=>{S&&g&&p==="played"&&(S.setAttribute("offset",100*m+"%"),g.setAttribute("offset",100*m+"%"))}),R.on("ready",x),R.on("resize",x),R.on("artplayerPluginDanmuku:loaded",x)}})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}]},["bgm6t"],"bgm6t","parcelRequire4dc0")})(We);const st=Ke(We.exports);var Ge={exports:{}};(function(ie,fe){var K=function(M){var D=!1;try{if(typeof WebAssembly=="object"&&typeof WebAssembly.instantiate=="function"){const f=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));f instanceof WebAssembly.Module&&(D=new WebAssembly.Instance(f)instanceof WebAssembly.Instance)}}catch{}console.log("WebAssembly support detected: "+(D?"yes":"no"));var T=this;T.canvas=M.canvas,T.renderMode=M.renderMode||(M.lossyRender?"lossy":"wasm-blend"),T.libassMemoryLimit=M.libassMemoryLimit||0,T.libassGlyphLimit=M.libassGlyphLimit||0,T.targetFps=M.targetFps||24,T.prescaleFactor=M.prescaleFactor||1,T.prescaleHeightLimit=M.prescaleHeightLimit||1080,T.maxRenderHeight=M.maxRenderHeight||0,T.dropAllAnimations=M.dropAllAnimations||!1,T.isOurCanvas=!1,T.video=M.video,T.canvasParent=null,T.fonts=M.fonts||[],T.availableFonts=M.availableFonts||[],T.fallbackFont=M.fallbackFont||"default.woff2",T.lazyFileLoading=M.lazyFileLoading||!1,T.onReadyEvent=M.onReady,D?T.workerUrl=M.workerUrl||"subtitles-octopus-worker.js":T.workerUrl=M.legacyWorkerUrl||"subtitles-octopus-worker-legacy.js",T.subUrl=M.subUrl,T.subContent=M.subContent||null,T.onErrorEvent=M.onError,T.debug=M.debug||!1,T.lastRenderTime=0,T.pixelRatio=window.devicePixelRatio||1,T.timeOffset=M.timeOffset||0,T.hasAlphaBug=!1,function(){if(typeof ImageData.prototype.constructor=="function")try{new window.ImageData(new Uint8ClampedArray([0,0,0,0]),1,1);return}catch{console.log("detected that ImageData is not constructable despite browser saying so")}var f=document.createElement("canvas"),r=f.getContext("2d");window.ImageData=function(){var e=0;if(arguments[0]instanceof Uint8ClampedArray)var a=arguments[e++];var l=arguments[e++],h=arguments[e],n=r.createImageData(l,h);return a&&n.data.set(a),n}}(),T.workerError=function(f){if(console.error("Worker error: ",f),T.onErrorEvent&&T.onErrorEvent(f),!T.debug)throw T.dispose(),new Error("Worker error: "+f)},T.init=function(){if(!window.Worker){T.workerError("worker not supported");return}T.worker||(T.worker=new Worker(T.workerUrl),T.worker.addEventListener("message",T.onWorkerMessage),T.worker.addEventListener("error",T.workerError)),T.workerActive=!1,T.createCanvas(),T.setVideo(M.video),T.setSubUrl(M.subUrl),T.worker.postMessage({target:"worker-init",width:T.canvas.width,height:T.canvas.height,URL:document.URL,currentScript:T.workerUrl,preMain:!0,renderMode:T.renderMode,subUrl:T.subUrl,subContent:T.subContent,fonts:T.fonts,availableFonts:T.availableFonts,fallbackFont:T.fallbackFont,lazyFileLoading:T.lazyFileLoading,debug:T.debug,targetFps:T.targetFps,libassMemoryLimit:T.libassMemoryLimit,libassGlyphLimit:T.libassGlyphLimit,dropAllAnimations:T.dropAllAnimations})},T.createCanvas=function(){T.canvas||(T.video?(T.isOurCanvas=!0,T.canvas=document.createElement("canvas"),T.canvas.className="libassjs-canvas",T.canvas.style.display="none",T.canvasParent=document.createElement("div"),T.canvasParent.className="libassjs-canvas-parent",T.canvasParent.appendChild(T.canvas),T.video.nextSibling?T.video.parentNode.insertBefore(T.canvasParent,T.video.nextSibling):T.video.parentNode.appendChild(T.canvasParent)):T.canvas||T.workerError("Don't know where to render: you should give video or canvas in options.")),T.ctx=T.canvas.getContext("2d"),T.bufferCanvas=document.createElement("canvas"),T.bufferCanvasCtx=T.bufferCanvas.getContext("2d"),T.bufferCanvas.width=1,T.bufferCanvas.height=1;var f=new Uint8ClampedArray([0,255,0,0]),r=new ImageData(f,1,1);T.bufferCanvasCtx.clearRect(0,0,1,1),T.ctx.clearRect(0,0,1,1);var e=T.ctx.getImageData(0,0,1,1).data;T.bufferCanvasCtx.putImageData(r,0,0),T.ctx.drawImage(T.bufferCanvas,0,0);var a=T.ctx.getImageData(0,0,1,1).data;T.hasAlphaBug=e[1]!=a[1],T.hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround")};function R(){T.setCurrentTime(T.video.currentTime+T.timeOffset)}function O(){T.setIsPaused(!1,T.video.currentTime+T.timeOffset)}function b(){T.setIsPaused(!0,T.video.currentTime+T.timeOffset)}function C(){T.video.removeEventListener("timeupdate",R,!1)}function I(){T.video.addEventListener("timeupdate",R,!1);var f=T.video.currentTime+T.timeOffset;T.setCurrentTime(f)}function S(){T.setRate(T.video.playbackRate)}function g(){T.setIsPaused(!0,T.video.currentTime+T.timeOffset)}function x(f){f.target.removeEventListener(f.type,x,!1),T.resize()}T.setVideo=function(f){T.video=f,T.video&&(T.video.addEventListener("timeupdate",R,!1),T.video.addEventListener("playing",O,!1),T.video.addEventListener("pause",b,!1),T.video.addEventListener("seeking",C,!1),T.video.addEventListener("seeked",I,!1),T.video.addEventListener("ratechange",S,!1),T.video.addEventListener("waiting",g,!1),document.addEventListener("fullscreenchange",T.resizeWithTimeout,!1),document.addEventListener("mozfullscreenchange",T.resizeWithTimeout,!1),document.addEventListener("webkitfullscreenchange",T.resizeWithTimeout,!1),document.addEventListener("msfullscreenchange",T.resizeWithTimeout,!1),window.addEventListener("resize",T.resizeWithTimeout,!1),typeof ResizeObserver<"u"&&(T.ro=new ResizeObserver(T.resizeWithTimeout),T.ro.observe(T.video)),T.video.videoWidth>0?T.resize():T.video.addEventListener("loadedmetadata",x,!1))},T.getVideoPosition=function(){var f=T.video.videoWidth/T.video.videoHeight,r=T.video.offsetWidth,e=T.video.offsetHeight,a=r/e,l=r,h=e;a>f?l=Math.floor(e*f):h=Math.floor(r/f);var n=(r-l)/2,t=(e-h)/2;return{width:l,height:h,x:n,y:t}},T.setSubUrl=function(f){T.subUrl=f},T.renderFrameData=null;function p(){var f=T.renderFramesData,r=performance.now();T.ctx.clearRect(0,0,T.canvas.width,T.canvas.height);for(var e=0;e<f.canvases.length;e++){var a=f.canvases[e];T.bufferCanvas.width=a.w,T.bufferCanvas.height=a.h;var l=new Uint8ClampedArray(a.buffer);if(T.hasAlphaBug)for(var h=3;h<l.length;h=h+4)l[h]=l[h]>=1?l[h]:1;var n=new ImageData(l,a.w,a.h);T.bufferCanvasCtx.putImageData(n,0,0),T.ctx.drawImage(T.bufferCanvas,a.x,a.y)}if(T.debug){var t=Math.round(performance.now()-r),i=f.blendTime;console.log(typeof i<"u"?"render: "+Math.round(f.spentTime-i)+" ms, blend: "+Math.round(i)+" ms, draw: "+t+" ms; TOTAL="+Math.round(f.spentTime+t)+" ms":Math.round(f.spentTime)+" ms (+ "+t+" ms draw)"),T.renderStart=performance.now()}}function m(){var f=T.renderFramesData,r=performance.now();T.ctx.clearRect(0,0,T.canvas.width,T.canvas.height);for(var e=0;e<f.bitmaps.length;e++){var a=f.bitmaps[e];T.ctx.drawImage(a.bitmap,a.x,a.y)}if(T.debug){var l=Math.round(performance.now()-r);console.log(f.bitmaps.length+" bitmaps, libass: "+Math.round(f.libassTime)+"ms, decode: "+Math.round(f.decodeTime)+"ms, draw: "+l+"ms"),T.renderStart=performance.now()}}T.workerActive=!1,T.frameId=0,T.onWorkerMessage=function(f){T.workerActive||(T.workerActive=!0,T.onReadyEvent&&T.onReadyEvent());var r=f.data;switch(r.target){case"stdout":{console.log(r.content);break}case"console-log":{console.log.apply(console,JSON.parse(r.content));break}case"console-debug":{console.debug.apply(console,JSON.parse(r.content));break}case"console-info":{console.info.apply(console,JSON.parse(r.content));break}case"console-warn":{console.warn.apply(console,JSON.parse(r.content));break}case"console-error":{console.error.apply(console,JSON.parse(r.content));break}case"stderr":{console.error(r.content);break}case"window":{window[r.method]();break}case"canvas":{switch(r.op){case"getContext":{T.ctx=T.canvas.getContext(r.type,r.attributes);break}case"resize":{T.resize(r.width,r.height);break}case"renderCanvas":{T.lastRenderTime<r.time&&(T.lastRenderTime=r.time,T.renderFramesData=r,window.requestAnimationFrame(p));break}case"renderFastCanvas":{T.lastRenderTime<r.time&&(T.lastRenderTime=r.time,T.renderFramesData=r,window.requestAnimationFrame(m));break}case"setObjectProperty":{T.canvas[r.object][r.property]=r.value;break}default:throw"eh?"}break}case"tick":{T.frameId=r.id,T.worker.postMessage({target:"tock",id:T.frameId});break}case"custom":{if(T.onCustomMessage)T.onCustomMessage(f);else throw"Custom message received but client onCustomMessage not implemented.";break}case"setimmediate":{T.worker.postMessage({target:"setimmediate"});break}case"get-events":break;case"get-styles":break;case"ready":break;default:throw"what? "+r.target}};function v(f,r){var e=T.prescaleFactor<=0?1:T.prescaleFactor;if(r<=0||f<=0)f=0,r=0;else{var a=e<1?-1:1,l=r;a*l*e<=a*T.prescaleHeightLimit?l*=e:a*l<a*T.prescaleHeightLimit&&(l=T.prescaleHeightLimit),T.maxRenderHeight>0&&l>T.maxRenderHeight&&(l=T.maxRenderHeight),f*=l/r,r=l}return{width:f,height:r}}T.resize=function(f,r,e,a){var l=null;if(e=e||0,a=a||0,(!f||!r)&&T.video){l=T.getVideoPosition();var h=v(l.width*T.pixelRatio,l.height*T.pixelRatio);f=h.width,r=h.height;var n=T.canvasParent.getBoundingClientRect().top-T.video.getBoundingClientRect().top;e=l.y-n,a=l.x}if(!f||!r){T.video||console.error("width or height is 0. You should specify width & height for resize.");return}(T.canvas.width!=f||T.canvas.height!=r||T.canvas.style.top!=e||T.canvas.style.left!=a)&&(T.canvas.width=f,T.canvas.height=r,l!=null&&(T.canvasParent.style.position="relative",T.canvas.style.display="block",T.canvas.style.position="absolute",T.canvas.style.width=l.width+"px",T.canvas.style.height=l.height+"px",T.canvas.style.top=e+"px",T.canvas.style.left=a+"px",T.canvas.style.pointerEvents="none"),T.worker.postMessage({target:"canvas",width:T.canvas.width,height:T.canvas.height}))},T.resizeWithTimeout=function(){T.resize(),setTimeout(T.resize,100)},T.runBenchmark=function(){T.worker.postMessage({target:"runBenchmark"})},T.customMessage=function(f,r){r=r||{},T.worker.postMessage({target:"custom",userData:f,preMain:r.preMain})},T.setCurrentTime=function(f){T.worker.postMessage({target:"video",currentTime:f})},T.setTrackByUrl=function(f){T.worker.postMessage({target:"set-track-by-url",url:f})},T.setTrack=function(f){T.worker.postMessage({target:"set-track",content:f})},T.freeTrack=function(f){T.worker.postMessage({target:"free-track"})},T.render=T.setCurrentTime,T.setIsPaused=function(f,r){T.worker.postMessage({target:"video",isPaused:f,currentTime:r})},T.setRate=function(f){T.worker.postMessage({target:"video",rate:f})},T.dispose=function(){T.worker.postMessage({target:"destroy"}),T.worker.terminate(),T.worker.removeEventListener("message",T.onWorkerMessage),T.worker.removeEventListener("error",T.workerError),T.workerActive=!1,T.worker=null,T.video&&(T.video.removeEventListener("timeupdate",R,!1),T.video.removeEventListener("playing",O,!1),T.video.removeEventListener("pause",b,!1),T.video.removeEventListener("seeking",C,!1),T.video.removeEventListener("seeked",I,!1),T.video.removeEventListener("ratechange",S,!1),T.video.removeEventListener("waiting",g,!1),T.video.removeEventListener("loadedmetadata",x,!1),document.removeEventListener("fullscreenchange",T.resizeWithTimeout,!1),document.removeEventListener("mozfullscreenchange",T.resizeWithTimeout,!1),document.removeEventListener("webkitfullscreenchange",T.resizeWithTimeout,!1),document.removeEventListener("msfullscreenchange",T.resizeWithTimeout,!1),window.removeEventListener("resize",T.resizeWithTimeout,!1),T.video.parentNode.removeChild(T.canvasParent),T.video=null),T.ro&&(T.ro.disconnect(),T.ro=null),T.onCustomMessage=null,T.onErrorEvent=null,T.onReadyEvent=null},T.fetchFromWorker=function(f,r,e){try{var a=f.target,l=setTimeout(function(){n(Error("Error: Timeout while try to fetch "+a))},5e3),h=function(t){t.data.target==a&&(r(t.data),T.worker.removeEventListener("message",h),T.worker.removeEventListener("error",n),clearTimeout(l))},n=function(t){e(t),T.worker.removeEventListener("message",h),T.worker.removeEventListener("error",n),clearTimeout(l)};T.worker.addEventListener("message",h),T.worker.addEventListener("error",n),T.worker.postMessage(f)}catch(t){e(t)}},T.createEvent=function(f){T.worker.postMessage({target:"create-event",event:f})},T.getEvents=function(f,r){T.fetchFromWorker({target:"get-events"},function(e){f(e.events)},r)},T.setEvent=function(f,r){T.worker.postMessage({target:"set-event",event:f,index:r})},T.removeEvent=function(f){T.worker.postMessage({target:"remove-event",index:f})},T.createStyle=function(f){T.worker.postMessage({target:"create-style",style:f})},T.getStyles=function(f,r){T.fetchFromWorker({target:"get-styles"},function(e){f(e.styles)},r)},T.setStyle=function(f,r){T.worker.postMessage({target:"set-style",style:f,index:r})},T.removeStyle=function(f){T.worker.postMessage({target:"remove-style",index:f})},T.init()};typeof SubtitlesOctopusOnLoad=="function"&&SubtitlesOctopusOnLoad(),ie.exports&&(ie.exports=K)})(Ge);const Je=Ge.exports,Ze= window.__dynamic_base__+"/assets/subtitles-octopus-worker.f95f2186.js",qe= window.__dynamic_base__+"/assets/subtitles-octopus-worker.62892886.wasm",et= window.__dynamic_base__+"/assets/TimesNewRoman.d9fb32eb.ttf",tt= window.__dynamic_base__+"/assets/SourceHanSansCN-Bold.b5627435.woff2";let xe=null;function rt(ie){return/^https?:\/\//.test(ie)}function be(ie){return rt(ie)?ie:new URL(ie,document.baseURI).toString()}function it({workerUrl:ie,wasmUrl:fe}){return new Promise(K=>{fetch(ie).then(M=>M.text()).then(M=>{let D=M;D=D.replace(/wasmBinaryFile\s*=\s*"(subtitles-octopus-worker\.wasm)"/g,(R,O)=>(fe?fe=be(fe):fe=new URL(O,be(ie)).toString(),`wasmBinaryFile = "${fe}"`));const T=new Blob([D],{type:"text/javascript"});K(URL.createObjectURL(T))})})}function Be(ie){xe.canvasParent&&(xe.canvasParent.style.display=ie?"block":"none")}function ot(ie){return async fe=>(xe=new Je({availableFonts:{"times new roman":be(et)},workerUrl:await it({workerUrl:Ze,wasmUrl:qe}),fallbackFont:be(tt),video:fe.template.$video,...ie}),xe.canvasParent.className="artplayer-plugin-ass",xe.canvasParent.style.cssText=`
20
+ position: absolute;
21
+ width: 100%;
22
+ height: 100%;
23
+ user-select: none;
24
+ pointer-events: none;
25
+ z-index: 20;
26
+ `,fe.on("artplayer-plugin-ass:switch",K=>{xe.freeTrack(),xe.setTrackByUrl(K),Be(!0)}),fe.on("subtitle",K=>Be(K)),fe.on("artplayer-plugin-ass:visible",K=>Be(K)),fe.on("subtitleOffset",K=>xe.timeOffset=K),fe.on("destroy",()=>xe.dispose()),{name:"artplayerPluginAss",instance:xe})}var je={exports:{}};(function(ie,fe){typeof window<"u"&&function(M,D){ie.exports=D()}(ke,function(){return function(K){var M={};function D(T){if(M[T])return M[T].exports;var R=M[T]={i:T,l:!1,exports:{}};return K[T].call(R.exports,R,R.exports,D),R.l=!0,R.exports}return D.m=K,D.c=M,D.d=function(T,R,O){D.o(T,R)||Object.defineProperty(T,R,{enumerable:!0,get:O})},D.r=function(T){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(T,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(T,"__esModule",{value:!0})},D.t=function(T,R){if(R&1&&(T=D(T)),R&8||R&4&&typeof T=="object"&&T&&T.__esModule)return T;var O=Object.create(null);if(D.r(O),Object.defineProperty(O,"default",{enumerable:!0,value:T}),R&2&&typeof T!="string")for(var b in T)D.d(O,b,function(C){return T[C]}.bind(null,b));return O},D.n=function(T){var R=T&&T.__esModule?function(){return T.default}:function(){return T};return D.d(R,"a",R),R},D.o=function(T,R){return Object.prototype.hasOwnProperty.call(T,R)},D.p="/dist/",D(D.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(K,M,D){var T=Object.prototype.hasOwnProperty,R="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(R=!1));function b(g,x,p){this.fn=g,this.context=x,this.once=p||!1}function C(g,x,p,m,v){if(typeof p!="function")throw new TypeError("The listener must be a function");var f=new b(p,m||g,v),r=R?R+x:x;return g._events[r]?g._events[r].fn?g._events[r]=[g._events[r],f]:g._events[r].push(f):(g._events[r]=f,g._eventsCount++),g}function I(g,x){--g._eventsCount===0?g._events=new O:delete g._events[x]}function S(){this._events=new O,this._eventsCount=0}S.prototype.eventNames=function(){var x=[],p,m;if(this._eventsCount===0)return x;for(m in p=this._events)T.call(p,m)&&x.push(R?m.slice(1):m);return Object.getOwnPropertySymbols?x.concat(Object.getOwnPropertySymbols(p)):x},S.prototype.listeners=function(x){var p=R?R+x:x,m=this._events[p];if(!m)return[];if(m.fn)return[m.fn];for(var v=0,f=m.length,r=new Array(f);v<f;v++)r[v]=m[v].fn;return r},S.prototype.listenerCount=function(x){var p=R?R+x:x,m=this._events[p];return m?m.fn?1:m.length:0},S.prototype.emit=function(x,p,m,v,f,r){var e=R?R+x:x;if(!this._events[e])return!1;var a=this._events[e],l=arguments.length,h,n;if(a.fn){switch(a.once&&this.removeListener(x,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,p),!0;case 3:return a.fn.call(a.context,p,m),!0;case 4:return a.fn.call(a.context,p,m,v),!0;case 5:return a.fn.call(a.context,p,m,v,f),!0;case 6:return a.fn.call(a.context,p,m,v,f,r),!0}for(n=1,h=new Array(l-1);n<l;n++)h[n-1]=arguments[n];a.fn.apply(a.context,h)}else{var t=a.length,i;for(n=0;n<t;n++)switch(a[n].once&&this.removeListener(x,a[n].fn,void 0,!0),l){case 1:a[n].fn.call(a[n].context);break;case 2:a[n].fn.call(a[n].context,p);break;case 3:a[n].fn.call(a[n].context,p,m);break;case 4:a[n].fn.call(a[n].context,p,m,v);break;default:if(!h)for(i=1,h=new Array(l-1);i<l;i++)h[i-1]=arguments[i];a[n].fn.apply(a[n].context,h)}}return!0},S.prototype.on=function(x,p,m){return C(this,x,p,m,!1)},S.prototype.once=function(x,p,m){return C(this,x,p,m,!0)},S.prototype.removeListener=function(x,p,m,v){var f=R?R+x:x;if(!this._events[f])return this;if(!p)return I(this,f),this;var r=this._events[f];if(r.fn)r.fn===p&&(!v||r.once)&&(!m||r.context===m)&&I(this,f);else{for(var e=0,a=[],l=r.length;e<l;e++)(r[e].fn!==p||v&&!r[e].once||m&&r[e].context!==m)&&a.push(r[e]);a.length?this._events[f]=a.length===1?a[0]:a:I(this,f)}return this},S.prototype.removeAllListeners=function(x){var p;return x?(p=R?R+x:x,this._events[p]&&I(this,p)):(this._events=new O,this._eventsCount=0),this},S.prototype.off=S.prototype.removeListener,S.prototype.addListener=S.prototype.on,S.prefixed=R,S.EventEmitter=S,K.exports=S},"./node_modules/url-toolkit/src/url-toolkit.js":function(K,M,D){(function(T){var R=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,O=/^(?=([^\/?#]*))\1([^]*)$/,b=/(?:\/|^)\.(?=\/)/g,C=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,I={buildAbsoluteURL:function(S,g,x){if(x=x||{},S=S.trim(),g=g.trim(),!g){if(!x.alwaysNormalize)return S;var p=I.parseURL(S);if(!p)throw new Error("Error trying to parse base URL.");return p.path=I.normalizePath(p.path),I.buildURLFromParts(p)}var m=I.parseURL(g);if(!m)throw new Error("Error trying to parse relative URL.");if(m.scheme)return x.alwaysNormalize?(m.path=I.normalizePath(m.path),I.buildURLFromParts(m)):g;var v=I.parseURL(S);if(!v)throw new Error("Error trying to parse base URL.");if(!v.netLoc&&v.path&&v.path[0]!=="/"){var f=O.exec(v.path);v.netLoc=f[1],v.path=f[2]}v.netLoc&&!v.path&&(v.path="/");var r={scheme:v.scheme,netLoc:m.netLoc,path:null,params:m.params,query:m.query,fragment:m.fragment};if(!m.netLoc&&(r.netLoc=v.netLoc,m.path[0]!=="/"))if(!m.path)r.path=v.path,m.params||(r.params=v.params,m.query||(r.query=v.query));else{var e=v.path,a=e.substring(0,e.lastIndexOf("/")+1)+m.path;r.path=I.normalizePath(a)}return r.path===null&&(r.path=x.alwaysNormalize?I.normalizePath(m.path):m.path),I.buildURLFromParts(r)},parseURL:function(S){var g=R.exec(S);return g?{scheme:g[1]||"",netLoc:g[2]||"",path:g[3]||"",params:g[4]||"",query:g[5]||"",fragment:g[6]||""}:null},normalizePath:function(S){for(S=S.split("").reverse().join("").replace(b,"");S.length!==(S=S.replace(C,"")).length;);return S.split("").reverse().join("")},buildURLFromParts:function(S){return S.scheme+S.netLoc+S.path+S.params+S.query+S.fragment}};K.exports=I})()},"./node_modules/webworkify-webpack/index.js":function(K,M,D){function T(x){var p={};function m(f){if(p[f])return p[f].exports;var r=p[f]={i:f,l:!1,exports:{}};return x[f].call(r.exports,r,r.exports,m),r.l=!0,r.exports}m.m=x,m.c=p,m.i=function(f){return f},m.d=function(f,r,e){m.o(f,r)||Object.defineProperty(f,r,{configurable:!1,enumerable:!0,get:e})},m.r=function(f){Object.defineProperty(f,"__esModule",{value:!0})},m.n=function(f){var r=f&&f.__esModule?function(){return f.default}:function(){return f};return m.d(r,"a",r),r},m.o=function(f,r){return Object.prototype.hasOwnProperty.call(f,r)},m.p="/",m.oe=function(f){throw console.error(f),f};var v=m(m.s=ENTRY_MODULE);return v.default||v}var R="[\\.|\\-|\\+|\\w|/|@]+",O="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+R+").*?\\)";function b(x){return(x+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function C(x){return!isNaN(1*x)}function I(x,p,m){var v={};v[m]=[];var f=p.toString(),r=f.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!r)return v;for(var e=r[1],a=new RegExp("(\\\\n|\\W)"+b(e)+O,"g"),l;l=a.exec(f);)l[3]!=="dll-reference"&&v[m].push(l[3]);for(a=new RegExp("\\("+b(e)+'\\("(dll-reference\\s('+R+'))"\\)\\)'+O,"g");l=a.exec(f);)x[l[2]]||(v[m].push(l[1]),x[l[2]]=D(l[1]).m),v[l[2]]=v[l[2]]||[],v[l[2]].push(l[4]);for(var h=Object.keys(v),n=0;n<h.length;n++)for(var t=0;t<v[h[n]].length;t++)C(v[h[n]][t])&&(v[h[n]][t]=1*v[h[n]][t]);return v}function S(x){var p=Object.keys(x);return p.reduce(function(m,v){return m||x[v].length>0},!1)}function g(x,p){for(var m={main:[p]},v={main:[]},f={main:{}};S(m);)for(var r=Object.keys(m),e=0;e<r.length;e++){var a=r[e],l=m[a],h=l.pop();if(f[a]=f[a]||{},!(f[a][h]||!x[a][h])){f[a][h]=!0,v[a]=v[a]||[],v[a].push(h);for(var n=I(x,x[a][h],a),t=Object.keys(n),i=0;i<t.length;i++)m[t[i]]=m[t[i]]||[],m[t[i]]=m[t[i]].concat(n[t[i]])}}return v}K.exports=function(x,p){p=p||{};var m={main:D.m},v=p.all?{main:Object.keys(m.main)}:g(m,x),f="";Object.keys(v).filter(function(h){return h!=="main"}).forEach(function(h){for(var n=0;v[h][n];)n++;v[h].push(n),m[h][n]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",f=f+"var "+h+" = ("+T.toString().replace("ENTRY_MODULE",JSON.stringify(n))+")({"+v[h].map(function(t){return""+JSON.stringify(t)+": "+m[h][t].toString()}).join(",")+`});
27
+ `}),f=f+"new (("+T.toString().replace("ENTRY_MODULE",JSON.stringify(x))+")({"+v.main.map(function(h){return""+JSON.stringify(h)+": "+m.main[h].toString()}).join(",")+"}))(self);";var r=new window.Blob([f],{type:"text/javascript"});if(p.bare)return r;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,a=e.createObjectURL(r),l=new window.Worker(a);return l.objectURL=a,l}},"./src/config.ts":function(K,M,D){D.r(M),D.d(M,"hlsDefaultConfig",function(){return i}),D.d(M,"mergeConfig",function(){return u}),D.d(M,"enableStreamingMode",function(){return d});var T=D("./src/controller/abr-controller.ts"),R=D("./src/controller/audio-stream-controller.ts"),O=D("./src/controller/audio-track-controller.ts"),b=D("./src/controller/subtitle-stream-controller.ts"),C=D("./src/controller/subtitle-track-controller.ts"),I=D("./src/controller/buffer-controller.ts"),S=D("./src/controller/timeline-controller.ts"),g=D("./src/controller/cap-level-controller.ts"),x=D("./src/controller/fps-controller.ts"),p=D("./src/controller/eme-controller.ts"),m=D("./src/controller/cmcd-controller.ts"),v=D("./src/utils/xhr-loader.ts"),f=D("./src/utils/fetch-loader.ts"),r=D("./src/utils/cues.ts"),e=D("./src/utils/mediakeys-helper.ts"),a=D("./src/utils/logger.ts");function l(){return l=Object.assign?Object.assign.bind():function(c){for(var o=1;o<arguments.length;o++){var s=arguments[o];for(var y in s)Object.prototype.hasOwnProperty.call(s,y)&&(c[y]=s[y])}return c},l.apply(this,arguments)}function h(c,o){var s=Object.keys(c);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(c);o&&(y=y.filter(function(L){return Object.getOwnPropertyDescriptor(c,L).enumerable})),s.push.apply(s,y)}return s}function n(c){for(var o=1;o<arguments.length;o++){var s=arguments[o]!=null?arguments[o]:{};o%2?h(Object(s),!0).forEach(function(y){t(c,y,s[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(s)):h(Object(s)).forEach(function(y){Object.defineProperty(c,y,Object.getOwnPropertyDescriptor(s,y))})}return c}function t(c,o,s){return o in c?Object.defineProperty(c,o,{value:s,enumerable:!0,configurable:!0,writable:!0}):c[o]=s,c}var i=n(n({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,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:v.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:T.default,bufferController:I.default,capLevelController:g.default,fpsController:x.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:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},E()),{},{subtitleStreamController:b.SubtitleStreamController,subtitleTrackController:C.default,timelineController:S.TimelineController,audioStreamController:R.default,audioTrackController:O.default,emeController:p.default,cmcdController:m.default});function E(){return{cueHandler:r.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function u(c,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return l({},c,o)}function d(c){var o=c.loader;if(o!==f.default&&o!==v.default)a.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),c.progressive=!1;else{var s=Object(f.fetchSupported)();s&&(c.loader=f.default,c.progressive=!0,c.enableSoftwareAES=!0,a.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(K,M,D){D.r(M);var T=D("./src/polyfills/number.ts"),R=D("./src/utils/ewma-bandwidth-estimator.ts"),O=D("./src/events.ts"),b=D("./src/utils/buffer-helper.ts"),C=D("./src/errors.ts"),I=D("./src/types/loader.ts"),S=D("./src/utils/logger.ts");function g(m,v){for(var f=0;f<v.length;f++){var r=v[f];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(m,r.key,r)}}function x(m,v,f){return v&&g(m.prototype,v),f&&g(m,f),Object.defineProperty(m,"prototype",{writable:!1}),m}var p=function(){function m(f){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=f;var r=f.config;this.bwEstimator=new R.default(r.abrEwmaSlowVoD,r.abrEwmaFastVoD,r.abrEwmaDefaultEstimate),this.registerListeners()}var v=m.prototype;return v.registerListeners=function(){var r=this.hls;r.on(O.Events.FRAG_LOADING,this.onFragLoading,this),r.on(O.Events.FRAG_LOADED,this.onFragLoaded,this),r.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),r.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(O.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var r=this.hls;r.off(O.Events.FRAG_LOADING,this.onFragLoading,this),r.off(O.Events.FRAG_LOADED,this.onFragLoaded,this),r.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),r.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(O.Events.ERROR,this.onError,this)},v.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},v.onFragLoading=function(r,e){var a=e.frag;if(a.type===I.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=a,this.partCurrent=(l=e.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},v.onLevelLoaded=function(r,e){var a=this.hls.config;e.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},v._abandonRulesCheck=function(){var r=this.fragCurrent,e=this.partCurrent,a=this.hls,l=a.autoLevelEnabled,h=a.config,n=a.media;if(!(!r||!n)){var t=e?e.stats:r.stats,i=e?e.duration:r.duration;if(t.aborted){S.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!l||n.paused||!n.playbackRate||!n.readyState)){var E=performance.now()-t.loading.start,u=Math.abs(n.playbackRate);if(!(E<=500*i/u)){var d=a.levels,c=a.minAutoLevel,o=d[r.level],s=t.total||Math.max(t.loaded,Math.round(i*o.maxBitrate/8)),y=Math.max(1,t.bwEstimate?t.bwEstimate/8:t.loaded*1e3/E),L=(s-t.loaded)/y,A=n.currentTime,P=(b.BufferHelper.bufferInfo(n,A,h.maxBufferHole).end-A)/u;if(!(P>=2*i/u||L<=P)){var _=Number.POSITIVE_INFINITY,F;for(F=r.level-1;F>c;F--){var B=d[F].maxBitrate;if(_=i*B/(8*.8*y),_<P)break}if(!(_>=L)){var k=this.bwEstimator.getEstimate();S.logger.warn("Fragment "+r.sn+(e?" part "+e.index:"")+" of level "+r.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+F+`
28
+ Current BW estimate: `+(Object(T.isFiniteNumber)(k)?(k/1024).toFixed(3):"Unknown")+` Kb/s
29
+ Estimated load time for current fragment: `+L.toFixed(3)+` s
30
+ Estimated load time for the next fragment: `+_.toFixed(3)+` s
31
+ Time to underbuffer: `+P.toFixed(3)+" s"),a.nextLoadLevel=F,this.bwEstimator.sample(E,t.loaded),this.clearTimer(),r.loader&&(this.fragCurrent=this.partCurrent=null,r.loader.abort()),a.trigger(O.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:e,stats:t})}}}}}},v.onFragLoaded=function(r,e){var a=e.frag,l=e.part;if(a.type===I.PlaylistLevelType.MAIN&&Object(T.isFiniteNumber)(a.sn)){var h=l?l.stats:a.stats,n=l?l.duration:a.duration;if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var t=this.hls.levels[a.level],i=(t.loaded?t.loaded.bytes:0)+h.loaded,E=(t.loaded?t.loaded.duration:0)+n;t.loaded={bytes:i,duration:E},t.realBitrate=Math.round(8*i/E)}if(a.bitrateTest){var u={stats:h,frag:a,part:l,id:a.type};this.onFragBuffered(O.Events.FRAG_BUFFERED,u),a.bitrateTest=!1}}},v.onFragBuffered=function(r,e){var a=e.frag,l=e.part,h=l?l.stats:a.stats;if(!h.aborted&&!(a.type!==I.PlaylistLevelType.MAIN||a.sn==="initSegment")){var n=h.parsing.end-h.loading.start;this.bwEstimator.sample(n,h.loaded),h.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}},v.onError=function(r,e){switch(e.details){case C.ErrorDetails.FRAG_LOAD_ERROR:case C.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break}},v.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},v.getNextABRAutoLevel=function(){var r=this.fragCurrent,e=this.partCurrent,a=this.hls,l=a.maxAutoLevel,h=a.config,n=a.minAutoLevel,t=a.media,i=e?e.duration:r?r.duration:0,E=t?t.currentTime:0,u=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,d=this.bwEstimator?this.bwEstimator.getEstimate():h.abrEwmaDefaultEstimate,c=(b.BufferHelper.bufferInfo(t,E,h.maxBufferHole).end-E)/u,o=this.findBestLevel(d,n,l,c,h.abrBandWidthFactor,h.abrBandWidthUpFactor);if(o>=0)return o;S.logger.trace((c?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var s=i?Math.min(i,h.maxStarvationDelay):h.maxStarvationDelay,y=h.abrBandWidthFactor,L=h.abrBandWidthUpFactor;if(!c){var A=this.bitrateTestDelay;if(A){var P=i?Math.min(i,h.maxLoadingDelay):h.maxLoadingDelay;s=P-A,S.logger.trace("bitrate test took "+Math.round(1e3*A)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*s)+" ms"),y=L=1}}return o=this.findBestLevel(d,n,l,c+s,y,L),Math.max(o,0)},v.findBestLevel=function(r,e,a,l,h,n){for(var t,i=this.fragCurrent,E=this.partCurrent,u=this.lastLoadedFragLevel,d=this.hls.levels,c=d[u],o=!!(c!=null&&(t=c.details)!==null&&t!==void 0&&t.live),s=c==null?void 0:c.codecSet,y=E?E.duration:i?i.duration:0,L=a;L>=e;L--){var A=d[L];if(!(!A||s&&A.codecSet!==s)){var P=A.details,_=(E?P==null?void 0:P.partTarget:P==null?void 0:P.averagetargetduration)||y,F=void 0;L<=u?F=h*r:F=n*r;var B=d[L].maxBitrate,k=B*_/F;if(S.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+L+"/"+Math.round(F)+"/"+B+"/"+_+"/"+l+"/"+k),F>B&&(!k||o&&!this.bitrateTestDelay||k<l))return L}}return-1},x(m,[{key:"nextAutoLevel",get:function(){var r=this._nextAutoLevel,e=this.bwEstimator;if(r!==-1&&(!e||!e.canEstimate()))return r;var a=this.getNextABRAutoLevel();return r!==-1&&(a=Math.min(r,a)),a},set:function(r){this._nextAutoLevel=r}}]),m}();M.default=p},"./src/controller/audio-stream-controller.ts":function(K,M,D){D.r(M);var T=D("./src/polyfills/number.ts"),R=D("./src/controller/base-stream-controller.ts"),O=D("./src/events.ts"),b=D("./src/utils/buffer-helper.ts"),C=D("./src/controller/fragment-tracker.ts"),I=D("./src/types/level.ts"),S=D("./src/types/loader.ts"),g=D("./src/loader/fragment.ts"),x=D("./src/demux/chunk-cache.ts"),p=D("./src/demux/transmuxer-interface.ts"),m=D("./src/types/transmuxer.ts"),v=D("./src/controller/fragment-finders.ts"),f=D("./src/utils/discontinuities.ts"),r=D("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var E=arguments[i];for(var u in E)Object.prototype.hasOwnProperty.call(E,u)&&(t[u]=E[u])}return t},e.apply(this,arguments)}function a(t,i){t.prototype=Object.create(i.prototype),t.prototype.constructor=t,l(t,i)}function l(t,i){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,d){return u.__proto__=d,u},l(t,i)}var h=100,n=function(t){a(i,t);function i(u,d){var c;return c=t.call(this,u,d,"[audio-stream-controller]")||this,c.videoBuffer=null,c.videoTrackCC=-1,c.waitingVideoCC=-1,c.audioSwitch=!1,c.trackId=-1,c.waitingData=null,c.mainDetails=null,c.bufferFlushed=!1,c.cachedTrackLoadedData=null,c._registerListeners(),c}var E=i.prototype;return E.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},E._registerListeners=function(){var d=this.hls;d.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.on(O.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.on(O.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.on(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.on(O.Events.ERROR,this.onError,this),d.on(O.Events.BUFFER_RESET,this.onBufferReset,this),d.on(O.Events.BUFFER_CREATED,this.onBufferCreated,this),d.on(O.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.on(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._unregisterListeners=function(){var d=this.hls;d.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),d.off(O.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),d.off(O.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),d.off(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),d.off(O.Events.ERROR,this.onError,this),d.off(O.Events.BUFFER_RESET,this.onBufferReset,this),d.off(O.Events.BUFFER_CREATED,this.onBufferCreated,this),d.off(O.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),d.off(O.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onInitPtsFound=function(d,c){var o=c.frag,s=c.id,y=c.initPTS;if(s==="main"){var L=o.cc;this.initPTS[o.cc]=y,this.log("InitPTS for cc: "+L+" found from main: "+y),this.videoTrackCC=L,this.state===R.State.WAITING_INIT_PTS&&this.tick()}},E.startLoad=function(d){if(!this.levels){this.startPosition=d,this.state=R.State.STOPPED;return}var c=this.lastCurrentTime;this.stopLoad(),this.setInterval(h),this.fragLoadError=0,c>0&&d===-1?(this.log("Override startPosition with lastCurrentTime @"+c.toFixed(3)),d=c,this.state=R.State.IDLE):(this.loadedmetadata=!1,this.state=R.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=d,this.tick()},E.doTick=function(){switch(this.state){case R.State.IDLE:this.doTickIdle();break;case R.State.WAITING_TRACK:{var d,c=this.levels,o=this.trackId,s=c==null||(d=c[o])===null||d===void 0?void 0:d.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=R.State.WAITING_INIT_PTS}break}case R.State.FRAG_LOADING_WAITING_RETRY:{var y,L=performance.now(),A=this.retryDate;(!A||L>=A||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=R.State.IDLE);break}case R.State.WAITING_INIT_PTS:{var P=this.waitingData;if(P){var _=P.frag,F=P.part,B=P.cache,k=P.complete;if(this.initPTS[_.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=R.State.FRAG_LOADING;var N=B.flush(),U={frag:_,part:F,payload:N,networkDetails:null};this._handleFragmentLoadProgress(U),k&&t.prototype._handleFragmentLoadComplete.call(this,U)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+_.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var w=this.getLoadPosition(),W=b.BufferHelper.bufferInfo(this.mediaBuffer,w,this.config.maxBufferHole),j=Object(v.fragmentWithinToleranceTest)(W.end,this.config.maxFragLookUpTolerance,_);j<0&&(this.log("Waiting fragment cc ("+_.cc+") @ "+_.start+" cancelled because another fragment at "+W.end+" is needed"),this.clearWaitingFragment())}}else this.state=R.State.IDLE}}this.onTickEnd()},E.clearWaitingFragment=function(){var d=this.waitingData;d&&(this.fragmentTracker.removeFragment(d.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=R.State.IDLE)},E.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},E.onTickEnd=function(){var d=this.media;if(!(!d||!d.readyState)){var c=this.mediaBuffer?this.mediaBuffer:d,o=c.buffered;!this.loadedmetadata&&o.length&&(this.loadedmetadata=!0),this.lastCurrentTime=d.currentTime}},E.doTickIdle=function(){var d,c,o=this.hls,s=this.levels,y=this.media,L=this.trackId,A=o.config;if(!(!s||!s[L])&&!(!y&&(this.startFragRequested||!A.startFragPrefetch))){var P=s[L],_=P.details;if(!_||_.live&&this.levelLastLoaded!==L||this.waitForCdnTuneIn(_)){this.state=R.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,g.ElementaryStreamTypes.AUDIO,S.PlaylistLevelType.AUDIO));var F=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,S.PlaylistLevelType.AUDIO);if(F!==null){var B=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,S.PlaylistLevelType.MAIN),k=F.len,N=this.getMaxBufferLength(B==null?void 0:B.len),U=this.audioSwitch;if(!(k>=N&&!U)){if(!U&&this._streamEnded(F,_)){o.trigger(O.Events.BUFFER_EOS,{type:"audio"}),this.state=R.State.ENDED;return}var w=_.fragments,W=w[0].start,j=F.end;if(U){var H=this.getLoadPosition();j=H,_.PTSKnown&&H<W&&(F.end>W||F.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),y.currentTime=W+.05)}if(!(B&&j>B.end+_.targetduration)&&!((!B||!B.len)&&F.len)){var G=this.getNextFragment(j,_);if(!G){this.bufferFlushed=!0;return}((d=G.decryptdata)===null||d===void 0?void 0:d.keyFormat)==="identity"&&!((c=G.decryptdata)!==null&&c!==void 0&&c.key)?this.loadKey(G,_):this.loadFragment(G,_,j)}}}}},E.getMaxBufferLength=function(d){var c=t.prototype.getMaxBufferLength.call(this);return d?Math.max(c,d):c},E.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},E.onAudioTracksUpdated=function(d,c){var o=c.audioTracks;this.resetTransmuxer(),this.levels=o.map(function(s){return new I.Level(s)})},E.onAudioTrackSwitching=function(d,c){var o=!!c.url;this.trackId=c.id;var s=this.fragCurrent;s!=null&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),o?this.setInterval(h):this.resetTransmuxer(),o?(this.audioSwitch=!0,this.state=R.State.IDLE):this.state=R.State.STOPPED,this.tick()},E.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},E.onLevelLoaded=function(d,c){this.mainDetails=c.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(O.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},E.onAudioTrackLoaded=function(d,c){var o;if(this.mainDetails==null){this.cachedTrackLoadedData=c;return}var s=this.levels,y=c.details,L=c.id;if(!s){this.warn("Audio tracks were reset while loading level "+L);return}this.log("Track "+L+" loaded ["+y.startSN+","+y.endSN+"],duration:"+y.totalduration);var A=s[L],P=0;if(y.live||(o=A.details)!==null&&o!==void 0&&o.live){var _=this.mainDetails;if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed||!_)return;!A.details&&y.hasProgramDateTime&&_.hasProgramDateTime?(Object(f.alignMediaPlaylistByPDT)(y,_),P=y.fragments[0].start):P=this.alignPlaylists(y,A.details)}A.details=y,this.levelLastLoaded=L,!this.startFragRequested&&(this.mainDetails||!y.live)&&this.setStartPosition(A.details,P),this.state===R.State.WAITING_TRACK&&!this.waitForCdnTuneIn(y)&&(this.state=R.State.IDLE),this.tick()},E._handleFragmentLoadProgress=function(d){var c,o=d.frag,s=d.part,y=d.payload,L=this.config,A=this.trackId,P=this.levels;if(!P){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+o.sn+" of level "+o.level+" will not be buffered");return}var _=P[A];console.assert(_,"Audio track is defined on fragment load progress");var F=_.details;console.assert(F,"Audio track details are defined on fragment load progress");var B=L.defaultAudioCodec||_.audioCodec||"mp4a.40.2",k=this.transmuxer;k||(k=this.transmuxer=new p.default(this.hls,S.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var N=this.initPTS[o.cc],U=(c=o.initSegment)===null||c===void 0?void 0:c.data;if(N!==void 0){var w=!1,W=s?s.index:-1,j=W!==-1,H=new m.ChunkMetadata(o.level,o.sn,o.stats.chunkCount,y.byteLength,W,j);k.push(y,U,B,"",o,s,F.totalduration,w,H,N)}else{this.log("Unknown video PTS for cc "+o.cc+", waiting for video PTS before demuxing audio frag "+o.sn+" of ["+F.startSN+" ,"+F.endSN+"],track "+A);var G=this.waitingData=this.waitingData||{frag:o,part:s,cache:new x.default,complete:!1},Y=G.cache;Y.push(new Uint8Array(y)),this.waitingVideoCC=this.videoTrackCC,this.state=R.State.WAITING_INIT_PTS}},E._handleFragmentLoadComplete=function(d){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,d)},E.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},E.onBufferCreated=function(d,c){var o=c.tracks.audio;o&&(this.mediaBuffer=o.buffer),c.tracks.video&&(this.videoBuffer=c.tracks.video.buffer)},E.onFragBuffered=function(d,c){var o=c.frag,s=c.part;if(o.type===S.PlaylistLevelType.AUDIO){if(this.fragContextChanged(o)){this.warn("Fragment "+o.sn+(s?" p: "+s.index:"")+" of level "+o.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}o.sn!=="initSegment"&&(this.fragPrevious=o,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(O.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(o,s)}},E.onError=function(d,c){switch(c.details){case r.ErrorDetails.FRAG_LOAD_ERROR:case r.ErrorDetails.FRAG_LOAD_TIMEOUT:case r.ErrorDetails.KEY_LOAD_ERROR:case r.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(S.PlaylistLevelType.AUDIO,c);break;case r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==R.State.ERROR&&this.state!==R.State.STOPPED&&(this.state=c.fatal?R.State.ERROR:R.State.IDLE,this.warn(c.details+" while loading frag, switching to "+this.state+" state"));break;case r.ErrorDetails.BUFFER_FULL_ERROR:if(c.parent==="audio"&&(this.state===R.State.PARSING||this.state===R.State.PARSED)){var o=!0,s=this.getFwdBufferInfo(this.mediaBuffer,S.PlaylistLevelType.AUDIO);s&&s.len>.5&&(o=!this.reduceMaxBufferLength(s.len)),o&&(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}},E.onBufferFlushed=function(d,c){var o=c.type;o===g.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},E._handleTransmuxComplete=function(d){var c,o="audio",s=this.hls,y=d.remuxResult,L=d.chunkMeta,A=this.getCurrentContext(L);if(!A){this.warn("The loading context changed while buffering fragment "+L.sn+" of level "+L.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(L.level);return}var P=A.frag,_=A.part,F=A.level.details,B=y.audio,k=y.text,N=y.id3,U=y.initSegment;if(!(this.fragContextChanged(P)||!F)){if(this.state=R.State.PARSING,this.audioSwitch&&B&&this.completeAudioSwitch(),U!=null&&U.tracks&&(this._bufferInitSegment(U.tracks,P,L),s.trigger(O.Events.FRAG_PARSING_INIT_SEGMENT,{frag:P,id:o,tracks:U.tracks})),B){var w=B.startPTS,W=B.endPTS,j=B.startDTS,H=B.endDTS;_&&(_.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:w,endPTS:W,startDTS:j,endDTS:H}),P.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,w,W,j,H),this.bufferFragmentData(B,P,_,L)}if(N!=null&&(c=N.samples)!==null&&c!==void 0&&c.length){var G=e({id:o,frag:P,details:F},N);s.trigger(O.Events.FRAG_PARSING_METADATA,G)}if(k){var Y=e({id:o,frag:P,details:F},k);s.trigger(O.Events.FRAG_PARSING_USERDATA,Y)}}},E._bufferInitSegment=function(d,c,o){if(this.state===R.State.PARSING){d.video&&delete d.video;var s=d.audio;if(!!s){s.levelCodec=s.codec,s.id="audio",this.log("Init audio buffer, container:"+s.container+", codecs[parsed]=["+s.codec+"]"),this.hls.trigger(O.Events.BUFFER_CODECS,d);var y=s.initSegment;if(y!=null&&y.byteLength){var L={type:"audio",frag:c,part:null,chunkMeta:o,parent:c.type,data:y};this.hls.trigger(O.Events.BUFFER_APPENDING,L)}this.tick()}}},E.loadFragment=function(d,c,o){var s=this.fragmentTracker.getState(d);this.fragCurrent=d,(this.audioSwitch||s===C.FragmentState.NOT_LOADED||s===C.FragmentState.PARTIAL)&&(d.sn==="initSegment"?this._loadInitSegment(d):c.live&&!Object(T.isFiniteNumber)(this.initPTS[d.cc])?(this.log("Waiting for video PTS in continuity counter "+d.cc+" of live stream before loading audio fragment "+d.sn+" of level "+this.trackId),this.state=R.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,d,c,o)))},E.completeAudioSwitch=function(){var d=this.hls,c=this.media,o=this.trackId;c&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,d.trigger(O.Events.AUDIO_TRACK_SWITCHED,{id:o})},i}(R.default);M.default=n},"./src/controller/audio-track-controller.ts":function(K,M,D){D.r(M);var T=D("./src/events.ts"),R=D("./src/errors.ts"),O=D("./src/controller/base-playlist-controller.ts"),b=D("./src/types/loader.ts");function C(p,m){for(var v=0;v<m.length;v++){var f=m[v];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(p,f.key,f)}}function I(p,m,v){return m&&C(p.prototype,m),v&&C(p,v),Object.defineProperty(p,"prototype",{writable:!1}),p}function S(p,m){p.prototype=Object.create(m.prototype),p.prototype.constructor=p,g(p,m)}function g(p,m){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,r){return f.__proto__=r,f},g(p,m)}var x=function(p){S(m,p);function m(f){var r;return r=p.call(this,f,"[audio-track-controller]")||this,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}var v=m.prototype;return v.registerListeners=function(){var r=this.hls;r.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(T.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(T.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(T.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(T.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var r=this.hls;r.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(T.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(T.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(T.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(T.Events.ERROR,this.onError,this)},v.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,p.prototype.destroy.call(this)},v.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},v.onManifestParsed=function(r,e){this.tracks=e.audioTracks||[]},v.onAudioTrackLoaded=function(r,e){var a=e.id,l=e.details,h=this.tracksInGroup[a];if(!h){this.warn("Invalid audio track id "+a);return}var n=h.details;h.details=e.details,this.log("audioTrack "+a+" loaded ["+l.startSN+"-"+l.endSN+"]"),a===this.trackId&&(this.retryCount=0,this.playlistLoaded(a,e,n))},v.onLevelLoading=function(r,e){this.switchLevel(e.level)},v.onLevelSwitching=function(r,e){this.switchLevel(e.level)},v.switchLevel=function(r){var e=this.hls.levels[r];if(!!(e!=null&&e.audioGroupIds)){var a=e.audioGroupIds[e.urlId];if(this.groupId!==a){this.groupId=a;var l=this.tracks.filter(function(n){return!a||n.groupId===a});this.selectDefaultTrack&&!l.some(function(n){return n.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=l;var h={audioTracks:l};this.log("Updating audio tracks, "+l.length+' track(s) found in "'+a+'" group-id'),this.hls.trigger(T.Events.AUDIO_TRACKS_UPDATED,h),this.selectInitialTrack()}}},v.onError=function(r,e){p.prototype.onError.call(this,r,e),!(e.fatal||!e.context)&&e.context.type===b.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},v.setAudioTrack=function(r){var e=this.tracksInGroup;if(r<0||r>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var a=e[this.trackId];this.log("Now switching to audio-track index "+r);var l=e[r],h=l.id,n=l.groupId,t=n===void 0?"":n,i=l.name,E=l.type,u=l.url;if(this.trackId=r,this.trackName=i,this.selectDefaultTrack=!1,this.hls.trigger(T.Events.AUDIO_TRACK_SWITCHING,{id:h,groupId:t,name:i,type:E,url:u}),!(l.details&&!l.details.live)){var d=this.switchParams(l.url,a==null?void 0:a.details);this.loadPlaylist(d)}},v.selectInitialTrack=function(){var r=this.tracksInGroup;console.assert(r.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,a=this.findTrackId(e)||this.findTrackId();a!==-1?this.setAudioTrack(a):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},v.findTrackId=function(r){for(var e=this.tracksInGroup,a=0;a<e.length;a++){var l=e[a];if((!this.selectDefaultTrack||l.default)&&(!r||r===l.name))return l.id}return-1},v.loadPlaylist=function(r){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var a=e.id,l=e.groupId,h=e.url;if(r)try{h=r.addDirectives(h)}catch(n){this.warn("Could not construct new URL with HLS Delivery Directives: "+n)}this.log("loading audio-track playlist for id: "+a),this.clearTimer(),this.hls.trigger(T.Events.AUDIO_TRACK_LOADING,{url:h,id:a,groupId:l,deliveryDirectives:r||null})}},I(m,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1,this.setAudioTrack(r)}}]),m}(O.default);M.default=x},"./src/controller/base-playlist-controller.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return I});var T=D("./src/polyfills/number.ts"),R=D("./src/types/level.ts"),O=D("./src/controller/level-helper.ts"),b=D("./src/utils/logger.ts"),C=D("./src/errors.ts"),I=function(){function S(x,p){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=b.logger.log.bind(b.logger,p+":"),this.warn=b.logger.warn.bind(b.logger,p+":"),this.hls=x}var g=S.prototype;return g.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},g.onError=function(p,m){m.fatal&&m.type===C.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},g.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},g.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},g.stopLoad=function(){this.canLoad=!1,this.clearTimer()},g.switchParams=function(p,m){var v=m==null?void 0:m.renditionReports;if(v)for(var f=0;f<v.length;f++){var r=v[f],e=""+r.URI;if(e===p.slice(-e.length)){var a=parseInt(r["LAST-MSN"]),l=parseInt(r["LAST-PART"]);if(m&&this.hls.config.lowLatencyMode){var h=Math.min(m.age-m.partTarget,m.targetduration);l!==void 0&&h>m.partTarget&&(l+=1)}if(Object(T.isFiniteNumber)(a))return new R.HlsUrlParameters(a,Object(T.isFiniteNumber)(l)?l:void 0,R.HlsSkip.No)}}},g.loadPlaylist=function(p){},g.shouldLoadTrack=function(p){return this.canLoad&&p&&!!p.url&&(!p.details||p.details.live)},g.playlistLoaded=function(p,m,v){var f=this,r=m.details,e=m.stats,a=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(r.advancedDateTime=Date.now()-a,r.live||v!=null&&v.live){if(r.reloaded(v),v&&this.log("live playlist "+p+" "+(r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:"MISSED")),v&&r.fragments.length>0&&Object(O.mergeDetails)(v,r),!this.canLoad||!r.live)return;var l,h=void 0,n=void 0;if(r.canBlockReload&&r.endSN&&r.advanced){var t=this.hls.config.lowLatencyMode,i=r.lastPartSn,E=r.endSN,u=r.lastPartIndex,d=u!==-1,c=i===E,o=t?0:u;d?(h=c?E+1:i,n=c?o:u+1):h=E+1;var s=r.age,y=s+r.ageHeader,L=Math.min(y-r.partTarget,r.targetduration*1.5);if(L>0){if(v&&L>v.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+v.tuneInGoal+" to: "+L+" with playlist age: "+r.age),L=0;else{var A=Math.floor(L/r.targetduration);if(h+=A,n!==void 0){var P=Math.round(L%r.targetduration/r.partTarget);n+=P}this.log("CDN Tune-in age: "+r.ageHeader+"s last advanced "+s.toFixed(2)+"s goal: "+L+" skip sn "+A+" to part "+n)}r.tuneInGoal=L}if(l=this.getDeliveryDirectives(r,m.deliveryDirectives,h,n),t||!c){this.loadPlaylist(l);return}}else l=this.getDeliveryDirectives(r,m.deliveryDirectives,h,n);var _=Object(O.computeReloadInterval)(r,e);h!==void 0&&r.canBlockReload&&(_-=r.partTarget||1),this.log("reload live playlist "+p+" in "+Math.round(_)+" ms"),this.timer=self.setTimeout(function(){return f.loadPlaylist(l)},_)}else this.clearTimer()},g.getDeliveryDirectives=function(p,m,v,f){var r=Object(R.getSkipValue)(p,v);return m!=null&&m.skip&&p.deltaUpdateFailed&&(v=m.msn,f=m.part,r=R.HlsSkip.No),new R.HlsUrlParameters(v,f,r)},g.retryLoadingOrFail=function(p){var m=this,v=this.hls.config,f=this.retryCount<v.levelLoadingMaxRetry;if(f){var r;if(this.retryCount++,p.details.indexOf("LoadTimeOut")>-1&&(r=p.context)!==null&&r!==void 0&&r.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+p.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*v.levelLoadingRetryDelay,v.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return m.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+p.details+'"')}}else this.warn('cannot recover from error "'+p.details+'"'),this.clearTimer(),p.fatal=!0;return f},S}()},"./src/controller/base-stream-controller.ts":function(K,M,D){D.r(M),D.d(M,"State",function(){return E}),D.d(M,"default",function(){return u});var T=D("./src/polyfills/number.ts"),R=D("./src/task-loop.ts"),O=D("./src/controller/fragment-tracker.ts"),b=D("./src/utils/buffer-helper.ts"),C=D("./src/utils/logger.ts"),I=D("./src/events.ts"),S=D("./src/errors.ts"),g=D("./src/types/transmuxer.ts"),x=D("./src/utils/mp4-tools.ts"),p=D("./src/utils/discontinuities.ts"),m=D("./src/controller/fragment-finders.ts"),v=D("./src/controller/level-helper.ts"),f=D("./src/loader/fragment-loader.ts"),r=D("./src/crypt/decrypter.ts"),e=D("./src/utils/time-ranges.ts"),a=D("./src/types/loader.ts");function l(d,c){for(var o=0;o<c.length;o++){var s=c[o];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(d,s.key,s)}}function h(d,c,o){return c&&l(d.prototype,c),o&&l(d,o),Object.defineProperty(d,"prototype",{writable:!1}),d}function n(d){if(d===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d}function t(d,c){d.prototype=Object.create(c.prototype),d.prototype.constructor=d,i(d,c)}function i(d,c){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,y){return s.__proto__=y,s},i(d,c)}var E={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},u=function(d){t(c,d);function c(s,y,L){var A;return A=d.call(this)||this,A.hls=void 0,A.fragPrevious=null,A.fragCurrent=null,A.fragmentTracker=void 0,A.transmuxer=null,A._state=E.STOPPED,A.media=void 0,A.mediaBuffer=void 0,A.config=void 0,A.bitrateTest=!1,A.lastCurrentTime=0,A.nextLoadPosition=0,A.startPosition=0,A.loadedmetadata=!1,A.fragLoadError=0,A.retryDate=0,A.levels=null,A.fragmentLoader=void 0,A.levelLastLoaded=null,A.startFragRequested=!1,A.decrypter=void 0,A.initPTS=[],A.onvseeking=null,A.onvended=null,A.logPrefix="",A.log=void 0,A.warn=void 0,A.logPrefix=L,A.log=C.logger.log.bind(C.logger,L+":"),A.warn=C.logger.warn.bind(C.logger,L+":"),A.hls=s,A.fragmentLoader=new f.default(s.config),A.fragmentTracker=y,A.config=s.config,A.decrypter=new r.default(s,s.config),s.on(I.Events.KEY_LOADED,A.onKeyLoaded,n(A)),A}var o=c.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(y){},o.stopLoad=function(){this.fragmentLoader.abort();var y=this.fragCurrent;y&&this.fragmentTracker.removeFragment(y),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=E.STOPPED},o._streamEnded=function(y,L){var A=this.fragCurrent,P=this.fragmentTracker;if(!L.live&&A&&A.sn>=L.endSN&&!y.nextStart){var _=L.partList;if(_!=null&&_.length){var F=_[_.length-1],B=b.BufferHelper.isBuffered(this.media,F.start+F.duration/2);return B}var k=P.getState(A);return k===O.FragmentState.PARTIAL||k===O.FragmentState.OK}return!1},o.onMediaAttached=function(y,L){var A=this.media=this.mediaBuffer=L.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),A.addEventListener("seeking",this.onvseeking),A.addEventListener("ended",this.onvended);var P=this.config;this.levels&&P.autoStartLoad&&this.state===E.STOPPED&&this.startLoad(P.startPosition)},o.onMediaDetaching=function(){var y=this.media;y!=null&&y.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),y&&(y.removeEventListener("seeking",this.onvseeking),y.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},o.onMediaSeeking=function(){var y=this.config,L=this.fragCurrent,A=this.media,P=this.mediaBuffer,_=this.state,F=A?A.currentTime:0,B=b.BufferHelper.bufferInfo(P||A,F,y.maxBufferHole);if(this.log("media seeking to "+(Object(T.isFiniteNumber)(F)?F.toFixed(3):F)+", state: "+_),_===E.ENDED)this.resetLoadingState();else if(L&&!B.len){var k=y.maxFragLookUpTolerance,N=L.start-k,U=L.start+L.duration+k,w=F>U;(F<N||w)&&(w&&L.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),L.loader.abort()),this.resetLoadingState())}A&&(this.lastCurrentTime=F),!this.loadedmetadata&&!B.len&&(this.nextLoadPosition=this.startPosition=F),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onKeyLoaded=function(y,L){if(!(this.state!==E.KEY_LOADING||L.frag!==this.fragCurrent||!this.levels)){this.state=E.IDLE;var A=this.levels[L.frag.level].details;A&&this.loadFragment(L.frag,A,L.frag.start)}},o.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=E.STOPPED,this.hls.off(I.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,d.prototype.onHandlerDestroyed.call(this)},o.loadKey=function(y,L){this.log("Loading key for "+y.sn+" of ["+L.startSN+"-"+L.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level),this.state=E.KEY_LOADING,this.fragCurrent=y,this.hls.trigger(I.Events.KEY_LOADING,{frag:y})},o.loadFragment=function(y,L,A){this._loadFragForPlayback(y,L,A)},o._loadFragForPlayback=function(y,L,A){var P=this,_=function(B){if(P.fragContextChanged(y)){P.warn("Fragment "+y.sn+(B.part?" p: "+B.part.index:"")+" of level "+y.level+" was dropped during download."),P.fragmentTracker.removeFragment(y);return}y.stats.chunkCount++,P._handleFragmentLoadProgress(B)};this._doFragLoad(y,L,A,_).then(function(F){if(!!F){P.fragLoadError=0;var B=P.state;if(P.fragContextChanged(y)){(B===E.FRAG_LOADING||!P.fragCurrent&&B===E.PARSING)&&(P.fragmentTracker.removeFragment(y),P.state=E.IDLE);return}"payload"in F&&(P.log("Loaded fragment "+y.sn+" of level "+y.level),P.hls.trigger(I.Events.FRAG_LOADED,F)),P._handleFragmentLoadComplete(F)}}).catch(function(F){P.state!==E.STOPPED&&(P.warn(F),P.resetFragmentLoading(y))})},o.flushMainBuffer=function(y,L,A){if(A===void 0&&(A=null),!!(y-L)){var P={startOffset:y,endOffset:L,type:A};this.fragLoadError=0,this.hls.trigger(I.Events.BUFFER_FLUSHING,P)}},o._loadInitSegment=function(y){var L=this;this._doFragLoad(y).then(function(A){if(!A||L.fragContextChanged(y)||!L.levels)throw new Error("init load aborted");return A}).then(function(A){var P=L.hls,_=A.payload,F=y.decryptdata;if(_&&_.byteLength>0&&F&&F.key&&F.iv&&F.method==="AES-128"){var B=self.performance.now();return L.decrypter.webCryptoDecrypt(new Uint8Array(_),F.key.buffer,F.iv.buffer).then(function(k){var N=self.performance.now();return P.trigger(I.Events.FRAG_DECRYPTED,{frag:y,payload:k,stats:{tstart:B,tdecrypt:N}}),A.payload=k,A})}return A}).then(function(A){var P=L.fragCurrent,_=L.hls,F=L.levels;if(!F)throw new Error("init load aborted, missing levels");var B=F[y.level].details;console.assert(B,"Level details are defined when init segment is loaded");var k=y.stats;L.state=E.IDLE,L.fragLoadError=0,y.data=new Uint8Array(A.payload),k.parsing.start=k.buffering.start=self.performance.now(),k.parsing.end=k.buffering.end=self.performance.now(),A.frag===P&&_.trigger(I.Events.FRAG_BUFFERED,{stats:k,frag:P,part:null,id:y.type}),L.tick()}).catch(function(A){L.warn(A),L.resetFragmentLoading(y)})},o.fragContextChanged=function(y){var L=this.fragCurrent;return!y||!L||y.level!==L.level||y.sn!==L.sn||y.urlId!==L.urlId},o.fragBufferedComplete=function(y,L){var A=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+y.type+" sn: "+y.sn+(L?" part: "+L.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+y.level+" "+e.default.toString(b.BufferHelper.getBuffered(A))),this.state=E.IDLE,this.tick()},o._handleFragmentLoadComplete=function(y){var L=this.transmuxer;if(!!L){var A=y.frag,P=y.part,_=y.partsLoaded,F=!_||_.length===0||_.some(function(k){return!k}),B=new g.ChunkMetadata(A.level,A.sn,A.stats.chunkCount+1,0,P?P.index:-1,!F);L.flush(B)}},o._handleFragmentLoadProgress=function(y){},o._doFragLoad=function(y,L,A,P){var _=this;if(A===void 0&&(A=null),!this.levels)throw new Error("frag load aborted, missing levels");if(A=Math.max(y.start,A||0),this.config.lowLatencyMode&&L){var F=L.partList;if(F&&P){A>y.end&&L.fragmentHint&&(y=L.fragmentHint);var B=this.getNextPart(F,y,A);if(B>-1){var k=F[B];return this.log("Loading part sn: "+y.sn+" p: "+k.index+" cc: "+y.cc+" of playlist ["+L.startSN+"-"+L.endSN+"] parts [0-"+B+"-"+(F.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(A.toFixed(3))),this.nextLoadPosition=k.start+k.duration,this.state=E.FRAG_LOADING,this.hls.trigger(I.Events.FRAG_LOADING,{frag:y,part:F[B],targetBufferTime:A}),this.doFragPartsLoad(y,F,B,P).catch(function(N){return _.handleFragLoadError(N)})}else if(!y.url||this.loadedEndOfParts(F,A))return Promise.resolve(null)}}return this.log("Loading fragment "+y.sn+" cc: "+y.cc+" "+(L?"of ["+L.startSN+"-"+L.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+y.level+", target: "+parseFloat(A.toFixed(3))),Object(T.isFiniteNumber)(y.sn)&&!this.bitrateTest&&(this.nextLoadPosition=y.start+y.duration),this.state=E.FRAG_LOADING,this.hls.trigger(I.Events.FRAG_LOADING,{frag:y,targetBufferTime:A}),this.fragmentLoader.load(y,P).catch(function(N){return _.handleFragLoadError(N)})},o.doFragPartsLoad=function(y,L,A,P){var _=this;return new Promise(function(F,B){var k=[],N=function U(w){var W=L[w];_.fragmentLoader.loadPart(y,W,P).then(function(j){k[W.index]=j;var H=j.part;_.hls.trigger(I.Events.FRAG_LOADED,j);var G=L[w+1];if(G&&G.fragment===y)U(w+1);else return F({frag:y,part:H,partsLoaded:k})}).catch(B)};N(A)})},o.handleFragLoadError=function(y){var L=y.data;return L&&L.details===S.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(L.frag,L.part):this.hls.trigger(I.Events.ERROR,L),null},o._handleTransmuxerFlush=function(y){var L=this.getCurrentContext(y);if(!L||this.state!==E.PARSING){this.fragCurrent||(this.state=E.IDLE);return}var A=L.frag,P=L.part,_=L.level,F=self.performance.now();A.stats.parsing.end=F,P&&(P.stats.parsing.end=F),this.updateLevelTiming(A,P,_,y.partial)},o.getCurrentContext=function(y){var L=this.levels,A=y.level,P=y.sn,_=y.part;if(!L||!L[A])return this.warn("Levels object was unset while buffering fragment "+P+" of level "+A+". The current chunk will not be buffered."),null;var F=L[A],B=_>-1?Object(v.getPartWith)(F,P,_):null,k=B?B.fragment:Object(v.getFragmentWithSN)(F,P,this.fragCurrent);return k?{frag:k,part:B,level:F}:null},o.bufferFragmentData=function(y,L,A,P){if(!(!y||this.state!==E.PARSING)){var _=y.data1,F=y.data2,B=_;if(_&&F&&(B=Object(x.appendUint8Array)(_,F)),!(!B||!B.length)){var k={type:y.type,frag:L,part:A,chunkMeta:P,parent:L.type,data:B};this.hls.trigger(I.Events.BUFFER_APPENDING,k),y.dropped&&y.independent&&!A&&this.flushBufferGap(L)}}},o.flushBufferGap=function(y){var L=this.media;if(!!L){if(!b.BufferHelper.isBuffered(L,L.currentTime)){this.flushMainBuffer(0,y.start);return}var A=L.currentTime,P=b.BufferHelper.bufferInfo(L,A,0),_=y.duration,F=Math.min(this.config.maxFragLookUpTolerance*2,_*.25),B=Math.max(Math.min(y.start-F,P.end-F),A+F);y.start-B>F&&this.flushMainBuffer(B,y.start)}},o.getFwdBufferInfo=function(y,L){var A=this.config,P=this.getLoadPosition();if(!Object(T.isFiniteNumber)(P))return null;var _=b.BufferHelper.bufferInfo(y,P,A.maxBufferHole);if(_.len===0&&_.nextStart!==void 0){var F=this.fragmentTracker.getBufferedFrag(P,L);if(F&&_.nextStart<F.end)return b.BufferHelper.bufferInfo(y,P,Math.max(_.nextStart,A.maxBufferHole))}return _},o.getMaxBufferLength=function(y){var L=this.config,A;return y?A=Math.max(8*L.maxBufferSize/y,L.maxBufferLength):A=L.maxBufferLength,Math.min(A,L.maxMaxBufferLength)},o.reduceMaxBufferLength=function(y){var L=this.config,A=y||L.maxBufferLength;return L.maxMaxBufferLength>=A?(L.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+L.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(y,L){var A=L.fragments,P=A.length;if(!P)return null;var _=this.config,F=A[0].start,B;if(L.live){var k=_.initialLiveManifestSize;if(P<k)return this.warn("Not enough fragments to start playback (have: "+P+", need: "+k+")"),null;!L.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(B=this.getInitialLiveFragment(L,A),this.startPosition=B?this.hls.liveSyncPosition||B.start:y)}else y<=F&&(B=A[0]);if(!B){var N=_.lowLatencyMode?L.partEnd:L.fragmentEnd;B=this.getFragmentAtPosition(y,N,L)}return this.mapToInitFragWhenRequired(B)},o.mapToInitFragWhenRequired=function(y){return y!=null&&y.initSegment&&!(y!=null&&y.initSegment.data)&&!this.bitrateTest?y.initSegment:y},o.getNextPart=function(y,L,A){for(var P=-1,_=!1,F=!0,B=0,k=y.length;B<k;B++){var N=y[B];if(F=F&&!N.independent,P>-1&&A<N.start)break;var U=N.loaded;!U&&(_||N.independent||F)&&N.fragment===L&&(P=B),_=U}return P},o.loadedEndOfParts=function(y,L){var A=y[y.length-1];return A&&L>A.start&&A.loaded},o.getInitialLiveFragment=function(y,L){var A=this.fragPrevious,P=null;if(A){if(y.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+A.programDateTime),P=Object(m.findFragmentByPDT)(L,A.endProgramDateTime,this.config.maxFragLookUpTolerance)),!P){var _=A.sn+1;if(_>=y.startSN&&_<=y.endSN){var F=L[_-y.startSN];A.cc===F.cc&&(P=F,this.log("Live playlist, switching playlist, load frag with next SN: "+P.sn))}P||(P=Object(m.findFragWithCC)(L,A.cc),P&&this.log("Live playlist, switching playlist, load frag with same CC: "+P.sn))}}else{var B=this.hls.liveSyncPosition;B!==null&&(P=this.getFragmentAtPosition(B,this.bitrateTest?y.fragmentEnd:y.edge,y))}return P},o.getFragmentAtPosition=function(y,L,A){var P=this.config,_=this.fragPrevious,F=A.fragments,B=A.endSN,k=A.fragmentHint,N=P.maxFragLookUpTolerance,U=!!(P.lowLatencyMode&&A.partList&&k);U&&k&&!this.bitrateTest&&(F=F.concat(k),B=k.sn);var w;if(y<L){var W=y>L-N?0:N;w=Object(m.findFragmentByPTS)(_,F,y,W)}else w=F[F.length-1];if(w){var j=w.sn-A.startSN,H=_&&w.level===_.level,G=F[j+1];_&&w.sn===_.sn&&!U&&H&&(w.sn<B&&this.fragmentTracker.getState(G)!==O.FragmentState.OK?(this.log("SN "+w.sn+" just loaded, load next one: "+G.sn),w=G):w=null)}return w},o.synchronizeToLiveEdge=function(y){var L=this.config,A=this.media;if(!!A){var P=this.hls.liveSyncPosition,_=A.currentTime,F=y.fragments[0].start,B=y.edge,k=_>=F-L.maxFragLookUpTolerance&&_<=B;if(P!==null&&A.duration>P&&(_<P||!k)){var N=L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:L.liveMaxLatencyDurationCount*y.targetduration;(!k&&A.readyState<4||_<B-N)&&(this.loadedmetadata||(this.nextLoadPosition=P),A.readyState&&(this.warn("Playback: "+_.toFixed(3)+" is located too far from the end of live sliding playlist: "+B+", reset currentTime to : "+P.toFixed(3)),A.currentTime=P))}}},o.alignPlaylists=function(y,L){var A=this.levels,P=this.levelLastLoaded,_=this.fragPrevious,F=P!==null?A[P]:null,B=y.fragments.length;if(!B)return this.warn("No fragments in live playlist"),0;var k=y.fragments[0].start,N=!L,U=y.alignedSliding&&Object(T.isFiniteNumber)(k);if(N||!U&&!k){Object(p.alignStream)(_,F,y);var w=y.fragments[0].start;return this.log("Live playlist sliding: "+w.toFixed(2)+" start-sn: "+(L?L.startSN:"na")+"->"+y.startSN+" prev-sn: "+(_?_.sn:"na")+" fragments: "+B),w}return k},o.waitForCdnTuneIn=function(y){var L=3;return y.live&&y.canBlockReload&&y.partTarget&&y.tuneInGoal>Math.max(y.partHoldBack,y.partTarget*L)},o.setStartPosition=function(y,L){var A=this.startPosition;if(A<L&&(A=-1),A===-1||this.lastCurrentTime===-1){var P=y.startTimeOffset;Object(T.isFiniteNumber)(P)?(A=L+P,P<0&&(A+=y.totalduration),A=Math.min(Math.max(L,A),L+y.totalduration),this.log("Start time offset "+P+" found in playlist, adjust startPosition to "+A),this.startPosition=A):y.live?A=this.hls.liveSyncPosition||L:this.startPosition=A=0,this.lastCurrentTime=A}this.nextLoadPosition=A},o.getLoadPosition=function(){var y=this.media,L=0;return this.loadedmetadata&&y?L=y.currentTime:this.nextLoadPosition&&(L=this.nextLoadPosition),L},o.handleFragLoadAborted=function(y,L){this.transmuxer&&y.sn!=="initSegment"&&y.stats.aborted&&(this.warn("Fragment "+y.sn+(L?" part"+L.index:"")+" of level "+y.level+" was aborted"),this.resetFragmentLoading(y))},o.resetFragmentLoading=function(y){(!this.fragCurrent||!this.fragContextChanged(y))&&(this.state=E.IDLE)},o.onFragmentOrKeyLoadError=function(y,L){if(!L.fatal){var A=L.frag;if(!(!A||A.type!==y)){var P=this.fragCurrent;console.assert(P&&A.sn===P.sn&&A.level===P.level&&A.urlId===P.urlId,"Frag load error must match current frag to retry");var _=this.config;if(this.fragLoadError+1<=_.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(A.level))return;var F=Math.min(Math.pow(2,this.fragLoadError)*_.fragLoadingRetryDelay,_.fragLoadingMaxRetryTimeout);this.warn("Fragment "+A.sn+" of "+y+" "+A.level+" failed to load, retrying in "+F+"ms"),this.retryDate=self.performance.now()+F,this.fragLoadError++,this.state=E.FRAG_LOADING_WAITING_RETRY}else L.levelRetry?(y===a.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=E.IDLE):(C.logger.error(L.details+" reaches max retry, redispatch as fatal ..."),L.fatal=!0,this.hls.stopLoad(),this.state=E.ERROR)}}},o.afterBufferFlushed=function(y,L,A){if(!!y){var P=b.BufferHelper.getBuffered(y);this.fragmentTracker.detectEvictedFragments(L,P,A),this.state===E.ENDED&&this.resetLoadingState()}},o.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=E.IDLE},o.resetLiveStartWhenNotLoaded=function(y){if(!this.loadedmetadata){this.startFragRequested=!1;var L=this.levels?this.levels[y].details:null;if(L!=null&&L.live)return this.startPosition=-1,this.setStartPosition(L,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},o.updateLevelTiming=function(y,L,A,P){var _=this,F=A.details;console.assert(!!F,"level.details must be defined");var B=Object.keys(y.elementaryStreams).reduce(function(k,N){var U=y.elementaryStreams[N];if(U){var w=U.endPTS-U.startPTS;if(w<=0)return _.warn("Could not parse fragment "+y.sn+" "+N+" duration reliably ("+w+")"),k||!1;var W=P?0:Object(v.updateFragPTSDTS)(F,y,U.startPTS,U.endPTS,U.startDTS,U.endDTS);return _.hls.trigger(I.Events.LEVEL_PTS_UPDATED,{details:F,level:A,drift:W,type:N,frag:y,start:U.startPTS,end:U.endPTS}),!0}return k},!1);B||(this.warn("Found no media in fragment "+y.sn+" of level "+A.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=E.PARSED,this.hls.trigger(I.Events.FRAG_PARSED,{frag:y,part:L})},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},h(c,[{key:"state",get:function(){return this._state},set:function(y){var L=this._state;L!==y&&(this._state=y,this.log(L+"->"+y))}}]),c}(R.default)},"./src/controller/buffer-controller.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return m});var T=D("./src/polyfills/number.ts"),R=D("./src/events.ts"),O=D("./src/utils/logger.ts"),b=D("./src/errors.ts"),C=D("./src/utils/buffer-helper.ts"),I=D("./src/utils/mediasource-helper.ts"),S=D("./src/loader/fragment.ts"),g=D("./src/controller/buffer-operation-queue.ts"),x=Object(I.getMediaSource)(),p=/([ha]vc.)(?:\.[^.,]+)+/,m=function(){function v(r){var e=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 a=e.hls,l=e.media,h=e.mediaSource;O.logger.log("[buffer-controller]: Media source opened"),l&&(e.updateMediaElementDuration(),a.trigger(R.Events.MEDIA_ATTACHED,{media:l})),h&&h.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){O.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){O.logger.log("[buffer-controller]: Media source ended")},this.hls=r,this._initSourceBuffer(),this.registerListeners()}var f=v.prototype;return f.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},f.destroy=function(){this.unregisterListeners(),this.details=null},f.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.Events.BUFFER_RESET,this.onBufferReset,this),e.on(R.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(R.Events.BUFFER_EOS,this.onBufferEos,this),e.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(R.Events.FRAG_PARSED,this.onFragParsed,this),e.on(R.Events.FRAG_CHANGED,this.onFragChanged,this)},f.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.Events.BUFFER_RESET,this.onBufferReset,this),e.off(R.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(R.Events.BUFFER_EOS,this.onBufferEos,this),e.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(R.Events.FRAG_PARSED,this.onFragParsed,this),e.off(R.Events.FRAG_CHANGED,this.onFragChanged,this)},f._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new g.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},f.onManifestParsed=function(e,a){var l=2;(a.audio&&!a.video||!a.altAudio)&&(l=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=l,this.details=null,O.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},f.onMediaAttaching=function(e,a){var l=this.media=a.media;if(l&&x){var h=this.mediaSource=new x;h.addEventListener("sourceopen",this._onMediaSourceOpen),h.addEventListener("sourceended",this._onMediaSourceEnded),h.addEventListener("sourceclose",this._onMediaSourceClose),l.src=self.URL.createObjectURL(h),this._objectUrl=l.src}},f.onMediaDetaching=function(){var e=this.media,a=this.mediaSource,l=this._objectUrl;if(a){if(O.logger.log("[buffer-controller]: media source detaching"),a.readyState==="open")try{a.endOfStream()}catch(h){O.logger.warn("[buffer-controller]: onMediaDetaching: "+h.message+" while calling endOfStream")}this.onBufferReset(),a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(l&&self.URL.revokeObjectURL(l),e.src===l?(e.removeAttribute("src"),e.load()):O.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(R.Events.MEDIA_DETACHED,void 0)},f.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(a){var l=e.sourceBuffer[a];try{l&&(e.removeBufferListeners(a),e.mediaSource&&e.mediaSource.removeSourceBuffer(l),e.sourceBuffer[a]=void 0)}catch(h){O.logger.warn("[buffer-controller]: Failed to reset the "+a+" buffer",h)}}),this._initSourceBuffer()},f.onBufferCodecs=function(e,a){var l=this,h=this.getSourceBufferTypes().length;Object.keys(a).forEach(function(n){if(h){var t=l.tracks[n];if(t&&typeof t.buffer.changeType=="function"){var i=a[n],E=i.id,u=i.codec,d=i.levelCodec,c=i.container,o=i.metadata,s=(t.levelCodec||t.codec).replace(p,"$1"),y=(d||u).replace(p,"$1");if(s!==y){var L=c+";codecs="+(d||u);l.appendChangeType(n,L),O.logger.log("[buffer-controller]: switching codec "+s+" to "+y),l.tracks[n]={buffer:t.buffer,codec:u,container:c,levelCodec:d,metadata:o,id:E}}}}else l.pendingTracks[n]=a[n]}),!h&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},f.appendChangeType=function(e,a){var l=this,h=this.operationQueue,n={execute:function(){var i=l.sourceBuffer[e];i&&(O.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+a),i.changeType(a)),h.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(i){O.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",i)}};h.append(n,e)},f.onBufferAppending=function(e,a){var l=this,h=this.hls,n=this.operationQueue,t=this.tracks,i=a.data,E=a.type,u=a.frag,d=a.part,c=a.chunkMeta,o=c.buffering[E],s=self.performance.now();o.start=s;var y=u.stats.buffering,L=d?d.stats.buffering:null;y.start===0&&(y.start=s),L&&L.start===0&&(L.start=s);var A=t.audio,P=E==="audio"&&c.id===1&&(A==null?void 0:A.container)==="audio/mpeg",_={execute:function(){if(o.executeStart=self.performance.now(),P){var B=l.sourceBuffer[E];if(B){var k=u.start-B.timestampOffset;Math.abs(k)>=.1&&(O.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+u.start+" (delta: "+k+") sn: "+u.sn+")"),B.timestampOffset=u.start)}}l.appendExecutor(i,E)},onStart:function(){},onComplete:function(){var B=self.performance.now();o.executeEnd=o.end=B,y.first===0&&(y.first=B),L&&L.first===0&&(L.first=B);var k=l.sourceBuffer,N={};for(var U in k)N[U]=C.BufferHelper.getBuffered(k[U]);l.appendError=0,l.hls.trigger(R.Events.BUFFER_APPENDED,{type:E,frag:u,part:d,chunkMeta:c,parent:u.type,timeRanges:N})},onError:function(B){O.logger.error("[buffer-controller]: Error encountered while trying to append to the "+E+" SourceBuffer",B);var k={type:b.ErrorTypes.MEDIA_ERROR,parent:u.type,details:b.ErrorDetails.BUFFER_APPEND_ERROR,err:B,fatal:!1};B.code===DOMException.QUOTA_EXCEEDED_ERR?k.details=b.ErrorDetails.BUFFER_FULL_ERROR:(l.appendError++,k.details=b.ErrorDetails.BUFFER_APPEND_ERROR,l.appendError>h.config.appendErrorMaxRetry&&(O.logger.error("[buffer-controller]: Failed "+h.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),k.fatal=!0)),h.trigger(R.Events.ERROR,k)}};n.append(_,E)},f.onBufferFlushing=function(e,a){var l=this,h=this.operationQueue,n=function(i){return{execute:l.removeExecutor.bind(l,i,a.startOffset,a.endOffset),onStart:function(){},onComplete:function(){l.hls.trigger(R.Events.BUFFER_FLUSHED,{type:i})},onError:function(u){O.logger.warn("[buffer-controller]: Failed to remove from "+i+" SourceBuffer",u)}}};a.type?h.append(n(a.type),a.type):this.getSourceBufferTypes().forEach(function(t){h.append(n(t),t)})},f.onFragParsed=function(e,a){var l=this,h=a.frag,n=a.part,t=[],i=n?n.elementaryStreams:h.elementaryStreams;i[S.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(i[S.ElementaryStreamTypes.AUDIO]&&t.push("audio"),i[S.ElementaryStreamTypes.VIDEO]&&t.push("video"));var E=function(){var d=self.performance.now();h.stats.buffering.end=d,n&&(n.stats.buffering.end=d);var c=n?n.stats:h.stats;l.hls.trigger(R.Events.FRAG_BUFFERED,{frag:h,part:n,stats:c,id:h.type})};t.length===0&&O.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+h.type+" level: "+h.level+" sn: "+h.sn),this.blockBuffers(E,t)},f.onFragChanged=function(e,a){this.flushBackBuffer()},f.onBufferEos=function(e,a){var l=this,h=this.getSourceBufferTypes().reduce(function(n,t){var i=l.sourceBuffer[t];return(!a.type||a.type===t)&&i&&!i.ended&&(i.ended=!0,O.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),n&&!!(!i||i.ended)},!0);h&&this.blockBuffers(function(){var n=l.mediaSource;!n||n.readyState!=="open"||n.endOfStream()})},f.onLevelUpdated=function(e,a){var l=a.details;!l.fragments.length||(this.details=l,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},f.flushBackBuffer=function(){var e=this.hls,a=this.details,l=this.media,h=this.sourceBuffer;if(!(!l||a===null)){var n=this.getSourceBufferTypes();if(!!n.length){var t=a.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(T.isFiniteNumber)(t)||t<0)){var i=l.currentTime,E=a.levelTargetDuration,u=Math.max(t,E),d=Math.floor(i/E)*E-u;n.forEach(function(c){var o=h[c];if(o){var s=C.BufferHelper.getBuffered(o);s.length>0&&d>s.start(0)&&(e.trigger(R.Events.BACK_BUFFER_REACHED,{bufferEnd:d}),a.live&&e.trigger(R.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:d}),e.trigger(R.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:d,type:c}))}})}}}},f.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,a=this.hls,l=this.media,h=this.mediaSource,n=e.fragments[0].start+e.totalduration,t=l.duration,i=Object(T.isFiniteNumber)(h.duration)?h.duration:0;e.live&&a.config.liveDurationInfinity?(O.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),h.duration=1/0,this.updateSeekableRange(e)):(n>i&&n>t||!Object(T.isFiniteNumber)(t))&&(O.logger.log("[buffer-controller]: Updating Media Source duration to "+n.toFixed(3)),h.duration=n)}},f.updateSeekableRange=function(e){var a=this.mediaSource,l=e.fragments,h=l.length;if(h&&e.live&&a!==null&&a!==void 0&&a.setLiveSeekableRange){var n=Math.max(0,l[0].start),t=Math.max(n,n+e.totalduration);a.setLiveSeekableRange(n,t)}},f.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,a=this.operationQueue,l=this.pendingTracks,h=Object.keys(l).length;if(h&&!e||h===2){this.createSourceBuffers(l),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length===0){this.hls.trigger(R.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}n.forEach(function(t){a.executeNext(t)})}},f.createSourceBuffers=function(e){var a=this.sourceBuffer,l=this.mediaSource;if(!l)throw Error("createSourceBuffers called when mediaSource was null");var h=0;for(var n in e)if(!a[n]){var t=e[n];if(!t)throw Error("source buffer exists for track "+n+", however track does not");var i=t.levelCodec||t.codec,E=t.container+";codecs="+i;O.logger.log("[buffer-controller]: creating sourceBuffer("+E+")");try{var u=a[n]=l.addSourceBuffer(E),d=n;this.addBufferListener(d,"updatestart",this._onSBUpdateStart),this.addBufferListener(d,"updateend",this._onSBUpdateEnd),this.addBufferListener(d,"error",this._onSBUpdateError),this.tracks[n]={buffer:u,codec:i,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id},h++}catch(c){O.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+c.message),this.hls.trigger(R.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,mimeType:E})}}h&&this.hls.trigger(R.Events.BUFFER_CREATED,{tracks:this.tracks})},f._onSBUpdateStart=function(e){var a=this.operationQueue,l=a.current(e);l.onStart()},f._onSBUpdateEnd=function(e){var a=this.operationQueue,l=a.current(e);l.onComplete(),a.shiftAndExecuteNext(e)},f._onSBUpdateError=function(e,a){O.logger.error("[buffer-controller]: "+e+" SourceBuffer error",a),this.hls.trigger(R.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var l=this.operationQueue.current(e);l&&l.onError(a)},f.removeExecutor=function(e,a,l){var h=this.media,n=this.mediaSource,t=this.operationQueue,i=this.sourceBuffer,E=i[e];if(!h||!n||!E){O.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),t.shiftAndExecuteNext(e);return}var u=Object(T.isFiniteNumber)(h.duration)?h.duration:1/0,d=Object(T.isFiniteNumber)(n.duration)?n.duration:1/0,c=Math.max(0,a),o=Math.min(l,u,d);o>c?(O.logger.log("[buffer-controller]: Removing ["+c+","+o+"] from the "+e+" SourceBuffer"),console.assert(!E.updating,e+" sourceBuffer must not be updating"),E.remove(c,o)):t.shiftAndExecuteNext(e)},f.appendExecutor=function(e,a){var l=this.operationQueue,h=this.sourceBuffer,n=h[a];if(!n){O.logger.warn("[buffer-controller]: Attempting to append to the "+a+" SourceBuffer, but it does not exist"),l.shiftAndExecuteNext(a);return}n.ended=!1,console.assert(!n.updating,a+" sourceBuffer must not be updating"),n.appendBuffer(e)},f.blockBuffers=function(e,a){var l=this;if(a===void 0&&(a=this.getSourceBufferTypes()),!a.length){O.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var h=this.operationQueue,n=a.map(function(t){return h.appendBlocker(t)});Promise.all(n).then(function(){e(),a.forEach(function(t){var i=l.sourceBuffer[t];(!i||!i.updating)&&h.shiftAndExecuteNext(t)})})},f.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},f.addBufferListener=function(e,a,l){var h=this.sourceBuffer[e];if(!!h){var n=l.bind(this,e);this.listeners[e].push({event:a,listener:n}),h.addEventListener(a,n)}},f.removeBufferListeners=function(e){var a=this.sourceBuffer[e];!a||this.listeners[e].forEach(function(l){a.removeEventListener(l.event,l.listener)})},v}()},"./src/controller/buffer-operation-queue.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return R});var T=D("./src/utils/logger.ts"),R=function(){function O(C){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=C}var b=O.prototype;return b.append=function(I,S){var g=this.queues[S];g.push(I),g.length===1&&this.buffers[S]&&this.executeNext(S)},b.insertAbort=function(I,S){var g=this.queues[S];g.unshift(I),this.executeNext(S)},b.appendBlocker=function(I){var S,g=new Promise(function(p){S=p}),x={execute:S,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(x,I),g},b.executeNext=function(I){var S=this.buffers,g=this.queues,x=S[I],p=g[I];if(p.length){var m=p[0];try{m.execute()}catch(v){T.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),m.onError(v),(!x||!x.updating)&&(p.shift(),this.executeNext(I))}}},b.shiftAndExecuteNext=function(I){this.queues[I].shift(),this.executeNext(I)},b.current=function(I){return this.queues[I][0]},O}()},"./src/controller/cap-level-controller.ts":function(K,M,D){D.r(M);var T=D("./src/events.ts");function R(C,I){for(var S=0;S<I.length;S++){var g=I[S];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(C,g.key,g)}}function O(C,I,S){return I&&R(C.prototype,I),S&&R(C,S),Object.defineProperty(C,"prototype",{writable:!1}),C}var b=function(){function C(S){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=S,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var I=C.prototype;return I.setStreamController=function(g){this.streamController=g},I.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},I.registerListeners=function(){var g=this.hls;g.on(T.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.on(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(T.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},I.unregisterListener=function(){var g=this.hls;g.off(T.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.off(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(T.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},I.onFpsDropLevelCapping=function(g,x){C.isLevelAllowed(x.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(x.droppedLevel)},I.onMediaAttaching=function(g,x){this.media=x.media instanceof HTMLVideoElement?x.media:null},I.onManifestParsed=function(g,x){var p=this.hls;this.restrictedLevels=[],this.firstLevel=x.firstLevel,p.config.capLevelToPlayerSize&&x.video&&this.startCapping()},I.onBufferCodecs=function(g,x){var p=this.hls;p.config.capLevelToPlayerSize&&x.video&&this.startCapping()},I.onMediaDetaching=function(){this.stopCapping()},I.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var x=this.hls;x.autoLevelCapping=this.getMaxLevel(g.length-1),x.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=x.autoLevelCapping}}},I.getMaxLevel=function(g){var x=this,p=this.hls.levels;if(!p.length)return-1;var m=p.filter(function(v,f){return C.isLevelAllowed(f,x.restrictedLevels)&&f<=g});return this.clientRect=null,C.getMaxLevelByMediaSize(m,this.mediaWidth,this.mediaHeight)},I.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())},I.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},I.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,x={width:0,height:0};if(g){var p=g.getBoundingClientRect();x.width=p.width,x.height=p.height,!x.width&&!x.height&&(x.width=p.right-p.left||g.width||0,x.height=p.bottom-p.top||g.height||0)}return this.clientRect=x,x},C.isLevelAllowed=function(g,x){return x===void 0&&(x=[]),x.indexOf(g)===-1},C.getMaxLevelByMediaSize=function(g,x,p){if(!g||!g.length)return-1;for(var m=function(a,l){return l?a.width!==l.width||a.height!==l.height:!0},v=g.length-1,f=0;f<g.length;f+=1){var r=g[f];if((r.width>=x||r.height>=p)&&m(r,g[f+1])){v=f;break}}return v},O(C,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var g=1;if(!this.hls.config.ignoreDevicePixelRatio)try{g=self.devicePixelRatio}catch{}return g}}]),C}();M.default=b},"./src/controller/cmcd-controller.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return m});var T=D("./src/events.ts"),R=D("./src/types/cmcd.ts"),O=D("./src/utils/buffer-helper.ts"),b=D("./src/utils/logger.ts");function C(v,f){for(var r=0;r<f.length;r++){var e=f[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(v,e.key,e)}}function I(v,f,r){return f&&C(v.prototype,f),r&&C(v,r),Object.defineProperty(v,"prototype",{writable:!1}),v}function S(v,f){var r=typeof Symbol<"u"&&v[Symbol.iterator]||v["@@iterator"];if(r)return(r=r.call(v)).next.bind(r);if(Array.isArray(v)||(r=g(v))||f&&v&&typeof v.length=="number"){r&&(v=r);var e=0;return function(){return e>=v.length?{done:!0}:{done:!1,value:v[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
32
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function g(v,f){if(!!v){if(typeof v=="string")return x(v,f);var r=Object.prototype.toString.call(v).slice(8,-1);if(r==="Object"&&v.constructor&&(r=v.constructor.name),r==="Map"||r==="Set")return Array.from(v);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(v,f)}}function x(v,f){(f==null||f>v.length)&&(f=v.length);for(var r=0,e=new Array(f);r<f;r++)e[r]=v[r];return e}function p(){return p=Object.assign?Object.assign.bind():function(v){for(var f=1;f<arguments.length;f++){var r=arguments[f];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(v[e]=r[e])}return v},p.apply(this,arguments)}var m=function(){function v(r){var e=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(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(h){try{e.apply(h,{ot:R.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(n){b.logger.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=function(h){try{var n=h.frag,t=e.hls.levels[n.level],i=e.getObjectType(n),E={d:n.duration*1e3,ot:i};(i===R.CMCDObjectType.VIDEO||i===R.CMCDObjectType.AUDIO||i==R.CMCDObjectType.MUXED)&&(E.br=t.bitrate/1e3,E.tb=e.getTopBandwidth(i)/1e3,E.bl=e.getBufferLength(i)),e.apply(h,E)}catch(u){b.logger.warn("Could not generate segment CMCD data.",u)}},this.hls=r;var a=this.config=r.config,l=a.cmcd;l!=null&&(a.pLoader=this.createPlaylistLoader(),a.fLoader=this.createFragmentLoader(),this.sid=l.sessionId||v.uuid(),this.cid=l.contentId,this.useHeaders=l.useHeaders===!0,this.registerListeners())}var f=v.prototype;return f.registerListeners=function(){var e=this.hls;e.on(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(T.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(T.Events.BUFFER_CREATED,this.onBufferCreated,this)},f.unregisterListeners=function(){var e=this.hls;e.off(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(T.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(T.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},f.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},f.onMediaAttached=function(e,a){this.media=a.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},f.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},f.onBufferCreated=function(e,a){var l,h;this.audioBuffer=(l=a.tracks.audio)===null||l===void 0?void 0:l.buffer,this.videoBuffer=(h=a.tracks.video)===null||h===void 0?void 0:h.buffer},f.createData=function(){var e;return{v:R.CMCDVersion,sf:R.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},f.apply=function(e,a){a===void 0&&(a={}),p(a,this.createData());var l=a.ot===R.CMCDObjectType.INIT||a.ot===R.CMCDObjectType.VIDEO||a.ot===R.CMCDObjectType.MUXED;if(this.starved&&l&&(a.bs=!0,a.su=!0,this.starved=!1),a.su==null&&(a.su=this.buffering),this.useHeaders){var h=v.toHeaders(a);if(!Object.keys(h).length)return;e.headers||(e.headers={}),p(e.headers,h)}else{var n=v.toQuery(a);if(!n)return;e.url=v.appendQueryToUri(e.url,n)}},f.getObjectType=function(e){var a=e.type;if(a==="subtitle")return R.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return R.CMCDObjectType.INIT;if(a==="audio")return R.CMCDObjectType.AUDIO;if(a==="main")return this.hls.audioTracks.length?R.CMCDObjectType.VIDEO:R.CMCDObjectType.MUXED},f.getTopBandwidth=function(e){var a=0,l,h=this.hls;if(e===R.CMCDObjectType.AUDIO)l=h.audioTracks;else{var n=h.maxAutoLevel,t=n>-1?n+1:h.levels.length;l=h.levels.slice(0,t)}for(var i=S(l),E;!(E=i()).done;){var u=E.value;u.bitrate>a&&(a=u.bitrate)}return a>0?a:NaN},f.getBufferLength=function(e){var a=this.hls.media,l=e===R.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!l||!a)return NaN;var h=O.BufferHelper.bufferInfo(l,a.currentTime,this.config.maxBufferHole);return h.len*1e3},f.createPlaylistLoader=function(){var e=this.config.pLoader,a=this.applyPlaylistData,l=e||this.config.loader;return function(){function h(t){this.loader=void 0,this.loader=new l(t)}var n=h.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(i,E,u){a(i),this.loader.load(i,E,u)},I(h,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),h}()},f.createFragmentLoader=function(){var e=this.config.fLoader,a=this.applyFragmentData,l=e||this.config.loader;return function(){function h(t){this.loader=void 0,this.loader=new l(t)}var n=h.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(i,E,u){a(i),this.loader.load(i,E,u)},I(h,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),h}()},v.uuid=function(){var e=URL.createObjectURL(new Blob),a=e.toString();return URL.revokeObjectURL(e),a.slice(a.lastIndexOf("/")+1)},v.serialize=function(e){for(var a=[],l=function(P){return!Number.isNaN(P)&&P!=null&&P!==""&&P!==!1},h=function(P){return Math.round(P)},n=function(P){return h(P/100)*100},t=function(P){return encodeURIComponent(P)},i={br:h,d:h,bl:n,dl:n,mtp:n,nor:t,rtp:n,tb:h},E=Object.keys(e||{}).sort(),u=S(E),d;!(d=u()).done;){var c=d.value,o=e[c];if(!!l(o)&&!(c==="v"&&o===1)&&!(c=="pr"&&o===1)){var s=i[c];s&&(o=s(o));var y=typeof o,L=void 0;c==="ot"||c==="sf"||c==="st"?L=c+"="+o:y==="boolean"?L=c:y==="number"?L=c+"="+o:L=c+"="+JSON.stringify(o),a.push(L)}}return a.join(",")},v.toHeaders=function(e){for(var a=Object.keys(e),l={},h=["Object","Request","Session","Status"],n=[{},{},{},{}],t={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},i=0,E=a;i<E.length;i++){var u=E[i],d=t[u]!=null?t[u]:1;n[d][u]=e[u]}for(var c=0;c<n.length;c++){var o=v.serialize(n[c]);o&&(l["CMCD-"+h[c]]=o)}return l},v.toQuery=function(e){return"CMCD="+encodeURIComponent(v.serialize(e))},v.appendQueryToUri=function(e,a){if(!a)return e;var l=e.includes("?")?"&":"?";return""+e+l+a},v}()},"./src/controller/eme-controller.ts":function(K,M,D){D.r(M);var T=D("./src/events.ts"),R=D("./src/errors.ts"),O=D("./src/utils/logger.ts"),b=D("./src/utils/mediakeys-helper.ts");function C(m,v){for(var f=0;f<v.length;f++){var r=v[f];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(m,r.key,r)}}function I(m,v,f){return v&&C(m.prototype,v),f&&C(m,f),Object.defineProperty(m,"prototype",{writable:!1}),m}var S=3,g=function(v,f,r){var e={audioCapabilities:[],videoCapabilities:[]};return v.forEach(function(a){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+a+'"',robustness:r.audioRobustness||""})}),f.forEach(function(a){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+a+'"',robustness:r.videoRobustness||""})}),[e]},x=function(v,f,r,e){switch(v){case b.KeySystems.WIDEVINE:return g(f,r,e);default:throw new Error("Unknown key-system: "+v)}},p=function(){function m(f){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=f,this._config=f.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 v=m.prototype;return v.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},v._registerListeners=function(){this.hls.on(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(T.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(T.Events.MANIFEST_PARSED,this.onManifestParsed,this)},v._unregisterListeners=function(){this.hls.off(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(T.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(T.Events.MANIFEST_PARSED,this.onManifestParsed,this)},v.getLicenseServerUrl=function(r){switch(r){case b.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+r+'"')},v._attemptKeySystemAccess=function(r,e,a){var l=this,h=x(r,e,a,this._drmSystemOptions);O.logger.log("Requesting encrypted media key-system access");var n=this.requestMediaKeySystemAccess(r,h);this.mediaKeysPromise=n.then(function(t){return l._onMediaKeySystemAccessObtained(r,t)}),n.catch(function(t){O.logger.error('Failed to obtain key-system "'+r+'" access:',t)})},v._onMediaKeySystemAccessObtained=function(r,e){var a=this;O.logger.log('Access for key-system "'+r+'" obtained');var l={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:r};this._mediaKeysList.push(l);var h=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(n){return l.mediaKeys=n,O.logger.log('Media-keys created for key-system "'+r+'"'),a._onMediaKeysCreated(),n});return h.catch(function(n){O.logger.error("Failed to create media-keys:",n)}),h},v._onMediaKeysCreated=function(){var r=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),r._onNewMediaKeySession(e.mediaKeysSession))})},v._onNewMediaKeySession=function(r){var e=this;O.logger.log("New key-system session "+r.sessionId),r.addEventListener("message",function(a){e._onKeySessionMessage(r,a.message)},!1)},v._onKeySessionMessage=function(r,e){O.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(a){O.logger.log("Received license data (length: "+(a&&a.byteLength)+"), updating key-session"),r.update(a).catch(function(l){O.logger.warn("Updating key-session failed: "+l)})})},v.onMediaEncrypted=function(r){var e=this;if(O.logger.log('Media is encrypted using "'+r.initDataType+'" init data type'),!this.mediaKeysPromise){O.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var a=function(h){!e._media||(e._attemptSetMediaKeys(h),e._generateRequestWithPreferredKeySession(r.initDataType,r.initData))};this.mediaKeysPromise.then(a).catch(a)},v._attemptSetMediaKeys=function(r){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){O.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}O.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},v._generateRequestWithPreferredKeySession=function(r,e){var a=this,l=this._mediaKeysList[0];if(!l){O.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(l.mediaKeysSessionInitialized){O.logger.warn("Key-Session already initialized but requested again");return}var h=l.mediaKeysSession;if(!h){O.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){O.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}O.logger.log('Generating key-session request for "'+r+'" init data type'),l.mediaKeysSessionInitialized=!0,h.generateRequest(r,e).then(function(){O.logger.debug("Key-session generation succeeded")}).catch(function(n){O.logger.error("Error generating key-session request:",n),a.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},v._createLicenseXhr=function(r,e,a){var l=new XMLHttpRequest;l.responseType="arraybuffer",l.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,l,r,e,a);var h=this._licenseXhrSetup;if(h)try{h.call(this.hls,l,r),h=void 0}catch(n){O.logger.error(n)}try{l.readyState||l.open("POST",r,!0),h&&h.call(this.hls,l,r)}catch(n){throw new Error("issue setting up KeySystem license XHR "+n)}return l},v._onLicenseRequestReadyStageChange=function(r,e,a,l){switch(r.readyState){case 4:if(r.status===200){this._requestLicenseFailureCount=0,O.logger.log("License request succeeded");var h=r.response,n=this._licenseResponseCallback;if(n)try{h=n.call(this.hls,r,e)}catch(i){O.logger.error(i)}l(h)}else{if(O.logger.error("License Request XHR failed ("+e+"). Status: "+r.status+" ("+r.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>S){this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var t=S-this._requestLicenseFailureCount+1;O.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(a,l)}break}},v._generateLicenseRequestChallenge=function(r,e){switch(r.mediaKeySystemDomain){case b.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+r.mediaKeySystemDomain)},v._requestLicense=function(r,e){O.logger.log("Requesting content license for key-system");var a=this._mediaKeysList[0];if(!a){O.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var l=this.getLicenseServerUrl(a.mediaKeySystemDomain),h=this._createLicenseXhr(l,r,e);O.logger.log("Sending license request to URL: "+l);var n=this._generateLicenseRequestChallenge(a,r);h.send(n)}catch(t){O.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.KEY_SYSTEM_ERROR,details:R.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},v.onMediaAttached=function(r,e){if(!!this._emeEnabled){var a=e.media;this._media=a,a.addEventListener("encrypted",this._onMediaEncrypted)}},v.onMediaDetached=function(){var r=this._media,e=this._mediaKeysList;!r||(r.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(a){if(a.mediaKeysSession)return a.mediaKeysSession.close().catch(function(){})})).then(function(){return r.setMediaKeys(null)}).catch(function(){}))},v.onManifestParsed=function(r,e){if(!!this._emeEnabled){var a=e.levels.map(function(h){return h.audioCodec}).filter(function(h){return!!h}),l=e.levels.map(function(h){return h.videoCodec}).filter(function(h){return!!h});this._attemptKeySystemAccess(b.KeySystems.WIDEVINE,a,l)}},I(m,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),m}();M.default=p},"./src/controller/fps-controller.ts":function(K,M,D){D.r(M);var T=D("./src/events.ts"),R=D("./src/utils/logger.ts"),O=function(){function b(I){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=I,this.registerListeners()}var C=b.prototype;return C.setStreamController=function(S){this.streamController=S},C.registerListeners=function(){this.hls.on(T.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},C.unregisterListeners=function(){this.hls.off(T.Events.MEDIA_ATTACHING,this.onMediaAttaching)},C.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},C.onMediaAttaching=function(S,g){var x=this.hls.config;if(x.capLevelOnFPSDrop){var p=g.media instanceof self.HTMLVideoElement?g.media:null;this.media=p,p&&typeof p.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},C.checkFPS=function(S,g,x){var p=performance.now();if(g){if(this.lastTime){var m=p-this.lastTime,v=x-this.lastDroppedFrames,f=g-this.lastDecodedFrames,r=1e3*v/m,e=this.hls;if(e.trigger(T.Events.FPS_DROP,{currentDropped:v,currentDecoded:f,totalDroppedFrames:x}),r>0&&v>e.config.fpsDroppedMonitoringThreshold*f){var a=e.currentLevel;R.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+a),a>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=a)&&(a=a-1,e.trigger(T.Events.FPS_DROP_LEVEL_CAPPING,{level:a,droppedLevel:e.currentLevel}),e.autoLevelCapping=a,this.streamController.nextLevelSwitch())}}this.lastTime=p,this.lastDroppedFrames=x,this.lastDecodedFrames=g}},C.checkFPSInterval=function(){var S=this.media;if(S)if(this.isVideoPlaybackQualityAvailable){var g=S.getVideoPlaybackQuality();this.checkFPS(S,g.totalVideoFrames,g.droppedVideoFrames)}else this.checkFPS(S,S.webkitDecodedFrameCount,S.webkitDroppedFrameCount)},b}();M.default=O},"./src/controller/fragment-finders.ts":function(K,M,D){D.r(M),D.d(M,"findFragmentByPDT",function(){return O}),D.d(M,"findFragmentByPTS",function(){return b}),D.d(M,"fragmentWithinToleranceTest",function(){return C}),D.d(M,"pdtWithinToleranceTest",function(){return I}),D.d(M,"findFragWithCC",function(){return S});var T=D("./src/polyfills/number.ts"),R=D("./src/utils/binary-search.ts");function O(g,x,p){if(x===null||!Array.isArray(g)||!g.length||!Object(T.isFiniteNumber)(x))return null;var m=g[0].programDateTime;if(x<(m||0))return null;var v=g[g.length-1].endProgramDateTime;if(x>=(v||0))return null;p=p||0;for(var f=0;f<g.length;++f){var r=g[f];if(I(x,p,r))return r}return null}function b(g,x,p,m){p===void 0&&(p=0),m===void 0&&(m=0);var v=null;if(g?v=x[g.sn-x[0].sn+1]||null:p===0&&x[0].start===0&&(v=x[0]),v&&C(p,m,v)===0)return v;var f=R.default.search(x,C.bind(null,p,m));return f||v}function C(g,x,p){g===void 0&&(g=0),x===void 0&&(x=0);var m=Math.min(x,p.duration+(p.deltaPTS?p.deltaPTS:0));return p.start+p.duration-m<=g?1:p.start-m>g&&p.start?-1:0}function I(g,x,p){var m=Math.min(x,p.duration+(p.deltaPTS?p.deltaPTS:0))*1e3,v=p.endProgramDateTime||0;return v-m>g}function S(g,x){return R.default.search(g,function(p){return p.cc<x?1:p.cc>x?-1:0})}},"./src/controller/fragment-tracker.ts":function(K,M,D){D.r(M),D.d(M,"FragmentState",function(){return O}),D.d(M,"FragmentTracker",function(){return b});var T=D("./src/events.ts"),R=D("./src/types/loader.ts"),O;(function(S){S.NOT_LOADED="NOT_LOADED",S.APPENDING="APPENDING",S.PARTIAL="PARTIAL",S.OK="OK"})(O||(O={}));var b=function(){function S(x){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=x,this._registerListeners()}var g=S.prototype;return g._registerListeners=function(){var p=this.hls;p.on(T.Events.BUFFER_APPENDED,this.onBufferAppended,this),p.on(T.Events.FRAG_BUFFERED,this.onFragBuffered,this),p.on(T.Events.FRAG_LOADED,this.onFragLoaded,this)},g._unregisterListeners=function(){var p=this.hls;p.off(T.Events.BUFFER_APPENDED,this.onBufferAppended,this),p.off(T.Events.FRAG_BUFFERED,this.onFragBuffered,this),p.off(T.Events.FRAG_LOADED,this.onFragLoaded,this)},g.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},g.getAppendedFrag=function(p,m){if(m===R.PlaylistLevelType.MAIN){var v=this.activeFragment,f=this.activeParts;if(!v)return null;if(f)for(var r=f.length;r--;){var e=f[r],a=e?e.end:v.appendedPTS;if(e.start<=p&&a!==void 0&&p<=a)return r>9&&(this.activeParts=f.slice(r-9)),e}else if(v.start<=p&&v.appendedPTS!==void 0&&p<=v.appendedPTS)return v}return this.getBufferedFrag(p,m)},g.getBufferedFrag=function(p,m){for(var v=this.fragments,f=Object.keys(v),r=f.length;r--;){var e=v[f[r]];if((e==null?void 0:e.body.type)===m&&e.buffered){var a=e.body;if(a.start<=p&&p<=a.end)return a}}return null},g.detectEvictedFragments=function(p,m,v){var f=this;Object.keys(this.fragments).forEach(function(r){var e=f.fragments[r];if(!!e){if(!e.buffered){e.body.type===v&&f.removeFragment(e.body);return}var a=e.range[p];!a||a.time.some(function(l){var h=!f.isTimeBuffered(l.startPTS,l.endPTS,m);return h&&f.removeFragment(e.body),h})}})},g.detectPartialFragments=function(p){var m=this,v=this.timeRanges,f=p.frag,r=p.part;if(!(!v||f.sn==="initSegment")){var e=I(f),a=this.fragments[e];!a||(Object.keys(v).forEach(function(l){var h=f.elementaryStreams[l];if(!!h){var n=v[l],t=r!==null||h.partial===!0;a.range[l]=m.getBufferedTimes(f,r,t,n)}}),a.loaded=null,Object.keys(a.range).length?a.buffered=!0:this.removeFragment(a.body))}},g.fragBuffered=function(p){var m=I(p),v=this.fragments[m];v&&(v.loaded=null,v.buffered=!0)},g.getBufferedTimes=function(p,m,v,f){for(var r={time:[],partial:v},e=m?m.start:p.start,a=m?m.end:p.end,l=p.minEndPTS||a,h=p.maxStartPTS||e,n=0;n<f.length;n++){var t=f.start(n)-this.bufferPadding,i=f.end(n)+this.bufferPadding;if(h>=t&&l<=i){r.time.push({startPTS:Math.max(e,f.start(n)),endPTS:Math.min(a,f.end(n))});break}else if(e<i&&a>t)r.partial=!0,r.time.push({startPTS:Math.max(e,f.start(n)),endPTS:Math.min(a,f.end(n))});else if(a<=t)break}return r},g.getPartialFragment=function(p){var m=null,v,f,r,e=0,a=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach(function(h){var n=l[h];!n||C(n)&&(f=n.body.start-a,r=n.body.end+a,p>=f&&p<=r&&(v=Math.min(p-f,r-p),e<=v&&(m=n.body,e=v)))}),m},g.getState=function(p){var m=I(p),v=this.fragments[m];return v?v.buffered?C(v)?O.PARTIAL:O.OK:O.APPENDING:O.NOT_LOADED},g.isTimeBuffered=function(p,m,v){for(var f,r,e=0;e<v.length;e++){if(f=v.start(e)-this.bufferPadding,r=v.end(e)+this.bufferPadding,p>=f&&m<=r)return!0;if(m<=f)return!1}return!1},g.onFragLoaded=function(p,m){var v=m.frag,f=m.part;if(!(v.sn==="initSegment"||v.bitrateTest||f)){var r=I(v);this.fragments[r]={body:v,loaded:m,buffered:!1,range:Object.create(null)}}},g.onBufferAppended=function(p,m){var v=this,f=m.frag,r=m.part,e=m.timeRanges;if(f.type===R.PlaylistLevelType.MAIN)if(this.activeFragment=f,r){var a=this.activeParts;a||(this.activeParts=a=[]),a.push(r)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(l){var h=e[l];if(v.detectEvictedFragments(l,h),!r)for(var n=0;n<h.length;n++)f.appendedPTS=Math.max(h.end(n),f.appendedPTS||0)})},g.onFragBuffered=function(p,m){this.detectPartialFragments(m)},g.hasFragment=function(p){var m=I(p);return!!this.fragments[m]},g.removeFragmentsInRange=function(p,m,v){var f=this;Object.keys(this.fragments).forEach(function(r){var e=f.fragments[r];if(!!e&&e.buffered){var a=e.body;a.type===v&&a.start<m&&a.end>p&&f.removeFragment(a)}})},g.removeFragment=function(p){var m=I(p);p.stats.loaded=0,p.clearElementaryStreamInfo(),delete this.fragments[m]},g.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},S}();function C(S){var g,x;return S.buffered&&(((g=S.range.video)===null||g===void 0?void 0:g.partial)||((x=S.range.audio)===null||x===void 0?void 0:x.partial))}function I(S){return S.type+"_"+S.level+"_"+S.urlId+"_"+S.sn}},"./src/controller/gap-controller.ts":function(K,M,D){D.r(M),D.d(M,"STALL_MINIMUM_DURATION_MS",function(){return C}),D.d(M,"MAX_START_GAP_JUMP",function(){return I}),D.d(M,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return S}),D.d(M,"SKIP_BUFFER_RANGE_START",function(){return g}),D.d(M,"default",function(){return x});var T=D("./src/utils/buffer-helper.ts"),R=D("./src/errors.ts"),O=D("./src/events.ts"),b=D("./src/utils/logger.ts"),C=250,I=2,S=.1,g=.05,x=function(){function p(v,f,r,e){this.config=void 0,this.media=null,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=v,this.media=f,this.fragmentTracker=r,this.hls=e}var m=p.prototype;return m.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},m.poll=function(f,r){var e=this.config,a=this.media,l=this.stalled;if(a!==null){var h=a.currentTime,n=a.seeking,t=this.seeking&&!n,i=!this.seeking&&n;if(this.seeking=n,h!==f){if(this.moved=!0,l!==null){if(this.stallReported){var E=self.performance.now()-l;b.logger.warn("playback not stuck anymore @"+h+", after "+Math.round(E)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((i||t)&&(this.stalled=null),!(a.paused&&!n||a.ended||a.playbackRate===0||!T.BufferHelper.getBuffered(a).length)){var u=T.BufferHelper.bufferInfo(a,h,0),d=u.len>0,c=u.nextStart||0;if(!(!d&&!c)){if(n){var o=u.len>I,s=!c||r&&r.start<=h||c-h>I&&!this.fragmentTracker.getPartialFragment(h);if(o||s)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var y,L=Math.max(c,u.start||0)-h,A=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=A==null||(y=A.details)===null||y===void 0?void 0:y.live,_=P?A.details.targetduration*2:I;if(L>0&&L<=_){this._trySkipBufferHole(null);return}}var F=self.performance.now();if(l===null){this.stalled=F;return}var B=F-l;if(!(!n&&B>=C&&(this._reportStall(u),!this.media))){var k=T.BufferHelper.bufferInfo(a,h,e.maxBufferHole);this._tryFixBufferStall(k,B)}}}}},m._tryFixBufferStall=function(f,r){var e=this.config,a=this.fragmentTracker,l=this.media;if(l!==null){var h=l.currentTime,n=a.getPartialFragment(h);if(n){var t=this._trySkipBufferHole(n);if(t||!this.media)return}f.len>e.maxBufferHole&&r>e.highBufferWatchdogPeriod*1e3&&(b.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},m._reportStall=function(f){var r=this.hls,e=this.media,a=this.stallReported;!a&&e&&(this.stallReported=!0,b.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(f)+")"),r.trigger(O.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:f.len}))},m._trySkipBufferHole=function(f){var r=this.config,e=this.hls,a=this.media;if(a===null)return 0;for(var l=a.currentTime,h=0,n=T.BufferHelper.getBuffered(a),t=0;t<n.length;t++){var i=n.start(t);if(l+r.maxBufferHole>=h&&l<i){var E=Math.max(i+g,a.currentTime+S);return b.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+E),this.moved=!0,this.stalled=null,a.currentTime=E,f&&e.trigger(O.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+E,frag:f}),E}h=n.end(t)}return 0},m._tryNudgeBuffer=function(){var f=this.config,r=this.hls,e=this.media,a=this.nudgeRetry;if(e!==null){var l=e.currentTime;if(this.nudgeRetry++,a<f.nudgeMaxRetry){var h=l+(a+1)*f.nudgeOffset;b.logger.warn("Nudging 'currentTime' from "+l+" to "+h),e.currentTime=h,r.trigger(O.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else b.logger.error("Playhead still not moving while enough data buffered @"+l+" after "+f.nudgeMaxRetry+" nudges"),r.trigger(O.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},p}()},"./src/controller/id3-track-controller.ts":function(K,M,D){D.r(M);var T=D("./src/polyfills/number.ts"),R=D("./src/events.ts"),O=D("./src/utils/texttrack-utils.ts"),b=D("./src/demux/id3.ts"),C=D("./src/loader/date-range.ts"),I=D("./src/types/demuxer.ts"),S=.25;function g(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function x(v,f){return v.getTime()/1e3-f}function p(v){return Uint8Array.from(v.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var m=function(){function v(r){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=r,this._registerListeners()}var f=v.prototype;return f.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},f._registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(R.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},f._unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(R.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},f.onMediaAttached=function(e,a){this.media=a.media},f.onMediaDetaching=function(){!this.id3Track||(Object(O.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},f.onManifestLoading=function(){this.dateRangeCuesAppended={}},f.createTrack=function(e){var a=this.getID3Track(e.textTracks);return a.mode="hidden",a},f.getID3Track=function(e){if(!!this.media){for(var a=0;a<e.length;a++){var l=e[a];if(l.kind==="metadata"&&l.label==="id3")return Object(O.sendAddTrackEvent)(l,this.media),l}return this.media.addTextTrack("metadata","id3")}},f.onFragParsingMetadata=function(e,a){if(!!this.media){var l=this.hls.config,h=l.enableEmsgMetadataCues,n=l.enableID3MetadataCues;if(!(!h&&!n)){var t=a.frag,i=a.samples,E=a.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var u=E.edge||t.end,d=g(),c=!1,o={},s=0;s<i.length;s++){var y=i[s].type;if(!(y===I.MetadataSchema.emsg&&!h||!n)){var L=b.getID3Frames(i[s].data);if(L){var A=i[s].pts,P=u,_=P-A;_<=0&&(P=A+S);for(var F=0;F<L.length;F++){var B=L[F];if(!b.isTimeStampFrame(B)){var k=new d(A,P,"");k.value=B,y&&(k.type=y),this.id3Track.addCue(k),o[B.key]=null,c=!0}}}}}c&&this.updateId3CueEnds(o)}}},f.updateId3CueEnds=function(e){var a,l=(a=this.id3Track)===null||a===void 0?void 0:a.cues;if(l)for(var h=l.length;h--;){var n,t=l[h],i=(n=t.value)===null||n===void 0?void 0:n.key;if(i&&i in e){var E=e[i];E&&t.endTime!==E&&(t.endTime=E),e[i]=t.startTime}}},f.onBufferFlushing=function(e,a){var l=a.startOffset,h=a.endOffset,n=a.type,t=this.id3Track,i=this.hls;if(!!i){var E=i.config,u=E.enableEmsgMetadataCues,d=E.enableID3MetadataCues;if(t&&(u||d)){var c;n==="audio"?c=function(s){return s.type===I.MetadataSchema.audioId3&&d}:n==="video"?c=function(s){return s.type===I.MetadataSchema.emsg&&u}:c=function(s){return s.type===I.MetadataSchema.audioId3&&d||s.type===I.MetadataSchema.emsg&&u},Object(O.removeCuesInRange)(t,l,h,c)}}},f.onLevelUpdated=function(e,a){var l=this,h=a.details;if(!(!this.media||!h.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var n=this.dateRangeCuesAppended,t=this.id3Track,i=h.dateRanges,E=Object.keys(i);if(t)for(var u=Object.keys(n).filter(function(_){return!E.includes(_)}),d=function(F){var B=u[F];Object.keys(n[B].cues).forEach(function(k){t.removeCue(n[B].cues[k])}),delete n[B]},c=u.length;c--;)d(c);var o=h.fragments[h.fragments.length-1];if(!(E.length===0||!Object(T.isFiniteNumber)(o==null?void 0:o.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var s=o.programDateTime/1e3-o.start,y=h.edge||o.end,L=g(),A=function(F){var B=E[F],k=i[B],N=n[B],U=(N==null?void 0:N.cues)||{},w=(N==null?void 0:N.durationKnown)||!1,W=x(k.startDate,s),j=y,H=k.endDate;if(H)j=x(H,s),w=!0;else if(k.endOnNext&&!w){var G=E.reduce(function(Q,J){var Z=i[J];return Z.class===k.class&&Z.id!==J&&Z.startDate>k.startDate&&Q.push(Z),Q},[]).sort(function(Q,J){return Q.startDate.getTime()-J.startDate.getTime()})[0];G&&(j=x(G.startDate,s),w=!0)}for(var Y=Object.keys(k.attr),X=0;X<Y.length;X++){var z=Y[X];if(!(z===C.DateRangeAttribute.ID||z===C.DateRangeAttribute.CLASS||z===C.DateRangeAttribute.START_DATE||z===C.DateRangeAttribute.DURATION||z===C.DateRangeAttribute.END_DATE||z===C.DateRangeAttribute.END_ON_NEXT)){var V=U[z];if(V)w&&!N.durationKnown&&(V.endTime=j);else{var $=k.attr[z];V=new L(W,j,""),(z===C.DateRangeAttribute.SCTE35_OUT||z===C.DateRangeAttribute.SCTE35_IN)&&($=p($)),V.value={key:z,data:$},V.type=I.MetadataSchema.dateRange,l.id3Track.addCue(V),U[z]=V}}}n[B]={cues:U,dateRange:k,durationKnown:w}},P=0;P<E.length;P++)A(P)}}},v}();M.default=m},"./src/controller/latency-controller.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return I});var T=D("./src/errors.ts"),R=D("./src/events.ts"),O=D("./src/utils/logger.ts");function b(S,g){for(var x=0;x<g.length;x++){var p=g[x];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(S,p.key,p)}}function C(S,g,x){return g&&b(S.prototype,g),x&&b(S,x),Object.defineProperty(S,"prototype",{writable:!1}),S}var I=function(){function S(x){var p=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 p.timeupdate()},this.hls=x,this.config=x.config,this.registerListeners()}var g=S.prototype;return g.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},g.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(R.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(R.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(R.Events.ERROR,this.onError)},g.onMediaAttached=function(p,m){this.media=m.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},g.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},g.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},g.onLevelUpdated=function(p,m){var v=m.details;this.levelDetails=v,v.advanced&&this.timeupdate(),!v.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},g.onError=function(p,m){m.details===T.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,O.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},g.timeupdate=function(){var p=this.media,m=this.levelDetails;if(!(!p||!m)){this.currentTime=p.currentTime;var v=this.computeLatency();if(v!==null){this._latency=v;var f=this.config,r=f.lowLatencyMode,e=f.maxLiveSyncPlaybackRate;if(!(!r||e===1)){var a=this.targetLatency;if(a!==null){var l=v-a,h=Math.min(this.maxLatency,a+m.targetduration),n=l<h;if(m.live&&n&&l>.05&&this.forwardBufferLength>1){var t=Math.min(2,Math.max(1,e)),i=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;p.playbackRate=Math.min(t,Math.max(1,i))}else p.playbackRate!==1&&p.playbackRate!==0&&(p.playbackRate=1)}}}}},g.estimateLiveEdge=function(){var p=this.levelDetails;return p===null?null:p.edge+p.age},g.computeLatency=function(){var p=this.estimateLiveEdge();return p===null?null:p-this.currentTime},C(S,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var p=this.config,m=this.levelDetails;return p.liveMaxLatencyDuration!==void 0?p.liveMaxLatencyDuration:m?p.liveMaxLatencyDurationCount*m.targetduration:0}},{key:"targetLatency",get:function(){var p=this.levelDetails;if(p===null)return null;var m=p.holdBack,v=p.partHoldBack,f=p.targetduration,r=this.config,e=r.liveSyncDuration,a=r.liveSyncDurationCount,l=r.lowLatencyMode,h=this.hls.userConfig,n=l&&v||m;(h.liveSyncDuration||h.liveSyncDurationCount||n===0)&&(n=e!==void 0?e:a*f);var t=f,i=1;return n+Math.min(this.stallCount*i,t)}},{key:"liveSyncPosition",get:function(){var p=this.estimateLiveEdge(),m=this.targetLatency,v=this.levelDetails;if(p===null||m===null||v===null)return null;var f=v.edge,r=p-m-this.edgeStalled,e=f-v.totalduration,a=f-(this.config.lowLatencyMode&&v.partTarget||v.targetduration);return Math.min(Math.max(e,r),a)}},{key:"drift",get:function(){var p=this.levelDetails;return p===null?1:p.drift}},{key:"edgeStalled",get:function(){var p=this.levelDetails;if(p===null)return 0;var m=(this.config.lowLatencyMode&&p.partTarget||p.targetduration)*3;return Math.max(p.age-m,0)}},{key:"forwardBufferLength",get:function(){var p=this.media,m=this.levelDetails;if(!p||!m)return 0;var v=p.buffered.length;return(v?p.buffered.end(v-1):m.edge)-this.currentTime}}]),S}()},"./src/controller/level-controller.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return r});var T=D("./src/types/level.ts"),R=D("./src/events.ts"),O=D("./src/errors.ts"),b=D("./src/utils/codecs.ts"),C=D("./src/controller/level-helper.ts"),I=D("./src/controller/base-playlist-controller.ts"),S=D("./src/types/loader.ts");function g(){return g=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var l=arguments[a];for(var h in l)Object.prototype.hasOwnProperty.call(l,h)&&(e[h]=l[h])}return e},g.apply(this,arguments)}function x(e,a){for(var l=0;l<a.length;l++){var h=a[l];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(e,h.key,h)}}function p(e,a,l){return a&&x(e.prototype,a),l&&x(e,l),Object.defineProperty(e,"prototype",{writable:!1}),e}function m(e,a){e.prototype=Object.create(a.prototype),e.prototype.constructor=e,v(e,a)}function v(e,a){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(h,n){return h.__proto__=n,h},v(e,a)}var f=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),r=function(e){m(a,e);function a(h){var n;return n=e.call(this,h,"[level-controller]")||this,n._levels=[],n._firstLevel=-1,n._startLevel=void 0,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.onParsedComplete=void 0,n._registerListeners(),n}var l=a.prototype;return l._registerListeners=function(){var n=this.hls;n.on(R.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.on(R.Events.FRAG_LOADED,this.onFragLoaded,this),n.on(R.Events.ERROR,this.onError,this)},l._unregisterListeners=function(){var n=this.hls;n.off(R.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(R.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),n.off(R.Events.FRAG_LOADED,this.onFragLoaded,this),n.off(R.Events.ERROR,this.onError,this)},l.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},l.startLoad=function(){var n=this._levels;n.forEach(function(t){t.loadError=0}),e.prototype.startLoad.call(this)},l.onManifestLoaded=function(n,t){var i=[],E=[],u=[],d,c={},o,s=!1,y=!1,L=!1;if(t.levels.forEach(function(F){var B=F.attrs;s=s||!!(F.width&&F.height),y=y||!!F.videoCodec,L=L||!!F.audioCodec,f&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var k=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;o=c[k],o?o.url.push(F.url):(o=new T.Level(F),c[k]=o,i.push(o)),B&&(B.AUDIO&&Object(C.addGroupId)(o,"audio",B.AUDIO),B.SUBTITLES&&Object(C.addGroupId)(o,"text",B.SUBTITLES))}),(s||y)&&L&&(i=i.filter(function(F){var B=F.videoCodec,k=F.width,N=F.height;return!!B||!!(k&&N)})),i=i.filter(function(F){var B=F.audioCodec,k=F.videoCodec;return(!B||Object(b.isCodecSupportedInMp4)(B,"audio"))&&(!k||Object(b.isCodecSupportedInMp4)(k,"video"))}),t.audioTracks&&(E=t.audioTracks.filter(function(F){return!F.audioCodec||Object(b.isCodecSupportedInMp4)(F.audioCodec,"audio")}),Object(C.assignTrackIdsByGroup)(E)),t.subtitles&&(u=t.subtitles,Object(C.assignTrackIdsByGroup)(u)),i.length>0){d=i[0].bitrate,i.sort(function(F,B){return F.bitrate-B.bitrate}),this._levels=i;for(var A=0;A<i.length;A++)if(i[A].bitrate===d){this._firstLevel=A,this.log("manifest loaded, "+i.length+" level(s) found, first bitrate: "+d);break}var P=L&&!y,_={levels:i,audioTracks:E,subtitleTracks:u,firstLevel:this._firstLevel,stats:t.stats,audio:L,video:y,altAudio:!P&&E.some(function(F){return!!F.url})};this.hls.trigger(R.Events.MANIFEST_PARSED,_),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(R.Events.ERROR,{type:O.ErrorTypes.MEDIA_ERROR,details:O.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},l.onError=function(n,t){if(e.prototype.onError.call(this,n,t),!t.fatal){var i=t.context,E=this._levels[this.currentLevelIndex];if(i&&(i.type===S.PlaylistContextType.AUDIO_TRACK&&E.audioGroupIds&&i.groupId===E.audioGroupIds[E.urlId]||i.type===S.PlaylistContextType.SUBTITLE_TRACK&&E.textGroupIds&&i.groupId===E.textGroupIds[E.urlId])){this.redundantFailover(this.currentLevelIndex);return}var u=!1,d=!0,c;switch(t.details){case O.ErrorDetails.FRAG_LOAD_ERROR:case O.ErrorDetails.FRAG_LOAD_TIMEOUT:case O.ErrorDetails.KEY_LOAD_ERROR:case O.ErrorDetails.KEY_LOAD_TIMEOUT:if(t.frag){var o=this._levels[t.frag.level];o?(o.fragmentError++,o.fragmentError>this.hls.config.fragLoadingMaxRetry&&(c=t.frag.level)):c=t.frag.level}break;case O.ErrorDetails.LEVEL_LOAD_ERROR:case O.ErrorDetails.LEVEL_LOAD_TIMEOUT:i&&(i.deliveryDirectives&&(d=!1),c=i.level),u=!0;break;case O.ErrorDetails.REMUX_ALLOC_ERROR:c=t.level,u=!0;break}c!==void 0&&this.recoverLevel(t,c,u,d)}},l.recoverLevel=function(n,t,i,E){var u=n.details,d=this._levels[t];if(d.loadError++,i){var c=this.retryLoadingOrFail(n);if(c)n.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(E){var o=d.url.length;if(o>1&&d.loadError<o)n.levelRetry=!0,this.redundantFailover(t);else if(this.manualLevelIndex===-1){var s=t===0?this._levels.length-1:t-1;this.currentLevelIndex!==s&&this._levels[s].loadError===0&&(this.warn(u+": switch to "+s),n.levelRetry=!0,this.hls.nextAutoLevel=s)}}},l.redundantFailover=function(n){var t=this._levels[n],i=t.url.length;if(i>1){var E=(t.urlId+1)%i;this.warn("Switching to redundant URL-id "+E),this._levels.forEach(function(u){u.urlId=E}),this.level=n}},l.onFragLoaded=function(n,t){var i=t.frag;if(i!==void 0&&i.type===S.PlaylistLevelType.MAIN){var E=this._levels[i.level];E!==void 0&&(E.fragmentError=0,E.loadError=0)}},l.onLevelLoaded=function(n,t){var i,E=t.level,u=t.details,d=this._levels[E];if(!d){var c;this.warn("Invalid level index "+E),(c=t.deliveryDirectives)!==null&&c!==void 0&&c.skip&&(u.deltaUpdateFailed=!0);return}E===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0,this.retryCount=0),this.playlistLoaded(E,t,d.details)):(i=t.deliveryDirectives)!==null&&i!==void 0&&i.skip&&(u.deltaUpdateFailed=!0)},l.onAudioTrackSwitched=function(n,t){var i=this.hls.levels[this.currentLevelIndex];if(!!i&&i.audioGroupIds){for(var E=-1,u=this.hls.audioTracks[t.id].groupId,d=0;d<i.audioGroupIds.length;d++)if(i.audioGroupIds[d]===u){E=d;break}E!==i.urlId&&(i.urlId=E,this.startLoad())}},l.loadPlaylist=function(n){var t=this.currentLevelIndex,i=this._levels[t];if(this.canLoad&&i&&i.url.length>0){var E=i.urlId,u=i.url[E];if(n)try{u=n.addDirectives(u)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}this.log("Attempt loading level index "+t+(n?" at sn "+n.msn+" part "+n.part:"")+" with URL-id "+E+" "+u),this.clearTimer(),this.hls.trigger(R.Events.LEVEL_LOADING,{url:u,level:t,id:E,deliveryDirectives:n||null})}},l.removeLevel=function(n,t){var i=function(d,c){return c!==t},E=this._levels.filter(function(u,d){return d!==n?!0:u.url.length>1&&t!==void 0?(u.url=u.url.filter(i),u.audioGroupIds&&(u.audioGroupIds=u.audioGroupIds.filter(i)),u.textGroupIds&&(u.textGroupIds=u.textGroupIds.filter(i)),u.urlId=0,!0):!1}).map(function(u,d){var c=u.details;return c!=null&&c.fragments&&c.fragments.forEach(function(o){o.level=d}),u});this._levels=E,this.hls.trigger(R.Events.LEVELS_UPDATED,{levels:E})},p(a,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(n){var t,i=this._levels;if(i.length!==0&&!(this.currentLevelIndex===n&&(t=i[n])!==null&&t!==void 0&&t.details)){if(n<0||n>=i.length){var E=n<0;if(this.hls.trigger(R.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.LEVEL_SWITCH_ERROR,level:n,fatal:E,reason:"invalid level idx"}),E)return;n=Math.min(n,i.length-1)}this.clearTimer();var u=this.currentLevelIndex,d=i[u],c=i[n];this.log("switching to level "+n+" from "+u),this.currentLevelIndex=n;var o=g({},c,{level:n,maxBitrate:c.maxBitrate,uri:c.uri,urlId:c.urlId});delete o._urlId,this.hls.trigger(R.Events.LEVEL_SWITCHING,o);var s=c.details;if(!s||s.live){var y=this.switchParams(c.uri,d==null?void 0:d.details);this.loadPlaylist(y)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(n){this.manualLevelIndex=n,this._startLevel===void 0&&(this._startLevel=n),n!==-1&&(this.level=n)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(n){this._firstLevel=n}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var n=this.hls.config.startLevel;return n!==void 0?n:this._firstLevel}else return this._startLevel},set:function(n){this._startLevel=n}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(n){this.level=n,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=n)}}]),a}(I.default)},"./src/controller/level-helper.ts":function(K,M,D){D.r(M),D.d(M,"addGroupId",function(){return C}),D.d(M,"assignTrackIdsByGroup",function(){return I}),D.d(M,"updatePTS",function(){return S}),D.d(M,"updateFragPTSDTS",function(){return x}),D.d(M,"mergeDetails",function(){return p}),D.d(M,"mapPartIntersection",function(){return v}),D.d(M,"mapFragmentIntersection",function(){return f}),D.d(M,"adjustSliding",function(){return r}),D.d(M,"addSliding",function(){return e}),D.d(M,"computeReloadInterval",function(){return a}),D.d(M,"getFragmentWithSN",function(){return l}),D.d(M,"getPartWith",function(){return h});var T=D("./src/polyfills/number.ts"),R=D("./src/utils/logger.ts"),O=D("./src/loader/date-range.ts");function b(){return b=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var E in i)Object.prototype.hasOwnProperty.call(i,E)&&(n[E]=i[E])}return n},b.apply(this,arguments)}function C(n,t,i){switch(t){case"audio":n.audioGroupIds||(n.audioGroupIds=[]),n.audioGroupIds.push(i);break;case"text":n.textGroupIds||(n.textGroupIds=[]),n.textGroupIds.push(i);break}}function I(n){var t={};n.forEach(function(i){var E=i.groupId||"";i.id=t[E]=t[E]||0,t[E]++})}function S(n,t,i){var E=n[t],u=n[i];g(E,u)}function g(n,t){var i=t.startPTS;if(Object(T.isFiniteNumber)(i)){var E=0,u;t.sn>n.sn?(E=i-n.start,u=n):(E=n.start-i,u=t),u.duration!==E&&(u.duration=E)}else if(t.sn>n.sn){var d=n.cc===t.cc;d&&n.minEndPTS?t.start=n.start+(n.minEndPTS-n.start):t.start=n.start+n.duration}else t.start=Math.max(n.start-t.duration,0)}function x(n,t,i,E,u,d){var c=E-i;c<=0&&(R.logger.warn("Fragment should have a positive duration",t),E=i+t.duration,d=u+t.duration);var o=i,s=E,y=t.startPTS,L=t.endPTS;if(Object(T.isFiniteNumber)(y)){var A=Math.abs(y-i);Object(T.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(A,t.deltaPTS):t.deltaPTS=A,o=Math.max(i,y),i=Math.min(i,y),u=Math.min(u,t.startDTS),s=Math.min(E,L),E=Math.max(E,L),d=Math.max(d,t.endDTS)}t.duration=E-i;var P=i-t.start;t.appendedPTS=E,t.start=t.startPTS=i,t.maxStartPTS=o,t.startDTS=u,t.endPTS=E,t.minEndPTS=s,t.endDTS=d;var _=t.sn;if(!n||_<n.startSN||_>n.endSN)return 0;var F,B=_-n.startSN,k=n.fragments;for(k[B]=t,F=B;F>0;F--)g(k[F],k[F-1]);for(F=B;F<k.length-1;F++)g(k[F],k[F+1]);return n.fragmentHint&&g(k[k.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,P}function p(n,t){for(var i=null,E=n.fragments,u=E.length-1;u>=0;u--){var d=E[u].initSegment;if(d){i=d;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;var c=0,o;if(f(n,t,function(F,B){F.relurl&&(c=F.cc-B.cc),Object(T.isFiniteNumber)(F.startPTS)&&Object(T.isFiniteNumber)(F.endPTS)&&(B.start=B.startPTS=F.startPTS,B.startDTS=F.startDTS,B.appendedPTS=F.appendedPTS,B.maxStartPTS=F.maxStartPTS,B.endPTS=F.endPTS,B.endDTS=F.endDTS,B.minEndPTS=F.minEndPTS,B.duration=F.endPTS-F.startPTS,B.duration&&(o=B),t.PTSKnown=t.alignedSliding=!0),B.elementaryStreams=F.elementaryStreams,B.loader=F.loader,B.stats=F.stats,B.urlId=F.urlId,F.initSegment&&(B.initSegment=F.initSegment,i=F.initSegment)}),i){var s=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;s.forEach(function(F){var B;(!F.initSegment||F.initSegment.relurl===((B=i)===null||B===void 0?void 0:B.relurl))&&(F.initSegment=i)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(function(F){return!F}),t.deltaUpdateFailed){R.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var y=t.skippedSegments;y--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=m(n.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var L=t.fragments;if(c){R.logger.warn("discontinuity sliding from playlist, take drift into account");for(var A=0;A<L.length;A++)L[A].cc+=c}t.skippedSegments&&(t.startCC=t.fragments[0].cc),v(n.partList,t.partList,function(F,B){B.elementaryStreams=F.elementaryStreams,B.stats=F.stats}),o?x(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):r(n,t),L.length&&(t.totalduration=t.edge-L[0].start),t.driftStartTime=n.driftStartTime,t.driftStart=n.driftStart;var P=t.advancedDateTime;if(t.advanced&&P){var _=t.edge;t.driftStart||(t.driftStartTime=P,t.driftStart=_),t.driftEndTime=P,t.driftEnd=_}else t.driftEndTime=n.driftEndTime,t.driftEnd=n.driftEnd,t.advancedDateTime=n.advancedDateTime}function m(n,t,i){var E=b({},n);return i&&i.forEach(function(u){delete E[u]}),Object.keys(t).forEach(function(u){var d=new O.DateRange(t[u].attr,E[u]);d.isValid?E[u]=d:R.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(t[u].attr)+'"')}),E}function v(n,t,i){if(n&&t)for(var E=0,u=0,d=n.length;u<=d;u++){var c=n[u],o=t[u+E];c&&o&&c.index===o.index&&c.fragment.sn===o.fragment.sn?i(c,o):E--}}function f(n,t,i){for(var E=t.skippedSegments,u=Math.max(n.startSN,t.startSN)-t.startSN,d=(n.fragmentHint?1:0)+(E?t.endSN:Math.min(n.endSN,t.endSN))-t.startSN,c=t.startSN-n.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,s=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments,y=u;y<=d;y++){var L=s[c+y],A=o[y];E&&!A&&y<E&&(A=t.fragments[y]=L),L&&A&&i(L,A)}}function r(n,t){var i=t.startSN+t.skippedSegments-n.startSN,E=n.fragments;i<0||i>=E.length||e(t,E[i].start)}function e(n,t){if(t){for(var i=n.fragments,E=n.skippedSegments;E<i.length;E++)i[E].start+=t;n.fragmentHint&&(n.fragmentHint.start+=t)}}function a(n,t){var i=1e3*n.levelTargetDuration,E=i/2,u=n.age,d=u>0&&u<i*3,c=t.loading.end-t.loading.start,o,s=n.availabilityDelay;if(n.updated===!1)if(d){var y=333*n.misses;o=Math.max(Math.min(E,c*2),y),n.availabilityDelay=(n.availabilityDelay||0)+o}else o=E;else d?(s=Math.min(s||i/2,u),n.availabilityDelay=s,o=s+i-u):o=i-c;return Math.round(o)}function l(n,t,i){if(!n||!n.details)return null;var E=n.details,u=E.fragments[t-E.startSN];return u||(u=E.fragmentHint,u&&u.sn===t)?u:t<E.startSN&&i&&i.sn===t?i:null}function h(n,t,i){if(!n||!n.details)return null;var E=n.details.partList;if(E)for(var u=E.length;u--;){var d=E[u];if(d.index===i&&d.fragment.sn===t)return d}return null}},"./src/controller/stream-controller.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return h});var T=D("./src/polyfills/number.ts"),R=D("./src/controller/base-stream-controller.ts"),O=D("./src/is-supported.ts"),b=D("./src/events.ts"),C=D("./src/utils/buffer-helper.ts"),I=D("./src/controller/fragment-tracker.ts"),S=D("./src/types/loader.ts"),g=D("./src/loader/fragment.ts"),x=D("./src/demux/transmuxer-interface.ts"),p=D("./src/types/transmuxer.ts"),m=D("./src/controller/gap-controller.ts"),v=D("./src/errors.ts");function f(n,t){for(var i=0;i<t.length;i++){var E=t[i];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(n,E.key,E)}}function r(n,t,i){return t&&f(n.prototype,t),i&&f(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n}function e(n,t){n.prototype=Object.create(t.prototype),n.prototype.constructor=n,a(n,t)}function a(n,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,u){return E.__proto__=u,E},a(n,t)}var l=100,h=function(n){e(t,n);function t(E,u){var d;return d=n.call(this,E,u,"[stream-controller]")||this,d.audioCodecSwap=!1,d.gapController=null,d.level=-1,d._forceStartLoad=!1,d.altAudio=!1,d.audioOnly=!1,d.fragPlaying=null,d.onvplaying=null,d.onvseeked=null,d.fragLastKbps=0,d.couldBacktrack=!1,d.backtrackFragment=null,d.audioCodecSwitch=!1,d.videoBuffer=null,d._registerListeners(),d}var i=t.prototype;return i._registerListeners=function(){var u=this.hls;u.on(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.on(b.Events.LEVEL_LOADING,this.onLevelLoading,this),u.on(b.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(b.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),u.on(b.Events.ERROR,this.onError,this),u.on(b.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.on(b.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.on(b.Events.BUFFER_CREATED,this.onBufferCreated,this),u.on(b.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.on(b.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),u.on(b.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var u=this.hls;u.off(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),u.off(b.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(b.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),u.off(b.Events.ERROR,this.onError,this),u.off(b.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),u.off(b.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.off(b.Events.BUFFER_CREATED,this.onBufferCreated,this),u.off(b.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),u.off(b.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),u.off(b.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},i.startLoad=function(u){if(this.levels){var d=this.lastCurrentTime,c=this.hls;if(this.stopLoad(),this.setInterval(l),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var o=c.startLevel;o===-1&&(c.config.testBandwidth?(o=0,this.bitrateTest=!0):o=c.nextAutoLevel),this.level=c.nextLoadLevel=o,this.loadedmetadata=!1}d>0&&u===-1&&(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),u=d),this.state=R.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=u,this.tick()}else this._forceStartLoad=!0,this.state=R.State.STOPPED},i.stopLoad=function(){this._forceStartLoad=!1,n.prototype.stopLoad.call(this)},i.doTick=function(){switch(this.state){case R.State.IDLE:this.doTickIdle();break;case R.State.WAITING_LEVEL:{var u,d=this.levels,c=this.level,o=d==null||(u=d[c])===null||u===void 0?void 0:u.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=R.State.IDLE;break}break}case R.State.FRAG_LOADING_WAITING_RETRY:{var s,y=self.performance.now(),L=this.retryDate;(!L||y>=L||(s=this.media)!==null&&s!==void 0&&s.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=R.State.IDLE)}break}this.onTickEnd()},i.onTickEnd=function(){n.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},i.doTickIdle=function(){var u,d,c=this.hls,o=this.levelLastLoaded,s=this.levels,y=this.media,L=c.config,A=c.nextLoadLevel;if(!(o===null||!y&&(this.startFragRequested||!L.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!s||!s[A])){var P=s[A];this.level=c.nextLoadLevel=A;var _=P.details;if(!_||this.state===R.State.WAITING_LEVEL||_.live&&this.levelLastLoaded!==A){this.state=R.State.WAITING_LEVEL;return}var F=this.getMainFwdBufferInfo();if(F!==null){var B=F.len,k=this.getMaxBufferLength(P.maxBitrate);if(!(B>=k)){if(this._streamEnded(F,_)){var N={};this.altAudio&&(N.type="video"),this.hls.trigger(b.Events.BUFFER_EOS,N),this.state=R.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>F.end&&(this.backtrackFragment=null);var U=this.backtrackFragment?this.backtrackFragment.start:F.end,w=this.getNextFragment(U,_);if(this.couldBacktrack&&!this.fragPrevious&&w&&w.sn!=="initSegment"&&this.fragmentTracker.getState(w)!==I.FragmentState.OK){var W,j=((W=this.backtrackFragment)!=null?W:w).sn,H=j-_.startSN,G=_.fragments[H-1];G&&w.cc===G.cc&&(w=G,this.fragmentTracker.removeFragment(G))}else this.backtrackFragment&&F.len&&(this.backtrackFragment=null);if(w&&this.fragmentTracker.getState(w)===I.FragmentState.OK&&this.nextLoadPosition>U){var Y=this.audioOnly&&!this.altAudio?g.ElementaryStreamTypes.AUDIO:g.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(y,Y,S.PlaylistLevelType.MAIN),w=this.getNextFragment(this.nextLoadPosition,_)}!w||(w.initSegment&&!w.initSegment.data&&!this.bitrateTest&&(w=w.initSegment),((u=w.decryptdata)===null||u===void 0?void 0:u.keyFormat)==="identity"&&!((d=w.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(w,_):this.loadFragment(w,_,U))}}}},i.loadFragment=function(u,d,c){var o,s=this.fragmentTracker.getState(u);this.fragCurrent=u,s===I.FragmentState.NOT_LOADED||s===I.FragmentState.PARTIAL?u.sn==="initSegment"?this._loadInitSegment(u):this.bitrateTest?(u.bitrateTest=!0,this.log("Fragment "+u.sn+" of level "+u.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(u)):(this.startFragRequested=!0,n.prototype.loadFragment.call(this,u,d,c)):s===I.FragmentState.APPENDING?this.reduceMaxBufferLength(u.duration)&&this.fragmentTracker.removeFragment(u):((o=this.media)===null||o===void 0?void 0:o.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},i.getAppendedFrag=function(u){var d=this.fragmentTracker.getAppendedFrag(u,S.PlaylistLevelType.MAIN);return d&&"fragment"in d?d.fragment:d},i.getBufferedFrag=function(u){return this.fragmentTracker.getBufferedFrag(u,S.PlaylistLevelType.MAIN)},i.followingBufferedFrag=function(u){return u?this.getBufferedFrag(u.end+.5):null},i.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},i.nextLevelSwitch=function(){var u=this.levels,d=this.media;if(d!=null&&d.readyState){var c,o=this.getAppendedFrag(d.currentTime);if(o&&o.start>1&&this.flushMainBuffer(0,o.start-1),!d.paused&&u){var s=this.hls.nextLoadLevel,y=u[s],L=this.fragLastKbps;L&&this.fragCurrent?c=this.fragCurrent.duration*y.maxBitrate/(1e3*L)+1:c=0}else c=0;var A=this.getBufferedFrag(d.currentTime+c);if(A){var P=this.followingBufferedFrag(A);if(P){this.abortCurrentFrag();var _=P.maxStartPTS?P.maxStartPTS:P.start,F=P.duration,B=Math.max(A.end,_+Math.min(Math.max(F-this.config.maxFragLookUpTolerance,F*.5),F*.75));this.flushMainBuffer(B,Number.POSITIVE_INFINITY)}}}},i.abortCurrentFrag=function(){var u=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,u!=null&&u.loader&&u.loader.abort(),this.state){case R.State.KEY_LOADING:case R.State.FRAG_LOADING:case R.State.FRAG_LOADING_WAITING_RETRY:case R.State.PARSING:case R.State.PARSED:this.state=R.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},i.flushMainBuffer=function(u,d){n.prototype.flushMainBuffer.call(this,u,d,this.altAudio?"video":null)},i.onMediaAttached=function(u,d){n.prototype.onMediaAttached.call(this,u,d);var c=d.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),c.addEventListener("playing",this.onvplaying),c.addEventListener("seeked",this.onvseeked),this.gapController=new m.default(this.config,c,this.fragmentTracker,this.hls)},i.onMediaDetaching=function(){var u=this.media;u&&(u.removeEventListener("playing",this.onvplaying),u.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),n.prototype.onMediaDetaching.call(this)},i.onMediaPlaying=function(){this.tick()},i.onMediaSeeked=function(){var u=this.media,d=u?u.currentTime:null;Object(T.isFiniteNumber)(d)&&this.log("Media seeked to "+d.toFixed(3)),this.tick()},i.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(b.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},i.onManifestParsed=function(u,d){var c=!1,o=!1,s;d.levels.forEach(function(y){s=y.audioCodec,s&&(s.indexOf("mp4a.40.2")!==-1&&(c=!0),s.indexOf("mp4a.40.5")!==-1&&(o=!0))}),this.audioCodecSwitch=c&&o&&!Object(O.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=d.levels,this.startFragRequested=!1},i.onLevelLoading=function(u,d){var c=this.levels;if(!(!c||this.state!==R.State.IDLE)){var o=c[d.level];(!o.details||o.details.live&&this.levelLastLoaded!==d.level||this.waitForCdnTuneIn(o.details))&&(this.state=R.State.WAITING_LEVEL)}},i.onLevelLoaded=function(u,d){var c,o=this.levels,s=d.level,y=d.details,L=y.totalduration;if(!o){this.warn("Levels were reset while loading level "+s);return}this.log("Level "+s+" loaded ["+y.startSN+","+y.endSN+"], cc ["+y.startCC+", "+y.endCC+"] duration:"+L);var A=this.fragCurrent;A&&(this.state===R.State.FRAG_LOADING||this.state===R.State.FRAG_LOADING_WAITING_RETRY)&&A.level!==d.level&&A.loader&&(this.state=R.State.IDLE,this.backtrackFragment=null,A.loader.abort());var P=o[s],_=0;if(y.live||(c=P.details)!==null&&c!==void 0&&c.live){if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed)return;_=this.alignPlaylists(y,P.details)}if(P.details=y,this.levelLastLoaded=s,this.hls.trigger(b.Events.LEVEL_UPDATED,{details:y,level:s}),this.state===R.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(y))return;this.state=R.State.IDLE}this.startFragRequested?y.live&&this.synchronizeToLiveEdge(y):this.setStartPosition(y,_),this.tick()},i._handleFragmentLoadProgress=function(u){var d,c=u.frag,o=u.part,s=u.payload,y=this.levels;if(!y){this.warn("Levels were reset while fragment load was in progress. Fragment "+c.sn+" of level "+c.level+" will not be buffered");return}var L=y[c.level],A=L.details;if(!A){this.warn("Dropping fragment "+c.sn+" of level "+c.level+" after level details were reset");return}var P=L.videoCodec,_=A.PTSKnown||!A.live,F=(d=c.initSegment)===null||d===void 0?void 0:d.data,B=this._getAudioCodec(L),k=this.transmuxer=this.transmuxer||new x.default(this.hls,S.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),N=o?o.index:-1,U=N!==-1,w=new p.ChunkMetadata(c.level,c.sn,c.stats.chunkCount,s.byteLength,N,U),W=this.initPTS[c.cc];k.push(s,F,B,P,c,o,A.totalduration,_,w,W)},i.onAudioTrackSwitching=function(u,d){var c=this.altAudio,o=!!d.url,s=d.id;if(!o){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var y=this.fragCurrent;y!=null&&y.loader&&(this.log("Switching to main audio track, cancel main fragment load"),y.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var L=this.hls;c&&L.trigger(b.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),L.trigger(b.Events.AUDIO_TRACK_SWITCHED,{id:s})}},i.onAudioTrackSwitched=function(u,d){var c=d.id,o=!!this.hls.audioTracks[c].url;if(o){var s=this.videoBuffer;s&&this.mediaBuffer!==s&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=s)}this.altAudio=o,this.tick()},i.onBufferCreated=function(u,d){var c=d.tracks,o,s,y=!1;for(var L in c){var A=c[L];if(A.id==="main"){if(s=L,o=A,L==="video"){var P=c[L];P&&(this.videoBuffer=P.buffer)}}else y=!0}y&&o?(this.log("Alternate track found, use "+s+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},i.onFragBuffered=function(u,d){var c=d.frag,o=d.part;if(!(c&&c.type!==S.PlaylistLevelType.MAIN)){if(this.fragContextChanged(c)){this.warn("Fragment "+c.sn+(o?" p: "+o.index:"")+" of level "+c.level+" finished buffering, but was aborted. state: "+this.state),this.state===R.State.PARSED&&(this.state=R.State.IDLE);return}var s=o?o.stats:c.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),c.sn!=="initSegment"&&(this.fragPrevious=c),this.fragBufferedComplete(c,o)}},i.onError=function(u,d){switch(d.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(S.PlaylistLevelType.MAIN,d);break;case v.ErrorDetails.LEVEL_LOAD_ERROR:case v.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==R.State.ERROR&&(d.fatal?(this.warn(""+d.details),this.state=R.State.ERROR):!d.levelRetry&&this.state===R.State.WAITING_LEVEL&&(this.state=R.State.IDLE));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="main"&&(this.state===R.State.PARSING||this.state===R.State.PARSED)){var c=!0,o=this.getFwdBufferInfo(this.media,S.PlaylistLevelType.MAIN);o&&o.len>.5&&(c=!this.reduceMaxBufferLength(o.len)),c&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break}},i.checkBuffer=function(){var u=this.media,d=this.gapController;if(!(!u||!d||!u.readyState)){var c=C.BufferHelper.getBuffered(u);if(!this.loadedmetadata&&c.length)this.loadedmetadata=!0,this.seekToStartPos();else{var o=this.state!==R.State.IDLE?this.fragCurrent:null;d.poll(this.lastCurrentTime,o)}this.lastCurrentTime=u.currentTime}},i.onFragLoadEmergencyAborted=function(){this.state=R.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},i.onBufferFlushed=function(u,d){var c=d.type;if(c!==g.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var o=(c===g.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,c,S.PlaylistLevelType.MAIN)}},i.onLevelsUpdated=function(u,d){this.levels=d.levels},i.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},i.seekToStartPos=function(){var u=this.media,d=u.currentTime,c=this.startPosition;if(c>=0&&d<c){if(u.seeking){this.log("could not seek to "+c+", already seeking at "+d);return}var o=C.BufferHelper.getBuffered(u),s=o.length?o.start(0):0,y=s-c;y>0&&(y<this.config.maxBufferHole||y<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+y+" to match buffer start"),c+=y,this.startPosition=c),this.log("seek to target start position "+c+" from current time "+d),u.currentTime=c}},i._getAudioCodec=function(u){var d=this.config.defaultAudioCodec||u.audioCodec;return this.audioCodecSwap&&d&&(this.log("Swapping audio codec"),d.indexOf("mp4a.40.5")!==-1?d="mp4a.40.2":d="mp4a.40.5"),d},i._loadBitrateTestFrag=function(u){var d=this;this._doFragLoad(u).then(function(c){var o=d.hls;if(!(!c||o.nextLoadLevel||d.fragContextChanged(u))){d.fragLoadError=0,d.state=R.State.IDLE,d.startFragRequested=!1,d.bitrateTest=!1;var s=u.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),o.trigger(b.Events.FRAG_LOADED,c)}})},i._handleTransmuxComplete=function(u){var d,c="main",o=this.hls,s=u.remuxResult,y=u.chunkMeta,L=this.getCurrentContext(y);if(!L){this.warn("The loading context changed while buffering fragment "+y.sn+" of level "+y.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(y.level);return}var A=L.frag,P=L.part,_=L.level,F=s.video,B=s.text,k=s.id3,N=s.initSegment,U=_.details,w=this.altAudio?void 0:s.audio;if(!this.fragContextChanged(A)){if(this.state=R.State.PARSING,N){N.tracks&&(this._bufferInitSegment(_,N.tracks,A,y),o.trigger(b.Events.FRAG_PARSING_INIT_SEGMENT,{frag:A,id:c,tracks:N.tracks}));var W=N.initPTS,j=N.timescale;Object(T.isFiniteNumber)(W)&&(this.initPTS[A.cc]=W,o.trigger(b.Events.INIT_PTS_FOUND,{frag:A,id:c,initPTS:W,timescale:j}))}if(F&&s.independent!==!1){if(U){var H=F.startPTS,G=F.endPTS,Y=F.startDTS,X=F.endDTS;if(P)P.elementaryStreams[F.type]={startPTS:H,endPTS:G,startDTS:Y,endDTS:X};else if(F.firstKeyFrame&&F.independent&&(this.couldBacktrack=!0),F.dropped&&F.independent){var z=this.getMainFwdBufferInfo(),V=(z?z.end:this.getLoadPosition())+this.config.maxBufferHole,$=F.firstKeyFramePTS?F.firstKeyFramePTS:H;if(V<$-this.config.maxBufferHole){this.backtrack(A);return}A.setElementaryStreamInfo(F.type,A.start,G,A.start,X,!0)}A.setElementaryStreamInfo(F.type,H,G,Y,X),this.backtrackFragment&&(this.backtrackFragment=A),this.bufferFragmentData(F,A,P,y)}}else if(s.independent===!1){this.backtrack(A);return}if(w){var Q=w.startPTS,J=w.endPTS,Z=w.startDTS,q=w.endDTS;P&&(P.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:Q,endPTS:J,startDTS:Z,endDTS:q}),A.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,Q,J,Z,q),this.bufferFragmentData(w,A,P,y)}if(U&&k!==null&&k!==void 0&&(d=k.samples)!==null&&d!==void 0&&d.length){var ee={id:c,frag:A,details:U,samples:k.samples};o.trigger(b.Events.FRAG_PARSING_METADATA,ee)}if(U&&B){var te={id:c,frag:A,details:U,samples:B.samples};o.trigger(b.Events.FRAG_PARSING_USERDATA,te)}}},i._bufferInitSegment=function(u,d,c,o){var s=this;if(this.state===R.State.PARSING){this.audioOnly=!!d.audio&&!d.video,this.altAudio&&!this.audioOnly&&delete d.audio;var y=d.audio,L=d.video,A=d.audiovideo;if(y){var P=u.audioCodec,_=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(P&&(P.indexOf("mp4a.40.5")!==-1?P="mp4a.40.2":P="mp4a.40.5"),y.metadata.channelCount!==1&&_.indexOf("firefox")===-1&&(P="mp4a.40.5")),_.indexOf("android")!==-1&&y.container!=="audio/mpeg"&&(P="mp4a.40.2",this.log("Android: force audio codec to "+P)),u.audioCodec&&u.audioCodec!==P&&this.log('Swapping manifest audio codec "'+u.audioCodec+'" for "'+P+'"'),y.levelCodec=P,y.id="main",this.log("Init audio buffer, container:"+y.container+", codecs[selected/level/parsed]=["+(P||"")+"/"+(u.audioCodec||"")+"/"+y.codec+"]")}L&&(L.levelCodec=u.videoCodec,L.id="main",this.log("Init video buffer, container:"+L.container+", codecs[level/parsed]=["+(u.videoCodec||"")+"/"+L.codec+"]")),A&&this.log("Init audiovideo buffer, container:"+A.container+", codecs[level/parsed]=["+(u.attrs.CODECS||"")+"/"+A.codec+"]"),this.hls.trigger(b.Events.BUFFER_CODECS,d),Object.keys(d).forEach(function(F){var B=d[F],k=B.initSegment;k!=null&&k.byteLength&&s.hls.trigger(b.Events.BUFFER_APPENDING,{type:F,data:k,frag:c,part:null,chunkMeta:o,parent:c.type})}),this.tick()}},i.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,S.PlaylistLevelType.MAIN)},i.backtrack=function(u){this.couldBacktrack=!0,this.backtrackFragment=u,this.resetTransmuxer(),this.flushBufferGap(u),this.fragmentTracker.removeFragment(u),this.fragPrevious=null,this.nextLoadPosition=u.start,this.state=R.State.IDLE},i.checkFragmentChanged=function(){var u=this.media,d=null;if(u&&u.readyState>1&&u.seeking===!1){var c=u.currentTime;if(C.BufferHelper.isBuffered(u,c)?d=this.getAppendedFrag(c):C.BufferHelper.isBuffered(u,c+.1)&&(d=this.getAppendedFrag(c+.1)),d){this.backtrackFragment=null;var o=this.fragPlaying,s=d.level;(!o||d.sn!==o.sn||o.level!==s||d.urlId!==o.urlId)&&(this.hls.trigger(b.Events.FRAG_CHANGED,{frag:d}),(!o||o.level!==s)&&this.hls.trigger(b.Events.LEVEL_SWITCHED,{level:s}),this.fragPlaying=d)}}},r(t,[{key:"nextLevel",get:function(){var u=this.nextBufferedFrag;return u?u.level:-1}},{key:"currentFrag",get:function(){var u=this.media;return u?this.fragPlaying||this.getAppendedFrag(u.currentTime):null}},{key:"currentProgramDateTime",get:function(){var u=this.media;if(u){var d=u.currentTime,c=this.currentFrag;if(c&&Object(T.isFiniteNumber)(d)&&Object(T.isFiniteNumber)(c.programDateTime)){var o=c.programDateTime+(d-c.start)*1e3;return new Date(o)}}return null}},{key:"currentLevel",get:function(){var u=this.currentFrag;return u?u.level:-1}},{key:"nextBufferedFrag",get:function(){var u=this.currentFrag;return u?this.followingBufferedFrag(u):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(R.default)},"./src/controller/subtitle-stream-controller.ts":function(K,M,D){D.r(M),D.d(M,"SubtitleStreamController",function(){return e});var T=D("./src/events.ts"),R=D("./src/utils/buffer-helper.ts"),O=D("./src/controller/fragment-finders.ts"),b=D("./src/utils/discontinuities.ts"),C=D("./src/controller/level-helper.ts"),I=D("./src/controller/fragment-tracker.ts"),S=D("./src/controller/base-stream-controller.ts"),g=D("./src/types/loader.ts"),x=D("./src/types/level.ts");function p(a,l){for(var h=0;h<l.length;h++){var n=l[h];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(a,n.key,n)}}function m(a,l,h){return l&&p(a.prototype,l),h&&p(a,h),Object.defineProperty(a,"prototype",{writable:!1}),a}function v(a,l){a.prototype=Object.create(l.prototype),a.prototype.constructor=a,f(a,l)}function f(a,l){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,t){return n.__proto__=t,n},f(a,l)}var r=500,e=function(a){v(l,a);function l(n,t){var i;return i=a.call(this,n,t,"[subtitle-stream-controller]")||this,i.levels=[],i.currentTrackId=-1,i.tracksBuffered=[],i.mainDetails=null,i._registerListeners(),i}var h=l.prototype;return h.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},h._registerListeners=function(){var t=this.hls;t.on(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(T.Events.ERROR,this.onError,this),t.on(T.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(T.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(T.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(T.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(T.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},h._unregisterListeners=function(){var t=this.hls;t.off(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(T.Events.ERROR,this.onError,this),t.off(T.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(T.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(T.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(T.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(T.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},h.startLoad=function(){this.stopLoad(),this.state=S.State.IDLE,this.setInterval(r),this.tick()},h.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},h.onLevelLoaded=function(t,i){this.mainDetails=i.details},h.onSubtitleFragProcessed=function(t,i){var E=i.frag,u=i.success;if(this.fragPrevious=E,this.state=S.State.IDLE,!!u){var d=this.tracksBuffered[this.currentTrackId];if(!!d){for(var c,o=E.start,s=0;s<d.length;s++)if(o>=d[s].start&&o<=d[s].end){c=d[s];break}var y=E.start+E.duration;c?c.end=y:(c={start:o,end:y},d.push(c)),this.fragmentTracker.fragBuffered(E)}}},h.onBufferFlushing=function(t,i){var E=i.startOffset,u=i.endOffset;if(E===0&&u!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,c=this.levels;if(!c.length||!c[d]||!c[d].details)return;var o=c[d].details,s=o.targetduration,y=u-s;if(y<=0)return;i.endOffsetSubtitles=Math.max(0,y),this.tracksBuffered.forEach(function(L){for(var A=0;A<L.length;){if(L[A].end<=y){L.shift();continue}else if(L[A].start<y)L[A].start=y;else break;A++}}),this.fragmentTracker.removeFragmentsInRange(E,y,g.PlaylistLevelType.SUBTITLE)}},h.onError=function(t,i){var E,u=i.frag;!u||u.type!==g.PlaylistLevelType.SUBTITLE||((E=this.fragCurrent)!==null&&E!==void 0&&E.loader&&this.fragCurrent.loader.abort(),this.state=S.State.IDLE)},h.onSubtitleTracksUpdated=function(t,i){var E=this,u=i.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(d){return new x.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){E.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},h.onSubtitleTrackSwitch=function(t,i){if(this.currentTrackId=i.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var E=this.levels[this.currentTrackId];E!=null&&E.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,E&&this.setInterval(r)},h.onSubtitleTrackLoaded=function(t,i){var E,u=i.details,d=i.id,c=this.currentTrackId,o=this.levels;if(!!o.length){var s=o[c];if(!(d>=o.length||d!==c||!s)){if(this.mediaBuffer=this.mediaBufferTimeRanges,u.live||(E=s.details)!==null&&E!==void 0&&E.live){var y=this.mainDetails;if(u.deltaUpdateFailed||!y)return;var L=y.fragments[0];if(!s.details)u.hasProgramDateTime&&y.hasProgramDateTime?Object(b.alignMediaPlaylistByPDT)(u,y):L&&Object(C.addSliding)(u,L.start);else{var A=this.alignPlaylists(u,s.details);A===0&&L&&Object(C.addSliding)(u,L.start)}}if(s.details=u,this.levelLastLoaded=d,this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===S.State.IDLE){var P=Object(O.findFragmentByPTS)(null,u.fragments,this.media.currentTime,0);P||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}}},h._handleFragmentLoadComplete=function(t){var i=t.frag,E=t.payload,u=i.decryptdata,d=this.hls;if(!this.fragContextChanged(i)&&E&&E.byteLength>0&&u&&u.key&&u.iv&&u.method==="AES-128"){var c=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(E),u.key.buffer,u.iv.buffer).then(function(o){var s=performance.now();d.trigger(T.Events.FRAG_DECRYPTED,{frag:i,payload:o,stats:{tstart:c,tdecrypt:s}})})}},h.doTick=function(){if(!this.media){this.state=S.State.IDLE;return}if(this.state===S.State.IDLE){var t=this.currentTrackId,i=this.levels;if(!i.length||!i[t]||!i[t].details)return;var E=i[t].details,u=E.targetduration,d=this.config,c=this.media,o=R.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,c.currentTime-u,d.maxBufferHole),s=o.end,y=o.len,L=this.getMaxBufferLength()+u;if(y>L)return;console.assert(E,"Subtitle track details are defined on idle subtitle stream controller tick");var A=E.fragments,P=A.length,_=E.edge,F,B=this.fragPrevious;if(s<_){var k=d.maxFragLookUpTolerance;F=Object(O.findFragmentByPTS)(B,A,Math.max(A[0].start,s),k),!F&&B&&B.start<A[0].start&&(F=A[0])}else F=A[P-1];if(F=this.mapToInitFragWhenRequired(F),!F)return;F.encrypted?this.loadKey(F,E):this.fragmentTracker.getState(F)===I.FragmentState.NOT_LOADED&&this.loadFragment(F,E,s)}},h.loadFragment=function(t,i,E){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t):a.prototype.loadFragment.call(this,t,i,E)},m(l,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),l}(S.default)},"./src/controller/subtitle-track-controller.ts":function(K,M,D){D.r(M);var T=D("./src/events.ts"),R=D("./src/utils/texttrack-utils.ts"),O=D("./src/controller/base-playlist-controller.ts"),b=D("./src/types/loader.ts");function C(m,v){for(var f=0;f<v.length;f++){var r=v[f];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(m,r.key,r)}}function I(m,v,f){return v&&C(m.prototype,v),f&&C(m,f),Object.defineProperty(m,"prototype",{writable:!1}),m}function S(m,v){m.prototype=Object.create(v.prototype),m.prototype.constructor=m,g(m,v)}function g(m,v){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},g(m,v)}var x=function(m){S(v,m);function v(r){var e;return e=m.call(this,r,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var f=v.prototype;return f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,m.prototype.destroy.call(this)},f.registerListeners=function(){var e=this.hls;e.on(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(T.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(T.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(T.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(T.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var e=this.hls;e.off(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(T.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(T.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(T.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(T.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(T.Events.ERROR,this.onError,this)},f.onMediaAttached=function(e,a){this.media=a.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))},f.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},f.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=p(this.media.textTracks);e.forEach(function(a){Object(R.clearCurrentCues)(a)}),this.subtitleTrack=-1,this.media=null}},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},f.onManifestParsed=function(e,a){this.tracks=a.subtitleTracks},f.onSubtitleTrackLoaded=function(e,a){var l=a.id,h=a.details,n=this.trackId,t=this.tracksInGroup[n];if(!t){this.warn("Invalid subtitle track id "+l);return}var i=t.details;t.details=a.details,this.log("subtitle track "+l+" loaded ["+h.startSN+"-"+h.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,a,i))},f.onLevelLoading=function(e,a){this.switchLevel(a.level)},f.onLevelSwitching=function(e,a){this.switchLevel(a.level)},f.switchLevel=function(e){var a=this.hls.levels[e];if(!!(a!=null&&a.textGroupIds)){var l=a.textGroupIds[a.urlId];if(this.groupId!==l){var h=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,n=this.tracks.filter(function(E){return!l||E.groupId===l});this.tracksInGroup=n;var t=this.findTrackId(h==null?void 0:h.name)||this.findTrackId();this.groupId=l;var i={subtitleTracks:n};this.log("Updating subtitle tracks, "+n.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(T.Events.SUBTITLE_TRACKS_UPDATED,i),t!==-1&&this.setSubtitleTrack(t,h)}}},f.findTrackId=function(e){for(var a=this.tracksInGroup,l=0;l<a.length;l++){var h=a[l];if((!this.selectDefaultTrack||h.default)&&(!e||e===h.name))return h.id}return-1},f.onError=function(e,a){m.prototype.onError.call(this,e,a),!(a.fatal||!a.context)&&a.context.type===b.PlaylistContextType.SUBTITLE_TRACK&&a.context.id===this.trackId&&a.context.groupId===this.groupId&&this.retryLoadingOrFail(a)},f.loadPlaylist=function(e){var a=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(a)){var l=a.id,h=a.groupId,n=a.url;if(e)try{n=e.addDirectives(n)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+l),this.hls.trigger(T.Events.SUBTITLE_TRACK_LOADING,{url:n,id:l,groupId:h,deliveryDirectives:e||null})}},f.toggleTrackModes=function(e){var a=this,l=this.media,h=this.trackId;if(!!l){var n=p(l.textTracks),t=n.filter(function(u){return u.groupId===a.groupId});if(e===-1)[].slice.call(n).forEach(function(u){u.mode="disabled"});else{var i=t[h];i&&(i.mode="disabled")}var E=t[e];E&&(E.mode=this.subtitleDisplay?"showing":"hidden")}},f.setSubtitleTrack=function(e,a){var l,h=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(l=h[e])!==null&&l!==void 0&&l.details)||e<-1||e>=h.length)){this.clearTimer();var n=h[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,n){var t=n.id,i=n.groupId,E=i===void 0?"":i,u=n.name,d=n.type,c=n.url;this.hls.trigger(T.Events.SUBTITLE_TRACK_SWITCH,{id:t,groupId:E,name:u,type:d,url:c});var o=this.switchParams(n.url,a==null?void 0:a.details);this.loadPlaylist(o)}else this.hls.trigger(T.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},f.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,a=p(this.media.textTracks),l=0;l<a.length;l++)if(a[l].mode==="hidden")e=l;else if(a[l].mode==="showing"){e=l;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},I(v,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,a)}}]),v}(O.default);function p(m){for(var v=[],f=0;f<m.length;f++){var r=m[f];r.kind==="subtitles"&&r.label&&v.push(m[f])}return v}M.default=x},"./src/controller/timeline-controller.ts":function(K,M,D){D.r(M),D.d(M,"TimelineController",function(){return m});var T=D("./src/polyfills/number.ts"),R=D("./src/events.ts"),O=D("./src/utils/cea-608-parser.ts"),b=D("./src/utils/output-filter.ts"),C=D("./src/utils/webvtt-parser.ts"),I=D("./src/utils/texttrack-utils.ts"),S=D("./src/utils/imsc1-ttml-parser.ts"),g=D("./src/utils/mp4-tools.ts"),x=D("./src/types/loader.ts"),p=D("./src/utils/logger.ts"),m=function(){function e(l){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=r(),this.captionsProperties=void 0,this.hls=l,this.config=l.config,this.Cues=l.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 h=new b.default(this,"textTrack1"),n=new b.default(this,"textTrack2"),t=new b.default(this,"textTrack3"),i=new b.default(this,"textTrack4");this.cea608Parser1=new O.default(1,h,n),this.cea608Parser2=new O.default(3,t,i)}l.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),l.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),l.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),l.on(R.Events.MANIFEST_LOADED,this.onManifestLoaded,this),l.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),l.on(R.Events.FRAG_LOADING,this.onFragLoading,this),l.on(R.Events.FRAG_LOADED,this.onFragLoaded,this),l.on(R.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),l.on(R.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),l.on(R.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),l.on(R.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),l.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var a=e.prototype;return a.destroy=function(){var h=this.hls;h.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),h.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(R.Events.MANIFEST_LOADED,this.onManifestLoaded,this),h.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),h.off(R.Events.FRAG_LOADING,this.onFragLoading,this),h.off(R.Events.FRAG_LOADED,this.onFragLoaded,this),h.off(R.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),h.off(R.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),h.off(R.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(R.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),h.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},a.addCues=function(h,n,t,i,E){for(var u=!1,d=E.length;d--;){var c=E[d],o=f(c[0],c[1],n,t);if(o>=0&&(c[0]=Math.min(c[0],n),c[1]=Math.max(c[1],t),u=!0,o/(t-n)>.5))return}if(u||E.push([n,t]),this.config.renderTextTracksNatively){var s=this.captionsTracks[h];this.Cues.newCue(s,n,t,i)}else{var y=this.Cues.newCue(null,n,t,i);this.hls.trigger(R.Events.CUES_PARSED,{type:"captions",cues:y,track:h})}},a.onInitPtsFound=function(h,n){var t=this,i=n.frag,E=n.id,u=n.initPTS,d=n.timescale,c=this.unparsedVttFrags;E==="main"&&(this.initPTS[i.cc]=u,this.timescale[i.cc]=d),c.length&&(this.unparsedVttFrags=[],c.forEach(function(o){t.onFragLoaded(R.Events.FRAG_LOADED,o)}))},a.getExistingTrack=function(h){var n=this.media;if(n)for(var t=0;t<n.textTracks.length;t++){var i=n.textTracks[t];if(i[h])return i}return null},a.createCaptionsTrack=function(h){this.config.renderTextTracksNatively?this.createNativeTrack(h):this.createNonNativeTrack(h)},a.createNativeTrack=function(h){if(!this.captionsTracks[h]){var n=this.captionsProperties,t=this.captionsTracks,i=this.media,E=n[h],u=E.label,d=E.languageCode,c=this.getExistingTrack(h);if(c)t[h]=c,Object(I.clearCurrentCues)(t[h]),Object(I.sendAddTrackEvent)(t[h],i);else{var o=this.createTextTrack("captions",u,d);o&&(o[h]=!0,t[h]=o)}}},a.createNonNativeTrack=function(h){if(!this.nonNativeCaptionsTracks[h]){var n=this.captionsProperties[h];if(!!n){var t=n.label,i={_id:h,label:t,kind:"captions",default:n.media?!!n.media.default:!1,closedCaptions:n.media};this.nonNativeCaptionsTracks[h]=i,this.hls.trigger(R.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},a.createTextTrack=function(h,n,t){var i=this.media;if(!!i)return i.addTextTrack(h,n,t)},a.onMediaAttaching=function(h,n){this.media=n.media,this._cleanTracks()},a.onMediaDetaching=function(){var h=this.captionsTracks;Object.keys(h).forEach(function(n){Object(I.clearCurrentCues)(h[n]),delete h[n]}),this.nonNativeCaptionsTracks={}},a.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=r(),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())},a._cleanTracks=function(){var h=this.media;if(!!h){var n=h.textTracks;if(n)for(var t=0;t<n.length;t++)Object(I.clearCurrentCues)(n[t])}},a.onSubtitleTracksUpdated=function(h,n){var t=this;this.textTracks=[];var i=n.subtitleTracks||[],E=i.some(function(o){return o.textCodec===S.IMSC1_CODEC});if(this.config.enableWebVTT||E&&this.config.enableIMSC1){var u=this.tracks&&i&&this.tracks.length===i.length;if(this.tracks=i||[],this.config.renderTextTracksNatively){var d=this.media?this.media.textTracks:[];this.tracks.forEach(function(o,s){var y;if(s<d.length){for(var L=null,A=0;A<d.length;A++)if(v(d[A],o)){L=d[A];break}L&&(y=L)}if(y)Object(I.clearCurrentCues)(y);else{var P=t._captionsOrSubtitlesFromCharacteristics(o);y=t.createTextTrack(P,o.name,o.lang),y&&(y.mode="disabled")}y&&(y.groupId=o.groupId,t.textTracks.push(y))})}else if(!u&&this.tracks&&this.tracks.length){var c=this.tracks.map(function(o){return{label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}});this.hls.trigger(R.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},a._captionsOrSubtitlesFromCharacteristics=function(h){var n;if((n=h.attrs)!==null&&n!==void 0&&n.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(h.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(h.attrs.CHARACTERISTICS);if(t&&i)return"captions"}return"subtitles"},a.onManifestLoaded=function(h,n){var t=this;this.config.enableCEA708Captions&&n.captions&&n.captions.forEach(function(i){var E=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!!E){var u="textTrack"+E[1],d=t.captionsProperties[u];!d||(d.label=i.name,i.lang&&(d.languageCode=i.lang),d.media=i)}})},a.onFragLoading=function(h,n){var t=this.cea608Parser1,i=this.cea608Parser2,E=this.lastSn,u=this.lastPartIndex;if(!(!this.enabled||!(t&&i))&&n.frag.type===x.PlaylistLevelType.MAIN){var d,c,o=n.frag.sn,s=(d=n==null||(c=n.part)===null||c===void 0?void 0:c.index)!=null?d:-1;o===E+1||o===E&&s===u+1||(t.reset(),i.reset()),this.lastSn=o,this.lastPartIndex=s}},a.onFragLoaded=function(h,n){var t=n.frag,i=n.payload,E=this.initPTS,u=this.unparsedVttFrags;if(t.type===x.PlaylistLevelType.SUBTITLE)if(i.byteLength){if(!Object(T.isFiniteNumber)(E[t.cc])){u.push(n),E.length&&this.hls.trigger(R.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")});return}var d=t.decryptdata,c="stats"in n;if(d==null||d.key==null||d.method!=="AES-128"||c){var o=this.tracks[t.level],s=this.vttCCs;s[t.cc]||(s[t.cc]={start:t.start,prevCC:this.prevCC,new:!0},this.prevCC=t.cc),o&&o.textCodec===S.IMSC1_CODEC?this._parseIMSC1(t,i):this._parseVTTs(t,i,s)}}else this.hls.trigger(R.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},a._parseIMSC1=function(h,n){var t=this,i=this.hls;Object(S.parseIMSC1)(n,this.initPTS[h.cc],this.timescale[h.cc],function(E){t._appendCues(E,h.level),i.trigger(R.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(E){p.logger.log("Failed to parse IMSC1: "+E),i.trigger(R.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:E})})},a._parseVTTs=function(h,n,t){var i,E=this,u=this.hls,d=(i=h.initSegment)!==null&&i!==void 0&&i.data?Object(g.appendUint8Array)(h.initSegment.data,new Uint8Array(n)):n;Object(C.parseWebVTT)(d,this.initPTS[h.cc],this.timescale[h.cc],t,h.cc,h.start,function(c){E._appendCues(c,h.level),u.trigger(R.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:h})},function(c){E._fallbackToIMSC1(h,n),p.logger.log("Failed to parse VTT cue: "+c),u.trigger(R.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:h,error:c})})},a._fallbackToIMSC1=function(h,n){var t=this,i=this.tracks[h.level];i.textCodec||Object(S.parseIMSC1)(n,this.initPTS[h.cc],this.timescale[h.cc],function(){i.textCodec=S.IMSC1_CODEC,t._parseIMSC1(h,n)},function(){i.textCodec="wvtt"})},a._appendCues=function(h,n){var t=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[n];if(!i||i.mode==="disabled")return;h.forEach(function(d){return Object(I.addCueToTrack)(i,d)})}else{var E=this.tracks[n];if(!E)return;var u=E.default?"default":"subtitles"+n;t.trigger(R.Events.CUES_PARSED,{type:"subtitles",cues:h,track:u})}},a.onFragDecrypted=function(h,n){var t=n.frag;if(t.type===x.PlaylistLevelType.SUBTITLE){if(!Object(T.isFiniteNumber)(this.initPTS[t.cc])){this.unparsedVttFrags.push(n);return}this.onFragLoaded(R.Events.FRAG_LOADED,n)}},a.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},a.onFragParsingUserdata=function(h,n){var t=this.cea608Parser1,i=this.cea608Parser2;if(!(!this.enabled||!(t&&i)))for(var E=0;E<n.samples.length;E++){var u=n.samples[E].bytes;if(u){var d=this.extractCea608Data(u);t.addData(n.samples[E].pts,d[0]),i.addData(n.samples[E].pts,d[1])}}},a.onBufferFlushing=function(h,n){var t=n.startOffset,i=n.endOffset,E=n.endOffsetSubtitles,u=n.type,d=this.media;if(!(!d||d.currentTime<i)){if(!u||u==="video"){var c=this.captionsTracks;Object.keys(c).forEach(function(s){return Object(I.removeCuesInRange)(c[s],t,i)})}if(this.config.renderTextTracksNatively&&t===0&&E!==void 0){var o=this.textTracks;Object.keys(o).forEach(function(s){return Object(I.removeCuesInRange)(o[s],t,E)})}}},a.extractCea608Data=function(h){for(var n=[[],[]],t=h[0]&31,i=2,E=0;E<t;E++){var u=h[i++],d=127&h[i++],c=127&h[i++];if(!(d===0&&c===0)){var o=(4&u)!==0;if(o){var s=3&u;(s===0||s===1)&&(n[s].push(d),n[s].push(c))}}}return n},e}();function v(e,a){return e&&e.label===a.name&&!(e.textTrack1||e.textTrack2)}function f(e,a,l,h){return Math.min(a,h)-Math.max(e,l)}function r(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return T});var T=function(){function R(b,C){this.subtle=void 0,this.aesIV=void 0,this.subtle=b,this.aesIV=C}var O=R.prototype;return O.decrypt=function(C,I){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},I,C)},R}()},"./src/crypt/aes-decryptor.ts":function(K,M,D){D.r(M),D.d(M,"removePadding",function(){return R}),D.d(M,"default",function(){return O});var T=D("./src/utils/typed-array.ts");function R(b){var C=b.byteLength,I=C&&new DataView(b.buffer).getUint8(C-1);return I?Object(T.sliceUint8)(b,0,C-I):b}var O=function(){function b(){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 C=b.prototype;return C.uint8ArrayToUint32Array_=function(S){for(var g=new DataView(S),x=new Uint32Array(4),p=0;p<4;p++)x[p]=g.getUint32(p*4);return x},C.initTable=function(){var S=this.sBox,g=this.invSBox,x=this.subMix,p=x[0],m=x[1],v=x[2],f=x[3],r=this.invSubMix,e=r[0],a=r[1],l=r[2],h=r[3],n=new Uint32Array(256),t=0,i=0,E=0;for(E=0;E<256;E++)E<128?n[E]=E<<1:n[E]=E<<1^283;for(E=0;E<256;E++){var u=i^i<<1^i<<2^i<<3^i<<4;u=u>>>8^u&255^99,S[t]=u,g[u]=t;var d=n[t],c=n[d],o=n[c],s=n[u]*257^u*16843008;p[t]=s<<24|s>>>8,m[t]=s<<16|s>>>16,v[t]=s<<8|s>>>24,f[t]=s,s=o*16843009^c*65537^d*257^t*16843008,e[u]=s<<24|s>>>8,a[u]=s<<16|s>>>16,l[u]=s<<8|s>>>24,h[u]=s,t?(t=d^n[n[n[o^d]]],i^=n[n[i]]):t=i=1}},C.expandKey=function(S){for(var g=this.uint8ArrayToUint32Array_(S),x=!0,p=0;p<g.length&&x;)x=g[p]===this.key[p],p++;if(!x){this.key=g;var m=this.keySize=g.length;if(m!==4&&m!==6&&m!==8)throw new Error("Invalid aes key size="+m);var v=this.ksRows=(m+6+1)*4,f,r,e=this.keySchedule=new Uint32Array(v),a=this.invKeySchedule=new Uint32Array(v),l=this.sBox,h=this.rcon,n=this.invSubMix,t=n[0],i=n[1],E=n[2],u=n[3],d,c;for(f=0;f<v;f++){if(f<m){d=e[f]=g[f];continue}c=d,f%m===0?(c=c<<8|c>>>24,c=l[c>>>24]<<24|l[c>>>16&255]<<16|l[c>>>8&255]<<8|l[c&255],c^=h[f/m|0]<<24):m>6&&f%m===4&&(c=l[c>>>24]<<24|l[c>>>16&255]<<16|l[c>>>8&255]<<8|l[c&255]),e[f]=d=(e[f-m]^c)>>>0}for(r=0;r<v;r++)f=v-r,r&3?c=e[f]:c=e[f-4],r<4||f<=4?a[r]=c:a[r]=t[l[c>>>24]]^i[l[c>>>16&255]]^E[l[c>>>8&255]]^u[l[c&255]],a[r]=a[r]>>>0}},C.networkToHostOrderSwap=function(S){return S<<24|(S&65280)<<8|(S&16711680)>>8|S>>>24},C.decrypt=function(S,g,x){for(var p=this.keySize+6,m=this.invKeySchedule,v=this.invSBox,f=this.invSubMix,r=f[0],e=f[1],a=f[2],l=f[3],h=this.uint8ArrayToUint32Array_(x),n=h[0],t=h[1],i=h[2],E=h[3],u=new Int32Array(S),d=new Int32Array(u.length),c,o,s,y,L,A,P,_,F,B,k,N,U,w,W=this.networkToHostOrderSwap;g<u.length;){for(F=W(u[g]),B=W(u[g+1]),k=W(u[g+2]),N=W(u[g+3]),L=F^m[0],A=N^m[1],P=k^m[2],_=B^m[3],U=4,w=1;w<p;w++)c=r[L>>>24]^e[A>>16&255]^a[P>>8&255]^l[_&255]^m[U],o=r[A>>>24]^e[P>>16&255]^a[_>>8&255]^l[L&255]^m[U+1],s=r[P>>>24]^e[_>>16&255]^a[L>>8&255]^l[A&255]^m[U+2],y=r[_>>>24]^e[L>>16&255]^a[A>>8&255]^l[P&255]^m[U+3],L=c,A=o,P=s,_=y,U=U+4;c=v[L>>>24]<<24^v[A>>16&255]<<16^v[P>>8&255]<<8^v[_&255]^m[U],o=v[A>>>24]<<24^v[P>>16&255]<<16^v[_>>8&255]<<8^v[L&255]^m[U+1],s=v[P>>>24]<<24^v[_>>16&255]<<16^v[L>>8&255]<<8^v[A&255]^m[U+2],y=v[_>>>24]<<24^v[L>>16&255]<<16^v[A>>8&255]<<8^v[P&255]^m[U+3],d[g]=W(c^n),d[g+1]=W(y^t),d[g+2]=W(s^i),d[g+3]=W(o^E),n=F,t=B,i=k,E=N,g=g+4}return d.buffer},b}()},"./src/crypt/decrypter.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return g});var T=D("./src/crypt/aes-crypto.ts"),R=D("./src/crypt/fast-aes-key.ts"),O=D("./src/crypt/aes-decryptor.ts"),b=D("./src/utils/logger.ts"),C=D("./src/utils/mp4-tools.ts"),I=D("./src/utils/typed-array.ts"),S=16,g=function(){function x(m,v,f){var r=f===void 0?{}:f,e=r.removePKCS7Padding,a=e===void 0?!0:e;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=m,this.config=v,this.removePKCS7Padding=a,a)try{var l=self.crypto;l&&(this.subtle=l.subtle||l.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var p=x.prototype;return p.destroy=function(){this.observer=null},p.isSync=function(){return this.config.enableSoftwareAES},p.flush=function(){var v=this.currentResult;if(!v){this.reset();return}var f=new Uint8Array(v);return this.reset(),this.removePKCS7Padding?Object(O.removePadding)(f):f},p.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},p.decrypt=function(v,f,r,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(v),f,r);var a=this.flush();a&&e(a.buffer)}else this.webCryptoDecrypt(new Uint8Array(v),f,r).then(e)},p.softwareDecrypt=function(v,f,r){var e=this.currentIV,a=this.currentResult,l=this.remainderData;this.logOnce("JS AES decrypt"),l&&(v=Object(C.appendUint8Array)(l,v),this.remainderData=null);var h=this.getValidChunk(v);if(!h.length)return null;e&&(r=e);var n=this.softwareDecrypter;n||(n=this.softwareDecrypter=new O.default),n.expandKey(f);var t=a;return this.currentResult=n.decrypt(h.buffer,0,r),this.currentIV=Object(I.sliceUint8)(h,-16).buffer,t||null},p.webCryptoDecrypt=function(v,f,r){var e=this,a=this.subtle;return(this.key!==f||!this.fastAesKey)&&(this.key=f,this.fastAesKey=new R.default(a,f)),this.fastAesKey.expandKey().then(function(l){if(!a)return Promise.reject(new Error("web crypto not initialized"));var h=new T.default(a,r);return h.decrypt(v.buffer,l)}).catch(function(l){return e.onWebCryptoError(l,v,f,r)})},p.onWebCryptoError=function(v,f,r,e){return b.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",v),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(f,r,e)},p.getValidChunk=function(v){var f=v,r=v.length-v.length%S;return r!==v.length&&(f=Object(I.sliceUint8)(v,0,r),this.remainderData=Object(I.sliceUint8)(v,r)),f},p.logOnce=function(v){!this.logEnabled||(b.logger.log("[decrypter.ts]: "+v),this.logEnabled=!1)},x}()},"./src/crypt/fast-aes-key.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return T});var T=function(){function R(b,C){this.subtle=void 0,this.key=void 0,this.subtle=b,this.key=C}var O=R.prototype;return O.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},R}()},"./src/demux/aacdemuxer.ts":function(K,M,D){D.r(M);var T=D("./src/demux/base-audio-demuxer.ts"),R=D("./src/demux/adts.ts"),O=D("./src/utils/logger.ts"),b=D("./src/demux/id3.ts");function C(g,x){g.prototype=Object.create(x.prototype),g.prototype.constructor=g,I(g,x)}function I(g,x){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,v){return m.__proto__=v,m},I(g,x)}var S=function(g){C(x,g);function x(m,v){var f;return f=g.call(this)||this,f.observer=void 0,f.config=void 0,f.observer=m,f.config=v,f}var p=x.prototype;return p.resetInitSegment=function(v,f,r,e){g.prototype.resetInitSegment.call(this,v,f,r,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:f,duration:e,inputTimeScale:9e4,dropped:0}},x.probe=function(v){if(!v)return!1;for(var f=b.getID3Data(v,0)||[],r=f.length,e=v.length;r<e;r++)if(R.probe(v,r))return O.logger.log("ADTS sync word found !"),!0;return!1},p.canParse=function(v,f){return R.canParse(v,f)},p.appendFrame=function(v,f,r){R.initTrackConfig(v,this.observer,f,r,v.manifestCodec);var e=R.appendFrame(v,f,r,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},x}(T.default);S.minProbeByteLength=9,M.default=S},"./src/demux/adts.ts":function(K,M,D){D.r(M),D.d(M,"getAudioConfig",function(){return b}),D.d(M,"isHeaderPattern",function(){return C}),D.d(M,"getHeaderLength",function(){return I}),D.d(M,"getFullFrameLength",function(){return S}),D.d(M,"canGetFrameLength",function(){return g}),D.d(M,"isHeader",function(){return x}),D.d(M,"canParse",function(){return p}),D.d(M,"probe",function(){return m}),D.d(M,"initTrackConfig",function(){return v}),D.d(M,"getFrameDuration",function(){return f}),D.d(M,"parseFrameHeader",function(){return r}),D.d(M,"appendFrame",function(){return e});var T=D("./src/utils/logger.ts"),R=D("./src/errors.ts"),O=D("./src/events.ts");function b(a,l,h,n){var t,i,E,u,d=navigator.userAgent.toLowerCase(),c=n,o=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((l[h+2]&192)>>>6)+1;var s=(l[h+2]&60)>>>2;if(s>o.length-1){a.trigger(O.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+s});return}return E=(l[h+2]&1)<<2,E|=(l[h+3]&192)>>>6,T.logger.log("manifest codec:"+n+", ADTS type:"+t+", samplingIndex:"+s),/firefox/i.test(d)?s>=6?(t=5,u=new Array(4),i=s-3):(t=2,u=new Array(2),i=s):d.indexOf("android")!==-1?(t=2,u=new Array(2),i=s):(t=5,u=new Array(4),n&&(n.indexOf("mp4a.40.29")!==-1||n.indexOf("mp4a.40.5")!==-1)||!n&&s>=6?i=s-3:((n&&n.indexOf("mp4a.40.2")!==-1&&(s>=6&&E===1||/vivaldi/i.test(d))||!n&&E===1)&&(t=2,u=new Array(2)),i=s)),u[0]=t<<3,u[0]|=(s&14)>>1,u[1]|=(s&1)<<7,u[1]|=E<<3,t===5&&(u[1]|=(i&14)>>1,u[2]=(i&1)<<7,u[2]|=2<<2,u[3]=0),{config:u,samplerate:o[s],channelCount:E,codec:"mp4a.40."+t,manifestCodec:c}}function C(a,l){return a[l]===255&&(a[l+1]&246)===240}function I(a,l){return a[l+1]&1?7:9}function S(a,l){return(a[l+3]&3)<<11|a[l+4]<<3|(a[l+5]&224)>>>5}function g(a,l){return l+5<a.length}function x(a,l){return l+1<a.length&&C(a,l)}function p(a,l){return g(a,l)&&C(a,l)&&S(a,l)<=a.length-l}function m(a,l){if(x(a,l)){var h=I(a,l);if(l+h>=a.length)return!1;var n=S(a,l);if(n<=h)return!1;var t=l+n;return t===a.length||x(a,t)}return!1}function v(a,l,h,n,t){if(!a.samplerate){var i=b(l,h,n,t);if(!i)return;a.config=i.config,a.samplerate=i.samplerate,a.channelCount=i.channelCount,a.codec=i.codec,a.manifestCodec=i.manifestCodec,T.logger.log("parsed codec:"+a.codec+", rate:"+i.samplerate+", channels:"+i.channelCount)}}function f(a){return 1024*9e4/a}function r(a,l){var h=I(a,l);if(l+h<=a.length){var n=S(a,l)-h;if(n>0)return{headerLength:h,frameLength:n}}}function e(a,l,h,n,t){var i=f(a.samplerate),E=n+t*i,u=r(l,h),d;if(u){var c=u.frameLength,o=u.headerLength,s=o+c,y=Math.max(0,h+s-l.length);y?(d=new Uint8Array(s-o),d.set(l.subarray(h+o,l.length),0)):d=l.subarray(h+o,h+s);var L={unit:d,pts:E};return y||a.samples.push(L),{sample:L,length:s,missing:y}}var A=l.length-h;d=new Uint8Array(A),d.set(l.subarray(h,l.length),0);var P={unit:d,pts:E};return{sample:P,length:A,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(K,M,D){D.r(M),D.d(M,"initPTSFn",function(){return g});var T=D("./src/polyfills/number.ts"),R=D("./src/demux/id3.ts"),O=D("./src/types/demuxer.ts"),b=D("./src/demux/dummy-demuxed-track.ts"),C=D("./src/utils/mp4-tools.ts"),I=D("./src/utils/typed-array.ts"),S=function(){function x(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var p=x.prototype;return p.resetInitSegment=function(v,f,r,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},p.resetTimeStamp=function(v){this.initPTS=v,this.resetContiguity()},p.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},p.canParse=function(v,f){return!1},p.appendFrame=function(v,f,r){},p.demux=function(v,f){this.cachedData&&(v=Object(C.appendUint8Array)(this.cachedData,v),this.cachedData=null);var r=R.getID3Data(v,0),e=r?r.length:0,a,l,h=this._audioTrack,n=this._id3Track,t=r?R.getTimeStamp(r):void 0,i=v.length;for((this.basePTS===null||this.frameIndex===0&&Object(T.isFiniteNumber)(t))&&(this.basePTS=g(t,f,this.initPTS)),r&&r.length>0&&n.samples.push({pts:this.basePTS,dts:this.basePTS,data:r,type:O.MetadataSchema.audioId3}),l=this.basePTS;e<i;){if(this.canParse(v,e)){var E=this.appendFrame(h,v,e);E?(this.frameIndex++,l=E.sample.pts,e+=E.length,a=e):e=i}else R.canParse(v,e)?(r=R.getID3Data(v,e),n.samples.push({pts:l,dts:l,data:r,type:O.MetadataSchema.audioId3}),e+=r.length,a=e):e++;if(e===i&&a!==i){var u=Object(I.sliceUint8)(v,a);this.cachedData?this.cachedData=Object(C.appendUint8Array)(this.cachedData,u):this.cachedData=u}}return{audioTrack:h,videoTrack:Object(b.dummyTrack)(),id3Track:n,textTrack:Object(b.dummyTrack)()}},p.demuxSampleAes=function(v,f,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},p.flush=function(v){var f=this.cachedData;return f&&(this.cachedData=null,this.demux(f,0)),{audioTrack:this._audioTrack,videoTrack:Object(b.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(b.dummyTrack)()}},p.destroy=function(){},x}(),g=function(p,m,v){return Object(T.isFiniteNumber)(p)?p*90:m*9e4+(v||0)};M.default=S},"./src/demux/chunk-cache.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return T});var T=function(){function O(){this.chunks=[],this.dataLength=0}var b=O.prototype;return b.push=function(I){this.chunks.push(I),this.dataLength+=I.length},b.flush=function(){var I=this.chunks,S=this.dataLength,g;if(I.length)I.length===1?g=I[0]:g=R(I,S);else return new Uint8Array(0);return this.reset(),g},b.reset=function(){this.chunks.length=0,this.dataLength=0},O}();function R(O,b){for(var C=new Uint8Array(b),I=0,S=0;S<O.length;S++){var g=O[S];C.set(g,I),I+=g.length}return C}},"./src/demux/dummy-demuxed-track.ts":function(K,M,D){D.r(M),D.d(M,"dummyTrack",function(){return T});function T(R,O){return R===void 0&&(R=""),O===void 0&&(O=9e4),{type:R,id:-1,pid:-1,inputTimeScale:O,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(K,M,D){D.r(M);var T=D("./src/utils/logger.ts"),R=function(){function O(C){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=C,this.bytesAvailable=C.byteLength,this.word=0,this.bitsAvailable=0}var b=O.prototype;return b.loadWord=function(){var I=this.data,S=this.bytesAvailable,g=I.byteLength-S,x=new Uint8Array(4),p=Math.min(4,S);if(p===0)throw new Error("no bytes available");x.set(I.subarray(g,g+p)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=p*8,this.bytesAvailable-=p},b.skipBits=function(I){var S;this.bitsAvailable>I?(this.word<<=I,this.bitsAvailable-=I):(I-=this.bitsAvailable,S=I>>3,I-=S>>3,this.bytesAvailable-=S,this.loadWord(),this.word<<=I,this.bitsAvailable-=I)},b.readBits=function(I){var S=Math.min(this.bitsAvailable,I),g=this.word>>>32-S;return I>32&&T.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=S,this.bitsAvailable>0?this.word<<=S:this.bytesAvailable>0&&this.loadWord(),S=I-S,S>0&&this.bitsAvailable?g<<S|this.readBits(S):g},b.skipLZ=function(){var I;for(I=0;I<this.bitsAvailable;++I)if((this.word&2147483648>>>I)!==0)return this.word<<=I,this.bitsAvailable-=I,I;return this.loadWord(),I+this.skipLZ()},b.skipUEG=function(){this.skipBits(1+this.skipLZ())},b.skipEG=function(){this.skipBits(1+this.skipLZ())},b.readUEG=function(){var I=this.skipLZ();return this.readBits(I+1)-1},b.readEG=function(){var I=this.readUEG();return 1&I?1+I>>>1:-1*(I>>>1)},b.readBoolean=function(){return this.readBits(1)===1},b.readUByte=function(){return this.readBits(8)},b.readUShort=function(){return this.readBits(16)},b.readUInt=function(){return this.readBits(32)},b.skipScalingList=function(I){for(var S=8,g=8,x,p=0;p<I;p++)g!==0&&(x=this.readEG(),g=(S+x+256)%256),S=g===0?S:g},b.readSPS=function(){var I=0,S=0,g=0,x=0,p,m,v,f=this.readUByte.bind(this),r=this.readBits.bind(this),e=this.readUEG.bind(this),a=this.readBoolean.bind(this),l=this.skipBits.bind(this),h=this.skipEG.bind(this),n=this.skipUEG.bind(this),t=this.skipScalingList.bind(this);f();var i=f();if(r(5),l(3),f(),n(),i===100||i===110||i===122||i===244||i===44||i===83||i===86||i===118||i===128){var E=e();if(E===3&&l(1),n(),n(),l(1),a())for(m=E!==3?8:12,v=0;v<m;v++)a()&&(v<6?t(16):t(64))}n();var u=e();if(u===0)e();else if(u===1)for(l(1),h(),h(),p=e(),v=0;v<p;v++)h();n(),l(1);var d=e(),c=e(),o=r(1);o===0&&l(1),l(1),a()&&(I=e(),S=e(),g=e(),x=e());var s=[1,1];if(a()&&a()){var y=f();switch(y){case 1:s=[1,1];break;case 2:s=[12,11];break;case 3:s=[10,11];break;case 4:s=[16,11];break;case 5:s=[40,33];break;case 6:s=[24,11];break;case 7:s=[20,11];break;case 8:s=[32,11];break;case 9:s=[80,33];break;case 10:s=[18,11];break;case 11:s=[15,11];break;case 12:s=[64,33];break;case 13:s=[160,99];break;case 14:s=[4,3];break;case 15:s=[3,2];break;case 16:s=[2,1];break;case 255:{s=[f()<<8|f(),f()<<8|f()];break}}}return{width:Math.ceil((d+1)*16-I*2-S*2),height:(2-o)*(c+1)*16-(o?2:4)*(g+x),pixelRatio:s}},b.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},O}();M.default=R},"./src/demux/id3.ts":function(K,M,D){D.r(M),D.d(M,"isHeader",function(){return T}),D.d(M,"isFooter",function(){return R}),D.d(M,"getID3Data",function(){return O}),D.d(M,"canParse",function(){return C}),D.d(M,"getTimeStamp",function(){return I}),D.d(M,"isTimeStampFrame",function(){return S}),D.d(M,"getID3Frames",function(){return x}),D.d(M,"decodeFrame",function(){return p}),D.d(M,"utf8ArrayToStr",function(){return e}),D.d(M,"testables",function(){return a});var T=function(t,i){return i+10<=t.length&&t[i]===73&&t[i+1]===68&&t[i+2]===51&&t[i+3]<255&&t[i+4]<255&&t[i+6]<128&&t[i+7]<128&&t[i+8]<128&&t[i+9]<128},R=function(t,i){return i+10<=t.length&&t[i]===51&&t[i+1]===68&&t[i+2]===73&&t[i+3]<255&&t[i+4]<255&&t[i+6]<128&&t[i+7]<128&&t[i+8]<128&&t[i+9]<128},O=function(t,i){for(var E=i,u=0;T(t,i);){u+=10;var d=b(t,i+6);u+=d,R(t,i+10)&&(u+=10),i+=u}if(u>0)return t.subarray(E,E+u)},b=function(t,i){var E=0;return E=(t[i]&127)<<21,E|=(t[i+1]&127)<<14,E|=(t[i+2]&127)<<7,E|=t[i+3]&127,E},C=function(t,i){return T(t,i)&&b(t,i+6)+10<=t.length-i},I=function(t){for(var i=x(t),E=0;E<i.length;E++){var u=i[E];if(S(u))return r(u)}},S=function(t){return t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp"},g=function(t){var i=String.fromCharCode(t[0],t[1],t[2],t[3]),E=b(t,4),u=10;return{type:i,size:E,data:t.subarray(u,u+E)}},x=function(t){for(var i=0,E=[];T(t,i);){var u=b(t,i+6);i+=10;for(var d=i+u;i+8<d;){var c=g(t.subarray(i)),o=p(c);o&&E.push(o),i+=c.size+10}R(t,i)&&(i+=10)}return E},p=function(t){return t.type==="PRIV"?m(t):t.type[0]==="W"?f(t):v(t)},m=function(t){if(!(t.size<2)){var i=e(t.data,!0),E=new Uint8Array(t.data.subarray(i.length+1));return{key:t.type,info:i,data:E.buffer}}},v=function(t){if(!(t.size<2)){if(t.type==="TXXX"){var i=1,E=e(t.data.subarray(i),!0);i+=E.length+1;var u=e(t.data.subarray(i));return{key:t.type,info:E,data:u}}var d=e(t.data.subarray(1));return{key:t.type,data:d}}},f=function(t){if(t.type==="WXXX"){if(t.size<2)return;var i=1,E=e(t.data.subarray(i),!0);i+=E.length+1;var u=e(t.data.subarray(i));return{key:t.type,info:E,data:u}}var d=e(t.data);return{key:t.type,data:d}},r=function(t){if(t.data.byteLength===8){var i=new Uint8Array(t.data),E=i[3]&1,u=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return u/=45,E&&(u+=4772185884e-2),Math.round(u)}},e=function(t,i){i===void 0&&(i=!1);var E=h();if(E){var u=E.decode(t);if(i){var d=u.indexOf("\0");return d!==-1?u.substring(0,d):u}return u.replace(/\0/g,"")}for(var c=t.length,o,s,y,L="",A=0;A<c;){if(o=t[A++],o===0&&i)return L;if(o===0||o===3)continue;switch(o>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:L+=String.fromCharCode(o);break;case 12:case 13:s=t[A++],L+=String.fromCharCode((o&31)<<6|s&63);break;case 14:s=t[A++],y=t[A++],L+=String.fromCharCode((o&15)<<12|(s&63)<<6|(y&63)<<0);break}}return L},a={decodeTextFrame:v},l;function h(){return!l&&typeof self.TextDecoder<"u"&&(l=new self.TextDecoder("utf-8")),l}},"./src/demux/mp3demuxer.ts":function(K,M,D){D.r(M);var T=D("./src/demux/base-audio-demuxer.ts"),R=D("./src/demux/id3.ts"),O=D("./src/utils/logger.ts"),b=D("./src/demux/mpegaudio.ts");function C(g,x){g.prototype=Object.create(x.prototype),g.prototype.constructor=g,I(g,x)}function I(g,x){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,v){return m.__proto__=v,m},I(g,x)}var S=function(g){C(x,g);function x(){return g.apply(this,arguments)||this}var p=x.prototype;return p.resetInitSegment=function(v,f,r,e){g.prototype.resetInitSegment.call(this,v,f,r,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:f,duration:e,inputTimeScale:9e4,dropped:0}},x.probe=function(v){if(!v)return!1;for(var f=R.getID3Data(v,0)||[],r=f.length,e=v.length;r<e;r++)if(b.probe(v,r))return O.logger.log("MPEG Audio sync word found !"),!0;return!1},p.canParse=function(v,f){return b.canParse(v,f)},p.appendFrame=function(v,f,r){if(this.basePTS!==null)return b.appendFrame(v,f,r,this.basePTS,this.frameIndex)},x}(T.default);S.minProbeByteLength=4,M.default=S},"./src/demux/mp4demuxer.ts":function(K,M,D){D.r(M);var T=D("./src/polyfills/number.ts"),R=D("./src/types/demuxer.ts"),O=D("./src/utils/mp4-tools.ts"),b=D("./src/demux/dummy-demuxed-track.ts"),C=/\/emsg[-/]ID3/i,I=function(){function S(x,p){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=p}var g=S.prototype;return g.resetTimeStamp=function(){},g.resetInitSegment=function(p,m,v,f){var r=Object(O.parseInitSegment)(p),e=this.videoTrack=Object(b.dummyTrack)("video",1),a=this.audioTrack=Object(b.dummyTrack)("audio",1),l=this.txtTrack=Object(b.dummyTrack)("text",1);if(this.id3Track=Object(b.dummyTrack)("id3",1),this.timeOffset=0,r.video){var h=r.video,n=h.id,t=h.timescale,i=h.codec;e.id=n,e.timescale=l.timescale=t,e.codec=i}if(r.audio){var E=r.audio,u=E.id,d=E.timescale,c=E.codec;a.id=u,a.timescale=d,a.codec=c}l.id=O.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=a.duration=f},g.resetContiguity=function(){},S.probe=function(p){return p=p.length>16384?p.subarray(0,16384):p,Object(O.findBox)(p,["moof"]).length>0},g.demux=function(p,m){this.timeOffset=m;var v=p,f=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(v=Object(O.appendUint8Array)(this.remainderData,p));var e=Object(O.segmentValidRange)(v);this.remainderData=e.remainder,f.samples=e.valid||new Uint8Array}else f.samples=v;var a=this.extractID3Track(f,m);return r.samples=Object(O.parseSamples)(m,f),{videoTrack:f,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}},g.flush=function(){var p=this.timeOffset,m=this.videoTrack,v=this.txtTrack;m.samples=this.remainderData||new Uint8Array,this.remainderData=null;var f=this.extractID3Track(m,this.timeOffset);return v.samples=Object(O.parseSamples)(p,m),{videoTrack:m,audioTrack:Object(b.dummyTrack)(),id3Track:f,textTrack:Object(b.dummyTrack)()}},g.extractID3Track=function(p,m){var v=this.id3Track;if(p.samples.length){var f=Object(O.findBox)(p.samples,["emsg"]);f&&f.forEach(function(r){var e=Object(O.parseEmsg)(r);if(C.test(e.schemeIdUri)){var a=Object(T.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:m+e.presentationTimeDelta/e.timeScale,l=e.payload;v.samples.push({data:l,len:l.byteLength,dts:a,pts:a,type:R.MetadataSchema.emsg})}})}return v},g.demuxSampleAes=function(p,m,v){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},g.destroy=function(){},S}();I.minProbeByteLength=1024,M.default=I},"./src/demux/mpegaudio.ts":function(K,M,D){D.r(M),D.d(M,"appendFrame",function(){return I}),D.d(M,"parseHeader",function(){return S}),D.d(M,"isHeaderPattern",function(){return g}),D.d(M,"isHeader",function(){return x}),D.d(M,"canParse",function(){return p}),D.d(M,"probe",function(){return m});var T=null,R=[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],O=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],b=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],C=[0,1,1,4];function I(v,f,r,e,a){if(!(r+24>f.length)){var l=S(f,r);if(l&&r+l.frameLength<=f.length){var h=l.samplesPerFrame*9e4/l.sampleRate,n=e+a*h,t={unit:f.subarray(r,r+l.frameLength),pts:n,dts:n};return v.config=[],v.channelCount=l.channelCount,v.samplerate=l.sampleRate,v.samples.push(t),{sample:t,length:l.frameLength,missing:0}}}}function S(v,f){var r=v[f+1]>>3&3,e=v[f+1]>>1&3,a=v[f+2]>>4&15,l=v[f+2]>>2&3;if(r!==1&&a!==0&&a!==15&&l!==3){var h=v[f+2]>>1&1,n=v[f+3]>>6,t=r===3?3-e:e===3?3:4,i=R[t*14+a-1]*1e3,E=r===3?0:r===2?1:2,u=O[E*3+l],d=n===3?1:2,c=b[r][e],o=C[e],s=c*8*o,y=Math.floor(c*i/u+h)*o;if(T===null){var L=navigator.userAgent||"",A=L.match(/Chrome\/(\d+)/i);T=A?parseInt(A[1]):0}var P=!!T&&T<=87;return P&&e===2&&i>=224e3&&n===0&&(v[f+3]=v[f+3]|128),{sampleRate:u,channelCount:d,frameLength:y,samplesPerFrame:s}}}function g(v,f){return v[f]===255&&(v[f+1]&224)===224&&(v[f+1]&6)!==0}function x(v,f){return f+1<v.length&&g(v,f)}function p(v,f){var r=4;return g(v,f)&&r<=v.length-f}function m(v,f){if(f+1<v.length&&g(v,f)){var r=4,e=S(v,f),a=r;e!=null&&e.frameLength&&(a=e.frameLength);var l=f+a;return l===v.length||x(v,l)}return!1}},"./src/demux/sample-aes.ts":function(K,M,D){D.r(M);var T=D("./src/crypt/decrypter.ts"),R=D("./src/demux/tsdemuxer.ts"),O=function(){function b(I,S,g){this.keyData=void 0,this.decrypter=void 0,this.keyData=g,this.decrypter=new T.default(I,S,{removePKCS7Padding:!1})}var C=b.prototype;return C.decryptBuffer=function(S,g){this.decrypter.decrypt(S,this.keyData.key.buffer,this.keyData.iv.buffer,g)},C.decryptAacSample=function(S,g,x,p){var m=S[g].unit;if(!(m.length<=16)){var v=m.subarray(16,m.length-m.length%16),f=v.buffer.slice(v.byteOffset,v.byteOffset+v.length),r=this;this.decryptBuffer(f,function(e){var a=new Uint8Array(e);m.set(a,16),p||r.decryptAacSamples(S,g+1,x)})}},C.decryptAacSamples=function(S,g,x){for(;;g++){if(g>=S.length){x();return}if(!(S[g].unit.length<32)){var p=this.decrypter.isSync();if(this.decryptAacSample(S,g,x,p),!p)return}}},C.getAvcEncryptedData=function(S){for(var g=Math.floor((S.length-48)/160)*16+16,x=new Int8Array(g),p=0,m=32;m<S.length-16;m+=160,p+=16)x.set(S.subarray(m,m+16),p);return x},C.getAvcDecryptedUnit=function(S,g){for(var x=new Uint8Array(g),p=0,m=32;m<S.length-16;m+=160,p+=16)S.set(x.subarray(p,p+16),m);return S},C.decryptAvcSample=function(S,g,x,p,m,v){var f=Object(R.discardEPB)(m.data),r=this.getAvcEncryptedData(f),e=this;this.decryptBuffer(r.buffer,function(a){m.data=e.getAvcDecryptedUnit(f,a),v||e.decryptAvcSamples(S,g,x+1,p)})},C.decryptAvcSamples=function(S,g,x,p){if(S instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;g++,x=0){if(g>=S.length){p();return}for(var m=S[g].units;!(x>=m.length);x++){var v=m[x];if(!(v.data.length<=48||v.type!==1&&v.type!==5)){var f=this.decrypter.isSync();if(this.decryptAvcSample(S,g,x,p,v,f),!f)return}}}},b}();M.default=O},"./src/demux/transmuxer-interface.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return x});var T=D("./node_modules/webworkify-webpack/index.js"),R=D("./src/events.ts"),O=D("./src/demux/transmuxer.ts"),b=D("./src/utils/logger.ts"),C=D("./src/errors.ts"),I=D("./src/utils/mediasource-helper.ts"),S=D("./node_modules/eventemitter3/index.js"),g=Object(I.getMediaSource)()||{isTypeSupported:function(){return!1}},x=function(){function p(v,f,r,e){var a=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=v,this.id=f,this.onTransmuxComplete=r,this.onFlush=e;var l=v.config,h=function(u,d){d=d||{},d.frag=a.frag,d.id=a.id,v.trigger(u,d)};this.observer=new S.EventEmitter,this.observer.on(R.Events.FRAG_DECRYPTED,h),this.observer.on(R.Events.ERROR,h);var n={mp4:g.isTypeSupported("video/mp4"),mpeg:g.isTypeSupported("audio/mpeg"),mp3:g.isTypeSupported('audio/mp4; codecs="mp3"')},t=navigator.vendor;if(l.enableWorker&&typeof Worker<"u"){b.logger.log("demuxing in webworker");var i;try{i=this.worker=T("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),i.addEventListener("message",this.onwmsg),i.onerror=function(E){v.trigger(R.Events.ERROR,{type:C.ErrorTypes.OTHER_ERROR,details:C.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(E.message+" ("+E.filename+":"+E.lineno+")")})},i.postMessage({cmd:"init",typeSupported:n,vendor:t,id:f,config:JSON.stringify(l)})}catch(E){b.logger.warn("Error in worker:",E),b.logger.error("Error while initializing DemuxerWorker, fallback to inline"),i&&self.URL.revokeObjectURL(i.objectURL),this.transmuxer=new O.default(this.observer,n,l,t,f),this.worker=null}}else this.transmuxer=new O.default(this.observer,n,l,t,f)}var m=p.prototype;return m.destroy=function(){var f=this.worker;if(f)f.removeEventListener("message",this.onwmsg),f.terminate(),this.worker=null,this.onwmsg=void 0;else{var r=this.transmuxer;r&&(r.destroy(),this.transmuxer=null)}var e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},m.push=function(f,r,e,a,l,h,n,t,i,E){var u,d,c=this;i.transmuxing.start=self.performance.now();var o=this.transmuxer,s=this.worker,y=h?h.start:l.start,L=l.decryptdata,A=this.frag,P=!(A&&l.cc===A.cc),_=!(A&&i.level===A.level),F=A?i.sn-A.sn:-1,B=this.part?i.part-this.part.index:-1,k=F===0&&i.id>1&&i.id===(A==null?void 0:A.stats.chunkCount),N=!_&&(F===1||F===0&&(B===1||k&&B<=0)),U=self.performance.now();(_||F||l.stats.parsing.start===0)&&(l.stats.parsing.start=U),h&&(B||!N)&&(h.stats.parsing.start=U);var w=!(A&&((u=l.initSegment)===null||u===void 0?void 0:u.url)===((d=A.initSegment)===null||d===void 0?void 0:d.url)),W=new O.TransmuxState(P,N,t,_,y,w);if(!N||P||w){b.logger.log("[transmuxer-interface, "+l.type+"]: Starting new transmux session for sn: "+i.sn+" p: "+i.part+" level: "+i.level+" id: "+i.id+`
33
+ discontinuity: `+P+`
34
+ trackSwitch: `+_+`
35
+ contiguous: `+N+`
36
+ accurateTimeOffset: `+t+`
37
+ timeOffset: `+y+`
38
+ initSegmentChange: `+w);var j=new O.TransmuxConfig(e,a,r,n,E);this.configureTransmuxer(j)}if(this.frag=l,this.part=h,s)s.postMessage({cmd:"demux",data:f,decryptdata:L,chunkMeta:i,state:W},f instanceof ArrayBuffer?[f]:[]);else if(o){var H=o.push(f,L,i,W);Object(O.isPromise)(H)?H.then(function(G){c.handleTransmuxComplete(G)}):this.handleTransmuxComplete(H)}},m.flush=function(f){var r=this;f.transmuxing.start=self.performance.now();var e=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:f});else if(e){var l=e.flush(f);Object(O.isPromise)(l)?l.then(function(h){r.handleFlushResult(h,f)}):this.handleFlushResult(l,f)}},m.handleFlushResult=function(f,r){var e=this;f.forEach(function(a){e.handleTransmuxComplete(a)}),this.onFlush(r)},m.onWorkerMessage=function(f){var r=f.data,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}case"workerLog":b.logger[r.data.logType]&&b.logger[r.data.logType](r.data.message);break;default:{r.data=r.data||{},r.data.frag=this.frag,r.data.id=this.id,e.trigger(r.event,r.data);break}}},m.configureTransmuxer=function(f){var r=this.worker,e=this.transmuxer;r?r.postMessage({cmd:"configure",config:f}):e&&e.configure(f)},m.handleTransmuxComplete=function(f){f.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(f)},p}()},"./src/demux/transmuxer-worker.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return C});var T=D("./src/demux/transmuxer.ts"),R=D("./src/events.ts"),O=D("./src/utils/logger.ts"),b=D("./node_modules/eventemitter3/index.js");function C(p){var m=new b.EventEmitter,v=function(e,a){p.postMessage({event:e,data:a})};m.on(R.Events.FRAG_DECRYPTED,v),m.on(R.Events.ERROR,v);var f=function(){var e=function(h){var n=function(i){v("workerLog",{logType:h,message:i})};O.logger[h]=n};for(var a in O.logger)e(a)};p.addEventListener("message",function(r){var e=r.data;switch(e.cmd){case"init":{var a=JSON.parse(e.config);p.transmuxer=new T.default(m,e.typeSupported,a,e.vendor,e.id),Object(O.enableLogs)(a.debug),f(),v("init",null);break}case"configure":{p.transmuxer.configure(e.config);break}case"demux":{var l=p.transmuxer.push(e.data,e.decryptdata,e.chunkMeta,e.state);Object(T.isPromise)(l)?l.then(function(t){I(p,t)}):I(p,l);break}case"flush":{var h=e.chunkMeta,n=p.transmuxer.flush(h);Object(T.isPromise)(n)?n.then(function(t){g(p,t,h)}):g(p,n,h);break}}})}function I(p,m){if(x(m.remuxResult))return!1;var v=[],f=m.remuxResult,r=f.audio,e=f.video;return r&&S(v,r),e&&S(v,e),p.postMessage({event:"transmuxComplete",data:m},v),!0}function S(p,m){m.data1&&p.push(m.data1.buffer),m.data2&&p.push(m.data2.buffer)}function g(p,m,v){var f=m.reduce(function(r,e){return I(p,e)||r},!1);f||p.postMessage({event:"transmuxComplete",data:m[0]}),p.postMessage({event:"flush",data:v})}function x(p){return!p.audio&&!p.video&&!p.text&&!p.id3&&!p.initSegment}},"./src/demux/transmuxer.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return a}),D.d(M,"isPromise",function(){return n}),D.d(M,"TransmuxConfig",function(){return t}),D.d(M,"TransmuxState",function(){return i});var T=D("./src/events.ts"),R=D("./src/errors.ts"),O=D("./src/crypt/decrypter.ts"),b=D("./src/demux/aacdemuxer.ts"),C=D("./src/demux/mp4demuxer.ts"),I=D("./src/demux/tsdemuxer.ts"),S=D("./src/demux/mp3demuxer.ts"),g=D("./src/remux/mp4-remuxer.ts"),x=D("./src/remux/passthrough-remuxer.ts"),p=D("./src/demux/chunk-cache.ts"),m=D("./src/utils/mp4-tools.ts"),v=D("./src/utils/logger.ts"),f;try{f=self.performance.now.bind(self.performance)}catch{v.logger.debug("Unable to use Performance API on this environment"),f=self.Date.now}var r=[{demux:I.default,remux:g.default},{demux:C.default,remux:x.default},{demux:b.default,remux:g.default},{demux:S.default,remux:g.default}],e=1024;r.forEach(function(E){var u=E.demux;e=Math.max(e,u.minProbeByteLength)});var a=function(){function E(d,c,o,s,y){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 p.default,this.observer=d,this.typeSupported=c,this.config=o,this.vendor=s,this.id=y}var u=E.prototype;return u.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},u.push=function(c,o,s,y){var L=this,A=s.transmuxing;A.executeStart=f();var P=new Uint8Array(c),_=this.cache,F=this.config,B=this.currentTransmuxState,k=this.transmuxConfig;y&&(this.currentTransmuxState=y);var N=l(P,o);if(N&&N.method==="AES-128"){var U=this.getDecrypter();if(F.enableSoftwareAES){var w=U.softwareDecrypt(P,N.key.buffer,N.iv.buffer);if(!w)return A.executeEnd=f(),h(s);P=new Uint8Array(w)}else return this.decryptionPromise=U.webCryptoDecrypt(P,N.key.buffer,N.iv.buffer).then(function(re){var oe=L.push(re,null,s);return L.decryptionPromise=null,oe}),this.decryptionPromise}var W=y||B,j=W.contiguous,H=W.discontinuity,G=W.trackSwitch,Y=W.accurateTimeOffset,X=W.timeOffset,z=W.initSegmentChange,V=k.audioCodec,$=k.videoCodec,Q=k.defaultInitPts,J=k.duration,Z=k.initSegmentData;if((H||G||z)&&this.resetInitSegment(Z,V,$,J),(H||z)&&this.resetInitialTimestamp(Q),j||this.resetContiguity(),this.needsProbing(P,H,G)){if(_.dataLength){var q=_.flush();P=Object(m.appendUint8Array)(q,P)}this.configureTransmuxer(P,k)}var ee=this.transmux(P,N,X,Y,s),te=this.currentTransmuxState;return te.contiguous=!0,te.discontinuity=!1,te.trackSwitch=!1,A.executeEnd=f(),ee},u.flush=function(c){var o=this,s=c.transmuxing;s.executeStart=f();var y=this.decrypter,L=this.cache,A=this.currentTransmuxState,P=this.decryptionPromise;if(P)return P.then(function(){return o.flush(c)});var _=[],F=A.timeOffset;if(y){var B=y.flush();B&&_.push(this.push(B,null,c))}var k=L.dataLength;L.reset();var N=this.demuxer,U=this.remuxer;if(!N||!U)return k>=e&&this.observer.emit(T.Events.ERROR,T.Events.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),s.executeEnd=f(),[h(c)];var w=N.flush(F);return n(w)?w.then(function(W){return o.flushRemux(_,W,c),_}):(this.flushRemux(_,w,c),_)},u.flushRemux=function(c,o,s){var y=o.audioTrack,L=o.videoTrack,A=o.id3Track,P=o.textTrack,_=this.currentTransmuxState,F=_.accurateTimeOffset,B=_.timeOffset;v.logger.log("[transmuxer.ts]: Flushed fragment "+s.sn+(s.part>-1?" p: "+s.part:"")+" of level "+s.level);var k=this.remuxer.remux(y,L,A,P,B,F,!0,this.id);c.push({remuxResult:k,chunkMeta:s}),s.transmuxing.executeEnd=f()},u.resetInitialTimestamp=function(c){var o=this.demuxer,s=this.remuxer;!o||!s||(o.resetTimeStamp(c),s.resetTimeStamp(c))},u.resetContiguity=function(){var c=this.demuxer,o=this.remuxer;!c||!o||(c.resetContiguity(),o.resetNextTimestamp())},u.resetInitSegment=function(c,o,s,y){var L=this.demuxer,A=this.remuxer;!L||!A||(L.resetInitSegment(c,o,s,y),A.resetInitSegment(c,o,s))},u.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},u.transmux=function(c,o,s,y,L){var A;return o&&o.method==="SAMPLE-AES"?A=this.transmuxSampleAes(c,o,s,y,L):A=this.transmuxUnencrypted(c,s,y,L),A},u.transmuxUnencrypted=function(c,o,s,y){var L=this.demuxer.demux(c,o,!1,!this.config.progressive),A=L.audioTrack,P=L.videoTrack,_=L.id3Track,F=L.textTrack,B=this.remuxer.remux(A,P,_,F,o,s,!1,this.id);return{remuxResult:B,chunkMeta:y}},u.transmuxSampleAes=function(c,o,s,y,L){var A=this;return this.demuxer.demuxSampleAes(c,o,s).then(function(P){var _=A.remuxer.remux(P.audioTrack,P.videoTrack,P.id3Track,P.textTrack,s,y,!1,A.id);return{remuxResult:_,chunkMeta:L}})},u.configureTransmuxer=function(c,o){for(var s=this.config,y=this.observer,L=this.typeSupported,A=this.vendor,P=o.audioCodec,_=o.defaultInitPts,F=o.duration,B=o.initSegmentData,k=o.videoCodec,N,U=0,w=r.length;U<w;U++)if(r[U].demux.probe(c)){N=r[U];break}N||(v.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),N={demux:C.default,remux:x.default});var W=this.demuxer,j=this.remuxer,H=N.remux,G=N.demux;(!j||!(j instanceof H))&&(this.remuxer=new H(y,s,L,A)),(!W||!(W instanceof G))&&(this.demuxer=new G(y,s,L),this.probe=G.probe),this.resetInitSegment(B,P,k,F),this.resetInitialTimestamp(_)},u.needsProbing=function(c,o,s){return!this.demuxer||!this.remuxer||o||s},u.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new O.default(this.observer,this.config)),c},E}();function l(E,u){var d=null;return E.byteLength>0&&u!=null&&u.key!=null&&u.iv!==null&&u.method!=null&&(d=u),d}var h=function(u){return{remuxResult:{},chunkMeta:u}};function n(E){return"then"in E&&E.then instanceof Function}var t=function(u,d,c,o,s){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=u,this.videoCodec=d,this.initSegmentData=c,this.duration=o,this.defaultInitPts=s},i=function(u,d,c,o,s,y){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=u,this.contiguous=d,this.accurateTimeOffset=c,this.trackSwitch=o,this.timeOffset=s,this.initSegmentChange=y}},"./src/demux/tsdemuxer.ts":function(K,M,D){D.r(M),D.d(M,"discardEPB",function(){return l});var T=D("./src/demux/adts.ts"),R=D("./src/demux/mpegaudio.ts"),O=D("./src/demux/exp-golomb.ts"),b=D("./src/demux/sample-aes.ts"),C=D("./src/events.ts"),I=D("./src/utils/mp4-tools.ts"),S=D("./src/utils/logger.ts"),g=D("./src/errors.ts"),x=D("./src/types/demuxer.ts");function p(){return p=Object.assign?Object.assign.bind():function(h){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(h[i]=t[i])}return h},p.apply(this,arguments)}var m=function(){function h(t,i,E){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._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=E}h.probe=function(i){var E=h.syncOffset(i);return E<0?!1:(E&&S.logger.warn("MPEG2-TS detected but first sync word found @ offset "+E+", junk ahead ?"),!0)},h.syncOffset=function(i){for(var E=Math.min(1e3,i.length-564),u=0;u<E;){if(i[u]===71&&i[u+188]===71&&i[u+2*188]===71)return u;u++}return-1},h.createTrack=function(i,E){return{container:i==="video"||i==="audio"?"video/mp2t":void 0,type:i,id:I.RemuxerTrackIdConfig[i],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:i==="audio"?E:void 0}};var n=h.prototype;return n.resetInitSegment=function(i,E,u,d){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=h.createTrack("video"),this._audioTrack=h.createTrack("audio",d),this._id3Track=h.createTrack("id3"),this._txtTrack=h.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.audioCodec=E,this.videoCodec=u,this._duration=d},n.resetTimeStamp=function(){},n.resetContiguity=function(){var i=this._audioTrack,E=this._avcTrack,u=this._id3Track;i&&(i.pesData=null),E&&(E.pesData=null),u&&(u.pesData=null),this.aacOverFlow=null},n.demux=function(i,E,u,d){u===void 0&&(u=!1),d===void 0&&(d=!1),u||(this.sampleAes=null);var c,o=this._avcTrack,s=this._audioTrack,y=this._id3Track,L=this._txtTrack,A=o.pid,P=o.pesData,_=s.pid,F=y.pid,B=s.pesData,k=y.pesData,N=!1,U=this.pmtParsed,w=this._pmtId,W=i.length;if(this.remainderData&&(i=Object(I.appendUint8Array)(this.remainderData,i),W=i.length,this.remainderData=null),W<188&&!d)return this.remainderData=i,{audioTrack:s,videoTrack:o,id3Track:y,textTrack:L};var j=Math.max(0,h.syncOffset(i));W-=(W+j)%188,W<i.byteLength&&!d&&(this.remainderData=new Uint8Array(i.buffer,W,i.buffer.byteLength-W));for(var H=0,G=j;G<W;G+=188)if(i[G]===71){var Y=!!(i[G+1]&64),X=((i[G+1]&31)<<8)+i[G+2],z=(i[G+3]&48)>>4,V=void 0;if(z>1){if(V=G+5+i[G+4],V===G+188)continue}else V=G+4;switch(X){case A:Y&&(P&&(c=e(P))&&this.parseAVCPES(o,L,c,!1),P={data:[],size:0}),P&&(P.data.push(i.subarray(V,G+188)),P.size+=G+188-V);break;case _:if(Y){if(B&&(c=e(B)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,c);break;case"mp3":this.parseMPEGPES(s,c);break}B={data:[],size:0}}B&&(B.data.push(i.subarray(V,G+188)),B.size+=G+188-V);break;case F:Y&&(k&&(c=e(k))&&this.parseID3PES(y,c),k={data:[],size:0}),k&&(k.data.push(i.subarray(V,G+188)),k.size+=G+188-V);break;case 0:Y&&(V+=i[V]+1),w=this._pmtId=f(i,V);break;case w:{Y&&(V+=i[V]+1);var $=r(i,V,this.typeSupported,u);A=$.avc,A>0&&(o.pid=A),_=$.audio,_>0&&(s.pid=_,s.segmentCodec=$.segmentCodec),F=$.id3,F>0&&(y.pid=F),N&&!U&&(S.logger.log("reparse from beginning"),N=!1,G=j-188),U=this.pmtParsed=!0;break}case 17:case 8191:break;default:N=!0;break}}else H++;H>0&&this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:g.ErrorTypes.MEDIA_ERROR,details:g.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+H+" TS packet/s that do not start with 0x47"}),o.pesData=P,s.pesData=B,y.pesData=k;var Q={audioTrack:s,videoTrack:o,id3Track:y,textTrack:L};return d&&this.extractRemainingSamples(Q),Q},n.flush=function(){var i=this.remainderData;this.remainderData=null;var E;return i?E=this.demux(i,-1,!1,!0):E={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(E),this.sampleAes?this.decrypt(E,this.sampleAes):E},n.extractRemainingSamples=function(i){var E=i.audioTrack,u=i.videoTrack,d=i.id3Track,c=i.textTrack,o=u.pesData,s=E.pesData,y=d.pesData,L;if(o&&(L=e(o))?(this.parseAVCPES(u,c,L,!0),u.pesData=null):u.pesData=o,s&&(L=e(s))){switch(E.segmentCodec){case"aac":this.parseAACPES(E,L);break;case"mp3":this.parseMPEGPES(E,L);break}E.pesData=null}else s!=null&&s.size&&S.logger.log("last AAC PES packet truncated,might overlap between fragments"),E.pesData=s;y&&(L=e(y))?(this.parseID3PES(d,L),d.pesData=null):d.pesData=y},n.demuxSampleAes=function(i,E,u){var d=this.demux(i,u,!0,!this.config.progressive),c=this.sampleAes=new b.default(this.observer,this.config,E);return this.decrypt(d,c)},n.decrypt=function(i,E){return new Promise(function(u){var d=i.audioTrack,c=i.videoTrack;d.samples&&d.segmentCodec==="aac"?E.decryptAacSamples(d.samples,0,function(){c.samples?E.decryptAvcSamples(c.samples,0,0,function(){u(i)}):u(i)}):c.samples&&E.decryptAvcSamples(c.samples,0,0,function(){u(i)})})},n.destroy=function(){this._duration=0},n.parseAVCPES=function(i,E,u,d){var c=this,o=this.parseAVCNALu(i,u.data),s=this.avcSample,y,L=!1;u.data=null,s&&o.length&&!i.audFound&&(a(s,i),s=this.avcSample=v(!1,u.pts,u.dts,"")),o.forEach(function(A){switch(A.type){case 1:{y=!0,s||(s=c.avcSample=v(!0,u.pts,u.dts,"")),s.frame=!0;var P=A.data;if(L&&P.length>4){var _=new O.default(P).readSliceType();(_===2||_===4||_===7||_===9)&&(s.key=!0)}break}case 5:y=!0,s||(s=c.avcSample=v(!0,u.pts,u.dts,"")),s.key=!0,s.frame=!0;break;case 6:{y=!0,Object(I.parseSEIMessageFromNALu)(l(A.data),u.pts,E.samples);break}case 7:if(y=!0,L=!0,!i.sps){var F=new O.default(A.data),B=F.readSPS();i.width=B.width,i.height=B.height,i.pixelRatio=B.pixelRatio,i.sps=[A.data],i.duration=c._duration;for(var k=A.data.subarray(1,4),N="avc1.",U=0;U<3;U++){var w=k[U].toString(16);w.length<2&&(w="0"+w),N+=w}i.codec=N}break;case 8:y=!0,i.pps||(i.pps=[A.data]);break;case 9:y=!1,i.audFound=!0,s&&a(s,i),s=c.avcSample=v(!1,u.pts,u.dts,"");break;case 12:y=!0;break;default:y=!1,s&&(s.debug+="unknown NAL "+A.type+" ");break}if(s&&y){var W=s.units;W.push(A)}}),d&&s&&(a(s,i),this.avcSample=null)},n.getLastNalUnit=function(i){var E,u=this.avcSample,d;if((!u||u.units.length===0)&&(u=i[i.length-1]),(E=u)!==null&&E!==void 0&&E.units){var c=u.units;d=c[c.length-1]}return d},n.parseAVCNALu=function(i,E){var u=E.byteLength,d=i.naluState||0,c=d,o=[],s=0,y,L,A,P=-1,_=0;for(d===-1&&(P=0,_=E[0]&31,d=0,s=1);s<u;){if(y=E[s++],!d){d=y?0:1;continue}if(d===1){d=y?0:2;continue}if(!y)d=3;else if(y===1){if(P>=0){var F={data:E.subarray(P,s-d-1),type:_};o.push(F)}else{var B=this.getLastNalUnit(i.samples);if(B&&(c&&s<=4-c&&B.state&&(B.data=B.data.subarray(0,B.data.byteLength-c)),L=s-d-1,L>0)){var k=new Uint8Array(B.data.byteLength+L);k.set(B.data,0),k.set(E.subarray(0,L),B.data.byteLength),B.data=k,B.state=0}}s<u?(A=E[s]&31,P=s,_=A,d=0):d=-1}else d=0}if(P>=0&&d>=0){var N={data:E.subarray(P,u),type:_,state:d};o.push(N)}if(o.length===0){var U=this.getLastNalUnit(i.samples);if(U){var w=new Uint8Array(U.data.byteLength+E.byteLength);w.set(U.data,0),w.set(E,U.data.byteLength),U.data=w}}return i.naluState=d,o},n.parseAACPES=function(i,E){var u=0,d=this.aacOverFlow,c=E.data;if(d){this.aacOverFlow=null;var o=d.missing,s=d.sample.unit.byteLength;if(o===-1){var y=new Uint8Array(s+c.byteLength);y.set(d.sample.unit,0),y.set(c,s),c=y}else{var L=s-o;d.sample.unit.set(c.subarray(0,o),L),i.samples.push(d.sample),u=d.missing}}var A,P;for(A=u,P=c.length;A<P-1&&!T.isHeader(c,A);A++);if(A!==u){var _,F;if(A<P-1?(_="AAC PES did not start with ADTS header,offset:"+A,F=!1):(_="no ADTS header found in AAC PES",F=!0),S.logger.warn("parsing error:"+_),this.observer.emit(C.Events.ERROR,C.Events.ERROR,{type:g.ErrorTypes.MEDIA_ERROR,details:g.ErrorDetails.FRAG_PARSING_ERROR,fatal:F,reason:_}),F)return}T.initTrackConfig(i,this.observer,c,A,this.audioCodec);var B;if(E.pts!==void 0)B=E.pts;else if(d){var k=T.getFrameDuration(i.samplerate);B=d.sample.pts+k}else{S.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var N=0,U;A<P;)if(U=T.appendFrame(i,c,A,B,N),A+=U.length,U.missing){this.aacOverFlow=U;break}else for(N++;A<P-1&&!T.isHeader(c,A);A++);},n.parseMPEGPES=function(i,E){var u=E.data,d=u.length,c=0,o=0,s=E.pts;if(s===void 0){S.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<d;)if(R.isHeader(u,o)){var y=R.appendFrame(i,u,o,s,c);if(y)o+=y.length,c++;else break}else o++},n.parseID3PES=function(i,E){if(E.pts===void 0){S.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var u=p({},E,{type:this._avcTrack?x.MetadataSchema.emsg:x.MetadataSchema.audioId3});i.samples.push(u)},h}();m.minProbeByteLength=188;function v(h,n,t,i){return{key:h,frame:!1,pts:n,dts:t,units:[],debug:i,length:0}}function f(h,n){return(h[n+10]&31)<<8|h[n+11]}function r(h,n,t,i){var E={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},u=(h[n+1]&15)<<8|h[n+2],d=n+3+u-4,c=(h[n+10]&15)<<8|h[n+11];for(n+=12+c;n<d;){var o=(h[n+1]&31)<<8|h[n+2];switch(h[n]){case 207:if(!i){S.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:E.audio===-1&&(E.audio=o);break;case 21:E.id3===-1&&(E.id3=o);break;case 219:if(!i){S.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:E.avc===-1&&(E.avc=o);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?S.logger.log("MPEG audio found, not supported in this browser"):E.audio===-1&&(E.audio=o,E.segmentCodec="mp3");break;case 36:S.logger.warn("Unsupported HEVC stream type found");break}n+=((h[n+3]&15)<<8|h[n+4])+5}return E}function e(h){var n=0,t,i,E,u,d,c=h.data;if(!h||h.size===0)return null;for(;c[0].length<19&&c.length>1;){var o=new Uint8Array(c[0].length+c[1].length);o.set(c[0]),o.set(c[1],c[0].length),c[0]=o,c.splice(1,1)}t=c[0];var s=(t[0]<<16)+(t[1]<<8)+t[2];if(s===1){if(i=(t[4]<<8)+t[5],i&&i>h.size-6)return null;var y=t[7];y&192&&(u=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,y&64?(d=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,u-d>60*9e4&&(S.logger.warn(Math.round((u-d)/9e4)+"s delta between PTS and DTS, align them"),u=d)):d=u),E=t[8];var L=E+9;if(h.size<=L)return null;h.size-=L;for(var A=new Uint8Array(h.size),P=0,_=c.length;P<_;P++){t=c[P];var F=t.byteLength;if(L)if(L>F){L-=F;continue}else t=t.subarray(L),F-=L,L=0;A.set(t,n),n+=F}return i&&(i-=E+3),{data:A,pts:u,dts:d,len:i}}return null}function a(h,n){if(h.units.length&&h.frame){if(h.pts===void 0){var t=n.samples,i=t.length;if(i){var E=t[i-1];h.pts=E.pts,h.dts=E.dts}else{n.dropped++;return}}n.samples.push(h)}h.debug.length&&S.logger.log(h.pts+"/"+h.dts+":"+h.debug)}function l(h){for(var n=h.byteLength,t=[],i=1;i<n-2;)h[i]===0&&h[i+1]===0&&h[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return h;var E=n-t.length,u=new Uint8Array(E),d=0;for(i=0;i<E;d++,i++)d===t[0]&&(d++,t.shift()),u[i]=h[d];return u}M.default=m},"./src/errors.ts":function(K,M,D){D.r(M),D.d(M,"ErrorTypes",function(){return T}),D.d(M,"ErrorDetails",function(){return R});var T;(function(O){O.NETWORK_ERROR="networkError",O.MEDIA_ERROR="mediaError",O.KEY_SYSTEM_ERROR="keySystemError",O.MUX_ERROR="muxError",O.OTHER_ERROR="otherError"})(T||(T={}));var R;(function(O){O.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",O.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",O.KEY_SYSTEM_NO_SESSION="keySystemNoSession",O.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",O.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",O.MANIFEST_LOAD_ERROR="manifestLoadError",O.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",O.MANIFEST_PARSING_ERROR="manifestParsingError",O.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",O.LEVEL_EMPTY_ERROR="levelEmptyError",O.LEVEL_LOAD_ERROR="levelLoadError",O.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",O.LEVEL_SWITCH_ERROR="levelSwitchError",O.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",O.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",O.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",O.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",O.FRAG_LOAD_ERROR="fragLoadError",O.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",O.FRAG_DECRYPT_ERROR="fragDecryptError",O.FRAG_PARSING_ERROR="fragParsingError",O.REMUX_ALLOC_ERROR="remuxAllocError",O.KEY_LOAD_ERROR="keyLoadError",O.KEY_LOAD_TIMEOUT="keyLoadTimeOut",O.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",O.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",O.BUFFER_APPEND_ERROR="bufferAppendError",O.BUFFER_APPENDING_ERROR="bufferAppendingError",O.BUFFER_STALLED_ERROR="bufferStalledError",O.BUFFER_FULL_ERROR="bufferFullError",O.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",O.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",O.INTERNAL_EXCEPTION="internalException",O.INTERNAL_ABORTED="aborted",O.UNKNOWN="unknown"})(R||(R={}))},"./src/events.ts":function(K,M,D){D.r(M),D.d(M,"Events",function(){return T});var T;(function(R){R.MEDIA_ATTACHING="hlsMediaAttaching",R.MEDIA_ATTACHED="hlsMediaAttached",R.MEDIA_DETACHING="hlsMediaDetaching",R.MEDIA_DETACHED="hlsMediaDetached",R.BUFFER_RESET="hlsBufferReset",R.BUFFER_CODECS="hlsBufferCodecs",R.BUFFER_CREATED="hlsBufferCreated",R.BUFFER_APPENDING="hlsBufferAppending",R.BUFFER_APPENDED="hlsBufferAppended",R.BUFFER_EOS="hlsBufferEos",R.BUFFER_FLUSHING="hlsBufferFlushing",R.BUFFER_FLUSHED="hlsBufferFlushed",R.MANIFEST_LOADING="hlsManifestLoading",R.MANIFEST_LOADED="hlsManifestLoaded",R.MANIFEST_PARSED="hlsManifestParsed",R.LEVEL_SWITCHING="hlsLevelSwitching",R.LEVEL_SWITCHED="hlsLevelSwitched",R.LEVEL_LOADING="hlsLevelLoading",R.LEVEL_LOADED="hlsLevelLoaded",R.LEVEL_UPDATED="hlsLevelUpdated",R.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",R.LEVELS_UPDATED="hlsLevelsUpdated",R.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",R.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",R.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",R.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",R.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",R.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",R.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",R.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",R.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",R.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",R.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",R.CUES_PARSED="hlsCuesParsed",R.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",R.INIT_PTS_FOUND="hlsInitPtsFound",R.FRAG_LOADING="hlsFragLoading",R.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",R.FRAG_LOADED="hlsFragLoaded",R.FRAG_DECRYPTED="hlsFragDecrypted",R.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",R.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",R.FRAG_PARSING_METADATA="hlsFragParsingMetadata",R.FRAG_PARSED="hlsFragParsed",R.FRAG_BUFFERED="hlsFragBuffered",R.FRAG_CHANGED="hlsFragChanged",R.FPS_DROP="hlsFpsDrop",R.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",R.ERROR="hlsError",R.DESTROYING="hlsDestroying",R.KEY_LOADING="hlsKeyLoading",R.KEY_LOADED="hlsKeyLoaded",R.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",R.BACK_BUFFER_REACHED="hlsBackBufferReached"})(T||(T={}))},"./src/hls.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return l});var T=D("./node_modules/url-toolkit/src/url-toolkit.js"),R=D("./src/loader/playlist-loader.ts"),O=D("./src/loader/key-loader.ts"),b=D("./src/controller/id3-track-controller.ts"),C=D("./src/controller/latency-controller.ts"),I=D("./src/controller/level-controller.ts"),S=D("./src/controller/fragment-tracker.ts"),g=D("./src/controller/stream-controller.ts"),x=D("./src/is-supported.ts"),p=D("./src/utils/logger.ts"),m=D("./src/config.ts"),v=D("./node_modules/eventemitter3/index.js"),f=D("./src/events.ts"),r=D("./src/errors.ts");function e(h,n){for(var t=0;t<n.length;t++){var i=n[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(h,i.key,i)}}function a(h,n,t){return n&&e(h.prototype,n),t&&e(h,t),Object.defineProperty(h,"prototype",{writable:!1}),h}var l=function(){h.isSupported=function(){return Object(x.isSupported)()};function h(t){t===void 0&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new v.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 i=this.config=Object(m.mergeConfig)(h.DefaultConfig,t);this.userConfig=t,Object(p.enableLogs)(i.debug),this._autoLevelCapping=-1,i.progressive&&Object(m.enableStreamingMode)(i);var E=i.abrController,u=i.bufferController,d=i.capLevelController,c=i.fpsController,o=this.abrController=new E(this),s=this.bufferController=new u(this),y=this.capLevelController=new d(this),L=new c(this),A=new R.default(this),P=new O.default(this),_=new b.default(this),F=this.levelController=new I.default(this),B=new S.FragmentTracker(this),k=this.streamController=new g.default(this,B);y.setStreamController(k),L.setStreamController(k);var N=[F,k];this.networkControllers=N;var U=[A,P,o,s,y,L,_,B];this.audioTrackController=this.createController(i.audioTrackController,null,N),this.createController(i.audioStreamController,B,N),this.subtitleTrackController=this.createController(i.subtitleTrackController,null,N),this.createController(i.subtitleStreamController,B,N),this.createController(i.timelineController,null,U),this.emeController=this.createController(i.emeController,null,U),this.cmcdController=this.createController(i.cmcdController,null,U),this.latencyController=this.createController(C.default,null,U),this.coreComponents=U}var n=h.prototype;return n.createController=function(i,E,u){if(i){var d=E?new i(this,E):new i(this);return u&&u.push(d),d}return null},n.on=function(i,E,u){u===void 0&&(u=this),this._emitter.on(i,E,u)},n.once=function(i,E,u){u===void 0&&(u=this),this._emitter.once(i,E,u)},n.removeAllListeners=function(i){this._emitter.removeAllListeners(i)},n.off=function(i,E,u,d){u===void 0&&(u=this),this._emitter.off(i,E,u,d)},n.listeners=function(i){return this._emitter.listeners(i)},n.emit=function(i,E,u){return this._emitter.emit(i,E,u)},n.trigger=function(i,E){if(this.config.debug)return this.emit(i,i,E);try{return this.emit(i,i,E)}catch(u){p.logger.error("An internal error happened while handling event "+i+'. Error message: "'+u.message+'". Here is a stacktrace:',u),this.trigger(f.Events.ERROR,{type:r.ErrorTypes.OTHER_ERROR,details:r.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:i,error:u})}return!1},n.listenerCount=function(i){return this._emitter.listenerCount(i)},n.destroy=function(){p.logger.log("destroy"),this.trigger(f.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(i){return i.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(i){return i.destroy()}),this.coreComponents.length=0},n.attachMedia=function(i){p.logger.log("attachMedia"),this._media=i,this.trigger(f.Events.MEDIA_ATTACHING,{media:i})},n.detachMedia=function(){p.logger.log("detachMedia"),this.trigger(f.Events.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(i){this.stopLoad();var E=this.media,u=this.url,d=this.url=T.buildAbsoluteURL(self.location.href,i,{alwaysNormalize:!0});p.logger.log("loadSource:"+d),E&&u&&u!==d&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(E)),this.trigger(f.Events.MANIFEST_LOADING,{url:i})},n.startLoad=function(i){i===void 0&&(i=-1),p.logger.log("startLoad("+i+")"),this.networkControllers.forEach(function(E){E.startLoad(i)})},n.stopLoad=function(){p.logger.log("stopLoad"),this.networkControllers.forEach(function(i){i.stopLoad()})},n.swapAudioCodec=function(){p.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){p.logger.log("recoverMediaError");var i=this._media;this.detachMedia(),i&&this.attachMedia(i)},n.removeLevel=function(i,E){E===void 0&&(E=0),this.levelController.removeLevel(i,E)},a(h,[{key:"levels",get:function(){var i=this.levelController.levels;return i||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(i){p.logger.log("set currentLevel:"+i),this.loadLevel=i,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(i){p.logger.log("set nextLevel:"+i),this.levelController.manualLevel=i,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(i){p.logger.log("set loadLevel:"+i),this.levelController.manualLevel=i}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(i){this.levelController.nextLoadLevel=i}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(i){p.logger.log("set firstLevel:"+i),this.levelController.firstLevel=i}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(i){p.logger.log("set startLevel:"+i),i!==-1&&(i=Math.max(i,this.minAutoLevel)),this.levelController.startLevel=i}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(i){var E=!!i;E!==this.config.capLevelToPlayerSize&&(E?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=E)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(i){this._autoLevelCapping!==i&&(p.logger.log("set autoLevelCapping:"+i),this._autoLevelCapping=i)}},{key:"bandwidthEstimate",get:function(){var i=this.abrController.bwEstimator;return i?i.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var i=this.levels,E=this.config.minAutoBitrate;if(!i)return 0;for(var u=i.length,d=0;d<u;d++)if(i[d].maxBitrate>=E)return d;return 0}},{key:"maxAutoLevel",get:function(){var i=this.levels,E=this.autoLevelCapping,u;return E===-1&&i&&i.length?u=i.length-1:u=E,u}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(i){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,i)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var i=this.audioTrackController;return i?i.audioTracks:[]}},{key:"audioTrack",get:function(){var i=this.audioTrackController;return i?i.audioTrack:-1},set:function(i){var E=this.audioTrackController;E&&(E.audioTrack=i)}},{key:"subtitleTracks",get:function(){var i=this.subtitleTrackController;return i?i.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var i=this.subtitleTrackController;return i?i.subtitleTrack:-1},set:function(i){var E=this.subtitleTrackController;E&&(E.subtitleTrack=i)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var i=this.subtitleTrackController;return i?i.subtitleDisplay:!1},set:function(i){var E=this.subtitleTrackController;E&&(E.subtitleDisplay=i)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(i){this.config.lowLatencyMode=i}},{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}}],[{key:"version",get:function(){return"1.2.1"}},{key:"Events",get:function(){return f.Events}},{key:"ErrorTypes",get:function(){return r.ErrorTypes}},{key:"ErrorDetails",get:function(){return r.ErrorDetails}},{key:"DefaultConfig",get:function(){return h.defaultConfig?h.defaultConfig:m.hlsDefaultConfig},set:function(i){h.defaultConfig=i}}]),h}();l.defaultConfig=void 0},"./src/is-supported.ts":function(K,M,D){D.r(M),D.d(M,"isSupported",function(){return O}),D.d(M,"changeTypeSupported",function(){return b});var T=D("./src/utils/mediasource-helper.ts");function R(){return self.SourceBuffer||self.WebKitSourceBuffer}function O(){var C=Object(T.getMediaSource)();if(!C)return!1;var I=R(),S=C&&typeof C.isTypeSupported=="function"&&C.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),g=!I||I.prototype&&typeof I.prototype.appendBuffer=="function"&&typeof I.prototype.remove=="function";return!!S&&!!g}function b(){var C,I=R();return typeof(I==null||(C=I.prototype)===null||C===void 0?void 0:C.changeType)=="function"}},"./src/loader/date-range.ts":function(K,M,D){D.r(M),D.d(M,"DateRangeAttribute",function(){return S}),D.d(M,"DateRange",function(){return g});var T=D("./src/polyfills/number.ts"),R=D("./src/utils/attr-list.ts"),O=D("./src/utils/logger.ts");function b(){return b=Object.assign?Object.assign.bind():function(x){for(var p=1;p<arguments.length;p++){var m=arguments[p];for(var v in m)Object.prototype.hasOwnProperty.call(m,v)&&(x[v]=m[v])}return x},b.apply(this,arguments)}function C(x,p){for(var m=0;m<p.length;m++){var v=p[m];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(x,v.key,v)}}function I(x,p,m){return p&&C(x.prototype,p),m&&C(x,m),Object.defineProperty(x,"prototype",{writable:!1}),x}var S;(function(x){x.ID="ID",x.CLASS="CLASS",x.START_DATE="START-DATE",x.DURATION="DURATION",x.END_DATE="END-DATE",x.END_ON_NEXT="END-ON-NEXT",x.PLANNED_DURATION="PLANNED-DURATION",x.SCTE35_OUT="SCTE35-OUT",x.SCTE35_IN="SCTE35-IN"})(S||(S={}));var g=function(){function x(p,m){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,m){var v=m.attr;for(var f in v)if(Object.prototype.hasOwnProperty.call(p,f)&&p[f]!==v[f]){O.logger.warn('DATERANGE tag attribute: "'+f+'" does not match for tags with ID: "'+p.ID+'"'),this._badValueForSameId=f;break}p=b(new R.AttrList({}),v,p)}if(this.attr=p,this._startDate=new Date(p[S.START_DATE]),S.END_DATE in this.attr){var r=new Date(this.attr[S.END_DATE]);Object(T.isFiniteNumber)(r.getTime())&&(this._endDate=r)}}return I(x,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var m=this.duration;return m!==null?new Date(this._startDate.getTime()+m*1e3):null}},{key:"duration",get:function(){if(S.DURATION in this.attr){var m=this.attr.decimalFloatingPoint(S.DURATION);if(Object(T.isFiniteNumber)(m))return m}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return S.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(S.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(S.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(T.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),x}()},"./src/loader/fragment-loader.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return m}),D.d(M,"LoadError",function(){return f});var T=D("./src/polyfills/number.ts"),R=D("./src/errors.ts");function O(r,e){r.prototype=Object.create(e.prototype),r.prototype.constructor=r,g(r,e)}function b(r){var e=typeof Map=="function"?new Map:void 0;return b=function(l){if(l===null||!S(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(l))return e.get(l);e.set(l,h)}function h(){return C(l,arguments,x(this).constructor)}return h.prototype=Object.create(l.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),g(h,l)},b(r)}function C(r,e,a){return I()?C=Reflect.construct.bind():C=function(h,n,t){var i=[null];i.push.apply(i,n);var E=Function.bind.apply(h,i),u=new E;return t&&g(u,t.prototype),u},C.apply(null,arguments)}function I(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function S(r){return Function.toString.call(r).indexOf("[native code]")!==-1}function g(r,e){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,h){return l.__proto__=h,l},g(r,e)}function x(r){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},x(r)}var p=Math.pow(2,17),m=function(){function r(a){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=a}var e=r.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(l,h){var n=this,t=l.url;if(!t)return Promise.reject(new f({type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,networkDetails:null},"Fragment does not have a "+(t?"part list":"url")));this.abort();var i=this.config,E=i.fLoader,u=i.loader;return new Promise(function(d,c){n.loader&&n.loader.destroy();var o=n.loader=l.loader=E?new E(i):new u(i),s=v(l),y={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout,highWaterMark:l.sn==="initSegment"?1/0:p};l.stats=o.stats,o.load(s,y,{onSuccess:function(A,P,_,F){n.resetLoader(l,o),d({frag:l,part:null,payload:A.data,networkDetails:F})},onError:function(A,P,_){n.resetLoader(l,o),c(new f({type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,response:A,networkDetails:_}))},onAbort:function(A,P,_){n.resetLoader(l,o),c(new f({type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:l,networkDetails:_}))},onTimeout:function(A,P,_){n.resetLoader(l,o),c(new f({type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,networkDetails:_}))},onProgress:function(A,P,_,F){h&&h({frag:l,part:null,payload:_,networkDetails:F})}})})},e.loadPart=function(l,h,n){var t=this;this.abort();var i=this.config,E=i.fLoader,u=i.loader;return new Promise(function(d,c){t.loader&&t.loader.destroy();var o=t.loader=l.loader=E?new E(i):new u(i),s=v(l,h),y={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout,highWaterMark:p};h.stats=o.stats,o.load(s,y,{onSuccess:function(A,P,_,F){t.resetLoader(l,o),t.updateStatsFromPart(l,h);var B={frag:l,part:h,payload:A.data,networkDetails:F};n(B),d(B)},onError:function(A,P,_){t.resetLoader(l,o),c(new f({type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:h,response:A,networkDetails:_}))},onAbort:function(A,P,_){l.stats.aborted=h.stats.aborted,t.resetLoader(l,o),c(new f({type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:l,part:h,networkDetails:_}))},onTimeout:function(A,P,_){t.resetLoader(l,o),c(new f({type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:h,networkDetails:_}))}})})},e.updateStatsFromPart=function(l,h){var n=l.stats,t=h.stats,i=t.total;if(n.loaded+=t.loaded,i){var E=Math.round(l.duration/h.duration),u=Math.min(Math.round(n.loaded/i),E),d=E-u,c=d*Math.round(n.loaded/u);n.total=n.loaded+c}else n.total=Math.max(n.loaded,n.total);var o=n.loading,s=t.loading;o.start?o.first+=s.first-s.start:(o.start=s.start,o.first=s.first),o.end=s.end},e.resetLoader=function(l,h){l.loader=null,this.loader===h&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),h.destroy()},r}();function v(r,e){e===void 0&&(e=null);var a=e||r,l={frag:r,part:e,responseType:"arraybuffer",url:a.url,headers:{},rangeStart:0,rangeEnd:0},h=a.byteRangeStartOffset,n=a.byteRangeEndOffset;return Object(T.isFiniteNumber)(h)&&Object(T.isFiniteNumber)(n)&&(l.rangeStart=h,l.rangeEnd=n),l}var f=function(r){O(e,r);function e(a){for(var l,h=arguments.length,n=new Array(h>1?h-1:0),t=1;t<h;t++)n[t-1]=arguments[t];return l=r.call.apply(r,[this].concat(n))||this,l.data=void 0,l.data=a,l}return e}(b(Error))},"./src/loader/fragment.ts":function(K,M,D){D.r(M),D.d(M,"ElementaryStreamTypes",function(){return p}),D.d(M,"BaseSegment",function(){return m}),D.d(M,"Fragment",function(){return v}),D.d(M,"Part",function(){return f});var T=D("./src/polyfills/number.ts"),R=D("./node_modules/url-toolkit/src/url-toolkit.js"),O=D("./src/utils/logger.ts"),b=D("./src/loader/level-key.ts"),C=D("./src/loader/load-stats.ts");function I(r,e){r.prototype=Object.create(e.prototype),r.prototype.constructor=r,S(r,e)}function S(r,e){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(l,h){return l.__proto__=h,l},S(r,e)}function g(r,e){for(var a=0;a<e.length;a++){var l=e[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(r,l.key,l)}}function x(r,e,a){return e&&g(r.prototype,e),a&&g(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r}var p;(function(r){r.AUDIO="audio",r.VIDEO="video",r.AUDIOVIDEO="audiovideo"})(p||(p={}));var m=function(){function r(a){var l;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(l={},l[p.AUDIO]=null,l[p.VIDEO]=null,l[p.AUDIOVIDEO]=null,l),this.baseurl=a}var e=r.prototype;return e.setByteRange=function(l,h){var n=l.split("@",2),t=[];n.length===1?t[0]=h?h.byteRangeEndOffset:0:t[0]=parseInt(n[1]),t[1]=parseInt(n[0])+t[0],this._byteRange=t},x(r,[{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(R.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(l){this._url=l}}]),r}(),v=function(r){I(e,r);function e(l,h){var n;return n=r.call(this,h)||this,n._decryptdata=null,n.rawProgramDateTime=null,n.programDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkey=void 0,n.type=void 0,n.loader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.appendedPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.stats=new C.LoadStats,n.urlId=0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.type=l,n}var a=e.prototype;return a.createInitializationVector=function(h){for(var n=new Uint8Array(16),t=12;t<16;t++)n[t]=h>>8*(15-t)&255;return n},a.setDecryptDataFromLevelKey=function(h,n){var t=h;return(h==null?void 0:h.method)==="AES-128"&&h.uri&&!h.iv&&(t=b.LevelKey.fromURI(h.uri),t.method=h.method,t.iv=this.createInitializationVector(n),t.keyFormat="identity"),t},a.setElementaryStreamInfo=function(h,n,t,i,E,u){u===void 0&&(u=!1);var d=this.elementaryStreams,c=d[h];if(!c){d[h]={startPTS:n,endPTS:t,startDTS:i,endDTS:E,partial:u};return}c.startPTS=Math.min(c.startPTS,n),c.endPTS=Math.max(c.endPTS,t),c.startDTS=Math.min(c.startDTS,i),c.endDTS=Math.max(c.endDTS,E)},a.clearElementaryStreamInfo=function(){var h=this.elementaryStreams;h[p.AUDIO]=null,h[p.VIDEO]=null,h[p.AUDIOVIDEO]=null},x(e,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var h=this.sn;typeof h!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&O.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),h=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,h)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(T.isFiniteNumber)(this.programDateTime))return null;var h=Object(T.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+h*1e3}},{key:"encrypted",get:function(){var h;return!!((h=this.decryptdata)!==null&&h!==void 0&&h.keyFormat&&this.decryptdata.uri)}}]),e}(m),f=function(r){I(e,r);function e(a,l,h,n,t){var i;i=r.call(this,h)||this,i.fragOffset=0,i.duration=0,i.gap=!1,i.independent=!1,i.relurl=void 0,i.fragment=void 0,i.index=void 0,i.stats=new C.LoadStats,i.duration=a.decimalFloatingPoint("DURATION"),i.gap=a.bool("GAP"),i.independent=a.bool("INDEPENDENT"),i.relurl=a.enumeratedString("URI"),i.fragment=l,i.index=n;var E=a.enumeratedString("BYTERANGE");return E&&i.setByteRange(E,t),t&&(i.fragOffset=t.fragOffset+t.duration),i}return x(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var l=this.elementaryStreams;return!!(l.audio||l.video||l.audiovideo)}}]),e}(m)},"./src/loader/key-loader.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return b});var T=D("./src/events.ts"),R=D("./src/errors.ts"),O=D("./src/utils/logger.ts"),b=function(){function C(S){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=S,this._registerListeners()}var I=C.prototype;return I._registerListeners=function(){this.hls.on(T.Events.KEY_LOADING,this.onKeyLoading,this)},I._unregisterListeners=function(){this.hls.off(T.Events.KEY_LOADING,this.onKeyLoading)},I.destroy=function(){this._unregisterListeners();for(var g in this.loaders){var x=this.loaders[g];x&&x.destroy()}this.loaders={}},I.onKeyLoading=function(g,x){var p=x.frag,m=p.type,v=this.loaders[m];if(!p.decryptdata){O.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var f=p.decryptdata.uri;if(f!==this.decrypturl||this.decryptkey===null){var r=this.hls.config;if(v&&(O.logger.warn("abort previous key loader for type:"+m),v.abort()),!f){O.logger.warn("key uri is falsy");return}var e=r.loader,a=p.loader=this.loaders[m]=new e(r);this.decrypturl=f,this.decryptkey=null;var l={url:f,frag:p,responseType:"arraybuffer"},h={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:r.fragLoadingRetryDelay,maxRetryDelay:r.fragLoadingMaxRetryTimeout,highWaterMark:0},n={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(l,h,n)}else this.decryptkey&&(p.decryptdata.key=this.decryptkey,this.hls.trigger(T.Events.KEY_LOADED,{frag:p}))},I.loadsuccess=function(g,x,p){var m=p.frag;if(!m.decryptdata){O.logger.error("after key load, decryptdata unset");return}this.decryptkey=m.decryptdata.key=new Uint8Array(g.data),m.loader=null,delete this.loaders[m.type],this.hls.trigger(T.Events.KEY_LOADED,{frag:m})},I.loaderror=function(g,x){var p=x.frag,m=p.loader;m&&m.abort(),delete this.loaders[p.type],this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:p,response:g})},I.loadtimeout=function(g,x){var p=x.frag,m=p.loader;m&&m.abort(),delete this.loaders[p.type],this.hls.trigger(T.Events.ERROR,{type:R.ErrorTypes.NETWORK_ERROR,details:R.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:p})},C}()},"./src/loader/level-details.ts":function(K,M,D){D.r(M),D.d(M,"LevelDetails",function(){return C});var T=D("./src/polyfills/number.ts");function R(I,S){for(var g=0;g<S.length;g++){var x=S[g];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(I,x.key,x)}}function O(I,S,g){return S&&R(I.prototype,S),g&&R(I,g),Object.defineProperty(I,"prototype",{writable:!1}),I}var b=10,C=function(){function I(g){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.dateRanges=void 0,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.dateRanges={},this.url=g}var S=I.prototype;return S.reloaded=function(x){if(!x){this.advanced=!0,this.updated=!0;return}var p=this.lastPartSn-x.lastPartSn,m=this.lastPartIndex-x.lastPartIndex;this.updated=this.endSN!==x.endSN||!!m||!!p,this.advanced=this.endSN>x.endSN||p>0||p===0&&m>0,this.updated||this.advanced?this.misses=Math.floor(x.misses*.6):this.misses=x.misses+1,this.availabilityDelay=x.availabilityDelay},O(I,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(T.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||b}},{key:"drift",get:function(){var x=this.driftEndTime-this.driftStartTime;if(x>0){var p=this.driftEnd-this.driftStart;return p*1e3/x}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var x;return(x=this.fragments)!==null&&x!==void 0&&x.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 x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var x;return(x=this.partList)!==null&&x!==void 0&&x.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),I}()},"./src/loader/level-key.ts":function(K,M,D){D.r(M),D.d(M,"LevelKey",function(){return b});var T=D("./node_modules/url-toolkit/src/url-toolkit.js");function R(C,I){for(var S=0;S<I.length;S++){var g=I[S];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(C,g.key,g)}}function O(C,I,S){return I&&R(C.prototype,I),S&&R(C,S),Object.defineProperty(C,"prototype",{writable:!1}),C}var b=function(){C.fromURL=function(S,g){return new C(S,g)},C.fromURI=function(S){return new C(S)};function C(I,S){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,S?this._uri=Object(T.buildAbsoluteURL)(I,S,{alwaysNormalize:!0}):this._uri=I}return O(C,[{key:"uri",get:function(){return this._uri}}]),C}()},"./src/loader/load-stats.ts":function(K,M,D){D.r(M),D.d(M,"LoadStats",function(){return T});var T=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":function(K,M,D){D.r(M),D.d(M,"default",function(){return a});var T=D("./src/polyfills/number.ts"),R=D("./node_modules/url-toolkit/src/url-toolkit.js"),O=D("./src/loader/date-range.ts"),b=D("./src/loader/fragment.ts"),C=D("./src/loader/level-details.ts"),I=D("./src/loader/level-key.ts"),S=D("./src/utils/attr-list.ts"),g=D("./src/utils/logger.ts"),x=D("./src/utils/codecs.ts"),p=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,m=/#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"),f=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),r=/\.(mp4|m4s|m4v|m4a)$/i;function e(E){var u,d;return r.test((u=(d=R.parseURL(E))===null||d===void 0?void 0:d.path)!=null?u:"")}var a=function(){function E(){}return E.findGroup=function(d,c){for(var o=0;o<d.length;o++){var s=d[o];if(s.id===c)return s}},E.convertAVC1ToAVCOTI=function(d){var c=d.split(".");if(c.length>2){var o=c.shift()+".";return o+=parseInt(c.shift()).toString(16),o+=("000"+parseInt(c.shift()).toString(16)).slice(-4),o}return d},E.resolve=function(d,c){return R.buildAbsoluteURL(c,d,{alwaysNormalize:!0})},E.parseMasterPlaylist=function(d,c){var o=[],s={},y=!1;p.lastIndex=0;for(var L;(L=p.exec(d))!=null;)if(L[1]){var A=new S.AttrList(L[1]),P={attrs:A,bitrate:A.decimalInteger("AVERAGE-BANDWIDTH")||A.decimalInteger("BANDWIDTH"),name:A.NAME,url:E.resolve(L[2],c)},_=A.decimalResolution("RESOLUTION");_&&(P.width=_.width,P.height=_.height),l((A.CODECS||"").split(/[ ,]+/).filter(function(B){return B}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=E.convertAVC1ToAVCOTI(P.videoCodec)),o.push(P)}else if(L[3]){var F=new S.AttrList(L[3]);F["DATA-ID"]&&(y=!0,s[F["DATA-ID"]]=F)}return{levels:o,sessionData:y?s:null}},E.parseMasterPlaylistMedia=function(d,c,o,s){s===void 0&&(s=[]);var y,L=[],A=0;for(m.lastIndex=0;(y=m.exec(d))!==null;){var P=new S.AttrList(y[1]);if(P.TYPE===o){var _={attrs:P,bitrate:0,id:A++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:o,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?E.resolve(P.URI,c):""};if(s.length){var F=E.findGroup(s,_.groupId)||s[0];h(_,F,"audioCodec"),h(_,F,"textCodec")}L.push(_)}}return L},E.parseLevelPlaylist=function(d,c,o,s,y){var L=new C.LevelDetails(c),A=L.fragments,P=null,_=0,F=0,B=0,k=0,N=null,U=new b.Fragment(s,c),w,W,j,H=-1,G=!1;for(v.lastIndex=0,L.m3u8=d;(w=v.exec(d))!==null;){G&&(G=!1,U=new b.Fragment(s,c),U.start=B,U.sn=_,U.cc=k,U.level=o,P&&(U.initSegment=P,U.rawProgramDateTime=P.rawProgramDateTime,P.rawProgramDateTime=null));var Y=w[1];if(Y){U.duration=parseFloat(Y);var X=(" "+w[2]).slice(1);U.title=X||null,U.tagList.push(X?["INF",Y,X]:["INF",Y])}else if(w[3])Object(T.isFiniteNumber)(U.duration)&&(U.start=B,j&&(U.levelkey=j),U.sn=_,U.level=o,U.cc=k,U.urlId=y,A.push(U),U.relurl=(" "+w[3]).slice(1),t(U,N),N=U,B+=U.duration,_++,F=0,G=!0);else if(w[4]){var z=(" "+w[4]).slice(1);N?U.setByteRange(z,N):U.setByteRange(z)}else if(w[5])U.rawProgramDateTime=(" "+w[5]).slice(1),U.tagList.push(["PROGRAM-DATE-TIME",U.rawProgramDateTime]),H===-1&&(H=A.length);else{if(w=w[0].match(f),!w){g.logger.warn("No matches on slow regex match for level playlist!");continue}for(W=1;W<w.length&&!(typeof w[W]<"u");W++);var V=(" "+w[W]).slice(1),$=(" "+w[W+1]).slice(1),Q=w[W+2]?(" "+w[W+2]).slice(1):"";switch(V){case"PLAYLIST-TYPE":L.type=$.toUpperCase();break;case"MEDIA-SEQUENCE":_=L.startSN=parseInt($);break;case"SKIP":{var J=new S.AttrList($),Z=J.decimalInteger("SKIPPED-SEGMENTS");if(Object(T.isFiniteNumber)(Z)){L.skippedSegments=Z;for(var q=Z;q--;)A.unshift(null);_+=Z}var ee=J.enumeratedString("RECENTLY-REMOVED-DATERANGES");ee&&(L.recentlyRemovedDateranges=ee.split(" "));break}case"TARGETDURATION":L.targetduration=parseFloat($);break;case"VERSION":L.version=parseInt($);break;case"EXTM3U":break;case"ENDLIST":L.live=!1;break;case"#":($||Q)&&U.tagList.push(Q?[$,Q]:[$]);break;case"DISCONTINUITY":k++,U.tagList.push(["DIS"]);break;case"GAP":U.tagList.push([V]);break;case"BITRATE":U.tagList.push([V,$]);break;case"DATERANGE":{var te=new S.AttrList($),re=new O.DateRange(te,L.dateRanges[te.ID]);re.isValid||L.skippedSegments?L.dateRanges[re.id]=re:g.logger.warn('Ignoring invalid DATERANGE tag: "'+$+'"'),U.tagList.push(["EXT-X-DATERANGE",$]);break}case"DISCONTINUITY-SEQUENCE":k=parseInt($);break;case"KEY":{var oe,de=new S.AttrList($),he=de.enumeratedString("METHOD"),ae=de.URI,Se=de.hexadecimalInteger("IV"),ce=de.enumeratedString("KEYFORMATVERSIONS"),le=de.enumeratedString("KEYID"),pe=(oe=de.enumeratedString("KEYFORMAT"))!=null?oe:"identity",ye=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(ye.indexOf(pe)>-1){g.logger.warn("Keyformat "+pe+" is not supported from the manifest");continue}else if(pe!=="identity")continue;he&&(j=I.LevelKey.fromURL(c,ae),ae&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(he)>=0&&(j.method=he,j.keyFormat=pe,le&&(j.keyID=le),ce&&(j.keyFormatVersions=ce),j.iv=Se));break}case"START":{var Ee=new S.AttrList($),ne=Ee.decimalFloatingPoint("TIME-OFFSET");Object(T.isFiniteNumber)(ne)&&(L.startTimeOffset=ne);break}case"MAP":{var ue=new S.AttrList($);if(U.duration){var ve=new b.Fragment(s,c);i(ve,ue,o,j),P=ve,U.initSegment=P,P.rawProgramDateTime&&!U.rawProgramDateTime&&(U.rawProgramDateTime=P.rawProgramDateTime)}else i(U,ue,o,j),P=U,G=!0;break}case"SERVER-CONTROL":{var ge=new S.AttrList($);L.canBlockReload=ge.bool("CAN-BLOCK-RELOAD"),L.canSkipUntil=ge.optionalFloat("CAN-SKIP-UNTIL",0),L.canSkipDateRanges=L.canSkipUntil>0&&ge.bool("CAN-SKIP-DATERANGES"),L.partHoldBack=ge.optionalFloat("PART-HOLD-BACK",0),L.holdBack=ge.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Te=new S.AttrList($);L.partTarget=Te.decimalFloatingPoint("PART-TARGET");break}case"PART":{var se=L.partList;se||(se=L.partList=[]);var me=F>0?se[se.length-1]:void 0,Le=F++,Ae=new b.Part(new S.AttrList($),U,c,Le,me);se.push(Ae),U.duration+=Ae.duration;break}case"PRELOAD-HINT":{var Oe=new S.AttrList($);L.preloadHint=Oe;break}case"RENDITION-REPORT":{var De=new S.AttrList($);L.renditionReports=L.renditionReports||[],L.renditionReports.push(De);break}default:g.logger.warn("line parsed but not handled: "+w);break}}}N&&!N.relurl?(A.pop(),B-=N.duration,L.partList&&(L.fragmentHint=N)):L.partList&&(t(U,N),U.cc=k,L.fragmentHint=U);var Pe=A.length,Ce=A[0],Re=A[Pe-1];if(B+=L.skippedSegments*L.targetduration,B>0&&Pe&&Re){L.averagetargetduration=B/Pe;var Me=Re.sn;L.endSN=Me!=="initSegment"?Me:0,Ce&&(L.startCC=Ce.cc,Ce.initSegment||L.fragments.every(function(Ie){return Ie.relurl&&e(Ie.relurl)})&&(g.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),U=new b.Fragment(s,c),U.relurl=Re.relurl,U.level=o,U.sn="initSegment",Ce.initSegment=U,L.needSidxRanges=!0))}else L.endSN=0,L.startCC=0;return L.fragmentHint&&(B+=L.fragmentHint.duration),L.totalduration=B,L.endCC=k,H>0&&n(A,H),L},E}();function l(E,u){["video","audio","text"].forEach(function(d){var c=E.filter(function(s){return Object(x.isCodecType)(s,d)});if(c.length){var o=c.filter(function(s){return s.lastIndexOf("avc1",0)===0||s.lastIndexOf("mp4a",0)===0});u[d+"Codec"]=o.length>0?o[0]:c[0],E=E.filter(function(s){return c.indexOf(s)===-1})}}),u.unknownCodecs=E}function h(E,u,d){var c=u[d];c&&(E[d]=c)}function n(E,u){for(var d=E[u],c=u;c--;){var o=E[c];if(!o)return;o.programDateTime=d.programDateTime-o.duration*1e3,d=o}}function t(E,u){E.rawProgramDateTime?E.programDateTime=Date.parse(E.rawProgramDateTime):u!=null&&u.programDateTime&&(E.programDateTime=u.endProgramDateTime),Object(T.isFiniteNumber)(E.programDateTime)||(E.programDateTime=null,E.rawProgramDateTime=null)}function i(E,u,d,c){E.relurl=u.URI,u.BYTERANGE&&E.setByteRange(u.BYTERANGE),E.level=d,E.sn="initSegment",c&&(E.levelkey=c),E.initSegment=null}},"./src/loader/playlist-loader.ts":function(K,M,D){D.r(M);var T=D("./src/polyfills/number.ts"),R=D("./src/events.ts"),O=D("./src/errors.ts"),b=D("./src/utils/logger.ts"),C=D("./src/utils/mp4-tools.ts"),I=D("./src/loader/m3u8-parser.ts"),S=D("./src/types/loader.ts"),g=D("./src/utils/attr-list.ts");function x(v){var f=v.type;switch(f){case S.PlaylistContextType.AUDIO_TRACK:return S.PlaylistLevelType.AUDIO;case S.PlaylistContextType.SUBTITLE_TRACK:return S.PlaylistLevelType.SUBTITLE;default:return S.PlaylistLevelType.MAIN}}function p(v,f){var r=v.url;return(r===void 0||r.indexOf("data:")===0)&&(r=f.url),r}var m=function(){function v(r){this.hls=void 0,this.loaders=Object.create(null),this.hls=r,this.registerListeners()}var f=v.prototype;return f.registerListeners=function(){var e=this.hls;e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(R.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},f.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(R.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},f.createInternalLoader=function(e){var a=this.hls.config,l=a.pLoader,h=a.loader,n=l||h,t=new n(a);return e.loader=t,this.loaders[e.type]=t,t},f.getInternalLoader=function(e){return this.loaders[e.type]},f.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},f.destroyInternalLoaders=function(){for(var e in this.loaders){var a=this.loaders[e];a&&a.destroy(),this.resetInternalLoader(e)}},f.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},f.onManifestLoading=function(e,a){var l=a.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:S.PlaylistContextType.MANIFEST,url:l,deliveryDirectives:null})},f.onLevelLoading=function(e,a){var l=a.id,h=a.level,n=a.url,t=a.deliveryDirectives;this.load({id:l,groupId:null,level:h,responseType:"text",type:S.PlaylistContextType.LEVEL,url:n,deliveryDirectives:t})},f.onAudioTrackLoading=function(e,a){var l=a.id,h=a.groupId,n=a.url,t=a.deliveryDirectives;this.load({id:l,groupId:h,level:null,responseType:"text",type:S.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:t})},f.onSubtitleTrackLoading=function(e,a){var l=a.id,h=a.groupId,n=a.url,t=a.deliveryDirectives;this.load({id:l,groupId:h,level:null,responseType:"text",type:S.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:t})},f.load=function(e){var a,l=this.hls.config,h=this.getInternalLoader(e);if(h){var n=h.context;if(n&&n.url===e.url){b.logger.trace("[playlist-loader]: playlist request ongoing");return}b.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),h.abort()}var t,i,E,u;switch(e.type){case S.PlaylistContextType.MANIFEST:t=l.manifestLoadingMaxRetry,i=l.manifestLoadingTimeOut,E=l.manifestLoadingRetryDelay,u=l.manifestLoadingMaxRetryTimeout;break;case S.PlaylistContextType.LEVEL:case S.PlaylistContextType.AUDIO_TRACK:case S.PlaylistContextType.SUBTITLE_TRACK:t=0,i=l.levelLoadingTimeOut;break;default:t=l.levelLoadingMaxRetry,i=l.levelLoadingTimeOut,E=l.levelLoadingRetryDelay,u=l.levelLoadingMaxRetryTimeout;break}if(h=this.createInternalLoader(e),(a=e.deliveryDirectives)!==null&&a!==void 0&&a.part){var d;if(e.type===S.PlaylistContextType.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===S.PlaylistContextType.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===S.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){var c=d.partTarget,o=d.targetduration;c&&o&&(i=Math.min(Math.max(c*3,o*.8)*1e3,i))}}var s={timeout:i,maxRetry:t,retryDelay:E,maxRetryDelay:u,highWaterMark:0},y={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};h.load(e,s,y)},f.loadsuccess=function(e,a,l,h){if(h===void 0&&(h=null),l.isSidxRequest){this.handleSidxRequest(e,l),this.handlePlaylistLoaded(e,a,l,h);return}this.resetInternalLoader(l.type);var n=e.data;if(n.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,l,"no EXTM3U delimiter",h);return}a.parsing.start=performance.now(),n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,a,l,h):this.handleMasterPlaylist(e,a,l,h)},f.loaderror=function(e,a,l){l===void 0&&(l=null),this.handleNetworkError(a,l,!1,e)},f.loadtimeout=function(e,a,l){l===void 0&&(l=null),this.handleNetworkError(a,l,!0)},f.handleMasterPlaylist=function(e,a,l,h){var n=this.hls,t=e.data,i=p(e,l),E=I.default.parseMasterPlaylist(t,i),u=E.levels,d=E.sessionData;if(!u.length){this.handleManifestParsingError(e,l,"no level found in manifest",h);return}var c=u.map(function(P){return{id:P.attrs.AUDIO,audioCodec:P.audioCodec}}),o=u.map(function(P){return{id:P.attrs.SUBTITLES,textCodec:P.textCodec}}),s=I.default.parseMasterPlaylistMedia(t,i,"AUDIO",c),y=I.default.parseMasterPlaylistMedia(t,i,"SUBTITLES",o),L=I.default.parseMasterPlaylistMedia(t,i,"CLOSED-CAPTIONS");if(s.length){var A=s.some(function(P){return!P.url});!A&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(b.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),s.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new g.AttrList({}),bitrate:0,url:""}))}n.trigger(R.Events.MANIFEST_LOADED,{levels:u,audioTracks:s,subtitles:y,captions:L,url:i,stats:a,networkDetails:h,sessionData:d})},f.handleTrackOrLevelPlaylist=function(e,a,l,h){var n=this.hls,t=l.id,i=l.level,E=l.type,u=p(e,l),d=Object(T.isFiniteNumber)(t)?t:0,c=Object(T.isFiniteNumber)(i)?i:d,o=x(l),s=I.default.parseLevelPlaylist(e.data,u,c,o,d);if(!s.fragments.length){n.trigger(R.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof l.level=="number"?l.level:void 0});return}if(E===S.PlaylistContextType.MANIFEST){var y={attrs:new g.AttrList({}),bitrate:0,details:s,name:"",url:u};n.trigger(R.Events.MANIFEST_LOADED,{levels:[y],audioTracks:[],url:u,stats:a,networkDetails:h,sessionData:null})}if(a.parsing.end=performance.now(),s.needSidxRanges){var L,A=(L=s.fragments[0].initSegment)===null||L===void 0?void 0:L.url;this.load({url:A,isSidxRequest:!0,type:E,level:i,levelDetails:s,id:t,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}l.levelDetails=s,this.handlePlaylistLoaded(e,a,l,h)},f.handleSidxRequest=function(e,a){var l=new Uint8Array(e.data),h=Object(C.findBox)(l,["sidx"])[0];if(!!h){var n=Object(C.parseSegmentIndex)(h);if(!!n){var t=n.references,i=a.levelDetails;t.forEach(function(E,u){var d=E.info,c=i.fragments[u];if(c.byteRange.length===0&&c.setByteRange(String(1+d.end-d.start)+"@"+String(d.start)),c.initSegment){var o=Object(C.findBox)(l,["moov"])[0],s=o?o.length:null;c.initSegment.setByteRange(String(s)+"@0")}})}}},f.handleManifestParsingError=function(e,a,l,h){this.hls.trigger(R.Events.ERROR,{type:O.ErrorTypes.NETWORK_ERROR,details:O.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:a.type===S.PlaylistContextType.MANIFEST,url:e.url,reason:l,response:e,context:a,networkDetails:h})},f.handleNetworkError=function(e,a,l,h){l===void 0&&(l=!1),b.logger.warn("[playlist-loader]: A network "+(l?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var n=O.ErrorDetails.UNKNOWN,t=!1,i=this.getInternalLoader(e);switch(e.type){case S.PlaylistContextType.MANIFEST:n=l?O.ErrorDetails.MANIFEST_LOAD_TIMEOUT:O.ErrorDetails.MANIFEST_LOAD_ERROR,t=!0;break;case S.PlaylistContextType.LEVEL:n=l?O.ErrorDetails.LEVEL_LOAD_TIMEOUT:O.ErrorDetails.LEVEL_LOAD_ERROR,t=!1;break;case S.PlaylistContextType.AUDIO_TRACK:n=l?O.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:O.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,t=!1;break;case S.PlaylistContextType.SUBTITLE_TRACK:n=l?O.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:O.ErrorDetails.SUBTITLE_LOAD_ERROR,t=!1;break}i&&this.resetInternalLoader(e.type);var E={type:O.ErrorTypes.NETWORK_ERROR,details:n,fatal:t,url:e.url,loader:i,context:e,networkDetails:a};h&&(E.response=h),this.hls.trigger(R.Events.ERROR,E)},f.handlePlaylistLoaded=function(e,a,l,h){var n=l.type,t=l.level,i=l.id,E=l.groupId,u=l.loader,d=l.levelDetails,c=l.deliveryDirectives;if(!(d!=null&&d.targetduration)){this.handleManifestParsingError(e,l,"invalid target duration",h);return}if(!!u)switch(d.live&&(u.getCacheAge&&(d.ageHeader=u.getCacheAge()||0),(!u.getCacheAge||isNaN(d.ageHeader))&&(d.ageHeader=0)),n){case S.PlaylistContextType.MANIFEST:case S.PlaylistContextType.LEVEL:this.hls.trigger(R.Events.LEVEL_LOADED,{details:d,level:t||0,id:i||0,stats:a,networkDetails:h,deliveryDirectives:c});break;case S.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(R.Events.AUDIO_TRACK_LOADED,{details:d,id:i||0,groupId:E||"",stats:a,networkDetails:h,deliveryDirectives:c});break;case S.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADED,{details:d,id:i||0,groupId:E||"",stats:a,networkDetails:h,deliveryDirectives:c});break}},v}();M.default=m},"./src/polyfills/number.ts":function(K,M,D){D.r(M),D.d(M,"isFiniteNumber",function(){return T}),D.d(M,"MAX_SAFE_INTEGER",function(){return R});var T=Number.isFinite||function(O){return typeof O=="number"&&isFinite(O)},R=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(K,M,D){D.r(M);var T=function(){function R(){}return R.getSilentFrame=function(b,C){switch(b){case"mp4a.40.2":if(C===1)return new Uint8Array([0,200,0,128,35,128]);if(C===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(C===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(C===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(C===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]);if(C===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(C===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]);if(C===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]);if(C===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}},R}();M.default=T},"./src/remux/mp4-generator.ts":function(K,M,D){D.r(M);var T=Math.pow(2,32)-1,R=function(){function O(){}return O.init=function(){O.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 C;for(C in O.types)O.types.hasOwnProperty(C)&&(O.types[C]=[C.charCodeAt(0),C.charCodeAt(1),C.charCodeAt(2),C.charCodeAt(3)]);var I=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]),S=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]);O.HDLR_TYPES={video:I,audio:S};var g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);O.STTS=O.STSC=O.STCO=x,O.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),O.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),O.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),O.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var p=new Uint8Array([105,115,111,109]),m=new Uint8Array([97,118,99,49]),v=new Uint8Array([0,0,0,1]);O.FTYP=O.box(O.types.ftyp,p,v,p,m),O.DINF=O.box(O.types.dinf,O.box(O.types.dref,g))},O.box=function(C){for(var I=8,S=arguments.length,g=new Array(S>1?S-1:0),x=1;x<S;x++)g[x-1]=arguments[x];for(var p=g.length,m=p;p--;)I+=g[p].byteLength;var v=new Uint8Array(I);for(v[0]=I>>24&255,v[1]=I>>16&255,v[2]=I>>8&255,v[3]=I&255,v.set(C,4),p=0,I=8;p<m;p++)v.set(g[p],I),I+=g[p].byteLength;return v},O.hdlr=function(C){return O.box(O.types.hdlr,O.HDLR_TYPES[C])},O.mdat=function(C){return O.box(O.types.mdat,C)},O.mdhd=function(C,I){I*=C;var S=Math.floor(I/(T+1)),g=Math.floor(I%(T+1));return O.box(O.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,C>>24&255,C>>16&255,C>>8&255,C&255,S>>24,S>>16&255,S>>8&255,S&255,g>>24,g>>16&255,g>>8&255,g&255,85,196,0,0]))},O.mdia=function(C){return O.box(O.types.mdia,O.mdhd(C.timescale,C.duration),O.hdlr(C.type),O.minf(C))},O.mfhd=function(C){return O.box(O.types.mfhd,new Uint8Array([0,0,0,0,C>>24,C>>16&255,C>>8&255,C&255]))},O.minf=function(C){return C.type==="audio"?O.box(O.types.minf,O.box(O.types.smhd,O.SMHD),O.DINF,O.stbl(C)):O.box(O.types.minf,O.box(O.types.vmhd,O.VMHD),O.DINF,O.stbl(C))},O.moof=function(C,I,S){return O.box(O.types.moof,O.mfhd(C),O.traf(S,I))},O.moov=function(C){for(var I=C.length,S=[];I--;)S[I]=O.trak(C[I]);return O.box.apply(null,[O.types.moov,O.mvhd(C[0].timescale,C[0].duration)].concat(S).concat(O.mvex(C)))},O.mvex=function(C){for(var I=C.length,S=[];I--;)S[I]=O.trex(C[I]);return O.box.apply(null,[O.types.mvex].concat(S))},O.mvhd=function(C,I){I*=C;var S=Math.floor(I/(T+1)),g=Math.floor(I%(T+1)),x=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,C>>24&255,C>>16&255,C>>8&255,C&255,S>>24,S>>16&255,S>>8&255,S&255,g>>24,g>>16&255,g>>8&255,g&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 O.box(O.types.mvhd,x)},O.sdtp=function(C){var I=C.samples||[],S=new Uint8Array(4+I.length),g,x;for(g=0;g<I.length;g++)x=I[g].flags,S[g+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return O.box(O.types.sdtp,S)},O.stbl=function(C){return O.box(O.types.stbl,O.stsd(C),O.box(O.types.stts,O.STTS),O.box(O.types.stsc,O.STSC),O.box(O.types.stsz,O.STSZ),O.box(O.types.stco,O.STCO))},O.avc1=function(C){var I=[],S=[],g,x,p;for(g=0;g<C.sps.length;g++)x=C.sps[g],p=x.byteLength,I.push(p>>>8&255),I.push(p&255),I=I.concat(Array.prototype.slice.call(x));for(g=0;g<C.pps.length;g++)x=C.pps[g],p=x.byteLength,S.push(p>>>8&255),S.push(p&255),S=S.concat(Array.prototype.slice.call(x));var m=O.box(O.types.avcC,new Uint8Array([1,I[3],I[4],I[5],255,224|C.sps.length].concat(I).concat([C.pps.length]).concat(S))),v=C.width,f=C.height,r=C.pixelRatio[0],e=C.pixelRatio[1];return O.box(O.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,v>>8&255,v&255,f>>8&255,f&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]),m,O.box(O.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),O.box(O.types.pasp,new Uint8Array([r>>24,r>>16&255,r>>8&255,r&255,e>>24,e>>16&255,e>>8&255,e&255])))},O.esds=function(C){var I=C.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(C.config).concat([6,1,2]))},O.mp4a=function(C){var I=C.samplerate;return O.box(O.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,C.channelCount,0,16,0,0,0,0,I>>8&255,I&255,0,0]),O.box(O.types.esds,O.esds(C)))},O.mp3=function(C){var I=C.samplerate;return O.box(O.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,C.channelCount,0,16,0,0,0,0,I>>8&255,I&255,0,0]))},O.stsd=function(C){return C.type==="audio"?C.segmentCodec==="mp3"&&C.codec==="mp3"?O.box(O.types.stsd,O.STSD,O.mp3(C)):O.box(O.types.stsd,O.STSD,O.mp4a(C)):O.box(O.types.stsd,O.STSD,O.avc1(C))},O.tkhd=function(C){var I=C.id,S=C.duration*C.timescale,g=C.width,x=C.height,p=Math.floor(S/(T+1)),m=Math.floor(S%(T+1));return O.box(O.types.tkhd,new Uint8Array([1,0,0,7,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,I&255,0,0,0,0,p>>24,p>>16&255,p>>8&255,p&255,m>>24,m>>16&255,m>>8&255,m&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,g>>8&255,g&255,0,0,x>>8&255,x&255,0,0]))},O.traf=function(C,I){var S=O.sdtp(C),g=C.id,x=Math.floor(I/(T+1)),p=Math.floor(I%(T+1));return O.box(O.types.traf,O.box(O.types.tfhd,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])),O.box(O.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,p>>24,p>>16&255,p>>8&255,p&255])),O.trun(C,S.length+16+20+8+16+8+8),S)},O.trak=function(C){return C.duration=C.duration||4294967295,O.box(O.types.trak,O.tkhd(C),O.mdia(C))},O.trex=function(C){var I=C.id;return O.box(O.types.trex,new Uint8Array([0,0,0,0,I>>24,I>>16&255,I>>8&255,I&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},O.trun=function(C,I){var S=C.samples||[],g=S.length,x=12+16*g,p=new Uint8Array(x),m,v,f,r,e,a;for(I+=8+x,p.set([0,0,15,1,g>>>24&255,g>>>16&255,g>>>8&255,g&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255],0),m=0;m<g;m++)v=S[m],f=v.duration,r=v.size,e=v.flags,a=v.cts,p.set([f>>>24&255,f>>>16&255,f>>>8&255,f&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,a>>>24&255,a>>>16&255,a>>>8&255,a&255],12+16*m);return O.box(O.types.trun,p)},O.initSegment=function(C){O.types||O.init();var I=O.moov(C),S=new Uint8Array(O.FTYP.byteLength+I.byteLength);return S.set(O.FTYP),S.set(I,O.FTYP.byteLength),S},O}();R.types=void 0,R.HDLR_TYPES=void 0,R.STTS=void 0,R.STSC=void 0,R.STCO=void 0,R.STSZ=void 0,R.VMHD=void 0,R.SMHD=void 0,R.STSD=void 0,R.FTYP=void 0,R.DINF=void 0,M.default=R},"./src/remux/mp4-remuxer.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return a}),D.d(M,"normalizePts",function(){return l}),D.d(M,"flushTextTrackMetadataCueSamples",function(){return n}),D.d(M,"flushTextTrackUserdataCueSamples",function(){return t});var T=D("./src/polyfills/number.ts"),R=D("./src/remux/aac-helper.ts"),O=D("./src/remux/mp4-generator.ts"),b=D("./src/events.ts"),C=D("./src/errors.ts"),I=D("./src/utils/logger.ts"),S=D("./src/types/loader.ts"),g=D("./src/utils/timescale-conversion.ts");function x(){return x=Object.assign?Object.assign.bind():function(u){for(var d=1;d<arguments.length;d++){var c=arguments[d];for(var o in c)Object.prototype.hasOwnProperty.call(c,o)&&(u[o]=c[o])}return u},x.apply(this,arguments)}var p=10*1e3,m=1024,v=1152,f=null,r=null,e=!1,a=function(){function u(c,o,s,y){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.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=c,this.config=o,this.typeSupported=s,this.ISGenerated=!1,f===null){var L=navigator.userAgent||"",A=L.match(/Chrome\/(\d+)/i);f=A?parseInt(A[1]):0}if(r===null){var P=navigator.userAgent.match(/Safari\/(\d+)/i);r=P?parseInt(P[1]):0}e=!(!!f&&f>=75||!!r&&r>=600)}var d=u.prototype;return d.destroy=function(){},d.resetTimeStamp=function(o){I.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=o},d.resetNextTimestamp=function(){I.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},d.resetInitSegment=function(){I.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},d.getVideoStartPts=function(o){var s=!1,y=o.reduce(function(L,A){var P=A.pts-L;return P<-4294967296?(s=!0,l(L,A.pts)):P>0?L:A.pts},o[0].pts);return s&&I.logger.debug("PTS rollover detected"),y},d.remux=function(o,s,y,L,A,P,_,F){var B,k,N,U,w,W,j=A,H=A,G=o.pid>-1,Y=s.pid>-1,X=s.samples.length,z=o.samples.length>0,V=_&&X>0||X>1,$=(!G||z)&&(!Y||V)||this.ISGenerated||_;if($){this.ISGenerated||(N=this.generateIS(o,s,A));var Q=this.isVideoContiguous,J=-1,Z;if(V&&(J=h(s.samples),!Q&&this.config.forceKeyFrameOnDiscontinuity))if(W=!0,J>0){I.logger.warn("[mp4-remuxer]: Dropped "+J+" out of "+X+" video samples due to a missing keyframe");var q=this.getVideoStartPts(s.samples);s.samples=s.samples.slice(J),s.dropped+=J,H+=(s.samples[0].pts-q)/s.inputTimeScale,Z=H}else J===-1&&(I.logger.warn("[mp4-remuxer]: No keyframe found out of "+X+" video samples"),W=!1);if(this.ISGenerated){if(z&&V){var ee=this.getVideoStartPts(s.samples),te=l(o.samples[0].pts,ee)-ee,re=te/s.inputTimeScale;j+=Math.max(0,re),H+=Math.max(0,-re)}if(z){if(o.samplerate||(I.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),N=this.generateIS(o,s,A)),k=this.remuxAudio(o,j,this.isAudioContiguous,P,Y||V||F===S.PlaylistLevelType.AUDIO?H:void 0),V){var oe=k?k.endPTS-k.startPTS:0;s.inputTimeScale||(I.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),N=this.generateIS(o,s,A)),B=this.remuxVideo(s,H,Q,oe)}}else V&&(B=this.remuxVideo(s,H,Q,0));B&&(B.firstKeyFrame=J,B.independent=J!==-1,B.firstKeyFramePTS=Z)}}return this.ISGenerated&&(y.samples.length&&(w=n(y,A,this._initPTS,this._initDTS)),L.samples.length&&(U=t(L,A,this._initPTS))),{audio:k,video:B,initSegment:N,independent:W,text:U,id3:w}},d.generateIS=function(o,s,y){var L=o.samples,A=s.samples,P=this.typeSupported,_={},F=!Object(T.isFiniteNumber)(this._initPTS),B="audio/mp4",k,N,U;if(F&&(k=N=1/0),o.config&&L.length){switch(o.timescale=o.samplerate,o.segmentCodec){case"mp3":P.mpeg?(B="audio/mpeg",o.codec=""):P.mp3&&(o.codec="mp3");break}_.audio={id:"audio",container:B,codec:o.codec,initSegment:o.segmentCodec==="mp3"&&P.mpeg?new Uint8Array(0):O.default.initSegment([o]),metadata:{channelCount:o.channelCount}},F&&(U=o.inputTimeScale,k=N=L[0].pts-Math.round(U*y))}if(s.sps&&s.pps&&A.length&&(s.timescale=s.inputTimeScale,_.video={id:"main",container:"video/mp4",codec:s.codec,initSegment:O.default.initSegment([s]),metadata:{width:s.width,height:s.height}},F)){U=s.inputTimeScale;var w=this.getVideoStartPts(A),W=Math.round(U*y);N=Math.min(N,l(A[0].dts,w)-W),k=Math.min(k,w-W)}if(Object.keys(_).length)return this.ISGenerated=!0,F&&(this._initPTS=k,this._initDTS=N),{tracks:_,initPTS:k,timescale:U}},d.remuxVideo=function(o,s,y,L){var A=o.inputTimeScale,P=o.samples,_=[],F=P.length,B=this._initPTS,k=this.nextAvcDts,N=8,U=this.videoSampleDuration,w,W,j=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,G=0,Y=!1;if(!y||k===null){var X=s*A,z=P[0].pts-l(P[0].dts,P[0].pts);k=X-z}for(var V=0;V<F;V++){var $=P[V];if($.pts=l($.pts-B,k),$.dts=l($.dts-B,k),$.dts>$.pts){var Q=18e3;G=Math.max(Math.min(G,$.pts-$.dts),-1*Q)}$.dts<P[V>0?V-1:V].dts&&(Y=!0)}Y&&P.sort(function(_e,Ne){var Xe=_e.dts-Ne.dts,Qe=_e.pts-Ne.pts;return Xe||Qe}),w=P[0].dts,W=P[P.length-1].dts;var J=W-w,Z=J?Math.round(J/(F-1)):U||o.inputTimeScale/30;if(G<0){if(G<Z*-2){I.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(g.toMsFromMpegTsClock)(-Z,!0)+" ms");for(var q=G,ee=0;ee<F;ee++)P[ee].dts=q=Math.max(q,P[ee].pts-Z),P[ee].pts=Math.max(q,P[ee].pts)}else{I.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(g.toMsFromMpegTsClock)(G,!0)+" ms to overcome this issue");for(var te=0;te<F;te++)P[te].dts=P[te].dts+G}w=P[0].dts}if(y){var re=w-k,oe=re>Z,de=re<-1;if(oe||de){oe?I.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(re,!0)+" ms ("+re+"dts) hole between fragments detected, filling it"):I.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(-re,!0)+" ms ("+re+"dts) overlapping between fragments detected"),w=k;var he=P[0].pts-re;P[0].dts=w,P[0].pts=he,I.logger.log("Video: First PTS/DTS adjusted: "+Object(g.toMsFromMpegTsClock)(he,!0)+"/"+Object(g.toMsFromMpegTsClock)(w,!0)+", delta: "+Object(g.toMsFromMpegTsClock)(re,!0)+" ms")}}e&&(w=Math.max(0,w));for(var ae=0,Se=0,ce=0;ce<F;ce++){for(var le=P[ce],pe=le.units,ye=pe.length,Ee=0,ne=0;ne<ye;ne++)Ee+=pe[ne].data.length;Se+=Ee,ae+=ye,le.length=Ee,le.dts=Math.max(le.dts,w),le.pts=Math.max(le.pts,le.dts,0),j=Math.min(le.pts,j),H=Math.max(le.pts,H)}W=P[F-1].dts;var ue=Se+4*ae+8,ve;try{ve=new Uint8Array(ue)}catch{this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:C.ErrorTypes.MUX_ERROR,details:C.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ue,reason:"fail allocating video mdat "+ue});return}var ge=new DataView(ve.buffer);ge.setUint32(0,ue),ve.set(O.default.types.mdat,4);for(var Te=!1,se=0;se<F;se++){for(var me=P[se],Le=me.units,Ae=0,Oe=0,De=Le.length;Oe<De;Oe++){var Pe=Le[Oe],Ce=Pe.data,Re=Pe.data.byteLength;ge.setUint32(N,Re),N+=4,ve.set(Ce,N),N+=Re,Ae+=4+Re}if(se<F-1)U=P[se+1].dts-me.dts;else{var Me=this.config,Ie=se>0?me.dts-P[se-1].dts:Z;if(Me.stretchShortVideoTrack&&this.nextAudioPts!==null){var He=Math.floor(Me.maxBufferHole*A),Fe=(L?j+L*A:this.nextAudioPts)-me.pts;Fe>He?(U=Fe-Ie,U<0?U=Ie:Te=!0,I.logger.log("[mp4-remuxer]: It is approximately "+Fe/90+" ms to the next segment; using duration "+U/90+" ms for the last video frame.")):U=Ie}else U=Ie}var Ve=Math.round(me.pts-me.dts);_.push(new i(me.key,U,Ae,Ve))}if(_.length&&f&&f<70){var Ue=_[0].flags;Ue.dependsOn=2,Ue.isNonSync=0}console.assert(U!==null,"mp4SampleDuration must be computed"),U=Te||!U?Z:U,this.nextAvcDts=k=W+U,this.videoSampleDuration=U,this.isVideoContiguous=!0;var ze=O.default.moof(o.sequenceNumber++,w,x({},o,{samples:_})),$e="video",Ye={data1:ze,data2:ve,startPTS:j/A,endPTS:(H+U)/A,startDTS:w/A,endDTS:k/A,type:$e,hasAudio:!1,hasVideo:!0,nb:_.length,dropped:o.dropped};return o.samples=[],o.dropped=0,console.assert(ve.length,"MDAT length must not be zero"),Ye},d.remuxAudio=function(o,s,y,L,A){var P=o.inputTimeScale,_=o.samplerate?o.samplerate:P,F=P/_,B=o.segmentCodec==="aac"?m:v,k=B*F,N=this._initPTS,U=o.segmentCodec==="mp3"&&this.typeSupported.mpeg,w=[],W=A!==void 0,j=o.samples,H=U?0:8,G=this.nextAudioPts||-1,Y=s*P;if(this.isAudioContiguous=y=y||j.length&&G>0&&(L&&Math.abs(Y-G)<9e3||Math.abs(l(j[0].pts-N,Y)-G)<20*k),j.forEach(function(De){De.pts=l(De.pts-N,Y)}),!y||G<0){if(j=j.filter(function(De){return De.pts>=0}),!j.length)return;A===0?G=0:L&&!W?G=Math.max(0,Y):G=j[0].pts}if(o.segmentCodec==="aac")for(var X=this.config.maxAudioFramesDrift,z=0,V=G;z<j.length;z++){var $=j[z],Q=$.pts,J=Q-V,Z=Math.abs(1e3*J/P);if(J<=-X*k&&W)z===0&&(I.logger.warn("Audio frame @ "+(Q/P).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*J/P)+" ms."),this.nextAudioPts=G=V=Q);else if(J>=X*k&&Z<p&&W){var q=Math.round(J/k);V=Q-q*k,V<0&&(q--,V+=k),z===0&&(this.nextAudioPts=G=V),I.logger.warn("[mp4-remuxer]: Injecting "+q+" audio frame @ "+(V/P).toFixed(3)+"s due to "+Math.round(1e3*J/P)+" ms gap.");for(var ee=0;ee<q;ee++){var te=Math.max(V,0),re=R.default.getSilentFrame(o.manifestCodec||o.codec,o.channelCount);re||(I.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),re=$.unit.subarray()),j.splice(z,0,{unit:re,pts:te}),V+=k,z++}}$.pts=V,V+=k}for(var oe=null,de=null,he,ae=0,Se=j.length;Se--;)ae+=j[Se].unit.byteLength;for(var ce=0,le=j.length;ce<le;ce++){var pe=j[ce],ye=pe.unit,Ee=pe.pts;if(de!==null){var ne=w[ce-1];ne.duration=Math.round((Ee-de)/F)}else if(y&&o.segmentCodec==="aac"&&(Ee=G),oe=Ee,ae>0){ae+=H;try{he=new Uint8Array(ae)}catch{this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:C.ErrorTypes.MUX_ERROR,details:C.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ae,reason:"fail allocating audio mdat "+ae});return}if(!U){var ue=new DataView(he.buffer);ue.setUint32(0,ae),he.set(O.default.types.mdat,4)}}else return;he.set(ye,H);var ve=ye.byteLength;H+=ve,w.push(new i(!0,B,ve,0)),de=Ee}var ge=w.length;if(!!ge){var Te=w[w.length-1];this.nextAudioPts=G=de+F*Te.duration;var se=U?new Uint8Array(0):O.default.moof(o.sequenceNumber++,oe/F,x({},o,{samples:w}));o.samples=[];var me=oe/P,Le=G/P,Ae="audio",Oe={data1:se,data2:he,startPTS:me,endPTS:Le,startDTS:me,endDTS:Le,type:Ae,hasAudio:!0,hasVideo:!1,nb:ge};return this.isAudioContiguous=!0,console.assert(he.length,"MDAT length must not be zero"),Oe}},d.remuxEmptyAudio=function(o,s,y,L){var A=o.inputTimeScale,P=o.samplerate?o.samplerate:A,_=A/P,F=this.nextAudioPts,B=(F!==null?F:L.startDTS*A)+this._initDTS,k=L.endDTS*A+this._initDTS,N=_*m,U=Math.ceil((k-B)/N),w=R.default.getSilentFrame(o.manifestCodec||o.codec,o.channelCount);if(I.logger.warn("[mp4-remuxer]: remux empty Audio"),!w){I.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var W=[],j=0;j<U;j++){var H=B+j*N;W.push({unit:w,pts:H,dts:H})}return o.samples=W,this.remuxAudio(o,s,y,!1)},u}();function l(u,d){var c;if(d===null)return u;for(d<u?c=-8589934592:c=8589934592;Math.abs(u-d)>4294967296;)u+=c;return u}function h(u){for(var d=0;d<u.length;d++)if(u[d].key)return d;return-1}function n(u,d,c,o){var s=u.samples.length;if(!!s){for(var y=u.inputTimeScale,L=0;L<s;L++){var A=u.samples[L];A.pts=l(A.pts-c,d*y)/y,A.dts=l(A.dts-o,d*y)/y}var P=u.samples;return u.samples=[],{samples:P}}}function t(u,d,c){var o=u.samples.length;if(!!o){for(var s=u.inputTimeScale,y=0;y<o;y++){var L=u.samples[y];L.pts=l(L.pts-c,d*s)/s}u.samples.sort(function(P,_){return P.pts-_.pts});var A=u.samples;return u.samples=[],{samples:A}}}var i=function(d,c,o,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=c,this.size=o,this.cts=s,this.flags=new E(d)},E=function(d){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=d?2:1,this.isNonSync=d?0:1}},"./src/remux/passthrough-remuxer.ts":function(K,M,D){D.r(M);var T=D("./src/polyfills/number.ts"),R=D("./src/remux/mp4-remuxer.ts"),O=D("./src/utils/mp4-tools.ts"),b=D("./src/loader/fragment.ts"),C=D("./src/utils/logger.ts"),I=function(){function x(){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 p=x.prototype;return p.destroy=function(){},p.resetTimeStamp=function(v){this.initPTS=v,this.lastEndDTS=null},p.resetNextTimestamp=function(){this.lastEndDTS=null},p.resetInitSegment=function(v,f,r){this.audioCodec=f,this.videoCodec=r,this.generateInitSegment(v),this.emitInitSegment=!0},p.generateInitSegment=function(v){var f=this.audioCodec,r=this.videoCodec;if(!v||!v.byteLength){this.initTracks=void 0,this.initData=void 0;return}var e=this.initData=Object(O.parseInitSegment)(v);f||(f=g(e.audio,b.ElementaryStreamTypes.AUDIO)),r||(r=g(e.video,b.ElementaryStreamTypes.VIDEO));var a={};e.audio&&e.video?a.audiovideo={container:"video/mp4",codec:f+","+r,initSegment:v,id:"main"}:e.audio?a.audio={container:"audio/mp4",codec:f,initSegment:v,id:"audio"}:e.video?a.video={container:"video/mp4",codec:r,initSegment:v,id:"main"}:C.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},p.remux=function(v,f,r,e,a){var l,h=this.initPTS,n=this.lastEndDTS,t={audio:void 0,video:void 0,text:e,id3:r,initSegment:void 0};Object(T.isFiniteNumber)(n)||(n=this.lastEndDTS=a||0);var i=f.samples;if(!i||!i.length)return t;var E={initPTS:void 0,timescale:1},u=this.initData;if((!u||!u.length)&&(this.generateInitSegment(i),u=this.initData),!u||!u.length)return C.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),t;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1),Object(T.isFiniteNumber)(h)||(this.initPTS=E.initPTS=h=S(u,i,n));var d=Object(O.getDuration)(i,u),c=n,o=d+c;Object(O.offsetStartDTS)(u,i,h),d>0?this.lastEndDTS=o:(C.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var s=!!u.audio,y=!!u.video,L="";s&&(L+="audio"),y&&(L+="video");var A={data1:i,startPTS:c,startDTS:c,endPTS:o,endDTS:o,type:L,hasAudio:s,hasVideo:y,nb:1,dropped:0};t.audio=A.type==="audio"?A:void 0,t.video=A.type!=="audio"?A:void 0,t.initSegment=E;var P=(l=this.initPTS)!=null?l:0;return t.id3=Object(R.flushTextTrackMetadataCueSamples)(r,a,P,P),e.samples.length&&(t.text=Object(R.flushTextTrackUserdataCueSamples)(e,a,P)),t},x}(),S=function(p,m,v){return Object(O.getStartDTS)(p,m)-v};function g(x,p){var m=x==null?void 0:x.codec;return m&&m.length>4?m:m==="hvc1"||m==="hev1"?"hvc1.1.c.L120.90":m==="av01"?"av01.0.04M.08":m==="avc1"||p===b.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}M.default=I},"./src/task-loop.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return T});var T=function(){function R(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var O=R.prototype;return O.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},O.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},O.onHandlerDestroyed=function(){},O.hasInterval=function(){return!!this._tickInterval},O.hasNextTick=function(){return!!this._tickTimer},O.setInterval=function(C){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,C),!0)},O.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},O.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},O.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},O.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},O.doTick=function(){},R}()},"./src/types/cmcd.ts":function(K,M,D){D.r(M),D.d(M,"CMCDVersion",function(){return T}),D.d(M,"CMCDObjectType",function(){return R}),D.d(M,"CMCDStreamingFormat",function(){return O}),D.d(M,"CMCDStreamType",function(){return b});var T=1,R;(function(C){C.MANIFEST="m",C.AUDIO="a",C.VIDEO="v",C.MUXED="av",C.INIT="i",C.CAPTION="c",C.TIMED_TEXT="tt",C.KEY="k",C.OTHER="o"})(R||(R={}));var O;(function(C){C.DASH="d",C.HLS="h",C.SMOOTH="s",C.OTHER="o"})(O||(O={}));var b;(function(C){C.VOD="v",C.LIVE="l"})(b||(b={}))},"./src/types/demuxer.ts":function(K,M,D){D.r(M),D.d(M,"MetadataSchema",function(){return T});var T;(function(R){R.audioId3="org.id3",R.dateRange="com.apple.quicktime.HLS",R.emsg="https://aomedia.org/emsg/ID3"})(T||(T={}))},"./src/types/level.ts":function(K,M,D){D.r(M),D.d(M,"HlsSkip",function(){return O}),D.d(M,"getSkipValue",function(){return b}),D.d(M,"HlsUrlParameters",function(){return C}),D.d(M,"Level",function(){return I});function T(S,g){for(var x=0;x<g.length;x++){var p=g[x];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(S,p.key,p)}}function R(S,g,x){return g&&T(S.prototype,g),x&&T(S,x),Object.defineProperty(S,"prototype",{writable:!1}),S}var O;(function(S){S.No="",S.Yes="YES",S.v2="v2"})(O||(O={}));function b(S,g){var x=S.canSkipUntil,p=S.canSkipDateRanges,m=S.endSN,v=g!==void 0?g-m:0;return x&&v<x?p?O.v2:O.Yes:O.No}var C=function(){function S(x,p,m){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=x,this.part=p,this.skip=m}var g=S.prototype;return g.addDirectives=function(p){var m=new self.URL(p);return this.msn!==void 0&&m.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&m.searchParams.set("_HLS_part",this.part.toString()),this.skip&&m.searchParams.set("_HLS_skip",this.skip),m.toString()},S}(),I=function(){function S(g){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=[g.url],this.attrs=g.attrs,this.bitrate=g.bitrate,g.details&&(this.details=g.details),this.id=g.id||0,this.name=g.name,this.width=g.width||0,this.height=g.height||0,this.audioCodec=g.audioCodec,this.videoCodec=g.videoCodec,this.unknownCodecs=g.unknownCodecs,this.codecSet=[g.videoCodec,g.audioCodec].filter(function(x){return x}).join(",").replace(/\.[^.,]+/g,"")}return R(S,[{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(x){var p=x%this.url.length;this._urlId!==p&&(this.details=void 0,this._urlId=p)}}]),S}()},"./src/types/loader.ts":function(K,M,D){D.r(M),D.d(M,"PlaylistContextType",function(){return T}),D.d(M,"PlaylistLevelType",function(){return R});var T;(function(O){O.MANIFEST="manifest",O.LEVEL="level",O.AUDIO_TRACK="audioTrack",O.SUBTITLE_TRACK="subtitleTrack"})(T||(T={}));var R;(function(O){O.MAIN="main",O.AUDIO="audio",O.SUBTITLE="subtitle"})(R||(R={}))},"./src/types/transmuxer.ts":function(K,M,D){D.r(M),D.d(M,"ChunkMetadata",function(){return T});var T=function(b,C,I,S,g,x){S===void 0&&(S=0),g===void 0&&(g=-1),x===void 0&&(x=!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=R(),this.buffering={audio:R(),video:R(),audiovideo:R()},this.level=b,this.sn=C,this.id=I,this.size=S,this.part=g,this.partial=x};function R(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(K,M,D){D.r(M),D.d(M,"AttrList",function(){return O});var T=/^(\d+)x(\d+)$/,R=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,O=function(){function b(I){typeof I=="string"&&(I=b.parseAttrList(I));for(var S in I)I.hasOwnProperty(S)&&(this[S]=I[S])}var C=b.prototype;return C.decimalInteger=function(S){var g=parseInt(this[S],10);return g>Number.MAX_SAFE_INTEGER?1/0:g},C.hexadecimalInteger=function(S){if(this[S]){var g=(this[S]||"0x").slice(2);g=(g.length&1?"0":"")+g;for(var x=new Uint8Array(g.length/2),p=0;p<g.length/2;p++)x[p]=parseInt(g.slice(p*2,p*2+2),16);return x}else return null},C.hexadecimalIntegerAsNumber=function(S){var g=parseInt(this[S],16);return g>Number.MAX_SAFE_INTEGER?1/0:g},C.decimalFloatingPoint=function(S){return parseFloat(this[S])},C.optionalFloat=function(S,g){var x=this[S];return x?parseFloat(x):g},C.enumeratedString=function(S){return this[S]},C.bool=function(S){return this[S]==="YES"},C.decimalResolution=function(S){var g=T.exec(this[S]);if(g!==null)return{width:parseInt(g[1],10),height:parseInt(g[2],10)}},b.parseAttrList=function(S){var g,x={},p='"';for(R.lastIndex=0;(g=R.exec(S))!==null;){var m=g[2];m.indexOf(p)===0&&m.lastIndexOf(p)===m.length-1&&(m=m.slice(1,-1)),x[g[1]]=m}return x},b}()},"./src/utils/binary-search.ts":function(K,M,D){D.r(M);var T={search:function(O,b){for(var C=0,I=O.length-1,S=null,g=null;C<=I;){S=(C+I)/2|0,g=O[S];var x=b(g);if(x>0)C=S+1;else if(x<0)I=S-1;else return g}return null}};M.default=T},"./src/utils/buffer-helper.ts":function(K,M,D){D.r(M),D.d(M,"BufferHelper",function(){return O});var T=D("./src/utils/logger.ts"),R={length:0,start:function(){return 0},end:function(){return 0}},O=function(){function b(){}return b.isBuffered=function(I,S){try{if(I){for(var g=b.getBuffered(I),x=0;x<g.length;x++)if(S>=g.start(x)&&S<=g.end(x))return!0}}catch{}return!1},b.bufferInfo=function(I,S,g){try{if(I){var x=b.getBuffered(I),p=[],m;for(m=0;m<x.length;m++)p.push({start:x.start(m),end:x.end(m)});return this.bufferedInfo(p,S,g)}}catch{}return{len:0,start:S,end:S,nextStart:void 0}},b.bufferedInfo=function(I,S,g){S=Math.max(0,S),I.sort(function(t,i){var E=t.start-i.start;return E||i.end-t.end});var x=[];if(g)for(var p=0;p<I.length;p++){var m=x.length;if(m){var v=x[m-1].end;I[p].start-v<g?I[p].end>v&&(x[m-1].end=I[p].end):x.push(I[p])}else x.push(I[p])}else x=I;for(var f=0,r,e=S,a=S,l=0;l<x.length;l++){var h=x[l].start,n=x[l].end;if(S+g>=h&&S<n)e=h,a=n,f=a-S;else if(S+g<h){r=h;break}}return{len:f,start:e||0,end:a||0,nextStart:r}},b.getBuffered=function(I){try{return I.buffered}catch(S){return T.logger.log("failed to get media.buffered",S),R}},b}()},"./src/utils/cea-608-parser.ts":function(K,M,D){D.r(M),D.d(M,"Row",function(){return a}),D.d(M,"CaptionScreen",function(){return l});var T=D("./src/utils/logger.ts"),R={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},O=function(d){var c=d;return R.hasOwnProperty(d)&&(c=R[d]),String.fromCharCode(c)},b=15,C=100,I={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},S={17:2,18:4,21:6,22:8,23:10,19:13,20:15},g={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},x={25:2,26:4,29:6,30:8,31:10,27:13,28:15},p=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],m;(function(u){u[u.ERROR=0]="ERROR",u[u.TEXT=1]="TEXT",u[u.WARNING=2]="WARNING",u[u.INFO=2]="INFO",u[u.DEBUG=3]="DEBUG",u[u.DATA=3]="DATA"})(m||(m={}));var v=function(){function u(){this.time=null,this.verboseLevel=m.ERROR}var d=u.prototype;return d.log=function(o,s){this.verboseLevel>=o&&T.logger.log(this.time+" ["+o+"] "+s)},u}(),f=function(d){for(var c=[],o=0;o<d.length;o++)c.push(d[o].toString(16));return c},r=function(){function u(c,o,s,y,L){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=c||"white",this.underline=o||!1,this.italics=s||!1,this.background=y||"black",this.flash=L||!1}var d=u.prototype;return d.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},d.setStyles=function(o){for(var s=["foreground","underline","italics","background","flash"],y=0;y<s.length;y++){var L=s[y];o.hasOwnProperty(L)&&(this[L]=o[L])}},d.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},d.equals=function(o){return this.foreground===o.foreground&&this.underline===o.underline&&this.italics===o.italics&&this.background===o.background&&this.flash===o.flash},d.copy=function(o){this.foreground=o.foreground,this.underline=o.underline,this.italics=o.italics,this.background=o.background,this.flash=o.flash},d.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},u}(),e=function(){function u(c,o,s,y,L,A){this.uchar=void 0,this.penState=void 0,this.uchar=c||" ",this.penState=new r(o,s,y,L,A)}var d=u.prototype;return d.reset=function(){this.uchar=" ",this.penState.reset()},d.setChar=function(o,s){this.uchar=o,this.penState.copy(s)},d.setPenState=function(o){this.penState.copy(o)},d.equals=function(o){return this.uchar===o.uchar&&this.penState.equals(o.penState)},d.copy=function(o){this.uchar=o.uchar,this.penState.copy(o.penState)},d.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},u}(),a=function(){function u(c){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var o=0;o<C;o++)this.chars.push(new e);this.logger=c,this.pos=0,this.currPenState=new r}var d=u.prototype;return d.equals=function(o){for(var s=!0,y=0;y<C;y++)if(!this.chars[y].equals(o.chars[y])){s=!1;break}return s},d.copy=function(o){for(var s=0;s<C;s++)this.chars[s].copy(o.chars[s])},d.isEmpty=function(){for(var o=!0,s=0;s<C;s++)if(!this.chars[s].isEmpty()){o=!1;break}return o},d.setCursor=function(o){this.pos!==o&&(this.pos=o),this.pos<0?(this.logger.log(m.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>C&&(this.logger.log(m.DEBUG,"Too large cursor position "+this.pos),this.pos=C)},d.moveCursor=function(o){var s=this.pos+o;if(o>1)for(var y=this.pos+1;y<s+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(s)},d.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},d.insertChar=function(o){o>=144&&this.backSpace();var s=O(o);if(this.pos>=C){this.logger.log(m.ERROR,"Cannot insert "+o.toString(16)+" ("+s+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(s,this.currPenState),this.moveCursor(1)},d.clearFromPos=function(o){var s;for(s=o;s<C;s++)this.chars[s].reset()},d.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},d.clearToEndOfRow=function(){this.clearFromPos(this.pos)},d.getTextString=function(){for(var o=[],s=!0,y=0;y<C;y++){var L=this.chars[y].uchar;L!==" "&&(s=!1),o.push(L)}return s?"":o.join("")},d.setPenStyles=function(o){this.currPenState.setStyles(o);var s=this.chars[this.pos];s.setPenState(this.currPenState)},u}(),l=function(){function u(c){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var o=0;o<b;o++)this.rows.push(new a(c));this.logger=c,this.currRow=b-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var d=u.prototype;return d.reset=function(){for(var o=0;o<b;o++)this.rows[o].clear();this.currRow=b-1},d.equals=function(o){for(var s=!0,y=0;y<b;y++)if(!this.rows[y].equals(o.rows[y])){s=!1;break}return s},d.copy=function(o){for(var s=0;s<b;s++)this.rows[s].copy(o.rows[s])},d.isEmpty=function(){for(var o=!0,s=0;s<b;s++)if(!this.rows[s].isEmpty()){o=!1;break}return o},d.backSpace=function(){var o=this.rows[this.currRow];o.backSpace()},d.clearToEndOfRow=function(){var o=this.rows[this.currRow];o.clearToEndOfRow()},d.insertChar=function(o){var s=this.rows[this.currRow];s.insertChar(o)},d.setPen=function(o){var s=this.rows[this.currRow];s.setPenStyles(o)},d.moveCursor=function(o){var s=this.rows[this.currRow];s.moveCursor(o)},d.setCursor=function(o){this.logger.log(m.INFO,"setCursor: "+o);var s=this.rows[this.currRow];s.setCursor(o)},d.setPAC=function(o){this.logger.log(m.INFO,"pacData = "+JSON.stringify(o));var s=o.row-1;if(this.nrRollUpRows&&s<this.nrRollUpRows-1&&(s=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==s){for(var y=0;y<b;y++)this.rows[y].clear();var L=this.currRow+1-this.nrRollUpRows,A=this.lastOutputScreen;if(A){var P=A.rows[L].cueStartTime,_=this.logger.time;if(P&&_!==null&&P<_)for(var F=0;F<this.nrRollUpRows;F++)this.rows[s-this.nrRollUpRows+F+1].copy(A.rows[L+F])}}this.currRow=s;var B=this.rows[this.currRow];if(o.indent!==null){var k=o.indent,N=Math.max(k-1,0);B.setCursor(o.indent),o.color=B.chars[N].penState.foreground}var U={foreground:o.color,underline:o.underline,italics:o.italics,background:"black",flash:!1};this.setPen(U)},d.setBkgData=function(o){this.logger.log(m.INFO,"bkgData = "+JSON.stringify(o)),this.backSpace(),this.setPen(o),this.insertChar(32)},d.setRollUpRows=function(o){this.nrRollUpRows=o},d.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(m.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(m.TEXT,this.getDisplayText());var o=this.currRow+1-this.nrRollUpRows,s=this.rows.splice(o,1)[0];s.clear(),this.rows.splice(this.currRow,0,s),this.logger.log(m.INFO,"Rolling up")},d.getDisplayText=function(o){o=o||!1;for(var s=[],y="",L=-1,A=0;A<b;A++){var P=this.rows[A].getTextString();P&&(L=A+1,o?s.push("Row "+L+": '"+P+"'"):s.push(P.trim()))}return s.length>0&&(o?y="["+s.join(" | ")+"]":y=s.join(`
39
+ `)),y},d.getTextAndFormat=function(){return this.rows},u}(),h=function(){function u(c,o,s){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=c,this.outputFilter=o,this.mode=null,this.verbose=0,this.displayedMemory=new l(s),this.nonDisplayedMemory=new l(s),this.lastOutputScreen=new l(s),this.currRollUpRow=this.displayedMemory.rows[b-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}var d=u.prototype;return d.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[b-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},d.getHandler=function(){return this.outputFilter},d.setHandler=function(o){this.outputFilter=o},d.setPAC=function(o){this.writeScreen.setPAC(o)},d.setBkgData=function(o){this.writeScreen.setBkgData(o)},d.setMode=function(o){o!==this.mode&&(this.mode=o,this.logger.log(m.INFO,"MODE="+o),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=o)},d.insertChars=function(o){for(var s=0;s<o.length;s++)this.writeScreen.insertChar(o[s]);var y=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(m.INFO,y+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(m.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},d.ccRCL=function(){this.logger.log(m.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},d.ccBS=function(){this.logger.log(m.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},d.ccAOF=function(){},d.ccAON=function(){},d.ccDER=function(){this.logger.log(m.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},d.ccRU=function(o){this.logger.log(m.INFO,"RU("+o+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(o)},d.ccFON=function(){this.logger.log(m.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},d.ccRDC=function(){this.logger.log(m.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},d.ccTR=function(){this.logger.log(m.INFO,"TR"),this.setMode("MODE_TEXT")},d.ccRTD=function(){this.logger.log(m.INFO,"RTD"),this.setMode("MODE_TEXT")},d.ccEDM=function(){this.logger.log(m.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},d.ccCR=function(){this.logger.log(m.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},d.ccENM=function(){this.logger.log(m.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},d.ccEOC=function(){if(this.logger.log(m.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(m.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},d.ccTO=function(o){this.logger.log(m.INFO,"TO("+o+") - Tab Offset"),this.writeScreen.moveCursor(o)},d.ccMIDROW=function(o){var s={flash:!1};if(s.underline=o%2===1,s.italics=o>=46,s.italics)s.foreground="white";else{var y=Math.floor(o/2)-16,L=["white","green","blue","cyan","red","yellow","magenta"];s.foreground=L[y]}this.logger.log(m.INFO,"MIDROW: "+JSON.stringify(s)),this.writeScreen.setPen(s)},d.outputDataUpdate=function(o){o===void 0&&(o=!1);var s=this.logger.time;s!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=s:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,s,this.lastOutputScreen),o&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:s),this.lastOutputScreen.copy(this.displayedMemory))},d.cueSplitAtTime=function(o){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,o,this.displayedMemory),this.cueStartTime=o))},u}(),n=function(){function u(c,o,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new v;this.channels=[null,new h(c,o,y),new h(c+1,s,y)],this.cmdHistory=E(),this.logger=y}var d=u.prototype;return d.getHandler=function(o){return this.channels[o].getHandler()},d.setHandler=function(o,s){this.channels[o].setHandler(s)},d.addData=function(o,s){var y,L,A,P=!1;this.logger.time=o;for(var _=0;_<s.length;_+=2)if(L=s[_]&127,A=s[_+1]&127,!(L===0&&A===0)){if(this.logger.log(m.DATA,"["+f([s[_],s[_+1]])+"] -> ("+f([L,A])+")"),y=this.parseCmd(L,A),y||(y=this.parseMidrow(L,A)),y||(y=this.parsePAC(L,A)),y||(y=this.parseBackgroundAttributes(L,A)),!y&&(P=this.parseChars(L,A),P)){var F=this.currentChannel;if(F&&F>0){var B=this.channels[F];B.insertChars(P)}else this.logger.log(m.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!P&&this.logger.log(m.WARNING,"Couldn't parse cleaned data "+f([L,A])+" orig: "+f([s[_],s[_+1]]))}},d.parseCmd=function(o,s){var y=this.cmdHistory,L=(o===20||o===28||o===21||o===29)&&s>=32&&s<=47,A=(o===23||o===31)&&s>=33&&s<=35;if(!(L||A))return!1;if(i(o,s,y))return t(null,null,y),this.logger.log(m.DEBUG,"Repeated command ("+f([o,s])+") is dropped"),!0;var P=o===20||o===21||o===23?1:2,_=this.channels[P];return o===20||o===21||o===28||o===29?s===32?_.ccRCL():s===33?_.ccBS():s===34?_.ccAOF():s===35?_.ccAON():s===36?_.ccDER():s===37?_.ccRU(2):s===38?_.ccRU(3):s===39?_.ccRU(4):s===40?_.ccFON():s===41?_.ccRDC():s===42?_.ccTR():s===43?_.ccRTD():s===44?_.ccEDM():s===45?_.ccCR():s===46?_.ccENM():s===47&&_.ccEOC():_.ccTO(s-32),t(o,s,y),this.currentChannel=P,!0},d.parseMidrow=function(o,s){var y=0;if((o===17||o===25)&&s>=32&&s<=47){if(o===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(m.ERROR,"Mismatch channel in midrow parsing"),!1;var L=this.channels[y];return L?(L.ccMIDROW(s),this.logger.log(m.DEBUG,"MIDROW ("+f([o,s])+")"),!0):!1}return!1},d.parsePAC=function(o,s){var y,L=this.cmdHistory,A=(o>=17&&o<=23||o>=25&&o<=31)&&s>=64&&s<=127,P=(o===16||o===24)&&s>=64&&s<=95;if(!(A||P))return!1;if(i(o,s,L))return t(null,null,L),!0;var _=o<=23?1:2;s>=64&&s<=95?y=_===1?I[o]:g[o]:y=_===1?S[o]:x[o];var F=this.channels[_];return F?(F.setPAC(this.interpretPAC(y,s)),t(o,s,L),this.currentChannel=_,!0):!1},d.interpretPAC=function(o,s){var y,L={color:null,italics:!1,indent:null,underline:!1,row:o};return s>95?y=s-96:y=s-64,L.underline=(y&1)===1,y<=13?L.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(L.italics=!0,L.color="white"):L.indent=Math.floor((y-16)/2)*4,L},d.parseChars=function(o,s){var y,L=null,A=null;if(o>=25?(y=2,A=o-8):(y=1,A=o),A>=17&&A<=19){var P;A===17?P=s+80:A===18?P=s+112:P=s+144,this.logger.log(m.INFO,"Special char '"+O(P)+"' in channel "+y),L=[P]}else o>=32&&o<=127&&(L=s===0?[o]:[o,s]);if(L){var _=f(L);this.logger.log(m.DEBUG,"Char codes = "+_.join(",")),t(o,s,this.cmdHistory)}return L},d.parseBackgroundAttributes=function(o,s){var y=(o===16||o===24)&&s>=32&&s<=47,L=(o===23||o===31)&&s>=45&&s<=47;if(!(y||L))return!1;var A,P={};o===16||o===24?(A=Math.floor((s-32)/2),P.background=p[A],s%2===1&&(P.background=P.background+"_semi")):s===45?P.background="transparent":(P.foreground="black",s===47&&(P.underline=!0));var _=o<=23?1:2,F=this.channels[_];return F.setBkgData(P),t(o,s,this.cmdHistory),!0},d.reset=function(){for(var o=0;o<Object.keys(this.channels).length;o++){var s=this.channels[o];s&&s.reset()}this.cmdHistory=E()},d.cueSplitAtTime=function(o){for(var s=0;s<this.channels.length;s++){var y=this.channels[s];y&&y.cueSplitAtTime(o)}},u}();function t(u,d,c){c.a=u,c.b=d}function i(u,d,c){return c.a===u&&c.b===d}function E(){return{a:null,b:null}}M.default=n},"./src/utils/codecs.ts":function(K,M,D){D.r(M),D.d(M,"isCodecType",function(){return R}),D.d(M,"isCodecSupportedInMp4",function(){return O});var T={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 R(b,C){var I=T[C];return!!I&&I[b.slice(0,4)]===!0}function O(b,C){return MediaSource.isTypeSupported((C||"video")+'/mp4;codecs="'+b+'"')}},"./src/utils/cues.ts":function(K,M,D){D.r(M);var T=D("./src/utils/vttparser.ts"),R=D("./src/utils/webvtt-parser.ts"),O=D("./src/utils/texttrack-utils.ts"),b=/\s/,C={newCue:function(S,g,x,p){for(var m=[],v,f,r,e,a,l=self.VTTCue||self.TextTrackCue,h=0;h<p.rows.length;h++)if(v=p.rows[h],r=!0,e=0,a="",!v.isEmpty()){for(var n=0;n<v.chars.length;n++)b.test(v.chars[n].uchar)&&r?e++:(a+=v.chars[n].uchar,r=!1);v.cueStartTime=g,g===x&&(x+=1e-4),e>=16?e--:e++;var t=Object(T.fixLineBreaks)(a.trim()),i=Object(R.generateCueId)(g,x,t);(!S||!S.cues||!S.cues.getCueById(i))&&(f=new l(g,x,t),f.id=i,f.line=h+1,f.align="left",f.position=10+Math.min(80,Math.floor(e*8/32)*10),m.push(f))}return S&&m.length&&(m.sort(function(E,u){return E.line==="auto"||u.line==="auto"?0:E.line>8&&u.line>8?u.line-E.line:E.line-u.line}),m.forEach(function(E){return Object(O.addCueToTrack)(S,E)})),m}};M.default=C},"./src/utils/discontinuities.ts":function(K,M,D){D.r(M),D.d(M,"findFirstFragWithCC",function(){return b}),D.d(M,"shouldAlignOnDiscontinuities",function(){return C}),D.d(M,"findDiscontinuousReferenceFrag",function(){return I}),D.d(M,"adjustSlidingStart",function(){return g}),D.d(M,"alignStream",function(){return x}),D.d(M,"alignPDT",function(){return m}),D.d(M,"alignFragmentByPDTDelta",function(){return v}),D.d(M,"alignMediaPlaylistByPDT",function(){return f});var T=D("./src/polyfills/number.ts"),R=D("./src/utils/logger.ts"),O=D("./src/controller/level-helper.ts");function b(r,e){for(var a=null,l=0,h=r.length;l<h;l++){var n=r[l];if(n&&n.cc===e){a=n;break}}return a}function C(r,e,a){return!!(e.details&&(a.endCC>a.startCC||r&&r.cc<a.startCC))}function I(r,e){var a=r.fragments,l=e.fragments;if(!l.length||!a.length){R.logger.log("No fragments to align");return}var h=b(a,l[0].cc);if(!h||h&&!h.startPTS){R.logger.log("No frag in previous level to align on");return}return h}function S(r,e){if(r){var a=r.start+e;r.start=r.startPTS=a,r.endPTS=a+r.duration}}function g(r,e){for(var a=e.fragments,l=0,h=a.length;l<h;l++)S(a[l],r);e.fragmentHint&&S(e.fragmentHint,r),e.alignedSliding=!0}function x(r,e,a){!e||(p(r,a,e),!a.alignedSliding&&e.details&&m(a,e.details),!a.alignedSliding&&e.details&&!a.skippedSegments&&Object(O.adjustSliding)(e.details,a))}function p(r,e,a){if(C(r,a,e)){var l=I(a.details,e);l&&Object(T.isFiniteNumber)(l.start)&&(R.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),g(l.start,e))}}function m(r,e){if(!(!e.fragments.length||!r.hasProgramDateTime||!e.hasProgramDateTime)){var a=e.fragments[0].programDateTime,l=r.fragments[0].programDateTime,h=(l-a)/1e3+e.fragments[0].start;h&&Object(T.isFiniteNumber)(h)&&(R.logger.log("Adjusting PTS using programDateTime delta "+(l-a)+"ms, sliding:"+h.toFixed(3)+" "+r.url+" "),g(h,r))}}function v(r,e){var a=r.programDateTime;if(!!a){var l=(a-e)/1e3;r.start=r.startPTS=l,r.endPTS=l+r.duration}}function f(r,e){if(!(!e.fragments.length||!r.hasProgramDateTime||!e.hasProgramDateTime)){var a=e.fragments[0].programDateTime,l=e.fragments[0].start,h=a-l*1e3;r.fragments.forEach(function(n){v(n,h)}),r.fragmentHint&&v(r.fragmentHint,h),r.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(K,M,D){D.r(M);var T=D("./src/utils/ewma.ts"),R=function(){function O(C,I,S){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=S,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new T.default(C),this.fast_=new T.default(I)}var b=O.prototype;return b.update=function(I,S){var g=this.slow_,x=this.fast_;this.slow_.halfLife!==I&&(this.slow_=new T.default(I,g.getEstimate(),g.getTotalWeight())),this.fast_.halfLife!==S&&(this.fast_=new T.default(S,x.getEstimate(),x.getTotalWeight()))},b.sample=function(I,S){I=Math.max(I,this.minDelayMs_);var g=8*S,x=I/1e3,p=g/x;this.fast_.sample(x,p),this.slow_.sample(x,p)},b.canEstimate=function(){var I=this.fast_;return I&&I.getTotalWeight()>=this.minWeight_},b.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},b.destroy=function(){},O}();M.default=R},"./src/utils/ewma.ts":function(K,M,D){D.r(M);var T=function(){function R(b,C,I){C===void 0&&(C=0),I===void 0&&(I=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=b,this.alpha_=b?Math.exp(Math.log(.5)/b):0,this.estimate_=C,this.totalWeight_=I}var O=R.prototype;return O.sample=function(C,I){var S=Math.pow(this.alpha_,C);this.estimate_=I*(1-S)+S*this.estimate_,this.totalWeight_+=C},O.getTotalWeight=function(){return this.totalWeight_},O.getEstimate=function(){if(this.alpha_){var C=1-Math.pow(this.alpha_,this.totalWeight_);if(C)return this.estimate_/C}return this.estimate_},R}();M.default=T},"./src/utils/fetch-loader.ts":function(K,M,D){D.r(M),D.d(M,"fetchSupported",function(){return v});var T=D("./src/polyfills/number.ts"),R=D("./src/loader/load-stats.ts"),O=D("./src/demux/chunk-cache.ts");function b(l,h){l.prototype=Object.create(h.prototype),l.prototype.constructor=l,x(l,h)}function C(l){var h=typeof Map=="function"?new Map:void 0;return C=function(t){if(t===null||!g(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof h<"u"){if(h.has(t))return h.get(t);h.set(t,i)}function i(){return I(t,arguments,p(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),x(i,t)},C(l)}function I(l,h,n){return S()?I=Reflect.construct.bind():I=function(i,E,u){var d=[null];d.push.apply(d,E);var c=Function.bind.apply(i,d),o=new c;return u&&x(o,u.prototype),o},I.apply(null,arguments)}function S(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function g(l){return Function.toString.call(l).indexOf("[native code]")!==-1}function x(l,h){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},x(l,h)}function p(l){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},p(l)}function m(){return m=Object.assign?Object.assign.bind():function(l){for(var h=1;h<arguments.length;h++){var n=arguments[h];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(l[t]=n[t])}return l},m.apply(this,arguments)}function v(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var f=function(){function l(n){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=n.fetchSetup||e,this.controller=new self.AbortController,this.stats=new R.LoadStats}var h=l.prototype;return h.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},h.abortInternal=function(){var t=this.response;(!t||!t.ok)&&(this.stats.aborted=!0,this.controller.abort())},h.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!==null&&t!==void 0&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},h.load=function(t,i,E){var u=this,d=this.stats;if(d.loading.start)throw new Error("Loader can only be used once.");d.loading.start=self.performance.now();var c=r(t,this.controller.signal),o=E.onProgress,s=t.responseType==="arraybuffer",y=s?"byteLength":"length";this.context=t,this.config=i,this.callbacks=E,this.request=this.fetchSetup(t,c),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){u.abortInternal(),E.onTimeout(d,t,u.response)},i.timeout),self.fetch(this.request).then(function(L){if(u.response=u.loader=L,!L.ok){var A=L.status,P=L.statusText;throw new a(P||"fetch, bad network response",A,L)}return d.loading.first=Math.max(self.performance.now(),d.loading.start),d.total=parseInt(L.headers.get("Content-Length")||"0"),o&&Object(T.isFiniteNumber)(i.highWaterMark)?u.loadProgressively(L,d,t,i.highWaterMark,o):s?L.arrayBuffer():L.text()}).then(function(L){var A=u.response;self.clearTimeout(u.requestTimeout),d.loading.end=Math.max(self.performance.now(),d.loading.first),d.loaded=d.total=L[y];var P={url:A.url,data:L};o&&!Object(T.isFiniteNumber)(i.highWaterMark)&&o(d,t,L,A),E.onSuccess(P,d,t,A)}).catch(function(L){if(self.clearTimeout(u.requestTimeout),!d.aborted){var A=L&&L.code||0,P=L?L.message:null;E.onError({code:A,text:P},t,L?L.details:null)}})},h.getCacheAge=function(){var t=null;if(this.response){var i=this.response.headers.get("age");t=i?parseFloat(i):null}return t},h.loadProgressively=function(t,i,E,u,d){u===void 0&&(u=0);var c=new O.default,o=t.body.getReader(),s=function y(){return o.read().then(function(L){if(L.done)return c.dataLength&&d(i,E,c.flush(),t),Promise.resolve(new ArrayBuffer(0));var A=L.value,P=A.length;return i.loaded+=P,P<u||c.dataLength?(c.push(A),c.dataLength>=u&&d(i,E,c.flush(),t)):d(i,E,A,t),y()}).catch(function(){return Promise.reject()})};return s()},l}();function r(l,h){var n={method:"GET",mode:"cors",credentials:"same-origin",signal:h,headers:new self.Headers(m({},l.headers))};return l.rangeEnd&&n.headers.set("Range","bytes="+l.rangeStart+"-"+String(l.rangeEnd-1)),n}function e(l,h){return new self.Request(l.url,h)}var a=function(l){b(h,l);function h(n,t,i){var E;return E=l.call(this,n)||this,E.code=void 0,E.details=void 0,E.code=t,E.details=i,E}return h}(C(Error));M.default=f},"./src/utils/imsc1-ttml-parser.ts":function(K,M,D){D.r(M),D.d(M,"IMSC1_CODEC",function(){return g}),D.d(M,"parseIMSC1",function(){return v});var T=D("./src/utils/mp4-tools.ts"),R=D("./src/utils/vttparser.ts"),O=D("./src/utils/vttcue.ts"),b=D("./src/demux/id3.ts"),C=D("./src/utils/timescale-conversion.ts"),I=D("./src/utils/webvtt-parser.ts");function S(){return S=Object.assign?Object.assign.bind():function(u){for(var d=1;d<arguments.length;d++){var c=arguments[d];for(var o in c)Object.prototype.hasOwnProperty.call(c,o)&&(u[o]=c[o])}return u},S.apply(this,arguments)}var g="stpp.ttml.im1t",x=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,p=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,m={left:"start",center:"center",right:"end",start:"start",end:"end"};function v(u,d,c,o,s){var y=Object(T.findBox)(new Uint8Array(u),["mdat"]);if(y.length===0){s(new Error("Could not parse IMSC1 mdat"));return}var L=y.map(function(P){return Object(b.utf8ArrayToStr)(P)}),A=Object(C.toTimescaleFromScale)(d,1,c);try{L.forEach(function(P){return o(f(P,A))})}catch(P){s(P)}}function f(u,d){var c=new DOMParser,o=c.parseFromString(u,"text/xml"),s=o.getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");var y={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},L=Object.keys(y).reduce(function(B,k){return B[k]=s.getAttribute("ttp:"+k)||y[k],B},{}),A=s.getAttribute("xml:space")!=="preserve",P=e(r(s,"styling","style")),_=e(r(s,"layout","region")),F=r(s,"body","[begin]");return[].map.call(F,function(B){var k=a(B,A);if(!k||!B.hasAttribute("begin"))return null;var N=t(B.getAttribute("begin"),L),U=t(B.getAttribute("dur"),L),w=t(B.getAttribute("end"),L);if(N===null)throw n(B);if(w===null){if(U===null)throw n(B);w=N+U}var W=new O.default(N-d,w-d,k);W.id=Object(I.generateCueId)(W.startTime,W.endTime,W.text);var j=_[B.getAttribute("region")],H=P[B.getAttribute("style")];W.position=10,W.size=80;var G=l(j,H,P),Y=G.textAlign;if(Y){var X=m[Y];X&&(W.lineAlign=X),W.align=Y}return S(W,G),W}).filter(function(B){return B!==null})}function r(u,d,c){var o=u.getElementsByTagName(d)[0];return o?[].slice.call(o.querySelectorAll(c)):[]}function e(u){return u.reduce(function(d,c){var o=c.getAttribute("xml:id");return o&&(d[o]=c),d},{})}function a(u,d){return[].slice.call(u.childNodes).reduce(function(c,o,s){var y;return o.nodeName==="br"&&s?c+`
40
+ `:(y=o.childNodes)!==null&&y!==void 0&&y.length?a(o,d):d?c+o.textContent.trim().replace(/\s+/g," "):c+o.textContent},"")}function l(u,d,c){var o="http://www.w3.org/ns/ttml#styling",s=null,y=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],L=u!=null&&u.hasAttribute("style")?u.getAttribute("style"):null;return L&&c.hasOwnProperty(L)&&(s=c[L]),y.reduce(function(A,P){var _=h(d,o,P)||h(u,o,P)||h(s,o,P);return _&&(A[P]=_),A},{})}function h(u,d,c){return u&&u.hasAttributeNS(d,c)?u.getAttributeNS(d,c):null}function n(u){return new Error("Could not parse ttml timestamp "+u)}function t(u,d){if(!u)return null;var c=Object(R.parseTimeStamp)(u);return c===null&&(x.test(u)?c=i(u,d):p.test(u)&&(c=E(u,d))),c}function i(u,d){var c=x.exec(u),o=(c[4]|0)+(c[5]|0)/d.subFrameRate;return(c[1]|0)*3600+(c[2]|0)*60+(c[3]|0)+o/d.frameRate}function E(u,d){var c=p.exec(u),o=Number(c[1]),s=c[2];switch(s){case"h":return o*3600;case"m":return o*60;case"ms":return o*1e3;case"f":return o/d.frameRate;case"t":return o/d.tickRate}return o}},"./src/utils/logger.ts":function(K,M,D){D.r(M),D.d(M,"enableLogs",function(){return I}),D.d(M,"logger",function(){return S});var T=function(){},R={trace:T,debug:T,log:T,warn:T,info:T,error:T},O=R;function b(g){var x=self.console[g];return x?x.bind(self.console,"["+g+"] >"):T}function C(g){for(var x=arguments.length,p=new Array(x>1?x-1:0),m=1;m<x;m++)p[m-1]=arguments[m];p.forEach(function(v){O[v]=g[v]?g[v].bind(g):b(v)})}function I(g){if(self.console&&g===!0||typeof g=="object"){C(g,"debug","log","info","warn","error");try{O.log()}catch{O=R}}else O=R}var S=O},"./src/utils/mediakeys-helper.ts":function(K,M,D){D.r(M),D.d(M,"KeySystems",function(){return T}),D.d(M,"requestMediaKeySystemAccess",function(){return R});var T;(function(O){O.WIDEVINE="com.widevine.alpha",O.PLAYREADY="com.microsoft.playready"})(T||(T={}));var R=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(K,M,D){D.r(M),D.d(M,"getMediaSource",function(){return T});function T(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(K,M,D){D.r(M),D.d(M,"RemuxerTrackIdConfig",function(){return I}),D.d(M,"bin2str",function(){return S}),D.d(M,"readUint16",function(){return g}),D.d(M,"readUint32",function(){return x}),D.d(M,"readSint32",function(){return p}),D.d(M,"writeUint32",function(){return m}),D.d(M,"findBox",function(){return v}),D.d(M,"parseSegmentIndex",function(){return f}),D.d(M,"parseInitSegment",function(){return r}),D.d(M,"getStartDTS",function(){return e}),D.d(M,"getDuration",function(){return a}),D.d(M,"computeRawDurationFromSamples",function(){return l}),D.d(M,"offsetStartDTS",function(){return h}),D.d(M,"segmentValidRange",function(){return n}),D.d(M,"appendUint8Array",function(){return t}),D.d(M,"parseSamples",function(){return i}),D.d(M,"parseSEIMessageFromNALu",function(){return d}),D.d(M,"parseEmsg",function(){return o});var T=D("./src/utils/typed-array.ts"),R=D("./src/loader/fragment.ts"),O=D("./src/demux/id3.ts"),b=Math.pow(2,32)-1,C=[].push,I={video:1,audio:2,id3:3,text:4};function S(s){return String.fromCharCode.apply(null,s)}function g(s,y){var L=s[y]<<8|s[y+1];return L<0?65536+L:L}function x(s,y){var L=p(s,y);return L<0?4294967296+L:L}function p(s,y){return s[y]<<24|s[y+1]<<16|s[y+2]<<8|s[y+3]}function m(s,y,L){s[y]=L>>24,s[y+1]=L>>16&255,s[y+2]=L>>8&255,s[y+3]=L&255}function v(s,y){var L=[];if(!y.length)return L;for(var A=s.byteLength,P=0;P<A;){var _=x(s,P),F=S(s.subarray(P+4,P+8)),B=_>1?P+_:A;if(F===y[0])if(y.length===1)L.push(s.subarray(P+8,B));else{var k=v(s.subarray(P+8,B),y.slice(1));k.length&&C.apply(L,k)}P=B}return L}function f(s){var y=[],L=s[0],A=8,P=x(s,A);A+=4;var _=0,F=0;L===0?A+=8:A+=16,A+=2;var B=s.length+F,k=g(s,A);A+=2;for(var N=0;N<k;N++){var U=A,w=x(s,U);U+=4;var W=w&2147483647,j=(w&2147483648)>>>31;if(j===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var H=x(s,U);U+=4,y.push({referenceSize:W,subsegmentDuration:H,info:{duration:H/P,start:B,end:B+W-1}}),B+=W,U+=4,A=U}return{earliestPresentationTime:_,timescale:P,version:L,referencesCount:k,references:y}}function r(s){for(var y=[],L=v(s,["moov","trak"]),A=0;A<L.length;A++){var P=L[A],_=v(P,["tkhd"])[0];if(_){var F=_[0],B=F===0?12:20,k=x(_,B),N=v(P,["mdia","mdhd"])[0];if(N){F=N[0],B=F===0?12:20;var U=x(N,B),w=v(P,["mdia","hdlr"])[0];if(w){var W=S(w.subarray(8,12)),j={soun:R.ElementaryStreamTypes.AUDIO,vide:R.ElementaryStreamTypes.VIDEO}[W];if(j){var H=v(P,["mdia","minf","stbl","stsd"])[0],G=void 0;H&&(G=S(H.subarray(12,16))),y[k]={timescale:U,type:j},y[j]={timescale:U,id:k,codec:G}}}}}}var Y=v(s,["moov","mvex","trex"]);return Y.forEach(function(X){var z=x(X,4),V=y[z];V&&(V.default={duration:x(X,12),flags:x(X,20)})}),y}function e(s,y){return v(y,["moof","traf"]).reduce(function(L,A){var P=v(A,["tfdt"])[0],_=P[0],F=v(A,["tfhd"]).reduce(function(B,k){var N=x(k,4),U=s[N];if(U){var w=x(P,4);_===1&&(w*=Math.pow(2,32),w+=x(P,8));var W=U.timescale||9e4,j=w/W;if(isFinite(j)&&(B===null||j<B))return j}return B},null);return F!==null&&isFinite(F)&&(L===null||F<L)?F:L},null)||0}function a(s,y){for(var L=0,A=0,P=0,_=v(s,["moof","traf"]),F=0;F<_.length;F++){var B=_[F],k=v(B,["tfhd"])[0],N=x(k,4),U=y[N];if(!!U){var w=U.default,W=x(k,0)|(w==null?void 0:w.flags),j=w==null?void 0:w.duration;W&8&&(W&2?j=x(k,12):j=x(k,8));for(var H=U.timescale||9e4,G=v(B,["trun"]),Y=0;Y<G.length;Y++){if(L=l(G[Y]),!L&&j){var X=x(G[Y],4);L=j*X}U.type===R.ElementaryStreamTypes.VIDEO?A+=L/H:U.type===R.ElementaryStreamTypes.AUDIO&&(P+=L/H)}}}if(A===0&&P===0){for(var z=0,V=v(s,["sidx"]),$=0;$<V.length;$++){var Q=f(V[$]);Q!=null&&Q.references&&(z+=Q.references.reduce(function(J,Z){return J+Z.info.duration||0},0))}return z}return A||P}function l(s){var y=x(s,0),L=8;y&1&&(L+=4),y&4&&(L+=4);for(var A=0,P=x(s,4),_=0;_<P;_++){if(y&256){var F=x(s,L);A+=F,L+=4}y&512&&(L+=4),y&1024&&(L+=4),y&2048&&(L+=4)}return A}function h(s,y,L){v(y,["moof","traf"]).forEach(function(A){v(A,["tfhd"]).forEach(function(P){var _=x(P,4),F=s[_];if(!!F){var B=F.timescale||9e4;v(A,["tfdt"]).forEach(function(k){var N=k[0],U=x(k,4);if(N===0)U-=L*B,U=Math.max(U,0),m(k,4,U);else{U*=Math.pow(2,32),U+=x(k,8),U-=L*B,U=Math.max(U,0);var w=Math.floor(U/(b+1)),W=Math.floor(U%(b+1));m(k,4,w),m(k,8,W)}})}})})}function n(s){var y={valid:null,remainder:null},L=v(s,["moof"]);if(L){if(L.length<2)return y.remainder=s,y}else return y;var A=L[L.length-1];return y.valid=Object(T.sliceUint8)(s,0,A.byteOffset-8),y.remainder=Object(T.sliceUint8)(s,A.byteOffset-8),y}function t(s,y){var L=new Uint8Array(s.length+y.length);return L.set(s),L.set(y,s.length),L}function i(s,y){var L=[],A=y.samples,P=y.timescale,_=y.id,F=!1,B=v(A,["moof"]);return B.map(function(k){var N=k.byteOffset-8,U=v(k,["traf"]);U.map(function(w){var W=v(w,["tfdt"]).map(function(j){var H=j[0],G=x(j,4);return H===1&&(G*=Math.pow(2,32),G+=x(j,8)),G/P})[0];return W!==void 0&&(s=W),v(w,["tfhd"]).map(function(j){var H=x(j,4),G=x(j,0)&16777215,Y=(G&1)!==0,X=(G&2)!==0,z=(G&8)!==0,V=0,$=(G&16)!==0,Q=0,J=(G&32)!==0,Z=8;H===_&&(Y&&(Z+=8),X&&(Z+=4),z&&(V=x(j,Z),Z+=4),$&&(Q=x(j,Z),Z+=4),J&&(Z+=4),y.type==="video"&&(F=E(y.codec)),v(w,["trun"]).map(function(q){var ee=q[0],te=x(q,0)&16777215,re=(te&1)!==0,oe=0,de=(te&4)!==0,he=(te&256)!==0,ae=0,Se=(te&512)!==0,ce=0,le=(te&1024)!==0,pe=(te&2048)!==0,ye=0,Ee=x(q,4),ne=8;re&&(oe=x(q,ne),ne+=4),de&&(ne+=4);for(var ue=oe+N,ve=0;ve<Ee;ve++){if(he?(ae=x(q,ne),ne+=4):ae=V,Se?(ce=x(q,ne),ne+=4):ce=Q,le&&(ne+=4),pe&&(ee===0?ye=x(q,ne):ye=p(q,ne),ne+=4),y.type===R.ElementaryStreamTypes.VIDEO)for(var ge=0;ge<ce;){var Te=x(A,ue);ue+=4;var se=A[ue]&31;if(u(F,se)){var me=A.subarray(ue,ue+Te);d(me,s+ye/P,L)}ue+=Te,ge+=Te+4}s+=ae/P}}))})})}),L}function E(s){if(!s)return!1;var y=s.indexOf("."),L=y<0?s:s.substring(0,y);return L==="hvc1"||L==="hev1"||L==="dvh1"||L==="dvhe"}function u(s,y){return s?y===39||y===40:y===6}function d(s,y,L){var A=c(s),P=0;P++;for(var _=0,F=0,B=!1,k=0;P<A.length;){_=0;do{if(P>=A.length)break;k=A[P++],_+=k}while(k===255);F=0;do{if(P>=A.length)break;k=A[P++],F+=k}while(k===255);var N=A.length-P;if(!B&&_===4&&P<A.length){B=!0;var U=A[P++];if(U===181){var w=g(A,P);if(P+=2,w===49){var W=x(A,P);if(P+=4,W===1195456820){var j=A[P++];if(j===3){var H=A[P++],G=31&H,Y=64&H,X=Y?2+G*3:0,z=new Uint8Array(X);if(Y){z[0]=H;for(var V=1;V<X;V++)z[V]=A[P++]}L.push({type:j,payloadType:_,pts:y,bytes:z})}}}}}else if(_===5&&F<N){if(B=!0,F>16){for(var $=[],Q=0;Q<16;Q++){var J=A[P++].toString(16);$.push(J.length==1?"0"+J:J),(Q===3||Q===5||Q===7||Q===9)&&$.push("-")}for(var Z=F-16,q=new Uint8Array(Z),ee=0;ee<Z;ee++)q[ee]=A[P++];L.push({payloadType:_,pts:y,uuid:$.join(""),userData:Object(O.utf8ArrayToStr)(q),userDataBytes:q})}}else if(F<N)P+=F;else if(F>N)break}}function c(s){for(var y=s.byteLength,L=[],A=1;A<y-2;)s[A]===0&&s[A+1]===0&&s[A+2]===3?(L.push(A+2),A+=2):A++;if(L.length===0)return s;var P=y-L.length,_=new Uint8Array(P),F=0;for(A=0;A<P;F++,A++)F===L[0]&&(F++,L.shift()),_[A]=s[F];return _}function o(s){var y=s[0],L="",A="",P=0,_=0,F=0,B=0,k=0,N=0;if(y===0){for(;S(s.subarray(N,N+1))!=="\0";)L+=S(s.subarray(N,N+1)),N+=1;for(L+=S(s.subarray(N,N+1)),N+=1;S(s.subarray(N,N+1))!=="\0";)A+=S(s.subarray(N,N+1)),N+=1;A+=S(s.subarray(N,N+1)),N+=1,P=x(s,12),_=x(s,16),B=x(s,20),k=x(s,24),N=28}else if(y===1){N+=4,P=x(s,N),N+=4;var U=x(s,N);N+=4;var w=x(s,N);for(N+=4,F=Math.pow(2,32)*U+w,Number.isSafeInteger(F)||(F=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),B=x(s,N),N+=4,k=x(s,N),N+=4;S(s.subarray(N,N+1))!=="\0";)L+=S(s.subarray(N,N+1)),N+=1;for(L+=S(s.subarray(N,N+1)),N+=1;S(s.subarray(N,N+1))!=="\0";)A+=S(s.subarray(N,N+1)),N+=1;A+=S(s.subarray(N,N+1)),N+=1}var W=s.subarray(N,s.byteLength);return{schemeIdUri:L,value:A,timeScale:P,presentationTime:F,presentationTimeDelta:_,eventDuration:B,id:k,payload:W}}},"./src/utils/output-filter.ts":function(K,M,D){D.r(M),D.d(M,"default",function(){return T});var T=function(){function R(b,C){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=b,this.trackName=C}var O=R.prototype;return O.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},O.newCue=function(C,I,S){(this.startTime===null||this.startTime>C)&&(this.startTime=C),this.endTime=I,this.screen=S,this.timelineController.createCaptionsTrack(this.trackName)},O.reset=function(){this.cueRanges=[],this.startTime=null},R}()},"./src/utils/texttrack-utils.ts":function(K,M,D){D.r(M),D.d(M,"sendAddTrackEvent",function(){return R}),D.d(M,"addCueToTrack",function(){return O}),D.d(M,"clearCurrentCues",function(){return b}),D.d(M,"removeCuesInRange",function(){return C}),D.d(M,"getCuesInRange",function(){return S});var T=D("./src/utils/logger.ts");function R(g,x){var p;try{p=new Event("addtrack")}catch{p=document.createEvent("Event"),p.initEvent("addtrack",!1,!1)}p.track=g,x.dispatchEvent(p)}function O(g,x){var p=g.mode;if(p==="disabled"&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(x.id))try{if(g.addCue(x),!g.cues.getCueById(x.id))throw new Error("addCue is failed for: "+x)}catch(v){T.logger.debug("[texttrack-utils]: "+v);var m=new self.TextTrackCue(x.startTime,x.endTime,x.text);m.id=x.id,g.addCue(m)}p==="disabled"&&(g.mode=p)}function b(g){var x=g.mode;if(x==="disabled"&&(g.mode="hidden"),g.cues)for(var p=g.cues.length;p--;)g.removeCue(g.cues[p]);x==="disabled"&&(g.mode=x)}function C(g,x,p,m){var v=g.mode;if(v==="disabled"&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var f=S(g.cues,x,p),r=0;r<f.length;r++)(!m||m(f[r]))&&g.removeCue(f[r]);v==="disabled"&&(g.mode=v)}function I(g,x){if(x<g[0].startTime)return 0;var p=g.length-1;if(x>g[p].endTime)return-1;for(var m=0,v=p;m<=v;){var f=Math.floor((v+m)/2);if(x<g[f].startTime)v=f-1;else if(x>g[f].startTime&&m<p)m=f+1;else return f}return g[m].startTime-x<x-g[v].startTime?m:v}function S(g,x,p){var m=[],v=I(g,x);if(v>-1)for(var f=v,r=g.length;f<r;f++){var e=g[f];if(e.startTime>=x&&e.endTime<=p)m.push(e);else if(e.startTime>p)return m}return m}},"./src/utils/time-ranges.ts":function(K,M,D){D.r(M);var T={toString:function(O){for(var b="",C=O.length,I=0;I<C;I++)b+="["+O.start(I).toFixed(3)+","+O.end(I).toFixed(3)+"]";return b}};M.default=T},"./src/utils/timescale-conversion.ts":function(K,M,D){D.r(M),D.d(M,"toTimescaleFromBase",function(){return R}),D.d(M,"toTimescaleFromScale",function(){return O}),D.d(M,"toMsFromMpegTsClock",function(){return b}),D.d(M,"toMpegTsClockFromTimescale",function(){return C});var T=9e4;function R(I,S,g,x){g===void 0&&(g=1),x===void 0&&(x=!1);var p=I*S*g;return x?Math.round(p):p}function O(I,S,g,x){return g===void 0&&(g=1),x===void 0&&(x=!1),R(I,S,1/g,x)}function b(I,S){return S===void 0&&(S=!1),R(I,1e3,1/T,S)}function C(I,S){return S===void 0&&(S=1),R(I,T,1/S)}},"./src/utils/typed-array.ts":function(K,M,D){D.r(M),D.d(M,"sliceUint8",function(){return T});function T(R,O,b){return Uint8Array.prototype.slice?R.slice(O,b):new Uint8Array(Array.prototype.slice.call(R,O,b))}},"./src/utils/vttcue.ts":function(K,M,D){D.r(M),M.default=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;var T=["","lr","rl"],R=["start","middle","end","left","right"];function O(g,x){if(typeof x!="string"||!Array.isArray(g))return!1;var p=x.toLowerCase();return~g.indexOf(p)?p:!1}function b(g){return O(T,g)}function C(g){return O(R,g)}function I(g){for(var x=arguments.length,p=new Array(x>1?x-1:0),m=1;m<x;m++)p[m-1]=arguments[m];for(var v=1;v<arguments.length;v++){var f=arguments[v];for(var r in f)g[r]=f[r]}return g}function S(g,x,p){var m=this,v={enumerable:!0};m.hasBeenReset=!1;var f="",r=!1,e=g,a=x,l=p,h=null,n="",t=!0,i="auto",E="start",u=50,d="middle",c=50,o="middle";Object.defineProperty(m,"id",I({},v,{get:function(){return f},set:function(y){f=""+y}})),Object.defineProperty(m,"pauseOnExit",I({},v,{get:function(){return r},set:function(y){r=!!y}})),Object.defineProperty(m,"startTime",I({},v,{get:function(){return e},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");e=y,this.hasBeenReset=!0}})),Object.defineProperty(m,"endTime",I({},v,{get:function(){return a},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");a=y,this.hasBeenReset=!0}})),Object.defineProperty(m,"text",I({},v,{get:function(){return l},set:function(y){l=""+y,this.hasBeenReset=!0}})),Object.defineProperty(m,"region",I({},v,{get:function(){return h},set:function(y){h=y,this.hasBeenReset=!0}})),Object.defineProperty(m,"vertical",I({},v,{get:function(){return n},set:function(y){var L=b(y);if(L===!1)throw new SyntaxError("An invalid or illegal string was specified.");n=L,this.hasBeenReset=!0}})),Object.defineProperty(m,"snapToLines",I({},v,{get:function(){return t},set:function(y){t=!!y,this.hasBeenReset=!0}})),Object.defineProperty(m,"line",I({},v,{get:function(){return i},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");i=y,this.hasBeenReset=!0}})),Object.defineProperty(m,"lineAlign",I({},v,{get:function(){return E},set:function(y){var L=C(y);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");E=L,this.hasBeenReset=!0}})),Object.defineProperty(m,"position",I({},v,{get:function(){return u},set:function(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");u=y,this.hasBeenReset=!0}})),Object.defineProperty(m,"positionAlign",I({},v,{get:function(){return d},set:function(y){var L=C(y);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");d=L,this.hasBeenReset=!0}})),Object.defineProperty(m,"size",I({},v,{get:function(){return c},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");c=y,this.hasBeenReset=!0}})),Object.defineProperty(m,"align",I({},v,{get:function(){return o},set:function(y){var L=C(y);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");o=L,this.hasBeenReset=!0}})),m.displayState=void 0}return S.prototype.getCueAsHTML=function(){var g=self.WebVTT;return g.convertCueToDOMTree(self,this.text)},S}()},"./src/utils/vttparser.ts":function(K,M,D){D.r(M),D.d(M,"parseTimeStamp",function(){return O}),D.d(M,"fixLineBreaks",function(){return x}),D.d(M,"VTTParser",function(){return p});var T=D("./src/utils/vttcue.ts"),R=function(){function m(){}var v=m.prototype;return v.decode=function(r,e){if(!r)return"";if(typeof r!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(r))},m}();function O(m){function v(r,e,a,l){return(r|0)*3600+(e|0)*60+(a|0)+parseFloat(l||0)}var f=m.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return f?parseFloat(f[2])>59?v(f[2],f[3],0,f[4]):v(f[1],f[2],f[3],f[4]):null}var b=function(){function m(){this.values=Object.create(null)}var v=m.prototype;return v.set=function(r,e){!this.get(r)&&e!==""&&(this.values[r]=e)},v.get=function(r,e,a){return a?this.has(r)?this.values[r]:e[a]:this.has(r)?this.values[r]:e},v.has=function(r){return r in this.values},v.alt=function(r,e,a){for(var l=0;l<a.length;++l)if(e===a[l]){this.set(r,e);break}},v.integer=function(r,e){/^-?\d+$/.test(e)&&this.set(r,parseInt(e,10))},v.percent=function(r,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var a=parseFloat(e);if(a>=0&&a<=100)return this.set(r,a),!0}return!1},m}();function C(m,v,f,r){var e=r?m.split(r):[m];for(var a in e)if(typeof e[a]=="string"){var l=e[a].split(f);if(l.length===2){var h=l[0],n=l[1];v(h,n)}}}var I=new T.default(0,0,""),S=I.align==="middle"?"middle":"center";function g(m,v,f){var r=m;function e(){var h=O(m);if(h===null)throw new Error("Malformed timestamp: "+r);return m=m.replace(/^[^\sa-zA-Z-]+/,""),h}function a(h,n){var t=new b;C(h,function(u,d){var c;switch(u){case"region":for(var o=f.length-1;o>=0;o--)if(f[o].id===d){t.set(u,f[o].region);break}break;case"vertical":t.alt(u,d,["rl","lr"]);break;case"line":c=d.split(","),t.integer(u,c[0]),t.percent(u,c[0])&&t.set("snapToLines",!1),t.alt(u,c[0],["auto"]),c.length===2&&t.alt("lineAlign",c[1],["start",S,"end"]);break;case"position":c=d.split(","),t.percent(u,c[0]),c.length===2&&t.alt("positionAlign",c[1],["start",S,"end","line-left","line-right","auto"]);break;case"size":t.percent(u,d);break;case"align":t.alt(u,d,["start",S,"end","left","right"]);break}},/:/,/\s/),n.region=t.get("region",null),n.vertical=t.get("vertical","");var i=t.get("line","auto");i==="auto"&&I.line===-1&&(i=-1),n.line=i,n.lineAlign=t.get("lineAlign","start"),n.snapToLines=t.get("snapToLines",!0),n.size=t.get("size",100),n.align=t.get("align",S);var E=t.get("position","auto");E==="auto"&&I.position===50&&(E=n.align==="start"||n.align==="left"?0:n.align==="end"||n.align==="right"?100:50),n.position=E}function l(){m=m.replace(/^\s+/,"")}if(l(),v.startTime=e(),l(),m.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);m=m.slice(3),l(),v.endTime=e(),l(),a(m,v)}function x(m){return m.replace(/<br(?: \/)?>/gi,`
41
+ `)}var p=function(){function m(){this.state="INITIAL",this.buffer="",this.decoder=new R,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var v=m.prototype;return v.parse=function(r){var e=this;r&&(e.buffer+=e.decoder.decode(r,{stream:!0}));function a(){var E=e.buffer,u=0;for(E=x(E);u<E.length&&E[u]!=="\r"&&E[u]!==`
42
+ `;)++u;var d=E.slice(0,u);return E[u]==="\r"&&++u,E[u]===`
43
+ `&&++u,e.buffer=E.slice(u),d}function l(E){C(E,function(u,d){},/:/)}try{var h="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;h=a();var n=h.match(/^()?WEBVTT([ \t].*)?$/);if(!n||!n[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var t=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(t?t=!1:h=a(),e.state){case"HEADER":/:/.test(h)?l(h):h||(e.state="ID");continue;case"NOTE":h||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(h)){e.state="NOTE";break}if(!h)continue;if(e.cue=new T.default(0,0,""),e.state="CUE",h.indexOf("-->")===-1){e.cue.id=h;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{g(h,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var i=h.indexOf("-->")!==-1;if(!h||i&&(t=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
44
+ `),e.cue.text+=h}continue;case"BADCUE":h||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},v.flush=function(){var r=this;try{if((r.cue||r.state==="HEADER")&&(r.buffer+=`
45
+
46
+ `,r.parse()),r.state==="INITIAL"||r.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){r.onparsingerror&&r.onparsingerror(e)}return r.onflush&&r.onflush(),this},m}()},"./src/utils/webvtt-parser.ts":function(K,M,D){D.r(M),D.d(M,"generateCueId",function(){return p}),D.d(M,"parseWebVTT",function(){return v});var T=D("./src/polyfills/number.ts"),R=D("./src/utils/vttparser.ts"),O=D("./src/demux/id3.ts"),b=D("./src/utils/timescale-conversion.ts"),C=D("./src/remux/mp4-remuxer.ts"),I=/\r\n|\n\r|\n|\r/g,S=function(r,e,a){return a===void 0&&(a=0),r.slice(a,a+e.length)===e},g=function(r){var e=parseInt(r.slice(-3)),a=parseInt(r.slice(-6,-4)),l=parseInt(r.slice(-9,-7)),h=r.length>9?parseInt(r.substring(0,r.indexOf(":"))):0;if(!Object(T.isFiniteNumber)(e)||!Object(T.isFiniteNumber)(a)||!Object(T.isFiniteNumber)(l)||!Object(T.isFiniteNumber)(h))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+r);return e+=1e3*a,e+=60*1e3*l,e+=60*60*1e3*h,e},x=function(r){for(var e=5381,a=r.length;a;)e=e*33^r.charCodeAt(--a);return(e>>>0).toString()};function p(f,r,e){return x(f.toString())+x(r.toString())+x(e)}var m=function(r,e,a){var l=r[e],h=r[l.prevCC];if(!h||!h.new&&l.new){r.ccOffset=r.presentationOffset=l.start,l.new=!1;return}for(;(n=h)!==null&&n!==void 0&&n.new;){var n;r.ccOffset+=l.start-h.start,l.new=!1,l=h,h=r[l.prevCC]}r.presentationOffset=a};function v(f,r,e,a,l,h,n,t){var i=new R.VTTParser,E=Object(O.utf8ArrayToStr)(new Uint8Array(f)).trim().replace(I,`
47
+ `).split(`
48
+ `),u=[],d=Object(b.toMpegTsClockFromTimescale)(r,e),c="00:00.000",o=0,s=0,y,L=!0;i.oncue=function(A){var P=a[l],_=a.ccOffset,F=(o-d)/9e4;P!=null&&P.new&&(s!==void 0?_=a.ccOffset=P.start:m(a,l,F)),F&&(_=F-a.presentationOffset);var B=A.endTime-A.startTime,k=Object(C.normalizePts)((A.startTime+_-s)*9e4,h*9e4)/9e4;A.startTime=Math.max(k,0),A.endTime=Math.max(k+B,0);var N=A.text.trim();A.text=decodeURIComponent(encodeURIComponent(N)),A.id||(A.id=p(A.startTime,A.endTime,N)),A.endTime>0&&u.push(A)},i.onparsingerror=function(A){y=A},i.onflush=function(){if(y){t(y);return}n(u)},E.forEach(function(A){if(L)if(S(A,"X-TIMESTAMP-MAP=")){L=!1,A.slice(16).split(",").forEach(function(P){S(P,"LOCAL:")?c=P.slice(6):S(P,"MPEGTS:")&&(o=parseInt(P.slice(7)))});try{s=g(c)/1e3}catch(P){y=P}return}else A===""&&(L=!1);i.parse(A+`
49
+ `)}),i.flush()}},"./src/utils/xhr-loader.ts":function(K,M,D){D.r(M);var T=D("./src/utils/logger.ts"),R=D("./src/loader/load-stats.ts"),O=/^age:\s*[\d.]+\s*$/m,b=function(){function C(S){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=S?S.xhrSetup:null,this.stats=new R.LoadStats,this.retryDelay=0}var I=C.prototype;return I.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},I.abortInternal=function(){var g=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),g&&(g.onreadystatechange=null,g.onprogress=null,g.readyState!==4&&(this.stats.aborted=!0,g.abort()))},I.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},I.load=function(g,x,p){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=g,this.config=x,this.callbacks=p,this.retryDelay=x.retryDelay,this.loadInternal()},I.loadInternal=function(){var g=this.config,x=this.context;if(!!g){var p=this.loader=new self.XMLHttpRequest,m=this.stats;m.loading.first=0,m.loaded=0;var v=this.xhrSetup;try{if(v)try{v(p,x.url)}catch{p.open("GET",x.url,!0),v(p,x.url)}p.readyState||p.open("GET",x.url,!0);var f=this.context.headers;if(f)for(var r in f)p.setRequestHeader(r,f[r])}catch(e){this.callbacks.onError({code:p.status,text:e.message},x,p);return}x.rangeEnd&&p.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),p.onreadystatechange=this.readystatechange.bind(this),p.onprogress=this.loadprogress.bind(this),p.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),p.send()}},I.readystatechange=function(){var g=this.context,x=this.loader,p=this.stats;if(!(!g||!x)){var m=x.readyState,v=this.config;if(!p.aborted&&m>=2)if(self.clearTimeout(this.requestTimeout),p.loading.first===0&&(p.loading.first=Math.max(self.performance.now(),p.loading.start)),m===4){x.onreadystatechange=null,x.onprogress=null;var f=x.status;if(f>=200&&f<300){p.loading.end=Math.max(self.performance.now(),p.loading.first);var r,e;if(g.responseType==="arraybuffer"?(r=x.response,e=r.byteLength):(r=x.responseText,e=r.length),p.loaded=p.total=e,!this.callbacks)return;var a=this.callbacks.onProgress;if(a&&a(p,g,r,x),!this.callbacks)return;var l={url:x.responseURL,data:r};this.callbacks.onSuccess(l,p,g,x)}else p.retry>=v.maxRetry||f>=400&&f<499?(T.logger.error(f+" while loading "+g.url),this.callbacks.onError({code:f,text:x.statusText},g,x)):(T.logger.warn(f+" while loading "+g.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,v.maxRetryDelay),p.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),v.timeout)}},I.loadtimeout=function(){T.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},I.loadprogress=function(g){var x=this.stats;x.loaded=g.loaded,g.lengthComputable&&(x.total=g.total)},I.getCacheAge=function(){var g=null;if(this.loader&&O.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");g=x?parseFloat(x):null}return g},C}();M.default=b}}).default})})(je);const lt=Ke(je.exports);export{lt as H,ot as a,st as b};