@volcengine/veplayer 1.12.0-rc.6 → 1.12.0-rc.8
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/index.d.ts +181 -360
- package/index.min.js +2 -2
- package/package.json +1 -1
- package/plugin/dash.js +2 -2
- package/plugin/hls.js +1 -1
- package/plugin/hlsEncrypt.js +2 -2
- package/plugin/mp4Encrypt.js +2 -2
package/plugin/hls.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.object.assign.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.object.get-own-property-descriptor.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.string.iterator.js"),require("xgplayer"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.json.stringify.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.promise.finally.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/esnext.typed-array.at.js"),require("core-js/modules/es.typed-array.copy-within.js"),require("core-js/modules/es.typed-array.every.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.filter.js"),require("core-js/modules/es.typed-array.find.js"),require("core-js/modules/es.typed-array.find-index.js"),require("core-js/modules/esnext.typed-array.find-last.js"),require("core-js/modules/esnext.typed-array.find-last-index.js"),require("core-js/modules/es.typed-array.for-each.js"),require("core-js/modules/es.typed-array.includes.js"),require("core-js/modules/es.typed-array.index-of.js"),require("core-js/modules/es.typed-array.iterator.js"),require("core-js/modules/es.typed-array.join.js"),require("core-js/modules/es.typed-array.last-index-of.js"),require("core-js/modules/es.typed-array.map.js"),require("core-js/modules/es.typed-array.reduce.js"),require("core-js/modules/es.typed-array.reduce-right.js"),require("core-js/modules/es.typed-array.reverse.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.slice.js"),require("core-js/modules/es.typed-array.some.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.subarray.js"),require("core-js/modules/es.typed-array.to-locale-string.js"),require("core-js/modules/es.typed-array.to-string.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.number.is-nan.js"),require("core-js/modules/es.number.constructor.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.string.trim.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.number.is-finite.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.math.hypot.js"),require("core-js/modules/es.string.from-code-point.js"),require("core-js/modules/es.string.match.js"),require("core-js/modules/es.array.sort.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.typed-array.int8-array.js"),require("core-js/modules/es.typed-array.uint8-clamped-array.js"),require("core-js/modules/es.typed-array.int16-array.js"),require("core-js/modules/es.typed-array.uint16-array.js"),require("core-js/modules/es.typed-array.int32-array.js"),require("core-js/modules/es.typed-array.uint32-array.js"),require("core-js/modules/es.typed-array.float32-array.js"),require("core-js/modules/es.typed-array.float64-array.js"),require("core-js/modules/es.regexp.constructor.js"),require("core-js/modules/es.regexp.sticky.js"),require("core-js/modules/es.number.to-fixed.js"),require("core-js/modules/es.string.split.js"),require("core-js/modules/es.number.max-safe-integer.js"),require("core-js/modules/es.array.find-index.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.object.assign.js","core-js/modules/es.array.concat.js","core-js/modules/es.object.get-own-property-descriptor.js","core-js/modules/es.object.to-string.js","core-js/modules/es.promise.js","core-js/modules/es.array.slice.js","core-js/modules/es.array.join.js","core-js/modules/es.array.map.js","core-js/modules/es.array.from.js","core-js/modules/es.string.iterator.js","xgplayer","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.test.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.keys.js","core-js/modules/es.array.iterator.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/web.url.js","core-js/modules/web.url-search-params.js","core-js/modules/es.array.splice.js","core-js/modules/es.function.name.js","core-js/modules/es.json.stringify.js","core-js/modules/es.array.includes.js","core-js/modules/es.promise.finally.js","core-js/modules/es.array.filter.js","core-js/modules/es.typed-array.uint8-array.js","core-js/modules/esnext.typed-array.at.js","core-js/modules/es.typed-array.copy-within.js","core-js/modules/es.typed-array.every.js","core-js/modules/es.typed-array.fill.js","core-js/modules/es.typed-array.filter.js","core-js/modules/es.typed-array.find.js","core-js/modules/es.typed-array.find-index.js","core-js/modules/esnext.typed-array.find-last.js","core-js/modules/esnext.typed-array.find-last-index.js","core-js/modules/es.typed-array.for-each.js","core-js/modules/es.typed-array.includes.js","core-js/modules/es.typed-array.index-of.js","core-js/modules/es.typed-array.iterator.js","core-js/modules/es.typed-array.join.js","core-js/modules/es.typed-array.last-index-of.js","core-js/modules/es.typed-array.map.js","core-js/modules/es.typed-array.reduce.js","core-js/modules/es.typed-array.reduce-right.js","core-js/modules/es.typed-array.reverse.js","core-js/modules/es.typed-array.set.js","core-js/modules/es.typed-array.slice.js","core-js/modules/es.typed-array.some.js","core-js/modules/es.typed-array.sort.js","core-js/modules/es.typed-array.subarray.js","core-js/modules/es.typed-array.to-locale-string.js","core-js/modules/es.typed-array.to-string.js","core-js/modules/es.string.replace.js","core-js/modules/es.number.is-nan.js","core-js/modules/es.number.constructor.js","core-js/modules/es.object.get-prototype-of.js","core-js/modules/es.symbol.js","core-js/modules/es.string.trim.js","core-js/modules/es.set.js","core-js/modules/es.number.is-finite.js","core-js/modules/es.array.find.js","core-js/modules/es.string.includes.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.math.hypot.js","core-js/modules/es.string.from-code-point.js","core-js/modules/es.string.match.js","core-js/modules/es.array.sort.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array-buffer.constructor.js","core-js/modules/es.typed-array.int8-array.js","core-js/modules/es.typed-array.uint8-clamped-array.js","core-js/modules/es.typed-array.int16-array.js","core-js/modules/es.typed-array.uint16-array.js","core-js/modules/es.typed-array.int32-array.js","core-js/modules/es.typed-array.uint32-array.js","core-js/modules/es.typed-array.float32-array.js","core-js/modules/es.typed-array.float64-array.js","core-js/modules/es.regexp.constructor.js","core-js/modules/es.regexp.sticky.js","core-js/modules/es.number.to-fixed.js","core-js/modules/es.string.split.js","core-js/modules/es.number.max-safe-integer.js","core-js/modules/es.array.find-index.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).HlsPlayer=t(null,null,null,null,null,null,null,null,null,null,e.Player)}(this,(function(e,t,r,n,i,s,a,o,u,c,l){"use strict";function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(){f=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(C){u=function(e,t,r){return e[t]=r}}function c(e,t,r,i){var s=t&&t.prototype instanceof h?t:h,a=Object.create(s.prototype),o=new T(i||[]);return n(a,"_invoke",{value:S(e,r,o)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(C){return{type:"throw",arg:C}}}e.wrap=c;var d={};function h(){}function p(){}function v(){}var m={};u(m,s,(function(){return this}));var y=Object.getPrototypeOf,_=y&&y(y(D([])));_&&_!==t&&r.call(_,s)&&(m=_);var g=v.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(n,s,a,o){var u=l(e[n],e,s);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){i("next",e,a,o)}),(function(e){i("throw",e,a,o)})):t.resolve(d).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,o)}))}o(u.arg)}var s;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return s=s?s.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw s;return{value:void 0,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var o=E(a,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"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var s=i.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function x(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 w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function D(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return p.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=u(v,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,o,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(k.prototype),u(k.prototype,a,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var a=new k(c(t,r,n,i),s);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(g),u(g,o,"Generator"),u(g,s,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=D,T.prototype={constructor:T,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(w),!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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(o){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var a=s?s.completion:{};return a.type=e,a.arg=t,s?(this.method="next",this.next=s.finallyLoc,d):this.complete(a)},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),w(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 n=r.completion;if("throw"===n.type){var i=n.arg;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:D(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function p(e){return(p="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})(e)}function v(e,t,r,n,i,s,a){try{var o=e[s](a),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function m(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function a(e){v(s,n,i,a,o,"next",e)}function o(e){v(s,n,i,a,o,"throw",e)}a(void 0)}))}}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,U(n.key),n)}}function g(e,t,r){return t&&_(e.prototype,t),r&&_(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e,t,r){return(t=U(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function k(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&&E(e,t)}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){return(E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function x(){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 w(e,t,r){return(w=x()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&E(i,r.prototype),i}).apply(null,arguments)}function T(e){var t="function"==typeof Map?new Map:void 0;return T=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,n)}function n(){return w(e,arguments,S(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),E(n,e)},T(e)}function D(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function A(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function C(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return A(e)}function L(e){var t=x();return function(){var r,n=S(e);if(t){var i=S(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return C(this,r)}}function R(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=S(e)););return e}function O(){return O="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=R(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},O.apply(this,arguments)}function P(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){var n,i,s,a,o=[],u=!0,c=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=s.call(r)).done)&&(o.push(n.value),o.length!==t);u=!0);}catch(l){c=!0,i=l}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}}(e,t)||j(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 I(e){return function(e){if(Array.isArray(e))return B(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(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 j(e,t){if(e){if("string"==typeof e)return B(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)?B(e,t):void 0}}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function M(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=j(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}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 s,a=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==r.return||r.return()}finally{if(o)throw s}}}}function U(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var N,F=function(){function e(){y(this,e)}return g(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(t){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],n=0,i=e.length;n<i;n++){var s=r.length;if(s&&t){var a=r[s-1],o=a[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(a[1]=u)}else r.push([e.start(n),e.end(n)])}else r.push([e.start(n),e.end(n)])}return r}},{key:"totalLength",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var i=0,s=0,a=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),h=0,f=d.length;h<f;h++){var p=d[h];if(r+n>=p[0]&&r<=p[1])i=p[0],s=p[1],a=h;else{if(r+n<p[0]){o=p[0],u=p[1];break}r+n>p[1]&&(c=p[0],l=p[1])}}return{start:i,end:s,index:a,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:s?s-r:0,length:e.totalLength&&e.totalLength(d)}}},{key:"isBuffered",value:function(t,r){if(t){var n=e.get(t);if(null!=n&&n.length)for(var i=0;i<n.length;i++)if(r>=n.start(i)&&r<=n.end(i))return!0}return!1}}]),e}(),V="undefined"!=typeof window,z="manifest",G="network",q="network_timeout",H="network_forbidden",K="network_notfound",Y="network_range_not_satisfiable",W="demux",X="remux",Q="media",J="drm",Z="other",$="runtime",ee={FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"},te=(b(N={},z,{HLS:1100,DASH:1200}),b(N,G,2100),b(N,q,2101),b(N,H,2103),b(N,K,2104),b(N,Y,2116),b(N,W,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),b(N,X,{FMP4:4100,MP4:4200}),b(N,Q,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),b(N,J,{LICENSE:7100,CUSTOM_LICENSE:7200}),b(N,Z,8e3),b(N,$,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),N),re=function(e){k(r,e);var t=L(r);function r(e,n,i,s,a){var o;return y(this,r),(o=t.call(this,a||(null==i?void 0:i.message))).errorType=e===q?G:e,o.originError=i,o.ext=s,o.errorCode=te[e][n]||te[e],o.errorMessage=o.message,o.errorCode||(o.errorType=Z,o.errorCode=te[o.errorType]),o}return g(r,null,[{key:"create",value:function(e,t,n,i,s){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=Z),new r(e,t,n,i,s))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?q:G,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}]),r}(T(Error)),ne={DEBUG:1,LOG:2,WARN:3,ERROR:4},ie=["Boolean","Number","String","Undefined","Null","Date","Object"],se=function(){function e(t,r){y(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return g(e,[{key:"debug",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[ne.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,["[".concat(ae(),"]"),this._prefix].concat(n))}},{key:"log",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[ne.LOG].concat(n)),e.disabled||(t=console).log.apply(t,["[".concat(ae(),"]"),this._prefix].concat(n))}},{key:"warn",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[ne.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,["[".concat(ae(),"]"),this._prefix].concat(n))}},{key:"error",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[ne.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,["[".concat(ae(),"]"),this._prefix].concat(n))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var s=n.map((function(e){return ue(e)}));t="[".concat(ae(),"]")+this._prefix+JSON.stringify(s)}catch(o){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var a=this.logTextArray.shift();this.logSize-=a.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join("\n");return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();function ae(){return(new Date).toLocaleString()}function oe(e){if("object"!==p(e))return e;var t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function ue(e,t,r){r||(r=1),t||(t=2);var n={};if(!e||"object"!==p(e))return e;var i=Object.prototype.toString.call(e).slice(8,-1);if(!ie.includes(i))return i;if(!(r>t)){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r===t?n[s]=oe(e[s]):"object"===p(e[s])?n[s]=ue(e[s],t,r+1):n[s]=e[s]);return n}}function ce(){var e,t,r=new Promise((function(r,n){e=r,t=n}));return r.used=!1,r.resolve=function(){return r.used=!0,e.apply(void 0,arguments)},r.reject=function(){return r.used=!0,t.apply(void 0,arguments)},r}function le(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}b(se,"disabled",!0);var de=function(e){try{return JSON.stringify(e)}catch(t){return""}};function he(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return V?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(t){}}function fe(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var pe="appendBuffer",ve="removeBuffer",me="updateDuration",ye=function(){function e(t,r){var n=this;y(this,e),b(this,"media",null),b(this,"mediaSource",null),b(this,"_openPromise",ce()),b(this,"_queue",Object.create(null)),b(this,"_sourceBuffer",Object.create(null)),b(this,"_mseFullFlag",{}),b(this,"_st",0),b(this,"_opst",0),b(this,"_logger",null),b(this,"_config",null),b(this,"_url",null),b(this,"_onStartStreaming",(function(){n._logger.debug("startstreaming")})),b(this,"_onEndStreaming",(function(){n._logger.debug("endstreaming")})),b(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==me&&t.shift(),r){var i,s,a=le()-n._opst;n._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),de(function(e){var t=[];if(e instanceof TimeRanges)for(var r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}(null===(i=n._sourceBuffer[e])||void 0===i?void 0:i.buffered)),a,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:a});var o=null===(s=r.context)||void 0===s?void 0:s.callback;o&&"function"==typeof o&&o(r.context),n._startQueue(e)}}})),b(this,"_onSBUpdateError",(function(e,t){var r=n._queue[e];if(r){var i=r[0];i&&(n._logger.error("UpdateError",e,i.opName,i.context),i.promise.reject(new re(Q,ee.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new se("MSE"),this._config.openLog&&se.enable()}var t,r,n;return g(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"hasOpTasks",get:function(){var e=this,t=!1;return Object.keys(this._queue).forEach((function(r){var n=e._queue[r];Array.isArray(n)&&(t||(t=n.length>0))})),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return!!this.mediaSource&&"ended"===this.mediaSource.readyState}},{key:"streaming",get:function(){return!fe(this.mediaSource)||this.mediaSource.streaming}},{key:"isFull",value:function(t){return t?this._mseFullFlag[t]:this._mseFullFlag[e.VIDEO]}},{key:"updateDuration",value:function(e){var t=this,r=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var n=0;if(Object.keys(this._sourceBuffer).forEach((function(e){try{n=Math.max(t.bufferEnd(e)||0,n)}catch(r){}})),e<n)return Promise.resolve()}return this._enqueueBlockingOp((function(){t.isEnded?t._logger.debug("setDuration but ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))}),me,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function r(){var n=le()-e._st;e._logger.debug("sourceopen",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=ce()}return this._openPromise}},{key:"bindMedia",value:(n=m(f().mark((function e(t){var r,n,i,s,a=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(r=he(this._config.preferMMS),t&&r){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,n=this.mediaSource=new r,i=fe(n),this._st=le(),s=function e(){var r=le()-a._st;a._logger.debug("sourceopen"),n.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),a._openPromise.resolve({costtime:r})},n.addEventListener("sourceopen",s),i&&(n.addEventListener("startstreaming",this._onStartStreaming),n.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(n),t.src=this._url,t.disableRemotePlayback=i,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unbindMedia",value:(r=m(f().mark((function e(){var t,r,n,i=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),t=this.mediaSource){if(Object.keys(this._queue).forEach((function(e){var t=i._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),r=!!this.media&&this.media.readyState>=1,n="open"===t.readyState,r&&n)try{t.endOfStream()}catch(s){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(i._sourceBuffer[e])}catch(s){}})),fe(t)&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(s){}this.media=null}this.mediaSource=null,this._openPromise=ce(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new re(Q,ee.MSE_ADD_SB,n)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,n=this._sourceBuffer[e];return this.mediaSource&&n&&n.mimeType!==t?"function"!=typeof n.changeType?Promise.reject(new re(Q,ee.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{n.changeType(t)}catch(i){throw new re(Q,ee.MSE_CHANGE_TYPE,i)}n.mimeType=t,r._onSBUpdateEnd(e)}),"changeType",{mimeType:t}):Promise.resolve()}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,r){var n=this;return t&&t.byteLength&&this._sourceBuffer[e]?this._enqueueOp(e,(function(){var i;n.mediaSource&&!n.media.error&&(n._logger.debug("MSE APPEND START",r),n._opst=le(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),pe,r):Promise.resolve()}},{key:"remove",value:function(e,t,r,n){var i=this,s=!1;return this._mseFullFlag[e]&&(s=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var s=i._sourceBuffer[e];t>=r||!s?i._onSBUpdateEnd(e):(i._opst=le(),i._logger.debug("MSE REMOVE START",e,t,r,n),s.remove(t,r))}}),ve,n,s)}},{key:"clearBuffer",value:function(e,t){var r,n=this;return Object.keys(this._sourceBuffer).forEach((function(i){r=n.remove(i,e,t)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){var n=t._sourceBuffer[r];e=t.remove(r,0,F.end(F.get(n)))})),e}},{key:"clearOpQueues",value:function(e,t){var r;this._logger.debug("MSE clearOpQueue START");var n=this._queue[e];if(t&&n)this._queue[e]=[];else if(n&&n[e]&&!(n.length<5)){var i=[];n.forEach((function(e){e.context&&e.context.isinit&&i.push(e)})),this._queue[e]=n.slice(0,2),i.length>0&&(r=this._queue[e]).push.apply(r,i)}}},{key:"endOfStream",value:function(e){var t=this;return this.mediaSource&&"open"===this.mediaSource.readyState?this._enqueueBlockingOp((function(){var r=t.mediaSource;r&&"open"===r.readyState&&(t._logger.debug("MSE endOfStream START"),e?r.endOfStream(e):r.endOfStream())}),"endOfStream"):Promise.resolve()}},{key:"setLiveSeekableRange",value:function(e,t){var r=this.mediaSource;e<0||t<e||null==r||!r.setLiveSeekableRange||"open"!==r.readyState||r.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return F.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return F.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return F.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,n,i){var s=this;if(!this.mediaSource)return Promise.resolve();var a=this._queue[e]=this._queue[e]||[],o={exec:t,promise:ce(),opName:r,context:n};return i?(a.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):a.push(o),this.isOpened||this.isEnded?1===a.length&&this._startQueue(e):this._openPromise.then((function(){1===a.length&&s._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=m(f().mark((function e(t,r,n){var i,s,a=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaSource){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:if((i=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],i.forEach((function(e){var t=a._queue[e],i=ce();s.push(i),t.push({exec:function(){i.resolve()},promise:i,opName:r,context:n}),1===t.length&&a._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{i.forEach((function(e){var t=a._queue[e],r=a._sourceBuffer[e];null==t||t.shift(),r&&r.updating||a._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(s){var n,i;if(s&&s.message&&s.message.indexOf("SourceBuffer is full")>=0)this._mseFullFlag[e]=!0,r.context&&"object"===p(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),null==r||null===(n=r.promise)||void 0===n||n.reject(new re(Q,ee.MSE_FULL,s));else this._logger.error(s),null==r||null===(i=r.promise)||void 0===i||i.reject(s.constructor===re?s:new re(Q,ee.MSE_OTHER,s)),t.shift(),this._startQueue(e)}}}},{key:"setTimeoffset",value:function(e,t,r){var n=this;return this._enqueueOp(e,(function(){t<0&&(t+=.001),n._sourceBuffer[e].timestampOffset=t,n._onSBUpdateEnd(e)}),"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,(function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=he();if(!t)return!1;try{return t.isTypeSupported(e)}catch(r){return this._logger.error(e,r),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();b(ye,"VIDEO","video"),b(ye,"AUDIO","audio");var _e="fetch",ge="xhr",be="arraybuffer",ke="text",Se="json",Ee=function(e){k(r,e);var t=L(r);function r(e,n,i,s){var a;return y(this,r),b(A(a=t.call(this,s)),"retryCount",0),b(A(a),"isTimeout",!1),b(A(a),"loaderType",_e),b(A(a),"startTime",0),b(A(a),"endTime",0),b(A(a),"options",{}),a.url=e,a.request=n,a.response=i,a}return g(r)}(T(Error)),xe=Object.prototype.toString;function we(e){if("[object Object]"!==xe.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Te(e){if(e&&null!==e[0]&&void 0!==e[0]&&(0!==e[0]||null!==e[1]&&void 0!==e[1])){var t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function De(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ae(e,t){if(e){if(!t)return e;var r,n=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===xe.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===p(e)}(t)&&(t=JSON.stringify(t)),"".concat(De(e),"=").concat(De(t))})).join("&")})).filter(Boolean).join("&");if(n){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e}}function Ce(e,t,r,n,i,s,a,o,u,c,l){return i=null!=i?parseFloat(i):null,n=parseInt(n||"0",10),Number.isNaN(n)&&(n=0),{data:e,done:t,options:{range:u,vid:c,index:o,contentLength:n,age:i,startTime:s,firstByteTime:a,endTime:Date.now(),priOptions:l},response:r}}function Le(e,t){return Math.round(8*e*1e3/t/1024)}var Re={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"},Oe={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,s||e,a),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},o.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a},o.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,i,s,a){var o=r?r+e:e;if(!this._events[o])return!1;var u,c,l=this._events[o],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,s),!0;case 6:return l.fn.call(l.context,t,n,i,s,a),!0}for(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var h,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,i);break;default:if(!u)for(h=1,u=new Array(d-1);h<d;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].context,u)}}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||a(this,s);else{for(var u=0,c=[],l=o.length;u<l;u++)(o[u].fn!==t||i&&!o[u].once||n&&o[u].context!==n)&&c.push(o[u]);c.length?this._events[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,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}(Oe);var Pe=Oe.exports,Ie=2097152,je=function(e){k(n,e);var t,r=L(n);function n(){var e;return y(this,n),b(A(e=r.call(this)),"_abortController",null),b(A(e),"_timeoutTimer",null),b(A(e),"_reader",null),b(A(e),"_response",null),b(A(e),"_aborted",!1),b(A(e),"_index",-1),b(A(e),"_range",null),b(A(e),"_receivedLength",0),b(A(e),"_running",!1),b(A(e),"_logger",null),b(A(e),"_vid",""),b(A(e),"_onProcessMinLen",0),b(A(e),"_onCancel",null),b(A(e),"_priOptions",null),e}return g(n,[{key:"load",value:function(e){var t,r=this,n=e.url,i=e.vid,s=e.timeout,a=e.responseType,o=e.onProgress,u=e.index,c=e.onTimeout,l=e.onCancel,d=e.range,h=e.transformResponse,p=e.request,v=e.params,y=e.logger,_=e.method,g=e.headers,b=e.body,k=e.mode,S=e.credentials,E=e.cache,x=e.redirect,w=e.referrer,T=e.referrerPolicy,D=e.onProcessMinLen,A=e.priOptions;this._logger=y,this._aborted=!1,this._onProcessMinLen=D,this._onCancel=l,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=u,this._range=d||[0,0],this._vid=i||n,this._priOptions=A||{};var C={method:_,headers:g,body:b,mode:k,credentials:S,cache:E,redirect:x,referrer:w,referrerPolicy:T,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},L=!1;clearTimeout(this._timeoutTimer),n=Ae(n,v);var R=Te(d);R&&(g=p?p.headers:C.headers=C.headers||(Headers?new Headers:{}),Headers&&g instanceof Headers?g.append("Range",R):g.Range=R),s&&(this._timeoutTimer=setTimeout((function(){if(L=!0,r.cancel(),c){var e=new Ee(n,C,null,"timeout");e.isTimeout=!0,c(e,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})}}),s));var O=Date.now();return this._logger.debug("[fetch load start], index,",u,",range,",d),new Promise((function(e,t){fetch(p||n,p?void 0:C).then(function(){var i=m(f().mark((function i(s){var c,l,p,v;return f().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=s,!r._aborted&&r._running){i.next=4;break}return i.abrupt("return");case 4:if(h&&(s=h(s,n)||s),s.ok){i.next=7;break}throw new Ee(n,C,s,"bad network response");case 7:if(c=Date.now(),a!==ke){i.next=15;break}return i.next=11,s.text();case 11:l=i.sent,r._running=!1,i.next=37;break;case 15:if(a!==Se){i.next=22;break}return i.next=18,s.json();case 18:l=i.sent,r._running=!1,i.next=37;break;case 22:if(!o){i.next=29;break}return r.resolve=e,r.reject=t,r._loadChunk(s,o,O,c),i.abrupt("return");case 29:return i.next=31,s.arrayBuffer();case 31:l=i.sent,l=new Uint8Array(l),r._running=!1,p=Date.now()-O,v=Le(l.byteLength,p),r.emit(Re.REAL_TIME_SPEED,{speed:v,len:l.byteLength,time:p,vid:r._vid,index:r._index,range:r._range,priOptions:r._priOptions});case 37:r._logger.debug("[fetch load end], index,",u,",range,",d),e(Ce(l,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),O,c,u,d,r._vid,r._priOptions));case 39:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}()).catch((function(e){var i;clearTimeout(r._timeoutTimer),r._running=!1,r._aborted&&!L||((e=e instanceof Ee?e:new Ee(n,C,null,null===(i=e)||void 0===i?void 0:i.message)).startTime=O,e.endTime=Date.now(),e.isTimeout=L,e.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},t(e))}))}))}},{key:"cancel",value:(t=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._aborted){e.next=2;break}return e.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){e.next=14;break}if(e.prev=5,!this._reader){e.next=9;break}return e.next=9,this._reader.cancel();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(t){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return t.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,r,n){var i=this;if(!e.body||!e.body.getReader){this._running=!1;var s=new Ee(e.url,"",e,"onProgress of bad response.body.getReader");return s.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(s)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Ie),this._writeIdx=0);var a,o,u,c=this._reader=e.body.getReader(),l=function(){var s=m(f().mark((function s(){var d,h,p,v,m,y,_,g;return f().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Date.now(),s.prev=1,s.next=4,c.read();case 4:a=s.sent,u=Date.now(),s.next=13;break;case 8:return s.prev=8,s.t0=s.catch(1),u=Date.now(),i._aborted||(i._running=!1,s.t0.options={index:i._index,range:i._range,vid:i._vid,priOptions:i._priOptions},i.reject(s.t0)),s.abrupt("return");case 13:if(h=(null===(d=i._range)||void 0===d?void 0:d.length)>0?i._range[0]:0,p=h+i._receivedLength,!i._aborted){s.next=19;break}return i._running=!1,t(void 0,!1,{range:[p,p],vid:i._vid,index:i._index,startTime:o,endTime:u,st:r,firstByteTime:n,priOptions:i._priOptions},e),s.abrupt("return");case 19:v=a.value?a.value.byteLength:0,i._receivedLength+=v,i._logger.debug("【fetchLoader,onProgress call】,task,",i._range,", start,",p,", end,",h+i._receivedLength,", done,",a.done),i._onProcessMinLen>0?i._writeIdx+v>=i._onProcessMinLen||a.done?((m=new Uint8Array(i._writeIdx+v)).set(i._cache.slice(0,i._writeIdx),0),v>0&&m.set(a.value,i._writeIdx),i._writeIdx=0,i._logger.debug("【fetchLoader,onProgress enough】,done,",a.done,",len,",m.byteLength,", writeIdx,",i._writeIdx)):v>0&&i._writeIdx+v<Ie?(i._cache.set(a.value,i._writeIdx),i._writeIdx+=v,i._logger.debug("【fetchLoader,onProgress cache】,len,",v,", writeIdx,",i._writeIdx)):v>0&&(y=new Uint8Array(i._writeIdx+v+2048),i._logger.debug("【fetchLoader,onProgress extra start】,size,",i._writeIdx+v+2048,", datalen,",v,", writeIdx,",i._writeIdx),y.set(i._cache.slice(0,i._writeIdx),0),v>0&&y.set(a.value,i._writeIdx),i._writeIdx+=v,delete i._cache,i._cache=y,i._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",i._writeIdx)):m=a.value,(m&&m.byteLength>0||a.done)&&t(m,a.done,{range:[i._range[0]+i._receivedLength-(m?m.byteLength:0),i._range[0]+i._receivedLength],vid:i._vid,index:i._index,startTime:o,endTime:u,st:r,firstByteTime:n,priOptions:i._priOptions},e),a.done?(_=Date.now()-r,g=Le(i._receivedLength,_),i.emit(Re.REAL_TIME_SPEED,{speed:g,len:i._receivedLength,time:_,vid:i._vid,index:i._index,range:i._range,priOptions:i._priOptions}),i._running=!1,i._logger.debug("[fetchLoader onProgress end],task,",i._range,",done,",a.done),i.resolve(Ce(a,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),r,n,i._index,i._range,i._vid,i._priOptions))):l();case 25:case"end":return s.stop()}}),s,null,[[1,8]])})));return function(){return s.apply(this,arguments)}}();l()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}}],[{key:"isSupported",value:function(){return!("undefined"==typeof fetch)}}]),n}(Pe);var Be=function(e){k(r,e);var t=L(r);function r(){var e;return y(this,r),b(A(e=t.call(this)),"_xhr",null),b(A(e),"_aborted",!1),b(A(e),"_timeoutTimer",null),b(A(e),"_range",null),b(A(e),"_receivedLength",0),b(A(e),"_url",null),b(A(e),"_onProgress",null),b(A(e),"_index",-1),b(A(e),"_headers",null),b(A(e),"_currentChunkSizeKB",384),b(A(e),"_timeout",null),b(A(e),"_xhr",null),b(A(e),"_withCredentials",null),b(A(e),"_startTime",-1),b(A(e),"_loadCompleteResolve",null),b(A(e),"_loadCompleteReject",null),b(A(e),"_runing",!1),b(A(e),"_logger",!1),b(A(e),"_vid",""),b(A(e),"_responseType",void 0),b(A(e),"_credentials",void 0),b(A(e),"_method",void 0),b(A(e),"_transformResponse",void 0),b(A(e),"_firstRtt",void 0),b(A(e),"_onCancel",null),b(A(e),"_priOptions",null),e}return g(r,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=Ae(e.url,e.params);var r=Date.now();return new Promise((function(e,r){t._loadCompleteResolve=e,t._loadCompleteReject=r,t._startLoad()})).catch((function(e){if(clearTimeout(t._timeoutTimer),t._runing=!1,!t._aborted)throw(e=e instanceof Ee?e:new Ee(t._url,t._request)).startTime=r,e.endTime=Date.now(),e.options={index:t._index,vid:t._vid,priOptions:t._priOptions},e}))}},{key:"_startLoad",value:function(){var e=null;if(this._responseType===be&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,r=this._range[0]+this._receivedLength,n=this._range[1];t<this._range[1]-r&&(n=r+t),e=[r,n],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var t=this;try{this._startTime=Date.now();var r=this._xhr=new XMLHttpRequest;r.open(this._method||"GET",this._url,!0),r.responseType=this._responseType,this._timeout&&(r.timeout=this._timeout),r.withCredentials=this._withCredentials,r.onload=this._onLoad.bind(this),r.onreadystatechange=this._onReadyStatechange.bind(this),r.onerror=function(e){var r,n,i;t._running=!1;var s=new Ee(t._url,t._request,null==e||null===(r=e.currentTarget)||void 0===r?void 0:r.response,"xhr.onerror.status:"+(null==e||null===(n=e.currentTarget)||void 0===n?void 0:n.status)+",statusText,"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.statusText));s.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(s)},r.ontimeout=function(e){t.cancel();var r=new Ee(t._url,t._request,{status:408},"timeout");t._onTimeout&&(r.isTimeout=!0,t._onTimeout(r,{index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions})),r.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(r)};var n=this._headers||{},i=Te(e);i&&(n.Range=i),n&&Object.keys(n).forEach((function(e){r.setRequestHeader(e,n[e])})),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e),r.send(this._body)}catch(s){s.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(s)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var t,r=e.target.status;if(r<200||r>299){var n=new Ee(this._url,null,h(h({},e.target.response),{},{status:r}),"bad response,status:"+r);return n.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(n)}var i,s=null,a=!1,o=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===be){var u,c=new Uint8Array(e.target.response);if(i=o+this._receivedLength,c&&c.byteLength>0){this._receivedLength+=c.byteLength;var l=Date.now()-this._startTime,d=Le(this._receivedLength,l);this.emit(Re.REAL_TIME_SPEED,{speed:d,len:this._receivedLength,time:l,vid:this._vid,index:this._index,range:[i,o+this._receivedLength],priOptions:this._priOptions})}s=c,a=!((null===(u=this._range)||void 0===u?void 0:u.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",i,"end ",o+this._receivedLength,",dataLen,",c?c.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",a)}else a=!0,s=e.target.response;var f={ok:r>=200&&r<300,status:r,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(f=this._transformResponse(f,this._url)||f),this._onProgress&&this._onProgress(s,a,{index:this._index,vid:this._vid,range:[i,o+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},f),a?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(Ce(this._onProgress?null:s,a,f,f.headers["content-length"],f.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._runing=!1,O(S(r.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var t,r={},n=M(e.getAllResponseHeaders().trim().split("\r\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value.split(": ");r[i[0].toLowerCase()]=i.slice(1).join(": ")}}catch(s){n.e(s)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),r}(Pe),Me=["retry","retryDelay","onRetryError","transformError"],Ue=function(){function e(t,r){y(this,e),this.promise=ce(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new se("Loader")),this._loaderType=t,this._loader=t===_e&&"undefined"!=typeof fetch?new je:new Be,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return g(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,n=t.retryDelay,i=t.onRetryError,s=t.transformError,a=D(t,Me),o=function(){var t=m(f().mark((function t(){var u,c,l;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(a);case 3:u=t.sent,e.promise.resolve(u),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,c=t.t0,s&&(c=s(c)||c),i&&e._retryCount>0&&i(c,e._retryCount,{index:a.index,vid:a.vid,range:a.range,priOptions:a.priOptions}),e._retryCount++,l=!0,e._retryCheckFunc&&(l=e._retryCheckFunc(t.t0)),!(l&&e._retryCount<=r)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",a.range),e._retryTimer=setTimeout(o,n),t.abrupt("return");case 26:e.promise.reject(c);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return o(),this.promise}},{key:"cancel",value:(t=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,e.abrupt("return",this._loader.cancel());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),e}();function Ne(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if((t=t.filter(Boolean)).length<2)return t[0];var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}function Fe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var Ve=function(e){k(n,e);var t,r=L(n);function n(e){var t;return y(this,n),b(A(t=r.call(this,e)),"type",_e),b(A(t),"_queue",[]),b(A(t),"_alive",[]),b(A(t),"_currentTask",null),b(A(t),"_finnalUrl",""),b(A(t),"_config",void 0),t._config=function(e){return h({loaderType:_e,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:ke,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}(e),t._config.loaderType!==ge&&je.isSupported()||(t.type=ge),t.log=e.logger,t}return g(n,[{key:"isFetch",value:function(){return this.type===_e}},{key:"load",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?r=e:r.url=e||r.url||this._config.url,(r=Object.assign({},this._config,r)).params&&(r.params=Object.assign({},r.params)),r.headers&&we(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&we(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new Ue(this.type,r);return n.loader.on(Re.REAL_TIME_SPEED,(function(e){t.emit(Re.REAL_TIME_SPEED,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(t=m(f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._queue.map((function(e){return e.cancel()})).concat(this._alive.map((function(e){return e.cancel()}))),this._currentTask&&t.push(this._currentTask.cancel()),this._queue=[],this._alive=[],e.next=6,Promise.all(t);case 6:return e.next=8,Fe();case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var t=this._currentTask.exec().catch((function(e){}));t&&"function"==typeof t.finally&&t.finally((function(){var t,r;null!==(t=e._currentTask)&&void 0!==t&&t.alive&&(null===(r=e._alive)||void 0===r?void 0:r.length)>0&&(e._alive=e._alive.filter((function(t){return t&&t!==e._currentTask}))),e._processTask()}))}}}],[{key:"isFetchSupport",value:function(){return je.isSupported()}}]),n}(Pe),ze=function(){function e(){y(this,e),b(this,"_prevCurrentTime",0)}return g(e,[{key:"do",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(e){var i=e.currentTime,s=0;if(this._prevCurrentTime===i){var a=F.info(F.get(e),i);if(!a.buffers.length)return;r&&a.nextStart||a.nextStart&&a.nextStart-i<t?s=a.nextStart+.1:a.end&&a.end-i>n&&!e.seeking&&(s=i+.1)}this._prevCurrentTime=i,s&&i!==s&&(e.currentTime=s)}}}]),e}(),Ge=function(){function e(t){var r=this;y(this,e),b(this,"_seiSet",new Set),this.emitter=t,t.on(Re.SEI,(function(e){e&&r._seiSet.add(e)}))}return g(e,[{key:"throw",value:function(e,t){var r=this;if(null!=e&&this._seiSet.size){var n=e-.2,i=e+.2,s=[];this._seiSet.forEach((function(e){e.time>=n&&e.time<=i&&s.push(e)})),s.forEach((function(e){r._seiSet.delete(e),r.emitter.emit(Re.SEI_IN_TIME,e)})),t&&this._seiSet.forEach((function(t){t.time<e-5&&r._seiSet.delete(t)}))}}},{key:"reset",value:function(){this._seiSet.clear()}}]),e}(),qe=function(){function e(t){y(this,e),b(this,"_chunkSpeed",0),b(this,"_chunkCache",[]),b(this,"_speeds",[]),b(this,"_totalSize",0),b(this,"_totalCost",0),this._opts=t||{}}return g(e,[{key:"addRecord",value:function(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){var r,n;if(e&&t&&!(e<((null===(r=this._opts)||void 0===r?void 0:r.skipChunkSize)||1e3))){this._totalSize+=e,this._totalCost+=t,this._chunkSpeed=8e3*e/t,this._chunkCache.push({size:e,duration:t,timestamp:performance.now()});var i=(null===(n=this._opts)||void 0===n?void 0:n.chunkCountForSpeed)||50;this._chunkCache.length>i&&(this._chunkCache=this._chunkCache.slice(-i))}}},{key:"getAvgSpeed",value:function(){var e;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce((function(e,t){return e+t}))/this._speeds.length;var t=this._chunkCache[this._chunkCache.length-1],r=performance.now()-t.timestamp;return r>((null===(e=this._opts)||void 0===e?void 0:e.longtimeNoReceived)||3e3)&&this._chunkCache.push({size:0,duration:r,timestamp:performance.now()}),8e3*this._chunkCache.reduce((function(e,t){return e+t.size}),0)/this._chunkCache.reduce((function(e,t){return e+t.duration}),0)}},{key:"getLatestSpeed",value:function(){return this._chunkCache.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed:0}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),e}(),He=function(){function e(t){y(this,e),b(this,"encodeType",""),b(this,"audioCodec",""),b(this,"videoCodec",""),b(this,"domain",""),b(this,"fps",0),b(this,"bitrate",0),b(this,"width",0),b(this,"height",0),b(this,"samplerate",0),b(this,"channelCount",0),b(this,"gop",0),b(this,"_bitsAccumulateSize",0),b(this,"_bitsAccumulateDuration",0),b(this,"_startGopId",-1),this._timescale=t}return g(e,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var t,r=e.data,n=null==r||null===(t=r.onMetaData)||void 0===t?void 0:t.framerate;n&&n>0&&n<100&&(this.fps=n)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce((function(e,t){return e+t.duration}),0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach((function(e){-1===t._startGopId&&(t._startGopId=e.gopId),e.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=e.duration/(t._timescale/1e3),t._bitsAccumulateSize+=e.units.reduce((function(e,t){return e+t.length}),0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=8*t._bitsAccumulateSize,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)}))}}]),e}(),Ke=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;y(this,e),b(this,"_core",null),b(this,"_samples",[]),this._core=t,this._timescale=r,this._stats=new He(r),this._bindEvents()}return g(e,[{key:"getStats",value:function(){var e,t,r,n,i,s,a,o,u,c,l,d=(null===(e=this._core)||void 0===e?void 0:e.media)||{},f=d.currentTime,p=void 0===f?0:f,v=d.decodeFps,m=void 0===v?0:v;return h(h({},this._stats.getStats()),{},{downloadSpeed:(null===(t=this._core)||void 0===t||null===(r=t.speedInfo)||void 0===r?void 0:r.call(t).speed)||0,avgSpeed:(null===(n=this._core)||void 0===n||null===(i=n.speedInfo)||void 0===i?void 0:i.call(n).avgSpeed)||0,totalReceivedByte:(null===(s=this._core)||void 0===s||null===(a=s.speedInfo)||void 0===a?void 0:a.call(s).totalSize)||0,totalReceivedCost:(null===(o=this._core)||void 0===o||null===(u=o.speedInfo)||void 0===u?void 0:u.call(o).totalCost)||0,currentTime:p,bufferEnd:(null===(c=this._core)||void 0===c||null===(l=c.bufferInfo())||void 0===l?void 0:l.remaining)||0,decodeFps:m})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(Re.DEMUXED_TRACK,(function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)})),this._core.on(Re.FLV_SCRIPT_DATA,(function(t){e._stats.setFpsFromScriptData(t)})),this._core.on(Re.METADATA_PARSED,(function(t){"video"===t.type?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)})),this._core.on(Re.TTFB,(function(t){e._stats.setDomain(t.responseUrl)}))}},{key:"reset",value:function(){this._samples=[],this._stats=new He(this._timescale)}}]),e}(),Ye="video",We="audio",Xe="metadata",Qe="av1",Je="avc",Ze="hevc",$e="aac",et="g7110a",tt="g7110m",rt="opus",nt="mp3",it="LARGE_AV_SHIFT",st="LARGE_VIDEO_GAP",at="LARGE_VIDEO_GAP_BETWEEN_CHUNK",ot="LARGE_AUDIO_GAP",ut="AUDIO_FILLED",ct="AUDIO_DROPPED",lt=function(){function e(){y(this,e),b(this,"id",1),b(this,"type",Ye),b(this,"codecType",Je),b(this,"pid",-1),b(this,"hvcC",void 0),b(this,"codec",""),b(this,"timescale",0),b(this,"formatTimescale",0),b(this,"sequenceNumber",0),b(this,"baseMediaDecodeTime",0),b(this,"baseDts",0),b(this,"duration",0),b(this,"warnings",[]),b(this,"samples",[]),b(this,"pps",[]),b(this,"sps",[]),b(this,"vps",[]),b(this,"fpsNum",0),b(this,"fpsDen",0),b(this,"sarRatio",[]),b(this,"width",0),b(this,"height",0),b(this,"nalUnitSize",4),b(this,"present",!1),b(this,"isVideoEncryption",!1),b(this,"isAudioEncryption",!1),b(this,"isVideo",!0),b(this,"lastKeyFrameDts",0),b(this,"kid",null),b(this,"pssh",null),b(this,"ext",void 0)}return g(e,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}},{key:"exist",value:function(){return!!/av01/.test(this.codec)||!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),dt=function(){function e(){y(this,e),b(this,"id",2),b(this,"type",We),b(this,"codecType",$e),b(this,"pid",-1),b(this,"codec",""),b(this,"container",""),b(this,"sequenceNumber",0),b(this,"sampleDuration",0),b(this,"timescale",0),b(this,"formatTimescale",0),b(this,"baseMediaDecodeTime",0),b(this,"duration",0),b(this,"warnings",[]),b(this,"samples",[]),b(this,"baseDts",0),b(this,"sampleSize",16),b(this,"sampleRate",0),b(this,"channelCount",0),b(this,"objectType",0),b(this,"sampleRateIndex",0),b(this,"config",[]),b(this,"present",!1),b(this,"isVideoEncryption",!1),b(this,"isAudioEncryption",!1),b(this,"kid",null),b(this,"ext",void 0)}return g(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!(!this.sampleRate||!this.channelCount||!this.codec&&!this.container||this.codecType!==$e&&this.codecType!==et&&this.codecType!==tt&&this.codecType!==rt&&this.codecType!==nt)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}}]),e}(),ht=function(){function e(t,r,n){y(this,e),b(this,"flag",{}),b(this,"keyframe",!1),b(this,"gopId",0),b(this,"duration",0),b(this,"size",0),b(this,"units",[]),b(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return g(e,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),e}(),ft=g((function e(t,r,n,i){y(this,e),b(this,"duration",1024),b(this,"flag",{dependsOn:2,isNonSyncSample:0}),b(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),pt=g((function e(t,r){y(this,e),b(this,"time",0),this.data=t,this.originPts=this.pts=r})),vt=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r)}(pt),mt=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r)}(pt),yt=function(){function e(){y(this,e),b(this,"id",3),b(this,"type",Xe),b(this,"timescale",0),b(this,"flvScriptSamples",[]),b(this,"seiSamples",[])}return g(e,[{key:"exist",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length||!this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length)}}]),e}(),_t=function(){function e(t){if(y(this,e),b(this,"_bytesAvailable",void 0),b(this,"_bitsAvailable",0),b(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return g(e,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),(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:"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:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,n=0;n<e;n++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),gt=function(){function e(t){y(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return g(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();b(gt,"disabled",!0);var bt=function(){function e(){y(this,e)}return g(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,s=t.length;i<s;)if(n[i]<128)r.push(String.fromCharCode(n[i])),++i;else{if(n[i]<192);else if(n[i]<224){if(e._checkContinuation(n,i,1)){var a=(31&n[i])<<6|63&n[i+1];if(a>=128){r.push(String.fromCharCode(65535&a)),i+=2;continue}}}else if(n[i]<240){if(e._checkContinuation(n,i,2)){var o=(15&n[i])<<12|(63&n[i+1])<<6|63&n[i+2];if(o>=2048&&55296!=(63488&o)){r.push(String.fromCharCode(65535&o)),i+=3;continue}}}else if(n[i]<248&&e._checkContinuation(n,i,3)){var u=(7&n[i])<<18|(63&n[i+1])<<12|(63&n[i+2])<<6|63&n[i+3];if(u>65536&&u<1114112){u-=65536,r.push(String.fromCharCode(u>>>10|55296)),r.push(String.fromCharCode(1023&u|56320)),i+=4;continue}}r.push(String.fromCharCode(65533)),++i}return r.join("")}},{key:"_checkContinuation",value:function(e,t,r){var n=e;if(t+r<n.length){for(;r--;)if(128!=(192&n[++t]))return!1;return!0}return!1}}]),e}(),kt="undefined"!=typeof window,St=kt&&navigator.userAgent.toLocaleLowerCase(),Et=kt&&/^((?!chrome|android).)*safari/.test(St),xt=kt&&St.includes("firefox"),wt=kt&&St.includes("android");function Tt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}var Dt=Math.pow(2,32);function At(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function Ct(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Lt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Ct(e,t)*Dt+Ct(e,t+4)}function Rt(e){for(var t,r="avc1.",n=0;n<3;n++)(t=e[n].toString(16)).length<2&&(t="0".concat(t)),r+=t;return r}function Ot(e){if(!Array.isArray(e)){for(var t=[],r="",n=0;n<e.length;n++)n%2&&(r=e[n-1]+e[n],t.push(parseInt(r,16)),r="");return t}return e.map((function(e){return parseInt(e,16)}))}function Pt(e,t){return Number(e+"."+t)}var It=function(){function e(){y(this,e)}return g(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var n=t.length,i=0;i+2<n&&(255!==t[i]||240!=(246&t[i+1]));)i++;if(!(i>=n)){var s=i,a=[],o=(60&t[i+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var c,l,d=1+((192&t[i+2])>>>6),h=(1&t[i+2])<<2|(192&t[i+3])>>>6,f=e._getConfig(o,h,d),p=f.config,v=f.codec,m=0,y=e.getFrameDuration(u);i+7<n;)if(255===t[i]&&240==(246&t[i+1])){if(!(l=(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>5)||n-i<l)break;c=2*(1&~t[i+1]),a.push({pts:r+m*y,data:t.subarray(i+7+c,i+l)}),m++,i+=l}else i++;return{skip:s,remaining:i>=n?void 0:t.subarray(i),frames:a,samplingFrequencyIndex:o,sampleRate:u,objectType:d,channelCount:h,codec:v,config:p,originCodec:"mp4a.40.".concat(d)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(t.length){var r=t[0]>>>3,n=(7&t[0])<<1|t[1]>>>7,i=(120&t[1])>>>3,s=e.FREQ[n];if(s){var a=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:s,objectType:r,channelCount:i,config:a.config,codec:a.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n,i,s=[];return xt?e>=6?(n=5,i=e-3):(n=2,i=e):wt?(n=2,i=e):(n=5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),s[0]=n<<3,s[0]|=(14&e)>>1,s[1]=(1&e)<<7,s[1]|=t<<3,5===n&&(s[1]|=(14&i)>>1,s[2]=(1&i)<<7,s[2]|=8,s[3]=0),{config:s,codec:"mp4a.40.".concat(n)}}},{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}();b(It,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var jt=function(){function e(){y(this,e)}return g(e,null,[{key:"parseAnnexB",value:function(e){var t=e.byteLength-1,r=0;do{if(0!==e[t])break;r++,t--}while(t>0);r>=3&&(e=e.subarray(0,t+1));for(var n=e.length,i=2,s=0;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if((s=++i+2)>=n)return[];for(var a=[];s<n;)switch(e[s]){case 0:if(0!==e[s-1]){s+=2;break}if(0!==e[s-2]){s++;break}if(s<n-1&&1!==e[s+1]){s++;break}i!==s-2&&a.push(e.subarray(i,s-2));do{s++}while(1!==e[s]&&s<n);s=(i=s+1)+2;break;case 1:if(0!==e[s-1]||0!==e[s-2]){s+=3;break}i!==s-2&&a.push(e.subarray(i,s-2)),s=(i=s+1)+2;break;default:s+=3}return i<n&&a.push(e.subarray(i)),a}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(!(e.length<4)){for(var r,n=e.length,i=[],s=0;s+t<n;)if(r=Ct(e,s),3===t&&(r>>>=8),s+=t,r){if(s+r>n)break;i.push(e.subarray(s,s+r)),s+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,s=0,a="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)s+=255,n++;if(s+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)a+=e[n].toString(16),n++;return{payload:e.subarray(n,n+s),type:i,size:s,uuid:a}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(!r.length)return e;var i=t-r.length,s=new Uint8Array(i),a=0;for(n=0;n<i;a++,n++)a===r[0]&&(a++,r.shift()),s[n]=e[a];return s}}]),e}(),Bt=function(){function e(){y(this,e)}return g(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),s=[],a=[],o=6,u=31&t[5],c=0;c<u;c++)if(n=t[o]<<8|t[o+1],o+=2,n){var l=t.subarray(o,o+n);o+=n,s.push(l),r||(r=e.parseSPS(jt.removeEPB(l)))}var d,h=t[o];o++;for(var f=0;f<h;f++)d=t[o]<<8|t[o+1],o+=2,d&&(a.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:s,ppsArr:a,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new _t(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var s=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var a=t.readUEG();if(a<=3&&(s=[0,420,422,444][a]),3===a&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==a?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var c=t.readUEG();if(0===c)t.readUEG();else if(1===c){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var l=t.readUEG(),d=0;d<l;d++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var h=t.readUEG(),f=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,m,y,_,g,b=0,k=0,S=0,E=0;if(t.readBool()&&(b=t.readUEG(),k=t.readUEG(),S=t.readUEG(),E=t.readUEG()),t.readBool()){if(t.readBool())switch(t.readUByte()){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:v=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()]}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var x=t.readBits(32),w=t.readBits(32);m=t.readBool(),g=(y=w)/(_=2*x)}}return{codec:Rt(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:s,width:Math.ceil(16*(h+1)-2*(b+k)),height:(2-p)*(f+1)*16-(p?2:4)*(S+E),sarRatio:v,fpsNum:y,fpsDen:_,fps:g,fixedFrame:m}}}]),e}(),Mt=function(){function e(){y(this,e)}return g(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var n,i,s,a,o,u=1+(3&t[21]),c=[],l=[],d=[],h=23,f=t[22],p=0;p<f;p++){s=63&t[h],a=t[h+1]<<8|t[h+2],h+=3;for(var v=0;v<a;v++)if(o=t[h]<<8|t[h+1],h+=2,o){switch(s){case 32:var m=t.subarray(h,h+o);n||(n=e.parseVPS(jt.removeEPB(m),r)),d.push(m);break;case 33:var y=t.subarray(h,h+o);i||(i=e.parseSPS(jt.removeEPB(y),r)),c.push(y);break;case 34:l.push(t.subarray(h,h+o))}h+=o}}return{hvcC:r,sps:i,spsArr:c,ppsArr:l,vpsArr:d,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var n=new _t(t);n.readUByte(),n.readUByte(),n.readBits(12);var i=n.readBits(3);return r.numTemporalLayers=Math.max(r.numTemporalLayers||0,i+1),n.readBits(17),e._parseProfileTierLevel(n,i,r),r}},{key:"parseSPS",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r=r||{};var n=new _t(t);n.readUByte(),n.readUByte(),n.readBits(4);var i=n.readBits(3);r.numTemporalLayers=Math.max(i+1,r.numTemporalLayers||0),r.temporalIdNested=n.readBits(1),e._parseProfileTierLevel(n,i,r),n.readUEG();var s=r.chromaFormatIdc=n.readUEG(),a=420;s<=3&&(a=[0,420,422,444][s]);var o=0;3===s&&(o=n.readBits(1));var u,c,l,d,h=n.readUEG(),f=n.readUEG(),p=n.readBits(1);if(1===p&&(u=n.readUEG(),c=n.readUEG(),l=n.readUEG(),d=n.readUEG()),r.bitDepthLumaMinus8=n.readUEG(),r.bitDepthChromaMinus8=n.readUEG(),1===p){var v=1!==s&&2!==s||0!==o?1:2,m=1===s&&0===o?2:1;h-=v*(c+u),f-=m*(d+l)}return{codec:"hev1.1.6.L93.B0",width:h,height:f,chromaFormat:a,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var n=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),n),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var i=e.readBits(8);n<r.generalTierFlag?r.generalLevelIdc=i:r.generalLevelIdc=Math.max(i,r.generalLevelIdc||0);var s=[],a=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)s[o]=e.readBits(1),a[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==s[u]&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),0!==a[u]&&e.readBits(8)}}]),e}(),Ut=function(){function e(){y(this,e)}return g(e,null,[{key:"getFrameDuration",value:function(e){return 20}},{key:"parseHeaderPackets",value:function(e){if(e.length){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),r="",n=0;n<8;n++)r+=String.fromCodePoint(e[n]);if("OpusHead"!==r)throw new Error("Invalid Opus MagicSignature");var i=e[9];console.log("Pre-skip",e[10],e[11]);var s=t.getUint32(12,!0),a=t.getInt16(16,!0);if(s){return{outputGain:a,sampleRate:s,channelCount:i,config:new Uint8Array(e.buffer,e.byteOffset+8,e.byteLength-8),codec:"opus",originCodec:"opus"}}}}}]),e}(),Nt=[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],Ft=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Vt=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],zt=[0,1,1,4],Gt=null,qt=function(){function e(){y(this,e)}return g(e,null,[{key:"isHeader",value:function(e,t){return t+1<e.length&&255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}},{key:"appendFrame",value:function(t,r,n,i,s){if(!(n+24>r.length)){var a=e.parseHeader(r,n);if(a&&n+a.frameLength<=r.length){var o=i+s*(9e4*a.samplesPerFrame/a.sampleRate),u={data:r.subarray(n,n+a.frameLength),pts:o,dts:o};return u.size=u.data.byteLength,t.config=[],t.channelCount=a.channelCount,t.sampleRate=a.sampleRate,xt?t.codec="mp3":t.container="audio/mpeg",t.samples.push(u),{length:a.frameLength}}}}},{key:"parseHeader",value:function(e,t){var r=e[t+1]>>3&3,n=e[t+1]>>1&3,i=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!==r&&0!==i&&15!==i&&3!==s){var a=e[t+2]>>1&1,o=e[t+3]>>6,u=1e3*Nt[14*(3===r?3-n:3===n?3:4)+i-1],c=Ft[3*(3===r?0:2===r?1:2)+s],l=3===o?1:2,d=Vt[r][n],h=zt[n],f=8*d*h,p=Math.floor(d*u/c+a)*h;if(null===Gt){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Gt=v?parseInt(v[1]):0}return!!Gt&&Gt<=87&&2===n&&u>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:l,frameLength:p,samplesPerFrame:f}}}}]),e}(),Ht=1e3,Kt=5e3,Yt=function(){function e(t,r,n){y(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=n,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return g(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var i=this.videoTrack,s=this.audioTrack;!r&&n||(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),r&&!n&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(s,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var a=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(a&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._keyFrameInNextChunk=!1,this._fixVideo(i),this.metadataTrack.exist()){var o=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o}))}i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].dts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var n;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts,e.keyframe&&(t._keyFrameInNextChunk=!0)})),e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var i=e.samples[0],s=e.samples[r.length-1];n=Math.floor((s.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var a=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=a,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u=r.length,c=0,l=r[0],d=this._videoNextDts-l.dts;if(Math.abs(d)>200){var h;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:at,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(h=r[1])||void 0===h?void 0:h.dts,sampleDuration:d});this._videoTimestampBreak>=5?(this._videoNextDts=l.dts,this._videoTimestampBreak=0):(l.dts+=d,l.pts+=d,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var f=0;f<u;f++){var p=r[f].dts,v=r[f+1];((c=f<u-1?v.dts-p:a?a.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:st,time:p/e.timescale,dts:p,originDts:r[f].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[f].duration=c,this._videoNextDts+=c,this._lastVideoDuration=c}}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;r.length&&(r.forEach((function(e){e.dts=e.pts-=t._baseDts})),this._doFixAudioInternal(e,r,1e3))}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,n=t.samples;if(!r.length&&!n.length)return!1;var i=1/0,s=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=s=n[0].dts),this._baseDts=Math.min(i,s);var a=s-i;return Number.isFinite(a)&&Math.abs(a)>500&&t.warnings.push({type:it,videoBaseDts:s,audioBasePts:i,baseDts:this._baseDts,delta:a}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,r){if(!e.sampleDuration)switch(e.codecType){case $e:e.sampleDuration=It.getFrameDuration(e.timescale,r);break;case rt:e.sampleDuration=Ut.getFrameDuration(e.samples,r);break;case et:case tt:e.sampleDuration=this._getG711Duration(e);break;default:console.error("can't fix audio codecType:",e.codecType)}var n=e.sampleDuration,i=e.codecType===rt?20:e.codecType===$e?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var s=t[0];this._audioNextPts=s.pts}for(var a=0;a<t.length;a++){var o=this._audioNextPts,u=t[a],c=u.pts-o;if(0===a&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=Ht&&!Et){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>Kt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:ut,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var h=0;h<d;h++){var f=new ft(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);f.originPts=Math.floor(this._baseDts+o),t.splice(a,0,f),this._audioNextPts+=n,a++}a--}else if(c<=-3*n&&c>=-1e3)Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>Kt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:ct,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(a,1),a--;else{if(Math.abs(c)>Ht&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>Kt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:ot,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),e.codecType===rt){var p=t[t.length-1];p&&(p.duration=u.pts-p.pts)}else u.dts=u.pts=o,u.duration=i;this._audioNextPts+=n}}}},{key:"_getG711Duration",value:function(e){var t=e.sampleSize,r=e.channelCount,n=e.sampleRate,i=e.samples[0];if(i)return 2*i.data.byteLength/r/(t/8)/n*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===$e?It.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),Wt=function(){function e(){y(this,e)}return g(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},n=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),i=e._parseValue(new DataView(t.buffer,t.byteOffset+n.size,t.byteLength-n.size));return r[n.data]=i.data,r}}},{key:"_parseValue",value:function(t){var r,n=t.byteLength,i=1,s=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),i+=8;break;case 1:r=!!t.getUint8(1),i+=1;break;case 2:var a=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=a.data,i+=a.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(n-4))&&(o=3);i<n-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-o)),c=u.size,l=u.data;if(u.isEnd)break;r[l.name]=l.value,i+=c}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 8:r={},i+=4;var d=0;for(9==(16777215&t.getUint32(n-4))&&(d=3);i<n-8;){var h=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),f=h.size,p=h.data;if(h.isEnd)break;r[p.name]=p.value,i+=f}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 9:r=void 0,i=1,s=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var m=0;m<v;m++){var y=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),_=y.data,g=y.size;r.push(_),i+=g}break;case 11:var b=t.getFloat64(i)+6e4*t.getInt16(i+8);r=new Date(b),i+=10;break;case 12:var k=t.getUint32(1);i+=4,r="",k>0&&(r=bt.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:s}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=bt.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:r,size:2+t}}},{key:"_parseObject",value:function(t){if(!(t.byteLength<3)){var r=e._parseString(t),n=e._parseValue(new DataView(t.buffer,t.byteOffset+r.size,t.byteLength-r.size));return{data:{name:r.data,value:n.data},size:r.size+n.size,isEnd:n.isEnd}}}}]),e}(),Xt=7,Qt=8,Jt=10,Zt=13,$t=new gt("FlvDemuxer"),er=function(){function e(t,r,n){y(this,e),b(this,"_headerParsed",!1),b(this,"_remainingData",null),b(this,"_gopId",0),b(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new lt,this.audioTrack=r||new dt,this.metadataTrack=n||new yt,this._fixer=new Yt(this.videoTrack,this.audioTrack,this.metadataTrack)}return g(e,[{key:"demux",value:function(t){var r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=arguments.length>3?arguments[3]:void 0,a=this.audioTrack,o=this.videoTrack,u=this.metadataTrack;if(!n&&i||(this._remainingData=null),n&&(this._headerParsed=!1),n?(o.reset(),a.reset(),u.reset()):(o.samples=[],a.samples=[],u.seiSamples=[],u.flvScriptSamples=[],o.warnings=[],a.warnings=[],this._remainingData&&(t=Tt(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:o,audioTrack:a,metadataTrack:u};var c=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");a.present=(4&t[4])>>>2!=0,o.present=0!=(1&t[4]),this._headerParsed=!0,c=Ct(t,5)+4}for(var l,d,h,f,p,v=t.length;c+15<v&&(l=t[c],!(c+15+(d=t[c+1]<<16|t[c+2]<<8|t[c+3])>v));)h=(t[c+7]<<24>>>0)+(t[c+4]<<16)+(t[c+5]<<8)+t[c+6],c+=11,f=t.subarray(c,c+d),8===l?this._parseAudio(f,h):9===l?(s&&(this.seamlessLoadingSwitching=!0),this._parseVideo(f,h)):18===l?this._parseScript(f,h):$t.warn("Invalid tag type: ".concat(l)),(p=Ct(t,c+=d))!==11+d&&$t.warn("Invalid PrevTagSize ".concat(p," (").concat(11+d,")")),c+=4;c<v&&(this._remainingData=t.subarray(c)),a.formatTimescale=o.formatTimescale=o.timescale=u.timescale=1e3,a.timescale=a.codecType===rt?1e3:a.sampleRate||0,!a.exist()&&a.hasSample()&&a.reset(),!o.exist()&&o.hasSample()&&o.reset();var m=u.flvScriptSamples[u.flvScriptSamples.length-1],y=null==m||null===(r=m.data)||void 0===r?void 0:r.onMetaData;return y&&(null!=o&&o.exist()&&(y.hasOwnProperty("duration")&&(o.duration=1e3*y.duration),y.hasOwnProperty("width")&&y.hasOwnProperty("height")&&(o.width=y.width,o.height=y.height)),null!=a&&a.exist()&&y.hasOwnProperty("duration")&&(a.duration=1e3*y.duration)),{videoTrack:o,audioTrack:a,metadataTrack:u}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,n,i){return this.demux(e,t,r,i),this.fix(n,t,r)}},{key:"_parseAudio",value:function(t,r){if(t.length){var n=(240&t[0])>>>4,i=this.audioTrack;if(n!==Jt&&n!==Xt&&n!==Qt&&n!==Zt)return $t.warn("Unsupported sound format: ".concat(n)),void i.reset();if(n!==Jt&&n!==Zt){var s=(12&t[0])>>2,a=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[s],i.sampleSize=a?16:8,i.channelCount=o+1}switch(n){case Xt:case Qt:this._parseG711(t,r,n);break;case Jt:this._parseAac(t,r);break;case Zt:this._parseOpus(t,r)}}}},{key:"_parseOpus",value:function(e,t){var r=this.audioTrack,n=e[1];switch(r.codecType=rt,n){case 0:var i=Ut.parseHeaderPackets(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.sampleDuration=Ut.getFrameDuration([],r.timescale)):(r.reset(),$t.warn("Cannot parse AudioSpecificConfig",e));break;case 1:if(null==t)return;var s=new ft(t,e.subarray(2),r.sampleDuration);r.samples.push(s);break;default:$t.warn("Unknown OpusPacketType: ".concat(n))}}},{key:"_parseG711",value:function(e,t,r){var n=this.audioTrack,i=e.subarray(1);if(!(i.byteLength<1)){var s=new ft(t,i);n.codecType=7===r?et:tt,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(s)}}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=$e,0===e[1]){var n=It.parseAudioSpecificConfig(e.subarray(2));n?(r.codec=n.codec,r.channelCount=n.channelCount,r.sampleRate=n.sampleRate,r.config=n.config,r.objectType=n.objectType,r.sampleRateIndex=n.samplingFrequencyIndex):(r.reset(),$t.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new ft(t,e.subarray(2)))}else $t.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var n=(240&e[0])>>>4,i=15&e[0],s=this.videoTrack;if(7!==i&&12!==i)return s.reset(),void $t.warn("Unsupported codecId: ".concat(i));var a=12===i;s.codecType=a?Ze:Je;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=a?Mt.parseHEVCDecoderConfigurationRecord(c):Bt.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,h=l.sps,f=l.ppsArr,p=l.spsArr,v=l.vpsArr,m=l.nalUnitSize;d&&(s.hvcC=s.hvcC||d),h&&(s.codec=h.codec,s.width=h.width,s.height=h.height,s.sarRatio=h.sarRatio,s.fpsNum=h.fpsNum,s.fpsDen=h.fpsDen),p.length&&(s.sps=p),f.length&&(s.pps=f),v&&v.length&&(s.vps=v),m&&(s.nalUnitSize=m)}else $t.warn("Cannot parse ".concat(a?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var y=jt.parseAvcC(e.subarray(5),s.nalUnitSize);if((y=this._checkAddMetaNalToUnits(a,y,s))&&y.length){var _=new ht(t+u,t,y);if(this.seamlessLoadingSwitching&&t<s.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,1===n&&(_.setToKeyframe(),s.lastKeyFrameDts=t),s.samples.push(_),y.forEach((function(e){var n=a?e[0]>>>1&63:31&e[0];switch(n){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!a&&5!==n||a&&5===n)break;_.setToKeyframe();break;case 6:case 39:case 40:if(!a&&6!==n||a&&6===n)break;r.metadataTrack.seiSamples.push(new mt(jt.parseSEI(jt.removeEPB(e),a),t+u))}})),_.keyframe&&this._gopId++,_.gopId=this._gopId}else $t.warn("Cannot parse NALUs",e)}else 2===o||$t.warn("Unknown AVCPacketType: ".concat(o))}}},{key:"_checkAddMetaNalToUnits",value:function(e,t,r){return e&&this._needAddMetaBeforeKeyFrameNal?t.map((function(e){return e[0]>>>1&63})).includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(r.pps[0]),t.unshift(r.sps[0]),t.unshift(r.vps[0]),t.filter(Boolean)):(this._needAddMetaBeforeKeyFrameNal=!1,t)}},{key:"_parseScript",value:function(e,t){this.metadataTrack.flvScriptSamples.push(new vt(Wt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&Ct(e,5)>=9}}]),e}();b(er,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var tr=9e4,rr=45e4,nr=9e4,ir=function(){function e(t,r,n,i){y(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=n,this._baseDts=-1,this._baseVideoDts=-1,this._baseAudioDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0,this._needForceFixLargeGap=null==i?void 0:i.forceFixLargeGap,this._largeGapThreshold=(null==i?void 0:i.largeGapThreshold)||45e4}return g(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(9e4*t);var i=this.videoTrack,s=this.audioTrack,a=i.samples,o=s.samples;if(a.length||o.length){var u=a[0],c=o[0],l=0;if(a.length&&o.length&&(l=u.dts-c.pts),this._baseDtsInited||this._calculateBaseDts(this.audioTrack,this.videoTrack),r&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=t,this._baseAudioDts-=t,this._baseVideoDts-=t),!n){this._videoNextDts=l>0?t+l:t,this._audioNextPts=l>0?t:t-l,this._needForceFixLargeGap&&(this._videoNextDts=0,this._audioNextPts=0);var d=u?u.dts-this._baseDts-this._videoNextDts:0,h=c?c.pts-this._baseDts-this._audioNextPts:0;Math.abs(d||h)>nr&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=t)}if(this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._fixVideo(i),this.metadataTrack.exist()){var f=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/f}))}i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].dts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.timescale/9e4)}}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){if(r.forEach((function(e){e.dts-=t._needForceFixLargeGap?t._baseVideoDts:t._baseDts,e.pts-=t._needForceFixLargeGap?t._baseVideoDts:t._baseDts})),void 0===this._videoNextDts){var n=r[0];this._videoNextDts=n.dts}var i,s,a=r.length,o=0,u=r[0],c=r[1],l=this._videoNextDts-u.dts;if(Math.abs(l)>45e3)if(e.warnings.push({type:at,nextDts:this._videoNextDts/90,firstSampleDts:u.dts/90,nextSampleDts:((null===(i=r[1])||void 0===i?void 0:i.dts)||0)/90,sampleDuration:l/90}),u.dts+=l,u.pts+=l,c&&Math.abs(c.dts-u.dts)>nr)this._videoTimestampBreak=!0,r.forEach((function(e,t){0!==t&&(e.dts+=l,e.pts+=l)}));else for(var d=1;d<a-1;d++){var h,f=null===(h=r[d])||void 0===h?void 0:h.dts,p=r[d-1].dts;f&&f-p<0&&(r[d].dts+=l,r[d].pts+=l)}if(e.fpsNum&&e.fpsDen&&(s=e.timescale*(e.fpsDen/e.fpsNum)),s<900&&(s=0),!s){var v=e.samples[0],m=e.samples[1];s=1===a?9e3:Math.floor(m.dts-v.dts)}for(var y=0;y<a;y++){var _=r[y].dts,g=r[y+1];if((o=y<a-1?g.dts-_:r[y-1]?Math.min(_-r[y-1].dts,s):s)>nr||o<0){this._videoTimestampBreak=!0,o=this._audioTimestampBreak?s:Math.max(o,2700);var b=this._audioNextPts||0;g&&g.dts>b&&(o=s),e.warnings.push({type:st,time:_/e.timescale,dts:_,originDts:r[y].originDts,nextDts:this._videoNextDts,sampleDuration:o,refSampleDuration:s})}r[y].duration=o,this._videoNextDts+=o}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;if(r.length)if(e.codecType!==nt)r.forEach((function(e){e.pts-=t._needForceFixLargeGap?t._baseAudioDts:t._baseDts,e.dts=e.pts})),this._doFixAudioInternal(e,r,9e4);else{this.lastAudioSample&&r.unshift(this.lastAudioSample);for(var n=0;n<r.length;n++){var i=r[n];if(!r[n+1])break;i.duration=r[n+1].pts-i.pts,i.pts-=this._baseDts,i.dts=i.pts}this.lastAudioSample=r.pop()}}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,n=t.samples;if(!r.length&&!n.length)return!1;var i=1/0,s=1/0;r.length&&(e.baseDts=i=r[0].pts,this._baseAudioDts=i),n.length&&(t.baseDts=s=n[0].dts,this._baseVideoDts=s),this._baseDts=Math.min(i,s);var a=s-i,o=!1;return Number.isFinite(a)&&Math.abs(a)>45e3&&t.warnings.push({type:it,videoBaseDts:s,audioBasePts:i,baseDts:this._baseDts,delta:a}),Number.isFinite(a)&&Math.abs(a)>this._largeGapThreshold*tr&&(o=!0),this._baseDtsInited||(o&&this._needForceFixLargeGap?this._needForceFixLargeGap=!0:this._needForceFixLargeGap=!1),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){if(this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak){if(!this._calculateBaseDts(this.audioTrack,this.videoTrack))return;this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts),this._audioLastSample=null,this._videoLastSample=null,this._videoTimestampBreak=!1,this._audioTimestampBreak=!1}}},{key:"_doFixAudioInternal",value:function(e,t,r){e.sampleDuration||(e.sampleDuration=It.getFrameDuration(e.timescale,r));var n=e.sampleDuration;if(void 0===this._audioNextPts){var i=t[0];this._audioNextPts=i.pts}for(var s=0;s<t.length;s++){var a=this._audioNextPts,o=t[s],u=o.pts-a;if(!this._audioTimestampBreak&&u>=3*n&&u<=tr&&!Et){var c=It.getSilentFrame(e.codec,e.channelCount)||t[0].data.subarray(),l=Math.floor(u/n);Math.abs(o.pts-this._lastAudioExceptionGapDot)>rr&&(this._lastAudioExceptionGapDot=o.pts),e.warnings.push({type:ut,pts:o.pts/90,originPts:o.originPts,count:l,nextPts:a/90,refSampleDuration:n});for(var d=0;d<l;d++){var h=new ft(Math.floor(a),c);h.originPts=Math.floor(this._baseDts+a),t.splice(s,0,h),this._audioNextPts+=n,s++}s--}else u<=-3*n&&u>=-9e4?(Math.abs(o.pts-this._lastAudioExceptionOverlapDot)>rr&&(this._lastAudioExceptionOverlapDot=o.pts,e.warnings.push({type:ct,pts:o.pts/90,originPts:o.originPts,nextPts:a/90,refSampleDuration:n})),t.splice(s,1),s--):(Math.abs(u)>=tr&&(this._audioTimestampBreak=!0,Math.abs(o.pts-this._lastAudioExceptionLargeGapDot)>rr&&(this._lastAudioExceptionLargeGapDot=o.pts,e.warnings.push({type:ot,time:o.pts/1e3,pts:o.pts/90,originPts:o.originPts,nextPts:a/90,sampleDuration:u,refSampleDuration:n}))),o.dts=o.pts=a,this._audioNextPts+=n)}}}]),e}(),sr=new gt("TsDemuxer"),ar=function(){function e(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};y(this,e),b(this,"_pmtId",-1),b(this,"_remainingPacketData",null),b(this,"_videoPesData",[]),b(this,"_audioPesData",[]),b(this,"_gopId",0),this.videoTrack=t||new lt,this.audioTrack=r||new dt,this.metadataTrack=n||new yt,this._fixer=new ir(this.videoTrack,this.audioTrack,this.metadataTrack,i)}return g(e,[{key:"demux",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.audioTrack,i=this.videoTrack,s=this.metadataTrack;t&&(this._pmtId=-1,i.reset(),n.reset(),s.reset()),!r||t?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(i.samples=[],n.samples=[],s.seiSamples=[],i.warnings=[],n.warnings=[],this._remainingPacketData&&(e=Tt(this._remainingPacketData,e),this._remainingPacketData=null));var a=e.length,o=a%188;o&&(this._remainingPacketData=e.subarray(a-o),a-=o);for(var u=i.pid,c=n.pid,l=0;l<a;l+=188){if(71!==e[l])throw new Error("TS packet did not start with 0x47");var d=!!(64&e[l+1]),h=((31&e[l+1])<<8)+e[l+2],f=(48&e[l+3])>>4,p=void 0;if(f>1){if((p=l+5+e[l+4])===l+188)continue}else p=l+4;switch(h){case 0:d&&(p+=e[p]+1),this._pmtId=(31&e[p+10])<<8|e[p+11];break;case this._pmtId:d&&(p+=e[p]+1);var v=p+3+((15&e[p+1])<<8|e[p+2])-4,m=(15&e[p+10])<<8|e[p+11];for(p+=12+m;p<v;){var y=(31&e[p+1])<<8|e[p+2];switch(e[p]){case 15:n.pid=c=y;break;case 3:case 4:-1===n.pid&&(n.pid=c=y,n.codecType=nt);break;case 27:if(-1!==u)break;i.codecType=Je,i.pid=u=y;break;case 36:if(-1!==u)break;i.codecType=Ze,i.pid=u=y;break;default:sr.warn("Unsupported stream. type: ".concat(e[p],", pid: ").concat(y))}p+=5+((15&e[p+3])<<8|e[p+4])}break;case u:d&&this._videoPesData.length&&this._parseVideoData(),this._videoPesData.push(e.subarray(p,l+188));break;case c:d&&this._audioPesData.length&&this._parseAudioData(),this._audioPesData.push(e.subarray(p,l+188));break;case 17:case 8191:break;default:sr.warn("Unknown pid: ".concat(h))}}return this._parseVideoData(),this._parseAudioData(),n.formatTimescale=i.formatTimescale=i.timescale=s.timescale=9e4,n.timescale=n.sampleRate||0,{videoTrack:i,audioTrack:n,metadataTrack:s}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,n){return this.demux(e,t,r),this.fix(n,t,r)}},{key:"_parseVideoData",value:function(){if(this._videoPesData.length){var t=e._parsePES(Tt.apply(void 0,I(this._videoPesData)));if(t){var r=jt.parseAnnexB(t.data);r?this._createVideoSample(r,t.pts,t.dts):sr.warn("Cannot parse avc units",t),this._videoPesData=[]}else sr.warn("Cannot parse video pes",this._videoPesData)}}},{key:"_createVideoSample",value:function(e,t,r){var n=this;if(e.length){var i=this.videoTrack,s=i.codecType===Ze,a=new ht(t,r);e.forEach((function(e){var r=s?e[0]>>>1&63:31&e[0];switch(r){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==r||s&&5===r)break;a.setToKeyframe(),n._gopId++;break;case 6:case 39:case 40:if(!s&&6!==r||s&&6===r)break;return void n.metadataTrack.seiSamples.push(new mt(jt.parseSEI(jt.removeEPB(e),s),t));case 32:if(!s)break;if(!i.vps.length){var o=Mt.parseVPS(jt.removeEPB(e),i.hvcC);i.hvcC=i.hvcC||o,i.vps=[e]}break;case 7:case 33:if(!s&&7!==r||s&&7===r)break;if(!i.sps.length){var u=jt.removeEPB(e),c=s?Mt.parseSPS(u,i.hvcC):Bt.parseSPS(u);i.sps=[e],i.hvcC=i.hvcC||c.hvcC,i.codec=c.codec,i.width=c.width,i.height=c.height,i.sarRatio=c.sarRatio,i.fpsNum=c.fpsNum,i.fpsDen=c.fpsDen}break;case 8:case 34:if(!s&&8!==r||s&&8===r)break;i.pps.length||(i.pps=[e]);break;case 9:case 35:break;case 38:if(s){for(var l=!1,d=2;d<e.byteLength;d++)if(255===e[d]){l=!0;break}if(!l)return}}a.units.push(e)})),a.gopId=this._gopId,this._pushVideoSample(i,a)}}},{key:"_pushVideoSample",value:function(e,t){if(t.units.length)if(null===t.pts||void 0===t.pts){sr.warn("Video sample no pts",t);var r=e.samples[e.samples.length-1];r?(t.pts=r.pts,t.dts=r.dts):sr.warn("Drop video sample",t)}else e.samples.push(t)}},{key:"_parseAudioData",value:function(){if(this._audioPesData.length){var t=e._parsePES(Tt.apply(void 0,I(this._audioPesData)));if(t){switch(this.audioTrack.codecType){case $e:this._parseAacData(t);break;case nt:this._parseMPEG(t)}this._audioPesData=[]}else sr.warn("Cannot parse audio pes",this._audioPesData)}}},{key:"_parseAacData",value:function(e){var t=this.audioTrack,r=e.pts;if(null==r){if(sr.warn("AAC pes not pts",t),!t.samples.length||!t.sampleRate)return;r=t.samples[t.samples.length-1].pts+It.getFrameDuration(t.sampleRate)}var n,i=It.parseADTS(e.data,r);i?(t.codec=i.codec,t.channelCount=i.channelCount,t.sampleRate=i.sampleRate,t.objectType=i.objectType,t.sampleRateIndex=i.samplingFrequencyIndex,t.config=i.config,(n=t.samples).push.apply(n,I(i.frames.map((function(e){return new ft(e.pts,e.data)})))),i.skip&&sr.warn("Skip aac adts ".concat(i.skip," bits")),i.remaining&&sr.warn("Remaining aac adts ".concat(i.remaining," bits"))):sr.warn("Cannot parse aac adts",e)}},{key:"_parseMPEG",value:function(e){var t=e.data,r=t.length,n=0,i=0,s=e.pts;if(void 0!==s)for(;i<r;)if(qt.isHeader(t,i)){var a=qt.appendFrame(this.audioTrack,t,i,s,n);if(!a)break;i+=a.length,n++}else i++;else sr.warn("[tsdemuxer]: MPEG PES unknown PTS")}}],[{key:"probe",value:function(e){return!!e.length&&(71===e[0]&&71===e[188]&&71===e[376])}},{key:"_parsePES",value:function(e){var t=e[8];if(!(null==t||e.length<t+9)&&1===(e[0]<<16|e[1]<<8|e[2])){var r=(e[4]<<8)+e[5];if(!(r&&r>e.length-6)){var n,i,s=e[7];return 192&s&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&s?n-(i=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(n=i):i=n),{data:e.subarray(9+t),pts:n,dts:i}}}}}]),e}(),or=function(){function e(t,r,n){y(this,e),this.dv=new DataView(t),this.start=this.offset=r||this.dv.byteOffset,this.end=n?this.start+n:this.start+this.dv.byteLength}return g(e,[{key:"buffer",get:function(){return this.dv.buffer}},{key:"unreadLength",get:function(){return Math.max(this.end-this.offset,0)}},{key:"size",get:function(){return this.end-this.start}},{key:"readFloat",value:function(e){var t=0;switch(e){case 4:t=this.dv.getFloat32(this.offset);break;case 8:t=this.dv.getFloat64(this.offset);break;default:throw new Error("read ".concat(e,"-byte float is not supported"))}return this.offset+=e,t}},{key:"back",value:function(e){this.offset-=e}},{key:"skip",value:function(e){this.offset+=e}},{key:"readInt",value:function(e){var t=this.offset;switch(this.offset+=e,e){case 1:return this.dv.getInt8(t);case 2:return this.dv.getInt16(t);case 4:return this.dv.getInt32(t);default:throw new Error("read ".concat(e,"-byte integers is not supported"))}}},{key:"read",value:function(e){var t=this.offset;switch(this.offset+=e,e){case 1:return this.dv.getUint8(t);case 2:return this.dv.getUint16(t);case 3:return(this.dv.getUint16(t)<<8)+this.dv.getUint8(t+2);case 4:return this.dv.getUint32(t);default:return this.back(e-4),this.read(e-4)+this.dv.getUint32(t)*Math.pow(256,e-4)}}},{key:"write",value:function(e,t){var r=this.offset;switch(this.offset+=e,e){case 1:return this.dv.setUint8(r,t);case 2:return this.dv.setUint16(r,t);case 3:return this.dv.setUint8(r,t>>>16),this.dv.setUint16(r+1,65535&t);case 4:return this.dv.setUint32(r,t);default:throw new Error("write ".concat(e,"-byte integers is not supported"))}}},{key:"readToBuffer",value:function(e){var t;return t=this.offset||e?this.dv.buffer.slice(this.offset,e?this.offset+e:this.end):this.dv.buffer,this.offset+=t.byteLength,t}},{key:"readToUint8",value:function(e){var t=new Uint8Array(this.dv.buffer,this.offset,e||this.unreadLength);return this.offset+=t.byteLength,t}},{key:"readString",value:function(e){for(var t=0,r="";t<e;t++)r+=String.fromCharCode(this.dv.getUint8(this.offset)),this.offset++;return r}}],[{key:"fromUint8",value:function(t){return new e(t.buffer,t.byteOffset,t.byteLength)}},{key:"concatUint8s",value:function(e){var t=new Uint8Array(e.reduce((function(e,t){return e+t.byteLength}),0)),r=0;return e.forEach((function(e){t.set(e,r),r+=e.byteLength})),t}},{key:"concatUint8",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.concatUint8s(t)}}]),e}(),ur=function(){function e(t,r){y(this,e),this.offset=0,this.val=t,this.size=r}return g(e,[{key:"skip",value:function(e){this.offset+=e}},{key:"read",value:function(e){var t=this.size-this.offset-e;if(t>=0){var r=0,n=0;if(this.offset+=e,this.size>31){for(;n<e;n++)r+=Math.pow(2,n);return this.val/Math.pow(2,t)&r}for(;n<e;n++)r+=1<<n;return this.val>>>t&r}throw new Error("the number of the read operation exceeds the total length limit of bits")}}],[{key:"fromByte",value:function(t,r){return new e(t.read(r),r<<3)}}]),e}(),cr=function(){function e(){y(this,e)}return g(e,null,[{key:"findBox",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[];if(!t)return i;for(var s=0,a="",o=0;t.length>7;){if(s=Ct(t),a=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===s?(s=Lt(t,8),o+=8):s||(s=t.length),!r[0]||a===r[0]){var u=t.subarray(0,s);if(!(r.length<2))return e.findBox(u.subarray(o),r.slice(1),n+o);i.push({start:n,size:s,headerSize:o,type:a,data:u})}n+=s,t=t.subarray(s)}return i}},{key:"tfhd",value:function(e){return fr(e,!0,(function(e,t){e.trackId=Ct(t);var r=4,n=1&e.flags,i=2&e.flags,s=8&e.flags,a=16&e.flags,o=32&e.flags;n&&(r+=4,e.baseDataOffset=Ct(t,r),r+=4),i&&(e.sampleDescriptionIndex=Ct(t,r),r+=4),s&&(e.defaultSampleDuration=Ct(t,r),r+=4),a&&(e.defaultSampleSize=Ct(t,r),r+=4),o&&(e.defaultSampleFlags=Ct(t,r))}))}},{key:"sidx",value:function(e){return fr(e,!0,(function(e,t){var r=0;e.reference_ID=Ct(t,r),r+=4,e.timescale=Ct(t,r),r+=4,0===e.version?(e.earliest_presentation_time=Ct(t,r),r+=4,e.first_offset=Ct(t,r),r+=4):(e.earliest_presentation_time=Lt(t,r),r+=8,e.first_offset=Lt(t,r),r+=8),r+=2,e.references=[];var n=At(t,r);r+=2;for(var i=0;i<n;i++){var s={};e.references.push(s);var a=Ct(t,r);r+=4,s.reference_type=a>>31&1,s.referenced_size=2147483647&a,s.subsegment_duration=Ct(t,r),a=Ct(t,r+=4),r+=4,s.starts_with_SAP=a>>31&1,s.SAP_type=a>>28&7,s.SAP_delta_time=268435455&a}}))}},{key:"moov",value:function(t){return fr(t,!1,(function(t,r,n){t.mvhd=e.mvhd(e.findBox(r,["mvhd"],n)[0]),t.trak=e.findBox(r,["trak"],n).map((function(t){return e.trak(t)})),t.pssh=e.pssh(e.findBox(r,["pssh"],n)[0])}))}},{key:"mvhd",value:function(e){return fr(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=Ct(t,16),e.duration=Lt(t,20),r+=28):(e.timescale=Ct(t,8),e.duration=Ct(t,12),r+=16),e.nextTrackId=Ct(t,r+76)}))}},{key:"trak",value:function(t){return fr(t,!1,(function(t,r,n){t.tkhd=e.tkhd(e.findBox(r,["tkhd"],n)[0]),t.mdia=e.mdia(e.findBox(r,["mdia"],n)[0])}))}},{key:"tkhd",value:function(e){return fr(e,!0,(function(e,t){var r=or.fromUint8(t);1===e.version?(r.read(8),r.read(8),e.trackId=r.read(4),r.read(4),e.duration=r.read(8)):(r.read(4),r.read(4),e.trackId=r.read(4),r.read(4),e.duration=r.read(4)),r.skip(16),e.matrix=[];for(var n=0;n<36;n++)e.matrix.push(r.read(1));r.back(36);for(var i,s=[],a=0;a<3;a++)s.push(Pt(r.readInt(2),r.readInt(2))),s.push(Pt(r.readInt(2),r.readInt(2))),i=r.readInt(4),s.push(Pt(i>>30,1073741823&i));e.rotation=function(e){if(e.length<5)return 0;var t=Math.hypot(e[0],e[3]),r=Math.hypot(e[1],e[4]);return 0===t||0===r?0:180*Math.atan2(e[1]/r,e[0]/t)/Math.PI}(s),e.width=r.read(4),e.height=r.read(4)}))}},{key:"mdia",value:function(t){return fr(t,!1,(function(t,r,n){t.mdhd=e.mdhd(e.findBox(r,["mdhd"],n)[0]),t.hdlr=e.hdlr(e.findBox(r,["hdlr"],n)[0]),t.minf=e.minf(e.findBox(r,["minf"],n)[0])}))}},{key:"mdhd",value:function(e){return fr(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=Ct(t,16),e.duration=Lt(t,20),r+=28):(e.timescale=Ct(t,8),e.duration=Ct(t,12),r+=16);var n=At(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return fr(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return fr(t,!1,(function(t,r,n){t.vmhd=e.vmhd(e.findBox(r,["vmhd"],n)[0]),t.smhd=e.smhd(e.findBox(r,["smhd"],n)[0]),t.stbl=e.stbl(e.findBox(r,["stbl"],n)[0])}))}},{key:"vmhd",value:function(e){return fr(e,!0,(function(e,t){e.graphicsmode=At(t),e.opcolor=[At(t,2),At(t,4),At(t,6)]}))}},{key:"smhd",value:function(e){return fr(e,!0,(function(e,t){e.balance=At(t)}))}},{key:"stbl",value:function(t){return fr(t,!1,(function(t,r,n){var i,s,a;t.stsd=e.stsd(e.findBox(r,["stsd"],n)[0]),t.stts=e.stts(e.findBox(r,["stts"],n)[0]),t.ctts=e.ctts(e.findBox(r,["ctts"],n)[0]),t.stsc=e.stsc(e.findBox(r,["stsc"],n)[0]),t.stsz=e.stsz(e.findBox(r,["stsz"],n)[0]),t.stco=e.stco(e.findBox(r,["stco"],n)[0]),t.stco||(t.co64=e.co64(e.findBox(r,["co64"],n)[0]),t.stco=t.co64);var o=null===(i=t.stsd.entries[0])||void 0===i||null===(s=i.sinf)||void 0===s||null===(a=s.schi)||void 0===a?void 0:a.tenc.default_IV_size;t.stss=e.stss(e.findBox(r,["stss"],n)[0]),t.senc=e.senc(e.findBox(r,["senc"],n)[0],o)}))}},{key:"senc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return fr(e,!0,(function(e,r){var n=0,i=Ct(r,n);n+=4,e.samples=[];for(var s=0;s<i;s++){for(var a={InitializationVector:[]},o=0;o<t;o++)a.InitializationVector[o]=r[n+o];if(n+=t,2&e.flags){a.subsamples=[];var u=At(r,n);n+=2;for(var c=0;c<u;c++){var l={};l.BytesOfClearData=At(r,n),n+=2,l.BytesOfProtectedData=Ct(r,n),n+=4,a.subsamples.push(l)}}e.samples.push(a)}}))}},{key:"pssh",value:function(e){return fr(e,!0,(function(e,t){for(var r=[],n=[],i=0,s=0;s<16;s++)n.push(vr(t[i+s]));if(i+=16,e.version>0){var a=Ct(t,i);i+=4;for(var o=0;o<(""+a).length;o++)for(var u=0;u<16;u++){var c=t[i];i+=1,r.push(vr(c))}}var l=Ct(t,i);e.data_size=l,i+=4,e.kid=r,e.system_id=n,e.buffer=t}))}},{key:"stsd",value:function(t){return fr(t,!0,(function(t,r,n){t.entryCount=Ct(r),t.entries=e.findBox(r.subarray(4),[],n+4).map((function(t){switch(t.type){case"av01":return e.av01(t);case"avc1":case"avc2":case"avc3":case"avc4":return e.avc1(t);case"hvc1":case"hev1":return e.hvc1(t);case"mp4a":return e.mp4a(t);case"alaw":case"ulaw":return e.alaw(t);case"enca":return fr(t,!1,(function(t,r,n){t.channelCount=At(r,16),t.samplesize=At(r,18),t.sampleRate=Ct(r,24)/65536,r=r.subarray(28),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.esds=e.esds(e.findBox(r,["esds"],n)[0])}));case"encv":return fr(t,!1,(function(t,r,n){t.width=At(r,24),t.height=At(r,26),t.horizresolution=Ct(r,28),t.vertresolution=Ct(r,32),r=r.subarray(78),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.avcC=e.avcC(e.findBox(r,["avcC"],n)[0]),t.hvcC=e.hvcC(e.findBox(r,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(r,["pasp"],n)[0])}))}})).filter(Boolean)}))}},{key:"tenc",value:function(e){return fr(e,!1,(function(e,t){var r=6;e.default_IsEncrypted=t[r],r+=1,e.default_IV_size=t[r],r+=1,e.default_KID=[];for(var n=0;n<16;n++)e.default_KID.push(vr(t[r])),r+=1}))}},{key:"schi",value:function(t){return fr(t,!1,(function(t,r,n){t.tenc=e.tenc(e.findBox(r,["tenc"],n)[0])}))}},{key:"sinf",value:function(t){return fr(t,!1,(function(t,r,n){t.schi=e.schi(e.findBox(r,["schi"],n)[0]),t.frma=e.frma(e.findBox(r,["frma"],n)[0])}))}},{key:"frma",value:function(e){return fr(e,!1,(function(e,t){e.data_format="";for(var r=0;r<4;r++)e.data_format+=String.fromCharCode(t[r])}))}},{key:"colr",value:function(e){return fr(e,!1,(function(t,r){var n=or.fromUint8(r);t.data=e.data,t.colorType=n.readString(4),"nclx"===t.colorType?(t.colorPrimaries=n.read(2),t.transferCharacteristics=n.read(2),t.matrixCoefficients=n.read(2),t.fullRangeFlag=n.read(1)>>7):"rICC"!==t.colorType&&"prof"!==t.colorType||(t.iccProfile=r.readToUint8())}))}},{key:"av01",value:function(t){return fr(t,!1,(function(t,r,n){var i=dr(t,r),s=r.subarray(i);n+=i,t.av1C=e.av1C(e.findBox(s,["av1C"],n)[0]),t.colr=e.colr(e.findBox(s,["colr"],n)[0])}))}},{key:"av1C",value:function(e){return fr(e,!1,(function(t,r){t.data=e.data;var n,i=or.fromUint8(r),s=ur.fromByte(i,4);t.marker=s.read(1),t.version=s.read(7),t.seqProfile=s.read(3),t.seqLevelIdx0=s.read(5),t.seqTier0=s.read(1),t.highBitdepth=s.read(1),t.twelveBit=s.read(1),t.monochrome=s.read(1),t.chromaSubsamplingX=s.read(1),t.chromaSubsamplingY=s.read(1),t.chromaSamplePosition=s.read(2),t.reserved=s.read(3),t.initialPresentationDelayPresent=s.read(1),t.initialPresentationDelayPresent?t.initialPresentationDelayMinusOne=s.read(4):t.initialPresentationDelayMinusOne=0,t.configOBUs=i.readToUint8(),2===t.seqLevelIdx0&&1===t.highBitdepth?n=1===t.twelveBit?"12":"10":t.seqProfile<=2&&(n=1===t.highBitdepth?"10":"08"),t.codec=["av01",t.seqProfile,(t.seqLevelIdx0<10?"0"+t.seqLevelIdx0:t.seqLevelIdx0)+(t.seqTier0?"H":"M"),n].join(".")}))}},{key:"avc1",value:function(t){return fr(t,!1,(function(t,r,n){var i=dr(t,r),s=r.subarray(i);n+=i,t.avcC=e.avcC(e.findBox(s,["avcC"],n)[0]),t.pasp=e.pasp(e.findBox(s,["pasp"],n)[0])}))}},{key:"avcC",value:function(e){return fr(e,!1,(function(t,r){t.data=e.data,t.configurationVersion=r[0],t.AVCProfileIndication=r[1],t.profileCompatibility=r[2],t.AVCLevelIndication=r[3],t.codec=Rt([r[1],r[2],r[3]]),t.lengthSizeMinusOne=3&r[4],t.spsLength=31&r[5],t.sps=[];for(var n=6,i=0;i<t.spsLength;i++){var s=At(r,n);n+=2,t.sps.push(r.subarray(n,n+s)),n+=s}t.ppsLength=r[n],n+=1,t.pps=[];for(var a=0;a<t.ppsLength;a++){var o=At(r,n);n+=2,t.pps.push(r.subarray(n,n+=o)),n+=o}}))}},{key:"hvc1",value:function(t){return fr(t,!1,(function(t,r,n){var i=dr(t,r),s=r.subarray(i);n+=i,t.hvcC=e.hvcC(e.findBox(s,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(s,["pasp"],n)[0])}))}},{key:"hvcC",value:function(e){return fr(e,!1,(function(t,r){t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=r[0];var n=r[1];t.generalProfileSpace=n>>6,t.generalTierFlag=(32&n)>>5,t.generalProfileIdc=31&n,t.generalProfileCompatibility=Ct(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=At(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var i=23,s=0,a=0,o=0,u=0;u<t.numOfArrays;u++){s=63&r[i],a=At(r,i+1),i+=3;for(var c,l=[],d=0;d<a;d++)o=At(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===s)(c=t.vps).push.apply(c,l);else if(33===s){var h;(h=t.sps).push.apply(h,l)}else if(34===s){var f;(f=t.pps).push.apply(f,l)}}}))}},{key:"pasp",value:function(e){return fr(e,!1,(function(e,t){e.hSpacing=Ct(t),e.vSpacing=Ct(t,4)}))}},{key:"mp4a",value:function(t){return fr(t,!1,(function(t,r,n){var i=hr(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return fr(e,!0,(function(e,t){e.codec="mp4a.";for(var r=0,n=0,i=0,s=0;t.length;){for(s=t[r=0],n=t[r+1],r+=2;128&n;)i=(127&n)<<7,n=t[r],r+=1;if(i+=127&n,3===s)t=t.subarray(r+3);else{if(4!==s){if(5===s){var a=e.config=t.subarray(r,r+i),o=(248&a[0])>>3;return 31===o&&a.length>=2&&(o=32+((7&a[0])<<3)+((224&a[1])>>5)),e.objectType=o,e.codec+=o.toString(16),void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}e.codec+=(t[r].toString(16)+".").padStart(3,"0"),t=t.subarray(r+13)}}}))}},{key:"alaw",value:function(e){return fr(e,!1,(function(e,t){hr(e,t)}))}},{key:"stts",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push({count:Ct(t,i),delta:Ct(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return fr(e,!0,(function(e,t){var r=Ct(t),n=[],i=4;if(1===e.version)for(var s=0;s<r;s++)n.push({count:Ct(t,i),offset:Ct(t,i+4)}),i+=8;else for(var a=0;a<r;a++)n.push({count:Ct(t,i),offset:-(1+~Ct(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push({firstChunk:Ct(t,i),samplesPerChunk:Ct(t,i+4),sampleDescriptionIndex:Ct(t,i+8)}),i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return fr(e,!0,(function(e,t){var r=Ct(t),n=Ct(t,4),i=[];if(!r)for(var s=8,a=0;a<n;a++)i.push(Ct(t,s)),s+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push(Ct(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"co64",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push(Lt(t,i)),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push(Ct(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return fr(t,!1,(function(t,r,n){t.mfhd=e.mfhd(e.findBox(r,["mfhd"],n)[0]),t.traf=e.findBox(r,["traf"],n).map((function(t){return e.traf(t)}))}))}},{key:"mfhd",value:function(e){return fr(e,!0,(function(e,t){e.sequenceNumber=Ct(t)}))}},{key:"traf",value:function(t){return fr(t,!1,(function(t,r,n){t.tfhd=e.tfhd(e.findBox(r,["tfhd"],n)[0]),t.tfdt=e.tfdt(e.findBox(r,["tfdt"],n)[0]),t.trun=e.trun(e.findBox(r,["trun"],n)[0])}))}},{key:"trun",value:function(e){return fr(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,s=e.sampleCount=Ct(t),a=4;if(i>a&&1&n&&(e.dataOffset=-(1+~Ct(t,a)),a+=4),i>a&&4&n&&(e.firstSampleFlags=Ct(t,a),a+=4),e.samples=[],i>a)for(var o,u=0;u<s;u++)o={},256&n&&(o.duration=Ct(t,a),a+=4),512&n&&(o.size=Ct(t,a),a+=4),1024&n&&(o.flags=Ct(t,a),a+=4),2048&n&&(o.cts=r?-(1+~Ct(t,a+4)):Ct(t,a),a+=4),e.samples.push(o)}))}},{key:"tfdt",value:function(e){return fr(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=Lt(t):e.baseMediaDecodeTime=Ct(t)}))}},{key:"probe",value:function(t){return!!e.findBox(t,["ftyp"])}},{key:"parseSampleFlags",value:function(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}},{key:"moovToTrack",value:function(e,t,r){var n,i,s=e.trak;if(s&&s.length){var a=s.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),o=s.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(a&&t){var u,c,l,d,h,f,p,v=t,m=null===(u=a.tkhd)||void 0===u?void 0:u.trackId;null!=m&&(v.id=a.tkhd.trackId),v.tkhdDuration=a.tkhd.duration,v.mvhdDurtion=e.mvhd.duration,v.mvhdTimecale=e.mvhd.timescale,v.timescale=v.formatTimescale=a.mdia.mdhd.timescale,v.duration=a.mdia.mdhd.duration||v.mvhdDurtion/v.mvhdTimecale*v.timescale,v.rotation=a.tkhd.rotation,v.matrix=a.tkhd.matrix;var y,_,g,b,k,S,E,x,w=a.mdia.minf.stbl.stsd.entries[0];if(v.width=w.width,v.height=w.height,w.pasp&&(v.sarRatio=[w.pasp.hSpacing,w.pasp.vSpacing]),w.av1C)v.codecType=Qe,v.codec=w.av1C.codec,v.av1C=w.av1C.data,v.colr=w.colr.data;else if(w.hvcC)v.codecType=Ze,v.codec=w.hvcC.codec,v.vps=w.hvcC.vps,v.sps=w.hvcC.sps,v.pps=w.hvcC.pps,v.hvcC=w.hvcC.data;else{if(!w.avcC)throw new Error("unknown video stsd entry");v.codec=w.avcC.codec,v.sps=w.avcC.sps,v.pps=w.avcC.pps}if(v.present=!0,v.ext={},v.ext.stss=null===(c=a.mdia)||void 0===c||null===(l=c.minf)||void 0===l||null===(d=l.stbl)||void 0===d?void 0:d.stss,v.ext.ctts=null===(h=a.mdia)||void 0===h||null===(f=h.minf)||void 0===f||null===(p=f.stbl)||void 0===p?void 0:p.ctts,w&&"encv"===w.type)v.isVideoEncryption=!0,w.default_KID=null===(y=w.sinf)||void 0===y||null===(_=y.schi)||void 0===_?void 0:_.tenc.default_KID,w.default_IsEncrypted=null===(g=w.sinf)||void 0===g||null===(b=g.schi)||void 0===b?void 0:b.tenc.default_IsEncrypted,w.default_IV_size=null===(k=w.sinf)||void 0===k||null===(S=k.schi)||void 0===S?void 0:S.tenc.default_IV_size,v.videoSenc=a.mdia.minf.stbl.senc&&a.mdia.minf.stbl.senc.samples,w.data_format=null===(E=w.sinf)||void 0===E||null===(x=E.frma)||void 0===x?void 0:x.data_format,v.useEME=e.useEME,v.kidValue=e.kidValue,v.pssh=e.pssh,v.encv=w}if(o&&r){var T,D,A,C,L,R,O,P,I,j=r,B=null===(T=o.tkhd)||void 0===T?void 0:T.trackId;null!=B&&(j.id=o.tkhd.trackId),j.tkhdDuration=o.tkhd.duration,j.mvhdDurtion=e.mvhd.duration,j.mvhdTimecale=e.mvhd.timescale,j.timescale=j.formatTimescale=o.mdia.mdhd.timescale,j.duration=o.mdia.mdhd.duration||j.mvhdDurtion/j.mvhdTimecale*j.timescale;var M,U,N,F,V,z,G,q,H=o.mdia.minf.stbl.stsd.entries[0];switch(j.sampleSize=H.sampleSize,j.sampleRate=H.sampleRate,j.channelCount=H.channelCount,j.present=!0,H.type){case"alaw":j.codecType=j.codec=et,j.sampleRate=8e3;break;case"ulaw":j.codecType=j.codec=tt,j.sampleRate=8e3;break;default:j.sampleDuration=It.getFrameDuration(j.sampleRate,j.timescale),j.sampleRateIndex=It.getRateIndexByRate(j.sampleRate),j.objectType=(null===(n=H.esds)||void 0===n?void 0:n.objectType)||2,H.esds&&(j.config=Array.from(H.esds.config)),j.codec=(null===(i=H.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}if(j.sampleDuration=It.getFrameDuration(j.sampleRate,j.timescale),j.objectType=(null===(D=H.esds)||void 0===D?void 0:D.objectType)||2,H.esds&&(H.esds.config?j.config=Array.from(H.esds.config):console.warn("esds config is null")),j.codec=(null===(A=H.esds)||void 0===A?void 0:A.codec)||"mp4a.40.2",j.sampleRateIndex=It.getRateIndexByRate(j.sampleRate),j.ext={},j.ext.stss=null===(C=o.mdia)||void 0===C||null===(L=C.minf)||void 0===L||null===(R=L.stbl)||void 0===R?void 0:R.stss,j.ext.ctts=null===(O=o.mdia)||void 0===O||null===(P=O.minf)||void 0===P||null===(I=P.stbl)||void 0===I?void 0:I.ctts,j.present=!0,H&&"enca"===H.type)j.isAudioEncryption=!0,H.data_format=null===(M=H.sinf)||void 0===M||null===(U=M.frma)||void 0===U?void 0:U.data_format,H.default_KID=null===(N=H.sinf)||void 0===N||null===(F=N.schi)||void 0===F?void 0:F.tenc.default_KID,H.default_IsEncrypted=null===(V=H.sinf)||void 0===V||null===(z=V.schi)||void 0===z?void 0:z.tenc.default_IsEncrypted,H.default_IV_size=null===(G=H.sinf)||void 0===G||null===(q=G.schi)||void 0===q?void 0:q.tenc.default_IV_size,j.audioSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,j.useEME=e.useEME,j.kidValue=e.kidValue,j.enca=H}if(r&&(r.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!r&&r.isAudioEncryption),null!=t&&t.encv||null!=r&&r.enca){var K,Y,W=null==t||null===(K=t.encv)||void 0===K?void 0:K.default_KID,X=null==r||null===(Y=r.enca)||void 0===Y?void 0:Y.default_KID,Q=W||X?(W||X).join(""):null;t&&(t.kid=Q),r&&(r.kid=Q)}return t&&(t.flags=3841),r&&(r.flags=1793),{videoTrack:t,audioTrack:r}}}},{key:"evaluateDefaultDuration",value:function(e,t,r){var n,i=null==t||null===(n=t.samples)||void 0===n?void 0:n.length;return i?1024*i/t.timescale*e.timescale/r:1024}},{key:"moofToSamples",value:function(t,r,n){var i={};return t.mfhd&&(r&&(r.sequenceNumber=t.mfhd.sequenceNumber),n&&(n.sequenceNumber=t.mfhd.sequenceNumber)),t.traf.forEach((function(t){var s=t.tfhd,a=t.tfdt,o=t.trun;if(s&&o){a&&(r&&r.id===s.trackId&&(r.baseMediaDecodeTime=a.baseMediaDecodeTime),n&&n.id===s.trackId&&(n.baseMediaDecodeTime=a.baseMediaDecodeTime));var u=s.defaultSampleSize||0,c=s.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,h=-1;if(!o.samples.length&&o.sampleCount){i[s.trackId]=[];for(var f=0;f<o.sampleCount;f++)i[s.trackId].push({offset:l,dts:d,duration:c,size:u}),d+=c,l+=u}else i[s.trackId]=o.samples.map((function(e,t){return(e={offset:l,dts:d,pts:d+(e.cts||0),duration:e.duration||c,size:e.size||u,gopId:h,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(h++,e.gopId=h),d+=e.duration,l+=e.size,e}))}})),i}},{key:"moovToSamples",value:function(e){var t=e.trak;if(t&&t.length){var r=t.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),n=t.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(r||n){var i,s;if(r){var a,o,u=null===(a=r.mdia)||void 0===a||null===(o=a.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,h=u.stco,f=u.stss,p=u.ctts;if(!(c&&l&&d&&h&&f))return;i=lr(c,l,d,h,p,f)}if(n){var v,m,y,_=null===(v=n.mdia)||void 0===v||null===(m=v.minf)||void 0===m?void 0:m.stbl;if(!_)return;var g=null===(y=n.mdia.mdhd)||void 0===y?void 0:y.timescale,b=_.stts,k=_.stsc,S=_.stsz,E=_.stco;if(!(g&&b&&k&&S&&E))return;s=lr(b,k,S,E)}return{videoSamples:i,audioSamples:s}}}}}]),e}();function lr(e,t,r,n,i,s){var a,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,h=n.entries,f=r.entrySizes,p=null==s?void 0:s.entries;p&&(a={},p.forEach((function(e){a[e-1]=!0}))),l&&(o=[],l.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)o.push(r)})));var v=-1,m=0,y=0,_=0,g=0,b=0,k=d[0].samplesPerChunk,S=d[1]?d[1].firstChunk-1:1/0;return e.entries.forEach((function(e){for(var t=e.count,n=e.delta,i=0;i<t;i++)u={dts:m,duration:n,size:f[y]||r.sampleSize,offset:h[_]+b,index:y},p&&(u.keyframe=a[y],u.keyframe&&v++,u.gopId=v),o&&y<o.length&&(u.pts=u.dts+o[y]),c.push(u),m+=n,++y<k?b+=u.size:(_++,b=0,_>=S&&(g++,S=d[g+1]?d[g+1].firstChunk-1:1/0),k+=d[g].samplesPerChunk)})),c}function dr(e,t){return e.dataReferenceIndex=At(t,6),e.width=At(t,24),e.height=At(t,26),e.horizresolution=Ct(t,28),e.vertresolution=Ct(t,32),e.frameCount=At(t,40),e.depth=At(t,74),78}function hr(e,t){return e.dataReferenceIndex=At(t,6),e.channelCount=At(t,16),e.sampleSize=At(t,18),e.sampleRate=Ct(t,24)/65536,28}function fr(e,t,r){if(e){if(e.size!==e.data.length)throw new Error("box ".concat(e.type," size !== data.length"));var n={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(n.version=e.data[e.headerSize],n.flags=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),n.headerSize+=4),r(n,e.data.subarray(n.headerSize),n.start+n.headerSize),n}}var pr=function(e,t,r){for(var n=String(r),i=t>>0,s=Math.ceil(i/n.length),a=[],o=String(e);s--;)a.push(n);return a.join("").substring(0,i-o.length)+o},vr=function(){for(var e=[],t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach((function(t){e.push(pr(Number(t).toString(16),2,0))})),e[0]},mr=function(){function e(t,r,n){y(this,e),b(this,"__loadedMoofWraps",[]),b(this,"__lastRemainData",null),b(this,"__lastRemainDataStart",0),b(this,"__nextMoofStart",-1),this.videoTrack=t||new lt,this.audioTrack=r||new dt,this.metadataTrack=n||new yt}return g(e,[{key:"demuxPart",value:function(e,t,r){var n=this,i=this.videoTrack,s=this.audioTrack,a=i.exist(),o=s.exist(),u=/av01/.test(i.codec);i.samples=[],s.samples=[];var c=e,l=t;if(this.__lastRemainData){var d=this.__lastRemainDataStart+this.__lastRemainData.byteLength;if(t<=d&&t>this.__lastRemainDataStart&&t+e.byteLength>d){var h=e.subarray(this.__lastRemainData.byteLength+this.__lastRemainDataStart-t);c=Tt(this.__lastRemainData,h),l=this.__lastRemainDataStart,this.__lastRemainData=null}else this.__lastRemainData=null,this.__lastRemainDataStart=0,this.__nextMoofStart=-1}if(!r){var f=cr.findBox(c,["moov"])[0];if(!f)throw new Error("cannot found moov box");r=cr.moov(f)}if(c){var p=l+c.byteLength;a||o||cr.moovToTrack(r,i,s);var v=[];this.__nextMoofStart<0?cr.findBox(c,["moof"],l).forEach((function(e){return v.push(e)})):this.__nextMoofStart>=l&&this.__nextMoofStart<=p-8&&cr.findBox(c.subarray(this.__nextMoofStart-l),["moof"],this.__nextMoofStart).forEach((function(e){return v.push(e)})),v.filter((function(e){return e.size<=e.data.length})).forEach((function(e){var t=cr.moof(e);n.__nextMoofStart=t.start+Math.max.apply(Math,I(t.traf.map((function(e){return e.trun.samples.reduce((function(e,t){return e+t.size}),e.trun.dataOffset||0)})))),n.__loadedMoofWraps.push({start:t.start,nextMoofStart:n.__nextMoofStart,moof:t}),n.__loadedMoofWraps.sort((function(e,t){return e.start-t.start}))}));var m,y=M(this.__loadedMoofWraps);try{var _=function(){var e=m.value;if(e.start>p||e.nextMoofStart<l)return"continue";var t,r=e.start,a=cr.moofToSamples(e.moof,i,s),o=i.baseMediaDecodeTime,d=s.baseMediaDecodeTime;Object.keys(a).forEach((function(e){i.id==e?a[e].some((function(e){var s=e.offset+=r;if(!(s<l)){if(s+e.size>p)return!0;var a=new ht((e.pts||e.dts)+o,e.dts+o);a.duration=e.duration,a.gopId=e.gopId,e.keyframe&&a.setToKeyframe();var d=c.subarray(s-l,s-l+e.size);if(a.data=d,!u)for(var h=0,f=d.length-1;h<f;)t=Ct(d,h),h+=4,a.units.push(d.subarray(h,h+t)),h+=t;n.__lastRemainDataStart=s+e.size,i.samples.push(a)}})):s.id==e&&a[e].some((function(e){var t=e.offset+r;if(!(t<l)){if(t+e.size>p)return!0;var i=c.subarray(t-l,t-l+e.size);s.samples.push(new ft(e.dts+d,i,e.duration)),n.__lastRemainDataStart=t+e.size}}))}))};for(y.s();!(m=y.n()).done;)_()}catch(g){y.e(g)}finally{y.f()}}return this.__lastRemainDataStart>l&&this.__lastRemainDataStart<c.byteLength+l?this.__lastRemainData=c.subarray(this.__lastRemainDataStart-l):(this.__lastRemainData=c,this.__lastRemainDataStart=l),i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].pts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts),{videoTrack:i,audioTrack:s,metadataTrack:this.metadataTrack}}},{key:"demux",value:function(e,t){var r=this.videoTrack,n=this.audioTrack,i=r.exist(),s=n.exist();if(r.samples=[],n.samples=[],t){if(!s){var a=cr.findBox(t,["moov"])[0];if(!a)throw new Error("cannot found moov box");cr.moovToTrack(cr.moov(a),null,n)}var o=cr.findBox(t,["moof"])[0];if(o){var u=cr.moofToSamples(cr.moof(o),null,n)[n.id],c=n.baseMediaDecodeTime;if(u){var l=o.start;u.map((function(e){e.offset+=l;var r=t.subarray(e.offset,e.offset+e.size);n.samples.push(new ft(e.dts+c,r,e.duration))}))}}}if(e){if(!i&&!s){var d=cr.findBox(e,["moov"])[0];if(!d)throw new Error("cannot found moov box");cr.moovToTrack(cr.moov(d),r,n)}var h=cr.findBox(e,["moof"])[0];if(h){var f,p=cr.moofToSamples(cr.moof(h),r,n),v=r.baseMediaDecodeTime,m=n.baseMediaDecodeTime,y=h.start;Object.keys(p).forEach((function(t){r.id==t?p[t].map((function(t){t.offset+=y;var n=new ht((t.pts||t.dts)+v,t.dts+v);n.duration=t.duration,n.gopId=t.gopId,t.keyframe&&n.setToKeyframe();var i=e.subarray(t.offset,t.offset+t.size);n.data=i;for(var s=0,a=i.length-1;s<a;)f=Ct(i,s),s+=4,n.units.push(i.subarray(s,s+f)),s+=f;r.samples.push(n)})):n.id==t&&p[t].map((function(t){t.offset+=y;var r=e.subarray(t.offset,t.offset+t.size);n.samples.push(new ft(t.dts+m,r,t.duration))}))}))}}return{videoTrack:r,audioTrack:n,metadataTrack:this.metadataTrack}}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset(),this.metadataTrack.reset()}}],[{key:"probe",value:function(e){return cr.probe(e)}}]),e}();function yr(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.forEach((function(e){t+=e.length}));var s=new e(t),a=0;return n.forEach((function(e){s.set(e,a),a+=e.length})),s}var _r=function(){function e(){y(this,e),this.buffer=new Uint8Array(0)}return g(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){t?e.buffer=yr(Uint8Array,e.buffer,t):window.console.warn(t)}))}}],[{key:"writeUint16",value:function(e){return new Uint8Array([e>>8&255,255&e])}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e])}}]),e}(),gr=Math.pow(2,32)-1,br=function(){function e(){y(this,e)}return g(e,null,[{key:"box",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=8+(r=r.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),s=new Uint8Array(i);s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4);var a=8;return r.forEach((function(e){s.set(e,a),a+=e.byteLength})),s}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===Ye&&e.codecType===Ze}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return Tt(e.ftyp(t),e.moov(t))}},{key:"pssh",value:function(t){var r=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],Ot(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(t[0].useEME&&(t[0].encv||t[0].enca)){t[0].pssh||(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat(I(t.map((function(t){return e.trak(t)}))),[r]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(I(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,n=e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,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 n}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,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,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]));return s}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,n=e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]));return n}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===Ye?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){var r=[];return t&&t.ext&&t.ext.stss&&r.push(e.stss(t.ext.stss.entries)),e.box(e.types.stbl,e.stsd(t),e.STTS,r[0],e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var r;return r="audio"===t.type?t.useEME&&t.enca?e.enca(t):t.codecType===rt?e.opus(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):t.av1C?e.av01(t):e.avc1hev1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r)}},{key:"enca",value:function(t){var r=t.enca.channelCount,n=t.enca.sampleRate,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,n>>8&255,255&n,0,0]),s=e.esds(t.config),a=e.sinf(t.enca);return e.box(e.types.enca,i,s,a)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],s=t.pps.length>0?t.pps[0]:[],a=t.width,o=t.height,u=t.sarRatio[0],c=t.sarRatio[1],l=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,a>>8&255,255&a,o>>8&255,255&o,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]),d=new Uint8Array((r=(n=[1,i[1],i[2],i[3],255,225,i.length>>>8&255,255&i.length]).concat.apply(n,I(i)).concat([1,s.length>>>8&255,255&s.length])).concat.apply(r,I(s))),h=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),f=e.sinf(t.encv),p=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c]);return e.box(e.types.encv,l,e.box(e.types.avcC,d),e.box(e.types.btrt,h),f,e.box(e.types.pasp,p))}},{key:"schi",value:function(t){var r=new Uint8Array([]),n=e.tenc(t);return e.box(e.types.schi,r,n)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(Ot(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),n=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),i=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),s=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),s)}},{key:"av01",value:function(t){return e.box(e.types.av01,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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),t.av1C,t.colr)}},{key:"avc1hev1",value:function(t){var r=t.codecType===Ze,n=r?e.types.hvc1:e.types.avc1,i=r?e.hvcC(t):e.avcC(t),s=[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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),i];return r?s.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&s.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(s))}},{key:"avcC",value:function(t){var r,n,i,s=[],a=[];return t.sps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,I(e))})),t.pps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,I(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,s[3],s[4],s[5],255,224|t.sps.length]).concat.apply(n,s).concat([t.pps.length])).concat.apply(r,a)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,s=t.sps,a=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(s.length&&1)+(a.length&&1);n=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],r.generalLevelIdc,240,0,252,252|r.chromaFormatIdc,248|r.bitDepthLumaMinus8,248|r.bitDepthChromaMinus8,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,c];var l=function(e){var t;n.push(e.length>>8,e.length),(t=n).push.apply(t,I(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),s.length&&(n.push(161,0,s.length),s.forEach(l)),a.length&&(n.push(162,0,a.length),a.forEach(l))}else n=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(n))}},{key:"pasp",value:function(t){var r=P(t,2),n=r[0],i=r[1];return e.box(e.types.pasp,new Uint8Array([n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"opus",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),n=t.config.length?e.dOps(t):[];return e.box(e.types.Opus,r,n)}},{key:"dOps",value:function(t){if(t.config)return t.config[4]=t.sampleRate>>>24&255,t.config[5]=t.sampleRate>>>16&255,t.config[6]=t.sampleRate>>>8&255,t.config[7]=255&t.sampleRate,e.box(e.types.dOps,t.config)}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(I(t.map((function(t){return e.trex(t.id)})))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat(I(t.map((function(t){return e.traf(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:"traf",value:function(t){var r=e.tfhd(t.id),n=e.tfdt(t,t.baseMediaDecodeTime),i=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){i+=8,e.subsamples&&e.subsamples.length&&(i+=2,i+=6*e.subsamples.length)})),t.videoSencLength=i,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var s=e.saiz(t),a=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,s,a,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),d=e.saio(t),h=e.senc(t),f=e.trun1(t);return e.box(e.types.traf,r,n,c,l,d,h,f)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var m=e.trun1(t);return e.box(e.types.traf,r,n,m)}var y=e.sbgp(),_=e.saiz(t),g=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,y,_,g,b,k)}var S=e.sdtp(t);return e.box(e.types.traf,r,n,S,e.trun(t.samples,S.byteLength+76))}},{key:"sdtp",value:function(t){var r=new _r;return t.samples.forEach((function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))})),e.box(e.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new _r,n=_r.writeUint32(t.samples.length),i=null;if(t.isVideo){var s=t.videoSencLength;i=_r.writeUint32(16*t.samples.length+s+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=_r.writeUint32(16*t.samples.length+92))}else{var a=12*t.samples.length+124;t.isAudioEncryption&&(a=12*t.samples.length+8*t.audioSenc.length+177),i=_r.writeUint32(a)}return t.samples.forEach((function(e){r.write(_r.writeUint32(e.duration)),r.write(_r.writeUint32(e.size)),r.write(_r.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(_r.writeUint32(e.cts?e.cts:0))})),e.box(e.types.trun,this.extension(0,t.flags),n,i,r.buffer)}},{key:"senc",value:function(t){var r=new _r,n=t.samples.length,i=t.isVideo?16:8,s=t.isVideo?2:0,a=[],o=0;return t.isVideo?(a=t.videoSenc,o=t.videoSencLength):a=t.audioSenc,o=o||i*n,r.write(_r.writeUint32(16+o),e.types.senc,this.extension(0,s)),r.write(_r.writeUint32(n)),a.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(_r.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(_r.writeUint16(e.BytesOfClearData)),r.write(_r.writeUint32(e.BytesOfProtectedData))})))})),r.buffer}},{key:"saio",value:function(t){var r=12*t.samples.length+141;!t.isVideo&&t.isAudioEncryption&&(r=149);var n=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saio,n)}},{key:"saiz",value:function(t){var r=t.samples.length,n=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saiz,n)}},{key:"sbgp",value:function(){var t=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return e.box(e.types.sbgp,this.extension(0,0),t)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}},{key:"tfhd",value:function(t){return e.box(e.types.tfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"tfdt",value:function(t,r){var n=Math.floor(r/(gr+1)),i=Math.floor(r%(gr+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])):e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var s=new Uint8Array(i);s.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var a=0;a<n;a++){var o=t[a],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,h=o.cts,f=void 0===h?0:h;s.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|(null===d.dependsOn||void 0===d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null===d.isNonSyncSample||void 0===d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*a)}return e.box(e.types.trun,s)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(I(t.map((function(t){return e.trackMP4(t)})))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===Ye?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var r=t.ext,n=[e.stsd(t),e.stts(r.stts),e.stsc(r.stsc),e.stsz(r.stsz),e.stco(r.stco)];return r.stss.length&&n.push(e.stss(r.stss)),r.ctts.length&&n.push(e.ctts(r.ctts)),e.box.apply(e,[e.types.stbl].concat(n))}},{key:"stts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach((function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8})),e.box(e.types.stts,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsc",value:function(t){var r=t.length,n=new Uint8Array(12*r),i=0;return t.forEach((function(e){var t=e.firstChunk,r=e.samplesPerChunk,s=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s],i),i+=12})),e.box(e.types.stsc,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsz",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stsz,Tt(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stco",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stco,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stss",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stss,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"ctts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach((function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8})),e.box(e.types.ctts,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,n=t.samples[0].duration,i=n*t.samples.length,s=t.samples[0].sampleOffset*n,a=8;t.samples.forEach((function(e){a+=e.size}));var o=0;if(t.isVideo){var u,c=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){c+=8,e.subsamples&&e.subsamples.length&&(c+=2,c+=6*e.subsamples.length)})),t.videoSencLength=c,o=a+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=a+16*t.samples.length+84)}else o=a+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=a+169+12*t.samples.length+8*t.audioSenc.length);var l=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,s>>24&255,s>>16&255,s>>8&255,255&s,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,144,0,0,0]);return e.box(e.types.sidx,l)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();b(br,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),b(br,"HDLR_TYPES",{video: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]),audio: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])}),b(br,"FTYPAVC1",br.box(br.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),b(br,"FTYPHEV1",br.box(br.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),b(br,"DINF",br.box(br.types.dinf,br.box(br.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),b(br,"VMHD",br.box(br.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),b(br,"SMHD",br.box(br.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),b(br,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),b(br,"STTS",br.box(br.types.stts,br.StblTable)),b(br,"STSC",br.box(br.types.stsc,br.StblTable)),b(br,"STSZ",br.box(br.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),b(br,"STCO",br.box(br.types.stco,br.StblTable));var kr=function(){function e(t,r){y(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return g(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).debug.apply(t,[this._prefix].concat(n))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).log.apply(t,[this._prefix].concat(n))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).error.apply(t,[this._prefix].concat(n))}}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();b(kr,"disabled",!0);for(var Sr=function(){function e(t,r,n){y(this,e),this.videoTrack=t,this.audioTrack=r;var i=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=i&&Number(i[1])<50,this.log=new kr("FMP4Remuxer",!n||!n.openLog||!n.openLog)}return g(e,[{key:"remux",value:function(){var e,t,r,n,i,s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,c=o.exist(),l=u.exist(),d=[];return s&&(a&&a.initMerge?(c&&d.push(this.videoTrack),l&&d.push(this.audioTrack),r=br.initSegment(d)):(c&&(e=br.initSegment([this.videoTrack])),l&&(t=br.initSegment([this.audioTrack])))),c&&o.hasSample()&&(n=this._remuxVideo()),l&&u.hasSample()&&(i=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:r,videoInitSegment:e,audioInitSegment:t,videoSegment:n,audioSegment:i}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=/av01/.test(e.codec),n=0;r?t.forEach((function(e){n+=e.data.byteLength})):t.forEach((function(e){n+=e.units.reduce((function(e,t){return e+t.byteLength}),0),n+=4*e.units.length}));var i=new Uint8Array(n);if(r)for(var s,a=0,o=t.length,u=0;a<o;a++)s=t[a],i.set(s.data,u),s.size=s.data.byteLength,u+=s.size;else for(var c,l=new DataView(i.buffer),d=function(e,r){r=t[h];var n=0;r.units.forEach((function(t){l.setUint32(e,t.byteLength),e+=4,i.set(t,e),e+=t.byteLength,n+=4+t.byteLength})),r.size=n,p=e,c=r},h=0,f=t.length,p=0;h<f;h++)d(p,c);var v=br.mdat(i);return Tt(br.moof([e]),v)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,r){return t.set(r.data,e),e+r.size}),0);var r=br.mdat(t);return Tt(br.moof([e]),r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),Er=function(){function e(){y(this,e)}return g(e,[{key:"mixIn",value:function(e){return Object.assign(this,e)}},{key:"clone",value:function(){var e=new this.constructor;return Object.assign(e,this),e}}],[{key:"create",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return w(this,t)}}]),e}(),xr=function(e){k(r,e);var t=L(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4*n.length;y(this,r),e=t.call(this);var s=n;if(s instanceof ArrayBuffer&&(s=new Uint8Array(s)),(s instanceof Int8Array||s instanceof Uint8ClampedArray||s instanceof Int16Array||s instanceof Uint16Array||s instanceof Int32Array||s instanceof Uint32Array||s instanceof Float32Array||s instanceof Float64Array)&&(s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength)),s instanceof Uint8Array){for(var a=s.byteLength,o=[],u=0;u<a;u+=1)o[u>>>2]|=s[u]<<24-u%4*8;e.words=o,e.sigBytes=a}else e.words=n,e.sigBytes=i;return e}return g(r,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:wr;return e.stringify(this)}},{key:"concat",value:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s+=1){var a=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=a<<24-(n+s)%4*8}else for(var o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this}},{key:"clamp",value:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=Math.ceil(t/4)}},{key:"clone",value:function(){var e=O(S(r.prototype),"clone",this).call(this);return e.words=this.words.slice(0),e}}],[{key:"random",value:function(e){for(var t,n=[],i=function(e){var t=e,r=987654321,n=4294967295;return function(){var e=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return e/=4294967296,(e+=.5)*(Math.random()>.5?1:-1)}},s=0;s<e;s+=4){var a=i(4294967296*(t||Math.random()));t=987654071*a(),n.push(4294967296*a()|0)}return new r(n,e)}}]),r}(Er),wr={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=1){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new xr(r,t/2)}},Tr=function(e){for(var t=e.length,r=[],n=0;n<t;n+=1)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new xr(r,t)},Dr=function(e){return Tr(unescape(encodeURIComponent(e)))},Ar=function(e){k(r,e);var t=L(r);function r(){var e;return y(this,r),(e=t.call(this))._minBufferSize=0,e}return g(r,[{key:"reset",value:function(){this._data=new xr,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=Dr(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes}},{key:"_process",value:function(e){var t,r=this._data,n=this.blockSize,i=r.words,s=r.sigBytes,a=s/(4*n),o=(a=e?Math.ceil(a):Math.max((0|a)-this._minBufferSize,0))*n,u=Math.min(4*o,s);if(o){for(var c=0;c<o;c+=n)this._doProcessBlock(i,c);t=i.splice(0,o),r.sigBytes-=u}return new xr(t,u)}},{key:"clone",value:function(){var e=O(S(r.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),r}(Er),Cr=function(e){k(r,e);var t=L(r);function r(e){var n;return y(this,r),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new Er,e),n.reset(),n}return g(r,[{key:"reset",value:function(){O(S(r.prototype),"reset",this).call(this),this._doReset()}},{key:"update",value:function(e){return this._append(e),this._process(),this}},{key:"finalize",value:function(e){return e&&this._append(e),this._doFinalize()}}],[{key:"_createHelper",value:function(e){return function(t,r){return new e(r).finalize(t)}}},{key:"_createHmacHelper",value:function(e){return function(t,r){return new Lr(e,r).finalize(t)}}}]),r}(Ar),Lr=function(e){k(r,e);var t=L(r);function r(e,n){var i;y(this,r),i=t.call(this);var s=new e;i._hasher=s;var a=n;"string"==typeof a&&(a=Dr(a));var o=s.blockSize,u=4*o;a.sigBytes>u&&(a=s.finalize(n)),a.clamp();var c=a.clone();i._oKey=c;var l=a.clone();i._iKey=l;for(var d=c.words,h=l.words,f=0;f<o;f+=1)d[f]^=1549556828,h[f]^=909522486;return c.sigBytes=u,l.sigBytes=u,i.reset(),i}return g(r,[{key:"reset",value:function(){var e=this._hasher;e.reset(),e.update(this._iKey)}},{key:"update",value:function(e){return this._hasher.update(e),this}},{key:"finalize",value:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}}]),r}(Er),Rr={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],s=0;s<r;s+=3)for(var a=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,o=0;o<4&&s+.75*o<r;o+=1)i.push(n.charAt(a>>>6*(3-o)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){this._reverseMap=[],n=this._reverseMap;for(var i=0;i<r.length;i+=1)n[r.charCodeAt(i)]=i}var s=r.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],i=0,s=0;s<t;s+=1)if(s%4){var a=r[e.charCodeAt(s-1)]<<s%4*2|r[e.charCodeAt(s)]>>>6-s%4*2;n[i>>>2]|=a<<24-i%4*8,i+=1}return xr.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},Or=[],Pr=0;Pr<64;Pr+=1)Or[Pr]=4294967296*Math.abs(Math.sin(Pr+1))|0;var Ir=function(e,t,r,n,i,s,a){var o=e+(t&r|~t&n)+i+a;return(o<<s|o>>>32-s)+t},jr=function(e,t,r,n,i,s,a){var o=e+(t&n|r&~n)+i+a;return(o<<s|o>>>32-s)+t},Br=function(e,t,r,n,i,s,a){var o=e+(t^r^n)+i+a;return(o<<s|o>>>32-s)+t},Mr=function(e,t,r,n,i,s,a){var o=e+(r^(t|~n))+i+a;return(o<<s|o>>>32-s)+t},Ur=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"_doReset",value:function(){this._hash=new xr([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var r=e,n=0;n<16;n+=1){var i=t+n,s=e[i];r[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var a=this._hash.words,o=r[t+0],u=r[t+1],c=r[t+2],l=r[t+3],d=r[t+4],h=r[t+5],f=r[t+6],p=r[t+7],v=r[t+8],m=r[t+9],y=r[t+10],_=r[t+11],g=r[t+12],b=r[t+13],k=r[t+14],S=r[t+15],E=a[0],x=a[1],w=a[2],T=a[3];E=Ir(E,x,w,T,o,7,Or[0]),T=Ir(T,E,x,w,u,12,Or[1]),w=Ir(w,T,E,x,c,17,Or[2]),x=Ir(x,w,T,E,l,22,Or[3]),E=Ir(E,x,w,T,d,7,Or[4]),T=Ir(T,E,x,w,h,12,Or[5]),w=Ir(w,T,E,x,f,17,Or[6]),x=Ir(x,w,T,E,p,22,Or[7]),E=Ir(E,x,w,T,v,7,Or[8]),T=Ir(T,E,x,w,m,12,Or[9]),w=Ir(w,T,E,x,y,17,Or[10]),x=Ir(x,w,T,E,_,22,Or[11]),E=Ir(E,x,w,T,g,7,Or[12]),T=Ir(T,E,x,w,b,12,Or[13]),w=Ir(w,T,E,x,k,17,Or[14]),x=Ir(x,w,T,E,S,22,Or[15]),E=jr(E,x,w,T,u,5,Or[16]),T=jr(T,E,x,w,f,9,Or[17]),w=jr(w,T,E,x,_,14,Or[18]),x=jr(x,w,T,E,o,20,Or[19]),E=jr(E,x,w,T,h,5,Or[20]),T=jr(T,E,x,w,y,9,Or[21]),w=jr(w,T,E,x,S,14,Or[22]),x=jr(x,w,T,E,d,20,Or[23]),E=jr(E,x,w,T,m,5,Or[24]),T=jr(T,E,x,w,k,9,Or[25]),w=jr(w,T,E,x,l,14,Or[26]),x=jr(x,w,T,E,v,20,Or[27]),E=jr(E,x,w,T,b,5,Or[28]),T=jr(T,E,x,w,c,9,Or[29]),w=jr(w,T,E,x,p,14,Or[30]),x=jr(x,w,T,E,g,20,Or[31]),E=Br(E,x,w,T,h,4,Or[32]),T=Br(T,E,x,w,v,11,Or[33]),w=Br(w,T,E,x,_,16,Or[34]),x=Br(x,w,T,E,k,23,Or[35]),E=Br(E,x,w,T,u,4,Or[36]),T=Br(T,E,x,w,d,11,Or[37]),w=Br(w,T,E,x,p,16,Or[38]),x=Br(x,w,T,E,y,23,Or[39]),E=Br(E,x,w,T,b,4,Or[40]),T=Br(T,E,x,w,o,11,Or[41]),w=Br(w,T,E,x,l,16,Or[42]),x=Br(x,w,T,E,f,23,Or[43]),E=Br(E,x,w,T,m,4,Or[44]),T=Br(T,E,x,w,g,11,Or[45]),w=Br(w,T,E,x,S,16,Or[46]),x=Br(x,w,T,E,c,23,Or[47]),E=Mr(E,x,w,T,o,6,Or[48]),T=Mr(T,E,x,w,p,10,Or[49]),w=Mr(w,T,E,x,k,15,Or[50]),x=Mr(x,w,T,E,h,21,Or[51]),E=Mr(E,x,w,T,g,6,Or[52]),T=Mr(T,E,x,w,l,10,Or[53]),w=Mr(w,T,E,x,y,15,Or[54]),x=Mr(x,w,T,E,u,21,Or[55]),E=Mr(E,x,w,T,v,6,Or[56]),T=Mr(T,E,x,w,S,10,Or[57]),w=Mr(w,T,E,x,f,15,Or[58]),x=Mr(x,w,T,E,b,21,Or[59]),E=Mr(E,x,w,T,d,6,Or[60]),T=Mr(T,E,x,w,_,10,Or[61]),w=Mr(w,T,E,x,c,15,Or[62]),x=Mr(x,w,T,E,m,21,Or[63]),a[0]=a[0]+E|0,a[1]=a[1]+x|0,a[2]=a[2]+w|0,a[3]=a[3]+T|0}},{key:"_doFinalize",value:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32;var i=Math.floor(r/4294967296),s=r;t[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(t.length+1),this._process();for(var a=this._hash,o=a.words,u=0;u<4;u+=1){var c=o[u];o[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return a}},{key:"clone",value:function(){var e=O(S(r.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),r}(Cr);Cr._createHelper(Ur),Cr._createHmacHelper(Ur);var Nr=function(e){k(r,e);var t=L(r);function r(e){var n;return y(this,r),(n=t.call(this)).cfg=Object.assign(new Er,{keySize:4,hasher:Ur,iterations:1},e),n}return g(r,[{key:"compute",value:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),s=xr.create(),a=s.words,o=n.keySize,u=n.iterations;a.length<o;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var c=1;c<u;c+=1)r=i.finalize(r),i.reset();s.concat(r)}return s.sigBytes=4*o,s}}]),r}(Er),Fr=function(e){k(r,e);var t=L(r);function r(e,n,i){var s;return y(this,r),(s=t.call(this)).cfg=Object.assign(new Er,i),s._xformMode=e,s._key=n,s.reset(),s}return g(r,[{key:"reset",value:function(){O(S(r.prototype),"reset",this).call(this),this._doReset()}},{key:"process",value:function(e){return this._append(e),this._process()}},{key:"finalize",value:function(e){return e&&this._append(e),this._doFinalize()}}],[{key:"createEncryptor",value:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)}},{key:"createDecryptor",value:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)}},{key:"_createHelper",value:function(e){var t=function(e){return"string"==typeof e?Qr:Wr};return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}]),r}(Ar);Fr._ENC_XFORM_MODE=1,Fr._DEC_XFORM_MODE=2,Fr.keySize=4,Fr.ivSize=4;var Vr=function(e){k(r,e);var t=L(r);function r(e,n){var i;return y(this,r),(i=t.call(this))._cipher=e,i._iv=n,i}return g(r,null,[{key:"createEncryptor",value:function(e,t){return this.Encryptor.create(e,t)}},{key:"createDecryptor",value:function(e,t){return this.Decryptor.create(e,t)}}]),r}(Er);function zr(e,t,r){var n,i=e,s=this._iv;s?(n=s,this._iv=void 0):n=this._prevBlock;for(var a=0;a<r;a+=1)i[t+a]^=n[a]}var Gr=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r)}(Vr);Gr.Encryptor=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize;zr.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),r}(Gr),Gr.Decryptor=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize,i=e.slice(t,t+n);r.decryptBlock(e,t),zr.call(this,e,t,n),this._prevBlock=i}}]),r}(Gr);var qr={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,s=[],a=0;a<n;a+=4)s.push(i);var o=xr.create(s,n);e.concat(o)},unpad:function(e){var t=e,r=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=r}},Hr=function(e){k(r,e);var t=L(r);function r(e,n,i){var s;return y(this,r),(s=t.call(this,e,n,Object.assign({mode:Gr,padding:qr},i))).blockSize=4,s}return g(r,[{key:"reset",value:function(){var e;O(S(r.prototype),"reset",this).call(this);var t=this.cfg,n=t.iv,i=t.mode;this._xformMode===this.constructor._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode=e.call(i,this,n&&n.words),this._mode.__creator=e}},{key:"_doProcessBlock",value:function(e,t){this._mode.processBlock(e,t)}},{key:"_doFinalize",value:function(){var e,t=this.cfg.padding;return this._xformMode===this.constructor._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e}}]),r}(Fr),Kr=function(e){k(r,e);var t=L(r);function r(e){var n;return y(this,r),(n=t.call(this)).mixIn(e),n}return g(r,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),r}(Er),Yr={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?xr.create([1398893684,1701076831]).concat(r).concat(t):t).toString(Rr)},parse:function(e){var t,r=Rr.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=xr.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),Kr.create({ciphertext:r,salt:t})}},Wr=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new Er,this.cfg,n),s=e.createEncryptor(r,i),a=s.finalize(t),o=s.cfg;return Kr.create({ciphertext:a,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:s.blockSize,formatter:i.format})}},{key:"decrypt",value:function(e,t,r,n){var i=t,s=Object.assign(new Er,this.cfg,n);return i=this._parse(i,s.format),e.createDecryptor(r,s).finalize(i.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),r}(Er);Wr.cfg=Object.assign(new Er,{format:Yr});var Xr={execute:function(e,t,r,n){var i=n;i||(i=xr.random(8));var s=Nr.create({keySize:t+r}).compute(e,i),a=xr.create(s.words.slice(t),4*r);return s.sigBytes=4*t,Kr.create({key:s,iv:a,salt:i})}},Qr=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new Er,this.cfg,n),s=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=s.iv;var a=Wr.encrypt.call(this,e,t,s.key,i);return a.mixIn(s),a}},{key:"decrypt",value:function(e,t,r,n){var i=t,s=Object.assign(new Er,this.cfg,n);i=this._parse(i,s.format);var a=s.kdf.execute(r,e.keySize,e.ivSize,i.salt);return s.iv=a.iv,Wr.decrypt.call(this,e,i,a.key,s)}}]),r}(Wr);Qr.cfg=Object.assign(Wr.cfg,{kdf:Xr});for(var Jr=[],Zr=[],$r=[],en=[],tn=[],rn=[],nn=[],sn=[],an=[],on=[],un=[],cn=0;cn<256;cn+=1)un[cn]=cn<128?cn<<1:cn<<1^283;for(var ln=0,dn=0,hn=0;hn<256;hn+=1){var fn=dn^dn<<1^dn<<2^dn<<3^dn<<4;fn=fn>>>8^255&fn^99,Jr[ln]=fn,Zr[fn]=ln;var pn=un[ln],vn=un[pn],mn=un[vn],yn=257*un[fn]^16843008*fn;$r[ln]=yn<<24|yn>>>8,en[ln]=yn<<16|yn>>>16,tn[ln]=yn<<8|yn>>>24,rn[ln]=yn,yn=16843009*mn^65537*vn^257*pn^16843008*ln,nn[fn]=yn<<24|yn>>>8,sn[fn]=yn<<16|yn>>>16,an[fn]=yn<<8|yn>>>24,on[fn]=yn,ln?(ln=pn^un[un[un[mn^pn]]],dn^=un[un[dn]]):ln=dn=1}var _n=[0,1,2,4,8,16,32,64,128,27,54],gn=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"_doReset",value:function(){var e;if(!this._nRounds||this._keyPriorReset!==this._key){this._keyPriorReset=this._key;var t=this._keyPriorReset,r=t.words,n=t.sigBytes/4;this._nRounds=n+6;var i=4*(this._nRounds+1);this._keySchedule=[];for(var s=this._keySchedule,a=0;a<i;a+=1)a<n?s[a]=r[a]:(e=s[a-1],a%n?n>6&&a%n==4&&(e=Jr[e>>>24]<<24|Jr[e>>>16&255]<<16|Jr[e>>>8&255]<<8|Jr[255&e]):(e=Jr[(e=e<<8|e>>>24)>>>24]<<24|Jr[e>>>16&255]<<16|Jr[e>>>8&255]<<8|Jr[255&e],e^=_n[a/n|0]<<24),s[a]=s[a-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<i;u+=1){var c=i-u;e=u%4?s[c]:s[c-4],o[u]=u<4||c<=4?e:nn[Jr[e>>>24]]^sn[Jr[e>>>16&255]]^an[Jr[e>>>8&255]]^on[Jr[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,$r,en,tn,rn,Jr)}},{key:"decryptBlock",value:function(e,t){var r=e,n=r[t+1];r[t+1]=r[t+3],r[t+3]=n,this._doCryptBlock(r,t,this._invKeySchedule,nn,sn,an,on,Zr),n=r[t+1],r[t+1]=r[t+3],r[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,r,n,i,s,a,o){for(var u=e,c=this._nRounds,l=u[t]^r[0],d=u[t+1]^r[1],h=u[t+2]^r[2],f=u[t+3]^r[3],p=4,v=1;v<c;v+=1){var m=n[l>>>24]^i[d>>>16&255]^s[h>>>8&255]^a[255&f]^r[p];p+=1;var y=n[d>>>24]^i[h>>>16&255]^s[f>>>8&255]^a[255&l]^r[p];p+=1;var _=n[h>>>24]^i[f>>>16&255]^s[l>>>8&255]^a[255&d]^r[p];p+=1;var g=n[f>>>24]^i[l>>>16&255]^s[d>>>8&255]^a[255&h]^r[p];p+=1,l=m,d=y,h=_,f=g}var b=(o[l>>>24]<<24|o[d>>>16&255]<<16|o[h>>>8&255]<<8|o[255&f])^r[p];p+=1;var k=(o[d>>>24]<<24|o[h>>>16&255]<<16|o[f>>>8&255]<<8|o[255&l])^r[p];p+=1;var S=(o[h>>>24]<<24|o[f>>>16&255]<<16|o[l>>>8&255]<<8|o[255&d])^r[p];p+=1;var E=(o[f>>>24]<<24|o[l>>>16&255]<<16|o[d>>>8&255]<<8|o[255&h])^r[p];p+=1,u[t]=b,u[t+1]=k,u[t+2]=S,u[t+3]=E}}]),r}(Hr);gn.keySize=8,Hr._createHelper(gn);var bn=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r)}(Vr);bn.Encryptor=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"processBlock",value:function(e,t){var r=e,n=this._cipher,i=n.blockSize,s=this._iv,a=this._counter;s&&(this._counter=s.slice(0),a=this._counter,this._iv=void 0);var o=a.slice(0);n.encryptBlock(o,0),a[i-1]=a[i-1]+1|0;for(var u=0;u<i;u+=1)r[t+u]^=o[u]}}]),r}(bn),bn.Decryptor=bn.Encryptor;var kn=function(){function e(){y(this,e);var t=window.crypto||window.msCrypto;this.subtle=t&&(t.subtle||t.webkitSubtle),this.externalDecryptor=null}var t,r;return g(e,[{key:"destroy",value:function(){var e;null!==(e=this.externalDecryptor)&&void 0!==e&&e.destroy&&this.externalDecryptor.destroy()}},{key:"decrypt",value:function(e,t){if(e||t){var r=[];return e&&(r[0]=this._decryptSegment(e)),t&&(r[1]=this._decryptSegment(t)),Promise.all(r)}}},{key:"_decryptSegment",value:(r=m(f().mark((function e(t){var r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.data,!t.key){e.next=5;break}return e.next=4,this._decryptData(t.data,t.key,t.keyIv);case 4:r=e.sent;case 5:if(t.map){e.next=7;break}return e.abrupt("return",r);case 7:return e.abrupt("return",Ne(t.map,r));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_decryptData",value:(t=m(f().mark((function e(t,r,n){var i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.externalDecryptor){e.next=6;break}return e.next=3,this.externalDecryptor.decrypt(t,r,n);case 3:return e.abrupt("return",e.sent);case 6:if(this.subtle){e.next=8;break}throw new Error("crypto is not defined");case 8:return e.next=10,this.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt","decrypt"]);case 10:return i=e.sent,e.t0=Uint8Array,e.next=14,this.subtle.decrypt({name:"AES-CBC",iv:n},i,t);case 14:return e.t1=e.sent,e.abrupt("return",new e.t0(e.t1));case 16:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}(),Sn=h(h({},Re),{},{STREAM_PARSED:"core.streamparsed",NO_AUDIO_TRACK:"core.noaudiotrack",SUBTITLE_SEGMENTS:"core.subtitlesegments",SUBTITLE_PLAYLIST:"core.subtitleplaylist",SEI_PAYLOAD_TIME:"core.seipayloadtime",APPEND_COST:"core.appendcost"}),En=new se("Transmuxer"),xn=function(){function e(t,r,n,i){y(this,e),b(this,"_initSegmentId",""),this.hls=t,this._demuxer=r?new mr:new ar(null,null,null,i),this._isMP4=r,n&&(this._remuxer=new Sr(this._demuxer.videoTrack,this._demuxer.audioTrack))}return g(e,[{key:"transmux",value:function(e,t,r,n,i,s){var a=this._demuxer;try{this._isMP4?a.demux(e,t):a.demuxAndFix(Ne(e,t),r,n,i)}catch(k){throw new re(W,ee.HLS,k)}var o=a.videoTrack,u=a.audioTrack,c=a.metadataTrack,l={codec:o.codec,timescale:o.timescale,firstDts:o.firstDts/o.timescale,firstPts:o.firstPts/o.timescale,duration:o.samplesDuration/o.timescale},d={codec:u.codec,timescale:u.timescale,firstDts:u.firstDts/o.timescale,firstPts:u.firstPts/o.timescale,duration:u.samplesDuration/o.timescale,container:u.container},f="".concat(o.codec,"/").concat(o.width,"/").concat(o.height,"/").concat(u.codec,"/").concat(u.config);if(f!==this._initSegmentId&&(this._initSegmentId=f,s=!0),this._fireEvents(o,u,c,r||s),this.hls.emit(Sn.DEMUXED_TRACK,{videoTrack:o,audioTrack:u}),!this._remuxer)return[o,u];s&&this.hls.isLive&&!this.hls.config.mseLowLatency&&(o.duration=this.hls.totalDuration*o.timescale,u.duration=this.hls.totalDuration*u.timescale);try{var p=this._remuxer.remux(s),v=p.videoInitSegment,m=p.videoSegment,y=p.audioInitSegment,_=p.audioSegment,g=Ne(v,m),b=Ne(y,_);return[g?h(h({},l),{},{data:g}):void 0,b?h(h({},d),{},{data:b}):void 0]}catch(k){throw new re(X,ee.FMP4,k)}}},{key:"_fireEvents",value:function(e,t,r,n){var i=this,s=[e,t],a="discontinuity: ".concat(n);s.forEach((function(e){var t;null!==(t=e.samples)&&void 0!==t&&t.length&&(a+="; ".concat(e.samples.length," ").concat(e.type===Ye?"video":"audio"," samples, firstDts/firstPts/duration: ").concat((e.firstDts/e.timescale).toFixed(3),"/").concat((e.firstPts/e.timescale).toFixed(3),"/").concat((e.samplesDuration/e.timescale).toFixed(3))),n&&e.exist()&&i.hls.emit(Sn.METADATA_PARSED,{type:e.type,track:e,meta:h({codec:e.codec,timescale:e.timescale,baseDts:e.baseDts},e.type===Ye?{width:e.width,height:e.height,sarRatio:e.sarRatio}:{codec:e.codec,channelCount:e.channelCount,sampleRate:e.sampleRate})})})),En.debug(a),e.warnings.forEach((function(e){var t;switch(e.type){case it:t=Sn.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case st:t=Sn.LARGE_VIDEO_DTS_GAP_DETECT;break;case at:t=Sn.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT}t&&i.hls.emit(Sn.STREAM_EXCEPTION,h(h({},e),{},{type:t})),En.warn("video exception",e)})),t.warnings.forEach((function(e){var t;switch(e.type){case ot:t=Sn.LARGE_AUDIO_DTS_GAP_DETECT;break;case ut:t=Sn.AUDIO_GAP_DETECT;break;case ct:t=Sn.AUDIO_OVERLAP_DETECT}t&&i.hls.emit(Sn.STREAM_EXCEPTION,h(h({},e),{},{type:t})),En.warn("audio exception",e)})),e.samples.forEach((function(e){e.keyframe&&i.hls.emit(Sn.KEYFRAME,{pts:e.pts})})),r.seiSamples.forEach((function(e){i.hls.emit(Sn.SEI,h(h({},e),{},{originPts:e.originPts/90,sei:{code:e.data.type,content:e.data.payload,dts:e.pts}}))}))}}]),e}(),wn=["data"],Tn=["data"],Dn=new se("BufferService"),An=function(){function e(t){var r=this;y(this,e),b(this,"_decryptor",new kn),b(this,"_transmuxer",null),b(this,"_mse",null),b(this,"_softVideo",null),b(this,"_sourceCreated",!1),b(this,"_needInitSegment",!0),b(this,"_directAppend",!1),this.hls=t,t.config.softDecode?this._softVideo=t.media:(this._mse=new ye(null,{preferMMS:t.config.preferMMS}),t.config.url&&this._mse.bindMedia(t.media).then((function(e){r.hls.emit(Re.MEDIASOURCE_OPENED,e)}))),t.config.decryptor&&(this._decryptor.externalDecryptor=t.config.decryptor)}var t,r,n,i,s,a,o,u,c,l;return g(e,[{key:"baseDts",get:function(){var e,t,r;return null===(e=this._transmuxer)||void 0===e||null===(t=e._demuxer)||void 0===t||null===(r=t._fixer)||void 0===r?void 0:r._baseDts}},{key:"nbSb",get:function(){var e;return null!==(e=this._mse)&&void 0!==e&&e._sourceBuffer?Object.keys(this._mse._sourceBuffer).length:0}},{key:"msIsOpened",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.isOpened}},{key:"msHasOpTasks",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.hasOpTasks}},{key:"msStreaming",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.streaming}},{key:"updateDuration",value:(l=m(f().mark((function e(t){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Dn.debug("update duration",t),!this._mse){e.next=9;break}if(this._mse.isOpened){e.next=5;break}return e.next=5,this._mse.open();case 5:return e.next=7,this._mse.updateDuration(t);case 7:e.next=10;break;case 9:this._softVideo&&(this._softVideo.duration=t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"createSource",value:function(e,t,r,n){if(!this._sourceCreated){var i=e||t;if(i){if(ar.probe(i))this._transmuxer||(this._transmuxer=new xn(this.hls,!1,!this._softVideo,this.hls.config.fixerConfig));else{if(!cr.probe(i))throw new re(Z,null,null,null,"unsupported stream");if(this._softVideo)this._transmuxer||(this._transmuxer=new xn(this.hls,!0,null,this.hls.config.fixerConfig));else{this._directAppend=!0;var s=!1;e&&!r&&cr.findBox(e,["moov","trak"]).forEach((function(e){var t=cr.findBox(e.data,["trak","mdia","minf","stbl","stsd"])[0];if(t){var i=cr.stsd(t).entries[0];if(i)if(i.hvcC)r=i.hvcC.codec||"hev1.1.6.L93.B0";else if(i.avcC)r=i.avcC.codec;else if(i.sampleRate||i.esds){var a;n=(null===(a=i.esds)||void 0===a?void 0:a.codec)||"mp4a.40.2",s=!0}}})),t&&!n&&cr.findBox(t,["moov","trak","mdia","minf","stbl","stsd"]).forEach((function(e){var t=cr.stsd(e).entries[0];t&&t.esds&&(n=t.esds.codec)})),e&&!r&&(r="avc1.42e01e"),t&&!n&&(n="mp4a.40.2"),s&&(r+=", ".concat(n),n=""),this._createMseSource(r,n)}}this._softVideo&&(this._sourceCreated=!0)}}}},{key:"appendBuffer",value:(c=m(f().mark((function e(t,r,n,i,s,a,o){var u,c,l,d,h,p,v,m,y,_,g,b,k,S,E,x=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=n&&n.length||null!=i&&i.length){e.next=2;break}return e.abrupt("return");case 2:if(u=function(){var e,r;null!==(e=x.hls)&&void 0!==e&&e.emit&&(null===(r=x.hls)||void 0===r||r.emit(Re.APPEND_BUFFER,{start:t.start,end:t.end}))},!this._directAppend){e.next=8;break}return c=[],n&&c.push(this._mse.append(ye.VIDEO,n)),i&&c.push(this._mse.append(ye.AUDIO,i)),e.abrupt("return",Promise.all(c).then(u));case 8:if(l=this._needInitSegment||s,d=this._transmuxer.transmux(n,i,l,a,o,this._needInitSegment||s),h=P(d,2),p=h[0],v=h[1],i&&r&&(null==r||r.setTrackExist(!1,!0)),i&&t&&(null==t||t.setTrackExist(!0,!1)),r||null==t||t.setTrackExist(!!p,!!v),p&&!v&&this.hls.emit(Sn.NO_AUDIO_TRACK),!this._softVideo){e.next=20;break}this._softVideo.appendBuffer(p,v),this._needInitSegment=!1,u(),e.next=32;break;case 20:if(!this._mse){e.next=32;break}return(m=!this._sourceCreated)&&this._createMseSource(null==p?void 0:p.codec,null==v?void 0:v.codec,null==v?void 0:v.container),this._needInitSegment=!1,y=this._mse,_=[],l&&!m&&this._handleCodecChange(p,v).forEach((function(e){return _.push(e)})),p&&(g=p.data,b=D(p,wn),_.push(y.append(ye.VIDEO,g,b))),v&&(k=v.data,S=D(v,Tn),_.push(y.append(ye.AUDIO,k,S))),(E=Promise.all(_)).then(u),e.abrupt("return",E);case 32:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i,s,a){return c.apply(this,arguments)})},{key:"removeBuffer",value:(u=m(f().mark((function e(){var t,r,n,i=this,s=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:0,r=s.length>1&&void 0!==s[1]?s[1]:1/0,n=this.hls.media,!(!this._mse||!n||t<0||r<t||t>=this._mse.duration)){e.next=5;break}return e.abrupt("return");case 5:return e.abrupt("return",this._mse.clearBuffer(t,r).then((function(){return i.hls.emit(Re.REMOVE_BUFFER,{start:t,end:r,removeEnd:r})})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"evictBuffer",value:(o=m(f().mark((function e(t){var r,n,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.hls.media,this._mse&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(n=r.currentTime,!((i=n-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(F.start(F.get(r))+1>=i)){e.next=10;break}return e.abrupt("return");case 10:return e.abrupt("return",this.removeBuffer(0,i));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"clearAllBuffer",value:(a=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=2;break}return e.abrupt("return",this._mse.clearAllBuffer());case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"decryptBuffer",value:function(e,t){return this._decryptor.decrypt(e,t)}},{key:"reset",value:(s=m(f().mark((function e(){var t,r=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this._mse||t){e.next=8;break}return this._transmuxer=null,this._sourceCreated=!1,e.next=6,this._mse.unbindMedia();case 6:return e.next=8,this._mse.bindMedia(this.hls.media);case 8:this._needInitSegment=!0,this._directAppend=!1;case 10:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"endOfStream",value:(i=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=5;break}if(!this._sourceCreated){e.next=5;break}return e.next=4,this._mse.endOfStream();case 4:this.hls.emit(Re.BUFFEREOS);case 5:this._softVideo&&this._softVideo.endOfStream();case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setLiveSeekableRange",value:(n=m(f().mark((function e(t,r){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._mse&&this._mse.setLiveSeekableRange(t,r);case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"detachMedia",value:(r=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=3;break}return e.next=3,this._mse.unbindMedia();case 3:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"destroy",value:(t=m(f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(t=this._decryptor)||void 0===t||t.destroy(),e.next=3,this.detachMedia();case 3:this._decryptor=null,this._mse=null,this._softVideo=null;case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_createMseSource",value:function(e,t,r){Dn.debug("create mse source, videoCodec=".concat(e,", audioCodec=").concat(t));var n=this._mse;n&&(e&&(n.createSource(ye.VIDEO,"video/mp4;codecs=".concat(e)),this._sourceCreated=!0),t?(n.createSource(ye.AUDIO,"audio/mp4;codecs=".concat(t)),this._sourceCreated=!0):r&&(n.createSource(ye.AUDIO,"".concat(r,';codecs=""')),this._sourceCreated=!0),this.hls.emit(Re.SOURCEBUFFER_CREATED))}},{key:"_handleCodecChange",value:function(e,t){var r=[],n=this._mse;return[{type:ye.VIDEO,codecs:null==e?void 0:e.codec},{type:ye.AUDIO,codecs:null==t?void 0:t.codec}].filter((function(e){return!!e.codecs})).forEach((function(e){var t=e.type,i=e.codecs,s=n.getSourceBuffer(t);if(s){var a=i.split(",")[0];new RegExp(a,"ig").test(s.mimeType)||r.push(n.changeType(t,"".concat(t,"/mp4;codecs=").concat(i)))}})),r}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0}},{key:"isFull",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ye.VIDEO;return null===(e=this._mse)||void 0===e?void 0:e.isFull(t)}}]),e}();var Cn=g((function e(){y(this,e),b(this,"version",0),b(this,"streams",[]),b(this,"isMaster",!0)})),Ln="AUDIO",Rn="SUBTITLE",On={CLEAR_KEY:"org.w3.clearkey",FAIRPLAY:["urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2","com.apple.streamingkeydelivery"],WIDEVINE:["urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine.alpha","com.widevine"],PLAYREADY:["urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95","com.microsoft.playready"]};function Pn(e){for(var t=[],r=0;r<e.length;r++)Array.isArray(e[r])?t=t.concat(Pn(e[r])):t.push(e[r]);return t}var In=g((function e(){y(this,e),b(this,"id",0),b(this,"url",""),b(this,"default",!1),b(this,"autoSelect",!1),b(this,"forced",!1),b(this,"group",""),b(this,"name",""),b(this,"lang",""),b(this,"segments",[]),b(this,"endSN",0)})),jn=function(e){k(r,e);var t=L(r);function r(){var e;y(this,r);for(var n=arguments.length,i=new Array(n),s=0;s<n;s++)i[s]=arguments[s];return b(A(e=t.call.apply(t,[this].concat(i))),"mediaType",Ln),b(A(e),"channels",0),e}return g(r)}(In),Bn=function(e){k(r,e);var t=L(r);function r(){var e;y(this,r);for(var n=arguments.length,i=new Array(n),s=0;s<n;s++)i[s]=arguments[s];return b(A(e=t.call.apply(t,[this].concat(i))),"mediaType",Rn),e}return g(r)}(In),Mn=g((function e(){y(this,e),b(this,"id",0),b(this,"bitrate",0),b(this,"width",0),b(this,"height",0),b(this,"name",""),b(this,"url",""),b(this,"audioCodec",""),b(this,"videoCodec",""),b(this,"textCodec",""),b(this,"audioGroup",""),b(this,"audioStreams",[]),b(this,"subtitleStreams",[]),b(this,"closedCaptionsStream",[])})),Un=g((function e(){y(this,e),b(this,"version",0),b(this,"url",""),b(this,"type",""),b(this,"startCC",0),b(this,"endCC",0),b(this,"startSN",0),b(this,"endSN",0),b(this,"totalDuration",0),b(this,"targetDuration",0),b(this,"partTargetDuration",0),b(this,"canSkipUntil",0),b(this,"canSkipDateRanges",!1),b(this,"skippedSegments",0),b(this,"canBlockReload",!1),b(this,"partHoldBack",0),b(this,"live",!0),b(this,"lowLatency",!1),b(this,"endPartIndex",0),b(this,"segments",[]),b(this,"dateRanges",{}),b(this,"skippedSegments",0)})),Nn=function(){function e(t){y(this,e),b(this,"sn",0),b(this,"cc",0),b(this,"url",""),b(this,"parentUrl",""),b(this,"title",""),b(this,"start",0),b(this,"duration",0),b(this,"dataTime",""),b(this,"key",null),b(this,"byteRange",null),b(this,"isInitSegment",!1),b(this,"initSegment",null),b(this,"isLast",!1),b(this,"hasAudio",!1),b(this,"hasVideo",!1),b(this,"independent",!1),b(this,"partIndex",0),this.parentUrl=t}return g(e,[{key:"end",get:function(){return this.start+this.duration}},{key:"setTrackExist",value:function(e,t){this.hasVideo=e,this.hasAudio=t}},{key:"setByteRange",value:function(e,t){this.byteRange=[0];var r=e.split("@");1===r.length&&t&&t.byteRange?(this.byteRange[0]=t.byteRange[1]||0,this.byteRange[0]&&(this.byteRange[0]+=1)):this.byteRange[0]=parseInt(r[1]),this.byteRange[1]=this.byteRange[0]+parseInt(r[0])-1}}]),e}(),Fn=function(){function e(t){y(this,e),b(this,"method",""),b(this,"url",""),b(this,"iv",null),b(this,"keyFormat",""),b(this,"keyFormatVersions",""),t instanceof e&&(this.method=t.method,this.url=t.url,this.keyFormat=t.keyFormat,this.keyFormatVersions=t.keyFormatVersions,t.iv&&(this.iv=new Uint8Array(t.iv)))}return g(e,[{key:"clone",value:function(t){var r=new e(this);return null!=t&&r.setIVFromSN(t),r}},{key:"setIVFromSN",value:function(e){if(!this.iv&&"AES-128"===this.method&&"number"==typeof e&&this.url){this.iv=new Uint8Array(16);for(var t=12;t<16;t++)this.iv[t]=e>>8*(15-t)&255}}},{key:"isSegmentEncrypted",value:function(){return"AES-128"===this.method}},{key:"isValidKeySystem",value:function(){return Pn([On.CLEAR_KEY,On.FAIRPLAY,On.WIDEVINE,On.PLAYREADY]).indexOf(this.keyFormat)>-1&&!!(["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)>-1)}},{key:"isSupported",value:function(){return!!this.method&&(!!this.isSegmentEncrypted()||!!this.isValidKeySystem())}}]),e}(),Vn=function(){function e(t,r,n){y(this,e),this.msn=t,this.part=r,this.skip=n}return g(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()),this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}]),e}(),zn=/^#(EXT[^:]*)(?::(.*))?$/,Gn=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,qn=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,Hn=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function Kn(e){return e.split(/[\r\n]/).map((function(e){return e.trim()})).filter(Boolean)}function Yn(e){var t=e.match(zn);if(t&&t[1])return[t[1].replace("EXT-X-",""),t[2]]}function Wn(e){for(var t={},r=Gn.exec(e);r;)t[r[1]]=r[2]||r[3],r=Gn.exec(e);return t}function Xn(e,t){if(!t||!e||qn.test(e))return e;var r=Hn.exec(t);return r?"/"===e[0]?r[1]+e:r[1]+r[2]+e:e}var Qn={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function Jn(e,t){var r=Qn[e];if(r&&t&&t.length)for(var n=0;n<r.length;n++)for(var i=0;i<t.length;i++)if(r[n].test(t[i]))return t[i]}function Zn(e,t){var r;if(t)for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e[n]!==t[n]){r=n;break}var i=null;e.DURATION&&(i=parseFloat(e.DURATION),Number.isFinite(i)?e._endDate&&(i=(e._endDate.getTime()-e._startDate.getTime())/1e3):i=null);var s,a,o=(s=e.CUE||e["X-CUE"],a={pre:!1,post:!1,once:!1},(s?s.split(/[ ,]+/):[]).reduce((function(e,t){return e[t.toLowerCase()]=!0,e}),a));return!!e.ID&&!r&&Number.isFinite(e._startDate.getTime())&&(null===i||i>=0)&&(!("YES"===e.END_ON_NEXT)||!!e.CLASS)&&(!e.CUE||!o.pre&&!o.post||o.pre!==o.post)&&(!("com.apple.hls.interstitial"===e.CLASS)||"X-ASSET-URI"in e||"X-ASSET-LIST"in e)}function $n(e,t){for(var r,n=new Cn,i=0,s=[],a=[];r=e[i++];){var o=Yn(r);if(o){var u=P(o,2),c=u[0],l=u[1];if("VERSION"===c)n.version=parseInt(l);else if("MEDIA"===c&&l){var d=Wn(l),h=void 0;switch(d.TYPE){case"AUDIO":h=new jn;break;case"SUBTITLES":h=new Bn;break;default:h=new In}h.url=Xn(d.URI,t),h.default="YES"===d.DEFAULT,h.autoSelect="YES"===d.AUTOSELECT,h.group=d["GROUP-ID"],h.name=d.NAME,h.lang=d.LANGUAGE,d.CHANNELS&&(h.channels=Number(d.CHANNELS.split("/")[0]),Number.isNaN(h.channels)&&(h.channels=0)),"AUDIO"===d.TYPE&&d.URI&&s.push(h),"SUBTITLES"===d.TYPE&&a.push(h)}else if("STREAM-INF"===c&&l){var f=new Mn,p=Wn(l);if(f.bitrate=parseInt(p["AVERAGE-BANDWIDTH"]||p.BANDWIDTH),f.name=p.NAME,f.url=Xn(e[i++],t),p.RESOLUTION){var v=P(p.RESOLUTION.split("x"),2),m=v[0],y=v[1];f.width=parseInt(m),f.height=parseInt(y)}if(p.CODECS){var _=p.CODECS.split(/[ ,]+/).filter(Boolean);f.videoCodec=Jn("video",_),f.audioCodec=Jn("audio",_),f.textCodec=Jn("text",_)}f.audioGroup=p.AUDIO,f.subtitleGroup=p.SUBTITLES,n.streams.push(f)}}}return n.streams.forEach((function(e,t){e.id=t})),s.length&&(s.forEach((function(e,t){e.id=t})),n.streams.forEach((function(e){e.audioGroup&&(e.audioStreams=s.filter((function(t){return t.group===e.audioGroup})))}))),a.length&&(a.forEach((function(e,t){e.id=t})),n.streams.forEach((function(e){e.subtitleGroup&&(e.subtitleStreams=a.filter((function(t){return t.group===e.subtitleGroup})))}))),n}function ei(e,t,r){var n=new Un;n.url=t;for(var i,s=new Nn(t),a=null,o=null,u=0,c=0,l=0,d=0,h=!1,f=0;i=e[d++];)if("#"===i[0]){var p=Yn(i);if(p){var v=P(p,2),m=v[0],y=v[1];switch(m){case"VERSION":n.version=parseInt(y);break;case"PLAYLIST-TYPE":n.type=null==y?void 0:y.toUpperCase();break;case"TARGETDURATION":n.targetDuration=parseFloat(y);break;case"PART-INF":r&&(n.lowLatency=!0);var _=Wn(y);_["PART-TARGET"]&&(n.partTargetDuration=parseFloat(_["PART-TARGET"]));break;case"SERVER-CONTROL":var g=Wn(y);n.canBlockReload="YES"===g["CAN-BLOCK-RELOAD"],n.partHoldBack=parseFloat(g["PART-HOLD-BACK"]||0),n.canSkipUntil=parseFloat(g["CAN-SKIP-UNTIL"]||0),n.canSkipDateRanges=n.canSkipUntil>0&&"YES"===g["CAN-SKIP-DATERANGES"];break;case"ENDLIST":h=!0;break;case"MEDIA-SEQUENCE":c=n.startSN=parseInt(y);break;case"DISCONTINUITY-SEQUENCE":l=n.startCC=parseInt(y);break;case"DISCONTINUITY":l++;break;case"BYTERANGE":s.setByteRange(y,n.segments[n.segments.length-1]);break;case"PART":if(!n.lowLatency)break;var b=Wn(y);s.duration=parseFloat(b.DURATION),s.independent="YES"===b.INDEPENDENT,s.sn=c,s.cc=l,s.partIndex=f,s.start=u,s.duration=parseFloat(b.DURATION),u+=s.duration,s.url=Xn(b.URI,t),o&&(s.key=o.clone(c)),a&&(s.initSegment=a),n.segments.push(s),s=new Nn(t),f++;break;case"PRELOAD-HINT":var k=Wn(y);if(n.preloadHint=k,"PART"===k.TYPE&&k.URI){var S=k.URI.split(".ts")[0].split("-");n.nextSN=S[3],n.nextIndex=S[S.length-1]}break;case"PROGRAM-DATE-TIME":s.dataTime=y;break;case"EXTINF":if(n.lowLatency){f=0;break}var E=P(y.split(","),2),x=E[0],w=E[1];s.start=u,s.duration=parseFloat(x),u+=s.duration,s.title=w;break;case"KEY":var T=Wn(y);if("NONE"===T.METHOD){o=null;break}if((o=new Fn).method=T.METHOD,o.url=/^blob:/.test(T.URI)?T.URI:Xn(T.URI,t),o.keyFormat=T.KEYFORMAT||"identity",o.keyFormatVersions=T.KEYFORMATVERSIONS,!o.isSupported())throw new Error("encrypt ".concat(T.METHOD,"/").concat(T.KEYFORMAT," is not supported"));if(T.IV){var D=T.IV.slice(2);D=(1&D.length?"0":"")+D,o.iv=new Uint8Array(D.length/2);for(var A=0,C=D.length/2;A<C;A++)o.iv[A]=parseInt(D.slice(2*A,2*A+2),16)}break;case"MAP":var L=Wn(y);s.url=Xn(L.URI,t),L.BYTERANGE&&s.setByteRange(L.BYTERANGE),s.isInitSegment=!0,s.sn=0,o&&(s.key=o.clone(0)),a=s,s=new Nn(t);break;case"SKIP":var R=Wn(y),O=parseInt(R["SKIPPED-SEGMENTS"],10);O<=Number.MAX_SAFE_INTEGER&&(n.skippedSegments+=O,c+=O);break;case"DATERANGE":var I=Wn(y),j=n.dateRanges[I.ID];I._startDate=j?j._startDate:new Date(I["START-DATE"]);var B=(null==j?void 0:j._endDate)||new Date(I.END_DATE);Number.isFinite(B)&&(I._endDate=B),(Zn(I,j)||n.skippedSegments)&&(n.dateRanges[I.ID]=I)}}}else{if(n.lowLatency){c++;continue}s.sn=c,s.cc=l,s.url=Xn(i,t),o&&(s.key=o.clone(c)),a&&(s.initSegment=a),n.segments.push(s),s=new Nn(t),c++}n.segments=n.segments.filter((function(e){return 0!==e.duration}));var M=n.segments[n.segments.length-1];return M&&(h&&(M.isLast=!0),n.endSN=M.sn,n.endPartIndex=M.partIndex),h&&(n.live=!1),n.totalDuration=u,n.endCC=l,n}var ti=function(){function e(){y(this,e)}return g(e,null,[{key:"parse",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(!t.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");var i=Kn(t);return e.isMediaPlaylist(t)?ei(i,r,n):$n(i,r)}},{key:"isMediaPlaylist",value:function(e){return e.includes("#EXTINF:")||e.includes("#EXT-X-TARGETDURATION:")}}]),e}(),ri=function(){function e(t){var r=this;y(this,e),b(this,"_emitOnLoaded",(function(e,t){var n=e.response,i=e.options||{},s=i.firstByteTime,a=i.startTime,o=i.endTime,u=i.contentLength,c=o-a;r.hls.emit(Re.SPEED,{time:c,byteLength:u,url:t}),r.hls.emit(Re.LOAD_COMPLETE,{url:t,elapsed:c||0}),r.hls.emit(Re.TTFB,{url:t,responseUrl:n.url,elapsed:s-a}),r.hls.emit(Re.LOAD_RESPONSE_HEADERS,{headers:n.headers,url:t})})),b(this,"_onLoaderRetry",(function(e,t){r.hls.emit(Sn.LOAD_RETRY,{error:re.network(e),retryTime:t})})),this.hls=t,this._timer=null,this._useLowLatency=t.config.useLowLatency;var n=this.hls.config,i=n.retryCount,s=n.retryDelay,a=n.manifestLoadTimeout,o=n.fetchOptions;this._loader=new Ve(h(h({},o),{},{responseType:"text",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry})),this._audioLoader=new Ve(h(h({},o),{},{responseType:"text",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry})),this._subtitleLoader=new Ve(h(h({},o),{},{responseType:"text",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry}))}var t;return g(e,[{key:"load",value:(t=m(f().mark((function e(t,r,n){var i,s,a,o,u,c,l,d,h,p,v,m,y,_,g,b,k,S,E,x;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=[this._loader.load(t)],r&&i.push(this._audioLoader.load(r)),n&&i.push(this._subtitleLoader.load(n)),e.prev=3,e.next=6,Promise.all(i);case 6:if(d=e.sent,h=P(d,3),p=h[0],v=h[1],m=h[2],p){e.next=13;break}return e.abrupt("return",[]);case 13:this._emitOnLoaded(p,t),s=p.data,u=p.response.url||t,r?(a=null==v?void 0:v.data,o=null==m?void 0:m.data,c=(null==v||null===(y=v.response)||void 0===y?void 0:y.url)||r,l=(null==m||null===(_=m.response)||void 0===_?void 0:_.url)||n,a&&this._emitOnLoaded(v,r),o&&this._emitOnLoaded(m,n)):(o=null==v?void 0:v.data,l=(null==v||null===(g=v.response)||void 0===g?void 0:g.url)||n,o&&this._emitOnLoaded(v,n)),e.next=22;break;case 19:throw e.prev=19,e.t0=e.catch(3),re.network(e.t0);case 22:if(b=this.hls.config.onPreM3U8Parse,e.prev=23,b&&(s=b(s)||s,a&&(a=b(a,!0)||a),o&&(o=b(o,!0)||o)),k=ti.parse(s,u,this._useLowLatency),!1!==(null===(x=k)||void 0===x?void 0:x.live)||!k.segments||k.segments.length){e.next=28;break}throw new Error("empty segments list");case 28:a&&(S=ti.parse(a,c,this._useLowLatency)),o&&(E=ti.parse(o,l,this._useLowLatency)),e.next=35;break;case 32:throw e.prev=32,e.t1=e.catch(23),new re(z,ee.HLS,e.t1);case 35:return k&&(k.isMaster?this.hls.emit(Sn.HLS_MANIFEST_LOADED,{playlist:k}):(this._useLowLatency&&(k.canBlockReload?this.deliveryDirectives=new Vn(k.nextSN,k.nextIndex,""):this.deliveryDirectives=null),this.hls.emit(Sn.HLS_LEVEL_LOADED,{playlist:k}))),e.abrupt("return",[k,S,E]);case 37:case"end":return e.stop()}}),e,this,[[3,19],[23,32]])}))),function(e,r,n){return t.apply(this,arguments)})},{key:"parseText",value:function(e,t){var r,n=this.hls.config.onPreM3U8Parse;try{var i;if(n&&(e=n(e)||e),!1===(null===(i=r=ti.parse(e,t,this._useLowLatency))||void 0===i?void 0:i.live)&&r.segments&&!r.segments.length)throw new Error("empty segments list")}catch(s){throw new re(z,ee.HLS,s)}return r&&(r.isMaster?this.hls.emit(Sn.HLS_MANIFEST_LOADED,{playlist:r}):this.hls.emit(Sn.HLS_LEVEL_LOADED,{playlist:r})),[r]}},{key:"poll",value:function(e,t,r,n,i,s){var a=this;clearTimeout(this._timer),s=s||3e3;var o=this.hls.config.pollRetryCount,u=function(){var c=m(f().mark((function c(){var l,d;return f().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return clearTimeout(a._timer),l=e,c.prev=2,a.deliveryDirectives&&(l=a.deliveryDirectives.addDirectives(e)),c.next=6,a.load(l,t,r);case 6:if((d=c.sent)[0]){c.next=9;break}return c.abrupt("return");case 9:o=a.hls.config.pollRetryCount,n(d[0],d[1],d[2]),c.next=17;break;case 13:c.prev=13,c.t0=c.catch(2),--o<=0&&i(c.t0);case 17:a._timer=setTimeout(u,s);case 18:case"end":return c.stop()}}),c,null,[[2,13]])})));return function(){return c.apply(this,arguments)}}();this._timer=setTimeout(u,s)}},{key:"stopPoll",value:function(){return clearTimeout(this._timer),this.cancel()}},{key:"cancel",value:function(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}}]),e}();function ni(e,t,r){return t>r&&(r=t),Math.min(Math.max(e,t),r)}var ii=new se("playlist"),si=function(){function e(t,r,n){y(this,e),b(this,"live",void 0),b(this,"id",0),b(this,"bitrate",0),b(this,"width",0),b(this,"height",0),b(this,"name",""),b(this,"url",""),b(this,"audioCodec",""),b(this,"videoCodec",""),b(this,"textCodec",""),b(this,"startCC",0),b(this,"endCC",0),b(this,"startSN",0),b(this,"endSN",-1),b(this,"totalDuration",0),b(this,"targetDuration",0),b(this,"partTargetDuration",0),b(this,"canSkipUntil",0),b(this,"canSkipDateRanges",!1),b(this,"skippedSegments",0),b(this,"canBlockReload",!1),b(this,"partHoldBack",0),b(this,"lowLatency",!1),b(this,"endPartIndex",0),b(this,"snDiff",null),b(this,"segments",[]),b(this,"audioStreams",[]),b(this,"subtitleStreams",[]),b(this,"closedCaptions",[]),b(this,"currentAudioStream",null),b(this,"currentSubtitleStream",null),this.update(this._setLLPlaybackPoint(t),r,n)}return g(e,[{key:"lastSegment",get:function(){return this.segments.length?this.segments[this.segments.length-1]:null}},{key:"segmentDuration",get:function(){var e;return this.targetDuration||(null===(e=this.segments[0])||void 0===e?void 0:e.duration)||0}},{key:"liveEdge",get:function(){return this.endTime},set:function(e){this.endTime=e}},{key:"endTime",get:function(){var e;return(null===(e=this.lastSegment)||void 0===e?void 0:e.end)||0},set:function(e){var t=this.lastSegment;t&&(t.duration=e-t.start)}},{key:"currentSubtitleEndSn",get:function(){var e;return(null===(e=this.currentSubtitleStream)||void 0===e?void 0:e.endSN)||0}},{key:"clearOldSegment",value:function(e,t){return this.currentAudioStream&&this._clearSegments(e,t),this._clearSegments(e,t)}},{key:"getAudioSegment",value:function(e){if(e&&this.currentAudioStream){var t=e.sn-this.snDiff;return this.currentAudioStream.segments.find((function(e){return e.sn===t}))}}},{key:"update",value:function(e,t){this.url=e.url,Array.isArray(e.segments)?(null!==this.live&&void 0!==this.live||(this.live=e.live),this._updateSegments(e,this),this.startCC=e.startCC,this.endCC=e.endCC,this.startSN=e.startSN,this.endSN=e.endSN||-1,this.totalDuration=e.totalDuration,this.targetDuration=e.targetDuration,this.live=e.live,this.lowLatency=e.lowLatency,this.canBlockReload=e.canBlockReload,this.canSkipDateRanges=e.canSkipDateRanges,this.canSkipUntil=e.canSkipUntil,this.partHoldBack=e.partHoldBack,this.partTargetDuration=e.partTargetDuration,this.skippedSegments=e.skippedSegments,this.endPartIndex=e.endPartIndex,t&&this.currentAudioStream&&Array.isArray(t.segments)&&(this._updateSegments(t,this.currentAudioStream),(null===this.snDiff||void 0===this.snDiff)&&e.segments.length&&t.segments.length&&(this.snDiff=e.segments[0].sn-t.segments[0].sn))):(this.id=e.id,this.bitrate=e.bitrate,this.width=e.width,this.height=e.height,this.name=e.name,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.textCodec=e.textCodec,this.audioStreams=e.audioStreams,this.subtitleStreams=e.subtitleStreams,!this.currentAudioStream&&this.audioStreams.length&&(this.currentAudioStream=this.audioStreams.find((function(e){return e.default}))||this.audioStreams[0]),!this.currentSubtitleStream&&this.subtitleStreams.length&&(this.currentSubtitleStream=this.subtitleStreams.find((function(e){return e.default}))||this.subtitleStreams[0]))}},{key:"updateSubtitle",value:function(e){var t=this;if(e&&this.currentSubtitleStream&&Array.isArray(e.segments)){var r=this._updateSegments(e,this.currentSubtitleStream),n=this.currentSubtitleStream.segments;if(n.length>100&&(this.currentSubtitleStream.segments=n.slice(100)),r)return r.map((function(e){return{sn:e.sn,url:e.url,duration:e.duration,start:e.start,end:e.end,lang:t.currentSubtitleStream.lang}}))}}},{key:"switchSubtitle",value:function(e){var t=this.subtitleStreams.find((function(t){return t.lang===e})),r=this.currentSubtitleStream;t&&(this.currentSubtitleStream=t,r.segments=[])}},{key:"_setLLPlaybackPoint",value:function(e){if(!e.lowLatency||!e.segments.length)return e;for(var t=e.totalDuration-e.partHoldBack,r=e.segments,n=0,i=0,s=r.length;i<s;i++)r[i].start<=t&&r[i].independent&&(n=i);var a=r.slice(n),o=0;return a.forEach((function(e){e.start=o,o=e.end})),e.segments=a,e.totalDuration=o,e.startSN=a[0].sn,e.startCC=a[0].cc,ii.log("set ll-hls playback point: SN=".concat(e.startSN," partIndex=").concat(a[0].partIndex,", duration=").concat(o)),e}},{key:"_clearSegments",value:function(e,t){for(var r=0,n=this.segments,i=0,s=n.length;i<s;i++)if(n[i].end>=e){r=i;break}return r>t&&(r=t),r&&(this.segments=this.segments.slice(r),this.currentAudioStream&&(this.currentAudioStream.segments=this.currentAudioStream.segments.slice(r))),t-r}},{key:"_updateSegments",value:function(e,t){var r=t.segments;if(this.live){var n,i=e.lowLatency,s=r[r.length-1],a=null!==(n=null==s?void 0:s.sn)&&void 0!==n?n:-1,o=(null==s?void 0:s.partIndex)||0,u=a<e.endSN&&e.segments.length;if(i&&(u=u||o<e.endPartIndex),u){ii.log("update segments: endSN:".concat(a,", partIndex:").concat(o," --\x3e endSN:").concat(e.endSN,", partIndex:").concat(e.endPartIndex));var c=e.segments.findIndex((function(e){return e.sn===a&&e.partIndex===o})),l=c<0?e.segments:e.segments.slice(c+1);if(r.length&&l.length){var d=s.end,h=d;l.forEach((function(e){e.start=d,d=e.end})),ii.log("liveEdge: ".concat(h," -> ").concat(d));var f=(null==s?void 0:s.cc)||-1;f>l[0].cc&&l.forEach((function(e){return e.cc+=f}))}return t.endSN=e.endSN,t.segments=r.concat(l),l}}else t.segments=e.segments}}]),e}(),ai=function(){function e(t){y(this,e),b(this,"streams",[]),b(this,"currentStream",null),b(this,"dvrWindow",0),b(this,"_segmentPointer",-1),this.hls=t}return g(e,[{key:"lowLatency",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.lowLatency}},{key:"lastSegment",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.lastSegment}},{key:"currentSegment",get:function(){var e;return null===(e=this.currentSegments)||void 0===e?void 0:e[this._segmentPointer]}},{key:"nextSegment",get:function(){var e;return null===(e=this.currentSegments)||void 0===e?void 0:e[this._segmentPointer+1]}},{key:"currentSegments",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.segments}},{key:"currentSubtitleEndSn",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.currentSubtitleEndSn}},{key:"liveEdge",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.liveEdge},set:function(e){this.currentStream&&(this.currentStream.liveEdge=e)}},{key:"totalDuration",get:function(){var e;return(null===(e=this.currentStream)||void 0===e?void 0:e.totalDuration)||0}},{key:"seekRange",get:function(){var e=this.currentSegments;if(e&&e.length)return[e[0].start,e[e.length-1].end]}},{key:"nbSegments",get:function(){var e;return(null===(e=this.currentSegments)||void 0===e?void 0:e.length)||0}},{key:"isEmpty",get:function(){var e;return!(null!==(e=this.currentSegments)&&void 0!==e&&e.length)}},{key:"isLive",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.live}},{key:"hadSegmentLoaded",get:function(){return-1!==this._segmentPointer}},{key:"hasSubtitle",get:function(){var e;return!(null===(e=this.currentStream)||void 0===e||!e.currentSubtitleStream)}},{key:"getAudioSegment",value:function(e){var t;return null===(t=this.currentStream)||void 0===t?void 0:t.getAudioSegment(e)}},{key:"moveSegmentPointer",value:function(e){var t;null==e&&(e=this._segmentPointer+1),this._segmentPointer=ni(e,-1,null===(t=this.currentSegments)||void 0===t?void 0:t.length)}},{key:"reset",value:function(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}},{key:"getSegmentByIndex",value:function(e){var t;return null===(t=this.currentSegments)||void 0===t?void 0:t[e]}},{key:"setNextSegmentByIndex",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._segmentPointer=e-1}},{key:"setNextSegmentBySN",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=null===(e=this.currentSegments)||void 0===e?void 0:e.findIndex((function(e){return e.sn===t}));return-1!==r&&this.setNextSegmentByIndex(r+1),r}},{key:"findSegmentIndexByTime",value:function(e){var t=this.currentSegments;if(t){for(var r,n=0,i=t.length;n<i;n++)if(e>=(r=t[n]).start&&e<r.end)return n;var s=t[t.length-1];if(Math.abs(e-(null==s?void 0:s.end))<.2)return t.length-1}}},{key:"upsertPlaylist",value:function(e,t,r){var n=this;if(e){if(e.isMaster)this.streams.length=e.streams.length,e.streams.filter((function(e){return e.url})).forEach((function(e,t){n.streams[t]?n.streams[t].update(e):n.streams[t]=new si(e)})),this.currentStream=this.streams[0];else if(Array.isArray(e.segments)){var i=this.currentStream;if(i){i.update(e,t,r);var s=i.updateSubtitle(r);s&&this.hls.emit(Sn.SUBTITLE_SEGMENTS,{list:s})}else this.reset(),this.currentStream=this.streams[0]=new si(e,t,r)}this.currentStream&&this.hls.isLive&&!this.dvrWindow&&(this.dvrWindow=this.currentSegments.reduce((function(e,t){return e+=t.duration}),0))}}},{key:"updateSegmentsRanges",value:function(e,t){var r;(null===(r=this.currentSegments)||void 0===r?void 0:r.filter((function(t){return t.sn>=e}))).forEach((function(e){e.start=t,t=e.end}))}},{key:"switchSubtitle",value:function(e){var t;null===(t=this.currentStream)||void 0===t||t.switchSubtitle(e)}},{key:"clearOldSegment",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.hls.config.maxPlaylistSize||50,t=this.currentStream;if(this.dvrWindow&&t){var r=t.endTime-this.dvrWindow;if(!(r<=0)){var n=t.segments;n.length<=e||(this._segmentPointer=t.clearOldSegment(r,this._segmentPointer))}}}},{key:"checkSegmentTrackChange",value:function(e,t){var r=this.findSegmentIndexByTime(e),n=this.getSegmentByIndex(r);if(n&&(n.hasAudio||n.hasVideo)){if(2!==t&&n.hasAudio&&n.hasVideo)return n;if(!(n.end-e>.3)){var i=this.getSegmentByIndex(r+1);if(i&&(i.hasAudio||i.hasVideo))return i.hasAudio!==n.hasAudio||i.hasVideo!==n.hasVideo?i:void 0}}}},{key:"feedbackLiveEdge",value:function(e,t){var r;this.currentSegments&&((null===(r=this.lastSegment)||void 0===r?void 0:r.sn)===e.sn?this.liveEdge=t:this.updateSegmentsRanges(e.sn+1,t))}}]),e}(),oi=function(){function e(t){var r=this;y(this,e),b(this,"error",null),b(this,"_emitOnLoaded",(function(e,t){var n=e.data,i=e.response,s=e.options||{},a=s.firstByteTime,o=s.startTime,u=s.endTime,c=s.contentLength,l=u-o;r._bandwidthService.addRecord(c||n.byteLength,l),r.hls.emit(Re.SPEED,{time:l,byteLength:c,url:t}),r.hls.emit(Re.LOAD_COMPLETE,{url:t,elapsed:l||0}),r.hls.emit(Re.TTFB,{url:t,responseUrl:i.url,elapsed:a-o}),r.hls.emit(Re.LOAD_RESPONSE_HEADERS,{headers:i.headers,url:t})})),b(this,"_onLoaderRetry",(function(e,t){r.hls.emit(Re.LOAD_RETRY,{error:re.network(e),retryTime:t})})),this.hls=t,this._bandwidthService=new qe,this._mapCache={},this._keyCache={};var n=this.hls.config,i=n.retryCount,s=n.retryDelay,a=n.loadTimeout,o=n.fetchOptions;this._segmentLoader=new Ve(h(h({},o),{},{responseType:"arraybuffer",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry})),this._audioSegmentLoader=new Ve(h(h({},o),{},{responseType:"arraybuffer",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry})),this._keyLoader=new Ve(h(h({},o),{},{responseType:"arraybuffer",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry}))}var t,r;return g(e,[{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}},{key:"load",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r,i=[];return e&&(i[0]=this.loadVideoSegment(e,r)),t&&(i[1]=this.loadAudioSegment(t,n)),Promise.all(i)}},{key:"loadVideoSegment",value:function(e,t){return this._loadSegment(this._segmentLoader,e,t)}},{key:"loadAudioSegment",value:function(e,t){return this._loadSegment(this._audioSegmentLoader,e,t)}},{key:"_loadSegment",value:(r=m(f().mark((function e(t,r,n){var i,s,a,o,u,c,l,d,h,p,v,m,y,_,g,b=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=[],this.hls.emit(Re.LOAD_START,{url:r.url}),l[0]=t.load(r.url),n&&r.initSegment&&(h=r.initSegment.url,(s=this._mapCache[h])||(this.hls.emit(Re.LOAD_START,{url:h}),l[1]=t.load(h).then((function(e){e&&(Object.keys(b._mapCache)>30&&(b._mapCache={}),s=b._mapCache[h]=e.data,b._emitOnLoaded(e,h))}))),(p=null===(d=r.initSegment.key)||void 0===d?void 0:d.url)&&(c=r.initSegment.key.iv,(u=this._keyCache[p])||(this.hls.emit(Re.LOAD_START,{url:p}),l[2]=this._keyLoader.load(p).then((function(e){e&&(u=b._keyCache[p]=e.data,b._emitOnLoaded(e,p))}))))),(v=null===(i=r.key)||void 0===i?void 0:i.url)&&r.key.isSegmentEncrypted()&&(o=r.key.iv,(a=this._keyCache[v])||(this.hls.emit(Re.LOAD_START,{url:v}),l[3]=this._keyLoader.load(v).then((function(e){e&&(a=b._keyCache[v]=e.data,b._emitOnLoaded(e,v))})))),e.next=8,Promise.all(l);case 8:if(m=e.sent,y=P(m,1),_=y[0]){e.next=13;break}return e.abrupt("return");case 13:return g=_.data,this._emitOnLoaded(_,r.url),e.abrupt("return",{data:g,map:s,key:a,mapKey:u,keyIv:o,mapKeyIv:c});case 16:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"reset",value:function(){this.error=null,this._mapCache={},this._keyCache={},this._bandwidthService.reset()}},{key:"cancel",value:(t=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all([this._keyLoader.cancel(),this._segmentLoader.cancel(),this._audioSegmentLoader.cancel()]);case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),ui=new se("hls"),ci=function(e){k(w,e);var t,r,n,i,s,a,o,u,c,l,d,v,_,S,E,x=L(w);function w(e){var t,r,n;return y(this,w),b(A(t=x.call(this)),"version",w.version),b(A(t),"media",null),b(A(t),"config",null),b(A(t),"_manifestLoader",null),b(A(t),"_segmentLoader",null),b(A(t),"_playlist",null),b(A(t),"_bufferService",null),b(A(t),"_gapService",null),b(A(t),"_seiService",null),b(A(t),"_stats",null),b(A(t),"_prevSegSn",null),b(A(t),"_prevSegCc",null),b(A(t),"_tickTimer",null),b(A(t),"_tickInterval",500),b(A(t),"_segmentProcessing",!1),b(A(t),"_reloadOnPlay",!1),b(A(t),"_switchUrlOpts",null),b(A(t),"_isProcessQuotaExceeded",!1),b(A(t),"_loadSegment",m(f().mark((function e(){var r,n,i,s,a,o,u,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._segmentProcessing&&t.media){e.next=2;break}return e.abrupt("return");case 2:if(r=t._playlist,n=r.nextSegment,i=r.lastSegment,s=A(t),a=s.config,.016,o=Math.min(Math.max((null==i?void 0:i.duration)-.008||0,.016),.1),n){e.next=8;break}return e.abrupt("return");case 8:if(t.isLive){e.next=18;break}if(u=t.bufferInfo(),t.media.paused&&!t.media.currentTime&&(u=t.bufferInfo(u.nextStart||.5)),c=Math.abs(u.end-t.media.duration)<o,!(u.remaining>=a.preloadTime||c)){e.next=15;break}return t._tryEos(),e.abrupt("return");case 15:if(!a.preferMMSStreaming||t._bufferService.msStreaming){e.next=17;break}return e.abrupt("return");case 17:!t._urlSwitching&&t._prevSegSn!==n.sn-1&&u.end&&Math.abs(n.start-u.end)>1&&t._playlist.setNextSegmentByIndex(t._playlist.findSegmentIndexByTime(u.end+.1));case 18:return e.abrupt("return",t._loadSegmentDirect());case 19:case"end":return e.stop()}}),e)})))),b(A(t),"_onLoadeddata",(function(){t.isLive&&!t.config.mseLowLatency&&t.media.duration!==1/0&&t._bufferService.updateDuration(1/0).catch((function(e){}))})),b(A(t),"_onPlay",m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.media.seeking||0!==t.media.currentTime){e.next=3;break}return ui.debug("replay currentTime 0, return"),e.abrupt("return");case 3:if(clearTimeout(t._disconnectTimer),!t._reloadOnPlay){e.next=9;break}t._reloadOnPlay=!1,t.replay(!0),e.next=12;break;case 9:return e.next=11,t._loadSegment();case 11:t._startTick();case 12:case"end":return e.stop()}}),e)})))),b(A(t),"_onPause",(function(){if(t.isLive){if(!t._reloadOnPlay){var e=t.config.disconnectTime;if(null==e&&(e=t._playlist.dvrWindow),!Number.isFinite(e))return;clearTimeout(t._disconnectTimer),t._disconnectTimer=setTimeout((function(){t._reloadOnPlay=!0,t._clear()}),e||0)}}else t._stopTick()})),b(A(t),"_onSeeking",m(f().mark((function e(){var r,n,i,s,a,o,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.media){e.next=2;break}return e.abrupt("return");case 2:if(t._onCheckQuotaExceeded(),r=t.media.currentTime,!(n=t._playlist.seekRange)){e.next=10;break}if(!((i=ni(r,n[0],t.isLive?n[1]:t.media.duration))>=0&&Math.abs(r-i)>=.1)){e.next=10;break}return t.media.currentTime=i,e.abrupt("return");case 10:if(s=t._playlist.currentSegment,a=F.info(F.get(t.media),r,.1),!s){e.next=17;break}if(!(a.end&&Math.abs(a.end-s.end)<.2)){e.next=15;break}return e.abrupt("return");case 15:if(!t.isLive||!a.end){e.next=17;break}return e.abrupt("return");case 17:if(o=t._playlist.findSegmentIndexByTime(r),u=t._playlist.getSegmentByIndex(o),null!=o&&u&&(!t._segmentProcessing||u!==t._playlist.nextSegment)){e.next=21;break}return e.abrupt("return");case 21:return ui.debug("seek to",r,u),t._playlist.setNextSegmentByIndex(o),t._stopTick(),e.next=26,t._segmentLoader.cancel();case 26:if(t._segmentProcessing=!1,a.end&&!t.isLive){e.next=30;break}return e.next=30,t._loadSegmentDirect(!0);case 30:t._startTick();case 31:case"end":return e.stop()}}),e)})))),b(A(t),"_onTimeupdate",(function(){if(t.media){var e,r=t.config;if(r.isLive&&r.maxLatency&&r.targetLatency){var n=t._playlist.liveEdge;if(!n)return;var i=n-t.media.currentTime;i>=r.maxLatency&&(ui.debug("latency jump, currentTime:".concat(t.media.currentTime,", liveEdge:").concat(n,", latency=").concat(i)),t.media.currentTime=n-r.targetLatency)}if(r.seiInTime)null===(e=t._seiService)||void 0===e||e.throw(t.media.currentTime);r.allowedStreamTrackChange&&!r.softDecode&&t.media.readyState&&t._checkStreamTrackChange(t.media.currentTime)}})),b(A(t),"_tick",(function(){if(t.media){t._startTick();var e=t.media,r=t._segmentLoader.error;if(t._onCheckQuotaExceeded(),t._isProcessQuotaExceeded&&(t._bufferService.isFull()||(t._isProcessQuotaExceeded=!1,t._segmentProcessing=!1)),r){(!e.readyState||t.bufferInfo(.5).remaining<1)&&(r.fatal=!0,t._emitError(re.network(r)))}else e.readyState&&(!function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e)?e.readyState<2&&t._gapService&&t._gapService.do(e,t.config.maxJumpDistance,!e.currentTime||t.isLive):(t._loadSegment(),t._gapService&&t._gapService.do(e,t.config.maxJumpDistance,t.isLive))),t.isLive||t._tryEos()}})),t.config=(n=(null==(r=e)?void 0:r.media)||document.createElement("video"),e=h(h({maxPlaylistSize:50,retryCount:3,retryDelay:1e3,pollRetryCount:2,loadTimeout:1e4,manifestLoadTimeout:1e4,preloadTime:30,softDecode:!1,bufferBehind:10,maxJumpDistance:3,startTime:0,useLowLatency:!0,targetLatency:10,maxLatency:20,allowedStreamTrackChange:!0,seiInTime:!1,manifestList:[],minSegmentsStartPlay:3,preferMMS:!1,preferMMSStreaming:!1,mseLowLatency:!0,fixerConfig:{forceFixLargeGap:!1,largeGapThreshold:5}},r),{},{media:n})),t.media=t.config.media,t._manifestLoader=new ri(A(t)),t._segmentLoader=new oi(A(t)),t._playlist=new ai(A(t)),t._bufferService=new An(A(t)),e.seiInTime&&(t._seiService=new Ge(A(t))),e.softDecode||(t._gapService=new ze),t._stats=new Ke(A(t),9e4),t.media.addEventListener("loadeddata",t._onLoadeddata),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("pause",t._onPause),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t}return g(w,[{key:"isLive",get:function(){return this._playlist.isLive}},{key:"streams",get:function(){return this._playlist.streams}},{key:"currentStream",get:function(){return this._playlist.currentStream}},{key:"hasSubtitle",get:function(){return this._playlist.hasSubtitle}},{key:"totalDuration",get:function(){return this._playlist.totalDuration}},{key:"baseDts",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}},{key:"abrSwitchPoint",get:function(){var e=this._urlSwitching?this._playlist.currentSegment:this._playlist.nextSegment;return e?e.start+e.duration/2:null}},{key:"speedInfo",value:function(){return this._segmentLoader.speedInfo()}},{key:"bufferInfo",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.1;return F.info(F.get(this.media),null===(e=this.media)||void 0===e?void 0:e.currentTime,t)}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"playbackQuality",value:function(){return function(e){if(!e)return{};if("function"==typeof e.getVideoPlaybackQuality){var t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}return{droppedVideoFrames:e.webkitDroppedFrameCount,totalVideoFrames:e.webkitDecodedFrameCount,creationTime:performance.now()}}(this.media)}},{key:"load",value:(E=m(f().mark((function e(){var t,r,n,i=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:"",r=i.length>1&&void 0!==i[1]?i[1]:{},n="boolean"==typeof r?r:!(null==r||!r.reuseMse),"object"===p(r)&&null!=r&&r.clearSwitchStatus&&(this._urlSwitching=!1,this._switchUrlOpts=null,this.config.startTime=void 0),t&&(this.config.url=t),t=this.config.url,e.next=8,this._reset(n);case 8:return e.next=10,this._loadData(t);case 10:this._startTick();case 11:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"_loadData",value:(S=m(f().mark((function e(t){var r,n,i,s,a,o,u,c,l,d,h,p,v;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{t&&(t=t.trim())}catch(f){}if(t){e.next=3;break}throw this._emitError(new re(Z,ee.OPTION,null,null,"m3u8 url is missing"));case 3:return e.next=5,this._loadM3U8(t);case 5:if(r=e.sent,n=this._playlist.currentStream,!this._urlSwitching){e.next=23;break}if(!this.isLive){e.next=14;break}i=this._playlist.setNextSegmentBySN(this._prevSegSn),ui.log("segment nb=".concat(this._prevSegSn," index of ").concat(i," in the new playlist")),-1===i&&(this._prevSegCc=null,this._prevSegSn=null),e.next=23;break;case 14:if(0===n.bitrate&&null!==(s=this._switchUrlOpts)&&void 0!==s&&s.bitrate&&(n.bitrate=null===(u=this._switchUrlOpts)||void 0===u?void 0:u.bitrate),c="number"==typeof(null===(a=this._switchUrlOpts)||void 0===a?void 0:a.startTime)?null===(o=this._switchUrlOpts)||void 0===o?void 0:o.startTime:this._getSeamlessSwitchPoint(),this.config.startTime=c,l=this._playlist.findSegmentIndexByTime(c),!(d=this._playlist.getSegmentByIndex(l+1))){e.next=23;break}return h=d.start,e.next=23,this._bufferService.removeBuffer(h);case 23:if(r){e.next=25;break}return e.abrupt("return");case 25:if(!this.isLive){e.next=36;break}if(this._bufferService.setLiveSeekableRange(0,4294967295),ui.log("totalDuration first time got:",this._playlist.totalDuration),ui.log("nb segments got:",this._playlist.nbSegments),this.config.targetLatency<this._playlist.totalDuration&&(this.config.targetLatency=this._playlist.totalDuration,this.config.maxLatency=1.5*this.config.targetLatency),r.isMaster||this._pollM3U8(t),!(this._playlist.nbSegments<this.config.minSegmentsStartPlay)){e.next=33;break}return e.abrupt("return");case 33:return e.next=35,this._loadSegment();case 35:return e.abrupt("return");case 36:return e.next=38,this._bufferService.updateDuration(n.totalDuration);case 38:return(p=this.config.startTime)&&(null!==(v=this._switchUrlOpts)&&void 0!==v&&v.seamless||(this.media.currentTime=p),this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(p)||0)),e.next=42,this._loadSegment();case 42:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"replay",value:(_=m(f().mark((function e(t){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.config.startTime=0,this._urlSwitching=!1,this._switchUrlOpts=null,e.next=5,this.load();case 5:return this._reloadOnPlay=!1,e.abrupt("return",this.media.play(!t));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"switchURL",value:(v=m(f().mark((function e(t){var r,n,i,s,a,o,u,c=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=c.length>1&&void 0!==c[1]?c[1]:{},n={seamless:!1,startTime:0,bitrate:0},e.t0=p(r),e.next="number"===e.t0?5:"boolean"===e.t0?7:"object"===e.t0?9:11;break;case 5:return r={startTime:r},e.abrupt("break",12);case 7:return r={seamless:r},e.abrupt("break",12);case 9:for(i in r)void 0!==r[i]&&null!==r[i]||delete r[i];return e.abrupt("break",12);case 11:throw"unsupported switchURL args: ".concat(r);case 12:if(r=Object.assign({},n,r),a=(s=r).seamless,o=s.startTime,this.config.url=t,this.config.startTime=o,this._switchUrlOpts=r,a){e.next=38;break}if(e.prev=18,!this.config.softDecode){e.next=23;break}e.t1=this.load(t),e.next=26;break;case 23:return e.next=25,this.load(t);case 25:e.t1=e.sent;case 26:u=e.t1,e.next=33;break;case 29:throw e.prev=29,e.t2=e.catch(18),this.emit(Sn.SWITCH_URL_FAILED,e.t2),e.t2;case 33:return this._reloadOnPlay=!1,u&&this.emit(Sn.SWITCH_URL_SUCCESS,{url:t}),e.abrupt("return",this.media.play(!0));case 38:return this._urlSwitching=!0,this.isLive||(this._prevSegSn=null,this._prevSegCc=null),this._playlist.reset(),this._bufferService.seamlessSwitch(),e.next=44,this._clear();case 44:return e.next=46,this._loadData(t);case 46:this._startTick();case 47:this._switchUrlOpts=null;case 48:case"end":return e.stop()}}),e,this,[[18,29]])}))),function(e){return v.apply(this,arguments)})},{key:"switchStream",value:(d=m(f().mark((function e(t){var r,n,i,s,a,o=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!(o.length>1&&void 0!==o[1])||o[1],n=this.currentStream,i=this.streams,n&&n.id!==t&&i&&!(i.length<2)){e.next=5;break}return e.abrupt("return");case 5:if(s=i.find((function(e){return e.id===t}))){e.next=8;break}return e.abrupt("return");case 8:return e.prev=8,e.next=11,this._clear();case 11:if(!r){e.next=14;break}return e.next=14,this._bufferService.clearAllBuffer();case 14:e.next=19;break;case 16:throw e.prev=16,e.t0=e.catch(8),this._emitError(re.create(e.t0));case 19:if(n.currentAudioStream&&s.audioStreams.length>2&&(a=n.currentAudioStream.id,s.currentAudioStream=s.audioStreams.find((function(e){return e.id===a}))||s.currentAudioStream),this._playlist.currentStream=s,e.prev=21,!this.isLive&&s.segments.length){e.next=25;break}return e.next=25,this._refreshM3U8();case 25:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,e.next=29,this._loadSegmentDirect();case 29:e.next=35;break;case 31:throw e.prev=31,e.t1=e.catch(21),this._playlist.currentStream=n,e.t1;case 35:return this._startTick(),e.abrupt("return",s);case 37:case"end":return e.stop()}}),e,this,[[8,16],[21,31]])}))),function(e){return d.apply(this,arguments)})},{key:"switchAudioStream",value:(l=m(f().mark((function e(t){var r,n,i,s,a=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!(a.length>1&&void 0!==a[1])||a[1],n=this.currentStream){e.next=4;break}return e.abrupt("return");case 4:if((i=n.currentAudioStream)&&i.id!==t&&!(n.audioStreams.length<2)){e.next=7;break}return e.abrupt("return");case 7:if(s=n.audioStreams.find((function(e){return e.id===t}))){e.next=10;break}return e.abrupt("return");case 10:return e.prev=10,e.next=13,this._clear();case 13:if(!r){e.next=16;break}return e.next=16,this._bufferService.clearAllBuffer();case 16:e.next=21;break;case 18:throw e.prev=18,e.t0=e.catch(10),this._emitError(re.create(e.t0));case 21:if(n.currentAudioStream=s,e.prev=22,!this.isLive&&s.segments.length){e.next=26;break}return e.next=26,this._refreshM3U8();case 26:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,e.next=30,this._loadSegmentDirect();case 30:e.next=36;break;case 32:throw e.prev=32,e.t1=e.catch(22),n.currentAudioStream=i,e.t1;case 36:return this._startTick(),e.abrupt("return",s);case 38:case"end":return e.stop()}}),e,this,[[10,18],[22,32]])}))),function(e){return l.apply(this,arguments)})},{key:"switchSubtitleStream",value:(c=m(f().mark((function e(t){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._playlist.switchSubtitle(t),e.next=3,this._manifestLoader.stopPoll();case 3:return e.next=5,this._refreshM3U8();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"detachMedia",value:(u=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._bufferService){e.next=3;break}return e.next=3,this._bufferService.detachMedia();case 3:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"destroy",value:(o=m(f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.media){e.next=2;break}return e.abrupt("return");case 2:return this.removeAllListeners(),this._playlist.reset(),this._segmentLoader.reset(),null===(t=this._seiService)||void 0===t||t.reset(),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("pause",this._onPause),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),e.next=13,Promise.all([this._clear(),this._bufferService.destroy()]);case 13:this.media=null;case 14:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_loadM3U8",value:(a=m(f().mark((function e(t){var r,n,i,s,a,o,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(s=null===(n=this.config.manifestList)||void 0===n||null===(i=n.filter((function(e){return e.url===t}))[0])||void 0===i?void 0:i.manifest)){e.next=6;break}e.t0=this._manifestLoader.parseText(s,t),e.next=9;break;case 6:return e.next=8,this._manifestLoader.load(t);case 8:e.t0=e.sent;case 9:a=e.t0,o=P(a,1),r=o[0],e.next=17;break;case 14:throw e.prev=14,e.t1=e.catch(0),this._emitError(re.create(e.t1));case 17:if(r){e.next=19;break}return e.abrupt("return");case 19:if(this._playlist.upsertPlaylist(r),!r.isMaster){e.next=24;break}return null!==(u=this._playlist.currentStream.subtitleStreams)&&void 0!==u&&u.length&&this.emit(Sn.SUBTITLE_PLAYLIST,{list:this._playlist.currentStream.subtitleStreams}),e.next=24,this._refreshM3U8();case 24:return this.emit(Sn.STREAM_PARSED),e.abrupt("return",r);case 26:case"end":return e.stop()}}),e,this,[[0,14]])}))),function(e){return a.apply(this,arguments)})},{key:"_refreshM3U8",value:function(){var e,t,r=this,n=this._playlist.currentStream;if(!n||!n.url)throw this._emitError(re.create(null,null,new Error("m3u8 url is not defined")));var i=n.url,s=null===(e=n.currentAudioStream)||void 0===e?void 0:e.url,a=null===(t=n.currentSubtitleStream)||void 0===t?void 0:t.url;return this._manifestLoader.load(i,s,a).then((function(e){var t=P(e,3),n=t[0],o=t[1],u=t[2];n&&(r._playlist.upsertPlaylist(n,o,u),r.isLive&&r._pollM3U8(i,s,a))})).catch((function(e){throw r._emitError(re.create(e))}))}},{key:"_pollM3U8",value:function(e,t,r){var n,i,s=this,a=this._playlist.isEmpty;this._playlist.lowLatency?n=1e3*(this._playlist.currentStream.partTargetDuration||0):n=1e3*((null===(i=this._playlist.lastSegment)||void 0===i?void 0:i.duration)||0);this._manifestLoader.poll(e,t,r,(function(e,t,r){s._playlist.upsertPlaylist(e,t,r),s._playlist.clearOldSegment(),(e&&a&&!s._playlist.isEmpty||!s._playlist.hadSegmentLoaded&&s._playlist.nbSegments>=s.config.minSegmentsStartPlay)&&s._loadSegment(),a&&(a=s._playlist.isEmpty)}),(function(e){s._emitError(re.create(e))}),n)}},{key:"_loadSegmentDirect",value:(s=m(f().mark((function e(t){var r,n,i,s,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this._playlist.nextSegment){e.next=3;break}return e.abrupt("return");case 3:return n=!1,i=null,e.prev=5,this._segmentProcessing=!0,ui.log("load segment, sn:".concat(r.sn,", [").concat(r.start,", ").concat(r.end,"], partIndex:").concat(r.partIndex)),e.next=10,this._reqAndBufferSegment(r,this._playlist.getAudioSegment(r));case 10:n=e.sent,e.next=16;break;case 13:e.prev=13,e.t0=e.catch(5),i=e.t0;case 16:return e.prev=16,this._segmentProcessing=!1,e.finish(16);case 19:if(!i){e.next=26;break}if(!this._bufferService.isFull()){e.next=25;break}return ui.log("load segment, sn:".concat(r.sn,", partIndex:").concat(r.partIndex)),this._segmentProcessing=!0,this._isProcessQuotaExceeded=!0,e.abrupt("return",!1);case 25:return e.abrupt("return",this._emitError(re.create(i)));case 26:return n&&(a=this.bufferInfo().end,this.isLive&&!this.media.seeking&&a&&Math.abs(r.end-a)>1&&(ui.warn("segment: ".concat(r.sn," expected end=").concat(r.end,", real end=").concat(a)),this._playlist.feedbackLiveEdge(r,a)),o=(null===(s=this._playlist.currentStream)||void 0===s?void 0:s.url)===r.parentUrl,this._urlSwitching&&!o&&(ui.warn("pre playlist segment appended!"),this._bufferService.seamlessSwitch()),this.isLive&&this._urlSwitching&&o&&(this._urlSwitching=!1,this.emit(Sn.SWITCH_URL_SUCCESS,{url:this.config.url})),this._playlist.moveSegmentPointer(),r.isLast?this._end():t||this._loadSegment()),e.abrupt("return",n);case 28:case"end":return e.stop()}}),e,this,[[5,13,16,19]])}))),function(e){return s.apply(this,arguments)})},{key:"_reqAndBufferSegment",value:(i=m(f().mark((function e(t,r){var n,i,s,a,o,u,c,l,d,h,p;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t?t.cc:r.cc,s=this._prevSegCc!==i,a=[],e.prev=3,e.next=6,this._segmentLoader.load(t,r,s);case 6:a=e.sent,e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(3),e.t0.fatal=!1,this._segmentLoader.error=e.t0,e.t0;case 14:if(a[0]){e.next=16;break}return e.abrupt("return");case 16:return e.next=18,(n=this._bufferService).decryptBuffer.apply(n,I(a));case 18:if(o=e.sent){e.next=21;break}return e.abrupt("return");case 21:return u=t?t.sn:r.sn,c=t?t.start:r.start,l=this._playlist.currentStream,this._bufferService.createSource(o[0],o[1],null==l?void 0:l.videoCodec,null==l?void 0:l.audioCodec),d=Date.now(),h=this._prevSegSn===u-1,this.isLive&&this._urlSwitching&&(p=this.bufferInfo().end,this._playlist.updateSegmentsRanges(u,p),ui.warn("update the new playlist liveEdge, segment id=".concat(u,", buffer start=").concat(p,", liveEdge=").concat(this._playlist.liveEdge)),c=p),e.next=30,this._bufferService.appendBuffer(t,r,o[0],o[1],s,h,c);case 30:return this.emit(Sn.APPEND_COST,{elapsed:Date.now()-d,url:t.url}),e.next=33,this._bufferService.evictBuffer(this.config.bufferBehind);case 33:return this._prevSegCc=i,this._prevSegSn=u,e.abrupt("return",!0);case 36:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e,t){return i.apply(this,arguments)})},{key:"_onCheckQuotaExceeded",value:(n=m(f().mark((function e(){var t,r,n,i,s,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.media.currentTime,r=this.media.buffered,n=!1,i=0;case 4:if(!(i<r.length)){e.next=11;break}if(!(r.start(0)>=t&&t<r.end(i))){e.next=8;break}return n=!0,e.abrupt("break",11);case 8:i++,e.next=4;break;case 11:if(!this._bufferService.isFull()){e.next=17;break}if(s=n?this.config.bufferBehind:5,!((a=this.media.currentTime)-s>0)){e.next=17;break}return e.next=17,this._bufferService.removeBuffer(0,a-s);case 17:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_checkStreamTrackChange",value:function(e){var t=this._playlist.checkSegmentTrackChange(e,this._bufferService.nbSb);t&&this.switchURL(this.config.url,t.start+.2)}},{key:"_clear",value:(r=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._disconnectTimer),this._stopTick(),e.next=4,Promise.all([this._segmentLoader.cancel(),this._manifestLoader.stopPoll()]);case 4:this._segmentProcessing=!1;case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_reset",value:(t=m(f().mark((function e(){var t,r,n=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>0&&void 0!==n[0]&&n[0],this._reloadOnPlay=!1,this._prevSegSn=null,this._prevSegCc=null,this._switchUrlOpts=null,this._playlist.reset(),this._segmentLoader.reset(),null===(t=this._seiService)||void 0===t||t.reset(),this._stats.reset(),e.next=11,this._clear();case 11:return e.abrupt("return",this._bufferService.reset(r));case 12:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_end",value:function(){this._clear(),this._bufferService.endOfStream(),(this.media.readyState<=2||this.media.buffered.length>1)&&this._startTick()}},{key:"_stopTick",value:function(){this._tickTimer&&clearTimeout(this._tickTimer),this._tickTimer=null}},{key:"_startTick",value:function(){this._stopTick(),this._tickTimer=setTimeout(this._tick,this._tickInterval)}},{key:"_emitError",value:function(e){var t,r,n,i,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!1===(null===(t=e.originError)||void 0===t?void 0:t.fatal)?ui.warn(e):(ui.table(e),ui.error(e),ui.error(null===(r=this.media)||void 0===r?void 0:r.error),null!==(n=this.media)&&void 0!==n&&n.readyState&&this.media.pause(),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit(Sn.SWITCH_URL_FAILED,e)),this.emit(Sn.ERROR,e),s&&this._end(),null===(i=this._seiService)||void 0===i||i.reset());return e}},{key:"_getSeamlessSwitchPoint",value:function(){var e=this.media,t=e.currentTime;if(!e.paused){var r,n=this._playlist.findSegmentIndexByTime(e.currentTime),i=this._playlist.getSegmentByIndex(n),s=null===(r=this._stats)||void 0===r?void 0:r.getStats().downloadSpeed;if(s&&i)t+=i.duration*this._playlist.currentStream.bitrate/s+1;else t+=5}return t}},{key:"_tryEos",value:function(){var e,t,r=this.media,n=this._playlist,i=n.nextSegment,s=n.lastSegment;if((!i||s&&F.isBuffered(r,s.start+s.duration/2))&&r.readyState&&r.duration>0&&(null===(e=this._bufferService)||void 0===e?void 0:e.msIsOpened)&&!(null!==(t=this._bufferService)&&void 0!==t&&t.msHasOpTasks)){var a=this.bufferInfo();r.paused&&!r.currentTime&&(a=this.bufferInfo(a.nextStart||.5)),(Math.abs(a.end-r.duration)<.1||!this.isLive&&s&&a.end>=s.start+s.duration)&&this._bufferService.endOfStream()}}}],[{key:"isSupported",value:function(e){return e&&"video"!==e&&"audio"!==e?"undefined"!=typeof WebAssembly:ye.isSupported()}},{key:"enableLogger",value:function(){se.enable(),gt.enable()}},{key:"disableLogger",value:function(){se.disable(),gt.disable()}}]),w}(Pe);b(ci,"version","3.0.21");try{localStorage.getItem("xgd")?ci.enableLogger():ci.disableLogger()}catch(fi){}var li=function(){function e(t,r){var n=this;y(this,e),b(this,"_opts",null),b(this,"_plugin",null),b(this,"_onLowDecode",(function(){var e,t,r,i,s=n._opts,a=s.media,o=s.innerDegrade;null===(e=n._plugin)||void 0===e||null===(t=e.player)||void 0===t||t.emit("lowdecode",a.degradeInfo),null===(r=n._plugin)||void 0===r||null===(i=r.player)||void 0===i||i.emit("core_event",h(h({},a.degradeInfo),{},{eventName:Sn.LOWDECODE})),1===o&&n._degrade(a.src)})),b(this,"_degrade",(function(e){var t=n._plugin.player,r=t.video;if(!r||"MVideo"===r.TAG){var i=t.video.degradeVideo;t.video=i,r.degrade(e),e&&(t.config.url=e);var s=t.root.firstChild;"MVideo"===s.TAG&&t.root.replaceChild(i,s);var a=n._plugin.constructor.pluginName.toLowerCase();t.unRegisterPlugin(a),t.once("canplay",(function(){t.play()}))}})),b(this,"forceDegradeToVideo",(function(e){1===n._opts.innerDegrade&&n._degrade(e)})),this._opts=t,this._plugin=r,this._init()}return g(e,[{key:"_init",value:function(){var e=this._opts,t=e.media,r=e.preloadTime,n=e.innerDegrade,i=e.isLive;t&&(i||!t.setPlayMode?(n&&t.setAttribute("innerdegrade",n),r&&t.setAttribute("preloadtime",r),this._bindEvents()):t.setPlayMode("VOD"))}},{key:"_bindEvents",value:function(){this._opts.media.addEventListener("lowdecode",this._onLowDecode)}},{key:"destroy",value:function(){var e,t;null===(e=this._opts)||void 0===e||null===(t=e.media)||void 0===t||t.removeEventListener("lowdecode",this._onLowDecode),this._plugin=null}}]),e}(),di=["currentTime"];var hi=function(e){k(r,e);var t=L(r);function r(){var e;y(this,r);for(var n=arguments.length,i=new Array(n),s=0;s<n;s++)i[s]=arguments[s];return b(A(e=t.call.apply(t,[this].concat(i))),"logger",ui),b(A(e),"hls",null),b(A(e),"pluginExtension",null),b(A(e),"getStats",(function(){var t;return null===(t=e.hls)||void 0===t?void 0:t.getStats()})),b(A(e),"_onSwitchSubtitle",(function(t){var r,n=t.lang;null===(r=e.hls)||void 0===r||r.switchSubtitleStream(n)})),b(A(e),"_keepPauseStatus",(function(){e.player.paused&&e.player.once("canplay",(function(){e.player.pause()}))})),e}return g(r,[{key:"core",get:function(){return this.hls}},{key:"version",get:function(){var e;return null===(e=this.hls)||void 0===e?void 0:e.version}},{key:"softDecode",get:function(){var e,t,r=null===(e=this.player)||void 0===e||null===(t=e.config)||void 0===t?void 0:t.mediaType;return!!r&&"video"!==r&&"audio"!==r&&"offscreen-video"!==r}},{key:"beforePlayerInit",value:function(){var e=this,t=this.player.config,r=this.player.media||this.player.video,n=t.hls||{};if((t.url||t.__allowHlsEmptyUrl__)&&(this.softDecode||n.preferMMS||!ye.isMMSOnly())){this.hls&&this.hls.destroy();var i=Object.getOwnPropertyDescriptor(this.player,"switchURL");i&&!i.writable||(this.player.switchURL=function(t,r){return new Promise((function(n,i){var s=e.player,a=e.hls;if(a){var o,u,c=function(e,t){var r={startTime:t.player.currentTime};switch(p(e)){case"boolean":r.seamless=e;break;case"object":var n=e.currentTime,i=D(e,di);Object.assign(r,i),"number"==typeof n&&(r.startTime=n)}return r}(r,e);s.config.url=t,a.switchURL(t,c).then((function(){return n(!0)})).catch(i),!c.seamless&&null!==(o=e.player.config)&&void 0!==o&&null!==(u=o.hls)&&void 0!==u&&u.keepStatusAfterSwitch&&e._keepPauseStatus()}else i()}))});var s,a=this.player.switchURL;if(this.player.handleSource=!1,n.innerDegrade=n.innerDegrade||t.innerDegrade,null!==n.disconnectTime&&void 0!==n.disconnectTime||(n.disconnectTime=0),this.hls=new ci(h({softDecode:this.softDecode,isLive:t.isLive,media:r,startTime:t.startTime,url:t.url},n)),this.softDecode||l.BasePlugin.defineGetterOrSetter(this.player,{url:{get:function(){var t,r;return null===(t=e.hls)||void 0===t||null===(r=t.media)||void 0===r?void 0:r.src},configurable:!0}}),this.softDecode&&(this.pluginExtension=new li(h({isLive:t.isLive,media:r},n),this),this.player.forceDegradeToVideo=function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return null===(t=e.pluginExtension)||void 0===t?void 0:t.forceDegradeToVideo.apply(t,n)}),t.isLive)null===(s=this.player)||void 0===s||s.useHooks("replay",(function(){var t;return null===(t=e.hls)||void 0===t?void 0:t.replay()}));this.on(l.Events.URL_CHANGE,a),this.on(l.Events.SWITCH_SUBTITLE||"switch_subtitle",this._onSwitchSubtitle),this.on(l.Events.DESTROY,this.destroy.bind(this)),this._transError(),this._transCoreEvent(Re.TTFB),this._transCoreEvent(Re.LOAD_START),this._transCoreEvent(Re.LOAD_RESPONSE_HEADERS),this._transCoreEvent(Re.LOAD_COMPLETE),this._transCoreEvent(Re.LOAD_RETRY),this._transCoreEvent(Re.SOURCEBUFFER_CREATED),this._transCoreEvent(Re.MEDIASOURCE_OPENED),this._transCoreEvent(Re.APPEND_BUFFER),this._transCoreEvent(Re.REMOVE_BUFFER),this._transCoreEvent(Re.BUFFEREOS),this._transCoreEvent(Re.KEYFRAME),this._transCoreEvent(Re.METADATA_PARSED),this._transCoreEvent(Re.DEMUXED_TRACK),this._transCoreEvent(Re.SEI),this._transCoreEvent(Re.SEI_IN_TIME),this._transCoreEvent(Re.SPEED),this._transCoreEvent(Re.HLS_MANIFEST_LOADED),this._transCoreEvent(Re.HLS_LEVEL_LOADED),this._transCoreEvent(Re.STREAM_EXCEPTION),this._transCoreEvent(Re.SWITCH_URL_SUCCESS),this._transCoreEvent(Re.SWITCH_URL_FAILED),this._transCoreEvent(Sn.NO_AUDIO_TRACK),this._transCoreEvent(Sn.STREAM_PARSED),this._transCoreEvent(Sn.SUBTITLE_SEGMENTS),this._transCoreEvent(Sn.SUBTITLE_PLAYLIST),this._transCoreEvent(Sn.APPEND_COST),t.url&&this.hls.load(t.url,{reuseMse:!0}).catch((function(e){}))}}},{key:"destroy",value:function(){var e;this.hls&&(this.hls.destroy(),this.hls=null),null===(e=this.pluginExtension)||void 0===e||e.destroy(),this.pluginExtension=null}},{key:"_transError",value:function(){var e=this;this.hls.on(Sn.ERROR,(function(t){e.player&&e.player.emit(l.Events.ERROR,new l.Errors(e.player,t))}))}},{key:"_transCoreEvent",value:function(e){var t=this;this.hls.on(e,(function(r){t.player&&(t.player.emit("core_event",h(h({},r),{},{eventName:e})),e===Re.SEI_IN_TIME&&t.hls.hasSubtitle&&t._emitSeiPaylodTime(r))}))}},{key:"_emitSeiPaylodTime",value:function(e){try{var t=JSON.parse(Array.from(e.data.payload).map((function(e){return String.fromCharCode(e)})).join("").slice(0,-1));if(!t.rtmp_dts)return;this.player.emit("core_event",{eventName:Sn.SEI_PAYLOAD_TIME,time:t.rtmp_dts})}catch(r){}}}],[{key:"pluginName",get:function(){return"hls"}},{key:"isSupported",value:function(e,t){return ci.isSupported(e,t)}}]),r}(l.BasePlugin);return b(hi,"Hls",ci),b(hi,"EVENT",Sn),hi}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.object.assign.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.object.get-own-property-descriptor.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.string.iterator.js"),require("xgplayer"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.json.stringify.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.promise.finally.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.typed-array.uint8-array.js"),require("core-js/modules/esnext.typed-array.at.js"),require("core-js/modules/es.typed-array.copy-within.js"),require("core-js/modules/es.typed-array.every.js"),require("core-js/modules/es.typed-array.fill.js"),require("core-js/modules/es.typed-array.filter.js"),require("core-js/modules/es.typed-array.find.js"),require("core-js/modules/es.typed-array.find-index.js"),require("core-js/modules/esnext.typed-array.find-last.js"),require("core-js/modules/esnext.typed-array.find-last-index.js"),require("core-js/modules/es.typed-array.for-each.js"),require("core-js/modules/es.typed-array.includes.js"),require("core-js/modules/es.typed-array.index-of.js"),require("core-js/modules/es.typed-array.iterator.js"),require("core-js/modules/es.typed-array.join.js"),require("core-js/modules/es.typed-array.last-index-of.js"),require("core-js/modules/es.typed-array.map.js"),require("core-js/modules/es.typed-array.reduce.js"),require("core-js/modules/es.typed-array.reduce-right.js"),require("core-js/modules/es.typed-array.reverse.js"),require("core-js/modules/es.typed-array.set.js"),require("core-js/modules/es.typed-array.slice.js"),require("core-js/modules/es.typed-array.some.js"),require("core-js/modules/es.typed-array.sort.js"),require("core-js/modules/es.typed-array.subarray.js"),require("core-js/modules/es.typed-array.to-locale-string.js"),require("core-js/modules/es.typed-array.to-string.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.number.is-nan.js"),require("core-js/modules/es.number.constructor.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.string.trim.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.number.is-finite.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.math.hypot.js"),require("core-js/modules/es.string.from-code-point.js"),require("core-js/modules/es.string.match.js"),require("core-js/modules/es.array.sort.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.typed-array.int8-array.js"),require("core-js/modules/es.typed-array.uint8-clamped-array.js"),require("core-js/modules/es.typed-array.int16-array.js"),require("core-js/modules/es.typed-array.uint16-array.js"),require("core-js/modules/es.typed-array.int32-array.js"),require("core-js/modules/es.typed-array.uint32-array.js"),require("core-js/modules/es.typed-array.float32-array.js"),require("core-js/modules/es.typed-array.float64-array.js"),require("core-js/modules/es.regexp.constructor.js"),require("core-js/modules/es.regexp.sticky.js"),require("core-js/modules/es.number.to-fixed.js"),require("core-js/modules/es.string.split.js"),require("core-js/modules/es.number.max-safe-integer.js"),require("core-js/modules/es.array.find-index.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.object.assign.js","core-js/modules/es.array.concat.js","core-js/modules/es.object.get-own-property-descriptor.js","core-js/modules/es.object.to-string.js","core-js/modules/es.promise.js","core-js/modules/es.array.slice.js","core-js/modules/es.array.join.js","core-js/modules/es.array.map.js","core-js/modules/es.array.from.js","core-js/modules/es.string.iterator.js","xgplayer","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.test.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.keys.js","core-js/modules/es.array.iterator.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/web.url.js","core-js/modules/web.url-search-params.js","core-js/modules/es.array.splice.js","core-js/modules/es.function.name.js","core-js/modules/es.json.stringify.js","core-js/modules/es.array.includes.js","core-js/modules/es.promise.finally.js","core-js/modules/es.array.filter.js","core-js/modules/es.typed-array.uint8-array.js","core-js/modules/esnext.typed-array.at.js","core-js/modules/es.typed-array.copy-within.js","core-js/modules/es.typed-array.every.js","core-js/modules/es.typed-array.fill.js","core-js/modules/es.typed-array.filter.js","core-js/modules/es.typed-array.find.js","core-js/modules/es.typed-array.find-index.js","core-js/modules/esnext.typed-array.find-last.js","core-js/modules/esnext.typed-array.find-last-index.js","core-js/modules/es.typed-array.for-each.js","core-js/modules/es.typed-array.includes.js","core-js/modules/es.typed-array.index-of.js","core-js/modules/es.typed-array.iterator.js","core-js/modules/es.typed-array.join.js","core-js/modules/es.typed-array.last-index-of.js","core-js/modules/es.typed-array.map.js","core-js/modules/es.typed-array.reduce.js","core-js/modules/es.typed-array.reduce-right.js","core-js/modules/es.typed-array.reverse.js","core-js/modules/es.typed-array.set.js","core-js/modules/es.typed-array.slice.js","core-js/modules/es.typed-array.some.js","core-js/modules/es.typed-array.sort.js","core-js/modules/es.typed-array.subarray.js","core-js/modules/es.typed-array.to-locale-string.js","core-js/modules/es.typed-array.to-string.js","core-js/modules/es.string.replace.js","core-js/modules/es.number.is-nan.js","core-js/modules/es.number.constructor.js","core-js/modules/es.object.get-prototype-of.js","core-js/modules/es.symbol.js","core-js/modules/es.string.trim.js","core-js/modules/es.set.js","core-js/modules/es.number.is-finite.js","core-js/modules/es.array.find.js","core-js/modules/es.string.includes.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.math.hypot.js","core-js/modules/es.string.from-code-point.js","core-js/modules/es.string.match.js","core-js/modules/es.array.sort.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array-buffer.constructor.js","core-js/modules/es.typed-array.int8-array.js","core-js/modules/es.typed-array.uint8-clamped-array.js","core-js/modules/es.typed-array.int16-array.js","core-js/modules/es.typed-array.uint16-array.js","core-js/modules/es.typed-array.int32-array.js","core-js/modules/es.typed-array.uint32-array.js","core-js/modules/es.typed-array.float32-array.js","core-js/modules/es.typed-array.float64-array.js","core-js/modules/es.regexp.constructor.js","core-js/modules/es.regexp.sticky.js","core-js/modules/es.number.to-fixed.js","core-js/modules/es.string.split.js","core-js/modules/es.number.max-safe-integer.js","core-js/modules/es.array.find-index.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).HlsPlayer=t(null,null,null,null,null,null,null,null,null,null,e.Player)}(this,(function(e,t,r,n,i,s,a,o,u,c,l){"use strict";function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function f(){f=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(C){u=function(e,t,r){return e[t]=r}}function c(e,t,r,i){var s=t&&t.prototype instanceof h?t:h,a=Object.create(s.prototype),o=new T(i||[]);return n(a,"_invoke",{value:S(e,r,o)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(C){return{type:"throw",arg:C}}}e.wrap=c;var d={};function h(){}function p(){}function v(){}var m={};u(m,s,(function(){return this}));var y=Object.getPrototypeOf,_=y&&y(y(D([])));_&&_!==t&&r.call(_,s)&&(m=_);var g=v.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function i(n,s,a,o){var u=l(e[n],e,s);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==typeof d&&r.call(d,"__await")?t.resolve(d.__await).then((function(e){i("next",e,a,o)}),(function(e){i("throw",e,a,o)})):t.resolve(d).then((function(e){c.value=e,a(c)}),(function(e){return i("throw",e,a,o)}))}o(u.arg)}var s;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return s=s?s.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw s;return{value:void 0,done:!0}}for(r.method=i,r.arg=s;;){var a=r.delegate;if(a){var o=E(a,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"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=l(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,d;var s=i.arg;return s?s.done?(t[e.resultName]=s.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):s:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function x(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 w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function D(e){if(e){var t=e[s];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:A}}function A(){return{value:void 0,done:!0}}return p.prototype=v,n(g,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=u(v,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,u(e,o,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(k.prototype),u(k.prototype,a,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var a=new k(c(t,r,n,i),s);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(g),u(g,o,"Generator"),u(g,s,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=D,T.prototype={constructor:T,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(w),!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 n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(o&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(o){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var a=s?s.completion:{};return a.type=e,a.arg=t,s?(this.method="next",this.next=s.finallyLoc,d):this.complete(a)},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),w(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 n=r.completion;if("throw"===n.type){var i=n.arg;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:D(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function p(e){return(p="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})(e)}function v(e,t,r,n,i,s,a){try{var o=e[s](a),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function m(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function a(e){v(s,n,i,a,o,"next",e)}function o(e){v(s,n,i,a,o,"throw",e)}a(void 0)}))}}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,U(n.key),n)}}function g(e,t,r){return t&&_(e.prototype,t),r&&_(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e,t,r){return(t=U(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function k(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&&E(e,t)}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){return(E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function x(){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 w(e,t,r){return(w=x()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&E(i,r.prototype),i}).apply(null,arguments)}function T(e){var t="function"==typeof Map?new Map:void 0;return T=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,n)}function n(){return w(e,arguments,S(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),E(n,e)},T(e)}function D(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function A(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function C(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return A(e)}function L(e){var t=x();return function(){var r,n=S(e);if(t){var i=S(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return C(this,r)}}function R(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=S(e)););return e}function O(){return O="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=R(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},O.apply(this,arguments)}function P(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){var n,i,s,a,o=[],u=!0,c=!1;try{if(s=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=s.call(r)).done)&&(o.push(n.value),o.length!==t);u=!0);}catch(l){c=!0,i=l}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}}(e,t)||j(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 I(e){return function(e){if(Array.isArray(e))return B(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(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 j(e,t){if(e){if("string"==typeof e)return B(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)?B(e,t):void 0}}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function M(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=j(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}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 s,a=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==r.return||r.return()}finally{if(o)throw s}}}}function U(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var N,F=function(){function e(){y(this,e)}return g(e,null,[{key:"start",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6||1===e.length&&e.start(0)<0?0:e.start(0):0}},{key:"end",value:function(e){return e&&e.length?1===e.length&&e.end(0)-e.start(0)<1e-6?0:e.end(e.length-1):0}},{key:"get",value:function(e){if(e)try{return e.buffered}catch(t){}}},{key:"buffers",value:function(e,t){if(!e||!e.length)return[];for(var r=[],n=0,i=e.length;n<i;n++){var s=r.length;if(s&&t){var a=r[s-1],o=a[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(a[1]=u)}else r.push([e.start(n),e.end(n)])}else r.push([e.start(n),e.end(n)])}return r}},{key:"totalLength",value:function(e){return e&&e.length?e.reduce((function(e,t){return e+(t[1]-t[0])}),0):0}},{key:"info",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!t||!t.length)return{start:0,end:0,buffers:[]};for(var i=0,s=0,a=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),h=0,f=d.length;h<f;h++){var p=d[h];if(r+n>=p[0]&&r<=p[1])i=p[0],s=p[1],a=h;else{if(r+n<p[0]){o=p[0],u=p[1];break}r+n>p[1]&&(c=p[0],l=p[1])}}return{start:i,end:s,index:a,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:s?s-r:0,length:e.totalLength&&e.totalLength(d)}}},{key:"isBuffered",value:function(t,r){if(t){var n=e.get(t);if(null!=n&&n.length)for(var i=0;i<n.length;i++)if(r>=n.start(i)&&r<=n.end(i))return!0}return!1}}]),e}(),V="undefined"!=typeof window,z="manifest",G="network",q="network_timeout",H="network_forbidden",K="network_notfound",Y="network_range_not_satisfiable",W="demux",X="remux",Q="media",J="drm",Z="other",$="runtime",ee={FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"},te=(b(N={},z,{HLS:1100,DASH:1200}),b(N,G,2100),b(N,q,2101),b(N,H,2103),b(N,K,2104),b(N,Y,2116),b(N,W,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),b(N,X,{FMP4:4100,MP4:4200}),b(N,Q,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),b(N,J,{LICENSE:7100,CUSTOM_LICENSE:7200}),b(N,Z,8e3),b(N,$,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),N),re=function(e){k(r,e);var t=L(r);function r(e,n,i,s,a){var o;return y(this,r),(o=t.call(this,a||(null==i?void 0:i.message))).errorType=e===q?G:e,o.originError=i,o.ext=s,o.errorCode=te[e][n]||te[e],o.errorMessage=o.message,o.errorCode||(o.errorType=Z,o.errorCode=te[o.errorType]),o}return g(r,null,[{key:"create",value:function(e,t,n,i,s){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=Z),new r(e,t,n,i,s))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?q:G,null,e instanceof Error?e:null,{url:null==e?void 0:e.url,response:null==e?void 0:e.response,httpCode:null==e||null===(t=e.response)||void 0===t?void 0:t.status})}}]),r}(T(Error)),ne={DEBUG:1,LOG:2,WARN:3,ERROR:4},ie=["Boolean","Number","String","Undefined","Null","Date","Object"],se=function(){function e(t,r){y(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(null==r?void 0:r.logCacheLevel)||3,this.logMaxSize=(null==r?void 0:r.logMaxSize)||204800,this.logSize=0,this.logTextArray=[]}return g(e,[{key:"debug",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[ne.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,["[".concat(ae(),"]"),this._prefix].concat(n))}},{key:"log",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[ne.LOG].concat(n)),e.disabled||(t=console).log.apply(t,["[".concat(ae(),"]"),this._prefix].concat(n))}},{key:"warn",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[ne.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,["[".concat(ae(),"]"),this._prefix].concat(n))}},{key:"error",value:function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];this.logCache.apply(this,[ne.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,["[".concat(ae(),"]"),this._prefix].concat(n))}},{key:"logCache",value:function(e){if(!(e<this.logCacheLevel)){var t="";try{for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];var s=n.map((function(e){return ue(e)}));t="[".concat(ae(),"]")+this._prefix+JSON.stringify(s)}catch(o){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var a=this.logTextArray.shift();this.logSize-=a.length}}}},{key:"getLogCache",value:function(){var e=this.logTextArray.join("\n");return this.reset(),e}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(e){this.logCacheLevel=e}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();function ae(){return(new Date).toLocaleString()}function oe(e){if("object"!==p(e))return e;var t=Object.prototype.toString.call(e).slice(8,-1);switch(t){case"Array":case"Uint8Array":case"ArrayBuffer":return t+"["+e.length+"]";case"Object":return"{}";default:return t}}function ue(e,t,r){r||(r=1),t||(t=2);var n={};if(!e||"object"!==p(e))return e;var i=Object.prototype.toString.call(e).slice(8,-1);if(!ie.includes(i))return i;if(!(r>t)){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r===t?n[s]=oe(e[s]):"object"===p(e[s])?n[s]=ue(e[s],t,r+1):n[s]=e[s]);return n}}function ce(){var e,t,r=new Promise((function(r,n){e=r,t=n}));return r.used=!1,r.resolve=function(){return r.used=!0,e.apply(void 0,arguments)},r.reject=function(){return r.used=!0,t.apply(void 0,arguments)},r}function le(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}b(se,"disabled",!0);var de=function(e){try{return JSON.stringify(e)}catch(t){return""}};function he(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];try{return V?e&&"undefined"!=typeof ManagedMediaSource?ManagedMediaSource:window.MediaSource:null}catch(t){}}function fe(e){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(e))}var pe="appendBuffer",ve="removeBuffer",me="updateDuration",ye=function(){function e(t,r){var n=this;y(this,e),b(this,"media",null),b(this,"mediaSource",null),b(this,"_openPromise",ce()),b(this,"_queue",Object.create(null)),b(this,"_sourceBuffer",Object.create(null)),b(this,"_mseFullFlag",{}),b(this,"_st",0),b(this,"_opst",0),b(this,"_logger",null),b(this,"_config",null),b(this,"_url",null),b(this,"_onStartStreaming",(function(){n._logger.debug("startstreaming")})),b(this,"_onEndStreaming",(function(){n._logger.debug("endstreaming")})),b(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==me&&t.shift(),r){var i,s,a=le()-n._opst;n._logger.debug("UpdateEnd(".concat(e,"/").concat(r.opName,")"),de(function(e){var t=[];if(e instanceof TimeRanges)for(var r=0;r<e.length;r++)t.push({start:e.start(r),end:e.end(r)});return t}(null===(i=n._sourceBuffer[e])||void 0===i?void 0:i.buffered)),a,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:a});var o=null===(s=r.context)||void 0===s?void 0:s.callback;o&&"function"==typeof o&&o(r.context),n._startQueue(e)}}})),b(this,"_onSBUpdateError",(function(e,t){var r=n._queue[e];if(r){var i=r[0];i&&(n._logger.error("UpdateError",e,i.opName,i.context),i.promise.reject(new re(Q,ee.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new se("MSE"),this._config.openLog&&se.enable()}var t,r,n;return g(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{key:"hasOpTasks",get:function(){var e=this,t=!1;return Object.keys(this._queue).forEach((function(r){var n=e._queue[r];Array.isArray(n)&&(t||(t=n.length>0))})),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var e;return(null===(e=this.mediaSource)||void 0===e?void 0:e.duration)||-1}},{key:"isEnded",get:function(){return!!this.mediaSource&&"ended"===this.mediaSource.readyState}},{key:"streaming",get:function(){return!fe(this.mediaSource)||this.mediaSource.streaming}},{key:"isFull",value:function(t){return t?this._mseFullFlag[t]:this._mseFullFlag[e.VIDEO]}},{key:"updateDuration",value:function(e){var t=this,r=this.mediaSource&&this.mediaSource.duration>e;if(this.mediaSource&&this.mediaSource.duration>e){var n=0;if(Object.keys(this._sourceBuffer).forEach((function(e){try{n=Math.max(t.bufferEnd(e)||0,n)}catch(r){}})),e<n)return Promise.resolve()}return this._enqueueBlockingOp((function(){t.isEnded?t._logger.debug("setDuration but ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("setDuration",e))}),me,{isReduceDuration:r})}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function r(){var n=le()-e._st;e._logger.debug("sourceopen",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=ce()}return this._openPromise}},{key:"bindMedia",value:(n=m(f().mark((function e(t){var r,n,i,s,a=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaSource&&!this.media){e.next=3;break}return e.next=3,this.unbindMedia();case 3:if(r=he(this._config.preferMMS),t&&r){e.next=6;break}throw new Error("Param media or MediaSource does not exist");case 6:return this.media=t,n=this.mediaSource=new r,i=fe(n),this._st=le(),s=function e(){var r=le()-a._st;a._logger.debug("sourceopen"),n.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),a._openPromise.resolve({costtime:r})},n.addEventListener("sourceopen",s),i&&(n.addEventListener("startstreaming",this._onStartStreaming),n.addEventListener("endstreaming",this._onEndStreaming)),this._url=URL.createObjectURL(n),t.src=this._url,t.disableRemotePlayback=i,e.abrupt("return",this._openPromise);case 17:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unbindMedia",value:(r=m(f().mark((function e(){var t,r,n,i=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._openPromise.used||this._openPromise.resolve(),t=this.mediaSource){if(Object.keys(this._queue).forEach((function(e){var t=i._queue[e];t&&t.forEach((function(e){var t,r;return null===(t=e.promise)||void 0===t||null===(r=t.resolve)||void 0===r?void 0:r.call(t)}))})),r=!!this.media&&this.media.readyState>=1,n="open"===t.readyState,r&&n)try{t.endOfStream()}catch(s){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(i._sourceBuffer[e])}catch(s){}})),fe(t)&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch(s){}this.media=null}this.mediaSource=null,this._openPromise=ce(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createSource",value:function(e,t){if(!this._sourceBuffer[e]&&this.mediaSource){var r;try{r=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new re(Q,ee.MSE_ADD_SB,n)}r.mimeType=t,r.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),r.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var r=this,n=this._sourceBuffer[e];return this.mediaSource&&n&&n.mimeType!==t?"function"!=typeof n.changeType?Promise.reject(new re(Q,ee.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(e,(function(){try{n.changeType(t)}catch(i){throw new re(Q,ee.MSE_CHANGE_TYPE,i)}n.mimeType=t,r._onSBUpdateEnd(e)}),"changeType",{mimeType:t}):Promise.resolve()}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,r){var n=this;return t&&t.byteLength&&this._sourceBuffer[e]?this._enqueueOp(e,(function(){var i;n.mediaSource&&!n.media.error&&(n._logger.debug("MSE APPEND START",r),n._opst=le(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),pe,r):Promise.resolve()}},{key:"remove",value:function(e,t,r,n){var i=this,s=!1;return this._mseFullFlag[e]&&(s=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var s=i._sourceBuffer[e];t>=r||!s?i._onSBUpdateEnd(e):(i._opst=le(),i._logger.debug("MSE REMOVE START",e,t,r,n),s.remove(t,r))}}),ve,n,s)}},{key:"clearBuffer",value:function(e,t){var r,n=this;return Object.keys(this._sourceBuffer).forEach((function(i){r=n.remove(i,e,t)})),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(r){var n=t._sourceBuffer[r];e=t.remove(r,0,F.end(F.get(n)))})),e}},{key:"clearOpQueues",value:function(e,t){var r;this._logger.debug("MSE clearOpQueue START");var n=this._queue[e];if(t&&n)this._queue[e]=[];else if(n&&n[e]&&!(n.length<5)){var i=[];n.forEach((function(e){e.context&&e.context.isinit&&i.push(e)})),this._queue[e]=n.slice(0,2),i.length>0&&(r=this._queue[e]).push.apply(r,i)}}},{key:"endOfStream",value:function(e){var t=this;return this.mediaSource&&"open"===this.mediaSource.readyState?this._enqueueBlockingOp((function(){var r=t.mediaSource;r&&"open"===r.readyState&&(t._logger.debug("MSE endOfStream START"),e?r.endOfStream(e):r.endOfStream())}),"endOfStream"):Promise.resolve()}},{key:"setLiveSeekableRange",value:function(e,t){var r=this.mediaSource;e<0||t<e||null==r||!r.setLiveSeekableRange||"open"!==r.readyState||r.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return F.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return F.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return F.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,n,i){var s=this;if(!this.mediaSource)return Promise.resolve();var a=this._queue[e]=this._queue[e]||[],o={exec:t,promise:ce(),opName:r,context:n};return i?(a.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):a.push(o),this.isOpened||this.isEnded?1===a.length&&this._startQueue(e):this._openPromise.then((function(){1===a.length&&s._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=m(f().mark((function e(t,r,n){var i,s,a=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaSource){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:if((i=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],i.forEach((function(e){var t=a._queue[e],i=ce();s.push(i),t.push({exec:function(){i.resolve()},promise:i,opName:r,context:n}),1===t.length&&a._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{i.forEach((function(e){var t=a._queue[e],r=a._sourceBuffer[e];null==t||t.shift(),r&&r.updating||a._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var r=t[0];if(r&&!this._mseFullFlag[e])try{r.exec()}catch(n){n&&n.message&&n.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,r.context&&"object"===p(r.context)&&(r.context.isFull=!0),this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new re(Q,ee.MSE_FULL,n))):(this._logger.error(n),r.promise.reject(n.constructor===re?n:new re(Q,ee.MSE_OTHER,n)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,r){var n=this;return this._enqueueOp(e,(function(){t<0&&(t+=.001),n._sourceBuffer[e].timestampOffset=t,n._onSBUpdateEnd(e)}),"setTimeoffset",r)}},{key:"abort",value:function(e,t){var r=this;return this.isOpened?this._enqueueOp(e,(function(){r._sourceBuffer[e].abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=he();if(!t)return!1;try{return t.isTypeSupported(e)}catch(r){return this._logger.error(e,r),!1}}},{key:"isMMSOnly",value:function(){return"undefined"!=typeof ManagedMediaSource&&"undefined"==typeof MediaSource}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),e}();b(ye,"VIDEO","video"),b(ye,"AUDIO","audio");var _e="fetch",ge="xhr",be="arraybuffer",ke="text",Se="json",Ee=function(e){k(r,e);var t=L(r);function r(e,n,i,s){var a;return y(this,r),b(A(a=t.call(this,s)),"retryCount",0),b(A(a),"isTimeout",!1),b(A(a),"loaderType",_e),b(A(a),"startTime",0),b(A(a),"endTime",0),b(A(a),"options",{}),a.url=e,a.request=n,a.response=i,a}return g(r)}(T(Error)),xe=Object.prototype.toString;function we(e){if("[object Object]"!==xe.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Te(e){if(e&&null!==e[0]&&void 0!==e[0]&&(0!==e[0]||null!==e[1]&&void 0!==e[1])){var t="bytes="+e[0]+"-";return e[1]&&(t+=e[1]),t}}function De(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ae(e,t){if(e){if(!t)return e;var r,n=Object.keys(t).map((function(e){if(null!=(r=t[e]))return Array.isArray(r)?e+="[]":r=[r],r.map((function(t){var r;return r=t,"[object Date]"===xe.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===p(e)}(t)&&(t=JSON.stringify(t)),"".concat(De(e),"=").concat(De(t))})).join("&")})).filter(Boolean).join("&");if(n){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e}}function Ce(e,t,r,n,i,s,a,o,u,c,l){return i=null!=i?parseFloat(i):null,n=parseInt(n||"0",10),Number.isNaN(n)&&(n=0),{data:e,done:t,options:{range:u,vid:c,index:o,contentLength:n,age:i,startTime:s,firstByteTime:a,endTime:Date.now(),priOptions:l},response:r}}function Le(e,t){return Math.round(8*e*1e3/t/1024)}var Re={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"},Oe={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,s||e,a),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},o.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a},o.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,i,s,a){var o=r?r+e:e;if(!this._events[o])return!1;var u,c,l=this._events[o],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,s),!0;case 6:return l.fn.call(l.context,t,n,i,s,a),!0}for(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var h,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,i);break;default:if(!u)for(h=1,u=new Array(d-1);h<d;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].context,u)}}return!0},o.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||a(this,s);else{for(var u=0,c=[],l=o.length;u<l;u++)(o[u].fn!==t||i&&!o[u].once||n&&o[u].context!==n)&&c.push(o[u]);c.length?this._events[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,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}(Oe);var Pe=Oe.exports,Ie=2097152,je=function(e){k(n,e);var t,r=L(n);function n(){var e;return y(this,n),b(A(e=r.call(this)),"_abortController",null),b(A(e),"_timeoutTimer",null),b(A(e),"_reader",null),b(A(e),"_response",null),b(A(e),"_aborted",!1),b(A(e),"_index",-1),b(A(e),"_range",null),b(A(e),"_receivedLength",0),b(A(e),"_running",!1),b(A(e),"_logger",null),b(A(e),"_vid",""),b(A(e),"_onProcessMinLen",0),b(A(e),"_onCancel",null),b(A(e),"_priOptions",null),e}return g(n,[{key:"load",value:function(e){var t,r=this,n=e.url,i=e.vid,s=e.timeout,a=e.responseType,o=e.onProgress,u=e.index,c=e.onTimeout,l=e.onCancel,d=e.range,h=e.transformResponse,p=e.request,v=e.params,y=e.logger,_=e.method,g=e.headers,b=e.body,k=e.mode,S=e.credentials,E=e.cache,x=e.redirect,w=e.referrer,T=e.referrerPolicy,D=e.onProcessMinLen,A=e.priOptions;this._logger=y,this._aborted=!1,this._onProcessMinLen=D,this._onCancel=l,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._index=u,this._range=d||[0,0],this._vid=i||n,this._priOptions=A||{};var C={method:_,headers:g,body:b,mode:k,credentials:S,cache:E,redirect:x,referrer:w,referrerPolicy:T,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},L=!1;clearTimeout(this._timeoutTimer),n=Ae(n,v);var R=Te(d);R&&(g=p?p.headers:C.headers=C.headers||(Headers?new Headers:{}),Headers&&g instanceof Headers?g.append("Range",R):g.Range=R),s&&(this._timeoutTimer=setTimeout((function(){if(L=!0,r.cancel(),c){var e=new Ee(n,C,null,"timeout");e.isTimeout=!0,c(e,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})}}),s));var O=Date.now();return this._logger.debug("[fetch load start], index,",u,",range,",d),new Promise((function(e,t){fetch(p||n,p?void 0:C).then(function(){var i=m(f().mark((function i(s){var c,l,p,v;return f().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(clearTimeout(r._timeoutTimer),r._response=s,!r._aborted&&r._running){i.next=4;break}return i.abrupt("return");case 4:if(h&&(s=h(s,n)||s),s.ok){i.next=7;break}throw new Ee(n,C,s,"bad network response");case 7:if(c=Date.now(),a!==ke){i.next=15;break}return i.next=11,s.text();case 11:l=i.sent,r._running=!1,i.next=37;break;case 15:if(a!==Se){i.next=22;break}return i.next=18,s.json();case 18:l=i.sent,r._running=!1,i.next=37;break;case 22:if(!o){i.next=29;break}return r.resolve=e,r.reject=t,r._loadChunk(s,o,O,c),i.abrupt("return");case 29:return i.next=31,s.arrayBuffer();case 31:l=i.sent,l=new Uint8Array(l),r._running=!1,p=Date.now()-O,v=Le(l.byteLength,p),r.emit(Re.REAL_TIME_SPEED,{speed:v,len:l.byteLength,time:p,vid:r._vid,index:r._index,range:r._range,priOptions:r._priOptions});case 37:r._logger.debug("[fetch load end], index,",u,",range,",d),e(Ce(l,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),O,c,u,d,r._vid,r._priOptions));case 39:case"end":return i.stop()}}),i)})));return function(e){return i.apply(this,arguments)}}()).catch((function(e){var i;clearTimeout(r._timeoutTimer),r._running=!1,r._aborted&&!L||((e=e instanceof Ee?e:new Ee(n,C,null,null===(i=e)||void 0===i?void 0:i.message)).startTime=O,e.endTime=Date.now(),e.isTimeout=L,e.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},t(e))}))}))}},{key:"cancel",value:(t=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._aborted){e.next=2;break}return e.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){e.next=14;break}if(e.prev=5,!this._reader){e.next=9;break}return e.next=9,this._reader.cancel();case 9:e.next=13;break;case 11:e.prev=11,e.t0=e.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch(t){}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return e.stop()}}),e,this,[[5,11]])}))),function(){return t.apply(this,arguments)})},{key:"_loadChunk",value:function(e,t,r,n){var i=this;if(!e.body||!e.body.getReader){this._running=!1;var s=new Ee(e.url,"",e,"onProgress of bad response.body.getReader");return s.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(s)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Ie),this._writeIdx=0);var a,o,u,c=this._reader=e.body.getReader(),l=function(){var s=m(f().mark((function s(){var d,h,p,v,m,y,_,g;return f().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:return o=Date.now(),s.prev=1,s.next=4,c.read();case 4:a=s.sent,u=Date.now(),s.next=13;break;case 8:return s.prev=8,s.t0=s.catch(1),u=Date.now(),i._aborted||(i._running=!1,s.t0.options={index:i._index,range:i._range,vid:i._vid,priOptions:i._priOptions},i.reject(s.t0)),s.abrupt("return");case 13:if(h=(null===(d=i._range)||void 0===d?void 0:d.length)>0?i._range[0]:0,p=h+i._receivedLength,!i._aborted){s.next=19;break}return i._running=!1,t(void 0,!1,{range:[p,p],vid:i._vid,index:i._index,startTime:o,endTime:u,st:r,firstByteTime:n,priOptions:i._priOptions},e),s.abrupt("return");case 19:v=a.value?a.value.byteLength:0,i._receivedLength+=v,i._logger.debug("【fetchLoader,onProgress call】,task,",i._range,", start,",p,", end,",h+i._receivedLength,", done,",a.done),i._onProcessMinLen>0?i._writeIdx+v>=i._onProcessMinLen||a.done?((m=new Uint8Array(i._writeIdx+v)).set(i._cache.slice(0,i._writeIdx),0),v>0&&m.set(a.value,i._writeIdx),i._writeIdx=0,i._logger.debug("【fetchLoader,onProgress enough】,done,",a.done,",len,",m.byteLength,", writeIdx,",i._writeIdx)):v>0&&i._writeIdx+v<Ie?(i._cache.set(a.value,i._writeIdx),i._writeIdx+=v,i._logger.debug("【fetchLoader,onProgress cache】,len,",v,", writeIdx,",i._writeIdx)):v>0&&(y=new Uint8Array(i._writeIdx+v+2048),i._logger.debug("【fetchLoader,onProgress extra start】,size,",i._writeIdx+v+2048,", datalen,",v,", writeIdx,",i._writeIdx),y.set(i._cache.slice(0,i._writeIdx),0),v>0&&y.set(a.value,i._writeIdx),i._writeIdx+=v,delete i._cache,i._cache=y,i._logger.debug("【fetchLoader,onProgress extra end】,len,",v,", writeIdx,",i._writeIdx)):m=a.value,(m&&m.byteLength>0||a.done)&&t(m,a.done,{range:[i._range[0]+i._receivedLength-(m?m.byteLength:0),i._range[0]+i._receivedLength],vid:i._vid,index:i._index,startTime:o,endTime:u,st:r,firstByteTime:n,priOptions:i._priOptions},e),a.done?(_=Date.now()-r,g=Le(i._receivedLength,_),i.emit(Re.REAL_TIME_SPEED,{speed:g,len:i._receivedLength,time:_,vid:i._vid,index:i._index,range:i._range,priOptions:i._priOptions}),i._running=!1,i._logger.debug("[fetchLoader onProgress end],task,",i._range,",done,",a.done),i.resolve(Ce(a,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),r,n,i._index,i._range,i._vid,i._priOptions))):l();case 25:case"end":return s.stop()}}),s,null,[[1,8]])})));return function(){return s.apply(this,arguments)}}();l()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}}],[{key:"isSupported",value:function(){return!("undefined"==typeof fetch)}}]),n}(Pe);var Be=function(e){k(r,e);var t=L(r);function r(){var e;return y(this,r),b(A(e=t.call(this)),"_xhr",null),b(A(e),"_aborted",!1),b(A(e),"_timeoutTimer",null),b(A(e),"_range",null),b(A(e),"_receivedLength",0),b(A(e),"_url",null),b(A(e),"_onProgress",null),b(A(e),"_index",-1),b(A(e),"_headers",null),b(A(e),"_currentChunkSizeKB",384),b(A(e),"_timeout",null),b(A(e),"_xhr",null),b(A(e),"_withCredentials",null),b(A(e),"_startTime",-1),b(A(e),"_loadCompleteResolve",null),b(A(e),"_loadCompleteReject",null),b(A(e),"_runing",!1),b(A(e),"_logger",!1),b(A(e),"_vid",""),b(A(e),"_responseType",void 0),b(A(e),"_credentials",void 0),b(A(e),"_method",void 0),b(A(e),"_transformResponse",void 0),b(A(e),"_firstRtt",void 0),b(A(e),"_onCancel",null),b(A(e),"_priOptions",null),e}return g(r,[{key:"load",value:function(e){var t=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials="include"===e.credentials||"same-origin"===e.credentials,this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=Ae(e.url,e.params);var r=Date.now();return new Promise((function(e,r){t._loadCompleteResolve=e,t._loadCompleteReject=r,t._startLoad()})).catch((function(e){if(clearTimeout(t._timeoutTimer),t._runing=!1,!t._aborted)throw(e=e instanceof Ee?e:new Ee(t._url,t._request)).startTime=r,e.endTime=Date.now(),e.options={index:t._index,vid:t._vid,priOptions:t._priOptions},e}))}},{key:"_startLoad",value:function(){var e=null;if(this._responseType===be&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var t=1024*this._currentChunkSizeKB,r=this._range[0]+this._receivedLength,n=this._range[1];t<this._range[1]-r&&(n=r+t),e=[r,n],this._logger.debug("[xhr_loader->],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var t=this;try{this._startTime=Date.now();var r=this._xhr=new XMLHttpRequest;r.open(this._method||"GET",this._url,!0),r.responseType=this._responseType,this._timeout&&(r.timeout=this._timeout),r.withCredentials=this._withCredentials,r.onload=this._onLoad.bind(this),r.onreadystatechange=this._onReadyStatechange.bind(this),r.onerror=function(e){var r,n,i;t._running=!1;var s=new Ee(t._url,t._request,null==e||null===(r=e.currentTarget)||void 0===r?void 0:r.response,"xhr.onerror.status:"+(null==e||null===(n=e.currentTarget)||void 0===n?void 0:n.status)+",statusText,"+(null==e||null===(i=e.currentTarget)||void 0===i?void 0:i.statusText));s.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(s)},r.ontimeout=function(e){t.cancel();var r=new Ee(t._url,t._request,{status:408},"timeout");t._onTimeout&&(r.isTimeout=!0,t._onTimeout(r,{index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions})),r.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(r)};var n=this._headers||{},i=Te(e);i&&(n.Range=i),n&&Object.keys(n).forEach((function(e){r.setRequestHeader(e,n[e])})),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e),r.send(this._body)}catch(s){s.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(s)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var t,r=e.target.status;if(r<200||r>299){var n=new Ee(this._url,null,h(h({},e.target.response),{},{status:r}),"bad response,status:"+r);return n.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(n)}var i,s=null,a=!1,o=(null===(t=this._range)||void 0===t?void 0:t.length)>0?this._range[0]:0;if(this._responseType===be){var u,c=new Uint8Array(e.target.response);if(i=o+this._receivedLength,c&&c.byteLength>0){this._receivedLength+=c.byteLength;var l=Date.now()-this._startTime,d=Le(this._receivedLength,l);this.emit(Re.REAL_TIME_SPEED,{speed:d,len:this._receivedLength,time:l,vid:this._vid,index:this._index,range:[i,o+this._receivedLength],priOptions:this._priOptions})}s=c,a=!((null===(u=this._range)||void 0===u?void 0:u.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",i,"end ",o+this._receivedLength,",dataLen,",c?c.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",a)}else a=!0,s=e.target.response;var f={ok:r>=200&&r<300,status:r,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(f=this._transformResponse(f,this._url)||f),this._onProgress&&this._onProgress(s,a,{index:this._index,vid:this._vid,range:[i,o+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},f),a?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(Ce(this._onProgress?null:s,a,f,f.headers["content-length"],f.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted)return this._aborted=!0,this._runing=!1,O(S(r.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr?this._xhr.abort():void 0}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var t,r={},n=M(e.getAllResponseHeaders().trim().split("\r\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value.split(": ");r[i[0].toLowerCase()]=i.slice(1).join(": ")}}catch(s){n.e(s)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),r}(Pe),Me=["retry","retryDelay","onRetryError","transformError"],Ue=function(){function e(t,r){y(this,e),this.promise=ce(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new se("Loader")),this._loaderType=t,this._loader=t===_e&&"undefined"!=typeof fetch?new je:new Be,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return g(e,[{key:"exec",value:function(){var e=this,t=this._config,r=t.retry,n=t.retryDelay,i=t.onRetryError,s=t.transformError,a=D(t,Me),o=function(){var t=m(f().mark((function t(){var u,c,l;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(a);case 3:u=t.sent,e.promise.resolve(u),t.next=27;break;case 7:if(t.prev=7,t.t0=t.catch(0),e._loader.running=!1,e._logger.debug("[task request catch err]",t.t0),!e._canceled){t.next=13;break}return t.abrupt("return");case 13:if(t.t0.loaderType=e._loaderType,t.t0.retryCount=e._retryCount,c=t.t0,s&&(c=s(c)||c),i&&e._retryCount>0&&i(c,e._retryCount,{index:a.index,vid:a.vid,range:a.range,priOptions:a.priOptions}),e._retryCount++,l=!0,e._retryCheckFunc&&(l=e._retryCheckFunc(t.t0)),!(l&&e._retryCount<=r)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",a.range),e._retryTimer=setTimeout(o,n),t.abrupt("return");case 26:e.promise.reject(c);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return o(),this.promise}},{key:"cancel",value:(t=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,e.abrupt("return",this._loader.cancel());case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),e}();function Ne(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if((t=t.filter(Boolean)).length<2)return t[0];var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}function Fe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var Ve=function(e){k(n,e);var t,r=L(n);function n(e){var t;return y(this,n),b(A(t=r.call(this,e)),"type",_e),b(A(t),"_queue",[]),b(A(t),"_alive",[]),b(A(t),"_currentTask",null),b(A(t),"_finnalUrl",""),b(A(t),"_config",void 0),t._config=function(e){return h({loaderType:_e,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:ke,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},e)}(e),t._config.loaderType!==ge&&je.isSupported()||(t.type=ge),t.log=e.logger,t}return g(n,[{key:"isFetch",value:function(){return this.type===_e}},{key:"load",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"!=typeof e&&e?r=e:r.url=e||r.url||this._config.url,(r=Object.assign({},this._config,r)).params&&(r.params=Object.assign({},r.params)),r.headers&&we(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&we(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new Ue(this.type,r);return n.loader.on(Re.REAL_TIME_SPEED,(function(e){t.emit(Re.REAL_TIME_SPEED,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(t=m(f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this._queue.map((function(e){return e.cancel()})).concat(this._alive.map((function(e){return e.cancel()}))),this._currentTask&&t.push(this._currentTask.cancel()),this._queue=[],this._alive=[],e.next=6,Promise.all(t);case 6:return e.next=8,Fe();case 8:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var t=this._currentTask.exec().catch((function(e){}));t&&"function"==typeof t.finally&&t.finally((function(){var t,r;null!==(t=e._currentTask)&&void 0!==t&&t.alive&&(null===(r=e._alive)||void 0===r?void 0:r.length)>0&&(e._alive=e._alive.filter((function(t){return t&&t!==e._currentTask}))),e._processTask()}))}}}],[{key:"isFetchSupport",value:function(){return je.isSupported()}}]),n}(Pe),ze=function(){function e(){y(this,e),b(this,"_prevCurrentTime",0)}return g(e,[{key:"do",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;if(e){var i=e.currentTime,s=0;if(this._prevCurrentTime===i){var a=F.info(F.get(e),i);if(!a.buffers.length)return;r&&a.nextStart||a.nextStart&&a.nextStart-i<t?s=a.nextStart+.1:a.end&&a.end-i>n&&!e.seeking&&(s=i+.1)}this._prevCurrentTime=i,s&&i!==s&&(e.currentTime=s)}}}]),e}(),Ge=function(){function e(t){var r=this;y(this,e),b(this,"_seiSet",new Set),this.emitter=t,t.on(Re.SEI,(function(e){e&&r._seiSet.add(e)}))}return g(e,[{key:"throw",value:function(e,t){var r=this;if(null!=e&&this._seiSet.size){var n=e-.2,i=e+.2,s=[];this._seiSet.forEach((function(e){e.time>=n&&e.time<=i&&s.push(e)})),s.forEach((function(e){r._seiSet.delete(e),r.emitter.emit(Re.SEI_IN_TIME,e)})),t&&this._seiSet.forEach((function(t){t.time<e-5&&r._seiSet.delete(t)}))}}},{key:"reset",value:function(){this._seiSet.clear()}}]),e}(),qe=function(){function e(t){y(this,e),b(this,"_chunkSpeed",0),b(this,"_chunkCache",[]),b(this,"_speeds",[]),b(this,"_totalSize",0),b(this,"_totalCost",0),this._opts=t||{}}return g(e,[{key:"addRecord",value:function(e,t){e&&t&&(this._speeds.push(8e3*e/t),this._speeds=this._speeds.slice(-3))}},{key:"addChunkRecord",value:function(e,t){var r,n;if(e&&t&&!(e<((null===(r=this._opts)||void 0===r?void 0:r.skipChunkSize)||1e3))){this._totalSize+=e,this._totalCost+=t,this._chunkSpeed=8e3*e/t,this._chunkCache.push({size:e,duration:t,timestamp:performance.now()});var i=(null===(n=this._opts)||void 0===n?void 0:n.chunkCountForSpeed)||50;this._chunkCache.length>i&&(this._chunkCache=this._chunkCache.slice(-i))}}},{key:"getAvgSpeed",value:function(){var e;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce((function(e,t){return e+t}))/this._speeds.length;var t=this._chunkCache[this._chunkCache.length-1],r=performance.now()-t.timestamp;return r>((null===(e=this._opts)||void 0===e?void 0:e.longtimeNoReceived)||3e3)&&this._chunkCache.push({size:0,duration:r,timestamp:performance.now()}),8e3*this._chunkCache.reduce((function(e,t){return e+t.size}),0)/this._chunkCache.reduce((function(e,t){return e+t.duration}),0)}},{key:"getLatestSpeed",value:function(){return this._chunkCache.length||this._speeds.length?this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed:0}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),e}(),He=function(){function e(t){y(this,e),b(this,"encodeType",""),b(this,"audioCodec",""),b(this,"videoCodec",""),b(this,"domain",""),b(this,"fps",0),b(this,"bitrate",0),b(this,"width",0),b(this,"height",0),b(this,"samplerate",0),b(this,"channelCount",0),b(this,"gop",0),b(this,"_bitsAccumulateSize",0),b(this,"_bitsAccumulateDuration",0),b(this,"_startGopId",-1),this._timescale=t}return g(e,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(e){this.encodeType=e}},{key:"setFpsFromScriptData",value:function(e){var t,r=e.data,n=null==r||null===(t=r.onMetaData)||void 0===t?void 0:t.framerate;n&&n>0&&n<100&&(this.fps=n)}},{key:"setVideoMeta",value:function(e){if(this.width=e.width,this.height=e.height,this.videoCodec=e.codec,this.encodeType=e.codecType,e.fpsNum&&e.fpsDen){var t=e.fpsNum/e.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(e){this.audioCodec=e.codec,this.samplerate=e.sampleRate,this.channelCount=e.channelCount}},{key:"setDomain",value:function(e){this.domain=e.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(e){var t=this;if((!this.fps||this.fps>=100)&&e.length){var r=e.reduce((function(e,t){return e+t.duration}),0)/e.length;this.fps=Math.round(this._timescale/r)}e.forEach((function(e){-1===t._startGopId&&(t._startGopId=e.gopId),e.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=e.duration/(t._timescale/1e3),t._bitsAccumulateSize+=e.units.reduce((function(e,t){return e+t.length}),0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=8*t._bitsAccumulateSize,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)}))}}]),e}(),Ke=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;y(this,e),b(this,"_core",null),b(this,"_samples",[]),this._core=t,this._timescale=r,this._stats=new He(r),this._bindEvents()}return g(e,[{key:"getStats",value:function(){var e,t,r,n,i,s,a,o,u,c,l,d=(null===(e=this._core)||void 0===e?void 0:e.media)||{},f=d.currentTime,p=void 0===f?0:f,v=d.decodeFps,m=void 0===v?0:v;return h(h({},this._stats.getStats()),{},{downloadSpeed:(null===(t=this._core)||void 0===t||null===(r=t.speedInfo)||void 0===r?void 0:r.call(t).speed)||0,avgSpeed:(null===(n=this._core)||void 0===n||null===(i=n.speedInfo)||void 0===i?void 0:i.call(n).avgSpeed)||0,totalReceivedByte:(null===(s=this._core)||void 0===s||null===(a=s.speedInfo)||void 0===a?void 0:a.call(s).totalSize)||0,totalReceivedCost:(null===(o=this._core)||void 0===o||null===(u=o.speedInfo)||void 0===u?void 0:u.call(o).totalCost)||0,currentTime:p,bufferEnd:(null===(c=this._core)||void 0===c||null===(l=c.bufferInfo())||void 0===l?void 0:l.remaining)||0,decodeFps:m})}},{key:"_bindEvents",value:function(){var e=this;this._core.on(Re.DEMUXED_TRACK,(function(t){var r=t.videoTrack;return e._stats.updateBitrate(r.samples)})),this._core.on(Re.FLV_SCRIPT_DATA,(function(t){e._stats.setFpsFromScriptData(t)})),this._core.on(Re.METADATA_PARSED,(function(t){"video"===t.type?e._stats.setVideoMeta(t.track):e._stats.setAudioMeta(t.track)})),this._core.on(Re.TTFB,(function(t){e._stats.setDomain(t.responseUrl)}))}},{key:"reset",value:function(){this._samples=[],this._stats=new He(this._timescale)}}]),e}(),Ye="video",We="audio",Xe="metadata",Qe="av1",Je="avc",Ze="hevc",$e="aac",et="g7110a",tt="g7110m",rt="opus",nt="mp3",it="LARGE_AV_SHIFT",st="LARGE_VIDEO_GAP",at="LARGE_VIDEO_GAP_BETWEEN_CHUNK",ot="LARGE_AUDIO_GAP",ut="AUDIO_FILLED",ct="AUDIO_DROPPED",lt=function(){function e(){y(this,e),b(this,"id",1),b(this,"type",Ye),b(this,"codecType",Je),b(this,"pid",-1),b(this,"hvcC",void 0),b(this,"codec",""),b(this,"timescale",0),b(this,"formatTimescale",0),b(this,"sequenceNumber",0),b(this,"baseMediaDecodeTime",0),b(this,"baseDts",0),b(this,"duration",0),b(this,"warnings",[]),b(this,"samples",[]),b(this,"pps",[]),b(this,"sps",[]),b(this,"vps",[]),b(this,"fpsNum",0),b(this,"fpsDen",0),b(this,"sarRatio",[]),b(this,"width",0),b(this,"height",0),b(this,"nalUnitSize",4),b(this,"present",!1),b(this,"isVideoEncryption",!1),b(this,"isAudioEncryption",!1),b(this,"isVideo",!0),b(this,"lastKeyFrameDts",0),b(this,"kid",null),b(this,"pssh",null),b(this,"ext",void 0)}return g(e,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}},{key:"exist",value:function(){return!!/av01/.test(this.codec)||!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),dt=function(){function e(){y(this,e),b(this,"id",2),b(this,"type",We),b(this,"codecType",$e),b(this,"pid",-1),b(this,"codec",""),b(this,"container",""),b(this,"sequenceNumber",0),b(this,"sampleDuration",0),b(this,"timescale",0),b(this,"formatTimescale",0),b(this,"baseMediaDecodeTime",0),b(this,"duration",0),b(this,"warnings",[]),b(this,"samples",[]),b(this,"baseDts",0),b(this,"sampleSize",16),b(this,"sampleRate",0),b(this,"channelCount",0),b(this,"objectType",0),b(this,"sampleRateIndex",0),b(this,"config",[]),b(this,"present",!1),b(this,"isVideoEncryption",!1),b(this,"isAudioEncryption",!1),b(this,"kid",null),b(this,"ext",void 0)}return g(e,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!(!this.sampleRate||!this.channelCount||!this.codec&&!this.container||this.codecType!==$e&&this.codecType!==et&&this.codecType!==tt&&this.codecType!==rt&&this.codecType!==nt)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var e=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-e.dts+t.duration}return 0}}]),e}(),ht=function(){function e(t,r,n){y(this,e),b(this,"flag",{}),b(this,"keyframe",!1),b(this,"gopId",0),b(this,"duration",0),b(this,"size",0),b(this,"units",[]),b(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return g(e,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),e}(),ft=g((function e(t,r,n,i){y(this,e),b(this,"duration",1024),b(this,"flag",{dependsOn:2,isNonSyncSample:0}),b(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),pt=g((function e(t,r){y(this,e),b(this,"time",0),this.data=t,this.originPts=this.pts=r})),vt=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r)}(pt),mt=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r)}(pt),yt=function(){function e(){y(this,e),b(this,"id",3),b(this,"type",Xe),b(this,"timescale",0),b(this,"flvScriptSamples",[]),b(this,"seiSamples",[])}return g(e,[{key:"exist",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length||!this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!(!this.flvScriptSamples.length&&!this.seiSamples.length)}}]),e}(),_t=function(){function e(t){if(y(this,e),b(this,"_bytesAvailable",void 0),b(this,"_bitsAvailable",0),b(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return g(e,[{key:"bitsAvailable",get:function(){return this._bitsAvailable}},{key:"_loadWord",value:function(){var e=this._data.byteLength-this._bytesAvailable,t=Math.min(4,this._bytesAvailable);if(0===t)throw new Error("No bytes available");var r=new Uint8Array(4);r.set(this._data.subarray(e,e+t)),this._word=new DataView(r.buffer).getUint32(0),this._bitsAvailable=8*t,this._bytesAvailable-=t}},{key:"skipBits",value:function(e){if(this._bitsAvailable>e)this._word<<=e,this._bitsAvailable-=e;else{e-=this._bitsAvailable;var t=Math.floor(e/8);e-=8*t,this._bytesAvailable-=t,this._loadWord(),this._word<<=e,this._bitsAvailable-=e}}},{key:"readBits",value:function(e){if(e>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,e),r=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),(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:"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:"readBool",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(e){for(var t=8,r=8,n=0;n<e;n++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r}}]),e}(),gt=function(){function e(t){y(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return g(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();b(gt,"disabled",!0);var bt=function(){function e(){y(this,e)}return g(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,s=t.length;i<s;)if(n[i]<128)r.push(String.fromCharCode(n[i])),++i;else{if(n[i]<192);else if(n[i]<224){if(e._checkContinuation(n,i,1)){var a=(31&n[i])<<6|63&n[i+1];if(a>=128){r.push(String.fromCharCode(65535&a)),i+=2;continue}}}else if(n[i]<240){if(e._checkContinuation(n,i,2)){var o=(15&n[i])<<12|(63&n[i+1])<<6|63&n[i+2];if(o>=2048&&55296!=(63488&o)){r.push(String.fromCharCode(65535&o)),i+=3;continue}}}else if(n[i]<248&&e._checkContinuation(n,i,3)){var u=(7&n[i])<<18|(63&n[i+1])<<12|(63&n[i+2])<<6|63&n[i+3];if(u>65536&&u<1114112){u-=65536,r.push(String.fromCharCode(u>>>10|55296)),r.push(String.fromCharCode(1023&u|56320)),i+=4;continue}}r.push(String.fromCharCode(65533)),++i}return r.join("")}},{key:"_checkContinuation",value:function(e,t,r){var n=e;if(t+r<n.length){for(;r--;)if(128!=(192&n[++t]))return!1;return!0}return!1}}]),e}(),kt="undefined"!=typeof window,St=kt&&navigator.userAgent.toLocaleLowerCase(),Et=kt&&/^((?!chrome|android).)*safari/.test(St),xt=kt&&St.includes("firefox"),wt=kt&&St.includes("android");function Tt(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t=t.filter(Boolean);var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),i=0;return t.forEach((function(e){n.set(e,i),i+=e.byteLength})),n}var Dt=Math.pow(2,32);function At(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function Ct(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<24>>>0)+(e[t+1]<<16)+(e[t+2]<<8)+(e[t+3]||0)}function Lt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Ct(e,t)*Dt+Ct(e,t+4)}function Rt(e){for(var t,r="avc1.",n=0;n<3;n++)(t=e[n].toString(16)).length<2&&(t="0".concat(t)),r+=t;return r}function Ot(e){if(!Array.isArray(e)){for(var t=[],r="",n=0;n<e.length;n++)n%2&&(r=e[n-1]+e[n],t.push(parseInt(r,16)),r="");return t}return e.map((function(e){return parseInt(e,16)}))}function Pt(e,t){return Number(e+"."+t)}var It=function(){function e(){y(this,e)}return g(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,r){for(var n=t.length,i=0;i+2<n&&(255!==t[i]||240!=(246&t[i+1]));)i++;if(!(i>=n)){var s=i,a=[],o=(60&t[i+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var c,l,d=1+((192&t[i+2])>>>6),h=(1&t[i+2])<<2|(192&t[i+3])>>>6,f=e._getConfig(o,h,d),p=f.config,v=f.codec,m=0,y=e.getFrameDuration(u);i+7<n;)if(255===t[i]&&240==(246&t[i+1])){if(!(l=(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>5)||n-i<l)break;c=2*(1&~t[i+1]),a.push({pts:r+m*y,data:t.subarray(i+7+c,i+l)}),m++,i+=l}else i++;return{skip:s,remaining:i>=n?void 0:t.subarray(i),frames:a,samplingFrequencyIndex:o,sampleRate:u,objectType:d,channelCount:h,codec:v,config:p,originCodec:"mp4a.40.".concat(d)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(t.length){var r=t[0]>>>3,n=(7&t[0])<<1|t[1]>>>7,i=(120&t[1])>>>3,s=e.FREQ[n];if(s){var a=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:s,objectType:r,channelCount:i,config:a.config,codec:a.codec,originCodec:"mp4a.40.".concat(r)}}}}},{key:"getFrameDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4;return 1024*t/e}},{key:"_getConfig",value:function(e,t,r){var n,i,s=[];return xt?e>=6?(n=5,i=e-3):(n=2,i=e):wt?(n=2,i=e):(n=2===r||5===r?r:5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),s[0]=n<<3,s[0]|=(14&e)>>1,s[1]=(1&e)<<7,s[1]|=t<<3,5===n&&(s[1]|=(14&i)>>1,s[2]=(1&i)<<7,s[2]|=8,s[3]=0),{config:s,codec:"mp4a.40.".concat(n)}}},{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}();b(It,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var jt=function(){function e(){y(this,e)}return g(e,null,[{key:"parseAnnexB",value:function(e){var t=e.byteLength-1,r=0;do{if(0!==e[t])break;r++,t--}while(t>0);r>=3&&(e=e.subarray(0,t+1));for(var n=e.length,i=2,s=0;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if((s=++i+2)>=n)return[];for(var a=[];s<n;)switch(e[s]){case 0:if(0!==e[s-1]){s+=2;break}if(0!==e[s-2]){s++;break}if(s<n-1&&1!==e[s+1]){s++;break}i!==s-2&&a.push(e.subarray(i,s-2));do{s++}while(1!==e[s]&&s<n);s=(i=s+1)+2;break;case 1:if(0!==e[s-1]||0!==e[s-2]){s+=3;break}i!==s-2&&a.push(e.subarray(i,s-2)),s=(i=s+1)+2;break;default:s+=3}return i<n&&a.push(e.subarray(i)),a}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(!(e.length<4)){for(var r,n=e.length,i=[],s=0;s+t<n;)if(r=Ct(e,s),3===t&&(r>>>=8),s+=t,r){if(s+r>n)break;i.push(e.subarray(s,s+r)),s+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,s=0,a="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)s+=255,n++;if(s+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)a+=e[n].toString(16),n++;return{payload:e.subarray(n,n+s),type:i,size:s,uuid:a}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,r=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(r.push(n+2),n+=2):n++;if(!r.length)return e;var i=t-r.length,s=new Uint8Array(i),a=0;for(n=0;n<i;a++,n++)a===r[0]&&(a++,r.shift()),s[n]=e[a];return s}}]),e}(),Bt=function(){function e(){y(this,e)}return g(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),s=[],a=[],o=6,u=31&t[5],c=0;c<u;c++)if(n=t[o]<<8|t[o+1],o+=2,n){var l=t.subarray(o,o+n);o+=n,s.push(l),r||(r=e.parseSPS(jt.removeEPB(l)))}var d,h=t[o];o++;for(var f=0;f<h;f++)d=t[o]<<8|t[o+1],o+=2,d&&(a.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:s,ppsArr:a,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new _t(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var s=420;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r||138===r||144===r){var a=t.readUEG();if(a<=3&&(s=[0,420,422,444][a]),3===a&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==a?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var c=t.readUEG();if(0===c)t.readUEG();else if(1===c){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var l=t.readUEG(),d=0;d<l;d++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var h=t.readUEG(),f=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,m,y,_,g,b=0,k=0,S=0,E=0;if(t.readBool()&&(b=t.readUEG(),k=t.readUEG(),S=t.readUEG(),E=t.readUEG()),t.readBool()){if(t.readBool())switch(t.readUByte()){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:v=[t.readUByte()<<8|t.readUByte(),t.readUByte()<<8|t.readUByte()]}if(t.readBool()&&t.readBool(),t.readBool()&&(t.readBits(4),t.readBool()&&t.readBits(24)),t.readBool()&&(t.readUEG(),t.readUEG()),t.readBool()){var x=t.readBits(32),w=t.readBits(32);m=t.readBool(),g=(y=w)/(_=2*x)}}return{codec:Rt(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:s,width:Math.ceil(16*(h+1)-2*(b+k)),height:(2-p)*(f+1)*16-(p?2:4)*(S+E),sarRatio:v,fpsNum:y,fpsDen:_,fps:g,fixedFrame:m}}}]),e}(),Mt=function(){function e(){y(this,e)}return g(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){r=r||{};for(var n,i,s,a,o,u=1+(3&t[21]),c=[],l=[],d=[],h=23,f=t[22],p=0;p<f;p++){s=63&t[h],a=t[h+1]<<8|t[h+2],h+=3;for(var v=0;v<a;v++)if(o=t[h]<<8|t[h+1],h+=2,o){switch(s){case 32:var m=t.subarray(h,h+o);n||(n=e.parseVPS(jt.removeEPB(m),r)),d.push(m);break;case 33:var y=t.subarray(h,h+o);i||(i=e.parseSPS(jt.removeEPB(y),r)),c.push(y);break;case 34:l.push(t.subarray(h,h+o))}h+=o}}return{hvcC:r,sps:i,spsArr:c,ppsArr:l,vpsArr:d,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,r){r=r||{};var n=new _t(t);n.readUByte(),n.readUByte(),n.readBits(12);var i=n.readBits(3);return r.numTemporalLayers=Math.max(r.numTemporalLayers||0,i+1),n.readBits(17),e._parseProfileTierLevel(n,i,r),r}},{key:"parseSPS",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};r=r||{};var n=new _t(t);n.readUByte(),n.readUByte(),n.readBits(4);var i=n.readBits(3);r.numTemporalLayers=Math.max(i+1,r.numTemporalLayers||0),r.temporalIdNested=n.readBits(1),e._parseProfileTierLevel(n,i,r),n.readUEG();var s=r.chromaFormatIdc=n.readUEG(),a=420;s<=3&&(a=[0,420,422,444][s]);var o=0;3===s&&(o=n.readBits(1));var u,c,l,d,h=n.readUEG(),f=n.readUEG(),p=n.readBits(1);if(1===p&&(u=n.readUEG(),c=n.readUEG(),l=n.readUEG(),d=n.readUEG()),r.bitDepthLumaMinus8=n.readUEG(),r.bitDepthChromaMinus8=n.readUEG(),1===p){var v=1!==s&&2!==s||0!==o?1:2,m=1===s&&0===o?2:1;h-=v*(c+u),f-=m*(d+l)}return{codec:"hev1.1.6.L93.B0",width:h,height:f,chromaFormat:a,hvcC:r}}},{key:"_parseProfileTierLevel",value:function(e,t,r){var n=r.generalTierFlag||0;r.generalProfileSpace=e.readBits(2),r.generalTierFlag=Math.max(e.readBits(1),n),r.generalProfileIdc=Math.max(e.readBits(5),r.generalProfileIdc||0),r.generalProfileCompatibilityFlags=e.readBits(32),r.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var i=e.readBits(8);n<r.generalTierFlag?r.generalLevelIdc=i:r.generalLevelIdc=Math.max(i,r.generalLevelIdc||0);var s=[],a=[];if(t>e.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var o=0;o<t;o++)s[o]=e.readBits(1),a[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==s[u]&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),0!==a[u]&&e.readBits(8)}}]),e}(),Ut=function(){function e(){y(this,e)}return g(e,null,[{key:"getFrameDuration",value:function(e){return 20}},{key:"parseHeaderPackets",value:function(e){if(e.length){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),r="",n=0;n<8;n++)r+=String.fromCodePoint(e[n]);if("OpusHead"!==r)throw new Error("Invalid Opus MagicSignature");var i=e[9];console.log("Pre-skip",e[10],e[11]);var s=t.getUint32(12,!0),a=t.getInt16(16,!0);if(s){return{outputGain:a,sampleRate:s,channelCount:i,config:new Uint8Array(e.buffer,e.byteOffset+8,e.byteLength-8),codec:"opus",originCodec:"opus"}}}}}]),e}(),Nt=[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],Ft=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Vt=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],zt=[0,1,1,4],Gt=null,qt=function(){function e(){y(this,e)}return g(e,null,[{key:"isHeader",value:function(e,t){return t+1<e.length&&255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}},{key:"appendFrame",value:function(t,r,n,i,s){if(!(n+24>r.length)){var a=e.parseHeader(r,n);if(a&&n+a.frameLength<=r.length){var o=i+s*(9e4*a.samplesPerFrame/a.sampleRate),u={data:r.subarray(n,n+a.frameLength),pts:o,dts:o};return u.size=u.data.byteLength,t.config=[],t.channelCount=a.channelCount,t.sampleRate=a.sampleRate,xt?t.codec="mp3":t.container="audio/mpeg",t.samples.push(u),{length:a.frameLength}}}}},{key:"parseHeader",value:function(e,t){var r=e[t+1]>>3&3,n=e[t+1]>>1&3,i=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!==r&&0!==i&&15!==i&&3!==s){var a=e[t+2]>>1&1,o=e[t+3]>>6,u=1e3*Nt[14*(3===r?3-n:3===n?3:4)+i-1],c=Ft[3*(3===r?0:2===r?1:2)+s],l=3===o?1:2,d=Vt[r][n],h=zt[n],f=8*d*h,p=Math.floor(d*u/c+a)*h;if(null===Gt){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Gt=v?parseInt(v[1]):0}return!!Gt&&Gt<=87&&2===n&&u>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:l,frameLength:p,samplesPerFrame:f}}}}]),e}(),Ht=1e3,Kt=5e3,Yt=function(){function e(t,r,n){y(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=n,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return g(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(1e3*t);var i=this.videoTrack,s=this.audioTrack;!r&&n||(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),r&&!n&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(s,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var a=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(a&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._keyFrameInNextChunk=!1,this._fixVideo(i),this.metadataTrack.exist()){var o=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o})),this.metadataTrack.flvScriptSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/o}))}i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].dts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){var n;if(r.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts,e.keyframe&&(t._keyFrameInNextChunk=!0)})),e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else if(e.length>1){var i=e.samples[0],s=e.samples[r.length-1];n=Math.floor((s.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var a=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=a,r.length){if(void 0===this._videoNextDts){var o=r[0];this._videoNextDts=o.dts}var u=r.length,c=0,l=r[0],d=this._videoNextDts-l.dts;if(Math.abs(d)>200){var h;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:at,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(h=r[1])||void 0===h?void 0:h.dts,sampleDuration:d});this._videoTimestampBreak>=5?(this._videoNextDts=l.dts,this._videoTimestampBreak=0):(l.dts+=d,l.pts+=d,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var f=0;f<u;f++){var p=r[f].dts,v=r[f+1];((c=f<u-1?v.dts-p:a?a.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:st,time:p/e.timescale,dts:p,originDts:r[f].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[f].duration=c,this._videoNextDts+=c,this._lastVideoDuration=c}}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;r.length&&(r.forEach((function(e){e.dts=e.pts-=t._baseDts})),this._doFixAudioInternal(e,r,1e3))}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,n=t.samples;if(!r.length&&!n.length)return!1;var i=1/0,s=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=s=n[0].dts),this._baseDts=Math.min(i,s);var a=s-i;return Number.isFinite(a)&&Math.abs(a)>500&&t.warnings.push({type:it,videoBaseDts:s,audioBasePts:i,baseDts:this._baseDts,delta:a}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,r){if(!e.sampleDuration)switch(e.codecType){case $e:e.sampleDuration=It.getFrameDuration(e.timescale,r);break;case rt:e.sampleDuration=Ut.getFrameDuration(e.samples,r);break;case et:case tt:e.sampleDuration=this._getG711Duration(e);break;default:console.error("can't fix audio codecType:",e.codecType)}var n=e.sampleDuration,i=e.codecType===rt?20:e.codecType===$e?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var s=t[0];this._audioNextPts=s.pts}for(var a=0;a<t.length;a++){var o=this._audioNextPts,u=t[a],c=u.pts-o;if(0===a&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=Ht&&!Et){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>Kt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:ut,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var h=0;h<d;h++){var f=new ft(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);f.originPts=Math.floor(this._baseDts+o),t.splice(a,0,f),this._audioNextPts+=n,a++}a--}else if(c<=-3*n&&c>=-1e3)Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>Kt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:ct,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(a,1),a--;else{if(Math.abs(c)>Ht&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>Kt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:ot,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),e.codecType===rt){var p=t[t.length-1];p&&(p.duration=u.pts-p.pts)}else u.dts=u.pts=o,u.duration=i;this._audioNextPts+=n}}}},{key:"_getG711Duration",value:function(e){var t=e.sampleSize,r=e.channelCount,n=e.sampleRate,i=e.samples[0];if(i)return 2*i.data.byteLength/r/(t/8)/n*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===$e?It.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),Wt=function(){function e(){y(this,e)}return g(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var r={},n=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),i=e._parseValue(new DataView(t.buffer,t.byteOffset+n.size,t.byteLength-n.size));return r[n.data]=i.data,r}}},{key:"_parseValue",value:function(t){var r,n=t.byteLength,i=1,s=!1;switch(t.getUint8(0)){case 0:r=t.getFloat64(1),i+=8;break;case 1:r=!!t.getUint8(1),i+=1;break;case 2:var a=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=a.data,i+=a.size;break;case 3:r={};var o=0;for(9==(16777215&t.getUint32(n-4))&&(o=3);i<n-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-o)),c=u.size,l=u.data;if(u.isEnd)break;r[l.name]=l.value,i+=c}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 8:r={},i+=4;var d=0;for(9==(16777215&t.getUint32(n-4))&&(d=3);i<n-8;){var h=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),f=h.size,p=h.data;if(h.isEnd)break;r[p.name]=p.value,i+=f}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 9:r=void 0,i=1,s=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var m=0;m<v;m++){var y=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),_=y.data,g=y.size;r.push(_),i+=g}break;case 11:var b=t.getFloat64(i)+6e4*t.getInt16(i+8);r=new Date(b),i+=10;break;case 12:var k=t.getUint32(1);i+=4,r="",k>0&&(r=bt.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:s}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=bt.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:r,size:2+t}}},{key:"_parseObject",value:function(t){if(!(t.byteLength<3)){var r=e._parseString(t),n=e._parseValue(new DataView(t.buffer,t.byteOffset+r.size,t.byteLength-r.size));return{data:{name:r.data,value:n.data},size:r.size+n.size,isEnd:n.isEnd}}}}]),e}(),Xt=7,Qt=8,Jt=10,Zt=13,$t=new gt("FlvDemuxer"),er=function(){function e(t,r,n){y(this,e),b(this,"_headerParsed",!1),b(this,"_remainingData",null),b(this,"_gopId",0),b(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new lt,this.audioTrack=r||new dt,this.metadataTrack=n||new yt,this._fixer=new Yt(this.videoTrack,this.audioTrack,this.metadataTrack)}return g(e,[{key:"demux",value:function(t){var r,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=arguments.length>3?arguments[3]:void 0,a=this.audioTrack,o=this.videoTrack,u=this.metadataTrack;if(!n&&i||(this._remainingData=null),n&&(this._headerParsed=!1),n?(o.reset(),a.reset(),u.reset()):(o.samples=[],a.samples=[],u.seiSamples=[],u.flvScriptSamples=[],o.warnings=[],a.warnings=[],this._remainingData&&(t=Tt(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:o,audioTrack:a,metadataTrack:u};var c=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");a.present=(4&t[4])>>>2!=0,o.present=0!=(1&t[4]),this._headerParsed=!0,c=Ct(t,5)+4}for(var l,d,h,f,p,v=t.length;c+15<v&&(l=t[c],!(c+15+(d=t[c+1]<<16|t[c+2]<<8|t[c+3])>v));)h=(t[c+7]<<24>>>0)+(t[c+4]<<16)+(t[c+5]<<8)+t[c+6],c+=11,f=t.subarray(c,c+d),8===l?this._parseAudio(f,h):9===l?(s&&(this.seamlessLoadingSwitching=!0),this._parseVideo(f,h)):18===l?this._parseScript(f,h):$t.warn("Invalid tag type: ".concat(l)),(p=Ct(t,c+=d))!==11+d&&$t.warn("Invalid PrevTagSize ".concat(p," (").concat(11+d,")")),c+=4;c<v&&(this._remainingData=t.subarray(c)),a.formatTimescale=o.formatTimescale=o.timescale=u.timescale=1e3,a.timescale=a.codecType===rt?1e3:a.sampleRate||0,!a.exist()&&a.hasSample()&&a.reset(),!o.exist()&&o.hasSample()&&o.reset();var m=u.flvScriptSamples[u.flvScriptSamples.length-1],y=null==m||null===(r=m.data)||void 0===r?void 0:r.onMetaData;return y&&(null!=o&&o.exist()&&(y.hasOwnProperty("duration")&&(o.duration=1e3*y.duration),y.hasOwnProperty("width")&&y.hasOwnProperty("height")&&(o.width=y.width,o.height=y.height)),null!=a&&a.exist()&&y.hasOwnProperty("duration")&&(a.duration=1e3*y.duration)),{videoTrack:o,audioTrack:a,metadataTrack:u}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,n,i){return this.demux(e,t,r,i),this.fix(n,t,r)}},{key:"_parseAudio",value:function(t,r){if(t.length){var n=(240&t[0])>>>4,i=this.audioTrack;if(n!==Jt&&n!==Xt&&n!==Qt&&n!==Zt)return $t.warn("Unsupported sound format: ".concat(n)),void i.reset();if(n!==Jt&&n!==Zt){var s=(12&t[0])>>2,a=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[s],i.sampleSize=a?16:8,i.channelCount=o+1}switch(n){case Xt:case Qt:this._parseG711(t,r,n);break;case Jt:this._parseAac(t,r);break;case Zt:this._parseOpus(t,r)}}}},{key:"_parseOpus",value:function(e,t){var r=this.audioTrack,n=e[1];switch(r.codecType=rt,n){case 0:var i=Ut.parseHeaderPackets(e.subarray(2));i?(r.codec=i.codec,r.channelCount=i.channelCount,r.sampleRate=i.sampleRate,r.config=i.config,r.sampleDuration=Ut.getFrameDuration([],r.timescale)):(r.reset(),$t.warn("Cannot parse AudioSpecificConfig",e));break;case 1:if(null==t)return;var s=new ft(t,e.subarray(2),r.sampleDuration);r.samples.push(s);break;default:$t.warn("Unknown OpusPacketType: ".concat(n))}}},{key:"_parseG711",value:function(e,t,r){var n=this.audioTrack,i=e.subarray(1);if(!(i.byteLength<1)){var s=new ft(t,i);n.codecType=7===r?et:tt,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(s)}}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=$e,0===e[1]){var n=It.parseAudioSpecificConfig(e.subarray(2));n?(r.codec=n.codec,r.channelCount=n.channelCount,r.sampleRate=n.sampleRate,r.config=n.config,r.objectType=n.objectType,r.sampleRateIndex=n.samplingFrequencyIndex):(r.reset(),$t.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new ft(t,e.subarray(2)))}else $t.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var r=this;if(!(e.length<6)){var n=(240&e[0])>>>4,i=15&e[0],s=this.videoTrack;if(7!==i&&12!==i)return s.reset(),void $t.warn("Unsupported codecId: ".concat(i));var a=12===i;s.codecType=a?Ze:Je;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=a?Mt.parseHEVCDecoderConfigurationRecord(c):Bt.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,h=l.sps,f=l.ppsArr,p=l.spsArr,v=l.vpsArr,m=l.nalUnitSize;d&&(s.hvcC=s.hvcC||d),h&&(s.codec=h.codec,s.width=h.width,s.height=h.height,s.sarRatio=h.sarRatio,s.fpsNum=h.fpsNum,s.fpsDen=h.fpsDen),p.length&&(s.sps=p),f.length&&(s.pps=f),v&&v.length&&(s.vps=v),m&&(s.nalUnitSize=m)}else $t.warn("Cannot parse ".concat(a?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var y=jt.parseAvcC(e.subarray(5),s.nalUnitSize);if((y=this._checkAddMetaNalToUnits(a,y,s))&&y.length){var _=new ht(t+u,t,y);if(this.seamlessLoadingSwitching&&t<s.lastKeyFrameDts)return;this.seamlessLoadingSwitching=!1,1===n&&(_.setToKeyframe(),s.lastKeyFrameDts=t),s.samples.push(_),y.forEach((function(e){var n=a?e[0]>>>1&63:31&e[0];switch(n){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!a&&5!==n||a&&5===n)break;_.setToKeyframe();break;case 6:case 39:case 40:if(!a&&6!==n||a&&6===n)break;r.metadataTrack.seiSamples.push(new mt(jt.parseSEI(jt.removeEPB(e),a),t+u))}})),_.keyframe&&this._gopId++,_.gopId=this._gopId}else $t.warn("Cannot parse NALUs",e)}else 2===o||$t.warn("Unknown AVCPacketType: ".concat(o))}}},{key:"_checkAddMetaNalToUnits",value:function(e,t,r){return e&&this._needAddMetaBeforeKeyFrameNal?t.map((function(e){return e[0]>>>1&63})).includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(r.pps[0]),t.unshift(r.sps[0]),t.unshift(r.vps[0]),t.filter(Boolean)):(this._needAddMetaBeforeKeyFrameNal=!1,t)}},{key:"_parseScript",value:function(e,t){this.metadataTrack.flvScriptSamples.push(new vt(Wt.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&Ct(e,5)>=9}}]),e}();b(er,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var tr=9e4,rr=45e4,nr=9e4,ir=function(){function e(t,r,n,i){y(this,e),this.videoTrack=t,this.audioTrack=r,this.metadataTrack=n,this._baseDts=-1,this._baseVideoDts=-1,this._baseAudioDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0,this._needForceFixLargeGap=null==i?void 0:i.forceFixLargeGap,this._largeGapThreshold=(null==i?void 0:i.largeGapThreshold)||45e4}return g(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t=Math.round(9e4*t);var i=this.videoTrack,s=this.audioTrack,a=i.samples,o=s.samples;if(a.length||o.length){var u=a[0],c=o[0],l=0;if(a.length&&o.length&&(l=u.dts-c.pts),this._baseDtsInited||this._calculateBaseDts(this.audioTrack,this.videoTrack),r&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=t,this._baseAudioDts-=t,this._baseVideoDts-=t),!n){this._videoNextDts=l>0?t+l:t,this._audioNextPts=l>0?t:t-l,this._needForceFixLargeGap&&(this._videoNextDts=0,this._audioNextPts=0);var d=u?u.dts-this._baseDts-this._videoNextDts:0,h=c?c.pts-this._baseDts-this._audioNextPts:0;Math.abs(d||h)>nr&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=t)}if(this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._fixVideo(i),this.metadataTrack.exist()){var f=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach((function(t){t.pts=t.originPts-e._baseDts,t.time=Math.max(0,t.pts)/f}))}i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].dts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.timescale/9e4)}}},{key:"_fixVideo",value:function(e){var t=this,r=e.samples;if(r.length){if(r.forEach((function(e){e.dts-=t._needForceFixLargeGap?t._baseVideoDts:t._baseDts,e.pts-=t._needForceFixLargeGap?t._baseVideoDts:t._baseDts})),void 0===this._videoNextDts){var n=r[0];this._videoNextDts=n.dts}var i,s,a=r.length,o=0,u=r[0],c=r[1],l=this._videoNextDts-u.dts;if(Math.abs(l)>45e3)if(e.warnings.push({type:at,nextDts:this._videoNextDts/90,firstSampleDts:u.dts/90,nextSampleDts:((null===(i=r[1])||void 0===i?void 0:i.dts)||0)/90,sampleDuration:l/90}),u.dts+=l,u.pts+=l,c&&Math.abs(c.dts-u.dts)>nr)this._videoTimestampBreak=!0,r.forEach((function(e,t){0!==t&&(e.dts+=l,e.pts+=l)}));else for(var d=1;d<a-1;d++){var h,f=null===(h=r[d])||void 0===h?void 0:h.dts,p=r[d-1].dts;f&&f-p<0&&(r[d].dts+=l,r[d].pts+=l)}if(e.fpsNum&&e.fpsDen&&(s=e.timescale*(e.fpsDen/e.fpsNum)),s<900&&(s=0),!s){var v=e.samples[0],m=e.samples[1];s=1===a?9e3:Math.floor(m.dts-v.dts)}for(var y=0;y<a;y++){var _=r[y].dts,g=r[y+1];if((o=y<a-1?g.dts-_:r[y-1]?Math.min(_-r[y-1].dts,s):s)>nr||o<0){this._videoTimestampBreak=!0,o=this._audioTimestampBreak?s:Math.max(o,2700);var b=this._audioNextPts||0;g&&g.dts>b&&(o=s),e.warnings.push({type:st,time:_/e.timescale,dts:_,originDts:r[y].originDts,nextDts:this._videoNextDts,sampleDuration:o,refSampleDuration:s})}r[y].duration=o,this._videoNextDts+=o}}}},{key:"_fixAudio",value:function(e){var t=this,r=e.samples;if(r.length)if(e.codecType!==nt)r.forEach((function(e){e.pts-=t._needForceFixLargeGap?t._baseAudioDts:t._baseDts,e.dts=e.pts})),this._doFixAudioInternal(e,r,9e4);else{this.lastAudioSample&&r.unshift(this.lastAudioSample);for(var n=0;n<r.length;n++){var i=r[n];if(!r[n+1])break;i.duration=r[n+1].pts-i.pts,i.pts-=this._baseDts,i.dts=i.pts}this.lastAudioSample=r.pop()}}},{key:"_calculateBaseDts",value:function(e,t){var r=e.samples,n=t.samples;if(!r.length&&!n.length)return!1;var i=1/0,s=1/0;r.length&&(e.baseDts=i=r[0].pts,this._baseAudioDts=i),n.length&&(t.baseDts=s=n[0].dts,this._baseVideoDts=s),this._baseDts=Math.min(i,s);var a=s-i,o=!1;return Number.isFinite(a)&&Math.abs(a)>45e3&&t.warnings.push({type:it,videoBaseDts:s,audioBasePts:i,baseDts:this._baseDts,delta:a}),Number.isFinite(a)&&Math.abs(a)>this._largeGapThreshold*tr&&(o=!0),this._baseDtsInited||(o&&this._needForceFixLargeGap?this._needForceFixLargeGap=!0:this._needForceFixLargeGap=!1),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){if(this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak){if(!this._calculateBaseDts(this.audioTrack,this.videoTrack))return;this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts),this._audioLastSample=null,this._videoLastSample=null,this._videoTimestampBreak=!1,this._audioTimestampBreak=!1}}},{key:"_doFixAudioInternal",value:function(e,t,r){e.sampleDuration||(e.sampleDuration=It.getFrameDuration(e.timescale,r));var n=e.sampleDuration;if(void 0===this._audioNextPts){var i=t[0];this._audioNextPts=i.pts}for(var s=0;s<t.length;s++){var a=this._audioNextPts,o=t[s],u=o.pts-a;if(!this._audioTimestampBreak&&u>=3*n&&u<=tr&&!Et){var c=It.getSilentFrame(e.codec,e.channelCount)||t[0].data.subarray(),l=Math.floor(u/n);Math.abs(o.pts-this._lastAudioExceptionGapDot)>rr&&(this._lastAudioExceptionGapDot=o.pts),e.warnings.push({type:ut,pts:o.pts/90,originPts:o.originPts,count:l,nextPts:a/90,refSampleDuration:n});for(var d=0;d<l;d++){var h=new ft(Math.floor(a),c);h.originPts=Math.floor(this._baseDts+a),t.splice(s,0,h),this._audioNextPts+=n,s++}s--}else u<=-3*n&&u>=-9e4?(Math.abs(o.pts-this._lastAudioExceptionOverlapDot)>rr&&(this._lastAudioExceptionOverlapDot=o.pts,e.warnings.push({type:ct,pts:o.pts/90,originPts:o.originPts,nextPts:a/90,refSampleDuration:n})),t.splice(s,1),s--):(Math.abs(u)>=tr&&(this._audioTimestampBreak=!0,Math.abs(o.pts-this._lastAudioExceptionLargeGapDot)>rr&&(this._lastAudioExceptionLargeGapDot=o.pts,e.warnings.push({type:ot,time:o.pts/1e3,pts:o.pts/90,originPts:o.originPts,nextPts:a/90,sampleDuration:u,refSampleDuration:n}))),o.dts=o.pts=a,this._audioNextPts+=n)}}}]),e}(),sr=new gt("TsDemuxer"),ar=function(){function e(t,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};y(this,e),b(this,"_pmtId",-1),b(this,"_remainingPacketData",null),b(this,"_videoPesData",[]),b(this,"_audioPesData",[]),b(this,"_gopId",0),this.videoTrack=t||new lt,this.audioTrack=r||new dt,this.metadataTrack=n||new yt,this._fixer=new ir(this.videoTrack,this.audioTrack,this.metadataTrack,i)}return g(e,[{key:"demux",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=this.audioTrack,i=this.videoTrack,s=this.metadataTrack;t&&(this._pmtId=-1,i.reset(),n.reset(),s.reset()),!r||t?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(i.samples=[],n.samples=[],s.seiSamples=[],i.warnings=[],n.warnings=[],this._remainingPacketData&&(e=Tt(this._remainingPacketData,e),this._remainingPacketData=null));var a=e.length,o=a%188;o&&(this._remainingPacketData=e.subarray(a-o),a-=o);for(var u=i.pid,c=n.pid,l=0;l<a;l+=188){if(71!==e[l])throw new Error("TS packet did not start with 0x47");var d=!!(64&e[l+1]),h=((31&e[l+1])<<8)+e[l+2],f=(48&e[l+3])>>4,p=void 0;if(f>1){if((p=l+5+e[l+4])===l+188)continue}else p=l+4;switch(h){case 0:d&&(p+=e[p]+1),this._pmtId=(31&e[p+10])<<8|e[p+11];break;case this._pmtId:d&&(p+=e[p]+1);var v=p+3+((15&e[p+1])<<8|e[p+2])-4,m=(15&e[p+10])<<8|e[p+11];for(p+=12+m;p<v;){var y=(31&e[p+1])<<8|e[p+2];switch(e[p]){case 15:n.pid=c=y;break;case 3:case 4:-1===n.pid&&(n.pid=c=y,n.codecType=nt);break;case 27:if(-1!==u)break;i.codecType=Je,i.pid=u=y;break;case 36:if(-1!==u)break;i.codecType=Ze,i.pid=u=y;break;default:sr.warn("Unsupported stream. type: ".concat(e[p],", pid: ").concat(y))}p+=5+((15&e[p+3])<<8|e[p+4])}break;case u:d&&this._videoPesData.length&&this._parseVideoData(),this._videoPesData.push(e.subarray(p,l+188));break;case c:d&&this._audioPesData.length&&this._parseAudioData(),this._audioPesData.push(e.subarray(p,l+188));break;case 17:case 8191:break;default:sr.warn("Unknown pid: ".concat(h))}}return this._parseVideoData(),this._parseAudioData(),n.formatTimescale=i.formatTimescale=i.timescale=s.timescale=9e4,n.timescale=n.sampleRate||0,{videoTrack:i,audioTrack:n,metadataTrack:s}}},{key:"fix",value:function(e,t,r){return this._fixer.fix(e,t,r),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,r,n){return this.demux(e,t,r),this.fix(n,t,r)}},{key:"_parseVideoData",value:function(){if(this._videoPesData.length){var t=e._parsePES(Tt.apply(void 0,I(this._videoPesData)));if(t){var r=jt.parseAnnexB(t.data);r?this._createVideoSample(r,t.pts,t.dts):sr.warn("Cannot parse avc units",t),this._videoPesData=[]}else sr.warn("Cannot parse video pes",this._videoPesData)}}},{key:"_createVideoSample",value:function(e,t,r){var n=this;if(e.length){var i=this.videoTrack,s=i.codecType===Ze,a=new ht(t,r);e.forEach((function(e){var r=s?e[0]>>>1&63:31&e[0];switch(r){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!s&&5!==r||s&&5===r)break;a.setToKeyframe(),n._gopId++;break;case 6:case 39:case 40:if(!s&&6!==r||s&&6===r)break;return void n.metadataTrack.seiSamples.push(new mt(jt.parseSEI(jt.removeEPB(e),s),t));case 32:if(!s)break;if(!i.vps.length){var o=Mt.parseVPS(jt.removeEPB(e),i.hvcC);i.hvcC=i.hvcC||o,i.vps=[e]}break;case 7:case 33:if(!s&&7!==r||s&&7===r)break;if(!i.sps.length){var u=jt.removeEPB(e),c=s?Mt.parseSPS(u,i.hvcC):Bt.parseSPS(u);i.sps=[e],i.hvcC=i.hvcC||c.hvcC,i.codec=c.codec,i.width=c.width,i.height=c.height,i.sarRatio=c.sarRatio,i.fpsNum=c.fpsNum,i.fpsDen=c.fpsDen}break;case 8:case 34:if(!s&&8!==r||s&&8===r)break;i.pps.length||(i.pps=[e]);break;case 9:case 35:break;case 38:if(s){for(var l=!1,d=2;d<e.byteLength;d++)if(255===e[d]){l=!0;break}if(!l)return}}a.units.push(e)})),a.gopId=this._gopId,this._pushVideoSample(i,a)}}},{key:"_pushVideoSample",value:function(e,t){if(t.units.length)if(null===t.pts||void 0===t.pts){sr.warn("Video sample no pts",t);var r=e.samples[e.samples.length-1];r?(t.pts=r.pts,t.dts=r.dts):sr.warn("Drop video sample",t)}else e.samples.push(t)}},{key:"_parseAudioData",value:function(){if(this._audioPesData.length){var t=e._parsePES(Tt.apply(void 0,I(this._audioPesData)));if(t){switch(this.audioTrack.codecType){case $e:this._parseAacData(t);break;case nt:this._parseMPEG(t)}this._audioPesData=[]}else sr.warn("Cannot parse audio pes",this._audioPesData)}}},{key:"_parseAacData",value:function(e){var t=this.audioTrack,r=e.pts;if(null==r){if(sr.warn("AAC pes not pts",t),!t.samples.length||!t.sampleRate)return;r=t.samples[t.samples.length-1].pts+It.getFrameDuration(t.sampleRate)}var n,i=It.parseADTS(e.data,r);i?(t.codec=i.codec,t.channelCount=i.channelCount,t.sampleRate=i.sampleRate,t.objectType=i.objectType,t.sampleRateIndex=i.samplingFrequencyIndex,t.config=i.config,(n=t.samples).push.apply(n,I(i.frames.map((function(e){return new ft(e.pts,e.data)})))),i.skip&&sr.warn("Skip aac adts ".concat(i.skip," bits")),i.remaining&&sr.warn("Remaining aac adts ".concat(i.remaining," bits"))):sr.warn("Cannot parse aac adts",e)}},{key:"_parseMPEG",value:function(e){var t=e.data,r=t.length,n=0,i=0,s=e.pts;if(void 0!==s)for(;i<r;)if(qt.isHeader(t,i)){var a=qt.appendFrame(this.audioTrack,t,i,s,n);if(!a)break;i+=a.length,n++}else i++;else sr.warn("[tsdemuxer]: MPEG PES unknown PTS")}}],[{key:"probe",value:function(e){return!!e.length&&(71===e[0]&&71===e[188]&&71===e[376])}},{key:"_parsePES",value:function(e){var t=e[8];if(!(null==t||e.length<t+9)&&1===(e[0]<<16|e[1]<<8|e[2])){var r=(e[4]<<8)+e[5];if(!(r&&r>e.length-6)){var n,i,s=e[7];return 192&s&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&s?n-(i=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(n=i):i=n),{data:e.subarray(9+t),pts:n,dts:i}}}}}]),e}(),or=function(){function e(t,r,n){y(this,e),this.dv=new DataView(t),this.start=this.offset=r||this.dv.byteOffset,this.end=n?this.start+n:this.start+this.dv.byteLength}return g(e,[{key:"buffer",get:function(){return this.dv.buffer}},{key:"unreadLength",get:function(){return Math.max(this.end-this.offset,0)}},{key:"size",get:function(){return this.end-this.start}},{key:"readFloat",value:function(e){var t=0;switch(e){case 4:t=this.dv.getFloat32(this.offset);break;case 8:t=this.dv.getFloat64(this.offset);break;default:throw new Error("read ".concat(e,"-byte float is not supported"))}return this.offset+=e,t}},{key:"back",value:function(e){this.offset-=e}},{key:"skip",value:function(e){this.offset+=e}},{key:"readInt",value:function(e){var t=this.offset;switch(this.offset+=e,e){case 1:return this.dv.getInt8(t);case 2:return this.dv.getInt16(t);case 4:return this.dv.getInt32(t);default:throw new Error("read ".concat(e,"-byte integers is not supported"))}}},{key:"read",value:function(e){var t=this.offset;switch(this.offset+=e,e){case 1:return this.dv.getUint8(t);case 2:return this.dv.getUint16(t);case 3:return(this.dv.getUint16(t)<<8)+this.dv.getUint8(t+2);case 4:return this.dv.getUint32(t);default:return this.back(e-4),this.read(e-4)+this.dv.getUint32(t)*Math.pow(256,e-4)}}},{key:"write",value:function(e,t){var r=this.offset;switch(this.offset+=e,e){case 1:return this.dv.setUint8(r,t);case 2:return this.dv.setUint16(r,t);case 3:return this.dv.setUint8(r,t>>>16),this.dv.setUint16(r+1,65535&t);case 4:return this.dv.setUint32(r,t);default:throw new Error("write ".concat(e,"-byte integers is not supported"))}}},{key:"readToBuffer",value:function(e){var t;return t=this.offset||e?this.dv.buffer.slice(this.offset,e?this.offset+e:this.end):this.dv.buffer,this.offset+=t.byteLength,t}},{key:"readToUint8",value:function(e){var t=new Uint8Array(this.dv.buffer,this.offset,e||this.unreadLength);return this.offset+=t.byteLength,t}},{key:"readString",value:function(e){for(var t=0,r="";t<e;t++)r+=String.fromCharCode(this.dv.getUint8(this.offset)),this.offset++;return r}}],[{key:"fromUint8",value:function(t){return new e(t.buffer,t.byteOffset,t.byteLength)}},{key:"concatUint8s",value:function(e){var t=new Uint8Array(e.reduce((function(e,t){return e+t.byteLength}),0)),r=0;return e.forEach((function(e){t.set(e,r),r+=e.byteLength})),t}},{key:"concatUint8",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.concatUint8s(t)}}]),e}(),ur=function(){function e(t,r){y(this,e),this.offset=0,this.val=t,this.size=r}return g(e,[{key:"skip",value:function(e){this.offset+=e}},{key:"read",value:function(e){var t=this.size-this.offset-e;if(t>=0){var r=0,n=0;if(this.offset+=e,this.size>31){for(;n<e;n++)r+=Math.pow(2,n);return this.val/Math.pow(2,t)&r}for(;n<e;n++)r+=1<<n;return this.val>>>t&r}throw new Error("the number of the read operation exceeds the total length limit of bits")}}],[{key:"fromByte",value:function(t,r){return new e(t.read(r),r<<3)}}]),e}(),cr=function(){function e(){y(this,e)}return g(e,null,[{key:"findBox",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[];if(!t)return i;for(var s=0,a="",o=0;t.length>7;){if(s=Ct(t),a=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===s?(s=Lt(t,8),o+=8):s||(s=t.length),!r[0]||a===r[0]){var u=t.subarray(0,s);if(!(r.length<2))return e.findBox(u.subarray(o),r.slice(1),n+o);i.push({start:n,size:s,headerSize:o,type:a,data:u})}n+=s,t=t.subarray(s)}return i}},{key:"tfhd",value:function(e){return fr(e,!0,(function(e,t){e.trackId=Ct(t);var r=4,n=1&e.flags,i=2&e.flags,s=8&e.flags,a=16&e.flags,o=32&e.flags;n&&(r+=4,e.baseDataOffset=Ct(t,r),r+=4),i&&(e.sampleDescriptionIndex=Ct(t,r),r+=4),s&&(e.defaultSampleDuration=Ct(t,r),r+=4),a&&(e.defaultSampleSize=Ct(t,r),r+=4),o&&(e.defaultSampleFlags=Ct(t,r))}))}},{key:"sidx",value:function(e){return fr(e,!0,(function(e,t){var r=0;e.reference_ID=Ct(t,r),r+=4,e.timescale=Ct(t,r),r+=4,0===e.version?(e.earliest_presentation_time=Ct(t,r),r+=4,e.first_offset=Ct(t,r),r+=4):(e.earliest_presentation_time=Lt(t,r),r+=8,e.first_offset=Lt(t,r),r+=8),r+=2,e.references=[];var n=At(t,r);r+=2;for(var i=0;i<n;i++){var s={};e.references.push(s);var a=Ct(t,r);r+=4,s.reference_type=a>>31&1,s.referenced_size=2147483647&a,s.subsegment_duration=Ct(t,r),a=Ct(t,r+=4),r+=4,s.starts_with_SAP=a>>31&1,s.SAP_type=a>>28&7,s.SAP_delta_time=268435455&a}}))}},{key:"moov",value:function(t){return fr(t,!1,(function(t,r,n){t.mvhd=e.mvhd(e.findBox(r,["mvhd"],n)[0]),t.trak=e.findBox(r,["trak"],n).map((function(t){return e.trak(t)})),t.pssh=e.pssh(e.findBox(r,["pssh"],n)[0])}))}},{key:"mvhd",value:function(e){return fr(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=Ct(t,16),e.duration=Lt(t,20),r+=28):(e.timescale=Ct(t,8),e.duration=Ct(t,12),r+=16),e.nextTrackId=Ct(t,r+76)}))}},{key:"trak",value:function(t){return fr(t,!1,(function(t,r,n){t.tkhd=e.tkhd(e.findBox(r,["tkhd"],n)[0]),t.mdia=e.mdia(e.findBox(r,["mdia"],n)[0])}))}},{key:"tkhd",value:function(e){return fr(e,!0,(function(e,t){var r=or.fromUint8(t);1===e.version?(r.read(8),r.read(8),e.trackId=r.read(4),r.read(4),e.duration=r.read(8)):(r.read(4),r.read(4),e.trackId=r.read(4),r.read(4),e.duration=r.read(4)),r.skip(16),e.matrix=[];for(var n=0;n<36;n++)e.matrix.push(r.read(1));r.back(36);for(var i,s=[],a=0;a<3;a++)s.push(Pt(r.readInt(2),r.readInt(2))),s.push(Pt(r.readInt(2),r.readInt(2))),i=r.readInt(4),s.push(Pt(i>>30,1073741823&i));e.rotation=function(e){if(e.length<5)return 0;var t=Math.hypot(e[0],e[3]),r=Math.hypot(e[1],e[4]);return 0===t||0===r?0:180*Math.atan2(e[1]/r,e[0]/t)/Math.PI}(s),e.width=r.read(4),e.height=r.read(4)}))}},{key:"mdia",value:function(t){return fr(t,!1,(function(t,r,n){t.mdhd=e.mdhd(e.findBox(r,["mdhd"],n)[0]),t.hdlr=e.hdlr(e.findBox(r,["hdlr"],n)[0]),t.minf=e.minf(e.findBox(r,["minf"],n)[0])}))}},{key:"mdhd",value:function(e){return fr(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=Ct(t,16),e.duration=Lt(t,20),r+=28):(e.timescale=Ct(t,8),e.duration=Ct(t,12),r+=16);var n=At(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return fr(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return fr(t,!1,(function(t,r,n){t.vmhd=e.vmhd(e.findBox(r,["vmhd"],n)[0]),t.smhd=e.smhd(e.findBox(r,["smhd"],n)[0]),t.stbl=e.stbl(e.findBox(r,["stbl"],n)[0])}))}},{key:"vmhd",value:function(e){return fr(e,!0,(function(e,t){e.graphicsmode=At(t),e.opcolor=[At(t,2),At(t,4),At(t,6)]}))}},{key:"smhd",value:function(e){return fr(e,!0,(function(e,t){e.balance=At(t)}))}},{key:"stbl",value:function(t){return fr(t,!1,(function(t,r,n){var i,s,a;t.stsd=e.stsd(e.findBox(r,["stsd"],n)[0]),t.stts=e.stts(e.findBox(r,["stts"],n)[0]),t.ctts=e.ctts(e.findBox(r,["ctts"],n)[0]),t.stsc=e.stsc(e.findBox(r,["stsc"],n)[0]),t.stsz=e.stsz(e.findBox(r,["stsz"],n)[0]),t.stco=e.stco(e.findBox(r,["stco"],n)[0]),t.stco||(t.co64=e.co64(e.findBox(r,["co64"],n)[0]),t.stco=t.co64);var o=null===(i=t.stsd.entries[0])||void 0===i||null===(s=i.sinf)||void 0===s||null===(a=s.schi)||void 0===a?void 0:a.tenc.default_IV_size;t.stss=e.stss(e.findBox(r,["stss"],n)[0]),t.senc=e.senc(e.findBox(r,["senc"],n)[0],o)}))}},{key:"senc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return fr(e,!0,(function(e,r){var n=0,i=Ct(r,n);n+=4,e.samples=[];for(var s=0;s<i;s++){for(var a={InitializationVector:[]},o=0;o<t;o++)a.InitializationVector[o]=r[n+o];if(n+=t,2&e.flags){a.subsamples=[];var u=At(r,n);n+=2;for(var c=0;c<u;c++){var l={};l.BytesOfClearData=At(r,n),n+=2,l.BytesOfProtectedData=Ct(r,n),n+=4,a.subsamples.push(l)}}e.samples.push(a)}}))}},{key:"pssh",value:function(e){return fr(e,!0,(function(e,t){for(var r=[],n=[],i=0,s=0;s<16;s++)n.push(vr(t[i+s]));if(i+=16,e.version>0){var a=Ct(t,i);i+=4;for(var o=0;o<(""+a).length;o++)for(var u=0;u<16;u++){var c=t[i];i+=1,r.push(vr(c))}}var l=Ct(t,i);e.data_size=l,i+=4,e.kid=r,e.system_id=n,e.buffer=t}))}},{key:"stsd",value:function(t){return fr(t,!0,(function(t,r,n){t.entryCount=Ct(r),t.entries=e.findBox(r.subarray(4),[],n+4).map((function(t){switch(t.type){case"av01":return e.av01(t);case"avc1":case"avc2":case"avc3":case"avc4":return e.avc1(t);case"hvc1":case"hev1":return e.hvc1(t);case"mp4a":return e.mp4a(t);case"alaw":case"ulaw":return e.alaw(t);case"enca":return fr(t,!1,(function(t,r,n){t.channelCount=At(r,16),t.samplesize=At(r,18),t.sampleRate=Ct(r,24)/65536,r=r.subarray(28),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.esds=e.esds(e.findBox(r,["esds"],n)[0])}));case"encv":return fr(t,!1,(function(t,r,n){t.width=At(r,24),t.height=At(r,26),t.horizresolution=Ct(r,28),t.vertresolution=Ct(r,32),r=r.subarray(78),t.sinf=e.sinf(e.findBox(r,["sinf"],n)[0]),t.avcC=e.avcC(e.findBox(r,["avcC"],n)[0]),t.hvcC=e.hvcC(e.findBox(r,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(r,["pasp"],n)[0])}))}})).filter(Boolean)}))}},{key:"tenc",value:function(e){return fr(e,!1,(function(e,t){var r=6;e.default_IsEncrypted=t[r],r+=1,e.default_IV_size=t[r],r+=1,e.default_KID=[];for(var n=0;n<16;n++)e.default_KID.push(vr(t[r])),r+=1}))}},{key:"schi",value:function(t){return fr(t,!1,(function(t,r,n){t.tenc=e.tenc(e.findBox(r,["tenc"],n)[0])}))}},{key:"sinf",value:function(t){return fr(t,!1,(function(t,r,n){t.schi=e.schi(e.findBox(r,["schi"],n)[0]),t.frma=e.frma(e.findBox(r,["frma"],n)[0])}))}},{key:"frma",value:function(e){return fr(e,!1,(function(e,t){e.data_format="";for(var r=0;r<4;r++)e.data_format+=String.fromCharCode(t[r])}))}},{key:"colr",value:function(e){return fr(e,!1,(function(t,r){var n=or.fromUint8(r);t.data=e.data,t.colorType=n.readString(4),"nclx"===t.colorType?(t.colorPrimaries=n.read(2),t.transferCharacteristics=n.read(2),t.matrixCoefficients=n.read(2),t.fullRangeFlag=n.read(1)>>7):"rICC"!==t.colorType&&"prof"!==t.colorType||(t.iccProfile=r.readToUint8())}))}},{key:"av01",value:function(t){return fr(t,!1,(function(t,r,n){var i=dr(t,r),s=r.subarray(i);n+=i,t.av1C=e.av1C(e.findBox(s,["av1C"],n)[0]),t.colr=e.colr(e.findBox(s,["colr"],n)[0])}))}},{key:"av1C",value:function(e){return fr(e,!1,(function(t,r){t.data=e.data;var n,i=or.fromUint8(r),s=ur.fromByte(i,4);t.marker=s.read(1),t.version=s.read(7),t.seqProfile=s.read(3),t.seqLevelIdx0=s.read(5),t.seqTier0=s.read(1),t.highBitdepth=s.read(1),t.twelveBit=s.read(1),t.monochrome=s.read(1),t.chromaSubsamplingX=s.read(1),t.chromaSubsamplingY=s.read(1),t.chromaSamplePosition=s.read(2),t.reserved=s.read(3),t.initialPresentationDelayPresent=s.read(1),t.initialPresentationDelayPresent?t.initialPresentationDelayMinusOne=s.read(4):t.initialPresentationDelayMinusOne=0,t.configOBUs=i.readToUint8(),2===t.seqLevelIdx0&&1===t.highBitdepth?n=1===t.twelveBit?"12":"10":t.seqProfile<=2&&(n=1===t.highBitdepth?"10":"08"),t.codec=["av01",t.seqProfile,(t.seqLevelIdx0<10?"0"+t.seqLevelIdx0:t.seqLevelIdx0)+(t.seqTier0?"H":"M"),n].join(".")}))}},{key:"avc1",value:function(t){return fr(t,!1,(function(t,r,n){var i=dr(t,r),s=r.subarray(i);n+=i,t.avcC=e.avcC(e.findBox(s,["avcC"],n)[0]),t.pasp=e.pasp(e.findBox(s,["pasp"],n)[0])}))}},{key:"avcC",value:function(e){return fr(e,!1,(function(t,r){t.data=e.data,t.configurationVersion=r[0],t.AVCProfileIndication=r[1],t.profileCompatibility=r[2],t.AVCLevelIndication=r[3],t.codec=Rt([r[1],r[2],r[3]]),t.lengthSizeMinusOne=3&r[4],t.spsLength=31&r[5],t.sps=[];for(var n=6,i=0;i<t.spsLength;i++){var s=At(r,n);n+=2,t.sps.push(r.subarray(n,n+s)),n+=s}t.ppsLength=r[n],n+=1,t.pps=[];for(var a=0;a<t.ppsLength;a++){var o=At(r,n);n+=2,t.pps.push(r.subarray(n,n+=o)),n+=o}}))}},{key:"hvc1",value:function(t){return fr(t,!1,(function(t,r,n){var i=dr(t,r),s=r.subarray(i);n+=i,t.hvcC=e.hvcC(e.findBox(s,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(s,["pasp"],n)[0])}))}},{key:"hvcC",value:function(e){return fr(e,!1,(function(t,r){t.data=e.data,t.codec="hev1.1.6.L93.B0",t.configurationVersion=r[0];var n=r[1];t.generalProfileSpace=n>>6,t.generalTierFlag=(32&n)>>5,t.generalProfileIdc=31&n,t.generalProfileCompatibility=Ct(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=At(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var i=23,s=0,a=0,o=0,u=0;u<t.numOfArrays;u++){s=63&r[i],a=At(r,i+1),i+=3;for(var c,l=[],d=0;d<a;d++)o=At(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===s)(c=t.vps).push.apply(c,l);else if(33===s){var h;(h=t.sps).push.apply(h,l)}else if(34===s){var f;(f=t.pps).push.apply(f,l)}}}))}},{key:"pasp",value:function(e){return fr(e,!1,(function(e,t){e.hSpacing=Ct(t),e.vSpacing=Ct(t,4)}))}},{key:"mp4a",value:function(t){return fr(t,!1,(function(t,r,n){var i=hr(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return fr(e,!0,(function(e,t){e.codec="mp4a.";for(var r=0,n=0,i=0,s=0;t.length;){for(s=t[r=0],n=t[r+1],r+=2;128&n;)i=(127&n)<<7,n=t[r],r+=1;if(i+=127&n,3===s)t=t.subarray(r+3);else{if(4!==s){if(5===s){var a=e.config=t.subarray(r,r+i),o=(248&a[0])>>3;return 31===o&&a.length>=2&&(o=32+((7&a[0])<<3)+((224&a[1])>>5)),e.objectType=o,e.codec+=o.toString(16),void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}return void("."===e.codec[e.codec.length-1]&&(e.codec=e.codec.substring(0,e.codec.length-1)))}e.codec+=(t[r].toString(16)+".").padStart(3,"0"),t=t.subarray(r+13)}}}))}},{key:"alaw",value:function(e){return fr(e,!1,(function(e,t){hr(e,t)}))}},{key:"stts",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push({count:Ct(t,i),delta:Ct(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return fr(e,!0,(function(e,t){var r=Ct(t),n=[],i=4;if(1===e.version)for(var s=0;s<r;s++)n.push({count:Ct(t,i),offset:Ct(t,i+4)}),i+=8;else for(var a=0;a<r;a++)n.push({count:Ct(t,i),offset:-(1+~Ct(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push({firstChunk:Ct(t,i),samplesPerChunk:Ct(t,i+4),sampleDescriptionIndex:Ct(t,i+8)}),i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return fr(e,!0,(function(e,t){var r=Ct(t),n=Ct(t,4),i=[];if(!r)for(var s=8,a=0;a<n;a++)i.push(Ct(t,s)),s+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push(Ct(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"co64",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push(Lt(t,i)),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return fr(e,!0,(function(e,t){for(var r=Ct(t),n=[],i=4,s=0;s<r;s++)n.push(Ct(t,i)),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return fr(t,!1,(function(t,r,n){t.mfhd=e.mfhd(e.findBox(r,["mfhd"],n)[0]),t.traf=e.findBox(r,["traf"],n).map((function(t){return e.traf(t)}))}))}},{key:"mfhd",value:function(e){return fr(e,!0,(function(e,t){e.sequenceNumber=Ct(t)}))}},{key:"traf",value:function(t){return fr(t,!1,(function(t,r,n){t.tfhd=e.tfhd(e.findBox(r,["tfhd"],n)[0]),t.tfdt=e.tfdt(e.findBox(r,["tfdt"],n)[0]),t.trun=e.trun(e.findBox(r,["trun"],n)[0])}))}},{key:"trun",value:function(e){return fr(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,s=e.sampleCount=Ct(t),a=4;if(i>a&&1&n&&(e.dataOffset=-(1+~Ct(t,a)),a+=4),i>a&&4&n&&(e.firstSampleFlags=Ct(t,a),a+=4),e.samples=[],i>a)for(var o,u=0;u<s;u++)o={},256&n&&(o.duration=Ct(t,a),a+=4),512&n&&(o.size=Ct(t,a),a+=4),1024&n&&(o.flags=Ct(t,a),a+=4),2048&n&&(o.cts=r?-(1+~Ct(t,a+4)):Ct(t,a),a+=4),e.samples.push(o)}))}},{key:"tfdt",value:function(e){return fr(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=Lt(t):e.baseMediaDecodeTime=Ct(t)}))}},{key:"probe",value:function(t){return!!e.findBox(t,["ftyp"])}},{key:"parseSampleFlags",value:function(e){return{isLeading:(12&e[0])>>>2,dependsOn:3&e[0],isDependedOn:(192&e[1])>>>6,hasRedundancy:(48&e[1])>>>4,paddingValue:(14&e[1])>>>1,isNonSyncSample:1&e[1],degradationPriority:e[2]<<8|e[3]}}},{key:"moovToTrack",value:function(e,t,r){var n,i,s=e.trak;if(s&&s.length){var a=s.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),o=s.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(a&&t){var u,c,l,d,h,f,p,v=t,m=null===(u=a.tkhd)||void 0===u?void 0:u.trackId;null!=m&&(v.id=a.tkhd.trackId),v.tkhdDuration=a.tkhd.duration,v.mvhdDurtion=e.mvhd.duration,v.mvhdTimecale=e.mvhd.timescale,v.timescale=v.formatTimescale=a.mdia.mdhd.timescale,v.duration=a.mdia.mdhd.duration||v.mvhdDurtion/v.mvhdTimecale*v.timescale,v.rotation=a.tkhd.rotation,v.matrix=a.tkhd.matrix;var y,_,g,b,k,S,E,x,w=a.mdia.minf.stbl.stsd.entries[0];if(v.width=w.width,v.height=w.height,w.pasp&&(v.sarRatio=[w.pasp.hSpacing,w.pasp.vSpacing]),w.av1C)v.codecType=Qe,v.codec=w.av1C.codec,v.av1C=w.av1C.data,v.colr=w.colr.data;else if(w.hvcC)v.codecType=Ze,v.codec=w.hvcC.codec,v.vps=w.hvcC.vps,v.sps=w.hvcC.sps,v.pps=w.hvcC.pps,v.hvcC=w.hvcC.data;else{if(!w.avcC)throw new Error("unknown video stsd entry");v.codec=w.avcC.codec,v.sps=w.avcC.sps,v.pps=w.avcC.pps}if(v.present=!0,v.ext={},v.ext.stss=null===(c=a.mdia)||void 0===c||null===(l=c.minf)||void 0===l||null===(d=l.stbl)||void 0===d?void 0:d.stss,v.ext.ctts=null===(h=a.mdia)||void 0===h||null===(f=h.minf)||void 0===f||null===(p=f.stbl)||void 0===p?void 0:p.ctts,w&&"encv"===w.type)v.isVideoEncryption=!0,w.default_KID=null===(y=w.sinf)||void 0===y||null===(_=y.schi)||void 0===_?void 0:_.tenc.default_KID,w.default_IsEncrypted=null===(g=w.sinf)||void 0===g||null===(b=g.schi)||void 0===b?void 0:b.tenc.default_IsEncrypted,w.default_IV_size=null===(k=w.sinf)||void 0===k||null===(S=k.schi)||void 0===S?void 0:S.tenc.default_IV_size,v.videoSenc=a.mdia.minf.stbl.senc&&a.mdia.minf.stbl.senc.samples,w.data_format=null===(E=w.sinf)||void 0===E||null===(x=E.frma)||void 0===x?void 0:x.data_format,v.useEME=e.useEME,v.kidValue=e.kidValue,v.pssh=e.pssh,v.encv=w}if(o&&r){var T,D,A,C,L,R,O,P,I,j=r,B=null===(T=o.tkhd)||void 0===T?void 0:T.trackId;null!=B&&(j.id=o.tkhd.trackId),j.tkhdDuration=o.tkhd.duration,j.mvhdDurtion=e.mvhd.duration,j.mvhdTimecale=e.mvhd.timescale,j.timescale=j.formatTimescale=o.mdia.mdhd.timescale,j.duration=o.mdia.mdhd.duration||j.mvhdDurtion/j.mvhdTimecale*j.timescale;var M,U,N,F,V,z,G,q,H=o.mdia.minf.stbl.stsd.entries[0];switch(j.sampleSize=H.sampleSize,j.sampleRate=H.sampleRate,j.channelCount=H.channelCount,j.present=!0,H.type){case"alaw":j.codecType=j.codec=et,j.sampleRate=8e3;break;case"ulaw":j.codecType=j.codec=tt,j.sampleRate=8e3;break;default:j.sampleDuration=It.getFrameDuration(j.sampleRate,j.timescale),j.sampleRateIndex=It.getRateIndexByRate(j.sampleRate),j.objectType=(null===(n=H.esds)||void 0===n?void 0:n.objectType)||2,H.esds&&(j.config=Array.from(H.esds.config)),j.codec=(null===(i=H.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}if(j.sampleDuration=It.getFrameDuration(j.sampleRate,j.timescale),j.objectType=(null===(D=H.esds)||void 0===D?void 0:D.objectType)||2,H.esds&&(H.esds.config?j.config=Array.from(H.esds.config):console.warn("esds config is null")),j.codec=(null===(A=H.esds)||void 0===A?void 0:A.codec)||"mp4a.40.2",j.sampleRateIndex=It.getRateIndexByRate(j.sampleRate),j.ext={},j.ext.stss=null===(C=o.mdia)||void 0===C||null===(L=C.minf)||void 0===L||null===(R=L.stbl)||void 0===R?void 0:R.stss,j.ext.ctts=null===(O=o.mdia)||void 0===O||null===(P=O.minf)||void 0===P||null===(I=P.stbl)||void 0===I?void 0:I.ctts,j.present=!0,H&&"enca"===H.type)j.isAudioEncryption=!0,H.data_format=null===(M=H.sinf)||void 0===M||null===(U=M.frma)||void 0===U?void 0:U.data_format,H.default_KID=null===(N=H.sinf)||void 0===N||null===(F=N.schi)||void 0===F?void 0:F.tenc.default_KID,H.default_IsEncrypted=null===(V=H.sinf)||void 0===V||null===(z=V.schi)||void 0===z?void 0:z.tenc.default_IsEncrypted,H.default_IV_size=null===(G=H.sinf)||void 0===G||null===(q=G.schi)||void 0===q?void 0:q.tenc.default_IV_size,j.audioSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,j.useEME=e.useEME,j.kidValue=e.kidValue,j.enca=H}if(r&&(r.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!r&&r.isAudioEncryption),null!=t&&t.encv||null!=r&&r.enca){var K,Y,W=null==t||null===(K=t.encv)||void 0===K?void 0:K.default_KID,X=null==r||null===(Y=r.enca)||void 0===Y?void 0:Y.default_KID,Q=W||X?(W||X).join(""):null;t&&(t.kid=Q),r&&(r.kid=Q)}return t&&(t.flags=3841),r&&(r.flags=1793),{videoTrack:t,audioTrack:r}}}},{key:"evaluateDefaultDuration",value:function(e,t,r){var n,i=null==t||null===(n=t.samples)||void 0===n?void 0:n.length;return i?1024*i/t.timescale*e.timescale/r:1024}},{key:"moofToSamples",value:function(t,r,n){var i={};return t.mfhd&&(r&&(r.sequenceNumber=t.mfhd.sequenceNumber),n&&(n.sequenceNumber=t.mfhd.sequenceNumber)),t.traf.forEach((function(t){var s=t.tfhd,a=t.tfdt,o=t.trun;if(s&&o){a&&(r&&r.id===s.trackId&&(r.baseMediaDecodeTime=a.baseMediaDecodeTime),n&&n.id===s.trackId&&(n.baseMediaDecodeTime=a.baseMediaDecodeTime));var u=s.defaultSampleSize||0,c=s.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,h=-1;if(!o.samples.length&&o.sampleCount){i[s.trackId]=[];for(var f=0;f<o.sampleCount;f++)i[s.trackId].push({offset:l,dts:d,duration:c,size:u}),d+=c,l+=u}else i[s.trackId]=o.samples.map((function(e,t){return(e={offset:l,dts:d,pts:d+(e.cts||0),duration:e.duration||c,size:e.size||u,gopId:h,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(h++,e.gopId=h),d+=e.duration,l+=e.size,e}))}})),i}},{key:"moovToSamples",value:function(e){var t=e.trak;if(t&&t.length){var r=t.find((function(e){var t,r;return"vide"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)})),n=t.find((function(e){var t,r;return"soun"===(null===(t=e.mdia)||void 0===t||null===(r=t.hdlr)||void 0===r?void 0:r.handlerType)}));if(r||n){var i,s;if(r){var a,o,u=null===(a=r.mdia)||void 0===a||null===(o=a.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,h=u.stco,f=u.stss,p=u.ctts;if(!(c&&l&&d&&h&&f))return;i=lr(c,l,d,h,p,f)}if(n){var v,m,y,_=null===(v=n.mdia)||void 0===v||null===(m=v.minf)||void 0===m?void 0:m.stbl;if(!_)return;var g=null===(y=n.mdia.mdhd)||void 0===y?void 0:y.timescale,b=_.stts,k=_.stsc,S=_.stsz,E=_.stco;if(!(g&&b&&k&&S&&E))return;s=lr(b,k,S,E)}return{videoSamples:i,audioSamples:s}}}}}]),e}();function lr(e,t,r,n,i,s){var a,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,h=n.entries,f=r.entrySizes,p=null==s?void 0:s.entries;p&&(a={},p.forEach((function(e){a[e-1]=!0}))),l&&(o=[],l.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)o.push(r)})));var v=-1,m=0,y=0,_=0,g=0,b=0,k=d[0].samplesPerChunk,S=d[1]?d[1].firstChunk-1:1/0;return e.entries.forEach((function(e){for(var t=e.count,n=e.delta,i=0;i<t;i++)u={dts:m,duration:n,size:f[y]||r.sampleSize,offset:h[_]+b,index:y},p&&(u.keyframe=a[y],u.keyframe&&v++,u.gopId=v),o&&y<o.length&&(u.pts=u.dts+o[y]),c.push(u),m+=n,++y<k?b+=u.size:(_++,b=0,_>=S&&(g++,S=d[g+1]?d[g+1].firstChunk-1:1/0),k+=d[g].samplesPerChunk)})),c}function dr(e,t){return e.dataReferenceIndex=At(t,6),e.width=At(t,24),e.height=At(t,26),e.horizresolution=Ct(t,28),e.vertresolution=Ct(t,32),e.frameCount=At(t,40),e.depth=At(t,74),78}function hr(e,t){return e.dataReferenceIndex=At(t,6),e.channelCount=At(t,16),e.sampleSize=At(t,18),e.sampleRate=Ct(t,24)/65536,28}function fr(e,t,r){if(e){if(e.size!==e.data.length)throw new Error("box ".concat(e.type," size !== data.length"));var n={start:e.start,size:e.size,headerSize:e.headerSize,type:e.type};return t&&(n.version=e.data[e.headerSize],n.flags=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<16)+(e[t+1]<<8)+(e[t+2]||0)}(e.data,e.headerSize+1),n.headerSize+=4),r(n,e.data.subarray(n.headerSize),n.start+n.headerSize),n}}var pr=function(e,t,r){for(var n=String(r),i=t>>0,s=Math.ceil(i/n.length),a=[],o=String(e);s--;)a.push(n);return a.join("").substring(0,i-o.length)+o},vr=function(){for(var e=[],t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return r.forEach((function(t){e.push(pr(Number(t).toString(16),2,0))})),e[0]},mr=function(){function e(t,r,n){y(this,e),b(this,"__loadedMoofWraps",[]),b(this,"__lastRemainData",null),b(this,"__lastRemainDataStart",0),b(this,"__nextMoofStart",-1),this.videoTrack=t||new lt,this.audioTrack=r||new dt,this.metadataTrack=n||new yt}return g(e,[{key:"demuxPart",value:function(e,t,r){var n=this,i=this.videoTrack,s=this.audioTrack,a=i.exist(),o=s.exist(),u=/av01/.test(i.codec);i.samples=[],s.samples=[];var c=e,l=t;if(this.__lastRemainData){var d=this.__lastRemainDataStart+this.__lastRemainData.byteLength;if(t<=d&&t>this.__lastRemainDataStart&&t+e.byteLength>d){var h=e.subarray(this.__lastRemainData.byteLength+this.__lastRemainDataStart-t);c=Tt(this.__lastRemainData,h),l=this.__lastRemainDataStart,this.__lastRemainData=null}else this.__lastRemainData=null,this.__lastRemainDataStart=0,this.__nextMoofStart=-1}if(!r){var f=cr.findBox(c,["moov"])[0];if(!f)throw new Error("cannot found moov box");r=cr.moov(f)}if(c){var p=l+c.byteLength;a||o||cr.moovToTrack(r,i,s);var v=[];this.__nextMoofStart<0?cr.findBox(c,["moof"],l).forEach((function(e){return v.push(e)})):this.__nextMoofStart>=l&&this.__nextMoofStart<=p-8&&cr.findBox(c.subarray(this.__nextMoofStart-l),["moof"],this.__nextMoofStart).forEach((function(e){return v.push(e)})),v.filter((function(e){return e.size<=e.data.length})).forEach((function(e){var t=cr.moof(e);n.__nextMoofStart=t.start+Math.max.apply(Math,I(t.traf.map((function(e){return e.trun.samples.reduce((function(e,t){return e+t.size}),e.trun.dataOffset||0)})))),n.__loadedMoofWraps.push({start:t.start,nextMoofStart:n.__nextMoofStart,moof:t}),n.__loadedMoofWraps.sort((function(e,t){return e.start-t.start}))}));var m,y=M(this.__loadedMoofWraps);try{var _=function(){var e=m.value;if(e.start>p||e.nextMoofStart<l)return"continue";var t,r=e.start,a=cr.moofToSamples(e.moof,i,s),o=i.baseMediaDecodeTime,d=s.baseMediaDecodeTime;Object.keys(a).forEach((function(e){i.id==e?a[e].some((function(e){var s=e.offset+=r;if(!(s<l)){if(s+e.size>p)return!0;var a=new ht((e.pts||e.dts)+o,e.dts+o);a.duration=e.duration,a.gopId=e.gopId,e.keyframe&&a.setToKeyframe();var d=c.subarray(s-l,s-l+e.size);if(a.data=d,!u)for(var h=0,f=d.length-1;h<f;)t=Ct(d,h),h+=4,a.units.push(d.subarray(h,h+t)),h+=t;n.__lastRemainDataStart=s+e.size,i.samples.push(a)}})):s.id==e&&a[e].some((function(e){var t=e.offset+r;if(!(t<l)){if(t+e.size>p)return!0;var i=c.subarray(t-l,t-l+e.size);s.samples.push(new ft(e.dts+d,i,e.duration)),n.__lastRemainDataStart=t+e.size}}))}))};for(y.s();!(m=y.n()).done;)_()}catch(g){y.e(g)}finally{y.f()}}return this.__lastRemainDataStart>l&&this.__lastRemainDataStart<c.byteLength+l?this.__lastRemainData=c.subarray(this.__lastRemainDataStart-l):(this.__lastRemainData=c,this.__lastRemainDataStart=l),i.samples.length&&(i.baseMediaDecodeTime=i.samples[0].pts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts),{videoTrack:i,audioTrack:s,metadataTrack:this.metadataTrack}}},{key:"demux",value:function(e,t){var r=this.videoTrack,n=this.audioTrack,i=r.exist(),s=n.exist();if(r.samples=[],n.samples=[],t){if(!s){var a=cr.findBox(t,["moov"])[0];if(!a)throw new Error("cannot found moov box");cr.moovToTrack(cr.moov(a),null,n)}var o=cr.findBox(t,["moof"])[0];if(o){var u=cr.moofToSamples(cr.moof(o),null,n)[n.id],c=n.baseMediaDecodeTime;if(u){var l=o.start;u.map((function(e){e.offset+=l;var r=t.subarray(e.offset,e.offset+e.size);n.samples.push(new ft(e.dts+c,r,e.duration))}))}}}if(e){if(!i&&!s){var d=cr.findBox(e,["moov"])[0];if(!d)throw new Error("cannot found moov box");cr.moovToTrack(cr.moov(d),r,n)}var h=cr.findBox(e,["moof"])[0];if(h){var f,p=cr.moofToSamples(cr.moof(h),r,n),v=r.baseMediaDecodeTime,m=n.baseMediaDecodeTime,y=h.start;Object.keys(p).forEach((function(t){r.id==t?p[t].map((function(t){t.offset+=y;var n=new ht((t.pts||t.dts)+v,t.dts+v);n.duration=t.duration,n.gopId=t.gopId,t.keyframe&&n.setToKeyframe();var i=e.subarray(t.offset,t.offset+t.size);n.data=i;for(var s=0,a=i.length-1;s<a;)f=Ct(i,s),s+=4,n.units.push(i.subarray(s,s+f)),s+=f;r.samples.push(n)})):n.id==t&&p[t].map((function(t){t.offset+=y;var r=e.subarray(t.offset,t.offset+t.size);n.samples.push(new ft(t.dts+m,r,t.duration))}))}))}}return{videoTrack:r,audioTrack:n,metadataTrack:this.metadataTrack}}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset(),this.metadataTrack.reset()}}],[{key:"probe",value:function(e){return cr.probe(e)}}]),e}();function yr(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];n.forEach((function(e){t+=e.length}));var s=new e(t),a=0;return n.forEach((function(e){s.set(e,a),a+=e.length})),s}var _r=function(){function e(){y(this,e),this.buffer=new Uint8Array(0)}return g(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];r.forEach((function(t){t?e.buffer=yr(Uint8Array,e.buffer,t):window.console.warn(t)}))}}],[{key:"writeUint16",value:function(e){return new Uint8Array([e>>8&255,255&e])}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>24,e>>16&255,e>>8&255,255&e])}}]),e}(),gr=Math.pow(2,32)-1,br=function(){function e(){y(this,e)}return g(e,null,[{key:"box",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=8+(r=r.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),s=new Uint8Array(i);s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4);var a=8;return r.forEach((function(e){s.set(e,a),a+=e.byteLength})),s}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===Ye&&e.codecType===Ze}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return Tt(e.ftyp(t),e.moov(t))}},{key:"pssh",value:function(t){var r=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],Ot(t.kid),[0,0,0,0]));return e.box(e.types.pssh,r)}},{key:"moov",value:function(t){if(t[0].useEME&&(t[0].encv||t[0].enca)){t[0].pssh||(t[0].pssh={kid:t[0].kid});var r=this.pssh(t[0].pssh);return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale),e.mvex(t)].concat(I(t.map((function(t){return e.trak(t)}))),[r]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(I(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,n=e.box(e.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,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 n}},{key:"trak",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.tkhdDuration||0,t.width,t.height),e.mdia(t))}},{key:"tkhd",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,0,0,0,0,0,0,0,0,1,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,n>>8&255,255&n,0,0,i>>8&255,255&i,0,0]));return s}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9e4,n=e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,t>>24&255,t>>16&255,t>>8&255,255&t,85,196,0,0]));return n}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"minf",value:function(t){return e.box(e.types.minf,t.type===Ye?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){var r=[];return t&&t.ext&&t.ext.stss&&r.push(e.stss(t.ext.stss.entries)),e.box(e.types.stbl,e.stsd(t),e.STTS,r[0],e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var r;return r="audio"===t.type?t.useEME&&t.enca?e.enca(t):t.codecType===rt?e.opus(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):t.av1C?e.av01(t):e.avc1hev1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),r)}},{key:"enca",value:function(t){var r=t.enca.channelCount,n=t.enca.sampleRate,i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,r,0,16,0,0,0,0,n>>8&255,255&n,0,0]),s=e.esds(t.config),a=e.sinf(t.enca);return e.box(e.types.enca,i,s,a)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],s=t.pps.length>0?t.pps[0]:[],a=t.width,o=t.height,u=t.sarRatio[0],c=t.sarRatio[1],l=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,a>>8&255,255&a,o>>8&255,255&o,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]),d=new Uint8Array((r=(n=[1,i[1],i[2],i[3],255,225,i.length>>>8&255,255&i.length]).concat.apply(n,I(i)).concat([1,s.length>>>8&255,255&s.length])).concat.apply(r,I(s))),h=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),f=e.sinf(t.encv),p=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c]);return e.box(e.types.encv,l,e.box(e.types.avcC,d),e.box(e.types.btrt,h),f,e.box(e.types.pasp,p))}},{key:"schi",value:function(t){var r=new Uint8Array([]),n=e.tenc(t);return e.box(e.types.schi,r,n)}},{key:"tenc",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(Ot(t.default_KID)));return e.box(e.types.tenc,r)}},{key:"sinf",value:function(t){var r=new Uint8Array([]),n=new Uint8Array([t.data_format.charCodeAt(0),t.data_format.charCodeAt(1),t.data_format.charCodeAt(2),t.data_format.charCodeAt(3)]),i=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),s=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),s)}},{key:"av01",value:function(t){return e.box(e.types.av01,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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),t.av1C,t.colr)}},{key:"avc1hev1",value:function(t){var r=t.codecType===Ze,n=r?e.types.hvc1:e.types.avc1,i=r?e.hvcC(t):e.avcC(t),s=[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,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,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,0,0,0,0,0,0,24,17,17]),i];return r?s.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&s.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(s))}},{key:"avcC",value:function(t){var r,n,i,s=[],a=[];return t.sps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,I(e))})),t.pps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,I(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,s[3],s[4],s[5],255,224|t.sps.length]).concat.apply(n,s).concat([t.pps.length])).concat.apply(r,a)))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,s=t.sps,a=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(s.length&&1)+(a.length&&1);n=[1,r.generalProfileSpace<<6|r.generalTierFlag<<5|r.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],r.generalLevelIdc,240,0,252,252|r.chromaFormatIdc,248|r.bitDepthLumaMinus8,248|r.bitDepthChromaMinus8,0,0,r.numTemporalLayers<<3|r.temporalIdNested<<2|3,c];var l=function(e){var t;n.push(e.length>>8,e.length),(t=n).push.apply(t,I(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),s.length&&(n.push(161,0,s.length),s.forEach(l)),a.length&&(n.push(162,0,a.length),a.forEach(l))}else n=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return e.box(e.types.hvcC,new Uint8Array(n))}},{key:"pasp",value:function(t){var r=P(t,2),n=r[0],i=r[1];return e.box(e.types.pasp,new Uint8Array([n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),t.config.length?e.esds(t.config):void 0)}},{key:"esds",value:function(t){var r=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+r,0,0,0,4,15+r,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([r]).concat(t).concat([6,1,2])))}},{key:"opus",value:function(t){var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.sampleRate>>8&255,255&t.sampleRate,0,0]),n=t.config.length?e.dOps(t):[];return e.box(e.types.Opus,r,n)}},{key:"dOps",value:function(t){if(t.config)return t.config[4]=t.sampleRate>>>24&255,t.config[5]=t.sampleRate>>>16&255,t.config[6]=t.sampleRate>>>8&255,t.config[7]=255&t.sampleRate,e.box(e.types.dOps,t.config)}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(I(t.map((function(t){return e.trex(t.id)})))))}},{key:"trex",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trex1",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]))}},{key:"trex2",value:function(t){return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]))}},{key:"moof",value:function(t){return e.box.apply(e,[e.types.moof,e.mfhd(t[0].samples?t[0].samples[0].gopId:0)].concat(I(t.map((function(t){return e.traf(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:"traf",value:function(t){var r=e.tfhd(t.id),n=e.tfdt(t,t.baseMediaDecodeTime),i=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){i+=8,e.subsamples&&e.subsamples.length&&(i+=2,i+=6*e.subsamples.length)})),t.videoSencLength=i,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var s=e.saiz(t),a=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,s,a,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),d=e.saio(t),h=e.senc(t),f=e.trun1(t);return e.box(e.types.traf,r,n,c,l,d,h,f)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var m=e.trun1(t);return e.box(e.types.traf,r,n,m)}var y=e.sbgp(),_=e.saiz(t),g=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,y,_,g,b,k)}var S=e.sdtp(t);return e.box(e.types.traf,r,n,S,e.trun(t.samples,S.byteLength+76))}},{key:"sdtp",value:function(t){var r=new _r;return t.samples.forEach((function(e){r.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))})),e.box(e.types.sdtp,this.extension(0,0),r.buffer)}},{key:"trun1",value:function(t){var r=new _r,n=_r.writeUint32(t.samples.length),i=null;if(t.isVideo){var s=t.videoSencLength;i=_r.writeUint32(16*t.samples.length+s+149),!t.isVideoEncryption&&t.isAudioEncryption&&(i=_r.writeUint32(16*t.samples.length+92))}else{var a=12*t.samples.length+124;t.isAudioEncryption&&(a=12*t.samples.length+8*t.audioSenc.length+177),i=_r.writeUint32(a)}return t.samples.forEach((function(e){r.write(_r.writeUint32(e.duration)),r.write(_r.writeUint32(e.size)),r.write(_r.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(_r.writeUint32(e.cts?e.cts:0))})),e.box(e.types.trun,this.extension(0,t.flags),n,i,r.buffer)}},{key:"senc",value:function(t){var r=new _r,n=t.samples.length,i=t.isVideo?16:8,s=t.isVideo?2:0,a=[],o=0;return t.isVideo?(a=t.videoSenc,o=t.videoSencLength):a=t.audioSenc,o=o||i*n,r.write(_r.writeUint32(16+o),e.types.senc,this.extension(0,s)),r.write(_r.writeUint32(n)),a.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)r.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(r.write(_r.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(_r.writeUint16(e.BytesOfClearData)),r.write(_r.writeUint32(e.BytesOfProtectedData))})))})),r.buffer}},{key:"saio",value:function(t){var r=12*t.samples.length+141;!t.isVideo&&t.isAudioEncryption&&(r=149);var n=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saio,n)}},{key:"saiz",value:function(t){var r=t.samples.length,n=new Uint8Array([0,0,0,0,16,r>>24&255,r>>16&255,r>>8&255,255&r]);return e.box(e.types.saiz,n)}},{key:"sbgp",value:function(){var t=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return e.box(e.types.sbgp,this.extension(0,0),t)}},{key:"extension",value:function(e,t){return new Uint8Array([e,t>>16&255,t>>8&255,255&t])}},{key:"tfhd",value:function(t){return e.box(e.types.tfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"tfdt",value:function(t,r){var n=Math.floor(r/(gr+1)),i=Math.floor(r%(gr+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])):e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var s=new Uint8Array(i);s.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0);for(var a=0;a<n;a++){var o=t[a],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,h=o.cts,f=void 0===h?0:h;s.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,c>>>24&255,c>>>16&255,c>>>8&255,255&c,d.isLeading<<2|(null===d.dependsOn||void 0===d.dependsOn?1:d.dependsOn),d.isDependedOn<<6|d.hasRedundancy<<4|d.paddingValue<<1|(null===d.isNonSyncSample||void 0===d.isNonSyncSample?1:d.isNonSyncSample),61440&d.degradationPriority,15&d.degradationPriority,f>>>24&255,f>>>16&255,f>>>8&255,255&f],12+16*a)}return e.box(e.types.trun,s)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(I(t.map((function(t){return e.trackMP4(t)})))))}},{key:"trackMP4",value:function(t){return e.box(e.types.trak,e.tkhd(t.id,t.duration,t.width,t.height),e.mdiaMP4(t))}},{key:"mdiaMP4",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minfMP4(t))}},{key:"minfMP4",value:function(t){return e.box(e.types.minf,t.type===Ye?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var r=t.ext,n=[e.stsd(t),e.stts(r.stts),e.stsc(r.stsc),e.stsz(r.stsz),e.stco(r.stco)];return r.stss.length&&n.push(e.stss(r.stss)),r.ctts.length&&n.push(e.ctts(r.ctts)),e.box.apply(e,[e.types.stbl].concat(n))}},{key:"stts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach((function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8})),e.box(e.types.stts,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsc",value:function(t){var r=t.length,n=new Uint8Array(12*r),i=0;return t.forEach((function(e){var t=e.firstChunk,r=e.samplesPerChunk,s=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s],i),i+=12})),e.box(e.types.stsc,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stsz",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stsz,Tt(new Uint8Array([0,0,0,0,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stco",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stco,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"stss",value:function(t){var r=t.length,n=new Uint8Array(4*r),i=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],i),i+=4})),e.box(e.types.stss,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"ctts",value:function(t){var r=t.length,n=new Uint8Array(8*r),i=0;return t.forEach((function(e){var t=e.value,r=e.count;n.set([r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t],i),i+=8})),e.box(e.types.ctts,Tt(new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r]),n))}},{key:"styp",value:function(){return e.box(e.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(t){var r=t.timescale,n=t.samples[0].duration,i=n*t.samples.length,s=t.samples[0].sampleOffset*n,a=8;t.samples.forEach((function(e){a+=e.size}));var o=0;if(t.isVideo){var u,c=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){c+=8,e.subsamples&&e.subsamples.length&&(c+=2,c+=6*e.subsamples.length)})),t.videoSencLength=c,o=a+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=a+16*t.samples.length+84)}else o=a+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=a+169+12*t.samples.length+8*t.audioSenc.length);var l=new Uint8Array([0,0,0,0,0,0,0,255&t.id,r>>24&255,r>>16&255,r>>8&255,255&r,s>>24&255,s>>16&255,s>>8&255,255&s,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,i>>24&255,i>>16&255,i>>8&255,255&i,144,0,0,0]);return e.box(e.types.sidx,l)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();b(br,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),b(br,"HDLR_TYPES",{video: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]),audio: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])}),b(br,"FTYPAVC1",br.box(br.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),b(br,"FTYPHEV1",br.box(br.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),b(br,"DINF",br.box(br.types.dinf,br.box(br.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),b(br,"VMHD",br.box(br.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),b(br,"SMHD",br.box(br.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),b(br,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),b(br,"STTS",br.box(br.types.stts,br.StblTable)),b(br,"STSC",br.box(br.types.stsc,br.StblTable)),b(br,"STSZ",br.box(br.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),b(br,"STCO",br.box(br.types.stco,br.StblTable));var kr=function(){function e(t,r){y(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return g(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).debug.apply(t,[this._prefix].concat(n))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).log.apply(t,[this._prefix].concat(n))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).warn.apply(t,[this._prefix].concat(n))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];(t=console).error.apply(t,[this._prefix].concat(n))}}},{key:"table",value:function(){var t;e.disabled||(console.group(this._prefix),(t=console).table.apply(t,arguments),console.groupEnd())}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();b(kr,"disabled",!0);for(var Sr=function(){function e(t,r,n){y(this,e),this.videoTrack=t,this.audioTrack=r;var i=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=i&&Number(i[1])<50,this.log=new kr("FMP4Remuxer",!n||!n.openLog||!n.openLog)}return g(e,[{key:"remux",value:function(){var e,t,r,n,i,s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,c=o.exist(),l=u.exist(),d=[];return s&&(a&&a.initMerge?(c&&d.push(this.videoTrack),l&&d.push(this.audioTrack),r=br.initSegment(d)):(c&&(e=br.initSegment([this.videoTrack])),l&&(t=br.initSegment([this.audioTrack])))),c&&o.hasSample()&&(n=this._remuxVideo()),l&&u.hasSample()&&(i=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:r,videoInitSegment:e,audioInitSegment:t,videoSegment:n,audioSegment:i}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,r=/av01/.test(e.codec),n=0;r?t.forEach((function(e){n+=e.data.byteLength})):t.forEach((function(e){n+=e.units.reduce((function(e,t){return e+t.byteLength}),0),n+=4*e.units.length}));var i=new Uint8Array(n);if(r)for(var s,a=0,o=t.length,u=0;a<o;a++)s=t[a],i.set(s.data,u),s.size=s.data.byteLength,u+=s.size;else for(var c,l=new DataView(i.buffer),d=function(e,r){r=t[h];var n=0;r.units.forEach((function(t){l.setUint32(e,t.byteLength),e+=4,i.set(t,e),e+=t.byteLength,n+=4+t.byteLength})),r.size=n,p=e,c=r},h=0,f=t.length,p=0;h<f;h++)d(p,c);var v=br.mdat(i);return Tt(br.moof([e]),v)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,r){return t.set(r.data,e),e+r.size}),0);var r=br.mdat(t);return Tt(br.moof([e]),r)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),Er=function(){function e(){y(this,e)}return g(e,[{key:"mixIn",value:function(e){return Object.assign(this,e)}},{key:"clone",value:function(){var e=new this.constructor;return Object.assign(e,this),e}}],[{key:"create",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return w(this,t)}}]),e}(),xr=function(e){k(r,e);var t=L(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4*n.length;y(this,r),e=t.call(this);var s=n;if(s instanceof ArrayBuffer&&(s=new Uint8Array(s)),(s instanceof Int8Array||s instanceof Uint8ClampedArray||s instanceof Int16Array||s instanceof Uint16Array||s instanceof Int32Array||s instanceof Uint32Array||s instanceof Float32Array||s instanceof Float64Array)&&(s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength)),s instanceof Uint8Array){for(var a=s.byteLength,o=[],u=0;u<a;u+=1)o[u>>>2]|=s[u]<<24-u%4*8;e.words=o,e.sigBytes=a}else e.words=n,e.sigBytes=i;return e}return g(r,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:wr;return e.stringify(this)}},{key:"concat",value:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s+=1){var a=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=a<<24-(n+s)%4*8}else for(var o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this}},{key:"clamp",value:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=Math.ceil(t/4)}},{key:"clone",value:function(){var e=O(S(r.prototype),"clone",this).call(this);return e.words=this.words.slice(0),e}}],[{key:"random",value:function(e){for(var t,n=[],i=function(e){var t=e,r=987654321,n=4294967295;return function(){var e=((r=36969*(65535&r)+(r>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return e/=4294967296,(e+=.5)*(Math.random()>.5?1:-1)}},s=0;s<e;s+=4){var a=i(4294967296*(t||Math.random()));t=987654071*a(),n.push(4294967296*a()|0)}return new r(n,e)}}]),r}(Er),wr={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=1){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new xr(r,t/2)}},Tr=function(e){for(var t=e.length,r=[],n=0;n<t;n+=1)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new xr(r,t)},Dr=function(e){return Tr(unescape(encodeURIComponent(e)))},Ar=function(e){k(r,e);var t=L(r);function r(){var e;return y(this,r),(e=t.call(this))._minBufferSize=0,e}return g(r,[{key:"reset",value:function(){this._data=new xr,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=Dr(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes}},{key:"_process",value:function(e){var t,r=this._data,n=this.blockSize,i=r.words,s=r.sigBytes,a=s/(4*n),o=(a=e?Math.ceil(a):Math.max((0|a)-this._minBufferSize,0))*n,u=Math.min(4*o,s);if(o){for(var c=0;c<o;c+=n)this._doProcessBlock(i,c);t=i.splice(0,o),r.sigBytes-=u}return new xr(t,u)}},{key:"clone",value:function(){var e=O(S(r.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),r}(Er),Cr=function(e){k(r,e);var t=L(r);function r(e){var n;return y(this,r),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new Er,e),n.reset(),n}return g(r,[{key:"reset",value:function(){O(S(r.prototype),"reset",this).call(this),this._doReset()}},{key:"update",value:function(e){return this._append(e),this._process(),this}},{key:"finalize",value:function(e){return e&&this._append(e),this._doFinalize()}}],[{key:"_createHelper",value:function(e){return function(t,r){return new e(r).finalize(t)}}},{key:"_createHmacHelper",value:function(e){return function(t,r){return new Lr(e,r).finalize(t)}}}]),r}(Ar),Lr=function(e){k(r,e);var t=L(r);function r(e,n){var i;y(this,r),i=t.call(this);var s=new e;i._hasher=s;var a=n;"string"==typeof a&&(a=Dr(a));var o=s.blockSize,u=4*o;a.sigBytes>u&&(a=s.finalize(n)),a.clamp();var c=a.clone();i._oKey=c;var l=a.clone();i._iKey=l;for(var d=c.words,h=l.words,f=0;f<o;f+=1)d[f]^=1549556828,h[f]^=909522486;return c.sigBytes=u,l.sigBytes=u,i.reset(),i}return g(r,[{key:"reset",value:function(){var e=this._hasher;e.reset(),e.update(this._iKey)}},{key:"update",value:function(e){return this._hasher.update(e),this}},{key:"finalize",value:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}}]),r}(Er),Rr={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],s=0;s<r;s+=3)for(var a=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,o=0;o<4&&s+.75*o<r;o+=1)i.push(n.charAt(a>>>6*(3-o)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){this._reverseMap=[],n=this._reverseMap;for(var i=0;i<r.length;i+=1)n[r.charCodeAt(i)]=i}var s=r.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],i=0,s=0;s<t;s+=1)if(s%4){var a=r[e.charCodeAt(s-1)]<<s%4*2|r[e.charCodeAt(s)]>>>6-s%4*2;n[i>>>2]|=a<<24-i%4*8,i+=1}return xr.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},Or=[],Pr=0;Pr<64;Pr+=1)Or[Pr]=4294967296*Math.abs(Math.sin(Pr+1))|0;var Ir=function(e,t,r,n,i,s,a){var o=e+(t&r|~t&n)+i+a;return(o<<s|o>>>32-s)+t},jr=function(e,t,r,n,i,s,a){var o=e+(t&n|r&~n)+i+a;return(o<<s|o>>>32-s)+t},Br=function(e,t,r,n,i,s,a){var o=e+(t^r^n)+i+a;return(o<<s|o>>>32-s)+t},Mr=function(e,t,r,n,i,s,a){var o=e+(r^(t|~n))+i+a;return(o<<s|o>>>32-s)+t},Ur=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"_doReset",value:function(){this._hash=new xr([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var r=e,n=0;n<16;n+=1){var i=t+n,s=e[i];r[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var a=this._hash.words,o=r[t+0],u=r[t+1],c=r[t+2],l=r[t+3],d=r[t+4],h=r[t+5],f=r[t+6],p=r[t+7],v=r[t+8],m=r[t+9],y=r[t+10],_=r[t+11],g=r[t+12],b=r[t+13],k=r[t+14],S=r[t+15],E=a[0],x=a[1],w=a[2],T=a[3];E=Ir(E,x,w,T,o,7,Or[0]),T=Ir(T,E,x,w,u,12,Or[1]),w=Ir(w,T,E,x,c,17,Or[2]),x=Ir(x,w,T,E,l,22,Or[3]),E=Ir(E,x,w,T,d,7,Or[4]),T=Ir(T,E,x,w,h,12,Or[5]),w=Ir(w,T,E,x,f,17,Or[6]),x=Ir(x,w,T,E,p,22,Or[7]),E=Ir(E,x,w,T,v,7,Or[8]),T=Ir(T,E,x,w,m,12,Or[9]),w=Ir(w,T,E,x,y,17,Or[10]),x=Ir(x,w,T,E,_,22,Or[11]),E=Ir(E,x,w,T,g,7,Or[12]),T=Ir(T,E,x,w,b,12,Or[13]),w=Ir(w,T,E,x,k,17,Or[14]),x=Ir(x,w,T,E,S,22,Or[15]),E=jr(E,x,w,T,u,5,Or[16]),T=jr(T,E,x,w,f,9,Or[17]),w=jr(w,T,E,x,_,14,Or[18]),x=jr(x,w,T,E,o,20,Or[19]),E=jr(E,x,w,T,h,5,Or[20]),T=jr(T,E,x,w,y,9,Or[21]),w=jr(w,T,E,x,S,14,Or[22]),x=jr(x,w,T,E,d,20,Or[23]),E=jr(E,x,w,T,m,5,Or[24]),T=jr(T,E,x,w,k,9,Or[25]),w=jr(w,T,E,x,l,14,Or[26]),x=jr(x,w,T,E,v,20,Or[27]),E=jr(E,x,w,T,b,5,Or[28]),T=jr(T,E,x,w,c,9,Or[29]),w=jr(w,T,E,x,p,14,Or[30]),x=jr(x,w,T,E,g,20,Or[31]),E=Br(E,x,w,T,h,4,Or[32]),T=Br(T,E,x,w,v,11,Or[33]),w=Br(w,T,E,x,_,16,Or[34]),x=Br(x,w,T,E,k,23,Or[35]),E=Br(E,x,w,T,u,4,Or[36]),T=Br(T,E,x,w,d,11,Or[37]),w=Br(w,T,E,x,p,16,Or[38]),x=Br(x,w,T,E,y,23,Or[39]),E=Br(E,x,w,T,b,4,Or[40]),T=Br(T,E,x,w,o,11,Or[41]),w=Br(w,T,E,x,l,16,Or[42]),x=Br(x,w,T,E,f,23,Or[43]),E=Br(E,x,w,T,m,4,Or[44]),T=Br(T,E,x,w,g,11,Or[45]),w=Br(w,T,E,x,S,16,Or[46]),x=Br(x,w,T,E,c,23,Or[47]),E=Mr(E,x,w,T,o,6,Or[48]),T=Mr(T,E,x,w,p,10,Or[49]),w=Mr(w,T,E,x,k,15,Or[50]),x=Mr(x,w,T,E,h,21,Or[51]),E=Mr(E,x,w,T,g,6,Or[52]),T=Mr(T,E,x,w,l,10,Or[53]),w=Mr(w,T,E,x,y,15,Or[54]),x=Mr(x,w,T,E,u,21,Or[55]),E=Mr(E,x,w,T,v,6,Or[56]),T=Mr(T,E,x,w,S,10,Or[57]),w=Mr(w,T,E,x,f,15,Or[58]),x=Mr(x,w,T,E,b,21,Or[59]),E=Mr(E,x,w,T,d,6,Or[60]),T=Mr(T,E,x,w,_,10,Or[61]),w=Mr(w,T,E,x,c,15,Or[62]),x=Mr(x,w,T,E,m,21,Or[63]),a[0]=a[0]+E|0,a[1]=a[1]+x|0,a[2]=a[2]+w|0,a[3]=a[3]+T|0}},{key:"_doFinalize",value:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32;var i=Math.floor(r/4294967296),s=r;t[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(t.length+1),this._process();for(var a=this._hash,o=a.words,u=0;u<4;u+=1){var c=o[u];o[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return a}},{key:"clone",value:function(){var e=O(S(r.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),r}(Cr);Cr._createHelper(Ur),Cr._createHmacHelper(Ur);var Nr=function(e){k(r,e);var t=L(r);function r(e){var n;return y(this,r),(n=t.call(this)).cfg=Object.assign(new Er,{keySize:4,hasher:Ur,iterations:1},e),n}return g(r,[{key:"compute",value:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),s=xr.create(),a=s.words,o=n.keySize,u=n.iterations;a.length<o;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var c=1;c<u;c+=1)r=i.finalize(r),i.reset();s.concat(r)}return s.sigBytes=4*o,s}}]),r}(Er),Fr=function(e){k(r,e);var t=L(r);function r(e,n,i){var s;return y(this,r),(s=t.call(this)).cfg=Object.assign(new Er,i),s._xformMode=e,s._key=n,s.reset(),s}return g(r,[{key:"reset",value:function(){O(S(r.prototype),"reset",this).call(this),this._doReset()}},{key:"process",value:function(e){return this._append(e),this._process()}},{key:"finalize",value:function(e){return e&&this._append(e),this._doFinalize()}}],[{key:"createEncryptor",value:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)}},{key:"createDecryptor",value:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)}},{key:"_createHelper",value:function(e){var t=function(e){return"string"==typeof e?Qr:Wr};return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}]),r}(Ar);Fr._ENC_XFORM_MODE=1,Fr._DEC_XFORM_MODE=2,Fr.keySize=4,Fr.ivSize=4;var Vr=function(e){k(r,e);var t=L(r);function r(e,n){var i;return y(this,r),(i=t.call(this))._cipher=e,i._iv=n,i}return g(r,null,[{key:"createEncryptor",value:function(e,t){return this.Encryptor.create(e,t)}},{key:"createDecryptor",value:function(e,t){return this.Decryptor.create(e,t)}}]),r}(Er);function zr(e,t,r){var n,i=e,s=this._iv;s?(n=s,this._iv=void 0):n=this._prevBlock;for(var a=0;a<r;a+=1)i[t+a]^=n[a]}var Gr=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r)}(Vr);Gr.Encryptor=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize;zr.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),r}(Gr),Gr.Decryptor=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize,i=e.slice(t,t+n);r.decryptBlock(e,t),zr.call(this,e,t,n),this._prevBlock=i}}]),r}(Gr);var qr={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,s=[],a=0;a<n;a+=4)s.push(i);var o=xr.create(s,n);e.concat(o)},unpad:function(e){var t=e,r=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=r}},Hr=function(e){k(r,e);var t=L(r);function r(e,n,i){var s;return y(this,r),(s=t.call(this,e,n,Object.assign({mode:Gr,padding:qr},i))).blockSize=4,s}return g(r,[{key:"reset",value:function(){var e;O(S(r.prototype),"reset",this).call(this);var t=this.cfg,n=t.iv,i=t.mode;this._xformMode===this.constructor._ENC_XFORM_MODE?e=i.createEncryptor:(e=i.createDecryptor,this._minBufferSize=1),this._mode=e.call(i,this,n&&n.words),this._mode.__creator=e}},{key:"_doProcessBlock",value:function(e,t){this._mode.processBlock(e,t)}},{key:"_doFinalize",value:function(){var e,t=this.cfg.padding;return this._xformMode===this.constructor._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e}}]),r}(Fr),Kr=function(e){k(r,e);var t=L(r);function r(e){var n;return y(this,r),(n=t.call(this)).mixIn(e),n}return g(r,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),r}(Er),Yr={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?xr.create([1398893684,1701076831]).concat(r).concat(t):t).toString(Rr)},parse:function(e){var t,r=Rr.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=xr.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),Kr.create({ciphertext:r,salt:t})}},Wr=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new Er,this.cfg,n),s=e.createEncryptor(r,i),a=s.finalize(t),o=s.cfg;return Kr.create({ciphertext:a,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:s.blockSize,formatter:i.format})}},{key:"decrypt",value:function(e,t,r,n){var i=t,s=Object.assign(new Er,this.cfg,n);return i=this._parse(i,s.format),e.createDecryptor(r,s).finalize(i.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),r}(Er);Wr.cfg=Object.assign(new Er,{format:Yr});var Xr={execute:function(e,t,r,n){var i=n;i||(i=xr.random(8));var s=Nr.create({keySize:t+r}).compute(e,i),a=xr.create(s.words.slice(t),4*r);return s.sigBytes=4*t,Kr.create({key:s,iv:a,salt:i})}},Qr=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new Er,this.cfg,n),s=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=s.iv;var a=Wr.encrypt.call(this,e,t,s.key,i);return a.mixIn(s),a}},{key:"decrypt",value:function(e,t,r,n){var i=t,s=Object.assign(new Er,this.cfg,n);i=this._parse(i,s.format);var a=s.kdf.execute(r,e.keySize,e.ivSize,i.salt);return s.iv=a.iv,Wr.decrypt.call(this,e,i,a.key,s)}}]),r}(Wr);Qr.cfg=Object.assign(Wr.cfg,{kdf:Xr});for(var Jr=[],Zr=[],$r=[],en=[],tn=[],rn=[],nn=[],sn=[],an=[],on=[],un=[],cn=0;cn<256;cn+=1)un[cn]=cn<128?cn<<1:cn<<1^283;for(var ln=0,dn=0,hn=0;hn<256;hn+=1){var fn=dn^dn<<1^dn<<2^dn<<3^dn<<4;fn=fn>>>8^255&fn^99,Jr[ln]=fn,Zr[fn]=ln;var pn=un[ln],vn=un[pn],mn=un[vn],yn=257*un[fn]^16843008*fn;$r[ln]=yn<<24|yn>>>8,en[ln]=yn<<16|yn>>>16,tn[ln]=yn<<8|yn>>>24,rn[ln]=yn,yn=16843009*mn^65537*vn^257*pn^16843008*ln,nn[fn]=yn<<24|yn>>>8,sn[fn]=yn<<16|yn>>>16,an[fn]=yn<<8|yn>>>24,on[fn]=yn,ln?(ln=pn^un[un[un[mn^pn]]],dn^=un[un[dn]]):ln=dn=1}var _n=[0,1,2,4,8,16,32,64,128,27,54],gn=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"_doReset",value:function(){var e;if(!this._nRounds||this._keyPriorReset!==this._key){this._keyPriorReset=this._key;var t=this._keyPriorReset,r=t.words,n=t.sigBytes/4;this._nRounds=n+6;var i=4*(this._nRounds+1);this._keySchedule=[];for(var s=this._keySchedule,a=0;a<i;a+=1)a<n?s[a]=r[a]:(e=s[a-1],a%n?n>6&&a%n==4&&(e=Jr[e>>>24]<<24|Jr[e>>>16&255]<<16|Jr[e>>>8&255]<<8|Jr[255&e]):(e=Jr[(e=e<<8|e>>>24)>>>24]<<24|Jr[e>>>16&255]<<16|Jr[e>>>8&255]<<8|Jr[255&e],e^=_n[a/n|0]<<24),s[a]=s[a-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<i;u+=1){var c=i-u;e=u%4?s[c]:s[c-4],o[u]=u<4||c<=4?e:nn[Jr[e>>>24]]^sn[Jr[e>>>16&255]]^an[Jr[e>>>8&255]]^on[Jr[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,$r,en,tn,rn,Jr)}},{key:"decryptBlock",value:function(e,t){var r=e,n=r[t+1];r[t+1]=r[t+3],r[t+3]=n,this._doCryptBlock(r,t,this._invKeySchedule,nn,sn,an,on,Zr),n=r[t+1],r[t+1]=r[t+3],r[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,r,n,i,s,a,o){for(var u=e,c=this._nRounds,l=u[t]^r[0],d=u[t+1]^r[1],h=u[t+2]^r[2],f=u[t+3]^r[3],p=4,v=1;v<c;v+=1){var m=n[l>>>24]^i[d>>>16&255]^s[h>>>8&255]^a[255&f]^r[p];p+=1;var y=n[d>>>24]^i[h>>>16&255]^s[f>>>8&255]^a[255&l]^r[p];p+=1;var _=n[h>>>24]^i[f>>>16&255]^s[l>>>8&255]^a[255&d]^r[p];p+=1;var g=n[f>>>24]^i[l>>>16&255]^s[d>>>8&255]^a[255&h]^r[p];p+=1,l=m,d=y,h=_,f=g}var b=(o[l>>>24]<<24|o[d>>>16&255]<<16|o[h>>>8&255]<<8|o[255&f])^r[p];p+=1;var k=(o[d>>>24]<<24|o[h>>>16&255]<<16|o[f>>>8&255]<<8|o[255&l])^r[p];p+=1;var S=(o[h>>>24]<<24|o[f>>>16&255]<<16|o[l>>>8&255]<<8|o[255&d])^r[p];p+=1;var E=(o[f>>>24]<<24|o[l>>>16&255]<<16|o[d>>>8&255]<<8|o[255&h])^r[p];p+=1,u[t]=b,u[t+1]=k,u[t+2]=S,u[t+3]=E}}]),r}(Hr);gn.keySize=8,Hr._createHelper(gn);var bn=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r)}(Vr);bn.Encryptor=function(e){k(r,e);var t=L(r);function r(){return y(this,r),t.apply(this,arguments)}return g(r,[{key:"processBlock",value:function(e,t){var r=e,n=this._cipher,i=n.blockSize,s=this._iv,a=this._counter;s&&(this._counter=s.slice(0),a=this._counter,this._iv=void 0);var o=a.slice(0);n.encryptBlock(o,0),a[i-1]=a[i-1]+1|0;for(var u=0;u<i;u+=1)r[t+u]^=o[u]}}]),r}(bn),bn.Decryptor=bn.Encryptor;var kn=function(){function e(){y(this,e);var t=window.crypto||window.msCrypto;this.subtle=t&&(t.subtle||t.webkitSubtle),this.externalDecryptor=null}var t,r;return g(e,[{key:"destroy",value:function(){var e;null!==(e=this.externalDecryptor)&&void 0!==e&&e.destroy&&this.externalDecryptor.destroy()}},{key:"decrypt",value:function(e,t){if(e||t){var r=[];return e&&(r[0]=this._decryptSegment(e)),t&&(r[1]=this._decryptSegment(t)),Promise.all(r)}}},{key:"_decryptSegment",value:(r=m(f().mark((function e(t){var r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.data,!t.key){e.next=5;break}return e.next=4,this._decryptData(t.data,t.key,t.keyIv);case 4:r=e.sent;case 5:if(t.map){e.next=7;break}return e.abrupt("return",r);case 7:return e.abrupt("return",Ne(t.map,r));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_decryptData",value:(t=m(f().mark((function e(t,r,n){var i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.externalDecryptor){e.next=6;break}return e.next=3,this.externalDecryptor.decrypt(t,r,n);case 3:return e.abrupt("return",e.sent);case 6:if(this.subtle){e.next=8;break}throw new Error("crypto is not defined");case 8:return e.next=10,this.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt","decrypt"]);case 10:return i=e.sent,e.t0=Uint8Array,e.next=14,this.subtle.decrypt({name:"AES-CBC",iv:n},i,t);case 14:return e.t1=e.sent,e.abrupt("return",new e.t0(e.t1));case 16:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}(),Sn=h(h({},Re),{},{STREAM_PARSED:"core.streamparsed",NO_AUDIO_TRACK:"core.noaudiotrack",SUBTITLE_SEGMENTS:"core.subtitlesegments",SUBTITLE_PLAYLIST:"core.subtitleplaylist",SEI_PAYLOAD_TIME:"core.seipayloadtime",APPEND_COST:"core.appendcost"}),En=new se("Transmuxer"),xn=function(){function e(t,r,n,i){y(this,e),b(this,"_initSegmentId",""),this.hls=t,this._demuxer=r?new mr:new ar(null,null,null,i),this._isMP4=r,n&&(this._remuxer=new Sr(this._demuxer.videoTrack,this._demuxer.audioTrack))}return g(e,[{key:"transmux",value:function(e,t,r,n,i,s){var a=this._demuxer;try{this._isMP4?a.demux(e,t):a.demuxAndFix(Ne(e,t),r,n,i)}catch(k){throw new re(W,ee.HLS,k)}var o=a.videoTrack,u=a.audioTrack,c=a.metadataTrack,l={codec:o.codec,timescale:o.timescale,firstDts:o.firstDts/o.timescale,firstPts:o.firstPts/o.timescale,duration:o.samplesDuration/o.timescale},d={codec:u.codec,timescale:u.timescale,firstDts:u.firstDts/o.timescale,firstPts:u.firstPts/o.timescale,duration:u.samplesDuration/o.timescale,container:u.container},f="".concat(o.codec,"/").concat(o.width,"/").concat(o.height,"/").concat(u.codec,"/").concat(u.config);if(f!==this._initSegmentId&&(this._initSegmentId=f,s=!0),this._fireEvents(o,u,c,r||s),this.hls.emit(Sn.DEMUXED_TRACK,{videoTrack:o,audioTrack:u}),!this._remuxer)return[o,u];s&&this.hls.isLive&&!this.hls.config.mseLowLatency&&(o.duration=this.hls.totalDuration*o.timescale,u.duration=this.hls.totalDuration*u.timescale);try{var p=this._remuxer.remux(s),v=p.videoInitSegment,m=p.videoSegment,y=p.audioInitSegment,_=p.audioSegment,g=Ne(v,m),b=Ne(y,_);return[g?h(h({},l),{},{data:g}):void 0,b?h(h({},d),{},{data:b}):void 0]}catch(k){throw new re(X,ee.FMP4,k)}}},{key:"_fireEvents",value:function(e,t,r,n){var i=this,s=[e,t],a="discontinuity: ".concat(n);s.forEach((function(e){var t;null!==(t=e.samples)&&void 0!==t&&t.length&&(a+="; ".concat(e.samples.length," ").concat(e.type===Ye?"video":"audio"," samples, firstDts/firstPts/duration: ").concat((e.firstDts/e.timescale).toFixed(3),"/").concat((e.firstPts/e.timescale).toFixed(3),"/").concat((e.samplesDuration/e.timescale).toFixed(3))),n&&e.exist()&&i.hls.emit(Sn.METADATA_PARSED,{type:e.type,track:e,meta:h({codec:e.codec,timescale:e.timescale,baseDts:e.baseDts},e.type===Ye?{width:e.width,height:e.height,sarRatio:e.sarRatio}:{codec:e.codec,channelCount:e.channelCount,sampleRate:e.sampleRate})})})),En.debug(a),e.warnings.forEach((function(e){var t;switch(e.type){case it:t=Sn.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case st:t=Sn.LARGE_VIDEO_DTS_GAP_DETECT;break;case at:t=Sn.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT}t&&i.hls.emit(Sn.STREAM_EXCEPTION,h(h({},e),{},{type:t})),En.warn("video exception",e)})),t.warnings.forEach((function(e){var t;switch(e.type){case ot:t=Sn.LARGE_AUDIO_DTS_GAP_DETECT;break;case ut:t=Sn.AUDIO_GAP_DETECT;break;case ct:t=Sn.AUDIO_OVERLAP_DETECT}t&&i.hls.emit(Sn.STREAM_EXCEPTION,h(h({},e),{},{type:t})),En.warn("audio exception",e)})),e.samples.forEach((function(e){e.keyframe&&i.hls.emit(Sn.KEYFRAME,{pts:e.pts})})),r.seiSamples.forEach((function(e){i.hls.emit(Sn.SEI,h(h({},e),{},{originPts:e.originPts/90,sei:{code:e.data.type,content:e.data.payload,dts:e.pts}}))}))}}]),e}(),wn=["data"],Tn=["data"],Dn=new se("BufferService"),An=function(){function e(t){var r=this;y(this,e),b(this,"_decryptor",new kn),b(this,"_transmuxer",null),b(this,"_mse",null),b(this,"_softVideo",null),b(this,"_sourceCreated",!1),b(this,"_needInitSegment",!0),b(this,"_directAppend",!1),this.hls=t,t.config.softDecode?this._softVideo=t.media:(this._mse=new ye(null,{preferMMS:t.config.preferMMS}),t.config.url&&this._mse.bindMedia(t.media).then((function(e){r.hls.emit(Re.MEDIASOURCE_OPENED,e)}))),t.config.decryptor&&(this._decryptor.externalDecryptor=t.config.decryptor)}var t,r,n,i,s,a,o,u,c,l;return g(e,[{key:"baseDts",get:function(){var e,t,r;return null===(e=this._transmuxer)||void 0===e||null===(t=e._demuxer)||void 0===t||null===(r=t._fixer)||void 0===r?void 0:r._baseDts}},{key:"nbSb",get:function(){var e;return null!==(e=this._mse)&&void 0!==e&&e._sourceBuffer?Object.keys(this._mse._sourceBuffer).length:0}},{key:"msIsOpened",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.isOpened}},{key:"msHasOpTasks",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.hasOpTasks}},{key:"msStreaming",get:function(){var e;return null===(e=this._mse)||void 0===e?void 0:e.streaming}},{key:"updateDuration",value:(l=m(f().mark((function e(t){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Dn.debug("update duration",t),!this._mse){e.next=9;break}if(this._mse.isOpened){e.next=5;break}return e.next=5,this._mse.open();case 5:return e.next=7,this._mse.updateDuration(t);case 7:e.next=10;break;case 9:this._softVideo&&(this._softVideo.duration=t);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"createSource",value:function(e,t,r,n){if(!this._sourceCreated){var i=e||t;if(i){if(ar.probe(i))this._transmuxer||(this._transmuxer=new xn(this.hls,!1,!this._softVideo,this.hls.config.fixerConfig));else{if(!cr.probe(i))throw new re(Z,null,null,null,"unsupported stream");if(this._softVideo)this._transmuxer||(this._transmuxer=new xn(this.hls,!0,null,this.hls.config.fixerConfig));else{this._directAppend=!0;var s=!1;e&&!r&&cr.findBox(e,["moov","trak"]).forEach((function(e){var t=cr.findBox(e.data,["trak","mdia","minf","stbl","stsd"])[0];if(t){var i=cr.stsd(t).entries[0];if(i)if(i.hvcC)r=i.hvcC.codec||"hev1.1.6.L93.B0";else if(i.avcC)r=i.avcC.codec;else if(i.sampleRate||i.esds){var a;n=(null===(a=i.esds)||void 0===a?void 0:a.codec)||"mp4a.40.2",s=!0}}})),t&&!n&&cr.findBox(t,["moov","trak","mdia","minf","stbl","stsd"]).forEach((function(e){var t=cr.stsd(e).entries[0];t&&t.esds&&(n=t.esds.codec)})),e&&!r&&(r="avc1.42e01e"),t&&!n&&(n="mp4a.40.2"),s&&(r+=", ".concat(n),n=""),this._createMseSource(r,n)}}this._softVideo&&(this._sourceCreated=!0)}}}},{key:"appendBuffer",value:(c=m(f().mark((function e(t,r,n,i,s,a,o){var u,c,l,d,h,p,v,m,y,_,g,b,k,S,E,x=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=n&&n.length||null!=i&&i.length){e.next=2;break}return e.abrupt("return");case 2:if(u=function(){var e,r;null!==(e=x.hls)&&void 0!==e&&e.emit&&(null===(r=x.hls)||void 0===r||r.emit(Re.APPEND_BUFFER,{start:t.start,end:t.end}))},!this._directAppend){e.next=8;break}return c=[],n&&c.push(this._mse.append(ye.VIDEO,n)),i&&c.push(this._mse.append(ye.AUDIO,i)),e.abrupt("return",Promise.all(c).then(u));case 8:if(l=this._needInitSegment||s,d=this._transmuxer.transmux(n,i,l,a,o,this._needInitSegment||s),h=P(d,2),p=h[0],v=h[1],i&&r&&(null==r||r.setTrackExist(!1,!0)),i&&t&&(null==t||t.setTrackExist(!0,!1)),r||null==t||t.setTrackExist(!!p,!!v),p&&!v&&this.hls.emit(Sn.NO_AUDIO_TRACK),!this._softVideo){e.next=20;break}this._softVideo.appendBuffer(p,v),this._needInitSegment=!1,u(),e.next=32;break;case 20:if(!this._mse){e.next=32;break}return(m=!this._sourceCreated)&&this._createMseSource(null==p?void 0:p.codec,null==v?void 0:v.codec,null==v?void 0:v.container),this._needInitSegment=!1,y=this._mse,_=[],l&&!m&&this._handleCodecChange(p,v).forEach((function(e){return _.push(e)})),p&&(g=p.data,b=D(p,wn),_.push(y.append(ye.VIDEO,g,b))),v&&(k=v.data,S=D(v,Tn),_.push(y.append(ye.AUDIO,k,S))),(E=Promise.all(_)).then(u),e.abrupt("return",E);case 32:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i,s,a){return c.apply(this,arguments)})},{key:"removeBuffer",value:(u=m(f().mark((function e(){var t,r,n,i=this,s=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:0,r=s.length>1&&void 0!==s[1]?s[1]:1/0,n=this.hls.media,!(!this._mse||!n||t<0||r<t||t>=this._mse.duration)){e.next=5;break}return e.abrupt("return");case 5:return e.abrupt("return",this._mse.clearBuffer(t,r).then((function(){return i.hls.emit(Re.REMOVE_BUFFER,{start:t,end:r,removeEnd:r})})));case 6:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"evictBuffer",value:(o=m(f().mark((function e(t){var r,n,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this.hls.media,this._mse&&r&&t&&!(t<0)){e.next=3;break}return e.abrupt("return");case 3:if(n=r.currentTime,!((i=n-t)<=0)){e.next=7;break}return e.abrupt("return");case 7:if(!(F.start(F.get(r))+1>=i)){e.next=10;break}return e.abrupt("return");case 10:return e.abrupt("return",this.removeBuffer(0,i));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"clearAllBuffer",value:(a=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=2;break}return e.abrupt("return",this._mse.clearAllBuffer());case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"decryptBuffer",value:function(e,t){return this._decryptor.decrypt(e,t)}},{key:"reset",value:(s=m(f().mark((function e(){var t,r=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this._mse||t){e.next=8;break}return this._transmuxer=null,this._sourceCreated=!1,e.next=6,this._mse.unbindMedia();case 6:return e.next=8,this._mse.bindMedia(this.hls.media);case 8:this._needInitSegment=!0,this._directAppend=!1;case 10:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"endOfStream",value:(i=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=5;break}if(!this._sourceCreated){e.next=5;break}return e.next=4,this._mse.endOfStream();case 4:this.hls.emit(Re.BUFFEREOS);case 5:this._softVideo&&this._softVideo.endOfStream();case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"setLiveSeekableRange",value:(n=m(f().mark((function e(t,r){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._mse&&this._mse.setLiveSeekableRange(t,r);case 1:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"detachMedia",value:(r=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=3;break}return e.next=3,this._mse.unbindMedia();case 3:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"destroy",value:(t=m(f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(t=this._decryptor)||void 0===t||t.destroy(),e.next=3,this.detachMedia();case 3:this._decryptor=null,this._mse=null,this._softVideo=null;case 6:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_createMseSource",value:function(e,t,r){Dn.debug("create mse source, videoCodec=".concat(e,", audioCodec=").concat(t));var n=this._mse;n&&(e&&(n.createSource(ye.VIDEO,"video/mp4;codecs=".concat(e)),this._sourceCreated=!0),t?(n.createSource(ye.AUDIO,"audio/mp4;codecs=".concat(t)),this._sourceCreated=!0):r&&(n.createSource(ye.AUDIO,"".concat(r,';codecs=""')),this._sourceCreated=!0),this.hls.emit(Re.SOURCEBUFFER_CREATED))}},{key:"_handleCodecChange",value:function(e,t){var r=[],n=this._mse;return[{type:ye.VIDEO,codecs:null==e?void 0:e.codec},{type:ye.AUDIO,codecs:null==t?void 0:t.codec}].filter((function(e){return!!e.codecs})).forEach((function(e){var t=e.type,i=e.codecs,s=n.getSourceBuffer(t);if(s){var a=i.split(",")[0];new RegExp(a,"ig").test(s.mimeType)||r.push(n.changeType(t,"".concat(t,"/mp4;codecs=").concat(i)))}})),r}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0}},{key:"isFull",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ye.VIDEO;return null===(e=this._mse)||void 0===e?void 0:e.isFull(t)}}]),e}();var Cn=g((function e(){y(this,e),b(this,"version",0),b(this,"streams",[]),b(this,"isMaster",!0)})),Ln="AUDIO",Rn="SUBTITLE",On={CLEAR_KEY:"org.w3.clearkey",FAIRPLAY:["urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2","com.apple.streamingkeydelivery"],WIDEVINE:["urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine.alpha","com.widevine"],PLAYREADY:["urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95","com.microsoft.playready"]};function Pn(e){for(var t=[],r=0;r<e.length;r++)Array.isArray(e[r])?t=t.concat(Pn(e[r])):t.push(e[r]);return t}var In=g((function e(){y(this,e),b(this,"id",0),b(this,"url",""),b(this,"default",!1),b(this,"autoSelect",!1),b(this,"forced",!1),b(this,"group",""),b(this,"name",""),b(this,"lang",""),b(this,"segments",[]),b(this,"endSN",0)})),jn=function(e){k(r,e);var t=L(r);function r(){var e;y(this,r);for(var n=arguments.length,i=new Array(n),s=0;s<n;s++)i[s]=arguments[s];return b(A(e=t.call.apply(t,[this].concat(i))),"mediaType",Ln),b(A(e),"channels",0),e}return g(r)}(In),Bn=function(e){k(r,e);var t=L(r);function r(){var e;y(this,r);for(var n=arguments.length,i=new Array(n),s=0;s<n;s++)i[s]=arguments[s];return b(A(e=t.call.apply(t,[this].concat(i))),"mediaType",Rn),e}return g(r)}(In),Mn=g((function e(){y(this,e),b(this,"id",0),b(this,"bitrate",0),b(this,"width",0),b(this,"height",0),b(this,"name",""),b(this,"url",""),b(this,"audioCodec",""),b(this,"videoCodec",""),b(this,"textCodec",""),b(this,"audioGroup",""),b(this,"audioStreams",[]),b(this,"subtitleStreams",[]),b(this,"closedCaptionsStream",[])})),Un=g((function e(){y(this,e),b(this,"version",0),b(this,"url",""),b(this,"type",""),b(this,"startCC",0),b(this,"endCC",0),b(this,"startSN",0),b(this,"endSN",0),b(this,"totalDuration",0),b(this,"targetDuration",0),b(this,"partTargetDuration",0),b(this,"canSkipUntil",0),b(this,"canSkipDateRanges",!1),b(this,"skippedSegments",0),b(this,"canBlockReload",!1),b(this,"partHoldBack",0),b(this,"live",!0),b(this,"lowLatency",!1),b(this,"endPartIndex",0),b(this,"segments",[]),b(this,"dateRanges",{}),b(this,"skippedSegments",0)})),Nn=function(){function e(t){y(this,e),b(this,"sn",0),b(this,"cc",0),b(this,"url",""),b(this,"parentUrl",""),b(this,"title",""),b(this,"start",0),b(this,"duration",0),b(this,"dataTime",""),b(this,"key",null),b(this,"byteRange",null),b(this,"isInitSegment",!1),b(this,"initSegment",null),b(this,"isLast",!1),b(this,"hasAudio",!1),b(this,"hasVideo",!1),b(this,"independent",!1),b(this,"partIndex",0),this.parentUrl=t}return g(e,[{key:"end",get:function(){return this.start+this.duration}},{key:"setTrackExist",value:function(e,t){this.hasVideo=e,this.hasAudio=t}},{key:"setByteRange",value:function(e,t){this.byteRange=[0];var r=e.split("@");1===r.length&&t&&t.byteRange?(this.byteRange[0]=t.byteRange[1]||0,this.byteRange[0]&&(this.byteRange[0]+=1)):this.byteRange[0]=parseInt(r[1]),this.byteRange[1]=this.byteRange[0]+parseInt(r[0])-1}}]),e}(),Fn=function(){function e(t){y(this,e),b(this,"method",""),b(this,"url",""),b(this,"iv",null),b(this,"keyFormat",""),b(this,"keyFormatVersions",""),t instanceof e&&(this.method=t.method,this.url=t.url,this.keyFormat=t.keyFormat,this.keyFormatVersions=t.keyFormatVersions,t.iv&&(this.iv=new Uint8Array(t.iv)))}return g(e,[{key:"clone",value:function(t){var r=new e(this);return null!=t&&r.setIVFromSN(t),r}},{key:"setIVFromSN",value:function(e){if(!this.iv&&"AES-128"===this.method&&"number"==typeof e&&this.url){this.iv=new Uint8Array(16);for(var t=12;t<16;t++)this.iv[t]=e>>8*(15-t)&255}}},{key:"isSegmentEncrypted",value:function(){return"AES-128"===this.method}},{key:"isValidKeySystem",value:function(){return Pn([On.CLEAR_KEY,On.FAIRPLAY,On.WIDEVINE,On.PLAYREADY]).indexOf(this.keyFormat)>-1&&!!(["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)>-1)}},{key:"isSupported",value:function(){return!!this.method&&(!!this.isSegmentEncrypted()||!!this.isValidKeySystem())}}]),e}(),Vn=function(){function e(t,r,n){y(this,e),this.msn=t,this.part=r,this.skip=n}return g(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()),this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}]),e}(),zn=/^#(EXT[^:]*)(?::(.*))?$/,Gn=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,qn=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,Hn=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function Kn(e){return e.split(/[\r\n]/).map((function(e){return e.trim()})).filter(Boolean)}function Yn(e){var t=e.match(zn);if(t&&t[1])return[t[1].replace("EXT-X-",""),t[2]]}function Wn(e){for(var t={},r=Gn.exec(e);r;)t[r[1]]=r[2]||r[3],r=Gn.exec(e);return t}function Xn(e,t){if(!t||!e||qn.test(e))return e;var r=Hn.exec(t);return r?"/"===e[0]?r[1]+e:r[1]+r[2]+e:e}var Qn={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function Jn(e,t){var r=Qn[e];if(r&&t&&t.length)for(var n=0;n<r.length;n++)for(var i=0;i<t.length;i++)if(r[n].test(t[i]))return t[i]}function Zn(e,t){var r;if(t)for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e[n]!==t[n]){r=n;break}var i=null;e.DURATION&&(i=parseFloat(e.DURATION),Number.isFinite(i)?e._endDate&&(i=(e._endDate.getTime()-e._startDate.getTime())/1e3):i=null);var s,a,o=(s=e.CUE||e["X-CUE"],a={pre:!1,post:!1,once:!1},(s?s.split(/[ ,]+/):[]).reduce((function(e,t){return e[t.toLowerCase()]=!0,e}),a));return!!e.ID&&!r&&Number.isFinite(e._startDate.getTime())&&(null===i||i>=0)&&(!("YES"===e.END_ON_NEXT)||!!e.CLASS)&&(!e.CUE||!o.pre&&!o.post||o.pre!==o.post)&&(!("com.apple.hls.interstitial"===e.CLASS)||"X-ASSET-URI"in e||"X-ASSET-LIST"in e)}function $n(e,t){for(var r,n=new Cn,i=0,s=[],a=[];r=e[i++];){var o=Yn(r);if(o){var u=P(o,2),c=u[0],l=u[1];if("VERSION"===c)n.version=parseInt(l);else if("MEDIA"===c&&l){var d=Wn(l),h=void 0;switch(d.TYPE){case"AUDIO":h=new jn;break;case"SUBTITLES":h=new Bn;break;default:h=new In}h.url=Xn(d.URI,t),h.default="YES"===d.DEFAULT,h.autoSelect="YES"===d.AUTOSELECT,h.group=d["GROUP-ID"],h.name=d.NAME,h.lang=d.LANGUAGE,d.CHANNELS&&(h.channels=Number(d.CHANNELS.split("/")[0]),Number.isNaN(h.channels)&&(h.channels=0)),"AUDIO"===d.TYPE&&d.URI&&s.push(h),"SUBTITLES"===d.TYPE&&a.push(h)}else if("STREAM-INF"===c&&l){var f=new Mn,p=Wn(l);if(f.bitrate=parseInt(p["AVERAGE-BANDWIDTH"]||p.BANDWIDTH),f.name=p.NAME,f.url=Xn(e[i++],t),p.RESOLUTION){var v=P(p.RESOLUTION.split("x"),2),m=v[0],y=v[1];f.width=parseInt(m),f.height=parseInt(y)}if(p.CODECS){var _=p.CODECS.split(/[ ,]+/).filter(Boolean);f.videoCodec=Jn("video",_),f.audioCodec=Jn("audio",_),f.textCodec=Jn("text",_)}f.audioGroup=p.AUDIO,f.subtitleGroup=p.SUBTITLES,n.streams.push(f)}}}return n.streams.forEach((function(e,t){e.id=t})),s.length&&(s.forEach((function(e,t){e.id=t})),n.streams.forEach((function(e){e.audioGroup&&(e.audioStreams=s.filter((function(t){return t.group===e.audioGroup})))}))),a.length&&(a.forEach((function(e,t){e.id=t})),n.streams.forEach((function(e){e.subtitleGroup&&(e.subtitleStreams=a.filter((function(t){return t.group===e.subtitleGroup})))}))),n}function ei(e,t,r){var n=new Un;n.url=t;for(var i,s=new Nn(t),a=null,o=null,u=0,c=0,l=0,d=0,h=!1,f=0;i=e[d++];)if("#"===i[0]){var p=Yn(i);if(p){var v=P(p,2),m=v[0],y=v[1];switch(m){case"VERSION":n.version=parseInt(y);break;case"PLAYLIST-TYPE":n.type=null==y?void 0:y.toUpperCase();break;case"TARGETDURATION":n.targetDuration=parseFloat(y);break;case"PART-INF":r&&(n.lowLatency=!0);var _=Wn(y);_["PART-TARGET"]&&(n.partTargetDuration=parseFloat(_["PART-TARGET"]));break;case"SERVER-CONTROL":var g=Wn(y);n.canBlockReload="YES"===g["CAN-BLOCK-RELOAD"],n.partHoldBack=parseFloat(g["PART-HOLD-BACK"]||0),n.canSkipUntil=parseFloat(g["CAN-SKIP-UNTIL"]||0),n.canSkipDateRanges=n.canSkipUntil>0&&"YES"===g["CAN-SKIP-DATERANGES"];break;case"ENDLIST":h=!0;break;case"MEDIA-SEQUENCE":c=n.startSN=parseInt(y);break;case"DISCONTINUITY-SEQUENCE":l=n.startCC=parseInt(y);break;case"DISCONTINUITY":l++;break;case"BYTERANGE":s.setByteRange(y,n.segments[n.segments.length-1]);break;case"PART":if(!n.lowLatency)break;var b=Wn(y);s.duration=parseFloat(b.DURATION),s.independent="YES"===b.INDEPENDENT,s.sn=c,s.cc=l,s.partIndex=f,s.start=u,s.duration=parseFloat(b.DURATION),u+=s.duration,s.url=Xn(b.URI,t),o&&(s.key=o.clone(c)),a&&(s.initSegment=a),n.segments.push(s),s=new Nn(t),f++;break;case"PRELOAD-HINT":var k=Wn(y);if(n.preloadHint=k,"PART"===k.TYPE&&k.URI){var S=k.URI.split(".ts")[0].split("-");n.nextSN=S[3],n.nextIndex=S[S.length-1]}break;case"PROGRAM-DATE-TIME":s.dataTime=y;break;case"EXTINF":if(n.lowLatency){f=0;break}var E=P(y.split(","),2),x=E[0],w=E[1];s.start=u,s.duration=parseFloat(x),u+=s.duration,s.title=w;break;case"KEY":var T=Wn(y);if("NONE"===T.METHOD){o=null;break}if((o=new Fn).method=T.METHOD,o.url=/^blob:/.test(T.URI)?T.URI:Xn(T.URI,t),o.keyFormat=T.KEYFORMAT||"identity",o.keyFormatVersions=T.KEYFORMATVERSIONS,!o.isSupported())throw new Error("encrypt ".concat(T.METHOD,"/").concat(T.KEYFORMAT," is not supported"));if(T.IV){var D=T.IV.slice(2);D=(1&D.length?"0":"")+D,o.iv=new Uint8Array(D.length/2);for(var A=0,C=D.length/2;A<C;A++)o.iv[A]=parseInt(D.slice(2*A,2*A+2),16)}break;case"MAP":var L=Wn(y);s.url=Xn(L.URI,t),L.BYTERANGE&&s.setByteRange(L.BYTERANGE),s.isInitSegment=!0,s.sn=0,o&&(s.key=o.clone(0)),a=s,s=new Nn(t);break;case"SKIP":var R=Wn(y),O=parseInt(R["SKIPPED-SEGMENTS"],10);O<=Number.MAX_SAFE_INTEGER&&(n.skippedSegments+=O,c+=O);break;case"DATERANGE":var I=Wn(y),j=n.dateRanges[I.ID];I._startDate=j?j._startDate:new Date(I["START-DATE"]);var B=(null==j?void 0:j._endDate)||new Date(I.END_DATE);Number.isFinite(B)&&(I._endDate=B),(Zn(I,j)||n.skippedSegments)&&(n.dateRanges[I.ID]=I)}}}else{if(n.lowLatency){c++;continue}s.sn=c,s.cc=l,s.url=Xn(i,t),o&&(s.key=o.clone(c)),a&&(s.initSegment=a),n.segments.push(s),s=new Nn(t),c++}n.segments=n.segments.filter((function(e){return 0!==e.duration}));var M=n.segments[n.segments.length-1];return M&&(h&&(M.isLast=!0),n.endSN=M.sn,n.endPartIndex=M.partIndex),h&&(n.live=!1),n.totalDuration=u,n.endCC=l,n}var ti=function(){function e(){y(this,e)}return g(e,null,[{key:"parse",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;if(!t.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");var i=Kn(t);return e.isMediaPlaylist(t)?ei(i,r,n):$n(i,r)}},{key:"isMediaPlaylist",value:function(e){return e.includes("#EXTINF:")||e.includes("#EXT-X-TARGETDURATION:")}}]),e}(),ri=function(){function e(t){var r=this;y(this,e),b(this,"_emitOnLoaded",(function(e,t){var n=e.response,i=e.options||{},s=i.firstByteTime,a=i.startTime,o=i.endTime,u=i.contentLength,c=o-a;r.hls.emit(Re.SPEED,{time:c,byteLength:u,url:t}),r.hls.emit(Re.LOAD_COMPLETE,{url:t,elapsed:c||0}),r.hls.emit(Re.TTFB,{url:t,responseUrl:n.url,elapsed:s-a}),r.hls.emit(Re.LOAD_RESPONSE_HEADERS,{headers:n.headers,url:t})})),b(this,"_onLoaderRetry",(function(e,t){r.hls.emit(Sn.LOAD_RETRY,{error:re.network(e),retryTime:t})})),this.hls=t,this._timer=null,this._useLowLatency=t.config.useLowLatency;var n=this.hls.config,i=n.retryCount,s=n.retryDelay,a=n.manifestLoadTimeout,o=n.fetchOptions;this._loader=new Ve(h(h({},o),{},{responseType:"text",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry})),this._audioLoader=new Ve(h(h({},o),{},{responseType:"text",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry})),this._subtitleLoader=new Ve(h(h({},o),{},{responseType:"text",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry}))}var t;return g(e,[{key:"load",value:(t=m(f().mark((function e(t,r,n){var i,s,a,o,u,c,l,d,h,p,v,m,y,_,g,b,k,S,E,x;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=[this._loader.load(t)],r&&i.push(this._audioLoader.load(r)),n&&i.push(this._subtitleLoader.load(n)),e.prev=3,e.next=6,Promise.all(i);case 6:if(d=e.sent,h=P(d,3),p=h[0],v=h[1],m=h[2],p){e.next=13;break}return e.abrupt("return",[]);case 13:this._emitOnLoaded(p,t),s=p.data,u=p.response.url||t,r?(a=null==v?void 0:v.data,o=null==m?void 0:m.data,c=(null==v||null===(y=v.response)||void 0===y?void 0:y.url)||r,l=(null==m||null===(_=m.response)||void 0===_?void 0:_.url)||n,a&&this._emitOnLoaded(v,r),o&&this._emitOnLoaded(m,n)):(o=null==v?void 0:v.data,l=(null==v||null===(g=v.response)||void 0===g?void 0:g.url)||n,o&&this._emitOnLoaded(v,n)),e.next=22;break;case 19:throw e.prev=19,e.t0=e.catch(3),re.network(e.t0);case 22:if(b=this.hls.config.onPreM3U8Parse,e.prev=23,b&&(s=b(s)||s,a&&(a=b(a,!0)||a),o&&(o=b(o,!0)||o)),k=ti.parse(s,u,this._useLowLatency),!1!==(null===(x=k)||void 0===x?void 0:x.live)||!k.segments||k.segments.length){e.next=28;break}throw new Error("empty segments list");case 28:a&&(S=ti.parse(a,c,this._useLowLatency)),o&&(E=ti.parse(o,l,this._useLowLatency)),e.next=35;break;case 32:throw e.prev=32,e.t1=e.catch(23),new re(z,ee.HLS,e.t1);case 35:return k&&(k.isMaster?this.hls.emit(Sn.HLS_MANIFEST_LOADED,{playlist:k}):(this._useLowLatency&&(k.canBlockReload?this.deliveryDirectives=new Vn(k.nextSN,k.nextIndex,""):this.deliveryDirectives=null),this.hls.emit(Sn.HLS_LEVEL_LOADED,{playlist:k}))),e.abrupt("return",[k,S,E]);case 37:case"end":return e.stop()}}),e,this,[[3,19],[23,32]])}))),function(e,r,n){return t.apply(this,arguments)})},{key:"parseText",value:function(e,t){var r,n=this.hls.config.onPreM3U8Parse;try{var i;if(n&&(e=n(e)||e),!1===(null===(i=r=ti.parse(e,t,this._useLowLatency))||void 0===i?void 0:i.live)&&r.segments&&!r.segments.length)throw new Error("empty segments list")}catch(s){throw new re(z,ee.HLS,s)}return r&&(r.isMaster?this.hls.emit(Sn.HLS_MANIFEST_LOADED,{playlist:r}):this.hls.emit(Sn.HLS_LEVEL_LOADED,{playlist:r})),[r]}},{key:"poll",value:function(e,t,r,n,i,s){var a=this;clearTimeout(this._timer),s=s||3e3;var o=this.hls.config.pollRetryCount,u=function(){var c=m(f().mark((function c(){var l,d;return f().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return clearTimeout(a._timer),l=e,c.prev=2,a.deliveryDirectives&&(l=a.deliveryDirectives.addDirectives(e)),c.next=6,a.load(l,t,r);case 6:if((d=c.sent)[0]){c.next=9;break}return c.abrupt("return");case 9:o=a.hls.config.pollRetryCount,n(d[0],d[1],d[2]),c.next=17;break;case 13:c.prev=13,c.t0=c.catch(2),--o<=0&&i(c.t0);case 17:a._timer=setTimeout(u,s);case 18:case"end":return c.stop()}}),c,null,[[2,13]])})));return function(){return c.apply(this,arguments)}}();this._timer=setTimeout(u,s)}},{key:"stopPoll",value:function(){return clearTimeout(this._timer),this.cancel()}},{key:"cancel",value:function(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}}]),e}();function ni(e,t,r){return t>r&&(r=t),Math.min(Math.max(e,t),r)}var ii=new se("playlist"),si=function(){function e(t,r,n){y(this,e),b(this,"live",void 0),b(this,"id",0),b(this,"bitrate",0),b(this,"width",0),b(this,"height",0),b(this,"name",""),b(this,"url",""),b(this,"audioCodec",""),b(this,"videoCodec",""),b(this,"textCodec",""),b(this,"startCC",0),b(this,"endCC",0),b(this,"startSN",0),b(this,"endSN",-1),b(this,"totalDuration",0),b(this,"targetDuration",0),b(this,"partTargetDuration",0),b(this,"canSkipUntil",0),b(this,"canSkipDateRanges",!1),b(this,"skippedSegments",0),b(this,"canBlockReload",!1),b(this,"partHoldBack",0),b(this,"lowLatency",!1),b(this,"endPartIndex",0),b(this,"snDiff",null),b(this,"segments",[]),b(this,"audioStreams",[]),b(this,"subtitleStreams",[]),b(this,"closedCaptions",[]),b(this,"currentAudioStream",null),b(this,"currentSubtitleStream",null),this.update(this._setLLPlaybackPoint(t),r,n)}return g(e,[{key:"lastSegment",get:function(){return this.segments.length?this.segments[this.segments.length-1]:null}},{key:"segmentDuration",get:function(){var e;return this.targetDuration||(null===(e=this.segments[0])||void 0===e?void 0:e.duration)||0}},{key:"liveEdge",get:function(){return this.endTime},set:function(e){this.endTime=e}},{key:"endTime",get:function(){var e;return(null===(e=this.lastSegment)||void 0===e?void 0:e.end)||0},set:function(e){var t=this.lastSegment;t&&(t.duration=e-t.start)}},{key:"currentSubtitleEndSn",get:function(){var e;return(null===(e=this.currentSubtitleStream)||void 0===e?void 0:e.endSN)||0}},{key:"clearOldSegment",value:function(e,t){return this.currentAudioStream&&this._clearSegments(e,t),this._clearSegments(e,t)}},{key:"getAudioSegment",value:function(e){if(e&&this.currentAudioStream){var t=e.sn-this.snDiff;return this.currentAudioStream.segments.find((function(e){return e.sn===t}))}}},{key:"update",value:function(e,t){this.url=e.url,Array.isArray(e.segments)?(null!==this.live&&void 0!==this.live||(this.live=e.live),this._updateSegments(e,this),this.startCC=e.startCC,this.endCC=e.endCC,this.startSN=e.startSN,this.endSN=e.endSN||-1,this.totalDuration=e.totalDuration,this.targetDuration=e.targetDuration,this.live=e.live,this.lowLatency=e.lowLatency,this.canBlockReload=e.canBlockReload,this.canSkipDateRanges=e.canSkipDateRanges,this.canSkipUntil=e.canSkipUntil,this.partHoldBack=e.partHoldBack,this.partTargetDuration=e.partTargetDuration,this.skippedSegments=e.skippedSegments,this.endPartIndex=e.endPartIndex,t&&this.currentAudioStream&&Array.isArray(t.segments)&&(this._updateSegments(t,this.currentAudioStream),(null===this.snDiff||void 0===this.snDiff)&&e.segments.length&&t.segments.length&&(this.snDiff=e.segments[0].sn-t.segments[0].sn))):(this.id=e.id,this.bitrate=e.bitrate,this.width=e.width,this.height=e.height,this.name=e.name,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.textCodec=e.textCodec,this.audioStreams=e.audioStreams,this.subtitleStreams=e.subtitleStreams,!this.currentAudioStream&&this.audioStreams.length&&(this.currentAudioStream=this.audioStreams.find((function(e){return e.default}))||this.audioStreams[0]),!this.currentSubtitleStream&&this.subtitleStreams.length&&(this.currentSubtitleStream=this.subtitleStreams.find((function(e){return e.default}))||this.subtitleStreams[0]))}},{key:"updateSubtitle",value:function(e){var t=this;if(e&&this.currentSubtitleStream&&Array.isArray(e.segments)){var r=this._updateSegments(e,this.currentSubtitleStream),n=this.currentSubtitleStream.segments;if(n.length>100&&(this.currentSubtitleStream.segments=n.slice(100)),r)return r.map((function(e){return{sn:e.sn,url:e.url,duration:e.duration,start:e.start,end:e.end,lang:t.currentSubtitleStream.lang}}))}}},{key:"switchSubtitle",value:function(e){var t=this.subtitleStreams.find((function(t){return t.lang===e})),r=this.currentSubtitleStream;t&&(this.currentSubtitleStream=t,r.segments=[])}},{key:"_setLLPlaybackPoint",value:function(e){if(!e.lowLatency||!e.segments.length)return e;for(var t=e.totalDuration-e.partHoldBack,r=e.segments,n=0,i=0,s=r.length;i<s;i++)r[i].start<=t&&r[i].independent&&(n=i);var a=r.slice(n),o=0;return a.forEach((function(e){e.start=o,o=e.end})),e.segments=a,e.totalDuration=o,e.startSN=a[0].sn,e.startCC=a[0].cc,ii.log("set ll-hls playback point: SN=".concat(e.startSN," partIndex=").concat(a[0].partIndex,", duration=").concat(o)),e}},{key:"_clearSegments",value:function(e,t){for(var r=0,n=this.segments,i=0,s=n.length;i<s;i++)if(n[i].end>=e){r=i;break}return r>t&&(r=t),r&&(this.segments=this.segments.slice(r),this.currentAudioStream&&(this.currentAudioStream.segments=this.currentAudioStream.segments.slice(r))),t-r}},{key:"_updateSegments",value:function(e,t){var r=t.segments;if(this.live){var n,i=e.lowLatency,s=r[r.length-1],a=null!==(n=null==s?void 0:s.sn)&&void 0!==n?n:-1,o=(null==s?void 0:s.partIndex)||0,u=a<e.endSN&&e.segments.length;if(i&&(u=u||o<e.endPartIndex),u){ii.log("update segments: endSN:".concat(a,", partIndex:").concat(o," --\x3e endSN:").concat(e.endSN,", partIndex:").concat(e.endPartIndex));var c=e.segments.findIndex((function(e){return e.sn===a&&e.partIndex===o})),l=c<0?e.segments:e.segments.slice(c+1);if(r.length&&l.length){var d=s.end,h=d;l.forEach((function(e){e.start=d,d=e.end})),ii.log("liveEdge: ".concat(h," -> ").concat(d));var f=(null==s?void 0:s.cc)||-1;f>l[0].cc&&l.forEach((function(e){return e.cc+=f}))}return t.endSN=e.endSN,t.segments=r.concat(l),l}}else t.segments=e.segments}}]),e}(),ai=function(){function e(t){y(this,e),b(this,"streams",[]),b(this,"currentStream",null),b(this,"dvrWindow",0),b(this,"_segmentPointer",-1),this.hls=t}return g(e,[{key:"lowLatency",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.lowLatency}},{key:"lastSegment",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.lastSegment}},{key:"currentSegment",get:function(){var e;return null===(e=this.currentSegments)||void 0===e?void 0:e[this._segmentPointer]}},{key:"nextSegment",get:function(){var e;return null===(e=this.currentSegments)||void 0===e?void 0:e[this._segmentPointer+1]}},{key:"currentSegments",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.segments}},{key:"currentSubtitleEndSn",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.currentSubtitleEndSn}},{key:"liveEdge",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.liveEdge},set:function(e){this.currentStream&&(this.currentStream.liveEdge=e)}},{key:"totalDuration",get:function(){var e;return(null===(e=this.currentStream)||void 0===e?void 0:e.totalDuration)||0}},{key:"seekRange",get:function(){var e=this.currentSegments;if(e&&e.length)return[e[0].start,e[e.length-1].end]}},{key:"nbSegments",get:function(){var e;return(null===(e=this.currentSegments)||void 0===e?void 0:e.length)||0}},{key:"isEmpty",get:function(){var e;return!(null!==(e=this.currentSegments)&&void 0!==e&&e.length)}},{key:"isLive",get:function(){var e;return null===(e=this.currentStream)||void 0===e?void 0:e.live}},{key:"hadSegmentLoaded",get:function(){return-1!==this._segmentPointer}},{key:"hasSubtitle",get:function(){var e;return!(null===(e=this.currentStream)||void 0===e||!e.currentSubtitleStream)}},{key:"getAudioSegment",value:function(e){var t;return null===(t=this.currentStream)||void 0===t?void 0:t.getAudioSegment(e)}},{key:"moveSegmentPointer",value:function(e){var t;null==e&&(e=this._segmentPointer+1),this._segmentPointer=ni(e,-1,null===(t=this.currentSegments)||void 0===t?void 0:t.length)}},{key:"reset",value:function(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}},{key:"getSegmentByIndex",value:function(e){var t;return null===(t=this.currentSegments)||void 0===t?void 0:t[e]}},{key:"setNextSegmentByIndex",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._segmentPointer=e-1}},{key:"setNextSegmentBySN",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=null===(e=this.currentSegments)||void 0===e?void 0:e.findIndex((function(e){return e.sn===t}));return-1!==r&&this.setNextSegmentByIndex(r+1),r}},{key:"findSegmentIndexByTime",value:function(e){var t=this.currentSegments;if(t){for(var r,n=0,i=t.length;n<i;n++)if(e>=(r=t[n]).start&&e<r.end)return n;var s=t[t.length-1];if(Math.abs(e-(null==s?void 0:s.end))<.2)return t.length-1}}},{key:"upsertPlaylist",value:function(e,t,r){var n=this;if(e){if(e.isMaster)this.streams.length=e.streams.length,e.streams.filter((function(e){return e.url})).forEach((function(e,t){n.streams[t]?n.streams[t].update(e):n.streams[t]=new si(e)})),this.currentStream=this.streams[0];else if(Array.isArray(e.segments)){var i=this.currentStream;if(i){i.update(e,t,r);var s=i.updateSubtitle(r);s&&this.hls.emit(Sn.SUBTITLE_SEGMENTS,{list:s})}else this.reset(),this.currentStream=this.streams[0]=new si(e,t,r)}this.currentStream&&this.hls.isLive&&!this.dvrWindow&&(this.dvrWindow=this.currentSegments.reduce((function(e,t){return e+=t.duration}),0))}}},{key:"updateSegmentsRanges",value:function(e,t){var r;(null===(r=this.currentSegments)||void 0===r?void 0:r.filter((function(t){return t.sn>=e}))).forEach((function(e){e.start=t,t=e.end}))}},{key:"switchSubtitle",value:function(e){var t;null===(t=this.currentStream)||void 0===t||t.switchSubtitle(e)}},{key:"clearOldSegment",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.hls.config.maxPlaylistSize||50,t=this.currentStream;if(this.dvrWindow&&t){var r=t.endTime-this.dvrWindow;if(!(r<=0)){var n=t.segments;n.length<=e||(this._segmentPointer=t.clearOldSegment(r,this._segmentPointer))}}}},{key:"checkSegmentTrackChange",value:function(e,t){var r=this.findSegmentIndexByTime(e),n=this.getSegmentByIndex(r);if(n&&(n.hasAudio||n.hasVideo)){if(2!==t&&n.hasAudio&&n.hasVideo)return n;if(!(n.end-e>.3)){var i=this.getSegmentByIndex(r+1);if(i&&(i.hasAudio||i.hasVideo))return i.hasAudio!==n.hasAudio||i.hasVideo!==n.hasVideo?i:void 0}}}},{key:"feedbackLiveEdge",value:function(e,t){var r;this.currentSegments&&((null===(r=this.lastSegment)||void 0===r?void 0:r.sn)===e.sn?this.liveEdge=t:this.updateSegmentsRanges(e.sn+1,t))}}]),e}(),oi=function(){function e(t){var r=this;y(this,e),b(this,"error",null),b(this,"_emitOnLoaded",(function(e,t){var n=e.data,i=e.response,s=e.options||{},a=s.firstByteTime,o=s.startTime,u=s.endTime,c=s.contentLength,l=u-o;r._bandwidthService.addRecord(c||n.byteLength,l),r.hls.emit(Re.SPEED,{time:l,byteLength:c,url:t}),r.hls.emit(Re.LOAD_COMPLETE,{url:t,elapsed:l||0}),r.hls.emit(Re.TTFB,{url:t,responseUrl:i.url,elapsed:a-o}),r.hls.emit(Re.LOAD_RESPONSE_HEADERS,{headers:i.headers,url:t})})),b(this,"_onLoaderRetry",(function(e,t){r.hls.emit(Re.LOAD_RETRY,{error:re.network(e),retryTime:t})})),this.hls=t,this._bandwidthService=new qe,this._mapCache={},this._keyCache={};var n=this.hls.config,i=n.retryCount,s=n.retryDelay,a=n.loadTimeout,o=n.fetchOptions;this._segmentLoader=new Ve(h(h({},o),{},{responseType:"arraybuffer",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry})),this._audioSegmentLoader=new Ve(h(h({},o),{},{responseType:"arraybuffer",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry})),this._keyLoader=new Ve(h(h({},o),{},{responseType:"arraybuffer",retry:i,retryDelay:s,timeout:a,onRetryError:this._onLoaderRetry}))}var t,r;return g(e,[{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}},{key:"load",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r,i=[];return e&&(i[0]=this.loadVideoSegment(e,r)),t&&(i[1]=this.loadAudioSegment(t,n)),Promise.all(i)}},{key:"loadVideoSegment",value:function(e,t){return this._loadSegment(this._segmentLoader,e,t)}},{key:"loadAudioSegment",value:function(e,t){return this._loadSegment(this._audioSegmentLoader,e,t)}},{key:"_loadSegment",value:(r=m(f().mark((function e(t,r,n){var i,s,a,o,u,c,l,d,h,p,v,m,y,_,g,b=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=[],this.hls.emit(Re.LOAD_START,{url:r.url}),l[0]=t.load(r.url),n&&r.initSegment&&(h=r.initSegment.url,(s=this._mapCache[h])||(this.hls.emit(Re.LOAD_START,{url:h}),l[1]=t.load(h).then((function(e){e&&(Object.keys(b._mapCache)>30&&(b._mapCache={}),s=b._mapCache[h]=e.data,b._emitOnLoaded(e,h))}))),(p=null===(d=r.initSegment.key)||void 0===d?void 0:d.url)&&(c=r.initSegment.key.iv,(u=this._keyCache[p])||(this.hls.emit(Re.LOAD_START,{url:p}),l[2]=this._keyLoader.load(p).then((function(e){e&&(u=b._keyCache[p]=e.data,b._emitOnLoaded(e,p))}))))),(v=null===(i=r.key)||void 0===i?void 0:i.url)&&r.key.isSegmentEncrypted()&&(o=r.key.iv,(a=this._keyCache[v])||(this.hls.emit(Re.LOAD_START,{url:v}),l[3]=this._keyLoader.load(v).then((function(e){e&&(a=b._keyCache[v]=e.data,b._emitOnLoaded(e,v))})))),e.next=8,Promise.all(l);case 8:if(m=e.sent,y=P(m,1),_=y[0]){e.next=13;break}return e.abrupt("return");case 13:return g=_.data,this._emitOnLoaded(_,r.url),e.abrupt("return",{data:g,map:s,key:a,mapKey:u,keyIv:o,mapKeyIv:c});case 16:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"reset",value:function(){this.error=null,this._mapCache={},this._keyCache={},this._bandwidthService.reset()}},{key:"cancel",value:(t=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all([this._keyLoader.cancel(),this._segmentLoader.cancel(),this._audioSegmentLoader.cancel()]);case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),ui=new se("hls"),ci=function(e){k(w,e);var t,r,n,i,s,a,o,u,c,l,d,v,_,S,E,x=L(w);function w(e){var t,r,n;return y(this,w),b(A(t=x.call(this)),"version",w.version),b(A(t),"media",null),b(A(t),"config",null),b(A(t),"_manifestLoader",null),b(A(t),"_segmentLoader",null),b(A(t),"_playlist",null),b(A(t),"_bufferService",null),b(A(t),"_gapService",null),b(A(t),"_seiService",null),b(A(t),"_stats",null),b(A(t),"_prevSegSn",null),b(A(t),"_prevSegCc",null),b(A(t),"_tickTimer",null),b(A(t),"_tickInterval",500),b(A(t),"_segmentProcessing",!1),b(A(t),"_reloadOnPlay",!1),b(A(t),"_switchUrlOpts",null),b(A(t),"_isProcessQuotaExceeded",!1),b(A(t),"_loadSegment",m(f().mark((function e(){var r,n,i,s,a,o,u,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._segmentProcessing&&t.media){e.next=2;break}return e.abrupt("return");case 2:if(r=t._playlist,n=r.nextSegment,i=r.lastSegment,s=A(t),a=s.config,.016,o=Math.min(Math.max((null==i?void 0:i.duration)-.008||0,.016),.1),n){e.next=8;break}return e.abrupt("return");case 8:if(t.isLive){e.next=18;break}if(u=t.bufferInfo(),t.media.paused&&!t.media.currentTime&&(u=t.bufferInfo(u.nextStart||.5)),c=Math.abs(u.end-t.media.duration)<o,!(u.remaining>=a.preloadTime||c)){e.next=15;break}return t._tryEos(),e.abrupt("return");case 15:if(!a.preferMMSStreaming||t._bufferService.msStreaming){e.next=17;break}return e.abrupt("return");case 17:!t._urlSwitching&&t._prevSegSn!==n.sn-1&&u.end&&Math.abs(n.start-u.end)>1&&t._playlist.setNextSegmentByIndex(t._playlist.findSegmentIndexByTime(u.end+.1));case 18:return e.abrupt("return",t._loadSegmentDirect());case 19:case"end":return e.stop()}}),e)})))),b(A(t),"_onLoadeddata",(function(){t.isLive&&!t.config.mseLowLatency&&t.media.duration!==1/0&&t._bufferService.updateDuration(1/0).catch((function(e){}))})),b(A(t),"_onPlay",m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.media.seeking||0!==t.media.currentTime){e.next=3;break}return ui.debug("replay currentTime 0, return"),e.abrupt("return");case 3:if(clearTimeout(t._disconnectTimer),!t._reloadOnPlay){e.next=9;break}t._reloadOnPlay=!1,t.replay(!0),e.next=12;break;case 9:return e.next=11,t._loadSegment();case 11:t._startTick();case 12:case"end":return e.stop()}}),e)})))),b(A(t),"_onPause",(function(){if(t.isLive){if(!t._reloadOnPlay){var e=t.config.disconnectTime;if(null==e&&(e=t._playlist.dvrWindow),!Number.isFinite(e))return;clearTimeout(t._disconnectTimer),t._disconnectTimer=setTimeout((function(){t._reloadOnPlay=!0,t._clear()}),e||0)}}else t._stopTick()})),b(A(t),"_onSeeking",m(f().mark((function e(){var r,n,i,s,a,o,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.media){e.next=2;break}return e.abrupt("return");case 2:if(t._onCheckQuotaExceeded(),r=t.media.currentTime,!(n=t._playlist.seekRange)){e.next=10;break}if(!((i=ni(r,n[0],t.isLive?n[1]:t.media.duration))>=0&&Math.abs(r-i)>=.1)){e.next=10;break}return t.media.currentTime=i,e.abrupt("return");case 10:if(s=t._playlist.currentSegment,a=F.info(F.get(t.media),r,.1),!s){e.next=17;break}if(!(a.end&&Math.abs(a.end-s.end)<.2)){e.next=15;break}return e.abrupt("return");case 15:if(!t.isLive||!a.end){e.next=17;break}return e.abrupt("return");case 17:if(o=t._playlist.findSegmentIndexByTime(r),u=t._playlist.getSegmentByIndex(o),null!=o&&u&&(!t._segmentProcessing||u!==t._playlist.nextSegment)){e.next=21;break}return e.abrupt("return");case 21:return ui.debug("seek to",r,u),t._playlist.setNextSegmentByIndex(o),t._stopTick(),e.next=26,t._segmentLoader.cancel();case 26:if(t._segmentProcessing=!1,a.end&&!t.isLive){e.next=30;break}return e.next=30,t._loadSegmentDirect(!0);case 30:t._startTick();case 31:case"end":return e.stop()}}),e)})))),b(A(t),"_onTimeupdate",(function(){if(t.media){var e,r=t.config;if(r.isLive&&r.maxLatency&&r.targetLatency&&t.media){var n=t._playlist.liveEdge;if(!n)return;var i=n-t.media.currentTime;i>=r.maxLatency&&(ui.debug("latency jump, currentTime:".concat(t.media.currentTime,", liveEdge:").concat(n,", latency=").concat(i)),t.media.currentTime=n-r.targetLatency)}if(r.seiInTime)null===(e=t._seiService)||void 0===e||e.throw(t.media.currentTime);t.config.allowedStreamTrackChange&&!t.config.softDecode&&t._checkStreamTrackChange(t.media.currentTime)}})),b(A(t),"_tick",(function(){if(t.media){t._startTick();var e=t.media,r=t._segmentLoader.error;if(t._onCheckQuotaExceeded(),t._isProcessQuotaExceeded&&(t._bufferService.isFull()||(t._isProcessQuotaExceeded=!1,t._segmentProcessing=!1)),r){(!e.readyState||t.bufferInfo(.5).remaining<1)&&(r.fatal=!0,t._emitError(re.network(r)))}else e.readyState&&(!function(e){return e&&!e.paused&&!e.ended&&0!==e.playbackRate&&0!==e.readyState}(e)?e.readyState<2&&t._gapService&&t._gapService.do(e,t.config.maxJumpDistance,!e.currentTime||t.isLive):(t._loadSegment(),t._gapService&&t._gapService.do(e,t.config.maxJumpDistance,t.isLive))),t.isLive||t._tryEos()}})),t.config=(n=(null==(r=e)?void 0:r.media)||document.createElement("video"),e=h(h({maxPlaylistSize:50,retryCount:3,retryDelay:1e3,pollRetryCount:2,loadTimeout:1e4,manifestLoadTimeout:1e4,preloadTime:30,softDecode:!1,bufferBehind:10,maxJumpDistance:3,startTime:0,useLowLatency:!0,targetLatency:10,maxLatency:20,allowedStreamTrackChange:!0,seiInTime:!1,manifestList:[],minSegmentsStartPlay:3,preferMMS:!1,preferMMSStreaming:!1,mseLowLatency:!0,fixerConfig:{forceFixLargeGap:!1,largeGapThreshold:5}},r),{},{media:n})),t.media=t.config.media,t._manifestLoader=new ri(A(t)),t._segmentLoader=new oi(A(t)),t._playlist=new ai(A(t)),t._bufferService=new An(A(t)),e.seiInTime&&(t._seiService=new Ge(A(t))),e.softDecode||(t._gapService=new ze),t._stats=new Ke(A(t),9e4),t.media.addEventListener("loadeddata",t._onLoadeddata),t.media.addEventListener("play",t._onPlay),t.media.addEventListener("pause",t._onPause),t.media.addEventListener("seeking",t._onSeeking),t.media.addEventListener("timeupdate",t._onTimeupdate),t}return g(w,[{key:"isLive",get:function(){return this._playlist.isLive}},{key:"streams",get:function(){return this._playlist.streams}},{key:"currentStream",get:function(){return this._playlist.currentStream}},{key:"hasSubtitle",get:function(){return this._playlist.hasSubtitle}},{key:"totalDuration",get:function(){return this._playlist.totalDuration}},{key:"baseDts",get:function(){var e;return null===(e=this._bufferService)||void 0===e?void 0:e.baseDts}},{key:"abrSwitchPoint",get:function(){var e=this._urlSwitching?this._playlist.currentSegment:this._playlist.nextSegment;return e?e.start+e.duration/2:null}},{key:"speedInfo",value:function(){return this._segmentLoader.speedInfo()}},{key:"bufferInfo",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.1;return F.info(F.get(this.media),null===(e=this.media)||void 0===e?void 0:e.currentTime,t)}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"playbackQuality",value:function(){return function(e){if(!e)return{};if("function"==typeof e.getVideoPlaybackQuality){var t=e.getVideoPlaybackQuality();return{droppedVideoFrames:t.droppedVideoFrames||t.corruptedVideoFrames,totalVideoFrames:t.totalVideoFrames,creationTime:t.creationTime}}return{droppedVideoFrames:e.webkitDroppedFrameCount,totalVideoFrames:e.webkitDecodedFrameCount,creationTime:performance.now()}}(this.media)}},{key:"load",value:(E=m(f().mark((function e(){var t,r,n,i=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:"",r=i.length>1&&void 0!==i[1]?i[1]:{},n="boolean"==typeof r?r:!(null==r||!r.reuseMse),"object"===p(r)&&null!=r&&r.clearSwitchStatus&&(this._urlSwitching=!1,this._switchUrlOpts=null,this.config.startTime=void 0),t&&(this.config.url=t),t=this.config.url,e.next=8,this._reset(n);case 8:return e.next=10,this._loadData(t);case 10:this._startTick();case 11:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{key:"_loadData",value:(S=m(f().mark((function e(t){var r,n,i,s,a,o,u,c,l,d,h,p,v;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{t&&(t=t.trim())}catch(f){}if(t){e.next=3;break}throw this._emitError(new re(Z,ee.OPTION,null,null,"m3u8 url is missing"));case 3:return e.next=5,this._loadM3U8(t);case 5:if(r=e.sent,n=this._playlist.currentStream,!this._urlSwitching){e.next=23;break}if(!this.isLive){e.next=14;break}i=this._playlist.setNextSegmentBySN(this._prevSegSn),ui.log("segment nb=".concat(this._prevSegSn," index of ").concat(i," in the new playlist")),-1===i&&(this._prevSegCc=null,this._prevSegSn=null),e.next=23;break;case 14:if(0===n.bitrate&&null!==(s=this._switchUrlOpts)&&void 0!==s&&s.bitrate&&(n.bitrate=null===(u=this._switchUrlOpts)||void 0===u?void 0:u.bitrate),c="number"==typeof(null===(a=this._switchUrlOpts)||void 0===a?void 0:a.startTime)?null===(o=this._switchUrlOpts)||void 0===o?void 0:o.startTime:this._getSeamlessSwitchPoint(),this.config.startTime=c,l=this._playlist.findSegmentIndexByTime(c),!(d=this._playlist.getSegmentByIndex(l+1))){e.next=23;break}return h=d.start,e.next=23,this._bufferService.removeBuffer(h);case 23:if(r){e.next=25;break}return e.abrupt("return");case 25:if(!this.isLive){e.next=36;break}if(this._bufferService.setLiveSeekableRange(0,4294967295),ui.log("totalDuration first time got:",this._playlist.totalDuration),ui.log("nb segments got:",this._playlist.nbSegments),this.config.targetLatency<this._playlist.totalDuration&&(this.config.targetLatency=this._playlist.totalDuration,this.config.maxLatency=1.5*this.config.targetLatency),r.isMaster||this._pollM3U8(t),!(this._playlist.nbSegments<this.config.minSegmentsStartPlay)){e.next=33;break}return e.abrupt("return");case 33:return e.next=35,this._loadSegment();case 35:return e.abrupt("return");case 36:return e.next=38,this._bufferService.updateDuration(n.totalDuration);case 38:return(p=this.config.startTime)&&(null!==(v=this._switchUrlOpts)&&void 0!==v&&v.seamless||(this.media.currentTime=p),this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(p)||0)),e.next=42,this._loadSegment();case 42:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"replay",value:(_=m(f().mark((function e(t){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.config.startTime=0,this._urlSwitching=!1,this._switchUrlOpts=null,e.next=5,this.load();case 5:return this._reloadOnPlay=!1,e.abrupt("return",this.media.play(!t));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"switchURL",value:(v=m(f().mark((function e(t){var r,n,i,s,a,o,u,c=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=c.length>1&&void 0!==c[1]?c[1]:{},n={seamless:!1,startTime:0,bitrate:0},e.t0=p(r),e.next="number"===e.t0?5:"boolean"===e.t0?7:"object"===e.t0?9:11;break;case 5:return r={startTime:r},e.abrupt("break",12);case 7:return r={seamless:r},e.abrupt("break",12);case 9:for(i in r)void 0!==r[i]&&null!==r[i]||delete r[i];return e.abrupt("break",12);case 11:throw"unsupported switchURL args: ".concat(r);case 12:if(r=Object.assign({},n,r),a=(s=r).seamless,o=s.startTime,this.config.url=t,this.config.startTime=o,this._switchUrlOpts=r,a){e.next=38;break}if(e.prev=18,!this.config.softDecode){e.next=23;break}e.t1=this.load(t),e.next=26;break;case 23:return e.next=25,this.load(t);case 25:e.t1=e.sent;case 26:u=e.t1,e.next=33;break;case 29:throw e.prev=29,e.t2=e.catch(18),this.emit(Sn.SWITCH_URL_FAILED,e.t2),e.t2;case 33:return this._reloadOnPlay=!1,u&&this.emit(Sn.SWITCH_URL_SUCCESS,{url:t}),e.abrupt("return",this.media.play(!0));case 38:return this._urlSwitching=!0,this.isLive||(this._prevSegSn=null,this._prevSegCc=null),this._playlist.reset(),this._bufferService.seamlessSwitch(),e.next=44,this._clear();case 44:return e.next=46,this._loadData(t);case 46:this._startTick();case 47:this._switchUrlOpts=null;case 48:case"end":return e.stop()}}),e,this,[[18,29]])}))),function(e){return v.apply(this,arguments)})},{key:"switchStream",value:(d=m(f().mark((function e(t){var r,n,i,s,a,o=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!(o.length>1&&void 0!==o[1])||o[1],n=this.currentStream,i=this.streams,n&&n.id!==t&&i&&!(i.length<2)){e.next=5;break}return e.abrupt("return");case 5:if(s=i.find((function(e){return e.id===t}))){e.next=8;break}return e.abrupt("return");case 8:return e.prev=8,e.next=11,this._clear();case 11:if(!r){e.next=14;break}return e.next=14,this._bufferService.clearAllBuffer();case 14:e.next=19;break;case 16:throw e.prev=16,e.t0=e.catch(8),this._emitError(re.create(e.t0));case 19:if(n.currentAudioStream&&s.audioStreams.length>2&&(a=n.currentAudioStream.id,s.currentAudioStream=s.audioStreams.find((function(e){return e.id===a}))||s.currentAudioStream),this._playlist.currentStream=s,e.prev=21,!this.isLive&&s.segments.length){e.next=25;break}return e.next=25,this._refreshM3U8();case 25:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,e.next=29,this._loadSegmentDirect();case 29:e.next=35;break;case 31:throw e.prev=31,e.t1=e.catch(21),this._playlist.currentStream=n,e.t1;case 35:return this._startTick(),e.abrupt("return",s);case 37:case"end":return e.stop()}}),e,this,[[8,16],[21,31]])}))),function(e){return d.apply(this,arguments)})},{key:"switchAudioStream",value:(l=m(f().mark((function e(t){var r,n,i,s,a=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=!(a.length>1&&void 0!==a[1])||a[1],n=this.currentStream){e.next=4;break}return e.abrupt("return");case 4:if((i=n.currentAudioStream)&&i.id!==t&&!(n.audioStreams.length<2)){e.next=7;break}return e.abrupt("return");case 7:if(s=n.audioStreams.find((function(e){return e.id===t}))){e.next=10;break}return e.abrupt("return");case 10:return e.prev=10,e.next=13,this._clear();case 13:if(!r){e.next=16;break}return e.next=16,this._bufferService.clearAllBuffer();case 16:e.next=21;break;case 18:throw e.prev=18,e.t0=e.catch(10),this._emitError(re.create(e.t0));case 21:if(n.currentAudioStream=s,e.prev=22,!this.isLive&&s.segments.length){e.next=26;break}return e.next=26,this._refreshM3U8();case 26:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,e.next=30,this._loadSegmentDirect();case 30:e.next=36;break;case 32:throw e.prev=32,e.t1=e.catch(22),n.currentAudioStream=i,e.t1;case 36:return this._startTick(),e.abrupt("return",s);case 38:case"end":return e.stop()}}),e,this,[[10,18],[22,32]])}))),function(e){return l.apply(this,arguments)})},{key:"switchSubtitleStream",value:(c=m(f().mark((function e(t){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._playlist.switchSubtitle(t),e.next=3,this._manifestLoader.stopPoll();case 3:return e.next=5,this._refreshM3U8();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"detachMedia",value:(u=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._bufferService){e.next=3;break}return e.next=3,this._bufferService.detachMedia();case 3:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"destroy",value:(o=m(f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.media){e.next=2;break}return e.abrupt("return");case 2:return this.removeAllListeners(),this._playlist.reset(),this._segmentLoader.reset(),null===(t=this._seiService)||void 0===t||t.reset(),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("pause",this._onPause),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),e.next=13,Promise.all([this._clear(),this._bufferService.destroy()]);case 13:this.media=null;case 14:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_loadM3U8",value:(a=m(f().mark((function e(t){var r,n,i,s,a,o,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(s=null===(n=this.config.manifestList)||void 0===n||null===(i=n.filter((function(e){return e.url===t}))[0])||void 0===i?void 0:i.manifest)){e.next=6;break}e.t0=this._manifestLoader.parseText(s,t),e.next=9;break;case 6:return e.next=8,this._manifestLoader.load(t);case 8:e.t0=e.sent;case 9:a=e.t0,o=P(a,1),r=o[0],e.next=17;break;case 14:throw e.prev=14,e.t1=e.catch(0),this._emitError(re.create(e.t1));case 17:if(r){e.next=19;break}return e.abrupt("return");case 19:if(this._playlist.upsertPlaylist(r),!r.isMaster){e.next=24;break}return null!==(u=this._playlist.currentStream.subtitleStreams)&&void 0!==u&&u.length&&this.emit(Sn.SUBTITLE_PLAYLIST,{list:this._playlist.currentStream.subtitleStreams}),e.next=24,this._refreshM3U8();case 24:return this.emit(Sn.STREAM_PARSED),e.abrupt("return",r);case 26:case"end":return e.stop()}}),e,this,[[0,14]])}))),function(e){return a.apply(this,arguments)})},{key:"_refreshM3U8",value:function(){var e,t,r=this,n=this._playlist.currentStream;if(!n||!n.url)throw this._emitError(re.create(null,null,new Error("m3u8 url is not defined")));var i=n.url,s=null===(e=n.currentAudioStream)||void 0===e?void 0:e.url,a=null===(t=n.currentSubtitleStream)||void 0===t?void 0:t.url;return this._manifestLoader.load(i,s,a).then((function(e){var t=P(e,3),n=t[0],o=t[1],u=t[2];n&&(r._playlist.upsertPlaylist(n,o,u),r.isLive&&r._pollM3U8(i,s,a))})).catch((function(e){throw r._emitError(re.create(e))}))}},{key:"_pollM3U8",value:function(e,t,r){var n,i,s=this,a=this._playlist.isEmpty;this._playlist.lowLatency?n=1e3*(this._playlist.currentStream.partTargetDuration||0):n=1e3*((null===(i=this._playlist.lastSegment)||void 0===i?void 0:i.duration)||0);this._manifestLoader.poll(e,t,r,(function(e,t,r){s._playlist.upsertPlaylist(e,t,r),s._playlist.clearOldSegment(),(e&&a&&!s._playlist.isEmpty||!s._playlist.hadSegmentLoaded&&s._playlist.nbSegments>=s.config.minSegmentsStartPlay)&&s._loadSegment(),a&&(a=s._playlist.isEmpty)}),(function(e){s._emitError(re.create(e))}),n)}},{key:"_loadSegmentDirect",value:(s=m(f().mark((function e(t){var r,n,i,s,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=this._playlist.nextSegment){e.next=3;break}return e.abrupt("return");case 3:return n=!1,i=null,e.prev=5,this._segmentProcessing=!0,ui.log("load segment, sn:".concat(r.sn,", [").concat(r.start,", ").concat(r.end,"], partIndex:").concat(r.partIndex)),e.next=10,this._reqAndBufferSegment(r,this._playlist.getAudioSegment(r));case 10:n=e.sent,e.next=16;break;case 13:e.prev=13,e.t0=e.catch(5),i=e.t0;case 16:return e.prev=16,this._segmentProcessing=!1,e.finish(16);case 19:if(!i){e.next=26;break}if(!this._bufferService.isFull()){e.next=25;break}return ui.log("load segment, sn:".concat(r.sn,", partIndex:").concat(r.partIndex)),this._segmentProcessing=!0,this._isProcessQuotaExceeded=!0,e.abrupt("return",!1);case 25:return e.abrupt("return",this._emitError(re.create(i)));case 26:return n&&(a=this.bufferInfo().end,this.isLive&&!this.media.seeking&&a&&Math.abs(r.end-a)>1&&(ui.warn("segment: ".concat(r.sn," expected end=").concat(r.end,", real end=").concat(a)),this._playlist.feedbackLiveEdge(r,a)),o=(null===(s=this._playlist.currentStream)||void 0===s?void 0:s.url)===r.parentUrl,this._urlSwitching&&!o&&(ui.warn("pre playlist segment appended!"),this._bufferService.seamlessSwitch()),this.isLive&&this._urlSwitching&&o&&(this._urlSwitching=!1,this.emit(Sn.SWITCH_URL_SUCCESS,{url:this.config.url})),this._playlist.moveSegmentPointer(),r.isLast?this._end():t||this._loadSegment()),e.abrupt("return",n);case 28:case"end":return e.stop()}}),e,this,[[5,13,16,19]])}))),function(e){return s.apply(this,arguments)})},{key:"_reqAndBufferSegment",value:(i=m(f().mark((function e(t,r){var n,i,s,a,o,u,c,l,d,h,p;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t?t.cc:r.cc,s=this._prevSegCc!==i,a=[],e.prev=3,e.next=6,this._segmentLoader.load(t,r,s);case 6:a=e.sent,e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(3),e.t0.fatal=!1,this._segmentLoader.error=e.t0,e.t0;case 14:if(a[0]){e.next=16;break}return e.abrupt("return");case 16:return e.next=18,(n=this._bufferService).decryptBuffer.apply(n,I(a));case 18:if(o=e.sent){e.next=21;break}return e.abrupt("return");case 21:return u=t?t.sn:r.sn,c=t?t.start:r.start,l=this._playlist.currentStream,this._bufferService.createSource(o[0],o[1],null==l?void 0:l.videoCodec,null==l?void 0:l.audioCodec),d=Date.now(),h=this._prevSegSn===u-1,this.isLive&&this._urlSwitching&&(p=this.bufferInfo().end,this._playlist.updateSegmentsRanges(u,p),ui.warn("update the new playlist liveEdge, segment id=".concat(u,", buffer start=").concat(p,", liveEdge=").concat(this._playlist.liveEdge)),c=p),e.next=30,this._bufferService.appendBuffer(t,r,o[0],o[1],s,h,c);case 30:return this.emit(Sn.APPEND_COST,{elapsed:Date.now()-d,url:t.url}),e.next=33,this._bufferService.evictBuffer(this.config.bufferBehind);case 33:return this._prevSegCc=i,this._prevSegSn=u,e.abrupt("return",!0);case 36:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e,t){return i.apply(this,arguments)})},{key:"_onCheckQuotaExceeded",value:(n=m(f().mark((function e(){var t,r,n,i,s,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.media.currentTime,r=this.media.buffered,n=!1,i=0;case 4:if(!(i<r.length)){e.next=11;break}if(!(r.start(0)>=t&&t<r.end(i))){e.next=8;break}return n=!0,e.abrupt("break",11);case 8:i++,e.next=4;break;case 11:if(!this._bufferService.isFull()){e.next=17;break}if(s=n?this.config.bufferBehind:5,!((a=this.media.currentTime)-s>0)){e.next=17;break}return e.next=17,this._bufferService.removeBuffer(0,a-s);case 17:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_checkStreamTrackChange",value:function(e){var t=this._playlist.checkSegmentTrackChange(e,this._bufferService.nbSb);t&&this.switchURL(this.config.url,t.start+.2)}},{key:"_clear",value:(r=m(f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return clearTimeout(this._disconnectTimer),this._stopTick(),e.next=4,Promise.all([this._segmentLoader.cancel(),this._manifestLoader.stopPoll()]);case 4:this._segmentProcessing=!1;case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_reset",value:(t=m(f().mark((function e(){var t,r,n=arguments;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.length>0&&void 0!==n[0]&&n[0],this._reloadOnPlay=!1,this._prevSegSn=null,this._prevSegCc=null,this._switchUrlOpts=null,this._playlist.reset(),this._segmentLoader.reset(),null===(t=this._seiService)||void 0===t||t.reset(),this._stats.reset(),e.next=11,this._clear();case 11:return e.abrupt("return",this._bufferService.reset(r));case 12:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_end",value:function(){this._clear(),this._bufferService.endOfStream(),(this.media.readyState<=2||this.media.buffered.length>1)&&this._startTick()}},{key:"_stopTick",value:function(){this._tickTimer&&clearTimeout(this._tickTimer),this._tickTimer=null}},{key:"_startTick",value:function(){this._stopTick(),this._tickTimer=setTimeout(this._tick,this._tickInterval)}},{key:"_emitError",value:function(e){var t,r,n,i,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!1===(null===(t=e.originError)||void 0===t?void 0:t.fatal)?ui.warn(e):(ui.table(e),ui.error(e),ui.error(null===(r=this.media)||void 0===r?void 0:r.error),null!==(n=this.media)&&void 0!==n&&n.readyState&&this.media.pause(),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit(Sn.SWITCH_URL_FAILED,e)),this.emit(Sn.ERROR,e),s&&this._end(),null===(i=this._seiService)||void 0===i||i.reset());return e}},{key:"_getSeamlessSwitchPoint",value:function(){var e=this.media,t=e.currentTime;if(!e.paused){var r,n=this._playlist.findSegmentIndexByTime(e.currentTime),i=this._playlist.getSegmentByIndex(n),s=null===(r=this._stats)||void 0===r?void 0:r.getStats().downloadSpeed;if(s&&i)t+=i.duration*this._playlist.currentStream.bitrate/s+1;else t+=5}return t}},{key:"_tryEos",value:function(){var e,t,r=this.media,n=this._playlist,i=n.nextSegment,s=n.lastSegment;if((!i||s&&F.isBuffered(r,s.start+s.duration/2))&&r.readyState&&r.duration>0&&(null===(e=this._bufferService)||void 0===e?void 0:e.msIsOpened)&&!(null!==(t=this._bufferService)&&void 0!==t&&t.msHasOpTasks)){var a=this.bufferInfo();r.paused&&!r.currentTime&&(a=this.bufferInfo(a.nextStart||.5)),(Math.abs(a.end-r.duration)<.1||!this.isLive&&s&&a.end>=s.start+s.duration)&&this._bufferService.endOfStream()}}}],[{key:"isSupported",value:function(e){return e&&"video"!==e&&"audio"!==e?"undefined"!=typeof WebAssembly:ye.isSupported()}},{key:"enableLogger",value:function(){se.enable(),gt.enable()}},{key:"disableLogger",value:function(){se.disable(),gt.disable()}}]),w}(Pe);b(ci,"version","3.0.21-rc.9");try{localStorage.getItem("xgd")?ci.enableLogger():ci.disableLogger()}catch(fi){}var li=function(){function e(t,r){var n=this;y(this,e),b(this,"_opts",null),b(this,"_plugin",null),b(this,"_onLowDecode",(function(){var e,t,r,i,s=n._opts,a=s.media,o=s.innerDegrade;null===(e=n._plugin)||void 0===e||null===(t=e.player)||void 0===t||t.emit("lowdecode",a.degradeInfo),null===(r=n._plugin)||void 0===r||null===(i=r.player)||void 0===i||i.emit("core_event",h(h({},a.degradeInfo),{},{eventName:Sn.LOWDECODE})),1===o&&n._degrade(a.src)})),b(this,"_degrade",(function(e){var t=n._plugin.player,r=t.video;if(!r||"MVideo"===r.TAG){var i=t.video.degradeVideo;t.video=i,r.degrade(e),e&&(t.config.url=e);var s=t.root.firstChild;"MVideo"===s.TAG&&t.root.replaceChild(i,s);var a=n._plugin.constructor.pluginName.toLowerCase();t.unRegisterPlugin(a),t.once("canplay",(function(){t.play()}))}})),b(this,"forceDegradeToVideo",(function(e){1===n._opts.innerDegrade&&n._degrade(e)})),this._opts=t,this._plugin=r,this._init()}return g(e,[{key:"_init",value:function(){var e=this._opts,t=e.media,r=e.preloadTime,n=e.innerDegrade,i=e.isLive;t&&(i||!t.setPlayMode?(n&&t.setAttribute("innerdegrade",n),r&&t.setAttribute("preloadtime",r),this._bindEvents()):t.setPlayMode("VOD"))}},{key:"_bindEvents",value:function(){this._opts.media.addEventListener("lowdecode",this._onLowDecode)}},{key:"destroy",value:function(){var e,t;null===(e=this._opts)||void 0===e||null===(t=e.media)||void 0===t||t.removeEventListener("lowdecode",this._onLowDecode),this._plugin=null}}]),e}(),di=["currentTime"];var hi=function(e){k(r,e);var t=L(r);function r(){var e;y(this,r);for(var n=arguments.length,i=new Array(n),s=0;s<n;s++)i[s]=arguments[s];return b(A(e=t.call.apply(t,[this].concat(i))),"logger",ui),b(A(e),"hls",null),b(A(e),"pluginExtension",null),b(A(e),"getStats",(function(){var t;return null===(t=e.hls)||void 0===t?void 0:t.getStats()})),b(A(e),"_onSwitchSubtitle",(function(t){var r,n=t.lang;null===(r=e.hls)||void 0===r||r.switchSubtitleStream(n)})),b(A(e),"_keepPauseStatus",(function(){e.player.paused&&e.player.once("canplay",(function(){e.player.pause()}))})),e}return g(r,[{key:"core",get:function(){return this.hls}},{key:"version",get:function(){var e;return null===(e=this.hls)||void 0===e?void 0:e.version}},{key:"softDecode",get:function(){var e,t,r=null===(e=this.player)||void 0===e||null===(t=e.config)||void 0===t?void 0:t.mediaType;return!!r&&"video"!==r&&"audio"!==r&&"offscreen-video"!==r}},{key:"beforePlayerInit",value:function(){var e=this,t=this.player.config,r=this.player.media||this.player.video,n=t.hls||{};if((t.url||t.__allowHlsEmptyUrl__)&&(this.softDecode||n.preferMMS||!ye.isMMSOnly())){this.hls&&this.hls.destroy();var i=Object.getOwnPropertyDescriptor(this.player,"switchURL");i&&!i.writable||(this.player.switchURL=function(t,r){return new Promise((function(n,i){var s=e.player,a=e.hls;if(a){var o,u,c=function(e,t){var r={startTime:t.player.currentTime};switch(p(e)){case"boolean":r.seamless=e;break;case"object":var n=e.currentTime,i=D(e,di);Object.assign(r,i),"number"==typeof n&&(r.startTime=n)}return r}(r,e);s.config.url=t,a.switchURL(t,c).then((function(){return n(!0)})).catch(i),!c.seamless&&null!==(o=e.player.config)&&void 0!==o&&null!==(u=o.hls)&&void 0!==u&&u.keepStatusAfterSwitch&&e._keepPauseStatus()}else i()}))});var s,a=this.player.switchURL;if(this.player.handleSource=!1,n.innerDegrade=n.innerDegrade||t.innerDegrade,null!==n.disconnectTime&&void 0!==n.disconnectTime||(n.disconnectTime=0),this.hls=new ci(h({softDecode:this.softDecode,isLive:t.isLive,media:r,startTime:t.startTime,url:t.url},n)),this.softDecode||l.BasePlugin.defineGetterOrSetter(this.player,{url:{get:function(){var t,r;return null===(t=e.hls)||void 0===t||null===(r=t.media)||void 0===r?void 0:r.src},configurable:!0}}),this.softDecode&&(this.pluginExtension=new li(h({isLive:t.isLive,media:r},n),this),this.player.forceDegradeToVideo=function(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return null===(t=e.pluginExtension)||void 0===t?void 0:t.forceDegradeToVideo.apply(t,n)}),t.isLive)null===(s=this.player)||void 0===s||s.useHooks("replay",(function(){var t;return null===(t=e.hls)||void 0===t?void 0:t.replay()}));this.on(l.Events.URL_CHANGE,a),this.on(l.Events.SWITCH_SUBTITLE||"switch_subtitle",this._onSwitchSubtitle),this.on(l.Events.DESTROY,this.destroy.bind(this)),this._transError(),this._transCoreEvent(Re.TTFB),this._transCoreEvent(Re.LOAD_START),this._transCoreEvent(Re.LOAD_RESPONSE_HEADERS),this._transCoreEvent(Re.LOAD_COMPLETE),this._transCoreEvent(Re.LOAD_RETRY),this._transCoreEvent(Re.SOURCEBUFFER_CREATED),this._transCoreEvent(Re.MEDIASOURCE_OPENED),this._transCoreEvent(Re.APPEND_BUFFER),this._transCoreEvent(Re.REMOVE_BUFFER),this._transCoreEvent(Re.BUFFEREOS),this._transCoreEvent(Re.KEYFRAME),this._transCoreEvent(Re.METADATA_PARSED),this._transCoreEvent(Re.DEMUXED_TRACK),this._transCoreEvent(Re.SEI),this._transCoreEvent(Re.SEI_IN_TIME),this._transCoreEvent(Re.SPEED),this._transCoreEvent(Re.HLS_MANIFEST_LOADED),this._transCoreEvent(Re.HLS_LEVEL_LOADED),this._transCoreEvent(Re.STREAM_EXCEPTION),this._transCoreEvent(Re.SWITCH_URL_SUCCESS),this._transCoreEvent(Re.SWITCH_URL_FAILED),this._transCoreEvent(Sn.NO_AUDIO_TRACK),this._transCoreEvent(Sn.STREAM_PARSED),this._transCoreEvent(Sn.SUBTITLE_SEGMENTS),this._transCoreEvent(Sn.SUBTITLE_PLAYLIST),this._transCoreEvent(Sn.APPEND_COST),t.url&&this.hls.load(t.url,{reuseMse:!0}).catch((function(e){}))}}},{key:"destroy",value:function(){var e;this.hls&&(this.hls.destroy(),this.hls=null),null===(e=this.pluginExtension)||void 0===e||e.destroy(),this.pluginExtension=null}},{key:"_transError",value:function(){var e=this;this.hls.on(Sn.ERROR,(function(t){e.player&&e.player.emit(l.Events.ERROR,new l.Errors(e.player,t))}))}},{key:"_transCoreEvent",value:function(e){var t=this;this.hls.on(e,(function(r){t.player&&(t.player.emit("core_event",h(h({},r),{},{eventName:e})),e===Re.SEI_IN_TIME&&t.hls.hasSubtitle&&t._emitSeiPaylodTime(r))}))}},{key:"_emitSeiPaylodTime",value:function(e){try{var t=JSON.parse(Array.from(e.data.payload).map((function(e){return String.fromCharCode(e)})).join("").slice(0,-1));if(!t.rtmp_dts)return;this.player.emit("core_event",{eventName:Sn.SEI_PAYLOAD_TIME,time:t.rtmp_dts})}catch(r){}}}],[{key:"pluginName",get:function(){return"hls"}},{key:"isSupported",value:function(e,t){return ci.isSupported(e,t)}}]),r}(l.BasePlugin);return b(hi,"Hls",ci),b(hi,"EVENT",Sn),hi}));
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|