xgplayer-mp4-loader 3.0.9-rc.21 → 3.0.9-rc.23

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/dist/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.array.find.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.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.regexp.exec.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.json.stringify.js"),require("core-js/modules/es.array.join.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.string.includes.js"),require("core-js/modules/es.number.is-finite.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.array.find-index.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.string.match.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.find.js","core-js/modules/es.object.to-string.js","core-js/modules/es.array.slice.js","core-js/modules/es.object.assign.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.keys.js","core-js/modules/es.promise.js","core-js/modules/es.array.iterator.js","core-js/modules/es.string.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.regexp.exec.js","core-js/modules/es.function.name.js","core-js/modules/es.array.concat.js","core-js/modules/es.array.map.js","core-js/modules/es.json.stringify.js","core-js/modules/es.array.join.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.string.includes.js","core-js/modules/es.number.is-finite.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.regexp.test.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js","core-js/modules/es.array.find-index.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.string.match.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).MP4Loader=t()}(this,(function(){"use strict";function e(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 t(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(T){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,s=Object.create(a.prototype),o=new j(n||[]);return i(s,"_invoke",{value:x(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(T){return{type:"throw",arg:T}}}e.wrap=l;var f={};function h(){}function p(){}function v(){}var y={};c(y,s,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(B([])));g&&g!==t&&n.call(g,s)&&(y=g);var _=v.prototype=h.prototype=Object.create(y);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,o)}),(function(e){r("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function x(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var o=w(s,r);if(o){if(o===f)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=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function w(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,w(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function S(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 E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function B(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 r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],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,i(_,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,u,"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,c(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},b(k.prototype),c(k.prototype,o,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new k(l(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(_),c(_,u,"Generator"),c(_,s,(function(){return this})),c(_,"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=B,j.prototype={constructor:j,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(E),!e)for(var t in this)"t"===t.charAt(0)&&n.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 r(r,n){return s.type="throw",s.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 a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},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),E(r),f}},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;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:B(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function n(e){return(n="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 i(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,u,"next",e)}function u(e){i(s,n,a,o,u,"throw",e)}o(void 0)}))}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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,j(n.key),n)}}function u(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=j(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(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&&f(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,r){return(p=h()?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&&f(i,r.prototype),i}).apply(null,arguments)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=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 p(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)},v(e)}function y(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(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 m(e)}function _(e){var t=h();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return g(this,r)}}function b(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function k(){return k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=b(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},k.apply(this,arguments)}function x(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,a,s,o=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.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&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(e,t)||S(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 w(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(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 S(e,t){if(e){if("string"==typeof e)return E(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)?E(e,t):void 0}}function E(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 j(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)}function B(){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 A(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var T,C=function(){function e(){s(this,e)}return u(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 a=r.length;if(a&&t){var s=r[a-1],o=s[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(s[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,a=0,s=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),f=0,h=d.length;f<h;f++){var p=d[f];if(r+n>=p[0]&&r<=p[1])i=p[0],a=p[1],s=f;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:a,index:s,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(d)}}}]),e}(),D="network",O="network_timeout",L="network_forbidden",P="network_notfound",U="network_range_not_satisfiable",R="demux",I="remux",M="media",z="drm",F="other",N="runtime",q={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",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"},V=(c(T={},"manifest",{HLS:1100,DASH:1200}),c(T,D,2100),c(T,O,2101),c(T,L,2103),c(T,P,2104),c(T,U,2116),c(T,R,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),c(T,I,{FMP4:4100,MP4:4200}),c(T,M,{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,EME_HIJACK:5301}),c(T,z,{LICENSE:7100,CUSTOM_LICENSE:7200}),c(T,F,8e3),c(T,N,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),T),G=function(e){l(r,e);var t=_(r);function r(e,n,i,a,o){var u;return s(this,r),(u=t.call(this,o||(null==i?void 0:i.message))).errorType=e===O?D:e,u.originError=i,u.ext=a,u.errorCode=V[e][n]||V[e],u.errorMessage=u.message,u.errorCode||(u.errorType=F,u.errorCode=V[u.errorType]),u}return u(r,null,[{key:"create",value:function(e,t,n,i,a){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=F),new r(e,t,n,i,a))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?O:D,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}(v(Error)),H="undefined"!=typeof window,K={DEBUG:1,LOG:2,WARN:3,ERROR:4},W=["Boolean","Number","String","Undefined","Null","Date","Object"],Q=function(){function e(t,r){s(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 u(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,[K.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,[this._prefix,Y()].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,[K.LOG].concat(n)),e.disabled||(t=console).log.apply(t,[this._prefix,Y()].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,[K.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,[this._prefix,Y()].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,[K.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,[this._prefix,Y()].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 a=n.map((function(e){return Z(e)}));t=this._prefix+Y()+JSON.stringify(a)}catch(o){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var s=this.logTextArray.shift();this.logSize-=s.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 Y(){return(new Date).toLocaleString()}function X(e){if("object"!==n(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 Z(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==n(e))return e;var a=Object.prototype.toString.call(e).slice(8,-1);if(!W.includes(a))return a;if(!(r>t)){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r===t?i[s]=X(e[s]):"object"===n(e[s])?i[s]=Z(e[s],t,r+1):i[s]=e[s]);return i}}c(Q,"disabled",!0);var J=function(){try{return H?window.MediaSource:null}catch(e){}}(),$="appendBuffer",ee="removeBuffer",te="updateDuration",re=function(){function e(t,r){var n=this;s(this,e),c(this,"media",null),c(this,"mediaSource",null),c(this,"_openPromise",B()),c(this,"_queue",Object.create(null)),c(this,"_sourceBuffer",Object.create(null)),c(this,"_mseFullFlag",{}),c(this,"_st",0),c(this,"_opst",0),c(this,"_logger",null),c(this,"_config",null),c(this,"_url",null),c(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==te&&t.shift(),r){var i=A()-n._opst;n._logger.debug("UpdateEnd",r.opName,i,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:i}),n._startQueue(e)}}})),c(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 G(M,q.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new Q("MSE"),this._config.openLog&&Q.enable()}var t,n,i;return u(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{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:"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("[debug mse] setDuration ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("[debug mse] setDuration"))}),te,{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=A()-e._st;e._logger.debug("MSE OPEN",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=B()}return this._openPromise}},{key:"bindMedia",value:(i=a(r().mark((function e(t){var n,i,a=this;return r().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(t&&J){e.next=5;break}throw new Error("Param media or MediaSource does not exist");case 5:return this.media=t,n=this.mediaSource=new J,this._st=A(),i=function e(){var r=A()-a._st;a._logger.debug("MSE OPEN"),n.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),a._openPromise.resolve({costtime:r})},n.addEventListener("sourceopen",i),this._url=URL.createObjectURL(n),t.src=this._url,e.abrupt("return",this._openPromise);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unbindMedia",value:(n=a(r().mark((function e(){var t,n,i,a=this;return r().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=a._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)}))})),n=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,n&&i)try{t.endOfStream()}catch(r){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(a._sourceBuffer[e])}catch(r){}}))}if(this.media){this.media.removeAttribute("src");try{this.media.load()}catch(r){}this.media=null}this.mediaSource=null,this._openPromise=B(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.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 G(M,q.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():this._enqueueOp(e,(function(){n.changeType(t),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=A(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),$,r):Promise.resolve()}},{key:"remove",value:function(e,t,r,n){var i=this,a=!1;return this._mseFullFlag[e]&&(a=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var a=i._sourceBuffer[e];t>=r||!a?i._onSBUpdateEnd(e):(i._opst=A(),i._logger.debug("MSE REMOVE START",e,t,r,n),a.remove(t,r))}}),ee,n,a)}},{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,C.end(C.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 C.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return C.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return C.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,n,i){var a=this;if(!this.mediaSource)return Promise.resolve();var s=this._queue[e]=this._queue[e]||[],o={exec:t,promise:B(),opName:r,context:n};return i?(s.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):s.push(o),this.isOpened||this.isEnded?1===s.length&&this._startQueue(e):this._openPromise.then((function(){1===s.length&&a._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=a(r().mark((function e(t,n,i){var a,s,o=this;return r().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((a=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],a.forEach((function(e){var t=o._queue[e],r=B();s.push(r),t.push({exec:function(){r.resolve()},promise:r,opName:n,context:i}),1===t.length&&o._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{a.forEach((function(e){var t=o._queue[e],r=o._sourceBuffer[e];null==t||t.shift(),r&&r.updating||o._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,this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new G(M,q.MSE_FULL,n))):(this._logger.error(n),r.promise.reject(new G(M,q.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(){var t;null===(t=r._sourceBuffer[e])||void 0===t||t.abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"getDefaultConfig",value:function(){return{openLog:!1}}},{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';if(!J)return!1;try{return J.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}}]),e}();c(re,"VIDEO","video"),c(re,"AUDIO","audio");var ne="fetch",ie="xhr",ae="arraybuffer",se="text",oe="json",ue=function(e){l(r,e);var t=_(r);function r(e,n,i,a){var o;return s(this,r),c(m(o=t.call(this,a)),"retryCount",0),c(m(o),"isTimeout",!1),c(m(o),"loaderType",ne),c(m(o),"startTime",0),c(m(o),"endTime",0),c(m(o),"options",{}),o.url=e,o.request=n,o.response=i,o}return u(r)}(v(Error)),ce=Object.prototype.toString;function le(e){if("[object Object]"!==ce.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function de(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 fe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function he(e,t){if(e){if(!t)return e;var r,i=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]"===ce.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===n(e)}(t)&&(t=JSON.stringify(t)),"".concat(fe(e),"=").concat(fe(t))})).join("&")})).filter(Boolean).join("&");if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function pe(e,t,r,n,i,a,s,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:a,firstByteTime:s,endTime:Date.now(),priOptions:l},response:r}}function ve(e,t){return Math.round(8*e*1e3/t/1024)}var ye="real_time_speed",me={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 a(e,t,n,a,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,a||e,s),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 s(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,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s},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,a,s){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,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,s),!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 f,h=l.length;for(c=0;c<h;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(f=1,u=new Array(d-1);f<d;f++)u[f-1]=arguments[f];l[c].fn.apply(l[c].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||s(this,a);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[a]=1===c.length?c[0]:c:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new 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}(me);var ge=me.exports,_e=2097152,be=function(e){l(i,e);var t,n=_(i);function i(){var e;return s(this,i),c(m(e=n.call(this)),"_abortController",null),c(m(e),"_timeoutTimer",null),c(m(e),"_reader",null),c(m(e),"_response",null),c(m(e),"_aborted",!1),c(m(e),"_index",-1),c(m(e),"_range",null),c(m(e),"_receivedLength",0),c(m(e),"_running",!1),c(m(e),"_logger",null),c(m(e),"_vid",""),c(m(e),"_onProcessMinLen",0),c(m(e),"_onCancel",null),c(m(e),"_priOptions",null),c(m(e),"_processMaxGapTime",1/0),e}return u(i,[{key:"load",value:function(e){var t,n=this,i=e.url,s=e.vid,o=e.timeout,u=e.responseType,c=e.onProgress,l=e.index,d=e.onTimeout,f=e.onCancel,h=e.range,p=e.transformResponse,v=e.request,y=e.params,m=e.logger,g=e.method,_=e.headers,b=e.body,k=e.mode,x=e.credentials,w=e.cache,S=e.redirect,E=e.referrer,j=e.referrerPolicy,B=e.onProcessMinLen,A=e.processMaxGapTime,T=e.priOptions;this._logger=m,this._aborted=!1,this._onProcessMinLen=B,this._onCancel=f,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._receivedLength=0,this._index=l,this._range=h||[0,0],this._vid=s||i,this._priOptions=T||{},this._processMaxGapTime=A;var C={method:g,headers:_,body:b,mode:k,credentials:x,cache:w,redirect:S,referrer:E,referrerPolicy:j,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},D=!1;clearTimeout(this._timeoutTimer),i=he(i,y);var O=de(h);O&&(_=v?v.headers:C.headers=C.headers||(Headers?new Headers:{}),Headers&&_ instanceof Headers?_.append("Range",O):_.Range=O),o&&(this._timeoutTimer=setTimeout(a(r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return D=!0,e.next=3,n.cancel();case 3:d&&((t=new ue(i,C,null,"timeout")).isTimeout=!0,d(t,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions}));case 4:case"end":return e.stop()}}),e)}))),o));var L=Date.now();return this._logger.debug("[fetch load start], index,",l,",range,",h),new Promise((function(e,t){fetch(v||i,v?void 0:C).then(function(){var s=a(r().mark((function a(s){var o,d,f,v;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(clearTimeout(n._timeoutTimer),n._response=s,!n._aborted&&n._running){r.next=4;break}return r.abrupt("return");case 4:if(p&&(s=p(s,i)||s),s.ok){r.next=7;break}throw new ue(i,C,s,"bad network response");case 7:if(o=Date.now(),u!==se){r.next=15;break}return r.next=11,s.text();case 11:d=r.sent,n._running=!1,r.next=37;break;case 15:if(u!==oe){r.next=22;break}return r.next=18,s.json();case 18:d=r.sent,n._running=!1,r.next=37;break;case 22:if(!c){r.next=29;break}return n.resolve=e,n.reject=t,n._loadChunk(s,c,L,o),r.abrupt("return");case 29:return r.next=31,s.arrayBuffer();case 31:d=r.sent,d=new Uint8Array(d),n._running=!1,f=Date.now()-L,v=ve(d.byteLength,f),n.emit(ye,{speed:v,len:d.byteLength,time:f,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions});case 37:n._logger.debug("[fetch load end], index,",l,",range,",h),e(pe(d,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),L,o,l,h,n._vid,n._priOptions));case 39:case"end":return r.stop()}}),a)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){var r;clearTimeout(n._timeoutTimer),n._running=!1,n._aborted&&!D||((e=e instanceof ue?e:new ue(i,C,null,null===(r=e)||void 0===r?void 0:r.message)).startTime=L,e.endTime=Date.now(),e.isTimeout=D,e.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},t(e))}))}))}},{key:"cancel",value:(t=a(r().mark((function e(){return r().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,n,i){var s=this;if(!e.body||!e.body.getReader){this._running=!1;var o=new ue(e.url,"",e,"onProgress of bad response.body.getReader");return o.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(o)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(_e),this._writeIdx=0);var u,c,l,d=this._reader=e.body.getReader(),f=Date.now(),h=function(){var o=a(r().mark((function a(){var o,p,v,y,m,g,_,b,k;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return c=Date.now(),r.prev=1,r.next=4,d.read();case 4:u=r.sent,l=Date.now(),r.next=13;break;case 8:return r.prev=8,r.t0=r.catch(1),l=Date.now(),s._aborted||(s._running=!1,r.t0.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.reject(r.t0)),r.abrupt("return");case 13:if(p=(null===(o=s._range)||void 0===o?void 0:o.length)>0?s._range[0]:0,v=p+s._receivedLength,!s._aborted){r.next=19;break}return s._running=!1,t(void 0,!1,{range:[v,v],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e),r.abrupt("return");case 19:if(y=u.value?u.value.byteLength:0,s._receivedLength+=y,s._onProcessMinLen>0?s._writeIdx+y>=s._onProcessMinLen||u.done?((m=new Uint8Array(s._writeIdx+y)).set(s._cache.subarray(0,s._writeIdx),0),y>0&&m.set(u.value,s._writeIdx),s._writeIdx=0,s._logger.debug("【fetchLoader,onProgress enough】,done,",u.done,",len,",m.byteLength,", writeIdx,",s._writeIdx)):y>0&&s._writeIdx+y<_e?(s._cache.set(u.value,s._writeIdx),s._writeIdx+=y,s._logger.debug("【fetchLoader,onProgress cache】,len,",y,", writeIdx,",s._writeIdx)):y>0&&(g=new Uint8Array(s._writeIdx+y+2048),s._logger.debug("【fetchLoader,onProgress extra start】,size,",s._writeIdx+y+2048,", datalen,",y,", writeIdx,",s._writeIdx),g.set(s._cache.subarray(0,s._writeIdx),0),y>0&&g.set(u.value,s._writeIdx),s._writeIdx+=y,delete s._cache,s._cache=g,s._logger.debug("【fetchLoader,onProgress extra end】,len,",y,", writeIdx,",s._writeIdx)):m=u.value,!(m&&m.byteLength>0||u.done)){r.next=28;break}s._logger.debug("【fetchLoader,onProgress call】,task,",s._range,", start,",v,", end,",p+s._receivedLength,", done,",u.done,n),t(m,u.done,{range:[s._range[0]+s._receivedLength-(m?m.byteLength:0),s._range[0]+s._receivedLength],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e),f=Date.now(),r.next=37;break;case 28:if(!(Date.now()-f>=s._processMaxGapTime)){r.next=37;break}return s._logger.debug("[onProgress timeout],task: ".concat(JSON.stringify(s._range)," done: ").concat(u.done," processMaxGapTime: ").concat(s._processMaxGapTime)),(_=new ue(e.url,null,e,"process timeout")).options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.running=!1,r.next=35,s.cancel();case 35:return s.reject(_),r.abrupt("return");case 37:u.done?(b=Date.now()-n,k=ve(s._receivedLength,b),s.emit(ye,{speed:k,len:s._receivedLength,time:b,vid:s._vid,index:s._index,range:s._range,priOptions:s._priOptions}),s._running=!1,s._logger.debug("[fetchLoader onProgress end],task,",s._range,",done,",u.done),s.resolve(pe(u,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),n,i,s._index,s._range,s._vid,s._priOptions))):h();case 38:case"end":return r.stop()}}),a,null,[[1,8]])})));return function(){return o.apply(this,arguments)}}();h()}},{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)}}]),i}(ge);var ke=function(e){l(n,e);var r=_(n);function n(){var e;return s(this,n),c(m(e=r.call(this)),"_xhr",null),c(m(e),"_aborted",!1),c(m(e),"_timeoutTimer",null),c(m(e),"_range",null),c(m(e),"_receivedLength",0),c(m(e),"_url",null),c(m(e),"_onProgress",null),c(m(e),"_index",-1),c(m(e),"_headers",null),c(m(e),"_currentChunkSizeKB",384),c(m(e),"_timeout",null),c(m(e),"_xhr",null),c(m(e),"_withCredentials",null),c(m(e),"_startTime",-1),c(m(e),"_loadCompleteResolve",null),c(m(e),"_loadCompleteReject",null),c(m(e),"_runing",!1),c(m(e),"_logger",!1),c(m(e),"_vid",""),c(m(e),"_responseType",void 0),c(m(e),"_credentials",void 0),c(m(e),"_method",void 0),c(m(e),"_transformResponse",void 0),c(m(e),"_firstRtt",void 0),c(m(e),"_onCancel",null),c(m(e),"_priOptions",null),e}return u(n,[{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=he(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 ue?e:new ue(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===ae&&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 a=new ue(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));a.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(a)},r.ontimeout=function(e){t.cancel();var r=new ue(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=de(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(a){a.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(a)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var r,n=e.target.status;if(n<200||n>299){var i=new ue(this._url,null,t(t({},e.target.response),{},{status:n}),"bad response,status:"+n);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var a,s=null,o=!1,u=(null===(r=this._range)||void 0===r?void 0:r.length)>0?this._range[0]:0;if(this._responseType===ae){var c,l=new Uint8Array(e.target.response);if(a=u+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,f=ve(this._receivedLength,d);this.emit(ye,{speed:f,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[a,u+this._receivedLength],priOptions:this._priOptions})}s=l,o=!((null===(c=this._range)||void 0===c?void 0:c.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",a,"end ",u+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",o)}else o=!0,s=e.target.response;var h={ok:n>=200&&n<300,status:n,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(h=this._transformResponse(h,this._url)||h),this._onProgress&&this._onProgress(s,o,{index:this._index,vid:this._vid,range:[a,u+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},h),o?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(pe(this._onProgress?null:s,o,h,h.headers["content-length"],h.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,k(d(n.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=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=S(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 a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(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(a){n.e(a)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),n}(ge),xe=["retry","retryDelay","onRetryError","transformError"],we=function(){function e(t,r){s(this,e),this.promise=B(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new Q("Loader")),this._loaderType=t,this._loader=t===ne&&window.fetch?new be:new ke,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return u(e,[{key:"exec",value:function(){var e=this,t=this._config,n=t.retry,i=t.retryDelay,s=t.onRetryError,o=t.transformError,u=y(t,xe),c=function(){var t=a(r().mark((function t(){var a,l,d;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(u);case 3:a=t.sent,e.promise.resolve(a),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,l=t.t0,o&&(l=o(l)||l),s&&e._retryCount>0&&s(l,e._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),e._retryCount++,d=!0,e._retryCheckFunc&&(d=e._retryCheckFunc(t.t0)),!(d&&e._retryCount<=n)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",u.range),e._retryTimer=setTimeout(c,i),t.abrupt("return");case 26:e.promise.reject(l);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return c(),this.promise}},{key:"cancel",value:(t=a(r().mark((function e(){return r().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 Se(){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=t.reduce((function(e,t){return e+t.byteLength}),0),i=Ee(n),a=0;return t.forEach((function(e){i.set(e,a),a+=e.byteLength})),i}function Ee(e){for(var t,r=0;r<10;)try{if((t=new Uint8Array(e))&&t.byteLength>0)break;r++}catch(n){if(!(r<10))throw new Error("new array failed final,".concat(null==n?void 0:n.message));r++}return t}function je(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var Be=function(e){l(o,e);var n,i=_(o);function o(e){var r;return s(this,o),c(m(r=i.call(this,e)),"type",ne),c(m(r),"_queue",[]),c(m(r),"_alive",[]),c(m(r),"_currentTask",null),c(m(r),"_finnalUrl",""),c(m(r),"_config",void 0),r._config=function(e){return t({loaderType:ne,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:se,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,processMaxGapTime:1/0},e)}(e),r._config.loaderType!==ie&&be.isSupported()||(r.type=ie),r.log=e.logger,r}return u(o,[{key:"isFetch",value:function(){return this.type===ne}},{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&&le(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&le(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new we(this.type,r);return n.loader.on(ye,(function(e){t.emit(ye,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(n=a(r().mark((function e(){var t;return r().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,je();case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.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 be.isSupported()}}]),o}(ge),Ae="video",Te="audio",Ce="metadata",De="avc",Oe="hevc",Le="vvcC",Pe="aac",Ue="g7110a",Re="g7110m",Ie="LARGE_AV_SHIFT",Me="LARGE_VIDEO_GAP",ze="LARGE_VIDEO_GAP_BETWEEN_CHUNK",Fe="LARGE_AUDIO_GAP",Ne="AUDIO_FILLED",qe="AUDIO_DROPPED",Ve=function(){function e(){s(this,e),c(this,"id",1),c(this,"type",Ae),c(this,"codecType",De),c(this,"pid",-1),c(this,"hvcC",void 0),c(this,"codec",""),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"sequenceNumber",0),c(this,"baseMediaDecodeTime",0),c(this,"baseDts",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"pps",[]),c(this,"sps",[]),c(this,"vps",[]),c(this,"fpsNum",0),c(this,"fpsDen",0),c(this,"sarRatio",[]),c(this,"width",0),c(this,"height",0),c(this,"nalUnitSize",4),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"isVideo",!0),c(this,"kid",null),c(this,"pssh",null),c(this,"ext",void 0)}return u(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:"exist",value:function(){return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),Ge=function(){function e(){s(this,e),c(this,"id",2),c(this,"type",Te),c(this,"codecType",Pe),c(this,"pid",-1),c(this,"codec",""),c(this,"sequenceNumber",0),c(this,"sampleDuration",0),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"baseMediaDecodeTime",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"baseDts",0),c(this,"sampleSize",16),c(this,"sampleRate",0),c(this,"channelCount",0),c(this,"objectType",0),c(this,"sampleRateIndex",0),c(this,"config",[]),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"kid",null),c(this,"ext",void 0)}return u(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.codecType===Pe)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}}]),e}(),He=function(){function e(t,r,n){s(this,e),c(this,"flag",{}),c(this,"keyframe",!1),c(this,"gopId",0),c(this,"duration",0),c(this,"size",0),c(this,"units",[]),c(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return u(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}(),Ke=u((function e(t,r,n,i){s(this,e),c(this,"duration",1024),c(this,"flag",{dependsOn:2,isNonSyncSample:0}),c(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),We=u((function e(t,r){s(this,e),c(this,"time",0),this.data=t,this.originPts=this.pts=r})),Qe=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(We),Ye=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(We),Xe=function(){function e(){s(this,e),c(this,"id",3),c(this,"type",Ce),c(this,"timescale",0),c(this,"flvScriptSamples",[]),c(this,"seiSamples",[])}return u(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}(),Ze=function(){function e(t){if(s(this,e),c(this,"_bytesAvailable",void 0),c(this,"_bitsAvailable",0),c(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return u(e,[{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}(),Je=function(){function e(t){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return u(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}();c(Je,"disabled",!0);var $e=function(){function e(){s(this,e)}return u(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,a=t.length;i<a;)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 s=(31&n[i])<<6|63&n[i+1];if(s>=128){r.push(String.fromCharCode(65535&s)),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}(),et="undefined"!=typeof window,tt=et&&navigator.userAgent.toLocaleLowerCase(),rt=et&&/^((?!chrome|android).)*safari/.test(tt),nt=et&&tt.includes("firefox"),it=et&&tt.includes("android");function at(){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 st=Math.pow(2,32);function ot(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function ut(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 ct(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getInt32(t)}function lt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ut(e,t)*st+ut(e,t+4)}function dt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getUint32(t)<<32|r.getUint32(t+4)}function ft(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 ht(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)}))}var pt=function(){function e(){s(this,e)}return u(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,n=0;null!==e[r]&&void 0!==e[r]&&1!==e[r];)r++;if((n=++r+2)>=t)return[];for(var i=[];n<t;)switch(e[n]){case 0:if(0!==e[n-1]){n+=2;break}if(0!==e[n-2]){n++;break}r!==n-2&&i.push(e.subarray(r,n-2));do{n++}while(1!==e[n]&&n<t);n=(r=n+1)+2;break;case 1:if(0!==e[n-1]||0!==e[n-2]){n+=3;break}r!==n-2&&i.push(e.subarray(r,n-2)),n=(r=n+1)+2;break;default:n+=3}return r<t&&i.push(e.subarray(r)),i}},{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=[],a=0;a+t<n;)if(r=ut(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>n)break;i.push(e.subarray(a,a+r)),a+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,a=0,s="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)a+=255,n++;if(a+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)s+=e[n].toString(16),n++;return{payload:e.subarray(n),type:i,size:a,uuid:s}}},{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,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}}]),e}(),vt=function(){function e(){s(this,e)}return u(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),a=[],s=[],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,a.push(l),r||(r=e.parseSPS(pt.removeEPB(l)))}var d,f=t[o];o++;for(var h=0;h<f;h++)d=t[o]<<8|t[o+1],o+=2,d&&(s.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new Ze(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var a=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 s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?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 f=t.readUEG(),h=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,y,m,g,_,b=0,k=0,x=0,w=0;if(t.readBool()&&(b=t.readUEG(),k=t.readUEG(),x=t.readUEG(),w=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 S=t.readBits(32),E=t.readBits(32);y=t.readBool(),_=(m=E)/(g=2*S)}}return{codec:ft(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:a,width:Math.ceil(16*(f+1)-2*(b+k)),height:(2-p)*(h+1)*16-(p?2:4)*(x+w),sarRatio:v,fpsNum:m,fpsDen:g,fps:_,fixedFrame:y}}}]),e}(),yt=function(){function e(){s(this,e)}return u(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 a=i,s=[],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),f=(1&t[i+2])<<2|(192&t[i+3])>>>6,h=e._getConfig(o,f,d),p=h.config,v=h.codec,y=0,m=e.getFrameDuration(u);i+7<n;)if(255===t[i]&&240==(246&t[i+1])){if(n-i<(l=(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>5))break;c=2*(1&~t[i+1]),s.push({pts:r+y*m,data:t.subarray(i+7+c,i+l)}),y++,i+=l}else i++;return{skip:a,remaining:i>=n?void 0:t.subarray(i),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType:d,channelCount:f,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,a=e.FREQ[n];if(a){var s=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:a,objectType:r,channelCount:i,config:s.config,codec:s.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,a=[];return nt?e>=6?(n=5,i=e-3):(n=2,i=e):it?(n=2,i=e):(n=2===r||5===r?r:5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),a[0]=n<<3,a[0]|=(14&e)>>1,a[1]=(1&e)<<7,a[1]|=t<<3,5===n&&(a[1]|=(14&i)>>1,a[2]=(1&i)<<7,a[2]|=8,a[3]=0),{config:a,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}();c(yt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var mt=function(){function e(t){if(s(this,e),c(this,"_bytesAvailable",void 0),c(this,"_bitsAvailable",0),c(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return u(e,[{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:"bitsPos",value:function(){return 8*this._bytesAvailable-this._bitsAvailable}},{key:"bitsLeft",value:function(){return 8*this._data.length-this.bitsPos()}},{key:"byteAligned",value:function(){return 0===this.bitsPos()||this.bitsPos()%8==0}},{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){s(this,e),this._buffer=t,this._offset=0,this._heldBits=0,this._numHeldBits=0}return u(e,[{key:"readUint8",value:function(){return this._buffer[this._offset++]}},{key:"readUint16",value:function(){return this._buffer[this._offset++]<<8|this._buffer[this._offset++]}},{key:"readUint32",value:function(){return this._buffer[this._offset++]<<24|this._buffer[this._offset++]<<16|this._buffer[this._offset++]<<8|this._buffer[this._offset++]}},{key:"readUint8Array",value:function(e){var t=this._buffer.slice(this._offset,this._offset+e);return this._offset+=e,t}},{key:"streamRead1Bytes",value:function(){this._heldBits=this.readUint8(),this._numHeldBits=8}},{key:"streamRead2Bytes",value:function(){this._heldBits=this.readUint16(),this._numHeldBits=16}},{key:"extractBits",value:function(e){var t=this._heldBits>>this._numHeldBits-e&(1<<e)-1;return this._numHeldBits-=e,t}}]),e}(),_t=function(){function e(){s(this,e)}return u(e,null,[{key:"parseVVCDecoderConfigurationRecord",value:function(t){var r=new gt(t),n=r.readUint8();r.streamRead1Bytes(),r.extractBits(5);var i,a,s,o,u,c,l,d,f=r.extractBits(2)+1,h=r.extractBits(1),p={};h&&(r.streamRead2Bytes(),o=r.extractBits(2),u=r.extractBits(3),a=r.extractBits(3),s=r.extractBits(2),r.extractBits(6),p=e.parseVVCPTLRecord(r,a),i=r.readUint16(),c=r.readUint16(),l=r.readUint16(),d=r.readUint16());for(var v=r.readUint8(),y=[],m=[],g=[],_=null,b=0;b<v;b++){r.streamRead1Bytes(),r.extractBits(1),r.extractBits(2);var k=r.extractBits(5),x=1;13!==k&&12!==k&&(x=r.readUint16());for(var w=0;w<x;w++){var S=r.readUint16();switch(k){case 14:y.push(r.readUint8Array(S));break;case 15:var E=r.readUint8Array(S);_||(_=e.parseSPS(e.removeEPB(E))),m.push(E);break;case 16:g.push(r.readUint8Array(S))}}}return{data:t,configurationVersion:n,codec:"bvc2.1.6.L93.B0",nalUnitSize:f,ptlPresentFlag:h,olsIdx:i,numSublayers:a,constantFrameRate:s,chromaFormatIdc:o,bitDepthLumaMinus8:u,ptlRecord:p,width:c,height:l,sampleRate:d,numOfArrays:v,vps:y,sps:m,pps:g,spsParsed:_}}},{key:"parseVVCPTLRecord",value:function(e,t){e.streamRead2Bytes(),e.extractBits(2);var r=e.extractBits(6),n=e.extractBits(7),i=e.extractBits(1),a=e.readUint8();e.streamRead1Bytes();var s=e.extractBits(1),o=e.extractBits(1),u=new Uint8Array(r);if(r){for(var c=0;c<r-1;c++){var l=e.extractBits(6);e.streamRead1Bytes();var d=e.extractBits(2);u[c]=l<<2|d}u[r-1]=e.extractBits(6)}else e.extractBits(6);var f=[];if(t>1){e.streamRead1Bytes();for(var h=0,p=t-2;p>=0;--p){h|=e.extractBits(1)<<p}for(var v=t;v<=8&&t>1;++v)e.extractBits(1);for(var y=t-2;y>=0;--y)h&1<<y&&(f[y]=e.readUint8())}var m=e.readUint8(),g=[];if(m)for(var _=0;_<m;_++)g.push(e.readUint32());return{generalProfileIdc:n,generalTierFlag:i,generalLevelIdc:a,ptlFrameOnlyConstraintFlag:s,ptlMultilayerEnabledFlag:o,generalConstraintInfo:u,subLayerLevelIdc:f,generalSubProfileIdc:g,ptlNumSubProfiles:m,numBytesConstraintInfo:r}}},{key:"getAvccNals",value:function(e){for(var t=[];e.position<e.length-4;){var r=e.dataview.getInt32(e.dataview.position);if(!(e.length-e.position>=r))break;var n=e.buffer.slice(e.position,e.position+4);e.skip(4);var i=new Uint8Array(e.buffer.slice(e.position,e.position+r));e.skip(r),t.push({header:n,body:i})}return t}},{key:"analyseNal",value:function(e){var t=(248&e.body[1])>>3;switch(e.type=t,t){case 23:case 24:break;case 7:case 8:e.key=!0;break;case 14:e.vps=!0;break;case 15:e.sps=!0;break;case 16:e.pps=!0;break;case 17:e.aps=!0}}},{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,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}},{key:"parseVps",value:function(){}},{key:"parseSPS",value:function(t){var r=new mt(t);r.readUByte(),r.readUByte(),r.skipBits(4);var n=r.readBits(4),i=r.readBits(3),a=r.readBits(2),s=420;a<=3&&(s=[0,420,422,444][a]),r.readBits(2),r.readBits(1);var o=e._parseProfileTierLevel(r,1,i);return r.readBits(1),r.readBits(1)&&r.readBits(1),{width:r.readUEG(),height:r.readUEG(),spsMaxSubLayerMinus1:i,spsVideoParameterSetId:n,chromaFormatIdc:a,chromaFormat:s,ptlInfo:o}}},{key:"_parseProfileTierLevel",value:function(t,r,n){var i,a=t.readBits(7),s=t.readBits(1),o=t.readBits(8),u=t.readBits(1),c=t.readBits(1);r&&(i=e._parseGeneralConstraintsInfo(t));for(var l=n-1,d=[],f=[],h=[],p=l;p>=0;--p)d[p]=t.readBits(1);for(;!t.byteAligned();)t.readBits(1);for(var v=l;v>=0;--v)d[v]&&(f[v]=t.readUByte());if(r)for(var y=t.readUByte(),m=0;m<y;m++)h[m]=t.readBits(32);return{generalProfileIdc:a,generalTierFlag:s,generalLevelIdc:o,ptlFrameOnlyConstraintFlag:u,ptlMultilayerEnabledFlag:c,ptlSublayerLevelPresentFlags:d,ptlSublayerLevelIdcs:f,ptlSubProfileIdcs:h,gciInfo:i}}},{key:"_parseGeneralConstraintsInfo",value:function(e){var t=e.readBits(1);if(t){e.skipBits(71);var r=e.readBits(8);r&&e.skipBits(r)}var n=8-e.bitsPos()%8;return e.skipBits(n),{gciPresentFlag:t}}}]),e}(),bt=function(){function e(){s(this,e)}return u(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,a,s,o,u=1+(3&t[21]),c=[],l=[],d=[],f=23,h=t[22],p=0;p<h;p++){a=63&t[f],s=t[f+1]<<8|t[f+2],f+=3;for(var v=0;v<s;v++)if(o=t[f]<<8|t[f+1],f+=2,o){switch(a){case 32:var y=t.subarray(f,f+o);n||(n=e.parseVPS(pt.removeEPB(y),r)),d.push(y);break;case 33:var m=t.subarray(f,f+o);i||(i=e.parseSPS(pt.removeEPB(m),r)),c.push(m);break;case 34:l.push(t.subarray(f,f+o))}f+=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 Ze(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 Ze(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 a=r.chromaFormatIdc=n.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=n.readBits(1));var u,c,l,d,f=n.readUEG(),h=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!==a&&2!==a||0!==o?1:2,y=1===a&&0===o?2:1;f-=v*(c+u),h-=y*(d+l)}return{codec:"hev1.1.6.L93.B0",width:f,height:h,chromaFormat:s,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);for(var a=[],s=[],o=0;o<t;o++)a[o]=e.readBits(1),s[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==a[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!==s[u]&&e.readBits(8)}}]),e}(),kt=1e3,xt=5e3,wt=function(){function e(t,r,n){s(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 u(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,a=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(a,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var s=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(s&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),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),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.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],a=e.samples[r.length-1];n=Math.floor((a.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,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 f;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:ze,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(f=r[1])||void 0===f?void 0:f.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 h=0;h<u;h++){var p=r[h].dts,v=r[h+1];((c=h<u-1?v.dts-p:s?s.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:Me,time:p/e.timescale,dts:p,originDts:r[h].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[h].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,a=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=a=n[0].dts),this._baseDts=Math.min(i,a);var s=a-i;return Number.isFinite(s)&&Math.abs(s)>500&&t.warnings.push({type:Ie,videoBaseDts:a,audioBasePts:i,baseDts:this._baseDts,delta:s}),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){e.sampleDuration||(e.sampleDuration=e.codecType===Pe?yt.getFrameDuration(e.timescale,r):this._getG711Duration(e));var n=e.sampleDuration,i=e.codecType===Pe?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var a=t[0];this._audioNextPts=a.pts}for(var s=0;s<t.length;s++){var o=this._audioNextPts,u=t[s],c=u.pts-o;if(0===s&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=kt&&!rt){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>xt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:Ne,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var f=0;f<d;f++){var h=new Ke(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);h.originPts=Math.floor(this._baseDts+o),t.splice(s,0,h),this._audioNextPts+=n,s++}s--}else c<=-3*n&&c>=-1e3?(Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>xt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:qe,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(s,1),s--):(Math.abs(c)>kt&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>xt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:Fe,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),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===Pe?yt.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),St=function(){function e(){s(this,e)}return u(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,a=!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 s=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=s.data,i+=s.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 f=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),h=f.size,p=f.data;if(f.isEnd)break;r[p.name]=p.value,i+=h}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 9:r=void 0,i=1,a=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var y=0;y<v;y++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),g=m.data,_=m.size;r.push(g),i+=_}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=$e.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:a}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=$e.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}(),Et=new Je("FlvDemuxer"),jt=function(){function e(t,r,n){s(this,e),c(this,"_headerParsed",!1),c(this,"_remainingData",null),c(this,"_gopId",0),c(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new Ve,this.audioTrack=r||new Ge,this.metadataTrack=n||new Xe,this._fixer=new wt(this.videoTrack,this.audioTrack,this.metadataTrack)}return u(e,[{key:"demux",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=this.audioTrack,a=this.videoTrack,s=this.metadataTrack;if(!r&&n||(this._remainingData=null),r&&(this._headerParsed=!1),r?(a.reset(),i.reset(),s.reset()):(a.samples=[],i.samples=[],s.seiSamples=[],s.flvScriptSamples=[],a.warnings=[],i.warnings=[],this._remainingData&&(t=at(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:a,audioTrack:i,metadataTrack:s};var o=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");i.present=(4&t[4])>>>2!=0,a.present=0!=(1&t[4]),this._headerParsed=!0,o=ut(t,5)+4}for(var u,c,l,d,f,h=t.length;o+15<h&&(u=t[o],!(o+15+(c=t[o+1]<<16|t[o+2]<<8|t[o+3])>h));)l=(t[o+7]<<24>>>0)+(t[o+4]<<16)+(t[o+5]<<8)+t[o+6],o+=11,d=t.subarray(o,o+c),8===u?this._parseAudio(d,l):9===u?this._parseVideo(d,l):18===u?this._parseScript(d,l):Et.warn("Invalid tag type: ".concat(u)),(f=ut(t,o+=c))!==11+c&&Et.warn("Invalid PrevTagSize ".concat(f," (").concat(11+c,")")),o+=4;return o<h&&(this._remainingData=t.subarray(o)),i.formatTimescale=a.formatTimescale=a.timescale=s.timescale=1e3,i.timescale=i.sampleRate||0,!i.exist()&&i.hasSample()&&i.reset(),!a.exist()&&a.hasSample()&&a.reset(),{videoTrack:a,audioTrack:i,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:"_parseAudio",value:function(t,r){if(t.length){var n=(240&t[0])>>>4,i=this.audioTrack;if(10!==n&&7!==n&&8!==n)return Et.warn("Unsupported sound format: ".concat(n)),void i.reset();if(10!==n){var a=(12&t[0])>>2,s=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[a],i.sampleSize=s?16:8,i.channelCount=o+1}10===n?this._parseAac(t,r):this._parseG711(t,r,n)}}},{key:"_parseG711",value:function(e,t,r){var n=this.audioTrack;n.codecType=7===r?Ue:Re,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new Ke(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=Pe,0===e[1]){var n=yt.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(),Et.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new Ke(t,e.subarray(2)))}else Et.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],a=this.videoTrack;if(7!==i&&12!==i)return a.reset(),void Et.warn("Unsupported codecId: ".concat(i));var s=12===i;a.codecType=s?Oe:De;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=s?bt.parseHEVCDecoderConfigurationRecord(c):vt.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,f=l.sps,h=l.ppsArr,p=l.spsArr,v=l.vpsArr,y=l.nalUnitSize;d&&(a.hvcC=a.hvcC||d),f&&(a.codec=f.codec,a.width=f.width,a.height=f.height,a.sarRatio=f.sarRatio,a.fpsNum=f.fpsNum,a.fpsDen=f.fpsDen),p.length&&(a.sps=p),h.length&&(a.pps=h),v&&v.length&&(a.vps=v),y&&(a.nalUnitSize=y)}else Et.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=pt.parseAvcC(e.subarray(5),a.nalUnitSize);if((m=this._checkAddMetaNalToUnits(s,m,a))&&m.length){var g=new He(t+u,t,m);1===n&&g.setToKeyframe(),a.samples.push(g),m.forEach((function(e){var n=s?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(!s&&5!==n||s&&5===n)break;g.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==n||s&&6===n)break;r.metadataTrack.seiSamples.push(new Ye(pt.parseSEI(pt.removeEPB(e),s),t+u))}})),g.keyframe&&this._gopId++,g.gopId=this._gopId}else Et.warn("Cannot parse NALUs",e)}else 2===o||Et.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 Qe(St.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&ut(e,5)>=9}}]),e}();c(jt,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new Je("TsDemuxer");var Bt=function(){function e(){s(this,e)}return u(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 a=0,s="",o=0;t.length>7;){if(a=ut(t),s=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===a?(a=lt(t,8),o+=8):a||(a=t.length),!r[0]||s===r[0]){var u=t.subarray(0,a);if(!(r.length<2))return e.findBox(u.subarray(o),r.slice(1),n+o);i.push({start:n,size:a,headerSize:o,type:s,data:u})}n+=a,t=t.subarray(a)}return i}},{key:"tfhd",value:function(e){return Dt(e,!0,(function(e,t){e.trackId=ut(t);var r=4,n=1&e.flags,i=2&e.flags,a=8&e.flags,s=16&e.flags,o=32&e.flags;n&&(r+=4,e.baseDataOffset=ut(t,r),r+=4),i&&(e.sampleDescriptionIndex=ut(t,r),r+=4),a&&(e.defaultSampleDuration=ut(t,r),r+=4),s&&(e.defaultSampleSize=ut(t,r),r+=4),o&&(e.defaultSampleFlags=ut(t,r))}))}},{key:"sidx",value:function(e){return Dt(e,!0,(function(e,t){var r=0;e.reference_ID=ut(t,r),r+=4,e.timescale=ut(t,r),r+=4,0===e.version?(e.earliest_presentation_time=ut(t,r),r+=4,e.first_offset=ut(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=ot(t,r);r+=2;for(var i=0;i<n;i++){var a={};e.references.push(a);var s=ut(t,r);r+=4,a.reference_type=s>>31&1,a.referenced_size=2147483647&s,a.subsegment_duration=ut(t,r),s=ut(t,r+=4),r+=4,a.starts_with_SAP=s>>31&1,a.SAP_type=s>>28&7,a.SAP_delta_time=268435455&s}}))}},{key:"moov",value:function(t){return Dt(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 Dt(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ut(t,16),e.duration=lt(t,20),r+=28):(e.timescale=ut(t,8),e.duration=ut(t,12),r+=16),e.nextTrackId=ut(t,r+76)}))}},{key:"trak",value:function(t){return Dt(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]),t.edts=e.edts(e.findBox(r,["edts"],n)[0])}))}},{key:"tkhd",value:function(e){return Dt(e,!0,(function(e,t){var r=0;1===e.version?(e.trackId=ut(t,16),e.duration=lt(t,24),r+=32):(e.trackId=ut(t,8),e.duration=ut(t,16),r+=20),e.width=ut(t,r+52),e.height=ut(t,r+56)}))}},{key:"mdia",value:function(t){return Dt(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:"edts",value:function(t){return Dt(t,!1,(function(t,r,n){t.elst=e.elst(e.findBox(r,["elst"],n)[0])}))}},{key:"elst",value:function(e){return Dt(e,!0,(function(e,t,r){e.entries=[],e.entriesData=t;var n=0,i=ut(t,n);n+=4;for(var a=0;a<i;a++){var s={};e.entries.push(s),1===e.version?(s.segment_duration=lt(t,n),n+=8,s.media_time=dt(t,n),n+=8):(s.segment_duration=ut(t,n),n+=4,s.media_time=ct(t,n),n+=4),s.media_rate_integer=ot(t,n),n+=2,s.media_rate_fraction=ot(t,r),n+=2}}))}},{key:"mdhd",value:function(e){return Dt(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ut(t,16),e.duration=lt(t,20),r+=28):(e.timescale=ut(t,8),e.duration=ut(t,12),r+=16);var n=ot(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return Dt(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return Dt(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 Dt(e,!0,(function(e,t){e.graphicsmode=ot(t),e.opcolor=[ot(t,2),ot(t,4),ot(t,6)]}))}},{key:"smhd",value:function(e){return Dt(e,!0,(function(e,t){e.balance=ot(t)}))}},{key:"stbl",value:function(t){return Dt(t,!1,(function(t,r,n){var i,a,s;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===(a=i.sinf)||void 0===a||null===(s=a.schi)||void 0===s?void 0:s.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 Dt(e,!0,(function(e,r){var n=0,i=ut(r,n);n+=4,e.samples=[];for(var a=0;a<i;a++){for(var s={InitializationVector:[]},o=0;o<t;o++)s.InitializationVector[o]=r[n+o];if(n+=t,2&e.flags){s.subsamples=[];var u=ot(r,n);n+=2;for(var c=0;c<u;c++){var l={};l.BytesOfClearData=ot(r,n),n+=2,l.BytesOfProtectedData=ut(r,n),n+=4,s.subsamples.push(l)}}e.samples.push(s)}}))}},{key:"pssh",value:function(e){return Dt(e,!0,(function(e,t){for(var r=[],n=[],i=0,a=0;a<16;a++)n.push(Lt(t[i+a]));if(i+=16,e.version>0){var s=ut(t,i);i+=4;for(var o=0;o<(""+s).length;o++)for(var u=0;u<16;u++){var c=t[i];i+=1,r.push(Lt(c))}}var l=ut(t,i);e.data_size=l,i+=4,e.kid=r,e.system_id=n,e.buffer=t}))}},{key:"bvc2",value:function(t){return Dt(t,!1,(function(t,r,n){var i=Tt(t,r),a=r.subarray(i);n+=i,t.vvcC=e.bv2C(e.findBox(a,["bv2C"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"bv2C",value:function(e){return Dt(e,!1,(function(e,t,r){var n=_t.parseVVCDecoderConfigurationRecord(t);for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}))}},{key:"stsd",value:function(t){return Dt(t,!0,(function(t,r,n){t.entryCount=ut(r),t.entries=e.findBox(r.subarray(4),[],n+4).map((function(t){switch(t.type){case"avc1":case"avc2":case"avc3":case"avc4":return e.avc1(t);case"hvc1":case"hev1":return e.hvc1(t);case"bvc2":return e.bvc2(t);case"mp4a":return e.mp4a(t);case"alaw":case"ulaw":return e.alaw(t);case"enca":return Dt(t,!1,(function(t,r,n){t.channelCount=ot(r,16),t.samplesize=ot(r,18),t.sampleRate=ut(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 Dt(t,!1,(function(t,r,n){t.width=ot(r,24),t.height=ot(r,26),t.horizresolution=ut(r,28),t.vertresolution=ut(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 Dt(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(Lt(t[r])),r+=1}))}},{key:"schi",value:function(t){return Dt(t,!1,(function(t,r,n){t.tenc=e.tenc(e.findBox(r,["tenc"],n)[0])}))}},{key:"sinf",value:function(t){return Dt(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 Dt(e,!1,(function(e,t){e.data_format="";for(var r=0;r<4;r++)e.data_format+=String.fromCharCode(t[r])}))}},{key:"avc1",value:function(t){return Dt(t,!1,(function(t,r,n){var i=Tt(t,r),a=r.subarray(i);n+=i,t.avcC=e.avcC(e.findBox(a,["avcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"avcC",value:function(e){return Dt(e,!1,(function(e,t){e.configurationVersion=t[0],e.AVCProfileIndication=t[1],e.profileCompatibility=t[2],e.AVCLevelIndication=t[3],e.codec=ft([t[1],t[2],t[3]]),e.lengthSizeMinusOne=3&t[4],e.spsLength=31&t[5],e.sps=[];for(var r=6,n=0;n<e.spsLength;n++){var i=ot(t,r);r+=2,e.sps.push(t.subarray(r,r+i)),r+=i}e.ppsLength=t[r],r+=1,e.pps=[];for(var a=0;a<e.ppsLength;a++){var s=ot(t,r);r+=2,e.pps.push(t.subarray(r,r+=s)),r+=s}}))}},{key:"hvc1",value:function(t){return Dt(t,!1,(function(t,r,n){var i=Tt(t,r),a=r.subarray(i);n+=i,t.hvcC=e.hvcC(e.findBox(a,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"hvcC",value:function(e){return Dt(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=ut(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=ot(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var i=23,a=0,s=0,o=0,u=0;u<t.numOfArrays;u++){a=63&r[i],s=ot(r,i+1),i+=3;for(var c,l=[],d=0;d<s;d++)o=ot(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===a)(c=t.vps).push.apply(c,l);else if(33===a){var f;(f=t.sps).push.apply(f,l)}else if(34===a){var h;(h=t.pps).push.apply(h,l)}}}))}},{key:"pasp",value:function(e){return Dt(e,!1,(function(e,t){e.hSpacing=ut(t),e.vSpacing=ut(t,4)}))}},{key:"mp4a",value:function(t){return Dt(t,!1,(function(t,r,n){var i=Ct(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return Dt(e,!0,(function(e,t){e.codec="mp4a.";for(var r=0,n=0,i=0,a=0;t.length;){for(a=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===a)t=t.subarray(r+3);else{if(4!==a){if(5===a){var s=e.config=t.subarray(r,r+i),o=(248&s[0])>>3;return 31===o&&s.length>=2&&(o=32+((7&s[0])<<3)+((224&s[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 Dt(e,!1,(function(e,t){Ct(e,t)}))}},{key:"stts",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=[],i=4,a=0;a<r;a++)n.push({count:ut(t,i),delta:ut(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return Dt(e,!0,(function(e,t){var r=ut(t),n=[],i=4;if(1===e.version)for(var a=0;a<r;a++)n.push({count:ut(t,i),offset:ut(t,i+4)}),i+=8;else for(var s=0;s<r;s++)n.push({count:ut(t,i),offset:-(1+~ut(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=new Array(r),i=4,a=0;a<r;a++)n[a]={firstChunk:ut(t,i),samplesPerChunk:ut(t,i+4),sampleDescriptionIndex:ut(t,i+8)},i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return Dt(e,!0,(function(e,t){var r=ut(t),n=ut(t,4),i=new Array(n);if(!r)for(var a=8,s=0;s<n;s++)i[s]=ut(t,a),a+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=new Array(r),i=4,a=0;a<r;a++)n[a]=ut(t,i),i+=4;e.entryCount=r,e.entries=n}))}},{key:"co64",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=new Array(r),i=4,a=0;a<r;a++)n[a]=lt(t,i),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=new Array(r),i=4,a=0;a<r;a++)n[a]=ut(t,i),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return Dt(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 Dt(e,!0,(function(e,t){e.sequenceNumber=ut(t)}))}},{key:"traf",value:function(t){return Dt(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 Dt(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,a=e.sampleCount=ut(t),s=4;if(i>s&&1&n&&(e.dataOffset=-(1+~ut(t,s)),s+=4),i>s&&4&n&&(e.firstSampleFlags=ut(t,s),s+=4),i>s){var o;e.samples=new Array(a);for(var u=0;u<a;u++)o={},256&n&&(o.duration=ut(t,s),s+=4),512&n&&(o.size=ut(t,s),s+=4),1024&n&&(o.flags=ut(t,s),s+=4),2048&n&&(o.cts=r?-(1+~ut(t,s+4)):ut(t,s),s+=4),e.samples[u]=o}}))}},{key:"tfdt",value:function(e){return Dt(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=lt(t):e.baseMediaDecodeTime=ut(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,a=e.trak;if(a&&a.length){var s=a.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=a.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(s&&t){var u,c,l,d,f,h,p,v,y=t,m=null===(u=s.tkhd)||void 0===u?void 0:u.trackId;null!=m&&(y.id=s.tkhd.trackId),y.tkhdDuration=s.tkhd.duration,y.mvhdDurtion=e.mvhd.duration,y.mvhdTimecale=e.mvhd.timescale,y.timescale=y.formatTimescale=s.mdia.mdhd.timescale,y.duration=s.mdia.mdhd.duration||y.mvhdDurtion/y.mvhdTimecale*y.timescale,null!==(c=s.edts)&&void 0!==c&&c.elst&&(y.editList=s.edts.elst,y.editListApplied=s.editListApplied);var g,_,b,k,x,w,S,E,j=s.mdia.minf.stbl.stsd.entries[0];if(y.width=j.width,y.height=j.height,j.pasp&&(y.sarRatio=[j.pasp.hSpacing,j.pasp.vSpacing]),j.hvcC)y.codecType=Oe,y.codec=j.hvcC.codec,y.vps=j.hvcC.vps,y.sps=j.hvcC.sps,y.pps=j.hvcC.pps,y.hvcC=j.hvcC.data;else if(j.avcC)y.codec=j.avcC.codec,y.sps=j.avcC.sps,y.pps=j.avcC.pps;else{if(!j.vvcC)throw new Error("unknown video stsd entry");y.codecType=Le,y.codec=j.vvcC.codec,y.sps=j.vvcC.sps,y.pps=j.vvcC.pps,y.vps=j.vvcC.vps,y.vvcC=j.vvcC.data}if(y.present=!0,y.ext={},y.ext.stss=null===(l=s.mdia)||void 0===l||null===(d=l.minf)||void 0===d||null===(f=d.stbl)||void 0===f?void 0:f.stss,y.ext.ctts=null===(h=s.mdia)||void 0===h||null===(p=h.minf)||void 0===p||null===(v=p.stbl)||void 0===v?void 0:v.ctts,j&&"encv"===j.type)y.isVideoEncryption=!0,j.default_KID=null===(g=j.sinf)||void 0===g||null===(_=g.schi)||void 0===_?void 0:_.tenc.default_KID,j.default_IsEncrypted=null===(b=j.sinf)||void 0===b||null===(k=b.schi)||void 0===k?void 0:k.tenc.default_IsEncrypted,j.default_IV_size=null===(x=j.sinf)||void 0===x||null===(w=x.schi)||void 0===w?void 0:w.tenc.default_IV_size,y.videoSenc=s.mdia.minf.stbl.senc&&s.mdia.minf.stbl.senc.samples,j.data_format=null===(S=j.sinf)||void 0===S||null===(E=S.frma)||void 0===E?void 0:E.data_format,y.useEME=e.useEME,y.kidValue=e.kidValue,y.pssh=e.pssh,y.encv=j}if(o&&r){var B,A,T,C,D,O,L,P,U,R,I=r,M=null===(B=o.tkhd)||void 0===B?void 0:B.trackId;null!=M&&(I.id=o.tkhd.trackId),I.tkhdDuration=o.tkhd.duration,I.mvhdDurtion=e.mvhd.duration,I.mvhdTimecale=e.mvhd.timescale,I.timescale=I.formatTimescale=o.mdia.mdhd.timescale,I.duration=o.mdia.mdhd.duration||I.mvhdDurtion/I.mvhdTimecale*I.timescale,null!==(A=o.edts)&&void 0!==A&&A.elst&&(I.editList=o.edts.elst,I.editListApplied=o.editListApplied);var z,F,N,q,V,G,H,K,W=o.mdia.minf.stbl.stsd.entries[0];switch(I.sampleSize=W.sampleSize,I.sampleRate=W.sampleRate,I.channelCount=W.channelCount,I.present=!0,W.type){case"alaw":I.codecType=I.codec=Ue,I.sampleRate=8e3;break;case"ulaw":I.codecType=I.codec=Re,I.sampleRate=8e3;break;default:I.sampleDuration=yt.getFrameDuration(I.sampleRate,I.timescale),I.sampleRateIndex=yt.getRateIndexByRate(I.sampleRate),I.objectType=(null===(n=W.esds)||void 0===n?void 0:n.objectType)||2,W.esds&&(I.config=Array.from(W.esds.config)),I.codec=(null===(i=W.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}if(I.sampleDuration=yt.getFrameDuration(I.sampleRate,I.timescale),I.objectType=(null===(T=W.esds)||void 0===T?void 0:T.objectType)||2,W.esds&&(W.esds.config?I.config=Array.from(W.esds.config):console.warn("esds config is null")),I.codec=(null===(C=W.esds)||void 0===C?void 0:C.codec)||"mp4a.40.2",I.sampleRateIndex=yt.getRateIndexByRate(I.sampleRate),I.ext={},I.ext.stss=null===(D=o.mdia)||void 0===D||null===(O=D.minf)||void 0===O||null===(L=O.stbl)||void 0===L?void 0:L.stss,I.ext.ctts=null===(P=o.mdia)||void 0===P||null===(U=P.minf)||void 0===U||null===(R=U.stbl)||void 0===R?void 0:R.ctts,I.present=!0,W&&"enca"===W.type)I.isAudioEncryption=!0,W.data_format=null===(z=W.sinf)||void 0===z||null===(F=z.frma)||void 0===F?void 0:F.data_format,W.default_KID=null===(N=W.sinf)||void 0===N||null===(q=N.schi)||void 0===q?void 0:q.tenc.default_KID,W.default_IsEncrypted=null===(V=W.sinf)||void 0===V||null===(G=V.schi)||void 0===G?void 0:G.tenc.default_IsEncrypted,W.default_IV_size=null===(H=W.sinf)||void 0===H||null===(K=H.schi)||void 0===K?void 0:K.tenc.default_IV_size,I.audioSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,I.useEME=e.useEME,I.kidValue=e.kidValue,I.enca=W}if(r&&(r.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!r&&r.isAudioEncryption),null!=t&&t.encv||null!=r&&r.enca){var Q,Y,X=null==t||null===(Q=t.encv)||void 0===Q?void 0:Q.default_KID,Z=null==r||null===(Y=r.enca)||void 0===Y?void 0:Y.default_KID,J=X||Z?(X||Z).join(""):null;t&&(t.kid=J),r&&(r.kid=J)}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 a=t.tfhd,s=t.tfdt,o=t.trun;if(a&&o){s&&(r&&r.id===a.trackId&&(r.baseMediaDecodeTime=s.baseMediaDecodeTime),n&&n.id===a.trackId&&(n.baseMediaDecodeTime=s.baseMediaDecodeTime));var u=a.defaultSampleSize||0,c=a.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,f=-1;if(!o.samples.length&&o.sampleCount){i[a.trackId]=new Array(o.sampleCount);for(var h=0;h<o.sampleCount;h++)i[a.trackId][h]={offset:l,dts:d,duration:c,size:u},d+=c,l+=u}else i[a.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:f,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(f++,e.gopId=f),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,a;if(r){var s,o,u=null===(s=r.mdia)||void 0===s||null===(o=s.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,f=u.stco,h=u.stss,p=u.ctts;if(!(c&&l&&d&&f&&h))return;i=At(c,l,d,f,p,h)}if(n){var v,y,m,g=null===(v=n.mdia)||void 0===v||null===(y=v.minf)||void 0===y?void 0:y.stbl;if(!g)return;var _=null===(m=n.mdia.mdhd)||void 0===m?void 0:m.timescale,b=g.stts,k=g.stsc,x=g.stsz,w=g.stco;if(!(_&&b&&k&&x&&w))return;a=At(b,k,x,w)}return{videoSamples:i,audioSamples:a}}}}}]),e}();function At(e,t,r,n,i,a){var s,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,f=n.entries,h=r.entrySizes,p=null==a?void 0:a.entries;p&&(s={},p.forEach((function(e){s[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,y=0,m=0,g=0,_=0,b=0,k=d[0].samplesPerChunk,x=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:y,duration:n,size:h[m]||r.sampleSize,offset:f[g]+b,index:m},p&&(u.keyframe=s[m],u.keyframe&&v++,u.gopId=v),o&&m<o.length&&(u.pts=u.dts+o[m]),c.push(u),y+=n,++m<k?b+=u.size:(g++,b=0,g>=x&&(_++,x=d[_+1]?d[_+1].firstChunk-1:1/0),k+=d[_].samplesPerChunk)})),c}function Tt(e,t){return e.dataReferenceIndex=ot(t,6),e.width=ot(t,24),e.height=ot(t,26),e.horizresolution=ut(t,28),e.vertresolution=ut(t,32),e.frameCount=ot(t,40),e.depth=ot(t,74),78}function Ct(e,t){return e.dataReferenceIndex=ot(t,6),e.channelCount=ot(t,16),e.sampleSize=ot(t,18),e.sampleRate=ut(t,24)/65536,28}function Dt(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 Ot=function(e,t,r){for(var n=String(r),i=t>>0,a=Math.ceil(i/n.length),s=[],o=String(e);a--;)s.push(n);return s.join("").substring(0,i-o.length)+o},Lt=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(Ot(Number(t).toString(16),2,0))})),e[0]};function Pt(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 a=new e(t),s=0;return n.forEach((function(e){a.set(e,s),s+=e.length})),a}var Ut=function(){function e(){s(this,e),this.buffer=new Uint8Array(0)}return u(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=Pt(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}(),Rt=Math.pow(2,32)-1,It=function(){function e(){s(this,e)}return u(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),a=new Uint8Array(i);a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4);var s=8;return r.forEach((function(e){a.set(e,s),s+=e.byteLength})),a}},{key:"FullBox",value:function(t,r,n){for(var i=arguments.length,a=new Array(i>3?i-3:0),s=3;s<i;s++)a[s-3]=arguments[s];return e.box.apply(e,[t,new Uint8Array([r,n>>16&255,n>>8&255,255&n])].concat(a))}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===Ae&&e.codecType===Oe}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return at(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],ht(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(w(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(w(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,a=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 a}},{key:"edts",value:function(t){return e.box(e.types.edts,e.elst(t))}},{key:"elst",value:function(t){t.entries;var r=t.entriesData,n=t.version;return e.FullBox(e.types.elst,n,0,r)}},{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===Ae?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){return t&&t.ext,e.box(e.types.stbl,e.stsd(t),e.STTS,[][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):e.mp4a(t):t.useEME&&t.encv?e.encv(t):e.avc1hev1vvc1(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]),a=e.esds(t.config),s=e.sinf(t.enca);return e.box(e.types.enca,i,a,s)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],a=t.pps.length>0?t.pps[0]:[],s=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,s>>8&255,255&s,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,w(i)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,w(a))),f=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),h=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,f),h,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(ht(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]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),a)}},{key:"avc1hev1vvc1",value:function(t){var r,n;t.codecType===Oe?(r=e.hvcC(t),n=e.types.hvc1):t.codecType===Le?(r=e.vvcC(t),n=e.types.bvc2):(r=e.avcC(t),n=e.types.avc1);var i=[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]),r];return t.codecType===Oe?i.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&i.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(i))}},{key:"avcC",value:function(t){var r,n,i,a=[],s=[];return t.sps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,w(e))})),t.pps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,w(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,a[3],a[4],a[5],255,224|t.sps.length]).concat.apply(n,a).concat([t.pps.length])).concat.apply(r,s)))}},{key:"vvcC",value:function(t){var r=t.vvcC;return e.box(e.types.bv2C,new Uint8Array(r))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,a=t.sps,s=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(a.length&&1)+(s.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,w(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),a.length&&(n.push(161,0,a.length),a.forEach(l)),s.length&&(n.push(162,0,s.length),s.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=x(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:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(w(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(w(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.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 a=e.saiz(t),s=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,a,s,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),d=e.saio(t),f=e.senc(t),h=e.trun1(t);return e.box(e.types.traf,r,n,c,l,d,f,h)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var y=e.trun1(t);return e.box(e.types.traf,r,n,y)}var m=e.sbgp(),g=e.saiz(t),_=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,m,g,_,b,k)}var x=e.sdtp(t);return e.box(e.types.traf,r,n,x,e.trun(t.samples,x.byteLength+76))}},{key:"sdtp",value:function(t){var r=new Ut;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 Ut,n=Ut.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=Ut.writeUint32(76+16*t.samples.length+a+77),!t.isVideoEncryption&&t.isAudioEncryption&&(i=Ut.writeUint32(76+16*t.samples.length+20))}else{var s=76+12*t.samples.length+52;t.isAudioEncryption&&(s=76+12*t.samples.length+8*t.audioSenc.length+105),i=Ut.writeUint32(s)}return t.samples.forEach((function(e){r.write(Ut.writeUint32(e.duration)),r.write(Ut.writeUint32(e.size)),r.write(Ut.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(Ut.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 Ut,n=t.samples.length,i=t.isVideo?16:8,a=t.isVideo?2:0,s=[],o=0;return t.isVideo?(s=t.videoSenc,o=t.videoSencLength):s=t.audioSenc,o=o||i*n,r.write(Ut.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(Ut.writeUint32(n)),s.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(Ut.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(Ut.writeUint16(e.BytesOfClearData)),r.write(Ut.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){var r=Math.floor(t/(Rt+1)),n=Math.floor(t%(Rt+1));return e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var a=new Uint8Array(i);a.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 s=0;s<n;s++){var o=t[s],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,f=o.cts,h=void 0===f?0:f;a.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,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*s)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(w(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===Ae?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,at(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,a=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],i),i+=12})),e.box(e.types.stsc,at(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,at(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,at(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,at(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,at(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,a=t.samples[0].sampleOffset*n,s=8;t.samples.forEach((function(e){s+=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=s+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=s+16*t.samples.length+84)}else o=s+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=s+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,a>>24&255,a>>16&255,a>>8&255,255&a,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}();c(It,"types",["avc1","avcC","hvc1","hvcC","dinf","dref","edts","elst","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","bvc2","bv2C"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),c(It,"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])}),c(It,"FTYPAVC1",It.box(It.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),c(It,"FTYPHEV1",It.box(It.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),c(It,"DINF",It.box(It.types.dinf,It.box(It.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),c(It,"VMHD",It.box(It.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),c(It,"SMHD",It.box(It.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),c(It,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),c(It,"STTS",It.box(It.types.stts,It.StblTable)),c(It,"STSC",It.box(It.types.stsc,It.StblTable)),c(It,"STSZ",It.box(It.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),c(It,"STCO",It.box(It.types.stco,It.StblTable));var Mt=function(){function e(t,r){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return u(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}();c(Mt,"disabled",!0);for(var zt=function(){function e(){s(this,e)}return u(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 p(this,t)}}]),e}(),Ft=function(e){l(r,e);var t=_(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;s(this,r),e=t.call(this);var a=n;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),(a instanceof Int8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)&&(a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),a instanceof Uint8Array){for(var o=a.byteLength,u=[],c=0;c<o;c+=1)u[c>>>2]|=a[c]<<24-c%4*8;e.words=u,e.sigBytes=o}else e.words=n,e.sigBytes=i;return e}return u(r,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Nt;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 a=0;a<i;a+=1){var s=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=s<<24-(n+a)%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=k(d(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)}},a=0;a<e;a+=4){var s=i(4294967296*(t||Math.random()));t=987654071*s(),n.push(4294967296*s()|0)}return new r(n,e)}}]),r}(zt),Nt={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=1){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).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 Ft(r,t/2)}},qt=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 Ft(r,t)},Vt=function(e){return qt(unescape(encodeURIComponent(e)))},Gt=function(e){l(r,e);var t=_(r);function r(){var e;return s(this,r),(e=t.call(this))._minBufferSize=0,e}return u(r,[{key:"reset",value:function(){this._data=new Ft,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=Vt(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,a=r.sigBytes,s=a/(4*n),o=(s=e?Math.ceil(s):Math.max((0|s)-this._minBufferSize,0))*n,u=Math.min(4*o,a);if(o){for(var c=0;c<o;c+=n)this._doProcessBlock(i,c);t=i.splice(0,o),r.sigBytes-=u}return new Ft(t,u)}},{key:"clone",value:function(){var e=k(d(r.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),r}(zt),Ht=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new zt,e),n.reset(),n}return u(r,[{key:"reset",value:function(){k(d(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 Kt(e,r).finalize(t)}}}]),r}(Gt),Kt=function(e){l(r,e);var t=_(r);function r(e,n){var i;s(this,r),i=t.call(this);var a=new e;i._hasher=a;var o=n;"string"==typeof o&&(o=Vt(o));var u=a.blockSize,c=4*u;o.sigBytes>c&&(o=a.finalize(n)),o.clamp();var l=o.clone();i._oKey=l;var d=o.clone();i._iKey=d;for(var f=l.words,h=d.words,p=0;p<u;p+=1)f[p]^=1549556828,h[p]^=909522486;return l.sigBytes=c,d.sigBytes=c,i.reset(),i}return u(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}(zt),Wt={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var s=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,o=0;o<4&&a+.75*o<r;o+=1)i.push(n.charAt(s>>>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 a=r.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return function(e,t,r){for(var n=[],i=0,a=0;a<t;a+=1)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2|r[e.charCodeAt(a)]>>>6-a%4*2;n[i>>>2]|=s<<24-i%4*8,i+=1}return Ft.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},Qt=[],Yt=0;Yt<64;Yt+=1)Qt[Yt]=4294967296*Math.abs(Math.sin(Yt+1))|0;var Xt=function(e,t,r,n,i,a,s){var o=e+(t&r|~t&n)+i+s;return(o<<a|o>>>32-a)+t},Zt=function(e,t,r,n,i,a,s){var o=e+(t&n|r&~n)+i+s;return(o<<a|o>>>32-a)+t},Jt=function(e,t,r,n,i,a,s){var o=e+(t^r^n)+i+s;return(o<<a|o>>>32-a)+t},$t=function(e,t,r,n,i,a,s){var o=e+(r^(t|~n))+i+s;return(o<<a|o>>>32-a)+t},er=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"_doReset",value:function(){this._hash=new Ft([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var r=e,n=0;n<16;n+=1){var i=t+n,a=e[i];r[i]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var s=this._hash.words,o=r[t+0],u=r[t+1],c=r[t+2],l=r[t+3],d=r[t+4],f=r[t+5],h=r[t+6],p=r[t+7],v=r[t+8],y=r[t+9],m=r[t+10],g=r[t+11],_=r[t+12],b=r[t+13],k=r[t+14],x=r[t+15],w=s[0],S=s[1],E=s[2],j=s[3];w=Xt(w,S,E,j,o,7,Qt[0]),j=Xt(j,w,S,E,u,12,Qt[1]),E=Xt(E,j,w,S,c,17,Qt[2]),S=Xt(S,E,j,w,l,22,Qt[3]),w=Xt(w,S,E,j,d,7,Qt[4]),j=Xt(j,w,S,E,f,12,Qt[5]),E=Xt(E,j,w,S,h,17,Qt[6]),S=Xt(S,E,j,w,p,22,Qt[7]),w=Xt(w,S,E,j,v,7,Qt[8]),j=Xt(j,w,S,E,y,12,Qt[9]),E=Xt(E,j,w,S,m,17,Qt[10]),S=Xt(S,E,j,w,g,22,Qt[11]),w=Xt(w,S,E,j,_,7,Qt[12]),j=Xt(j,w,S,E,b,12,Qt[13]),E=Xt(E,j,w,S,k,17,Qt[14]),S=Xt(S,E,j,w,x,22,Qt[15]),w=Zt(w,S,E,j,u,5,Qt[16]),j=Zt(j,w,S,E,h,9,Qt[17]),E=Zt(E,j,w,S,g,14,Qt[18]),S=Zt(S,E,j,w,o,20,Qt[19]),w=Zt(w,S,E,j,f,5,Qt[20]),j=Zt(j,w,S,E,m,9,Qt[21]),E=Zt(E,j,w,S,x,14,Qt[22]),S=Zt(S,E,j,w,d,20,Qt[23]),w=Zt(w,S,E,j,y,5,Qt[24]),j=Zt(j,w,S,E,k,9,Qt[25]),E=Zt(E,j,w,S,l,14,Qt[26]),S=Zt(S,E,j,w,v,20,Qt[27]),w=Zt(w,S,E,j,b,5,Qt[28]),j=Zt(j,w,S,E,c,9,Qt[29]),E=Zt(E,j,w,S,p,14,Qt[30]),S=Zt(S,E,j,w,_,20,Qt[31]),w=Jt(w,S,E,j,f,4,Qt[32]),j=Jt(j,w,S,E,v,11,Qt[33]),E=Jt(E,j,w,S,g,16,Qt[34]),S=Jt(S,E,j,w,k,23,Qt[35]),w=Jt(w,S,E,j,u,4,Qt[36]),j=Jt(j,w,S,E,d,11,Qt[37]),E=Jt(E,j,w,S,p,16,Qt[38]),S=Jt(S,E,j,w,m,23,Qt[39]),w=Jt(w,S,E,j,b,4,Qt[40]),j=Jt(j,w,S,E,o,11,Qt[41]),E=Jt(E,j,w,S,l,16,Qt[42]),S=Jt(S,E,j,w,h,23,Qt[43]),w=Jt(w,S,E,j,y,4,Qt[44]),j=Jt(j,w,S,E,_,11,Qt[45]),E=Jt(E,j,w,S,x,16,Qt[46]),S=Jt(S,E,j,w,c,23,Qt[47]),w=$t(w,S,E,j,o,6,Qt[48]),j=$t(j,w,S,E,p,10,Qt[49]),E=$t(E,j,w,S,k,15,Qt[50]),S=$t(S,E,j,w,f,21,Qt[51]),w=$t(w,S,E,j,_,6,Qt[52]),j=$t(j,w,S,E,l,10,Qt[53]),E=$t(E,j,w,S,m,15,Qt[54]),S=$t(S,E,j,w,u,21,Qt[55]),w=$t(w,S,E,j,v,6,Qt[56]),j=$t(j,w,S,E,x,10,Qt[57]),E=$t(E,j,w,S,h,15,Qt[58]),S=$t(S,E,j,w,b,21,Qt[59]),w=$t(w,S,E,j,d,6,Qt[60]),j=$t(j,w,S,E,g,10,Qt[61]),E=$t(E,j,w,S,c,15,Qt[62]),S=$t(S,E,j,w,y,21,Qt[63]),s[0]=s[0]+w|0,s[1]=s[1]+S|0,s[2]=s[2]+E|0,s[3]=s[3]+j|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),a=r;t[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(n+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,o=s.words,u=0;u<4;u+=1){var c=o[u];o[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return s}},{key:"clone",value:function(){var e=k(d(r.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),r}(Ht);Ht._createHelper(er),Ht._createHmacHelper(er);var tr=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).cfg=Object.assign(new zt,{keySize:4,hasher:er,iterations:1},e),n}return u(r,[{key:"compute",value:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=Ft.create(),s=a.words,o=n.keySize,u=n.iterations;s.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();a.concat(r)}return a.sigBytes=4*o,a}}]),r}(zt),rr=function(e){l(r,e);var t=_(r);function r(e,n,i){var a;return s(this,r),(a=t.call(this)).cfg=Object.assign(new zt,i),a._xformMode=e,a._key=n,a.reset(),a}return u(r,[{key:"reset",value:function(){k(d(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?fr:lr};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}(Gt);rr._ENC_XFORM_MODE=1,rr._DEC_XFORM_MODE=2,rr.keySize=4,rr.ivSize=4;var nr=function(e){l(r,e);var t=_(r);function r(e,n){var i;return s(this,r),(i=t.call(this))._cipher=e,i._iv=n,i}return u(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}(zt);function ir(e,t,r){var n,i=e,a=this._iv;a?(n=a,this._iv=void 0):n=this._prevBlock;for(var s=0;s<r;s+=1)i[t+s]^=n[s]}var ar=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(nr);ar.Encryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize;ir.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),r}(ar),ar.Decryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize,i=e.slice(t,t+n);r.decryptBlock(e,t),ir.call(this,e,t,n),this._prevBlock=i}}]),r}(ar);var sr={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var o=Ft.create(a,n);e.concat(o)},unpad:function(e){var t=e,r=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=r}},or=function(e){l(r,e);var t=_(r);function r(e,n,i){var a;return s(this,r),(a=t.call(this,e,n,Object.assign({mode:ar,padding:sr},i))).blockSize=4,a}return u(r,[{key:"reset",value:function(){var e;k(d(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}(rr),ur=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).mixIn(e),n}return u(r,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),r}(zt),cr={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?Ft.create([1398893684,1701076831]).concat(r).concat(t):t).toString(Wt)},parse:function(e){var t,r=Wt.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=Ft.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),ur.create({ciphertext:r,salt:t})}},lr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new zt,this.cfg,n),a=e.createEncryptor(r,i),s=a.finalize(t),o=a.cfg;return ur.create({ciphertext:s,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:a.blockSize,formatter:i.format})}},{key:"decrypt",value:function(e,t,r,n){var i=t,a=Object.assign(new zt,this.cfg,n);return i=this._parse(i,a.format),e.createDecryptor(r,a).finalize(i.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),r}(zt);lr.cfg=Object.assign(new zt,{format:cr});var dr={execute:function(e,t,r,n){var i=n;i||(i=Ft.random(8));var a=tr.create({keySize:t+r}).compute(e,i),s=Ft.create(a.words.slice(t),4*r);return a.sigBytes=4*t,ur.create({key:a,iv:s,salt:i})}},fr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new zt,this.cfg,n),a=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=a.iv;var s=lr.encrypt.call(this,e,t,a.key,i);return s.mixIn(a),s}},{key:"decrypt",value:function(e,t,r,n){var i=t,a=Object.assign(new zt,this.cfg,n);i=this._parse(i,a.format);var s=a.kdf.execute(r,e.keySize,e.ivSize,i.salt);return a.iv=s.iv,lr.decrypt.call(this,e,i,s.key,a)}}]),r}(lr);fr.cfg=Object.assign(lr.cfg,{kdf:dr});for(var hr=[],pr=[],vr=[],yr=[],mr=[],gr=[],_r=[],br=[],kr=[],xr=[],wr=[],Sr=0;Sr<256;Sr+=1)wr[Sr]=Sr<128?Sr<<1:Sr<<1^283;for(var Er=0,jr=0,Br=0;Br<256;Br+=1){var Ar=jr^jr<<1^jr<<2^jr<<3^jr<<4;Ar=Ar>>>8^255&Ar^99,hr[Er]=Ar,pr[Ar]=Er;var Tr=wr[Er],Cr=wr[Tr],Dr=wr[Cr],Or=257*wr[Ar]^16843008*Ar;vr[Er]=Or<<24|Or>>>8,yr[Er]=Or<<16|Or>>>16,mr[Er]=Or<<8|Or>>>24,gr[Er]=Or,Or=16843009*Dr^65537*Cr^257*Tr^16843008*Er,_r[Ar]=Or<<24|Or>>>8,br[Ar]=Or<<16|Or>>>16,kr[Ar]=Or<<8|Or>>>24,xr[Ar]=Or,Er?(Er=Tr^wr[wr[wr[Dr^Tr]]],jr^=wr[wr[jr]]):Er=jr=1}var Lr=[0,1,2,4,8,16,32,64,128,27,54],Pr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(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 a=this._keySchedule,s=0;s<i;s+=1)s<n?a[s]=r[s]:(e=a[s-1],s%n?n>6&&s%n==4&&(e=hr[e>>>24]<<24|hr[e>>>16&255]<<16|hr[e>>>8&255]<<8|hr[255&e]):(e=hr[(e=e<<8|e>>>24)>>>24]<<24|hr[e>>>16&255]<<16|hr[e>>>8&255]<<8|hr[255&e],e^=Lr[s/n|0]<<24),a[s]=a[s-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<i;u+=1){var c=i-u;e=u%4?a[c]:a[c-4],o[u]=u<4||c<=4?e:_r[hr[e>>>24]]^br[hr[e>>>16&255]]^kr[hr[e>>>8&255]]^xr[hr[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,vr,yr,mr,gr,hr)}},{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,_r,br,kr,xr,pr),n=r[t+1],r[t+1]=r[t+3],r[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,r,n,i,a,s,o){for(var u=e,c=this._nRounds,l=u[t]^r[0],d=u[t+1]^r[1],f=u[t+2]^r[2],h=u[t+3]^r[3],p=4,v=1;v<c;v+=1){var y=n[l>>>24]^i[d>>>16&255]^a[f>>>8&255]^s[255&h]^r[p];p+=1;var m=n[d>>>24]^i[f>>>16&255]^a[h>>>8&255]^s[255&l]^r[p];p+=1;var g=n[f>>>24]^i[h>>>16&255]^a[l>>>8&255]^s[255&d]^r[p];p+=1;var _=n[h>>>24]^i[l>>>16&255]^a[d>>>8&255]^s[255&f]^r[p];p+=1,l=y,d=m,f=g,h=_}var b=(o[l>>>24]<<24|o[d>>>16&255]<<16|o[f>>>8&255]<<8|o[255&h])^r[p];p+=1;var k=(o[d>>>24]<<24|o[f>>>16&255]<<16|o[h>>>8&255]<<8|o[255&l])^r[p];p+=1;var x=(o[f>>>24]<<24|o[h>>>16&255]<<16|o[l>>>8&255]<<8|o[255&d])^r[p];p+=1;var w=(o[h>>>24]<<24|o[l>>>16&255]<<16|o[d>>>8&255]<<8|o[255&f])^r[p];p+=1,u[t]=b,u[t+1]=k,u[t+2]=x,u[t+3]=w}}]),r}(or);Pr.keySize=8,or._createHelper(Pr);var Ur=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(nr);Ur.Encryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=e,n=this._cipher,i=n.blockSize,a=this._iv,s=this._counter;a&&(this._counter=a.slice(0),s=this._counter,this._iv=void 0);var o=s.slice(0);n.encryptBlock(o,0),s[i-1]=s[i-1]+1|0;for(var u=0;u<i;u+=1)r[t+u]^=o[u]}}]),r}(Ur),Ur.Decryptor=Ur.Encryptor;var Rr=u((function e(t,r){s(this,e),this.type="file",this.message=t,this.data=r})),Ir=function(){function e(){s(this,e),c(this,"_data",Object.create(null))}return u(e,[{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){return this._data[e]}},{key:"clear",value:function(){this._data=Object.create(null)}}]),e}(),Mr=function(){function e(){s(this,e),this.frames=[],this.dur=0,this.minPts=Number.MAX_VALUE,this.maxPts=0}return u(e,[{key:"appendFrame",value:function(e){this.frames.push(e),this.dur+=e.duration}},{key:"calMinMaxPts",value:function(e){e.pts<this.minPts&&(this.minPts=e.pts);var t=e.pts+e.duration;t>this.maxPts&&(this.maxPts=t)}}]),e}();function zr(){var e=!0,t=navigator.userAgent||"";if(/Chrome/gi.test(t)&&!/Edge\//gi.test(t)){var r=t.match(/Chrome\/(\d+)/i),n=r?parseInt(r[1],10):0;e=!!n&&n>=75}return e}function Fr(e,t){var r=t.segmentDuration,n=e.trak;if(n&&n.length){var i=n.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)})),a=n.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(i||a){var s,o=[],u=[];return i&&(s=(o=Nr("video",i,r,t)).map((function(e){return e.duration}))),a&&(u=Nr("audio",a,r,t,s,o)),{videoSegments:o,audioSegments:u}}}}function Nr(e,t,r,n){var i,a,s,o,u,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=arguments.length>5?arguments[5]:void 0,d=n.fixEditListOffset,f=n.fixEditListOffsetThreshold,h=n.audioGroupingStrategy,p=n.memoryOpt,v=null===(i=t.mdia)||void 0===i||null===(a=i.minf)||void 0===a?void 0:a.stbl;if(!v)return[];var y=null===(s=t.mdia.mdhd)||void 0===s?void 0:s.timescale,m=v.stts,g=v.stsc,_=v.stsz,b=v.stco,k=v.stss,x=v.ctts;if(!(y&&m&&g&&_&&b&&("video"!==e||k)))return[];var S=0,E=null===(o=t.edts)||void 0===o||null===(u=o.elst)||void 0===u?void 0:u.entries;if(d&&zr()&&Array.isArray(E)&&E.length>0){var j=E[0].media_time,B=f?f*y:5*y;j>0&&j<B&&(S=j)}var A,T,C=[],D=[],O=[],L=[],P=[],U=g.entries,R=b.entries,I=_.entrySizes,M=null==k?void 0:k.entries,z=null==x?void 0:x.entries,F=[],N={};p||(z&&z.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)F.push(r)})),M&&M.forEach((function(e){N[e-1]=!0})));var q,V=0,G=0,H=0,K=0,W=U.length>0?U[0].samplesPerChunk:0,Q=U.length>1&&U[1]?U[1].firstChunk-1:1/0,Y=0,X=-1,Z=!1,J={};(null==z?void 0:z.length)>0&&S>0&&(Y-=S,Z=!0),t.editListApplied=Z,p&&(q=null==M?void 0:M.shift()),m.entries.forEach((function(e){var t=e.count,r=e.delta;T=r;for(var n=0;n<t;n++){if(A={dts:Y,duration:T,size:I[V]||_.sampleSize,offset:R[G]+K,index:V},z&&(p?(qr(z,V,J),A.pts=Y+((null==J?void 0:J.offset)||0)):F&&V<F.length&&(A.pts=Y+F[V])),0===S&&0===V&&(A.pts=0),void 0===A.pts&&(A.pts=A.dts),M){if(p?V+1===q&&(A.keyframe=!0,q=M.shift()):A.keyframe=N[V],A.keyframe)if(X++,p){var i=new Mr;i.appendFrame(A),D.push(i)}else D.push([A]),O.push(A.duration);else p?D[D.length-1].appendFrame(A):(D[D.length-1].push(A),O[D.length-1]+=A.duration);A.gopId=X,p&&D[D.length-1].calMinMaxPts(A)}if(!p)if(A.keyframe?L[L.length]=A.pts:A.pts<L[D.length-1]&&(L[D.length-1]=A.pts),A.keyframe)P[P.length]=A.index;else if(D.length>0&&void 0!==P[D.length-1]){var a,s=null===(a=C[P[D.length-1]])||void 0===a?void 0:a.pts;void 0!==s&&A.pts>s&&(P[D.length-1]=A.index)}C[C.length]=A,Y+=r,++V<W?K+=A.size:(G++,K=0,G>=Q&&(H++,Q=U[H+1]?U[H+1].firstChunk-1:1/0),W+=U[H].samplesPerChunk)}}));var $=C.length;if(!$||k&&!C[0].keyframe)return[];var ee,te,re=[],ne=[],ie=0,ae=0,se=0,oe=0,ue=function(e,t,r){(ee=ne[ne.length-1],p?(se=(null==D?void 0:D.length)>0?D[t].minPts:ne[0].pts,oe=(null==D?void 0:D.length)>0?D[r].maxPts:ee.pts+ee.duration):(se=L[t],te=C[P[r]],oe=te.pts+te.duration),0===re.length)&&(e=(oe-se)/y);re.push({index:re.length,startTime:se/y,endTime:oe/y,duration:e,range:[ne[0].offset,ee.offset+ee.size-1],frames:ne}),1!==h&&(ie=0),ne=[]},ce=0;if(k)for(var le=r*y,de=0,fe=D.length;de<fe;de++){var he,pe;if(p)ie+=D[de].dur,(he=ne).push.apply(he,w(D[de].frames));else ie+=O[de],(pe=ne).push.apply(pe,w(D[de]));de+1<fe?(0===de||ie>le)&&(ue(ie/y,ce,de),ie=0,ce=de+1):(ue(ie/y,ce,de),ie=0,ce=de+1)}else{p||(L=[],P=[]);var ve=c[0]||r;if(1===h)for(var ye,me=0;me<$;me++){var ge=C[me],_e=C[me+1],be=me===$-1;ne.push(ge),ie+=ge.duration;var ke=ye||ie/y;ye=(_e?ie+_e.duration:0)/y,(be||(l[re.length]?ye>l[re.length].endTime:ye-ne[0].pts/y>=ve))&&(p||(L.push(ne[0].pts),P.push(ne[ne.length-1].index)),ue(ke,re.length,re.length),ve=c[re.length]||r)}else for(var xe,we=0;we<$;we++){var Se=C[we],Ee=C[we+1],je=we===$-1;ne.push(Se),ie+=Se.duration;var Be=xe||ie/y;xe=(Ee?ie+Ee.duration:0)/y,(je||xe+ae>=ve)&&(ae+=2===h?ie/y-ve:xe-ve,p||(L.push(ne[0].pts),P.push(ne[ne.length-1].index)),ue(Be,re.length,re.length),ve=c[re.length]||r)}}return re}function qr(e,t,r){r.offset=0;var n=(null==r?void 0:r.beforeFrameNum)||0,i=(null==r?void 0:r.usedCttsIdx)||0;if(!e||(null==e?void 0:e.length)<=0||(null==r?void 0:r.usedCttsIdx)>=e.length)r.offset=0,r.usedCttsIdx=i,r.beforeFrameNum=n;else{var a=e[i];if(t<n+((null==a?void 0:a.count)||1))r.offset=(null==a?void 0:a.offset)||0;else{var s=e[++i];s?(r.offset=s.offset||0,r.beforeFrameNum=n+a.count):(r.offset=0,r.beforeFrameNum=n+1),r.usedCttsIdx=i}}}function Vr(e){var t="",r="",n=0,i=0,a=0,s=0,o=0,u=0,c=0;e.mvhd&&(o=e.mvhd.duration/e.mvhd.timescale);var l=e.trak;if(l){var d,f,h,p,v,y,m,g,_,b,k,x,w,S,E,j,B,A=l.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)})),T=l.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)})),C=null;if(A)if(C=null===(f=A.mdia)||void 0===f||null===(h=f.minf)||void 0===h||null===(p=h.stbl)||void 0===p?void 0:p.stsd.entries[0])if(n=C.width,i=C.height,u=null===(v=A.mdia)||void 0===v||null===(y=v.mdhd)||void 0===y?void 0:y.timescale,t=null===(m=C.avcC||C.hvcC||C.vvcC)||void 0===m?void 0:m.codec,"encv"===C.type)d=null===(g=C.sinf)||void 0===g||null===(_=g.schi)||void 0===_?void 0:_.tenc.default_KID;if(T)if(C=null===(b=T.mdia)||void 0===b||null===(k=b.minf)||void 0===k||null===(x=k.stbl)||void 0===x?void 0:x.stsd.entries[0])if(a=C.channelCount,s=C.sampleRate,r=null===(w=C.esds)||void 0===w?void 0:w.codec,c=null===(S=T.mdia)||void 0===S||null===(E=S.mdhd)||void 0===E?void 0:E.timescale,"enca"===C.type)d=d||(null===(j=C.sinf)||void 0===j||null===(B=j.schi)||void 0===B?void 0:B.tenc.default_KID);return{kid:d?d.join(""):null,videoCodec:t,audioCodec:r,width:n,height:i,videoTimescale:u,audioChannelCount:a,audioSampleRate:s,duration:o,audioTimescale:c,moov:e}}}function Gr(e){return"number"==typeof e&&!Number.isNaN(e)}function Hr(e){if(!e)return!1;var t=e.audioSegments,r=e.videoSegments,n=!r||0===r.length,i=!t||0===t.length;return!n||!i}var Kr=["vid","cache"],Wr=function(e){l(S,e);var n,i,o,d,f,h,p,v,g,b,k,w=_(S);function S(e){var r,n;s(this,S),c(m(r=w.call(this)),"vid",""),c(m(r),"url",""),c(m(r),"meta",{}),c(m(r),"downloadInfo",[]),c(m(r),"videoSegments",[]),c(m(r),"audioSegments",[]),c(m(r),"cache",null),c(m(r),"_currentSegmentIndex",-1),c(m(r),"_currentLoadingSegmentIndex",-1),c(m(r),"buffer",void 0),c(m(r),"bufferDataLen",0),c(m(r),"_error",void 0),c(m(r),"_transformError",(function(e){return e})),r._config=("boolean"!=typeof(n=e).fixEditListOffset&&delete n.fixEditListOffset,t({vid:"",moovEnd:8e4,segmentDuration:2,maxDownloadInfoSize:30,responseType:"arraybuffer",fixEditListOffset:!0,cache:null},n));var i=r._config,a=i.vid,o=i.cache,u=y(i,Kr);return r.cache=o||new Ir,r.vid=a||u.url,r.url=u.url,u.transformError=r._transformError,r.logger=new Q("MP4Loader_"+r.vid),e.openLog&&Q.enable(),u.logger=r.logger,r._loader=new Be(u),r._loader.on(ye,(function(e){r.emit(ye,e)})),r}return u(S,[{key:"isMetaLoaded",get:function(){return this.videoSegments.length||this.audioSegments.length}},{key:"setCurrentSegment",value:function(e){Gr(e)&&(this._currentSegmentIndex=e)}},{key:"isLastSegment",value:function(e){var t,r;return!!Gr(e)&&e>=((null===(t=this.videoSegments[this.videoSegments.length-1])||void 0===t?void 0:t.index)||(null===(r=this.audioSegments[this.audioSegments.length-1])||void 0===r?void 0:r.index)||0)}},{key:"isSegmentLoading",value:function(e){return e===this._currentLoadingSegmentIndex}},{key:"changeUrl",value:(k=a(r().mark((function e(t){var n,i,a,s=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:t,i=s.length>2?s[2]:void 0,a=s.length>3?s[3]:void 0,e.next=5,this.reset(a);case 5:t&&(this.url=t),n&&(this.vid=n),i&&(this._config.moovEnd=i);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getOrLoadMeta",value:(b=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(t);case 3:return e.abrupt("return",this.meta);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"newBufferArray",value:function(e,t){var r;if(this.buffer){if(t||(null===(r=this.buffer)||void 0===r?void 0:r.byteLength)<e){var n,i=this.buffer.subarray(0,this.bufferDataLen),a=Ee(((null===(n=this.buffer)||void 0===n?void 0:n.byteLength)||0)+e);a.set(i,0),delete this.buffer,this.buffer=a}}else this.buffer=Ee(e),this.bufferDataLen=0}},{key:"loadMetaProcess",value:(g=a(r().mark((function e(n,i,s){var o,u,c,l,d,f,h=this,p=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(u=x(i,2),c=u[0],l=u[1],d=p.length>3&&void 0!==p[3]?p[3]:{},this._error=!1,this.logger.debug("[loadMetaProcess start], range,",[c,l]),null!==(o=this._config)&&void 0!==o&&o.memoryOpt&&(!this.buffer||null!=d&&d.isExp))try{this.newBufferArray(l-c+1,null==d?void 0:d.isExp)}catch(v){s(null,!0,{},new Rr(null==v?void 0:v.message),{})}return f=function(){var e=a(r().mark((function e(t,i,a,o){var u,f,p,v,y,m,g,_,b,k,x;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h.meta&&null!=a&&a.range&&a.range.length>0&&a.range[1]>=l&&(i=!0,h.logger.debug("[loadMetaProcess],data done,setstate true,[",c,l,"]")),i&&null!=a&&a.range&&a.range.length>0&&a.range[1]<l&&(i=!1,h.logger.debug("[loadMetaProcess],data not done,setstate false,[",c,l,"]")),h.logger.debug("[loadMetaProcess],task,[",c,l,"], range,",a.range,",dataLen,",t?t.byteLength:void 0,", state,",i,",err,",h._error),!h._error&&t&&t.byteLength>0&&s(t,i,a,null,o),!h.meta.moov&&!h._error){e.next=6;break}return e.abrupt("return");case 6:if(!(t&&t.byteLength>0)){e.next=52;break}e.prev=7,null!==(f=h._config)&&void 0!==f&&f.memoryOpt?(h.buffer.set(t,h.bufferDataLen),h.bufferDataLen+=(null==t?void 0:t.byteLength)||0,u=h.buffer.subarray(0,h.bufferDataLen)):(h.buffer=Se(h.buffer,t),u=h.buffer),e.next=15;break;case 11:return e.prev=11,e.t0=e.catch(7),s(null,i,a,new Rr(null===e.t0||void 0===e.t0?void 0:e.t0.message),o),e.abrupt("return");case 15:if(p=Bt.findBox(u,["moov"])[0]){e.next=30;break}if(v=Bt.findBox(u,["mdat"])[0],!i){e.next=30;break}if(v){e.next=25;break}return h._error=!0,s(null,i,a,new Rr("cannot find moov or mdat box"),o),e.abrupt("return");case 25:return y=v.start+v.size,e.next=28,h.loadData([y,""],n,d);case 28:(m=e.sent)&&(p=Bt.findBox(m.data,["moov"])[0]);case 30:if(!(p&&i&&p.size>p.data.length)){e.next=34;break}return h.logger.debug("[loadMetaProcess],moov not all, range,",a.range[1],",dataLen,",h.bufferDataLen,", state,",i),e.next=34,h.loadMetaProcess(n,[a.range[1],p.start+p.size-1],s,{isExp:!0});case 34:if(!(p&&p.size<=p.data.length)||h.meta.moov){e.next=52;break}if(_=Bt.moov(p)){e.next=40;break}return h._error=!0,s(null,i,a,new Rr("cannot parse moov box"),o),e.abrupt("return");case 40:if(Hr(b=Fr(_,h._config))){e.next=45;break}return h._error=!0,s(null,i,a,new Rr("cannot parse segments"),o),e.abrupt("return");case 45:h.meta=Vr(_),k=b.videoSegments,x=b.audioSegments,h.videoSegments=k,h.audioSegments=x,null!==(g=h._config)&&void 0!==g&&g.memoryOpt&&(delete h.buffer,h.bufferDataLen=0),h.logger.debug("[loadMetaProcess] moov ok"),s(void 0,i,{meta:{meta:h.meta,videoSegments:k,audioSegments:x}},null,o);case 52:case"end":return e.stop()}}),e,null,[[7,11]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),e.next=8,this.loadData([c,l||this._config.moovEnd],n,t({onProgress:f},d));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return g.apply(this,arguments)})},{key:"loadMeta",value:(v=a(r().mark((function e(t,n){var i,a,s,o,u,c,l,d,f,h,p=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=p.length>2&&void 0!==p[2]?p[2]:{},a=[],this.logger.debug("[loadMeta start]"),e.next=5,this.loadData([0,n||this._config.moovEnd],t,i);case 5:if(s=e.sent){e.next=8;break}return e.abrupt("return");case 8:if(a.push(s),o=Bt.findBox(s.data,["moov"])[0]){e.next=24;break}if(u=Bt.findBox(s.data,["mdat"])[0]){e.next=14;break}throw new Rr("cannot find moov or mdat box",s.data);case 14:return c=u.start+u.size,e.next=17,this.loadData([c],t,i);case 17:if(s=e.sent){e.next=20;break}return e.abrupt("return");case 20:if(a.push(s),o=Bt.findBox(s.data,["moov"],c)[0]){e.next=24;break}throw new Rr("cannot find moov box",s.data);case 24:if(!(o.size>o.data.length)){e.next=32;break}return e.next=27,this.loadData([s.data.length,o.start+o.size-1],t,i);case 27:if(s=e.sent){e.next=30;break}return e.abrupt("return");case 30:a.push(s),o.data=Se(o.data,s.data);case 32:if(l=Bt.moov(o)){e.next=35;break}throw new Rr("cannot parse moov box",o.data);case 35:if(Hr(d=Fr(l,this._config))){e.next=38;break}throw new Rr("cannot parse segments",o.data);case 38:return this.meta=Vr(l),f=d.videoSegments,h=d.audioSegments,this.videoSegments=f,this.audioSegments=h,delete this.buffer,this.bufferDataLen=0,this.logger.debug("[load moov end!!!!!]"),e.abrupt("return",{meta:this.meta,videoSegments:f,audioSegments:h,responses:a});case 46:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"loadCacheMeta",value:function(e,t){var r=Fr(e.moov,this._config),n=r.videoSegments,i=r.audioSegments;this.videoSegments=n,this.audioSegments=i,this._currentSegmentIndex=t,this.meta=e}},{key:"getSegmentByTime",value:function(e){var t,r;return this.videoSegments.length?(t=this.videoSegments.find((function(t){return t.startTime<=e&&t.endTime>e})))&&(r=this.audioSegments[t.index]):r=this.audioSegments.find((function(t){return t.startTime<=e&&t.endTime>e})),{video:t,audio:r}}},{key:"loadSegmentByTime",value:(p=a(r().mark((function e(t,n){var i,a,s,o,u,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!(c.length>2&&void 0!==c[2])||c[2],a=c.length>3&&void 0!==c[3]?c[3]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta(n);case 5:return s=this.getSegmentByTime(t),o=s.video,u=s.audio,e.abrupt("return",this._loadSegment(o,u,n,i,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"loadNextSegment",value:(h=a(r().mark((function e(t){var n,i,a,s,o=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(o.length>1&&void 0!==o[1])||o[1],i=o.length>2&&void 0!==o[2]?o[2]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta();case 5:return a=this.videoSegments[this._currentSegmentIndex+1],s=this.audioSegments[this._currentSegmentIndex+1],e.abrupt("return",this._loadSegment(a,s,t,n,i));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"preload",value:(f=a(r().mark((function e(t){var n,i,s,o,u,c,l,d=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(!0);case 3:if(t&&!(t<0)){e.next=5;break}return e.abrupt("return");case 5:if(n=this.getSegmentByTime(t),i=n.video,s=n.audio,o=Math.max((null==i?void 0:i.index)||0,(null==s?void 0:s.index)||0)){e.next=9;break}return e.abrupt("return");case 9:return u=this.videoSegments.slice(0,o),c=this.audioSegments.slice(0,o),l=function(){var e=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t>o)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,d._loadSegment(u[t],c[t],!0,!1);case 4:return e.next=6,l(t+1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=14,l(0);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"cancel",value:function(){return this._loader.cancel()}},{key:"reset",value:(d=a(r().mark((function e(){var t,n=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>0&&void 0!==n[0]&&n[0]){e.next=5;break}return this.logger.debug("[MP4loader reset func call loader.cancel]"),e.next=5,this._loader.cancel();case 5:this.vid=this.url="",this.meta={},this.downloadInfo=[],this.videoSegments=[],this.audioSegments=[],this._currentSegmentIndex=-1,this._currentLoadingSegmentIndex=-1,null!==(t=this._config)&&void 0!==t&&t.memoryOpt&&(delete this.buffer,this.bufferDataLen=0);case 13:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"destroy",value:(o=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.reset();case 2:this.cache.clear();case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_loadSegment",value:(i=a(r().mark((function e(t,n,i,a,s){var o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t||n){e.next=2;break}return e.abrupt("return");case 2:return o=(null==t?void 0:t.index)||(null==n?void 0:n.index)||0,this._currentLoadingSegmentIndex=o,e.prev=4,e.next=7,this.loadData([Math.min((null==t?void 0:t.range[0])||1/0,(null==n?void 0:n.range[0])||1/0),Math.max((null==t?void 0:t.range[1])||0,(null==n?void 0:n.range[1])||0)],i,s);case 7:u=e.sent;case 8:return e.prev=8,this._currentLoadingSegmentIndex=-1,e.finish(8);case 11:if(u){e.next=13;break}return e.abrupt("return");case 13:return a&&(this._currentSegmentIndex=o),u.video=t,u.audio=n,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this,[[4,,8,11]])}))),function(e,t,r,n,a){return i.apply(this,arguments)})},{key:"loadData",value:(n=a(r().mark((function e(n,i){var a,s,o,u,c,l=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=l.length>2&&void 0!==l[2]?l[2]:{},s=this._getCacheKey(n),e.next=4,this.cache.get(s);case 4:if(o=e.sent){e.next=12;break}return c=null!=a&&a.url?a.url:this.url,e.next=9,this._loader.load(c,t({range:n,vid:this.vid},a));case 9:u=e.sent,e.next=13;break;case 12:u={data:o,state:!0,options:{fromCache:!0,range:n,vid:this.vid}};case 13:if(u){e.next=15;break}return e.abrupt("return");case 15:return o||(u.data&&this.downloadInfo.push({startTime:u.startTime,endTime:u.endTime,size:u.data.byteLength,range:n}),this.downloadInfo&&this.downloadInfo.length>this._config.maxDownloadInfoSize&&(this.downloadInfo=this.downloadInfo.slice(-this._config.maxDownloadInfoSize))),e.abrupt("return",u);case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_getCacheKey",value:function(e){return(this.vid||this.url)+":"+e}}]),S}(ge);return Wr}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.object.assign.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.string.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.regexp.exec.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.json.stringify.js"),require("core-js/modules/es.array.join.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.string.includes.js"),require("core-js/modules/es.number.is-finite.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.array.find-index.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.string.match.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.array.concat.js","core-js/modules/es.array.find.js","core-js/modules/es.object.to-string.js","core-js/modules/es.array.slice.js","core-js/modules/es.object.assign.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.keys.js","core-js/modules/es.promise.js","core-js/modules/es.array.iterator.js","core-js/modules/es.string.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.regexp.exec.js","core-js/modules/es.function.name.js","core-js/modules/es.array.map.js","core-js/modules/es.json.stringify.js","core-js/modules/es.array.join.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.string.includes.js","core-js/modules/es.number.is-finite.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.regexp.test.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js","core-js/modules/es.array.find-index.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.string.match.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).MP4Loader=t()}(this,(function(){"use strict";function e(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 t(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?e(Object(n),!0).forEach((function(e){c(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(){r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(T){c=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof h?t:h,s=Object.create(a.prototype),o=new j(n||[]);return i(s,"_invoke",{value:x(e,r,o)}),s}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(T){return{type:"throw",arg:T}}}e.wrap=l;var f={};function h(){}function p(){}function v(){}var y={};c(y,s,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(A([])));g&&g!==t&&n.call(g,s)&&(y=g);var _=v.prototype=h.prototype=Object.create(y);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(i,a,s,o){var u=d(e[i],e,a);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,o)}),(function(e){r("throw",e,s,o)})):t.resolve(l).then((function(e){c.value=e,s(c)}),(function(e){return r("throw",e,s,o)}))}o(u.arg)}var a;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return a=a?a.then(i,i):i()}})}function x(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var s=r.delegate;if(s){var o=w(s,r);if(o){if(o===f)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=d(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function w(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,w(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,f;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function S(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 E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function A(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 r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:B}}function B(){return{value:void 0,done:!0}}return p.prototype=v,i(_,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,u,"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,c(e,u,"GeneratorFunction")),e.prototype=Object.create(_),e},e.awrap=function(e){return{__await:e}},b(k.prototype),c(k.prototype,o,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var s=new k(l(t,r,n,i),a);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},b(_),c(_,u,"Generator"),c(_,s,(function(){return this})),c(_,"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=A,j.prototype={constructor:j,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(E),!e)for(var t in this)"t"===t.charAt(0)&&n.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 r(r,n){return s.type="throw",s.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 a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var o=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(o&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(o){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var s=a?a.completion:{};return s.type=e,s.arg=t,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},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),E(r),f}},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;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}function n(e){return(n="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 i(e,t,r,n,i,a,s){try{var o=e[a](s),u=o.value}catch(c){return void r(c)}o.done?t(u):Promise.resolve(u).then(n,i)}function a(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var s=e.apply(t,r);function o(e){i(s,n,a,o,u,"next",e)}function u(e){i(s,n,a,o,u,"throw",e)}o(void 0)}))}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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,j(n.key),n)}}function u(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,r){return(t=j(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l(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&&f(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function p(e,t,r){return(p=h()?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&&f(i,r.prototype),i}).apply(null,arguments)}function v(e){var t="function"==typeof Map?new Map:void 0;return v=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 p(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)},v(e)}function y(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(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 m(e)}function _(e){var t=h();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return g(this,r)}}function b(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function k(){return k="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=b(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},k.apply(this,arguments)}function x(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,a,s,o=[],u=!0,c=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.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&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}(e,t)||S(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 w(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||S(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 S(e,t){if(e){if("string"==typeof e)return E(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)?E(e,t):void 0}}function E(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 j(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)}function A(){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 B(){try{return parseInt(performance.now(),10)}catch(e){return(new Date).getTime()}}var T,C=function(){function e(){s(this,e)}return u(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 a=r.length;if(a&&t){var s=r[a-1],o=s[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(s[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,a=0,s=0,o=0,u=0,c=0,l=0,d=e.buffers(t,n),f=0,h=d.length;f<h;f++){var p=d[f];if(r+n>=p[0]&&r<=p[1])i=p[0],a=p[1],s=f;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:a,index:s,buffers:d,nextStart:o,nextEnd:u,prevStart:c,prevEnd:l,currentTime:r,behind:r-i,remaining:a?a-r:0,length:e.totalLength&&e.totalLength(d)}}}]),e}(),D="network",O="network_timeout",L="network_forbidden",P="network_notfound",U="network_range_not_satisfiable",R="demux",I="remux",M="media",z="drm",F="other",N="runtime",q={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",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"},V=(c(T={},"manifest",{HLS:1100,DASH:1200}),c(T,D,2100),c(T,O,2101),c(T,L,2103),c(T,P,2104),c(T,U,2116),c(T,R,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),c(T,I,{FMP4:4100,MP4:4200}),c(T,M,{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,EME_HIJACK:5301}),c(T,z,{LICENSE:7100,CUSTOM_LICENSE:7200}),c(T,F,8e3),c(T,N,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),T),G=function(e){l(r,e);var t=_(r);function r(e,n,i,a,o){var u;return s(this,r),(u=t.call(this,o||(null==i?void 0:i.message))).errorType=e===O?D:e,u.originError=i,u.ext=a,u.errorCode=V[e][n]||V[e],u.errorMessage=u.message,u.errorCode||(u.errorType=F,u.errorCode=V[u.errorType]),u}return u(r,null,[{key:"create",value:function(e,t,n,i,a){return e instanceof r?e:(e instanceof Error&&(n=e,e=""),e||(e=F),new r(e,t,n,i,a))}},{key:"network",value:function(e){var t;return new r(null!=e&&e.isTimeout?O:D,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}(v(Error)),H="undefined"!=typeof window,K={DEBUG:1,LOG:2,WARN:3,ERROR:4},W=["Boolean","Number","String","Undefined","Null","Date","Object"],Q=function(){function e(t,r){s(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 u(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,[K.DEBUG].concat(n)),e.disabled||(t=console).debug.apply(t,[this._prefix,Y()].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,[K.LOG].concat(n)),e.disabled||(t=console).log.apply(t,[this._prefix,Y()].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,[K.WARN].concat(n)),e.disabled||(t=console).warn.apply(t,[this._prefix,Y()].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,[K.ERROR].concat(n)),e.disabled||(t=console).error.apply(t,[this._prefix,Y()].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 a=n.map((function(e){return Z(e)}));t=this._prefix+Y()+JSON.stringify(a)}catch(o){return}if(e>=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var s=this.logTextArray.shift();this.logSize-=s.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 Y(){return(new Date).toLocaleString()}function X(e){if("object"!==n(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 Z(e,t,r){r||(r=1),t||(t=2);var i={};if(!e||"object"!==n(e))return e;var a=Object.prototype.toString.call(e).slice(8,-1);if(!W.includes(a))return a;if(!(r>t)){for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r===t?i[s]=X(e[s]):"object"===n(e[s])?i[s]=Z(e[s],t,r+1):i[s]=e[s]);return i}}c(Q,"disabled",!0);var J=function(){try{return H?window.MediaSource:null}catch(e){}}(),$="appendBuffer",ee="removeBuffer",te="updateDuration",re=function(){function e(t,r){var n=this;s(this,e),c(this,"media",null),c(this,"mediaSource",null),c(this,"_openPromise",A()),c(this,"_queue",Object.create(null)),c(this,"_sourceBuffer",Object.create(null)),c(this,"_mseFullFlag",{}),c(this,"_st",0),c(this,"_opst",0),c(this,"_logger",null),c(this,"_config",null),c(this,"_url",null),c(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var r=t[0];if((null==r?void 0:r.opName)!==te&&t.shift(),r){var i=B()-n._opst;n._logger.debug("UpdateEnd",r.opName,i,r.context),r.promise.resolve({name:r.opName,context:r.context,costtime:i}),n._startQueue(e)}}})),c(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 G(M,q.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),r),t&&this.bindMedia(t),this._logger=new Q("MSE"),this._config.openLog&&Q.enable()}var t,n,i;return u(e,[{key:"isOpened",get:function(){var e;return"open"===(null===(e=this.mediaSource)||void 0===e?void 0:e.readyState)}},{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:"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("[debug mse] setDuration ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("[debug mse] setDuration"))}),te,{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=B()-e._st;e._logger.debug("MSE OPEN",n),t.removeEventListener("sourceopen",r),e._openPromise.resolve({costtime:n})})),this._openPromise=A()}return this._openPromise}},{key:"bindMedia",value:(i=a(r().mark((function e(t){var n,i,a=this;return r().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(t&&J){e.next=5;break}throw new Error("Param media or MediaSource does not exist");case 5:return this.media=t,n=this.mediaSource=new J,this._st=B(),i=function e(){var r=B()-a._st;a._logger.debug("MSE OPEN"),n.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),a._openPromise.resolve({costtime:r}),t.dispatchEvent(new CustomEvent("mseAttached"))},n.addEventListener("sourceopen",i),this._url=URL.createObjectURL(n),t.src=this._url,t.dispatchEvent(new CustomEvent("mseAttaching")),e.abrupt("return",this._openPromise);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"unbindMedia",value:(n=a(r().mark((function e(){var t,n,i,a=this;return r().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=a._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)}))})),n=!!this.media&&this.media.readyState>=1,i="open"===t.readyState,n&&i)try{t.endOfStream()}catch(r){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(a._sourceBuffer[e])}catch(r){}}))}if(this.media){this.media.removeAttribute("src");try{this.media.load()}catch(r){}this.media=null}this.mediaSource=null,this._openPromise=A(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.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 G(M,q.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():this._enqueueOp(e,(function(){n.changeType(t),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=B(),null===(i=n._sourceBuffer[e])||void 0===i||i.appendBuffer(t))}),$,r):Promise.resolve()}},{key:"remove",value:function(e,t,r,n){var i=this,a=!1;return this._mseFullFlag[e]&&(a=!0),this._enqueueOp(e,(function(){if(i.mediaSource&&!i.media.error){var a=i._sourceBuffer[e];t>=r||!a?i._onSBUpdateEnd(e):(i._opst=B(),i._logger.debug("MSE REMOVE START",e,t,r,n),a.remove(t,r))}}),ee,n,a)}},{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,C.end(C.get(n)))})),e}},{key:"clearOpQueues",value:function(e){var t,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._logger.debug("MSE clearOpQueue START");var n=this._queue[e];if(r&&n)this._queue[e]=[];else if(Array.isArray(n)&&!(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&&(t=this._queue[e]).push.apply(t,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 C.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return C.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return C.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,r,n,i){var a=this;if(!this.mediaSource)return Promise.resolve();var s=this._queue[e]=this._queue[e]||[],o={exec:t,promise:A(),opName:r,context:n};return i?(s.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):s.push(o),this.isOpened||this.isEnded?1===s.length&&this._startQueue(e):this._openPromise.then((function(){1===s.length&&a._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=a(r().mark((function e(t,n,i){var a,s,o=this;return r().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((a=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],a.forEach((function(e){var t=o._queue[e],r=A();s.push(r),t.push({exec:function(){r.resolve()},promise:r,opName:n,context:i}),1===t.length&&o._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{a.forEach((function(e){var t=o._queue[e],r=o._sourceBuffer[e];null==t||t.shift(),r&&r.updating||o._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,this._logger.error("[MSE error], context,",r.context," ,name,",r.opName,",err,SourceBuffer is full"),r.promise.reject(new G(M,q.MSE_FULL,n))):(this._logger.error(n),r.promise.reject(new G(M,q.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(){var t;null===(t=r._sourceBuffer[e])||void 0===t||t.abort(),r._onSBUpdateEnd(e)}),"abort",t):Promise.resolve()}}],[{key:"getDefaultConfig",value:function(){return{openLog:!1}}},{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';if(!J)return!1;try{return J.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}}]),e}();c(re,"VIDEO","video"),c(re,"AUDIO","audio");var ne="fetch",ie="xhr",ae="arraybuffer",se="text",oe="json",ue=function(e){l(r,e);var t=_(r);function r(e,n,i,a){var o;return s(this,r),c(m(o=t.call(this,a)),"retryCount",0),c(m(o),"isTimeout",!1),c(m(o),"loaderType",ne),c(m(o),"startTime",0),c(m(o),"endTime",0),c(m(o),"options",{}),o.url=e,o.request=n,o.response=i,o}return u(r)}(v(Error)),ce=Object.prototype.toString;function le(e){if("[object Object]"!==ce.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function de(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 fe(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function he(e,t){if(e){if(!t)return e;var r,i=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]"===ce.call(r)?t=t.toISOString():function(e){return null!==e&&"object"===n(e)}(t)&&(t=JSON.stringify(t)),"".concat(fe(e),"=").concat(fe(t))})).join("&")})).filter(Boolean).join("&");if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}}function pe(e,t,r,n,i,a,s,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:a,firstByteTime:s,endTime:Date.now(),priOptions:l},response:r}}function ve(e,t){return Math.round(8*e*1e3/t/1024)}var ye="real_time_speed",me={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 a(e,t,n,a,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,a||e,s),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 s(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,a=n.length,s=new Array(a);i<a;i++)s[i]=n[i].fn;return s},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,a,s){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,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,s),!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 f,h=l.length;for(c=0;c<h;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(f=1,u=new Array(d-1);f<d;f++)u[f-1]=arguments[f];l[c].fn.apply(l[c].context,u)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||s(this,a);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[a]=1===c.length?c[0]:c:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new 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}(me);var ge=me.exports,_e=2097152,be=function(e){l(i,e);var t,n=_(i);function i(){var e;return s(this,i),c(m(e=n.call(this)),"_abortController",null),c(m(e),"_timeoutTimer",null),c(m(e),"_reader",null),c(m(e),"_response",null),c(m(e),"_aborted",!1),c(m(e),"_index",-1),c(m(e),"_range",null),c(m(e),"_receivedLength",0),c(m(e),"_running",!1),c(m(e),"_logger",null),c(m(e),"_vid",""),c(m(e),"_onProcessMinLen",0),c(m(e),"_onCancel",null),c(m(e),"_priOptions",null),c(m(e),"_processMaxGapTime",1/0),e}return u(i,[{key:"load",value:function(e){var t,n=this,i=e.url,s=e.vid,o=e.timeout,u=e.responseType,c=e.onProgress,l=e.index,d=e.onTimeout,f=e.onCancel,h=e.range,p=e.transformResponse,v=e.request,y=e.params,m=e.logger,g=e.method,_=e.headers,b=e.body,k=e.mode,x=e.credentials,w=e.cache,S=e.redirect,E=e.referrer,j=e.referrerPolicy,A=e.onProcessMinLen,B=e.processMaxGapTime,T=e.priOptions;this._logger=m,this._aborted=!1,this._onProcessMinLen=A,this._onCancel=f,this._abortController="undefined"!=typeof AbortController&&new AbortController,this._running=!0,this._receivedLength=0,this._index=l,this._range=h||[0,0],this._vid=s||i,this._priOptions=T||{},this._processMaxGapTime=B;var C={method:g,headers:_,body:b,mode:k,credentials:x,cache:w,redirect:S,referrer:E,referrerPolicy:j,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal},D=!1;clearTimeout(this._timeoutTimer),i=he(i,y);var O=de(h);O&&(_=v?v.headers:C.headers=C.headers||(Headers?new Headers:{}),Headers&&_ instanceof Headers?_.append("Range",O):_.Range=O),o&&(this._timeoutTimer=setTimeout(a(r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return D=!0,e.next=3,n.cancel();case 3:d&&((t=new ue(i,C,null,"timeout")).isTimeout=!0,d(t,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions}));case 4:case"end":return e.stop()}}),e)}))),o));var L=Date.now();return this._logger.debug("[fetch load start], index,",l,",range,",h),new Promise((function(e,t){fetch(v||i,v?void 0:C).then(function(){var s=a(r().mark((function a(s){var o,d,f,v;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(clearTimeout(n._timeoutTimer),n._response=s,!n._aborted&&n._running){r.next=4;break}return r.abrupt("return");case 4:if(p&&(s=p(s,i)||s),s.ok){r.next=7;break}throw new ue(i,C,s,"bad network response");case 7:if(o=Date.now(),u!==se){r.next=15;break}return r.next=11,s.text();case 11:d=r.sent,n._running=!1,r.next=37;break;case 15:if(u!==oe){r.next=22;break}return r.next=18,s.json();case 18:d=r.sent,n._running=!1,r.next=37;break;case 22:if(!c){r.next=29;break}return n.resolve=e,n.reject=t,n._loadChunk(s,c,L,o),r.abrupt("return");case 29:return r.next=31,s.arrayBuffer();case 31:d=r.sent,d=new Uint8Array(d),n._running=!1,f=Date.now()-L,v=ve(d.byteLength,f),n.emit(ye,{speed:v,len:d.byteLength,time:f,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions});case 37:n._logger.debug("[fetch load end], index,",l,",range,",h),e(pe(d,!0,s,s.headers.get("Content-Length"),s.headers.get("age"),L,o,l,h,n._vid,n._priOptions));case 39:case"end":return r.stop()}}),a)})));return function(e){return s.apply(this,arguments)}}()).catch((function(e){var r;clearTimeout(n._timeoutTimer),n._running=!1,n._aborted&&!D||((e=e instanceof ue?e:new ue(i,C,null,null===(r=e)||void 0===r?void 0:r.message)).startTime=L,e.endTime=Date.now(),e.isTimeout=D,e.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},t(e))}))}))}},{key:"cancel",value:(t=a(r().mark((function e(){return r().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,n,i){var s=this;if(!e.body||!e.body.getReader){this._running=!1;var o=new ue(e.url,"",e,"onProgress of bad response.body.getReader");return o.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},void this.reject(o)}this._onProcessMinLen>0&&(this._cache=new Uint8Array(_e),this._writeIdx=0);var u,c,l,d=this._reader=e.body.getReader(),f=Date.now(),h=function(){var o=a(r().mark((function a(){var o,p,v,y,m,g,_,b,k;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return c=Date.now(),r.prev=1,r.next=4,d.read();case 4:u=r.sent,l=Date.now(),r.next=13;break;case 8:return r.prev=8,r.t0=r.catch(1),l=Date.now(),s._aborted||(s._running=!1,r.t0.options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.reject(r.t0)),r.abrupt("return");case 13:if(p=(null===(o=s._range)||void 0===o?void 0:o.length)>0?s._range[0]:0,v=p+s._receivedLength,!s._aborted){r.next=19;break}return s._running=!1,t(void 0,!1,{range:[v,v],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e),r.abrupt("return");case 19:if(y=u.value?u.value.byteLength:0,s._receivedLength+=y,s._onProcessMinLen>0?s._writeIdx+y>=s._onProcessMinLen||u.done?((m=new Uint8Array(s._writeIdx+y)).set(s._cache.subarray(0,s._writeIdx),0),y>0&&m.set(u.value,s._writeIdx),s._writeIdx=0,s._logger.debug("【fetchLoader,onProgress enough】,done,",u.done,",len,",m.byteLength,", writeIdx,",s._writeIdx)):y>0&&s._writeIdx+y<_e?(s._cache.set(u.value,s._writeIdx),s._writeIdx+=y,s._logger.debug("【fetchLoader,onProgress cache】,len,",y,", writeIdx,",s._writeIdx)):y>0&&(g=new Uint8Array(s._writeIdx+y+2048),s._logger.debug("【fetchLoader,onProgress extra start】,size,",s._writeIdx+y+2048,", datalen,",y,", writeIdx,",s._writeIdx),g.set(s._cache.subarray(0,s._writeIdx),0),y>0&&g.set(u.value,s._writeIdx),s._writeIdx+=y,delete s._cache,s._cache=g,s._logger.debug("【fetchLoader,onProgress extra end】,len,",y,", writeIdx,",s._writeIdx)):m=u.value,!(m&&m.byteLength>0||u.done)){r.next=28;break}s._logger.debug("【fetchLoader,onProgress call】,task,",s._range,", start,",v,", end,",p+s._receivedLength,", done,",u.done,n),t(m,u.done,{range:[s._range[0]+s._receivedLength-(m?m.byteLength:0),s._range[0]+s._receivedLength],vid:s._vid,index:s._index,startTime:c,endTime:l,st:n,firstByteTime:i,priOptions:s._priOptions},e),f=Date.now(),r.next=37;break;case 28:if(!(Date.now()-f>=s._processMaxGapTime)){r.next=37;break}return s._logger.debug("[onProgress timeout],task: ".concat(JSON.stringify(s._range)," done: ").concat(u.done," processMaxGapTime: ").concat(s._processMaxGapTime)),(_=new ue(e.url,null,e,"process timeout")).options={index:s._index,range:s._range,vid:s._vid,priOptions:s._priOptions},s.running=!1,r.next=35,s.cancel();case 35:return s.reject(_),r.abrupt("return");case 37:u.done?(b=Date.now()-n,k=ve(s._receivedLength,b),s.emit(ye,{speed:k,len:s._receivedLength,time:b,vid:s._vid,index:s._index,range:s._range,priOptions:s._priOptions}),s._running=!1,s._logger.debug("[fetchLoader onProgress end],task,",s._range,",done,",u.done),s.resolve(pe(u,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),n,i,s._index,s._range,s._vid,s._priOptions))):h();case 38:case"end":return r.stop()}}),a,null,[[1,8]])})));return function(){return o.apply(this,arguments)}}();h()}},{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)}}]),i}(ge);var ke=function(e){l(n,e);var r=_(n);function n(){var e;return s(this,n),c(m(e=r.call(this)),"_xhr",null),c(m(e),"_aborted",!1),c(m(e),"_timeoutTimer",null),c(m(e),"_range",null),c(m(e),"_receivedLength",0),c(m(e),"_url",null),c(m(e),"_onProgress",null),c(m(e),"_index",-1),c(m(e),"_headers",null),c(m(e),"_currentChunkSizeKB",384),c(m(e),"_timeout",null),c(m(e),"_xhr",null),c(m(e),"_withCredentials",null),c(m(e),"_startTime",-1),c(m(e),"_loadCompleteResolve",null),c(m(e),"_loadCompleteReject",null),c(m(e),"_runing",!1),c(m(e),"_logger",!1),c(m(e),"_vid",""),c(m(e),"_responseType",void 0),c(m(e),"_credentials",void 0),c(m(e),"_method",void 0),c(m(e),"_transformResponse",void 0),c(m(e),"_firstRtt",void 0),c(m(e),"_onCancel",null),c(m(e),"_priOptions",null),e}return u(n,[{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=he(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 ue?e:new ue(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===ae&&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 a=new ue(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));a.options={index:t._index,range:t._range,vid:t._vid,priOptions:t._priOptions},t._loadCompleteReject(a)},r.ontimeout=function(e){t.cancel();var r=new ue(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=de(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(a){a.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(a)}}},{key:"_onReadyStatechange",value:function(e){2===e.target.readyState&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var r,n=e.target.status;if(n<200||n>299){var i=new ue(this._url,null,t(t({},e.target.response),{},{status:n}),"bad response,status:"+n);return i.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(i)}var a,s=null,o=!1,u=(null===(r=this._range)||void 0===r?void 0:r.length)>0?this._range[0]:0;if(this._responseType===ae){var c,l=new Uint8Array(e.target.response);if(a=u+this._receivedLength,l&&l.byteLength>0){this._receivedLength+=l.byteLength;var d=Date.now()-this._startTime,f=ve(this._receivedLength,d);this.emit(ye,{speed:f,len:this._receivedLength,time:d,vid:this._vid,index:this._index,range:[a,u+this._receivedLength],priOptions:this._priOptions})}s=l,o=!((null===(c=this._range)||void 0===c?void 0:c.length)>1&&this._range[1]&&this._receivedLength<this._range[1]-this._range[0]),this._logger.debug("[xhr load done->], tast :",this._range,", start",a,"end ",u+this._receivedLength,",dataLen,",l?l.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",o)}else o=!0,s=e.target.response;var h={ok:n>=200&&n<300,status:n,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(h=this._transformResponse(h,this._url)||h),this._onProgress&&this._onProgress(s,o,{index:this._index,vid:this._vid,range:[a,u+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},h),o?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(pe(this._onProgress?null:s,o,h,h.headers["content-length"],h.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,k(d(n.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=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=S(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 a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}(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(a){n.e(a)}finally{n.f()}return r}}],[{key:"isSupported",value:function(){return"undefined"!=typeof XMLHttpRequest}}]),n}(ge),xe=["retry","retryDelay","onRetryError","transformError"],we=function(){function e(t,r){s(this,e),this.promise=A(),this.alive=!!r.onProgress,!r.logger&&(r.logger=new Q("Loader")),this._loaderType=t,this._loader=t===ne&&window.fetch?new be:new ke,this._config=r,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=r.retryCheckFunc,this._logger=r.logger}var t;return u(e,[{key:"exec",value:function(){var e=this,t=this._config,n=t.retry,i=t.retryDelay,s=t.onRetryError,o=t.transformError,u=y(t,xe),c=function(){var t=a(r().mark((function t(){var a,l,d;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e._loader.load(u);case 3:a=t.sent,e.promise.resolve(a),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,l=t.t0,o&&(l=o(l)||l),s&&e._retryCount>0&&s(l,e._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),e._retryCount++,d=!0,e._retryCheckFunc&&(d=e._retryCheckFunc(t.t0)),!(d&&e._retryCount<=n)){t.next=26;break}return clearTimeout(e._retryTimer),e._logger.debug("[task request setTimeout],retry",e._retryCount,",retry range,",u.range),e._retryTimer=setTimeout(c,i),t.abrupt("return");case 26:e.promise.reject(l);case 27:case"end":return t.stop()}}),t,null,[[0,7]])})));return function(){return t.apply(this,arguments)}}();return c(),this.promise}},{key:"cancel",value:(t=a(r().mark((function e(){return r().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 Se(){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=t.reduce((function(e,t){return e+t.byteLength}),0),i=Ee(n),a=0;return t.forEach((function(e){i.set(e,a),a+=e.byteLength})),i}function Ee(e){for(var t,r=0;r<10;)try{if((t=new Uint8Array(e))&&t.byteLength>0)break;r++}catch(n){if(!(r<10))throw new Error("new array failed final,".concat(null==n?void 0:n.message));r++}return t}function je(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new Promise((function(t){return setTimeout(t,e)}))}var Ae=function(e){l(o,e);var n,i=_(o);function o(e){var r;return s(this,o),c(m(r=i.call(this,e)),"type",ne),c(m(r),"_queue",[]),c(m(r),"_alive",[]),c(m(r),"_currentTask",null),c(m(r),"_finnalUrl",""),c(m(r),"_config",void 0),r._config=function(e){return t({loaderType:ne,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:se,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,processMaxGapTime:1/0},e)}(e),r._config.loaderType!==ie&&be.isSupported()||(r.type=ie),r.log=e.logger,r}return u(o,[{key:"isFetch",value:function(){return this.type===ne}},{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&&le(r.headers)&&(r.headers=Object.assign({},r.headers)),r.body&&le(r.body)&&(r.body=Object.assign({},r.body)),r.transformRequest&&(r=r.transformRequest(r)||r),r.logger=this.log;var n=new we(this.type,r);return n.loader.on(ye,(function(e){t.emit(ye,e)})),this._queue.push(n),1!==this._queue.length||this._currentTask&&this._currentTask.running||this._processTask(),n.promise}},{key:"cancel",value:(n=a(r().mark((function e(){var t;return r().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,je();case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.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 be.isSupported()}}]),o}(ge),Be="video",Te="audio",Ce="metadata",De="avc",Oe="hevc",Le="vvcC",Pe="aac",Ue="g7110a",Re="g7110m",Ie="LARGE_AV_SHIFT",Me="LARGE_VIDEO_GAP",ze="LARGE_VIDEO_GAP_BETWEEN_CHUNK",Fe="LARGE_AUDIO_GAP",Ne="AUDIO_FILLED",qe="AUDIO_DROPPED",Ve=function(){function e(){s(this,e),c(this,"id",1),c(this,"type",Be),c(this,"codecType",De),c(this,"pid",-1),c(this,"hvcC",void 0),c(this,"codec",""),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"sequenceNumber",0),c(this,"baseMediaDecodeTime",0),c(this,"baseDts",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"pps",[]),c(this,"sps",[]),c(this,"vps",[]),c(this,"fpsNum",0),c(this,"fpsDen",0),c(this,"sarRatio",[]),c(this,"width",0),c(this,"height",0),c(this,"nalUnitSize",4),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"isVideo",!0),c(this,"kid",null),c(this,"pssh",null),c(this,"ext",void 0)}return u(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:"exist",value:function(){return!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),e}(),Ge=function(){function e(){s(this,e),c(this,"id",2),c(this,"type",Te),c(this,"codecType",Pe),c(this,"pid",-1),c(this,"codec",""),c(this,"sequenceNumber",0),c(this,"sampleDuration",0),c(this,"timescale",0),c(this,"formatTimescale",0),c(this,"baseMediaDecodeTime",0),c(this,"duration",0),c(this,"warnings",[]),c(this,"samples",[]),c(this,"baseDts",0),c(this,"sampleSize",16),c(this,"sampleRate",0),c(this,"channelCount",0),c(this,"objectType",0),c(this,"sampleRateIndex",0),c(this,"config",[]),c(this,"present",!1),c(this,"isVideoEncryption",!1),c(this,"isAudioEncryption",!1),c(this,"kid",null),c(this,"ext",void 0)}return u(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.codecType===Pe)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}}]),e}(),He=function(){function e(t,r,n){s(this,e),c(this,"flag",{}),c(this,"keyframe",!1),c(this,"gopId",0),c(this,"duration",0),c(this,"size",0),c(this,"units",[]),c(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=r,n&&(this.units=n)}return u(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}(),Ke=u((function e(t,r,n,i){s(this,e),c(this,"duration",1024),c(this,"flag",{dependsOn:2,isNonSyncSample:0}),c(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=r,this.size=r.byteLength,this.sampleOffset=i,n&&(this.duration=n)})),We=u((function e(t,r){s(this,e),c(this,"time",0),this.data=t,this.originPts=this.pts=r})),Qe=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(We),Ye=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(We),Xe=function(){function e(){s(this,e),c(this,"id",3),c(this,"type",Ce),c(this,"timescale",0),c(this,"flvScriptSamples",[]),c(this,"seiSamples",[])}return u(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}(),Ze=function(){function e(t){if(s(this,e),c(this,"_bytesAvailable",void 0),c(this,"_bitsAvailable",0),c(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return u(e,[{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}(),Je=function(){function e(t){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return u(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}();c(Je,"disabled",!0);var $e=function(){function e(){s(this,e)}return u(e,null,[{key:"decode",value:function(t){for(var r=[],n=t,i=0,a=t.length;i<a;)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 s=(31&n[i])<<6|63&n[i+1];if(s>=128){r.push(String.fromCharCode(65535&s)),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}(),et="undefined"!=typeof window,tt=et&&navigator.userAgent.toLocaleLowerCase(),rt=et&&/^((?!chrome|android).)*safari/.test(tt),nt=et&&tt.includes("firefox"),it=et&&tt.includes("android");function at(){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 st=Math.pow(2,32);function ot(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(e[t]<<8)+(e[t+1]||0)}function ut(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 ct(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getInt32(t)}function lt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ut(e,t)*st+ut(e,t+4)}function dt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getUint32(t)<<32|r.getUint32(t+4)}function ft(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 ht(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)}))}var pt=function(){function e(){s(this,e)}return u(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,r=2,n=0;null!==e[r]&&void 0!==e[r]&&1!==e[r];)r++;if((n=++r+2)>=t)return[];for(var i=[];n<t;)switch(e[n]){case 0:if(0!==e[n-1]){n+=2;break}if(0!==e[n-2]){n++;break}r!==n-2&&i.push(e.subarray(r,n-2));do{n++}while(1!==e[n]&&n<t);n=(r=n+1)+2;break;case 1:if(0!==e[n-1]||0!==e[n-2]){n+=3;break}r!==n-2&&i.push(e.subarray(r,n-2)),n=(r=n+1)+2;break;default:n+=3}return r<t&&i.push(e.subarray(r)),i}},{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=[],a=0;a+t<n;)if(r=ut(e,a),3===t&&(r>>>=8),a+=t,r){if(a+r>n)break;i.push(e.subarray(a,a+r)),a+=r}return i}}},{key:"parseSEI",value:function(e,t){for(var r=e.length,n=t?2:1,i=0,a=0,s="";255===e[n];)i+=255,n++;for(i+=e[n++];255===e[n];)a+=255,n++;if(a+=e[n++],5===i&&r>n+16)for(var o=0;o<16;o++)s+=e[n].toString(16),n++;return{payload:e.subarray(n),type:i,size:a,uuid:s}}},{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,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}}]),e}(),vt=function(){function e(){s(this,e)}return u(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var r,n,i=1+(3&t[4]),a=[],s=[],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,a.push(l),r||(r=e.parseSPS(pt.removeEPB(l)))}var d,f=t[o];o++;for(var h=0;h<f;h++)d=t[o]<<8|t[o+1],o+=2,d&&(s.push(t.subarray(o,o+d)),o+=d);return{sps:r,spsArr:a,ppsArr:s,nalUnitSize:i}}}},{key:"parseSPS",value:function(e){var t=new Ze(e);t.readUByte();var r=t.readUByte(),n=t.readUByte(),i=t.readUByte();t.skipUEG();var a=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 s=t.readUEG();if(s<=3&&(a=[0,420,422,444][s]),3===s&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==s?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 f=t.readUEG(),h=t.readUEG(),p=t.readBits(1);0===p&&t.skipBits(1),t.skipBits(1);var v,y,m,g,_,b=0,k=0,x=0,w=0;if(t.readBool()&&(b=t.readUEG(),k=t.readUEG(),x=t.readUEG(),w=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 S=t.readBits(32),E=t.readBits(32);y=t.readBool(),_=(m=E)/(g=2*S)}}return{codec:ft(e.subarray(1,4)),profileIdc:r,profileCompatibility:n,levelIdc:i,chromaFormat:a,width:Math.ceil(16*(f+1)-2*(b+k)),height:(2-p)*(h+1)*16-(p?2:4)*(x+w),sarRatio:v,fpsNum:m,fpsDen:g,fps:_,fixedFrame:y}}}]),e}(),yt=function(){function e(){s(this,e)}return u(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 a=i,s=[],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),f=(1&t[i+2])<<2|(192&t[i+3])>>>6,h=e._getConfig(o,f,d),p=h.config,v=h.codec,y=0,m=e.getFrameDuration(u);i+7<n;)if(255===t[i]&&240==(246&t[i+1])){if(n-i<(l=(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>5))break;c=2*(1&~t[i+1]),s.push({pts:r+y*m,data:t.subarray(i+7+c,i+l)}),y++,i+=l}else i++;return{skip:a,remaining:i>=n?void 0:t.subarray(i),frames:s,samplingFrequencyIndex:o,sampleRate:u,objectType:d,channelCount:f,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,a=e.FREQ[n];if(a){var s=e._getConfig(n,i,r);return{samplingFrequencyIndex:n,sampleRate:a,objectType:r,channelCount:i,config:s.config,codec:s.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,a=[];return nt?e>=6?(n=5,i=e-3):(n=2,i=e):it?(n=2,i=e):(n=2===r||5===r?r:5,i=e,e>=6?i=e-3:1===t&&(n=2,i=e)),a[0]=n<<3,a[0]|=(14&e)>>1,a[1]=(1&e)<<7,a[1]|=t<<3,5===n&&(a[1]|=(14&i)>>1,a[2]=(1&i)<<7,a[2]|=8,a[3]=0),{config:a,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}();c(yt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var mt=function(){function e(t){if(s(this,e),c(this,"_bytesAvailable",void 0),c(this,"_bitsAvailable",0),c(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return u(e,[{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:"bitsPos",value:function(){return 8*this._bytesAvailable-this._bitsAvailable}},{key:"bitsLeft",value:function(){return 8*this._data.length-this.bitsPos()}},{key:"byteAligned",value:function(){return 0===this.bitsPos()||this.bitsPos()%8==0}},{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){s(this,e),this._buffer=t,this._offset=0,this._heldBits=0,this._numHeldBits=0}return u(e,[{key:"readUint8",value:function(){return this._buffer[this._offset++]}},{key:"readUint16",value:function(){return this._buffer[this._offset++]<<8|this._buffer[this._offset++]}},{key:"readUint32",value:function(){return this._buffer[this._offset++]<<24|this._buffer[this._offset++]<<16|this._buffer[this._offset++]<<8|this._buffer[this._offset++]}},{key:"readUint8Array",value:function(e){var t=this._buffer.slice(this._offset,this._offset+e);return this._offset+=e,t}},{key:"streamRead1Bytes",value:function(){this._heldBits=this.readUint8(),this._numHeldBits=8}},{key:"streamRead2Bytes",value:function(){this._heldBits=this.readUint16(),this._numHeldBits=16}},{key:"extractBits",value:function(e){var t=this._heldBits>>this._numHeldBits-e&(1<<e)-1;return this._numHeldBits-=e,t}}]),e}(),_t=function(){function e(){s(this,e)}return u(e,null,[{key:"parseVVCDecoderConfigurationRecord",value:function(t){var r=new gt(t),n=r.readUint8();r.streamRead1Bytes(),r.extractBits(5);var i,a,s,o,u,c,l,d,f=r.extractBits(2)+1,h=r.extractBits(1),p={};h&&(r.streamRead2Bytes(),o=r.extractBits(2),u=r.extractBits(3),a=r.extractBits(3),s=r.extractBits(2),r.extractBits(6),p=e.parseVVCPTLRecord(r,a),i=r.readUint16(),c=r.readUint16(),l=r.readUint16(),d=r.readUint16());for(var v=r.readUint8(),y=[],m=[],g=[],_=null,b=0;b<v;b++){r.streamRead1Bytes(),r.extractBits(1),r.extractBits(2);var k=r.extractBits(5),x=1;13!==k&&12!==k&&(x=r.readUint16());for(var w=0;w<x;w++){var S=r.readUint16();switch(k){case 14:y.push(r.readUint8Array(S));break;case 15:var E=r.readUint8Array(S);_||(_=e.parseSPS(e.removeEPB(E))),m.push(E);break;case 16:g.push(r.readUint8Array(S))}}}return{data:t,configurationVersion:n,codec:"bvc2.1.6.L93.B0",nalUnitSize:f,ptlPresentFlag:h,olsIdx:i,numSublayers:a,constantFrameRate:s,chromaFormatIdc:o,bitDepthLumaMinus8:u,ptlRecord:p,width:c,height:l,sampleRate:d,numOfArrays:v,vps:y,sps:m,pps:g,spsParsed:_}}},{key:"parseVVCPTLRecord",value:function(e,t){e.streamRead2Bytes(),e.extractBits(2);var r=e.extractBits(6),n=e.extractBits(7),i=e.extractBits(1),a=e.readUint8();e.streamRead1Bytes();var s=e.extractBits(1),o=e.extractBits(1),u=new Uint8Array(r);if(r){for(var c=0;c<r-1;c++){var l=e.extractBits(6);e.streamRead1Bytes();var d=e.extractBits(2);u[c]=l<<2|d}u[r-1]=e.extractBits(6)}else e.extractBits(6);var f=[];if(t>1){e.streamRead1Bytes();for(var h=0,p=t-2;p>=0;--p){h|=e.extractBits(1)<<p}for(var v=t;v<=8&&t>1;++v)e.extractBits(1);for(var y=t-2;y>=0;--y)h&1<<y&&(f[y]=e.readUint8())}var m=e.readUint8(),g=[];if(m)for(var _=0;_<m;_++)g.push(e.readUint32());return{generalProfileIdc:n,generalTierFlag:i,generalLevelIdc:a,ptlFrameOnlyConstraintFlag:s,ptlMultilayerEnabledFlag:o,generalConstraintInfo:u,subLayerLevelIdc:f,generalSubProfileIdc:g,ptlNumSubProfiles:m,numBytesConstraintInfo:r}}},{key:"getAvccNals",value:function(e){for(var t=[];e.position<e.length-4;){var r=e.dataview.getInt32(e.dataview.position);if(!(e.length-e.position>=r))break;var n=e.buffer.slice(e.position,e.position+4);e.skip(4);var i=new Uint8Array(e.buffer.slice(e.position,e.position+r));e.skip(r),t.push({header:n,body:i})}return t}},{key:"analyseNal",value:function(e){var t=(248&e.body[1])>>3;switch(e.type=t,t){case 23:case 24:break;case 7:case 8:e.key=!0;break;case 14:e.vps=!0;break;case 15:e.sps=!0;break;case 16:e.pps=!0;break;case 17:e.aps=!0}}},{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,a=new Uint8Array(i),s=0;for(n=0;n<i;s++,n++)s===r[0]&&(s++,r.shift()),a[n]=e[s];return a}},{key:"parseVps",value:function(){}},{key:"parseSPS",value:function(t){var r=new mt(t);r.readUByte(),r.readUByte(),r.skipBits(4);var n=r.readBits(4),i=r.readBits(3),a=r.readBits(2),s=420;a<=3&&(s=[0,420,422,444][a]),r.readBits(2),r.readBits(1);var o=e._parseProfileTierLevel(r,1,i);return r.readBits(1),r.readBits(1)&&r.readBits(1),{width:r.readUEG(),height:r.readUEG(),spsMaxSubLayerMinus1:i,spsVideoParameterSetId:n,chromaFormatIdc:a,chromaFormat:s,ptlInfo:o}}},{key:"_parseProfileTierLevel",value:function(t,r,n){var i,a=t.readBits(7),s=t.readBits(1),o=t.readBits(8),u=t.readBits(1),c=t.readBits(1);r&&(i=e._parseGeneralConstraintsInfo(t));for(var l=n-1,d=[],f=[],h=[],p=l;p>=0;--p)d[p]=t.readBits(1);for(;!t.byteAligned();)t.readBits(1);for(var v=l;v>=0;--v)d[v]&&(f[v]=t.readUByte());if(r)for(var y=t.readUByte(),m=0;m<y;m++)h[m]=t.readBits(32);return{generalProfileIdc:a,generalTierFlag:s,generalLevelIdc:o,ptlFrameOnlyConstraintFlag:u,ptlMultilayerEnabledFlag:c,ptlSublayerLevelPresentFlags:d,ptlSublayerLevelIdcs:f,ptlSubProfileIdcs:h,gciInfo:i}}},{key:"_parseGeneralConstraintsInfo",value:function(e){var t=e.readBits(1);if(t){e.skipBits(71);var r=e.readBits(8);r&&e.skipBits(r)}var n=8-e.bitsPos()%8;return e.skipBits(n),{gciPresentFlag:t}}}]),e}(),bt=function(){function e(){s(this,e)}return u(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,a,s,o,u=1+(3&t[21]),c=[],l=[],d=[],f=23,h=t[22],p=0;p<h;p++){a=63&t[f],s=t[f+1]<<8|t[f+2],f+=3;for(var v=0;v<s;v++)if(o=t[f]<<8|t[f+1],f+=2,o){switch(a){case 32:var y=t.subarray(f,f+o);n||(n=e.parseVPS(pt.removeEPB(y),r)),d.push(y);break;case 33:var m=t.subarray(f,f+o);i||(i=e.parseSPS(pt.removeEPB(m),r)),c.push(m);break;case 34:l.push(t.subarray(f,f+o))}f+=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 Ze(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 Ze(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 a=r.chromaFormatIdc=n.readUEG(),s=420;a<=3&&(s=[0,420,422,444][a]);var o=0;3===a&&(o=n.readBits(1));var u,c,l,d,f=n.readUEG(),h=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!==a&&2!==a||0!==o?1:2,y=1===a&&0===o?2:1;f-=v*(c+u),h-=y*(d+l)}return{codec:"hev1.1.6.L93.B0",width:f,height:h,chromaFormat:s,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);for(var a=[],s=[],o=0;o<t;o++)a[o]=e.readBits(1),s[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==a[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!==s[u]&&e.readBits(8)}}]),e}(),kt=1e3,xt=5e3,wt=function(){function e(t,r,n){s(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 u(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,a=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(a,i),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var s=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(s&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),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),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.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],a=e.samples[r.length-1];n=Math.floor((a.dts-i.dts)/(r.length-1))}else n=this._lastVideoDuration||40;var s=r.pop();if(this._videoLastSample&&r.unshift(this._videoLastSample),this._videoLastSample=s,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 f;if(Math.abs(l.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=l.dts,e.warnings.push({type:ze,nextDts:this._videoNextDts,firstSampleDts:l.dts,nextSampleDts:null===(f=r[1])||void 0===f?void 0:f.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 h=0;h<u;h++){var p=r[h].dts,v=r[h+1];((c=h<u-1?v.dts-p:s?s.dts-p:n)>1e3||c<0)&&(this._videoTimestampBreak++,Math.abs(p-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=p,e.warnings.push({type:Me,time:p/e.timescale,dts:p,originDts:r[h].originDts,nextDts:this._videoNextDts,sampleDuration:c,refSampleDuration:n})),c=n),r[h].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,a=1/0;r.length&&(e.baseDts=i=r[0].pts),n.length&&(t.baseDts=a=n[0].dts),this._baseDts=Math.min(i,a);var s=a-i;return Number.isFinite(s)&&Math.abs(s)>500&&t.warnings.push({type:Ie,videoBaseDts:a,audioBasePts:i,baseDts:this._baseDts,delta:s}),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){e.sampleDuration||(e.sampleDuration=e.codecType===Pe?yt.getFrameDuration(e.timescale,r):this._getG711Duration(e));var n=e.sampleDuration,i=e.codecType===Pe?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var a=t[0];this._audioNextPts=a.pts}for(var s=0;s<t.length;s++){var o=this._audioNextPts,u=t[s],c=u.pts-o;if(0===s&&this._audioTimestampBreak>=5&&this._keyFrameInNextChunk&&(o=this._audioNextPts=u.dts,c=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&c>=3*n&&c<=kt&&!rt){var l=this._getSilentFrame(e)||t[0].data.subarray(),d=Math.floor(c/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>xt&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:Ne,pts:u.pts,originPts:u.originPts,count:d,nextPts:o,refSampleDuration:n}));for(var f=0;f<d;f++){var h=new Ke(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),l,i);h.originPts=Math.floor(this._baseDts+o),t.splice(s,0,h),this._audioNextPts+=n,s++}s--}else c<=-3*n&&c>=-1e3?(Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>xt&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:qe,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(s,1),s--):(Math.abs(c)>kt&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>xt&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:Fe,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:c,refSampleDuration:n}))),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===Pe?yt.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),St=function(){function e(){s(this,e)}return u(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,a=!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 s=e._parseString(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i));r=s.data,i+=s.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 f=e._parseObject(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i-d)),h=f.size,p=f.data;if(f.isEnd)break;r[p.name]=p.value,i+=h}if(i<=n-3)9===(16777215&t.getUint32(i-1))&&(i+=3);break;case 9:r=void 0,i=1,a=!0;break;case 10:r=[];var v=t.getUint32(1);i+=4;for(var y=0;y<v;y++){var m=e._parseValue(new DataView(t.buffer,t.byteOffset+i,t.byteLength-i)),g=m.data,_=m.size;r.push(g),i+=_}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=$e.decode(new Uint8Array(t.buffer,t.byteOffset+i,k))),i+=k;break;default:i=n}return{data:r,size:i,isEnd:a}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),r="";return t>0&&(r=$e.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}(),Et=new Je("FlvDemuxer"),jt=function(){function e(t,r,n){s(this,e),c(this,"_headerParsed",!1),c(this,"_remainingData",null),c(this,"_gopId",0),c(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new Ve,this.audioTrack=r||new Ge,this.metadataTrack=n||new Xe,this._fixer=new wt(this.videoTrack,this.audioTrack,this.metadataTrack)}return u(e,[{key:"demux",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=this.audioTrack,a=this.videoTrack,s=this.metadataTrack;if(!r&&n||(this._remainingData=null),r&&(this._headerParsed=!1),r?(a.reset(),i.reset(),s.reset()):(a.samples=[],i.samples=[],s.seiSamples=[],s.flvScriptSamples=[],a.warnings=[],i.warnings=[],this._remainingData&&(t=at(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:a,audioTrack:i,metadataTrack:s};var o=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");i.present=(4&t[4])>>>2!=0,a.present=0!=(1&t[4]),this._headerParsed=!0,o=ut(t,5)+4}for(var u,c,l,d,f,h=t.length;o+15<h&&(u=t[o],!(o+15+(c=t[o+1]<<16|t[o+2]<<8|t[o+3])>h));)l=(t[o+7]<<24>>>0)+(t[o+4]<<16)+(t[o+5]<<8)+t[o+6],o+=11,d=t.subarray(o,o+c),8===u?this._parseAudio(d,l):9===u?this._parseVideo(d,l):18===u?this._parseScript(d,l):Et.warn("Invalid tag type: ".concat(u)),(f=ut(t,o+=c))!==11+c&&Et.warn("Invalid PrevTagSize ".concat(f," (").concat(11+c,")")),o+=4;return o<h&&(this._remainingData=t.subarray(o)),i.formatTimescale=a.formatTimescale=a.timescale=s.timescale=1e3,i.timescale=i.sampleRate||0,!i.exist()&&i.hasSample()&&i.reset(),!a.exist()&&a.hasSample()&&a.reset(),{videoTrack:a,audioTrack:i,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:"_parseAudio",value:function(t,r){if(t.length){var n=(240&t[0])>>>4,i=this.audioTrack;if(10!==n&&7!==n&&8!==n)return Et.warn("Unsupported sound format: ".concat(n)),void i.reset();if(10!==n){var a=(12&t[0])>>2,s=(2&t[0])>>1,o=1&t[0];i.sampleRate=e.AUDIO_RATE[a],i.sampleSize=s?16:8,i.channelCount=o+1}10===n?this._parseAac(t,r):this._parseG711(t,r,n)}}},{key:"_parseG711",value:function(e,t,r){var n=this.audioTrack;n.codecType=7===r?Ue:Re,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new Ke(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var r=this.audioTrack;if(r.codecType=Pe,0===e[1]){var n=yt.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(),Et.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;r.samples.push(new Ke(t,e.subarray(2)))}else Et.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],a=this.videoTrack;if(7!==i&&12!==i)return a.reset(),void Et.warn("Unsupported codecId: ".concat(i));var s=12===i;a.codecType=s?Oe:De;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var c=e.subarray(5),l=s?bt.parseHEVCDecoderConfigurationRecord(c):vt.parseAVCDecoderConfigurationRecord(c);if(l){var d=l.hvcC,f=l.sps,h=l.ppsArr,p=l.spsArr,v=l.vpsArr,y=l.nalUnitSize;d&&(a.hvcC=a.hvcC||d),f&&(a.codec=f.codec,a.width=f.width,a.height=f.height,a.sarRatio=f.sarRatio,a.fpsNum=f.fpsNum,a.fpsDen=f.fpsDen),p.length&&(a.sps=p),h.length&&(a.pps=h),v&&v.length&&(a.vps=v),y&&(a.nalUnitSize=y)}else Et.warn("Cannot parse ".concat(s?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var m=pt.parseAvcC(e.subarray(5),a.nalUnitSize);if((m=this._checkAddMetaNalToUnits(s,m,a))&&m.length){var g=new He(t+u,t,m);1===n&&g.setToKeyframe(),a.samples.push(g),m.forEach((function(e){var n=s?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(!s&&5!==n||s&&5===n)break;g.setToKeyframe();break;case 6:case 39:case 40:if(!s&&6!==n||s&&6===n)break;r.metadataTrack.seiSamples.push(new Ye(pt.parseSEI(pt.removeEPB(e),s),t+u))}})),g.keyframe&&this._gopId++,g.gopId=this._gopId}else Et.warn("Cannot parse NALUs",e)}else 2===o||Et.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 Qe(St.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&ut(e,5)>=9}}]),e}();c(jt,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new Je("TsDemuxer");var At=function(){function e(){s(this,e)}return u(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 a=0,s="",o=0;t.length>7;){if(a=ut(t),s=String.fromCharCode.apply(null,t.subarray(4,8)),o=8,1===a?(a=lt(t,8),o+=8):a||(a=t.length),!r[0]||s===r[0]){var u=t.subarray(0,a);if(!(r.length<2))return e.findBox(u.subarray(o),r.slice(1),n+o);i.push({start:n,size:a,headerSize:o,type:s,data:u})}n+=a,t=t.subarray(a)}return i}},{key:"tfhd",value:function(e){return Dt(e,!0,(function(e,t){e.trackId=ut(t);var r=4,n=1&e.flags,i=2&e.flags,a=8&e.flags,s=16&e.flags,o=32&e.flags;n&&(r+=4,e.baseDataOffset=ut(t,r),r+=4),i&&(e.sampleDescriptionIndex=ut(t,r),r+=4),a&&(e.defaultSampleDuration=ut(t,r),r+=4),s&&(e.defaultSampleSize=ut(t,r),r+=4),o&&(e.defaultSampleFlags=ut(t,r))}))}},{key:"sidx",value:function(e){return Dt(e,!0,(function(e,t){var r=0;e.reference_ID=ut(t,r),r+=4,e.timescale=ut(t,r),r+=4,0===e.version?(e.earliest_presentation_time=ut(t,r),r+=4,e.first_offset=ut(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=ot(t,r);r+=2;for(var i=0;i<n;i++){var a={};e.references.push(a);var s=ut(t,r);r+=4,a.reference_type=s>>31&1,a.referenced_size=2147483647&s,a.subsegment_duration=ut(t,r),s=ut(t,r+=4),r+=4,a.starts_with_SAP=s>>31&1,a.SAP_type=s>>28&7,a.SAP_delta_time=268435455&s}}))}},{key:"moov",value:function(t){return Dt(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 Dt(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ut(t,16),e.duration=lt(t,20),r+=28):(e.timescale=ut(t,8),e.duration=ut(t,12),r+=16),e.nextTrackId=ut(t,r+76)}))}},{key:"trak",value:function(t){return Dt(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]),t.edts=e.edts(e.findBox(r,["edts"],n)[0])}))}},{key:"tkhd",value:function(e){return Dt(e,!0,(function(e,t){var r=0;1===e.version?(e.trackId=ut(t,16),e.duration=lt(t,24),r+=32):(e.trackId=ut(t,8),e.duration=ut(t,16),r+=20),e.width=ut(t,r+52),e.height=ut(t,r+56)}))}},{key:"mdia",value:function(t){return Dt(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:"edts",value:function(t){return Dt(t,!1,(function(t,r,n){t.elst=e.elst(e.findBox(r,["elst"],n)[0])}))}},{key:"elst",value:function(e){return Dt(e,!0,(function(e,t,r){e.entries=[],e.entriesData=t;var n=0,i=ut(t,n);n+=4;for(var a=0;a<i;a++){var s={};e.entries.push(s),1===e.version?(s.segment_duration=lt(t,n),n+=8,s.media_time=dt(t,n),n+=8):(s.segment_duration=ut(t,n),n+=4,s.media_time=ct(t,n),n+=4),s.media_rate_integer=ot(t,n),n+=2,s.media_rate_fraction=ot(t,r),n+=2}}))}},{key:"mdhd",value:function(e){return Dt(e,!0,(function(e,t){var r=0;1===e.version?(e.timescale=ut(t,16),e.duration=lt(t,20),r+=28):(e.timescale=ut(t,8),e.duration=ut(t,12),r+=16);var n=ot(t,r);e.language=String.fromCharCode(96+(n>>10&31),96+(n>>5&31),96+(31&n))}))}},{key:"hdlr",value:function(e){return Dt(e,!0,(function(e,t){0===e.version&&(e.handlerType=String.fromCharCode.apply(null,t.subarray(4,8)))}))}},{key:"minf",value:function(t){return Dt(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 Dt(e,!0,(function(e,t){e.graphicsmode=ot(t),e.opcolor=[ot(t,2),ot(t,4),ot(t,6)]}))}},{key:"smhd",value:function(e){return Dt(e,!0,(function(e,t){e.balance=ot(t)}))}},{key:"stbl",value:function(t){return Dt(t,!1,(function(t,r,n){var i,a,s;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===(a=i.sinf)||void 0===a||null===(s=a.schi)||void 0===s?void 0:s.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 Dt(e,!0,(function(e,r){var n=0,i=ut(r,n);n+=4,e.samples=[];for(var a=0;a<i;a++){for(var s={InitializationVector:[]},o=0;o<t;o++)s.InitializationVector[o]=r[n+o];if(n+=t,2&e.flags){s.subsamples=[];var u=ot(r,n);n+=2;for(var c=0;c<u;c++){var l={};l.BytesOfClearData=ot(r,n),n+=2,l.BytesOfProtectedData=ut(r,n),n+=4,s.subsamples.push(l)}}e.samples.push(s)}}))}},{key:"pssh",value:function(e){return Dt(e,!0,(function(e,t){for(var r=[],n=[],i=0,a=0;a<16;a++)n.push(Lt(t[i+a]));if(i+=16,e.version>0){var s=ut(t,i);i+=4;for(var o=0;o<(""+s).length;o++)for(var u=0;u<16;u++){var c=t[i];i+=1,r.push(Lt(c))}}var l=ut(t,i);e.data_size=l,i+=4,e.kid=r,e.system_id=n,e.buffer=t}))}},{key:"bvc2",value:function(t){return Dt(t,!1,(function(t,r,n){var i=Tt(t,r),a=r.subarray(i);n+=i,t.vvcC=e.bv2C(e.findBox(a,["bv2C"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"bv2C",value:function(e){return Dt(e,!1,(function(e,t,r){var n=_t.parseVVCDecoderConfigurationRecord(t);for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}))}},{key:"stsd",value:function(t){return Dt(t,!0,(function(t,r,n){t.entryCount=ut(r),t.entries=e.findBox(r.subarray(4),[],n+4).map((function(t){switch(t.type){case"avc1":case"avc2":case"avc3":case"avc4":return e.avc1(t);case"hvc1":case"hev1":return e.hvc1(t);case"bvc2":return e.bvc2(t);case"mp4a":return e.mp4a(t);case"alaw":case"ulaw":return e.alaw(t);case"enca":return Dt(t,!1,(function(t,r,n){t.channelCount=ot(r,16),t.samplesize=ot(r,18),t.sampleRate=ut(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 Dt(t,!1,(function(t,r,n){t.width=ot(r,24),t.height=ot(r,26),t.horizresolution=ut(r,28),t.vertresolution=ut(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 Dt(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(Lt(t[r])),r+=1}))}},{key:"schi",value:function(t){return Dt(t,!1,(function(t,r,n){t.tenc=e.tenc(e.findBox(r,["tenc"],n)[0])}))}},{key:"sinf",value:function(t){return Dt(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 Dt(e,!1,(function(e,t){e.data_format="";for(var r=0;r<4;r++)e.data_format+=String.fromCharCode(t[r])}))}},{key:"avc1",value:function(t){return Dt(t,!1,(function(t,r,n){var i=Tt(t,r),a=r.subarray(i);n+=i,t.avcC=e.avcC(e.findBox(a,["avcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"avcC",value:function(e){return Dt(e,!1,(function(e,t){e.configurationVersion=t[0],e.AVCProfileIndication=t[1],e.profileCompatibility=t[2],e.AVCLevelIndication=t[3],e.codec=ft([t[1],t[2],t[3]]),e.lengthSizeMinusOne=3&t[4],e.spsLength=31&t[5],e.sps=[];for(var r=6,n=0;n<e.spsLength;n++){var i=ot(t,r);r+=2,e.sps.push(t.subarray(r,r+i)),r+=i}e.ppsLength=t[r],r+=1,e.pps=[];for(var a=0;a<e.ppsLength;a++){var s=ot(t,r);r+=2,e.pps.push(t.subarray(r,r+=s)),r+=s}}))}},{key:"hvc1",value:function(t){return Dt(t,!1,(function(t,r,n){var i=Tt(t,r),a=r.subarray(i);n+=i,t.hvcC=e.hvcC(e.findBox(a,["hvcC"],n)[0]),t.pasp=e.pasp(e.findBox(a,["pasp"],n)[0])}))}},{key:"hvcC",value:function(e){return Dt(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=ut(r,2),t.generalConstraintIndicatorFlags=r.subarray(6,12),t.generalLevelIdc=r[12],t.avgFrameRate=ot(r,19),t.numOfArrays=r[22],t.vps=[],t.sps=[],t.pps=[];for(var i=23,a=0,s=0,o=0,u=0;u<t.numOfArrays;u++){a=63&r[i],s=ot(r,i+1),i+=3;for(var c,l=[],d=0;d<s;d++)o=ot(r,i),i+=2,l.push(r.subarray(i,i+o)),i+=o;if(32===a)(c=t.vps).push.apply(c,l);else if(33===a){var f;(f=t.sps).push.apply(f,l)}else if(34===a){var h;(h=t.pps).push.apply(h,l)}}}))}},{key:"pasp",value:function(e){return Dt(e,!1,(function(e,t){e.hSpacing=ut(t),e.vSpacing=ut(t,4)}))}},{key:"mp4a",value:function(t){return Dt(t,!1,(function(t,r,n){var i=Ct(t,r);t.esds=e.esds(e.findBox(r.subarray(i),["esds"],n+i)[0])}))}},{key:"esds",value:function(e){return Dt(e,!0,(function(e,t){e.codec="mp4a.";for(var r=0,n=0,i=0,a=0;t.length;){for(a=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===a)t=t.subarray(r+3);else{if(4!==a){if(5===a){var s=e.config=t.subarray(r,r+i),o=(248&s[0])>>3;return 31===o&&s.length>=2&&(o=32+((7&s[0])<<3)+((224&s[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 Dt(e,!1,(function(e,t){Ct(e,t)}))}},{key:"stts",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=[],i=4,a=0;a<r;a++)n.push({count:ut(t,i),delta:ut(t,i+4)}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"ctts",value:function(e){return Dt(e,!0,(function(e,t){var r=ut(t),n=[],i=4;if(1===e.version)for(var a=0;a<r;a++)n.push({count:ut(t,i),offset:ut(t,i+4)}),i+=8;else for(var s=0;s<r;s++)n.push({count:ut(t,i),offset:-(1+~ut(t,i+4))}),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stsc",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=new Array(r),i=4,a=0;a<r;a++)n[a]={firstChunk:ut(t,i),samplesPerChunk:ut(t,i+4),sampleDescriptionIndex:ut(t,i+8)},i+=12;e.entryCount=r,e.entries=n}))}},{key:"stsz",value:function(e){return Dt(e,!0,(function(e,t){var r=ut(t),n=ut(t,4),i=new Array(n);if(!r)for(var a=8,s=0;s<n;s++)i[s]=ut(t,a),a+=4;e.sampleSize=r,e.sampleCount=n,e.entrySizes=i}))}},{key:"stco",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=new Array(r),i=4,a=0;a<r;a++)n[a]=ut(t,i),i+=4;e.entryCount=r,e.entries=n}))}},{key:"co64",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=new Array(r),i=4,a=0;a<r;a++)n[a]=lt(t,i),i+=8;e.entryCount=r,e.entries=n}))}},{key:"stss",value:function(e){return Dt(e,!0,(function(e,t){for(var r=ut(t),n=new Array(r),i=4,a=0;a<r;a++)n[a]=ut(t,i),i+=4;e.entryCount=r,e.entries=n}))}},{key:"moof",value:function(t){return Dt(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 Dt(e,!0,(function(e,t){e.sequenceNumber=ut(t)}))}},{key:"traf",value:function(t){return Dt(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 Dt(e,!0,(function(e,t){var r=e.version,n=e.flags,i=t.length,a=e.sampleCount=ut(t),s=4;if(i>s&&1&n&&(e.dataOffset=-(1+~ut(t,s)),s+=4),i>s&&4&n&&(e.firstSampleFlags=ut(t,s),s+=4),i>s){var o;e.samples=new Array(a);for(var u=0;u<a;u++)o={},256&n&&(o.duration=ut(t,s),s+=4),512&n&&(o.size=ut(t,s),s+=4),1024&n&&(o.flags=ut(t,s),s+=4),2048&n&&(o.cts=r?-(1+~ut(t,s+4)):ut(t,s),s+=4),e.samples[u]=o}}))}},{key:"tfdt",value:function(e){return Dt(e,!0,(function(e,t){1===e.version?e.baseMediaDecodeTime=lt(t):e.baseMediaDecodeTime=ut(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,a=e.trak;if(a&&a.length){var s=a.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=a.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(s&&t){var u,c,l,d,f,h,p,v,y=t,m=null===(u=s.tkhd)||void 0===u?void 0:u.trackId;null!=m&&(y.id=s.tkhd.trackId),y.tkhdDuration=s.tkhd.duration,y.mvhdDurtion=e.mvhd.duration,y.mvhdTimecale=e.mvhd.timescale,y.timescale=y.formatTimescale=s.mdia.mdhd.timescale,y.duration=s.mdia.mdhd.duration||y.mvhdDurtion/y.mvhdTimecale*y.timescale,null!==(c=s.edts)&&void 0!==c&&c.elst&&(y.editList=s.edts.elst,y.editListApplied=s.editListApplied);var g,_,b,k,x,w,S,E,j=s.mdia.minf.stbl.stsd.entries[0];if(y.width=j.width,y.height=j.height,j.pasp&&(y.sarRatio=[j.pasp.hSpacing,j.pasp.vSpacing]),j.hvcC)y.codecType=Oe,y.codec=j.hvcC.codec,y.vps=j.hvcC.vps,y.sps=j.hvcC.sps,y.pps=j.hvcC.pps,y.hvcC=j.hvcC.data;else if(j.avcC)y.codec=j.avcC.codec,y.sps=j.avcC.sps,y.pps=j.avcC.pps;else{if(!j.vvcC)throw new Error("unknown video stsd entry");y.codecType=Le,y.codec=j.vvcC.codec,y.sps=j.vvcC.sps,y.pps=j.vvcC.pps,y.vps=j.vvcC.vps,y.vvcC=j.vvcC.data}if(y.present=!0,y.ext={},y.ext.stss=null===(l=s.mdia)||void 0===l||null===(d=l.minf)||void 0===d||null===(f=d.stbl)||void 0===f?void 0:f.stss,y.ext.ctts=null===(h=s.mdia)||void 0===h||null===(p=h.minf)||void 0===p||null===(v=p.stbl)||void 0===v?void 0:v.ctts,j&&"encv"===j.type)y.isVideoEncryption=!0,j.default_KID=null===(g=j.sinf)||void 0===g||null===(_=g.schi)||void 0===_?void 0:_.tenc.default_KID,j.default_IsEncrypted=null===(b=j.sinf)||void 0===b||null===(k=b.schi)||void 0===k?void 0:k.tenc.default_IsEncrypted,j.default_IV_size=null===(x=j.sinf)||void 0===x||null===(w=x.schi)||void 0===w?void 0:w.tenc.default_IV_size,y.videoSenc=s.mdia.minf.stbl.senc&&s.mdia.minf.stbl.senc.samples,j.data_format=null===(S=j.sinf)||void 0===S||null===(E=S.frma)||void 0===E?void 0:E.data_format,y.useEME=e.useEME,y.kidValue=e.kidValue,y.pssh=e.pssh,y.encv=j}if(o&&r){var A,B,T,C,D,O,L,P,U,R,I=r,M=null===(A=o.tkhd)||void 0===A?void 0:A.trackId;null!=M&&(I.id=o.tkhd.trackId),I.tkhdDuration=o.tkhd.duration,I.mvhdDurtion=e.mvhd.duration,I.mvhdTimecale=e.mvhd.timescale,I.timescale=I.formatTimescale=o.mdia.mdhd.timescale,I.duration=o.mdia.mdhd.duration||I.mvhdDurtion/I.mvhdTimecale*I.timescale,null!==(B=o.edts)&&void 0!==B&&B.elst&&(I.editList=o.edts.elst,I.editListApplied=o.editListApplied);var z,F,N,q,V,G,H,K,W=o.mdia.minf.stbl.stsd.entries[0];switch(I.sampleSize=W.sampleSize,I.sampleRate=W.sampleRate,I.channelCount=W.channelCount,I.present=!0,W.type){case"alaw":I.codecType=I.codec=Ue,I.sampleRate=8e3;break;case"ulaw":I.codecType=I.codec=Re,I.sampleRate=8e3;break;default:I.sampleDuration=yt.getFrameDuration(I.sampleRate,I.timescale),I.sampleRateIndex=yt.getRateIndexByRate(I.sampleRate),I.objectType=(null===(n=W.esds)||void 0===n?void 0:n.objectType)||2,W.esds&&(I.config=Array.from(W.esds.config)),I.codec=(null===(i=W.esds)||void 0===i?void 0:i.codec)||"mp4a.40.2"}if(I.sampleDuration=yt.getFrameDuration(I.sampleRate,I.timescale),I.objectType=(null===(T=W.esds)||void 0===T?void 0:T.objectType)||2,W.esds&&(W.esds.config?I.config=Array.from(W.esds.config):console.warn("esds config is null")),I.codec=(null===(C=W.esds)||void 0===C?void 0:C.codec)||"mp4a.40.2",I.sampleRateIndex=yt.getRateIndexByRate(I.sampleRate),I.ext={},I.ext.stss=null===(D=o.mdia)||void 0===D||null===(O=D.minf)||void 0===O||null===(L=O.stbl)||void 0===L?void 0:L.stss,I.ext.ctts=null===(P=o.mdia)||void 0===P||null===(U=P.minf)||void 0===U||null===(R=U.stbl)||void 0===R?void 0:R.ctts,I.present=!0,W&&"enca"===W.type)I.isAudioEncryption=!0,W.data_format=null===(z=W.sinf)||void 0===z||null===(F=z.frma)||void 0===F?void 0:F.data_format,W.default_KID=null===(N=W.sinf)||void 0===N||null===(q=N.schi)||void 0===q?void 0:q.tenc.default_KID,W.default_IsEncrypted=null===(V=W.sinf)||void 0===V||null===(G=V.schi)||void 0===G?void 0:G.tenc.default_IsEncrypted,W.default_IV_size=null===(H=W.sinf)||void 0===H||null===(K=H.schi)||void 0===K?void 0:K.tenc.default_IV_size,I.audioSenc=o.mdia.minf.stbl.senc&&o.mdia.minf.stbl.senc.samples,I.useEME=e.useEME,I.kidValue=e.kidValue,I.enca=W}if(r&&(r.isVideoEncryption=!!t&&t.isVideoEncryption),t&&(t.isAudioEncryption=!!r&&r.isAudioEncryption),null!=t&&t.encv||null!=r&&r.enca){var Q,Y,X=null==t||null===(Q=t.encv)||void 0===Q?void 0:Q.default_KID,Z=null==r||null===(Y=r.enca)||void 0===Y?void 0:Y.default_KID,J=X||Z?(X||Z).join(""):null;t&&(t.kid=J),r&&(r.kid=J)}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 a=t.tfhd,s=t.tfdt,o=t.trun;if(a&&o){s&&(r&&r.id===a.trackId&&(r.baseMediaDecodeTime=s.baseMediaDecodeTime),n&&n.id===a.trackId&&(n.baseMediaDecodeTime=s.baseMediaDecodeTime));var u=a.defaultSampleSize||0,c=a.defaultSampleDuration||e.evaluateDefaultDuration(r,n,o.samples.length||o.sampleCount),l=o.dataOffset||0,d=0,f=-1;if(!o.samples.length&&o.sampleCount){i[a.trackId]=new Array(o.sampleCount);for(var h=0;h<o.sampleCount;h++)i[a.trackId][h]={offset:l,dts:d,duration:c,size:u},d+=c,l+=u}else i[a.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:f,keyframe:0===t||null!==e.flags&&void 0!==e.flags&&(65536&e.flags)>>>0!=65536}).keyframe&&(f++,e.gopId=f),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,a;if(r){var s,o,u=null===(s=r.mdia)||void 0===s||null===(o=s.minf)||void 0===o?void 0:o.stbl;if(!u)return;var c=u.stts,l=u.stsc,d=u.stsz,f=u.stco,h=u.stss,p=u.ctts;if(!(c&&l&&d&&f&&h))return;i=Bt(c,l,d,f,p,h)}if(n){var v,y,m,g=null===(v=n.mdia)||void 0===v||null===(y=v.minf)||void 0===y?void 0:y.stbl;if(!g)return;var _=null===(m=n.mdia.mdhd)||void 0===m?void 0:m.timescale,b=g.stts,k=g.stsc,x=g.stsz,w=g.stco;if(!(_&&b&&k&&x&&w))return;a=Bt(b,k,x,w)}return{videoSamples:i,audioSamples:a}}}}}]),e}();function Bt(e,t,r,n,i,a){var s,o,u,c=[],l=null==i?void 0:i.entries,d=t.entries,f=n.entries,h=r.entrySizes,p=null==a?void 0:a.entries;p&&(s={},p.forEach((function(e){s[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,y=0,m=0,g=0,_=0,b=0,k=d[0].samplesPerChunk,x=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:y,duration:n,size:h[m]||r.sampleSize,offset:f[g]+b,index:m},p&&(u.keyframe=s[m],u.keyframe&&v++,u.gopId=v),o&&m<o.length&&(u.pts=u.dts+o[m]),c.push(u),y+=n,++m<k?b+=u.size:(g++,b=0,g>=x&&(_++,x=d[_+1]?d[_+1].firstChunk-1:1/0),k+=d[_].samplesPerChunk)})),c}function Tt(e,t){return e.dataReferenceIndex=ot(t,6),e.width=ot(t,24),e.height=ot(t,26),e.horizresolution=ut(t,28),e.vertresolution=ut(t,32),e.frameCount=ot(t,40),e.depth=ot(t,74),78}function Ct(e,t){return e.dataReferenceIndex=ot(t,6),e.channelCount=ot(t,16),e.sampleSize=ot(t,18),e.sampleRate=ut(t,24)/65536,28}function Dt(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 Ot=function(e,t,r){for(var n=String(r),i=t>>0,a=Math.ceil(i/n.length),s=[],o=String(e);a--;)s.push(n);return s.join("").substring(0,i-o.length)+o},Lt=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(Ot(Number(t).toString(16),2,0))})),e[0]};function Pt(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 a=new e(t),s=0;return n.forEach((function(e){a.set(e,s),s+=e.length})),a}var Ut=function(){function e(){s(this,e),this.buffer=new Uint8Array(0)}return u(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=Pt(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}(),Rt=Math.pow(2,32)-1,It=function(){function e(){s(this,e)}return u(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),a=new Uint8Array(i);a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4);var s=8;return r.forEach((function(e){a.set(e,s),s+=e.byteLength})),a}},{key:"FullBox",value:function(t,r,n){for(var i=arguments.length,a=new Array(i>3?i-3:0),s=3;s<i;s++)a[s-3]=arguments[s];return e.box.apply(e,[t,new Uint8Array([r,n>>16&255,n>>8&255,255&n])].concat(a))}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===Be&&e.codecType===Oe}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return at(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],ht(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(w(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(w(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,a=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 a}},{key:"edts",value:function(t){return e.box(e.types.edts,e.elst(t))}},{key:"elst",value:function(t){t.entries;var r=t.entriesData,n=t.version;return e.FullBox(e.types.elst,n,0,r)}},{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===Be?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){return t&&t.ext,e.box(e.types.stbl,e.stsd(t),e.STTS,[][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):e.mp4a(t):t.useEME&&t.encv?e.encv(t):e.avc1hev1vvc1(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]),a=e.esds(t.config),s=e.sinf(t.enca);return e.box(e.types.enca,i,a,s)}},{key:"encv",value:function(t){var r,n,i=t.sps.length>0?t.sps[0]:[],a=t.pps.length>0?t.pps[0]:[],s=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,s>>8&255,255&s,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,w(i)).concat([1,a.length>>>8&255,255&a.length])).concat.apply(r,w(a))),f=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),h=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,f),h,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(ht(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]),a=e.schi(t);return e.box(e.types.sinf,r,e.box(e.types.frma,n),e.box(e.types.schm,i),a)}},{key:"avc1hev1vvc1",value:function(t){var r,n;t.codecType===Oe?(r=e.hvcC(t),n=e.types.hvc1):t.codecType===Le?(r=e.vvcC(t),n=e.types.bvc2):(r=e.avcC(t),n=e.types.avc1);var i=[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]),r];return t.codecType===Oe?i.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&i.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(i))}},{key:"avcC",value:function(t){var r,n,i,a=[],s=[];return t.sps.forEach((function(e){i=e.byteLength,a.push(i>>>8&255),a.push(255&i),a.push.apply(a,w(e))})),t.pps.forEach((function(e){i=e.byteLength,s.push(i>>>8&255),s.push(255&i),s.push.apply(s,w(e))})),e.box(e.types.avcC,new Uint8Array((r=(n=[1,a[3],a[4],a[5],255,224|t.sps.length]).concat.apply(n,a).concat([t.pps.length])).concat.apply(r,s)))}},{key:"vvcC",value:function(t){var r=t.vvcC;return e.box(e.types.bv2C,new Uint8Array(r))}},{key:"hvcC",value:function(t){var r=t.hvcC;if(r instanceof ArrayBuffer||r instanceof Uint8Array)return r;var n,i=t.vps,a=t.sps,s=t.pps;if(r){var o=r.generalProfileCompatibilityFlags,u=r.generalConstraintIndicatorFlags,c=(i.length&&1)+(a.length&&1)+(s.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,w(e))};i.length&&(n.push(160,0,i.length),i.forEach(l)),a.length&&(n.push(161,0,a.length),a.forEach(l)),s.length&&(n.push(162,0,s.length),s.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=x(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:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(w(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(w(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.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 a=e.saiz(t),s=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,r,n,a,s,o,u)}if(t.isAudioEncryption){var c=e.sbgp(),l=e.saiz(t),d=e.saio(t),f=e.senc(t),h=e.trun1(t);return e.box(e.types.traf,r,n,c,l,d,f,h)}var p=e.sbgp(),v=e.trun1(t);return e.box(e.types.traf,r,n,p,v)}if(t.isVideo){var y=e.trun1(t);return e.box(e.types.traf,r,n,y)}var m=e.sbgp(),g=e.saiz(t),_=e.saio(t),b=e.senc(t),k=e.trun1(t);return e.box(e.types.traf,r,n,m,g,_,b,k)}var x=e.sdtp(t);return e.box(e.types.traf,r,n,x,e.trun(t.samples,x.byteLength+76))}},{key:"sdtp",value:function(t){var r=new Ut;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 Ut,n=Ut.writeUint32(t.samples.length),i=null;if(t.isVideo){var a=t.videoSencLength;i=Ut.writeUint32(76+16*t.samples.length+a+77),!t.isVideoEncryption&&t.isAudioEncryption&&(i=Ut.writeUint32(76+16*t.samples.length+20))}else{var s=76+12*t.samples.length+52;t.isAudioEncryption&&(s=76+12*t.samples.length+8*t.audioSenc.length+105),i=Ut.writeUint32(s)}return t.samples.forEach((function(e){r.write(Ut.writeUint32(e.duration)),r.write(Ut.writeUint32(e.size)),r.write(Ut.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&r.write(Ut.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 Ut,n=t.samples.length,i=t.isVideo?16:8,a=t.isVideo?2:0,s=[],o=0;return t.isVideo?(s=t.videoSenc,o=t.videoSencLength):s=t.audioSenc,o=o||i*n,r.write(Ut.writeUint32(16+o),e.types.senc,this.extension(0,a)),r.write(Ut.writeUint32(n)),s.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(Ut.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){r.write(Ut.writeUint16(e.BytesOfClearData)),r.write(Ut.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){var r=Math.floor(t/(Rt+1)),n=Math.floor(t%(Rt+1));return e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n]))}},{key:"trun",value:function(t,r){var n=t.length,i=12+16*n;r+=8+i;var a=new Uint8Array(i);a.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 s=0;s<n;s++){var o=t[s],u=o.duration,c=o.size,l=o.flag,d=void 0===l?{}:l,f=o.cts,h=void 0===f?0:f;a.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,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*s)}return e.box(e.types.trun,a)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(w(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===Be?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,at(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,a=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a],i),i+=12})),e.box(e.types.stsc,at(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,at(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,at(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,at(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,at(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,a=t.samples[0].sampleOffset*n,s=8;t.samples.forEach((function(e){s+=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=s+141+16*t.samples.length+c,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=s+16*t.samples.length+84)}else o=s+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=s+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,a>>24&255,a>>16&255,a>>8&255,255&a,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}();c(It,"types",["avc1","avcC","hvc1","hvcC","dinf","dref","edts","elst","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","bvc2","bv2C"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),c(It,"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])}),c(It,"FTYPAVC1",It.box(It.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),c(It,"FTYPHEV1",It.box(It.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),c(It,"DINF",It.box(It.types.dinf,It.box(It.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),c(It,"VMHD",It.box(It.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),c(It,"SMHD",It.box(It.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),c(It,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),c(It,"STTS",It.box(It.types.stts,It.StblTable)),c(It,"STSC",It.box(It.types.stsc,It.StblTable)),c(It,"STSZ",It.box(It.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),c(It,"STCO",It.box(It.types.stco,It.StblTable));var Mt=function(){function e(t,r){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=r}return u(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}();c(Mt,"disabled",!0);for(var zt=function(){function e(){s(this,e)}return u(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 p(this,t)}}]),e}(),Ft=function(e){l(r,e);var t=_(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;s(this,r),e=t.call(this);var a=n;if(a instanceof ArrayBuffer&&(a=new Uint8Array(a)),(a instanceof Int8Array||a instanceof Uint8ClampedArray||a instanceof Int16Array||a instanceof Uint16Array||a instanceof Int32Array||a instanceof Uint32Array||a instanceof Float32Array||a instanceof Float64Array)&&(a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength)),a instanceof Uint8Array){for(var o=a.byteLength,u=[],c=0;c<o;c+=1)u[c>>>2]|=a[c]<<24-c%4*8;e.words=u,e.sigBytes=o}else e.words=n,e.sigBytes=i;return e}return u(r,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Nt;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 a=0;a<i;a+=1){var s=r[a>>>2]>>>24-a%4*8&255;t[n+a>>>2]|=s<<24-(n+a)%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=k(d(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)}},a=0;a<e;a+=4){var s=i(4294967296*(t||Math.random()));t=987654071*s(),n.push(4294967296*s()|0)}return new r(n,e)}}]),r}(zt),Nt={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i+=1){var a=t[i>>>2]>>>24-i%4*8&255;n.push((a>>>4).toString(16)),n.push((15&a).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 Ft(r,t/2)}},qt=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 Ft(r,t)},Vt=function(e){return qt(unescape(encodeURIComponent(e)))},Gt=function(e){l(r,e);var t=_(r);function r(){var e;return s(this,r),(e=t.call(this))._minBufferSize=0,e}return u(r,[{key:"reset",value:function(){this._data=new Ft,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=Vt(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,a=r.sigBytes,s=a/(4*n),o=(s=e?Math.ceil(s):Math.max((0|s)-this._minBufferSize,0))*n,u=Math.min(4*o,a);if(o){for(var c=0;c<o;c+=n)this._doProcessBlock(i,c);t=i.splice(0,o),r.sigBytes-=u}return new Ft(t,u)}},{key:"clone",value:function(){var e=k(d(r.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),r}(zt),Ht=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new zt,e),n.reset(),n}return u(r,[{key:"reset",value:function(){k(d(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 Kt(e,r).finalize(t)}}}]),r}(Gt),Kt=function(e){l(r,e);var t=_(r);function r(e,n){var i;s(this,r),i=t.call(this);var a=new e;i._hasher=a;var o=n;"string"==typeof o&&(o=Vt(o));var u=a.blockSize,c=4*u;o.sigBytes>c&&(o=a.finalize(n)),o.clamp();var l=o.clone();i._oKey=l;var d=o.clone();i._iKey=d;for(var f=l.words,h=d.words,p=0;p<u;p+=1)f[p]^=1549556828,h[p]^=909522486;return l.sigBytes=c,d.sigBytes=c,i.reset(),i}return u(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}(zt),Wt={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],a=0;a<r;a+=3)for(var s=(t[a>>>2]>>>24-a%4*8&255)<<16|(t[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|t[a+2>>>2]>>>24-(a+2)%4*8&255,o=0;o<4&&a+.75*o<r;o+=1)i.push(n.charAt(s>>>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 a=r.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return function(e,t,r){for(var n=[],i=0,a=0;a<t;a+=1)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2|r[e.charCodeAt(a)]>>>6-a%4*2;n[i>>>2]|=s<<24-i%4*8,i+=1}return Ft.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},Qt=[],Yt=0;Yt<64;Yt+=1)Qt[Yt]=4294967296*Math.abs(Math.sin(Yt+1))|0;var Xt=function(e,t,r,n,i,a,s){var o=e+(t&r|~t&n)+i+s;return(o<<a|o>>>32-a)+t},Zt=function(e,t,r,n,i,a,s){var o=e+(t&n|r&~n)+i+s;return(o<<a|o>>>32-a)+t},Jt=function(e,t,r,n,i,a,s){var o=e+(t^r^n)+i+s;return(o<<a|o>>>32-a)+t},$t=function(e,t,r,n,i,a,s){var o=e+(r^(t|~n))+i+s;return(o<<a|o>>>32-a)+t},er=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"_doReset",value:function(){this._hash=new Ft([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var r=e,n=0;n<16;n+=1){var i=t+n,a=e[i];r[i]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var s=this._hash.words,o=r[t+0],u=r[t+1],c=r[t+2],l=r[t+3],d=r[t+4],f=r[t+5],h=r[t+6],p=r[t+7],v=r[t+8],y=r[t+9],m=r[t+10],g=r[t+11],_=r[t+12],b=r[t+13],k=r[t+14],x=r[t+15],w=s[0],S=s[1],E=s[2],j=s[3];w=Xt(w,S,E,j,o,7,Qt[0]),j=Xt(j,w,S,E,u,12,Qt[1]),E=Xt(E,j,w,S,c,17,Qt[2]),S=Xt(S,E,j,w,l,22,Qt[3]),w=Xt(w,S,E,j,d,7,Qt[4]),j=Xt(j,w,S,E,f,12,Qt[5]),E=Xt(E,j,w,S,h,17,Qt[6]),S=Xt(S,E,j,w,p,22,Qt[7]),w=Xt(w,S,E,j,v,7,Qt[8]),j=Xt(j,w,S,E,y,12,Qt[9]),E=Xt(E,j,w,S,m,17,Qt[10]),S=Xt(S,E,j,w,g,22,Qt[11]),w=Xt(w,S,E,j,_,7,Qt[12]),j=Xt(j,w,S,E,b,12,Qt[13]),E=Xt(E,j,w,S,k,17,Qt[14]),S=Xt(S,E,j,w,x,22,Qt[15]),w=Zt(w,S,E,j,u,5,Qt[16]),j=Zt(j,w,S,E,h,9,Qt[17]),E=Zt(E,j,w,S,g,14,Qt[18]),S=Zt(S,E,j,w,o,20,Qt[19]),w=Zt(w,S,E,j,f,5,Qt[20]),j=Zt(j,w,S,E,m,9,Qt[21]),E=Zt(E,j,w,S,x,14,Qt[22]),S=Zt(S,E,j,w,d,20,Qt[23]),w=Zt(w,S,E,j,y,5,Qt[24]),j=Zt(j,w,S,E,k,9,Qt[25]),E=Zt(E,j,w,S,l,14,Qt[26]),S=Zt(S,E,j,w,v,20,Qt[27]),w=Zt(w,S,E,j,b,5,Qt[28]),j=Zt(j,w,S,E,c,9,Qt[29]),E=Zt(E,j,w,S,p,14,Qt[30]),S=Zt(S,E,j,w,_,20,Qt[31]),w=Jt(w,S,E,j,f,4,Qt[32]),j=Jt(j,w,S,E,v,11,Qt[33]),E=Jt(E,j,w,S,g,16,Qt[34]),S=Jt(S,E,j,w,k,23,Qt[35]),w=Jt(w,S,E,j,u,4,Qt[36]),j=Jt(j,w,S,E,d,11,Qt[37]),E=Jt(E,j,w,S,p,16,Qt[38]),S=Jt(S,E,j,w,m,23,Qt[39]),w=Jt(w,S,E,j,b,4,Qt[40]),j=Jt(j,w,S,E,o,11,Qt[41]),E=Jt(E,j,w,S,l,16,Qt[42]),S=Jt(S,E,j,w,h,23,Qt[43]),w=Jt(w,S,E,j,y,4,Qt[44]),j=Jt(j,w,S,E,_,11,Qt[45]),E=Jt(E,j,w,S,x,16,Qt[46]),S=Jt(S,E,j,w,c,23,Qt[47]),w=$t(w,S,E,j,o,6,Qt[48]),j=$t(j,w,S,E,p,10,Qt[49]),E=$t(E,j,w,S,k,15,Qt[50]),S=$t(S,E,j,w,f,21,Qt[51]),w=$t(w,S,E,j,_,6,Qt[52]),j=$t(j,w,S,E,l,10,Qt[53]),E=$t(E,j,w,S,m,15,Qt[54]),S=$t(S,E,j,w,u,21,Qt[55]),w=$t(w,S,E,j,v,6,Qt[56]),j=$t(j,w,S,E,x,10,Qt[57]),E=$t(E,j,w,S,h,15,Qt[58]),S=$t(S,E,j,w,b,21,Qt[59]),w=$t(w,S,E,j,d,6,Qt[60]),j=$t(j,w,S,E,g,10,Qt[61]),E=$t(E,j,w,S,c,15,Qt[62]),S=$t(S,E,j,w,y,21,Qt[63]),s[0]=s[0]+w|0,s[1]=s[1]+S|0,s[2]=s[2]+E|0,s[3]=s[3]+j|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),a=r;t[15+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t[14+(n+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(t.length+1),this._process();for(var s=this._hash,o=s.words,u=0;u<4;u+=1){var c=o[u];o[u]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return s}},{key:"clone",value:function(){var e=k(d(r.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),r}(Ht);Ht._createHelper(er),Ht._createHmacHelper(er);var tr=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).cfg=Object.assign(new zt,{keySize:4,hasher:er,iterations:1},e),n}return u(r,[{key:"compute",value:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=Ft.create(),s=a.words,o=n.keySize,u=n.iterations;s.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();a.concat(r)}return a.sigBytes=4*o,a}}]),r}(zt),rr=function(e){l(r,e);var t=_(r);function r(e,n,i){var a;return s(this,r),(a=t.call(this)).cfg=Object.assign(new zt,i),a._xformMode=e,a._key=n,a.reset(),a}return u(r,[{key:"reset",value:function(){k(d(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?fr:lr};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}(Gt);rr._ENC_XFORM_MODE=1,rr._DEC_XFORM_MODE=2,rr.keySize=4,rr.ivSize=4;var nr=function(e){l(r,e);var t=_(r);function r(e,n){var i;return s(this,r),(i=t.call(this))._cipher=e,i._iv=n,i}return u(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}(zt);function ir(e,t,r){var n,i=e,a=this._iv;a?(n=a,this._iv=void 0):n=this._prevBlock;for(var s=0;s<r;s+=1)i[t+s]^=n[s]}var ar=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(nr);ar.Encryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize;ir.call(this,e,t,n),r.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),r}(ar),ar.Decryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=this._cipher,n=r.blockSize,i=e.slice(t,t+n);r.decryptBlock(e,t),ir.call(this,e,t,n),this._prevBlock=i}}]),r}(ar);var sr={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var o=Ft.create(a,n);e.concat(o)},unpad:function(e){var t=e,r=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=r}},or=function(e){l(r,e);var t=_(r);function r(e,n,i){var a;return s(this,r),(a=t.call(this,e,n,Object.assign({mode:ar,padding:sr},i))).blockSize=4,a}return u(r,[{key:"reset",value:function(){var e;k(d(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}(rr),ur=function(e){l(r,e);var t=_(r);function r(e){var n;return s(this,r),(n=t.call(this)).mixIn(e),n}return u(r,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),r}(zt),cr={stringify:function(e){var t=e.ciphertext,r=e.salt;return(r?Ft.create([1398893684,1701076831]).concat(r).concat(t):t).toString(Wt)},parse:function(e){var t,r=Wt.parse(e),n=r.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=Ft.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),ur.create({ciphertext:r,salt:t})}},lr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new zt,this.cfg,n),a=e.createEncryptor(r,i),s=a.finalize(t),o=a.cfg;return ur.create({ciphertext:s,key:r,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:a.blockSize,formatter:i.format})}},{key:"decrypt",value:function(e,t,r,n){var i=t,a=Object.assign(new zt,this.cfg,n);return i=this._parse(i,a.format),e.createDecryptor(r,a).finalize(i.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),r}(zt);lr.cfg=Object.assign(new zt,{format:cr});var dr={execute:function(e,t,r,n){var i=n;i||(i=Ft.random(8));var a=tr.create({keySize:t+r}).compute(e,i),s=Ft.create(a.words.slice(t),4*r);return a.sigBytes=4*t,ur.create({key:a,iv:s,salt:i})}},fr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,null,[{key:"encrypt",value:function(e,t,r,n){var i=Object.assign(new zt,this.cfg,n),a=i.kdf.execute(r,e.keySize,e.ivSize);i.iv=a.iv;var s=lr.encrypt.call(this,e,t,a.key,i);return s.mixIn(a),s}},{key:"decrypt",value:function(e,t,r,n){var i=t,a=Object.assign(new zt,this.cfg,n);i=this._parse(i,a.format);var s=a.kdf.execute(r,e.keySize,e.ivSize,i.salt);return a.iv=s.iv,lr.decrypt.call(this,e,i,s.key,a)}}]),r}(lr);fr.cfg=Object.assign(lr.cfg,{kdf:dr});for(var hr=[],pr=[],vr=[],yr=[],mr=[],gr=[],_r=[],br=[],kr=[],xr=[],wr=[],Sr=0;Sr<256;Sr+=1)wr[Sr]=Sr<128?Sr<<1:Sr<<1^283;for(var Er=0,jr=0,Ar=0;Ar<256;Ar+=1){var Br=jr^jr<<1^jr<<2^jr<<3^jr<<4;Br=Br>>>8^255&Br^99,hr[Er]=Br,pr[Br]=Er;var Tr=wr[Er],Cr=wr[Tr],Dr=wr[Cr],Or=257*wr[Br]^16843008*Br;vr[Er]=Or<<24|Or>>>8,yr[Er]=Or<<16|Or>>>16,mr[Er]=Or<<8|Or>>>24,gr[Er]=Or,Or=16843009*Dr^65537*Cr^257*Tr^16843008*Er,_r[Br]=Or<<24|Or>>>8,br[Br]=Or<<16|Or>>>16,kr[Br]=Or<<8|Or>>>24,xr[Br]=Or,Er?(Er=Tr^wr[wr[wr[Dr^Tr]]],jr^=wr[wr[jr]]):Er=jr=1}var Lr=[0,1,2,4,8,16,32,64,128,27,54],Pr=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(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 a=this._keySchedule,s=0;s<i;s+=1)s<n?a[s]=r[s]:(e=a[s-1],s%n?n>6&&s%n==4&&(e=hr[e>>>24]<<24|hr[e>>>16&255]<<16|hr[e>>>8&255]<<8|hr[255&e]):(e=hr[(e=e<<8|e>>>24)>>>24]<<24|hr[e>>>16&255]<<16|hr[e>>>8&255]<<8|hr[255&e],e^=Lr[s/n|0]<<24),a[s]=a[s-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<i;u+=1){var c=i-u;e=u%4?a[c]:a[c-4],o[u]=u<4||c<=4?e:_r[hr[e>>>24]]^br[hr[e>>>16&255]]^kr[hr[e>>>8&255]]^xr[hr[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,vr,yr,mr,gr,hr)}},{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,_r,br,kr,xr,pr),n=r[t+1],r[t+1]=r[t+3],r[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,r,n,i,a,s,o){for(var u=e,c=this._nRounds,l=u[t]^r[0],d=u[t+1]^r[1],f=u[t+2]^r[2],h=u[t+3]^r[3],p=4,v=1;v<c;v+=1){var y=n[l>>>24]^i[d>>>16&255]^a[f>>>8&255]^s[255&h]^r[p];p+=1;var m=n[d>>>24]^i[f>>>16&255]^a[h>>>8&255]^s[255&l]^r[p];p+=1;var g=n[f>>>24]^i[h>>>16&255]^a[l>>>8&255]^s[255&d]^r[p];p+=1;var _=n[h>>>24]^i[l>>>16&255]^a[d>>>8&255]^s[255&f]^r[p];p+=1,l=y,d=m,f=g,h=_}var b=(o[l>>>24]<<24|o[d>>>16&255]<<16|o[f>>>8&255]<<8|o[255&h])^r[p];p+=1;var k=(o[d>>>24]<<24|o[f>>>16&255]<<16|o[h>>>8&255]<<8|o[255&l])^r[p];p+=1;var x=(o[f>>>24]<<24|o[h>>>16&255]<<16|o[l>>>8&255]<<8|o[255&d])^r[p];p+=1;var w=(o[h>>>24]<<24|o[l>>>16&255]<<16|o[d>>>8&255]<<8|o[255&f])^r[p];p+=1,u[t]=b,u[t+1]=k,u[t+2]=x,u[t+3]=w}}]),r}(or);Pr.keySize=8,or._createHelper(Pr);var Ur=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r)}(nr);Ur.Encryptor=function(e){l(r,e);var t=_(r);function r(){return s(this,r),t.apply(this,arguments)}return u(r,[{key:"processBlock",value:function(e,t){var r=e,n=this._cipher,i=n.blockSize,a=this._iv,s=this._counter;a&&(this._counter=a.slice(0),s=this._counter,this._iv=void 0);var o=s.slice(0);n.encryptBlock(o,0),s[i-1]=s[i-1]+1|0;for(var u=0;u<i;u+=1)r[t+u]^=o[u]}}]),r}(Ur),Ur.Decryptor=Ur.Encryptor;var Rr=u((function e(t,r){s(this,e),this.type="file",this.message=t,this.data=r})),Ir=function(){function e(){s(this,e),c(this,"_data",Object.create(null))}return u(e,[{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){return this._data[e]}},{key:"clear",value:function(){this._data=Object.create(null)}}]),e}(),Mr=function(){function e(){s(this,e),this.frames=[],this.dur=0,this.minPts=Number.MAX_VALUE,this.maxPts=0}return u(e,[{key:"appendFrame",value:function(e){this.frames.push(e),this.dur+=e.duration}},{key:"calMinMaxPts",value:function(e){e.pts<this.minPts&&(this.minPts=e.pts);var t=e.pts+e.duration;t>this.maxPts&&(this.maxPts=t)}}]),e}();function zr(){var e=!0,t=navigator.userAgent||"";if(/Chrome/gi.test(t)&&!/Edge\//gi.test(t)){var r=t.match(/Chrome\/(\d+)/i),n=r?parseInt(r[1],10):0;e=!!n&&n>=75}return e}function Fr(e,t){var r=t.segmentDuration,n=e.trak;if(n&&n.length){var i=n.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)})),a=n.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(i||a){var s,o=[],u=[];return i&&(s=(o=Nr("video",i,r,t)).map((function(e){return e.duration}))),a&&(u=Nr("audio",a,r,t,s,o)),{videoSegments:o,audioSegments:u}}}}function Nr(e,t,r,n){var i,a,s,o,u,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],l=arguments.length>5?arguments[5]:void 0,d=n.fixEditListOffset,f=n.fixEditListOffsetThreshold,h=n.audioGroupingStrategy,p=n.memoryOpt,v=null===(i=t.mdia)||void 0===i||null===(a=i.minf)||void 0===a?void 0:a.stbl;if(!v)return[];var y=null===(s=t.mdia.mdhd)||void 0===s?void 0:s.timescale,m=v.stts,g=v.stsc,_=v.stsz,b=v.stco,k=v.stss,x=v.ctts;if(!(y&&m&&g&&_&&b&&("video"!==e||k)))return[];var S=0,E=null===(o=t.edts)||void 0===o||null===(u=o.elst)||void 0===u?void 0:u.entries;if(d&&zr()&&Array.isArray(E)&&E.length>0){var j=E[0].media_time,A=f?f*y:5*y;j>0&&j<A&&(S=j)}var B,T,C=[],D=[],O=[],L=[],P=[],U=g.entries,R=b.entries,I=_.entrySizes,M=null==k?void 0:k.entries,z=null==x?void 0:x.entries,F=[],N={};p||(z&&z.forEach((function(e){for(var t=e.count,r=e.offset,n=0;n<t;n++)F.push(r)})),M&&M.forEach((function(e){N[e-1]=!0})));var q,V=0,G=0,H=0,K=0,W=U.length>0?U[0].samplesPerChunk:0,Q=U.length>1&&U[1]?U[1].firstChunk-1:1/0,Y=0,X=-1,Z=!1,J={};(null==z?void 0:z.length)>0&&S>0&&(Y-=S,Z=!0),t.editListApplied=Z,p&&(q=null==M?void 0:M.shift()),m.entries.forEach((function(e){var t=e.count,r=e.delta;T=r;for(var n=0;n<t;n++){if(B={dts:Y,duration:T,size:I[V]||_.sampleSize,offset:R[G]+K,index:V},z&&(p?(qr(z,V,J),B.pts=Y+((null==J?void 0:J.offset)||0)):F&&V<F.length&&(B.pts=Y+F[V])),0===S&&0===V&&(B.pts=0),void 0===B.pts&&(B.pts=B.dts),M){if(p?V+1===q&&(B.keyframe=!0,q=M.shift()):B.keyframe=N[V],B.keyframe)if(X++,p){var i=new Mr;i.appendFrame(B),D.push(i)}else D.push([B]),O.push(B.duration);else p?D[D.length-1].appendFrame(B):(D[D.length-1].push(B),O[D.length-1]+=B.duration);B.gopId=X,p&&D[D.length-1].calMinMaxPts(B)}if(!p)if(B.keyframe?L[L.length]=B.pts:B.pts<L[D.length-1]&&(L[D.length-1]=B.pts),B.keyframe)P[P.length]=B.index;else if(D.length>0&&void 0!==P[D.length-1]){var a,s=null===(a=C[P[D.length-1]])||void 0===a?void 0:a.pts;void 0!==s&&B.pts>s&&(P[D.length-1]=B.index)}C[C.length]=B,Y+=r,++V<W?K+=B.size:(G++,K=0,G>=Q&&(H++,Q=U[H+1]?U[H+1].firstChunk-1:1/0),W+=U[H].samplesPerChunk)}}));var $=C.length;if(!$||k&&!C[0].keyframe)return[];var ee,te,re=[],ne=[],ie=0,ae=0,se=0,oe=0,ue=function(e,t,r){(ee=ne[ne.length-1],p?(se=(null==D?void 0:D.length)>0?D[t].minPts:ne[0].pts,oe=(null==D?void 0:D.length)>0?D[r].maxPts:ee.pts+ee.duration):(se=L[t],te=C[P[r]],oe=te.pts+te.duration),0===re.length)&&(e=(oe-se)/y);re.push({index:re.length,startTime:se/y,endTime:oe/y,duration:e,range:[ne[0].offset,ee.offset+ee.size-1],frames:ne}),1!==h&&(ie=0),ne=[]},ce=0;if(k)for(var le=r*y,de=0,fe=D.length;de<fe;de++){var he,pe;if(p)ie+=D[de].dur,(he=ne).push.apply(he,w(D[de].frames));else ie+=O[de],(pe=ne).push.apply(pe,w(D[de]));de+1<fe?(0===de||ie>le)&&(ue(ie/y,ce,de),ie=0,ce=de+1):(ue(ie/y,ce,de),ie=0,ce=de+1)}else{p||(L=[],P=[]);var ve=c[0]||r;if(1===h)for(var ye,me=0;me<$;me++){var ge=C[me],_e=C[me+1],be=me===$-1;ne.push(ge),ie+=ge.duration;var ke=ye||ie/y;ye=(_e?ie+_e.duration:0)/y,(be||(l[re.length]?ye>l[re.length].endTime:ye-ne[0].pts/y>=ve))&&(p||(L.push(ne[0].pts),P.push(ne[ne.length-1].index)),ue(ke,re.length,re.length),ve=c[re.length]||r)}else for(var xe,we=0;we<$;we++){var Se=C[we],Ee=C[we+1],je=we===$-1;ne.push(Se),ie+=Se.duration;var Ae=xe||ie/y;xe=(Ee?ie+Ee.duration:0)/y,(je||xe+ae>=ve)&&(ae+=2===h?ie/y-ve:xe-ve,p||(L.push(ne[0].pts),P.push(ne[ne.length-1].index)),ue(Ae,re.length,re.length),ve=c[re.length]||r)}}return re}function qr(e,t,r){r.offset=0;var n=(null==r?void 0:r.beforeFrameNum)||0,i=(null==r?void 0:r.usedCttsIdx)||0;if(!e||(null==e?void 0:e.length)<=0||(null==r?void 0:r.usedCttsIdx)>=e.length)r.offset=0,r.usedCttsIdx=i,r.beforeFrameNum=n;else{var a=e[i];if(t<n+((null==a?void 0:a.count)||1))r.offset=(null==a?void 0:a.offset)||0;else{var s=e[++i];s?(r.offset=s.offset||0,r.beforeFrameNum=n+a.count):(r.offset=0,r.beforeFrameNum=n+1),r.usedCttsIdx=i}}}function Vr(e){var t="",r="",n=0,i=0,a=0,s=0,o=0,u=0,c=0;e.mvhd&&(o=e.mvhd.duration/e.mvhd.timescale);var l=e.trak;if(l){var d,f,h,p,v,y,m,g,_,b,k,x,w,S,E,j,A,B=l.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)})),T=l.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)})),C=null;if(B)if(C=null===(f=B.mdia)||void 0===f||null===(h=f.minf)||void 0===h||null===(p=h.stbl)||void 0===p?void 0:p.stsd.entries[0])if(n=C.width,i=C.height,u=null===(v=B.mdia)||void 0===v||null===(y=v.mdhd)||void 0===y?void 0:y.timescale,t=null===(m=C.avcC||C.hvcC||C.vvcC)||void 0===m?void 0:m.codec,"encv"===C.type)d=null===(g=C.sinf)||void 0===g||null===(_=g.schi)||void 0===_?void 0:_.tenc.default_KID;if(T)if(C=null===(b=T.mdia)||void 0===b||null===(k=b.minf)||void 0===k||null===(x=k.stbl)||void 0===x?void 0:x.stsd.entries[0])if(a=C.channelCount,s=C.sampleRate,r=null===(w=C.esds)||void 0===w?void 0:w.codec,c=null===(S=T.mdia)||void 0===S||null===(E=S.mdhd)||void 0===E?void 0:E.timescale,"enca"===C.type)d=d||(null===(j=C.sinf)||void 0===j||null===(A=j.schi)||void 0===A?void 0:A.tenc.default_KID);return{kid:d?d.join(""):null,videoCodec:t,audioCodec:r,width:n,height:i,videoTimescale:u,audioChannelCount:a,audioSampleRate:s,duration:o,audioTimescale:c,moov:e}}}function Gr(e){return"number"==typeof e&&!Number.isNaN(e)}function Hr(e){if(!e)return!1;var t=e.audioSegments,r=e.videoSegments,n=!r||0===r.length,i=!t||0===t.length;return!n||!i}var Kr=["vid","cache"],Wr=function(e){l(S,e);var n,i,o,d,f,h,p,v,g,b,k,w=_(S);function S(e){var r,n;s(this,S),c(m(r=w.call(this)),"vid",""),c(m(r),"url",""),c(m(r),"meta",{}),c(m(r),"downloadInfo",[]),c(m(r),"videoSegments",[]),c(m(r),"audioSegments",[]),c(m(r),"cache",null),c(m(r),"_currentSegmentIndex",-1),c(m(r),"_currentLoadingSegmentIndex",-1),c(m(r),"buffer",void 0),c(m(r),"bufferDataLen",0),c(m(r),"_error",void 0),c(m(r),"_transformError",(function(e){return e})),r._config=("boolean"!=typeof(n=e).fixEditListOffset&&delete n.fixEditListOffset,t({vid:"",moovEnd:8e4,segmentDuration:2,maxDownloadInfoSize:30,responseType:"arraybuffer",fixEditListOffset:!0,cache:null},n));var i=r._config,a=i.vid,o=i.cache,u=y(i,Kr);return r.cache=o||new Ir,r.vid=a||u.url,r.url=u.url,u.transformError=r._transformError,r.logger=new Q("MP4Loader_"+r.vid),e.openLog&&Q.enable(),u.logger=r.logger,r.filesize=0,r._loader=new Ae(u),r._loader.on(ye,(function(e){r.emit(ye,e)})),r}return u(S,[{key:"isMetaLoaded",get:function(){return this.videoSegments.length||this.audioSegments.length}},{key:"setCurrentSegment",value:function(e){Gr(e)&&(this._currentSegmentIndex=e)}},{key:"isLastSegment",value:function(e){var t,r;return!!Gr(e)&&e>=((null===(t=this.videoSegments[this.videoSegments.length-1])||void 0===t?void 0:t.index)||(null===(r=this.audioSegments[this.audioSegments.length-1])||void 0===r?void 0:r.index)||0)}},{key:"isSegmentLoading",value:function(e){return e===this._currentLoadingSegmentIndex}},{key:"changeUrl",value:(k=a(r().mark((function e(t){var n,i,a,s=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=s.length>1&&void 0!==s[1]?s[1]:t,i=s.length>2?s[2]:void 0,a=s.length>3?s[3]:void 0,e.next=5,this.reset(a);case 5:t&&(this.url=t),n&&(this.vid=n),i&&(this._config.moovEnd=i);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"getOrLoadMeta",value:(b=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(t);case 3:return e.abrupt("return",this.meta);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"newBufferArray",value:function(e,t){var r;if(this.buffer){if(t||(null===(r=this.buffer)||void 0===r?void 0:r.byteLength)<e){var n,i=this.buffer.subarray(0,this.bufferDataLen),a=Ee(((null===(n=this.buffer)||void 0===n?void 0:n.byteLength)||0)+e);a.set(i,0),delete this.buffer,this.buffer=a}}else this.buffer=Ee(e),this.bufferDataLen=0}},{key:"loadMetaProcess",value:(g=a(r().mark((function e(n,i,s){var o,u,c,l,d,f,h=this,p=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(u=x(i,2),c=u[0],l=u[1],d=p.length>3&&void 0!==p[3]?p[3]:{},this._error=!1,this.filesize=0,this.logger.debug("[loadMetaProcess start], range,",[c,l]),null!==(o=this._config)&&void 0!==o&&o.memoryOpt&&(!this.buffer||null!=d&&d.isExp))try{this.newBufferArray(l-c+1,null==d?void 0:d.isExp)}catch(v){s(null,!0,{},new Rr(null==v?void 0:v.message),{})}return f=function(){var e=a(r().mark((function e(t,i,a,o){var u,f,p,v,y,m,g,_,b,k,x,w,S;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!h.filesize&&null!=o&&o.headers&&(u=o.headers.get("content-range"))&&(f=u.split("/"),Array.isArray(f)&&2===f.length&&(h.filesize=parseInt(f[1]),h.filesize>0&&l>h.filesize&&(l=h.filesize,h.logger.debug("[loadMetaProcess] moovEnd changed by content-range in header, [".concat(c,"-").concat(l,"]"))))),!i&&h.meta&&null!=a&&a.range&&a.range.length>0&&a.range[1]>=l&&(i=!0,h.logger.debug("[loadMetaProcess],data done,setstate true,[",c,l,"]")),i&&null!=a&&a.range&&a.range.length>0&&a.range[1]<l&&(i=!1,h.logger.debug("[loadMetaProcess],data not done,setstate false,[",c,l,"]")),h.logger.debug("[loadMetaProcess],task,[",c,l,"], range,",a.range,",dataLen,",t?t.byteLength:void 0,", state,",i,",err,",h._error),!h._error&&t&&t.byteLength>0&&s(t,i,a,null,o),!h.meta.moov&&!h._error){e.next=7;break}return e.abrupt("return");case 7:if(!(t&&t.byteLength>0)){e.next=53;break}e.prev=8,null!==(v=h._config)&&void 0!==v&&v.memoryOpt?(h.buffer.set(t,h.bufferDataLen),h.bufferDataLen+=(null==t?void 0:t.byteLength)||0,p=h.buffer.subarray(0,h.bufferDataLen)):(h.buffer=Se(h.buffer,t),p=h.buffer),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),s(null,i,a,new Rr(null===e.t0||void 0===e.t0?void 0:e.t0.message),o),e.abrupt("return");case 16:if(y=At.findBox(p,["moov"])[0]){e.next=31;break}if(m=At.findBox(p,["mdat"])[0],!i){e.next=31;break}if(m){e.next=26;break}return h._error=!0,s(null,i,a,new Rr("cannot find moov or mdat box"),o),e.abrupt("return");case 26:return g=m.start+m.size,e.next=29,h.loadData([g,""],n,d);case 29:(_=e.sent)&&(y=At.findBox(_.data,["moov"])[0]);case 31:if(!(y&&i&&y.size>y.data.length)){e.next=35;break}return h.logger.debug("[loadMetaProcess],moov not all, range,",a.range[1],",dataLen,",h.bufferDataLen,", state,",i),e.next=35,h.loadMetaProcess(n,[a.range[1],y.start+y.size-1],s,{isExp:!0});case 35:if(!(y&&y.size<=y.data.length)||h.meta.moov){e.next=53;break}if(k=At.moov(y)){e.next=41;break}return h._error=!0,s(null,i,a,new Rr("cannot parse moov box"),o),e.abrupt("return");case 41:if(Hr(x=Fr(k,h._config))){e.next=46;break}return h._error=!0,s(null,i,a,new Rr("cannot parse segments"),o),e.abrupt("return");case 46:h.meta=Vr(k),w=x.videoSegments,S=x.audioSegments,h.videoSegments=w,h.audioSegments=S,null!==(b=h._config)&&void 0!==b&&b.memoryOpt&&(delete h.buffer,h.bufferDataLen=0),h.logger.debug("[loadMetaProcess] moov ok"),s(void 0,i,{meta:{meta:h.meta,videoSegments:w,audioSegments:S}},null,o);case 53:case"end":return e.stop()}}),e,null,[[8,12]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),e.next=9,this.loadData([c,l||this._config.moovEnd],n,t({onProgress:f},d));case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return g.apply(this,arguments)})},{key:"loadMeta",value:(v=a(r().mark((function e(t,n){var i,a,s,o,u,c,l,d,f,h,p=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=p.length>2&&void 0!==p[2]?p[2]:{},a=[],this.logger.debug("[loadMeta start]"),e.next=5,this.loadData([0,n||this._config.moovEnd],t,i);case 5:if(s=e.sent){e.next=8;break}return e.abrupt("return");case 8:if(a.push(s),o=At.findBox(s.data,["moov"])[0]){e.next=24;break}if(u=At.findBox(s.data,["mdat"])[0]){e.next=14;break}throw new Rr("cannot find moov or mdat box",s.data);case 14:return c=u.start+u.size,e.next=17,this.loadData([c],t,i);case 17:if(s=e.sent){e.next=20;break}return e.abrupt("return");case 20:if(a.push(s),o=At.findBox(s.data,["moov"],c)[0]){e.next=24;break}throw new Rr("cannot find moov box",s.data);case 24:if(!(o.size>o.data.length)){e.next=32;break}return e.next=27,this.loadData([s.data.length,o.start+o.size-1],t,i);case 27:if(s=e.sent){e.next=30;break}return e.abrupt("return");case 30:a.push(s),o.data=Se(o.data,s.data);case 32:if(l=At.moov(o)){e.next=35;break}throw new Rr("cannot parse moov box",o.data);case 35:if(Hr(d=Fr(l,this._config))){e.next=38;break}throw new Rr("cannot parse segments",o.data);case 38:return this.meta=Vr(l),f=d.videoSegments,h=d.audioSegments,this.videoSegments=f,this.audioSegments=h,delete this.buffer,this.bufferDataLen=0,this.logger.debug("[load moov end!!!!!]"),e.abrupt("return",{meta:this.meta,videoSegments:f,audioSegments:h,responses:a});case 46:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"loadCacheMeta",value:function(e,t){var r=Fr(e.moov,this._config),n=r.videoSegments,i=r.audioSegments;this.videoSegments=n,this.audioSegments=i,this._currentSegmentIndex=t,this.meta=e}},{key:"getSegmentByTime",value:function(e){var t,r;return this.videoSegments.length?(t=this.videoSegments.find((function(t){return t.startTime<=e&&t.endTime>e})))&&(r=this.audioSegments[t.index]):r=this.audioSegments.find((function(t){return t.startTime<=e&&t.endTime>e})),{video:t,audio:r}}},{key:"loadSegmentByTime",value:(p=a(r().mark((function e(t,n){var i,a,s,o,u,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!(c.length>2&&void 0!==c[2])||c[2],a=c.length>3&&void 0!==c[3]?c[3]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta(n);case 5:return s=this.getSegmentByTime(t),o=s.video,u=s.audio,e.abrupt("return",this._loadSegment(o,u,n,i,a));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"loadNextSegment",value:(h=a(r().mark((function e(t){var n,i,a,s,o=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(o.length>1&&void 0!==o[1])||o[1],i=o.length>2&&void 0!==o[2]?o[2]:{},this.isMetaLoaded){e.next=5;break}return e.next=5,this.loadMeta();case 5:return a=this.videoSegments[this._currentSegmentIndex+1],s=this.audioSegments[this._currentSegmentIndex+1],e.abrupt("return",this._loadSegment(a,s,t,n,i));case 8:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"preload",value:(f=a(r().mark((function e(t){var n,i,s,o,u,c,l,d=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isMetaLoaded){e.next=3;break}return e.next=3,this.loadMeta(!0);case 3:if(t&&!(t<0)){e.next=5;break}return e.abrupt("return");case 5:if(n=this.getSegmentByTime(t),i=n.video,s=n.audio,o=Math.max((null==i?void 0:i.index)||0,(null==s?void 0:s.index)||0)){e.next=9;break}return e.abrupt("return");case 9:return u=this.videoSegments.slice(0,o),c=this.audioSegments.slice(0,o),l=function(){var e=a(r().mark((function e(t){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t>o)){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,d._loadSegment(u[t],c[t],!0,!1);case 4:return e.next=6,l(t+1);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.next=14,l(0);case 14:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"cancel",value:function(){return this._loader.cancel()}},{key:"reset",value:(d=a(r().mark((function e(){var t,n=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length>0&&void 0!==n[0]&&n[0]){e.next=5;break}return this.logger.debug("[MP4loader reset func call loader.cancel]"),e.next=5,this._loader.cancel();case 5:this.vid=this.url="",this.meta={},this.downloadInfo=[],this.videoSegments=[],this.audioSegments=[],this._currentSegmentIndex=-1,this._currentLoadingSegmentIndex=-1,null!==(t=this._config)&&void 0!==t&&t.memoryOpt&&(delete this.buffer,this.bufferDataLen=0);case 13:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"destroy",value:(o=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.reset();case 2:this.cache.clear();case 3:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"_loadSegment",value:(i=a(r().mark((function e(t,n,i,a,s){var o,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t||n){e.next=2;break}return e.abrupt("return");case 2:return o=(null==t?void 0:t.index)||(null==n?void 0:n.index)||0,this._currentLoadingSegmentIndex=o,e.prev=4,e.next=7,this.loadData([Math.min((null==t?void 0:t.range[0])||1/0,(null==n?void 0:n.range[0])||1/0),Math.max((null==t?void 0:t.range[1])||0,(null==n?void 0:n.range[1])||0)],i,s);case 7:u=e.sent;case 8:return e.prev=8,this._currentLoadingSegmentIndex=-1,e.finish(8);case 11:if(u){e.next=13;break}return e.abrupt("return");case 13:return a&&(this._currentSegmentIndex=o),u.video=t,u.audio=n,e.abrupt("return",u);case 17:case"end":return e.stop()}}),e,this,[[4,,8,11]])}))),function(e,t,r,n,a){return i.apply(this,arguments)})},{key:"loadData",value:(n=a(r().mark((function e(n,i){var a,s,o,u,c,l=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=l.length>2&&void 0!==l[2]?l[2]:{},s=this._getCacheKey(n),e.next=4,this.cache.get(s);case 4:if(o=e.sent){e.next=12;break}return c=null!=a&&a.url?a.url:this.url,e.next=9,this._loader.load(c,t({range:n,vid:this.vid},a));case 9:u=e.sent,e.next=13;break;case 12:u={data:o,state:!0,options:{fromCache:!0,range:n,vid:this.vid}};case 13:if(u){e.next=15;break}return e.abrupt("return");case 15:return o||(u.data&&this.downloadInfo.push({startTime:u.startTime,endTime:u.endTime,size:u.data.byteLength,range:n}),this.downloadInfo&&this.downloadInfo.length>this._config.maxDownloadInfoSize&&(this.downloadInfo=this.downloadInfo.slice(-this._config.maxDownloadInfoSize))),e.abrupt("return",u);case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_getCacheKey",value:function(e){return(this.vid||this.url)+":"+e}}]),S}(ge);return Wr}));
2
2
  //# sourceMappingURL=index.min.js.map