alistgo-alist-web 3.56.0
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.
- package/README.md +34 -0
- package/dist/assets/2fa-46b8256b.js +1 -0
- package/dist/assets/2fa-legacy.398e8e78.js +1 -0
- package/dist/assets/About-e47182af.js +1 -0
- package/dist/assets/About-legacy.1289a3bb.js +1 -0
- package/dist/assets/AddLabelDialog-0c30515a.js +1 -0
- package/dist/assets/AddLabelDialog-legacy.cc57656a.js +1 -0
- package/dist/assets/AddOrEdit-1124188f.js +1 -0
- package/dist/assets/AddOrEdit-6d416fd2.js +1 -0
- package/dist/assets/AddOrEdit-9d27739a.js +1 -0
- package/dist/assets/AddOrEdit-e6bf2264.js +1 -0
- package/dist/assets/AddOrEdit-legacy.0f9dd018.js +1 -0
- package/dist/assets/AddOrEdit-legacy.73708fb8.js +1 -0
- package/dist/assets/AddOrEdit-legacy.8c9d1f76.js +1 -0
- package/dist/assets/AddOrEdit-legacy.abdbec5f.js +1 -0
- package/dist/assets/Common-972fe675.js +1 -0
- package/dist/assets/Common-legacy.d3b29529.js +1 -0
- package/dist/assets/Copy-27ccc5bb.js +1 -0
- package/dist/assets/Copy-legacy.4726f176.js +1 -0
- package/dist/assets/Decompress-487355e7.js +1 -0
- package/dist/assets/Decompress-legacy.c2c88fbd.js +1 -0
- package/dist/assets/DeletePopover-14667228.js +1 -0
- package/dist/assets/DeletePopover-legacy.eea88399.js +1 -0
- package/dist/assets/EditLabelDialog-e1c497f9.js +1 -0
- package/dist/assets/EditLabelDialog-legacy.4297e407.js +1 -0
- package/dist/assets/File-d8b1045a.js +8 -0
- package/dist/assets/File-legacy.42c11a63.js +1 -0
- package/dist/assets/Folder-015eb94d.js +179 -0
- package/dist/assets/Folder-6ee8584f.css +1 -0
- package/dist/assets/Folder-legacy.4311946a.js +29 -0
- package/dist/assets/FolderTree-6f54b0b0.js +1 -0
- package/dist/assets/FolderTree-legacy.eeec4df2.js +1 -0
- package/dist/assets/Grid-9188d13c.js +1 -0
- package/dist/assets/Grid-legacy.304bdbd6.js +1 -0
- package/dist/assets/GridItem-e11988da.js +1 -0
- package/dist/assets/GridItem-legacy.92e61601.js +1 -0
- package/dist/assets/ImageWithError-335988a8.js +1 -0
- package/dist/assets/ImageWithError-legacy.3b16de13.js +1 -0
- package/dist/assets/Images-12aaeeaa.js +1 -0
- package/dist/assets/Images-legacy.08b105c3.js +1 -0
- package/dist/assets/Layout-66d6a6fd.js +11 -0
- package/dist/assets/Layout-legacy.b2082e61.js +1 -0
- package/dist/assets/List-d289fe27.js +9 -0
- package/dist/assets/List-legacy.0b19a233.js +1 -0
- package/dist/assets/Messenger-b99aa3a0.js +1 -0
- package/dist/assets/Messenger-legacy.f7d5c274.js +1 -0
- package/dist/assets/Metas-73ad14ea.js +1 -0
- package/dist/assets/Metas-legacy.047fb1e9.js +1 -0
- package/dist/assets/Other-db3bfec1.js +1 -0
- package/dist/assets/Other-legacy.ca03d7c1.js +1 -0
- package/dist/assets/PackageDownload-8b8471d2.js +1 -0
- package/dist/assets/PackageDownload-legacy.6d567c0f.js +1 -0
- package/dist/assets/Paginator-6b8b297f.js +1 -0
- package/dist/assets/Paginator-legacy.0e75f264.js +1 -0
- package/dist/assets/Password-eb061964.js +1 -0
- package/dist/assets/Password-legacy.471d11cd.js +1 -0
- package/dist/assets/PermissionForm-4251595a.js +1 -0
- package/dist/assets/PermissionForm-legacy.90ad121a.js +1 -0
- package/dist/assets/Profile-3fecd1ab.js +1 -0
- package/dist/assets/Profile-legacy.8c4b70ea.js +1 -0
- package/dist/assets/ResponsiveGrid-35b6c8ed.js +1 -0
- package/dist/assets/ResponsiveGrid-legacy.6c0954c3.js +1 -0
- package/dist/assets/Role-a54a8031.js +1 -0
- package/dist/assets/Role-legacy.4362cd27.js +1 -0
- package/dist/assets/S3-3368841d.js +1 -0
- package/dist/assets/S3-legacy.88de8a46.js +1 -0
- package/dist/assets/S3Transition-0528c963.js +1 -0
- package/dist/assets/S3Transition-legacy.288c6def.js +1 -0
- package/dist/assets/SettingItem-b001fb21.js +1 -0
- package/dist/assets/SettingItem-legacy.30070d20.js +1 -0
- package/dist/assets/SourceHanSansCN-Bold-b5627435.woff2 +0 -0
- package/dist/assets/Storages-71961af9.js +1 -0
- package/dist/assets/Storages-legacy.62a6c6f5.js +1 -0
- package/dist/assets/Tag-28e6c753.js +1 -0
- package/dist/assets/Tag-legacy.02ba977c.js +1 -0
- package/dist/assets/Tasks-955b8122.js +1 -0
- package/dist/assets/Tasks-legacy.db2a67ab.js +1 -0
- package/dist/assets/TimesNewRoman-d9fb32eb.ttf +0 -0
- package/dist/assets/Upload-2acc2769.js +5 -0
- package/dist/assets/Upload-dac85921.js +1 -0
- package/dist/assets/Upload-legacy.2aae06b6.js +6 -0
- package/dist/assets/Upload-legacy.63a456fd.js +1 -0
- package/dist/assets/Users-d61fcb09.js +1 -0
- package/dist/assets/Users-legacy.351af943.js +1 -0
- package/dist/assets/Wether-efd806ad.js +1 -0
- package/dist/assets/Wether-legacy.99a49486.js +1 -0
- package/dist/assets/aliyun_office-f185e970.js +1 -0
- package/dist/assets/aliyun_office-legacy.bb247542.js +1 -0
- package/dist/assets/aliyun_video-fefe8145.js +1 -0
- package/dist/assets/aliyun_video-legacy.5de29048.js +1 -0
- package/dist/assets/archive-cd361e2c.js +1 -0
- package/dist/assets/archive-legacy.1dba1a02.js +1 -0
- package/dist/assets/asciinema-53412307.css +1 -0
- package/dist/assets/asciinema-9a29aaad.js +7 -0
- package/dist/assets/asciinema-legacy.f47a54ab.js +1 -0
- package/dist/assets/audio-43f4c02b.css +1 -0
- package/dist/assets/audio-4a4cbc3a.js +154 -0
- package/dist/assets/audio-legacy.e6590bf5.js +1 -0
- package/dist/assets/backup-restore-7a7d8f68.js +1 -0
- package/dist/assets/backup-restore-legacy.9aaed952.js +1 -0
- package/dist/assets/color-a58de010.js +1 -0
- package/dist/assets/color-legacy.24148ccb.js +1 -0
- package/dist/assets/entry-125255d4.js +9 -0
- package/dist/assets/entry-1f8750d3.js +5 -0
- package/dist/assets/entry-2dcf102b.js +5 -0
- package/dist/assets/entry-40c0efae.js +6 -0
- package/dist/assets/entry-89a5b151.js +5 -0
- package/dist/assets/entry-c149acf6.js +5 -0
- package/dist/assets/entry-c9079448.js +5 -0
- package/dist/assets/entry-e8ead902.js +7 -0
- package/dist/assets/entry-fe0e94b2.js +5 -0
- package/dist/assets/entry-ff0ec710.js +5 -0
- package/dist/assets/entry-legacy.0bf5e0ca.js +1 -0
- package/dist/assets/entry-legacy.1bea9f3a.js +1 -0
- package/dist/assets/entry-legacy.3cbf81df.js +1 -0
- package/dist/assets/entry-legacy.5e9cadea.js +1 -0
- package/dist/assets/entry-legacy.759fde7b.js +1 -0
- package/dist/assets/entry-legacy.bca06ca5.js +1 -0
- package/dist/assets/entry-legacy.c35a6372.js +1 -0
- package/dist/assets/entry-legacy.d14255c4.js +1 -0
- package/dist/assets/entry-legacy.e8ec9e72.js +1 -0
- package/dist/assets/entry-legacy.fea7f65d.js +1 -0
- package/dist/assets/helper-35b1dcfb.js +1 -0
- package/dist/assets/helper-edad9708.js +1 -0
- package/dist/assets/helper-legacy.a9f06abb.js +1 -0
- package/dist/assets/helper-legacy.f89e2639.js +1 -0
- package/dist/assets/hls-d6b9fc1a.js +52 -0
- package/dist/assets/hls-legacy.ae2e1dfe.js +8 -0
- package/dist/assets/html-d6918c57.js +1 -0
- package/dist/assets/html-legacy.3d2480dd.js +1 -0
- package/dist/assets/image-a16903d2.js +1 -0
- package/dist/assets/image-legacy.80edfdc1.js +1 -0
- package/dist/assets/index-13b290a7.js +103 -0
- package/dist/assets/index-4ce3d2a1.js +1 -0
- package/dist/assets/index-5b99d24c.js +263 -0
- package/dist/assets/index-69644529.js +1 -0
- package/dist/assets/index-8034ec29.js +14 -0
- package/dist/assets/index-864d4e91.js +1 -0
- package/dist/assets/index-870b387c.js +5 -0
- package/dist/assets/index-b206f97b.css +1 -0
- package/dist/assets/index-c1c6ff9d.js +1 -0
- package/dist/assets/index-d9416289.js +4 -0
- package/dist/assets/index-legacy.0f46aa15.js +1 -0
- package/dist/assets/index-legacy.43a11866.js +1 -0
- package/dist/assets/index-legacy.52c6160a.js +1 -0
- package/dist/assets/index-legacy.5b54d5e4.js +1 -0
- package/dist/assets/index-legacy.62c06d64.js +17 -0
- package/dist/assets/index-legacy.9842d021.js +1 -0
- package/dist/assets/index-legacy.d760057f.js +1 -0
- package/dist/assets/index-legacy.de03403a.js +18 -0
- package/dist/assets/index-legacy.e98cf2bb.js +1 -0
- package/dist/assets/indexes-7cc6998a.js +2 -0
- package/dist/assets/indexes-legacy.c057d4aa.js +1 -0
- package/dist/assets/ipa-99035991.js +1 -0
- package/dist/assets/ipa-legacy.5f9016d0.js +1 -0
- package/dist/assets/item_type-32dc6fdf.js +1 -0
- package/dist/assets/item_type-legacy.1b6076a1.js +1 -0
- package/dist/assets/lg-22b72ba5.ttf +0 -0
- package/dist/assets/lg-f2fe1c00.svg +54 -0
- package/dist/assets/lg-fefc5c0d.woff +0 -0
- package/dist/assets/loading-298ad3ff.gif +0 -0
- package/dist/assets/management-c5058b09.js +1 -0
- package/dist/assets/management-legacy.dac45ae8.js +1 -0
- package/dist/assets/markdown-68e1268c.js +1 -0
- package/dist/assets/markdown-legacy.345b4c89.js +1 -0
- package/dist/assets/markdown_with_word_wrap-223f2b9c.js +1 -0
- package/dist/assets/markdown_with_word_wrap-legacy.bfb81d65.js +1 -0
- package/dist/assets/mySession-94f62c14.js +1 -0
- package/dist/assets/mySession-legacy.1dc68111.js +1 -0
- package/dist/assets/offline_download-827377f8.js +1 -0
- package/dist/assets/offline_download-legacy.8be0325e.js +1 -0
- package/dist/assets/plist-a2abd5f6.js +1 -0
- package/dist/assets/plist-legacy.48a58efc.js +1 -0
- package/dist/assets/polyfills-legacy.4a227757.js +1 -0
- package/dist/assets/storage-class-1ac53f89.js +1 -0
- package/dist/assets/storage-class-legacy.7f6d9768.js +1 -0
- package/dist/assets/style-a6d16836.css +1 -0
- package/dist/assets/style-a91f2fe1.js +1 -0
- package/dist/assets/style-legacy.92f43969.js +1 -0
- package/dist/assets/subtitles-octopus-worker-62892886.wasm +0 -0
- package/dist/assets/subtitles-octopus-worker-f95f2186.js +1 -0
- package/dist/assets/text-editor-4cdde982.js +11 -0
- package/dist/assets/text-editor-legacy.c89be03c.js +1 -0
- package/dist/assets/ua-parser-5a8f43f2.js +1 -0
- package/dist/assets/ua-parser-legacy.5e4c06d6.js +1 -0
- package/dist/assets/url-64ba4724.js +1 -0
- package/dist/assets/url-legacy.bce70b79.js +1 -0
- package/dist/assets/useTitle-efd03a2a.js +1 -0
- package/dist/assets/useTitle-legacy.771fa6e1.js +1 -0
- package/dist/assets/video-e846152c.js +9 -0
- package/dist/assets/video-legacy.3e8def69.js +9 -0
- package/dist/assets/video360-7ff50eab.js +18 -0
- package/dist/assets/video360-f0192288.css +1 -0
- package/dist/assets/video360-legacy.53143d53.js +16 -0
- package/dist/assets/video_box-06f63821.js +18 -0
- package/dist/assets/video_box-legacy.95767478.js +8 -0
- package/dist/assets/webauthn-json.browser-ponyfill-f2f06d6e.js +1 -0
- package/dist/assets/webauthn-json.browser-ponyfill-legacy.1eb8248a.js +1 -0
- package/dist/images/config-active.png +0 -0
- package/dist/images/config-gray.png +0 -0
- package/dist/images/figplayer.webp +0 -0
- package/dist/images/fileball.webp +0 -0
- package/dist/images/filetypes/3GP.png +0 -0
- package/dist/images/filetypes/7z.png +0 -0
- package/dist/images/filetypes/AAC.png +0 -0
- package/dist/images/filetypes/AI-1.png +0 -0
- package/dist/images/filetypes/AI.png +0 -0
- package/dist/images/filetypes/AMR.png +0 -0
- package/dist/images/filetypes/ASE.png +0 -0
- package/dist/images/filetypes/ASP.png +0 -0
- package/dist/images/filetypes/ASPX.png +0 -0
- package/dist/images/filetypes/AU.png +0 -0
- package/dist/images/filetypes/AVI.png +0 -0
- package/dist/images/filetypes/BMP.png +0 -0
- package/dist/images/filetypes/C++.png +0 -0
- package/dist/images/filetypes/CAD.png +0 -0
- package/dist/images/filetypes/CFM.png +0 -0
- package/dist/images/filetypes/CGI.png +0 -0
- package/dist/images/filetypes/COM.png +0 -0
- package/dist/images/filetypes/CPP.png +0 -0
- package/dist/images/filetypes/CSS.png +0 -0
- package/dist/images/filetypes/CSV.png +0 -0
- package/dist/images/filetypes/DMG.png +0 -0
- package/dist/images/filetypes/DOC.png +0 -0
- package/dist/images/filetypes/DOCX.png +0 -0
- package/dist/images/filetypes/FLAC.png +0 -0
- package/dist/images/filetypes/GIF.png +0 -0
- package/dist/images/filetypes/GZ.png +0 -0
- package/dist/images/filetypes/ICO.png +0 -0
- package/dist/images/filetypes/ISO.png +0 -0
- package/dist/images/filetypes/JAVA.png +0 -0
- package/dist/images/filetypes/JPEG.png +0 -0
- package/dist/images/filetypes/JPG.png +0 -0
- package/dist/images/filetypes/JSON.png +0 -0
- package/dist/images/filetypes/MDF.png +0 -0
- package/dist/images/filetypes/MMF.png +0 -0
- package/dist/images/filetypes/MOV.png +0 -0
- package/dist/images/filetypes/MP3.png +0 -0
- package/dist/images/filetypes/MP4.png +0 -0
- package/dist/images/filetypes/MPG-1.png +0 -0
- package/dist/images/filetypes/MPG.png +0 -0
- package/dist/images/filetypes/MSI.png +0 -0
- package/dist/images/filetypes/OBJ.png +0 -0
- package/dist/images/filetypes/OTF.png +0 -0
- package/dist/images/filetypes/PDF.png +0 -0
- package/dist/images/filetypes/PHP.png +0 -0
- package/dist/images/filetypes/PKG.png +0 -0
- package/dist/images/filetypes/PNG-1.png +0 -0
- package/dist/images/filetypes/PNG.png +0 -0
- package/dist/images/filetypes/PPT-1.png +0 -0
- package/dist/images/filetypes/PPT.png +0 -0
- package/dist/images/filetypes/PPTX.png +0 -0
- package/dist/images/filetypes/PSD.png +0 -0
- package/dist/images/filetypes/PY.png +0 -0
- package/dist/images/filetypes/RM.png +0 -0
- package/dist/images/filetypes/RMVB.png +0 -0
- package/dist/images/filetypes/SQL.png +0 -0
- package/dist/images/filetypes/SRT.png +0 -0
- package/dist/images/filetypes/SVG.png +0 -0
- package/dist/images/filetypes/TAR.png +0 -0
- package/dist/images/filetypes/TIF-1.png +0 -0
- package/dist/images/filetypes/TIF.png +0 -0
- package/dist/images/filetypes/TIFF.png +0 -0
- package/dist/images/filetypes/TXT-1.png +0 -0
- package/dist/images/filetypes/TXT.png +0 -0
- package/dist/images/filetypes/WAV.png +0 -0
- package/dist/images/filetypes/WMA.png +0 -0
- package/dist/images/filetypes/WMV.png +0 -0
- package/dist/images/filetypes/WPS.png +0 -0
- package/dist/images/filetypes/XLS.png +0 -0
- package/dist/images/filetypes/XLSX.png +0 -0
- package/dist/images/filetypes/XML.png +0 -0
- package/dist/images/filetypes/ZIP.png +0 -0
- package/dist/images/filetypes/aif.png +0 -0
- package/dist/images/filetypes/apk.png +0 -0
- package/dist/images/filetypes/exe.png +0 -0
- package/dist/images/filetypes/htm.png +0 -0
- package/dist/images/filetypes/html.png +0 -0
- package/dist/images/filetypes/ipa.png +0 -0
- package/dist/images/filetypes/rar.png +0 -0
- package/dist/images/filetypes/rat.png +0 -0
- package/dist/images/filetypes/tipa.png +0 -0
- package/dist/images/iPlay.webp +0 -0
- package/dist/images/iina.webp +0 -0
- package/dist/images/infuse.webp +0 -0
- package/dist/images/mpv.webp +0 -0
- package/dist/images/mxplayer-pro.webp +0 -0
- package/dist/images/mxplayer.webp +0 -0
- package/dist/images/new_bg.png +0 -0
- package/dist/images/new_icon.png +0 -0
- package/dist/images/nplayer.webp +0 -0
- package/dist/images/omniplayer.webp +0 -0
- package/dist/images/permissions-active.png +0 -0
- package/dist/images/permissions-gray.png +0 -0
- package/dist/images/potplayer.webp +0 -0
- package/dist/images/role-active.png +0 -0
- package/dist/images/role-gray.png +0 -0
- package/dist/images/tag-active.png +0 -0
- package/dist/images/tag-gray.png +0 -0
- package/dist/images/vlc.webp +0 -0
- package/dist/index.html +81 -0
- package/dist/static/epub.js/viewer.html +467 -0
- package/dist/static/manifest.json +13 -0
- package/dist/streamer/mitm.html +186 -0
- package/dist/streamer/sw.js +141 -0
- package/package.json +104 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
!function(){function e(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var i,a,n=[],s=!0,o=!1;try{for(r=r.call(e);!(s=(i=r.next()).done)&&(n.push(i.value),!t||n.length!==t);s=!0);}catch(l){o=!0,a=l}finally{try{s||null==r.return||r.return()}finally{if(o)throw a}}return n}(e,t)||h(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(){return t="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var a=r(e,t);if(a){var n=Object.getOwnPropertyDescriptor(a,t);return n.get?n.get.call(arguments.length<3?e:i):n.value}},t.apply(this,arguments)}function r(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}function i(e){var t="function"==typeof Map?new Map:void 0;return i=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return a(e,arguments,u(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),p(i,e)},i(e)}function a(e,t,r){return a=l()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var a=new(Function.bind.apply(e,i));return r&&p(a,r.prototype),a},a.apply(null,arguments)}function n(e){var t=l();return function(){var r,i=u(e);if(t){var a=u(this).constructor;r=Reflect.construct(i,arguments,a)}else r=i.apply(this,arguments);return s(this,r)}}function s(e,t){if(t&&("object"===c(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return o(e)}function o(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function d(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function v(){v=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,i,a){var n=new RegExp(e,i);return t.set(n,a||t.get(e)),p(n,r.prototype)}function i(e,r){var i=t.get(r);return Object.keys(i).reduce((function(t,r){return t[r]=e[i[r]],t}),Object.create(null))}return g(r,RegExp),r.prototype.exec=function(t){var r=e.exec.call(this,t);return r&&(r.groups=i(r,this)),r},r.prototype[Symbol.replace]=function(r,a){if("string"==typeof a){var n=t.get(this);return e[Symbol.replace].call(this,r,a.replace(/\$<([^>]+)>/g,(function(e,t){return"$"+n[t]})))}if("function"==typeof a){var s=this;return e[Symbol.replace].call(this,r,(function(){var e=arguments;return"object"!=c(e[e.length-1])&&(e=[].slice.call(e)).push(i(e,s)),a.apply(this,e)}))}return e[Symbol.replace].call(this,r,a)},v.apply(this,arguments)}function g(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},p(e,t)}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){k(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */E=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",n=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function o(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{o({},"")}catch(w){o=function(e,t,r){return e[t]=r}}function l(e,t,r,i){var a=t&&t.prototype instanceof h?t:h,n=Object.create(a.prototype),s=new A(i||[]);return n._invoke=function(e,t,r){var i="suspendedStart";return function(a,n){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===a)throw n;return I()}for(r.method=a,r.arg=n;;){var s=r.delegate;if(s){var o=S(s,r);if(o){if(o===d)continue;return o}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===i)throw i="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i="executing";var l=u(e,t,r);if("normal"===l.type){if(i=r.done?"completed":"suspendedYield",l.arg===d)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i="completed",r.method="throw",r.arg=l.arg)}}}(e,r,s),n}function u(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(w){return{type:"throw",arg:w}}}e.wrap=l;var d={};function h(){}function f(){}function v(){}var g={};o(g,a,(function(){return this}));var p=Object.getPrototypeOf,m=p&&p(p(R([])));m&&m!==t&&r.call(m,a)&&(g=m);var y=v.prototype=h.prototype=Object.create(g);function k(e){["next","throw","return"].forEach((function(t){o(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function i(a,n,s,o){var l=u(e[a],e,n);if("throw"!==l.type){var d=l.arg,h=d.value;return h&&"object"==c(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){i("next",e,s,o)}),(function(e){i("throw",e,s,o)})):t.resolve(h).then((function(e){d.value=e,s(d)}),(function(e){return i("throw",e,s,o)}))}o(l.arg)}var a;this._invoke=function(e,r){function n(){return new t((function(t,a){i(e,r,t,a)}))}return a=a?a.then(n,n):n()}}function S(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,S(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=u(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function R(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,n=function t(){for(;++i<e.length;)if(r.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:I}}function I(){return{value:void 0,done:!0}}return f.prototype=v,o(y,"constructor",v),o(v,"constructor",f),f.displayName=o(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,o(e,s,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},k(T.prototype),o(T.prototype,n,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,i,a,n){void 0===n&&(n=Promise);var s=new T(l(t,r,i,a),n);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},k(y),o(y,s,"Generator"),o(y,a,(function(){return this})),o(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var i=t.pop();if(i in e)return r.value=i,r.done=!1,r}return r.done=!0,r}},e.values=R,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function i(r,i){return s.type="throw",s.arg=e,t.next=r,i&&(t.method="next",t.arg=void 0),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var n=this.tryEntries[a],s=n.completion;if("root"===n.tryLoc)return i("end");if(n.tryLoc<=this.prev){var o=r.call(n,"catchLoc"),l=r.call(n,"finallyLoc");if(o&&l){if(this.prev<n.catchLoc)return i(n.catchLoc,!0);if(this.prev<n.finallyLoc)return i(n.finallyLoc)}else if(o){if(this.prev<n.catchLoc)return i(n.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<n.finallyLoc)return i(n.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var n=a;break}}n&&("break"===e||"continue"===e)&&n.tryLoc<=t&&t<=n.finallyLoc&&(n=null);var s=n?n.completion:{};return s.type=e,s.arg=t,n?(this.method="next",this.next=n.finallyLoc,d):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),L(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var a=i.arg;L(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:R(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function T(e,t,r,i,a,n,s){try{var o=e[n](s),l=o.value}catch(u){return void r(u)}o.done?t(l):Promise.resolve(l).then(i,a)}function S(e){return function(){var t=this,r=arguments;return new Promise((function(i,a){var n=e.apply(t,r);function s(e){T(n,i,a,s,o,"next",e)}function o(e){T(n,i,a,s,o,"throw",e)}s(void 0)}))}}function b(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function L(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function A(e,t,r){return t&&L(e.prototype,t),r&&L(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}System.register(["./index-legacy.62c06d64.js","./index-legacy.de03403a.js"],(function(r,a){"use strict";var s,l,f;return{setters:[function(e){s=e.d8,l=e.d7},function(e){f=e.a}],execute:function(){var a;r("a",(function(e){return function(){var t=S(E().mark((function t(r){return E().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=T,t.t1=y,t.t2={"times new roman":R( window.__dynamic_base__+"/assets/TimesNewRoman-d9fb32eb.ttf")},t.next=5,I({workerUrl: window.__dynamic_base__+"/assets/subtitles-octopus-worker-f95f2186.js",wasmUrl: window.__dynamic_base__+"/assets/subtitles-octopus-worker-62892886.wasm"});case 5:return t.t3=t.sent,t.t4=R( window.__dynamic_base__+"/assets/SourceHanSansCN-Bold-b5627435.woff2"),t.t5=r.template.$video,t.t6={availableFonts:t.t2,workerUrl:t.t3,fallbackFont:t.t4,video:t.t5},t.t7=e,t.t8=(0,t.t1)(t.t6,t.t7),(L=new t.t0(t.t8)).canvasParent.className="artplayer-plugin-ass",L.canvasParent.style.cssText="\n position: absolute;\n width: 100%;\n height: 100%;\n user-select: none;\n pointer-events: none;\n z-index: 20;\n ",r.on("artplayer-plugin-ass:switch",(function(e){L.freeTrack(),L.setTrackByUrl(e),w(!0)})),r.on("subtitle",(function(e){return w(e)})),r.on("artplayer-plugin-ass:visible",(function(e){return w(e)})),r.on("subtitleOffset",(function(e){return L.timeOffset=e})),r.on("destroy",(function(){return L.dispose()})),t.abrupt("return",{name:"artplayerPluginAss",instance:L});case 20:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()}));var p={exports:{}};!function(e,t){
|
|
2
|
+
/*!
|
|
3
|
+
* artplayer-plugin-danmuku.js v5.1.5
|
|
4
|
+
* Github: https://github.com/zhw2590582/ArtPlayer
|
|
5
|
+
* (c) 2017-2025 Harvey Zack
|
|
6
|
+
* Released under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
!function(t,r,i,a,n){var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==l?l:{},o="function"==typeof s[a]&&s[a],u=o.cache||{},c="function"==typeof f&&f.bind(e);function d(e,r){if(!u[e]){if(!t[e]){var i="function"==typeof s[a]&&s[a];if(!r&&i)return i(e,!0);if(o)return o(e,!0);if(c&&"string"==typeof e)return c(e);var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}h.resolve=function(r){var i=t[e][1][r];return null!=i?i:r},h.cache={};var l=u[e]=new d.Module(e);t[e][0].call(l.exports,h,l,l.exports,this)}return u[e].exports;function h(e){var t=h.resolve(e);return!1===t?{}:d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.exports={}},d.modules=t,d.cache=u,d.parent=o,d.register=function(e,r){t[e]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return s[a]}}),s[a]=d;for(var h=0;h<r.length;h++)d(r[h]);var v=d(i);e.exports=v}({bgm6t:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"default",(function(){return c}));var a=e("./danmuku"),n=i.interopDefault(a),s=e("./setting"),o=i.interopDefault(s),l=e("./heatmap"),u=i.interopDefault(l);function c(e){return function(t){var r=new n.default(t,e),i=new o.default(t,r);return r.option.heatmap&&(0,u.default)(t,r,r.option.heatmap),{name:"artplayerPluginDanmuku",emit:r.emit.bind(r),load:r.load.bind(r),config:r.config.bind(r),hide:r.hide.bind(r),show:r.show.bind(r),reset:r.reset.bind(r),mount:i.mount.bind(i),get option(){return r.option},get isHide(){return r.isHide},get isStop(){return r.isStop}}}}c.icons=o.default.icons,"undefined"!=typeof window&&(window.artplayerPluginDanmuku=c)},{"./danmuku":"4ns48","./setting":"lO8OT","./heatmap":"8AxLD","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"4ns48":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r);var a=e("./bilibili"),n=e("bundle-text:./worker"),s=i.interopDefault(n),o=function(){function e(t,r){b(this,e);var i=t.constructor,a=t.template;this.utils=i.utils,this.validator=i.validator,this.$danmuku=a.$danmuku,this.$player=a.$player,this.art=t,this.queue=[],this.$refs=[],this.isStop=!1,this.isHide=!1,this.timer=null,this.index=0,this.option=e.option,this.states={wait:[],ready:[],emit:[],stop:[]},this.config(r);var n=new Blob([s.default],{type:"application/javascript"});this.worker=new Worker(URL.createObjectURL(n)),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this.reset=this.reset.bind(this),this.resize=this.resize.bind(this),this.destroy=this.destroy.bind(this),t.on("video:play",this.start),t.on("video:playing",this.start),t.on("video:pause",this.stop),t.on("video:waiting",this.stop),t.on("destroy",this.destroy),t.on("resize",this.resize),this.load()}var t,r;return A(e,[{key:"isRotate",get:function(){var e,t;return null===(e=this.art.plugins)||void 0===e||null===(t=e.autoOrientation)||void 0===t?void 0:t.state}},{key:"marginTop",get:function(){var t=this.utils.clamp,r=this.option.margin[0],i=this.$player.clientHeight;return"number"==typeof r?t(r,0,i):"string"==typeof r&&r.endsWith("%")?t(i*(parseFloat(r)/100),0,i):e.option.margin[0]}},{key:"marginBottom",get:function(){var t=this.utils.clamp,r=this.option.margin[1],i=this.$player.clientHeight;return"number"==typeof r?t(r,0,i):"string"==typeof r&&r.endsWith("%")?t(i*(parseFloat(r)/100),0,i):e.option.margin[1]}},{key:"fontSize",get:function(){var t=this.utils.clamp,r=this.$player.clientHeight,i=this.option.fontSize;return"number"==typeof i?Math.round(t(i,12,r)):"string"==typeof i&&i.endsWith("%")?Math.round(t(r*(parseFloat(i)/100),12,r)):e.option.fontSize}},{key:"$ref",get:function(){var t=this.$refs.pop()||document.createElement("div");return t.style.cssText=e.cssText,t.dataset.mode="",t.className="",t}},{key:"readys",get:function(){var e=this.art.currentTime,t=[];return this.filter("ready",(function(e){return t.push(e)})),this.filter("wait",(function(r){e+.1>=r.time&&r.time>=e-.1&&t.push(r)})),t}},{key:"visibles",get:function(){var e=this,t=[],r=this.$player.clientWidth,i=this.getLeft(this.$player);return this.filter("emit",(function(a){var n=a.$ref.offsetTop,s=e.getLeft(a.$ref)-i,o=a.$ref.clientHeight,l=a.$ref.clientWidth,u=s+l,c=u/a.$restTime,d={};d.top=n,d.left=s,d.height=o,d.width=l,d.right=r-u,d.speed=c,d.distance=u,d.time=a.$restTime,d.mode=a.mode,t.push(d)})),t}},{key:"speed",get:function(){return this.option.synchronousPlayback&&this.art.playbackRate?this.option.speed/Number(this.art.playbackRate):this.option.speed}},{key:"load",value:(r=S(E().mark((function e(t){var r,i,n,s,o;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.utils.errorHandle,i=[],n=t||this.option.danmuku,e.prev=1,"function"!=typeof n){e.next=8;break}return e.next=5,n();case 5:i=e.sent,e.next=21;break;case 8:if(!(n instanceof Promise)){e.next=14;break}return e.next=11,n;case 11:i=e.sent,e.next=21;break;case 14:if("string"!=typeof n){e.next=20;break}return e.next=17,(0,a.bilibiliDanmuParseFromUrl)(n);case 17:i=e.sent,e.next=21;break;case 20:Array.isArray(n)&&(i=n);case 21:r(Array.isArray(i),"Danmuku need return an array as result"),void 0===t&&(this.reset(),this.queue=[],this.states={wait:[],ready:[],emit:[],stop:[]},this.$refs=[],this.$danmuku.innerText=""),s=0;case 24:if(!(s<i.length)){e.next=31;break}return o=i[s],e.next=28,this.emit(o);case 28:s++,e.next=24;break;case 31:this.art.emit("artplayerPluginDanmuku:loaded",this.queue),e.next=37;break;case 34:throw e.prev=34,e.t0=e.catch(1),this.art.emit("artplayerPluginDanmuku:error",e.t0),e.t0;case 37:return e.abrupt("return",this);case 38:case"end":return e.stop()}}),e,this,[[1,34]])}))),function(e){return r.apply(this,arguments)})},{key:"emit",value:(t=S(E().mark((function e(t){var r,i;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.utils.clamp,this.validator(t,{text:"string",mode:"?number",color:"?string",time:"?number",border:"?boolean",style:"?object"}),t.text.trim()&&(t.time?t.time=r(t.time,0,1/0):t.time=this.art.currentTime+.5,void 0===t.mode&&(t.mode=this.option.mode),void 0===t.style&&(t.style={}),void 0===t.color&&(t.color=this.option.color),[0,1,2].includes(t.mode)&&this.option.filter(t))){e.next=3;break}return e.abrupt("return",this);case 3:return i=y(y({},t),{},{$state:"wait",$id:this.index++,$ref:null,$restTime:0,$lastStartTime:0}),e.abrupt("return",(this.setState(i,"wait"),this.queue.push(i),this));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"config",value:function(t){var r=this,i=this.utils.clamp,a=this.art.template.$controlsCenter;return Object.keys(t).some((function(e){return JSON.stringify(r.option[e])!==JSON.stringify(t[e])}))&&(this.option=Object.assign({},e.option,this.option,t),this.validator(this.option,e.scheme),this.option.mode=i(this.option.mode,0,2),this.option.speed=i(this.option.speed,1,10),this.option.opacity=i(this.option.opacity,0,1),this.option.lockTime=i(this.option.lockTime,1,60),this.option.maxLength=i(this.option.maxLength,1,1e3),this.option.mount=this.option.mount||a,t.fontSize&&this.reset(),this.option.visible?this.show():this.hide(),this.art.emit("artplayerPluginDanmuku:config",this.option)),this}},{key:"getLeft",value:function(e){var t=e.getBoundingClientRect();return this.isRotate?t.top:t.left}},{key:"postMessage",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new Promise((function(r){t.id=Date.now(),e.worker.postMessage(t),e.worker.onmessage=function(e){var i=e.data;i.id===t.id&&r(i)}}))}},{key:"filter",value:function(e,t){for(var r=this.states[e]||[],i=0;i<r.length;i++)t(r[i]);return r}},{key:"setState",value:function(e,t){this.states[e.$state]=this.states[e.$state].filter((function(t){return t!==e})),e.$state=t,e.$ref&&(e.$ref.dataset.state=t),this.states[t].push(e)}},{key:"makeWait",value:function(t){this.setState(t,"wait"),t.$ref&&(t.$ref.style.cssText=e.cssText,t.$ref.style.visibility="hidden",t.$ref.style.marginLeft="0px",t.$ref.style.transform="translateX(0px)",t.$ref.style.transition="transform 0s linear 0s",this.$refs.push(t.$ref),t.$ref=null)}},{key:"update",value:function(){var e=this,t=this.utils.setStyles;return this.timer=window.requestAnimationFrame(S(E().mark((function r(){var i,a,n,s,o,l,u,c,d;return E().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!e.art.playing||e.isHide){r.next=31;break}e.filter("emit",(function(t){var r=(Date.now()-t.$lastStartTime)/1e3;t.$restTime-=r,t.$lastStartTime=Date.now(),t.$restTime<=0&&e.makeWait(t)})),i=e.readys,a=0;case 4:if(!(a<i.length)){r.next=31;break}return n=i[a],r.next=8,e.option.beforeVisible(n);case 8:if(!r.sent){r.next=28;break}return s=e.$player,o=s.clientWidth,l=s.clientHeight,n.$ref=e.$ref,n.$ref.innerText=n.text,e.$danmuku.appendChild(n.$ref),n.$ref.style.opacity=e.option.opacity,n.$ref.style.fontSize="".concat(e.fontSize,"px"),n.$ref.style.color=n.color,n.$ref.style.border=n.border?"1px solid ".concat(n.color):null,n.$ref.style.backgroundColor=n.border?"rgb(0 0 0 / 50%)":null,t(n.$ref,n.style),n.$lastStartTime=Date.now(),n.$restTime=e.speed,u=o+n.$ref.clientWidth,r.next=14,e.postMessage({type:"getDanmuTop",target:{mode:n.mode,height:n.$ref.clientHeight,speed:u/n.$restTime},visibles:e.visibles,antiOverlap:e.option.antiOverlap,clientWidth:o,clientHeight:l,marginBottom:e.marginBottom,marginTop:e.marginTop});case 14:if(c=r.sent,d=c.result,!n.$ref){r.next=28;break}if(!e.isStop&&void 0!==d){r.next=21;break}e.setState(n,"ready"),e.$refs.push(n.$ref),n.$ref=null,r.next=28;break;case 21:r.t0=(e.setState(n,"emit"),n.$ref.style.top="".concat(d,"px"),n.$ref.style.visibility="visible",n.$ref.dataset.mode=n.mode,n.mode),r.next=0===r.t0?24:1===r.t0||2===r.t0?26:27;break;case 24:return n.$ref.style.left="".concat(o,"px"),n.$ref.style.marginLeft="0px",n.$ref.style.transform="translateX(".concat(-u,"px)"),n.$ref.style.transition="transform ".concat(n.$restTime,"s linear 0s"),r.abrupt("break",27);case 26:n.$ref.style.left="50%",n.$ref.style.marginLeft="-".concat(n.$ref.clientWidth/2,"px");case 27:e.art.emit("artplayerPluginDanmuku:visible",n);case 28:a++,r.next=4;break;case 31:e.isStop||e.update();case 32:case"end":return r.stop()}}),r)})))),this}},{key:"resize",value:function(){var e=this.$player.clientWidth;this.filter("stop",(function(t){0===t.mode&&(t.$ref.style.left="".concat(e,"px"))})),this.filter("emit",(function(t){if(t.$lastStartTime=Date.now(),0===t.mode){var r=e+t.$ref.clientWidth;t.$ref.style.left="".concat(e,"px"),t.$ref.style.transform="translateX(".concat(-r,"px)"),t.$ref.style.transition="transform ".concat(t.$restTime,"s linear 0s")}}))}},{key:"continue",value:function(){var e=this,t=this.$player.clientWidth;return this.filter("stop",(function(r){if(e.setState(r,"emit"),r.$lastStartTime=Date.now(),0===r.mode){var i=t+r.$ref.clientWidth;r.$ref.style.transform="translateX(".concat(-i,"px)"),r.$ref.style.transition="transform ".concat(r.$restTime,"s linear 0s")}})),this}},{key:"suspend",value:function(){var e=this,t=this.$player.clientWidth;return this.filter("emit",(function(r){if(e.setState(r,"stop"),0===r.mode){var i=t-(e.getLeft(r.$ref)-e.getLeft(e.$player));r.$ref.style.transform="translateX(".concat(-i,"px)"),r.$ref.style.transition="transform 0s linear 0s"}})),this}},{key:"stop",value:function(){return this.isStop=!0,this.suspend(),window.cancelAnimationFrame(this.timer),this.art.emit("artplayerPluginDanmuku:stop"),this}},{key:"start",value:function(){return this.isStop=!1,this.continue(),this.update(),this.art.emit("artplayerPluginDanmuku:start"),this}},{key:"reset",value:function(){var e=this;return this.queue.forEach((function(t){return e.makeWait(t)})),this.art.emit("artplayerPluginDanmuku:reset"),this}},{key:"show",value:function(){return this.isHide=!1,this.$danmuku.style.opacity=1,this.option.visible=!0,this.art.emit("artplayerPluginDanmuku:show"),this}},{key:"hide",value:function(){return this.isHide=!0,this.$danmuku.style.opacity=0,this.option.visible=!1,this.art.emit("artplayerPluginDanmuku:hide"),this}},{key:"destroy",value:function(){this.stop(),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")}}],[{key:"option",get:function(){return{danmuku:[],speed:5,margin:[10,"25%"],opacity:1,color:"#FFFFFF",mode:0,modes:[0,1,2],fontSize:25,antiOverlap:!0,synchronousPlayback:!1,mount:void 0,heatmap:!1,width:512,points:[],filter:function(){return!0},beforeEmit:function(){return!0},beforeVisible:function(){return!0},visible:!0,emitter:!0,maxLength:200,lockTime:5,theme:"dark",OPACITY:{},FONT_SIZE:{},MARGIN:{},SPEED:{},COLOR:[]}}},{key:"scheme",get:function(){return{danmuku:"array|function|string",speed:"number",margin:"array",opacity:"number",color:"string",mode:"number",modes:"array",fontSize:"number|string",antiOverlap:"boolean",synchronousPlayback:"boolean",mount:"?htmldivelement|string",heatmap:"object|boolean",width:"number",points:"array",filter:"function",beforeEmit:"function",beforeVisible:"function",visible:"boolean",emitter:"boolean",maxLength:"number",lockTime:"number",theme:"string",OPACITY:"object",FONT_SIZE:"object",MARGIN:"object",SPEED:"object",COLOR:"array"}}},{key:"cssText",get:function(){return' user-select: none; position: absolute; white-space: pre; pointer-events: none; perspective: 500px; display: inline-block; will-change: transform; font-weight: normal; line-height: 1.125; visibility: hidden; font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif; 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; '}}]),e}();r.default=o},{"./bilibili":"f83sx","bundle-text:./worker":"lfIAi","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],f83sx:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");function a(e){switch(e){case 1:case 2:case 3:default:return 0;case 4:return 2;case 5:return 1}}function n(e){if("string"!=typeof e)return[];var t=new RegExp(v(/<d (?:[\s\S]*? )??p="([\s\S]+?)"(?: [\s\S]*?)?>([\s\S]+?)<\/d>/g,{p:1,text:2}));return Array.from(e.matchAll(t)).map((function(e){var t=e.groups.p.split(",");return t.length>=8?{text:e.groups.text.trim().replaceAll(""",'"').replaceAll("'","'").replaceAll("<","<").replaceAll(">",">").replaceAll("&","&"),time:Number(t[0]),mode:a(Number(t[1])),fontSize:Number(t[2]),color:"#".concat(Number(t[3]).toString(16)),timestamp:Number(t[4]),pool:Number(t[5]),userID:t[6],rowID:Number(t[7])}:null})).filter(Boolean)}function s(e){var t=e.data,r=t.xml,i=t.id;if(i&&r){var a=n(r);self.postMessage({danmus:a,id:i})}}function o(e){return new Promise(function(){var t=S(E().mark((function t(r){var i,o,l;return E().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,fetch(e);case 2:return i=t.sent,t.next=5,i.text();case 5:o=t.sent;try{l=function(){var e=new Blob([" ".concat(a.toString()," ").concat(n.toString()," onmessage = ").concat(s.toString()," ")],{type:"application/javascript"});return new Worker(URL.createObjectURL(e))}(),l.onmessage=function(e){var t=e.data,i=t.danmus;t.id&&i&&(r(i),l.terminate())},l.postMessage({xml:o,id:Date.now()})}catch(e){r(n(o))}case 7:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())}i.defineInteropFlag(r),i.export(r,"bilibiliDanmuParseFromUrl",(function(){return o}))},{"@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],"9pCYc":[function(e,t,r){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach((function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})})),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}],lfIAi:[function(e,t,r){t.exports='!function(e,t,n,o,i){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},f="function"==typeof r[o]&&r[o],l=f.cache||{},d="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,n){if(!l[t]){if(!e[t]){var i="function"==typeof r[o]&&r[o];if(!n&&i)return i(t,!0);if(f)return f(t,!0);if(d&&"string"==typeof t)return d(t);var h=Error("Cannot find module \'"+t+"\'");throw h.code="MODULE_NOT_FOUND",h}s.resolve=function(n){var o=e[t][1][n];return null!=o?o:n},s.cache={};var p=l[t]=new u.Module(t);e[t][0].call(p.exports,s,p,p.exports,this)}return l[t].exports;function s(e){var t=s.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=l,u.parent=f,u.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(u,"root",{get:function(){return r[o]}}),r[o]=u;for(var h=0;h<t.length;h++)u(t[h]);if(n){var p=u(n);"object"==typeof exports&&"undefined"!=typeof module?module.exports=p:"function"==typeof define&&define.amd&&define(function(){return p})}}({"59OZS":[function(e,t,n){function o({target:e,visibles:t,clientWidth:n,clientHeight:o,marginBottom:i,marginTop:r,antiOverlap:f}){let l=o-i,d=t.filter(t=>t.mode===e.mode&&t.top<=l).sort((e,t)=>e.top-t.top);if(0===d.length)return 2===e.mode?l-e.height:r;if(d.unshift({type:"top",top:0,left:0,right:0,height:r,width:n,speed:0,distance:n}),d.push({type:"bottom",top:l,left:0,right:0,height:i,width:n,speed:0,distance:n}),2===e.mode)for(let t=d.length-2;t>=0;t-=1){let n=d[t],o=d[t+1],i=n.top+n.height;if(o.top-i>=e.height)return o.top-e.height}else for(let t=1;t<d.length;t+=1){let n=d[t],o=d[t-1],i=o.top+o.height;if(n.top-i>=e.height)return i}let u=[];for(let e=1;e<d.length-1;e+=1){let t=d[e];if(u.length){let e=u[u.length-1];e[0].top===t.top?e.push(t):u.push([t])}else u.push([t])}if(f)switch(e.mode){case 0:{let t=u.find(t=>t.every(t=>!(n<t.distance)&&(e.speed<t.speed||t.right/(e.speed-t.speed)>t.time)));return t&&t[0]?t[0].top:void 0}case 1:case 2:return}else{switch(e.mode){case 0:u.sort((e,t)=>{let n=Math.min(...t.map(e=>e.right)),o=Math.min(...e.map(e=>e.right));return n*t.length-o*e.length});break;case 1:case 2:u.sort((e,t)=>{let n=Math.max(...t.map(e=>e.width));return Math.max(...e.map(e=>e.width))*e.length-n*t.length})}return u[0][0].top}}onmessage=e=>{let{data:t}=e;if(!t.id||!t.type)return;let n=(0,({getDanmuTop:o})[t.type])(t);self.postMessage({result:n,id:t.id})}},{}]},["59OZS"],"59OZS","parcelRequire4dc0");'},{}],lO8OT:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r);var a=e("bundle-text:./style.less"),n=i.interopDefault(a),s=e("bundle-text:./img/on.svg"),o=i.interopDefault(s),l=e("bundle-text:./img/off.svg"),u=i.interopDefault(l),c=e("bundle-text:./img/config.svg"),h=i.interopDefault(c),f=e("bundle-text:./img/style.svg"),v=i.interopDefault(f),g=e("bundle-text:./img/mode_0_off.svg"),p=i.interopDefault(g),m=e("bundle-text:./img/mode_0_on.svg"),k=i.interopDefault(m),T=e("bundle-text:./img/mode_1_off.svg"),L=i.interopDefault(T),R=e("bundle-text:./img/mode_1_on.svg"),I=i.interopDefault(R),w=e("bundle-text:./img/mode_2_off.svg"),D=i.interopDefault(w),_=e("bundle-text:./img/mode_2_on.svg"),x=i.interopDefault(_),P=e("bundle-text:./img/check_on.svg"),C=i.interopDefault(P),M=e("bundle-text:./img/check_off.svg"),O=i.interopDefault(M);if(r.default=function(){function e(t,r){var i=this;b(this,e),this.art=t,this.danmuku=r,this.utils=t.constructor.utils;var a=this.utils.setStyle,n=t.template.$controlsCenter;a(n,"display","flex"),this.template={$controlsCenter:n,$mount:n,$danmuku:null,$toggle:null,$config:null,$configPanel:null,$configModes:null,$style:null,$stylePanel:null,$styleModes:null,$colors:null,$opacitySlider:null,$opacityValue:null,$marginSlider:null,$marginValue:null,$fontSizeSlider:null,$fontSizeValue:null,$speedSlider:null,$speedValue:null,$input:null,$send:null},this.slider={opacity:null,margin:null,fontSize:null,speed:null},this.emitting=!1,this.isLock=!1,this.timer=null,this.createTemplate(),this.createSliders(),this.createEvents(),this.mount(this.option.mount),t.on("resize",(function(){return i.resize()})),t.on("fullscreen",(function(e){return i.onFullscreen(e)})),t.on("fullscreenWeb",(function(e){return i.onFullscreen(e)})),t.proxy(this.template.$config,"mouseenter",(function(){i.onMouseEnter({$control:i.template.$config,$panel:i.template.$configPanel})})),t.proxy(this.template.$style,"mouseenter",(function(){i.onMouseEnter({$control:i.template.$style,$panel:i.template.$stylePanel})}))}var t;return A(e,[{key:"option",get:function(){return this.danmuku.option}},{key:"outside",get:function(){return this.template.$mount!==this.template.$controlsCenter}},{key:"TEMPLATE",get:function(){var e=this.option;return'<div class="apd-toggle">'.concat(o.default).concat(u.default,'</div><div class="apd-config">').concat(h.default,'<div class="apd-config-panel"><div class="apd-config-panel-inner"><div class="apd-config-mode">按类型屏蔽<div class="apd-modes"><div data-mode="0" class="apd-mode">').concat(p.default).concat(k.default,'<div>滚动</div></div><div data-mode="1" class="apd-mode">').concat(L.default).concat(I.default,'<div>顶部</div></div><div data-mode="2" class="apd-mode">').concat(D.default).concat(x.default,'<div>底部</div></div></div></div><div class="apd-config-other"><div class="apd-other apd-anti-overlap">').concat(C.default).concat(O.default,' 防止弹幕重叠</div><div class="apd-other apd-sync-video">').concat(C.default).concat(O.default,' 同步视频速度</div></div><div class="apd-config-slider apd-config-opacity">不透明度<div class="apd-slider"></div><div class="apd-value">未知</div></div><div class="apd-config-slider apd-config-margin">显示区域<div class="apd-slider"></div><div class="apd-value">未知</div></div><div class="apd-config-slider apd-config-fontSize">弹幕字号<div class="apd-slider"></div><div class="apd-value">未知</div></div><div class="apd-config-slider apd-config-speed">弹幕速度<div class="apd-slider"></div><div class="apd-value">未知</div></div></div></div></div><div class="apd-emitter"><div class="apd-style">').concat(v.default,'<div class="apd-style-panel"><div class="apd-style-panel-inner"><div class="apd-style-mode">模式<div class="apd-modes"><div data-mode="0" class="apd-mode">').concat(k.default,'<div>滚动</div></div><div data-mode="1" class="apd-mode">').concat(I.default,'<div>顶部</div></div><div data-mode="2" class="apd-mode">').concat(x.default,'<div>底部</div></div></div></div><div class="apd-style-color">颜色<div class="apd-colors">').concat(this.COLOR.map((function(e){return'<div data-color="'.concat(e,'" class="apd-color" style="background-color: ').concat(e,'"></div>')})).join(""),'</div></div></div></div></div><input class="apd-input" placeholder="发个友善的弹幕见证当下" autocomplete="off" maxLength="').concat(e.maxLength,'" /><div class="apd-send">发送</div></div>')}},{key:"OPACITY",get:function(){return y({min:0,max:100,steps:[]},this.option.OPACITY)}},{key:"FONT_SIZE",get:function(){return y({min:12,max:120,steps:[]},this.option.FONT_SIZE)}},{key:"MARGIN",get:function(){return y({min:0,max:3,steps:[{name:"1/4",value:[10,"75%"]},{name:"半屏",value:[10,"50%"]},{name:"3/4",value:[10,"25%"]},{name:"满屏",value:[10,10]}]},this.option.MARGIN)}},{key:"SPEED",get:function(){return y({min:0,max:4,steps:[{name:"极慢",value:10},{name:"较慢",value:7.5,hide:!0},{name:"适中",value:5},{name:"较快",value:2.5,hide:!0},{name:"极快",value:1}]},this.option.SPEED)}},{key:"COLOR",get:function(){return this.option.COLOR.length?this.option.COLOR:["#FE0302","#FF7204","#FFAA02","#FFD302","#FFFF00","#A0EE00","#00CD00","#019899","#4266BE","#89D5FF","#CC0273","#222222","#9B9B9B","#FFFFFF"]}},{key:"query",value:function(e){return(0,this.utils.query)(e,this.template.$danmuku)}},{key:"append",value:function(e,t){var r=this.utils.append;d(e.children).some((function(e){return e===t}))||r(e,t)}},{key:"setData",value:function(e,t){var r=this.art.template.$player,i=this.template.$mount;r.dataset[e]=t,this.outside&&(i.dataset[e]=t)}},{key:"createTemplate",value:function(){var e=this.utils,t=e.createElement,r=e.tooltip,i=t("div");i.className="artplayer-plugin-danmuku",i.innerHTML=this.TEMPLATE,this.template.$danmuku=i,this.template.$toggle=this.query(".apd-toggle"),this.template.$config=this.query(".apd-config"),this.template.$configPanel=this.query(".apd-config-panel"),this.template.$configModes=this.query(".apd-config-mode .apd-modes"),this.template.$style=this.query(".apd-style"),this.template.$stylePanel=this.query(".apd-style-panel"),this.template.$styleModes=this.query(".apd-style-mode .apd-modes"),this.template.$colors=this.query(".apd-colors"),this.template.$antiOverlap=this.query(".apd-anti-overlap"),this.template.$syncVideo=this.query(".apd-sync-video"),this.template.$opacitySlider=this.query(".apd-config-opacity .apd-slider"),this.template.$opacityValue=this.query(".apd-config-opacity .apd-value"),this.template.$marginSlider=this.query(".apd-config-margin .apd-slider"),this.template.$marginValue=this.query(".apd-config-margin .apd-value"),this.template.$fontSizeSlider=this.query(".apd-config-fontSize .apd-slider"),this.template.$fontSizeValue=this.query(".apd-config-fontSize .apd-value"),this.template.$speedSlider=this.query(".apd-config-speed .apd-slider"),this.template.$speedValue=this.query(".apd-config-speed .apd-value"),this.template.$input=this.query(".apd-input"),this.template.$send=this.query(".apd-send");var a=this.template.$toggle;this.art.on("artplayerPluginDanmuku:show",(function(){r(a,"关闭弹幕")})),this.art.on("artplayerPluginDanmuku:hide",(function(){r(a,"打开弹幕")}))}},{key:"createEvents",value:function(){var e=this,t=this.template,r=t.$toggle,i=t.$configModes,a=t.$styleModes,n=t.$colors,s=t.$antiOverlap,o=t.$syncVideo,l=t.$send,u=t.$input;this.art.proxy(r,"click",(function(){e.danmuku.config({visible:!e.option.visible}),e.reset()})),this.art.proxy(i,"click",(function(t){var r=t.target.closest(".apd-mode");if(r){var i=Number(r.dataset.mode);e.option.modes.includes(i)?e.danmuku.config({modes:e.option.modes.filter((function(e){return e!==i}))}):e.danmuku.config({modes:[].concat(d(e.option.modes),[i])}),e.reset()}})),this.art.proxy(s,"click",(function(){e.danmuku.config({antiOverlap:!e.option.antiOverlap}),e.reset()})),this.art.proxy(o,"click",(function(){e.danmuku.config({synchronousPlayback:!e.option.synchronousPlayback}),e.reset()})),this.art.proxy(a,"click",(function(t){var r=t.target.closest(".apd-mode");if(r){var i=Number(r.dataset.mode);e.danmuku.config({mode:i}),e.reset()}})),this.art.proxy(n,"click",(function(t){var r=t.target.closest(".apd-color");r&&(e.danmuku.config({color:r.dataset.color}),e.reset())})),this.art.proxy(l,"click",(function(){return e.emit()})),this.art.proxy(u,"keypress",(function(t){"Enter"===t.key&&(t.preventDefault(),e.emit())}))}},{key:"createSliders",value:function(){var e=this;this.slider.opacity=this.createSlider(y(y({},this.OPACITY),{},{container:this.template.$opacitySlider,findIndex:function(){return Math.round(100*e.option.opacity)},onChange:function(t){e.template.$opacityValue.textContent="".concat(t,"%"),e.danmuku.config({opacity:t/100})}})),this.slider.margin=this.createSlider(y(y({},this.MARGIN),{},{container:this.template.$marginSlider,findIndex:function(){return e.MARGIN.steps.findIndex((function(t){return t.value[0]===e.option.margin[0]&&t.value[1]===e.option.margin[1]}))},onChange:function(t){var r=e.MARGIN.steps[t];r&&(e.template.$marginValue.textContent=r.name,e.danmuku.config({margin:r.value}))}})),this.slider.fontSize=this.createSlider(y(y({},this.FONT_SIZE),{},{container:this.template.$fontSizeSlider,findIndex:function(){return e.danmuku.fontSize},onChange:function(t){e.template.$fontSizeValue.textContent="".concat(t,"px"),t!==e.danmuku.fontSize&&e.danmuku.config({fontSize:t})}})),this.slider.speed=this.createSlider(y(y({},this.SPEED),{},{container:this.template.$speedSlider,findIndex:function(){return e.SPEED.steps.findIndex((function(t){return t.value===e.option.speed}))},onChange:function(t){var r=e.SPEED.steps[t];r&&(e.template.$speedValue.textContent=r.name,e.danmuku.config({speed:r.value}))}}))}},{key:"createSlider",value:function(e){var t=this,r=e.min,i=e.max,a=e.container,n=e.findIndex,s=e.onChange,o=e.steps,l=void 0===o?[]:o,u=this.utils,c=u.query,d=u.clamp;(0,u.setStyle)(a,"touch-action","none"),a.innerHTML='<div class="apd-slider-line"><div class="apd-slider-points">'.concat(l.map((function(){return'<div class="apd-slider-point"></div>'})).join(""),'</div><div class="apd-slider-progress"></div></div><div class="apd-slider-dot"></div><div class="apd-slider-steps">').concat(l.map((function(e){return e.hide?"":'<div class="apd-slider-step">'.concat(e.name,"</div>")})).join(""),"</div>");var h=c(".apd-slider-dot",a),f=c(".apd-slider-progress",a),v=!1;function g(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:n();if(!(e<r||e>i)){var t=(e-r)/(i-r);h.style.left="".concat(100*t,"%"),0===l.length&&(f.style.width=h.style.left),s(e)}}function p(e){var t=a.getBoundingClientRect(),n=t.top,s=t.height,o=t.left,l=t.width;this.art.isRotate?g(Math.round(d(e.clientY-n,0,s)/s*(i-r)+r)):g(Math.round(d(e.clientX-o,0,l)/l*(i-r)+r))}return this.art.proxy(a,"click",(function(e){p.call(t,e)})),this.art.proxy(a,"pointerdown",(function(e){v=0===e.button})),this.art.proxy(document,"pointermove",(function(e){v&&p.call(t,e)})),this.art.proxy(document,"pointerup",(function(e){v&&(v=!1,p.call(t,e))})),{reset:g}}},{key:"onFullscreen",value:function(e){var t=this.template,r=t.$danmuku,i=t.$controlsCenter,a=t.$mount;this.outside?e?this.append(i,r):this.append(a,r):this.append(i,r)}},{key:"onMouseEnter",value:function(e){var t=e.$control,r=e.$panel,i=this.art.template.$player,a=t.getBoundingClientRect(),n=r.getBoundingClientRect(),s=i.getBoundingClientRect(),o=n.width/2-a.width/2,l=s.left-(a.left-o),u=a.right+o-s.right;r.style.left="".concat(l>0?-o+l:u>0?-o-u:-o,"px")}},{key:"emit",value:(t=S(E().mark((function e(){var t,r,i,a;return E().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.template.$input,(r=t.value.trim()).length&&!this.isLock&&!this.emitting){e.next=3;break}return e.abrupt("return");case 3:return i={text:r,mode:this.option.mode,color:this.option.color,time:this.art.currentTime},e.prev=4,this.emitting=!0,e.next=8,this.option.beforeEmit(i);case 8:if(a=e.sent,this.emitting=!1,!0===a){e.next=11;break}return e.abrupt("return");case 11:i.border=!0,delete i.time,this.danmuku.emit(i),t.value="",this.lock(),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(4),this.emitting=!1;case 17:case"end":return e.stop()}}),e,this,[[4,14]])}))),function(){return t.apply(this,arguments)})},{key:"lock",value:function(){var e=this,t=this.utils.addClass,r=this.template.$send;this.isLock=!0;var i=this.option.lockTime;r.innerText=i,t(r,"apd-lock");!function t(){e.timer=setTimeout((function(){0===i?e.unlock():(i-=1,r.innerText=i,t())}),1e3)}()}},{key:"unlock",value:function(){var e=this.utils.removeClass,t=this.template.$send;clearTimeout(this.timer),this.isLock=!1,t.innerText="发送",e(t,"apd-lock")}},{key:"resize",value:function(){if(!(this.outside||this.art.fullscreen||this.art.fullscreenWeb)){var e=this.art.template,t=e.$player,r=e.$controlsCenter,i=this.template.$danmuku;this.art.width<this.option.width?this.append(t,i):this.append(r,i)}}},{key:"reset",value:function(){var e=this,t=this.utils,r=t.inverseClass,i=t.tooltip,a=this.template,n=a.$toggle,s=a.$colors;this.slider.opacity.reset(),this.slider.margin.reset(),this.slider.fontSize.reset(),this.slider.speed.reset(),this.setData("danmukuVisible",this.option.visible),this.setData("danmukuMode",this.option.mode),this.setData("danmukuColor",this.option.color),this.setData("danmukuMode0",this.option.modes.includes(0)),this.setData("danmukuMode1",this.option.modes.includes(1)),this.setData("danmukuMode2",this.option.modes.includes(2)),this.setData("danmukuAntiOverlap",this.option.antiOverlap),this.setData("danmukuSyncVideo",this.option.synchronousPlayback),this.setData("danmukuTheme",this.option.theme),this.setData("danmukuEmitter",this.option.emitter);var o=Array.from(s.children).find((function(t){return t.dataset.color===e.option.color.toUpperCase()}));o&&r(o,"apd-active"),i(n,this.option.visible?"关闭弹幕":"打开弹幕"),this.resize()}},{key:"mount",value:function(e){var t=this.utils.errorHandle,r="string"==typeof e?document.querySelector(e):e;t(r,"Can not find the mount point: ".concat(e)),this.append(r,this.template.$danmuku),this.template.$mount=r,this.reset()}}],[{key:"icons",get:function(){return{$on:o.default,$off:u.default,$config:h.default,$style:v.default,$mode_0_off:p.default,$mode_0_on:k.default,$mode_1_off:L.default,$mode_1_on:I.default,$mode_2_off:D.default,$mode_2_on:x.default,$check_on:C.default,$check_off:O.default}}}]),e}(),"undefined"!=typeof document){var F="artplayer-plugin-danmuku",N=document.getElementById(F);if(N)N.textContent=n.default;else{var U=document.createElement("style");U.id=F,U.textContent=n.default,document.head.appendChild(U)}}},{"bundle-text:./style.less":"hViDo","bundle-text:./img/on.svg":"9pjcf","bundle-text:./img/off.svg":"b2dkP","bundle-text:./img/config.svg":"l8tyy","bundle-text:./img/style.svg":"5iZC3","bundle-text:./img/mode_0_off.svg":"i0Vut","bundle-text:./img/mode_0_on.svg":"hOSvZ","bundle-text:./img/mode_1_off.svg":"bOXC3","bundle-text:./img/mode_1_on.svg":"lKuh0","bundle-text:./img/mode_2_off.svg":"eB8W6","bundle-text:./img/mode_2_on.svg":"bpe2E","bundle-text:./img/check_on.svg":"kL9zy","bundle-text:./img/check_off.svg":"22xpM","@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}],hViDo:[function(e,t,r){t.exports='.artplayer-plugin-danmuku{z-index:99;color:#fff;flex-shrink:0;justify-content:center;align-items:center;gap:10px;width:100%;height:32px;font-size:12px;font-weight:300;display:flex;position:relative}.artplayer-plugin-danmuku .apd-icon{cursor:pointer;opacity:.75;fill:#fff;transition:all .2s}.artplayer-plugin-danmuku .apd-icon:hover{opacity:1}.artplayer-plugin-danmuku .apd-config{display:flex;position:relative}.artplayer-plugin-danmuku .apd-config .apd-config-panel{opacity:0;pointer-events:none;width:320px;padding:10px;position:absolute;bottom:24px;left:0}.artplayer-plugin-danmuku .apd-config .apd-config-panel .apd-config-panel-inner{background-color:#000000d9;border-radius:3px;width:100%;padding:10px}.artplayer-plugin-danmuku .apd-config:hover .apd-config-panel{opacity:100;pointer-events:all}.artplayer-plugin-danmuku .apd-config-mode,.artplayer-plugin-danmuku .apd-config-slider,.artplayer-plugin-danmuku .apd-config-other,.artplayer-plugin-danmuku .apd-style-mode{margin-bottom:15px}.artplayer-plugin-danmuku .apd-modes{align-items:center;gap:20px;margin-top:5px;display:flex}.artplayer-plugin-danmuku .apd-modes .apd-mode{cursor:pointer;text-align:center}.artplayer-plugin-danmuku .apd-modes .apd-mode:hover{color:#00a1d6}.artplayer-plugin-danmuku .apd-config-slider{align-items:center;gap:12px;display:flex}.artplayer-plugin-danmuku .apd-config-slider .apd-value{text-align:right;width:32px}.artplayer-plugin-danmuku .apd-slider{cursor:pointer;flex:1;justify-content:center;align-items:center;height:20px;display:flex;position:relative}.artplayer-plugin-danmuku .apd-slider .apd-slider-line{background-color:#ffffff40;border-radius:3px;width:100%;height:2px;position:relative;overflow:hidden}.artplayer-plugin-danmuku .apd-slider .apd-slider-points{justify-content:space-between;align-items:center;display:flex;position:absolute;inset:0}.artplayer-plugin-danmuku .apd-slider .apd-slider-points .apd-slider-point{background-color:#ffffff80;border-radius:50%;width:2px;height:2px}.artplayer-plugin-danmuku .apd-slider .apd-slider-progress{background-color:#00a1d6;width:0%;height:100%}.artplayer-plugin-danmuku .apd-slider .apd-slider-dot{background-color:#00a1d6;border-radius:50%;width:12px;height:12px;position:absolute;left:0%;transform:translate(-6px)}.artplayer-plugin-danmuku .apd-slider .apd-slider-steps{color:#777;justify-content:space-between;align-items:center;width:calc(100% + 32px);display:flex;position:absolute;bottom:-12px}.artplayer-plugin-danmuku .apd-slider .apd-slider-steps .apd-slider-step{text-align:center;flex-shrink:0;width:36px;scale:.95}.artplayer-plugin-danmuku .apd-config-other{align-items:center;gap:20px;display:flex}.artplayer-plugin-danmuku .apd-config-other .apd-check-off,.artplayer-plugin-danmuku .apd-config-other .apd-check-on{width:16px;height:16px}.artplayer-plugin-danmuku .apd-config-other .apd-other{cursor:pointer;align-items:center;gap:2px;display:flex}.artplayer-plugin-danmuku .apd-config-other .apd-other:hover{color:#00a1d6}.artplayer-plugin-danmuku .apd-emitter{background-color:#ffffff40;border-radius:5px;flex:1;align-items:center;height:100%;display:flex}.artplayer-plugin-danmuku .apd-style{justify-content:center;align-items:center;display:flex;position:relative}.artplayer-plugin-danmuku .apd-style .apd-style-panel{opacity:0;pointer-events:none;width:200px;padding:10px;position:absolute;bottom:24px;left:0}.artplayer-plugin-danmuku .apd-style .apd-style-panel .apd-style-panel-inner{background-color:#000000d9;border-radius:3px;width:100%;padding:10px}.artplayer-plugin-danmuku .apd-style:hover .apd-style-panel{opacity:100;pointer-events:all}.artplayer-plugin-danmuku .apd-colors{flex-wrap:wrap;gap:8px;margin-top:5px;display:flex}.artplayer-plugin-danmuku .apd-colors .apd-color{cursor:pointer;border-radius:2px;width:16px;height:16px}.artplayer-plugin-danmuku .apd-colors .apd-color.apd-active{border:1px solid #000;box-shadow:0 0 0 1px #fff}.artplayer-plugin-danmuku .apd-input{color:#fff;background-color:#0000;border:none;outline:none;flex:1;width:auto;min-width:0;height:100%;line-height:1}.artplayer-plugin-danmuku .apd-input::placeholder{color:#ffffff80}.artplayer-plugin-danmuku .apd-send{cursor:pointer;text-shadow:none;background-color:#00a1d6;border-top-right-radius:5px;border-bottom-right-radius:5px;flex-shrink:0;justify-content:center;align-items:center;width:60px;height:100%;display:flex}.artplayer-plugin-danmuku .apd-send.apd-lock{cursor:not-allowed;color:#666;background-color:#e7e7e7}.art-controls-center .apd-emitter{flex:none;width:260px}.art-fullscreen .artplayer-plugin-danmuku,.art-fullscreen-web .artplayer-plugin-danmuku{gap:16px;height:38px}.art-fullscreen .artplayer-plugin-danmuku .apd-config-icon,.art-fullscreen-web .artplayer-plugin-danmuku .apd-config-icon,.art-fullscreen .artplayer-plugin-danmuku .apd-toggle-off,.art-fullscreen-web .artplayer-plugin-danmuku .apd-toggle-off,.art-fullscreen .artplayer-plugin-danmuku .apd-toggle-on,.art-fullscreen-web .artplayer-plugin-danmuku .apd-toggle-on{width:28px;height:28px}.art-fullscreen .artplayer-plugin-danmuku .apd-emitter,.art-fullscreen-web .artplayer-plugin-danmuku .apd-emitter{flex:none;width:400px}.art-video-player>.artplayer-plugin-danmuku{padding:0 10px;position:absolute;bottom:-40px;left:0;right:0}.art-video-player:has(>.artplayer-plugin-danmuku){margin-bottom:40px}[data-danmuku-emitter=false] .apd-emitter{display:none!important}[data-danmuku-emitter=false] .art-controls-center .artplayer-plugin-danmuku{justify-content:flex-end;gap:18px}[data-danmuku-emitter=false].art-fullscreen .art-controls-center .artplayer-plugin-danmuku,[data-danmuku-emitter=false].art-fullscreen-web .art-controls-center .artplayer-plugin-danmuku{gap:24px}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-icon{fill:#333}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-emitter{background-color:#f1f2f3}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-input{color:#000}[data-danmuku-theme=light]>.artplayer-plugin-danmuku .apd-input::placeholder{color:#0000004d}[data-danmuku-visible=false] .apd-toggle-off{display:block}[data-danmuku-visible=false] .apd-toggle-on,[data-danmuku-visible=true] .apd-toggle-off{display:none}[data-danmuku-visible=true] .apd-toggle-on{display:block}[data-danmuku-anti-overlap=false] .apd-anti-overlap .apd-check-on{display:none}[data-danmuku-anti-overlap=false] .apd-anti-overlap .apd-check-off,[data-danmuku-anti-overlap=true] .apd-anti-overlap .apd-check-on{display:block}[data-danmuku-anti-overlap=true] .apd-anti-overlap .apd-check-off,[data-danmuku-sync-video=false] .apd-sync-video .apd-check-on{display:none}[data-danmuku-sync-video=false] .apd-sync-video .apd-check-off,[data-danmuku-sync-video=true] .apd-sync-video .apd-check-on{display:block}[data-danmuku-sync-video=true] .apd-sync-video .apd-check-off{display:none}[data-danmuku-mode0=false] .apd-config-mode .apd-mode-0-off{display:block}[data-danmuku-mode0=false] .apd-config-mode .apd-mode-0-on{display:none}[data-danmuku-mode0=false] .art-danmuku [data-mode="0"]{opacity:0!important}[data-danmuku-mode0=true] .apd-config-mode .apd-mode-0-off{display:none}[data-danmuku-mode0=true] .apd-config-mode .apd-mode-0-on{display:block}[data-danmuku-mode="0"] .apd-style-mode [data-mode="0"]{color:#00a1d6}[data-danmuku-mode="0"] .apd-style-mode [data-mode="0"] path{fill:#00a1d6}[data-danmuku-mode1=false] .apd-config-mode .apd-mode-1-off{display:block}[data-danmuku-mode1=false] .apd-config-mode .apd-mode-1-on{display:none}[data-danmuku-mode1=false] .art-danmuku [data-mode="1"]{opacity:0!important}[data-danmuku-mode1=true] .apd-config-mode .apd-mode-1-off{display:none}[data-danmuku-mode1=true] .apd-config-mode .apd-mode-1-on{display:block}[data-danmuku-mode="1"] .apd-style-mode [data-mode="1"]{color:#00a1d6}[data-danmuku-mode="1"] .apd-style-mode [data-mode="1"] path{fill:#00a1d6}[data-danmuku-mode2=false] .apd-config-mode .apd-mode-2-off{display:block}[data-danmuku-mode2=false] .apd-config-mode .apd-mode-2-on{display:none}[data-danmuku-mode2=false] .art-danmuku [data-mode="2"]{opacity:0!important}[data-danmuku-mode2=true] .apd-config-mode .apd-mode-2-off{display:none}[data-danmuku-mode2=true] .apd-config-mode .apd-mode-2-on{display:block}[data-danmuku-mode="2"] .apd-style-mode [data-mode="2"]{color:#00a1d6}[data-danmuku-mode="2"] .apd-style-mode [data-mode="2"] path{fill:#00a1d6}'},{}],"9pjcf":[function(e,t,r){t.exports='<svg class="apd-icon apd-toggle-on" xmlns="http://www.w3.org/2000/svg" data-pointer="none" viewBox="0 0 24 24" width="24" height="24"><path fill-rule="evenodd" d="M11.989 4.828c-.47 0-.975.004-1.515.012l-1.71-2.566a1.008 1.008 0 0 0-1.678 1.118l.999 1.5c-.681.018-1.403.04-2.164.068a4.013 4.013 0 0 0-3.83 3.44c-.165 1.15-.245 2.545-.245 4.185 0 1.965.115 3.67.35 5.116a4.012 4.012 0 0 0 3.763 3.363l.906.046c1.205.063 1.808.095 3.607.095a.988.988 0 0 0 0-1.975c-1.758 0-2.339-.03-3.501-.092l-.915-.047a2.037 2.037 0 0 1-1.91-1.708c-.216-1.324-.325-2.924-.325-4.798 0-1.563.076-2.864.225-3.904.14-.977.96-1.713 1.945-1.747 2.444-.087 4.465-.13 6.063-.131 1.598 0 3.62.044 6.064.13.96.034 1.71.81 1.855 1.814.075.524.113 1.962.141 3.065v.002c.01.342.017.65.025.88a.987.987 0 1 0 1.974-.068c-.008-.226-.016-.523-.025-.856v-.027c-.03-1.118-.073-2.663-.16-3.276-.273-1.906-1.783-3.438-3.74-3.507-.9-.032-1.743-.058-2.531-.078l1.05-1.46a1.008 1.008 0 0 0-1.638-1.177l-1.862 2.59c-.38-.004-.744-.007-1.088-.007h-.13Zm.521 4.775h-1.32v4.631h2.222v.847h-2.618v1.078h2.618l.003.678c.36.026.714.163 1.01.407h.11v-1.085h2.694v-1.078h-2.695v-.847H16.8v-4.63h-1.276a8.59 8.59 0 0 0 .748-1.42L15.183 7.8a14.232 14.232 0 0 1-.814 1.804h-1.518l.693-.308a8.862 8.862 0 0 0-.814-1.408l-1.045.352c.297.396.572.847.825 1.364Zm-4.18 3.564.154-1.485h1.98V8.294h-3.2v.98H9.33v1.43H7.472l-.308 3.453h2.277c0 1.166-.044 1.925-.12 2.277-.078.352-.386.528-.936.528-.308 0-.616-.022-.902-.055l.297 1.067.062.005c.285.02.551.04.818.04 1.001-.067 1.562-.419 1.694-1.057.11-.638.176-1.903.176-3.795h-2.2Zm7.458.11v-.858h-1.254v.858h1.254Zm-2.376-.858v.858h-1.199v-.858h1.2Zm-1.199-.946h1.2v-.902h-1.2v.902Zm2.321 0v-.902h1.254v.902h-1.254Z" clip-rule="evenodd"/><path fill="#00AEEC" fill-rule="evenodd" d="M22.846 14.627a1 1 0 0 0-1.412.075l-5.091 5.703-2.216-2.275-.097-.086-.008-.005a1 1 0 0 0-1.322 1.493l2.963 3.041.093.083.007.005a1 1 0 0 0 1.354-.124l5.81-6.505.08-.102.005-.008a1 1 0 0 0-.166-1.295Z" clip-rule="evenodd"/></svg>'},{}],b2dkP:[function(e,t,r){t.exports='<svg class="apd-icon apd-toggle-off" xmlns="http://www.w3.org/2000/svg" data-pointer="none" viewBox="0 0 24 24" width="24" height="24"><path fill-rule="evenodd" d="m8.085 4.891-.999-1.499a1.008 1.008 0 0 1 1.679-1.118l1.709 2.566c.54-.008 1.045-.012 1.515-.012h.13c.345 0 .707.003 1.088.007l1.862-2.59a1.008 1.008 0 0 1 1.637 1.177l-1.049 1.46c.788.02 1.631.046 2.53.078 1.958.069 3.468 1.6 3.74 3.507.088.613.13 2.158.16 3.276l.001.027c.01.333.017.63.025.856a.987.987 0 0 1-1.974.069c-.008-.23-.016-.539-.025-.881v-.002c-.028-1.103-.066-2.541-.142-3.065-.143-1.004-.895-1.78-1.854-1.813a179.14 179.14 0 0 0-6.064-.131c-1.598 0-3.619.044-6.063.13a2.037 2.037 0 0 0-1.945 1.748c-.15 1.04-.225 2.341-.225 3.904 0 1.874.11 3.474.325 4.798.154.949.95 1.66 1.91 1.708a97.58 97.58 0 0 0 5.416.139.988.988 0 0 1 0 1.975 99.78 99.78 0 0 1-5.513-.141A4.012 4.012 0 0 1 2.197 17.7c-.236-1.446-.351-3.151-.351-5.116 0-1.64.08-3.035.245-4.184A4.013 4.013 0 0 1 5.92 4.96c.761-.027 1.483-.05 2.164-.069Zm4.436 4.707h-1.32v4.63h2.222v.848h-2.618v1.078h2.431a5.01 5.01 0 0 1 3.575-3.115V9.598h-1.276a8.59 8.59 0 0 0 .748-1.42l-1.089-.384a14.232 14.232 0 0 1-.814 1.804h-1.518l.693-.308a8.862 8.862 0 0 0-.814-1.408l-1.045.352c.297.396.572.847.825 1.364Zm-4.18 3.564.154-1.485h1.98V8.289h-3.2v.979h2.067v1.43H7.483l-.308 3.454h2.277c0 1.166-.044 1.925-.12 2.277-.078.352-.386.528-.936.528-.308 0-.616-.022-.902-.055l.297 1.067.062.004c.285.02.551.04.818.04 1.001-.066 1.562-.418 1.694-1.056.11-.638.176-1.903.176-3.795h-2.2Zm7.458.11v-.858h-1.254v.858H15.8Zm-2.376-.858v.858h-1.199v-.858h1.2Zm-1.199-.946h1.2v-.902h-1.2v.902Zm2.321 0v-.902H15.8v.902h-1.254Zm3.517 10.594a4 4 0 1 0 0-8 4 4 0 0 0 0 8Zm-.002-1.502a2.5 2.5 0 0 1-2.217-3.657l3.326 3.398a2.49 2.49 0 0 1-1.109.259Zm2.5-2.5c0 .42-.103.815-.286 1.162l-3.328-3.401a2.5 2.5 0 0 1 3.614 2.239Z" clip-rule="evenodd"/></svg>'},{}],l8tyy:[function(e,t,r){t.exports='<svg class="apd-icon apd-config-icon" xmlns="http://www.w3.org/2000/svg" data-pointer="none" viewBox="0 0 24 24" width="24" height="24"><path fill-rule="evenodd" d="m15.645 4.881 1.06-1.473a.998.998 0 1 0-1.622-1.166L13.22 4.835a110.67 110.67 0 0 0-1.1-.007h-.131c-.47 0-.975.004-1.515.012L8.783 2.3A.998.998 0 0 0 7.12 3.408l.988 1.484c-.688.019-1.418.042-2.188.069a4.013 4.013 0 0 0-3.83 3.44c-.165 1.15-.245 2.545-.245 4.185 0 1.965.115 3.67.35 5.116a4.012 4.012 0 0 0 3.763 3.363 99.78 99.78 0 0 0 5.513.141.988.988 0 0 0 0-1.975 97.58 97.58 0 0 1-5.416-.139 2.037 2.037 0 0 1-1.91-1.708c-.216-1.324-.325-2.924-.325-4.798 0-1.563.076-2.864.225-3.904.14-.977.96-1.713 1.945-1.747 2.444-.087 4.465-.13 6.063-.131 1.598 0 3.62.044 6.064.13.96.034 1.71.81 1.855 1.814.075.524.113 1.962.141 3.065v.002c.005.183.01.07.014-.038.004-.096.008-.189.011-.081a.987.987 0 1 0 1.974-.069c-.004-.105-.007-.009-.011.09a2.175 2.175 0 0 1-.007.135l-.002.01a.574.574 0 0 1-.005-.091v-.027c-.03-1.118-.073-2.663-.16-3.276-.273-1.906-1.783-3.438-3.74-3.507-.905-.032-1.752-.058-2.543-.079Zm-3.113 4.703h-1.307v4.643h2.2v.04l.651-1.234c.113-.215.281-.389.482-.509v-.11h.235c.137-.049.283-.074.433-.074h1.553V9.584h-1.264a8.5 8.5 0 0 0 .741-1.405l-1.078-.381c-.24.631-.501 1.23-.806 1.786h-1.503l.686-.305a8.613 8.613 0 0 0-.806-1.394l-1.034.348c.294.392.566.839.817 1.35Zm-1.7 5.502h2.16l-.564 1.068h-1.595v-1.068Zm-2.498-1.863.152-1.561h1.96V8.289H7.277v.969h2.048v1.435h-1.84l-.306 3.51h2.254c0 1.155-.043 1.906-.12 2.255-.076.348-.38.523-.925.523-.305 0-.61-.022-.893-.055l.294 1.056.061.005c.282.02.546.039.81.039.991-.065 1.547-.414 1.677-1.046.11-.631.175-1.883.175-3.757H8.334Zm5.09-.8v.85h-1.188v-.85h1.187Zm-1.188-.955h1.187v-.893h-1.187v.893Zm2.322.007v-.893h1.241v.893h-1.241Zm.528 2.757a1.26 1.26 0 0 1 1.087-.627l4.003-.009a1.26 1.26 0 0 1 1.094.63l1.721 2.982c.226.39.225.872-.001 1.263l-1.743 3a1.26 1.26 0 0 1-1.086.628l-4.003.009a1.26 1.26 0 0 1-1.094-.63l-1.722-2.982a1.26 1.26 0 0 1 .002-1.263l1.742-3Zm1.967.858a1.26 1.26 0 0 0-1.08.614l-.903 1.513a1.26 1.26 0 0 0-.002 1.289l.885 1.492c.227.384.64.62 1.086.618l2.192-.005a1.26 1.26 0 0 0 1.08-.615l.904-1.518a1.26 1.26 0 0 0 .001-1.288l-.884-1.489a1.26 1.26 0 0 0-1.086-.616l-2.193.005Zm2.517 2.76a1.4 1.4 0 1 1-2.8 0 1.4 1.4 0 0 1 2.8 0Z" clip-rule="evenodd"/></svg>'},{}],"5iZC3":[function(e,t,r){t.exports='<svg class="apd-icon apd-style-icon" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" data-pointer="none" style="enable-background:new 0 0 22 22" viewBox="0 0 22 22" width="36" 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>'},{}],i0Vut:[function(e,t,r){t.exports='<svg class="apd-icon apd-mode-0-off" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" data-pointer="none" style="enable-background:new 0 0 28 28" viewBox="0 0 28 28" width="28" height="28"><path d="M23 15c1.487 0 2.866.464 4 1.255V7a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h11.674A7 7 0 0 1 23 15zM11 9h6a1 1 0 0 1 0 2h-6a1 1 0 0 1 0-2zm-3 2H6V9h2v2zm4 4h-2v-2h2v2zm2-1a1 1 0 0 1 1-1h1a1 1 0 0 1 0 2h-1a1 1 0 0 1-1-1z" fill="#00AEEC"/><path d="M26.536 18.464a5 5 0 0 0-7.071 0 5 5 0 0 0 0 7.071 5 5 0 1 0 7.071-7.071zm-5.657 5.657a3 3 0 0 1-.586-3.415l4.001 4.001a3 3 0 0 1-3.415-.586zm4.829-.827-4.001-4.001a3.002 3.002 0 0 1 4.001 4.001z" fill="#00AEEC"/></svg>'},{}],hOSvZ:[function(e,t,r){t.exports='<svg class="apd-icon apd-mode-0-on" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" data-pointer="none" style="enable-background:new 0 0 28 28" viewBox="0 0 28 28" width="28" height="28"><path d="M23 3H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h18a4 4 0 0 0 4-4V7a4 4 0 0 0-4-4zM11 9h6a1 1 0 0 1 0 2h-6a1 1 0 0 1 0-2zm-3 2H6V9h2v2zm4 4h-2v-2h2v2zm9 0h-6a1 1 0 0 1 0-2h6a1 1 0 0 1 0 2z" fill="#FFF"/></svg>'},{}],bOXC3:[function(e,t,r){t.exports='<svg class="apd-icon apd-mode-1-off" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" data-pointer="none" style="enable-background:new 0 0 28 28" viewBox="0 0 28 28" width="28" height="28"><path d="M23 15c1.487 0 2.866.464 4 1.255V7a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h11.674A7 7 0 0 1 23 15zm-4-8h2v2h-2V7zM9 9H7V7h2v2zm4 0h-2V7h2v2zm2-2h2v2h-2V7z" fill="#00AEEC"/><path d="M26.536 18.464a5 5 0 0 0-7.071 0 5 5 0 0 0 0 7.071 5 5 0 1 0 7.071-7.071zm-5.657 5.657a3 3 0 0 1-.586-3.415l4.001 4.001a3 3 0 0 1-3.415-.586zm4.829-.827-4.001-4.001a3.002 3.002 0 0 1 4.001 4.001z" fill="#00AEEC"/></svg>'},{}],lKuh0:[function(e,t,r){t.exports='<svg class="apd-icon apd-mode-1-on" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" data-pointer="none" style="enable-background:new 0 0 28 28" viewBox="0 0 28 28" width="28" height="28"><path d="M23 3H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h18a4 4 0 0 0 4-4V7a4 4 0 0 0-4-4zM9 9H7V7h2v2zm4 0h-2V7h2v2zm4 0h-2V7h2v2zm4 0h-2V7h2v2z" fill="#FFF"/></svg>'},{}],eB8W6:[function(e,t,r){t.exports='<svg class="apd-icon apd-mode-2-off" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" data-pointer="none" style="enable-background:new 0 0 28 28" viewBox="0 0 28 28" width="28" height="28"><path d="M23 15c1.487 0 2.866.464 4 1.255V7a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h11.674A7 7 0 0 1 23 15zM9 21H7v-2h2v2zm4 0h-2v-2h2v2z" fill="#00AEEC"/><path d="M26.536 18.464a5 5 0 0 0-7.071 0 5 5 0 0 0 0 7.071 5 5 0 1 0 7.071-7.071zm-5.657 5.657a3 3 0 0 1-.586-3.415l4.001 4.001a3 3 0 0 1-3.415-.586zm4.829-.827-4.001-4.001a3.002 3.002 0 0 1 4.001 4.001z" fill="#00AEEC"/></svg>'},{}],bpe2E:[function(e,t,r){t.exports='<svg class="apd-icon apd-mode-2-on" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" data-pointer="none" style="enable-background:new 0 0 28 28" viewBox="0 0 28 28" width="28" height="28"><path d="M23 3H5a4 4 0 0 0-4 4v14a4 4 0 0 0 4 4h18a4 4 0 0 0 4-4V7a4 4 0 0 0-4-4zM9 21H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2z" fill="#FFF"/></svg>'},{}],kL9zy:[function(e,t,r){t.exports='<svg class="apd-icon apd-check-on" xmlns="http://www.w3.org/2000/svg" data-pointer="none" viewBox="0 0 32 32" width="32" height="32"><path d="m13 18.25-1.8-1.8c-.6-.6-1.65-.6-2.25 0s-.6 1.5 0 2.25l2.85 2.85c.318.318.762.468 1.2.448.438.02.882-.13 1.2-.448l8.85-8.85c.6-.6.6-1.65 0-2.25s-1.65-.6-2.25 0l-7.8 7.8zM8 4h16c2.21 0 4 1.79 4 4v16c0 2.21-1.79 4-4 4H8c-2.21 0-4-1.79-4-4V8c0-2.21 1.79-4 4-4z" fill="#00AEEC"/></svg>'},{}],"22xpM":[function(e,t,r){t.exports='<svg class="apd-icon apd-check-off" xmlns="http://www.w3.org/2000/svg" data-pointer="none" viewBox="0 0 32 32" width="32" height="32"><path d="M8 6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2H8zm0-2h16c2.21 0 4 1.79 4 4v16c0 2.21-1.79 4-4 4H8c-2.21 0-4-1.79-4-4V8c0-2.21 1.79-4 4-4z" fill="#FFF"/></svg>'},{}],"8AxLD":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"default",(function(){return s}));var a=function(e,t,r,i,a){return(e-t)*(a-i)/(r-t)+i},n=function(e,t){var r=t[0]-e[0],i=t[1]-e[1];return{length:Math.sqrt(Math.pow(r,2)+Math.pow(i,2)),angle:Math.atan2(i,r)}};function s(e,t,r){var i=e.constructor.utils.query;e.controls.add({name:"heatmap",position:"top",html:"",style:{position:"absolute",top:"-100px",left:"0px",right:"0px",height:"100px",width:"100%",pointerEvents:"none"},mounted:function(s){var o=null,l=null;function u(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(o=null,l=null,s.innerHTML="",e.duration&&!e.option.isLive){var h={w:s.offsetWidth,h:s.offsetHeight},f={xMin:0,xMax:h.w,yMin:0,yMax:128,scale:.25,opacity:.2,minHeight:Math.floor(.05*h.h),sampling:Math.floor(h.w/100),smoothing:.2,flattening:.2};"object"==c(r)&&Object.assign(f,r);var v=[];if(Array.isArray(u)&&u.length?v=d(u):function(){for(var r=e.duration/h.w,i=function(e){var i=t.queue.filter((function(t){var i=t.time;return i>e*r&&i<=(e+f.sampling)*r})).length;v.push([e,i])},a=0;a<=h.w;a+=f.sampling)i(a)}(),0!==v.length){var g=v[v.length-1],p=g[0],m=g[1];p!==h.w&&v.push([h.w,m]);for(var y=v.map((function(e){return e[1]})),k=(Math.min.apply(Math,d(y))+Math.max.apply(Math,d(y)))/2,E=0;E<v.length;E++){var T=v[E],S=T[1];T[1]=S*(S>k?1+f.scale:1-f.scale)+f.minHeight}var b=function(e,t,r,i){var s=n(t||e,r||e),o=a(Math.cos(s.angle)*f.flattening,0,1,1,0),l=s.angle*o+(i?Math.PI:0),u=s.length*f.smoothing;return[e[0]+Math.cos(l)*u,e[1]+Math.sin(l)*u]},L=function(e,t,r){var i=b(r[t-1],r[t-2],e),a=b(e,r[t-1],r[t+1],!0),n=t===r.length-1?" z":"";return"C ".concat(i[0],",").concat(i[1]," ").concat(a[0],",").concat(a[1]," ").concat(e[0],",").concat(e[1]).concat(n)},A=v.map((function(e){return[a(e[0],f.xMin,f.xMax,0,h.w),a(e[1],f.yMin,f.yMax,h.h,0)]})).reduce((function(e,t,r,i){return 0===r?"M ".concat(i[i.length-1][0],",").concat(h.h," L ").concat(t[0],",").concat(h.h," L ").concat(t[0],",").concat(t[1]):"".concat(e," ").concat(L(t,r,i))}),"");s.innerHTML='<svg viewBox="0 0 '.concat(h.w," ").concat(h.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:').concat(f.opacity,'" /><stop offset="0%" style="stop-color:var(--art-theme);stop-opacity:').concat(f.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="').concat(A,'"></path></svg>'),o=i("#heatmap-start",s),l=i("#heatmap-stop",s),o.setAttribute("offset","".concat(100*e.played,"%")),l.setAttribute("offset","".concat(100*e.played,"%"))}}}e.on("video:timeupdate",(function(){o&&l&&(o.setAttribute("offset","".concat(100*e.played,"%")),l.setAttribute("offset","".concat(100*e.played,"%")))})),e.on("setBar",(function(e,t){o&&l&&"played"===e&&(o.setAttribute("offset","".concat(100*t,"%")),l.setAttribute("offset","".concat(100*t,"%")))})),e.on("ready",(function(){return u()})),e.on("resize",(function(){return u()})),e.on("artplayerPluginDanmuku:loaded",(function(){return u()})),e.on("artplayerPluginDanmuku:points",(function(e){return u(e)}))}})}},{"@parcel/transformer-js/src/esmodule-helpers.js":"9pCYc"}]},["bgm6t"],"bgm6t","parcelRequire4dc0")}(p);r("b",s(p.exports));var m={exports:{}};!function(e,t){"function"==typeof SubtitlesOctopusOnLoad&&SubtitlesOctopusOnLoad(),e.exports&&(e.exports=function(e){var t=!1;try{if("object"===("undefined"==typeof WebAssembly?"undefined":c(WebAssembly))&&"function"==typeof WebAssembly.instantiate){var r=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));r instanceof WebAssembly.Module&&(t=new WebAssembly.Instance(r)instanceof WebAssembly.Instance)}}catch(g){}console.log("WebAssembly support detected: "+(t?"yes":"no"));var i=this;function a(){i.setCurrentTime(i.video.currentTime+i.timeOffset)}function n(){i.setIsPaused(!1,i.video.currentTime+i.timeOffset)}function s(){i.setIsPaused(!0,i.video.currentTime+i.timeOffset)}function o(){i.video.removeEventListener("timeupdate",a,!1)}function l(){i.video.addEventListener("timeupdate",a,!1);var e=i.video.currentTime+i.timeOffset;i.setCurrentTime(e)}function u(){i.setRate(i.video.playbackRate)}function d(){i.setIsPaused(!0,i.video.currentTime+i.timeOffset)}function h(e){e.target.removeEventListener(e.type,h,!1),i.resize()}function f(){var e=i.renderFramesData,t=performance.now();i.ctx.clearRect(0,0,i.canvas.width,i.canvas.height);for(var r=0;r<e.canvases.length;r++){var a=e.canvases[r];i.bufferCanvas.width=a.w,i.bufferCanvas.height=a.h;var n=new Uint8ClampedArray(a.buffer);if(i.hasAlphaBug)for(var s=3;s<n.length;s+=4)n[s]=n[s]>=1?n[s]:1;var o=new ImageData(n,a.w,a.h);i.bufferCanvasCtx.putImageData(o,0,0),i.ctx.drawImage(i.bufferCanvas,a.x,a.y)}if(i.debug){var l=Math.round(performance.now()-t),u=e.blendTime;void 0!==u?console.log("render: "+Math.round(e.spentTime-u)+" ms, blend: "+Math.round(u)+" ms, draw: "+l+" ms; TOTAL="+Math.round(e.spentTime+l)+" ms"):console.log(Math.round(e.spentTime)+" ms (+ "+l+" ms draw)"),i.renderStart=performance.now()}}function v(){var e=i.renderFramesData,t=performance.now();i.ctx.clearRect(0,0,i.canvas.width,i.canvas.height);for(var r=0;r<e.bitmaps.length;r++){var a=e.bitmaps[r];i.ctx.drawImage(a.bitmap,a.x,a.y)}if(i.debug){var n=Math.round(performance.now()-t);console.log(e.bitmaps.length+" bitmaps, libass: "+Math.round(e.libassTime)+"ms, decode: "+Math.round(e.decodeTime)+"ms, draw: "+n+"ms"),i.renderStart=performance.now()}}i.canvas=e.canvas,i.renderMode=e.renderMode||(e.lossyRender?"lossy":"wasm-blend"),i.libassMemoryLimit=e.libassMemoryLimit||0,i.libassGlyphLimit=e.libassGlyphLimit||0,i.targetFps=e.targetFps||24,i.prescaleFactor=e.prescaleFactor||1,i.prescaleHeightLimit=e.prescaleHeightLimit||1080,i.maxRenderHeight=e.maxRenderHeight||0,i.dropAllAnimations=e.dropAllAnimations||!1,i.isOurCanvas=!1,i.video=e.video,i.canvasParent=null,i.fonts=e.fonts||[],i.availableFonts=e.availableFonts||[],i.fallbackFont=e.fallbackFont||"default.woff2",i.lazyFileLoading=e.lazyFileLoading||!1,i.onReadyEvent=e.onReady,i.workerUrl=t?e.workerUrl||"subtitles-octopus-worker.js":e.legacyWorkerUrl||"subtitles-octopus-worker-legacy.js",i.subUrl=e.subUrl,i.subContent=e.subContent||null,i.onErrorEvent=e.onError,i.debug=e.debug||!1,i.lastRenderTime=0,i.pixelRatio=window.devicePixelRatio||1,i.timeOffset=e.timeOffset||0,i.hasAlphaBug=!1,function(){if("function"==typeof ImageData.prototype.constructor)try{return void new window.ImageData(new Uint8ClampedArray([0,0,0,0]),1,1)}catch(g){console.log("detected that ImageData is not constructable despite browser saying so")}var e=document.createElement("canvas").getContext("2d");window.ImageData=function(){var t=0;if(arguments[0]instanceof Uint8ClampedArray)var r=arguments[t++];var i=arguments[t++],a=arguments[t],n=e.createImageData(i,a);return r&&n.data.set(r),n}}(),i.workerError=function(e){if(console.error("Worker error: ",e),i.onErrorEvent&&i.onErrorEvent(e),!i.debug)throw i.dispose(),new Error("Worker error: "+e)},i.init=function(){window.Worker?(i.worker||(i.worker=new Worker(i.workerUrl),i.worker.addEventListener("message",i.onWorkerMessage),i.worker.addEventListener("error",i.workerError)),i.workerActive=!1,i.createCanvas(),i.setVideo(e.video),i.setSubUrl(e.subUrl),i.worker.postMessage({target:"worker-init",width:i.canvas.width,height:i.canvas.height,URL:document.URL,currentScript:i.workerUrl,preMain:!0,renderMode:i.renderMode,subUrl:i.subUrl,subContent:i.subContent,fonts:i.fonts,availableFonts:i.availableFonts,fallbackFont:i.fallbackFont,lazyFileLoading:i.lazyFileLoading,debug:i.debug,targetFps:i.targetFps,libassMemoryLimit:i.libassMemoryLimit,libassGlyphLimit:i.libassGlyphLimit,dropAllAnimations:i.dropAllAnimations})):i.workerError("worker not supported")},i.createCanvas=function(){i.canvas||(i.video?(i.isOurCanvas=!0,i.canvas=document.createElement("canvas"),i.canvas.className="libassjs-canvas",i.canvas.style.display="none",i.canvasParent=document.createElement("div"),i.canvasParent.className="libassjs-canvas-parent",i.canvasParent.appendChild(i.canvas),i.video.nextSibling?i.video.parentNode.insertBefore(i.canvasParent,i.video.nextSibling):i.video.parentNode.appendChild(i.canvasParent)):i.canvas||i.workerError("Don't know where to render: you should give video or canvas in options.")),i.ctx=i.canvas.getContext("2d"),i.bufferCanvas=document.createElement("canvas"),i.bufferCanvasCtx=i.bufferCanvas.getContext("2d"),i.bufferCanvas.width=1,i.bufferCanvas.height=1;var e=new Uint8ClampedArray([0,255,0,0]),t=new ImageData(e,1,1);i.bufferCanvasCtx.clearRect(0,0,1,1),i.ctx.clearRect(0,0,1,1);var r=i.ctx.getImageData(0,0,1,1).data;i.bufferCanvasCtx.putImageData(t,0,0),i.ctx.drawImage(i.bufferCanvas,0,0);var a=i.ctx.getImageData(0,0,1,1).data;i.hasAlphaBug=r[1]!=a[1],i.hasAlphaBug&&console.log("Detected a browser having issue with transparent pixels, applying workaround")},i.setVideo=function(e){i.video=e,i.video&&(i.video.addEventListener("timeupdate",a,!1),i.video.addEventListener("playing",n,!1),i.video.addEventListener("pause",s,!1),i.video.addEventListener("seeking",o,!1),i.video.addEventListener("seeked",l,!1),i.video.addEventListener("ratechange",u,!1),i.video.addEventListener("waiting",d,!1),document.addEventListener("fullscreenchange",i.resizeWithTimeout,!1),document.addEventListener("mozfullscreenchange",i.resizeWithTimeout,!1),document.addEventListener("webkitfullscreenchange",i.resizeWithTimeout,!1),document.addEventListener("msfullscreenchange",i.resizeWithTimeout,!1),window.addEventListener("resize",i.resizeWithTimeout,!1),"undefined"!=typeof ResizeObserver&&(i.ro=new ResizeObserver(i.resizeWithTimeout),i.ro.observe(i.video)),i.video.videoWidth>0?i.resize():i.video.addEventListener("loadedmetadata",h,!1))},i.getVideoPosition=function(){var e=i.video.videoWidth/i.video.videoHeight,t=i.video.offsetWidth,r=i.video.offsetHeight,a=t,n=r;return t/r>e?a=Math.floor(r*e):n=Math.floor(t/e),{width:a,height:n,x:(t-a)/2,y:(r-n)/2}},i.setSubUrl=function(e){i.subUrl=e},i.renderFrameData=null,i.workerActive=!1,i.frameId=0,i.onWorkerMessage=function(e){i.workerActive||(i.workerActive=!0,i.onReadyEvent&&i.onReadyEvent());var t=e.data;switch(t.target){case"stdout":console.log(t.content);break;case"console-log":console.log.apply(console,JSON.parse(t.content));break;case"console-debug":console.debug.apply(console,JSON.parse(t.content));break;case"console-info":console.info.apply(console,JSON.parse(t.content));break;case"console-warn":console.warn.apply(console,JSON.parse(t.content));break;case"console-error":console.error.apply(console,JSON.parse(t.content));break;case"stderr":console.error(t.content);break;case"window":window[t.method]();break;case"canvas":switch(t.op){case"getContext":i.ctx=i.canvas.getContext(t.type,t.attributes);break;case"resize":i.resize(t.width,t.height);break;case"renderCanvas":i.lastRenderTime<t.time&&(i.lastRenderTime=t.time,i.renderFramesData=t,window.requestAnimationFrame(f));break;case"renderFastCanvas":i.lastRenderTime<t.time&&(i.lastRenderTime=t.time,i.renderFramesData=t,window.requestAnimationFrame(v));break;case"setObjectProperty":i.canvas[t.object][t.property]=t.value;break;default:throw"eh?"}break;case"tick":i.frameId=t.id,i.worker.postMessage({target:"tock",id:i.frameId});break;case"custom":if(!i.onCustomMessage)throw"Custom message received but client onCustomMessage not implemented.";i.onCustomMessage(e);break;case"setimmediate":i.worker.postMessage({target:"setimmediate"});break;case"get-events":case"get-styles":case"ready":break;default:throw"what? "+t.target}},i.resize=function(e,t,r,a){var n=null;if(r=r||0,a=a||0,(!e||!t)&&i.video){var s=function(e,t){var r=i.prescaleFactor<=0?1:i.prescaleFactor;if(t<=0||e<=0)e=0,t=0;else{var a=r<1?-1:1,n=t;a*n*r<=a*i.prescaleHeightLimit?n*=r:a*n<a*i.prescaleHeightLimit&&(n=i.prescaleHeightLimit),i.maxRenderHeight>0&&n>i.maxRenderHeight&&(n=i.maxRenderHeight),e*=n/t,t=n}return{width:e,height:t}}((n=i.getVideoPosition()).width*i.pixelRatio,n.height*i.pixelRatio);e=s.width,t=s.height;var o=i.canvasParent.getBoundingClientRect().top-i.video.getBoundingClientRect().top;r=n.y-o,a=n.x}e&&t?i.canvas.width==e&&i.canvas.height==t&&i.canvas.style.top==r&&i.canvas.style.left==a||(i.canvas.width=e,i.canvas.height=t,null!=n&&(i.canvasParent.style.position="relative",i.canvas.style.display="block",i.canvas.style.position="absolute",i.canvas.style.width=n.width+"px",i.canvas.style.height=n.height+"px",i.canvas.style.top=r+"px",i.canvas.style.left=a+"px",i.canvas.style.pointerEvents="none"),i.worker.postMessage({target:"canvas",width:i.canvas.width,height:i.canvas.height})):i.video||console.error("width or height is 0. You should specify width & height for resize.")},i.resizeWithTimeout=function(){i.resize(),setTimeout(i.resize,100)},i.runBenchmark=function(){i.worker.postMessage({target:"runBenchmark"})},i.customMessage=function(e,t){t=t||{},i.worker.postMessage({target:"custom",userData:e,preMain:t.preMain})},i.setCurrentTime=function(e){i.worker.postMessage({target:"video",currentTime:e})},i.setTrackByUrl=function(e){i.worker.postMessage({target:"set-track-by-url",url:e})},i.setTrack=function(e){i.worker.postMessage({target:"set-track",content:e})},i.freeTrack=function(e){i.worker.postMessage({target:"free-track"})},i.render=i.setCurrentTime,i.setIsPaused=function(e,t){i.worker.postMessage({target:"video",isPaused:e,currentTime:t})},i.setRate=function(e){i.worker.postMessage({target:"video",rate:e})},i.dispose=function(){i.worker.postMessage({target:"destroy"}),i.worker.terminate(),i.worker.removeEventListener("message",i.onWorkerMessage),i.worker.removeEventListener("error",i.workerError),i.workerActive=!1,i.worker=null,i.video&&(i.video.removeEventListener("timeupdate",a,!1),i.video.removeEventListener("playing",n,!1),i.video.removeEventListener("pause",s,!1),i.video.removeEventListener("seeking",o,!1),i.video.removeEventListener("seeked",l,!1),i.video.removeEventListener("ratechange",u,!1),i.video.removeEventListener("waiting",d,!1),i.video.removeEventListener("loadedmetadata",h,!1),document.removeEventListener("fullscreenchange",i.resizeWithTimeout,!1),document.removeEventListener("mozfullscreenchange",i.resizeWithTimeout,!1),document.removeEventListener("webkitfullscreenchange",i.resizeWithTimeout,!1),document.removeEventListener("msfullscreenchange",i.resizeWithTimeout,!1),window.removeEventListener("resize",i.resizeWithTimeout,!1),i.video.parentNode.removeChild(i.canvasParent),i.video=null),i.ro&&(i.ro.disconnect(),i.ro=null),i.onCustomMessage=null,i.onErrorEvent=null,i.onReadyEvent=null},i.fetchFromWorker=function(e,t,r){try{var a=e.target,n=setTimeout((function(){o(Error("Error: Timeout while try to fetch "+a))}),5e3),s=function e(r){r.data.target==a&&(t(r.data),i.worker.removeEventListener("message",e),i.worker.removeEventListener("error",o),clearTimeout(n))},o=function e(t){r(t),i.worker.removeEventListener("message",s),i.worker.removeEventListener("error",e),clearTimeout(n)};i.worker.addEventListener("message",s),i.worker.addEventListener("error",o),i.worker.postMessage(e)}catch(l){r(l)}},i.createEvent=function(e){i.worker.postMessage({target:"create-event",event:e})},i.getEvents=function(e,t){i.fetchFromWorker({target:"get-events"},(function(t){e(t.events)}),t)},i.setEvent=function(e,t){i.worker.postMessage({target:"set-event",event:e,index:t})},i.removeEvent=function(e){i.worker.postMessage({target:"remove-event",index:e})},i.createStyle=function(e){i.worker.postMessage({target:"create-style",style:e})},i.getStyles=function(e,t){i.fetchFromWorker({target:"get-styles"},(function(t){e(t.styles)}),t)},i.setStyle=function(e,t){i.worker.postMessage({target:"set-style",style:e,index:t})},i.removeStyle=function(e){i.worker.postMessage({target:"remove-style",index:e})},i.init()})}(m);var T=s(m.exports),L=null;function R(e){return function(e){return/^https?:\/\//.test(e)}(e)?e:new URL(e,document.baseURI).toString()}function I(e){var t=e.workerUrl,r=e.wasmUrl;return new Promise((function(e){fetch(t).then((function(e){return e.text()})).then((function(i){var a=i;a=a.replace(/wasmBinaryFile\s*=\s*"(subtitles-octopus-worker\.wasm)"/g,(function(e,i){return r=r?R(r):new URL(i,R(t)).toString(),'wasmBinaryFile = "'.concat(r,'"')}));var n=new Blob([a],{type:"text/javascript"});e(URL.createObjectURL(n))}))}))}function w(e){L.canvasParent&&(L.canvasParent.style.display=e?"block":"none")}var D=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},_=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=x},x=Number.MAX_SAFE_INTEGER||9007199254740991,P=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),C=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),M=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),O="manifest",F="level",N="audioTrack",U="subtitleTrack",B="main",G="audio",H="subtitle",K=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;b(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=r,this.totalWeight_=i}return A(e,[{key:"sample",value:function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}]),e}(),V=function(){function e(t,r,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;b(this,e),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new K(t),this.fast_=new K(r),this.defaultTTFB_=a,this.ttfb_=new K(t)}return A(e,[{key:"update",value:function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new K(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new K(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new K(e,a.getEstimate(),a.getTotalWeight()))}},{key:"sample",value:function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}},{key:"sampleTTFB",value:function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}},{key:"canEstimate",value:function(){return this.fast_.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"getEstimateTTFB",value:function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}},{key:"defaultEstimate",get:function(){return this.defaultEstimate_}},{key:"destroy",value:function(){}}]),e}();function j(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=c(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t);if("object"!=c(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==c(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},W.apply(null,arguments)}function Y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function q(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Y(Object(r),!0).forEach((function(t){j(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Y(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var $=A((function e(t,r){b(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var i="[".concat(t,"]:");this.trace=z,this.debug=r.debug.bind(null,i),this.log=r.log.bind(null,i),this.warn=r.warn.bind(null,i),this.info=r.info.bind(null,i),this.error=r.error.bind(null,i)})),z=function(){},X={trace:z,debug:z,log:z,warn:z,info:z,error:z};function Q(){return W({},X)}function Z(e,t,r){return t[e]?t[e].bind(t):function(e,t){var r=self.console[e];return r?r.bind(self.console,"".concat(t?"["+t+"] ":"","[").concat(e,"] >")):z}(e,r)}var J=Q();function ee(e,t,r){var i=Q();if("object"===("undefined"==typeof console?"undefined":c(console))&&!0===e||"object"===c(e)){var a=["debug","log","info","warn","error"];a.forEach((function(t){i[t]=Z(t,e,r)}));try{i.log('Debug logs enabled for "'.concat(t,'" in hls.js version ',"1.6.1"))}catch(n){return Q()}a.forEach((function(t){J[t]=Z(t,e)}))}else W(J,i);return i}var te=J;function re(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if("undefined"!=typeof self){var t=(e||!self.MediaSource)&&self.ManagedMediaSource;return t||self.MediaSource||self.WebKitMediaSource}}function ie(e,t){var r=Object.keys(e),i=Object.keys(t),a=r.length,n=i.length;return!a||!n||a===n&&!r.some((function(e){return-1===i.indexOf(e)}))}function ae(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("undefined"!=typeof TextDecoder){var r=new TextDecoder("utf-8"),i=r.decode(e);if(t){var a=i.indexOf("\0");return-1!==a?i.substring(0,a):i}return i.replace(/\0/g,"")}for(var n,s,o,l=e.length,u="",c=0;c<l;){if(0===(n=e[c++])&&t)return u;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(n);break;case 12:case 13:s=e[c++],u+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e[c++],o=e[c++],u+=String.fromCharCode((15&n)<<12|(63&s)<<6|(63&o)<<0)}}return u}var ne=function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t};function se(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oe,le={exports:{}};var ue=(oe||(oe=1,function(e,t){var r,i,a,n,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=s.normalizePath(a.path),s.buildURLFromParts(a)}var n=s.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=s.normalizePath(n.path),s.buildURLFromParts(n)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var c=o.path,d=c.substring(0,c.lastIndexOf("/")+1)+n.path;u.path=s.normalizePath(d)}else u.path=o.path,n.params||(u.params=o.params,n.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(n.path):n.path),s.buildURLFromParts(u)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(a,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=s}(le)),le.exports),ce=A((function e(){b(this,e),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}})),de="audio",he="video",fe="audiovideo",ve=function(){function e(t){var r,i,a;b(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t,(a=ye(r=this,i="stats"))&&(a.enumerable=!0,Object.defineProperty(r,i,a))}return A(e,[{key:"setByteRange",value:function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){var e;null===this._streams&&(this._streams=(k(e={},de,null),k(e,he,null),k(e,fe,null),e));return this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new ce),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=ue.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[de]=null,e[he]=null,e[fe]=null}}]),e}();function ge(e){return"initSegment"!==e.sn}var pe=function(e){g(r,e);var t=n(r);function r(e,i){var a;return b(this,r),(a=t.call(this,i))._decryptdata=null,a._programDateTime=null,a._ref=null,a._bitrate=void 0,a.rawProgramDateTime=null,a.tagList=[],a.duration=0,a.sn=0,a.levelkeys=void 0,a.type=void 0,a.loader=null,a.keyLoader=null,a.level=-1,a.cc=0,a.startPTS=void 0,a.endPTS=void 0,a.startDTS=void 0,a.endDTS=void 0,a.start=0,a.playlistOffset=0,a.deltaPTS=void 0,a.maxStartPTS=void 0,a.minEndPTS=void 0,a.data=void 0,a.bitrateTest=!1,a.title=null,a.initSegment=null,a.endList=void 0,a.gap=void 0,a.urlId=0,a.type=e,a}return A(r,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange){var t=this.byteRange[0],r=this.byteRange[1];if(D(t)&&D(r))return r-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=D(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){D(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return ge(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,r,i,a){var n=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,a)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:a,partial:n}}}]),r}(ve),me=function(e){g(r,e);var t=n(r);function r(e,i,a,n,s){var o;b(this,r),(o=t.call(this,a)).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=i,o.index=n;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,s),s&&(o.fragOffset=s.fragOffset+s.duration),o}return A(r,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),r}(ve);function ye(e,t){var r=Object.getPrototypeOf(e);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i||ye(r,t)}}var ke=Math.pow(2,32)-1,Ee=[].push,Te={video:1,audio:2,id3:3,text:4};function Se(e){return String.fromCharCode.apply(null,e)}function be(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function Le(e,t){var r=Re(e,t);return r<0?4294967296+r:r}function Ae(e,t){var r=Le(e,t);return r*=Math.pow(2,32),r+=Le(e,t+4)}function Re(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function Ie(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function we(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,a=0;a<i;){var n=Le(e,a),s=n>1?a+n:i;if(Se(e.subarray(a+4,a+8))===t[0])if(1===t.length)r.push(e.subarray(a+8,s));else{var o=we(e.subarray(a+8,s),t.slice(1));o.length&&Ee.apply(r,o)}a=s}return r}function De(e){var t=[],r=e[0],i=8,a=Le(e,i);i+=4;var n=0,s=0;0===r?(n=Le(e,i),s=Le(e,i+4),i+=8):(n=Ae(e,i),s=Ae(e,i+8),i+=16),i+=2;var o=e.length+s,l=be(e,i);i+=2;for(var u=0;u<l;u++){var c=i,d=Le(e,c);c+=4;var h=2147483647&d;if(1===(2147483648&d)>>>31)return te.warn("SIDX has hierarchical references (not supported)"),null;var f=Le(e,c);c+=4,t.push({referenceSize:h,subsegmentDuration:f,info:{duration:f/a,start:o,end:o+h-1}}),o+=h,i=c+=4}return{earliestPresentationTime:n,timescale:a,version:r,referencesCount:l,references:t}}function _e(e){for(var t=[],r=we(e,["moov","trak"]),i=0;i<r.length;i++){var a=r[i],n=we(a,["tkhd"])[0];if(n){var s=n[0],o=Le(n,0===s?12:20),l=we(a,["mdia","mdhd"])[0];if(l){var u=Le(l,0===(s=l[0])?12:20),c=we(a,["mdia","hdlr"])[0];if(c){var d=Se(c.subarray(8,12)),h={soun:de,vide:he}[d],f=xe(we(a,["mdia","minf","stbl","stsd"])[0]);h?(t[o]={timescale:u,type:h,stsd:f},t[h]=q({timescale:u,id:o},f)):t[o]={timescale:u,type:d,stsd:f}}}}}return we(e,["moov","mvex","trex"]).forEach((function(e){var r=Le(e,4),i=t[r];i&&(i.default={duration:Le(e,12),flags:Le(e,20)})})),t}function xe(e){var t,r=e.subarray(8),i=r.subarray(86),a=Se(r.subarray(4,8)),n=a,s="enca"===a||"encv"===a;if(s){var o=we(r,[a])[0];we(o.subarray("enca"===a?28:78),["sinf"]).forEach((function(e){var t=we(e,["schm"])[0];if(t){var r=Se(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=we(e,["frma"])[0];i&&(n=Se(i))}}}))}var l=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var u=we(i,["avcC"])[0];u&&u.length>3&&(n+="."+Me(u[1])+Me(u[2])+Me(u[3]),t=Pe("avc1"===l?"dva1":"dvav",i));break;case"mp4a":var c=we(r,[a])[0],d=we(c.subarray(28),["esds"])[0];if(d&&d.length>7){var h=4;if(3!==d[h++])break;h=Ce(d,h),h+=2;var f=d[h++];if(128&f&&(h+=2),64&f&&(h+=d[h++]),4!==d[h++])break;h=Ce(d,h);var v=d[h++];if(64!==v)break;if(n+="."+Me(v),h+=12,5!==d[h++])break;h=Ce(d,h);var g=d[h++],p=(248&g)>>3;31===p&&(p+=1+((7&g)<<3)+((224&d[h])>>5)),n+="."+p}break;case"hvc1":case"hev1":var m=we(i,["hvcC"])[0];if(m&&m.length>12){var y=m[1],k=["","A","B","C"][y>>6],E=31&y,T=Le(m,2),S=(32&y)>>5?"H":"L",b=m[12],L=m.subarray(6,12);n+="."+k+E,n+="."+T.toString(16).toUpperCase(),n+="."+S+b;for(var A="",R=L.length;R--;){var I=L[R];if(I||A)A="."+I.toString(16).toUpperCase()+A}n+=A}t=Pe("hev1"==l?"dvhe":"dvh1",i);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":n=Pe(n,i)||n;break;case"vp09":var w=we(i,["vpcC"])[0];if(w&&w.length>6){var D=w[4],_=w[5],x=w[6]>>4&15;n+="."+Oe(D)+"."+Oe(_)+"."+Oe(x)}break;case"av01":var P=we(i,["av1C"])[0];if(P&&P.length>2){var C=P[1]>>>5,M=31&P[1],O=P[2]>>>7?"H":"M",F=(64&P[2])>>6,N=(32&P[2])>>5,U=2===C&&F?N?12:10:F?10:8,B=(16&P[2])>>4,G=(8&P[2])>>3,H=(4&P[2])>>2,K=3&P[2];n+="."+C+"."+Oe(M)+O+"."+Oe(U)+"."+B+"."+G+H+K+"."+Oe(1)+"."+Oe(1)+"."+Oe(1)+".0",t=Pe("dav1",i)}}return{codec:n,encrypted:s,supplemental:t}}function Pe(e,t){var r=we(t,["dvvC"]),i=r.length?r[0]:we(t,["dvcC"])[0];if(i){var a=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return e+"."+Oe(a)+"."+Oe(n)}}function Ce(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function Me(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Oe(e){return(e<10?"0":"")+e}function Fe(e){var t=we(e,["schm"])[0];if(t){var r=Se(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return we(e,["schi","tenc"])[0]}return null}function Ne(e){var t=Le(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,a=Le(e,4),n=0;n<a;n++){if(256&t)i+=Le(e,r),r+=4;512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4)}return i}function Ue(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Be(e,t){var r=[],i=t.samples,a=t.timescale,n=t.id,s=!1;return we(i,["moof"]).map((function(o){var l=o.byteOffset-8;we(o,["traf"]).map((function(o){var u=we(o,["tfdt"]).map((function(e){var t=e[0],r=Le(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Le(e,8)),r/a}))[0];return void 0!==u&&(e=u),we(o,["tfhd"]).map((function(u){var c=Le(u,4),d=16777215&Le(u,0),h=0,f=0!=(16&d),v=0,g=0!=(32&d),p=8;c===n&&(0!=(1&d)&&(p+=8),0!=(2&d)&&(p+=4),0!=(8&d)&&(h=Le(u,p),p+=4),f&&(v=Le(u,p),p+=4),g&&(p+=4),"video"===t.type&&(s=Ge(t.codec)),we(o,["trun"]).map((function(n){var o=n[0],u=16777215&Le(n,0),c=0!=(1&u),d=0,f=0!=(4&u),g=0!=(256&u),p=0,m=0!=(512&u),y=0,k=0!=(1024&u),E=0!=(2048&u),T=0,S=Le(n,4),b=8;c&&(d=Le(n,b),b+=4),f&&(b+=4);for(var L=d+l,A=0;A<S;A++){if(g?(p=Le(n,b),b+=4):p=h,m?(y=Le(n,b),b+=4):y=v,k&&(b+=4),E&&(T=0===o?Le(n,b):Re(n,b),b+=4),t.type===he)for(var R=0;R<y;){var I=Le(i,L);if(He(s,i[L+=4]))Ke(i.subarray(L,L+I),s?2:1,e+T/a,r);L+=I,R+=I+4}e+=p/a}})))}))}))})),r}function Ge(e){if(!e)return!1;var t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function He(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6===(31&t)}function Ke(e,t,r,i){var a=Ve(e),n=0;n+=t;for(var s=0,o=0,l=0;n<a.length;){s=0;do{if(n>=a.length)break;s+=l=a[n++]}while(255===l);o=0;do{if(n>=a.length)break;o+=l=a[n++]}while(255===l);var u=a.length-n,c=n;if(o<u)n+=o;else if(o>u){te.error("Malformed SEI payload. ".concat(o," is too small, only ").concat(u," bytes left to parse."));break}if(4===s){if(181===a[c++]){var d=be(a,c);if(c+=2,49===d){var h=Le(a,c);if(c+=4,1195456820===h){var f=a[c++];if(3===f){var v=a[c++],g=64&v,p=g?2+3*(31&v):0,m=new Uint8Array(p);if(g){m[0]=v;for(var y=1;y<p;y++)m[y]=a[c++]}i.push({type:f,payloadType:s,pts:r,bytes:m})}}}}}else if(5===s&&o>16){for(var k=[],E=0;E<16;E++){var T=a[c++].toString(16);k.push(1==T.length?"0"+T:T),3!==E&&5!==E&&7!==E&&9!==E||k.push("-")}for(var S=o-16,b=new Uint8Array(S),L=0;L<S;L++)b[L]=a[c++];i.push({payloadType:s,pts:r,uuid:k.join(""),userData:ae(b),userDataBytes:b})}}}function Ve(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var a=t-r.length,n=new Uint8Array(a),s=0;for(i=0;i<a;s++,i++)s===r[0]&&(s++,r.shift()),n[i]=e[s];return n}function je(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");var i,a;i=new Uint8Array,a=new Uint8Array;var n=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(n.buffer).setUint32(0,r.byteLength,!1),function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var a=r.length,n=8,s=a;s--;)n+=r[s].byteLength;var o=new Uint8Array(n);for(o[0]=n>>24&255,o[1]=n>>16&255,o[2]=n>>8&255,o[3]=255&n,o.set(e,4),s=0,n=8;s<a;s++)o.set(r[s],n),n+=r[s].byteLength;return o}([112,115,115,104],new Uint8Array([0,0,0,0]),e,a,i,n,r||new Uint8Array)}function We(e){var t=e.getUint32(0),r=e.byteOffset,i=e.byteLength;if(i<t)return{offset:r,size:i};if(1886614376!==e.getUint32(4))return{offset:r,size:t};var a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:r,size:t};var n=e.buffer,s=ne(new Uint8Array(n,r+12,16)),o=e.getUint32(28),l=null,u=null;if(0===a){if(t-32<o||o<22)return{offset:r,size:t};u=new Uint8Array(n,r+32,o)}else if(1===a){if(!o||i<r+32+16*o+16)return{offset:r,size:t};l=[];for(var c=0;c<o;c++)l.push(new Uint8Array(n,r+32+16*c,16))}return{version:a,systemId:s,kids:l,data:u,offset:r,size:t}}var Ye=function(){return/\(Windows.+Firefox\//i.test(navigator.userAgent)},qe={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function $e(e,t){var r=qe[t];return!!r&&!!r[e.slice(0,4)]}function ze(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return!e.split(",").some((function(e){return!Xe(e,t,r)}))}function Xe(e,t){var r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=re(i);return null!=(r=null==a?void 0:a.isTypeSupported(Qe(e,t)))&&r}function Qe(e,t){return"".concat(t,"/mp4;codecs=").concat(e)}function Ze(e){if(e){var t=e.substring(0,4);return qe.video[t]}return 2}function Je(e){var t=Ye();return e.split(",").reduce((function(e,r){var i=t&&Ge(r)?9:qe.video[r];return i?(2*i+e)/(e?3:2):(qe.audio[r]+e)/(e?2:1)}),0)}var et={};function tt(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(et[e])return et[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],i=0;i<r.length;i++){var a;if(Xe(r[i],"audio",t))return et[e]=r[i],r[i];if("mp3"===r[i]&&null!=(a=re(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}var rt=/flac|opus|mp4a\.40\.34/i;function it(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.replace(rt,(function(e){return tt(e.toLowerCase(),t)}))}function at(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e)))return e;if(t){var r=t.split(",");if(r.length>1){if(e)for(var i=r.length;i--;)if(r[i].substring(0,4)===e.substring(0,4))return r[i];return r[0]}}return t||e}function nt(e){if(e.startsWith("av01.")){for(var t=e.split("."),r=["0","111","01","01","01","0"],i=t.length;i>4&&i<10;i++)t[i]=r[i-4];return t.join(".")}return e}function st(e){var t=re(e)||{isTypeSupported:function(){return!1}};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function ot(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var lt={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function ut(e,t){return{supported:!1,configurations:t,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:e}}var ct={};function dt(e,t,r){var i=e.videoCodec,a=e.audioCodec;if(!i&&!a||!r)return Promise.resolve(lt);var n=[];if(i){var s={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},o=e.videoRange;"SDR"!==o&&(s.transferFunction=o.toLowerCase());var l=i.split(","),u=navigator.userAgent;if(l.some((function(e){return Ge(e)}))&&Ye())return Promise.resolve(ut(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: (".concat(u,")")),n));n.push.apply(n,l.map((function(e){return{type:"media-source",video:q(q({},s),{},{contentType:Qe(nt(e),"video")})}})))}return a&&e.audioGroups&&e.audioGroups.forEach((function(e){var r;e&&(null==(r=t.groups[e])||r.tracks.forEach((function(t){if(t.groupId===e){var r=t.channels||"",i=parseFloat(r);D(i)&&i>2&&n.push.apply(n,a.split(",").map((function(e){return{type:"media-source",audio:{contentType:Qe(e,"audio"),channels:""+i}}})))}})))})),Promise.all(n.map((function(e){var t=function(e){var t=e.audio,r=e.video,i=r||t;if(i){var a=ot(i.contentType);if(r)return"r".concat(r.height,"x").concat(r.width,"f").concat(Math.ceil(r.framerate)).concat(r.transferFunction||"sd","_").concat(a,"_").concat(Math.ceil(r.bitrate/1e5));if(t)return"c".concat(t.channels).concat(t.spatialRendering?"s":"n","_").concat(a)}return""}(e);return ct[t]||(ct[t]=r.decodingInfo(e))}))).then((function(e){return{supported:!e.some((function(e){return!e.supported})),configurations:n,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:n,decodingInfoResults:[],error:e}}))}var ht=["NONE","TYPE-0","TYPE-1",null];var ft=["SDR","PQ","HLG"];var vt="",gt="YES",pt="v2";function mt(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i<t/2?r?pt:gt:vt}var yt=function(){function e(t,r,i){b(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=r,this.skip=i}return A(e,[{key:"addDirectives",value:function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}]),e}(),kt=function(){function e(t){if(b(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(e){return!!e})).map((function(e){return e.substring(0,4)})).join(","),"supplemental"in t){var r;this.supplemental=t.supplemental;var i=null==(r=t.supplemental)?void 0:r.videoCodec;i&&i!==t.videoCodec&&(this.codecSet+=",".concat(i.substring(0,4)))}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}return A(e,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return Et(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return Et(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===r.indexOf(t)&&r.push(t)}else if("text"===e){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===i.indexOf(t)&&i.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}]),e}();function Et(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function Tt(e,t){var r=!1,i=[];if(e&&(r="SDR"!==e,i=[e]),t){var a="SDR"!==(i=t.allowedVideoRanges||ft.slice(0)).join("")&&!t.videoCodec;(r=void 0!==t.preferHDR?t.preferHDR:a&&function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(i=["SDR"])}return{preferHDR:r,allowedVideoRanges:i}}var St=function(e,t){return JSON.stringify(e,function(e){var t=new WeakSet;return function(r,i){if(e&&(i=e(r,i)),"object"===c(i)&&null!==i){if(t.has(i))return;t.add(i)}return i}}(t))};function bt(e,t){te.log('[abr] start candidates with "'.concat(e,'" ignored because ').concat(t))}function Lt(e){return e.reduce((function(e,t){var r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);var i=t.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function At(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function Rt(e,t,r){if("attrs"in e){var i=t.indexOf(e);if(-1!==i)return i}for(var a=0;a<t.length;a++){if(It(e,t[a],r))return a}return-1}function It(e,t,r){var i=e.groupId,a=e.name,n=e.lang,s=e.assocLang,o=e.default,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===a||t.name===a)&&(void 0===n||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--";if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(n,t.lang))&&(void 0===n||t.assocLang===s)&&(void 0===o||t.default===o)&&(void 0===l||t.forced===l)&&(!("characteristics"in e)||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.split(","),i=t.split(",");return r.length===i.length&&!r.some((function(e){return-1===i.indexOf(e)}))}(e.characteristics||"",t.characteristics))&&(void 0===r||r(e,t))}function wt(e,t){var r=e.audioCodec,i=e.channels;return!(void 0!==r&&(t.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function Dt(e,t,r){for(var i=t;i>-1;i--)if(r(e[i]))return i;for(var a=t+1;a<e.length;a++)if(r(e[a]))return a;return-1}function _t(e,t){var r;return!!e&&e!==(null==(r=t.loadLevelObj)?void 0:r.uri)}var xt=function(e){g(r,e);var t=n(r);function r(e){var i;return b(this,r),(i=t.call(this,"abr",e.logger)).hls=void 0,i.lastLevelLoadSec=0,i.lastLoadedFragLevel=-1,i.firstSelection=-1,i._nextAutoLevel=-1,i.nextAutoLevelKey="",i.audioTracksByGroup=null,i.codecTiers=null,i.timer=-1,i.fragCurrent=null,i.partCurrent=null,i.bitrateTestDelay=0,i.rebufferNotice=-1,i.bwEstimator=void 0,i._abandonRulesCheck=function(e){var t,r=o(i),a=r.fragCurrent,n=r.partCurrent,s=r.hls,l=s.autoLevelEnabled,u=s.media;if(a&&u){var c=performance.now(),d=n?n.stats:a.stats,h=n?n.duration:a.duration,f=c-d.loading.start,v=s.minAutoLevel,g=a.level,p=i._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||g<=v)return i.clearTimer(),void(i._nextAutoLevel=-1);if(l){var m=p>-1&&p!==g,y=!!e||m;if(y||!u.paused&&u.playbackRate&&u.readyState){var k=s.mainForwardBufferInfo;if(y||null!==k){var E=i.bwEstimator.getEstimateTTFB(),T=Math.abs(u.playbackRate);if(!(f<=Math.max(E,h/(2*T)*1e3))){var S=k?k.len/T:0,b=d.loading.first?d.loading.first-d.loading.start:-1,L=d.loaded&&b>-1,A=i.getBwEstimate(),R=s.levels,I=R[g],w=Math.max(d.loaded,Math.round(h*(a.bitrate||I.averageBitrate)/8)),_=L?f-b:f;_<1&&L&&(_=Math.min(f,8*d.loaded/A));var x=L?1e3*d.loaded/_:0,P=E/1e3,C=x?(w-d.loaded)/x:8*w/A+P;if(!(C<=S)){var O,F=x?8*x:A,N=!0===(null==(t=(null==e?void 0:e.details)||i.hls.latestLevelDetails)?void 0:t.live),U=i.hls.config.abrBandWidthUpFactor,B=Number.POSITIVE_INFINITY;for(O=g-1;O>v;O--){var G=R[O].maxBitrate,H=!R[O].details||N;if((B=i.getTimeToLoadFrag(P,F,h*G,H))<Math.min(S,h+P))break}if(!(B>=C||B>10*h)){L?i.bwEstimator.sample(f-Math.min(E,b),d.loaded):i.bwEstimator.sampleTTFB(f);var K=R[O].maxBitrate;i.getBwEstimate()*U>K&&i.resetEstimator(K);var V=i.findBestLevel(K,v,O,0,S,1,1);V>-1&&(O=V),i.warn("Fragment ".concat(a.sn).concat(n?" part "+n.index:""," of level ").concat(g," is loading too slowly;\n Fragment duration: ").concat(a.duration.toFixed(3),"\n Time to underbuffer: ").concat(S.toFixed(3)," s\n Estimated load time for current fragment: ").concat(C.toFixed(3)," s\n Estimated load time for down switch fragment: ").concat(B.toFixed(3)," s\n TTFB estimate: ").concat(0|b," ms\n Current BW estimate: ").concat(D(A)?0|A:"Unknown"," bps\n New BW estimate: ").concat(0|i.getBwEstimate()," bps\n Switching to level ").concat(O," @ ").concat(0|K," bps")),s.nextLoadLevel=s.nextAutoLevel=O,i.clearTimer();var j=function(){if(i.clearTimer(),i.fragCurrent===a&&i.hls.loadLevel===O&&O>0){var e=i.getStarvationDelay();if(i.warn("Aborting inflight request ".concat(O>0?"and switching down":"","\n Fragment duration: ").concat(a.duration.toFixed(3)," s\n Time to underbuffer: ").concat(e.toFixed(3)," s")),a.abortRequests(),i.fragCurrent=i.partCurrent=null,O>v){var t=i.findBestLevel(i.hls.levels[v].bitrate,v,O,0,e,1,1);-1===t&&(t=v),i.hls.nextLoadLevel=i.hls.nextAutoLevel=t,i.resetEstimator(i.hls.levels[t].bitrate)}}};m||C>2*B?j():i.timer=self.setInterval(j,1e3*B),s.trigger(M.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:n,stats:d})}}}}}}}},i.hls=e,i.bwEstimator=i.initEstimator(),i.registerListeners(),i}return A(r,[{key:"resetEstimator",value:function(e){e&&(this.log("setting initial bwe to ".concat(e)),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new V(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.FRAG_LOADING,this.onFragLoading,this),e.on(M.FRAG_LOADED,this.onFragLoaded,this),e.on(M.FRAG_BUFFERED,this.onFragBuffered,this),e.on(M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(M.LEVEL_LOADED,this.onLevelLoaded,this),e.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(M.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.FRAG_LOADING,this.onFragLoading,this),e.off(M.FRAG_LOADED,this.onFragLoaded,this),e.off(M.FRAG_BUFFERED,this.onFragBuffered,this),e.off(M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(M.LEVEL_LOADED,this.onLevelLoaded,this),e.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(M.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(M.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var r=t.frag;if(!this.ignoreFragment(r)){var i;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case C.BUFFER_ADD_CODEC_ERROR:case C.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case C.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,a=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var n=performance.now(),s=a?a.stats:r.stats,o=n-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}}},{key:"getTimeToLoadFrag",value:function(e,t,r,i){return e+r/t+(i?e+this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var r=this.hls.config,i=t.stats.loading,a=i.end-i.first;D(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}},{key:"onFragLoaded",value:function(e,t){var r=t.frag,i=t.part,a=i?i.stats:r.stats;if(r.type===B&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var n=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+a.loaded,l=(s.loaded?s.loaded.duration:0)+n;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(M.FRAG_BUFFERED,u),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part,a=null!=i&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var n=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,a.loaded),a.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==B||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,r=e.minAutoLevel,i=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,n=this.findBestLevel(i,r,t,0,a,1,1);if(n>-1)return n;var s=this.hls.firstLevel,o=Math.min(Math.max(s,r),t);return this.warn("Could not find best starting auto level. Defaulting to first in playlist ".concat(s," clamped to ").concat(o)),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,i)&&a[e].loadError<=a[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}},{key:"getAutoLevelKey",value:function(){return"".concat(this.getBwEstimate(),"_").concat(this.getStarvationDelay().toFixed(2))}},{key:"getNextABRAutoLevel",value:function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls;if(r.levels.length<=1)return r.loadLevel;var i=r.maxAutoLevel,a=r.config,n=r.minAutoLevel,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),u=a.abrBandWidthFactor,c=a.abrBandWidthUpFactor;if(l){var d=this.findBestLevel(o,n,i,l,0,u,c);if(d>=0)return this.rebufferNotice=-1,d}var h=s?Math.min(s,a.maxStarvationDelay):a.maxStarvationDelay;if(!l){var f=this.bitrateTestDelay;if(f)h=(s?Math.min(s,a.maxLoadingDelay):a.maxLoadingDelay)-f,this.info("bitrate test took ".concat(Math.round(1e3*f),"ms, set first fragment max fetchDuration to ").concat(Math.round(1e3*h)," ms")),u=c=1}var v=this.findBestLevel(o,n,i,l,h,u,c);if(this.rebufferNotice!==v&&(this.rebufferNotice=v,this.info("".concat(l?"rebuffering expected":"buffer is empty",", optimal quality level ").concat(v))),v>-1)return v;var g=r.levels[n],p=r.loadLevelObj;return p&&(null==g?void 0:g.bitrate)<p.bitrate?n:r.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var r=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/r}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,r,i,a,n,s){var o,l=this,u=i+a,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,f=this.fragCurrent,v=this.partCurrent,g=this.hls,p=g.levels,m=g.allAudioTracks,y=g.loadLevel,k=g.config;if(1===p.length)return 0;var E,T=p[h],S=!(null==(o=this.hls.latestLevelDetails)||!o.live),b=-1===y||-1===d,L="SDR",A=(null==T?void 0:T.frameRate)||0,R=k.audioPreference,I=k.videoPreference,w=this.audioTracksByGroup||(this.audioTracksByGroup=Lt(m)),_=-1;if(b){if(-1!==this.firstSelection)return this.firstSelection;var x=this.codecTiers||(this.codecTiers=function(e,t,r,i){return e.slice(r,i+1).reduce((function(e,r,i){if(!r.codecSet)return e;var a=r.audioGroups,n=e[r.codecSet];n||(e[r.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,r.bitrate);var s=Math.min(r.height,r.width);return n.minHeight=Math.min(n.minHeight,s),n.minFramerate=Math.min(n.minFramerate,r.frameRate),n.minIndex=Math.min(n.minIndex,i),n.maxScore=Math.max(n.maxScore,r.score),n.fragmentError+=r.fragmentError,n.videoRanges[r.videoRange]=(n.videoRanges[r.videoRange]||0)+1,a&&a.forEach((function(e){if(e){var r=t.groups[e];r&&(n.hasDefaultAudio=n.hasDefaultAudio||t.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(r.channels).forEach((function(e){n.channels[e]=(n.channels[e]||0)+r.channels[e]})))}})),e}),{})}(p,w,t,r)),P=function(e,t,r,i,a){for(var n=Object.keys(e),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=null==a?void 0:a.videoCodec,u=s&&2===parseInt(s),c=!1,d=!1,h=1/0,f=1/0,v=1/0,g=1/0,p=0,m=[],y=Tt(t,a),k=y.preferHDR,E=y.allowedVideoRanges,T=function(t){var r=e[n[t]];c||(c=r.channels[2]>0),h=Math.min(h,r.minHeight),f=Math.min(f,r.minFramerate),v=Math.min(v,r.minBitrate),E.filter((function(e){return r.videoRanges[e]>0})).length>0&&(d=!0)},S=n.length;S--;)T(S);h=D(h)?h:0,f=D(f)?f:0;var b=Math.max(1080,h),L=Math.max(30,f);v=D(v)?v:r,r=Math.max(v,r),d||(t=void 0);var A=n.length>1;return{codecSet:n.reduce((function(t,i){var a=e[i];if(i===t)return t;if(m=d?E.filter((function(e){return a.videoRanges[e]>0})):[],A){if(a.minBitrate>r)return bt(i,"min bitrate of ".concat(a.minBitrate," > current estimate of ").concat(r)),t;if(!a.hasDefaultAudio)return bt(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return bt(i,'audio codec preference "'.concat(o,'" not found')),t;if(s&&!u){if(!a.channels[s])return bt(i,"no renditions with ".concat(s," channel sound found (channels options: ").concat(Object.keys(a.channels),")")),t}else if((!o||u)&&c&&0===a.channels[2])return bt(i,"no renditions with stereo sound found"),t;if(a.minHeight>b)return bt(i,"min resolution of ".concat(a.minHeight," > maximum of ").concat(b)),t;if(a.minFramerate>L)return bt(i,"min framerate of ".concat(a.minFramerate," > maximum of ").concat(L)),t;if(!m.some((function(e){return a.videoRanges[e]>0})))return bt(i,"no variants with VIDEO-RANGE of ".concat(St(m)," found")),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return bt(i,'video codec preference "'.concat(l,'" not found')),t;if(a.maxScore<p)return bt(i,"max score of ".concat(a.maxScore," < selected max of ").concat(p)),t}return t&&(Je(i)>=Je(t)||a.fragmentError>e[t].fragmentError)?t:(g=a.minIndex,p=a.maxScore,i)}),void 0),videoRanges:m,preferHDR:k,minFramerate:f,minBitrate:v,minIndex:g}}(x,L,e,R,I),C=P.codecSet,M=P.videoRanges,O=P.minFramerate,F=P.minBitrate,N=P.minIndex,U=P.preferHDR;_=N,E=C,L=U?M[M.length-1]:M[0],A=O,e=Math.max(e,F),this.log("picked start tier ".concat(St(P)))}else E=null==T?void 0:T.codecSet,L=null==T?void 0:T.videoRange;for(var B=v?v.duration:f?f.duration:0,G=this.bwEstimator.getEstimateTTFB()/1e3,H=[],K=function(t){var o=p[t],c=t>h;if(!o)return"continue";if(k.useMediaCapabilities&&!o.supportedResult&&!o.supportedPromise){var f=navigator.mediaCapabilities;"function"==typeof(null==f?void 0:f.decodingInfo)&&(function(e,t,r,i,a,n){var s=e.audioCodec?e.audioGroups:null,o=null==n?void 0:n.audioCodec,l=null==n?void 0:n.channels,u=l?parseInt(l):o?1/0:2,c=null;if(null!=s&&s.length)try{c=1===s.length&&s[0]?t.groups[s[0]].channels:s.reduce((function(e,r){if(r){var i=t.groups[r];if(!i)throw new Error("Audio track group ".concat(r," not found"));Object.keys(i.channels).forEach((function(t){e[t]=(e[t]||0)+i.channels[t]}))}return e}),{2:0})}catch(d){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==r||e.bitrate>Math.max(a,8e6))||!!c&&D(u)&&Object.keys(c).some((function(e){return parseInt(e)>u}))}(o,w,L,A,e,R)||Ge(o.videoCodec))?(o.supportedPromise=dt(o,w,f),o.supportedPromise.then((function(e){if(l.hls){o.supportedResult=e;var t=l.hls.levels,r=t.indexOf(o);e.error?l.warn('MediaCapabilities decodingInfo error: "'.concat(e.error,'" for level ').concat(r," ").concat(St(e))):e.supported||(l.warn("Unsupported MediaCapabilities decodingInfo result for level ".concat(r," ").concat(St(e))),r>-1&&t.length>1&&(l.log("Removing unsupported level ".concat(r)),l.hls.removeLevel(r),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0)))}}))):o.supportedResult=lt}if((E&&o.codecSet!==E||L&&o.videoRange!==L||c&&A>o.frameRate||!c&&A>0&&A<o.frameRate||o.supportedResult&&(null==(j=o.supportedResult.decodingInfoResults)||!j[0].smooth))&&(!b||t!==_))return H.push(t),"continue";var g=o.details,m=(v?null==g?void 0:g.partTarget:null==g?void 0:g.averagetargetduration)||B,T=void 0;T=c?s*e:n*e;var I=B&&i>=2*B&&0===a?o.averageBitrate:o.maxBitrate,x=l.getTimeToLoadFrag(G,T,I*m,void 0===g);if(T>=I&&(t===d||0===o.loadError&&0===o.fragmentError)&&(x<=G||!D(x)||S&&!l.bitrateTestDelay||x<u)){var P=l.forcedAutoLevel;return t===y||-1!==P&&P===y||(H.length&&l.trace("Skipped level(s) ".concat(H.join(",")," of ").concat(r,' max with CODECS and VIDEO-RANGE:"').concat(p[H[0]].codecs,'" ').concat(p[H[0]].videoRange,'; not compatible with "').concat(E,'" ').concat(L)),l.info("switch candidate:".concat(h,"->").concat(t," adjustedbw(").concat(Math.round(T),")-bitrate=").concat(Math.round(T-I)," ttfb:").concat(G.toFixed(1)," avgDuration:").concat(m.toFixed(1)," maxFetchDuration:").concat(u.toFixed(1)," fetchDuration:").concat(x.toFixed(1)," firstSelection:").concat(b," codecSet:").concat(o.codecSet," videoRange:").concat(o.videoRange," hls.loadLevel:").concat(y))),b&&(l.firstSelection=t),{v:t}}},V=r;V>=t;V--){var j,W=K(V);if("continue"!==W&&"object"===c(W))return W.v}return-1}},{key:"deriveNextAutoLevel",value:function(e){var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel;return Math.min(Math.max(e,i),r)}}]),r}($),Pt=function(e,t){for(var r=0,i=e.length-1,a=null,n=null;r<=i;){var s=t(n=e[a=(r+i)/2|0]);if(s>0)r=a+1;else{if(!(s<0))return n;i=a-1}}return null};function Ct(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.005,n=null;if(e){n=t[1+e.sn-t[0].sn]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7),n&&e.level!==n.level&&n.end<=e.end&&(n=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(n=t[0]);if(n&&((!e||e.level===n.level)&&0===Ot(r,i,n)||Mt(n,e,Math.min(a,i))))return n;var o=Pt(t,Ot.bind(null,r,i));return!o||o===e&&n?n:o}function Mt(e,t,r){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var i=t.tagList.reduce((function(e,t){return"INF"===t[0]&&(e+=parseFloat(t[1])),e}),r);return e.start<=i}return!1}function Ot(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;if(r.start<=e&&r.start+r.duration>e)return 0;var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Ft(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function Nt(e,t){return Pt(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}function Ut(e){switch(e.details){case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_TIMEOUT:case C.LEVEL_LOAD_TIMEOUT:case C.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Bt(e,t){var r=Ut(t);return e.default["".concat(r?"timeout":"error","Retry")]}function Gt(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function Ht(e){return q(q({},e),{errorRetry:null,timeoutRetry:null})}function Kt(e,t,r,i){if(!e)return!1;var a=null==i?void 0:i.code,n=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(a)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,n):n}var Vt=0,jt=2,Wt=3,Yt=5,qt=0,$t=1,zt=2,Xt=function(e){g(r,e);var t=n(r);function r(e){var i;return b(this,r),(i=t.call(this,"error-controller",e.logger)).hls=void 0,i.playlistError=0,i.penalizedRenditions={},i.hls=e,i.registerListeners(),i}return A(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(M.ERROR,this.onError,this),e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(M.ERROR,this.onError,this),e.off(M.ERROR,this.onErrorOut,this),e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.LEVEL_UPDATED,this.onLevelUpdated,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.playlistError=0}},{key:"getVariantLevelIndex",value:function(e){return(null==e?void 0:e.type)===B?e.level:this.hls.loadLevel}},{key:"onManifestLoading",value:function(){this.playlistError=0,this.penalizedRenditions={}}},{key:"onLevelUpdated",value:function(){this.playlistError=0}},{key:"onError",value:function(e,t){var r;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case C.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=Qt());case C.FRAG_GAP:case C.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=jt);case C.LEVEL_EMPTY_ERROR:case C.LEVEL_PARSING_ERROR:var n,s,o=t.parent===B?t.level:i.loadLevel;return void(t.details===C.LEVEL_EMPTY_ERROR&&null!=(n=t.context)&&null!=(s=n.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case C.LEVEL_LOAD_ERROR:case C.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.SUBTITLE_LOAD_ERROR:case C.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var l=i.loadLevelObj;if(l&&(a.type===N&&l.hasAudioGroup(a.groupId)||a.type===U&&l.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=jt,void(t.errorAction.flags=$t)}return;case C.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var u=i.loadLevelObj,c=null==u?void 0:u.attrs["HDCP-LEVEL"];return void(c?t.errorAction={action:jt,flags:zt,hdcpLevel:c}:this.keySystemError(t));case C.BUFFER_ADD_CODEC_ERROR:case C.REMUX_ALLOC_ERROR:case C.BUFFER_APPEND_ERROR:var d;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(d=t.level)?d:i.loadLevel);return;case C.INTERNAL_EXCEPTION:case C.BUFFER_APPENDING_ERROR:case C.BUFFER_FULL_ERROR:case C.LEVEL_SWITCH_ERROR:case C.BUFFER_STALLED_ERROR:case C.BUFFER_SEEK_OVER_HOLE:case C.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=Qt())}t.type===P.KEY_SYSTEM_ERROR&&this.keySystemError(t)}}},{key:"keySystemError",value:function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}},{key:"getPlaylistRetryOrSwitchAction",value:function(e,t){var r=Bt(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Kt(r,i,Ut(e),e.response))return{action:Yt,flags:qt,retryConfig:r,retryCount:i};var a=this.getLevelSwitchAction(e,t);return r&&(a.retryConfig=r,a.retryCount=i),a}},{key:"getFragRetryOrSwitchAction",value:function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],a=t.config,n=a.fragLoadPolicy,s=a.keyLoadPolicy,o=Bt(e.details.startsWith("key")?s:n,e),l=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(i&&(e.details!==C.FRAG_GAP&&i.fragmentError++,Kt(o,l,Ut(e),e.response)))return{action:Yt,flags:qt,retryConfig:o,retryCount:l};var u=this.getLevelSwitchAction(e,r);return o&&(u.retryConfig=o,u.retryCount=l),u}},{key:"getLevelSwitchAction",value:function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var a,n,s=e.details;i.loadError++,s===C.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,l=r.levels,u=r.loadLevel,c=r.minAutoLevel,d=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var h=null==(a=e.frag)?void 0:a.type,f=(h===G&&s===C.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===C.BUFFER_ADD_CODEC_ERROR||s===C.BUFFER_APPEND_ERROR))&&l.some((function(e){var t=e.audioCodec;return i.audioCodec!==t})),v="video"===e.sourceBufferName&&(s===C.BUFFER_ADD_CODEC_ERROR||s===C.BUFFER_APPEND_ERROR)&&l.some((function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),g=null!=(n=e.context)?n:{},p=g.type,m=g.groupId,y=l.length;y--;){var k=(y+u)%l.length;if(k!==u&&k>=c&&k<=d&&0===l[k].loadError){var E,T,S=function(){var t=l[k];if(s===C.FRAG_GAP&&h===B&&e.frag){var r=l[k].details;if(r){var a=Ct(e.frag,r.fragments,e.frag.start);if(null!=a&&a.gap)return"continue"}}else{if(p===N&&t.hasAudioGroup(m)||p===U&&t.hasSubtitleGroup(m))return"continue";if(h===G&&null!=(E=i.audioGroups)&&E.some((function(e){return t.hasAudioGroup(e)}))||h===H&&null!=(T=i.subtitleGroups)&&T.some((function(e){return t.hasSubtitleGroup(e)}))||f&&i.audioCodec===t.audioCodec||!f&&i.audioCodec!==t.audioCodec||v&&i.codecSet===t.codecSet)return"continue"}return o=k,"break"}();if("continue"===S)continue;if("break"===S)break}}if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:jt,flags:qt,nextAutoLevel:o}}return{action:jt,flags:$t}}},{key:"onErrorOut",value:function(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case Vt:break;case jt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===C.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'.concat(t.sourceBufferName,'" sourceBuffer append error. Attempting to recover from media error.')),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}},{key:"sendAlternateToPenaltyBox",value:function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,a=r.hdcpLevel,n=r.nextAutoLevel;switch(i){case qt:this.switchLevel(e,n);break;case zt:a&&(t.maxHdcpLevel=ht[ht.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'.concat(t.maxHdcpLevel,'" or lower'))}r.resolved||this.switchLevel(e,n)}}},{key:"switchLevel",value:function(e,t){if(void 0!==t&&e.errorAction&&(this.warn("switching to level ".concat(t," after ").concat(e.details)),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===C.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName))for(var r=ot(e.mimeType),i=this.hls.levels,a=i.length;a--;)i[a]["".concat(e.sourceBufferName,"Codec")]===r&&this.hls.removeLevel(a)}}]),r}($);function Qt(e){var t={action:Vt,flags:qt};return e&&(t.resolved=!0),t}var Zt="NOT_LOADED",Jt="APPENDING",er="PARTIAL",tr="OK",rr=function(){function e(t){b(this,e),this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}return A(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.BUFFER_APPENDED,this.onBufferAppended,this),e.on(M.FRAG_BUFFERED,this.onFragBuffered,this),e.on(M.FRAG_LOADED,this.onFragLoaded,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.BUFFER_APPENDED,this.onBufferAppended,this),e.off(M.FRAG_BUFFERED,this.onFragBuffered,this),e.off(M.FRAG_LOADED,this.onFragLoaded,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;var n=a.end;if(a.start<=e&&null!==n&&e<=n)return a}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,r){for(var i=this.fragments,a=Object.keys(i),n=a.length;n--;){var s=i[a[n]];if((null==s?void 0:s.body.type)===t&&(!r||s.buffered)){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null}},{key:"detectEvictedFragments",value:function(e,t,r,i,a){var n=this;this.timeRanges&&(this.timeRanges[e]=t);var s=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(i){var o=n.fragments[i];if(o&&!(s>=o.body.sn))if(o.buffered||o.loaded&&!a){var l=o.range[e];l&&(0!==l.time.length?l.time.some((function(e){var r=!n.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&n.removeFragment(o.body),r})):n.removeFragment(o.body))}else o.body.type===r&&n.removeFragment(o.body)}))}},{key:"detectPartialFragments",value:function(e){var t=this,r=this.timeRanges;if(r&&"initSegment"!==e.frag.sn){var i=e.frag,a=ar(i),n=this.fragments[a];if(!(!n||n.buffered&&i.gap)){var s=!i.relurl;if(Object.keys(r).forEach((function(a){var o=i.elementaryStreams[a];if(o){var l=r[a],u=s||!0===o.partial;n.range[a]=t.getBufferedTimes(i,e.part,u,l)}})),n.loaded=null,Object.keys(n.range).length)n.buffered=!0,(n.body.endList=i.endList||n.body.endList)&&(this.endListFragments[n.body.type]=n),ir(n)||this.removeParts(i.sn-1,i.type);else this.removeFragment(n.body)}}}},{key:"removeParts",value:function(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter((function(t){return t.fragment.sn>=e})))}},{key:"fragBuffered",value:function(e,t){var r=ar(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}},{key:"getBufferedTimes",value:function(e,t,r,i){for(var a={time:[],partial:r},n=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||n,u=0;u<i.length;u++){var c=i.start(u)-this.bufferPadding,d=i.end(u)+this.bufferPadding;if(l>=c&&o<=d){a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(n<d&&s>c){var h=Math.max(n,i.start(u)),f=Math.min(s,i.end(u));f>h&&(a.partial=!0,a.time.push({startPTS:h,endPTS:f}))}else if(s<=c)break}return a}},{key:"getPartialFragment",value:function(e){var t,r,i,a=null,n=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&ir(u)&&(r=u.body.start-s,i=u.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),n<=t&&(a=u.body,n=t)))})),a}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||ir(t))}},{key:"getState",value:function(e){var t=ar(e),r=this.fragments[t];return r?r.buffered?ir(r)?er:tr:Jt:Zt}},{key:"isTimeBuffered",value:function(e,t,r){for(var i,a,n=0;n<r.length;n++){if(i=r.start(n)-this.bufferPadding,a=r.end(n)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1}},{key:"onManifestLoading",value:function(){this.removeAllFragments()}},{key:"onFragLoaded",value:function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var r=t.frag,i=t.part?null:t,a=ar(r);this.fragments[a]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}}},{key:"onBufferAppended",value:function(e,t){var r=t.frag,i=t.part,a=t.timeRanges,n=t.type;if("initSegment"!==r.sn){var s=r.type;if(i){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(i)}this.timeRanges=a;var l=a[n];this.detectEvictedFragments(n,l,s,i)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=ar(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,r=Object.keys(t);if(!e)return r.length>0;for(var i=r.length;i--;){var a=t[r[i]];if((null==a?void 0:a.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,r,i,a){var n=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=n.fragments[s];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.start<t&&l.end>e&&(o.buffered||a)&&n.removeFragment(l)}}))}},{key:"removeFragment",value:function(e){var t=ar(e);e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=r.filter((function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e,t;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var r=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;r&&r.forEach((function(e){return e.clearElementaryStreamInfo()}))}}]),e}();function ir(e){var t,r,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function ar(e){return"".concat(e.type,"_").concat(e.level,"_").concat(e.sn)}var nr=0,sr=1,or=function(){function e(t,r,i){b(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=r,this.aesMode=i}return A(e,[{key:"decrypt",value:function(e,t){switch(this.aesMode){case nr:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case sr:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode ".concat(this.aesMode))}}}]),e}();var lr=function(){function e(){b(this,e),this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}return A(e,[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],d=o[3],h=new Uint32Array(256),f=0,v=0,g=0;for(g=0;g<256;g++)h[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=v^v<<1^v<<2^v<<3^v<<4;p=p>>>8^255&p^99,e[f]=p,t[p]=f;var m=h[f],y=h[m],k=h[y],E=257*h[p]^16843008*p;i[f]=E<<24|E>>>8,a[f]=E<<16|E>>>16,n[f]=E<<8|E>>>24,s[f]=E,E=16843009*k^65537*y^257*m^16843008*f,l[p]=E<<24|E>>>8,u[p]=E<<16|E>>>16,c[p]=E<<8|E>>>24,d[p]=E,f?(f=m^h[h[h[k^m]]],v^=h[h[v]]):f=v=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var n,s,o,l,u=this.ksRows=4*(a+6+1),c=this.keySchedule=new Uint32Array(u),d=this.invKeySchedule=new Uint32Array(u),h=this.sBox,f=this.rcon,v=this.invSubMix,g=v[0],p=v[1],m=v[2],y=v[3];for(n=0;n<u;n++)n<a?o=c[n]=t[n]:(l=o,n%a==0?(l=h[(l=l<<8|l>>>24)>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l],l^=f[n/a|0]<<24):a>6&&n%a==4&&(l=h[l>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l]),c[n]=o=(c[n-a]^l)>>>0);for(s=0;s<u;s++)n=u-s,l=3&s?c[n]:c[n-4],d[s]=s<4||n<=4?l:g[h[l>>>24]]^p[h[l>>>16&255]]^m[h[l>>>8&255]]^y[h[255&l]],d[s]=d[s]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,r){for(var i,a,n,s,o,l,u,c,d,h,f,v,g,p,m=this.keySize+6,y=this.invKeySchedule,k=this.invSBox,E=this.invSubMix,T=E[0],S=E[1],b=E[2],L=E[3],A=this.uint8ArrayToUint32Array_(r),R=A[0],I=A[1],w=A[2],D=A[3],_=new Int32Array(e),x=new Int32Array(_.length),P=this.networkToHostOrderSwap;t<_.length;){for(d=P(_[t]),h=P(_[t+1]),f=P(_[t+2]),v=P(_[t+3]),o=d^y[0],l=v^y[1],u=f^y[2],c=h^y[3],g=4,p=1;p<m;p++)i=T[o>>>24]^S[l>>16&255]^b[u>>8&255]^L[255&c]^y[g],a=T[l>>>24]^S[u>>16&255]^b[c>>8&255]^L[255&o]^y[g+1],n=T[u>>>24]^S[c>>16&255]^b[o>>8&255]^L[255&l]^y[g+2],s=T[c>>>24]^S[o>>16&255]^b[l>>8&255]^L[255&u]^y[g+3],o=i,l=a,u=n,c=s,g+=4;i=k[o>>>24]<<24^k[l>>16&255]<<16^k[u>>8&255]<<8^k[255&c]^y[g],a=k[l>>>24]<<24^k[u>>16&255]<<16^k[c>>8&255]<<8^k[255&o]^y[g+1],n=k[u>>>24]<<24^k[c>>16&255]<<16^k[o>>8&255]<<8^k[255&l]^y[g+2],s=k[c>>>24]<<24^k[o>>16&255]<<16^k[l>>8&255]<<8^k[255&u]^y[g+3],x[t]=P(i^R),x[t+1]=P(s^I),x[t+2]=P(n^w),x[t+3]=P(a^D),R=d,I=h,w=f,D=v,t+=4}return x.buffer}}]),e}(),ur=function(){function e(t,r,i){b(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=r,this.aesMode=i}return A(e,[{key:"expandKey",value:function(){var e=function(e){switch(e){case nr:return"AES-CBC";case sr:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode ".concat(e))}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}]),e}();var cr=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.removePKCS7Padding,a=void 0===i||i;if(b(this,e),this.logEnabled=!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.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=a,a)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(s){}this.useSoftware=!this.subtle}return A(e,[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,a,n=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=n).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?r.slice(0,i-a):r):n}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,r,i){var a=this;return this.useSoftware?new Promise((function(n,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);a.softwareDecrypt(o,t,r,i);var l=a.flush();l?n(l.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)}},{key:"softwareDecrypt",value:function(e,t,r,i){var a=this.currentIV,n=this.currentResult,s=this.remainderData;if(i!==nr||16!==t.byteLength)return te.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=Ue(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;a&&(r=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new lr),l.expandKey(t);var u=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,u||null}},{key:"webCryptoDecrypt",value:function(e,t,r,i){var a=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new ur(this.subtle,t,i)}return this.fastAesKey.expandKey().then((function(t){return a.subtle?(a.logOnce("WebCrypto AES decrypt"),new or(a.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return te.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, ".concat(n.name,": ").concat(n.message)),a.onWebCryptoError(e,t,r,i)}))}},{key:"onWebCryptoError",value:function(e,t,r,i){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);var n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(te.log("[decrypter]: ".concat(e)),this.logEnabled=!1)}}]),e}(),dr=Math.pow(2,17),hr=function(){function e(t){b(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}return A(e,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new pr({type:P.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a ".concat(i?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,n=a.fLoader,s=a.loader;return new Promise((function(o,l){if(r.loader&&r.loader.destroy(),e.gap){if(e.tagList.some((function(e){return"GAP"===e[0]})))return void l(vr(e));e.gap=!1}var u=r.loader=n?new n(a):new s(a),c=fr(e);e.loader=u;var d=Ht(a.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:dr};e.stats=u.stats;var f={onSuccess:function(t,i,a,n){r.resetLoader(e,u);var s=t.data;a.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),o({frag:e,part:null,payload:s,networkDetails:n})},onError:function(t,a,n,s){r.resetLoader(e,u),l(new pr({type:P.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:q({url:i,data:void 0},t),error:new Error("HTTP Error ".concat(t.code," ").concat(t.text)),networkDetails:n,stats:s}))},onAbort:function(t,i,a){r.resetLoader(e,u),l(new pr({type:P.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:a,stats:t}))},onTimeout:function(t,i,a){r.resetLoader(e,u),l(new pr({type:P.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after ".concat(h.timeout,"ms")),networkDetails:a,stats:t}))}};t&&(f.onProgress=function(r,i,a,n){return t({frag:e,part:null,payload:a,networkDetails:n})}),u.load(c,h,f)}))}},{key:"loadPart",value:function(e,t,r){var i=this;this.abort();var a=this.config,n=a.fLoader,s=a.loader;return new Promise((function(o,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(vr(e,t));else{var u=i.loader=n?new n(a):new s(a),c=fr(e,t);e.loader=u;var d=Ht(a.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:dr};t.stats=u.stats,u.load(c,h,{onSuccess:function(a,n,s,l){i.resetLoader(e,u),i.updateStatsFromPart(e,t);var c={frag:e,part:t,payload:a.data,networkDetails:l};r(c),o(c)},onError:function(r,a,n,s){i.resetLoader(e,u),l(new pr({type:P.NETWORK_ERROR,details:C.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:q({url:c.url,data:void 0},r),error:new Error("HTTP Error ".concat(r.code," ").concat(r.text)),networkDetails:n,stats:s}))},onAbort:function(r,a,n){e.stats.aborted=t.stats.aborted,i.resetLoader(e,u),l(new pr({type:P.NETWORK_ERROR,details:C.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:function(r,a,n){i.resetLoader(e,u),l(new pr({type:P.NETWORK_ERROR,details:C.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after ".concat(h.timeout,"ms")),networkDetails:n,stats:r}))}})}}))}},{key:"updateStatsFromPart",value:function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var n=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/a),n),o=(n-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}]),e}();function fr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,n=r.byteRangeEndOffset;if(D(a)&&D(n)){var s,o=a,l=n;if("initSegment"===e.sn&&gr(null==(s=e.decryptdata)?void 0:s.method)){var u=n-a;u%16&&(l=n+(16-u%16)),0!==a&&(i.resetIV=!0,o=a-16)}i.rangeStart=o,i.rangeEnd=l}return i}function vr(e,t){var r=new Error("GAP ".concat(e.gap?"tag":"attribute"," found")),i={type:P.MEDIA_ERROR,details:C.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new pr(i)}function gr(e){return"AES-128"===e||"AES-256"===e}var pr=function(e){g(r,e);var t=n(r);function r(e){var i;return b(this,r),(i=t.call(this,e.error.message)).data=void 0,i.data=e,i}return A(r)}(i(Error)),mr=function(e){g(r,e);var t=n(r);function r(e,i){var a;return b(this,r),(a=t.call(this,e,i))._boundTick=void 0,a._tickTimer=null,a._tickInterval=null,a._tickCallCount=0,a._boundTick=a.tick.bind(o(a)),a}return A(r,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}},{key:"doTick",value:function(){}}]),r}($),yr=A((function e(t,r,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];b(this,e),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=r,this.id=i,this.size=a,this.part=n,this.partial=s}));var kr={length:0,start:function(){return 0},end:function(){return 0}},Er=function(){function e(){b(this,e)}return A(e,null,[{key:"isBuffered",value:function(t,r){if(t)for(var i=e.getBuffered(t),a=i.length;a--;)if(r>=i.start(a)&&r<=i.end(a))return!0;return!1}},{key:"bufferedRanges",value:function(t){if(t){var r=e.getBuffered(t);return e.timeRangesToArray(r)}return[]}},{key:"timeRangesToArray",value:function(e){for(var t=[],r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}},{key:"bufferInfo",value:function(t,r,i){if(t){var a=e.bufferedRanges(t);if(a.length)return e.bufferedInfo(a,r,i)}return{len:0,start:r,end:r,bufferedIndex:-1}}},{key:"bufferedInfo",value:function(e,t,r){t=Math.max(0,t),e.length>1&&e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var i=-1,a=[];if(r)for(var n=0;n<e.length;n++){t>=e[n].start&&t<=e[n].end&&(i=n);var s=a.length;if(s){var o=a[s-1].end;e[n].start-o<r?e[n].end>o&&(a[s-1].end=e[n].end):a.push(e[n])}else a.push(e[n])}else a=e;for(var l,u=0,c=t,d=t,h=0;h<a.length;h++){var f=a[h].start,v=a[h].end;if(-1===i&&t>=f&&t<=v&&(i=h),t+r>=f&&t<v)c=f,u=(d=v)-t;else if(t+r<f){l=f;break}}return{len:u,start:c||0,end:d||0,nextStart:l,buffered:e,bufferedIndex:i}}},{key:"getBuffered",value:function(e){try{return e.buffered||kr}catch(t){return te.log("failed to get media.buffered",t),kr}}}]),e}(),Tr=/\{\$([a-zA-Z0-9-_]+)\}/g;function Sr(e){return Tr.test(e)}function br(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(Tr,(function(t){var i=t.substring(2,t.length-1),a=null==r?void 0:r[i];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'.concat(i,'"'))),t):a}))}return t}function Lr(e,t,r){var i,a,n=e.variableList;if(n||(e.variableList=n={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{var s=new self.URL(r).searchParams;if(!s.has(i))throw new Error('"'.concat(i,'" does not match any query parameter in URI: "').concat(r,'"'));a=s.get(i)}catch(o){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: ".concat(o.message)))}}else i=t.NAME,a=t.VALUE;i in n?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'.concat(i,'"'))):n[i]=a||""}function Ar(e,t,r){var i=t.IMPORT;if(r&&i in r){var a=e.variableList;a||(e.variableList=a={}),a[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'.concat(i,'"')))}var Rr=/^(\d+)x(\d+)$/,Ir=/(.+?)=(".*?"|.*?)(?:,|$)/g,wr=function(){function e(t,r){b(this,e),"string"==typeof t&&(t=e.parseAttrList(t,r)),W(this,t)}return A(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}},{key:"decimalInteger",value:function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"optionalFloat",value:function(e,t){var r=this[e];return r?parseFloat(r):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var r=this[e];return(r?r.split(/[ ,]+/):[]).reduce((function(e,t){return e[t.toLowerCase()]=!0,e}),t)}},{key:"bool",value:function(e){return"YES"===this[e]}},{key:"decimalResolution",value:function(e){var t=Rr.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var r,i={};for(Ir.lastIndex=0;null!==(r=Ir.exec(e));){var a=r[1].trim(),n=r[2],s=0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1,o=!1;if(s)n=n.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(s||o))n=br(t,n);else if(!o&&!s)switch(a){case"CLOSED-CAPTIONS":if("NONE"===n)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":te.warn("".concat(e,": attribute ").concat(a," is missing quotes"))}i[a]=n}return i}}]),e}();function Dr(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var _r=function(){function e(t,r){var i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(b(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==r?void 0:r.tagAnchor)||null,this.tagOrder=null!=(i=null==r?void 0:r.tagOrder)?i:a,r){var n=r.attr;for(var s in n)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==n[s]){te.warn('DATERANGE tag attribute: "'.concat(s,'" does not match for tags with ID: "').concat(t.ID,'"')),this._badValueForSameId=s;break}t=W(new wr({}),n,t)}if(this.attr=t,r?(this._startDate=r._startDate,this._cue=r._cue,this._endDate=r._endDate,this._dateAtEnd=r._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var o=(null==r?void 0:r.endDate)||new Date(this.attr["END-DATE"]);D(o.getTime())&&(this._endDate=o)}}return A(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(te.warn('Expected tagAnchor Fragment with PDT set for DateRange "'.concat(this.id,'": ').concat(e)),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(D(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&D(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}]),e}(),xr=function(){function e(t){b(this,e),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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!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.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return A(e,[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&D(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}]),e}();function Pr(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Cr(e){switch(e){case"AES-128":case"AES-256":return nr;case"AES-256-CTR":return sr;default:throw new Error("invalid full segment method ".concat(e))}}function Mr(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function Or(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}function Fr(e){var t,r,i=e.split(":"),a=null;if("data"===i[0]&&2===i.length){var n=i[1].split(";"),s=n[n.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(n.splice(-1,1),a=Mr(l)):(t=Or(l).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),a=r)}}return a}var Nr="undefined"!=typeof self?self:void 0,Ur={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Br="org.w3.clearkey",Gr="com.apple.streamingkeydelivery",Hr="com.microsoft.playready",Kr="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Vr(e){switch(e){case Gr:return Ur.FAIRPLAY;case Hr:return Ur.PLAYREADY;case Kr:return Ur.WIDEVINE;case Br:return Ur.CLEARKEY}}var jr="1077efecc0b24d02ace33c1e52e2fb4b",Wr="e2719d58a985b3c9781ab030af78d30e",Yr="9a04f07998404286ab92e65be0885f95",qr="edef8ba979d64acea3c827dcd51d21ed";function $r(e){return e===qr?Ur.WIDEVINE:e===Yr?Ur.PLAYREADY:e===jr||e===Wr?Ur.CLEARKEY:void 0}function zr(e){switch(e){case Ur.FAIRPLAY:return Gr;case Ur.PLAYREADY:return Hr;case Ur.WIDEVINE:return Kr;case Ur.CLEARKEY:return Br}}function Xr(e){var t=e.drmSystems,r=e.widevineLicenseUrl,i=t?[Ur.FAIRPLAY,Ur.WIDEVINE,Ur.PLAYREADY,Ur.CLEARKEY].filter((function(e){return!!t[e]})):[];return!i[Ur.WIDEVINE]&&r&&i.push(Ur.WIDEVINE),i}var Qr,Zr=null!=Nr&&null!=(Qr=Nr.navigator)&&Qr.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Jr(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,Array.from(t)),i=r.substring(r.indexOf("<"),r.length),a=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(a){var n=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(n){var s=Mr(n).subarray(0,16);return function(e){var t=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(s),s}}return null}var ei={},ti=function(){function e(t,r,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[1],n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;b(this,e),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=r,this.keyFormat=i,this.keyFormatVersions=a,this.iv=n,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!Pr(t)}return A(e,[{key:"isSupported",value:function(){if(this.method){if(Pr(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Gr:case Kr:case Hr:case Br:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}},{key:"getDecryptData",value:function(t){if(!this.encrypted||!this.uri)return null;if(Pr(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(te.warn('missing IV for initialization segment with method="'.concat(this.method,'" - compliance issue')),t=0);var r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var i=Fr(this.uri);if(i)switch(this.keyFormat){case Kr:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case Hr:var a=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=je(a,0,i),this.keyId=Jr(i);break;default:var n=i.subarray(0,16);if(16!==n.length){var s=new Uint8Array(16);s.set(n,16-n.length),n=s}this.keyId=n}if(!this.keyId||16!==this.keyId.byteLength){var o=ei[this.uri];if(!o){var l=Object.keys(ei).length%Number.MAX_SAFE_INTEGER;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),ei[this.uri]=o}this.keyId=o}return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){ei={}}}]),e}();var ri=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,ii=/#EXT-X-MEDIA:(.*)/g,ai=/^#EXT(?:INF|-X-TARGETDURATION):/m,ni=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),si=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),oi=function(){function e(){b(this,e)}return A(e,null,[{key:"findGroup",value:function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}}},{key:"resolve",value:function(e,t){return ue.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return ai.test(e)}},{key:"parseMasterPlaylist",value:function(t,r){var i,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Sr(t)},n=[];for(ri.lastIndex=0;null!=(i=ri.exec(t));)if(i[1]){var s,o=new wr(i[1],a),l=br(a,i[2]),u={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},c=o.decimalResolution("RESOLUTION");c&&(u.width=c.width,u.height=c.height),hi(o.CODECS,u);var d=o["SUPPLEMENTAL-CODECS"];d&&(u.supplemental={},hi(d,u.supplemental)),null!=(s=u.unknownCodecs)&&s.length||n.push(u),a.levels.push(u)}else if(i[3]){var h=i[3],f=i[4];switch(h){case"SESSION-DATA":var v=new wr(f,a),g=v["DATA-ID"];g&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[g]=v);break;case"SESSION-KEY":var p=ci(f,r,a);p.encrypted&&p.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(p)):te.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'.concat(f,'"'));break;case"DEFINE":Lr(a,new wr(f,a),r);break;case"CONTENT-STEERING":var m=new wr(f,a);a.contentSteering={uri:e.resolve(m["SERVER-URI"],r),pathwayId:m["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=di(f)}}var y=n.length>0&&n.length<a.levels.length;return a.levels=y?n:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}},{key:"parseMasterPlaylistMedia",value:function(t,r,i){var a,n={},s=i.levels,o={AUDIO:s.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:s.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(ii.lastIndex=0;null!==(a=ii.exec(t));){var u=new wr(a[1],i),c=u.TYPE;if(c){var d=o[c],h=n[c]||[];n[c]=h;var f=u.LANGUAGE,v=u["ASSOC-LANGUAGE"],g=u.CHANNELS,p=u.CHARACTERISTICS,m=u["INSTREAM-ID"],y={attrs:u,bitrate:0,id:l++,groupId:u["GROUP-ID"]||"",name:u.NAME||f||"",type:c,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:f,url:u.URI?e.resolve(u.URI,r):""};if(v&&(y.assocLang=v),g&&(y.channels=g),p&&(y.characteristics=p),m&&(y.instreamId=m),null!=d&&d.length){var k=e.findGroup(d,y.groupId)||d[0];fi(y,k,"audioCodec"),fi(y,k,"textCodec")}h.push(y)}}return n}},{key:"parseLevelPlaylist",value:function(e,t,r,i,a,n){var s,o,l,u,c,d={url:t},h=new xr(t),f=h.fragments,v=[],g=null,p=0,m=0,y=0,k=0,E=0,T=null,S=new pe(i,d),b=-1,L=!1,A=null;if(ni.lastIndex=0,h.m3u8=e,h.hasVariableRefs=Sr(e),"#EXTM3U"!==(null==(s=ni.exec(e))?void 0:s[0]))return h.playlistParsingError=new Error("Missing format identifier #EXTM3U"),h;for(;null!==(o=ni.exec(e));){L&&(L=!1,(S=new pe(i,d)).playlistOffset=y,S.start=y,S.sn=p,S.cc=k,E&&(S.bitrate=E),S.level=r,g&&(S.initSegment=g,g.rawProgramDateTime&&(S.rawProgramDateTime=g.rawProgramDateTime,g.rawProgramDateTime=null),A&&(S.setByteRange(A),A=null)));var R=o[1];if(R){S.duration=parseFloat(R);var I=(" "+o[2]).slice(1);S.title=I||null,S.tagList.push(I?["INF",R,I]:["INF",R])}else if(o[3]){if(D(S.duration)){S.playlistOffset=y,S.start=y,u&&pi(S,u,h),S.sn=p,S.level=r,S.cc=k,f.push(S);var w=(" "+o[3]).slice(1);S.relurl=br(h,w),vi(S,T,v),T=S,y+=S.duration,p++,m=0,L=!0}}else{if(!(o=o[0].match(si))){te.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&void 0===o[l];l++);var _=(" "+o[l]).slice(1),x=(" "+o[l+1]).slice(1),P=o[l+2]?(" "+o[l+2]).slice(1):null;switch(_){case"BYTERANGE":T?S.setByteRange(x,T):S.setByteRange(x);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=x,S.tagList.push(["PROGRAM-DATE-TIME",x]),-1===b&&(b=f.length);break;case"PLAYLIST-TYPE":h.type&&mi(h,_,o),h.type=x.toUpperCase();break;case"MEDIA-SEQUENCE":0!==h.startSN?mi(h,_,o):f.length>0&&yi(h,_,o),p=h.startSN=parseInt(x);break;case"SKIP":h.skippedSegments&&mi(h,_,o);var C=new wr(x,h),M=C.decimalInteger("SKIPPED-SEGMENTS");if(D(M)){h.skippedSegments+=M;for(var O=M;O--;)f.push(null);p+=M}var F=C.enumeratedString("RECENTLY-REMOVED-DATERANGES");F&&(h.recentlyRemovedDateranges=(h.recentlyRemovedDateranges||[]).concat(F.split("\t")));break;case"TARGETDURATION":0!==h.targetduration&&mi(h,_,o),h.targetduration=Math.max(parseInt(x),1);break;case"VERSION":null!==h.version&&mi(h,_,o),h.version=parseInt(x);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":h.live||mi(h,_,o),h.live=!1;break;case"#":(x||P)&&S.tagList.push(P?[x,P]:[x]);break;case"DISCONTINUITY":k++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([_]);break;case"BITRATE":S.tagList.push([_,x]),E=1e3*parseInt(x),D(E)?S.bitrate=E:E=0;break;case"DATERANGE":var N=new wr(x,h),U=new _r(N,h.dateRanges[N.ID],h.dateRangeTagCount);h.dateRangeTagCount++,U.isValid||h.skippedSegments?h.dateRanges[U.id]=U:te.warn('Ignoring invalid DATERANGE tag: "'.concat(x,'"')),S.tagList.push(["EXT-X-DATERANGE",x]);break;case"DEFINE":var B=new wr(x,h);"IMPORT"in B?Ar(h,B,n):Lr(h,B,t);break;case"DISCONTINUITY-SEQUENCE":0!==h.startCC?mi(h,_,o):f.length>0&&yi(h,_,o),h.startCC=k=parseInt(x);break;case"KEY":var G=ci(x,t,h);if(G.isSupported()){if("NONE"===G.method){u=void 0;break}u||(u={}),u[G.keyFormat]&&(u=W({},u)),u[G.keyFormat]=G}else te.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'.concat(x,'"'));break;case"START":h.startTimeOffset=di(x);break;case"MAP":var H=new wr(x,h);if(S.duration){var K=new pe(i,d);gi(K,H,r,u),g=K,S.initSegment=g,g.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=g.rawProgramDateTime)}else{var V=S.byteRangeEndOffset;if(V){var j=S.byteRangeStartOffset;A="".concat(V-j,"@").concat(j)}else A=null;gi(S,H,r,u),g=S,L=!0}g.cc=k;break;case"SERVER-CONTROL":c&&mi(h,_,o),c=new wr(x),h.canBlockReload=c.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=c.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&c.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=c.optionalFloat("PART-HOLD-BACK",0),h.holdBack=c.optionalFloat("HOLD-BACK",0);break;case"PART-INF":h.partTarget&&mi(h,_,o);var Y=new wr(x);h.partTarget=Y.decimalFloatingPoint("PART-TARGET");break;case"PART":var q=h.partList;q||(q=h.partList=[]);var $=m>0?q[q.length-1]:void 0,z=m++,X=new wr(x,h),Q=new me(X,S,d,z,$);q.push(Q),S.duration+=Q.duration;break;case"PRELOAD-HINT":var Z=new wr(x,h);h.preloadHint=Z;break;case"RENDITION-REPORT":var J=new wr(x,h);h.renditionReports=h.renditionReports||[],h.renditionReports.push(J);break;default:te.warn("line parsed but not handled: ".concat(o))}}}T&&!T.relurl?(f.pop(),y-=T.duration,h.partList&&(h.fragmentHint=T)):h.partList&&(vi(S,T,v),S.cc=k,h.fragmentHint=S,u&&pi(S,u,h)),h.targetduration||(h.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));var ee=f.length,re=f[0],ie=f[ee-1];if((y+=h.skippedSegments*h.targetduration)>0&&ee&&ie){h.averagetargetduration=y/ee;var ae=ie.sn;h.endSN="initSegment"!==ae?ae:0,h.live||(ie.endList=!0),re&&void 0===h.startCC&&(h.startCC=re.cc),b>0&&(!function(e,t){for(var r=e[t],i=t;i--;){var a=e[i];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}(f,b),re&&v.unshift(re))}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(y+=h.fragmentHint.duration),h.totalduration=y,v.length&&h.dateRangeTagCount&&re&&li(v,h),h.endCC=k,h}}]),e}();function li(e,t){for(var r=e.length,i=e[r-1],a=t.live?1/0:t.totalduration,n=Object.keys(t.dateRanges),s=n.length;s--;){var o=t.dateRanges[n[s]],l=o.startDate.getTime();o.tagAnchor=i.ref;for(var u=r;u--;){var c=ui(t,l,e,u,a);if(-1!==c){o.tagAnchor=t.fragments[c].ref;break}}}}function ui(e,t,r,i,a){var n=r[i];if(n){var s,o=n.programDateTime;if(t>=o||0===i)if(t<=o+1e3*(((null==(s=r[i+1])?void 0:s.start)||a)-n.start)){var l=r[i].sn-e.startSN,u=e.fragments;if(u.length>r.length)for(var c=(r[i+1]||u[u.length-1]).sn-e.startSN;c>l;c--){var d=u[c].programDateTime;if(t>=d&&t<d+1e3*u[c].duration)return c}return l}}return-1}function ci(e,t,r){var i,a,n=new wr(e,r),s=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),u=n.KEYFORMATVERSIONS,c=null!=(a=n.KEYFORMAT)?a:"identity";o&&n.IV&&!l&&te.error("Invalid IV: ".concat(n.IV));var d=o?oi.resolve(o,t):"",h=(u||"1").split("/").map(Number).filter(Number.isFinite);return new ti(s,d,c,h,l)}function di(e){var t=new wr(e).decimalFloatingPoint("TIME-OFFSET");return D(t)?t:null}function hi(e,t){var r=(e||"").split(/[ ,]+/).filter((function(e){return e}));["video","audio","text"].forEach((function(e){var i=r.filter((function(t){return $e(t,e)}));i.length&&(t["".concat(e,"Codec")]=i.map((function(e){return e.split("/")[0]})).join(","),r=r.filter((function(e){return-1===i.indexOf(e)})))})),t.unknownCodecs=r}function fi(e,t,r){var i=t[r];i&&(e[r]=i)}function vi(e,t,r){e.rawProgramDateTime?r.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function gi(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function pi(e,t,r){e.levelkeys=t;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((function(e){return t[e].isCommonEncryption}))||i.push(e)}function mi(e,t,r){e.playlistParsingError=new Error("#EXT-X-".concat(t," must not appear more than once (").concat(r[0],")"))}function yi(e,t,r){e.playlistParsingError=new Error("#EXT-X-".concat(t," must appear before the first Media Segment (").concat(r[0],")"))}function ki(e,t){var r=t.startPTS;if(D(r)){var i,a=0;t.sn>e.sn?(a=r-e.start,i=e):(a=e.start-r,i=t),i.duration!==a&&i.setDuration(a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function Ei(e,t,r,i,a,n){i-r<=0&&(te.warn("Fragment should have a positive duration",t),i=r+t.duration,n=a+t.duration);var s=r,o=i,l=t.startPTS,u=t.endPTS;if(D(l)){var c=Math.abs(l-r);D(t.deltaPTS)?t.deltaPTS=Math.max(c,t.deltaPTS):t.deltaPTS=c,s=Math.max(r,l),r=Math.min(r,l),a=Math.min(a,t.startDTS),o=Math.min(i,u),i=Math.max(i,u),n=Math.max(n,t.endDTS)}var d=r-t.start;0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=s,t.startDTS=a,t.endPTS=i,t.minEndPTS=o,t.endDTS=n;var h,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,g=e.fragments;for(g[v]=t,h=v;h>0;h--)ki(g[h],g[h-1]);for(h=v;h<g.length-1;h++)ki(g[h],g[h+1]);return e.fragmentHint&&ki(g[g.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,d}function Ti(e,t){if(e!==t){for(var r,i=null,a=e.fragments,n=a.length-1;n>=0;n--){var s=a[n].initSegment;if(s){i=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){for(var i=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,n=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=a;u<=n;u++){var c=l[s+u],d=o[u];if(i&&!d&&c&&(d=t.fragments[u]=c),c&&d){if(r(c,d,u,o),c.url&&c.url!==d.url)return void(t.playlistParsingError=Si("media sequence mismatch ".concat(d.sn,":"),e,t,c,d));if(c.cc!==d.cc)return void(t.playlistParsingError=Si("discontinuity sequence mismatch (".concat(c.cc,"!=").concat(d.cc,")"),e,t,c,d))}}}(e,t,(function(e,a,n,s){if(t.skippedSegments&&a.cc!==e.cc)for(var o=e.cc-a.cc,l=n;l<s.length;l++)s[l].cc+=o;D(e.startPTS)&&D(e.endPTS)&&(a.setStart(a.startPTS=e.startPTS),a.startDTS=e.startDTS,a.maxStartPTS=e.maxStartPTS,a.endPTS=e.endPTS,a.endDTS=e.endDTS,a.minEndPTS=e.minEndPTS,a.setDuration(e.endPTS-e.startPTS),a.duration&&(r=a),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(a.elementaryStreams=e.elementaryStreams),a.loader=e.loader,e.hasStats&&(a.stats=e.stats),e.initSegment&&(a.initSegment=e.initSegment,i=e.initSegment)}));var o=t.fragments,l=t.fragmentHint?o.concat(t.fragmentHint):o;if(i&&l.forEach((function(e){var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=i)?void 0:t.relurl)||(e.initSegment=i)})),t.skippedSegments)if(t.deltaUpdateFailed=o.some((function(e){return!e})),t.deltaUpdateFailed){te.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var u=t.skippedSegments;u--;)o.shift();t.startSN=o[0].sn}else{t.endCC=o[o.length-1].cc,t.canSkipDateRanges&&(t.dateRanges=function(e,t){var r=t.dateRanges,i=t.recentlyRemovedDateranges,a=W({},e);i&&i.forEach((function(e){delete a[e]}));var n=Object.keys(a).length;n&&Object.keys(r).forEach((function(e){var t=a[e],i=new _r(r[e].attr,t);i.isValid?(a[e]=i,t||(i.tagOrder+=n)):te.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'.concat(St(r[e].attr),'"'))}));return a}(e.dateRanges,t));var c=e.fragments.filter((function(e){return e.rawProgramDateTime}));if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var d=1;d<l.length;d++)null===l[d].programDateTime&&vi(l[d],l[d-1],c);li(c,t)}!function(e,t,r){if(e&&t)for(var i=0,a=0,n=e.length;a<=n;a++){var s=e[a],o=t[a+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),r?Ei(t,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):bi(e,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var h=t.advancedDateTime;if(t.advanced&&h){var f=t.edge;t.driftStart||(t.driftStartTime=h,t.driftStart=f),t.driftEndTime=h,t.driftEnd=f}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}}function Si(e,t,r,i,a){return new Error("".concat(e," ").concat(a.url,"\nPlaylist starting @").concat(t.startSN,"\n").concat(t.m3u8,"\n\nPlaylist starting @").concat(r.startSN,"\n").concat(r.m3u8))}function bi(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,n=i>=0,s=0;if(n&&i<a.length)s=a[i].start;else if(n&&t.startSN===e.endSN+1)s=e.fragmentEnd;else if(n&&r)s=e.fragmentStart+i*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;s=e.fragmentStart}Li(t,s)}function Li(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function Ai(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,r=1e3*e.targetduration;if(e.updated){var i=e.fragments,a=4;if(i.length&&r*a>t){var n=1e3*i[i.length-1].duration;n<r&&(r=n)}}else r/=2;return Math.round(r)}function Ri(e,t,r){return e?Ii(e.partList,t,r):null}function Ii(e,t,r){if(e)for(var i=e.length;i--;){var a=e[i];if(a.index===r&&a.fragment.sn===t)return a}return null}function wi(e){e.forEach((function(e,t){var r;null==(r=e.details)||r.fragments.forEach((function(e){e.level=t,e.initSegment&&(e.initSegment.level=t)}))}))}function Di(e,t){for(var r=0,i=e.length;r<i;r++){var a;if((null==(a=e[r])?void 0:a.cc)===t)return e[r]}return null}function _i(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function xi(e,t){for(var r=t.fragments,i=0,a=r.length;i<a;i++)_i(r[i],e);t.fragmentHint&&_i(t.fragmentHint,e),t.alignedSliding=!0}function Pi(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var r=Math.min(t.endCC,e.endCC),i=Di(t.fragments,r),a=Di(e.fragments,r);if(i&&a)te.log("Aligning playlist at start of dicontinuity sequence ".concat(r)),xi(i.start-a.start,e)}}function Ci(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var a,n,s=Math.min(t.endCC,e.endCC);t.startCC<s&&e.startCC<s&&(a=Di(i,s),n=Di(r,s)),a&&n||(n=Di(r,(a=i[Math.floor(i.length/2)]).cc)||r[Math.floor(r.length/2)]);var o=a.programDateTime,l=n.programDateTime;if(o&&l)xi((l-o)/1e3-(n.start-a.start),e)}}}var Mi=function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="[".concat(e.start(i).toFixed(3),"-").concat(e.end(i).toFixed(3),"]");return t},Oi="STOPPED",Fi="IDLE",Ni="KEY_LOADING",Ui="FRAG_LOADING",Bi="FRAG_LOADING_WAITING_RETRY",Gi="WAITING_TRACK",Hi="PARSING",Ki="PARSED",Vi="ENDED",ji="ERROR",Wi="WAITING_INIT_PTS",Yi="WAITING_LEVEL",qi=function(r){g(a,r);var i=n(a);function a(e,t,r,n,s){var l;return b(this,a),(l=i.call(this,n,e.logger)).hls=void 0,l.fragPrevious=null,l.fragCurrent=null,l.fragmentTracker=void 0,l.transmuxer=null,l._state=Oi,l.playlistType=void 0,l.media=null,l.mediaBuffer=null,l.config=void 0,l.bitrateTest=!1,l.lastCurrentTime=0,l.nextLoadPosition=0,l.startPosition=0,l.startTimeOffset=null,l.retryDate=0,l.levels=null,l.fragmentLoader=void 0,l.keyLoader=void 0,l.levelLastLoaded=null,l.startFragRequested=!1,l.decrypter=void 0,l.initPTS=[],l.buffering=!0,l.loadingParts=!1,l.loopSn=void 0,l.onMediaSeeking=function(){var e=o(l),t=e.config,r=e.fragCurrent,i=e.media,a=e.mediaBuffer,n=e.state,s=i?i.currentTime:0,u=Er.bufferInfo(a||i,s,t.maxBufferHole);if(l.log("media seeking to ".concat(D(s)?s.toFixed(3):s,", state: ").concat(n)),l.state===Vi)l.resetLoadingState();else if(r){var c=t.maxFragLookUpTolerance,d=r.start-c,h=r.start+r.duration+c;if(!u.len||h<u.start||d>u.end){var f=s>h;(s<d||f)&&(f&&r.loader&&(l.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests(),l.resetLoadingState()),l.fragPrevious=null)}}if(i&&(l.fragmentTracker.removeFragmentsInRange(s,1/0,l.playlistType,!0),s>l.lastCurrentTime&&(l.lastCurrentTime=s),!l.loadingParts)){var v=Math.max(u.end,s),g=l.shouldLoadParts(l.getLevelDetails(),v);g&&(l.log("LL-Part loading ON after seeking to ".concat(s.toFixed(2)," with buffer @").concat(v.toFixed(2))),l.loadingParts=g)}l.hls.hasEnoughToStart||u.len||(l.log("setting startPosition to ".concat(s," because of seek before start")),l.nextLoadPosition=l.startPosition=s),l.tickImmediate()},l.onMediaEnded=function(){l.log("setting startPosition to 0 because media ended"),l.startPosition=l.lastCurrentTime=0},l.playlistType=s,l.hls=e,l.fragmentLoader=new hr(e.config),l.keyLoader=r,l.fragmentTracker=t,l.config=e.config,l.decrypter=new cr(e.config),l}return A(a,[{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(M.ERROR,this.onError,this)}},{key:"doTick",value:function(){this.onTickEnd()}},{key:"onTickEnd",value:function(){}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){if(this.state!==Oi){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Oi}}},{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"pauseBuffering",value:function(){this.buffering=!1}},{key:"resumeBuffering",value:function(){this.buffering=!0}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"_streamEnded",value:function(e,t){if(t.live||!this.media)return!1;var r=e.end||0,i=this.config.timelineOffset||0;if(r<=i)return!1;var a=e.nextStart;if(a&&a>i&&a<t.edge)return!1;if(this.media.currentTime<e.start)return!1;var n=t.partList;if(null!=n&&n.length){var s=n[n.length-1];return Er.isBuffered(this.media,s.start+s.duration/2)}var o=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}},{key:"getLevelDetails",value:function(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"onMediaAttached",value:function(e,t){var r=this.media=this.mediaBuffer=t.media;r.removeEventListener("seeking",this.onMediaSeeking),r.removeEventListener("ended",this.onMediaEnded),r.addEventListener("seeking",this.onMediaSeeking),r.addEventListener("ended",this.onMediaEnded);var i=this.config;this.levels&&i.autoStartLoad&&this.state===Oi&&this.startLoad(i.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),i.removeEventListener("seeking",this.onMediaSeeking),i.removeEventListener("ended",this.onMediaEnded),this.keyLoader&&!r&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,r)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),t(u(a.prototype),"onHandlerDestroying",this).call(this),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=Oi,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,t(u(a.prototype),"onHandlerDestroyed",this).call(this)}},{key:"loadFragment",value:function(e,t,r){this.startFragRequested=!0,this._loadFragForPlayback(e,t,r)}},{key:"_loadFragForPlayback",value:function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(e){var t=e.frag;if(i.fragContextChanged(t))return i.warn("".concat(t.type," sn: ").concat(t.sn).concat(e.part?" part: "+e.part.index:""," of ").concat(i.fragInfo(t,!1,e.part),") was dropped during download.")),void i.fragmentTracker.removeFragment(t);t.stats.chunkCount++,i._handleFragmentLoadProgress(e)})).then((function(e){if(e){var t=i.state,r=e.frag;i.fragContextChanged(r)?(t===Ui||!i.fragCurrent&&t===Hi)&&(i.fragmentTracker.removeFragment(r),i.state=Fi):("payload"in e&&(i.log("Loaded ".concat(r.type," sn: ").concat(r.sn," of ").concat(i.playlistLabel()," ").concat(r.level)),i.hls.trigger(M.FRAG_LOADED,e)),i._handleFragmentLoadComplete(e))}})).catch((function(t){i.state!==Oi&&i.state!==ji&&(i.warn("Frag error: ".concat((null==t?void 0:t.message)||t)),i.resetFragmentLoading(e))}))}},{key:"clearTrackerIfNeeded",value:function(e){var t,r=this.fragmentTracker;if(r.getState(e)===Jt){var i=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),n=Math.max(e.duration,a?a.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?e.sn-s.sn:0)||this.reduceMaxBufferLength(n,e.duration))&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===er&&r.removeFragment(e))}},{key:"checkLiveUpdate",value:function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}},{key:"waitForLive",value:function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}},{key:"flushMainBuffer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(e-t){var i={startOffset:e,endOffset:t,type:r};this.hls.trigger(M.BUFFER_FLUSHING,i)}}},{key:"_loadInitSegment",value:function(e,t){var r=this;this._doFragLoad(e,t).then((function(e){var t=null==e?void 0:e.frag;if(!t||r.fragContextChanged(t)||!r.levels)throw new Error("init load aborted");return e})).then((function(e){var t=r.hls,i=e.frag,a=e.payload,n=i.decryptdata;if(a&&a.byteLength>0&&null!=n&&n.key&&n.iv&&Pr(n.method)){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(a),n.key.buffer,n.iv.buffer,Cr(n.method)).catch((function(e){throw t.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e})).then((function(a){var n=self.performance.now();return t.trigger(M.FRAG_DECRYPTED,{frag:i,payload:a,stats:{tstart:s,tdecrypt:n}}),e.payload=a,r.completeInitSegmentLoad(e)}))}return r.completeInitSegmentLoad(e)})).catch((function(t){r.state!==Oi&&r.state!==ji&&(r.warn(t),r.resetFragmentLoading(e))}))}},{key:"completeInitSegmentLoad",value:function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==Oi&&(this.state=Fi),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var r=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered ".concat(e.type," sn: ").concat(e.sn).concat(t?" part: "+t.index:""," of ").concat(this.fragInfo(e,!1,t)," > buffer:").concat(r?Mi(Er.getBuffered(r)):"(detached)",")")),ge(e)){var i;if(e.type!==H){var a=e.elementaryStreams;if(!Object.keys(a).some((function(e){return!!a[e]})))return void(this.state=Fi)}var n=null==(i=this.levels)?void 0:i[e.level];null!=n&&n.fragmentError&&(this.log("Resetting level fragment error count of ".concat(n.fragmentError," on frag buffered")),n.fragmentError=0)}this.state=Fi}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,a=e.partsLoaded,n=!a||0===a.length||a.some((function(e){return!e})),s=new yr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n);t.flush(s)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(t,r){var i,a=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3?arguments[3]:void 0;this.fragCurrent=t;var o=null==r?void 0:r.details;if(!this.levels||!o)throw new Error("frag load aborted, missing level".concat(o?"":" detail","s"));var l=null;!t.encrypted||null!=(i=t.decryptdata)&&i.key?!t.encrypted&&o.encryptedFragments.length&&this.keyLoader.loadClear(t,o.encryptedFragments):(this.log("Loading key for ".concat(t.sn," of [").concat(o.startSN,"-").concat(o.endSN,"], ").concat(this.playlistLabel()," ").concat(t.level)),this.state=Ni,this.fragCurrent=t,l=this.keyLoader.load(t).then((function(e){if(!a.fragContextChanged(e.frag))return a.hls.trigger(M.KEY_LOADED,e),a.state===Ni&&(a.state=Fi),e})),this.hls.trigger(M.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(l=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING"))));var u=this.fragPrevious;if(ge(t)&&(!u||t.sn!==u.sn)){var c=this.shouldLoadParts(r.details,t.end);c!==this.loadingParts&&(this.log("LL-Part loading ".concat(c?"ON":"OFF"," loading sn ").concat(null==u?void 0:u.sn,"->").concat(t.sn)),this.loadingParts=c)}if(n=Math.max(t.start,n||0),this.loadingParts&&ge(t)){var d=o.partList;if(d&&s){n>t.end&&o.fragmentHint&&(t=o.fragmentHint);var h=this.getNextPart(d,t,n);if(h>-1){var f,v=d[h];return t=this.fragCurrent=v.fragment,this.log("Loading ".concat(t.type," sn: ").concat(t.sn," part: ").concat(v.index," (").concat(h,"/").concat(d.length-1,") of ").concat(this.fragInfo(t,!1,v),") cc: ").concat(t.cc," [").concat(o.startSN,"-").concat(o.endSN,"], target: ").concat(parseFloat(n.toFixed(3)))),this.nextLoadPosition=v.start+v.duration,this.state=Ui,f=l?l.then((function(e){return!e||a.fragContextChanged(e.frag)?null:a.doFragPartsLoad(t,v,r,s)})).catch((function(e){return a.handleFragLoadError(e)})):this.doFragPartsLoad(t,v,r,s).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(M.FRAG_LOADING,{frag:t,part:v,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}if(!t.url||this.loadedEndOfParts(d,n))return Promise.resolve(null)}}if(ge(t)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @".concat(n.toFixed(2))),this.loadingParts=!1;else if(!t.url)return Promise.resolve(null);this.log("Loading ".concat(t.type," sn: ").concat(t.sn," of ").concat(this.fragInfo(t,!1),") cc: ").concat(t.cc," ").concat(o?"["+o.startSN+"-"+o.endSN+"]":"",", target: ").concat(parseFloat(n.toFixed(3)))),D(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Ui;var g,p=this.config.progressive;return g=p&&l?l.then((function(e){return!e||a.fragContextChanged(null==e?void 0:e.frag)?null:a.fragmentLoader.load(t,s)})).catch((function(e){return a.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(t,p?s:void 0),l]).then((function(t){var r=e(t,1)[0];return!p&&r&&s&&s(r),r})).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(M.FRAG_LOADING,{frag:t,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):g}},{key:"doFragPartsLoad",value:function(e,t,r,i){var a=this;return new Promise((function(n,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function t(o){a.fragmentLoader.loadPart(e,o,i).then((function(i){l[o.index]=i;var s=i.part;a.hls.trigger(M.FRAG_LOADED,i);var c=Ri(r.details,e.sn,o.index+1)||Ii(u,e.sn,o.index+1);if(!c)return n({frag:e,part:s,partsLoaded:l});t(c)})).catch(s)}(t)}))}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;e.data&&t.details===C.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(M.ERROR,t)}else this.hls.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===Hi){var r=t.frag,i=t.part,a=t.level,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n);var s=this.getLevelDetails(),o=s&&r.sn>s.endSN||this.shouldLoadParts(s,r.end);o!==this.loadingParts&&(this.log("LL-Part loading ".concat(o?"ON":"OFF"," after parsing segment ending @").concat(r.end.toFixed(2))),this.loadingParts=o),this.updateLevelTiming(r,i,a,e.partial)}else this.fragCurrent||this.state===Oi||this.state===ji||(this.state=Fi)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var r,i,a=e.partList[0];if(t>=a.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0))if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t=this.levels,r=this.fragCurrent,i=e.level,a=e.sn,n=e.part;if(null==t||!t[i])return this.warn("Levels object was unset while buffering fragment ".concat(a," of ").concat(this.playlistLabel()," ").concat(i,". The current chunk will not be buffered.")),null;var s=t[i],o=s.details,l=n>-1?Ri(o,a,n):null,u=l?l.fragment:function(e,t,r){if(!e)return null;var i=e.fragments[t-e.startSN];return i||((i=e.fragmentHint)&&i.sn===t?i:t<e.startSN&&r&&r.sn===t?r:null)}(o,a,r);return u?(r&&r!==u&&(u.stats=r.stats),{frag:u,part:l,level:s}):null}},{key:"bufferFragmentData",value:function(e,t,r,i,a){var n;if(e&&this.state===Hi){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=Ue(s,o)),null!=(n=l)&&n.length){var u={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:l};if(this.hls.trigger(M.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(a)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(Er.isBuffered(t,t.currentTime)){var r=t.currentTime,i=Er.bufferInfo(t,r,0),a=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(e.start-n,i.end-n),r+n);e.start-s>n&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var r,i=this.getLoadPosition();if(!D(i))return null;var a=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,a)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,r,i){var a=Er.bufferInfo(e,t,i);if(0===a.len&&void 0!==a.nextStart){var n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&(a.nextStart<=n.end||n.gap)){var s=Math.max(Math.min(a.nextStart,n.end)-t,i);return Er.bufferInfo(e,t,s)}}return a}},{key:"getMaxBufferLength",value:function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)}},{key:"reduceMaxBufferLength",value:function(e,t){var r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t),a=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return a>=i&&(r.maxMaxBufferLength=a,this.warn("Reduce max buffer length to ".concat(a,"s")),!0)}},{key:"getAppendedFrag",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:B,i=null==(t=this.fragmentTracker)?void 0:t.getAppendedFrag(e,r);return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var a=this.config,n=r[0].start,s=a.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l=a.initialLiveManifestSize;if(i<l)return this.warn("Not enough fragments to start playback (have: ".concat(i,", need: ").concat(l,")")),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<n){var u;s&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(t,r);var c=this.hls.startPosition,d=this.hls.liveSyncPosition,h=o?(-1!==c&&c>=n?c:d)||o.start:e;this.log("Setting startPosition to ".concat(h," to match start frag at live edge. mainStart: ").concat(c," liveSyncPosition: ").concat(d," frag.start: ").concat(null==(u=o)?void 0:u.start)),this.startPosition=this.nextLoadPosition=h}}else e<=n&&(o=r[0]);if(!o){var f=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,f,t)}var v=this.filterReplacedPrimary(o,t);if(!v&&o){var g=o.sn-t.startSN;v=this.filterReplacedPrimary(r[g+1]||null,t)}return this.mapToInitFragWhenRequired(v)}},{key:"isLoopLoading",value:function(e,t){var r=this.fragmentTracker.getState(e);return(r===tr||r===er&&!!e.gap)&&this.nextLoadPosition>t}},{key:"getNextFragmentLoopLoading",value:function(e,t,r,i,a){var n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t))&&!n.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==s&&r.len+s.len>=a){var o=n.sn;return this.loopSn!==o&&(this.log('buffer full after gaps in "'.concat(i,'" playlist starting at sn: ').concat(o)),this.loopSn=o),null}}return this.loopSn=void 0,n}},{key:"primaryPrefetch",get:function(){var e,t;if($i(this.hls.config)&&(null==(e=this.hls.interstitialsManager)||null==(t=e.playingItem)?void 0:t.event))return!0;return!1}},{key:"filterReplacedPrimary",value:function(e,t){if(!e)return e;if($i(this.hls.config)&&e.type!==H){var r=this.hls.interstitialsManager,i=null==r?void 0:r.bufferingItem;if(i){var a=i.event;if(a){if(a.appendInPlace||Math.abs(e.start-i.start)>1||0===i.start)return null}else{if(e.end<=i.start&&!1===(null==t?void 0:t.live))return null;if(e.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||e.start-i.end>1))return null}}var n=null==r?void 0:r.playerQueue;if(n)for(var s=n.length;s--;){var o=n[s].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,r){for(var i=-1,a=!1,n=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(n=n&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;u?i=-1:(a||l.independent||n)&&l.fragment===t&&(i=s),a=u}return i}},{key:"loadedEndOfParts",value:function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded}},{key:"getInitialLiveFragment",value:function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: ".concat(r.programDateTime)),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!D(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i<e.length;++i){var a=e[i];if(Ft(t,r,a))return a}return null}(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var a=r.sn+1;if(a>=e.startSN&&a<=e.endSN){var n=t[a-e.startSN];r.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: ".concat(i.sn)))}i||(i=Nt(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: ".concat(i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}},{key:"getFragmentAtPosition",value:function(e,t,r){var i,a,n=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=n.maxFragLookUpTolerance,d=r.partList,h=!!(this.loadingParts&&null!=d&&d.length&&u);(h&&u&&!this.bitrateTest&&d[d.length-1].fragment.sn===u.sn&&(o=o.concat(u),l=u.sn),e<t)?i=Ct(s,o,e,e<this.lastCurrentTime||e>t-c||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:c):i=o[o.length-1];if(i){var f=i.sn-r.startSN,v=this.fragmentTracker.getState(i);if((v===tr||v===er&&i.gap)&&(s=i),s&&i.sn===s.sn&&(!h||d[0].fragment.sn>i.sn||!r.live&&!h))if(s&&i.level===s.level){var g=o[f+1];i=i.sn<l&&this.fragmentTracker.getState(g)!==tr?g:null}}return i}},{key:"alignPlaylists",value:function(e,t,r){var i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,n=!t,s=e.alignedSliding&&D(a);if(n||!s&&!a){!function(e,t){e&&(Pi(t,e),!t.alignedSliding&&e&&Ci(t,e),t.alignedSliding||!e||t.skippedSegments||bi(e,t,!1))}(r,e);var o=e.fragmentStart;return this.log("Live playlist sliding: ".concat(o.toFixed(2)," start-sn: ").concat(t?t.startSN:"na","->").concat(e.startSN," fragments: ").concat(i)),o}return a}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var r=this.startPosition;r<t&&(r=-1);var i=this.timelineOffset;if(-1===r){var a=null!==this.startTimeOffset,n=a?this.startTimeOffset:e.startTimeOffset;null!==n&&D(n)?(r=t+n,n<0&&(r+=e.edge),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Setting startPosition to ".concat(r," for start time offset ").concat(n," found in ").concat(a?"multivariant":"media"," playlist")),this.startPosition=r):e.live?(r=this.hls.liveSyncPosition||t,this.log("Setting startPosition to -1 to start at live edge ".concat(r)),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=r=0),this.lastCurrentTime=r+i}this.nextLoadPosition=r+i}},{key:"getLoadPosition",value:function(){var e,t=this.media,r=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?r=t.currentTime:this.nextLoadPosition>=0&&(r=this.nextLoadPosition),r}},{key:"handleFragLoadAborted",value:function(e,t){this.transmuxer&&e.type===this.playlistType&&ge(e)&&e.stats.aborted&&(this.warn("Fragment ".concat(e.sn).concat(t?" part "+t.index:""," of ").concat(this.playlistLabel()," ").concat(e.level," was aborted")),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===Bi)||(this.state=Fi)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag;if(i&&i.type===e&&this.levels)if(this.fragContextChanged(i)){var a;this.warn("Frag load error must match current frag to retry ".concat(i.url," > ").concat(null==(a=this.fragCurrent)?void 0:a.url))}else{var n=t.details===C.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);var s=t.errorAction,o=s||{},l=o.action,u=o.flags,c=o.retryCount,d=void 0===c?0:c,h=o.retryConfig,f=!!s&&!!h,v=f&&l===Yt,g=f&&!s.resolved&&u===$t;if(!v&&g&&ge(i)&&!i.endList)this.resetFragmentErrors(e),this.treatAsGap(i),s.resolved=!0;else if((v||g)&&d<h.maxNumRetry){this.resetStartWhenNotLoaded(this.levelLastLoaded);var p=Gt(h,d);this.warn("Fragment ".concat(i.sn," of ").concat(e," ").concat(i.level," errored with ").concat(t.details,", retrying loading ").concat(d+1,"/").concat(h.maxNumRetry," in ").concat(p,"ms")),s.resolved=!0,this.retryDate=self.performance.now()+p,this.state=Bi}else if(h&&s){if(this.resetFragmentErrors(e),!(d<h.maxNumRetry))return void this.warn("".concat(t.details," reached or exceeded max retry (").concat(d,")"));n||l===Wt||(s.resolved=!0)}else this.state=l===jt?Yi:ji;this.tickImmediate()}}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===Hi||this.state===Ki){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var n=!a;return n&&this.warn("Buffer full error while media.currentTime is not buffered, flush ".concat(r," buffer")),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1}},{key:"resetFragmentErrors",value:function(e){e===G&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Oi&&(this.state=Fi)}},{key:"afterBufferFlushed",value:function(e,t,r){if(e){var i=Er.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===Vi&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Oi&&(this.state=Fi)}},{key:"resetStartWhenNotLoaded",value:function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){this.warn("The loading context changed while buffering fragment ".concat(e.sn," of ").concat(this.playlistLabel()," ").concat(e.level,". This chunk will not be buffered.")),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,r,i){var a=this,n=r.details;if(n){var s;if(!Object.keys(e.elementaryStreams).reduce((function(t,s){var o=e.elementaryStreams[s];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return a.warn("Could not parse fragment ".concat(e.sn," ").concat(s," duration reliably (").concat(l,")")),t||!1;var u=i?0:Ei(n,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return a.hls.trigger(M.LEVEL_PTS_UPDATED,{details:n,level:r,drift:u,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1))if(0===r.fragmentError&&this.treatAsGap(e,r),null===(null==(s=this.transmuxer)?void 0:s.error)){var o=new Error("Found no media in fragment ".concat(e.sn," of ").concat(this.playlistLabel()," ").concat(e.level," resetting transmuxer to fallback to playlist timing"));if(this.warn(o.message),this.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:e,reason:"Found no media in msn ".concat(e.sn," of ").concat(this.playlistLabel(),' "').concat(r.url,'"')}),!this.hls)return;this.resetTransmuxer()}this.state=Ki,this.log("Parsed ".concat(e.type," sn: ").concat(e.sn).concat(t?" part: "+t.index:""," of ").concat(this.fragInfo(e,!1,t),")")),this.hls.trigger(M.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===B?"level":"track"}},{key:"fragInfo",value:function(e){var t,r,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=arguments.length>2?arguments[2]:void 0;return"".concat(this.playlistLabel()," ").concat(e.level," (").concat(a?"part":"frag",":[").concat((null!=(t=i&&!a?e.startPTS:(a||e).start)?t:NaN).toFixed(3),"-").concat((null!=(r=i&&!a?e.endPTS:(a||e).end)?r:NaN).toFixed(3),"]").concat(a&&"main"===e.type?"INDEPENDENT="+(a.independent?"YES":"NO"):"")}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log("".concat(t,"->").concat(e)))}}]),a}(mr);function $i(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}var zi=function(){function e(){b(this,e),this.chunks=[],this.dataLength=0}return A(e,[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,a=0;a<e.length;a++){var n=e[a];r.set(n,i),i+=n.length}return r}(t,r),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}]),e}();var Xi,Qi={exports:{}};var Zi=(Xi||(Xi=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new a(i,n||e,s),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,a=[];if(0===this._eventsCount)return a;for(i in e=this._events)t.call(e,i)&&a.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var a=0,n=i.length,s=new Array(n);a<n;a++)s[a]=i[a].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,a,n,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,u,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,a),!0;case 5:return c.fn.call(c.context,t,i,a,n),!0;case 6:return c.fn.call(c.context,t,i,a,n,s),!0}for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var h,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),d){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,i);break;case 4:c[u].fn.call(c[u].context,t,i,a);break;default:if(!l)for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];c[u].fn.apply(c[u].context,l)}}return!0},o.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,a){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||a&&!o.once||i&&o.context!==i||s(this,n);else{for(var l=0,u=[],c=o.length;l<c;l++)(o[l].fn!==t||a&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[n]=1===u.length?u[0]:u:s(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(Qi)),Qi.exports),Ji=se(Zi),ea="1.6.1",ta={};function ra(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function ia(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function aa(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]}function na(e,t){for(var r=t,i=0;ia(e,t);){i+=10,i+=aa(e,t+6),ra(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(r,r+i)}function sa(e,t){return 255===e[t]&&240==(246&e[t+1])}function oa(e,t){return 1&e[t+1]?7:9}function la(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function ua(e,t){return t+1<e.length&&sa(e,t)}function ca(e,t){if(ua(e,t)){var r=oa(e,t);if(t+r>=e.length)return!1;var i=la(e,t);if(i<=r)return!1;var a=t+i;return a===e.length||ua(e,a)}return!1}function da(e,t,r,i,a){if(!e.samplerate){var n=function(e,t,r,i){var a=t[r+2],n=a>>2&15;if(!(n>12)){var s=1+(a>>6&3),o=t[r+3]>>6&3|(1&a)<<2,l="mp4a.40."+s,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n],c=n;5!==s&&29!==s||(c-=3);var d=[s<<3|(14&c)>>1,(1&c)<<7|o<<3];return te.log("manifest codec:".concat(i,", parsed codec:").concat(l,", channels:").concat(o,", rate:").concat(u," (ADTS object type:").concat(s," sampling index:").concat(n,")")),{config:d,samplerate:u,channelCount:o,codec:l,parsedCodec:l,manifestCodec:i}}var h=new Error("invalid ADTS sampling index:".concat(n));e.emit(M.ERROR,M.ERROR,{type:P.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message})}(t,r,i,a);if(!n)return;W(e,n)}}function ha(e){return 9216e4/e}function fa(e,t,r,i,a){var n,s=i+a*ha(e.samplerate),o=function(e,t){var r=oa(e,t);if(t+r<=e.length){var i=la(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var l=o.frameLength,u=o.headerLength,c=u+l,d=Math.max(0,r+c-t.length);d?(n=new Uint8Array(c-u)).set(t.subarray(r+u,t.length),0):n=t.subarray(r+u,r+c);var h={unit:n,pts:s};return d||e.samples.push(h),{sample:h,length:c,missing:d}}var f=t.length-r;return(n=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:n,pts:s},length:f,missing:-1}}function va(e,t){return ia(e,t)&&aa(e,t+6)+10<=e.length-t}function ga(e,t){if(e<0)return-ga(-e,t);var r=Math.pow(10,t);if(Math.abs(e*r%1-.5)<Number.EPSILON){var i=Math.floor(e*r);return(i%2==0?i:i+1)/r}return Math.round(e*r)/r}function pa(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0;return ma(e,t,r,Uint8Array)}function ma(e,t,r,i){var a=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),n=1;"BYTES_PER_ELEMENT"in i&&(n=i.BYTES_PER_ELEMENT);var s,o=(s=e)&&s.buffer instanceof ArrayBuffer&&void 0!==s.byteLength&&void 0!==s.byteOffset?e.byteOffset:0,l=(o+e.byteLength)/n,u=(o+t)/n,c=Math.floor(Math.max(0,Math.min(u,l)));return new i(a,c,Math.floor(Math.min(c+Math.max(r,0),l))-c)}function ya(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var r=e.data.subarray(1).indexOf(0);if(-1!==r){var i=ae(pa(e.data,1,r)),a=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1!==n){var s,o=ae(pa(e.data,3+r,n));return s="--\x3e"===i?ae(pa(e.data,4+r+n)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+r+n)),t.mimeType=i,t.pictureType=a,t.description=o,t.data=s,t}}}else console.log("Ignore frame with unrecognized character encoding")}function ka(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=ae(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=ae(e.data.subarray(t),!0);t+=r.length+1;var i=ae(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=ae(e.data);return{key:e.type,info:"",data:a}}(e):"APIC"===e.type?ya(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=ae(e.data.subarray(t),!0);t+=r.length+1;var i=ae(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=ae(e.data.subarray(1));return{key:e.type,info:"",data:a}}}(e)}function Ea(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=aa(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}function Ta(e){for(var t=0,r=[];ia(e,t);){var i=aa(e,t+6);e[t+5]>>6&1&&(t+=10);for(var a=(t+=10)+i;t+10<a;){var n=Ea(e.subarray(t)),s=ka(n);s&&r.push(s),t+=n.size+10}ra(e,t)&&(t+=10)}return r}function Sa(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function ba(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}}function La(e){for(var t=Ta(e),r=0;r<t.length;r++){var i=t[r];if(Sa(i))return ba(i)}}var Aa=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function Ra(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var Ia=function(){function e(){b(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}return A(e,[{key:"resetInitSegment",value:function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,r){}},{key:"demux",value:function(e,t){this.cachedData&&(e=Ue(this.cachedData,e),this.cachedData=null);var r,i=na(e,0),a=i?i.length:0,n=this._audioTrack,s=this._id3Track,o=i?La(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&D(o))&&(this.basePTS=wa(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Aa.audioId3,duration:Number.POSITIVE_INFINITY});a<l;){if(this.canParse(e,a)){var u=this.appendFrame(n,e,a);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r=a+=u.length):a=l}else va(e,a)?(i=na(e,a),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Aa.audioId3,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===l&&r!==l){var c=e.slice(r);this.cachedData?this.cachedData=Ue(this.cachedData,c):this.cachedData=c}}return{audioTrack:n,videoTrack:Ra(),id3Track:s,textTrack:Ra()}}},{key:"demuxSampleAes",value:function(e,t,r){return Promise.reject(new Error("[".concat(this,"] This demuxer does not support Sample-AES decryption")))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ra(),id3Track:this._id3Track,textTrack:Ra()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}]),e}(),wa=function(e,t,r){return D(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},Da=null,_a=[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],xa=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Pa=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ca=[0,1,1,4];function Ma(e,t,r,i,a){if(!(r+24>t.length)){var n=Oa(t,r);if(n&&r+n.frameLength<=t.length){var s=i+a*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}}function Oa(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==a&&15!==a&&3!==n){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*_a[14*(3===r?3-i:3===i?3:4)+a-1],u=xa[3*(3===r?0:2===r?1:2)+n],c=3===o?1:2,d=Pa[r][i],h=Ca[i],f=8*d*h,v=Math.floor(d*l/u+s)*h;if(null===Da){var g=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Da=g?parseInt(g[1]):0}return!!Da&&Da<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:c,frameLength:v,samplesPerFrame:f}}}function Fa(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function Na(e,t){return t+1<e.length&&Fa(e,t)}function Ua(e,t){if(t+1<e.length&&Fa(e,t)){var r=Oa(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var a=t+i;return a===e.length||Na(e,a)}return!1}var Ba=function(e){g(i,e);var r=n(i);function i(e,t){var a;return b(this,i),(a=r.call(this)).observer=void 0,a.config=void 0,a.observer=e,a.config=t,a}return A(i,[{key:"resetInitSegment",value:function(e,r,a,n){t(u(i.prototype),"resetInitSegment",this).call(this,e,r,a,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&sa(e,t)&&la(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){da(e,this.observer,t,r,e.manifestCodec);var i=fa(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}}],[{key:"probe",value:function(e,t){if(!e)return!1;var r=na(e,0),i=(null==r?void 0:r.length)||0;if(Ua(e,i))return!1;for(var a=e.length;i<a;i++)if(ca(e,i))return t.log("ADTS sync word found !"),!0;return!1}}]),i}(Ia),Ga=function(e,t){var r=0,i=5;t+=i;for(var a=new Uint32Array(1),n=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=e[t];var o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,a[0]=(s[0]&n[0])>>l,r=r?r<<o|a[0]:a[0],t+=1,i-=o}return r},Ha=function(e){g(i,e);var r=n(i);function i(e){var t;return b(this,i),(t=r.call(this)).observer=void 0,t.observer=e,t}return A(i,[{key:"resetInitSegment",value:function(e,r,a,n){t(u(i.prototype),"resetInitSegment",this).call(this,e,r,a,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,r){var i=Ka(e,t,r,this.basePTS,this.frameIndex);if(-1!==i)return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=na(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==La(t)&&Ga(e,r)<16}}]),i}(Ia);function Ka(e,t,r,i,a){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;var n=t[r+4]>>6;if(n>=3)return-1;var s=[48e3,44100,32e3][n],o=63&t[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+n];if(r+l>t.length)return-1;var u=t[r+6]>>5,c=0;2===u?c+=2:(1&u&&1!==u&&(c+=2),4&u&&(c+=2));var d=(t[r+6]<<8|t[r+7])>>12-c&1,h=[2,1,2,3,3,4,4,5][u]+d,f=t[r+5]>>3,v=7&t[r+5],g=new Uint8Array([n<<6|f<<1|v>>2,(3&v)<<6|u<<3|d<<2|o>>4,o<<4&224]),p=i+a*(1536/s*9e4),m=t.subarray(r,r+l);return e.config=g,e.channelCount=h,e.samplerate=s,e.samples.push({unit:m,pts:p}),l}var Va=function(e){g(i,e);var r=n(i);function i(){return b(this,i),r.apply(this,arguments)}return A(i,[{key:"resetInitSegment",value:function(e,r,a,n){t(u(i.prototype),"resetInitSegment",this).call(this,e,r,a,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return Fa(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,r){if(null!==this.basePTS)return Ma(e,t,r,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=na(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==La(t)&&Ga(e,r)<=16)return!1;for(var i=e.length;r<i;r++)if(Ua(e,r))return te.log("MPEG Audio sync word found !"),!0;return!1}}]),i}(Ia),ja=/\/emsg[-/]ID3/i,Wa=function(){function e(t,r){b(this,e),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=r}return A(e,[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,r,i){var a=this.videoTrack=Ra("video",1),n=this.audioTrack=Ra("audio",1),s=this.txtTrack=Ra("text",1);if(this.id3Track=Ra("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=_e(e);if(o.video){var l=o.video,u=l.id,c=l.timescale,d=l.codec,h=l.supplemental;a.id=u,a.timescale=s.timescale=c,a.codec=d,a.supplemental=h}if(o.audio){var f=o.audio,v=f.id,g=f.timescale,p=f.codec;n.id=v,n.timescale=g,n.codec=p}s.id=Te.text,a.sampleDuration=0,a.duration=n.duration=i}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ue(this.remainderData,e));var n=function(e){var t={valid:null,remainder:null},r=we(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(r);this.remainderData=n.remainder,i.samples=n.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,t);return a.samples=Be(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}},{key:"flush",value:function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=Be(e,t),{videoTrack:t,audioTrack:Ra(),id3Track:i,textTrack:Ra()}}},{key:"extractID3Track",value:function(e,t){var r=this,i=this.id3Track;if(e.samples.length){var a=we(e.samples,["emsg"]);a&&a.forEach((function(e){var a=function(e){var t=e[0],r="",i="",a=0,n=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==Se(e.subarray(u,u+1));)r+=Se(e.subarray(u,u+1)),u+=1;for(r+=Se(e.subarray(u,u+1)),u+=1;"\0"!==Se(e.subarray(u,u+1));)i+=Se(e.subarray(u,u+1)),u+=1;i+=Se(e.subarray(u,u+1)),u+=1,a=Le(e,12),n=Le(e,16),o=Le(e,20),l=Le(e,24),u=28}else if(1===t){a=Le(e,u+=4);var c=Le(e,u+=4),d=Le(e,u+=4);for(u+=4,s=Math.pow(2,32)*c+d,_(s)||(s=Number.MAX_SAFE_INTEGER,te.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=Le(e,u),l=Le(e,u+=4),u+=4;"\0"!==Se(e.subarray(u,u+1));)r+=Se(e.subarray(u,u+1)),u+=1;for(r+=Se(e.subarray(u,u+1)),u+=1;"\0"!==Se(e.subarray(u,u+1));)i+=Se(e.subarray(u,u+1)),u+=1;i+=Se(e.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:a,presentationTime:s,presentationTimeDelta:n,eventDuration:o,id:l,payload:e.subarray(u,e.byteLength)}}(e);if(ja.test(a.schemeIdUri)){var n=Ya(a,t),s=4294967295===a.eventDuration?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);var o=a.payload;i.samples.push({data:o,len:o.byteLength,dts:n,pts:n,type:Aa.emsg,duration:s})}else if(r.config.enableEmsgKLVMetadata&&a.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var l=Ya(a,t);i.samples.push({data:a.payload,len:a.payload.byteLength,dts:l,pts:l,type:Aa.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return i}},{key:"demuxSampleAes",value:function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return function(e){for(var t=e.byteLength,r=0;r<t;){var i=Le(e,r);if(i>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=i>1?r+i:t}return!1}(e)}}]),e}();function Ya(e,t){return D(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var qa=function(){function e(t,r,i){b(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new cr(r,{removePKCS7Padding:!1})}return A(e,[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,nr)}},{key:"decryptAacSample",value:function(e,t,r){var i=this,a=e[t].unit;if(!(a.length<=16)){var n=a.subarray(16,a.length-a.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then((function(n){var s=new Uint8Array(n);a.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)}))}}},{key:"decryptAacSamples",value:function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var r=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(r.subarray(i,i+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,r,i,a){var n=this,s=Ve(a.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){a.data=n.getAvcDecryptedUnit(s,o),n.decrypter.isSync()||n.decryptAvcSamples(e,t,r+1,i)}))}},{key:"decryptAvcSamples",value:function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(e,t,r,i,n),this.decrypter.isSync())))return}}}}]),e}(),$a=function(){function e(){b(this,e),this.VideoSample=null}return A(e,[{key:"createVideoSample",value:function(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){var a=i.units;r=a[a.length-1]}return r}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var a=r[i-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,r){var i,a,n=t.byteLength,s=e.naluState||0,o=s,l=[],u=0,c=-1,d=0;for(-1===s&&(c=0,d=this.getNALuType(t,0),s=0,u=1);u<n;)if(i=t[u++],s)if(1!==s)if(i)if(1===i){if(a=u-s-1,c>=0){var h={data:t.subarray(c,a),type:d};l.push(h)}else{var f=this.getLastNalUnit(e.samples);f&&(o&&u<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),a>0&&(f.data=Ue(f.data,t.subarray(0,a)),f.state=0))}u<n?(c=u,d=this.getNALuType(t,u),s=0):s=-1}else s=0;else s=3;else s=i?0:2;else s=i?0:1;if(c>=0&&s>=0){var v={data:t.subarray(c,n),type:d,state:s};l.push(v)}if(0===l.length){var g=this.getLastNalUnit(e.samples);g&&(g.data=Ue(g.data,t))}return e.naluState=s,l}}]),e}(),za=function(){function e(t){b(this,e),this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}return A(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&te.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}}]),e}(),Xa=function(e){g(r,e);var t=n(r);function r(){return b(this,r),t.apply(this,arguments)}return A(r,[{key:"parsePES",value:function(e,t,r,i){var a,n=this,s=this.parseNALu(e,r.data,i),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),s.forEach((function(i){var s,u;switch(i.type){case 1:var c=!1;a=!0;var d,h=i.data;if(l&&h.length>4){var f=n.readSliceType(h);2!==f&&4!==f&&7!==f&&9!==f||(c=!0)}if(c)null!=(d=o)&&d.frame&&!o.key&&(n.pushAccessUnit(o,e),o=n.VideoSample=null);o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=c;break;case 5:a=!0,null!=(s=o)&&s.frame&&!o.key&&(n.pushAccessUnit(o,e),o=n.VideoSample=null),o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,Ke(i.data,1,r.pts,t.samples);break;case 7:var v,g;a=!0,l=!0;var p=i.data,m=n.readSPS(p);if(!e.sps||e.width!==m.width||e.height!==m.height||(null==(v=e.pixelRatio)?void 0:v[0])!==m.pixelRatio[0]||(null==(g=e.pixelRatio)?void 0:g[1])!==m.pixelRatio[1]){e.width=m.width,e.height=m.height,e.pixelRatio=m.pixelRatio,e.sps=[p];for(var y=p.subarray(1,4),k="avc1.",E=0;E<3;E++){var T=y[E].toString(16);T.length<2&&(T="0"+T),k+=T}e.codec=k}break;case 8:a=!0,e.pps=[i.data];break;case 9:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(n.pushAccessUnit(o,e),o=null),o||(o=n.VideoSample=n.createVideoSample(!1,r.pts,r.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(i)})),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return 31&e[t]}},{key:"readSliceType",value:function(e){var t=new za(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var r=8,i=8,a=0;a<e;a++)0!==i&&(i=(r+t.readEG()+256)%256),r=0===i?r:i}},{key:"readSPS",value:function(e){var t,r,i,a=new za(e),n=0,s=0,o=0,l=0,u=a.readUByte.bind(a),c=a.readBits.bind(a),d=a.readUEG.bind(a),h=a.readBoolean.bind(a),f=a.skipBits.bind(a),v=a.skipEG.bind(a),g=a.skipUEG.bind(a),p=this.skipScalingList.bind(this);u();var m=u();if(c(5),f(3),u(),g(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){var y=d();if(3===y&&f(1),g(),g(),f(1),h())for(r=3!==y?8:12,i=0;i<r;i++)h()&&p(i<6?16:64,a)}g();var k=d();if(0===k)d();else if(1===k)for(f(1),v(),v(),t=d(),i=0;i<t;i++)v();g(),f(1);var E=d(),T=d(),S=c(1);0===S&&f(1),f(1),h()&&(n=d(),s=d(),o=d(),l=d());var b=[1,1];if(h()&&h())switch(u()){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:b=[u()<<8|u(),u()<<8|u()]}return{width:Math.ceil(16*(E+1)-2*n-2*s),height:(2-S)*(T+1)*16-(S?2:4)*(o+l),pixelRatio:b}}}]),r}($a),Qa=function(e){g(i,e);var r=n(i);function i(){var e;b(this,i);for(var t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];return(e=r.call.apply(r,[this].concat(a))).initVPS=null,e}return A(i,[{key:"parsePES",value:function(e,t,r,i){var a,n=this,s=this.parseNALu(e,r.data,i),o=this.VideoSample,l=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),s.forEach((function(i){var s,u;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=n.VideoSample=n.createVideoSample(!1,r.pts,r.dts)),o.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:var d;if(a=!0,l)null!=(d=o)&&d.frame&&!o.key&&(n.pushAccessUnit(o,e),o=n.VideoSample=null);o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:a=!0,null!=(s=o)&&s.frame&&!o.key&&(n.pushAccessUnit(o,e),o=n.VideoSample=null),o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 39:a=!0,Ke(i.data,2,r.pts,t.samples);break;case 32:a=!0,e.vps||("object"!==c(e.params)&&(e.params={}),e.params=W(e.params,n.readVPS(i.data)),n.initVPS=i.data),e.vps=[i.data];break;case 33:if(a=!0,l=!0,void 0===e.vps||e.vps[0]===n.initVPS||void 0===e.sps||n.matchSPS(e.sps[0],i.data)||(n.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var h=n.readSPS(i.data);for(var f in e.width=h.width,e.height=h.height,e.pixelRatio=h.pixelRatio,e.codec=h.codecString,e.sps=[],"object"!==c(e.params)&&(e.params={}),h.params)e.params[f]=h.params[f]}n.pushParameterSet(e.sps,i.data,e.vps),o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.key=!0;break;case 34:if(a=!0,"object"===c(e.params)){if(!e.pps){e.pps=[];var v=n.readPPS(i.data);for(var g in v)e.params[g]=v[g]}n.pushParameterSet(e.pps,i.data,e.vps)}break;case 35:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(n.pushAccessUnit(o,e),o=null),o||(o=n.VideoSample=n.createVideoSample(!1,r.pts,r.dts));break;default:a=!1}o&&a&&o.units.push(i)})),i&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"pushParameterSet",value:function(e,t,r){(r&&r[0]===this.initVPS||!r&&!e.length)&&e.push(t)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),r=0,i=0;i<e.byteLength;i++)i>=2&&3===e[i]&&0===e[i-1]&&0===e[i-2]||(t[r]=e[i],r++);return new Uint8Array(t.buffer,0,r)}},{key:"pushAccessUnit",value:function(e,r){t(u(i.prototype),"pushAccessUnit",this).call(this,e,r),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new za(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}},{key:"readSPS",value:function(e){var t=new za(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var r=t.readBits(3);t.readBoolean();for(var i=t.readBits(2),a=t.readBoolean(),n=t.readBits(5),s=t.readUByte(),o=t.readUByte(),l=t.readUByte(),u=t.readUByte(),c=t.readUByte(),d=t.readUByte(),h=t.readUByte(),f=t.readUByte(),v=t.readUByte(),g=t.readUByte(),p=t.readUByte(),m=[],y=[],k=0;k<r;k++)m.push(t.readBoolean()),y.push(t.readBoolean());if(r>0)for(var E=r;E<8;E++)t.readBits(2);for(var T=0;T<r;T++)m[T]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[T]&&t.readUByte();t.readUEG();var S=t.readUEG();3==S&&t.skipBits(1);var b=t.readUEG(),L=t.readUEG(),A=t.readBoolean(),R=0,I=0,w=0,D=0;A&&(R+=t.readUEG(),I+=t.readUEG(),w+=t.readUEG(),D+=t.readUEG());for(var _=t.readUEG(),x=t.readUEG(),P=t.readUEG(),C=t.readBoolean()?0:r;C<=r;C++)t.skipUEG(),t.skipUEG(),t.skipUEG();if((t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean())&&t.readBoolean())for(var M=0;M<4;M++)for(var O=0;O<(3===M?2:6);O++){if(t.readBoolean()){var F=Math.min(64,1<<4+(M<<1));M>1&&t.readEG();for(var N=0;N<F;N++)t.readEG()}else t.readUEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());for(var U=t.readUEG(),B=0,G=0;G<U;G++){var H=!1;if(0!==G&&(H=t.readBoolean()),H){G===U&&t.readUEG(),t.readBoolean(),t.readUEG();for(var K=0,V=0;V<=B;V++){var j=t.readBoolean(),W=!1;j||(W=t.readBoolean()),(j||W)&&K++}B=K}else{var Y=t.readUEG(),q=t.readUEG();B=Y+q;for(var $=0;$<Y;$++)t.readUEG(),t.readBoolean();for(var z=0;z<q;z++)t.readUEG(),t.readBoolean()}}if(t.readBoolean())for(var X=t.readUEG(),Q=0;Q<X;Q++){for(var Z=0;Z<P+4;Z++)t.readBits(1);t.readBits(1)}var J=0,ee=1,te=1,re=!0,ie=1,ae=0;t.readBoolean(),t.readBoolean();var ne=!1;if(t.readBoolean()){if(t.readBoolean()){var se=t.readUByte();se>0&&se<16?(ee=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][se-1],te=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][se-1]):255===se&&(ee=t.readBits(16),te=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean())t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte());if(t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),(ne=t.readBoolean())&&(R+=t.readUEG(),I+=t.readUEG(),w+=t.readUEG(),D+=t.readUEG()),t.readBoolean())if(ie=t.readBits(32),ae=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean()){var oe=t.readBoolean(),le=t.readBoolean(),ue=!1;(oe||le)&&((ue=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ue&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(var ce=0;ce<=r;ce++){var de=!1;(re=t.readBoolean())||t.readBoolean()?t.readEG():de=t.readBoolean();var he=de?1:t.readUEG()+1;if(oe)for(var fe=0;fe<he;fe++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(le)for(var ve=0;ve<he;ve++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),J=t.readUEG())}var ge=b,pe=L;if(A||ne){var me=1,ye=1;1===S?me=ye=2:2==S&&(me=2),ge=b-me*I-me*R,pe=L-ye*D-ye*w}for(var ke=i?["A","B","C"][i]:"",Ee=s<<24|o<<16|l<<8|u,Te=0,Se=0;Se<32;Se++)Te=(Te|(Ee>>Se&1)<<31-Se)>>>0;var be=Te.toString(16);1===n&&"2"===be&&(be="6");var Le=a?"H":"L";return{codecString:"hvc1.".concat(ke).concat(n,".").concat(be,".").concat(Le).concat(p,".B0"),params:{general_tier_flag:a,general_profile_idc:n,general_profile_space:i,general_profile_compatibility_flags:[s,o,l,u],general_constraint_indicator_flags:[c,d,h,f,v,g],general_level_idc:p,bit_depth:_+8,bit_depth_luma_minus8:_,bit_depth_chroma_minus8:x,min_spatial_segmentation_idc:J,chroma_format_idc:S,frame_rate:{fixed:re,fps:ae/ie}},width:ge,height:pe,pixelRatio:[ee,te]}}},{key:"readPPS",value:function(e){var t=new za(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var r=t.readBoolean(),i=t.readBoolean(),a=1;return i&&r?a=0:i?a=3:r&&(a=2),{parallelismType:a}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}]),i}($a),Za=188,Ja=function(){function e(t,r,i,a){b(this,e),this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=r,this.typeSupported=i,this.logger=a,this.videoParser=null}return A(e,[{key:"resetInitSegment",value:function(t,r,i,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,r){var i,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];a||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,c=s.pid,d=s.pesData,h=o.pid,f=l.pid,v=o.pesData,g=l.pesData,p=null,m=this.pmtParsed,y=this._pmtId,k=t.length;if(this.remainderData&&(k=(t=Ue(this.remainderData,t)).length,this.remainderData=null),k<Za&&!n)return this.remainderData=t,{audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};var E=Math.max(0,e.syncOffset(t));(k-=(k-E)%Za)<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,k,t.buffer.byteLength-k));for(var T=0,S=E;S<k;S+=Za)if(71===t[S]){var b=!!(64&t[S+1]),L=en(t,S),A=(48&t[S+3])>>4,R=void 0;if(A>1){if((R=S+5+t[S+4])===S+Za)continue}else R=S+4;switch(L){case c:if(b){if(d&&(i=sn(d,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new Xa;break;case"hevc":this.videoParser=new Qa}null!==this.videoParser&&this.videoParser.parsePES(s,u,i,!1)}d={data:[],size:0}}d&&(d.data.push(t.subarray(R,S+Za)),d.size+=S+Za-R);break;case h:if(b){if(v&&(i=sn(v,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,i);break;case"mp3":this.parseMPEGPES(o,i);break;case"ac3":this.parseAC3PES(o,i)}v={data:[],size:0}}v&&(v.data.push(t.subarray(R,S+Za)),v.size+=S+Za-R);break;case f:b&&(g&&(i=sn(g,this.logger))&&this.parseID3PES(l,i),g={data:[],size:0}),g&&(g.data.push(t.subarray(R,S+Za)),g.size+=S+Za-R);break;case 0:b&&(R+=t[R]+1),y=this._pmtId=tn(t,R);break;case y:b&&(R+=t[R]+1);var I=rn(t,R,this.typeSupported,a,this.observer,this.logger);(c=I.videoPid)>0&&(s.pid=c,s.segmentCodec=I.segmentVideoCodec),(h=I.audioPid)>0&&(o.pid=h,o.segmentCodec=I.segmentAudioCodec),(f=I.id3Pid)>0&&(l.pid=f),null===p||m||(this.logger.warn("MPEG-TS PMT found at ".concat(S," after unknown PID '").concat(p,"'. Backtracking to sync byte @").concat(E," to parse all TS packets.")),p=null,S=E-188),m=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=L}}else T++;T>0&&an(this.observer,new Error("Found ".concat(T," TS packet/s that do not start with 0x47")),void 0,this.logger),s.pesData=d,o.pesData=v,l.pesData=g;var w={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return n&&this.extractRemainingSamples(w),w}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,n=e.textTrack,s=i.pesData,o=r.pesData,l=a.pesData;if(s&&(t=sn(s,this.logger))){if(null===this.videoParser)switch(i.segmentCodec){case"avc":this.videoParser=new Xa;break;case"hevc":this.videoParser=new Qa}null!==this.videoParser&&(this.videoParser.parsePES(i,n,t,!0),i.pesData=null)}else i.pesData=s;if(o&&(t=sn(o,this.logger))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t);break;case"ac3":this.parseAC3PES(r,t)}r.pesData=null}else null!=o&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=sn(l,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=l}},{key:"demuxSampleAes",value:function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new qa(this.observer,this.config,t);return this.decrypt(i,a)}},{key:"decrypt",value:function(e,t){return new Promise((function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){a.samples?t.decryptAvcSamples(a.samples,0,0,(function(){r(e)})):r(e)})):a.samples&&t.decryptAvcSamples(a.samples,0,0,(function(){r(e)}))}))}},{key:"destroy",value:function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}},{key:"parseAACPES",value:function(e,t){var r,i,a,n=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l)o=Ue(s.sample.unit,o);else{var c=u-l;s.sample.unit.set(o.subarray(0,l),c),e.samples.push(s.sample),n=s.missing}}for(r=n,i=o.length;r<i-1&&!ua(o,r);r++);if(r!==n){var d,h=r<i-1;if(d=h?"AAC PES did not start with ADTS header,offset:".concat(r):"No ADTS header found in AAC PES",an(this.observer,new Error(d),h,this.logger),!h)return}if(da(e,this.observer,o,r,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!s)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var f=ha(e.samplerate);a=s.sample.pts+f}for(var v,g=0;r<i;){if(r+=(v=fa(e,o,r,a,g)).length,v.missing){this.aacOverFlow=v;break}for(g++;r<i-1&&!ua(o,r);r++);}}},{key:"parseMPEGPES",value:function(e,t){var r=t.data,i=r.length,a=0,n=0,s=t.pts;if(void 0!==s)for(;n<i;)if(Na(r,n)){var o=Ma(e,r,n,s,a);if(!o)break;n+=o.length,a++}else n++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var r=t.data,i=t.pts;if(void 0!==i)for(var a,n=r.length,s=0,o=0;o<n&&(a=Ka(e,r,o,i,s++))>0;)o+=a;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var r=W({},t,{type:this._videoTrack?Aa.emsg:Aa.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")}}],[{key:"probe",value:function(t,r){var i=e.syncOffset(t);return i>0&&r.warn("MPEG2-TS detected but first sync word found @ offset ".concat(i)),-1!==i}},{key:"syncOffset",value:function(e){for(var t=e.length,r=Math.min(940,t-Za)+1,i=0;i<r;){for(var a=!1,n=-1,s=0,o=i;o<t;o+=Za){if(71!==e[o]||t-o!==Za&&71!==e[o+Za]){if(s)return-1;break}if(s++,-1===n&&0!==(n=o)&&(r=Math.min(n+18612,e.length-Za)+1),a||(a=0===en(e,o)),a&&s>1&&(0===n&&s>2||o+Za>r))return n}i++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Te[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}]),e}();function en(e,t){return((31&e[t+1])<<8)+e[t+2]}function tn(e,t){return(31&e[t+10])<<8|e[t+11]}function rn(e,t,r,i,a,n){var s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){var l=en(e,t),u=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){nn("ADTS AAC",n);break}case 15:-1===s.audioPid&&(s.audioPid=l);break;case 21:-1===s.id3Pid&&(s.id3Pid=l);break;case 219:if(!i){nn("H.264",n);break}case 27:-1===s.videoPid&&(s.videoPid=l);break;case 3:case 4:r.mpeg||r.mp3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="mp3"):n.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){nn("AC-3",n);break}case 129:r.ac3?-1===s.audioPid&&(s.audioPid=l,s.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&u>0)for(var c=t+5,d=u;d>2;){if(106===e[c])!0!==r.ac3?n.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3");var h=e[c+1]+2;c+=h,d-=h}break;case 194:case 135:return an(a,new Error("Unsupported EC-3 in M2TS found"),void 0,n),s;case 36:-1===s.videoPid&&(s.videoPid=l,s.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"))}t+=u+5}return s}function an(e,t,r,i){i.warn("parsing error: ".concat(t.message)),e.emit(M.ERROR,M.ERROR,{type:P.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:t,reason:t.message})}function nn(e,t){t.log("".concat(e," with AES-128-CBC encryption found in unencrypted stream"))}function sn(e,t){var r,i,a,n,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=Ue(l[0],l[1]),l.splice(1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((i=(r[4]<<8)+r[5])&&i>e.size-6)return null;var u=r[7];192&u&&(n=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&u?n-(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>54e5&&(t.warn("".concat(Math.round((n-s)/9e4),"s delta between PTS and DTS, align them")),n=s):s=n);var c=(a=r[8])+9;if(e.size<=c)return null;e.size-=c;for(var d=new Uint8Array(e.size),h=0,f=l.length;h<f;h++){var v=(r=l[h]).byteLength;if(c){if(c>v){c-=v;continue}r=r.subarray(c),v-=c,c=0}d.set(r,o),o+=v}return i&&(i-=a+3),{data:d,pts:n,dts:s,len:i}}return null}var on=function(){function e(){b(this,e)}return A(e,null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)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])}}}]),e}(),ln=Math.pow(2,32)-1,un=function(){function e(){b(this,e)}return A(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=n,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];for(var n=i.length,s=n;n--;)t+=i[n].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),n=0,t=8;n<s;n++)o.set(i[n],t),t+=i[n].byteLength;return o}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){r*=t;var i=Math.floor(r/(ln+1)),a=Math.floor(r%(ln+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))}},{key:"moov",value:function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(i).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))}},{key:"mvhd",value:function(t,r){r*=t;var i=Math.floor(r/(ln+1)),a=Math.floor(r%(ln+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,n)}},{key:"sdtp",value:function(t){var r,i,a=t.samples||[],n=new Uint8Array(4+a.length);for(r=0;r<a.length;r++)i=a[r].flags,n[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,n)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r,i,a,n=[],s=[];for(r=0;r<t.sps.length;r++)a=(i=t.sps[r]).byteLength,n.push(a>>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)a=(i=t.pps[r]).byteLength,s.push(a>>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,c=t.pixelRatio[0],d=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))}},{key:"esds",value:function(e){var t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2].concat(d(t),[6,1,2]))}},{key:"audioStsd",value:function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){return e.box(e.types[".mp3"],e.audioStsd(t))}},{key:"ac3",value:function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))}},{key:"stsd",value:function(t){var r=t.segmentCodec;if("audio"===t.type){if("aac"===r)return e.box(e.types.stsd,e.STSD,e.mp4a(t));if("ac3"===r&&t.config)return e.box(e.types.stsd,e.STSD,e.ac3(t));if("mp3"===r&&"mp3"===t.codec)return e.box(e.types.stsd,e.STSD,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===r)return e.box(e.types.stsd,e.STSD,e.avc1(t));if("hevc"===r&&t.vps)return e.box(e.types.stsd,e.STSD,e.hvc1(t))}throw new Error("unsupported ".concat(t.type," segment codec (").concat(r,"/").concat(t.codec,")"))}},{key:"tkhd",value:function(t){var r=t.id,i=(t.duration||0)*(t.timescale||0),a=t.width||0,n=t.height||0,s=Math.floor(i/(ln+1)),o=Math.floor(i%(ln+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))}},{key:"traf",value:function(t,r){var i=e.sdtp(t),a=t.id,n=Math.floor(r/(ln+1)),s=Math.floor(r%(ln+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,r){var i,a,n,s,o,l,u=t.samples||[],c=u.length,d=12+16*c,h=new Uint8Array(d);for(r+=8+d,h.set(["video"===t.type?1:0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<c;i++)n=(a=u[i]).duration,s=a.size,o=a.flags,l=a.cts,h.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,h)}},{key:"initSegment",value:function(t){e.types||e.init();var r=e.moov(t);return Ue(e.FTYP,r)}},{key:"hvc1",value:function(t){for(var r=t.params,i=[t.vps,t.sps,t.pps],a=new Uint8Array([1,r.general_profile_space<<6|(r.general_tier_flag?32:0)|r.general_profile_idc,r.general_profile_compatibility_flags[0],r.general_profile_compatibility_flags[1],r.general_profile_compatibility_flags[2],r.general_profile_compatibility_flags[3],r.general_constraint_indicator_flags[0],r.general_constraint_indicator_flags[1],r.general_constraint_indicator_flags[2],r.general_constraint_indicator_flags[3],r.general_constraint_indicator_flags[4],r.general_constraint_indicator_flags[5],r.general_level_idc,240|r.min_spatial_segmentation_idc>>8,255&r.min_spatial_segmentation_idc,252|r.parallelismType,252|r.chroma_format_idc,248|r.bit_depth_luma_minus8,248|r.bit_depth_chroma_minus8,0,parseInt(r.frame_rate.fps),3|r.temporal_id_nested<<2|r.num_temporal_layers<<3|(r.frame_rate.fixed?64:0),i.length]),n=a.length,s=0;s<i.length;s+=1){n+=3;for(var o=0;o<i[s].length;o+=1)n+=2+i[s][o].length}var l=new Uint8Array(n);l.set(a,0),n=a.length;for(var u=i.length-1,c=0;c<i.length;c+=1){l.set(new Uint8Array([32+c|(c===u?128:0),0,i[c].length]),n),n+=3;for(var d=0;d<i[c].length;d+=1)l.set(new Uint8Array([i[c][d].length>>8,255&i[c][d].length]),n),n+=2,l.set(i[c][d],n),n+=i[c][d].length}var h=e.box(e.types.hvcC,l),f=t.width,v=t.height,g=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.types.hvc1,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,f>>8&255,255&f,v>>8&255,255&v,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]),h,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,255&g,p>>24,p>>16&255,p>>8&255,255&p])))}}]),e}();un.types=void 0,un.HDLR_TYPES=void 0,un.STTS=void 0,un.STSC=void 0,un.STCO=void 0,un.STSZ=void 0,un.VMHD=void 0,un.SMHD=void 0,un.STSD=void 0,un.FTYP=void 0,un.DINF=void 0;var cn=9e4;function dn(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e*t*r;return i?Math.round(a):a}function hn(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return dn(e,1e3,11111111111111112e-21,t)}var fn=null,vn=null;function gn(e,t,r,i){return{duration:t,size:r,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}var pn=function(){function e(t,r,i,a){if(b(this,e),this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=r,this.typeSupported=i,this.logger=a,this.ISGenerated=!1,null===fn){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);fn=n?parseInt(n[1]):0}if(null===vn){var s=navigator.userAgent.match(/Safari\/(\d+)/i);vn=s?parseInt(s[1]):0}}return A(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,r=e[0].pts,i=e.reduce((function(e,i){var a=i.pts,n=a-e;return n<-4294967296&&(t=!0,n=(a=mn(a,r))-e),n>0?e:a}),r);return t&&this.logger.debug("PTS rollover detected"),i}},{key:"remux",value:function(e,t,r,i,a,n,s,o){var l,u,c,d,h,f,v=a,g=a,p=e.pid>-1,m=t.pid>-1,y=t.samples.length,k=e.samples.length>0,E=s&&y>0||y>1;if((!p||k)&&(!m||E)||this.ISGenerated||s){if(this.ISGenerated){var T,S,b,L,A=this.videoTrackConfig;(A&&(t.width!==A.width||t.height!==A.height||(null==(T=t.pixelRatio)?void 0:T[0])!==(null==(S=A.pixelRatio)?void 0:S[0])||(null==(b=t.pixelRatio)?void 0:b[1])!==(null==(L=A.pixelRatio)?void 0:L[1]))||!A&&E||null===this.nextAudioPts&&k)&&this.resetInitSegment()}this.ISGenerated||(c=this.generateIS(e,t,a,n));var R,I=this.isVideoContiguous,w=-1;if(E&&(w=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!I&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,w>0){this.logger.warn("[mp4-remuxer]: Dropped ".concat(w," out of ").concat(y," video samples due to a missing keyframe"));var D=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(w),t.dropped+=w,R=g+=(t.samples[0].pts-D)/t.inputTimeScale}else-1===w&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of ".concat(y," video samples")),f=!1);if(this.ISGenerated){if(k&&E){var _=this.getVideoStartPts(t.samples),x=(mn(e.samples[0].pts,_)-_)/t.inputTimeScale;v+=Math.max(0,x),g+=Math.max(0,-x)}if(k){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,a,n)),u=this.remuxAudio(e,v,this.isAudioContiguous,n,m||E||o===G?g:void 0),E){var P=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,a,n)),l=this.remuxVideo(t,g,I,P)}}else E&&(l=this.remuxVideo(t,g,I,0));l&&(l.firstKeyFrame=w,l.independent=-1!==w,l.firstKeyFramePTS=R)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(h=yn(r,a,this._initPTS,this._initDTS)),i.samples.length&&(d=kn(i,a,this._initPTS))),{audio:u,video:l,initSegment:c,independent:f,text:d,id3:h}}},{key:"generateIS",value:function(e,t,r,i){var a,n,s,o=e.samples,l=t.samples,u=this.typeSupported,c={},d=this._initPTS,h=!d||i,f="audio/mp4";if(h&&(a=n=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":u.mpeg?(f="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}c.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&u.mpeg?new Uint8Array(0):un.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(s=e.inputTimeScale,d&&s===d.timescale?h=!1:a=n=o[0].pts-Math.round(s*r))}if(t.sps&&t.pps&&l.length){if(t.timescale=t.inputTimeScale,c.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:un.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(s=t.inputTimeScale,d&&s===d.timescale)h=!1;else{var v=this.getVideoStartPts(l),g=Math.round(s*r);n=Math.min(n,mn(l[0].dts,v)-g),a=Math.min(a,v-g)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(c).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:a,timescale:s},this._initDTS={baseTime:n,timescale:s}):a=s=void 0,{tracks:c,initPTS:a,timescale:s}}},{key:"remuxVideo",value:function(e,t,r,i){var a,n,s=e.inputTimeScale,o=e.samples,l=[],u=o.length,c=this._initPTS,d=this.nextAvcDts,h=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,p=!1;if(!r||null===d){var m=t*s,y=o[0].pts-mn(o[0].dts,o[0].pts);fn&&null!==d&&Math.abs(m-y-d)<15e3?r=!0:d=m-y}for(var k=c.baseTime*s/c.timescale,E=0;E<u;E++){var T=o[E];T.pts=mn(T.pts-k,d),T.dts=mn(T.dts-k,d),T.dts<o[E>0?E-1:E].dts&&(p=!0)}p&&o.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),a=o[0].dts;var S=(n=o[o.length-1].dts)-a,b=S?Math.round(S/(u-1)):f||e.inputTimeScale/30;if(r){var L=a-d,A=L>b,R=L<-1;if((A||R)&&(A?this.logger.warn("".concat((e.segmentCodec||"").toUpperCase(),": ").concat(hn(L,!0)," ms (").concat(L,"dts) hole between fragments detected at ").concat(t.toFixed(3))):this.logger.warn("".concat((e.segmentCodec||"").toUpperCase(),": ").concat(hn(-L,!0)," ms (").concat(L,"dts) overlapping between fragments detected at ").concat(t.toFixed(3))),!R||d>=o[0].pts||fn)){a=d;var I=o[0].pts-L;if(A)o[0].dts=a,o[0].pts=I;else for(var w=!0,D=0;D<o.length&&!(o[D].dts>I&&w);D++){var _=o[D].pts;if(o[D].dts-=L,o[D].pts-=L,D<o.length-1){var x=o[D+1].pts;w=x<=o[D].pts==x<=_}}this.logger.log("Video: Initial PTS/DTS adjusted: ".concat(hn(I,!0),"/").concat(hn(a,!0),", delta: ").concat(hn(L,!0)," ms"))}}for(var O=0,F=0,N=a=Math.max(0,a),U=0;U<u;U++){for(var B=o[U],G=B.units,H=G.length,K=0,V=0;V<H;V++)K+=G[V].data.length;F+=K,O+=H,B.length=K,B.dts<N?(B.dts=N,N+=b/4|0||1):N=B.dts,v=Math.min(B.pts,v),g=Math.max(B.pts,g)}n=o[u-1].dts;var j,Y=F+4*O+8;try{j=new Uint8Array(Y)}catch(Se){return void this.observer.emit(M.ERROR,M.ERROR,{type:P.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:Se,bytes:Y,reason:"fail allocating video mdat ".concat(Y)})}var q=new DataView(j.buffer);q.setUint32(0,Y),j.set(un.types.mdat,4);for(var $=!1,z=Number.POSITIVE_INFINITY,X=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,Z=Number.NEGATIVE_INFINITY,J=0;J<u;J++){for(var ee=o[J],te=ee.units,re=0,ie=0,ae=te.length;ie<ae;ie++){var ne=te[ie],se=ne.data,oe=ne.data.byteLength;q.setUint32(h,oe),h+=4,j.set(se,h),h+=oe,re+=4+oe}var le=void 0;if(J<u-1)f=o[J+1].dts-ee.dts,le=o[J+1].pts-ee.pts;else{var ue=this.config,ce=J>0?ee.dts-o[J-1].dts:b;if(le=J>0?ee.pts-o[J-1].pts:b,ue.stretchShortVideoTrack&&null!==this.nextAudioPts){var de=Math.floor(ue.maxBufferHole*s),he=(i?v+i*s:this.nextAudioPts)-ee.pts;he>de?((f=he-ce)<0?f=ce:$=!0,this.logger.log("[mp4-remuxer]: It is approximately ".concat(he/90," ms to the next segment; using duration ").concat(f/90," ms for the last video frame."))):f=ce}else f=ce}var fe=Math.round(ee.pts-ee.dts);z=Math.min(z,f),Q=Math.max(Q,f),X=Math.min(X,le),Z=Math.max(Z,le),l.push(gn(ee.key,f,re,fe))}if(l.length)if(fn){if(fn<70){var ve=l[0].flags;ve.dependsOn=2,ve.isNonSync=0}}else if(vn&&Z-X<Q-z&&b/Q<.025&&0===l[0].cts){this.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ge=a,pe=0,me=l.length;pe<me;pe++){var ye=ge+l[pe].duration,ke=ge+l[pe].cts;if(pe<me-1){var Ee=ye+l[pe+1].cts;l[pe].duration=Ee-ke}else l[pe].duration=pe?l[pe-1].duration:b;l[pe].cts=0,ge=ye}}f=$||!f?b:f,this.nextAvcDts=d=n+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;var Te={data1:un.moof(e.sequenceNumber++,a,W(e,{samples:l})),data2:j,startPTS:v/s,endPTS:(g+f)/s,startDTS:a/s,endDTS:d/s,type:"video",hasAudio:!1,hasVideo:!0,nb:l.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Te}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,r,i,a){var n=e.inputTimeScale,s=n/(e.samplerate?e.samplerate:n),o=this.getSamplesPerFrame(e),l=o*s,u=this._initPTS,c="mp3"===e.segmentCodec&&this.typeSupported.mpeg,d=[],h=void 0!==a,f=e.samples,v=c?0:8,g=this.nextAudioPts||-1,p=t*n,m=u.baseTime*n/u.timescale;if(this.isAudioContiguous=r=r||f.length&&g>0&&(i&&Math.abs(p-g)<9e3||Math.abs(mn(f[0].pts-m,p)-g)<20*l),f.forEach((function(e){e.pts=mn(e.pts-m,p)})),!r||g<0){if(f=f.filter((function(e){return e.pts>=0})),!f.length)return;g=0===a?0:i&&!h?Math.max(0,p):f[0].pts}if("aac"===e.segmentCodec)for(var y=this.config.maxAudioFramesDrift,k=0,E=g;k<f.length;k++){var T=f[k],S=T.pts,b=S-E,L=Math.abs(1e3*b/n);if(b<=-y*l&&h)0===k&&(this.logger.warn("Audio frame @ ".concat((S/n).toFixed(3),"s overlaps nextAudioPts by ").concat(Math.round(1e3*b/n)," ms.")),this.nextAudioPts=g=E=S);else if(b>=y*l&&L<1e4&&h){var A=Math.round(b/l);(E=S-A*l)<0&&(A--,E+=l),0===k&&(this.nextAudioPts=g=E),this.logger.warn("[mp4-remuxer]: Injecting ".concat(A," audio frame @ ").concat((E/n).toFixed(3),"s due to ").concat(Math.round(1e3*b/n)," ms gap."));for(var R=0;R<A;R++){var I=Math.max(E,0),w=on.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);w||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),w=T.unit.subarray()),f.splice(k,0,{unit:w,pts:I}),E+=l,k++}}T.pts=E,E+=l}for(var D,_=null,x=null,O=0,F=f.length;F--;)O+=f[F].unit.byteLength;for(var N=0,U=f.length;N<U;N++){var B=f[N],G=B.unit,H=B.pts;if(null!==x){d[N-1].duration=Math.round((H-x)/s)}else{if(r&&"aac"===e.segmentCodec&&(H=g),_=H,!(O>0))return;O+=v;try{D=new Uint8Array(O)}catch(X){return void this.observer.emit(M.ERROR,M.ERROR,{type:P.MUX_ERROR,details:C.REMUX_ALLOC_ERROR,fatal:!1,error:X,bytes:O,reason:"fail allocating audio mdat ".concat(O)})}c||(new DataView(D.buffer).setUint32(0,O),D.set(un.types.mdat,4))}D.set(G,v);var K=G.byteLength;v+=K,d.push(gn(!0,o,K,0)),x=H}var V=d.length;if(V){var j=d[d.length-1];this.nextAudioPts=g=x+s*j.duration;var Y=c?new Uint8Array(0):un.moof(e.sequenceNumber++,_/s,W({},e,{samples:d}));e.samples=[];var q=_/n,$=g/n,z={data1:Y,data2:D,startPTS:q,endPTS:$,startDTS:q,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:V};return this.isAudioContiguous=!0,z}}}]),e}();function mn(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function yn(e,t,r,i){var a=e.samples.length;if(a){for(var n=e.inputTimeScale,s=0;s<a;s++){var o=e.samples[s];o.pts=mn(o.pts-r.baseTime*n/r.timescale,t*n)/n,o.dts=mn(o.dts-i.baseTime*n/i.timescale,t*n)/n}var l=e.samples;return e.samples=[],{samples:l}}}function kn(e,t,r){var i=e.samples.length;if(i){for(var a=e.inputTimeScale,n=0;n<i;n++){var s=e.samples[n];s.pts=mn(s.pts-r.baseTime*a/r.timescale,t*a)/a}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var En,Tn=function(){function e(t,r,i,a){b(this,e),this.logger=void 0,this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.logger=a}return A(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.lastEndTime=null}},{key:"resetNextTimestamp",value:function(){this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(!e||!t)return e;var r=t.keyId;return r&&t.isCommonEncryption&&we(e,["moov","trak"]).forEach((function(e){var t=we(e,["mdia","minf","stbl","stsd"])[0].subarray(8),i=we(t,["enca"]),a=i.length>0;a||(i=we(t,["encv"])),i.forEach((function(e){we(a?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=Fe(e);if(t){var i=t.subarray(8,24);i.some((function(e){return 0!==e}))||(te.log("[eme] Patching keyId in 'enc".concat(a?"a":"v",">sinf>>tenc' box: ").concat(ne(i)," -> ").concat(ne(r))),t.set(r,8))}}))}))})),e}(e,i)),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e){var t=this.audioCodec,r=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=_e(e);i.audio&&(t=Sn(i.audio,de)),i.video&&(r=Sn(i.video,he));var a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:t+","+r,supplemental:i.video.supplemental,initSegment:e,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?a.video={container:"video/mp4",codec:r,supplemental:i.video.supplemental,initSegment:e,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a}},{key:"remux",value:function(e,t,r,i,a,n){var s,o,l=this.initPTS,u=this.lastEndTime,c={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};D(u)||(u=this.lastEndTime=a||0);var d=t.samples;if(null==d||!d.length)return c;var h={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(d),f=this.initData),null==(o=f)||!o.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);var v=function(e,t){for(var r=0,i=0,a=0,n=we(e,["moof","traf"]),s=0;s<n.length;s++){var o=n[s],l=we(o,["tfhd"])[0],u=t[Le(l,4)];if(u){var c=u.default,d=Le(l,0)|(null==c?void 0:c.flags),h=null==c?void 0:c.duration;8&d&&(h=Le(l,2&d?12:8));for(var f=u.timescale||9e4,v=we(o,["trun"]),g=0;g<v.length;g++)!(r=Ne(v[g]))&&h&&(r=h*Le(v[g],4)),u.type===he?i+=r/f:u.type===de&&(a+=r/f)}}if(0===i&&0===a){for(var p=1/0,m=0,y=0,k=we(e,["sidx"]),E=0;E<k.length;E++){var T=De(k[E]);if(null!=T&&T.references){p=Math.min(p,T.earliestPresentationTime/T.timescale);var S=T.references.reduce((function(e,t){return e+t.info.duration||0}),0);y=(m=Math.max(m,S+T.earliestPresentationTime/T.timescale))-p}}if(y&&D(y))return y}return i||a}(d,f),g=function(e,t){return we(t,["moof","traf"]).reduce((function(t,r){var i=we(r,["tfdt"])[0],a=i[0],n=we(r,["tfhd"]).reduce((function(t,r){var n=Le(r,4),s=e[n];if(s){var o=Le(i,4);if(1===a){if(o===ke)return te.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;o*=ke+1,o+=Le(i,8)}var l=o/(s.timescale||9e4);if(D(l)&&(null===t||l<t))return l}return t}),null);return null!==n&&D(n)&&(null===t||n<t)?n:t}),null)}(f,d),p=null===g?a:g;!n&&l||!function(e,t,r,i){if(null===e)return!0;var a=Math.max(i,1),n=t-e.baseTime/e.timescale;return Math.abs(n-r)>a}(l,p,a,v)&&h.timescale===l.timescale||(h.initPTS=p-a,l&&1===l.timescale&&this.logger.warn("Adjusting initPTS @".concat(a," from ").concat(l.baseTime/l.timescale," to ").concat(h.initPTS)),this.initPTS=l={baseTime:h.initPTS,timescale:1});var m=e?p-l.baseTime/l.timescale:u,y=m+v;!function(e,t,r){we(t,["moof","traf"]).forEach((function(t){we(t,["tfhd"]).forEach((function(i){var a=Le(i,4),n=e[a];if(n){var s=n.timescale||9e4;we(t,["tfdt"]).forEach((function(e){var t=e[0],i=r*s;if(i){var a=Le(e,4);if(0===t)a-=i,Ie(e,4,a=Math.max(a,0));else{a*=Math.pow(2,32),a+=Le(e,8),a-=i,a=Math.max(a,0);var n=Math.floor(a/(ke+1)),o=Math.floor(a%(ke+1));Ie(e,4,n),Ie(e,8,o)}}}))}}))}))}(f,d,l.baseTime/l.timescale),v>0?this.lastEndTime=y:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var k=!!f.audio,E=!!f.video,T="";k&&(T+="audio"),E&&(T+="video");var S={data1:d,startPTS:m,startDTS:m,endPTS:y,endDTS:y,type:T,hasAudio:k,hasVideo:E,nb:1,dropped:0};return c.audio="audio"===S.type?S:void 0,c.video="audio"!==S.type?S:void 0,c.initSegment=h,c.id3=yn(r,a,l,l),i.samples.length&&(c.text=kn(i,a,l)),c}}]),e}();function Sn(e,t){var r=null==e?void 0:e.codec;if(r&&r.length>4)return r;if(t===de){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){return it(r,!1)}return te.warn('Unhandled audio codec "'.concat(r,'" in mp4 MAP')),r||"mp4a"}return te.warn('Unhandled video codec "'.concat(r,'" in mp4 MAP')),r||"avc1"}try{En=self.performance.now.bind(self.performance)}catch(Ll){En=Date.now}var bn=[{demux:Wa,remux:Tn},{demux:Ja,remux:pn},{demux:Ba,remux:pn},{demux:Va,remux:pn}];bn.splice(2,0,{demux:Ha,remux:pn});var Ln=function(){function e(t,r,i,a,n,s){b(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=r,this.config=i,this.id=n,this.logger=s}return A(e,[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,r,i){var a=this,n=r.transmuxing;n.executeStart=En();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,c=u.contiguous,d=u.discontinuity,h=u.trackSwitch,f=u.accurateTimeOffset,v=u.timeOffset,g=u.initSegmentChange,p=l.audioCodec,m=l.videoCodec,y=l.defaultInitPts,k=l.duration,E=l.initSegmentData,T=function(e,t){var r=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t);return r}(s,t);if(T&&Pr(T.method)){var S=this.getDecrypter(),b=Cr(T.method);if(!S.isSync())return this.asyncResult=!0,this.decryptionPromise=S.webCryptoDecrypt(s,T.key.buffer,T.iv.buffer,b).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var L=S.softwareDecrypt(s,T.key.buffer,T.iv.buffer,b);if(r.part>-1){var A=S.flush();L=A?A.buffer:A}if(!L)return n.executeEnd=En(),An(r);s=new Uint8Array(L)}var R=this.needsProbing(d,h);if(R){var I=this.configureTransmuxer(s);if(I)return this.logger.warn("[transmuxer] ".concat(I.message)),this.observer.emit(M.ERROR,M.ERROR,{type:P.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),n.executeEnd=En(),An(r)}(d||h||g||R)&&this.resetInitSegment(E,p,m,k,t),(d||g||R)&&this.resetInitialTimestamp(y),c||this.resetContiguity();var w=this.transmux(s,T,v,f,r);this.asyncResult=Rn(w);var D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,n.executeEnd=En(),w}},{key:"flush",value:function(e){var t=this,r=e.transmuxing;r.executeStart=En();var i=this.decrypter,a=this.currentTransmuxState,n=this.decryptionPromise;if(n)return this.asyncResult=!0,n.then((function(){return t.flush(e)}));var s=[],o=a.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l.buffer,null,e))}var u=this.demuxer,c=this.remuxer;if(!u||!c){r.executeEnd=En();var d=[An(e)];return this.asyncResult?Promise.resolve(d):d}var h=u.flush(o);return Rn(h)?(this.asyncResult=!0,h.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,h,e),this.asyncResult?Promise.resolve(s):s)}},{key:"flushRemux",value:function(e,t,r){var i=t.audioTrack,a=t.videoTrack,n=t.id3Track,s=t.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;this.logger.log("[transmuxer.ts]: Flushed ".concat(this.id," sn: ").concat(r.sn).concat(r.part>-1?" part: "+r.part:""," of ").concat(this.id===B?"level":"track"," ").concat(r.level));var c=this.remuxer.remux(i,a,n,s,u,l,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=En()}},{key:"resetInitialTimestamp",value:function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}},{key:"resetContiguity",value:function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}},{key:"resetInitSegment",value:function(e,t,r,i,a){var n=this.demuxer,s=this.remuxer;n&&s&&(n.resetInitSegment(e,t,r,i),s.resetInitSegment(e,t,r,a))}},{key:"destroy",value:function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}},{key:"transmux",value:function(e,t,r,i,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)}},{key:"transmuxUnencrypted",value:function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),n=a.audioTrack,s=a.videoTrack,o=a.id3Track,l=a.textTrack;return{remuxResult:this.remuxer.remux(n,s,o,l,t,r,!1,this.id),chunkMeta:i}}},{key:"transmuxSampleAes",value:function(e,t,r,i,a){var n=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:n.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,n.id),chunkMeta:a}}))}},{key:"configureTransmuxer",value:function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,n=0,s=bn.length;n<s;n++){var o;if(null!=(o=bn[n].demux)&&o.probe(e,this.logger)){t=bn[n];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var l=this.demuxer,u=this.remuxer,c=t.remux,d=t.demux;u&&u instanceof c||(this.remuxer=new c(i,r,a,this.logger)),l&&l instanceof d||(this.demuxer=new d(i,r,a,this.logger),this.probe=d.probe)}},{key:"needsProbing",value:function(e,t){return!this.demuxer||!this.remuxer||e||t}},{key:"getDecrypter",value:function(){var e=this.decrypter;return e||(e=this.decrypter=new cr(this.config)),e}}]),e}();var An=function(e){return{remuxResult:{},chunkMeta:e}};function Rn(e){return"then"in e&&e.then instanceof Function}var In=A((function e(t,r,i,a,n){b(this,e),this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=r,this.initSegmentData=i,this.duration=a,this.defaultInitPts=n||null})),wn=A((function e(t,r,i,a,n,s){b(this,e),this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=r,this.accurateTimeOffset=i,this.trackSwitch=a,this.timeOffset=n,this.initSegmentChange=s})),Dn=0,_n=function(){function e(t,r,i,a){var n=this;b(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=Dn++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=function(e){var t=e.data,r=n.hls;if(r&&null!=t&&t.event&&t.instanceNo===n.instanceNo)switch(t.event){case"init":var i,a=null==(i=n.workerContext)?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":n.handleTransmuxComplete(t.data);break;case"flush":n.onFlush(t.data);break;case"workerLog":r.logger[t.data.logType]&&r.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=n.frag,t.data.part=n.part,t.data.id=n.id,r.trigger(t.event,t.data)}},this.onWorkerError=function(e){if(n.hls){var t=new Error("".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")"));n.hls.config.enableWorker=!1,n.hls.logger.warn('Error in "'.concat(n.id,'" Web Worker, fallback to inline')),n.hls.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})}};var s=t.config;this.hls=t,this.id=r,this.useWorker=!!s.enableWorker,this.onTransmuxComplete=i,this.onFlush=a;var o=function(e,t){(t=t||{}).frag=n.frag||void 0,e===M.ERROR&&(t.parent=n.id,t.part=n.part,n.error=t.error),n.hls.trigger(e,t)};this.observer=new Ji,this.observer.on(M.FRAG_DECRYPTED,o),this.observer.on(M.ERROR,o);var l=st(s.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var u=this.hls.logger;if(s.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{s.workerPath?(u.log("loading Web Worker ".concat(s.workerPath,' for "').concat(r,'"')),this.workerContext=function(e){var t=ta[e];if(t)return t.clientCount++,t;var r=new self.URL(e,self.location.href).href,i={worker:new self.Worker(r),scriptURL:r,clientCount:1};return ta[e]=i,i}(s.workerPath)):(u.log('injecting Web Worker for "'.concat(r,'"')),this.workerContext=function(){var e=ta[ea];if(e)return e.clientCount++,e;var t=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(".concat(__HLS_WORKER_BUNDLE__.toString(),")(true);")],{type:"text/javascript"}),r=self.URL.createObjectURL(t),i={worker:new self.Worker(r),objectURL:r,clientCount:1};return ta[ea]=i,i}());var c=this.workerContext.worker;c.addEventListener("message",this.onWorkerMessage),c.addEventListener("error",this.onWorkerError),c.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:l,id:r,config:St(s)})}catch(Ll){u.warn('Error setting up "'.concat(r,'" Web Worker, fallback to inline'),Ll),this.terminateWorker(),this.error=null,this.transmuxer=new Ln(this.observer,l,s,"",r,t.logger)}return}}this.transmuxer=new Ln(this.observer,l,s,"",r,t.logger)}return A(e,[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=Dn++;var t=this.hls.config,r=st(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:r,id:this.id,config:St(t)})}}},{key:"terminateWorker",value:function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){var t=ta[e||ea];if(t&&1==t.clientCount--){var r=t.worker,i=t.objectURL;delete ta[e||ea],i&&self.URL.revokeObjectURL(i),r.terminate()}}(this.hls.config.workerPath)}}},{key:"destroy",value:function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}},{key:"push",value:function(e,t,r,i,a,n,s,o,l,u){var c,d,h=this;l.transmuxing.start=self.performance.now();var f=this.instanceNo,v=this.transmuxer,g=n?n.start:a.start,p=a.decryptdata,m=this.frag,y=!(m&&a.cc===m.cc),k=!(m&&l.level===m.level),E=m?l.sn-m.sn:-1,T=this.part?l.part-this.part.index:-1,S=0===E&&l.id>1&&l.id===(null==m?void 0:m.stats.chunkCount),b=!k&&(1===E||0===E&&(1===T||S&&T<=0)),L=self.performance.now();(k||E||0===a.stats.parsing.start)&&(a.stats.parsing.start=L),!n||!T&&b||(n.stats.parsing.start=L);var A=!(m&&(null==(c=a.initSegment)?void 0:c.url)===(null==(d=m.initSegment)?void 0:d.url)),R=new wn(y,b,o,k,g,A);if(!b||y||A){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for ".concat(a.type," sn: ").concat(l.sn).concat(l.part>-1?" part: "+l.part:""," ").concat(this.id===B?"level":"track",": ").concat(l.level," id: ").concat(l.id,"\n discontinuity: ").concat(y,"\n trackSwitch: ").concat(k,"\n contiguous: ").concat(b,"\n accurateTimeOffset: ").concat(o,"\n timeOffset: ").concat(g,"\n initSegmentChange: ").concat(A));var I=new In(r,i,t,s,u);this.configureTransmuxer(I)}if(this.frag=a,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:R},e instanceof ArrayBuffer?[e]:[]);else if(v){var w=v.push(e,p,l,R);Rn(w)?w.then((function(e){h.handleTransmuxComplete(e)})).catch((function(e){h.transmuxerError(e,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(w)}}},{key:"flush",value:function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);Rn(a)?a.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}}},{key:"transmuxerError",value:function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))}},{key:"handleFlushResult",value:function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}]),e}(),xn=function(e){g(i,e);var r=n(i);function i(e,t,a){var n;return b(this,i),(n=r.call(this,e,t,a,"audio-stream-controller",G)).mainAnchor=null,n.mainFragLoading=null,n.audioOnly=!1,n.bufferedTrack=null,n.switchingTrack=null,n.trackId=-1,n.waitingData=null,n.mainDetails=null,n.flushing=!1,n.bufferFlushed=!1,n.cachedTrackLoadedData=null,n.registerListeners(),n}return A(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),t(u(i.prototype),"onHandlerDestroying",this).call(this),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){t(u(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(M.LEVEL_LOADED,this.onLevelLoaded,this),e.on(M.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(M.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(M.BUFFER_RESET,this.onBufferReset,this),e.on(M.BUFFER_CREATED,this.onBufferCreated,this),e.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(M.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(M.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(M.FRAG_LOADING,this.onFragLoading,this),e.on(M.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(t(u(i.prototype),"unregisterListeners",this).call(this),e.off(M.LEVEL_LOADED,this.onLevelLoaded,this),e.off(M.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(M.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(M.BUFFER_RESET,this.onBufferReset,this),e.off(M.BUFFER_CREATED,this.onBufferCreated,this),e.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(M.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(M.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(M.FRAG_LOADING,this.onFragLoading,this),e.off(M.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,t){var r=t.frag,i=t.id,a=t.initPTS,n=t.timescale;if(i===B){var s=r.cc,o=this.fragCurrent;if(this.initPTS[s]={baseTime:a,timescale:n},this.log("InitPTS for cc: ".concat(s," found from main: ").concat(a,"/").concat(n)),this.mainAnchor=r,this.state===Wi){var l=this.waitingData;(!l&&!this.loadingParts||l&&l.frag.cc!==s)&&(this.nextLoadPosition=this.findSyncFrag(r).start),this.tick()}else!this.hls.hasEnoughToStart&&o&&o.cc!==s?(this.startFragRequested=!1,this.nextLoadPosition=this.findSyncFrag(r).start,o.abortRequests(),this.resetLoadingState()):this.state===Fi&&this.tick()}}},{key:"findSyncFrag",value:function(e){var t=this.getLevelDetails(),r=e.cc;return function(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var i=r.start,a=r.end,n=e.fragments;if(!r.relurl){var s=e.fragmentHint;s&&(n=n.concat(s))}return Pt(n,(function(e){return e.cc<t||e.end<=i?1:e.cc>t||e.start>=a?-1:0}))}return null}(t,r,e)||t&&Nt(t.fragments,r)||e}},{key:"startLoad",value:function(e,t){if(!this.levels)return this.startPosition=e,void(this.state=Oi);var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3))),e=r,this.state=Fi):this.state=Gi,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case Fi:this.doTickIdle();break;case Gi:var e=this.levels,r=this.trackId,a=null==e?void 0:e[r],n=null==a?void 0:a.details;if(n&&!this.waitForLive(a)){if(this.waitForCdnTuneIn(n))break;this.state=Wi}break;case Bi:var s,o=performance.now(),l=this.retryDate;if(!l||o>=l||null!=(s=this.media)&&s.seeking){var c=this.levels,d=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==c?void 0:c[d])||null),this.state=Fi}break;case Wi:var h=this.waitingData;if(h){var f=h.frag,v=h.part,g=h.cache,p=h.complete,m=this.mainAnchor;if(void 0!==this.initPTS[f.cc]){this.waitingData=null,this.state=Ui;var y={frag:f,part:v,payload:g.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(y),p&&t(u(i.prototype),"_handleFragmentLoadComplete",this).call(this,y)}else m&&m.cc!==h.frag.cc&&(this.log("Waiting fragment cc (".concat(f.cc,") cancelled because video is at cc ").concat(m.cc)),this.nextLoadPosition=this.findSyncFrag(m).start,this.clearWaitingFragment())}else this.state=Fi}this.onTickEnd()}},{key:"clearWaitingFragment",value:function(){var e=this.waitingData;e&&(this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.state!==Oi&&(this.state=Fi))}},{key:"resetLoadingState",value:function(){this.clearWaitingFragment(),t(u(i.prototype),"resetLoadingState",this).call(this)}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,r=this.levels,i=this.media,a=this.trackId,n=t.config;if(this.buffering&&(i||this.primaryPrefetch||!this.startFragRequested&&n.startFragPrefetch)&&null!=r&&r[a]){var s=r[a],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=Gi,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,de,G));var u=this.getFwdBufferInfo(l,G);if(null!==u){if(!this.switchingTrack&&this._streamEnded(u,o))return t.trigger(M.BUFFER_EOS,{type:"audio"}),void(this.state=Vi);var c=u.len,d=t.maxBufferLength,h=o.fragments,f=h[0].start,v=this.getLoadPosition(),g=this.flushing?v:u.end;if(this.switchingTrack&&i){var p=v;o.PTSKnown&&p<f&&(u.end>f||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=f+.05)}if(!(c>=d&&!this.switchingTrack&&g<h[h.length-1].start)){var m=this.getNextFragment(g,o);if(m&&this.isLoopLoading(m,g)&&(m=this.getNextFragmentLoopLoading(m,o,u,B,d)),m){var y=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&y&&ge(m)&&!m.endList&&(!o.live||!this.loadingParts&&g<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(y)===tr&&(this.mainFragLoading=y=null),y&&ge(y))){if(m.start>y.end){var k=this.fragmentTracker.getFragAtPos(g,B);k&&k.end>y.end&&(y=k,this.mainFragLoading={frag:k,targetBufferTime:null})}if(m.start>y.end)return}this.loadFragment(m,s,g)}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(e,r){this.bufferFlushed=this.flushing=!1,t(u(i.prototype),"onMediaDetaching",this).call(this,e,r)}},{key:"onAudioTracksUpdated",value:function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(e){return new kt(e)}))}},{key:"onAudioTrackSwitching",value:function(e,t){var r=!!t.url;this.trackId=t.id;var i=this.fragCurrent;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==Oi&&(this.setInterval(100),this.state=Fi,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){t(u(i.prototype),"onManifestLoading",this).call(this),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var r=this.cachedTrackLoadedData;r&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(M.AUDIO_TRACK_LOADED,r))}},{key:"onAudioTrackLoaded",value:function(e,t){var r,i=this.levels,a=t.details,n=t.id,s=t.groupId,o=t.track;if(i){var l=this.mainDetails;if(!l||a.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==Oi&&(this.state=Gi));this.cachedTrackLoadedData=null,this.log("Audio track ".concat(n,' "').concat(o.name,'" of "').concat(s,'" loaded [').concat(a.startSN,",").concat(a.endSN,"]").concat(a.lastPartSn?"[part-".concat(a.lastPartSn,"-").concat(a.lastPartIndex,"]"):"",",duration:").concat(a.totalduration));var u=i[n],c=0;if(a.live||null!=(r=u.details)&&r.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;var d;if(u.details)c=this.alignPlaylists(a,u.details,null==(d=this.levelLastLoaded)?void 0:d.details);a.alignedSliding||(Pi(a,l),a.alignedSliding||Ci(a,l),c=a.fragmentStart)}u.details=a,this.levelLastLoaded=u,this.startFragRequested||this.setStartPosition(l,c),this.hls.trigger(M.AUDIO_TRACK_UPDATED,{details:a,id:n,groupId:t.groupId}),this.state!==Gi||this.waitForCdnTuneIn(a)||(this.state=Fi),this.tick()}else this.warn("Audio tracks reset while loading track ".concat(n,' "').concat(o.name,'" of "').concat(s,'"'))}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r=e.frag,i=e.part,a=e.payload,n=this.config,s=this.trackId,o=this.levels;if(o){var l=o[s];if(l){var u=l.details;if(!u)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);var c=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2",d=this.transmuxer;d||(d=this.transmuxer=new _n(this.hls,G,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var h=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==h){var v=i?i.index:-1,g=-1!==v,p=new yr(r.level,r.sn,r.stats.chunkCount,a.byteLength,v,g);d.push(a,f,c,"",r,i,u.totalduration,!1,p,h)}else{this.log("Unknown video PTS for cc ".concat(r.cc,", waiting for video PTS before demuxing audio frag ").concat(r.sn," of [").concat(u.startSN," ,").concat(u.endSN,"],track ").concat(s)),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new zi,complete:!1}).cache.push(new Uint8Array(a)),this.state!==Oi&&(this.state=Wi)}}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ").concat(r.level," will not be buffered"))}},{key:"_handleFragmentLoadComplete",value:function(e){this.waitingData?this.waitingData.complete=!0:t(u(i.prototype),"_handleFragmentLoadComplete",this).call(this,e)}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===B&&ge(t.frag)&&(this.mainFragLoading=t,this.state===Fi&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part;if(r.type===G)if(this.fragContextChanged(r))this.warn("Fragment ".concat(r.sn).concat(i?" p: "+i.index:""," of level ").concat(r.level," finished buffering, but was aborted. state: ").concat(this.state,", audioSwitch: ").concat(this.switchingTrack?this.switchingTrack.name:"false"));else{if(ge(r)){this.fragPrevious=r;var a=this.switchingTrack;a&&(this.bufferedTrack=a,this.switchingTrack=null,this.hls.trigger(M.AUDIO_TRACK_SWITCHED,q({},a)))}this.fragBufferedComplete(r,i),this.media&&this.tick()}else this.audioOnly||r.type!==B||r.elementaryStreams.video||r.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(e,r){var a;if(r.fatal)this.state=ji;else switch(r.details){case C.FRAG_GAP:case C.FRAG_PARSING_ERROR:case C.FRAG_DECRYPT_ERROR:case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(G,r);break;case C.AUDIO_TRACK_LOAD_ERROR:case C.AUDIO_TRACK_LOAD_TIMEOUT:case C.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Gi||(null==(a=r.context)?void 0:a.type)!==N||(this.state=Fi);break;case C.BUFFER_ADD_CODEC_ERROR:case C.BUFFER_APPEND_ERROR:if("audio"!==r.parent)return;this.resetLoadingState();break;case C.BUFFER_FULL_ERROR:if("audio"!==r.parent)return;this.reduceLengthAndFlushBuffer(r)&&(this.bufferedTrack=null,t(u(i.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case C.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}}},{key:"onBufferFlushing",value:function(e,t){t.type!==he&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==he){this.flushing=!1,this.bufferFlushed=!0,this.state===Vi&&(this.state=Fi);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,r,G),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,r="audio",i=this.hls,a=e.remuxResult,n=e.chunkMeta,s=this.getCurrentContext(n);if(s){var o=s.frag,l=s.part,u=s.level,c=u.details,d=a.audio,h=a.text,f=a.id3,v=a.initSegment;if(!this.fragContextChanged(o)&&c){if(this.state=Hi,this.switchingTrack&&d&&this.completeAudioSwitch(this.switchingTrack),null!=v&&v.tracks){var g=o.initSegment||o;this._bufferInitSegment(u,v.tracks,g,n),i.trigger(M.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:v.tracks})}if(d){var p=d.startPTS,m=d.endPTS,y=d.startDTS,k=d.endDTS;l&&(l.elementaryStreams[de]={startPTS:p,endPTS:m,startDTS:y,endDTS:k}),o.setElementaryStreamInfo(de,p,m,y,k),this.bufferFragmentData(d,o,l,n)}if(null!=f&&null!=(t=f.samples)&&t.length){var E=W({id:r,frag:o,details:c},f);i.trigger(M.FRAG_PARSING_METADATA,E)}if(h){var T=W({id:r,frag:o,details:c},h);i.trigger(M.FRAG_PARSING_USERDATA,T)}}else this.fragmentTracker.removeFragment(o)}else this.resetWhenMissingContext(n)}},{key:"_bufferInitSegment",value:function(e,t,r,i){if(this.state===Hi&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var a=t.audio;a.id=G;var n=e.audioCodec;this.log("Init audio buffer, container:".concat(a.container,", codecs[level/parsed]=[").concat(n,"/").concat(a.codec,"]")),n&&1===n.split(",").length&&(a.levelCodec=n),this.hls.trigger(M.BUFFER_CODECS,t);var s=a.initSegment;if(null!=s&&s.byteLength){var o={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:s};this.hls.trigger(M.BUFFER_APPENDING,o)}this.tickImmediate()}}},{key:"loadFragment",value:function(e,r,a){var n,s=this.fragmentTracker.getState(e);if(this.switchingTrack||s===Zt||s===er)if(ge(e))if(null!=(n=r.details)&&n.live&&!this.initPTS[e.cc]){this.log("Waiting for video PTS in continuity counter ".concat(e.cc," of live stream before loading audio fragment ").concat(e.sn," of level ").concat(this.trackId)),this.state=Wi;var o=this.mainDetails;o&&o.fragmentStart!==r.details.fragmentStart&&Ci(r.details,o)}else t(u(i.prototype),"loadFragment",this).call(this,e,r,a);else this._loadInitSegment(e,r);else this.clearTrackerIfNeeded(e)}},{key:"flushAudioIfNeeded",value:function(e){if(this.media&&this.bufferedTrack){var r=this.bufferedTrack;It({name:r.name,lang:r.lang,assocLang:r.assocLang,characteristics:r.characteristics,audioCodec:r.audioCodec,channels:r.channels},e,wt)||(_t(e.url,this.hls)?(this.log("Switching audio track : flushing all audio"),t(u(i.prototype),"flushMainBuffer",this).call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=e)}}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(M.AUDIO_TRACK_SWITCHED,q({},e))}}]),i}(qi),Pn=function(e){g(r,e);var t=n(r);function r(e,i){var a;return b(this,r),(a=t.call(this,i,e.logger)).hls=void 0,a.canLoad=!1,a.timer=-1,a.hls=e,a}return A(r,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var a=-1,n=0;n<i.length;n++){var s=i[n],o=void 0;try{o=new self.URL(s.URI,t.url).href}catch(f){this.warn("Could not construct new URL for Rendition Report: ".concat(f)),o=s.URI||""}if(o===e){a=n;break}o===e.substring(0,o.length)&&(a=n)}if(-1!==a){var l=i[a],u=parseInt(l["LAST-MSN"])||(null==t?void 0:t.lastPartSn),c=parseInt(l["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var d=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&d>t.partTarget&&(c+=1)}var h=r&&mt(r);return new yt(u,c>=0?c:void 0,h)}}}},{key:"loadPlaylist",value:function(e){this.clearTimer()}},{key:"loadingPlaylist",value:function(e,t){this.clearTimer()}},{key:"shouldLoadPlaylist",value:function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}},{key:"getUrlWithDirectives",value:function(e,t){if(t)try{return t.addDirectives(e)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: ".concat(r))}return e}},{key:"playlistLoaded",value:function(e,t,r){var i=t.details,a=t.stats,n=self.performance.now(),s=a.loading.first?Math.max(0,n-a.loading.first):0;i.advancedDateTime=Date.now()-s;var o=this.hls.config.timelineOffset;if(o!==i.appliedTimelineOffset){var l=Math.max(o||0,0);i.appliedTimelineOffset=l,i.fragments.forEach((function(e){e.start=e.playlistOffset+l}))}if(i.live||null!=r&&r.live){var u="levelInfo"in t?t.levelInfo:t.track;if(i.reloaded(r),r&&i.fragments.length>0){Ti(r,i);var c=i.playlistParsingError;if(c){this.warn(c);var d=this.hls;if(!d.config.ignorePlaylistParsingErrors){var h,f=t.networkDetails;return void d.trigger(M.ERROR,{type:P.NETWORK_ERROR,details:C.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:c,reason:c.message,level:t.level||void 0,parent:null==(h=i.fragments[0])?void 0:h.type,networkDetails:f,stats:a})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=a.loading.start);var v,g=this.hls.mainForwardBufferInfo,p=g?g.end-g.len:0,m=Ai(i,1e3*(i.edge-p));if(i.requestScheduled+m<n?i.requestScheduled=n:i.requestScheduled+=m,this.log("live playlist ".concat(e," ").concat(i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED")),!this.canLoad||!i.live)return;var y=void 0,k=void 0;if(i.canBlockReload&&i.endSN&&i.advanced){var E=this.hls.config.lowLatencyMode,T=i.lastPartSn,S=i.endSN,b=i.lastPartIndex,L=T===S;-1!==b?L?(y=S+1,k=E?0:b):(y=T,k=E?b+1:i.maxPartIndex):y=S+1;var A=i.age,R=A+i.ageHeader,I=Math.min(R-i.partTarget,1.5*i.targetduration);if(I>0){if(R>3*i.targetduration)this.log("Playlist last advanced ".concat(A.toFixed(2),"s ago. Omitting segment and part directives.")),y=void 0,k=void 0;else if(null!=r&&r.tuneInGoal&&R-i.partTarget>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: ".concat(r.tuneInGoal," to: ").concat(I," with playlist age: ").concat(i.age)),I=0;else{var w=Math.floor(I/i.targetduration);if(y+=w,void 0!==k)k+=Math.round(I%i.targetduration/i.partTarget);this.log("CDN Tune-in age: ".concat(i.ageHeader,"s last advanced ").concat(A.toFixed(2),"s goal: ").concat(I," skip sn ").concat(w," to part ").concat(k))}i.tuneInGoal=I}if(v=this.getDeliveryDirectives(i,t.deliveryDirectives,y,k),E||!L)return i.requestScheduled=n,void this.loadingPlaylist(u,v)}else(i.canBlockReload||i.canSkipUntil)&&(v=this.getDeliveryDirectives(i,t.deliveryDirectives,y,k));v&&void 0!==y&&i.canBlockReload&&(i.requestScheduled=a.loading.first+Math.max(m-2*s,m/2)),this.scheduleLoading(u,v,i)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,r){var i=this,a=r||e.details;if(a){var n=self.performance.now(),s=a.requestScheduled;if(n>=s)this.loadingPlaylist(e,t);else{var o=s-n;this.log("reload live playlist ".concat(e.name||e.bitrate+"bps"," in ").concat(Math.round(o)," ms")),this.clearTimer(),this.timer=self.setTimeout((function(){return i.loadingPlaylist(e,t)}),o)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,r,i){var a=mt(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=vt),new yt(r,i,a)}},{key:"checkRetry",value:function(e){var t=this,r=e.details,i=Ut(e),a=e.errorAction,n=a||{},s=n.action,o=n.retryCount,l=void 0===o?0:o,u=n.retryConfig,c=!!a&&!!u&&(s===Yt||!a.resolved&&s===jt);if(c){var d;if(l>=u.maxNumRetry)return!1;if(i&&null!=(d=e.context)&&d.deliveryDirectives)this.warn("Retrying playlist loading ".concat(l+1,"/").concat(u.maxNumRetry,' after "').concat(r,'" without delivery-directives')),this.loadPlaylist();else{var h=Gt(u,l);this.clearTimer(),this.timer=self.setTimeout((function(){return t.loadPlaylist()}),h),this.warn("Retrying playlist loading ".concat(l+1,"/").concat(u.maxNumRetry,' after "').concat(r,'" in ').concat(h,"ms"))}e.levelRetry=!0,a.resolved=!0}return c}}]),r}($);function Cn(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!Mn(e[r].attrs,t[r].attrs))return!1;return!0}function Mn(e,t,r){var i=e["STABLE-RENDITION-ID"];return i&&!r?i===t["STABLE-RENDITION-ID"]:!(r||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some((function(r){return e[r]!==t[r]}))}function On(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var Fn=function(e){g(i,e);var r=n(i);function i(e){var t;return b(this,i),(t=r.call(this,e,"audio-track-controller")).tracks=[],t.groupIds=null,t.tracksInGroup=[],t.trackId=-1,t.currentTrack=null,t.selectDefaultTrack=!0,t.registerListeners(),t}return A(i,[{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.LEVEL_LOADING,this.onLevelLoading,this),e.on(M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(M.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.LEVEL_LOADING,this.onLevelLoading,this),e.off(M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(M.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(M.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,t(u(i.prototype),"destroy",this).call(this)}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var r=t.id,i=t.groupId,a=t.details,n=this.tracksInGroup[r];if(n&&n.groupId===i){var s=n.details;n.details=t.details,this.log("Audio track ".concat(r,' "').concat(n.name,'" lang:').concat(n.lang," group:").concat(i," loaded [").concat(a.startSN,"-").concat(a.endSN,"]")),r===this.trackId&&this.playlistLoaded(r,t,s)}else this.warn("Audio track with id:".concat(r," and group:").concat(i," not found in active group ").concat(null==n?void 0:n.groupId))}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.audioGroups||null,i=this.groupIds,a=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some((function(e){return-1===(null==i?void 0:i.indexOf(e))}))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;var n=this.tracks.filter((function(e){return!r||-1!==r.indexOf(e.groupId)}));if(n.length)this.selectDefaultTrack&&!n.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),n.forEach((function(e,t){e.id=t}));else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=n;var s=this.hls.config.audioPreference;if(!a&&s){var o=Rt(s,n,wt);if(o>-1)a=n[o];else{var l=Rt(s,this.tracks);a=this.tracks[l]}}var u=this.findTrackId(a);-1===u&&a&&(u=this.findTrackId(null));var c={audioTracks:n};this.log("Updating audio tracks, ".concat(n.length," track(s) found in group(s): ").concat(null==r?void 0:r.join(","))),this.hls.trigger(M.AUDIO_TRACKS_UPDATED,c);var d=this.trackId;if(-1!==u&&-1===d)this.setAudioTrack(u);else if(n.length&&-1===d){var h,f=new Error("No audio track selected for current audio group-ID(s): ".concat(null==(h=this.groupIds)?void 0:h.join(",")," track count: ").concat(n.length));this.warn(f.message),this.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:f})}}}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==N||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}},{key:"setAudioOption",value:function(e){var t=this.hls;if(t.config.audioPreference=e,e){var r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){var i=this.currentTrack;if(i&&It(e,i,wt))return i;var a=Rt(e,this.tracksInGroup,wt);if(a>-1){var n=this.tracksInGroup[a];return this.setAudioTrack(a),n}if(i){var s=t.loadLevel;-1===s&&(s=t.firstAutoLevel);var o=function(e,t,r,i,a){var n=t[i],s=t.reduce((function(e,t,r){var i=t.uri;return(e[i]||(e[i]=[])).push(r),e}),{})[n.uri];s.length>1&&(i=Math.max.apply(Math,s));var o=n.videoRange,l=n.frameRate,u=n.codecSet.substring(0,4),c=Dt(t,i,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==u)return!1;var i=t.audioGroups,n=r.filter((function(e){return!i||-1!==i.indexOf(e.groupId)}));return Rt(e,n,a)>-1}));return c>-1?c:Dt(t,i,(function(t){var i=t.audioGroups,n=r.filter((function(e){return!i||-1!==i.indexOf(e.groupId)}));return Rt(e,n,a)>-1}))}(e,t.levels,r,s,wt);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=Rt(e,r);if(l>-1)return r[l]}}}return null}},{key:"setAudioTrack",value:function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn("Invalid audio track id: ".concat(e));else{this.selectDefaultTrack=!1;var r=this.currentTrack,i=t[e],a=i.details&&!i.details.live;if(!(e===this.trackId&&i===r&&a||(this.log("Switching to audio-track ".concat(e,' "').concat(i.name,'" lang:').concat(i.lang," group:").concat(i.groupId," channels:").concat(i.channels)),this.trackId=e,this.currentTrack=i,this.hls.trigger(M.AUDIO_TRACK_SWITCHING,q({},i)),a))){var n=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(n)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||It(e,i,wt)))return r}if(e){for(var a=e.name,n=e.lang,s=e.assocLang,o=e.characteristics,l=e.audioCodec,u=e.channels,c=0;c<t.length;c++){if(It({name:a,lang:n,assocLang:s,characteristics:o,audioCodec:l,channels:u},t[c],wt))return c}for(var d=0;d<t.length;d++){var h=t[d];if(Mn(e.attrs,h.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(var f=0;f<t.length;f++){var v=t[f];if(Mn(e.attrs,v.attrs,["LANGUAGE"]))return f}}return-1}},{key:"loadPlaylist",value:function(e){t(u(i.prototype),"loadPlaylist",this).call(this);var r=this.currentTrack;this.shouldLoadPlaylist(r)&&_t(r.url,this.hls)&&this.scheduleLoading(r,e)}},{key:"loadingPlaylist",value:function(e,r){t(u(i.prototype),"loadingPlaylist",this).call(this,e,r);var a=e.id,n=e.groupId,s=this.getUrlWithDirectives(e.url,r),o=e.details,l=null==o?void 0:o.age;this.log("Loading audio-track ".concat(a,' "').concat(e.name,'" lang:').concat(e.lang," group:").concat(n).concat(void 0!==(null==r?void 0:r.msn)?" at sn "+r.msn+" part "+r.part:"").concat(l&&o.live?" age "+l.toFixed(1)+(o.type&&" "+o.type||""):""," ").concat(s)),this.hls.trigger(M.AUDIO_TRACK_LOADING,{url:s,id:a,groupId:n,deliveryDirectives:r||null,track:e})}}]),i}(Pn),Nn=function(){function e(t){b(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t}return A(e,[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,r){if(null!==this.queues&&null!==this.tracks){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){var t=this;return new Promise((function(r){var i={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(i,e)}))}},{key:"prependBlocker",value:function(e){var t=this;return new Promise((function(r){if(t.queues){var i={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(i)}}))}},{key:"removeBlockers",value:function(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach((function(e){var t,r=null==(t=e[0])?void 0:t.label;"async-blocker"!==r&&"async-blocker-prepend"!==r||(e[0].execute(),e.splice(0,1))}))}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(n){var i;if(r.onError(n),null===this.queues||null===this.tracks)return;var a=null==(i=this.tracks[e])?void 0:i.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e=this.queues,t=this.tracks;return null===e||null===t?"<destroyed>":"\n".concat(this.list("video"),"\n").concat(this.list("audio"),"\n").concat(this.list("audiovideo"),"}")}},{key:"list",value:function(e){var t,r;return null!=(t=this.queues)&&t[e]||null!=(r=this.tracks)&&r[e]?"".concat(e,": (").concat(this.listSbInfo(e),") ").concat(this.listOps(e)):""}},{key:"listSbInfo",value:function(e){var t,r=null==(t=this.tracks)?void 0:t[e],i=null==r?void 0:r.buffer;return i?"SourceBuffer".concat(i.updating?" updating":"").concat(r.ended?" ended":"").concat(r.ending?" ending":""):"none"}},{key:"listOps",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e].map((function(e){return e.label})).join(", "))||""}}]),e}(),Un=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Bn="HlsJsTrackRemovedError",Gn=function(e){g(r,e);var t=n(r);function r(e){var i;return b(this,r),(i=t.call(this,e)).name=Bn,i}return A(r)}(i(Error)),Hn=function(t){g(i,t);var r=n(i);function i(e,t){var a,n;return b(this,i),(a=r.call(this,"buffer-controller",e.logger)).hls=void 0,a.fragmentTracker=void 0,a.details=null,a._objectUrl=null,a.operationQueue=null,a.bufferCodecEventsTotal=0,a.media=null,a.mediaSource=null,a.lastMpegAudioChunk=null,a.blockedAudioAppend=null,a.lastVideoAppendEnd=0,a.appendSource=void 0,a.transferData=void 0,a.overrides=void 0,a.appendErrors={audio:0,video:0,audiovideo:0},a.tracks={},a.sourceBuffers=[[null,null],[null,null]],a._onEndStreaming=function(e){var t;a.hls&&"open"===(null==(t=a.mediaSource)?void 0:t.readyState)&&a.hls.pauseBuffering()},a._onStartStreaming=function(e){a.hls&&a.hls.resumeBuffering()},a._onMediaSourceOpen=function(e){var t=o(a),r=t.media,i=t.mediaSource;e&&a.log("Media source opened"),r&&i&&(i.removeEventListener("sourceopen",a._onMediaSourceOpen),r.removeEventListener("emptied",a._onMediaEmptied),a.updateDuration(),a.hls.trigger(M.MEDIA_ATTACHED,{media:r,mediaSource:i}),null!==a.mediaSource&&a.checkPendingTracks())},a._onMediaSourceClose=function(){a.log("Media source closed")},a._onMediaSourceEnded=function(){a.log("Media source ended")},a._onMediaEmptied=function(){var e=o(a),t=e.mediaSrc,r=e._objectUrl;t!==r&&a.error("Media element src was set while attaching MediaSource (".concat(r," > ").concat(t,")"))},a.hls=e,a.fragmentTracker=t,a.appendSource=(n=re(e.config.preferManagedMediaSource),"undefined"!=typeof self&&n===self.ManagedMediaSource),a.initTracks(),a.registerListeners(),a}return A(i,[{key:"hasSourceTypes",value:function(){return Object.keys(this.tracks).length>0}},{key:"destroy",value:function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.BUFFER_RESET,this.onBufferReset,this),e.on(M.BUFFER_APPENDING,this.onBufferAppending,this),e.on(M.BUFFER_CODECS,this.onBufferCodecs,this),e.on(M.BUFFER_EOS,this.onBufferEos,this),e.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(M.FRAG_PARSED,this.onFragParsed,this),e.on(M.FRAG_CHANGED,this.onFragChanged,this),e.on(M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.BUFFER_RESET,this.onBufferReset,this),e.off(M.BUFFER_APPENDING,this.onBufferAppending,this),e.off(M.BUFFER_CODECS,this.onBufferCodecs,this),e.off(M.BUFFER_EOS,this.onBufferEos,this),e.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(M.FRAG_PARSED,this.onFragParsed,this),e.off(M.FRAG_CHANGED,this.onFragChanged,this),e.off(M.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var t=this,r=this.media,i=this.mediaSource;if(!r)return null;var a={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var s=this.isQueued();(n||s)&&this.warn("Transfering MediaSource with".concat(s?" operations in queue":"").concat(n?" updating SourceBuffer(s)":""," ").concat(this.operationQueue)),this.operationQueue.destroy()}var o=this.transferData;return!this.sourceBufferCount&&o&&o.mediaSource===i?W(a,o.tracks):this.sourceBuffers.forEach((function(r){var i=e(r,1)[0];i&&(a[i]=W({},t.tracks[i]),t.removeBuffer(i)),r[0]=r[1]=null})),{media:r,mediaSource:i,tracks:a}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var r,i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log("".concat(i," bufferCodec event(s) expected.")),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media,i=re(this.appendSource);if(this.transferData=this.overrides=void 0,r&&i){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var n=this.mediaSource=t.mediaSource||new i;if(this.assignMediaSource(n),a)this._objectUrl=r.src,this.attachTransferred();else{var s=this._objectUrl=self.URL.createObjectURL(n);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&n instanceof o,Kn(r),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(r,s),r.load()}catch(l){r.src=s}else r.src=s}r.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,r;this.log("".concat((null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"," media source: ").concat(null==(r=e.constructor)?void 0:r.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this,t=this.media,r=this.transferData;if(r&&t){var i=this.tracks,a=r.tracks,n=a?Object.keys(a):null,s=n?n.length:0,o=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(a&&n&&s){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log("attachTransferred: (bufferCodecEventsTotal ".concat(this.bufferCodecEventsTotal,")\nrequired tracks: ").concat(St(i,(function(e,t){return"initSegment"===e?void 0:t})),";\ntransfer tracks: ").concat(St(a,(function(e,t){return"initSegment"===e?void 0:t})),"}")),!ie(a,i)){r.mediaSource=null,r.tracks=void 0;var l=t.currentTime,u=this.details,c=Math.max(l,(null==u?void 0:u.fragments[0].start)||0);return c-l>1?void this.log("attachTransferred: waiting for playback to reach new tracks start time ".concat(l," -> ").concat(c)):(this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'.concat(Object.keys(a),'"->"').concat(Object.keys(i),'") start time: ').concat(c," currentTime: ").concat(l)),this.onMediaDetaching(M.MEDIA_DETACHING,{}),this.onMediaAttaching(M.MEDIA_ATTACHING,r),void(t.currentTime=c))}this.transferData=void 0,n.forEach((function(t){var r=t,i=a[r];if(i){var n=i.buffer;if(n){var s=e.fragmentTracker,o=i.id;if(s.hasFragments(o)||s.hasParts(o)){var l=Er.getBuffered(n);s.detectEvictedFragments(r,l,o,null,!0)}var u=Vn(r),c=[r,n];e.sourceBuffers[u]=c,n.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,i)}}})),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(t,r){var i=this,a=!!r.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,s=this.mediaSource,o=this._objectUrl;if(s){if(this.log("media source ".concat(a?"transferring":"detaching")),a)this.sourceBuffers.forEach((function(t){var r=e(t,1)[0];r&&i.removeBuffer(r)})),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var l="open"===s.readyState;try{for(var u=s.sourceBuffers,c=u.length;c--;)l&&u[c].abort(),s.removeSourceBuffer(u[c]);l&&s.endOfStream()}catch(Ll){this.warn("onMediaDetaching: ".concat(Ll.message," while calling endOfStream"))}}this.sourceBufferCount&&this.onBufferReset()}s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(s.removeEventListener("startstreaming",this._onStartStreaming),s.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),a||(o&&self.URL.revokeObjectURL(o),this.mediaSrc===o?(n.removeAttribute("src"),this.appendSource&&Kn(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(M.MEDIA_DETACHED,r)}},{key:"onBufferReset",value:function(){var t=this;this.sourceBuffers.forEach((function(r){var i=e(r,1)[0];i&&t.resetBuffer(i)})),this.initTracks()}},{key:"resetBuffer",value:function(e){var t,r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(Ll){this.warn("onBufferReset ".concat(e),Ll)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[Vn(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)}},{key:"resetQueue",value:function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Nn(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var r=this,i=this.tracks,a=Object.keys(t);this.log('BUFFER_CODECS: "'.concat(a,'" (current SB count ').concat(this.sourceBufferCount,")"));var n="audiovideo"in t&&(i.audio||i.video)||i.audiovideo&&("audio"in t||"video"in t),s=!n&&this.sourceBufferCount&&this.media&&a.some((function(e){return!i[e]}));n||s?this.warn('Unsupported transition between "'.concat(Object.keys(i),'" and "').concat(a,'" SourceBuffers')):(a.forEach((function(e){var a,n,s,o=t[e],l=o.id,u=o.codec,c=o.levelCodec,d=o.container,h=o.metadata,f=o.supplemental,v=i[e],g=null==(a=r.transferData)||null==(n=a.tracks)?void 0:n[e],p=null!=g&&g.buffer?g:v,m=(null==p?void 0:p.pendingCodec)||(null==p?void 0:p.codec),y=null==p?void 0:p.levelCodec;v||(v=i[e]={buffer:void 0,listeners:[],codec:u,supplemental:f,container:d,levelCodec:c,metadata:h,id:l});var k=at(m,y),E=null==k?void 0:k.replace(Un,"$1"),T=at(u,c),S=null==(s=T)?void 0:s.replace(Un,"$1");T&&k&&E!==S&&("audio"===e.slice(0,5)&&(T=it(T,r.appendSource)),r.log("switching codec ".concat(m," to ").concat(T)),T!==(v.pendingCodec||v.codec)&&(v.pendingCodec=T),v.container=d,r.appendChangeType(e,d,T))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())}},{key:"sourceBufferTracks",get:function(){var e=this;return Object.keys(this.tracks).reduce((function(t,r){var i=e.tracks[r];return t[r]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},t}),{})}},{key:"appendChangeType",value:function(e,t,r){var i=this,a="".concat(t,";codecs=").concat(r),n={label:"change-type=".concat(a),execute:function(){var n=i.tracks[e];if(n){var s=n.buffer;null!=s&&s.changeType&&(i.log("changing ".concat(e," sourceBuffer type to ").concat(a)),s.changeType(a),n.codec=r,n.container=t)}i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){i.warn("Failed to change ".concat(e," SourceBuffer type"),t)}};this.append(n,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,r=this,i=e.start,a=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,B))?void 0:t.gap))){var n={label:"block-audio",execute:function(){var e,t=r.tracks.video;(r.lastVideoAppendEnd>a||null!=t&&t.buffer&&Er.isBuffered(t.buffer,a)||!0===(null==(e=r.fragmentTracker.getAppendedFrag(a,B))?void 0:e.gap))&&(r.blockedAudioAppend=null,r.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(e){r.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:n,frag:e},this.append(n,"audio",!0)}}},{key:"unblockAudio",value:function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}},{key:"onBufferAppending",value:function(t,r){var i=this,a=this.tracks,n=r.data,s=r.type,o=r.parent,l=r.frag,u=r.part,c=r.chunkMeta,d=c.buffering[s],h=l.sn,f=self.performance.now();d.start=f;var v=l.stats.buffering,g=u?u.stats.buffering:null;0===v.start&&(v.start=f),g&&0===g.start&&(g.start=f);var p=a.audio,m=!1;"audio"===s&&"audio/mpeg"===(null==p?void 0:p.container)&&(m=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);var y=this.tracks.video,k=null==y?void 0:y.buffer;if(k&&"initSegment"!==h){var E=u||l,T=this.blockedAudioAppend;if("audio"!==s||"main"===o||this.blockedAudioAppend){if("video"===s){var S=E.end;if(T){var b=T.frag.start;(S>b||S<this.lastVideoAppendEnd||Er.isBuffered(k,b))&&this.unblockAudio()}this.lastVideoAppendEnd=S}}else{var L=E.start+.05*E.duration,A=k.buffered,R=this.currentOp("video");A.length||R?!R&&!Er.isBuffered(k,L)&&this.lastVideoAppendEnd<L&&this.blockAudio(E):this.blockAudio(E)}}var I=(u||l).start,w={label:"append-".concat(s),execute:function(){if(d.executeStart=self.performance.now(),m){var e=i.tracks[s];if(e){var t=e.buffer;if(t){var r=I-t.timestampOffset;Math.abs(r)>=.1&&(i.log("Updating audio SourceBuffer timestampOffset to ".concat(I," (delta: ").concat(r,") sn: ").concat(h,")")),t.timestampOffset=I)}}}i.appendExecutor(n,s)},onStart:function(){},onComplete:function(){var t=self.performance.now();d.executeEnd=d.end=t,0===v.first&&(v.first=t),g&&0===g.first&&(g.first=t);var r={};i.sourceBuffers.forEach((function(t){var i=e(t,2),a=i[0],n=i[1];a&&(r[a]=Er.getBuffered(n))})),i.appendErrors[s]=0,"audio"===s||"video"===s?i.appendErrors.audiovideo=0:(i.appendErrors.audio=0,i.appendErrors.video=0),i.hls.trigger(M.BUFFER_APPENDED,{type:s,frag:l,part:u,chunkMeta:c,parent:l.type,timeRanges:r})},onError:function(e){var t,r={type:P.MEDIA_ERROR,parent:l.type,details:C.BUFFER_APPEND_ERROR,sourceBufferName:s,frag:l,part:u,chunkMeta:c,error:e,err:e,fatal:!1},a=null==(t=i.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR)r.details=C.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&i.mediaSourceOpenOrEnded&&!a)r.errorAction=Qt(!0);else if(e.name===Bn&&0===i.sourceBufferCount)r.errorAction=Qt(!0);else{var n=++i.appendErrors[s];i.warn("Failed ".concat(n,"/").concat(i.hls.config.appendErrorMaxRetry,' times to append segment in "').concat(s,'" sourceBuffer (').concat(a||"no media error",")")),(n>=i.hls.config.appendErrorMaxRetry||a)&&(r.fatal=!0)}i.hls.trigger(M.ERROR,r)}};this.append(w,s,this.isPending(this.tracks[s]))}},{key:"getFlushOp",value:function(e,t,r){var i=this;return this.log('queuing "'.concat(e,'" remove ').concat(t,"-").concat(r)),{label:"remove",execute:function(){i.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){i.hls.trigger(M.BUFFER_FLUSHED,{type:e})},onError:function(a){i.warn("Failed to remove ".concat(t,"-").concat(r,' from "').concat(e,'" SourceBuffer'),a)}}}},{key:"onBufferFlushing",value:function(t,r){var i=this,a=r.type,n=r.startOffset,s=r.endOffset;a?this.append(this.getFlushOp(a,n,s),a):this.sourceBuffers.forEach((function(t){var r=e(t,1)[0];r&&i.append(i.getFlushOp(r,n,s),r)}))}},{key:"onFragParsed",value:function(e,t){var r=this,i=t.frag,a=t.part,n=[],s=a?a.elementaryStreams:i.elementaryStreams;s[fe]?n.push("audiovideo"):(s[de]&&n.push("audio"),s[he]&&n.push("video"));0===n.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: ".concat(i.type," level: ").concat(i.level," sn: ").concat(i.sn)),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,a&&(a.stats.buffering.end=e);var t=a?a.stats:i.stats;r.hls.trigger(M.FRAG_BUFFERED,{frag:i,part:a,stats:t,id:i.type})}),n).catch((function(e){r.warn("Fragment buffered callback ".concat(e)),r.stepOperationQueue(r.sourceBufferTypes)}))}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){var t=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some((function(r){var i,a,n=e(r,1)[0];return n&&(!(null!=(i=t.tracks[n])&&i.ended)||(null==(a=t.tracks[n])?void 0:a.ending))}))}},{key:"onBufferEos",value:function(t,r){var i,a=this;this.sourceBuffers.forEach((function(t){var i=e(t,1)[0];if(i){var n=a.tracks[i];r.type&&r.type!==i||(n.ending=!0,n.ended||(n.ended=!0,a.log("".concat(i," buffer reached EOS"))))}}));var n=!1!==(null==(i=this.overrides)?void 0:i.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some((function(t){var r,i=e(t,1)[0];return i&&!(null!=(r=a.tracks[i])&&r.ended)}))&&(n?(this.log("Queueing EOS"),this.blockUntilOpen((function(){a.tracksEnded();var e=a.mediaSource;e&&"open"===e.readyState?(a.log("Calling mediaSource.endOfStream()"),e.endOfStream(),a.hls.trigger(M.BUFFERED_TO_END,void 0)):e&&a.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: ".concat(e.readyState))}))):(this.tracksEnded(),this.hls.trigger(M.BUFFERED_TO_END,void 0)))}},{key:"tracksEnded",value:function(){var t=this;this.sourceBuffers.forEach((function(r){var i=e(r,1)[0];if(null!==i){var a=t.tracks[i];a&&(a.ending=!1)}}))}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.updateDuration())}},{key:"updateDuration",value:function(){var e=this,t=this.getDurationAndRange();t&&this.blockUntilOpen((function(){return e.updateMediaSource(t)}))}},{key:"onError",value:function(e,t){if(t.details===C.BUFFER_APPEND_ERROR&&t.frag){var r,i=null==(r=t.errorAction)?void 0:r.nextAutoLevel;D(i)&&i!==t.frag.level&&this.resetAppendErrors()}}},{key:"resetAppendErrors",value:function(){this.appendErrors={audio:0,video:0,audiovideo:0}}},{key:"trimBuffers",value:function(){var e=this.hls,t=this.details,r=this.media;if(r&&null!==t&&this.sourceBufferCount){var i=e.config,a=r.currentTime,n=t.levelTargetDuration,s=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(D(s)&&s>=0){var o=Math.max(s,n),l=Math.floor(a/n)*n-o;this.flushBackBuffer(a,n,l)}if(D(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var u=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),c=Math.max(u,n),d=Math.floor(a/n)*n+c;this.flushFrontBuffer(a,n,d)}}}},{key:"flushBackBuffer",value:function(t,r,i){var a=this;this.sourceBuffers.forEach((function(t){var r=e(t,2),n=r[0],s=r[1];if(s){var o=Er.getBuffered(s);if(o.length>0&&i>o.start(0)){var l;a.hls.trigger(M.BACK_BUFFER_REACHED,{bufferEnd:i});var u=a.tracks[n];if(null!=(l=a.details)&&l.live)a.hls.trigger(M.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=u&&u.ended)return void a.log("Cannot flush ".concat(n," back buffer while SourceBuffer is in ended state"));a.hls.trigger(M.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:n})}}}))}},{key:"flushFrontBuffer",value:function(t,r,i){var a=this;this.sourceBuffers.forEach((function(r){var n=e(r,2),s=n[0],o=n[1];if(o){var l=Er.getBuffered(o),u=l.length;if(u<2)return;var c=l.start(u-1),d=l.end(u-1);if(i>c||t>=c&&t<=d)return;a.hls.trigger(M.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:s})}}))}},{key:"getDurationAndRange",value:function(){var e,t=this.details,r=this.mediaSource;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;var i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&t.live&&r.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,i)}}return{duration:1/0}}var n=null==(e=this.overrides)?void 0:e.duration;if(n)return D(n)?{duration:n}:null;var s=this.media.duration;return i>(D(r.duration)?r.duration:0)&&i>s||!D(s)?{duration:i}:null}},{key:"updateMediaSource",value:function(e){var t=e.duration,r=e.start,i=e.end,a=this.mediaSource;this.media&&a&&"open"===a.readyState&&(a.duration!==t&&(D(t)&&this.log("Updating MediaSource duration to ".concat(t.toFixed(3))),a.duration=t),void 0!==r&&void 0!==i&&(this.log("MediaSource duration is set to ".concat(a.duration,". Setting seekable range to ").concat(r,"-").concat(i,".")),a.setLiveSeekableRange(r,i)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,r=this.tracks;if(this.log("checkPendingTracks (pending: ".concat(t," codec events expected: ").concat(e,") ").concat(St(r))),this.tracksReady){var i,a=null==(i=this.transferData)?void 0:i.tracks;a&&Object.keys(a).length?this.attachTransferred():this.createSourceBuffers()}}},{key:"bufferCreated",value:function(){var t=this;if(this.sourceBufferCount){var r={};this.sourceBuffers.forEach((function(i){var a=e(i,2),n=a[0],s=a[1];if(n){var o=t.tracks[n];r[n]={buffer:s,container:o.container,codec:o.codec,supplemental:o.supplemental,levelCodec:o.levelCodec,id:o.id,metadata:o.metadata}}})),this.hls.trigger(M.BUFFER_CREATED,{tracks:r}),this.log("SourceBuffers created. Running queue: ".concat(this.operationQueue)),this.sourceBuffers.forEach((function(r){var i=e(r,1)[0];t.executeNext(i)}))}else{var i=new Error("could not create source buffer for media codec(s)");this.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:i,reason:i.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,r=this.mediaSource;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(var i in e){var a=i,n=e[a];if(this.isPending(n)){var s=this.getTrackCodec(n,a),o="".concat(n.container,";codecs=").concat(s);n.codec=s,this.log("creating sourceBuffer(".concat(o,")").concat(this.currentOp(a)?" Queued":""," ").concat(St(n)));try{var l=r.addSourceBuffer(o),u=Vn(a),c=[a,l];t[u]=c,n.buffer=l}catch(h){var d;return this.error("error while trying to add sourceBuffer: ".concat(h.message)),this.shiftAndExecuteNext(a),null==(d=this.operationQueue)||d.removeBlockers(),delete this.tracks[a],void this.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:h,sourceBufferName:a,mimeType:o,parent:n.id})}this.trackSourceBuffer(a,n)}}this.bufferCreated()}},{key:"getTrackCodec",value:function(e,t){var r=e.supplemental,i=e.codec;r&&("video"===t||"audiovideo"===t)&&ze(r,"video")&&(i=function(e,t){var r=[];if(e)for(var i=e.split(","),a=0;a<i.length;a++)$e(i[a],"video")||r.push(i[a]);return t&&r.push(t),r.join(",")}(i,r));var a=at(i,e.levelCodec);return a?"audio"===t.slice(0,5)?it(a,this.appendSource):a:""}},{key:"trackSourceBuffer",value:function(e,t){var r=this,i=t.buffer;if(i){var a=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:a,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(function(e,t){var i=t.removedRanges;null!=i&&i.length&&r.hls.trigger(M.BUFFER_FLUSHED,{type:e})}))}}},{key:"mediaSrc",get:function(){var e,t,r=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==r?void 0:r.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var r=this.currentOp(e);r&&(r.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var r,i=new Error("".concat(e," SourceBuffer error. MediaSource readyState: ").concat(null==(r=this.mediaSource)?void 0:r.readyState));this.error("".concat(i),t),this.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});var a=this.currentOp(e);a&&a.onError(i)}},{key:"removeExecutor",value:function(e,t,r){var i=this.media,a=this.mediaSource,n=this.tracks[e],s=null==n?void 0:n.buffer;if(!i||!a||!s)return this.warn("Attempting to remove from the ".concat(e," SourceBuffer, but it does not exist")),void this.shiftAndExecuteNext(e);var o=D(i.duration)?i.duration:1/0,l=D(a.duration)?a.duration:1/0,u=Math.max(0,t),c=Math.min(r,o,l);c>u&&(!n.ending||n.ended)?(n.ended=!1,this.log("Removing [".concat(u,",").concat(c,"] from the ").concat(e," SourceBuffer")),s.remove(u,c)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var r=this.tracks[t],i=null==r?void 0:r.buffer;if(!i)throw new Gn("Attempting to append to the ".concat(t," SourceBuffer, but it does not exist"));r.ending=!1,r.ended=!1,i.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){var t=this;if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch((function(e){t.warn("SourceBuffer blocked callback ".concat(e)),t.stepOperationQueue(t.sourceBufferTypes)}));else try{e()}catch(r){this.warn("Callback run without blocking ".concat(this.operationQueue," ").concat(r))}}},{key:"isUpdating",value:function(){return this.sourceBuffers.some((function(t){var r=e(t,2),i=r[0],a=r[1];return i&&a.updating}))}},{key:"isQueued",value:function(){var t=this;return this.sourceBuffers.some((function(r){var i=e(r,1)[0];return i&&!!t.currentOp(i)}))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.sourceBufferTypes;if(!r.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var i=this.operationQueue,a=r.map((function(e){return t.appendBlocker(e)})),n=r.length>1&&!!this.blockedAudioAppend;return n&&this.unblockAudio(),Promise.all(a).then((function(r){i===t.operationQueue&&(e(),t.stepOperationQueue(t.sourceBufferTypes))}))}},{key:"stepOperationQueue",value:function(e){var t=this;e.forEach((function(e){var r,i=null==(r=t.tracks[e])?void 0:r.buffer;i&&!i.updating&&t.shiftAndExecuteNext(e)}))}},{key:"append",value:function(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){var e=this;return Object.keys(this.tracks).reduce((function(t,r){return t+(e.isPending(e.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce((function(t,r){return t+(e(r,1)[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map((function(t){return e(t,1)[0]})).filter((function(e){return!!e}))}},{key:"addBufferListener",value:function(e,t,r){var i=this.tracks[e];if(i){var a=i.buffer;if(a){var n=r.bind(this,e);i.listeners.push({event:t,listener:n}),a.addEventListener(t,n)}}}},{key:"removeBufferListeners",value:function(e){var t=this.tracks[e];if(t){var r=t.buffer;r&&(t.listeners.forEach((function(e){r.removeEventListener(e.event,e.listener)})),t.listeners.length=0)}}}]),i}($);function Kn(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach((function(t){e.removeChild(t)}))}function Vn(e){return"audio"===e?1:0}var jn=function(){function e(t){b(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return A(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(M.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(M.BUFFER_CODECS,this.onBufferCodecs,this),e.on(M.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(M.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(M.BUFFER_CODECS,this.onBufferCodecs,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"onFpsDropLevelCapping",value:function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}},{key:"onManifestParsed",value:function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onLevelsUpdated",value:function(e,t){this.timer&&D(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&t.logger.log("Setting autoLevelCapping to ".concat(r,": ").concat(e[r].height,"p@").concat(e[r].bitrate," for media ").concat(this.mediaWidth,"x").concat(this.mediaHeight)),t.autoLevelCapping=r,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var a=i.filter((function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}},{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 e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(t){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(null==e||!e.length)return-1;for(var i,a,n=e.length-1,s=Math.max(t,r),o=0;o<e.length;o+=1){var l=e[o];if((l.width>=s||l.height>=s)&&(i=l,!(a=e[o+1])||i.width!==a.width||i.height!==a.height)){n=o;break}}return n}}]),e}(),Wn={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},Yn={HLS:"h"},qn="CMCD-Request",$n="CMCD-Session",zn="CMCD-Status",Xn=(k(a={},"CMCD-Object",["br","d","ot","tb"]),k(a,qn,["bl","dl","mtp","nor","nrr","su"]),k(a,$n,["cid","pr","sf","sid","st","v"]),k(a,zn,["bs","rtp"]),a),Qn=A((function e(t,r){b(this,e),Array.isArray(t)&&(t=t.map((function(t){return t instanceof e?t:new e(t)}))),this.value=t,this.params=r})),Zn="Dict";function Jn(e,t,r,i){return new Error("failed to ".concat(e,' "').concat((a=t,Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":"object"===c(a)?JSON.stringify(a):String(a)),'" as ').concat(r),{cause:i});var a}function es(e,t,r){return Jn("serialize",e,t,r)}var ts=A((function e(t){b(this,e),this.description=t})),rs="Bare Item";function is(e){if(!1===ArrayBuffer.isView(e))throw es(e,"Byte Sequence");return":".concat((t=e,btoa(String.fromCharCode.apply(String,d(t)))),":");var t}function as(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw es(e,"Integer");return e.toString()}function ns(e){var t=ga(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw es(e,"Decimal");var r=t.toString();return r.includes(".")?r:"".concat(r,".0")}var ss=/[\x00-\x1f\x7f]+/;function os(e){var t,r=(t=e).description||t.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(r))throw es(r,"Token");return r}function ls(e){switch(c(e)){case"number":if(!D(e))throw es(e,rs);return Number.isInteger(e)?as(e):ns(e);case"string":return function(e){if(ss.test(e))throw es(e,"String");return'"'.concat(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),'"')}(e);case"symbol":return os(e);case"boolean":return function(e){if("boolean"!=typeof e)throw es(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return"@".concat(as(e.getTime()/1e3))}(e);if(e instanceof Uint8Array)return is(e);if(e instanceof ts)return os(e);default:throw es(e,rs)}}function us(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw es(e,"Key");return e}function cs(t){return null==t?"":Object.entries(t).map((function(t){var r=e(t,2),i=r[0],a=r[1];return!0===a?";".concat(us(i)):";".concat(us(i),"=").concat(ls(a))})).join("")}function ds(e){return e instanceof Qn?"".concat(ls(e.value)).concat(cs(e.params)):ls(e)}function hs(e){return"(".concat(e.value.map(ds).join(" "),")").concat(cs(e.params))}function fs(t,r){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{whitespace:!0};if("object"!==c(t))throw es(t,Zn);var i=t instanceof Map?t.entries():Object.entries(t),a=(null==r?void 0:r.whitespace)?" ":"";return Array.from(i).map((function(t){var r=e(t,2),i=r[0],a=r[1];a instanceof Qn==0&&(a=new Qn(a));var n=us(i);return!0===a.value?n+=cs(a.params):(n+="=",Array.isArray(a.value)?n+=hs(a):n+=ds(a)),n})).join(",".concat(a))}(t,r)}var vs=function(e){return Math.round(e)},gs=function(e){return 100*vs(e/100)},ps={br:vs,d:vs,bl:gs,dl:gs,mtp:gs,nor:function(e,t){return(null==t?void 0:t.baseUrl)&&(e=function(e,t){var r=new URL(e),i=new URL(t);if(r.origin!==i.origin)return e;for(var a=r.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);a[0]===n[0];)a.shift(),n.shift();for(;n.length;)n.shift(),a.unshift("..");return a.join("/")}(e,t.baseUrl)),encodeURIComponent(e)},rtp:gs,tb:vs};function ms(e,t){var r={};if(null==e||"object"!==c(e))return r;var i=Object.keys(e).sort(),a=W({},ps,null==t?void 0:t.formatters),n=null==t?void 0:t.filter;return i.forEach((function(i){if(!(null==n?void 0:n(i))){var s=e[i],o=a[i];o&&(s=o(s,t)),"v"===i&&1===s||"pr"==i&&1===s||function(e){return"number"==typeof e?D(e):null!=e&&""!==e&&!1!==e}(s)&&(function(e){return"ot"===e||"sf"===e||"st"===e}(i)&&"string"==typeof s&&(s=new ts(s)),r[i]=s)}})),r}function ys(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e?fs(ms(e,t),W({whitespace:!1},t)):""}function ks(t,r,i){return W(t,function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={};if(!t)return i;var a=Object.entries(t),n=Object.entries(Xn).concat(Object.entries((null==r?void 0:r.customHeaderMap)||{})),s=a.reduce((function(t,r){var i,a,s=e(r,2),o=s[0],l=s[1],u=(null===(i=n.find((function(e){return e[1].includes(o)})))||void 0===i?void 0:i[0])||qn;return null!==(a=t[u])&&void 0!==a||(t[u]={}),t[u][o]=l,t}),{});return Object.entries(s).reduce((function(t,i){var a=e(i,2),n=a[0],s=a[1];return t[n]=ys(s,r),t}),i)}(r,i))}var Es="CMCD";var Ts=/CMCD=[^&#]+/;function Ss(e,t,r){var i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return"";var r=ys(e,t);return"".concat(Es,"=").concat(encodeURIComponent(r))}(t,r);if(!i)return e;if(Ts.test(e))return e.replace(Ts,i);var a=e.includes("?")?"&":"?";return"".concat(e).concat(a).concat(i)}var bs=function(){function e(t){var r=this;b(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(e){try{r.apply(e,{ot:Wn.MANIFEST,su:!r.initialized})}catch(t){r.hls.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(e){try{var t=e.frag,i=e.part,a=r.hls.levels[t.level],n=r.getObjectType(t),s={d:1e3*(i||t).duration,ot:n};n!==Wn.VIDEO&&n!==Wn.AUDIO&&n!=Wn.MUXED||(s.br=a.bitrate/1e3,s.tb=r.getTopBandwidth(n)/1e3,s.bl=r.getBufferLength(n));var o=i?r.getNextPart(i):r.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(s.nor=o.url),r.apply(e,s)}catch(l){r.hls.logger.warn("Could not generate segment CMCD data.",l)}},this.hls=t;var i=this.config=t.config,a=i.cmcd;null!=a&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||t.sessionId,this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.includeKeys=a.includeKeys,this.registerListeners())}return A(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.MEDIA_DETACHED,this.onMediaDetached,this),e.on(M.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.MEDIA_DETACHED,this.onMediaDetached,this),e.off(M.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}},{key:"onMediaDetached",value:function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}},{key:"onBufferCreated",value:function(e,t){var r,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:Yn.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};W(t,this.createData());var r=t.ot===Wn.INIT||t.ot===Wn.VIDEO||t.ot===Wn.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var i=this.includeKeys;i&&(t=Object.keys(t).reduce((function(e,r){return i.includes(r)&&(e[r]=t[r]),e}),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),ks(e.headers,t,a)):e.url=Ss(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,r=null==(t=this.hls.levels[e.level])?void 0:t.details;if(r){var i=e.sn-r.startSN;return r.fragments[i+1]}}},{key:"getNextPart",value:function(e){var t,r,i=e.index,a=e.fragment,n=null==(t=this.hls.levels[a.level])||null==(r=t.details)?void 0:r.partList;if(n)for(var s=a.sn,o=n.length-1;o>=0;o--){var l=n[o];if(l.index===i&&l.fragment.sn===s)return n[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?Wn.TIMED_TEXT:"initSegment"===e.sn?Wn.INIT:"audio"===t?Wn.AUDIO:"main"===t?this.hls.audioTracks.length?Wn.VIDEO:Wn.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,r=0,i=this.hls;if(e===Wn.AUDIO)t=i.audioTracks;else{var a=i.maxAutoLevel,n=a>-1?a+1:i.levels.length;t=i.levels.slice(0,n)}var s,o=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=h(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,n=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw n}}}}(t);try{for(o.s();!(s=o.n()).done;){var l=s.value;l.bitrate>r&&(r=l.bitrate)}}catch(Ll){o.e(Ll)}finally{o.f()}return r>0?r:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,r=e===Wn.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*Er.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(t){b(this,e),this.loader=void 0,this.loader=new r(t)}return A(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,r,i){t(e),this.loader.load(e,r,i)}}]),e}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function e(t){b(this,e),this.loader=void 0,this.loader=new r(t)}return A(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,r,i){t(e),this.loader.load(e,r,i)}}]),e}()}}]),e}(),Ls=function(e){g(r,e);var t=n(r);function r(e){var i;return b(this,r),(i=t.call(this,"content-steering",e.logger)).hls=void 0,i.loader=null,i.uri=null,i.pathwayId=".",i._pathwayPriority=null,i.timeToLoad=300,i.reloadTimer=-1,i.updated=0,i.started=!1,i.enabled=!0,i.levels=null,i.audioTracks=null,i.subtitleTracks=null,i.penalizedPathways={},i.hls=e,i.registerListeners(),i}return A(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.ERROR,this.onError,this))}},{key:"pathways",value:function(){return(this.levels||[]).reduce((function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e}),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=t.filter((function(t){return t!==e})))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===jt&&r.flags===$t){var i=this.levels,a=this._pathwayPriority,n=this.pathwayId;if(t.context){var s=t.context,o=s.groupId,l=s.pathwayId,u=s.type;o&&i?n=this.getPathwayForGroupId(o,u,n):l&&(n=l)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!a&&i&&(a=this.pathways()),a&&a.length>1&&(this.updatePathwayPriority(a),r.resolved=this.pathwayId!==n),r.resolved||this.warn("Could not resolve ".concat(t.details,' ("').concat(t.error.message,'") with content-steering for Pathway: ').concat(n," levels: ").concat(i?i.length:i," priorities: ").concat(St(a)," penalized: ").concat(St(this.penalizedPathways)))}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var r=e[0].pathwayId;this.log("No levels found in Pathway ".concat(this.pathwayId,'. Setting initial Pathway to "').concat(r,'"')),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found ".concat(t.length,"/").concat(e.length,' levels in Pathway "').concat(this.pathwayId,'"')),t}},{key:"getLevelsForPathway",value:function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))}},{key:"updatePathwayPriority",value:function(e){var t;this._pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(e){i-r[e]>3e5&&delete r[e]}));for(var a=0;a<e.length;a++){var n=e[a];if(!(n in r)){if(n===this.pathwayId)return;var s=this.hls.nextLoadLevel,o=this.hls.levels[s];if((t=this.getLevelsForPathway(n)).length>0){this.log('Setting Pathway to "'.concat(n,'"')),this.pathwayId=n,wi(t),this.hls.trigger(M.LEVELS_UPDATED,{levels:t});var l=this.hls.levels[s];o&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate ".concat(o.bitrate," to ").concat(l.bitrate)),this.hls.nextLoadLevel=s);break}}}}},{key:"getPathwayForGroupId",value:function(e,t,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),a=0;a<i.length;a++)if(t===N&&i[a].hasAudioGroup(e)||t===U&&i[a].hasSubtitleGroup(e))return i[a].pathwayId;return r}},{key:"clonePathways",value:function(e){var t=this,r=this.levels;if(r){var i={},a={};e.forEach((function(e){var n=e.ID,s=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!r.some((function(e){return e.pathwayId===n}))){var l=t.getLevelsForPathway(s).map((function(e){var t=new wr(e.attrs);t["PATHWAY-ID"]=n;var r=t.AUDIO&&"".concat(t.AUDIO,"_clone_").concat(n),s=t.SUBTITLES&&"".concat(t.SUBTITLES,"_clone_").concat(n);r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(a[t.SUBTITLES]=s,t.SUBTITLES=s);var l=Rs(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),u=new kt({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:l,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var c=1;c<e.audioGroups.length;c++)u.addGroupId("audio","".concat(e.audioGroups[c],"_clone_").concat(n));if(e.subtitleGroups)for(var d=1;d<e.subtitleGroups.length;d++)u.addGroupId("text","".concat(e.subtitleGroups[d],"_clone_").concat(n));return u}));r.push.apply(r,d(l)),As(t.audioTracks,i,o,n),As(t.subtitleTracks,a,o,n)}}))}}},{key:"loadSteeringManifest",value:function(e){var t,r=this,i=this.hls.config,a=i.loader;this.loader&&this.loader.destroy(),this.loader=new a(i);try{t=new self.URL(e)}catch(d){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: ".concat(e))}if("data:"!==t.protocol){var n=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+n)}var s={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},c={onSuccess:function(e,i,a,n){r.log('Loaded steering manifest: "'.concat(t,'"'));var s=e.data;if(1===(null==s?void 0:s.VERSION)){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],l=s["PATHWAY-CLONES"],u=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new self.URL(o,t).href}catch(d){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: ".concat(o))}r.scheduleRefresh(r.uri||a.url),l&&r.clonePathways(l);var c={steeringManifest:s,url:t.toString()};r.hls.trigger(M.STEERING_MANIFEST_LOADED,c),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION ".concat(s.VERSION," not supported!"))},onError:function(e,t,i,a){if(r.log("Error loading steering manifest: ".concat(e.code," ").concat(e.text," (").concat(t.url,")")),r.stopLoad(),410===e.code)return r.enabled=!1,void r.log("Steering manifest ".concat(t.url," no longer available"));var n=1e3*r.timeToLoad;if(429!==e.code)r.scheduleRefresh(r.uri||t.url,n);else{var s=r.loader;if("function"==typeof(null==s?void 0:s.getResponseHeader)){var o=s.getResponseHeader("Retry-After");o&&(n=1e3*parseFloat(o))}r.log("Steering manifest ".concat(t.url," rate limited"))}},onTimeout:function(e,t,i){r.log("Timeout loading steering manifest (".concat(t.url,")")),r.scheduleRefresh(r.uri||t.url)}};this.log("Requesting steering manifest: ".concat(t)),this.loader.load(s,u,c)}},{key:"scheduleRefresh",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3*this.timeToLoad;this.clearTimeout(),this.reloadTimer=self.setTimeout((function(){var r,i=null==(r=t.hls)?void 0:r.media;!i||i.ended?t.scheduleRefresh(e,1e3*t.timeToLoad):t.loadSteeringManifest(e)}),r)}}]),r}($);function As(e,t,r,i){e&&Object.keys(t).forEach((function(a){var n=e.filter((function(e){return e.groupId===a})).map((function(e){var n=W({},e);return n.details=void 0,n.attrs=new wr(n.attrs),n.url=n.attrs.URI=Rs(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),n.groupId=n.attrs["GROUP-ID"]=t[a],n.attrs["PATHWAY-ID"]=i,n}));e.push.apply(e,d(n))}))}function Rs(e,t,r,i){var a,n=i.HOST,s=i.PARAMS,o=i[r];t&&(a=null==o?void 0:o[t])&&(e=a);var l=new self.URL(e);return n&&!a&&(l.host=n),s&&Object.keys(s).sort().forEach((function(e){e&&l.searchParams.set(e,s[e])})),l.href}var Is=function(e){g(r,e);var t=n(r);function r(e){var i;return b(this,r),(i=t.call(this,"eme",e.logger)).hls=void 0,i.config=void 0,i.media=null,i.keyFormatPromise=null,i.keySystemAccessPromises={},i._requestLicenseFailureCount=0,i.mediaKeySessions=[],i.keyIdToKeySessionPromise={},i.setMediaKeysQueue=r.CDMCleanupPromise?[r.CDMCleanupPromise]:[],i.onMediaEncrypted=function(e){var t=e.initDataType,r=e.initData,a='"'.concat(e.type,'" event: init data type: "').concat(t,'"');if(i.debug(a),null!==r){if(!i.keyFormatPromise){var n=Object.keys(i.keySystemAccessPromises);n.length||(n=Xr(i.config));var s=n.map(zr).filter((function(e){return!!e}));i.keyFormatPromise=i.getKeyFormatPromise(s)}i.keyFormatPromise.then((function(n){var s,l,u=Vr(n);if("sinf"===t){if(u!==Ur.FAIRPLAY)return void i.warn('Ignoring unexpected "'.concat(e.type,'" event with init data type: "').concat(t,'" for selected key-system ').concat(u));var c=Se(new Uint8Array(r));try{var d=Fe(Mr(JSON.parse(c).sinf));if(!d)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=new Uint8Array(d.subarray(8,24)),l=Ur.FAIRPLAY}catch(L){return void i.warn("".concat(a," Failed to parse sinf: ").concat(L))}}else{if(u!==Ur.WIDEVINE&&u!==Ur.PLAYREADY)return void i.warn('Ignoring unexpected "'.concat(e.type,'" event with init data type: "').concat(t,'" for selected key-system ').concat(u));var h=function(e){var t=[];if(e instanceof ArrayBuffer)for(var r=e.byteLength,i=0;i+32<r;){var a=We(new DataView(e,i));t.push(a),i+=a.size}return t}(r),f=h.filter((function(e){return!!e.systemId&&$r(e.systemId)===u}));f.length>1&&i.warn("".concat(a," Using first of ").concat(f.length," pssh found for selected key-system ").concat(u));var v=f[0];if(!v)return void(0===h.length||h.some((function(e){return!e.systemId}))?i.warn("".concat(a," contains incomplete or invalid pssh data")):i.log("ignoring ".concat(a," for ").concat(h.map((function(e){return $r(e.systemId)})).join(",")," pssh data in favor of playlist keys")));if(l=$r(v.systemId),0===v.version&&v.data)if(l===Ur.WIDEVINE){var g=v.data.length-22;s=new Uint8Array(v.data.subarray(g,g+16))}else l===Ur.PLAYREADY&&(s=Jr(v.data))}if(l&&s){for(var p=ne(s),m=o(i),y=m.keyIdToKeySessionPromise,k=m.mediaKeySessions,E=y[p],T=function(e){var a=k[e],n=a.decryptdata;if(!n.keyId)return"continue";var o=ne(n.keyId);return p===o||-1!==n.uri.replace(/-/g,"").indexOf(p)?(E=y[o],n.pssh||(delete y[o],n.pssh=new Uint8Array(r),n.keyId=s,(E=y[p]=E.then((function(){return i.generateRequestWithPreferredKeySession(a,t,r,"encrypted-event-key-match")}))).catch((function(e){return i.handleError(e)}))),"break"):void 0},S=0;S<k.length;S++){var b=T(S);if("continue"!==b&&"break"===b)break}if(!E){if(l!==u)return void i.log('Ignoring "'.concat(e.type,'" event with ').concat(l," init data for selected key-system ").concat(u));E=y[p]=i.getKeySystemSelectionPromise([l]).then((function(e){var a,n=e.keySystem,o=e.mediaKeys;i.throwIfDestroyed();var l=new ti("ISO-23001-7",p,null!=(a=zr(n))?a:"");return l.pssh=new Uint8Array(r),l.keyId=s,i.attemptSetMediaKeys(n,o).then((function(){i.throwIfDestroyed();var e=i.createMediaKeySessionContext({decryptdata:l,keySystem:n,mediaKeys:o});return i.generateRequestWithPreferredKeySession(e,t,r,"encrypted-event-no-match")}))})),E.catch((function(e){return i.handleError(e)}))}}}))}},i.onWaitingForKey=function(e){i.log('"'.concat(e.type,'" event'))},i.hls=e,i.config=e.config,i.registerListeners(),i}return A(r,[{key:"destroy",value:function(){var e=this.media;this.unregisterListeners(),this.onMediaDetached(),this._clear(e);var t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(M.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(M.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(M.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"unregisterListeners",value:function(){this.hls.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(M.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(M.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(M.MANIFEST_LOADED,this.onManifestLoaded,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,r=t.drmSystems,i=t.widevineLicenseUrl,a=r[e];return a?a.licenseUrl:e===Ur.WIDEVINE&&i?i:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error('no license server URL configured for key-system "'.concat(e,'"'));return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'.concat(e,'"]'))}},{key:"attemptKeySystemAccess",value:function(e){var t=this,r=this.hls.levels,i=function(e,t,r){return!!e&&r.indexOf(e)===t},a=r.map((function(e){return e.audioCodec})).filter(i),n=r.map((function(e){return e.videoCodec})).filter(i);return a.length+n.length===0&&n.push("avc1.42e01e"),new Promise((function(r,i){!function e(s){var o=s.shift();t.getMediaKeysPromise(o,a,n).then((function(e){return r({keySystem:o,mediaKeys:e})})).catch((function(t){s.length?e(s):i(t instanceof ws?t:new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))}(e)}))}},{key:"requestMediaKeySystemAccess",value:function(e,t){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var i="Configured requestMediaKeySystemAccess is not a function ".concat(r);return null===Zr&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol ".concat(location.protocol)),Promise.reject(new Error(i))}return r(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,r){var i=this,a=function(e,t,r,i){var a;switch(e){case Ur.FAIRPLAY:a=["cenc","sinf"];break;case Ur.WIDEVINE:case Ur.PLAYREADY:a=["cenc"];break;case Ur.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: ".concat(e))}return function(e,t,r,i){return[{initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map((function(e){return{contentType:"audio/mp4; codecs=".concat(e),robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:r.map((function(e){return{contentType:"video/mp4; codecs=".concat(e),robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))}]}(a,t,r,i)}(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e],s=null==n?void 0:n.keySystemAccess;if(!s){this.log('Requesting encrypted media "'.concat(e,'" key-system access with config: ').concat(St(a))),s=this.requestMediaKeySystemAccess(e,a);var o=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch((function(t){i.log('Failed to obtain access to key-system "'.concat(e,'": ').concat(t))})),s.then((function(t){i.log('Access for key-system "'.concat(t.keySystem,'" obtained'));var r=i.fetchServerCertificate(e);return i.log('Create media-keys for "'.concat(e,'"')),o.mediaKeys=t.createMediaKeys().then((function(t){return i.log('Media-keys created for "'.concat(e,'"')),r.then((function(r){return r?i.setMediaKeysServerCertificate(t,e,r):t}))})),o.mediaKeys.catch((function(t){i.error('Failed to create media-keys for "'.concat(e,'"}: ').concat(t))})),o.mediaKeys}))}return s.then((function(){return n.mediaKeys}))}},{key:"createMediaKeySessionContext",value:function(e){var t=e.decryptdata,r=e.keySystem,i=e.mediaKeys;this.log('Creating key-system session "'.concat(r,'" keyId: ').concat(ne(t.keyId||[])));var a=i.createSession(),n={decryptdata:t,keySystem:r,mediaKeys:i,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"getKeyIdString",value:function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return ne(e.keyId)}},{key:"updateKeySession",value:function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'.concat(i.sessionId,'" for keyID ').concat(ne((null==(r=e.decryptdata)?void 0:r.keyId)||[]),"\n } (data length: ").concat(t?t.byteLength:t,")")),i.update(t)}},{key:"selectKeySystemFormat",value:function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: ".concat(e.sn," ").concat(e.type,": ").concat(e.level,") key formats ").concat(t.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=this;return new Promise((function(r,i){var a=Xr(t.config),n=e.map(Vr).filter((function(e){return!!e&&-1!==a.indexOf(e)}));return t.getKeySystemSelectionPromise(n).then((function(e){var t=e.keySystem,a=zr(t);a?r(a):i(new Error('Unable to find format for key-system "'.concat(t,'"')))})).catch(i)}))}},{key:"loadKey",value:function(e){var t=this,r=e.keyInfo.decryptdata,i=this.getKeyIdString(r),a="(keyId: ".concat(i,' format: "').concat(r.keyFormat,'" method: ').concat(r.method," uri: ").concat(r.uri,")");this.log("Starting session for key ".concat(a));var n=this.keyIdToKeySessionPromise[i];n||(n=this.getKeySystemForKeyPromise(r).then((function(i){var n=i.keySystem,s=i.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: ".concat(e.frag.sn," ").concat(e.frag.type,": ").concat(e.frag.level," using key ").concat(a)),t.attemptSetMediaKeys(n,s).then((function(){return t.throwIfDestroyed(),t.createMediaKeySessionContext({keySystem:n,mediaKeys:s,decryptdata:r})}))})),(this.keyIdToKeySessionPromise[i]=n.then((function(e){var i=r.pssh?r.pssh.buffer:null;return t.generateRequestWithPreferredKeySession(e,"cenc",i,"playlist-key")}))).catch((function(e){return t.handleError(e)})));return n}},{key:"throwIfDestroyed",value:function(){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e){this.hls&&(this.error(e.message),e instanceof ws?this.hls.trigger(M.ERROR,e.data):this.hls.trigger(M.ERROR,{type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}},{key:"getKeySystemForKeyPromise",value:function(e){var t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){var i=Vr(e.keyFormat),a=i?[i]:Xr(this.config);return this.attemptKeySystemAccess(a)}return r}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=Xr(this.config)),0===e.length)throw new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options ".concat(St({drmSystems:this.config.drmSystems})));return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){var r=this,i=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'.concat(e,'"'));var a=Promise.all(i).then((function(){if(!r.media)throw new Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(a),a.then((function(){r.log('Media-keys set for "'.concat(e,'"')),i.push(a),r.setMediaKeysQueue=r.setMediaKeysQueue.filter((function(e){return-1===i.indexOf(e)}))}))}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,r,i){var a,n,s=this,o=null==(a=this.config.drmSystems)||null==(n=a[e.keySystem])?void 0:n.generateRequest;if(o)try{var l=o.call(this.hls,t,r,e);if(!l)throw new Error("Invalid response from configured generateRequest filter");t=l.initDataType,r=l.initData?l.initData:null,e.decryptdata.pssh=r?new Uint8Array(r):null}catch(g){var u;if(this.warn(g.message),null!=(u=this.hls)&&u.config.debug)throw g}if(null===r)return this.log('Skipping key-session request for "'.concat(i,'" (no initData)')),Promise.resolve(e);var c=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'.concat(i,'": ').concat(c," (init data type: ").concat(t," length: ").concat(r?r.byteLength:null,")"));var d=new Ji,h=e._onmessage=function(t){var r=e.mediaKeysSession;if(r){var i=t.messageType,a=t.message;s.log('"'.concat(i,'" message event for session "').concat(r.sessionId,'" message size: ').concat(a.byteLength)),"license-request"===i||"license-renewal"===i?s.renewLicense(e,a).catch((function(e){d.eventNames().length?d.emit("error",e):s.handleError(e)})):"license-release"===i?e.keySystem===Ur.FAIRPLAY&&(s.updateKeySession(e,Or("acknowledged")),s.removeSession(e)):s.warn('unhandled media key message type "'.concat(i,'"'))}else d.emit("error",new Error("invalid state"))},f=e._onkeystatuseschange=function(t){if(e.mediaKeysSession){s.onKeyStatusChange(e);var r=e.keyStatus;d.emit("keyStatus",r),"expired"===r&&(s.warn("".concat(e.keySystem," expired for key ").concat(c)),s.renewKeySession(e))}else d.emit("error",new Error("invalid state"))};e.mediaKeysSession.addEventListener("message",h),e.mediaKeysSession.addEventListener("keystatuseschange",f);var v=new Promise((function(e,t){d.on("error",t),d.on("keyStatus",(function(r){r.startsWith("usable")?e():"output-restricted"===r?t(new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'.concat(r,'"'))):"expired"===r?t(new Error("key expired while generating request")):s.warn('unhandled key status change "'.concat(r,'"'))}))}));return e.mediaKeysSession.generateRequest(t,r).then((function(){var t;s.log('Request generated for key-session "'.concat(null==(t=e.mediaKeysSession)?void 0:t.sessionId,'" keyId: ').concat(c))})).catch((function(e){throw new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: ".concat(e))})).then((function(){return v})).catch((function(t){throw d.removeAllListeners(),s.removeSession(e),t})).then((function(){return d.removeAllListeners(),e}))}},{key:"onKeyStatusChange",value:function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach((function(r,i){if("string"==typeof i&&"object"===c(r)){var a=i;i=r,r=a}t.log('key status change "'.concat(r,'" for keyStatuses keyId: ').concat(ne("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))," session keyId: ").concat(ne(new Uint8Array(e.decryptdata.keyId||[]))," uri: ").concat(e.decryptdata.uri)),e.keyStatus=r}))}},{key:"fetchServerCertificate",value:function(e){var t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching server certificate for "'.concat(e,'"')),new Promise((function(a,n){var s={responseType:"arraybuffer",url:i},o=t.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:function(e,t,r,i){a(e.data)},onError:function(t,r,a,o){n(new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:q({url:s.url,data:void 0},t)},'"'.concat(e,'" certificate request failed (').concat(i,"). Status: ").concat(t.code," (").concat(t.text,")")))},onTimeout:function(t,r,a){n(new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:s.url,data:void 0}},'"'.concat(e,'" certificate request timed out (').concat(i,")")))},onAbort:function(e,t,r){n(new Error("aborted"))}};r.load(s,l,u)}))):Promise.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,r){var i=this;return new Promise((function(a,n){e.setServerCertificate(r).then((function(n){i.log("setServerCertificate ".concat(n?"success":"not supported by CDM"," (").concat(null==r?void 0:r.byteLength,') on "').concat(t,'"')),a(e)})).catch((function(e){n(new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))}},{key:"renewLicense",value:function(e,t){var r=this;return this.requestLicense(e,new Uint8Array(t)).then((function(t){return r.updateKeySession(e,new Uint8Array(t)).catch((function(e){throw new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}))}},{key:"unpackPlayReadyKeyMessage",value:function(e,t){var r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var i=(new DOMParser).parseFromString(r,"application/xml"),a=i.querySelectorAll("HttpHeader");if(a.length>0)for(var n,s=0,o=a.length;s<o;s++){var l,u,c=null==(l=(n=a[s]).querySelector("name"))?void 0:l.textContent,d=null==(u=n.querySelector("value"))?void 0:u.textContent;c&&d&&e.setRequestHeader(c,d)}var h=i.querySelector("Challenge"),f=null==h?void 0:h.textContent;if(!f)throw new Error("Cannot find <Challenge> in key message");return Or(atob(f))}},{key:"setupLicenseXHR",value:function(e,t,r,i){var a=this,n=this.config.licenseXhrSetup;return n?Promise.resolve().then((function(){if(!r.decryptdata)throw new Error("Key removed");return n.call(a.hls,e,t,r,i)})).catch((function(s){if(!r.decryptdata)throw s;return e.open("POST",t,!0),n.call(a.hls,e,t,r,i)})).then((function(r){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||i}})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}},{key:"requestLicense",value:function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new Promise((function(a,n){var s=r.getLicenseServerUrlOrThrow(e.keySystem);r.log("Sending license request to URL: ".concat(s));var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(4===o.readyState)if(200===o.status){r._requestLicenseFailureCount=0;var l=o.response;r.log("License received ".concat(l instanceof ArrayBuffer?l.byteLength:l));var u=r.config.licenseResponseCallback;if(u)try{l=u.call(r.hls,o,s,e)}catch(f){r.error(f)}a(l)}else{var c=i.errorRetry,d=c?c.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new ws({type:P.KEY_SYSTEM_ERROR,details:C.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},"License Request XHR failed (".concat(s,"). Status: ").concat(o.status," (").concat(o.statusText,")")));else{var h=d-r._requestLicenseFailureCount+1;r.warn("Retrying license request, ".concat(h," attempts left")),r.requestLicense(e,t).then(a,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,r.setupLicenseXHR(o,s,e,t).then((function(t){var i=t.xhr,a=t.licenseChallenge;e.keySystem==Ur.PLAYREADY&&(a=r.unpackPlayReadyKeyMessage(i,a)),i.send(a)}))}))}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}}},{key:"onMediaDetached",value:function(){var e=this.media;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null)}},{key:"_clear",value:function(e){var t,i=this,a=this.mediaKeySessions;this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ti.clearKeyUriToKeyIdMap();var n=a.length;r.CDMCleanupPromise=Promise.all(a.map((function(e){return i.removeSession(e)})).concat(null==e||null==(t=e.setMediaKeys(null))?void 0:t.catch((function(e){var t;i.log("Could not clear media keys: ".concat(e)),null==(t=i.hls)||t.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: ".concat(e))})})))).then((function(){n&&(i.log("finished closing key sessions and clearing media keys"),a.length=0)})).catch((function(e){var t;i.log("Could not close sessions and clear media keys: ".concat(e)),null==(t=i.hls)||t.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close sessions and clear media keys: ".concat(e))})}))}},{key:"onManifestLoading",value:function(){this.keyFormatPromise=null}},{key:"onManifestLoaded",value:function(e,t){var r=t.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce((function(e,t){return-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys ".concat(i.join(", "))),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){this.log("Remove licenses and keys and close session ".concat(r.sessionId)),e._onmessage&&(r.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(r.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);a>-1&&this.mediaKeySessions.splice(a,1);var n=function(e){var t;return"persistent-license"===e.sessionType||!(null==(t=e.sessionTypes)||!t.some((function(e){return"persistent-license"===e})))}(this.config.drmSystemOptions)?new Promise((function(e,t){self.setTimeout((function(){return t(new Error("MediaKeySession.remove() timeout"))}),8e3),r.remove().then(e)})):Promise.resolve();return n.catch((function(e){var r;t.log("Could not remove session: ".concat(e)),null==(r=t.hls)||r.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error("Could not remove session: ".concat(e))})})).then((function(){return r.close()})).catch((function(e){var r;t.log("Could not close session: ".concat(e)),null==(r=t.hls)||r.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: ".concat(e))})}))}}}]),r}($);Is.CDMCleanupPromise=void 0;var ws=function(e){g(r,e);var t=n(r);function r(e,i){var a;return b(this,r),(a=t.call(this,i)).data=void 0,e.error||(e.error=new Error(i)),a.data=e,e.err=e.error,a}return A(r)}(i(Error)),Ds=function(){function e(t){b(this,e),this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}return A(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(M.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(M.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*n/a,l=this.hls;if(l.trigger(M.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),o>0&&n>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(M.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}]),e}();function _s(e,t){var r;try{r=new Event("addtrack")}catch(Ll){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function xs(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: ".concat(t))}catch(Ll){te.debug("[texttrack-utils]: ".concat(Ll));try{var i=new self.TextTrackCue(t.startTime,t.endTime,t.text);i.id=t.id,e.addCue(i)}catch(a){te.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: ".concat(a))}}"disabled"===r&&(e.mode=r)}function Ps(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues)for(var i=e.cues.length;i--;)t&&e.cues[i].removeEventListener("enter",t),e.removeCue(e.cues[i]);"disabled"===r&&(e.mode=r)}function Cs(e,t,r,i){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var n=function(e,t,r){var i=[],a=function(e,t){if(t<=e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;var i,a=0,n=r;for(;a<=n;)if(t<e[i=Math.floor((n+a)/2)].startTime)n=i-1;else{if(!(t>e[i].startTime&&a<r))return i;a=i+1}return e[a].startTime-t<t-e[n].startTime?a:n}(e,t);if(a>-1)for(var n=a,s=e.length;n<s;n++){var o=e[n];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;s<n.length;s++)i&&!i(n[s])||e.removeCue(n[s]);"disabled"===a&&(e.mode=a)}function Ms(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[r])}return t}var Os=function(e){g(i,e);var r=n(i);function i(e){var t;return b(this,i),(t=r.call(this,e,"subtitle-track-controller")).media=null,t.tracks=[],t.groupIds=null,t.tracksInGroup=[],t.trackId=-1,t.currentTrack=null,t.selectDefaultTrack=!0,t.queuedDefaultTrack=-1,t.useTextTrackPolling=!1,t.subtitlePollingInterval=-1,t._subtitleDisplay=!0,t.asyncPollTrackChange=function(){return t.pollTrackChange(0)},t.onTextTracksChanged=function(){if(t.useTextTrackPolling||self.clearInterval(t.subtitlePollingInterval),t.media&&t.hls.config.renderTextTracksNatively){for(var e=null,r=Ms(t.media.textTracks),i=0;i<r.length;i++)if("hidden"===r[i].mode)e=r[i];else if("showing"===r[i].mode){e=r[i];break}var a=t.findTrackForTextTrack(e);t.subtitleTrack!==a&&t.setSubtitleTrack(a)}},t.registerListeners(),t}return A(i,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,t(u(i.prototype),"destroy",this).call(this)}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.LEVEL_LOADING,this.onLevelLoading,this),e.on(M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(M.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.LEVEL_LOADING,this.onLevelLoading,this),e.off(M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(M.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(M.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.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))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var r=this.media;if(r){var i=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||r.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!i)Ms(r.textTracks).forEach((function(e){Ps(e)}))}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r=t.id,i=t.groupId,a=t.details,n=this.tracksInGroup[r];if(n&&n.groupId===i){var s=n.details;n.details=t.details,this.log("Subtitle track ".concat(r,' "').concat(n.name,'" lang:').concat(n.lang," group:").concat(i," loaded [").concat(a.startSN,"-").concat(a.endSN,"]")),r===this.trackId&&this.playlistLoaded(r,t,s)}else this.warn("Subtitle track with id:".concat(r," and group:").concat(i," not found in active group ").concat(null==n?void 0:n.groupId))}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var r=t.subtitleGroups||null,i=this.groupIds,a=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some((function(e){return-1===(null==i?void 0:i.indexOf(e))}))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;var n=this.tracks.filter((function(e){return!r||-1!==r.indexOf(e.groupId)}));if(n.length)this.selectDefaultTrack&&!n.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),n.forEach((function(e,t){e.id=t}));else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=n;var s=this.hls.config.subtitlePreference;if(!a&&s){this.selectDefaultTrack=!1;var o=Rt(s,n);if(o>-1)a=n[o];else{var l=Rt(s,this.tracks);a=this.tracks[l]}}var u=this.findTrackId(a);-1===u&&a&&(u=this.findTrackId(null));var c={subtitleTracks:n};this.log("Updating subtitle tracks, ".concat(n.length,' track(s) found in "').concat(null==r?void 0:r.join(","),'" group-id')),this.hls.trigger(M.SUBTITLE_TRACKS_UPDATED,c),-1!==u&&-1===this.trackId&&this.setSubtitleTrack(u)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,r=this.selectDefaultTrack,i=0;i<t.length;i++){var a=t[i];if((!r||a.default)&&(r||e)&&(!e||It(a,e)))return i}if(e){for(var n=0;n<t.length;n++){var s=t[n];if(Mn(e.attrs,s.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(var o=0;o<t.length;o++){var l=t[o];if(Mn(e.attrs,l.attrs,["LANGUAGE"]))return o}}return-1}},{key:"findTrackForTextTrack",value:function(e){if(e)for(var t=this.tracksInGroup,r=0;r<t.length;r++){if(On(t[r],e))return r}return-1}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==U||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var r=this.currentTrack;if(r&&It(e,r))return r;var i=Rt(e,this.tracksInGroup);if(i>-1){var a=this.tracksInGroup[i];return this.setSubtitleTrack(i),a}if(r)return null;var n=Rt(e,t);if(n>-1)return t[n]}}return null}},{key:"loadPlaylist",value:function(e){t(u(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,e)}},{key:"loadingPlaylist",value:function(e,r){t(u(i.prototype),"loadingPlaylist",this).call(this,e,r);var a=e.id,n=e.groupId,s=this.getUrlWithDirectives(e.url,r),o=e.details,l=null==o?void 0:o.age;this.log("Loading subtitle ".concat(a,' "').concat(e.name,'" lang:').concat(e.lang," group:").concat(n).concat(void 0!==(null==r?void 0:r.msn)?" at sn "+r.msn+" part "+r.part:"").concat(l&&o.live?" age "+l.toFixed(1)+(o.type&&" "+o.type||""):""," ").concat(s)),this.hls.trigger(M.SUBTITLE_TRACK_LOADING,{url:s,id:a,groupId:n,deliveryDirectives:r||null,track:e})}},{key:"toggleTrackModes",value:function(){var e=this.media;if(e){var t,r=Ms(e.textTracks),i=this.currentTrack;if(i&&((t=r.filter((function(e){return On(i,e)}))[0])||this.warn('Unable to find subtitle TextTrack with name "'.concat(i.name,'" and language "').concat(i.lang,'"'))),[].slice.call(r).forEach((function(e){"disabled"!==e.mode&&e!==t&&(e.mode="disabled")})),t){var a=this.subtitleDisplay?"showing":"hidden";t.mode!==a&&(t.mode=a)}}}},{key:"setSubtitleTrack",value:function(e){var t=this.tracksInGroup;if(this.media)if(e<-1||e>=t.length||!D(e))this.warn("Invalid subtitle track id: ".concat(e));else{this.selectDefaultTrack=!1;var r=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),i){var a=!!i.details&&!i.details.live;if(e!==this.trackId||i!==r||!a){this.log("Switching to subtitle-track ".concat(e)+(i?' "'.concat(i.name,'" lang:').concat(i.lang," group:").concat(i.groupId):""));var n=i.id,s=i.groupId,o=void 0===s?"":s,l=i.name,u=i.type,c=i.url;this.hls.trigger(M.SUBTITLE_TRACK_SWITCH,{id:n,groupId:o,name:l,type:u,url:c});var d=this.switchParams(i.url,null==r?void 0:r.details,i.details);this.loadPlaylist(d)}}else this.hls.trigger(M.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}]),i}(Pn);function Fs(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()}var Ns=.025,Us=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function Bs(e,t,r){return"".concat(e.identifier,"-").concat(r+1,"-").concat(Fs(t))}var Gs=function(){function e(t,r){b(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=r,this.dateRange=t,this.setDateRange(t)}return A(e,[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}},{key:"isAssetPastPlayoutLimit",value:function(e){if(e>=this.assetList.length)return!0;var t=this.playoutLimit;return!(e<=0||isNaN(t))&&this.assetList[e].startOffset>t}},{key:"findAssetIndex",value:function(e){return this.assetList.indexOf(e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return Hs(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"startIsAligned",get:function(){if(0===this.startTime||this.snapOptions.out)return!0;var e=this.dateRange.tagAnchor;if(e){var t=this.dateRange.startTime;return t-Hs(t,e)<.1}return!1}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=D(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return Hs(e,t)}return e}},{key:"appendInPlace",get:function(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<Ns))},set:function(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}},{key:"timelineStart",get:function(){return null!==this._timelineStart?this._timelineStart:this.startTime},set:function(e){this._timelineStart=e}},{key:"duration",get:function(){var e,t=this.playoutLimit;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e},set:function(e){this._duration=e}},{key:"cue",get:function(){return this.dateRange.cue}},{key:"timelineOccupancy",get:function(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?Us.Range:Us.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"assetListLoaded",get:function(){return this.assetList.length>0||null!==this.assetListResponse}},{key:"toString",value:function(){return'["'.concat((e=this).identifier,'" ').concat(e.cue.pre?"<pre>":e.cue.post?"<post>":"").concat(e.timelineStart.toFixed(2),"-").concat(e.resumeTime.toFixed(2),"]");var e}}]),e}();function Hs(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<Ns)?t.start:t.start+t.duration}function Ks(e,t,r){var i=new self.URL(e,r);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",t),i}function Vs(e){var t=e.timelineStart,r=e.duration||0;return'["'.concat(e.identifier,'" ').concat(t.toFixed(2),"-").concat((t+r).toFixed(2),"]")}var js=function(){function e(t,r,i,a){var n=this;b(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=function(){var e=n.interstitial.playoutLimit,t=n.currentTime;n.startOffset+t>=e&&n.hls.trigger(M.PLAYOUT_LIMIT_REACHED,{})};var s=this.hls=new t(r);this.interstitial=i,this.assetItem=a;var o=a.uri;try{o=Ks(o,s.sessionId).href}catch(u){}s.loadSource(o);var l=function(){n.hasDetails=!0};s.once(M.LEVEL_LOADED,l),s.once(M.AUDIO_TRACK_LOADED,l),s.once(M.SUBTITLE_TRACK_LOADED,l),s.on(M.MEDIA_ATTACHING,(function(e,t){var r=t.media;n.removeMediaListeners(),n.mediaAttached=r,n.interstitial.playoutLimit&&r.addEventListener("timeupdate",n.checkPlayout)}))}return A(e,[{key:"bufferedInPlaceToEnd",value:function(e){var t;if(!this.interstitial.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e||!this._bufferedEosTime)return!1;var r=this.timelineOffset,i=Er.bufferInfo(e,r,0);return this.getAssetTime(i.end)>=this._bufferedEosTime-.02}},{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){var e;return(null==(e=this.hls)?void 0:e.media)||null}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;var t=Er.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}},{key:"duration",get:function(){var e=this.assetItem.duration;return e||0}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"startOffset",get:function(){return this.assetItem.startOffset}},{key:"timelineOffset",get:function(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0},set:function(e){var t=this.timelineOffset;if(e!==t){var r=e-t;if(Math.abs(r)>1/9e4){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,r=this.duration;return Math.min(Math.max(0,e-t),r)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}},{key:"bufferSnapShot",value:function(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){this.hls.attachMedia(e)}},{key:"detachMedia",value:function(){this.removeMediaListeners(),this.mediaAttached=null,this.hls.detachMedia()}},{key:"resumeBuffering",value:function(){this.hls.resumeBuffering()}},{key:"pauseBuffering",value:function(){this.hls.pauseBuffering()}},{key:"transferMedia",value:function(){return this.bufferSnapShot(),this.hls.transferMedia()}},{key:"on",value:function(e,t,r){this.hls.on(e,t)}},{key:"once",value:function(e,t,r){this.hls.once(e,t)}},{key:"off",value:function(e,t,r){this.hls.off(e,t)}},{key:"toString",value:function(){var e,t;return"HlsAssetPlayer: ".concat(Vs(this.assetItem)," ").concat(null==(e=this.hls)?void 0:e.sessionId," ").concat(null!=(t=this.interstitial)&&t.appendInPlace?"append-in-place":"")}}]),e}(),Ws=function(e){g(r,e);var t=n(r);function r(e,i){var a;return b(this,r),(a=t.call(this,"interstitials-sched",i)).onScheduleUpdate=void 0,a.eventMap={},a.events=null,a.items=null,a.durations={primary:0,playout:0,integrated:0},a.onScheduleUpdate=e,a}return A(r,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach((function(e){return e.reset()})),this.events=this.items=null}},{key:"resetErrorsInRange",value:function(e,t){return this.events?this.events.reduce((function(r,i){return e<=i.startOffset&&t>i.startOffset?(delete i.error,r+1):r}),0):0}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var r=-1;e.nextEvent?r=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(r=this.findEventIndex(e.previousEvent.identifier)+1);var i=this.items;if(i)for(i[r]||(void 0===t&&(t=e.start),r=this.findItemIndexAtTime(t));r>=0&&null!=(a=i[r])&&a.event;){var a;r--}return r}},{key:"findItemIndexAtTime",value:function(e,t){var r=this.items;if(r)for(var i=0;i<r.length;i++){var a=r[i];if(t&&"primary"!==t&&(a=a[t]),e===a.start||e>a.start&&e<a.end)return i}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var r=this.items;if(r)for(var i=e;i<=t&&r[i];i++){var a=r[i].event;if(null!=a&&a.restrictions.jump&&!a.appendInPlace)return i}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var r=t.length;r--;){var i;if((null==(i=t[r].event)?void 0:i.identifier)===e)return r}return-1}},{key:"findAssetIndex",value:function(e,t){var r=e.assetList,i=r.length;if(i>1)for(var a=0;a<i;a++){var n=r[a];if(!n.error){var s=n.timelineStart;if(t===s||t>s&&t<s+(n.duration||0))return a}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t,r=null==(e=this.items)||null==(t=e[this.length-1])?void 0:t.event;if(r){var i=r.assetList,a=i[i.length-1];if(a)return a.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e,t){var r=this,i=e.main.details,a=i.dateRanges,n=this.events,s=this.parseDateRanges(a,{url:i.url},t),o=Object.keys(a),l=n?n.filter((function(e){return!o.includes(e.identifier)})):[];s.length&&s.sort((function(e,t){var r=e.cue.pre,i=e.cue.post,a=t.cue.pre,n=t.cue.post;if(r&&!a)return-1;if(a&&!r)return 1;if(i&&!n)return 1;if(n&&!i)return-1;if(!(r||a||i||n)){var s=e.startTime,o=t.startTime;if(s!==o)return s-o}return e.dateRange.tagOrder-t.dateRange.tagOrder})),this.events=s,l.forEach((function(e){r.removeEvent(e)})),this.updateSchedule(e,l)}},{key:"updateSchedule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this.events||[];if(r.length||t.length||this.length<2){var i=this.items,a=this.parseSchedule(r,e),n=t.length||(null==i?void 0:i.length)!==a.length||a.some((function(e,t){return Math.abs(e.playout.start-i[t].playout.start)>.005||Math.abs(e.playout.end-i[t].playout.end)>.005}));n&&(this.items=a,this.onScheduleUpdate(t,i))}}},{key:"parseDateRanges",value:function(e,t,r){for(var i=[],a=Object.keys(e),n=0;n<a.length;n++){var s=a[n],o=e[s];if(o.isInterstitial){var l=this.eventMap[s];l?l.setDateRange(o):(l=new Gs(o,t),this.eventMap[s]=l,!1===r&&(l.appendInPlace=r)),i.push(l)}}return i}},{key:"parseSchedule",value:function(e,t){var r=[],i=t.main.details,a=i.live?1/0:i.edge,n=0;if((e=e.filter((function(e){return!(e.error||e.cue.once&&e.hasPlayed)}))).length){this.resolveOffsets(e,t);var s=0,o=0;if(e.forEach((function(t,i){var l=t.cue.pre,u=t.cue.post,c=e[i-1]||null,d=t.appendInPlace,h=u?a:t.startOffset,f=t.duration,v=t.timelineOccupancy===Us.Range?f:0,g=t.resumptionOffset,p=(null==c?void 0:c.startTime)===h,m=h+t.cumulativeDuration,y=d?m+f:h+g;if(l||!u&&h<=0){var k=o;o+=v,t.timelineStart=m;var E=n;n+=f,r.push({event:t,start:m,end:y,playout:{start:E,end:n},integrated:{start:k,end:o}})}else{if(!(h<=a))return;if(!p){var T=h-s;if(T>.033){var S=s,b=o;o+=T;var L=n;n+=T;var A={previousEvent:e[i-1]||null,nextEvent:t,start:S,end:S+T,playout:{start:L,end:n},integrated:{start:b,end:o}};r.push(A)}else T>0&&c&&(c.cumulativeDuration+=T,r[r.length-1].end=h)}u&&(y=m),t.timelineStart=m;var R=o;o+=v;var I=n;n+=f,r.push({event:t,start:m,end:y,playout:{start:I,end:n},integrated:{start:R,end:o}})}var w=t.resumeTime;s=u||w>a?a:w})),s<a){var l,u=s,c=o,d=a-s;o+=d;var h=n;n+=d,r.push({previousEvent:(null==(l=r[r.length-1])?void 0:l.event)||null,nextEvent:null,start:s,end:u+d,playout:{start:h,end:n},integrated:{start:c,end:o}})}this.setDurations(a,n,o)}else{r.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a)}return r}},{key:"setDurations",value:function(e,t,r){this.durations={primary:e,playout:t,integrated:r}}},{key:"resolveOffsets",value:function(e,t){var r=this,i=t.main.details,a=i.live?1/0:i.edge,n=0,s=-1;e.forEach((function(o,l){var u=o.cue.pre,c=o.cue.post,d=u?0:c?a:o.startTime;(r.updateAssetDurations(o),s===d?o.cumulativeDuration=n:(n=0,s=d),!c&&o.snapOptions.in&&(o.resumeAnchor=Ct(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(r.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));!o.appendInPlace&&l+1<e.length&&(e[l+1].startTime-e[l].resumeTime<.033&&(e[l+1].appendInPlace=!1,e[l+1].appendInPlace&&r.warn("Could not change append strategy for abutting event ".concat(o))));var h=D(o.resumeOffset)?o.resumeOffset:o.duration;n+=h}))}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var r=this,i=e.resumeTime,a=e.startTime+e.resumptionOffset;return Math.abs(i-a)>Ns?(this.log('"'.concat(e.identifier,'" resumption ').concat(i," not aligned with estimated timeline end ").concat(a)),!1):t?!Object.keys(t).some((function(a){var n=t[a].details,s=n.edge;if(i>=s)return r.log('"'.concat(e.identifier,'" resumption ').concat(i," past ").concat(a," playlist end ").concat(s)),!1;var o=Ct(null,n.fragments,i);if(!o)return r.log('"'.concat(e.identifier,'" resumption ').concat(i," does not align with any fragments in ").concat(a," playlist (").concat(n.fragStart,"-").concat(n.fragmentEnd,")")),!0;var l="audio"===a?.175:0;return!(Math.abs(o.start-i)<Ns+l||Math.abs(o.end-i)<Ns+l)&&(r.log('"'.concat(e.identifier,'" resumption ').concat(i," not aligned with ").concat(a," fragment bounds (").concat(o.start,"-").concat(o.end," sn: ").concat(o.sn," cc: ").concat(o.cc,")")),!0)})):(this.log('"'.concat(e.identifier,'" resumption ').concat(i," can not be aligned with media (none selected)")),!1)}},{key:"updateAssetDurations",value:function(e){if(e.assetListLoaded){var t=e.timelineStart,r=0,i=!1,a=!1;e.assetList.forEach((function(e,n){var s=t+r;e.startOffset=r,e.timelineStart=s,i||(i=null===e.duration),a||(a=!!e.error);var o=e.error?0:e.duration||0;r+=o})),e.duration=i&&!a?Math.max(r,e.duration):r}}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}]),r}($);function Ys(e){return"[".concat(e.event?'"'+e.event.identifier+'"':"primary",": ").concat(e.start.toFixed(2),"-").concat(e.end.toFixed(2),"]")}var qs=function(){function e(t){b(this,e),this.hls=void 0,this.hls=t}return A(e,[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var r,i=this,a=e.assetListUrl;try{r=Ks(a,this.hls.sessionId,e.baseUrl)}catch(h){var n=this.assignAssetListError(e,C.ASSET_LIST_LOAD_ERROR,h,a);return void this.hls.trigger(M.ERROR,n)}t&&"data:"!==r.protocol&&r.searchParams.set("_HLS_start_offset",""+t);var s=this.hls.config,o=new(0,s.loader)(s),l={responseType:"json",url:r.href},u=s.interstitialAssetListLoadPolicy.default,c={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:function(t,r,a,n){var s=t.data,o=null==s?void 0:s.ASSETS;if(Array.isArray(o))e.assetListResponse=s,i.hls.trigger(M.ASSET_LIST_LOADED,{event:e,assetListResponse:s,networkDetails:n});else{var l=i.assignAssetListError(e,C.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),a.url,r,n);i.hls.trigger(M.ERROR,l)}},onError:function(t,r,a,n){var s=i.assignAssetListError(e,C.ASSET_LIST_LOAD_ERROR,new Error("Error loading X-ASSET-LIST: HTTP status ".concat(t.code," ").concat(t.text," (").concat(r.url,")")),r.url,n,a);i.hls.trigger(M.ERROR,s)},onTimeout:function(t,r,a){var n=i.assignAssetListError(e,C.ASSET_LIST_LOAD_TIMEOUT,new Error("Timeout loading X-ASSET-LIST (".concat(r.url,")")),r.url,t,a);i.hls.trigger(M.ERROR,n)}};return o.load(l,c,d),this.hls.trigger(M.ASSET_LIST_LOADING,{event:e}),o}},{key:"assignAssetListError",value:function(e,t,r,i,a,n){return e.error=r,{type:P.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:i,error:r,networkDetails:n,stats:a}}}]),e}();function $s(e,t,r){zs(e,t,r),e.addEventListener(t,r)}function zs(e,t,r){e.removeEventListener(t,r)}function Xs(e){null==e||e.play().catch((function(){}))}var Qs=function(e){g(r,e);var t=n(r);function r(e,i){var a;return b(this,r),(a=t.call(this,"interstitials",e.logger)).HlsPlayerClass=void 0,a.hls=void 0,a.assetListLoader=void 0,a.mediaSelection=null,a.altSelection=null,a.media=null,a.detachedData=null,a.requiredTracks=null,a.manager=null,a.playerQueue=[],a.bufferedPos=-1,a.timelinePos=-1,a.schedule=void 0,a.playingItem=null,a.bufferingItem=null,a.waitingItem=null,a.endedItem=null,a.playingAsset=null,a.endedAsset=null,a.bufferingAsset=null,a.shouldPlay=!1,a.onPlay=function(){a.shouldPlay=!0},a.onPause=function(){a.shouldPlay=!1},a.onSeeking=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled){var t=e-a.timelinePos;if(!(Math.abs(t)<1/7056e5)){var r=t<=-.01;a.timelinePos=e,a.bufferedPos=e;var i=a.playingItem;if(i){if(r)a.schedule.resetErrorsInRange(e,e-t)&&a.updateSchedule();if(a.checkBuffer(),r&&e<i.start||e>=i.end){var n,s=a.schedule.findItemIndexAtTime(a.timelinePos);if(!a.isInterstitial(i)&&null!=(n=a.media)&&n.paused&&(a.shouldPlay=!1),!r){var o=a.findItemIndex(i);if(s>o){var l=a.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void a.setSchedulePosition(l)}}a.setSchedulePosition(s)}else{var u=a.playingAsset;if(u){var c=u.timelineStart,d=u.duration||0;(r&&e<c||e>=c+d)&&a.setScheduleToAssetAtTime(e,u)}else if(a.playingLastItem&&a.isInterstitial(i)){var h=i.event.assetList[0];h&&(a.endedItem=a.playingItem,a.playingItem=null,a.setScheduleToAssetAtTime(e,h))}}}else a.checkBuffer()}}},a.onTimeupdate=function(){var e=a.currentTime;if(void 0!==e&&!a.playbackDisabled&&e>a.timelinePos){a.timelinePos=e,e>a.bufferedPos&&a.checkBuffer();var t=a.playingItem;if(t&&!a.playingLastItem){if(e>=t.end){a.timelinePos=t.end;var r=a.findItemIndex(t);a.setSchedulePosition(r+1)}var i=a.playingAsset;if(i)e>=i.timelineStart+(i.duration||0)&&a.setScheduleToAssetAtTime(e,i)}}},a.onScheduleUpdate=function(e,t){var r=a.schedule,i=a.playingItem,n=r.events||[],s=r.items||[],o=r.durations,l=e.map((function(e){return e.identifier})),u=!(!n.length&&!l.length);if(u&&a.log("INTERSTITIALS_UPDATED (".concat(n.length,"): ").concat(n,"\nSchedule: ").concat(s.map((function(e){return Ys(e)})))),l.length&&a.log("Removed events ".concat(l)),a.playerQueue.forEach((function(e){if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,r=e.timelineOffset-t;if(r)try{e.timelineOffset=t}catch(i){Math.abs(r)>Ns&&a.warn("".concat(i,' ("').concat(e.assetId,'" ').concat(e.timelineOffset,"->").concat(t,")"))}}})),i){var c=a.updateItem(i,a.timelinePos);a.itemsMatch(i,c)&&(a.playingItem=c,a.waitingItem=a.endedItem=null)}else a.waitingItem=a.updateItem(a.waitingItem),a.endedItem=a.updateItem(a.endedItem);var d=a.bufferingItem;if(d){var h=a.updateItem(d,a.bufferedPos);a.itemsMatch(d,h)?a.bufferingItem=h:d.event&&(a.bufferingItem=a.playingItem,a.clearInterstitial(d.event,null))}if(e.forEach((function(e){e.assetList.forEach((function(e){a.clearAssetPlayer(e.identifier,null)}))})),u||t){if(a.hls.trigger(M.INTERSTITIALS_UPDATED,{events:n.slice(0),schedule:s.slice(0),durations:o,removedIds:l}),a.isInterstitial(i)&&l.includes(i.event.identifier))return a.warn('Interstitial "'.concat(i.event.identifier,'" removed while playing')),void a.primaryFallback(i.event);a.checkBuffer()}},a.hls=e,a.HlsPlayerClass=i,a.assetListLoader=new qs(e),a.schedule=new Ws(a.onScheduleUpdate,e.logger),a.registerListeners(),a}return A(r,[{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(M.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(M.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(M.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(M.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(M.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(M.BUFFER_APPENDED,this.onBufferAppended,this),e.on(M.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(M.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(M.MEDIA_ENDED,this.onMediaEnded,this),e.on(M.ERROR,this.onError,this),e.on(M.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(M.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(M.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(M.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(M.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(M.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(M.BUFFER_CODECS,this.onBufferCodecs,this),e.off(M.BUFFER_APPENDED,this.onBufferAppended,this),e.off(M.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(M.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(M.MEDIA_ENDED,this.onMediaEnded,this),e.off(M.ERROR,this.onError,this),e.off(M.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){zs(e,"play",this.onPlay),zs(e,"pause",this.onPause),zs(e,"seeking",this.onSeeking),zs(e,"timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var r=this.media=t.media;$s(r,"seeking",this.onSeeking),$s(r,"timeupdate",this.onTimeupdate),$s(r,"play",this.onPlay),$s(r,"pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var r=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,null===r)this.checkStart();else if(!i){this.clearScheduleState();var a=this.findItemIndex(r);this.setSchedulePosition(a)}}},{key:"clearScheduleState",value:function(){this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia,i=this.media;if(this.media=null,!r&&(i&&this.removeMediaListeners(i),this.detachedData)){var a=this.getBufferingPlayer();a&&(this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,a.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.manager){if(!this.hls)return null;var e=this,t=function(){return e.bufferingItem||e.waitingItem},r=function(t){return t?e.getAssetPlayer(t.identifier):t},i=function(t,i,n,s,o){if(t){var l=t[i].start,u=t.event;if(u){if("playout"===i||u.timelineOccupancy!==Us.Point){var c=r(n);(null==c?void 0:c.interstitial)===u&&(l+=c.assetItem.startOffset+c[o])}}else l+=("bufferedPos"===s?a():e[s])-t.start;return l}return 0},a=function(){var t=e.bufferedPos;return t===Number.MAX_VALUE?n("primary"):Math.max(t,0)},n=function(t){var r;return null!=(r=e.primaryDetails)&&r.live?e.primaryDetails.edge:e.schedule.durations[t]},s=function(t,a){var n,s,o=e.effectivePlayingItem;if(null==o||null==(n=o.event)||!n.restrictions.skip){e.log("seek to ".concat(t,' "').concat(a,'"'));var l=e.effectivePlayingItem,u=e.schedule.findItemIndexAtTime(t,a),c=null==(s=e.schedule.items)?void 0:s[u],d=e.getBufferingPlayer(),h=null==d?void 0:d.interstitial,f=null==h?void 0:h.appendInPlace,v=l&&e.itemsMatch(l,c);if(l&&(f||v)){var g=r(e.playingAsset),p=(null==g?void 0:g.media)||e.primaryMedia;if(p){var m="primary"===a?p.currentTime:i(l,a,e.playingAsset,"timelinePos","currentTime"),y=t-m,k=(f?m:p.currentTime)+y;if(k>=0&&(!g||f||k<=g.duration))return void(p.currentTime=k)}}if(c){var E=t;if("primary"!==a){var T=t-c[a].start;E=c.start+T}var S=!e.isInterstitial(c);if(e.isInterstitial(l)&&!l.event.appendInPlace||!S&&!c.event.appendInPlace){if(l){var b=e.findItemIndex(l);if(u>b){var L=e.schedule.findJumpRestrictedIndex(b+1,u);if(L>b)return void e.setSchedulePosition(L)}var A=0;if(S)e.timelinePos=E,e.checkBuffer();else{var R,I=null==c||null==(R=c.event)?void 0:R.assetList;if(I)for(var w=t-(c[a]||c).start,D=I.length;D--;){var _=I[D];if(_.duration&&w>=_.startOffset&&w<_.startOffset+_.duration){A=D;break}}}e.setSchedulePosition(u,A)}}else{var x=e.media||(f?null==d?void 0:d.media:null);x&&(x.currentTime=E)}}}},o=function(){var r=e.effectivePlayingItem;if(e.isInterstitial(r))return r;var i=t();return e.isInterstitial(i)?i:null},l={get currentTime(){var t=o(),r=e.effectivePlayingItem;return r&&r===t?i(r,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-r.playout.start:0},set currentTime(t){var r=o(),i=e.effectivePlayingItem;i&&i===r&&s(t+i.playout.start,"playout")},get duration(){var e=o();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t,r=null==(t=o())?void 0:t.event.assetList;return r?r.map((function(t){return e.getAssetPlayer(t.identifier)})):[]},get playingIndex(){var t,r=null==(t=o())?void 0:t.event;return r&&e.effectivePlayingAsset?r.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return o()}};this.manager={get events(){var t,r;return(null==(t=e.schedule)||null==(r=t.events)?void 0:r.slice(0))||[]},get schedule(){var t,r;return(null==(t=e.schedule)||null==(r=t.items)?void 0:r.slice(0))||[]},get interstitialPlayer(){return o()?l:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){var r=t();return e.findItemIndex(r)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){var t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return a()},get currentTime(){var t=e.timelinePos;return t>0?t:0},set currentTime(e){s(e,"primary")},get duration(){return n("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){s(e,"integrated")},get duration(){return n("integrated")},get seekableStart(){var t;return function(t,r){if(0!==t&&"primary"!==r&&e.schedule.length){var i,a=e.schedule.findItemIndexAtTime(t),n=null==(i=e.schedule.items)?void 0:i[a];if(n)return t+(n[r].start-n.start)}return t}((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:function(){var t=e.effectivePlayingItem,r=null==t?void 0:t.event;if(r&&!r.restrictions.skip){var i=e.findItemIndex(t);if(r.appendInPlace){var a=t.playout.start+t.event.duration;s(a+.001,"playout")}else e.advanceAfterAssetEnded(r,i,1/0)}}}}return this.manager}},{key:"effectivePlayingItem",get:function(){return this.waitingItem||this.playingItem||this.endedItem}},{key:"effectivePlayingAsset",get:function(){return this.playingAsset||this.endedAsset}},{key:"playingLastItem",get:function(){var e,t=this.playingItem,r=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&r)&&this.findItemIndex(t)===r.length-1}},{key:"playbackStarted",get:function(){return null!==this.effectivePlayingItem}},{key:"currentTime",get:function(){var e,t,r;if(null!==this.mediaSelection){var i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var a=this.media;!a&&null!=(e=this.bufferingItem)&&null!=(t=e.event)&&t.appendInPlace&&(a=this.primaryMedia);var n=null==(r=a)?void 0:r.currentTime;if(void 0!==n&&D(n))return n}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var r=this.getAssetPlayer(e);r&&this.transferMediaFromPlayer(r,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var r=e.interstitial.appendInPlace,i=e.media;if(r&&i===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&i)return void(this.detachedData={media:i});var a=e.transferMedia();this.log("transfer MediaSource from ".concat(e," ").concat(St(a))),this.detachedData=a}else t&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}},{key:"transferMediaTo",value:function(e,t){var r,i,a=this;if(e.media!==t){var n,s=null,o=this.hls,l=e!==o,u=l&&e.interstitial.appendInPlace,c=null==(r=this.detachedData)?void 0:r.mediaSource;if(o.media)u&&(s=o.transferMedia(),this.detachedData=s),n="Primary";else if(c){var d=this.getBufferingPlayer();d?(s=d.transferMedia(),n="".concat(d)):n="detached MediaSource"}else n="detached media";if(!s)if(c)s=this.detachedData,this.log("using detachedData: MediaSource ".concat(St(s)));else if(!this.detachedData||o.media===t){var h=this.playerQueue;h.length>1&&h.forEach((function(e){if(l&&e.interstitial.appendInPlace!==u){var t=e.interstitial;a.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&a.warn("Could not change append strategy for queued assets ".concat(t))}})),this.hls.detachMedia(),this.detachedData={media:t}}var f=s&&"mediaSource"in s&&"closed"!==(null==(i=s.mediaSource)?void 0:i.readyState),v=f&&s?s:t;if(this.log("".concat(f?"transfering MediaSource":"attaching media"," to ").concat(l?e:"Primary"," from ").concat(n)),v===s){var g=l&&e.assetId===this.schedule.assetIdAtEnd;v.overrides={duration:this.schedule.duration,endOfStream:!l||g,cueRemoval:!l}}e.attachMedia(v)}}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=e.events;if(t&&!this.playbackDisabled&&this.media){-1===this.bufferedPos&&(this.bufferedPos=0);var r=this.timelinePos,i=this.effectivePlayingItem;if(-1===r){var a=this.hls.startPosition;if(this.timelinePos=a,t.length&&t[0].cue.pre){var n=e.findEventIndex(t[0].identifier);this.setSchedulePosition(n)}else if(a>=0||!this.primaryLive){var s=this.timelinePos=a>0?a:0,o=e.findItemIndexAtTime(s);this.setSchedulePosition(o)}}else if(i&&!this.playingItem){var l=e.findItemIndex(i);this.setSchedulePosition(l)}}}},{key:"advanceAfterAssetEnded",value:function(e,t,r){var i=r+1;if(e.isAssetPastPlayoutLimit(i)||e.assetList[i].error){var a=this.schedule.items;if(a){var n=t+1;if(n>=a.length)return void this.setSchedulePosition(-1);var s=e.resumeTime;this.timelinePos<s&&(this.timelinePos=s,this.checkBuffer()),this.setSchedulePosition(n)}}else this.setSchedulePosition(t,i)}},{key:"setScheduleToAssetAtTime",value:function(e,t){var r=this.schedule,i=t.parentIdentifier,a=r.getEvent(i);if(a){var n=r.findEventIndex(i),s=r.findAssetIndex(a,e);this.setSchedulePosition(n,s)}}},{key:"setSchedulePosition",value:function(e,t){var r=this.schedule.items;if(r&&!this.playbackDisabled){this.log("setSchedulePosition ".concat(e,", ").concat(t));var i=e>=0?r[e]:null,a=this.playingItem,n=this.playingLastItem;if(this.isInterstitial(a)){var s,o=a.event,l=this.playingAsset,u=null==l?void 0:l.identifier,c=u?this.getAssetPlayer(u):null;if(c&&u&&(!this.eventItemsMatch(a,i)||void 0!==t&&u!==(null==(s=o.assetList)?void 0:s[t].identifier))){var d,h=o.findAssetIndex(l);this.log("INTERSTITIAL_ASSET_ENDED ".concat(h+1,"/").concat(o.assetList.length," ").concat(Vs(l))),this.endedAsset=l,this.playingAsset=null,this.hls.trigger(M.INTERSTITIAL_ASSET_ENDED,{asset:l,assetListIndex:h,event:o,schedule:r.slice(0),scheduleIndex:e,player:c}),this.retreiveMediaSource(u,i),!c.media||null!=(d=this.detachedData)&&d.mediaSource||c.detachMedia()}if(!this.eventItemsMatch(a,i)&&(this.endedItem=a,this.playingItem=null,this.log("INTERSTITIAL_ENDED ".concat(o," ").concat(Ys(a))),o.hasPlayed=!0,this.hls.trigger(M.INTERSTITIAL_ENDED,{event:o,schedule:r.slice(0),scheduleIndex:e}),o.cue.once)){this.updateSchedule();var f=this.schedule.items;if(i&&f){var v=this.schedule.findItemIndex(i);this.advanceSchedule(v,f,t,a,n)}return}}this.advanceSchedule(e,r,t,a,n)}}},{key:"advanceSchedule",value:function(e,t,r,i,a){var n=this,s=e>=0?t[e]:null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach((function(t){var r=t.interstitial,i=n.schedule.findEventIndex(r.identifier);(i<e||i>e+1)&&n.clearInterstitial(r,s)})),this.isInterstitial(s)){this.timelinePos=Math.min(Math.max(this.timelinePos,s.start),s.end);var u=s.event;void 0===r&&(r=this.schedule.findAssetIndex(u,this.timelinePos));var c=this.waitingItem;this.assetsBuffered(s,o)||this.setBufferingItem(s);var d=this.preloadAssets(u,r);if(this.eventItemsMatch(s,c||i)||(this.waitingItem=s,this.log("INTERSTITIAL_STARTED ".concat(Ys(s)," ").concat(u.appendInPlace?"append in place":"")),this.hls.trigger(M.INTERSTITIAL_STARTED,{event:u,schedule:t.slice(0),scheduleIndex:e})),!u.assetListLoaded)return void this.log("Waiting for ASSET-LIST to complete loading ".concat(u));if(u.assetListLoader&&(u.assetListLoader.destroy(),u.assetListLoader=void 0),!o)return void this.log("Waiting for attachMedia to start Interstitial ".concat(u));this.waitingItem=this.endedItem=null,this.playingItem=s;var h=u.assetList[r];if(!h){var f=t[e+1],v=this.media;return f&&v&&!this.isInterstitial(f)&&v.currentTime<f.start&&(v.currentTime=this.timelinePos=f.start),void this.advanceAfterAssetEnded(u,e,r||0)}if(d||(d=this.getAssetPlayer(h.identifier)),null===d||d.destroyed){var g=u.assetList.length;this.warn("asset ".concat(r+1,"/").concat(g," player destroyed ").concat(u)),d=this.createAssetPlayer(u,h,r)}if(!this.eventItemsMatch(s,this.bufferingItem)&&u.appendInPlace&&this.isAssetBuffered(h))return;this.startAssetPlayer(d,r,t,e,o),this.shouldPlay&&Xs(d.media)}else null!==s?(this.resumePrimary(s,e,i),this.shouldPlay&&Xs(this.hls.media)):a&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(this.schedule.durations.primary,null))}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e,t;return null==(e=this.mediaSelection)||null==(t=e.main)?void 0:t.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}},{key:"resumePrimary",value:function(e,t,r){var i;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log("resuming ".concat(Ys(e))),null==(i=this.detachedData)||!i.mediaSource){var a=this.timelinePos;(a<e.start||a>=e.end)&&(a=this.getPrimaryResumption(e,t),this.timelinePos=a),this.attachPrimary(a,e)}if(r){var n=this.schedule.items;n&&(this.log("resumed ".concat(Ys(e))),this.hls.trigger(M.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var r=e.start;if(this.primaryLive){var i=this.primaryDetails;if(0===t)return this.hls.startPosition;if(i&&(r<i.fragmentStart||r>i.edge))return this.hls.liveSyncPosition||-1}return r}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:Er.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}},{key:"attachPrimary",value:function(e,t,r){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;var i=this.primaryMedia;if(i){var a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,i),r&&this.startLoadingPrimaryAt(e,r)),r||(this.timelinePos=e,this.startLoadingPrimaryAt(e,r))}}},{key:"startLoadingPrimaryAt",value:function(e,t){var r,i=this.hls;!i.loadingEnabled||!i.media||Math.abs(((null==(r=i.mainForwardBufferInfo)?void 0:r.start)||i.media.currentTime)-e)>.5?i.startLoad(e,t):i.bufferingEnabled||i.resumeBuffering()}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.schedule.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(M.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(M.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level){var r=this.hls.levels[t.level],i=q(q({},this.mediaSelection||this.altSelection),{},{main:r});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}}},{key:"onAudioTrackUpdated",value:function(e,t){var r=this.hls.audioTracks[t.id],i=this.mediaSelection;if(i){var a=q(q({},i),{},{audio:r});this.mediaSelection=a}else this.altSelection=q(q({},this.altSelection),{},{audio:r})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var r=this.hls.subtitleTracks[t.id],i=this.mediaSelection;if(i){var a=q(q({},i),{},{subtitles:r});this.mediaSelection=a}else this.altSelection=q(q({},this.altSelection),{},{subtitles:r})}},{key:"onAudioTrackSwitching",value:function(e,t){var r=At(t);this.playerQueue.forEach((function(e){return e.hls.setAudioOption(t)||e.hls.setAudioOption(r)}))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r=At(t);this.playerQueue.forEach((function(e){return e.hls.setSubtitleOption(t)||-1!==t.id&&e.hls.setSubtitleOption(r)}))}},{key:"onBufferCodecs",value:function(e,t){var r=t.tracks;r&&(this.requiredTracks=r)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var r=this.playingItem;if(r&&!this.itemsMatch(r,this.bufferingItem)&&!this.isInterstitial(r)){var i=this.timelinePos;this.bufferedPos=i,this.checkBuffer()}}},{key:"onBufferedToEnd",value:function(e){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var r=0;r<t.length;r++){var i=t[r];if(i.cue.post){var a,n=this.schedule.findEventIndex(i.identifier),s=null==(a=this.schedule.items)?void 0:a[n];this.isInterstitial(s)&&this.eventItemsMatch(s,this.bufferingItem)&&this.bufferedToItem(s,0);break}}this.bufferedPos=Number.MAX_VALUE}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var r=this.findItemIndex(t);this.setSchedulePosition(r+1)}else this.shouldPlay=!1}},{key:"updateItem",value:function(e,t){var r=this.schedule.items;return e&&r&&r[this.findItemIndex(e,t)]||null}},{key:"itemsMatch",value:function(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}},{key:"eventItemsMatch",value:function(e,t){var r;return!!t&&(e===t||e.event.identifier===(null==(r=t.event)?void 0:r.identifier))}},{key:"findItemIndex",value:function(e,t){return e?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(){var e=this.mediaSelection;e&&this.schedule.updateSchedule(e,[])}},{key:"checkBuffer",value:function(e){var t=this.schedule.items;if(t){var r=Er.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=r.len<1),this.updateBufferedPos(r.end,t,e)}}},{key:"updateBufferedPos",value:function(e,t,r){var i=this.schedule,a=this.bufferingItem;if(!(this.bufferedPos>e))if(1===t.length&&this.itemsMatch(t[0],a))this.bufferedPos=e;else{var n=this.playingItem,s=this.findItemIndex(n),o=i.findItemIndexAtTime(e);if(this.bufferedPos<e){var l,u,c=this.findItemIndex(a),d=Math.min(c+1,t.length-1),h=t[d];if((-1===o&&a&&e>=a.end||null!=(l=h.event)&&l.appendInPlace&&e+.01>=h.start)&&(o=d),d-s>1&&!1===(null==a||null==(u=a.event)?void 0:u.appendInPlace))return;if(this.bufferedPos=e,o>c&&o>s)this.bufferedToItem(h);else{var f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&h.start<f.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else r&&n&&!this.itemsMatch(n,a)&&(o===s?this.bufferedToItem(n):o===s+1&&this.bufferedToItem(t[o]))}}},{key:"assetsBuffered",value:function(e,t){var r=this;return 0!==e.event.assetList.length&&!e.event.assetList.some((function(e){var i=r.getAssetPlayer(e.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(t))}))}},{key:"setBufferingItem",value:function(e){var t=this,r=this.bufferingItem,i=this.schedule;if(this.itemsMatch(e,r))this.bufferingItem!==e&&(this.bufferingItem=e);else{var a=i.items,n=i.events;if(!a||!n)return r;var s=this.isInterstitial(e),o=this.getBufferingPlayer();if(this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos)),!this.playbackDisabled){var l=o?o.remaining:r?r.end-this.timelinePos:0;this.log("buffered to boundary ".concat(Ys(e))+(r?" (".concat(l.toFixed(2)," remaining)"):"")),s?e.event.assetList.forEach((function(e){var r=t.getAssetPlayer(e.identifier);r&&r.resumeBuffering()})):(this.hls.resumeBuffering(),this.playerQueue.forEach((function(e){return e.pauseBuffering()})))}this.hls.trigger(M.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:n.slice(0),schedule:a.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}return r}},{key:"bufferedToItem",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==r){this.bufferingAsset=null;var i=this.detachedData;if(i)if(i.mediaSource){var a=!0;this.attachPrimary(e.start,e,a)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),r=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(r)}},{key:"bufferedToEvent",value:function(e,t){var r=e.event,i=0===r.assetList.length&&!r.assetListLoader,a=r.cue.once;if(i||!a){var n=this.preloadAssets(r,t);if(null!=n&&n.interstitial.appendInPlace){var s=r.assetList[t],o=this.primaryMedia;s&&o&&this.bufferAssetPlayer(n,o)}}}},{key:"preloadAssets",value:function(e,t){var r=e.assetUrl,i=e.assetList.length,a=0===i&&!e.assetListLoader,n=e.cue.once;if(a){var s,o=e.timelineStart;if(e.appendInPlace){var l,u=this.playingItem;this.isInterstitial(u)||(null==u||null==(l=u.nextEvent)?void 0:l.identifier)!==e.identifier||this.flushFrontBuffer(o+.25)}var c=0;if(!this.playingItem&&this.primaryLive&&-1===(c=this.hls.startPosition)&&(c=this.hls.liveSyncPosition||0),c&&!e.cue.pre&&!e.cue.post){var d=c-o;d>0&&(s=Math.round(1e3*d)/1e3)}if(this.log("Load interstitial asset ".concat(t+1,"/").concat(r?1:i," ").concat(e).concat(s?" live-start: ".concat(c," start-offset: ").concat(s):"")),r)return this.createAsset(e,0,0,o,e.duration,r);var h=this.assetListLoader.loadAssetList(e,s);h&&(e.assetListLoader=h)}else if(!n&&i){for(var f=t;f<i;f++){var v=e.assetList[f],g=this.getAssetPlayerQueueIndex(v.identifier);-1!==g&&!this.playerQueue[g].destroyed||v.error||this.createAssetPlayer(e,v,f)}return this.getAssetPlayer(e.assetList[t].identifier)}return null}},{key:"flushFrontBuffer",value:function(e){var t=this,r=this.requiredTracks;r&&(this.log("Removing front buffer starting at ".concat(e)),Object.keys(r).forEach((function(r){t.hls.trigger(M.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:r})})))}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,r=0;r<t.length;r++)if(e===t[r].assetId)return r;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var r=0;r<e.length;r++)if(e[r].media===t)return e[r];return null}},{key:"createAsset",value:function(e,t,r,i,a,n){var s={parentIdentifier:e.identifier,identifier:Bs(e,n,t),duration:a,startOffset:r,timelineStart:i,uri:n};return this.createAssetPlayer(e,s,t)}},{key:"createAssetPlayer",value:function(e,t,r){var i=this;this.log("create HLSAssetPlayer for ".concat(Vs(t)));var a=this.hls,n=a.userConfig,s=n.videoPreference,o=a.loadLevelObj||a.levels[a.currentLevel];(s||o)&&(s=W({},s),o.videoCodec&&(s.videoCodec=o.videoCodec),o.videoRange&&(s.allowedVideoRanges=[o.videoRange]));var l=a.audioTracks[a.audioTrack],u=a.subtitleTracks[a.subtitleTrack],c=0;if(this.primaryLive||e.appendInPlace){var d=this.timelinePos-t.timelineStart;if(d>1){var h=t.duration;h&&d<h&&(c=d)}}var f=t.identifier,v=q(q({},n),{},{autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:a.sessionId,assetPlayerId:f,abrEwmaDefaultEstimate:a.bandwidthEstimate,interstitialsController:void 0,startPosition:c,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:s,audioPreference:l||n.audioPreference,subtitlePreference:u||n.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(v.timelineOffset=t.timelineStart));var g=v.cmcd;null!=g&&g.sessionId&&g.contentId&&(v.cmcd=W({},g,{contentId:Fs(t.uri)})),this.getAssetPlayer(f)&&this.warn("Duplicate date range identifier ".concat(e," and asset ").concat(f));var p=new js(this.HlsPlayerClass,v,e,t);this.playerQueue.push(p),e.assetList[r]=t;var m=function(a){if(a.live){var n=new Error("Interstitials MUST be VOD assets ".concat(e)),s={fatal:!0,type:P.OTHER_ERROR,details:C.INTERSTITIAL_ASSET_ITEM_ERROR,error:n};i.handleAssetItemError(s,e,i.schedule.findEventIndex(e.identifier),r,n.message)}else{var o=a.edge-a.fragmentStart,l=t.duration;(null===l||o>l)&&(i.log('Interstitial asset "'.concat(f,'" duration change ').concat(l," > ").concat(o)),t.duration=o,i.updateSchedule())}};p.on(M.LEVEL_UPDATED,(function(e,t){var r=t.details;return m(r)})),p.on(M.LEVEL_PTS_UPDATED,(function(e,t){var r=t.details;return m(r)}));p.on(M.BUFFER_CODECS,(function e(t,r){var a=i.getAssetPlayer(f);if(a&&r.tracks){a.off(M.BUFFER_CODECS,e),a.tracks=r.tracks;var n=i.primaryMedia;i.bufferingAsset===a.assetItem&&n&&!a.media&&i.bufferAssetPlayer(a,n)}}));var y=function(){var r,a=i.getAssetPlayer(f);if(i.log("buffered to end of asset ".concat(a)),a){var n=i.schedule.findEventIndex(e.identifier),s=e.findAssetIndex(t),o=s+1,l=null==(r=i.schedule.items)?void 0:r[n];if(i.isInterstitial(l))if(-1===s||e.isAssetPastPlayoutLimit(o)||e.assetList[o].error){var u,c=null==(u=i.schedule.items)?void 0:u[n+1];c&&i.bufferedToItem(c)}else i.bufferedToItem(l,o)}};p.on(M.BUFFERED_TO_END,y);var k=function(t){return function(){if(i.getAssetPlayer(f)){i.shouldPlay=!0;var r=i.schedule.findEventIndex(e.identifier);i.advanceAfterAssetEnded(e,r,t)}}};return p.once(M.MEDIA_ENDED,k(r)),p.once(M.PLAYOUT_LIMIT_REACHED,k(1/0)),p.on(M.ERROR,(function(t,a){var n=i.getAssetPlayer(f);if(a.details!==C.BUFFER_STALLED_ERROR)i.handleAssetItemError(a,e,i.schedule.findEventIndex(e.identifier),r,"Asset player error ".concat(a.error," ").concat(e));else if(null!=n&&n.media){var s=n.currentTime,o=n.duration-s;s&&e.appendInPlace&&o/n.media.playbackRate<.5?(i.log("Advancing buffer past end of asset ".concat(f," ").concat(e," at ").concat(n.media.currentTime)),y()):(i.warn("Stalled at ".concat(s," of ").concat(s+o," in asset ").concat(f," ").concat(e)),i.onTimeupdate(),i.checkBuffer(!0))}})),p.on(M.DESTROYING,(function(){if(i.getAssetPlayer(f)){var t=new Error("Asset player destroyed unexpectedly ".concat(f)),a={fatal:!0,type:P.OTHER_ERROR,details:C.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};i.handleAssetItemError(a,e,i.schedule.findEventIndex(e.identifier),r,t.message)}})),this.hls.trigger(M.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:r,event:e,player:p}),p}},{key:"clearInterstitial",value:function(e,t){var r=this;e.assetList.forEach((function(e){r.clearAssetPlayer(e.identifier,t)})),e.reset()}},{key:"clearAssetPlayer",value:function(e,t){var r=this.getAssetPlayerQueueIndex(e);if(-1!==r){this.log('clearAssetPlayer "'.concat(e,'" toSegment: ').concat(t?Ys(t):t));var i=this.playerQueue[r];this.transferMediaFromPlayer(i,t),this.playerQueue.splice(r,1),i.destroy()}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,r,i,a){var n=e.interstitial,s=e.assetItem,o=e.assetId,l=n.assetList.length,u=this.playingAsset;this.endedAsset=null,this.playingAsset=s,u&&u.identifier===o||(u&&(this.clearAssetPlayer(u.identifier,r[i]),delete u.error),this.log("INTERSTITIAL_ASSET_STARTED ".concat(t+1,"/").concat(l," ").concat(e)),this.hls.trigger(M.INTERSTITIAL_ASSET_STARTED,{asset:s,assetListIndex:t,event:n,schedule:r.slice(0),scheduleIndex:i,player:e})),this.bufferAssetPlayer(e,a)}},{key:"bufferAssetPlayer",value:function(e,t){var r,i,a=e.interstitial,n=e.assetItem,s=e.assetId,o=this.schedule.findEventIndex(a.identifier),l=null==(r=this.schedule.items)?void 0:r[o];if(l){this.setBufferingItem(l),this.bufferingAsset=n;var u=this.getBufferingPlayer();if(u!==e){var c=a.appendInPlace;if(!c||!1!==(null==u?void 0:u.interstitial.appendInPlace)){var d=(null==u?void 0:u.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(c&&n!==this.playingAsset){if(!e.tracks)return;if(d&&!ie(d,e.tracks)){var h=new Error('Asset "'.concat(s,"\" SourceBuffer tracks ('").concat(Object.keys(e.tracks),"') are not compatible with primary content tracks ('").concat(Object.keys(d),"')")),f={fatal:!0,type:P.OTHER_ERROR,details:C.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},v=a.findAssetIndex(n);return void this.handleAssetItemError(f,a,o,v,h.message)}}this.transferMediaTo(e,t)}}}}},{key:"handleAssetItemError",value:function(e,t,r,i,a){if(e.details!==C.BUFFER_STALLED_ERROR){var n=t.assetList[i]||null,s=null;if(n){var o=this.getAssetPlayerQueueIndex(n.identifier);s=this.playerQueue[o]||null}var l=this.schedule.items,u=W({},e,{fatal:!1,errorAction:Qt(!0),asset:n,assetListIndex:i,event:t,schedule:l,scheduleIndex:r,player:s});if(this.warn("Asset item error: ".concat(e.error)),this.hls.trigger(M.INTERSTITIAL_ASSET_ERROR,u),e.fatal){var c=new Error(a);n&&(this.playingAsset!==n&&this.clearAssetPlayer(n.identifier,null),n.error=c),t.assetList.some((function(e){return!e.error}))?t.appendInPlace&&(t.error=c):t.error=c,this.primaryFallback(t)}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,r=this.effectivePlayingItem;if(this.updateSchedule(),r){this.log('Fallback to primary from event "'.concat(e.identifier,'" start: ').concat(t," pos: ").concat(this.timelinePos," playing: ").concat(r?Ys(r):"<none>"," error: ").concat(e.error)),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t));var i=this.timelinePos;-1===i&&(i=this.hls.startPosition);var a=this.updateItem(r,i);if(this.itemsMatch(r,a))this.clearInterstitial(e,null);else{var n=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(n)}}else this.checkStart()}},{key:"onAssetListLoaded",value:function(e,t){var r,i=this,a=t.event,n=a.identifier,s=t.assetListResponse.ASSETS;if(this.schedule.hasEvent(n)){var o=a.timelineStart,l=a.duration,u=0;s.forEach((function(e,t){var r=parseFloat(e.DURATION);i.createAsset(a,t,u,o+u,r,e.URI),u+=r})),a.duration=u,this.log("Loaded asset-list with duration: ".concat(u," (was: ").concat(l,") ").concat(a));var c=this.waitingItem,d=(null==c?void 0:c.event.identifier)===n;this.updateSchedule();var h=null==(r=this.bufferingItem)?void 0:r.event;if(d){var f,v=this.schedule.findEventIndex(n),g=null==(f=this.schedule.items)?void 0:f[v];if(g){if(!this.playingItem&&this.timelinePos>g.end)if(this.schedule.findItemIndexAtTime(this.timelinePos)!==v)return a.error=new Error("Interstitial no longer within playback range ".concat(this.timelinePos," ").concat(a)),void this.primaryFallback(a);this.setBufferingItem(g)}this.setSchedulePosition(v)}else if((null==h?void 0:h.identifier)===n&&h.appendInPlace){var p=a.assetList[0],m=this.getAssetPlayer(p.identifier),y=this.primaryMedia;p&&m&&y&&this.bufferAssetPlayer(m,y)}}}},{key:"onError",value:function(e,t){switch(t.details){case C.ASSET_LIST_PARSING_ERROR:case C.ASSET_LIST_LOAD_ERROR:case C.ASSET_LIST_LOAD_TIMEOUT:var r=t.interstitial;r&&this.primaryFallback(r);break;case C.BUFFER_STALLED_ERROR:this.onTimeupdate(),this.checkBuffer(!0)}}}]),r}($),Zs=function(e){g(i,e);var r=n(i);function i(e,t,a){var n;return b(this,i),(n=r.call(this,e,t,a,"subtitle-stream-controller",H)).currentTrackId=-1,n.tracksBuffered=[],n.mainDetails=null,n.registerListeners(),n}return A(i,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),t(u(i.prototype),"onHandlerDestroying",this).call(this),this.mainDetails=null}},{key:"registerListeners",value:function(){t(u(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(M.LEVEL_LOADED,this.onLevelLoaded,this),e.on(M.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(M.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(M.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(M.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){t(u(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(M.LEVEL_LOADED,this.onLevelLoaded,this),e.off(M.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(M.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(M.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(M.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e,t){this.stopLoad(),this.state=Fi,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"onManifestLoading",value:function(){t(u(i.prototype),"onManifestLoading",this).call(this),this.mainDetails=null}},{key:"onMediaDetaching",value:function(e,r){this.tracksBuffered=[],t(u(i.prototype),"onMediaDetaching",this).call(this,e,r)}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var r=t.frag,i=t.success;if(ge(r)&&(this.fragPrevious=r),this.state=Fi,i){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var n,s=r.start,o=0;o<a.length;o++)if(s>=a[o].start&&s<=a[o].end){n=a[o];break}var l=r.start+r.duration;n?n.end=l:(n={start:s,end:l},a.push(n)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var a=i-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach((function(e){for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}})),this.fragmentTracker.removeFragmentsInRange(r,a,H)}}},{key:"onError",value:function(e,t){var r=t.frag;(null==r?void 0:r.type)===H&&(t.details===C.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Oi&&(this.state=Fi))}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks;this.levels&&Cn(this.levels,i)?this.levels=i.map((function(e){return new kt(e)})):(this.tracksBuffered=[],this.levels=i.map((function(e){var t=new kt(e);return r.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,H),this.fragPrevious=null,this.mediaBuffer=null)}},{key:"onSubtitleTrackSwitch",value:function(e,t){var r;if(this.currentTrackId=t.id,null!=(r=this.levels)&&r.length&&-1!==this.currentTrackId){var i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==Oi&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var r,i=this.currentTrackId,a=this.levels,n=t.details,s=t.id;if(a){var o=a[s];if(!(s>=a.length)&&o){this.log("Subtitle track ".concat(s," loaded [").concat(n.startSN,",").concat(n.endSN,"]").concat(n.lastPartSn?"[part-".concat(n.lastPartSn,"-").concat(n.lastPartIndex,"]"):"",",duration:").concat(n.totalduration)),this.mediaBuffer=this.mediaBufferTimeRanges;if(n.live||null!=(r=o.details)&&r.live){var l=this.mainDetails;if(n.deltaUpdateFailed||!l)return;var u,c=l.fragments[0];if(o.details)0===this.alignPlaylists(n,o.details,null==(u=this.levelLastLoaded)?void 0:u.details)&&c&&Li(n,c.start);else n.hasProgramDateTime&&l.hasProgramDateTime?(Ci(n,l),n.fragmentStart):c&&Li(n,c.start)}if(o.details=n,this.levelLastLoaded=o,s===i)if(this.hls.trigger(M.SUBTITLE_TRACK_UPDATED,{details:n,id:s,groupId:t.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===Fi)Ct(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}else this.warn("Subtitle tracks were reset while loading level ".concat(s))}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this,r=e.frag,i=e.payload,a=r.decryptdata,n=this.hls;if(!this.fragContextChanged(r)&&i&&i.byteLength>0&&null!=a&&a.key&&a.iv&&Pr(a.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),a.key.buffer,a.iv.buffer,Cr(a.method)).catch((function(e){throw n.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(e){var t=performance.now();n.trigger(M.FRAG_DECRYPTED,{frag:r,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){t.warn("".concat(e.name,": ").concat(e.message)),t.state=Fi}))}}},{key:"doTick",value:function(){if(this.media){if(this.state===Fi){var e=this.currentTrackId,t=this.levels,r=null==t?void 0:t[e];if(!r||!t.length||!r.details)return;if(this.waitForLive(r))return;var i=this.config,a=this.getLoadPosition(),n=Er.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,i.maxBufferHole),s=n.end,o=n.len,l=r.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;var u=l.fragments,c=u.length,d=l.edge,h=null,f=this.fragPrevious;if(s<d){var v=i.maxFragLookUpTolerance,g=s>d-v?0:v;!(h=Ct(f,u,Math.max(u[0].start,s),g))&&f&&f.start<u[0].start&&(h=u[0])}else h=u[c-1];if(!(h=this.filterReplacedPrimary(h,r.details)))return;var p=u[h.sn-l.startSN-1];if(p&&p.cc===h.cc&&this.fragmentTracker.getState(p)===Zt&&(h=p),this.fragmentTracker.getState(h)===Zt){var m=this.mapToInitFragWhenRequired(h);m&&this.loadFragment(m,r,s)}}}else this.state=Fi}},{key:"loadFragment",value:function(e,r,a){ge(e)?t(u(i.prototype),"loadFragment",this).call(this,e,r,a):this._loadInitSegment(e,r)}},{key:"mediaBufferTimeRanges",get:function(){return new Js(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(qi),Js=A((function e(t){b(this,e),this.buffered=void 0;var r=function(e,r,i){if((r>>>=0)>i-1)throw new DOMException("Failed to execute '".concat(e,"' on 'TimeRanges': The index provided (").concat(r,") is greater than the maximum bound (").concat(i,")"));return t[r][e]};this.buffered={get length(){return t.length},end:function(e){return r("end",e,t.length)},start:function(e){return r("start",e,t.length)}}})),eo={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},to=function(e){return String.fromCharCode(eo[e]||e)},ro=15,io=100,ao={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},no={17:2,18:4,21:6,22:8,23:10,19:13,20:15},so={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},oo={25:2,26:4,29:6,30:8,31:10,27:13,28:15},lo=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],uo=function(){function e(){b(this,e),this.time=null,this.verboseLevel=0}return A(e,[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var r="function"==typeof t?t():t;te.log("".concat(this.time," [").concat(e,"] ").concat(r))}}}]),e}(),co=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},ho=function(){function e(){b(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}return A(e,[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}]),e}(),fo=function(){function e(){b(this,e),this.uchar=" ",this.penState=new ho}return A(e,[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}]),e}(),vo=function(){function e(t){b(this,e),this.chars=[],this.pos=0,this.currPenState=new ho,this.cueStartTime=null,this.logger=void 0;for(var r=0;r<io;r++)this.chars.push(new fo);this.logger=t}return A(e,[{key:"equals",value:function(e){for(var t=0;t<io;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<io;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<io;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>io&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=io)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){var t=this;e>=144&&this.backSpace();var r=to(e);this.pos>=io?this.logger.log(0,(function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"})):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t<io;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,r=0;r<io;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}]),e}(),go=function(){function e(t){b(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var r=0;r<ro;r++)this.rows.push(new vo(t));this.logger=t}return A(e,[{key:"reset",value:function(){for(var e=0;e<ro;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,r=0;r<ro;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<ro;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<ro;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){this.logger.log(2,(function(){return"pacData = "+St(e)}));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<ro;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var n=a.rows[i].cueStartTime,s=this.logger.time;if(null!==n&&null!==s&&n<s)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(a.rows[i+o])}}this.currRow=t;var l=this.rows[this.currRow];if(null!==e.indent){var u=e.indent,c=Math.max(u-1,0);l.setCursor(e.indent),e.color=l.chars[c].penState.foreground}var d={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(d)}},{key:"setBkgData",value:function(e){this.logger.log(2,(function(){return"bkgData = "+St(e)})),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){var e=this;if(null!==this.nrRollUpRows){this.logger.log(1,(function(){return e.getDisplayText()}));var t=this.currRow+1-this.nrRollUpRows,r=this.rows.splice(t,1)[0];r.clear(),this.rows.splice(this.currRow,0,r),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],r="",i=-1,a=0;a<ro;a++){var n=this.rows[a].getTextString();n&&(i=a+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),po=function(){function e(t,r,i){b(this,e),this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new go(i),this.nonDisplayedMemory=new go(i),this.lastOutputScreen=new go(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}return A(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(function(){return"MODE="+e})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(function(){return i+": "+t.writeScreen.getDisplayText(!0)})),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,(function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)})),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){var e=this;if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,(function(){return"DISP: "+e.displayedMemory.getDisplayText()}))}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+St(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}]),e}(),mo=function(){function e(t,r,i){b(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new uo;this.channels=[null,new po(t,r,a),new po(t+1,i,a)]}return A(e,[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var r=this;this.logger.time=e;for(var i=function(e){var i=127&t[e],a=127&t[e+1],n=!1,s=null;if(0===i&&0===a)return"continue";r.logger.log(3,(function(){return"["+co([t[e],t[e+1]])+"] -> ("+co([i,a])+")"}));var o=r.cmdHistory;if(i>=16&&i<=31){if(function(e,t,r){return r.a===e&&r.b===t}(i,a,o))return yo(null,null,o),r.logger.log(3,(function(){return"Repeated command ("+co([i,a])+") is dropped"})),"continue";yo(i,a,r.cmdHistory),(n=r.parseCmd(i,a))||(n=r.parseMidrow(i,a)),n||(n=r.parsePAC(i,a)),n||(n=r.parseBackgroundAttributes(i,a))}else yo(null,null,o);if(!n&&(s=r.parseChars(i,a))){var l=r.currentChannel;if(l&&l>0)r.channels[l].insertChars(s);else r.logger.log(2,"No channel found yet. TEXT-MODE?")}n||s||r.logger.log(2,(function(){return"Couldn't parse cleaned data "+co([i,a])+" orig: "+co([t[e],t[e+1]])}))},a=0;a<t.length;a+=2)i(a)}},{key:"parseCmd",value:function(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;var r=20===e||21===e||23===e?1:2,i=this.channels[r];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=r,!0}},{key:"parseMidrow",value:function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,(function(){return"MIDROW ("+co([e,t])+")"})),!0)}return!1}},{key:"parsePAC",value:function(e,t){var r;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var i=e<=23?1:2;r=t>=64&&t<=95?1===i?ao[e]:so[e]:1===i?no[e]:oo[e];var a=this.channels[i];return!!a&&(a.setPAC(this.interpretPAC(r,t)),this.currentChannel=i,!0)}},{key:"interpretPAC",value:function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}},{key:"parseChars",value:function(e,t){var r,i,a=null,n=null;(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19)?(i=17===n?t+80:18===n?t+112:t+144,this.logger.log(2,(function(){return"Special char '"+to(i)+"' in channel "+r})),a=[i]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]);return a&&this.logger.log(3,(function(){return"Char codes = "+co(a).join(",")})),a}},{key:"parseBackgroundAttributes",value:function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=lo[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(i),!0}},{key:"reset",value:function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}yo(null,null,this.cmdHistory)}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}}}]),e}();function yo(e,t,r){r.a=e,r.b=t}var ko=function(){if(null!=Nr&&Nr.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){return r(t,e)}function a(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var s in n)e[s]=n[s]}return e}function n(t,n,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,d=t,h=n,f=s,v=null,g="",p=!0,m="auto",y="start",k=50,E="middle",T=50,S="middle";Object.defineProperty(o,"id",a({},l,{get:function(){return u},set:function(e){u=""+e}})),Object.defineProperty(o,"pauseOnExit",a({},l,{get:function(){return c},set:function(e){c=!!e}})),Object.defineProperty(o,"startTime",a({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",a({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",a({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",a({},l,{get:function(){return v},set:function(e){v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",a({},l,{get:function(){return g},set:function(t){var i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",a({},l,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",a({},l,{get:function(){return m},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",a({},l,{get:function(){return y},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",a({},l,{get:function(){return k},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");k=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",a({},l,{get:function(){return E},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",a({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",a({},l,{get:function(){return S},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),o.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}(),Eo=function(){function e(){b(this,e)}return A(e,[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}]),e}();function To(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var So=function(){function e(){b(this,e),this.values=Object.create(null)}return A(e,[{key:"set",value:function(e,t){this.get(e)||""===t||(this.values[e]=t)}},{key:"get",value:function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}},{key:"has",value:function(e){return e in this.values}},{key:"alt",value:function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}]),e}();function bo(e,t,r,i){var a=i?e.split(i):[e];for(var n in a)if("string"==typeof a[n]){var s=a[n].split(r);if(2===s.length)t(s[0],s[1])}}var Lo=new ko(0,0,""),Ao="middle"===Lo.align?"middle":"center";function Ro(e,t,r){var i=e;function a(){var t=To(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(){e=e.replace(/^\s+/,"")}if(n(),t.startTime=a(),n(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),n(),t.endTime=a(),n(),function(e,t){var i=new So;bo(e,(function(e,t){var a;switch(e){case"region":for(var n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),i.integer(e,a[0]),i.percent(e,a[0])&&i.set("snapToLines",!1),i.alt(e,a[0],["auto"]),2===a.length&&i.alt("lineAlign",a[1],["start",Ao,"end"]);break;case"position":a=t.split(","),i.percent(e,a[0]),2===a.length&&i.alt("positionAlign",a[1],["start",Ao,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",Ao,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var a=i.get("line","auto");"auto"===a&&-1===Lo.line&&(a=-1),t.line=a,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",Ao);var n=i.get("position","auto");"auto"===n&&50===Lo.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t)}function Io(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var wo=function(){function e(){b(this,e),this.state="INITIAL",this.buffer="",this.decoder=new Eo,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}return A(e,[{key:"parse",value:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=Io(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(null==a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var n=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(n?n=!1:i=r(),t.state){case"HEADER":/:/.test(i)?bo(i,(function(e,t){}),/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new ko(0,0,""),t.state="CUE",-1===i.indexOf("--\x3e")){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Ro(i,t.cue,t.regionList)}catch(o){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==i.indexOf("--\x3e");if(!i||s&&(n=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=i;continue;case"BADCUE":i||(t.state="ID")}}}catch(o){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}]),e}(),Do=/\r\n|\n\r|\n|\r/g,_o=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return e.slice(r,r+t.length)===t};function xo(e,t,r){return Fs(e.toString())+Fs(t.toString())+Fs(r)}function Po(e,t,r,i,a,n,s){var o,l=new wo,u=ae(new Uint8Array(e)).trim().replace(Do,"\n").split("\n"),c=[],d=t?function(e){return dn(e,cn,1/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1))}(t.baseTime,t.timescale):0,h="00:00.000",f=0,v=0,g=!0;l.oncue=function(e){var n=r[i],s=r.ccOffset,l=(f-d)/9e4;if(null!=n&&n.new&&(void 0!==v?s=r.ccOffset=n.start:function(e,t,r){var i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(n=a)&&n.new;){var n;e.ccOffset+=i.start-a.start,i.new=!1,a=e[(i=a).prevCC]}e.presentationOffset=r}(r,i,l)),l){if(!t)return void(o=new Error("Missing initPTS for VTT MPEGTS"));s=l-r.presentationOffset}var u=e.endTime-e.startTime,h=mn(9e4*(e.startTime+s-v),9e4*a)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+u,0);var g=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(g)),e.id||(e.id=xo(e.startTime,e.endTime,g)),e.endTime>0&&c.push(e)},l.onparsingerror=function(e){o=e},l.onflush=function(){o?s(o):n(c)},u.forEach((function(e){if(g){if(_o(e,"X-TIMESTAMP-MAP=")){g=!1,e.slice(16).split(",").forEach((function(e){_o(e,"LOCAL:")?h=e.slice(6):_o(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))}));try{v=function(e){var t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(D(t)&&D(r)&&D(i)&&D(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:".concat(e));return t+=1e3*r,t+=6e4*i,t+36e5*a}(h)/1e3}catch(t){o=t}return}""===e&&(g=!1)}l.parse(e+"\n")})),l.flush()}var Co="stpp.ttml.im1t",Mo=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Oo=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Fo={left:"start",center:"center",right:"end",start:"start",end:"end"};function No(e,t,r,i){var a=we(new Uint8Array(e),["mdat"]);if(0!==a.length){var n=a.map((function(e){return ae(e)})),s=function(e,t){return dn(e,t,1/(arguments.length>2&&void 0!==arguments[2]?arguments[2]:1),arguments.length>3&&void 0!==arguments[3]&&arguments[3])}(t.baseTime,1,t.timescale);try{n.forEach((function(e){return r(function(e,t){var r=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(i).reduce((function(e,t){return e[t]=r.getAttribute("ttp:".concat(t))||i[t],e}),{}),n="preserve"!==r.getAttribute("xml:space"),s=Bo(Uo(r,"styling","style")),o=Bo(Uo(r,"layout","region")),l=Uo(r,"body","[begin]");return[].map.call(l,(function(e){var r=Go(e,n);if(!r||!e.hasAttribute("begin"))return null;var i=Vo(e.getAttribute("begin"),a),l=Vo(e.getAttribute("dur"),a),u=Vo(e.getAttribute("end"),a);if(null===i)throw Ko(e);if(null===u){if(null===l)throw Ko(e);u=i+l}var c=new ko(i-t,u-t,r);c.id=xo(c.startTime,c.endTime,c.text);var d=function(e,t,r){var i="http://www.w3.org/ns/ttml#styling",a=null,n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;s&&r.hasOwnProperty(s)&&(a=r[s]);return n.reduce((function(r,n){var s=Ho(t,i,n)||Ho(e,i,n)||Ho(a,i,n);return s&&(r[n]=s),r}),{})}(o[e.getAttribute("region")],s[e.getAttribute("style")],s),h=d.textAlign;if(h){var f=Fo[h];f&&(c.lineAlign=f),c.align=h}return W(c,d),c})).filter((function(e){return null!==e}))}(e,s))}))}catch(o){i(o)}}else i(new Error("Could not parse IMSC1 mdat"))}function Uo(e,t,r){var i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function Bo(e){return e.reduce((function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function Go(e,t){return[].slice.call(e.childNodes).reduce((function(e,r,i){var a;return"br"===r.nodeName&&i?e+"\n":null!=(a=r.childNodes)&&a.length?Go(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent}),"")}function Ho(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function Ko(e){return new Error("Could not parse ttml timestamp ".concat(e))}function Vo(e,t){if(!e)return null;var r=To(e);return null===r&&(Mo.test(e)?r=function(e,t){var r=Mo.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):Oo.test(e)&&(r=function(e,t){var r=Oo.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}var jo=function(){function e(t,r){b(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=r}return A(e,[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}]),e}(),Wo=function(){function e(t){b(this,e),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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},t.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(M.MANIFEST_LOADING,this.onManifestLoading,this),t.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(M.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(M.FRAG_LOADING,this.onFragLoading,this),t.on(M.FRAG_LOADED,this.onFragLoaded,this),t.on(M.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(M.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(M.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(M.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this)}return A(e,[{key:"destroy",value:function(){var e=this.hls;e.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(M.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(M.FRAG_LOADING,this.onFragLoading,this),e.off(M.FRAG_LOADED,this.onFragLoaded,this),e.off(M.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(M.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(M.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(M.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}},{key:"initCea608Parsers",value:function(){var e=new jo(this,"textTrack1"),t=new jo(this,"textTrack2"),r=new jo(this,"textTrack3"),i=new jo(this,"textTrack4");this.cea608Parser1=new mo(1,e,t),this.cea608Parser2=new mo(3,r,i)}},{key:"addCues",value:function(e,t,r,i,a){for(var n,s,o,l,u=!1,c=a.length;c--;){var d=a[c],h=(n=d[0],s=d[1],o=t,l=r,Math.min(s,l)-Math.max(n,o));if(h>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],r),u=!0,h/(r-t)>.5))return}if(u||a.push([t,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[e];this.Cues.newCue(f,t,r,i)}else{var v=this.Cues.newCue(null,t,r,i);this.hls.trigger(M.CUES_PARSED,{type:"captions",cues:v,track:e})}}},{key:"onInitPtsFound",value:function(e,t){var r=this,i=t.frag,a=t.id,n=t.initPTS,s=t.timescale,o=this.unparsedVttFrags;a===B&&(this.initPTS[i.cc]={baseTime:n,timescale:s}),o.length&&(this.unparsedVttFrags=[],o.forEach((function(e){r.onFragLoaded(M.FRAG_LOADED,e)})))}},{key:"getExistingTrack",value:function(e,t){var r=this.media;if(r)for(var i=0;i<r.textTracks.length;i++){var a=r.textTracks[i];if(qo(a,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return a}return null}},{key:"createCaptionsTrack",value:function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}},{key:"createNativeTrack",value:function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,a=t[e],n=a.label,s=a.languageCode,o=this.getExistingTrack(n,s);if(o)r[e]=o,Ps(r[e]),_s(r[e],i);else{var l=this.createTextTrack("captions",n,s);l&&(l[e]=!0,r[e]=l)}}}},{key:"createNonNativeTrack",value:function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(M.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}}},{key:"createTextTrack",value:function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var r=!!t.transferMedia;if(this.media=null,!r){var i=this.captionsTracks;Object.keys(i).forEach((function(e){Ps(i[e]),delete i[e]})),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)Ps(t[r])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var r=this,i=t.subtitleTracks||[],a=i.some((function(e){return e.textCodec===Co}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){if(Cn(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var n=this.media,s=n?Ms(n.textTracks):null;if(this.tracks.forEach((function(e,t){var i;if(s){for(var a=null,n=0;n<s.length;n++)if(s[n]&&qo(s[n],e)){a=s[n],s[n]=null;break}a&&(i=a)}if(i)Ps(i);else{var o=Yo(e);(i=r.createTextTrack(o,e.name,e.lang))&&(i.mode="disabled")}i&&r.textTracks.push(i)})),null!=s&&s.length){var o=s.filter((function(e){return null!==e})).map((function(e){return e.label}));o.length&&this.hls.logger.warn("Media element contains unused subtitle tracks: ".concat(o.join(", "),". Replace media element for each source to clear TextTracks and captions menu."))}}else if(this.tracks.length){var l=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(M.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}}},{key:"onManifestLoaded",value:function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var i="textTrack".concat(t[1]),a=r.captionsProperties[i];a&&(a.label=e.name,e.lang&&(a.languageCode=e.lang),a.media=e)}}))}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===B){var r,i,a=this.cea608Parser1,n=this.cea608Parser2,s=this.lastSn,o=t.frag,l=o.cc,u=o.sn,c=null!=(r=null==(i=t.part)?void 0:i.index)?r:-1;a&&n&&(u!==s+1||u===s&&c!==this.lastPartIndex+1||l!==this.lastCc)&&(a.reset(),n.reset()),this.lastCc=l,this.lastSn=u,this.lastPartIndex=c}}},{key:"onFragLoaded",value:function(e,t){var r=t.frag,i=t.payload;if(r.type===H)if(i.byteLength){var a=r.decryptdata,n="stats"in t;if(null==a||!a.encrypted||n){var s=this.tracks[r.level],o=this.vttCCs;o[r.cc]||(o[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),s&&s.textCodec===Co?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(M.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var r=this,i=this.hls;No(t,this.initPTS[e.cc],(function(t){r._appendCues(t,e.level),i.trigger(M.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){i.logger.log("Failed to parse IMSC1: ".concat(t)),i.trigger(M.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}},{key:"_parseVTTs",value:function(e){var t,r=this,i=e.frag,a=e.payload,n=this.initPTS,s=this.unparsedVttFrags,o=n.length-1;if(n[i.cc]||-1!==o){var l=this.hls;Po(null!=(t=i.initSegment)&&t.data?Ue(i.initSegment.data,new Uint8Array(a)).buffer:a,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(function(e){r._appendCues(e,i.level),l.trigger(M.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})}),(function(t){var n="Missing initPTS for VTT MPEGTS"===t.message;n?s.push(e):r._fallbackToIMSC1(i,a),l.logger.log("Failed to parse VTT cue: ".concat(t)),n&&o>i.cc||l.trigger(M.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})}))}else s.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||No(t,this.initPTS[e.cc],(function(){i.textCodec=Co,r._parseIMSC1(e,t)}),(function(){i.textCodec="wvtt"}))}},{key:"_appendCues",value:function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||"disabled"===i.mode)return;e.forEach((function(e){return xs(i,e)}))}else{var a=this.tracks[t];if(!a)return;var n=a.default?"default":"subtitles"+t;r.trigger(M.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===H&&this.onFragLoaded(M.FRAG_LOADED,t)}},{key:"onSubtitleTracksCleared",value:function(){this.tracks=[],this.captionsTracks={}}},{key:"onFragParsingUserdata",value:function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var r=t.frag,i=t.samples;if(r.type!==B||"NONE"!==this.closedCaptionsForLevel(r))for(var a=0;a<i.length;a++){var n=i[a].bytes;if(n){this.cea608Parser1||this.initCea608Parsers();var s=this.extractCea608Data(n);this.cea608Parser1.addData(i[a].pts,s[0]),this.cea608Parser2.addData(i[a].pts,s[1])}}}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,a=t.endOffsetSubtitles,n=t.type,s=this.media;if(s&&!(s.currentTime<i)){if(!n||"video"===n){var o=this.captionsTracks;Object.keys(o).forEach((function(e){return Cs(o[e],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==a){var l=this.textTracks;Object.keys(l).forEach((function(e){return Cs(l[e],r,a)}))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],r=31&e[0],i=2,a=0;a<r;a++){var n=e[i++],s=127&e[i++],o=127&e[i++];if(0!==s||0!==o)if(0!=(4&n)){var l=3&n;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t}}]),e}();function Yo(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function qo(e,t){return!!e&&e.kind===Yo(t)&&On(t,e)}var $o=/\s/,zo={newCue:function(e,t,r,i){for(var a,n,s,o,l,u=[],c=self.VTTCue||self.TextTrackCue,d=0;d<i.rows.length;d++)if(s=!0,o=0,l="",!(a=i.rows[d]).isEmpty()){for(var h,f=0;f<a.chars.length;f++)$o.test(a.chars[f].uchar)&&s?o++:(l+=a.chars[f].uchar,s=!1);a.cueStartTime=t,t===r&&(r+=1e-4),o>=16?o--:o++;var v=Io(l.trim()),g=xo(t,r,v);null!=e&&null!=(h=e.cues)&&h.getCueById(g)||((n=new c(t,r,v)).id=g,n.line=d+1,n.align="left",n.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(n))}return e&&u.length&&(u.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),u.forEach((function(t){return xs(e,t)}))),u}};var Xo=/(\d+)-(\d+)\/(\d+)/,Qo=function(){function e(t){b(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Zo,this.controller=new self.AbortController,this.stats=new ce}return A(e,[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var n=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(W({},e.headers))};e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return r}(e,this.controller.signal),s="arraybuffer"===e.responseType,o=s?"byteLength":"length",l=t.loadPolicy,u=l.maxTimeToFirstByteMs,c=l.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=u&&D(u)?u:c,this.requestTimeout=self.setTimeout((function(){i.callbacks&&(i.abortInternal(),i.callbacks.onTimeout(a,e,i.response))}),t.timeout),(Rn(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(r){var n;i.response=i.loader=r;var o=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=c,i.requestTimeout=self.setTimeout((function(){i.callbacks&&(i.abortInternal(),i.callbacks.onTimeout(a,e,i.response))}),c-(o-a.loading.start)),!r.ok){var l=r.status,u=r.statusText;throw new Jo(u||"fetch, bad network response",l,r)}a.loading.first=o,a.total=function(e){var t=e.get("Content-Range");if(t){var r=function(e){var t=Xo.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(D(r))return r}var i=e.get("Content-Length");if(i)return parseInt(i)}(r.headers)||a.total;var d=null==(n=i.callbacks)?void 0:n.onProgress;return d&&D(t.highWaterMark)?i.loadProgressively(r,a,e,t.highWaterMark,d):s?r.arrayBuffer():"json"===e.responseType?r.json():r.text()})).then((function(r){var n,s,l=i.response;if(!l)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var u=r[o];u&&(a.loaded=a.total=u);var c={url:l.url,data:r,code:l.status},d=null==(n=i.callbacks)?void 0:n.onProgress;d&&!D(t.highWaterMark)&&d(a,e,r,l),null==(s=i.callbacks)||s.onSuccess(c,a,e,l)})).catch((function(t){var r;if(self.clearTimeout(i.requestTimeout),!a.aborted){var n=t&&t.code||0,s=t?t.message:null;null==(r=i.callbacks)||r.onError({code:n,text:s},e,t?t.details:null,a)}}))}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4?arguments[4]:void 0,n=new zi,s=e.body.getReader(),o=function o(){return s.read().then((function(s){if(s.done)return n.dataLength&&a(t,r,n.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return t.loaded+=u,u<i||n.dataLength?(n.push(l),n.dataLength>=i&&a(t,r,n.flush().buffer,e)):a(t,r,l.buffer,e),o()})).catch((function(){return Promise.reject()}))};return o()}}]),e}();function Zo(e,t){return new self.Request(e.url,t)}var Jo=function(e){g(r,e);var t=n(r);function r(e,i,a){var n;return b(this,r),(n=t.call(this,e)).code=void 0,n.details=void 0,n.code=i,n.details=a,n}return A(r)}(i(Error)),el=/^age:\s*[\d.]+\s*$/im,tl=function(){function e(t){b(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new ce,this.retryDelay=0}return A(e,[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0,a.aborted=!1;var n=this.xhrSetup;n?Promise.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return n(i,r.url)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),n(i,r.url)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){var n;null==(n=e.callbacks)||n.onError({code:i.status,text:t.message},r,i,a)})):this.openAndSendXhr(i,r,t)}}},{key:"openAndSendXhr",value:function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=t.headers,a=r.loadPolicy,n=a.maxTimeToFirstByteMs,s=a.maxLoadTimeMs;if(i)for(var o in i)e.setRequestHeader(o,i[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&D(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var n=t.status,s="text"===t.responseType?t.responseText:null;if(n>=200&&n<300){var o=null!=s?s:t.response;if(null!=o){var l,u;r.loading.end=Math.max(self.performance.now(),r.loading.first);var c="arraybuffer"===t.responseType?o.byteLength:o.length;r.loaded=r.total=c,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);var d=null==(l=this.callbacks)?void 0:l.onProgress;d&&d(r,e,o,t);var h={url:t.responseURL,data:o,code:n};return void(null==(u=this.callbacks)||u.onSuccess(h,r,e,t))}}var f,v=a.loadPolicy.errorRetry;if(Kt(v,r.retry,!1,{url:e.url,data:void 0,code:n}))this.retry(v);else te.error("".concat(n," while loading ").concat(e.url)),null==(f=this.callbacks)||f.onError({code:n,text:t.statusText},e,t,r)}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(Kt(e,this.stats.retry,!0))this.retry(e);else{var t;te.warn("timeout while loading ".concat(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}}},{key:"retry",value:function(e){var t=this.context,r=this.stats;this.retryDelay=Gt(e,r.retry),r.retry++,te.warn("".concat(status?"HTTP Status "+status:"Timeout"," while loading ").concat(null==t?void 0:t.url,", retrying ").concat(r.retry,"/").concat(e.maxNumRetry," in ").concat(this.retryDelay,"ms")),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}},{key:"getCacheAge",value:function(){var e=null;if(this.loader&&el.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp("^".concat(e,":\\s*[\\d.]+\\s*$"),"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}]),e}(),rl=q(q({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:tl,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:xt,bufferController:Hn,capLevelController:jn,errorController:Xt,fpsController:Ds,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Zr,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:zo,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:Zs,subtitleTrackController:Os,timelineController:Wo,audioStreamController:xn,audioTrackController:Fn,emeController:Is,cmcdController:bs,contentSteeringController:Ls,interstitialsController:Qs});function il(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var i=al(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(e){var n="".concat("level"===e?"playlist":e,"LoadPolicy"),s=void 0===t[n],o=[];a.forEach((function(r){var a="".concat(e,"Loading").concat(r),l=t[a];if(void 0!==l&&s){o.push(a);var u=i[n].default;switch(t[n]={default:u},r){case"TimeOut":u.maxLoadTimeMs=l,u.maxTimeToFirstByteMs=l;break;case"MaxRetry":u.errorRetry.maxNumRetry=l,u.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":u.errorRetry.retryDelayMs=l,u.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=l,u.timeoutRetry.maxRetryDelayMs=l}}})),o.length&&r.warn('hls.js config: "'.concat(o.join('", "'),'" setting(s) are deprecated, use "').concat(n,'": ').concat(St(t[n])))})),q(q({},i),t)}function al(e){return e&&"object"===c(e)?Array.isArray(e)?e.map(al):Object.keys(e).reduce((function(t,r){return t[r]=al(e[r]),t}),{}):e}function nl(e,t){var r=e.loader;r!==Qo&&r!==tl?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=Qo,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var sl=function(e){g(i,e);var r=n(i);function i(e,t){var a;return b(this,i),(a=r.call(this,"gap-controller",e.logger)).hls=null,a.fragmentTracker=null,a.media=null,a.mediaSource=void 0,a.nudgeRetry=0,a.stallReported=!1,a.stalled=null,a.moved=!1,a.seeking=!1,a.buffered={},a.lastCurrentTime=0,a.ended=0,a.waiting=0,a.onMediaPlaying=function(){a.ended=0,a.waiting=0},a.onMediaWaiting=function(){var e;null!=(e=a.media)&&e.seeking||(a.waiting=self.performance.now(),a.tick())},a.onMediaEnded=function(){var e;a.hls&&(a.ended=(null==(e=a.media)?void 0:e.currentTime)||1,a.hls.trigger(M.MEDIA_ENDED,{stalled:!1}))},a.hls=e,a.fragmentTracker=t,a.registerListeners(),a}return A(i,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"destroy",value:function(){t(u(i.prototype),"destroy",this).call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}},{key:"onMediaAttached",value:function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var r=this.media=t.media;$s(r,"playing",this.onMediaPlaying),$s(r,"waiting",this.onMediaWaiting),$s(r,"ended",this.onMediaEnded)}},{key:"onMediaDetaching",value:function(e,t){this.clearInterval();var r=this.media;r&&(zs(r,"playing",this.onMediaPlaying),zs(r,"waiting",this.onMediaWaiting),zs(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}},{key:"onBufferAppended",value:function(e,t){this.buffered=t.timeRanges}},{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}},{key:"tick",value:function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}}},{key:"poll",value:function(e,t){var r,i,a=null==(r=this.hls)?void 0:r.config;if(a){var n=this.media,s=this.stalled;if(n){var o=n.seeking,l=this.seeking&&!o,u=!this.seeking&&o,c=n.paused&&!o||n.ended||0===n.playbackRate;if(this.seeking=o,e!==t)return t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,a.nudgeOnVideoHole&&!c&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(u||l)l&&this.stallResolved(e);else{if(c)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(M.MEDIA_ENDED,{stalled:!1})));if(Er.getBuffered(n).length){var d=Er.bufferInfo(n,e,0),h=d.nextStart||0,f=this.fragmentTracker;if(o&&f&&this.hls){var v=ol(this.hls.inFlightFragments,e),g=d.len>2,p=!h||v||h-e>2&&!f.getPartialFragment(e);if(g||p)return;this.moved=!1}var m=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&f){if(!(d.len>0)&&!h)return;var y=Math.max(h,d.start||0)-e,k=!(null==m||!m.live)?2*m.targetduration:2,E=f.getPartialFragment(e);if(y>0&&(y<=k||E))return void(n.paused||this._trySkipBufferHole(E))}var T=a.detectStallWithCurrentTimeMs,S=self.performance.now(),b=this.waiting;if(null!==s){var L=S-s;if(!o&&(L>=T||b)&&this.hls){var A;if("ended"===(null==(A=this.mediaSource)?void 0:A.readyState)&&(null==m||!m.live)&&Math.abs(e-((null==m?void 0:m.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(M.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}var R=Er.bufferInfo(n,e,a.maxBufferHole);this._tryFixBufferStall(R,L)}else this.stalled=b>0&&S-b<T?b:S}else this.nudgeRetry=0}}}}},{key:"stallResolved",value:function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var r=self.performance.now()-t;this.log("playback not stuck anymore @".concat(e,", after ").concat(Math.round(r),"ms")),this.stallReported=!1,this.waiting=0,this.hls.trigger(M.STALL_RESOLVED,{})}}},{key:"nudgeOnVideoHole",value:function(e,t){var r,i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(r=this.buffered.audio)&&r.length&&i&&i.length>1&&e>i.end(0)){var a=Er.bufferedInfo(Er.timeRangesToArray(this.buffered.audio),e,0);if(a.len>1&&t>=a.start){var n=Er.timeRangesToArray(i),s=Er.bufferedInfo(n,t,0).bufferedIndex;if(s>-1&&s<n.length-1){var o=Er.bufferedInfo(n,e,0).bufferedIndex,l=n[s].end,u=n[s+1].start;if((-1===o||o>s)&&u-l<1&&e-l<2){var c=new Error("nudging playhead to flush pipeline after video hole. currentTime: ".concat(e," hole: ").concat(l," -> ").concat(u," buffered index: ").concat(o));this.warn(c.message),this.media.currentTime+=1e-6;var d=this.fragmentTracker.getPartialFragment(e)||void 0,h=Er.bufferInfo(this.media,e,0);this.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:c,reason:c.message,frag:d,buffer:h.len,bufferInfo:h})}}}}}},{key:"_tryFixBufferStall",value:function(e,t){var r,i,a=this.fragmentTracker,n=this.media,s=null==(r=this.hls)?void 0:r.config;if(n&&a&&s){var o=n.currentTime,l=null==(i=this.hls)?void 0:i.latestLevelDetails,u=a.getPartialFragment(o);if(u||null!=l&&l.live&&o<l.fragmentStart)if(this._trySkipBufferHole(u)||!this.media)return;var c=e.buffered;(c&&c.length>1&&e.len>s.maxBufferHole||e.nextStart&&e.nextStart-o<s.maxBufferHole)&&(t>1e3*s.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}}},{key:"_reportStall",value:function(e){var t=this.hls,r=this.media,i=this.stallReported,a=this.stalled;if(!i&&null!==a&&r&&t){this.stallReported=!0;var n=new Error("Playback stalling at @".concat(r.currentTime," due to low buffer (").concat(St(e),")"));this.warn(n.message),t.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len,bufferInfo:e,stalled:{start:a}})}}},{key:"_trySkipBufferHole",value:function(e){var t,r=this.fragmentTracker,i=this.media,a=null==(t=this.hls)?void 0:t.config;if(!i||!r||!a)return 0;var n=i.currentTime,s=Er.bufferInfo(i,n,0),o=n<s.start?s.start:s.nextStart;if(o&&this.hls){var l=s.len<=a.maxBufferHole,u=s.len>0&&s.len<1&&i.readyState<3,c=o-n;if(c>0&&(l||u)){if(c>a.maxBufferHole){var d=!1;if(0===n){var h=r.getAppendedFrag(0,B);h&&o<h.end&&(d=!0)}if(!d){var f=e||r.getAppendedFrag(n,B);if(f){var v;if(null==(v=this.hls.loadLevelObj)||!v.details)return 0;if(ol(this.hls.inFlightFragments,o))return 0;for(var g=!1,p=f.end;p<o;){var m=r.getPartialFragment(p);if(!m){g=!0;break}p+=m.duration}if(g)return 0}}}var y=Math.max(o+.05,n+.1);if(this.warn("skipping hole, adjusting currentTime from ".concat(n," to ").concat(y)),this.moved=!0,i.currentTime=y,null==e||!e.gap){var k=new Error("fragment loaded with buffer holes, seeking from ".concat(n," to ").concat(y));this.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:k,reason:k.message,frag:e||void 0,buffer:s.len,bufferInfo:s})}return y}}return 0}},{key:"_tryNudgeBuffer",value:function(e){var t=this.hls,r=this.media,i=this.nudgeRetry,a=null==t?void 0:t.config;if(!r||!a)return 0;var n=r.currentTime;if(this.nudgeRetry++,i<a.nudgeMaxRetry){var s=n+(i+1)*a.nudgeOffset,o=new Error("Nudging 'currentTime' from ".concat(n," to ").concat(s));this.warn(o.message),r.currentTime=s,t.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1,buffer:e.len,bufferInfo:e})}else{var l=new Error("Playhead still not moving while enough data buffered @".concat(n," after ").concat(a.nudgeMaxRetry," nudges"));this.error(l.message),t.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.BUFFER_STALLED_ERROR,error:l,fatal:!0,buffer:e.len,bufferInfo:e})}}}]),i}(mr);function ol(e,t){var r=ll(e.main);if(r&&r.start<=t)return r;var i=ll(e.audio);return i&&i.start<=t?i:null}function ll(e){if(!e)return null;switch(e.state){case Fi:case Oi:case Vi:case ji:return null}return e.frag}function ul(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function cl(e,t,r,i,a){var n=new e(t,r,"");try{n.value=i,a&&(n.type=a)}catch(s){n=new e(t,r,St(a?q({type:a},i):i))}return n}var dl=function(){var e=ul();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();var hl=function(){function e(t){var r=this;b(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){r.hls&&r.hls.trigger(M.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()}return A(e,[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e.on(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(M.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(M.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)}},{key:"onMediaAttaching",value:function(e,t){var r;this.media=t.media,!1===(null==(r=t.overrides)?void 0:r.cueRemoval)&&(this.removeCues=!1)}},{key:"onMediaAttached",value:function(){var e=this.hls.latestLevelDetails;e&&this.updateDateRangeCues(e)}},{key:"onMediaDetaching",value:function(e,t){this.media=null,!!t.transferMedia||(this.id3Track&&(this.removeCues&&Ps(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}},{key:"onManifestLoading",value:function(){this.dateRangeCuesAppended={}}},{key:"createTrack",value:function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t}},{key:"getID3Track",value:function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return _s(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var n=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var s=ul();if(s)for(var o=0;o<n.length;o++){var l=n[o].type;if((l!==Aa.emsg||i)&&a){var u=Ta(n[o].data);if(u){var c=n[o].pts,d=c+n[o].duration;d>dl&&(d=dl),d-c<=0&&(d=c+.25);for(var h=0;h<u.length;h++){var f=u[h];if(!Sa(f)){this.updateId3CueEnds(c,l);var v=cl(s,c,d,f,l);v&&this.id3Track.addCue(v)}}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var r,i=null==(r=this.id3Track)?void 0:r.cues;if(i)for(var a=i.length;a--;){var n=i[a];n.type===t&&n.startTime<e&&n.endTime===dl&&(n.endTime=e)}}},{key:"onBufferFlushing",value:function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type,n=this.id3Track,s=this.hls;if(s){var o=s.config,l=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(n&&(l||u))Cs(n,r,i,"audio"===a?function(e){return e.type===Aa.audioId3&&u}:"video"===a?function(e){return e.type===Aa.emsg&&l}:function(e){return e.type===Aa.audioId3&&u||e.type===Aa.emsg&&l})}}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;this.updateDateRangeCues(r,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var r=this;if(this.media&&e.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var i,a=this.id3Track,n=e.dateRanges,s=Object.keys(n),o=this.dateRangeCuesAppended;if(a&&t)if(null!=(i=a.cues)&&i.length)for(var l=Object.keys(o).filter((function(e){return!s.includes(e)})),u=function(e){var t=l[e],i=o[t].cues;delete o[t],Object.keys(i).forEach((function(e){try{var t=i[e];t.removeEventListener("enter",r.onEventCueEnter),a.removeCue(t)}catch(n){}}))},c=l.length;c--;)u(c);else o=this.dateRangeCuesAppended={};var d=e.fragments[e.fragments.length-1];if(0!==s.length&&D(null==d?void 0:d.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var h=ul(),f=function(e){var t=s[e],i=n[t],a=i.startTime,l=o[t],u=(null==l?void 0:l.cues)||{},c=(null==l?void 0:l.durationKnown)||!1,d=dl,f=i.duration;if(i.endDate&&null!==f)d=a+f,c=!0;else if(i.endOnNext&&!c){var v=s.reduce((function(e,t){if(t!==i.id){var r=n[t];if(r.class===i.class&&r.startDate>i.startDate&&(!e||i.startDate<e.startDate))return r}return e}),null);v&&(d=v.startTime,c=!0)}for(var g,p,m=Object.keys(i.attr),y=0;y<m.length;y++){var k=m[y];if("ID"!==(p=k)&&"CLASS"!==p&&"CUE"!==p&&"START-DATE"!==p&&"DURATION"!==p&&"END-DATE"!==p&&"END-ON-NEXT"!==p){var E=u[k];if(E)c&&!l.durationKnown?E.endTime=d:Math.abs(E.startTime-a)>.01&&(E.startTime=a,E.endTime=d);else if(h){var T=i.attr[k];Dr(k)&&(g=T,T=Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var S=cl(h,a,d,{key:k,data:T},Aa.dateRange);S&&(S.id=t,r.id3Track.addCue(S),u[k]=S,r.hls.config.interstitialsController&&("X-ASSET-LIST"!==k&&"X-ASSET-URL"!==k||S.addEventListener("enter",r.onEventCueEnter)))}}}o[t]={cues:u,dateRange:i,durationKnown:c}},v=0;v<s.length;v++)f(v)}}}}]),e}(),fl=function(){function e(t){var r=this;b(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=function(){var e=r.media,t=r.levelDetails;if(e&&t){r.currentTime=e.currentTime;var i=r.computeLatency();if(null!==i){r._latency=i;var a=r.config,n=a.lowLatencyMode,s=a.maxLiveSyncPlaybackRate;if(n&&1!==s&&t.live){var o=r.targetLatency;if(null!==o){var l=i-o;if(l<Math.min(r.maxLatency,o+t.targetduration)&&l>.05&&r.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),c=Math.round(2/(1+Math.exp(-.75*l-r.edgeStalled))*20)/20,d=Math.min(u,Math.max(1,c));r.changeMediaPlaybackRate(e,d)}else 1!==e.playbackRate&&0!==e.playbackRate&&r.changeMediaPlaybackRate(e,1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()}return A(e,[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||null===this.hls)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,a=this.config,n=a.liveSyncDuration,s=a.liveSyncDurationCount,o=a.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==n?n:s*i);var c=i;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,c)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var r=this.levelDetails;if(null===r)return null;var i=r.edge,a=e-t-this.edgeStalled,n=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,a),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(M.ERROR,this.onError,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(M.ERROR,this.onError,this))}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaDetaching",value:function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}},{key:"onManifestLoading",value:function(){this._latency=null,this.stallCount=0}},{key:"onLevelUpdated",value:function(e,t){var r=t.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onError",value:function(e,t){var r;t.details===C.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(r=this.levelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}},{key:"changeMediaPlaybackRate",value:function(e,t){var r,i;e.playbackRate!==t&&(null==(r=this.hls)||r.logger.debug("[latency-controller]: latency=".concat(this.latency.toFixed(3),", targetLatency=").concat(null==(i=this.targetLatency)?void 0:i.toFixed(3),", forwardBufferLength=").concat(this.forwardBufferLength.toFixed(3),": adjusting playback rate from ").concat(e.playbackRate," to ").concat(t)),e.playbackRate=t)}},{key:"estimateLiveEdge",value:function(){var e=this.levelDetails;return null===e?null:e.edge+e.age}},{key:"computeLatency",value:function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}]),e}(),vl=function(e){g(i,e);var r=n(i);function i(e,t){var a;return b(this,i),(a=r.call(this,e,"level-controller"))._levels=[],a._firstLevel=-1,a._maxAutoLevel=-1,a._startLevel=void 0,a.currentLevel=null,a.currentLevelIndex=-1,a.manualLevelIndex=-1,a.steering=void 0,a.onParsedComplete=void 0,a.steering=t,a._registerListeners(),a}return A(i,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(M.LEVEL_LOADED,this.onLevelLoaded,this),e.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(M.FRAG_BUFFERED,this.onFragBuffered,this),e.on(M.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(M.LEVEL_LOADED,this.onLevelLoaded,this),e.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(M.FRAG_BUFFERED,this.onFragBuffered,this),e.off(M.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),t(u(i.prototype),"destroy",this).call(this)}},{key:"stopLoad",value:function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),t(u(i.prototype),"stopLoad",this).call(this)}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var r=this,i=this.hls.config.preferManagedMediaSource,a=[],n={},s={},o=!1,l=!1,u=!1;t.levels.forEach((function(e){var t,c=e.attrs,d=e.audioCodec,h=e.videoCodec;d&&(e.audioCodec=d=it(d,i)||void 0),0===(null==(t=h)?void 0:t.indexOf("avc1"))&&(h=e.videoCodec=function(e){for(var t=e.split(","),r=0;r<t.length;r++){var i=t[r].split(".");if(i.length>2){var a=i.shift()+".";a+=parseInt(i.shift()).toString(16),a+=("000"+parseInt(i.shift()).toString(16)).slice(-4),t[r]=a}}return t.join(",")}(h));var f=e.width,v=e.height,g=e.unknownCodecs,p=g?g.length:0;if(g)for(var m=p;m--;){var y=g[m];r.isAudioSupported(y)?(e.audioCodec=d=d?"".concat(d,",").concat(y):y,p--,qe.audio[d.substring(0,4)]=2):r.isVideoSupported(y)&&(e.videoCodec=h=h?"".concat(h,",").concat(y):y,p--,qe.video[h.substring(0,4)]=2)}if(o||(o=!(!f||!v)),l||(l=!!h),u||(u=!!d),p||d&&!r.isAudioSupported(d)||h&&!r.isVideoSupported(h))r.log('Some or all CODECS not supported "'.concat(c.CODECS,'"'));else{var k=c.CODECS,E=c["FRAME-RATE"],T=c["HDCP-LEVEL"],S=c["PATHWAY-ID"],b=c.RESOLUTION,L=c["VIDEO-RANGE"],A="".concat(S||".","-"),R="".concat(A).concat(e.bitrate,"-").concat(b,"-").concat(E,"-").concat(k,"-").concat(L,"-").concat(T);if(n[R])if(n[R].uri===e.url||e.attrs["PATHWAY-ID"])n[R].addGroupId("audio",c.AUDIO),n[R].addGroupId("text",c.SUBTITLES);else{var I=s[R]+=1;e.attrs["PATHWAY-ID"]=new Array(I+1).join(".");var w=r.createLevel(e);n[R]=w,a.push(w)}else{var D=r.createLevel(e);n[R]=D,s[R]=1,a.push(D)}}})),this.filterAndSortMediaOptions(a,t,o,l,u)}},{key:"createLevel",value:function(e){var t=new kt(e),r=e.supplemental;if(null!=r&&r.videoCodec&&!this.isVideoSupported(r.videoCodec)){var i=new Error('SUPPLEMENTAL-CODECS not supported "'.concat(r.videoCodec,'"'));this.log(i.message),t.supportedResult=ut(i,[])}return t}},{key:"isAudioSupported",value:function(e){return ze(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return ze(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,r,i,a){var n=this,s=[],o=[],l=e;if((r||i)&&a&&(l=l.filter((function(e){var t,r=e.videoCodec,i=e.videoRange,a=e.width,n=e.height;return(!!r||!(!a||!n))&&(!!(t=i)&&ft.indexOf(t)>-1)}))),0!==l.length){t.audioTracks&&gl(s=t.audioTracks.filter((function(e){return!e.audioCodec||n.isAudioSupported(e.audioCodec)}))),t.subtitles&&gl(o=t.subtitles);var u=l.slice(0);l.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return ft.indexOf(e.videoRange)-ft.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var i=Ze(e.videoCodec),a=Ze(t.videoCodec);if(i!==a)return a-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var n=Je(e.codecSet),s=Je(t.codecSet);if(n!==s)return s-n}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var c=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(var d=0;d<u.length;d++)if(u[d].pathwayId===l[0].pathwayId){c=u[d];break}this._levels=l;for(var h=0;h<l.length;h++)if(l[h]===c){var f;this._firstLevel=h;var v=c.bitrate,g=this.hls.bandwidthEstimate;if(this.log("manifest loaded, ".concat(l.length," level(s) found, first bitrate: ").concat(v)),void 0===(null==(f=this.hls.userConfig)?void 0:f.abrEwmaDefaultEstimate)){var p=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);p>g&&g===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=p)}break}var m=a&&!i,y=this.hls.config,k=!(!y.audioStreamController||!y.audioTrackController),E={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:i,altAudio:k&&!m&&s.some((function(e){return!!e.url}))};this.hls.trigger(M.MANIFEST_PARSED,E)}else Promise.resolve().then((function(){if(n.hls){var e="no level with compatible codecs found in manifest",r=e;t.levels.length&&(r="one or more CODECS in variant not supported: ".concat(St(t.levels.map((function(e){return e.attrs.CODECS})).filter((function(e,t,r){return r.indexOf(e)===t})))),n.warn(r),e+=" (".concat(r,")"));var i=new Error(e);n.hls.trigger(M.ERROR,{type:P.MEDIA_ERROR,details:C.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}}))}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,n=this.currentLevel,s=n?n.attrs["PATHWAY-ID"]:void 0,o=t[e],l=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,a!==e||!n||s!==l){this.log("Switching to level ".concat(e," (").concat(o.height?o.height+"p ":"").concat(o.videoRange?o.videoRange+" ":"").concat(o.codecSet?o.codecSet+" ":"","@").concat(o.bitrate,")").concat(l?" with Pathway "+l:""," from level ").concat(a).concat(s?" with Pathway "+s:""));var u={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(M.LEVEL_SWITCHING,u);var c=o.details;if(!c||c.live){var d=this.switchParams(o.uri,null==n?void 0:n.details,c);this.loadPlaylist(d)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),r=e.filter((function(e){return-1!==t.indexOf(e)}));if(e.length<1)return void this.warn("pathwayPriority ".concat(e," should contain at least one pathway from list: ").concat(t));this.steering.pathwayPriority=r}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===F&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,t){var r=t.frag;if(void 0!==r&&r.type===B){var i=r.elementaryStreams;if(!Object.keys(i).some((function(e){return!!i[e]})))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of ".concat(a.loadError," on frag buffered")),a.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var r,i,a=t.level,n=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index ".concat(a)),void(null!=(i=t.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);var o=s.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(a,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(e){t(u(i.prototype),"loadPlaylist",this).call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,e)}},{key:"loadingPlaylist",value:function(e,r){t(u(i.prototype),"loadingPlaylist",this).call(this,e,r);var a=this.getUrlWithDirectives(e.uri,r),n=this.currentLevelIndex,s=e.attrs["PATHWAY-ID"],o=e.details,l=null==o?void 0:o.age;this.log("Loading level index ".concat(n).concat(void 0!==(null==r?void 0:r.msn)?" at sn "+r.msn+" part "+r.part:"").concat(s?" Pathway "+s:"").concat(l&&o.live?" age "+l.toFixed(1)+(o.type&&" "+o.type||""):""," ").concat(a)),this.hls.trigger(M.LEVEL_LOADING,{url:a,level:n,levelInfo:e,pathwayId:e.attrs["PATHWAY-ID"],id:0,deliveryDirectives:r||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t,r=this;if(1!==this._levels.length){var i=this._levels.filter((function(t,i){return i!==e||(r.steering&&r.steering.removeLevel(t),t===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((function(e){return e.level=-1}))),!1)}));wi(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var a=i.length-1;this._firstLevel=Math.min(this._firstLevel,a),this._startLevel&&(this._startLevel=Math.min(this._startLevel,a)),this.hls.trigger(M.LEVELS_UPDATED,{levels:i})}}},{key:"onLevelsUpdated",value:function(e,t){var r=t.levels;this._levels=r}},{key:"checkMaxAutoUpdated",value:function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(M.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}]),i}(Pn);function gl(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}function pl(){return self.SourceBuffer||self.WebKitSourceBuffer}function ml(){if(!re())return!1;var e=pl();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var yl=function(e){g(i,e);var r=n(i);function i(e,t,a){var n;return b(this,i),(n=r.call(this,e,t,a,"stream-controller",B)).audioCodecSwap=!1,n.level=-1,n._forceStartLoad=!1,n._hasEnoughToStart=!1,n.altAudio=0,n.audioOnly=!1,n.fragPlaying=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n.onMediaPlaying=function(){n.tick()},n.onMediaSeeked=function(){var e=n.media,t=e?e.currentTime:null;if(null!==t&&D(t)&&(n.log("Media seeked to ".concat(t.toFixed(3))),n.getBufferedFrag(t))){var r=n.getFwdBufferInfoAtPos(e,t,B,0);null!==r&&0!==r.len?n.tick():n.warn("Main forward buffer length at ".concat(t,' on "seeked" event ').concat(r?r.len:"empty",")"))}},n.registerListeners(),n}return A(i,[{key:"registerListeners",value:function(){t(u(i.prototype),"registerListeners",this).call(this);var e=this.hls;e.on(M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(M.LEVEL_LOADING,this.onLevelLoading,this),e.on(M.LEVEL_LOADED,this.onLevelLoaded,this),e.on(M.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(M.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(M.BUFFER_CREATED,this.onBufferCreated,this),e.on(M.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(M.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){t(u(i.prototype),"unregisterListeners",this).call(this);var e=this.hls;e.off(M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(M.LEVEL_LOADED,this.onLevelLoaded,this),e.off(M.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(M.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(M.BUFFER_CREATED,this.onBufferCreated,this),e.off(M.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(M.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),t(u(i.prototype),"onHandlerDestroying",this).call(this)}},{key:"startLoad",value:function(e,t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=i.startLevel;-1===a&&(i.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=i.firstAutoLevel),i.nextLoadLevel=a,this.level=i.loadLevel,this._hasEnoughToStart=!!t}r>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @".concat(r.toFixed(3))),e=r),this.state=Fi,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Oi}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,t(u(i.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case Yi:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=Fi;break}if(this.hls.nextLoadLevel!==this.level){this.state=Fi;break}break;case Bi:var a,n=self.performance.now(),s=this.retryDate;if(!s||n>=s||null!=(a=this.media)&&a.seeking){var o=this.levels,l=this.level,u=null==o?void 0:o[l];this.resetStartWhenNotLoaded(u||null),this.state=Fi}}this.state===Fi&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){var e;t(u(i.prototype),"onTickEnd",this).call(this),null!=(e=this.media)&&e.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[a]){var n=r[a],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return 2===this.altAudio&&(l.type="video"),this.hls.trigger(M.BUFFER_EOS,l),void(this.state=Vi)}if(this.buffering){e.loadLevel!==a&&-1===e.manualLevel&&this.log("Adapting to level ".concat(a," from level ").concat(this.level)),this.level=e.nextLoadLevel=a;var u=n.details;if(!u||this.state===Yi||this.waitForLive(n))return this.level=a,this.state=Yi,void(this.startFragRequested=!1);var c=s.len,d=this.getMaxBufferLength(n.maxBitrate);if(!(c>=d)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var h=this.backtrackFragment?this.backtrackFragment.start:s.end,f=this.getNextFragment(h,u);if(this.couldBacktrack&&!this.fragPrevious&&f&&ge(f)&&this.fragmentTracker.getState(f)!==tr){var v,g=(null!=(v=this.backtrackFragment)?v:f).sn-u.startSN,p=u.fragments[g-1];p&&f.cc===p.cc&&(f=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){var m=this.audioOnly&&!this.altAudio?de:he,y=(m===he?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,m,B)}f=this.getNextFragmentLoopLoading(f,u,s,B,d)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,n,h))}}}}}}},{key:"loadFragment",value:function(e,r,a){var n=this.fragmentTracker.getState(e);n===Zt||n===er?ge(e)?this.bitrateTest?(this.log("Fragment ".concat(e.sn," of level ").concat(e.level," is being downloaded to test bitrate and will not be buffered")),this._loadBitrateTestFrag(e,r)):t(u(i.prototype),"loadFragment",this).call(this,e,r,a):this._loadInitSegment(e,r):this.clearTrackerIfNeeded(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,B)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.end+.5):null}},{key:"immediateLevelSwitch",value:function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}},{key:"nextLevelSwitch",value:function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var n=this.getMainFwdBufferInfo();if(!n||n.len<2*a.targetduration)return}if(!t.paused&&e){var s=e[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var l=this.getBufferedFrag(t.currentTime+r);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var c=u.maxStartPTS?u.maxStartPTS:u.start,d=u.duration,h=Math.max(l.end,c+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(h,Number.POSITIVE_INFINITY)}}}}},{key:"abortCurrentFrag",value:function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Ni:case Ui:case Bi:case Hi:case Ki:this.state=Fi}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(e,r){t(u(i.prototype),"flushMainBuffer",this).call(this,e,r,2===this.altAudio?"video":null)}},{key:"onMediaAttached",value:function(e,r){t(u(i.prototype),"onMediaAttached",this).call(this,e,r);var a=r.media;$s(a,"playing",this.onMediaPlaying),$s(a,"seeked",this.onMediaSeeked)}},{key:"onMediaDetaching",value:function(e,r){var a=this.media;a&&(zs(a,"playing",this.onMediaPlaying),zs(a,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,t(u(i.prototype),"onMediaDetaching",this).call(this,e,r),!!r.transferMedia||(this._hasEnoughToStart=!1)}},{key:"onManifestLoading",value:function(){t(u(i.prototype),"onManifestLoading",this).call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(M.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){var r,i,a=!1,n=!1;t.levels.forEach((function(e){var t=e.audioCodec;t&&(a=a||-1!==t.indexOf("mp4a.40.2"),n=n||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=a&&n&&!("function"==typeof(null==(i=pl())||null==(r=i.prototype)?void 0:r.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}},{key:"onLevelLoading",value:function(e,t){if(this.levels&&this.state===Fi){var r=t.levelInfo;(!r.details||r.details.live&&(this.levelLastLoaded!==r||r.details.expired)||this.waitForCdnTuneIn(r.details))&&(this.state=Yi)}}},{key:"onLevelLoaded",value:function(e,t){var r,i=this.levels,a=this.startFragRequested,n=t.level,s=t.details,o=s.totalduration;if(i){this.log("Level ".concat(n," loaded [").concat(s.startSN,",").concat(s.endSN,"]").concat(s.lastPartSn?"[part-".concat(s.lastPartSn,"-").concat(s.lastPartIndex,"]"):"",", cc [").concat(s.startCC,", ").concat(s.endCC,"] duration:").concat(o));var l=t.levelInfo,u=this.fragCurrent;!u||this.state!==Ui&&this.state!==Bi||u.level!==t.level&&u.loader&&this.abortCurrentFrag();var c=0;if(s.live||null!=(r=l.details)&&r.live){var d;if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;c=this.alignPlaylists(s,l.details,null==(d=this.levelLastLoaded)?void 0:d.details)}if(l.details=s,this.levelLastLoaded=l,a||this.setStartPosition(s,c),this.hls.trigger(M.LEVEL_UPDATED,{details:s,level:n}),this.state===Yi){if(this.waitForCdnTuneIn(s))return;this.state=Fi}a&&s.live&&this.synchronizeToLiveEdge(s),this.tick()}else this.warn("Levels were reset while loading level ".concat(n))}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,a=this.getLoadPosition(),n=e.fragmentStart,s=e.edge,o=a>=n-t.maxFragLookUpTolerance&&a<=s;if(null!==i&&r.duration>i&&(a<i||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||a<s-l)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: ".concat(a.toFixed(3)," is located too far from the end of live sliding playlist: ").concat(s,", reset currentTime to : ").concat(i.toFixed(3))),r.currentTime=i))}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,r=e.frag,i=e.part,a=e.payload,n=this.levels;if(n){var s=n[r.level];if(s){var o=s.details;if(!o)return this.warn("Dropping fragment ".concat(r.sn," of level ").concat(r.level," after level details were reset")),void this.fragmentTracker.removeFragment(r);var l=s.videoCodec,u=o.PTSKnown||!o.live,c=null==(t=r.initSegment)?void 0:t.data,d=this._getAudioCodec(s),h=this.transmuxer=this.transmuxer||new _n(this.hls,B,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,v=-1!==f,g=new yr(r.level,r.sn,r.stats.chunkCount,a.byteLength,f,v),p=this.initPTS[r.cc];h.push(a,c,d,l,r,i,o.totalduration,u,g,p)}else this.warn("Level ".concat(r.level," not found on progress"))}else this.warn("Levels were reset while fragment load was in progress. Fragment ".concat(r.sn," of level ").concat(r.level," will not be buffered"))}},{key:"onAudioTrackSwitching",value:function(e,t){var r=this,i=this.hls,a=2===this.altAudio;if(_t(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var n=this.fragCurrent;n&&(this.log("Switching to main audio track, cancel main fragment load"),n.abortRequests(),this.fragmentTracker.removeFragment(n)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(a)return this.fragmentTracker.removeAllFragments(),i.once(M.BUFFER_FLUSHED,(function(){var e;null==(e=r.hls)||e.trigger(M.AUDIO_TRACK_SWITCHED,t)})),void i.trigger(M.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});i.trigger(M.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var r=_t(t.url,this.hls);if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var r,i,a=t.tracks,n=!1;for(var s in a){var o=a[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=a[s];l&&(this.videoBuffer=l.buffer)}}else n=!0}n&&r?(this.log("Alternate track found, use ".concat(i,".buffered to schedule main fragment loading")),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var r=t.frag,i=t.part,a=r.type===B;if(a){if(this.fragContextChanged(r))return this.warn("Fragment ".concat(r.sn).concat(i?" p: "+i.index:""," of level ").concat(r.level," finished buffering, but was aborted. state: ").concat(this.state)),void(this.state===Ki&&(this.state=Fi));var n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),ge(r)&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}var s=this.media;s&&(!this._hasEnoughToStart&&Er.getBuffered(s).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var r;if(t.fatal)this.state=ji;else switch(t.details){case C.FRAG_GAP:case C.FRAG_PARSING_ERROR:case C.FRAG_DECRYPT_ERROR:case C.FRAG_LOAD_ERROR:case C.FRAG_LOAD_TIMEOUT:case C.KEY_LOAD_ERROR:case C.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(B,t);break;case C.LEVEL_LOAD_ERROR:case C.LEVEL_LOAD_TIMEOUT:case C.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==Yi||(null==(r=t.context)?void 0:r.type)!==F||(this.state=Fi);break;case C.BUFFER_ADD_CODEC_ERROR:case C.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.resetLoadingState();break;case C.BUFFER_FULL_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case C.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=Fi,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,t){var r=t.type;if(r!==de||!this.altAudio){var i=(r===he?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,r,B),this.tick())}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to ".concat(r,", already seeking at ").concat(t));var i=this.timelineOffset;i&&r&&(r+=i);var a=this.getLevelDetails(),n=Er.getBuffered(e),s=n.length?n.start(0):0,o=s-r,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);o>0&&(o<l||this.loadingParts&&o<2*((null==a?void 0:a.partTarget)||0))&&(this.log("adjusting start position by ".concat(o," to match buffer start")),r+=o,this.startPosition=r),t<r&&(this.log("seek to target start position ".concat(r," from current time ").concat(t," buffer start ").concat(s)),e.currentTime=r)}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){var r=this;e.bitrateTest=!0,this._doFragLoad(e,t).then((function(e){var i=r.hls,a=null==e?void 0:e.frag;if(a&&!r.fragContextChanged(a)){t.fragmentError=0,r.state=Fi,r.startFragRequested=!1,r.bitrateTest=!1;var n=a.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),i.trigger(M.FRAG_LOADED,e),a.bitrateTest=!1}}))}},{key:"_handleTransmuxComplete",value:function(e){var t,r=this.playlistType,i=this.hls,a=e.remuxResult,n=e.chunkMeta,s=this.getCurrentContext(n);if(s){var o=s.frag,l=s.part,u=s.level,c=a.video,d=a.text,h=a.id3,f=a.initSegment,v=u.details,g=this.altAudio?void 0:a.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=Hi,f){if(null!=f&&f.tracks){var p=o.initSegment||o;this._bufferInitSegment(u,f.tracks,p,n),i.trigger(M.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:r,tracks:f.tracks})}var m=f.initPTS,y=f.timescale;D(m)&&(this.initPTS[o.cc]={baseTime:m,timescale:y},i.trigger(M.INIT_PTS_FOUND,{frag:o,id:r,initPTS:m,timescale:y}))}if(c&&v){g||"audiovideo"!==c.type||this.logMuxedErr(o);var k=v.fragments[o.sn-1-v.startSN],E=o.sn===v.startSN,T=!k||o.cc>k.cc;if(!1!==a.independent){var S=c.startPTS,b=c.endPTS,L=c.startDTS,A=c.endDTS;if(l)l.elementaryStreams[c.type]={startPTS:S,endPTS:b,startDTS:L,endDTS:A};else if(c.firstKeyFrame&&c.independent&&1===n.id&&!T&&(this.couldBacktrack=!0),c.dropped&&c.independent){var R=this.getMainFwdBufferInfo(),I=(R?R.end:this.getLoadPosition())+this.config.maxBufferHole,w=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!E&&I<w-this.config.maxBufferHole&&!T)return void this.backtrack(o);T&&(o.gap=!0),o.setElementaryStreamInfo(c.type,o.start,b,o.start,A,!0)}else E&&S-(v.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(c.type,S,b,L,A),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(c,o,l,n,E||T)}else{if(!E&&!T)return void this.backtrack(o);o.gap=!0}}if(g){var _=g.startPTS,x=g.endPTS,P=g.startDTS,C=g.endDTS;l&&(l.elementaryStreams[de]={startPTS:_,endPTS:x,startDTS:P,endDTS:C}),o.setElementaryStreamInfo(de,_,x,P,C),this.bufferFragmentData(g,o,l,n)}if(v&&null!=h&&null!=(t=h.samples)&&t.length){var O={id:r,frag:o,details:v,samples:h.samples};i.trigger(M.FRAG_PARSING_METADATA,O)}if(v&&d){var F={id:r,frag:o,details:v,samples:d.samples};i.trigger(M.FRAG_PARSING_USERDATA,F)}}}else this.resetWhenMissingContext(n)}},{key:"logMuxedErr",value:function(e){this.warn("".concat(ge(e)?"Media":"Init"," segment with muxed audiovideo where only video expected: ").concat(e.url))}},{key:"_bufferInitSegment",value:function(e,t,r,i){var a=this;if(this.state===Hi){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));var n=t.audio,s=t.video,o=t.audiovideo;if(n){var l=at(n.codec,e.audioCodec);"mp4a"===l&&(l="mp4a.40.5");var u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l=-1!==l.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var c=n.metadata;c&&"channelCount"in c&&1!==(c.channelCount||1)&&-1===u.indexOf("firefox")&&(l="mp4a.40.5")}l&&-1!==l.indexOf("mp4a.40.5")&&-1!==u.indexOf("android")&&"audio/mpeg"!==n.container&&(l="mp4a.40.2",this.log("Android: force audio codec to ".concat(l))),e.audioCodec&&e.audioCodec!==l&&this.log('Swapping manifest audio codec "'.concat(e.audioCodec,'" for "').concat(l,'"')),n.levelCodec=l,n.id=B,this.log("Init audio buffer, container:".concat(n.container,", codecs[selected/level/parsed]=[").concat(l||"","/").concat(e.audioCodec||"","/").concat(n.codec,"]")),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=B;var d=s.codec;if(4===(null==d?void 0:d.length))switch(d){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log("Init video buffer, container:".concat(s.container,", codecs[level/parsed]=[").concat(e.videoCodec||"","/").concat(d,"]").concat(s.codec!==d?" parsed-corrected="+s.codec:"").concat(s.supplemental?" supplemental="+s.supplemental:"")),delete t.audiovideo}o&&(this.log("Init audiovideo buffer, container:".concat(o.container,", codecs[level/parsed]=[").concat(e.codecs,"/").concat(o.codec,"]")),delete t.video,delete t.audio);var h=Object.keys(t);if(h.length){if(this.hls.trigger(M.BUFFER_CODECS,t),!this.hls)return;h.forEach((function(e){var n=t[e].initSegment;null!=n&&n.byteLength&&a.hls.trigger(M.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})}))}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){var e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,B)}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}},{key:"backtrack",value:function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Fi}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(Er.isBuffered(e,r)?t=this.getAppendedFrag(r):Er.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,a=t.level;i&&t.sn===i.sn&&i.level===a||(this.fragPlaying=t,this.hls.trigger(M.FRAG_CHANGED,{frag:t}),i&&i.level===a||this.hls.trigger(M.LEVEL_SWITCHED,{level:a}))}}}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return D(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(D(t)){var r=this.getLevelDetails(),i=this.currentFrag||(r?Ct(null,r.fragments,t):null);if(i){var a=i.programDateTime;if(null!==a){var n=a+1e3*(t-i.start);return new Date(n)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),i}(qi),kl=function(){function e(t){b(this,e),this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}return A(e,[{key:"abort",value:function(e){for(var t in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}}},{key:"detach",value:function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}},{key:"createKeyLoadError",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:C.KEY_LOAD_ERROR,r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;return new pr({type:P.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:i})}},{key:"loadClear",value:function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,a=e.cc,n=function(e){var n=t[e];if(a<=n.cc&&("initSegment"===i||"initSegment"===n.sn||i<n.sn))return r.emeController.selectKeySystemFormat(n).then((function(e){n.setKeyFormat(e)})),"break"},s=0;s<t.length;s++){if("break"===n(s))break}}},{key:"load",value:function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then((function(r){return t.loadInternal(e,r)})):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var r,i;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var n=new Error(t?"Expected frag.decryptdata to be defined after setting format ".concat(t):"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,n))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error('Invalid key URI: "'.concat(s,'"'))));var o,l=this.keyUriToKeyInfo[s];if(null!=(r=l)&&r.decryptdata.key)return a.key=l.decryptdata.key,Promise.resolve({frag:e,keyInfo:l});if(null!=(i=l)&&i.keyLoadPromise)switch(null==(o=l.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return l.keyLoadPromise.then((function(t){return a.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:l}}))}switch(l=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(l,e):this.loadKeyEME(l,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,e);default:return Promise.reject(this.createKeyLoadError(e,C.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'.concat(a.method,'"'))))}}},{key:"loadKeyEME",value:function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then((function(t){return e.mediaKeySessionContext=t,r}))).catch((function(t){throw e.keyLoadPromise=null,t}))}return Promise.resolve(r)}},{key:"loadKeyHTTP",value:function(e,t){var r=this,i=this.config,a=new(0,i.loader)(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise((function(n,s){var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},l=i.keyLoadPolicy.default,u={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(e,t,i,a){var o=i.frag,l=i.keyInfo,u=i.url;if(!o.decryptdata||l!==r.keyUriToKeyInfo[u])return s(r.createKeyLoadError(o,C.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),a));l.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,l.loader=null,n({frag:o,keyInfo:l})},onError:function(e,i,a,n){r.resetLoader(i),s(r.createKeyLoadError(t,C.KEY_LOAD_ERROR,new Error("HTTP Error ".concat(e.code," loading key ").concat(e.text)),a,q({url:o.url,data:void 0},e)))},onTimeout:function(e,i,a){r.resetLoader(i),s(r.createKeyLoadError(t,C.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),a))},onAbort:function(e,i,a){r.resetLoader(i),s(r.createKeyLoadError(t,C.INTERNAL_ABORTED,new Error("key loading aborted"),a))}};a.load(o,u,c)}))}},{key:"resetLoader",value:function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()}}]),e}();function El(e){switch(e.type){case N:return G;case U:return H;default:return B}}function Tl(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var Sl=function(){function e(t){b(this,e),this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()}return A(e,[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.LEVEL_LOADING,this.onLevelLoading,this),e.on(M.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(M.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(M.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.LEVEL_LOADING,this.onLevelLoading,this),e.off(M.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(M.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(M.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}},{key:"onManifestLoading",value:function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:O,url:r,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var r=t.id,i=t.level,a=t.pathwayId,n=t.url,s=t.deliveryDirectives,o=t.levelInfo;this.load({id:r,level:i,pathwayId:a,responseType:"text",type:F,url:n,deliveryDirectives:s,levelOrTrack:o})}},{key:"onAudioTrackLoading",value:function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:N,url:a,deliveryDirectives:n,levelOrTrack:s})}},{key:"onSubtitleTrackLoading",value:function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:U,url:a,deliveryDirectives:n,levelOrTrack:s})}},{key:"onLevelsUpdated",value:function(e,t){var r=this.loaders[F];if(r){var i=r.context;i&&!t.levels.some((function(e){return e===i.levelOrTrack}))&&(r.abort(),delete this.loaders[F])}}},{key:"load",value:function(e){var t,r,i,a=this,n=this.hls.config,s=this.getInternalLoader(e);if(s){var o=this.hls.logger,l=s.context;if(l&&l.levelOrTrack===e.levelOrTrack&&(l.url===e.url||l.deliveryDirectives&&!e.deliveryDirectives))return void(l.url===e.url?o.log("[playlist-loader]: ignore ".concat(e.url," ongoing request")):o.log("[playlist-loader]: ignore ".concat(e.url," in favor of ").concat(l.url)));o.log("[playlist-loader]: aborting previous loader for type: ".concat(e.type)),s.abort()}if((r=e.type===O?n.manifestLoadPolicy.default:W({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),D(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===F&&null!==e.level?i=this.hls.levels[e.level].details:e.type===N&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===U&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var u=i.partTarget,c=i.targetduration;if(u&&c){var d=1e3*Math.max(3*u,.8*c);r=W({},r,{maxTimeToFirstByteMs:Math.min(d,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,r.maxTimeToFirstByteMs)})}}var h=r.errorRetry||r.timeoutRetry||{},f={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},v={onSuccess:function(e,t,r,i){var n=a.getInternalLoader(r);a.resetInternalLoader(r.type);var s=e.data;0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),oi.isMediaPlaylist(s)||r.type!==O?a.handleTrackOrLevelPlaylist(e,t,r,i||null,n):a.handleMasterPlaylist(e,t,r,i)):a.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:function(e,t,r,i){a.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){a.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,f,v)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e=this.hls,t=e.config,r=t.autoStartLoad,i=t.startPosition,a=e.forceStartLoad;(r||a)&&(this.hls.logger.log("".concat(r?"auto":"force"," startLoad with configured startPosition ").concat(i)),this.hls.startLoad(i))}}},{key:"handleMasterPlaylist",value:function(e,t,r,i){var a=this.hls,n=e.data,s=Tl(e,r),o=oi.parseMasterPlaylist(n,s);if(o.playlistParsingError)this.handleManifestParsingError(e,r,o.playlistParsingError,i,t);else{var l=o.contentSteering,u=o.levels,c=o.sessionData,d=o.sessionKeys,h=o.startTimeOffset,f=o.variableList;this.variableList=f;var v=oi.parseMasterPlaylistMedia(n,s,o),g=v.AUDIO,p=void 0===g?[]:g,m=v.SUBTITLES,y=v["CLOSED-CAPTIONS"];if(p.length)p.some((function(e){return!e.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new wr({}),bitrate:0,url:""}));a.trigger(M.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:m,captions:y,contentSteering:l,url:s,stats:t,networkDetails:i,sessionData:c,sessionKeys:d,startTimeOffset:h,variableList:f})}}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,r,i,a){var n=this.hls,s=r.id,o=r.level,l=r.type,u=Tl(e,r),c=D(o)?o:D(s)?s:0,d=El(r),h=oi.parseLevelPlaylist(e.data,u,c,d,0,this.variableList);if(l===O){var f={attrs:new wr({}),bitrate:0,details:h,name:"",url:u};h.requestScheduled=t.loading.start+Ai(h,0),n.trigger(M.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:u,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=h,this.handlePlaylistLoaded(h,e,t,r,i,a)}},{key:"handleManifestParsingError",value:function(e,t,r,i,a){this.hls.trigger(M.ERROR,{type:P.NETWORK_ERROR,details:C.MANIFEST_PARSING_ERROR,fatal:t.type===O,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})}},{key:"handleNetworkError",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0,n="A network ".concat(r?"timeout":"error"+(i?" (status "+i.code+")":"")," occurred while loading ").concat(e.type);e.type===F?n+=": ".concat(e.level," id: ").concat(e.id):e.type!==N&&e.type!==U||(n+=" id: ".concat(e.id,' group-id: "').concat(e.groupId,'"'));var s=new Error(n);this.hls.logger.warn("[playlist-loader]: ".concat(n));var o=C.UNKNOWN,l=!1,u=this.getInternalLoader(e);switch(e.type){case O:o=r?C.MANIFEST_LOAD_TIMEOUT:C.MANIFEST_LOAD_ERROR,l=!0;break;case F:o=r?C.LEVEL_LOAD_TIMEOUT:C.LEVEL_LOAD_ERROR,l=!1;break;case N:o=r?C.AUDIO_TRACK_LOAD_TIMEOUT:C.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case U:o=r?C.SUBTITLE_TRACK_LOAD_TIMEOUT:C.SUBTITLE_LOAD_ERROR,l=!1}u&&this.resetInternalLoader(e.type);var c={type:P.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:u,context:e,error:s,networkDetails:t,stats:a};if(i){var d=(null==t?void 0:t.url)||e.url;c.response=q({url:d,data:void 0},i)}this.hls.trigger(M.ERROR,c)}},{key:"handlePlaylistLoaded",value:function(e,t,r,i,a,n){var s=this.hls,o=i.type,l=i.level,u=i.id,c=i.groupId,d=i.deliveryDirectives,h=Tl(t,i),f=El(i),v="number"==typeof i.level&&f===B?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var g=e.playlistParsingError;if(g){if(this.hls.logger.warn(g),!s.config.ignorePlaylistParsingErrors)return void s.trigger(M.ERROR,{type:P.NETWORK_ERROR,details:C.LEVEL_PARSING_ERROR,fatal:!1,url:h,error:g,reason:g.message,response:t,context:i,level:v,parent:f,networkDetails:a,stats:r});e.playlistParsingError=null}switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case O:case F:s.trigger(M.LEVEL_LOADED,{details:e,levelInfo:i.levelOrTrack||s.levels[0],level:v||0,id:u||0,stats:r,networkDetails:a,deliveryDirectives:d,withoutMultiVariant:o===O});break;case N:s.trigger(M.AUDIO_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:a,deliveryDirectives:d});break;case U:s.trigger(M.SUBTITLE_TRACK_LOADED,{details:e,track:i.levelOrTrack,id:u||0,groupId:c||"",stats:r,networkDetails:a,deliveryDirectives:d})}}else{var p=e.playlistParsingError=new Error("No Segments found in Playlist");s.trigger(M.ERROR,{type:P.NETWORK_ERROR,details:C.LEVEL_EMPTY_ERROR,fatal:!1,url:h,error:p,reason:p.message,response:t,context:i,level:v,parent:f,networkDetails:a,stats:r})}}}]),e}(),bl=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};b(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Ji,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var r=this.logger=ee(t.debug||!1,"Hls instance",t.assetPlayerId),i=this.config=il(e.DefaultConfig,t,r);this.userConfig=t,i.progressive&&nl(i,r);var a=i.abrController,n=i.bufferController,s=i.capLevelController,o=i.errorController,l=i.fpsController,u=new o(this),c=this.abrController=new a(this),d=new rr(this),h=i.interstitialsController,f=h?this.interstitialsController=new h(this,e):null,v=this.bufferController=new n(this,d),g=this.capLevelController=new s(this),p=new l(this),m=new Sl(this),y=i.contentSteeringController,k=y?new y(this):null,E=this.levelController=new vl(this,k),T=new hl(this),S=new kl(this.config),L=this.streamController=new yl(this,d,S),A=this.gapController=new sl(this,d);g.setStreamController(L),p.setStreamController(L);var R=[m,E,L];f&&R.splice(1,0,f),k&&R.splice(1,0,k),this.networkControllers=R;var I=[c,v,A,g,p,T,d];this.audioTrackController=this.createController(i.audioTrackController,R);var w=i.audioStreamController;w&&R.push(this.audioStreamController=new w(this,d,S)),this.subtitleTrackController=this.createController(i.subtitleTrackController,R);var D=i.subtitleStreamController;D&&R.push(this.subtititleStreamController=new D(this,d,S)),this.createController(i.timelineController,I),S.emeController=this.emeController=this.createController(i.emeController,I),this.cmcdController=this.createController(i.cmcdController,I),this.latencyController=this.createController(fl,I),this.coreComponents=I,R.push(u);var _=u.onErrorOut;"function"==typeof _&&this.on(M.ERROR,_,u),this.on(M.MANIFEST_LOADED,m.onManifestLoaded,m)}return A(e,[{key:"createController",value:function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null}},{key:"on",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.on(e,t,r)}},{key:"once",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this;this._emitter.once(e,t,r)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this,i=arguments.length>3?arguments[3]:void 0;this._emitter.off(e,t,r,i)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,r){return this._emitter.emit(e,t,r)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),!this.triggeringException){this.triggeringException=!0;var r=e===M.ERROR;this.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.INTERNAL_EXCEPTION,fatal:r,event:e,error:i}),this.triggeringException=!1}}return!1}},{key:"listenerCount",value:function(e){return this._emitter.listenerCount(e)}},{key:"destroy",value:function(){this.logger.log("destroy"),this.trigger(M.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error("attachMedia failed: invalid argument (".concat(e,")"));this.trigger(M.ERROR,{type:P.OTHER_ERROR,details:C.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in e,i=r?e.media:e,a=r?e:{media:i};this._media=i,this.trigger(M.MEDIA_ATTACHING,a)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(M.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(M.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,r=this._url,i=this._url=ue.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:".concat(i)),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(M.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,t=arguments.length>1?arguments[1]:void 0;this.logger.log("startLoad(".concat(e+(t?", <skip seek to start>":""),")")),this.started=!0,this.resumeBuffering();for(var r=0;r<this.networkControllers.length&&(this.networkControllers[r].startLoad(e,t),this.started&&this.networkControllers);r++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach((function(e){e.resumeBuffering&&e.resumeBuffering()})))}},{key:"pauseBuffering",value:function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach((function(e){e.pauseBuffering&&e.pauseBuffering()})))}},{key:"inFlightFragments",get:function(){var e=k({},B,this.streamController.inFlightFrag);return this.audioStreamController&&(e[G]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[H]=this.subtititleStreamController.inFlightFrag),e}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(i){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(i){var r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)}))}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log("set currentLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log("set nextLevel:".concat(e)),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log("set loadLevel:".concat(e)),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log("set firstLevel:".concat(e)),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:".concat(e)),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:".concat(e)),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return ht.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var a=e;a--;){var n=t[a].attrs["HDCP-LEVEL"];if(n&&n<=i)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{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},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.allAudioTracks,r=Lt(t);return dt(e,r,navigator.mediaCapabilities)}}],[{key:"version",get:function(){return ea}},{key:"isMSESupported",value:function(){return ml()}},{key:"isSupported",value:function(){return function(){if(!ml())return!1;var e=re();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((function(t){return e.isTypeSupported(Qe(t,"video"))}))||["mp4a.40.2","fLaC"].some((function(t){return e.isTypeSupported(Qe(t,"audio"))})))}()}},{key:"getMediaSource",value:function(){return re()}},{key:"Events",get:function(){return M}},{key:"MetadataSchema",get:function(){return Aa}},{key:"ErrorTypes",get:function(){return P}},{key:"ErrorDetails",get:function(){return C}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:rl},set:function(t){e.defaultConfig=t}}]),e}();r("H",bl),bl.defaultConfig=void 0}}}))}();
|