@volcengine/veplayer 1.11.1-rc.1 → 1.11.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +6655 -0
- package/index.min.css +1 -0
- package/index.min.js +2 -0
- package/package.json +1 -1
- package/plugin/DashAbralgo.js +2 -0
- package/plugin/XGVideo.js +2 -0
- package/plugin/danmuMask.js +2 -0
- package/plugin/danmujs.js +3 -0
- package/plugin/dash.js +2 -0
- package/plugin/flv.js +2 -0
- package/plugin/hls.js +2 -0
- package/plugin/hlsEncrypt.js +2 -0
- package/plugin/mp4Encrypt.js +2 -0
- package/plugin/preloader.js +2 -0
- package/plugin/streamprobe.js +2 -0
- package/plugin/vestrategy.js +1 -0
- package/plugin/vestrategy_adapt_range.js +1 -0
- package/plugin/vestrategy_h265.js +1 -0
- package/plugin/vestrategy_preload.js +1 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("core-js/modules/es.object.to-string.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.object.get-own-property-names.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.concat.js"),require("core-js/modules/es.promise.finally.js"),require("core-js/modules/es.number.constructor.js"),require("core-js/modules/es.number.parse-float.js"),require("core-js/modules/es.number.is-nan.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/es.array.fill.js"),require("core-js/modules/es.array.iterator.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.object.assign.js"),require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.number.is-finite.js"),require("core-js/modules/es.array.sort.js"),require("core-js/modules/es.array.find-index.js"),require("core-js/modules/es.array.splice.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.regexp.flags.js"),require("core-js/modules/es.string.pad-start.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.array-buffer.constructor.js"),require("core-js/modules/es.typed-array.int8-array.js"),require("core-js/modules/es.typed-array.uint8-clamped-array.js"),require("core-js/modules/es.typed-array.int16-array.js"),require("core-js/modules/es.typed-array.uint16-array.js"),require("core-js/modules/es.typed-array.int32-array.js"),require("core-js/modules/es.typed-array.uint32-array.js"),require("core-js/modules/es.typed-array.float32-array.js"),require("core-js/modules/es.typed-array.float64-array.js"),require("core-js/modules/web.url.js"),require("core-js/modules/web.url-search-params.js"),require("core-js/modules/es.json.stringify.js"),require("core-js/modules/es.object.get-prototype-of.js"),require("core-js/modules/es.string.trim.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.object.entries.js"),require("core-js/modules/es.number.to-fixed.js")):"function"==typeof define&&define.amd?define(["core-js/modules/es.object.to-string.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/es.object.get-own-property-names.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.test.js","core-js/modules/es.string.replace.js","core-js/modules/es.array.filter.js","core-js/modules/es.promise.js","core-js/modules/es.array.concat.js","core-js/modules/es.promise.finally.js","core-js/modules/es.number.constructor.js","core-js/modules/es.number.parse-float.js","core-js/modules/es.number.is-nan.js","core-js/modules/es.array.map.js","core-js/modules/es.array.fill.js","core-js/modules/es.array.iterator.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.object.assign.js","core-js/modules/es.array.slice.js","core-js/modules/es.symbol.js","core-js/modules/es.number.is-finite.js","core-js/modules/es.array.sort.js","core-js/modules/es.array.find-index.js","core-js/modules/es.array.splice.js","core-js/modules/es.object.keys.js","core-js/modules/es.string.iterator.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/es.array.includes.js","core-js/modules/es.string.includes.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.function.name.js","core-js/modules/es.array.join.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.array.find.js","core-js/modules/es.array.from.js","core-js/modules/es.array-buffer.constructor.js","core-js/modules/es.typed-array.int8-array.js","core-js/modules/es.typed-array.uint8-clamped-array.js","core-js/modules/es.typed-array.int16-array.js","core-js/modules/es.typed-array.uint16-array.js","core-js/modules/es.typed-array.int32-array.js","core-js/modules/es.typed-array.uint32-array.js","core-js/modules/es.typed-array.float32-array.js","core-js/modules/es.typed-array.float64-array.js","core-js/modules/web.url.js","core-js/modules/web.url-search-params.js","core-js/modules/es.json.stringify.js","core-js/modules/es.object.get-prototype-of.js","core-js/modules/es.string.trim.js","core-js/modules/es.set.js","core-js/modules/es.object.entries.js","core-js/modules/es.number.to-fixed.js"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).XGVideo=t()}(this,(function(){"use strict";function e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function t(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?e(Object(n),!0).forEach((function(e){u(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 i(){i=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,i){e[t]=i.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function A(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{A({},"")}catch(C){A=function(e,t,i){return e[t]=i}}function d(e,t,i,n){var s=t&&t.prototype instanceof l?t:l,a=Object.create(s.prototype),o=new R(n||[]);return r(a,"_invoke",{value:k(e,i,o)}),a}function c(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(C){return{type:"throw",arg:C}}}e.wrap=d;var h={};function l(){}function f(){}function m(){}var _={};A(_,a,(function(){return this}));var p=Object.getPrototypeOf,v=p&&p(p(S([])));v&&v!==t&&n.call(v,a)&&(_=v);var y=m.prototype=l.prototype=Object.create(_);function g(e){["next","throw","return"].forEach((function(t){A(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function i(r,s,a,o){var u=c(e[r],e,s);if("throw"!==u.type){var A=u.arg,d=A.value;return d&&"object"==typeof d&&n.call(d,"__await")?t.resolve(d.__await).then((function(e){i("next",e,a,o)}),(function(e){i("throw",e,a,o)})):t.resolve(d).then((function(e){A.value=e,a(A)}),(function(e){return i("throw",e,a,o)}))}o(u.arg)}var s;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){i(e,n,t,r)}))}return s=s?s.then(r,r):r()}})}function k(e,t,i){var n="suspendedStart";return function(r,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===r)throw s;return{value:void 0,done:!0}}for(i.method=r,i.arg=s;;){var a=i.delegate;if(a){var o=E(a,i);if(o){if(o===h)continue;return o}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if("suspendedStart"===n)throw n="completed",i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n="executing";var u=c(e,t,i);if("normal"===u.type){if(n=i.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:i.done}}"throw"===u.type&&(n="completed",i.method="throw",i.arg=u.arg)}}}function E(e,t){var i=e.iterator[t.method];if(void 0===i){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,E(e,t),"throw"===t.method))return h;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=c(i,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var r=n.arg;return r?r.done?(t[e.resultName]=r.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function D(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 T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function S(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,r=function t(){for(;++i<e.length;)if(n.call(e,i))return t.value=e[i],t.done=!1,t;return t.value=void 0,t.done=!0,t};return r.next=r}}return{next:w}}function w(){return{value:void 0,done:!0}}return f.prototype=m,r(y,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:f,configurable:!0}),f.displayName=A(m,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,m):(e.__proto__=m,A(e,u,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},g(b.prototype),A(b.prototype,o,(function(){return this})),e.AsyncIterator=b,e.async=function(t,i,n,r,s){void 0===s&&(s=Promise);var a=new b(d(t,i,n,r),s);return e.isGeneratorFunction(i)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(y),A(y,u,"Generator"),A(y,a,(function(){return this})),A(y,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),i=[];for(var n in t)i.push(n);return i.reverse(),function e(){for(;i.length;){var n=i.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=S,R.prototype={constructor:R,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(T),!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 i(i,n){return a.type="throw",a.arg=e,t.next=i,n&&(t.method="next",t.arg=void 0),!!n}for(var r=this.tryEntries.length-1;r>=0;--r){var s=this.tryEntries[r],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var o=n.call(s,"catchLoc"),u=n.call(s,"finallyLoc");if(o&&u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(o){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(e,t){for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var s=r;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var a=s?s.completion:{};return a.type=e,a.arg=t,s?(this.method="next",this.next=s.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),T(i),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var n=i.completion;if("throw"===n.type){var r=n.arg;T(i)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,i){return this.delegate={iterator:S(e),resultName:t,nextLoc:i},"next"===this.method&&(this.arg=void 0),h}},e}function n(e,t,i,n,r,s,a){try{var o=e[s](a),u=o.value}catch(A){return void i(A)}o.done?t(u):Promise.resolve(u).then(n,r)}function r(e){return function(){var t=this,i=arguments;return new Promise((function(r,s){var a=e.apply(t,i);function o(e){n(a,r,s,o,u,"next",e)}function u(e){n(a,r,s,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 a(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function o(e,t,i){return t&&a(e.prototype,t),i&&a(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function A(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&&c(e,t)}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=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 l(e,t,i){return(l=h()?Reflect.construct.bind():function(e,t,i){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return i&&c(r,i.prototype),r}).apply(null,arguments)}function f(e){var t="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;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 l(e,arguments,d(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)},f(e)}function m(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _(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 p(e){var t=h();return function(){var i,n=d(e);if(t){var r=d(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return _(this,i)}}function v(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function y(){return y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var n=v(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(arguments.length<3?e:i):r.value}},y.apply(this,arguments)}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,s=[],a=!0,o=!1;try{for(i=i.call(e);!(a=(n=i.next()).done)&&(s.push(n.value),!t||s.length!==t);a=!0);}catch(u){o=!0,r=u}finally{try{a||null==i.return||i.return()}finally{if(o)throw r}}return s}(e,t)||k(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 b(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)||k(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 k(e,t){if(e){if("string"==typeof e)return E(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?E(e,t):void 0}}function E(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}var D,T=function(){return"undefined"!=typeof navigator&&parseFloat((""+(/CPU.*OS ([0-9_]{3,4})[0-9_]{0,1}|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))<10&&!window.MSStream},R=function(){return"wakeLock"in navigator},S=function(){function e(){var t=this;s(this,e),this.enabled=!1,R()?(this._wakeLock=null,this.handleVisibilityChange=function(){null!==t._wakeLock&&t.visible&&t.enable()},document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("fullscreenchange",this.handleVisibilityChange)):T()?this.noSleepTimer=null:(this.noSleepVideo=document.createElement("video"),this.noSleepVideo.setAttribute("playsinline",""),this._addSourceToVideo(this.noSleepVideo,"mp4","data:video/mp4;base64, AAAAHGZ0eXBNNFYgAAACAGlzb21pc28yYXZjMQAAAAhmcmVlAAAGF21kYXTeBAAAbGliZmFhYyAxLjI4AABCAJMgBDIARwAAArEGBf//rdxF6b3m2Ui3lizYINkj7u94MjY0IC0gY29yZSAxNDIgcjIgOTU2YzhkOCAtIEguMjY0L01QRUctNCBBVkMgY29kZWMgLSBDb3B5bGVmdCAyMDAzLTIwMTQgLSBodHRwOi8vd3d3LnZpZGVvbGF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lEEIKIYSUUggJAAAYcAAACDChDBQashIASAUAAIyx1lprrbXWQGettdZaa62AzFprrbXWWmuttdZaa6211lJrrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmstpZRSSimllFJKKaWUUkoppZRSSgUA+lU4APg/2LA6wknRWGChISsBgHAAAMAYpRhzDEIppVQIMeacdFRai7FCiDHnJKTUWmzFc85BKCGV1mIsnnMOQikpxVZjUSmEUlJKLbZYi0qho5JSSq3VWIwxqaTWWoutxmKMSSm01FqLMRYjbE2ptdhqq7EYY2sqLbQYY4zFCF9kbC2m2moNxggjWywt1VprMMYY3VuLpbaaizE++NpSLDHWXAAAd4MDAESCjTOsJJ0VjgYXGrISAAgJACAQUooxxhhzzjnnpFKMOeaccw5CCKFUijHGnHMOQgghlIwx5pxzEEIIIYRSSsaccxBCCCGEkFLqnHMQQgghhBBKKZ1zDkIIIYQQQimlgxBCCCGEEEoopaQUQgghhBBCCKmklEIIIYRSQighlZRSCCGEEEIpJaSUUgohhFJCCKGElFJKKYUQQgillJJSSimlEkoJJYQSUikppRRKCCGUUkpKKaVUSgmhhBJKKSWllFJKIYQQSikFAAAcOAAABBhBJxlVFmGjCRcegEJDVgIAZAAAkKKUUiktRYIipRikGEtGFXNQWoqocgxSzalSziDmJJaIMYSUk1Qy5hRCDELqHHVMKQYtlRhCxhik2HJLoXMOAAAAQQCAgJAAAAMEBTMAwOAA4XMQdAIERxsAgCBEZohEw0JweFAJEBFTAUBigkIuAFRYXKRdXECXAS7o4q4DIQQhCEEsDqCABByccMMTb3jCDU7QKSp1IAAAAAAADADwAACQXAAREdHMYWRobHB0eHyAhIiMkAgAAAAAABcAfAAAJCVAREQ0cxgZGhscHR4fICEiIyQBAIAAAgAAAAAggAAEBAQAAAAAAAIAAAAEBB9DtnUBAAAAAAAEPueBAKOFggAAgACjzoEAA4BwBwCdASqwAJAAAEcIhYWIhYSIAgIABhwJ7kPfbJyHvtk5D32ych77ZOQ99snIe+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kgA6jhYIDOoAOo5mBA0sAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCA0+ADqOFggNkgA6jmYEDcwAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYIDeoAOo4WCA4+ADqOZgQObADECAAEQEAAYABhYL/QACIBDmAYAAKOFggOkgA6jhYIDuoAOo5mBA8MAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCA8+ADqOFggPkgA6jhYID+oAOo4WCBA+ADhxTu2sBAAAAAAAAEbuPs4EDt4r3gQHxghEr8IEK"),this.noSleepVideo.addEventListener("loadedmetadata",(function(){t.noSleepVideo&&(t.noSleepVideo.duration<=1?t.noSleepVideo.setAttribute("loop",""):(t.onTimeupdate=function(){t.noSleepVideo.currentTime>.5&&(t.noSleepVideo.currentTime=Math.random())},t.noSleepVideo.addEventListener("timeupdate",t.onTimeupdate)))})))}return o(e,[{key:"_addSourceToVideo",value:function(e,t,i){var n=document.createElement("source");n.src=i,n.type="video/".concat(t),e.appendChild(n)}},{key:"visible",get:function(){return"visible"===document.visibilityState}},{key:"isEnabled",get:function(){return this.enabled}},{key:"enable",value:function(){var e,t=this;if(R()&&this.visible)return navigator.wakeLock.request("screen").then((function(e){t._wakeLock=e,t.enabled=!0,t._wakeLock.addEventListener("release",(function(){}))})).catch((function(){t.enabled=!1}));if(T())return this.disable(),console.warn("\n NoSleep enabled for older iOS devices. This can interrupt\n active or long-running network requests from completing successfully.\n See https://github.com/richtr/NoSleep.js/issues/15 for more details.\n "),this.noSleepTimer=window.setInterval((function(){document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))}),15e3),this.enabled=!0,Promise.resolve();if(null!==(e=this.noSleepVideo)&&void 0!==e&&e.paused){var i=this.noSleepVideo.play();return i&&i.then((function(e){return t.enabled=!0,e})).catch((function(e){console.log("noSleep: ",e.message),t.enabled=!1}))}}},{key:"disable",value:function(){R()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):T()?this.noSleepTimer&&(console.warn("\n NoSleep now disabled for older iOS devices.\n "),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}},{key:"toPlay",value:function(){if(this.noSleepVideo&&this.noSleepVideo.paused){var e=performance.now();this.lastTs||(this.lastTs=e),e-this.lastTs>1e4&&(this.enable(),this.lastTs=e)}}},{key:"destroy",value:function(){this.disable(),this.handleVisibilityChange&&(document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("fullscreenchange",this.handleVisibilityChange)),this.onTimeupdate&&this.noSleepVideo.removeEventListener("timeupdate",this.onTimeupdate),this.noSleepVideo=null}}]),e}();function w(){if(!document.querySelector("#hackAudioPP")){var e=document.createElement("div");e.innerHTML="<audio id='hackAudioPP'></audio>",document.body.appendChild(e);var t=e.children.item(0);t.controls=!1,t.preload="auto",t.innerHTML="<source src=".concat("data:audio/mpeg;base64,//uQxAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAACAAACcQCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA//////////////////////////////////////////////////////////////////8AAABhTEFNRTMuMTAwA8MAAAAAAAAAABQgJAUHQQAB9AAAAnGMHkkIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//sQxAADgnABGiAAQBCqgCRMAAgEAH///////////////7+n/9FTuQsQH//////2NG0jWUGlio5gLQTOtIoeR2WX////X4s9Atb/JRVCbBUpeRUq//////////////////9RUi0f2jn/+xDECgPCjAEQAABN4AAANIAAAAQVTEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==",' type="audio/mpeg"></source>'),t.muted=!0,t.loop=!0,t.play().catch((function(){}))}}function C(){var e=D||(D=document.querySelector("#hackAudioPP"));e?!1===e.paused&&!1===e.muted||(e.muted=!1,e.play().catch((function(e){console.log("bgAudio: ",e.message)}))):w()}var V=new(function(){function e(){var t=this;s(this,e);try{var i=/xgd=(\d)/.exec(document.cookie);this._status=!!i,this._level=i&&i[1]}catch(n){this._status=!1}["group","groupEnd","log","warn","error"].forEach((function(e){t[e]=function(i,n,r,s,a,o,u,A,d,c){var h;if(t._status){var l=i,f=[n,r,s,a,o,u,A,d,c].filter((function(e){return void 0!==e}));(h=console)[e].apply(h,["["+l+"]:"].concat(b(f)))}}}))}return o(e,[{key:"enable",get:function(){return this._status}},{key:"long",get:function(){return"2"===this._level}}]),e}());function I(e,t){if(e&&t){var i=new Uint8Array(e.byteLength+t.byteLength+11);i[0]=1,i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=255,i[5]=225;var n=6;return i.set(new Uint8Array([e.byteLength>>>8&255,255&e.byteLength]),n),n+=2,i.set(e,n),i[n+=e.byteLength]=1,n++,i.set(new Uint8Array([t.byteLength>>>8&255,255&t.byteLength]),n),n+=2,i.set(t,n),i}}var G="xg-video",L=!1;try{L=WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}catch(vn){}var Z={preloadDecoder:!1,reuseWasmDecoder:!0,reuseMseForAudio:!1,preciseSeek:0,h264WithWebcodec:!0,lowDecodeThreshold:100,wasmFallbackToAsm:!1,audioWithMse:!0,canUseThreadMode:!1,disabledWhenErrorOccur:!0,disabledDuration:43200,evaluateVVCount:0,disabledByLowdecodePrecent:.5,maxDecodeOnceWasm:L?6:8,maxDecodeOnceFirstTime:8,maxDecodeOnceWebcodec:20};function F(){return G}function x(){return Z}function B(){var e="undefined"!=typeof customElements&&customElements.get(G);return e?{H264_DECODER_URL:e.h264Url,ASM_H264_DECODER_URL:e.h264AsmUrl,H265_DECODER_URL:e.h265Url,H265_THREAD_DECODER_URL:e.h265ThreadUrl,H265_SIMD_DECODER_URL:e.h265SimdUrl,ASM_H265_DECODER_URL:e.h265AsmUrl}:{}}function U(){if("undefined"==typeof customElements)return!1;var e=customElements.get(G);return L&&!(null==e||!e.h265SimdUrl)}function N(){if("undefined"==typeof customElements)return!1;var e=customElements.get(G);return!!window.SharedArrayBuffer&&!(null==e||!e.h265ThreadUrl)}var P=!1;try{var O,W;P="1"===(null===(O=localStorage)||void 0===O||null===(W=O.getItem)||void 0===W?void 0:W.call(O,"_sds"))}catch(vn){}var j=0,Y=0,M=0,X=!1;function Q(e){localStorage.setItem("xgv_dis",e),2===e&&localStorage.setItem("xgv_dist",(new Date).getTime())}function J(){if(!0===(!!X||0!==x().evaluateVVCount&&(j===x().evaluateVVCount&&(M=Y/j),M>=x().disabledByLowdecodePrecent&&(X=!0),X)))return!0;var e=localStorage.getItem("xgv_dis");if(!e)return!1;if("1"===e)return!0;if("2"===e){var t=localStorage.getItem("xgv_dist")||0;if(t=Number(t),((new Date).getTime()-t)/1e3<x().disabledDuration)return!0;H()}}function H(){localStorage.removeItem("xgv_dist"),localStorage.removeItem("xgv_dis")}var K={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,i="~";function n(){}function r(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function s(e,t,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new r(n,s||e,a),u=i?i+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),o.prototype.eventNames=function(){var e,n,r=[];if(0===this._eventsCount)return r;for(n in e=this._events)t.call(e,n)&&r.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},o.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,s=n.length,a=new Array(s);r<s;r++)a[r]=n[r].fn;return a},o.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},o.prototype.emit=function(e,t,n,r,s,a){var o=i?i+e:e;if(!this._events[o])return!1;var u,A,d=this._events[o],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,r),!0;case 5:return d.fn.call(d.context,t,n,r,s),!0;case 6:return d.fn.call(d.context,t,n,r,s,a),!0}for(A=1,u=new Array(c-1);A<c;A++)u[A-1]=arguments[A];d.fn.apply(d.context,u)}else{var h,l=d.length;for(A=0;A<l;A++)switch(d[A].once&&this.removeListener(e,d[A].fn,void 0,!0),c){case 1:d[A].fn.call(d[A].context);break;case 2:d[A].fn.call(d[A].context,t);break;case 3:d[A].fn.call(d[A].context,t,n);break;case 4:d[A].fn.call(d[A].context,t,n,r);break;default:if(!u)for(h=1,u=new Array(c-1);h<c;h++)u[h-1]=arguments[h];d[A].fn.apply(d[A].context,u)}}return!0},o.prototype.on=function(e,t,i){return s(this,e,t,i,!1)},o.prototype.once=function(e,t,i){return s(this,e,t,i,!0)},o.prototype.removeListener=function(e,t,n,r){var s=i?i+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==t||r&&!o.once||n&&o.context!==n||a(this,s);else{for(var u=0,A=[],d=o.length;u<d;u++)(o[u].fn!==t||r&&!o[u].once||n&&o[u].context!==n)&&A.push(o[u]);A.length?this._events[s]=1===A.length?A[0]:A:a(this,s)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,e.exports=o}(K);var z=K.exports,q={WAITING:0,CANPLAY:1,PLAY:2,PLAYING:3,PAUSE:4,SEEKING:5,SEEKED:6,LOADEDDATA:7,LOADEDMETADATA:8,TIMEUPDATE:9,DURATION_CHANGE:10,VOLUME_CHANGE:11,PROGRESS:12,ERROR:13,ENDED:14,RESIZE:15,LOADSTART:16,DECODE_FPS:17,LOW_DECODE:18,LARGE_AV_GAP:19,FIRST_FRAME:20},$=["waiting","canplay","play","playing","pause","seeking","seeked","loadeddata","loadedmetadata","timeupdate","durationchange","volumechange","progress","error","ended","resize","loadstart","decodefps","lowdecode","largeavgap","firstframe"],ee={AUDIO_READY:"audio_ready",AUDIO_NOT_ALLOWED_AUTOPLAY:"audio_not_allowed_autoplay",AUDIO_WAITING:"audio_waiting",AUDIO_SYNC_DTS:"audio_sync_dts"},te={VIDEO_DECODER_INIT:"video_decode_init",VIDEO_READY:"video_ready",VIDEO_WAITING:"video_waiting",AUTO_RUN:"auto_run",DECODE_LOW_FPS:"decode_low_fps",UPDATE_VIDEO_FILLTYPE:"update_video_filltype",UPDATE_VIDEO_COVER_POSITION:"update_video_cover_position"},ie={PLAY_EVENT:"play_event",SET_METADATA:"set_metadata",APPEND_CHUNKS:"append_chunks",START_RENDER:"start_render",DO_PLAY:"do_play",DO_PAUSE:"do_pause",DO_SEEK:"do_seek",SET_PLAYBACKRATE:"set_playbackrate",SYNC_DTS:"sync_dts",RESET_BASE_DTS:"reset_base_dts",UPDATE_VOLUME:"update_volume",SINGLE_TRACK:"single_track",DESTROY:"destroy",READY:"ready",UPDATE_GL_OPTIONS:"update_gl_options",SET_VIDEO_DURATION:"set_video_duration",SET_PLAY_MODE:"set_play_mode",UPDATE_CAPABILITY_LEVEL:"update_capability_level",INNER_DEGRADE:"inner_degrade",ADJUST_SEEK_TIME:"adjust_seek_time",CHASE_FRAME:"chase_frame",END_OF_STREAM:"end_of_stream",UPDATE_SEGMENT_END:"update_segment_end"},ne={INIT:"init",READY:"decoderready",REMUX:"remux",INIT_FAILED:"initfailed",DATAREADY:"dataReady",PLAY_FAILED:"playfailed",FRAGMENT_END:"fragmentEnd",APPEND_VIDEO:"appendVideo",FIRST_FRAME:"firstFrame",DECODED:"decoded",RENDE_END:"rendeEnd",CHASE_VIDEO_FRAME:"chaseVideoFrame",CHASE_VIDEO_FRAME_END:"chaseVideoFrameEnd",CHASE_AUDIO_FRAME:"chaseAudioFrame",INIT_SEGMENT:"initSegment",MEDIA_SEGMENT:"mediaSegment",FRAME_MAX_COUNY:"frameMaxCount",FRAME_MIN_COUNY:"frameMinCount"},re=function(e){A(i,e);var t=p(i);function i(e,n){var r;return s(this,i),(r=t.call(this))._config=e,r._parent=n,r._meta=null,r._ready=!1,r._isLive=!0,r._innerDegrade=!1,r._singleTrack=-1,r}return o(i,[{key:"analyse",get:function(){return this._parent.analyse}},{key:"isLive",get:function(){return this._isLive}},{key:"innerDegrade",get:function(){return this._innerDegrade}},{key:"noAudio",get:function(){return 1===this._singleTrack||2===this._singleTrack}},{key:"noVideo",get:function(){return 3===this._singleTrack}},{key:"duration",get:function(){return this._timeRange.duration},set:function(e){this._timeRange&&(this._timeRange.duration=e)}},{key:"_bindEvents",value:function(){var e=this;this._parent.on(ie.APPEND_CHUNKS,this._appendChunk.bind(this)),this._parent.on(ie.RESET_BASE_DTS,this._resetDts.bind(this)),this._parent.on(ie.START_RENDER,this._startRender.bind(this)),this._parent.on(ie.DO_PLAY,this._doPlay.bind(this)),this._parent.on(ie.DO_PAUSE,this._doPause.bind(this)),this._parent.on(ie.DO_SEEK,this._doSeek.bind(this)),this._parent.on(ie.DESTROY,this._destroy.bind(this)),this._parent.on(ie.CHASE_FRAME,this._doChaseFrame.bind(this)),this._parent.on(ie.SINGLE_TRACK,(function(t){e._singleTrack=t})),this._parent.on(ie.SET_PLAY_MODE,(function(t){e._isLive="LIVE"===t})),this._parent.on(ie.INNER_DEGRADE,(function(){e._innerDegrade=!0})),this._parent.on(ie.SET_VIDEO_DURATION,(function(t){e.duration=t}))}}]),i}(z),se=function(){function e(t){s(this,e),this.TAG="AudioTimeRange",this._parent=t,this._buffers=[],this._duration=0,this._baseDts=0,this._lastBuffer=null}return o(e,[{key:"isLive",get:function(){return this._parent.isLive}},{key:"duration",get:function(){return this._duration},set:function(e){this._duration=e}},{key:"buffered",get:function(){var e=this;if(this.isLive)return{length:this._duration?1:0,start:function(){return 0},end:function(){return e._duration}};var t=this._mergeBufferRanges();return{length:t.length,start:function(e){var i=t[e];return i?i.start:0},end:function(e){var i=t[e];return i?i.end:1/0}}}},{key:"resetDts",value:function(e){this._baseDts=e}},{key:"_transitionSamples",value:function(e){for(var t=e.numberOfChannels,i=e.length,n=512,r=0;r<t;r++){for(var s=e.getChannelData(r),a=0;a<n;a++)s[a]=s[a]*a/n;for(var o=i-n;o<i;o++)s[o]=s[o]*(i-o)/n}}},{key:"append",value:function(e,t,i,n){-1===this._baseDts&&(this._baseDts=i),this._transitionSamples(e);var r=(i-this._baseDts)/1e3,s=r+t,a={start:r,end:s,startDts:i,source:e,duration:t,delay:n};if(V.log(this.TAG,"add new buffer range, startDts:".concat(i,", [").concat(a.start," , ").concat(a.end,"]")),!this._buffers.filter((function(e){return e.start===r})).length)return this._buffers.push(a),this.isLive&&(this._duration=s),a.start;console.error("音频重复")}},{key:"deletePassed",value:function(e){return this._buffers=this._buffers.filter((function(t){return t.start>=e})),this._buffers[0]}},{key:"canSeek",value:function(e){var t=this._buffers[this._buffers.length-1];return!!t&&!(t.start<e)}},{key:"_mergeBufferRanges",value:function(){var e=this._buffers.slice().sort((function(e,t){return e.start>t.start?1:-1})),t=e.length,i=[];if(!t)return i;for(var n={start:e[0].start,end:e[0].end},r=1;r<t;r++){var s=e[r];Math.abs(n.end-s.start)<.5?n.end=s.end:(i.push(n),n={start:s.start,end:s.end})}return i.push(n),i}},{key:"getBuffer",value:function(e){if(this.isLive)return this._buffers.shift();var t=this._buffers.filter((function(t){return t.start<e+.5&&t.end>e+.5}))[0];return V.log(this.TAG,"get audio buffer , currentTime:".concat(e," ,buffer:[").concat(t&&t.start," , ").concat(t&&t.end,"]")),0!==e||t?t:this._buffers[0]}},{key:"hasBuffer",value:function(){var e;return!(null===(e=this._buffers)||void 0===e||!e.length)}}]),e}(),ae=[-5504,-5248,-6016,-5760,-4480,-4224,-4992,-4736,-7552,-7296,-8064,-7808,-6528,-6272,-7040,-6784,-2752,-2624,-3008,-2880,-2240,-2112,-2496,-2368,-3776,-3648,-4032,-3904,-3264,-3136,-3520,-3392,-22016,-20992,-24064,-23040,-17920,-16896,-19968,-18944,-30208,-29184,-32256,-31232,-26112,-25088,-28160,-27136,-11008,-10496,-12032,-11520,-8960,-8448,-9984,-9472,-15104,-14592,-16128,-15616,-13056,-12544,-14080,-13568,-344,-328,-376,-360,-280,-264,-312,-296,-472,-456,-504,-488,-408,-392,-440,-424,-88,-72,-120,-104,-24,-8,-56,-40,-216,-200,-248,-232,-152,-136,-184,-168,-1376,-1312,-1504,-1440,-1120,-1056,-1248,-1184,-1888,-1824,-2016,-1952,-1632,-1568,-1760,-1696,-688,-656,-752,-720,-560,-528,-624,-592,-944,-912,-1008,-976,-816,-784,-880,-848,5504,5248,6016,5760,4480,4224,4992,4736,7552,7296,8064,7808,6528,6272,7040,6784,2752,2624,3008,2880,2240,2112,2496,2368,3776,3648,4032,3904,3264,3136,3520,3392,22016,20992,24064,23040,17920,16896,19968,18944,30208,29184,32256,31232,26112,25088,28160,27136,11008,10496,12032,11520,8960,8448,9984,9472,15104,14592,16128,15616,13056,12544,14080,13568,344,328,376,360,280,264,312,296,472,456,504,488,408,392,440,424,88,72,120,104,24,8,56,40,216,200,248,232,152,136,184,168,1376,1312,1504,1440,1120,1056,1248,1184,1888,1824,2016,1952,1632,1568,1760,1696,688,656,752,720,560,528,624,592,944,912,1008,976,816,784,880,848],oe=[-32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956,-23932,-22908,-21884,-20860,-19836,-18812,-17788,-16764,-15996,-15484,-14972,-14460,-13948,-13436,-12924,-12412,-11900,-11388,-10876,-10364,-9852,-9340,-8828,-8316,-7932,-7676,-7420,-7164,-6908,-6652,-6396,-6140,-5884,-5628,-5372,-5116,-4860,-4604,-4348,-4092,-3900,-3772,-3644,-3516,-3388,-3260,-3132,-3004,-2876,-2748,-2620,-2492,-2364,-2236,-2108,-1980,-1884,-1820,-1756,-1692,-1628,-1564,-1500,-1436,-1372,-1308,-1244,-1180,-1116,-1052,-988,-924,-876,-844,-812,-780,-748,-716,-684,-652,-620,-588,-556,-524,-492,-460,-428,-396,-372,-356,-340,-324,-308,-292,-276,-260,-244,-228,-212,-196,-180,-164,-148,-132,-120,-112,-104,-96,-88,-80,-72,-64,-56,-48,-40,-32,-24,-16,-8,0,32124,31100,30076,29052,28028,27004,25980,24956,23932,22908,21884,20860,19836,18812,17788,16764,15996,15484,14972,14460,13948,13436,12924,12412,11900,11388,10876,10364,9852,9340,8828,8316,7932,7676,7420,7164,6908,6652,6396,6140,5884,5628,5372,5116,4860,4604,4348,4092,3900,3772,3644,3516,3388,3260,3132,3004,2876,2748,2620,2492,2364,2236,2108,1980,1884,1820,1756,1692,1628,1564,1500,1436,1372,1308,1244,1180,1116,1052,988,924,876,844,812,780,748,716,684,652,620,588,556,524,492,460,428,396,372,356,340,324,308,292,276,260,244,228,212,196,180,164,148,132,120,112,104,96,88,80,72,64,56,48,40,32,24,16,8,0],ue=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]);var Ae={decodeG711:function(e,t){if("g7110a"===t)return function(e){for(var t=new Uint8Array(2*e.length),i=0,n=0;i<e.length;){var r=ae[e[i]];if(void 0===r)throw new Error("can not decode g711 alaw data!");t[n]=255&r,t[n+1]=r>>8,i+=1,n+=2}return t}(e);if("g7110m"===t)return function(e){for(var t=new Uint8Array(2*e.length),i=0,n=0;i<e.length;){var r=oe[e[i]];if(void 0===r)throw new Error("can not decode g711 ulaw data!");t[n]=255&r,t[n+1]=r>>8,i+=1,n+=2}return t}(e);throw new Error("no supported format=".concat(t," for g711"))},createAudioBufferFromPcm:function(e,t,i,n,r){for(var s,a=function(e,t,i){return e/t/i}(t.byteLength,i,r),o=e.createBuffer(i,a,n),u=new DataView(t),A=0;A<i;A++)for(var d=o.getChannelData(A),c=void 0,h=0;h<a;h++)c=u.getUint16(h*(2*i)+2*A,!0),d[h]=(s=c)>=32768?-(65536-s)/32768:s/32767;return{audioBuffer:o,duration:a/n}},packageAACToAdts:function(e,t){var i=new Uint8Array(t.data.byteLength+7),n=function(e,t){var i=e.sampleRateIndex,n=e.channelCount;i=function(e,t){var i=(7&e[0])<<1|e[1]>>>7;return i!==t?i:t}(e.config,i);var r=new Uint8Array(7);r[0]=255,r[1]=240,r[1]=1|r[1],r[2]=64,r[2]=r[2]|60&i<<2,r[2]=r[2]|1&n>>2,r[3]=192&n<<6;var s=t.byteLength+7;return r[3]=r[3]|3&s>>11,r[4]=255&s>>3,r[5]=224&s<<5,r[5]=31|r[5],r[6]=252,r}(e,t.data);return i.set(n),i.set(t.data,7),i},concatAdts:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=0,n=0,r=e.length;n<r;n++)t&&n%t==0||(i+=e[n].byteLength);for(var s=new Uint8Array(i),a=0,o=0,u=e.length;o<u;o++)t&&o%t==0||(s.set(e[o],a),a+=e[o].byteLength);return s},checkRefillFrame:function(e){var t=e[0].dts,i=e.filter((function(e){return e.dts===t})).length;if(!(i<=1))for(var n=0;n<i;n++)e[n].data=ue}},de="create new AudioContext error",ce=function(e){A(c,e);var t,n,a=p(c);function c(e,t){var i;return s(this,c),u(m(i=a.call(this,e,t)),"doPause",i._doPause),i.TAG="AudioRender",i._timeRange=new se(m(i)),i._lastTimeLineTime=0,i._sampleQueue=[],i._source=null,i._audioCanAutoplay=!0,i._lastBuffer=null,i._inDecoding=!1,i._endOfStream=!1,i._delay=0,i._isSourceBufferEnd=-1,i._onSourceBufferEnded=i._onSourceBufferEnded.bind(m(i)),i._initAudioCtx(e.volume||.6),i._bindEvents(),i}return o(c,[{key:"baseDts",get:function(){return this._timeRange._baseDts}},{key:"currentTime",get:function(){return this._audioCtx?this._lastTimeLineTime+this._audioCtx.currentTime:0}},{key:"preloadTime",get:function(){return this.isLive?1:0}},{key:"timescale",get:function(){return 1e3}},{key:"buffered",get:function(){return this._timeRange.buffered}},{key:"ctxState",get:function(){return this._audioCtx.state}},{key:"audioCanAutoplay",get:function(){return this._audioCanAutoplay}},{key:"resume",value:function(){if(this._audioCtx&&"suspended"===this._audioCtx.state)return this._audioCtx.resume().catch((function(e){}))}},{key:"canSeek",value:function(e){return this._timeRange.canSeek(e)}},{key:"_assembleErr",value:function(e){var t=new Error(e);return t.code=3,t}},{key:"_emitTimelineEvents",value:function(e,t,i){var n,r;null===(n=this._parent)||void 0===n||null===(r=n.emit)||void 0===r||r.call(n,e,t,i)}},{key:"_initAudioCtx",value:function(e){var t=this;V.log(this.TAG,"init audioCtx");var i=window.AudioContext||window.webkitAudioContext;return this._audioCtx=new i,this._audioCtx?(this._gainNode=this._audioCtx.createGain(),this._gainNode.gain.value=e,this._gainNode.connect(this._audioCtx.destination),this._audioCanAutoplay="running"===this._audioCtx.state,V.log(this.TAG,"webAudio state:",this._audioCtx.state),w(),this._bindAudioCtxEvent(),this._audioCtx.suspend()):(V.warn(this.TAG,"create webaudio error!"),void setTimeout((function(){t._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,t._assembleErr(de))})))}},{key:"_bindAudioCtxEvent",value:function(){var e=this;this._onStateChange=function(){e._audioCtx&&"running"===e._audioCtx.state&&e._ready&&e._emitTimelineEvents(ie.PLAY_EVENT,q.PLAYING)},this._audioCtx.addEventListener("statechange",this._onStateChange)}},{key:"_bindEvents",value:function(){var e=this;y(d(c.prototype),"_bindEvents",this).call(this),this._parent.on(ne.CHASE_AUDIO_FRAME,this._doChaseFrame.bind(this)),this._parent.on(ie.UPDATE_VOLUME,(function(t){e._gainNode&&(e._gainNode.gain.value=Number.isFinite(t)?t:1,e._emitTimelineEvents(ie.PLAY_EVENT,q.VOLUME_CHANGE))})),this._parent.on(ie.END_OF_STREAM,(function(){var t;e._endOfStream=!0,e.noAudio||null!==(t=e._timeRange)&&void 0!==t&&t.hasBuffer()||null==e||e._emitTimelineEvents(ie.PLAY_EVENT,q.ENDED)}))}},{key:"_appendChunk",value:function(e,t){if(!this.noAudio){this._meta||(this._meta=t,V.warn(this.TAG,"audio set metadata",this._meta));var i=t.samples;if(i.length)if(this._sampleQueue=this._sampleQueue.concat(i),t.samples=[],"aac"===this._meta.codecType){if(this._inDecoding)return;this._decodeAACWrapper()}else this._decodeG711()}}},{key:"_resetDts",value:function(e,t){"video"!==t&&this._timeRange.resetDts(e)}},{key:"_doPlay",value:function(){this.noAudio||this._parent.seeking||(this._source||!this.currentTime?this.resume():this._startRender())}},{key:"_doPause",value:function(){this.noAudio||this._audioCtx.suspend()}},{key:"_reInitAudioCtx",value:function(e){var t=this;if(this._lastTimeLineTime=e,this._lastBuffer=null,this._lastAudioBufferInfo=null,this._delay=0,!this._ready||!this._audioCtx.currentTime)return Promise.resolve();var i=this._gainNode.gain.value;return this._audioCtx.close().then((function(){return t._audioCtx.removeEventListener("statechange",t._onStateChange),t._audioCtx=null,t._source&&t._source.removeEventListener("ended",t._onSourceBufferEnded),t._source=null,t._initAudioCtx(i)}))}},{key:"_doSeek",value:function(e){var t=this;this._reInitAudioCtx(e).then((function(){t._getAudioBuffer(!0)})).catch((function(e){}))}},{key:"_doChaseFrame",value:function(e){var t=this,i=e.position,n=this._timeRange.deletePassed(i);n&&(V.log(this.TAG,"_doChaseFrame","startTime:",n.start,"buffeLength:",this.buffered.end(0)-n.start),this._reInitAudioCtx(n.start).then((function(){t._startRender(),t._emitTimelineEvents(ie.PLAY_EVENT,q.TIMEUPDATE)})).catch((function(e){})))}},{key:"_decodeAACWrapper",value:(n=r(i().mark((function e(){var t,n,r,s,a,o,u,A,d,c;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._sampleQueue.length,n=this._sampleQueue[0],r=this._sampleQueue[t-1],!((s=(r.dts-n.dts)/this.timescale)<1)){e.next=6;break}return e.abrupt("return");case 6:for(a=parseInt(s/3-1)||1,o=parseInt(t/a),u=[],A=0;A<a;A++)A<a-1?u.push(this._sampleQueue.slice(A*o,(A+1)*o)):u.push(this._sampleQueue.slice(A*o));return this._sampleQueue=[],this._inDecoding=!0,e.prev=12,e.next=15,this._decodeCycle(u);case 15:this._isLive||(d=this._timeRange._buffers,(c=d[d.length-1])&&this._emitTimelineEvents(ie.UPDATE_SEGMENT_END,c.end)),e.next=21;break;case 18:e.prev=18,e.t0=e.catch(12),this._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,this._assembleErr("ERROR_MSG.DECODE_ERR:".concat(e.t0&&e.t0.message)));case 21:this._inDecoding=!1;case 22:case"end":return e.stop()}}),e,this,[[12,18]])}))),function(){return n.apply(this,arguments)})},{key:"_decodeCycle",value:(t=r(i().mark((function e(t){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.shift()){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,this._decodeAAC(n);case 5:return e.next=7,this._decodeCycle(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_decodeAAC",value:function(e){var t=this,i=e[0],n=0;Ae.checkRefillFrame(e);var r=e.map((function(e){return Ae.packageAACToAdts(t._meta,e)})),s=Ae.concatAdts(r,0);return new Promise((function(e,r){var a=t._audioCtx.decodeAudioData(s.buffer,(function(r){if(t._timeRange){if(t._lastAudioBufferInfo&&t.isLive){var s=t._lastAudioBufferInfo,a=s.dts+s.duration;(n=i.dts-a)>1&&(t._timeRange._duration+=n/1e3,V.log(t.TAG,"_decodeAAC","audio data dts is not continue, last end dts:",a,",now start Dts:",i.dts,"delay:",n))}t._lastAudioBufferInfo={duration:Math.floor(1e3*r.duration),dts:i.dts};var o=t._timeRange.append(r,r.duration,i.dts,n/1e3);if(!t._ready){var u=Math.abs(o+r.duration-t.currentTime)<.5;(t.isLive||!u)&&(t._ready=!0,V.log(t.TAG,"_decodeAAC","set ready true start=",o),t.emit(ee.AUDIO_READY,o))}t._emitTimelineEvents(ie.PLAY_EVENT,q.PROGRESS),t._emitTimelineEvents(ie.PLAY_EVENT,q.DURATION_CHANGE),e()}}),r);a.catch&&a.catch(r)}))}},{key:"_decodeG711",value:function(){var e=this._sampleQueue.length,t=this._sampleQueue[0];if(!((this._sampleQueue[e-1].dts-t.dts)/this.timescale<.5)){var i=this._sampleQueue.reduce((function(e,t){return e+=t.data.byteLength}),0),n=new Uint8Array(i),r=0,s=0;this._sampleQueue.forEach((function(e,t){0===t&&(r=e.dts),n.set(e.data,s),s+=e.data.byteLength})),this._sampleQueue=[];try{var a=this._meta,o=a.codecType,u=a.channelCount,A=a.sampleSize,d=a.sampleRate,c=Ae.decodeG711(n,o),h=Ae.createAudioBufferFromPcm(this._audioCtx,c.buffer,u,d,A/8),l=h.audioBuffer,f=h.duration,m=this._timeRange.append(l,f,r,0);this._ready||(this._ready=!0,V.log(this.TAG,"_decodeG711","set ready true"),this.emit(ee.AUDIO_READY,m)),this._emitTimelineEvents(ie.PLAY_EVENT,q.PROGRESS),this._emitTimelineEvents(ie.PLAY_EVENT,q.DURATION_CHANGE)}catch(vn){this._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,this._assembleErr("ERROR_MSG.DECODE_ERR:".concat(vn&&vn.message)))}}}},{key:"_onSourceBufferEnded",value:function(){this._isSourceBufferEnd=!0,V.long&&V.log(this.TAG,"source play end! currentTime:".concat(this.currentTime," , duration:").concat(this.duration)),this._startRender()}},{key:"_ajustSeekTime",value:function(e){var t=this._timeRange.getBuffer(e,0);t&&(V.log(this.TAG,"ajust seek time to:",t.start),this._lastTimeLineTime=t.start)}},{key:"_getAudioBuffer",value:function(e){var t=this;if(this._timeRange){var i=this._timeRange.getBuffer(this._lastBuffer?this._lastBuffer.end:this.currentTime,0);return i?e?(this._ajustSeekTime(i.start),void this.emit(ee.AUDIO_READY)):i:(this._endOfStream||!this._isLive)&&this.currentTime-this.duration>-.5?(this._emitTimelineEvents(ie.PLAY_EVENT,q.TIMEUPDATE),void this._emitTimelineEvents(ie.PLAY_EVENT,q.ENDED)):(this._ready=!1,this._audioCtx.suspend(),this.emit(ee.AUDIO_WAITING),void(e&&(this._onAudioReady||(this._onAudioReady=function(e){t._ajustSeekTime(e)}),this.removeListener(ee.AUDIO_READY,this._onAudioReady),this.once(ee.AUDIO_READY,this._onAudioReady))))}}},{key:"_startRender",value:function(e){if(!this.noAudio){if("video"===e&&this.isLive&&this._ready&&!this._isSourceBufferEnd)return console.log(this.TAG,"_startRender, audio currentTime",this.currentTime,"from:",e,"_isSourceBufferEnd:",this._isSourceBufferEnd,"ready:",this._ready),void this._doPlay();var t=this._getAudioBuffer();if(t){"suspended"===this._audioCtx.state&&(this._audioCtx.resume().catch((function(e){})),C()),this._lastBuffer=t,this._source=null;var i=this._audioCtx.createBufferSource();i.buffer=t.source,i.loop=!1,this._source=i,i.addEventListener("ended",this._onSourceBufferEnded),i.connect(this._gainNode),t.delay&&t.delay>.001&&(this._delay+=t.delay),this.startDts=t.startDts;try{this._isSourceBufferEnd=!1,i.start()}catch(vn){}t.startDts&&this._emitTimelineEvents(ie.SYNC_DTS,t.startDts)}}}},{key:"_destroy",value:function(){V.log(this.TAG,"destroy audio..."),this._source&&this._source.removeEventListener("ended",this._onSourceBufferEnded),this._audioCtx&&"closed"!==this.ctxState&&this._audioCtx.close(),this._audioCtx=null,this._sampleQueue=null,this._timeRange=null,this._parent=null,this.removeAllListeners()}}]),c}(re),he="video",le="audio",fe="metadata",me="avc",_e="hevc",pe="aac",ve="g7110a",ye="g7110m",ge="LARGE_AV_SHIFT",be="LARGE_VIDEO_GAP",ke="LARGE_VIDEO_GAP_BETWEEN_CHUNK",Ee="LARGE_AUDIO_GAP",De="AUDIO_FILLED",Te="AUDIO_DROPPED",Re=function(){function e(){s(this,e),u(this,"id",1),u(this,"type",he),u(this,"codecType",me),u(this,"pid",-1),u(this,"hvcC",void 0),u(this,"codec",""),u(this,"timescale",0),u(this,"formatTimescale",0),u(this,"sequenceNumber",0),u(this,"baseMediaDecodeTime",0),u(this,"baseDts",0),u(this,"duration",0),u(this,"warnings",[]),u(this,"samples",[]),u(this,"pps",[]),u(this,"sps",[]),u(this,"vps",[]),u(this,"fpsNum",0),u(this,"fpsDen",0),u(this,"sarRatio",[]),u(this,"width",0),u(this,"height",0),u(this,"nalUnitSize",4),u(this,"present",!1),u(this,"isVideoEncryption",!1),u(this,"isAudioEncryption",!1),u(this,"isVideo",!0),u(this,"kid",null),u(this,"pssh",null),u(this,"ext",void 0)}return o(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}(),Se=function(){function e(){s(this,e),u(this,"id",2),u(this,"type",le),u(this,"codecType",pe),u(this,"pid",-1),u(this,"codec",""),u(this,"sequenceNumber",0),u(this,"sampleDuration",0),u(this,"timescale",0),u(this,"formatTimescale",0),u(this,"baseMediaDecodeTime",0),u(this,"duration",0),u(this,"warnings",[]),u(this,"samples",[]),u(this,"baseDts",0),u(this,"sampleSize",16),u(this,"sampleRate",0),u(this,"channelCount",0),u(this,"objectType",0),u(this,"sampleRateIndex",0),u(this,"config",[]),u(this,"present",!1),u(this,"isVideoEncryption",!1),u(this,"isAudioEncryption",!1),u(this,"kid",null),u(this,"ext",void 0)}return o(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}(),we=function(){function e(t,i,n){s(this,e),u(this,"flag",{}),u(this,"keyframe",!1),u(this,"gopId",0),u(this,"duration",0),u(this,"size",0),u(this,"units",[]),u(this,"chromaFormat",420),this.originPts=this.pts=t,this.originDts=this.dts=i,n&&(this.units=n)}return o(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}(),Ce=o((function e(t,i,n,r){s(this,e),u(this,"duration",1024),u(this,"flag",{dependsOn:2,isNonSyncSample:0}),u(this,"keyframe",!0),this.originPts=this.pts=this.dts=t,this.data=i,this.size=i.byteLength,this.sampleOffset=r,n&&(this.duration=n)})),Ve=o((function e(t,i){s(this,e),u(this,"time",0),this.data=t,this.originPts=this.pts=i})),Ie=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i)}(Ve),Ge=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i)}(Ve),Le=function(){function e(){s(this,e),u(this,"id",3),u(this,"type",fe),u(this,"timescale",0),u(this,"flvScriptSamples",[]),u(this,"seiSamples",[])}return o(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),u(this,"_bytesAvailable",void 0),u(this,"_bitsAvailable",0),u(this,"_word",0),!t)throw new Error("ExpGolomb data params is required");this._data=t,this._bytesAvailable=t.byteLength,this._bytesAvailable&&this._loadWord()}return o(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 i=new Uint8Array(4);i.set(this._data.subarray(e,e+t)),this._word=new DataView(i.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),i=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?i<<t|this.readBits(t):i}},{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,i=8,n=0;n<e;n++)0!==i&&(i=(t+this.readEG()+256)%256),t=0===i?t:i}}]),e}(),Fe=function(){function e(t){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return o(e,[{key:"warn",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(t=console).warn.apply(t,[this._prefix].concat(n))}}}],[{key:"enable",value:function(){e.disabled=!1}},{key:"disable",value:function(){e.disabled=!0}}]),e}();u(Fe,"disabled",!0);var xe=function(){function e(){s(this,e)}return o(e,null,[{key:"decode",value:function(t){for(var i=[],n=t,r=0,s=t.length;r<s;)if(n[r]<128)i.push(String.fromCharCode(n[r])),++r;else{if(n[r]<192);else if(n[r]<224){if(e._checkContinuation(n,r,1)){var a=(31&n[r])<<6|63&n[r+1];if(a>=128){i.push(String.fromCharCode(65535&a)),r+=2;continue}}}else if(n[r]<240){if(e._checkContinuation(n,r,2)){var o=(15&n[r])<<12|(63&n[r+1])<<6|63&n[r+2];if(o>=2048&&55296!=(63488&o)){i.push(String.fromCharCode(65535&o)),r+=3;continue}}}else if(n[r]<248&&e._checkContinuation(n,r,3)){var u=(7&n[r])<<18|(63&n[r+1])<<12|(63&n[r+2])<<6|63&n[r+3];if(u>65536&&u<1114112){u-=65536,i.push(String.fromCharCode(u>>>10|55296)),i.push(String.fromCharCode(1023&u|56320)),r+=4;continue}}i.push(String.fromCharCode(65533)),++r}return i.join("")}},{key:"_checkContinuation",value:function(e,t,i){var n=e;if(t+i<n.length){for(;i--;)if(128!=(192&n[++t]))return!1;return!0}return!1}}]),e}(),Be="undefined"!=typeof window,Ue=Be&&navigator.userAgent.toLocaleLowerCase(),Ne=Be&&/^((?!chrome|android).)*safari/.test(Ue),Pe=Be&&Ue.includes("firefox"),Oe=Be&&Ue.includes("android");function We(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t=t.filter(Boolean);var n=new Uint8Array(t.reduce((function(e,t){return e+t.byteLength}),0)),r=0;return t.forEach((function(e){n.set(e,r),r+=e.byteLength})),n}function je(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 Ye(e){for(var t,i="avc1.",n=0;n<3;n++)(t=e[n].toString(16)).length<2&&(t="0".concat(t)),i+=t;return i}function Me(e){if(!Array.isArray(e)){for(var t=[],i="",n=0;n<e.length;n++)n%2&&(i=e[n-1]+e[n],t.push(parseInt(i,16)),i="");return t}return e.map((function(e){return parseInt(e,16)}))}var Xe=function(){function e(){s(this,e)}return o(e,null,[{key:"parseAnnexB",value:function(e){for(var t=e.length,i=2,n=0;null!==e[i]&&void 0!==e[i]&&1!==e[i];)i++;if((n=++i+2)>=t)return[];for(var r=[];n<t;)switch(e[n]){case 0:if(0!==e[n-1]){n+=2;break}if(0!==e[n-2]){n++;break}i!==n-2&&r.push(e.subarray(i,n-2));do{n++}while(1!==e[n]&&n<t);n=(i=n+1)+2;break;case 1:if(0!==e[n-1]||0!==e[n-2]){n+=3;break}i!==n-2&&r.push(e.subarray(i,n-2)),n=(i=n+1)+2;break;default:n+=3}return i<t&&r.push(e.subarray(i)),r}},{key:"parseAvcC",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;if(!(e.length<4)){for(var i,n=e.length,r=[],s=0;s+t<n;)if(i=je(e,s),3===t&&(i>>>=8),s+=t,i){if(s+i>n)break;r.push(e.subarray(s,s+i)),s+=i}return r}}},{key:"parseSEI",value:function(e,t){for(var i=e.length,n=t?2:1,r=0,s=0,a="";255===e[n];)r+=255,n++;for(r+=e[n++];255===e[n];)s+=255,n++;if(s+=e[n++],5===r&&i>n+16)for(var o=0;o<16;o++)a+=e[n].toString(16),n++;return{payload:e.subarray(n),type:r,size:s,uuid:a}}},{key:"removeEPB",value:function(e){for(var t=e.byteLength,i=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(i.push(n+2),n+=2):n++;if(!i.length)return e;var r=t-i.length,s=new Uint8Array(r),a=0;for(n=0;n<r;a++,n++)a===i[0]&&(a++,i.shift()),s[n]=e[a];return s}}]),e}(),Qe=function(){function e(){s(this,e)}return o(e,null,[{key:"parseAVCDecoderConfigurationRecord",value:function(t){if(!(t.length<7)){for(var i,n,r=1+(3&t[4]),s=[],a=[],o=6,u=31&t[5],A=0;A<u;A++)if(n=t[o]<<8|t[o+1],o+=2,n){var d=t.subarray(o,o+n);o+=n,s.push(d),i||(i=e.parseSPS(Xe.removeEPB(d)))}var c,h=t[o];o++;for(var l=0;l<h;l++)c=t[o]<<8|t[o+1],o+=2,c&&(a.push(t.subarray(o,o+c)),o+=c);return{sps:i,spsArr:s,ppsArr:a,nalUnitSize:r}}}},{key:"parseSPS",value:function(e){var t=new Ze(e);t.readUByte();var i=t.readUByte(),n=t.readUByte(),r=t.readUByte();t.skipUEG();var s=420;if(100===i||110===i||122===i||244===i||44===i||83===i||86===i||118===i||128===i||138===i||144===i){var a=t.readUEG();if(a<=3&&(s=[0,420,422,444][a]),3===a&&t.skipBits(1),t.skipUEG(),t.skipUEG(),t.skipBits(1),t.readBool())for(var o=3!==a?8:12,u=0;u<o;u++)t.readBool()&&(u<6?t.skipScalingList(16):t.skipScalingList(64))}t.skipUEG();var A=t.readUEG();if(0===A)t.readUEG();else if(1===A){t.skipBits(1),t.skipUEG(),t.skipUEG();for(var d=t.readUEG(),c=0;c<d;c++)t.skipUEG()}t.skipUEG(),t.skipBits(1);var h=t.readUEG(),l=t.readUEG(),f=t.readBits(1);0===f&&t.skipBits(1),t.skipBits(1);var m,_,p,v,y,g=0,b=0,k=0,E=0;if(t.readBool()&&(g=t.readUEG(),b=t.readUEG(),k=t.readUEG(),E=t.readUEG()),t.readBool()){if(t.readBool())switch(t.readUByte()){case 1:m=[1,1];break;case 2:m=[12,11];break;case 3:m=[10,11];break;case 4:m=[16,11];break;case 5:m=[40,33];break;case 6:m=[24,11];break;case 7:m=[20,11];break;case 8:m=[32,11];break;case 9:m=[80,33];break;case 10:m=[18,11];break;case 11:m=[15,11];break;case 12:m=[64,33];break;case 13:m=[160,99];break;case 14:m=[4,3];break;case 15:m=[3,2];break;case 16:m=[2,1];break;case 255:m=[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 D=t.readBits(32),T=t.readBits(32);_=t.readBool(),y=(p=T)/(v=2*D)}}return{codec:Ye(e.subarray(1,4)),profileIdc:i,profileCompatibility:n,levelIdc:r,chromaFormat:s,width:Math.ceil(16*(h+1)-2*(g+b)),height:(2-f)*(l+1)*16-(f?2:4)*(k+E),sarRatio:m,fpsNum:p,fpsDen:v,fps:y,fixedFrame:_}}}]),e}(),Je=function(){function e(){s(this,e)}return o(e,null,[{key:"getRateIndexByRate",value:function(t){return e.FREQ.indexOf(t)}},{key:"parseADTS",value:function(t,i){for(var n=t.length,r=0;r+2<n&&(255!==t[r]||240!=(246&t[r+1]));)r++;if(!(r>=n)){var s=r,a=[],o=(60&t[r+2])>>>2,u=e.FREQ[o];if(!u)throw new Error("Invalid sampling index: ".concat(o));for(var A,d,c=1+((192&t[r+2])>>>6),h=(1&t[r+2])<<2|(192&t[r+3])>>>6,l=e._getConfig(o,h,c),f=l.config,m=l.codec,_=0,p=e.getFrameDuration(u);r+7<n;)if(255===t[r]&&240==(246&t[r+1])){if(n-r<(d=(3&t[r+3])<<11|t[r+4]<<3|(224&t[r+5])>>5))break;A=2*(1&~t[r+1]),a.push({pts:i+_*p,data:t.subarray(r+7+A,r+d)}),_++,r+=d}else r++;return{skip:s,remaining:r>=n?void 0:t.subarray(r),frames:a,samplingFrequencyIndex:o,sampleRate:u,objectType:c,channelCount:h,codec:m,config:f,originCodec:"mp4a.40.".concat(c)}}}},{key:"parseAudioSpecificConfig",value:function(t){if(t.length){var i=t[0]>>>3,n=(7&t[0])<<1|t[1]>>>7,r=(120&t[1])>>>3,s=e.FREQ[n];if(s){var a=e._getConfig(n,r,i);return{samplingFrequencyIndex:n,sampleRate:s,objectType:i,channelCount:r,config:a.config,codec:a.codec,originCodec:"mp4a.40.".concat(i)}}}}},{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,i){var n,r,s=[];return Pe?e>=6?(n=5,r=e-3):(n=2,r=e):Oe?(n=2,r=e):(n=2===i||5===i?i:5,r=e,e>=6?r=e-3:1===t&&(n=2,r=e)),s[0]=n<<3,s[0]|=(14&e)>>1,s[1]=(1&e)<<7,s[1]|=t<<3,5===n&&(s[1]|=(14&r)>>1,s[2]=(1&r)<<7,s[2]|=8,s[3]=0),{config:s,codec:"mp4a.40.".concat(n)}}},{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}]),e}();u(Je,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var He=function(){function e(){s(this,e)}return o(e,null,[{key:"parseHEVCDecoderConfigurationRecord",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(t.length<23)){i=i||{};for(var n,r,s,a,o,u=1+(3&t[21]),A=[],d=[],c=[],h=23,l=t[22],f=0;f<l;f++){s=63&t[h],a=t[h+1]<<8|t[h+2],h+=3;for(var m=0;m<a;m++)if(o=t[h]<<8|t[h+1],h+=2,o){switch(s){case 32:var _=t.subarray(h,h+o);n||(n=e.parseVPS(Xe.removeEPB(_),i)),c.push(_);break;case 33:var p=t.subarray(h,h+o);r||(r=e.parseSPS(Xe.removeEPB(p),i)),A.push(p);break;case 34:d.push(t.subarray(h,h+o))}h+=o}}return{hvcC:i,sps:r,spsArr:A,ppsArr:d,vpsArr:c,nalUnitSize:u}}}},{key:"parseVPS",value:function(t,i){i=i||{};var n=new Ze(t);n.readUByte(),n.readUByte(),n.readBits(12);var r=n.readBits(3);return i.numTemporalLayers=Math.max(i.numTemporalLayers||0,r+1),n.readBits(17),e._parseProfileTierLevel(n,r,i),i}},{key:"parseSPS",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i=i||{};var n=new Ze(t);n.readUByte(),n.readUByte(),n.readBits(4);var r=n.readBits(3);i.numTemporalLayers=Math.max(r+1,i.numTemporalLayers||0),i.temporalIdNested=n.readBits(1),e._parseProfileTierLevel(n,r,i),n.readUEG();var s=i.chromaFormatIdc=n.readUEG(),a=420;s<=3&&(a=[0,420,422,444][s]);var o=0;3===s&&(o=n.readBits(1));var u,A,d,c,h=n.readUEG(),l=n.readUEG(),f=n.readBits(1);if(1===f&&(u=n.readUEG(),A=n.readUEG(),d=n.readUEG(),c=n.readUEG()),i.bitDepthLumaMinus8=n.readUEG(),i.bitDepthChromaMinus8=n.readUEG(),1===f){var m=1!==s&&2!==s||0!==o?1:2,_=1===s&&0===o?2:1;h-=m*(A+u),l-=_*(c+d)}return{codec:"hev1.1.6.L93.B0",width:h,height:l,chromaFormat:a,hvcC:i}}},{key:"_parseProfileTierLevel",value:function(e,t,i){var n=i.generalTierFlag||0;i.generalProfileSpace=e.readBits(2),i.generalTierFlag=Math.max(e.readBits(1),n),i.generalProfileIdc=Math.max(e.readBits(5),i.generalProfileIdc||0),i.generalProfileCompatibilityFlags=e.readBits(32),i.generalConstraintIndicatorFlags=[e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8),e.readBits(8)];var r=e.readBits(8);n<i.generalTierFlag?i.generalLevelIdc=r:i.generalLevelIdc=Math.max(r,i.generalLevelIdc||0);for(var s=[],a=[],o=0;o<t;o++)s[o]=e.readBits(1),a[o]=e.readBits(1);t>0&&e.readBits(2*(8-t));for(var u=0;u<t;u++)0!==s[u]&&(e.readBits(2),e.readBits(1),e.readBits(5),e.readBits(16),e.readBits(16),e.readBits(4),e.readBits(16),e.readBits(16),e.readBits(12)),0!==a[u]&&e.readBits(8)}}]),e}(),Ke=1e3,ze=5e3,qe=function(){function e(t,i,n){s(this,e),this.videoTrack=t,this.audioTrack=i,this.metadataTrack=n,this._baseDts=-1,this._baseDtsInited=!1,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}return o(e,[{key:"fix",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,i=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 r=this.videoTrack,s=this.audioTrack;!i&&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),i&&!n&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(s,r),!n&&t&&(this._audioNextPts=this._videoNextDts=t);var a=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(a&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(s),this._fixVideo(r),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}))}r.samples.length&&(r.baseMediaDecodeTime=r.samples[0].dts),s.samples.length&&(s.baseMediaDecodeTime=s.samples[0].pts*s.timescale/1e3)}},{key:"_fixVideo",value:function(e){var t=this,i=e.samples;if(i.length){var n;if(i.forEach((function(e){e.dts-=t._baseDts,e.pts-=t._baseDts})),e.fpsNum&&e.fpsDen)n=e.timescale*(e.fpsDen/e.fpsNum);else{var r=e.samples[0],s=e.samples[i.length-1];n=Math.floor((s.dts-r.dts)/(i.length-1))}var a=i.pop();if(this._videoLastSample&&i.unshift(this._videoLastSample),this._videoLastSample=a,i.length){if(void 0===this._videoNextDts){var o=i[0];this._videoNextDts=o.dts}var u=i.length,A=0,d=i[0],c=this._videoNextDts-d.dts;if(Math.abs(c)>200){var h;if(Math.abs(d.dts-this._lastVideoExceptionChunkFirstDtsDot)>5e3)this._lastVideoExceptionChunkFirstDtsDot=d.dts,e.warnings.push({type:ke,nextDts:this._videoNextDts,firstSampleDts:d.dts,nextSampleDts:null===(h=i[1])||void 0===h?void 0:h.dts,sampleDuration:c});this._videoTimestampBreak>=5?(this._videoNextDts=d.dts,this._videoTimestampBreak=0):(d.dts+=c,d.pts+=c,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var l=0;l<u;l++){var f=i[l].dts,m=i[l+1];((A=l<u-1?m.dts-f:a?a.dts-f:n)>1e3||A<0)&&(this._videoTimestampBreak++,Math.abs(f-this._lastVideoExceptionLargeGapDot)>5e3&&(this._lastVideoExceptionLargeGapDot=f,e.warnings.push({type:be,time:f/e.timescale,dts:f,originDts:i[l].originDts,nextDts:this._videoNextDts,sampleDuration:A,refSampleDuration:n})),A=n),i[l].duration=A,this._videoNextDts+=A}}}}},{key:"_fixAudio",value:function(e){var t=this,i=e.samples;i.length&&(i.forEach((function(e){e.dts=e.pts-=t._baseDts})),this._doFixAudioInternal(e,i,1e3))}},{key:"_calculateBaseDts",value:function(e,t){var i=e.samples,n=t.samples;if(!i.length&&!n.length)return!1;var r=1/0,s=1/0;i.length&&(e.baseDts=r=i[0].pts),n.length&&(t.baseDts=s=n[0].dts),this._baseDts=Math.min(r,s);var a=s-r;return Number.isFinite(a)&&Math.abs(a)>500&&t.warnings.push({type:ge,videoBaseDts:s,audioBasePts:r,baseDts:this._baseDts,delta:a}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){this._calculateBaseDts(this.audioTrack,this.videoTrack)&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoLastSample=null,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(e,t,i){e.sampleDuration||(e.sampleDuration=e.codecType===pe?Je.getFrameDuration(e.timescale,i):this._getG711Duration(e));var n=e.sampleDuration,r=e.codecType===pe?1024:n*e.timescale/1e3;if(void 0===this._audioNextPts){var s=t[0];this._audioNextPts=s.pts}for(var a=0;a<t.length;a++){var o=this._audioNextPts,u=t[a],A=u.pts-o;if(0===a&&this._audioTimestampBreak>=5&&(o=this._audioNextPts=u.dts,A=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&A>=3*n&&A<=Ke&&!Ne){var d=this._getSilentFrame(e)||t[0].data.subarray(),c=Math.floor(A/n);Math.abs(u.pts-this._lastAudioExceptionGapDot)>ze&&(this._lastAudioExceptionGapDot=u.pts,e.warnings.push({type:De,pts:u.pts,originPts:u.originPts,count:c,nextPts:o,refSampleDuration:n}));for(var h=0;h<c;h++){var l=new Ce(Math.floor(this._audioNextPts+n)-Math.floor(this._audioNextPts),d,r);l.originPts=Math.floor(this._baseDts+o),t.splice(a,0,l),this._audioNextPts+=n,a++}a--}else A<=-3*n&&A>=-1e3?(Math.abs(u.pts-this._lastAudioExceptionOverlapDot)>ze&&(this._lastAudioExceptionOverlapDot=u.pts,e.warnings.push({type:Te,pts:u.pts,originPts:u.originPts,nextPts:o,refSampleDuration:n})),t.splice(a,1),a--):(Math.abs(A)>Ke&&(this._audioTimestampBreak++,Math.abs(u.pts-this._lastAudioExceptionLargeGapDot)>ze&&(this._lastAudioExceptionLargeGapDot=u.pts,e.warnings.push({type:Ee,time:u.pts/1e3,pts:u.pts,originPts:u.originPts,nextPts:o,sampleDuration:A,refSampleDuration:n}))),u.dts=u.pts=o,u.duration=r,this._audioNextPts+=n)}}},{key:"_getG711Duration",value:function(e){var t=e.sampleSize,i=e.channelCount,n=e.sampleRate,r=e.samples[0];if(r)return 2*r.data.byteLength/i/(t/8)/n*1e3}},{key:"_getSilentFrame",value:function(e){return e.codecType===pe?Je.getSilentFrame(e.codec,e.channelCount):new Uint8Array(8*e.sampleDuration*e.channelCount)}}]),e}(),$e=function(){function e(){s(this,e)}return o(e,null,[{key:"parse",value:function(t){if(!(t.length<3)){var i={},n=e._parseValue(new DataView(t.buffer,t.byteOffset,t.byteLength)),r=e._parseValue(new DataView(t.buffer,t.byteOffset+n.size,t.byteLength-n.size));return i[n.data]=r.data,i}}},{key:"_parseValue",value:function(t){var i,n=t.byteLength,r=1,s=!1;switch(t.getUint8(0)){case 0:i=t.getFloat64(1),r+=8;break;case 1:i=!!t.getUint8(1),r+=1;break;case 2:var a=e._parseString(new DataView(t.buffer,t.byteOffset+r,t.byteLength-r));i=a.data,r+=a.size;break;case 3:i={};var o=0;for(9==(16777215&t.getUint32(n-4))&&(o=3);r<n-4;){var u=e._parseObject(new DataView(t.buffer,t.byteOffset+r,t.byteLength-r-o)),A=u.size,d=u.data;if(u.isEnd)break;i[d.name]=d.value,r+=A}if(r<=n-3)9===(16777215&t.getUint32(r-1))&&(r+=3);break;case 8:i={},r+=4;var c=0;for(9==(16777215&t.getUint32(n-4))&&(c=3);r<n-8;){var h=e._parseObject(new DataView(t.buffer,t.byteOffset+r,t.byteLength-r-c)),l=h.size,f=h.data;if(h.isEnd)break;i[f.name]=f.value,r+=l}if(r<=n-3)9===(16777215&t.getUint32(r-1))&&(r+=3);break;case 9:i=void 0,r=1,s=!0;break;case 10:i=[];var m=t.getUint32(1);r+=4;for(var _=0;_<m;_++){var p=e._parseValue(new DataView(t.buffer,t.byteOffset+r,t.byteLength-r)),v=p.data,y=p.size;i.push(v),r+=y}break;case 11:var g=t.getFloat64(r)+6e4*t.getInt16(r+8);i=new Date(g),r+=10;break;case 12:var b=t.getUint32(1);r+=4,i="",b>0&&(i=xe.decode(new Uint8Array(t.buffer,t.byteOffset+r,b))),r+=b;break;default:r=n}return{data:i,size:r,isEnd:s}}},{key:"_parseString",value:function(e){var t=e.getUint16(0),i="";return t>0&&(i=xe.decode(new Uint8Array(e.buffer,e.byteOffset+2,t))),{data:i,size:2+t}}},{key:"_parseObject",value:function(t){if(!(t.byteLength<3)){var i=e._parseString(t),n=e._parseValue(new DataView(t.buffer,t.byteOffset+i.size,t.byteLength-i.size));return{data:{name:i.data,value:n.data},size:i.size+n.size,isEnd:n.isEnd}}}}]),e}(),et=new Fe("FlvDemuxer"),tt=function(){function e(t,i,n){s(this,e),u(this,"_headerParsed",!1),u(this,"_remainingData",null),u(this,"_gopId",0),u(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=t||new Re,this.audioTrack=i||new Se,this.metadataTrack=n||new Le,this._fixer=new qe(this.videoTrack,this.audioTrack,this.metadataTrack)}return o(e,[{key:"demux",value:function(t){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=this.audioTrack,s=this.videoTrack,a=this.metadataTrack;if(!i&&n||(this._remainingData=null,this._headerParsed=!1),i?(s.reset(),r.reset(),a.reset()):(s.samples=[],r.samples=[],a.seiSamples=[],a.flvScriptSamples=[],s.warnings=[],r.warnings=[],this._remainingData&&(t=We(this._remainingData,t),this._remainingData=null)),!t.length)return{videoTrack:s,audioTrack:r,metadataTrack:a};var o=0;if(!this._headerParsed){if(!e.probe(t))throw new Error("Invalid flv file");r.present=(4&t[4])>>>2!=0,s.present=0!=(1&t[4]),this._headerParsed=!0,o=je(t,5)+4}for(var u,A,d,c,h,l=t.length;o+15<l&&(u=t[o],!(o+15+(A=t[o+1]<<16|t[o+2]<<8|t[o+3])>l));)d=(t[o+7]<<24>>>0)+(t[o+4]<<16)+(t[o+5]<<8)+t[o+6],o+=11,c=t.subarray(o,o+A),8===u?this._parseAudio(c,d):9===u?this._parseVideo(c,d):18===u?this._parseScript(c,d):et.warn("Invalid tag type: ".concat(u)),(h=je(t,o+=A))!==11+A&&et.warn("Invalid PrevTagSize ".concat(h," (").concat(11+A,")")),o+=4;return o<l&&(this._remainingData=t.subarray(o)),r.formatTimescale=s.formatTimescale=s.timescale=a.timescale=1e3,r.timescale=r.sampleRate||0,!r.exist()&&r.hasSample()&&r.reset(),!s.exist()&&s.hasSample()&&s.reset(),{videoTrack:s,audioTrack:r,metadataTrack:a}}},{key:"fix",value:function(e,t,i){return this._fixer.fix(e,t,i),{videoTrack:this.videoTrack,audioTrack:this.audioTrack,metadataTrack:this.metadataTrack}}},{key:"demuxAndFix",value:function(e,t,i,n){return this.demux(e,t,i),this.fix(n,t,i)}},{key:"_parseAudio",value:function(t,i){if(t.length){var n=(240&t[0])>>>4,r=this.audioTrack;if(10!==n&&7!==n&&8!==n)return et.warn("Unsupported sound format: ".concat(n)),void r.reset();if(10!==n){var s=(12&t[0])>>2,a=(2&t[0])>>1,o=1&t[0];r.sampleRate=e.AUDIO_RATE[s],r.sampleSize=a?16:8,r.channelCount=o+1}10===n?this._parseAac(t,i):this._parseG711(t,i,n)}}},{key:"_parseG711",value:function(e,t,i){var n=this.audioTrack;n.codecType=7===i?ve:ye,n.sampleRate=8e3,n.codec=n.codecType,n.samples.push(new Ce(t,e.subarray(1)))}},{key:"_parseAac",value:function(e,t){var i=this.audioTrack;if(i.codecType=pe,0===e[1]){var n=Je.parseAudioSpecificConfig(e.subarray(2));n?(i.codec=n.codec,i.channelCount=n.channelCount,i.sampleRate=n.sampleRate,i.config=n.config,i.objectType=n.objectType,i.sampleRateIndex=n.samplingFrequencyIndex):(i.reset(),et.warn("Cannot parse AudioSpecificConfig",e))}else if(1===e[1]){if(null==t)return;i.samples.push(new Ce(t,e.subarray(2)))}else et.warn("Unknown AACPacketType: ".concat(e[1]))}},{key:"_parseVideo",value:function(e,t){var i=this;if(!(e.length<6)){var n=(240&e[0])>>>4,r=15&e[0],s=this.videoTrack;if(7!==r&&12!==r)return s.reset(),void et.warn("Unsupported codecId: ".concat(r));var a=12===r;s.codecType=a?_e:me;var o=e[1],u=(e[2]<<16|e[3]<<8|e[4])<<8>>8;if(0===o){var A=e.subarray(5),d=a?He.parseHEVCDecoderConfigurationRecord(A):Qe.parseAVCDecoderConfigurationRecord(A);if(d){var c=d.hvcC,h=d.sps,l=d.ppsArr,f=d.spsArr,m=d.vpsArr,_=d.nalUnitSize;c&&(s.hvcC=s.hvcC||c),h&&(s.codec=h.codec,s.width=h.width,s.height=h.height,s.sarRatio=h.sarRatio,s.fpsNum=h.fpsNum,s.fpsDen=h.fpsDen),f.length&&(s.sps=f),l.length&&(s.pps=l),m&&m.length&&(s.vps=m),_&&(s.nalUnitSize=_)}else et.warn("Cannot parse ".concat(a?"HEVC":"AVC","DecoderConfigurationRecord"),e)}else if(1===o){var p=Xe.parseAvcC(e.subarray(5),s.nalUnitSize);if((p=this._checkAddMetaNalToUnits(a,p,s))&&p.length){var v=new we(t+u,t,p);1===n&&v.setToKeyframe(),s.samples.push(v),p.forEach((function(e){var n=a?e[0]>>>1&63:31&e[0];switch(n){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!a&&5!==n||a&&5===n)break;v.setToKeyframe();break;case 6:case 39:case 40:if(!a&&6!==n||a&&6===n)break;i.metadataTrack.seiSamples.push(new Ge(Xe.parseSEI(Xe.removeEPB(e),a),t+u))}})),v.keyframe&&this._gopId++,v.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,i){return e&&this._needAddMetaBeforeKeyFrameNal?t.map((function(e){return e[0]>>>1&63})).includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(i.pps[0]),t.unshift(i.sps[0]),t.unshift(i.vps[0]),t.filter(Boolean)):(this._needAddMetaBeforeKeyFrameNal=!1,t)}},{key:"_parseScript",value:function(e,t){this.metadataTrack.flvScriptSamples.push(new Ie($e.parse(e),t))}}],[{key:"probe",value:function(e){return 70===e[0]&&76===e[1]&&86===e[2]&&1===e[3]&&je(e,5)>=9}}]),e}();function it(e){for(var t=0,i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];n.forEach((function(e){t+=e.length}));var s=new e(t),a=0;return n.forEach((function(e){s.set(e,a),a+=e.length})),s}u(tt,"AUDIO_RATE",[5500,11e3,22e3,44e3]),new Fe("TsDemuxer");var nt=function(){function e(){s(this,e),this.buffer=new Uint8Array(0)}return o(e,[{key:"write",value:function(){for(var e=this,t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];i.forEach((function(t){t?e.buffer=it(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,st=function(){function e(){s(this,e)}return o(e,null,[{key:"box",value:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];var r=8+(i=i.filter(Boolean)).reduce((function(e,t){return e+t.byteLength}),0),s=new Uint8Array(r);s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4);var a=8;return i.forEach((function(e){s.set(e,a),a+=e.byteLength})),s}},{key:"ftyp",value:function(t){return t.find((function(e){return e.type===he&&e.codecType===_e}))?e.FTYPHEV1:e.FTYPAVC1}},{key:"initSegment",value:function(t){return We(e.ftyp(t),e.moov(t))}},{key:"pssh",value:function(t){var i=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],Me(t.kid),[0,0,0,0]));return e.box(e.types.pssh,i)}},{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 i=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(b(t.map((function(t){return e.trak(t)}))),[i]))}return e.box.apply(e,[e.types.moov,e.mvhd(t[0].mvhdDurtion||t[0].duration,t[0].mvhdTimecale||t[0].timescale)].concat(b(t.map((function(t){return e.trak(t)}))),[e.mvex(t)]))}},{key:"mvhd",value:function(t){var i=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,i>>24&255,i>>16&255,i>>8&255,255&i,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,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,i>>24&255,i>>16&255,i>>8&255,255&i,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,r>>8&255,255&r,0,0]));return s}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.duration,t.timescale),e.hdlr(t.type),e.minf(t))}},{key:"mdhd",value:function(t){var i=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,i>>24&255,i>>16&255,i>>8&255,255&i,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===he?e.VMHD:e.SMHD,e.DINF,e.stbl(t))}},{key:"stbl",value:function(t){var i=[];return t&&t.ext&&t.ext.stss&&i.push(e.stss(t.ext.stss.entries)),e.box(e.types.stbl,e.stsd(t),e.STTS,i[0],e.STSC,e.STSZ,e.STCO)}},{key:"stsd",value:function(t){var i;return i="audio"===t.type?t.useEME&&t.enca?e.enca(t):e.mp4a(t):t.useEME&&t.encv?e.encv(t):e.avc1hev1(t),e.box(e.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),i)}},{key:"enca",value:function(t){var i=t.enca.channelCount,n=t.enca.sampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i,0,16,0,0,0,0,n>>8&255,255&n,0,0]),s=e.esds(t.config),a=e.sinf(t.enca);return e.box(e.types.enca,r,s,a)}},{key:"encv",value:function(t){var i,n,r=t.sps.length>0?t.sps[0]:[],s=t.pps.length>0?t.pps[0]:[],a=t.width,o=t.height,u=t.sarRatio[0],A=t.sarRatio[1],d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,o>>8&255,255&o,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),c=new Uint8Array((i=(n=[1,r[1],r[2],r[3],255,225,r.length>>>8&255,255&r.length]).concat.apply(n,b(r)).concat([1,s.length>>>8&255,255&s.length])).concat.apply(i,b(s))),h=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),l=e.sinf(t.encv),f=new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,A>>24,A>>16&255,A>>8&255,255&A]);return e.box(e.types.encv,d,e.box(e.types.avcC,c),e.box(e.types.btrt,h),l,e.box(e.types.pasp,f))}},{key:"schi",value:function(t){var i=new Uint8Array([]),n=e.tenc(t);return e.box(e.types.schi,i,n)}},{key:"tenc",value:function(t){var i=new Uint8Array([0,0,0,0,0,0,255&t.default_IsEncrypted,255&t.default_IV_size].concat(Me(t.default_KID)));return e.box(e.types.tenc,i)}},{key:"sinf",value:function(t){var i=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)]),r=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),s=e.schi(t);return e.box(e.types.sinf,i,e.box(e.types.frma,n),e.box(e.types.schm,r),s)}},{key:"avc1hev1",value:function(t){var i=t.codecType===_e,n=i?e.types.hvc1:e.types.avc1,r=i?e.hvcC(t):e.avcC(t),s=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,t.width>>8&255,255&t.width,t.height>>8&255,255&t.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),r];return i?s.push(e.box(e.types.fiel,new Uint8Array([1,0]))):t.sarRatio&&t.sarRatio.length>1&&s.push(e.pasp(t.sarRatio)),e.box.apply(e,[n].concat(s))}},{key:"avcC",value:function(t){var i,n,r,s=[],a=[];return t.sps.forEach((function(e){r=e.byteLength,s.push(r>>>8&255),s.push(255&r),s.push.apply(s,b(e))})),t.pps.forEach((function(e){r=e.byteLength,a.push(r>>>8&255),a.push(255&r),a.push.apply(a,b(e))})),e.box(e.types.avcC,new Uint8Array((i=(n=[1,s[3],s[4],s[5],255,224|t.sps.length]).concat.apply(n,s).concat([t.pps.length])).concat.apply(i,a)))}},{key:"hvcC",value:function(t){var i=t.hvcC;if(i instanceof ArrayBuffer||i instanceof Uint8Array)return i;var n,r=t.vps,s=t.sps,a=t.pps;if(i){var o=i.generalProfileCompatibilityFlags,u=i.generalConstraintIndicatorFlags,A=(r.length&&1)+(s.length&&1)+(a.length&&1);n=[1,i.generalProfileSpace<<6|i.generalTierFlag<<5|i.generalProfileIdc,o>>>24,o>>>16,o>>>8,o,u[0],u[1],u[2],u[3],u[4],u[5],i.generalLevelIdc,240,0,252,252|i.chromaFormatIdc,248|i.bitDepthLumaMinus8,248|i.bitDepthChromaMinus8,0,0,i.numTemporalLayers<<3|i.temporalIdNested<<2|3,A];var d=function(e){var t;n.push(e.length>>8,e.length),(t=n).push.apply(t,b(e))};r.length&&(n.push(160,0,r.length),r.forEach(d)),s.length&&(n.push(161,0,s.length),s.forEach(d)),a.length&&(n.push(162,0,a.length),a.forEach(d))}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 i=g(t,2),n=i[0],r=i[1];return e.box(e.types.pasp,new Uint8Array([n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r]))}},{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 i=t.length;return e.box(e.types.esds,new Uint8Array([0,0,0,0,3,23+i,0,0,0,4,15+i,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([i]).concat(t).concat([6,1,2])))}},{key:"mvex",value:function(t){return e.box.apply(e,[e.types.mvex].concat(b(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(b(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 i=e.tfhd(t.id),n=e.tfdt(t,t.baseMediaDecodeTime),r=0;if(t.isVideo&&t.videoSenc&&t.videoSenc.forEach((function(e){r+=8,e.subsamples&&e.subsamples.length&&(r+=2,r+=6*e.subsamples.length)})),t.videoSencLength=r,t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)){if(t.isVideoEncryption){if(t.isVideo){var s=e.saiz(t),a=e.saio(t),o=e.trun1(t),u=e.senc(t);return e.box(e.types.traf,i,n,s,a,o,u)}if(t.isAudioEncryption){var A=e.sbgp(),d=e.saiz(t),c=e.saio(t),h=e.senc(t),l=e.trun1(t);return e.box(e.types.traf,i,n,A,d,c,h,l)}var f=e.sbgp(),m=e.trun1(t);return e.box(e.types.traf,i,n,f,m)}if(t.isVideo){var _=e.trun1(t);return e.box(e.types.traf,i,n,_)}var p=e.sbgp(),v=e.saiz(t),y=e.saio(t),g=e.senc(t),b=e.trun1(t);return e.box(e.types.traf,i,n,p,v,y,g,b)}var k=e.sdtp(t);return e.box(e.types.traf,i,n,k,e.trun(t.samples,k.byteLength+76))}},{key:"sdtp",value:function(t){var i=new nt;return t.samples.forEach((function(e){i.write(new Uint8Array(t.isVideo?[e.keyframe?32:16]:[16]))})),e.box(e.types.sdtp,this.extension(0,0),i.buffer)}},{key:"trun1",value:function(t){var i=new nt,n=nt.writeUint32(t.samples.length),r=null;if(t.isVideo){var s=t.videoSencLength;r=nt.writeUint32(16*t.samples.length+s+149),!t.isVideoEncryption&&t.isAudioEncryption&&(r=nt.writeUint32(16*t.samples.length+92))}else{var a=12*t.samples.length+124;t.isAudioEncryption&&(a=12*t.samples.length+8*t.audioSenc.length+177),r=nt.writeUint32(a)}return t.samples.forEach((function(e){i.write(nt.writeUint32(e.duration)),i.write(nt.writeUint32(e.size)),i.write(nt.writeUint32(e.keyframe?33554432:65536)),t.isVideo&&i.write(nt.writeUint32(e.cts?e.cts:0))})),e.box(e.types.trun,this.extension(0,t.flags),n,r,i.buffer)}},{key:"senc",value:function(t){var i=new nt,n=t.samples.length,r=t.isVideo?16:8,s=t.isVideo?2:0,a=[],o=0;return t.isVideo?(a=t.videoSenc,o=t.videoSencLength):a=t.audioSenc,o=o||r*n,i.write(nt.writeUint32(16+o),e.types.senc,this.extension(0,s)),i.write(nt.writeUint32(n)),a.forEach((function(e){for(var t=0;t<e.InitializationVector.length;t++)i.write(new Uint8Array([e.InitializationVector[t]]));e.subsamples&&e.subsamples.length&&(i.write(nt.writeUint16(e.subsamples.length)),e.subsamples.forEach((function(e){i.write(nt.writeUint16(e.BytesOfClearData)),i.write(nt.writeUint32(e.BytesOfProtectedData))})))})),i.buffer}},{key:"saio",value:function(t){var i=12*t.samples.length+141;!t.isVideo&&t.isAudioEncryption&&(i=149);var n=new Uint8Array([1,0,0,0,0,0,0,1,0,0,0,0,i>>24&255,i>>16&255,i>>8&255,255&i]);return e.box(e.types.saio,n)}},{key:"saiz",value:function(t){var i=t.samples.length,n=new Uint8Array([0,0,0,0,16,i>>24&255,i>>16&255,i>>8&255,255&i]);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,i){var n=Math.floor(i/(rt+1)),r=Math.floor(i%(rt+1));return t.useEME&&(t.isVideoEncryption||t.isAudioEncryption)?e.box(e.types.tfdt,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])):e.box(e.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,r>>24,r>>16&255,r>>8&255,255&r]))}},{key:"trun",value:function(t,i){var n=t.length,r=12+16*n;i+=8+r;var s=new Uint8Array(r);s.set([0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0);for(var a=0;a<n;a++){var o=t[a],u=o.duration,A=o.size,d=o.flag,c=void 0===d?{}:d,h=o.cts,l=void 0===h?0:h;s.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,A>>>24&255,A>>>16&255,A>>>8&255,255&A,c.isLeading<<2|(null===c.dependsOn||void 0===c.dependsOn?1:c.dependsOn),c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|(null===c.isNonSyncSample||void 0===c.isNonSyncSample?1:c.isNonSyncSample),61440&c.degradationPriority,15&c.degradationPriority,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*a)}return e.box(e.types.trun,s)}},{key:"moovMP4",value:function(t){return e.box.apply(e,[e.types.moov,e.mvhd(t[0].duration,t[0].timescale)].concat(b(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===he?e.VMHD:e.SMHD,e.DINF,e.stblMP4(t))}},{key:"stblMP4",value:function(t){var i=t.ext,n=[e.stsd(t),e.stts(i.stts),e.stsc(i.stsc),e.stsz(i.stsz),e.stco(i.stco)];return i.stss.length&&n.push(e.stss(i.stss)),i.ctts.length&&n.push(e.ctts(i.ctts)),e.box.apply(e,[e.types.stbl].concat(n))}},{key:"stts",value:function(t){var i=t.length,n=new Uint8Array(8*i),r=0;return t.forEach((function(e){var t=e.value,i=e.count;n.set([i>>24,i>>16&255,i>>8&255,255&i,t>>24,t>>16&255,t>>8&255,255&t],r),r+=8})),e.box(e.types.stts,We(new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]),n))}},{key:"stsc",value:function(t){var i=t.length,n=new Uint8Array(12*i),r=0;return t.forEach((function(e){var t=e.firstChunk,i=e.samplesPerChunk,s=e.sampleDescIndex;n.set([t>>24,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s],r),r+=12})),e.box(e.types.stsc,We(new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]),n))}},{key:"stsz",value:function(t){var i=t.length,n=new Uint8Array(4*i),r=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],r),r+=4})),e.box(e.types.stsz,We(new Uint8Array([0,0,0,0,0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]),n))}},{key:"stco",value:function(t){var i=t.length,n=new Uint8Array(4*i),r=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],r),r+=4})),e.box(e.types.stco,We(new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]),n))}},{key:"stss",value:function(t){var i=t.length,n=new Uint8Array(4*i),r=0;return t.forEach((function(e){n.set([e>>24,e>>16&255,e>>8&255,255&e],r),r+=4})),e.box(e.types.stss,We(new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]),n))}},{key:"ctts",value:function(t){var i=t.length,n=new Uint8Array(8*i),r=0;return t.forEach((function(e){var t=e.value,i=e.count;n.set([i>>24,i>>16&255,i>>8&255,255&i,t>>24,t>>16&255,t>>8&255,255&t],r),r+=8})),e.box(e.types.ctts,We(new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]),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 i=t.timescale,n=t.samples[0].duration,r=n*t.samples.length,s=t.samples[0].sampleOffset*n,a=8;t.samples.forEach((function(e){a+=e.size}));var o=0;if(t.isVideo){var u,A=0;t.videoSenc&&(u=t.videoSenc),t.isVideo&&u.forEach((function(e){A+=8,e.subsamples&&e.subsamples.length&&(A+=2,A+=6*e.subsamples.length)})),t.videoSencLength=A,o=a+141+16*t.samples.length+A,t.useEME&&t.isAudioEncryption&&!t.isVideoEncryption&&(o=a+16*t.samples.length+84)}else o=a+116+12*t.samples.length,t.useEME&&t.isAudioEncryption&&(o=a+169+12*t.samples.length+8*t.audioSenc.length);var d=new Uint8Array([0,0,0,0,0,0,0,255&t.id,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s,0,0,0,0,0,0,0,1,0,o>>16&255,o>>8&255,255&o,r>>24&255,r>>16&255,r>>8&255,255&r,144,0,0,0]);return e.box(e.types.sidx,d)}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}}]),e}();u(st,"types",["avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce((function(e,t){return e[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)],e}),Object.create(null))),u(st,"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])}),u(st,"FTYPAVC1",st.box(st.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]))),u(st,"FTYPHEV1",st.box(st.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49]))),u(st,"DINF",st.box(st.types.dinf,st.box(st.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])))),u(st,"VMHD",st.box(st.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]))),u(st,"SMHD",st.box(st.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0]))),u(st,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0])),u(st,"STTS",st.box(st.types.stts,st.StblTable)),u(st,"STSC",st.box(st.types.stsc,st.StblTable)),u(st,"STSZ",st.box(st.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]))),u(st,"STCO",st.box(st.types.stco,st.StblTable));var at=function(){function e(t,i){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]"),e.disabled=i}return o(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(t=console).debug.apply(t,[this._prefix].concat(n))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(t=console).log.apply(t,[this._prefix].concat(n))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(t=console).warn.apply(t,[this._prefix].concat(n))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(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}();u(at,"disabled",!0);for(var ot=function(){function e(t,i,n){s(this,e),this.videoTrack=t,this.audioTrack=i;var r=/Chrome\/([^.]+)/.exec(navigator.userAgent);this.forceFirstIDR=r&&Number(r[1])<50,this.log=new at("FMP4Remuxer",!n||!n.openLog||!n.openLog)}return o(e,[{key:"remux",value:function(){var e,t,i,n,r,s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.videoTrack,u=this.audioTrack,A=o.exist(),d=u.exist(),c=[];return s&&(a&&a.initMerge?(A&&c.push(this.videoTrack),d&&c.push(this.audioTrack),i=st.initSegment(c)):(A&&(e=st.initSegment([this.videoTrack])),d&&(t=st.initSegment([this.audioTrack])))),A&&o.hasSample()&&(n=this._remuxVideo()),d&&u.hasSample()&&(r=this._remuxAudio()),o.samples=[],u.samples=[],{initSegment:i,videoInitSegment:e,audioInitSegment:t,videoSegment:n,audioSegment:r}}},{key:"_remuxVideo",value:function(){var e=this.videoTrack;this.forceFirstIDR&&(e.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=e.samples,i=0;t.forEach((function(e){i+=e.units.reduce((function(e,t){return e+t.byteLength}),0),i+=4*e.units.length}));for(var n,r=new Uint8Array(i),s=new DataView(r.buffer),a=function(e,i,a,o){o=t[e];var u=0;o.units.forEach((function(e){s.setUint32(a,e.byteLength),a+=4,r.set(e,a),a+=e.byteLength,u+=4+e.byteLength})),o.size=u,A=a,n=o},o=0,u=t.length,A=0;o<u;o++)a(o,0,A,n);var d=st.mdat(r);return We(st.moof([e]),d)}},{key:"_remuxAudio",value:function(){var e=this.audioTrack,t=new Uint8Array(e.samples.reduce((function(e,t){return e+t.size}),0));e.samples.reduce((function(e,i){return t.set(i.data,e),e+i.size}),0);var i=st.mdat(t);return We(st.moof([e]),i)}},{key:"reset",value:function(){this.videoTrack.reset(),this.audioTrack.reset()}}]),e}(),ut=function(){function e(){s(this,e)}return o(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),i=0;i<e;i++)t[i]=arguments[i];return l(this,t)}}]),e}(),At=function(e){A(i,e);var t=p(i);function i(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4*n.length;s(this,i),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=[],A=0;A<o;A+=1)u[A>>>2]|=a[A]<<24-A%4*8;e.words=u,e.sigBytes=o}else e.words=n,e.sigBytes=r;return e}return o(i,[{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:dt;return e.stringify(this)}},{key:"concat",value:function(e){var t=this.words,i=e.words,n=this.sigBytes,r=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<r;s+=1){var a=i[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=a<<24-(n+s)%4*8}else for(var o=0;o<r;o+=4)t[n+o>>>2]=i[o>>>2];return this.sigBytes+=r,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=y(d(i.prototype),"clone",this).call(this);return e.words=this.words.slice(0),e}}],[{key:"random",value:function(e){for(var t,n=[],r=function(e){var t=e,i=987654321,n=4294967295;return function(){var e=((i=36969*(65535&i)+(i>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return e/=4294967296,(e+=.5)*(Math.random()>.5?1:-1)}},s=0;s<e;s+=4){var a=r(4294967296*(t||Math.random()));t=987654071*a(),n.push(4294967296*a()|0)}return new i(n,e)}}]),i}(ut),dt={stringify:function(e){for(var t=e.words,i=e.sigBytes,n=[],r=0;r<i;r+=1){var s=t[r>>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,i=[],n=0;n<t;n+=2)i[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new At(i,t/2)}},ct=function(e){for(var t=e.length,i=[],n=0;n<t;n+=1)i[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new At(i,t)},ht=function(e){return ct(unescape(encodeURIComponent(e)))},lt=function(e){A(i,e);var t=p(i);function i(){var e;return s(this,i),(e=t.call(this))._minBufferSize=0,e}return o(i,[{key:"reset",value:function(){this._data=new At,this._nDataBytes=0}},{key:"_append",value:function(e){var t=e;"string"==typeof t&&(t=ht(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes}},{key:"_process",value:function(e){var t,i=this._data,n=this.blockSize,r=i.words,s=i.sigBytes,a=s/(4*n),o=(a=e?Math.ceil(a):Math.max((0|a)-this._minBufferSize,0))*n,u=Math.min(4*o,s);if(o){for(var A=0;A<o;A+=n)this._doProcessBlock(r,A);t=r.splice(0,o),i.sigBytes-=u}return new At(t,u)}},{key:"clone",value:function(){var e=y(d(i.prototype),"clone",this).call(this);return e._data=this._data.clone(),e}}]),i}(ut),ft=function(e){A(i,e);var t=p(i);function i(e){var n;return s(this,i),(n=t.call(this)).blockSize=16,n.cfg=Object.assign(new ut,e),n.reset(),n}return o(i,[{key:"reset",value:function(){y(d(i.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,i){return new e(i).finalize(t)}}},{key:"_createHmacHelper",value:function(e){return function(t,i){return new mt(e,i).finalize(t)}}}]),i}(lt),mt=function(e){A(i,e);var t=p(i);function i(e,n){var r;s(this,i),r=t.call(this);var a=new e;r._hasher=a;var o=n;"string"==typeof o&&(o=ht(o));var u=a.blockSize,A=4*u;o.sigBytes>A&&(o=a.finalize(n)),o.clamp();var d=o.clone();r._oKey=d;var c=o.clone();r._iKey=c;for(var h=d.words,l=c.words,f=0;f<u;f+=1)h[f]^=1549556828,l[f]^=909522486;return d.sigBytes=A,c.sigBytes=A,r.reset(),r}return o(i,[{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,i=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(i))}}]),i}(ut),_t={stringify:function(e){var t=e.words,i=e.sigBytes,n=this._map;e.clamp();for(var r=[],s=0;s<i;s+=3)for(var a=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,o=0;o<4&&s+.75*o<i;o+=1)r.push(n.charAt(a>>>6*(3-o)&63));var u=n.charAt(64);if(u)for(;r.length%4;)r.push(u);return r.join("")},parse:function(e){var t=e.length,i=this._map,n=this._reverseMap;if(!n){this._reverseMap=[],n=this._reverseMap;for(var r=0;r<i.length;r+=1)n[i.charCodeAt(r)]=r}var s=i.charAt(64);if(s){var a=e.indexOf(s);-1!==a&&(t=a)}return function(e,t,i){for(var n=[],r=0,s=0;s<t;s+=1)if(s%4){var a=i[e.charCodeAt(s-1)]<<s%4*2|i[e.charCodeAt(s)]>>>6-s%4*2;n[r>>>2]|=a<<24-r%4*8,r+=1}return At.create(n,r)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},pt=[],vt=0;vt<64;vt+=1)pt[vt]=4294967296*Math.abs(Math.sin(vt+1))|0;var yt=function(e,t,i,n,r,s,a){var o=e+(t&i|~t&n)+r+a;return(o<<s|o>>>32-s)+t},gt=function(e,t,i,n,r,s,a){var o=e+(t&n|i&~n)+r+a;return(o<<s|o>>>32-s)+t},bt=function(e,t,i,n,r,s,a){var o=e+(t^i^n)+r+a;return(o<<s|o>>>32-s)+t},kt=function(e,t,i,n,r,s,a){var o=e+(i^(t|~n))+r+a;return(o<<s|o>>>32-s)+t},Et=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i,[{key:"_doReset",value:function(){this._hash=new At([1732584193,4023233417,2562383102,271733878])}},{key:"_doProcessBlock",value:function(e,t){for(var i=e,n=0;n<16;n+=1){var r=t+n,s=e[r];i[r]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}var a=this._hash.words,o=i[t+0],u=i[t+1],A=i[t+2],d=i[t+3],c=i[t+4],h=i[t+5],l=i[t+6],f=i[t+7],m=i[t+8],_=i[t+9],p=i[t+10],v=i[t+11],y=i[t+12],g=i[t+13],b=i[t+14],k=i[t+15],E=a[0],D=a[1],T=a[2],R=a[3];E=yt(E,D,T,R,o,7,pt[0]),R=yt(R,E,D,T,u,12,pt[1]),T=yt(T,R,E,D,A,17,pt[2]),D=yt(D,T,R,E,d,22,pt[3]),E=yt(E,D,T,R,c,7,pt[4]),R=yt(R,E,D,T,h,12,pt[5]),T=yt(T,R,E,D,l,17,pt[6]),D=yt(D,T,R,E,f,22,pt[7]),E=yt(E,D,T,R,m,7,pt[8]),R=yt(R,E,D,T,_,12,pt[9]),T=yt(T,R,E,D,p,17,pt[10]),D=yt(D,T,R,E,v,22,pt[11]),E=yt(E,D,T,R,y,7,pt[12]),R=yt(R,E,D,T,g,12,pt[13]),T=yt(T,R,E,D,b,17,pt[14]),D=yt(D,T,R,E,k,22,pt[15]),E=gt(E,D,T,R,u,5,pt[16]),R=gt(R,E,D,T,l,9,pt[17]),T=gt(T,R,E,D,v,14,pt[18]),D=gt(D,T,R,E,o,20,pt[19]),E=gt(E,D,T,R,h,5,pt[20]),R=gt(R,E,D,T,p,9,pt[21]),T=gt(T,R,E,D,k,14,pt[22]),D=gt(D,T,R,E,c,20,pt[23]),E=gt(E,D,T,R,_,5,pt[24]),R=gt(R,E,D,T,b,9,pt[25]),T=gt(T,R,E,D,d,14,pt[26]),D=gt(D,T,R,E,m,20,pt[27]),E=gt(E,D,T,R,g,5,pt[28]),R=gt(R,E,D,T,A,9,pt[29]),T=gt(T,R,E,D,f,14,pt[30]),D=gt(D,T,R,E,y,20,pt[31]),E=bt(E,D,T,R,h,4,pt[32]),R=bt(R,E,D,T,m,11,pt[33]),T=bt(T,R,E,D,v,16,pt[34]),D=bt(D,T,R,E,b,23,pt[35]),E=bt(E,D,T,R,u,4,pt[36]),R=bt(R,E,D,T,c,11,pt[37]),T=bt(T,R,E,D,f,16,pt[38]),D=bt(D,T,R,E,p,23,pt[39]),E=bt(E,D,T,R,g,4,pt[40]),R=bt(R,E,D,T,o,11,pt[41]),T=bt(T,R,E,D,d,16,pt[42]),D=bt(D,T,R,E,l,23,pt[43]),E=bt(E,D,T,R,_,4,pt[44]),R=bt(R,E,D,T,y,11,pt[45]),T=bt(T,R,E,D,k,16,pt[46]),D=bt(D,T,R,E,A,23,pt[47]),E=kt(E,D,T,R,o,6,pt[48]),R=kt(R,E,D,T,f,10,pt[49]),T=kt(T,R,E,D,b,15,pt[50]),D=kt(D,T,R,E,h,21,pt[51]),E=kt(E,D,T,R,y,6,pt[52]),R=kt(R,E,D,T,d,10,pt[53]),T=kt(T,R,E,D,p,15,pt[54]),D=kt(D,T,R,E,u,21,pt[55]),E=kt(E,D,T,R,m,6,pt[56]),R=kt(R,E,D,T,k,10,pt[57]),T=kt(T,R,E,D,l,15,pt[58]),D=kt(D,T,R,E,g,21,pt[59]),E=kt(E,D,T,R,c,6,pt[60]),R=kt(R,E,D,T,v,10,pt[61]),T=kt(T,R,E,D,A,15,pt[62]),D=kt(D,T,R,E,_,21,pt[63]),a[0]=a[0]+E|0,a[1]=a[1]+D|0,a[2]=a[2]+T|0,a[3]=a[3]+R|0}},{key:"_doFinalize",value:function(){var e=this._data,t=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;t[n>>>5]|=128<<24-n%32;var r=Math.floor(i/4294967296),s=i;t[15+(n+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t[14+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e.sigBytes=4*(t.length+1),this._process();for(var a=this._hash,o=a.words,u=0;u<4;u+=1){var A=o[u];o[u]=16711935&(A<<8|A>>>24)|4278255360&(A<<24|A>>>8)}return a}},{key:"clone",value:function(){var e=y(d(i.prototype),"clone",this).call(this);return e._hash=this._hash.clone(),e}}]),i}(ft);ft._createHelper(Et),ft._createHmacHelper(Et);var Dt=function(e){A(i,e);var t=p(i);function i(e){var n;return s(this,i),(n=t.call(this)).cfg=Object.assign(new ut,{keySize:4,hasher:Et,iterations:1},e),n}return o(i,[{key:"compute",value:function(e,t){for(var i,n=this.cfg,r=n.hasher.create(),s=At.create(),a=s.words,o=n.keySize,u=n.iterations;a.length<o;){i&&r.update(i),i=r.update(e).finalize(t),r.reset();for(var A=1;A<u;A+=1)i=r.finalize(i),r.reset();s.concat(i)}return s.sigBytes=4*o,s}}]),i}(ut),Tt=function(e){A(i,e);var t=p(i);function i(e,n,r){var a;return s(this,i),(a=t.call(this)).cfg=Object.assign(new ut,r),a._xformMode=e,a._key=n,a.reset(),a}return o(i,[{key:"reset",value:function(){y(d(i.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?Ft:Lt};return{encrypt:function(i,n,r){return t(n).encrypt(e,i,n,r)},decrypt:function(i,n,r){return t(n).decrypt(e,i,n,r)}}}}]),i}(lt);Tt._ENC_XFORM_MODE=1,Tt._DEC_XFORM_MODE=2,Tt.keySize=4,Tt.ivSize=4;var Rt=function(e){A(i,e);var t=p(i);function i(e,n){var r;return s(this,i),(r=t.call(this))._cipher=e,r._iv=n,r}return o(i,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)}}]),i}(ut);function St(e,t,i){var n,r=e,s=this._iv;s?(n=s,this._iv=void 0):n=this._prevBlock;for(var a=0;a<i;a+=1)r[t+a]^=n[a]}var wt=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i)}(Rt);wt.Encryptor=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i,[{key:"processBlock",value:function(e,t){var i=this._cipher,n=i.blockSize;St.call(this,e,t,n),i.encryptBlock(e,t),this._prevBlock=e.slice(t,t+n)}}]),i}(wt),wt.Decryptor=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i,[{key:"processBlock",value:function(e,t){var i=this._cipher,n=i.blockSize,r=e.slice(t,t+n);i.decryptBlock(e,t),St.call(this,e,t,n),this._prevBlock=r}}]),i}(wt);var Ct={pad:function(e,t){for(var i=4*t,n=i-e.sigBytes%i,r=n<<24|n<<16|n<<8|n,s=[],a=0;a<n;a+=4)s.push(r);var o=At.create(s,n);e.concat(o)},unpad:function(e){var t=e,i=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=i}},Vt=function(e){A(i,e);var t=p(i);function i(e,n,r){var a;return s(this,i),(a=t.call(this,e,n,Object.assign({mode:wt,padding:Ct},r))).blockSize=4,a}return o(i,[{key:"reset",value:function(){var e;y(d(i.prototype),"reset",this).call(this);var t=this.cfg,n=t.iv,r=t.mode;this._xformMode===this.constructor._ENC_XFORM_MODE?e=r.createEncryptor:(e=r.createDecryptor,this._minBufferSize=1),this._mode=e.call(r,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}}]),i}(Tt),It=function(e){A(i,e);var t=p(i);function i(e){var n;return s(this,i),(n=t.call(this)).mixIn(e),n}return o(i,[{key:"toString",value:function(e){return(e||this.formatter).stringify(this)}}]),i}(ut),Gt={stringify:function(e){var t=e.ciphertext,i=e.salt;return(i?At.create([1398893684,1701076831]).concat(i).concat(t):t).toString(_t)},parse:function(e){var t,i=_t.parse(e),n=i.words;return 1398893684===n[0]&&1701076831===n[1]&&(t=At.create(n.slice(2,4)),n.splice(0,4),i.sigBytes-=16),It.create({ciphertext:i,salt:t})}},Lt=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i,null,[{key:"encrypt",value:function(e,t,i,n){var r=Object.assign(new ut,this.cfg,n),s=e.createEncryptor(i,r),a=s.finalize(t),o=s.cfg;return It.create({ciphertext:a,key:i,iv:o.iv,algorithm:e,mode:o.mode,padding:o.padding,blockSize:s.blockSize,formatter:r.format})}},{key:"decrypt",value:function(e,t,i,n){var r=t,s=Object.assign(new ut,this.cfg,n);return r=this._parse(r,s.format),e.createDecryptor(i,s).finalize(r.ciphertext)}},{key:"_parse",value:function(e,t){return"string"==typeof e?t.parse(e,this):e}}]),i}(ut);Lt.cfg=Object.assign(new ut,{format:Gt});var Zt={execute:function(e,t,i,n){var r=n;r||(r=At.random(8));var s=Dt.create({keySize:t+i}).compute(e,r),a=At.create(s.words.slice(t),4*i);return s.sigBytes=4*t,It.create({key:s,iv:a,salt:r})}},Ft=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i,null,[{key:"encrypt",value:function(e,t,i,n){var r=Object.assign(new ut,this.cfg,n),s=r.kdf.execute(i,e.keySize,e.ivSize);r.iv=s.iv;var a=Lt.encrypt.call(this,e,t,s.key,r);return a.mixIn(s),a}},{key:"decrypt",value:function(e,t,i,n){var r=t,s=Object.assign(new ut,this.cfg,n);r=this._parse(r,s.format);var a=s.kdf.execute(i,e.keySize,e.ivSize,r.salt);return s.iv=a.iv,Lt.decrypt.call(this,e,r,a.key,s)}}]),i}(Lt);Ft.cfg=Object.assign(Lt.cfg,{kdf:Zt});for(var xt=[],Bt=[],Ut=[],Nt=[],Pt=[],Ot=[],Wt=[],jt=[],Yt=[],Mt=[],Xt=[],Qt=0;Qt<256;Qt+=1)Xt[Qt]=Qt<128?Qt<<1:Qt<<1^283;for(var Jt=0,Ht=0,Kt=0;Kt<256;Kt+=1){var zt=Ht^Ht<<1^Ht<<2^Ht<<3^Ht<<4;zt=zt>>>8^255&zt^99,xt[Jt]=zt,Bt[zt]=Jt;var qt=Xt[Jt],$t=Xt[qt],ei=Xt[$t],ti=257*Xt[zt]^16843008*zt;Ut[Jt]=ti<<24|ti>>>8,Nt[Jt]=ti<<16|ti>>>16,Pt[Jt]=ti<<8|ti>>>24,Ot[Jt]=ti,ti=16843009*ei^65537*$t^257*qt^16843008*Jt,Wt[zt]=ti<<24|ti>>>8,jt[zt]=ti<<16|ti>>>16,Yt[zt]=ti<<8|ti>>>24,Mt[zt]=ti,Jt?(Jt=qt^Xt[Xt[Xt[ei^qt]]],Ht^=Xt[Xt[Ht]]):Jt=Ht=1}var ii=[0,1,2,4,8,16,32,64,128,27,54],ni=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i,[{key:"_doReset",value:function(){var e;if(!this._nRounds||this._keyPriorReset!==this._key){this._keyPriorReset=this._key;var t=this._keyPriorReset,i=t.words,n=t.sigBytes/4;this._nRounds=n+6;var r=4*(this._nRounds+1);this._keySchedule=[];for(var s=this._keySchedule,a=0;a<r;a+=1)a<n?s[a]=i[a]:(e=s[a-1],a%n?n>6&&a%n==4&&(e=xt[e>>>24]<<24|xt[e>>>16&255]<<16|xt[e>>>8&255]<<8|xt[255&e]):(e=xt[(e=e<<8|e>>>24)>>>24]<<24|xt[e>>>16&255]<<16|xt[e>>>8&255]<<8|xt[255&e],e^=ii[a/n|0]<<24),s[a]=s[a-n]^e);this._invKeySchedule=[];for(var o=this._invKeySchedule,u=0;u<r;u+=1){var A=r-u;e=u%4?s[A]:s[A-4],o[u]=u<4||A<=4?e:Wt[xt[e>>>24]]^jt[xt[e>>>16&255]]^Yt[xt[e>>>8&255]]^Mt[xt[255&e]]}}}},{key:"encryptBlock",value:function(e,t){this._doCryptBlock(e,t,this._keySchedule,Ut,Nt,Pt,Ot,xt)}},{key:"decryptBlock",value:function(e,t){var i=e,n=i[t+1];i[t+1]=i[t+3],i[t+3]=n,this._doCryptBlock(i,t,this._invKeySchedule,Wt,jt,Yt,Mt,Bt),n=i[t+1],i[t+1]=i[t+3],i[t+3]=n}},{key:"_doCryptBlock",value:function(e,t,i,n,r,s,a,o){for(var u=e,A=this._nRounds,d=u[t]^i[0],c=u[t+1]^i[1],h=u[t+2]^i[2],l=u[t+3]^i[3],f=4,m=1;m<A;m+=1){var _=n[d>>>24]^r[c>>>16&255]^s[h>>>8&255]^a[255&l]^i[f];f+=1;var p=n[c>>>24]^r[h>>>16&255]^s[l>>>8&255]^a[255&d]^i[f];f+=1;var v=n[h>>>24]^r[l>>>16&255]^s[d>>>8&255]^a[255&c]^i[f];f+=1;var y=n[l>>>24]^r[d>>>16&255]^s[c>>>8&255]^a[255&h]^i[f];f+=1,d=_,c=p,h=v,l=y}var g=(o[d>>>24]<<24|o[c>>>16&255]<<16|o[h>>>8&255]<<8|o[255&l])^i[f];f+=1;var b=(o[c>>>24]<<24|o[h>>>16&255]<<16|o[l>>>8&255]<<8|o[255&d])^i[f];f+=1;var k=(o[h>>>24]<<24|o[l>>>16&255]<<16|o[d>>>8&255]<<8|o[255&c])^i[f];f+=1;var E=(o[l>>>24]<<24|o[d>>>16&255]<<16|o[c>>>8&255]<<8|o[255&h])^i[f];f+=1,u[t]=g,u[t+1]=b,u[t+2]=k,u[t+3]=E}}]),i}(Vt);ni.keySize=8,Vt._createHelper(ni);var ri=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i)}(Rt);ri.Encryptor=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i,[{key:"processBlock",value:function(e,t){var i=e,n=this._cipher,r=n.blockSize,s=this._iv,a=this._counter;s&&(this._counter=s.slice(0),a=this._counter,this._iv=void 0);var o=a.slice(0);n.encryptBlock(o,0),a[r-1]=a[r-1]+1|0;for(var u=0;u<r;u+=1)i[t+u]^=o[u]}}]),i}(ri),ri.Decryptor=ri.Encryptor;var si=function(){function e(t,i){s(this,e),this.videoTrack=t,this.audioTrack=i}return o(e,[{key:"remux",value:function(e,t){this.videoTrack=e||this.videoTrack,this.audioTrack=t||this.audioTrack;var i,n,r=(null==e?void 0:e.exist())&&(null==e?void 0:e.hasSample()),s=(null==t?void 0:t.exist())&&(null==t?void 0:t.hasSample());return r&&s?i=this._remuxMix(e,t):r?i=this._remuxTrack(e):s&&(n=this._remuxTrack(t)),e&&(e.samples=[]),t&&(t.samples=[]),{videoSegment:i,audioSegment:n}}},{key:"_remuxMix",value:function(e,t){var i=st.ftyp([e,t]),n=this._remuxData(e,i.byteLength+8),r=n.mdatData,s=n.chunkOffset,a=this._remuxData(t,s).mdatData,o=st.mdat(We(r,a)),u=st.moovMP4([e,t]);return e.ext=void 0,t.ext=void 0,e.samples=[],t.samples=[],We(i,o,u)}},{key:"_remuxTrack",value:function(e){var t=st.ftyp([e]),i=this._remuxData(e,t.byteLength+8).mdatData,n=st.mdat(i),r=st.moovMP4([e]);return e.ext=void 0,e.samples=[],We(t,n,r)}},{key:"_remuxData",value:function(e,t){var i=e.type===he,n=e.samples,r=0;i?n.forEach((function(e){r+=e.units.reduce((function(e,t){return e+t.byteLength}),0),r+=4*e.units.length})):r=n.reduce((function(e,t){return e+t.size}),0);for(var s,a=new Uint8Array(r),o=new DataView(a.buffer),u=e.ext={stts:[],stsc:[],stsz:[],stco:[],stss:[],ctts:[]},A=0,d=0,c=n.length,h=0;h<c;h++){d+=(s=n[h]).duration;var l=i?0:s.size;i?s.units.forEach((function(e){o.setUint32(A,e.byteLength),A+=4,a.set(e,A),A+=e.byteLength,l+=4+e.byteLength})):(a.set(s.data,A),A+=l),s.size=l,u.stsz.push(l),i&&this._fillCttsSamples(u.ctts,s.cts),this._fillSttsSamples(u.stts,s,n[h+1]),this._fillStcoSamples(u.stco,h,1,t),t+=l,i&&s.keyframe&&u.stss.push(h+1)}return e.duration=d,this._fillStscSamples(u.stsc,c,1),{mdatData:a,chunkOffset:t}}},{key:"_fillSttsSamples",value:function(e,t,i){var n=e[e.length-1];i?n&&n.value===t.duration?n.count++:e.push({value:t.duration,count:1}):n?n.count++:e.push({value:40,count:1})}},{key:"_fillCttsSamples",value:function(e,t){var i=e[e.length-1];i&&i.value===t?i.count++:e.push({value:t,count:1})}},{key:"_fillStcoSamples",value:function(e,t,i,n){t%i||e.push(n)}},{key:"_fillStscSamples",value:function(e,t,i){if(t<=i)e.push({firstChunk:1,samplesPerChunk:t,sampleDescIndex:1});else{var n=Math.floor(t/i),r=t%i;e.push({firstChunk:1,samplesPerChunk:i,sampleDescIndex:1}),r&&e.push({firstChunk:n+1,samplesPerChunk:r,sampleDescIndex:1})}}}]),e}();function ai(){var e,t,i=new Promise((function(i,n){e=i,t=n}));return i.used=!1,i.resolve=function(){return i.used=!0,e.apply(void 0,arguments)},i.reject=function(){return i.used=!0,t.apply(void 0,arguments)},i}function oi(){try{return parseInt(performance.now(),10)}catch(vn){return(new Date).getTime()}}var ui,Ai=function(){function e(){s(this,e)}return o(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 i=[],n=0,r=e.length;n<r;n++){var s=i.length;if(s&&t){var a=i[s-1],o=a[1];if(e.start(n)-o<=t){var u=e.end(n);u>o&&(a[1]=u)}else i.push([e.start(n),e.end(n)])}else i.push([e.start(n),e.end(n)])}return i}},{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 i=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 r=0,s=0,a=0,o=0,u=0,A=0,d=0,c=e.buffers(t,n),h=0,l=c.length;h<l;h++){var f=c[h];if(i+n>=f[0]&&i<f[1])r=f[0],s=f[1],a=h;else{if(i+n<f[0]){o=f[0],u=f[1];break}i+n>f[1]&&(A=f[0],d=f[1])}}return{start:r,end:s,index:a,buffers:c,nextStart:o,nextEnd:u,prevStart:A,prevEnd:d,currentTime:i,behind:i-r,remaining:s?s-i:0,length:e.totalLength&&e.totalLength(c)}}}]),e}(),di="network",ci="network_timeout",hi="demux",li="remux",fi="media",mi="other",_i={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"},pi=(u(ui={},"manifest",{HLS:1100}),u(ui,di,2100),u(ui,ci,2101),u(ui,hi,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400}),u(ui,li,{FMP4:4100,MP4:4200}),u(ui,fi,{MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203}),u(ui,mi,8e3),ui),vi=function(e){A(i,e);var t=p(i);function i(e,n,r,a,o){var u;return s(this,i),(u=t.call(this,o||(null==r?void 0:r.message))).errorType=e===ci?di:e,u.originError=r,u.ext=a,u.errorCode=pi[e][n]||pi[e],u.errorMessage=u.message,u.errorCode||(u.errorType=mi,u.errorCode=pi[u.errorType]),u}return o(i,null,[{key:"create",value:function(e,t,n,r,s){return e instanceof i?e:(e instanceof Error&&(n=e,e=""),e||(e=mi),new i(e,t,n,r,s))}},{key:"network",value:function(e){var t;return new i(null!=e&&e.isTimeout?ci:di,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})}}]),i}(f(Error)),yi="undefined"!=typeof window,gi=function(){function e(t){s(this,e),this.name=t||"",this._prefix="[".concat(this.name,"]")}return o(e,[{key:"debug",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(t=console).debug.apply(t,[this._prefix,oi()].concat(n))}}},{key:"log",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(t=console).log.apply(t,[this._prefix,oi()].concat(n))}}},{key:"warn",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(t=console).warn.apply(t,[this._prefix,oi()].concat(n))}}},{key:"error",value:function(){var t;if(!e.disabled){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];(t=console).error.apply(t,[this._prefix,oi()].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}();u(gi,"disabled",!0);var bi=function(){try{return yi?window.MediaSource:null}catch(vn){}}(),ki="appendBuffer",Ei="removeBuffer",Di=function(){function e(t,i){var n=this;s(this,e),u(this,"media",null),u(this,"mediaSource",null),u(this,"_openPromise",ai()),u(this,"_queue",Object.create(null)),u(this,"_sourceBuffer",Object.create(null)),u(this,"_mseFullFlag",{}),u(this,"_st",0),u(this,"_opst",0),u(this,"_logger",null),u(this,"_config",null),u(this,"_url",null),u(this,"_onSBUpdateEnd",(function(e){var t=n._queue[e];if(t){var i=t.shift();if(i){var r=oi()-n._opst;n._logger.debug("UpdateEnd",i.opName,r,i.context),i.promise.resolve({name:i.opName,context:i.context,costtime:r}),n._startQueue(e)}}})),u(this,"_onSBUpdateError",(function(e,t){var i=n._queue[e];if(i){var r=i[0];r&&(n._logger.error("UpdateError",e,r.opName,r.context),r.promise.reject(new vi(fi,_i.MSE_APPEND_BUFFER,t)))}})),this._config=Object.assign(e.getDefaultConfig(),i),t&&this.bindMedia(t),this._logger=new gi("MSE"),this._config.openLog&&gi.enable()}var t,n,a;return o(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;return this.mediaSource&&this.mediaSource.duration>e?Promise.resolve():this._enqueueBlockingOp((function(){t.isEnded?t._logger.debug("[debug mse] setDuration ended"):t.mediaSource&&(t.mediaSource.duration=e,t._logger.debug("[debug mse] setDuration"))}),"updateDuration")}},{key:"open",value:function(){var e=this;if(this._openPromise.used&&!this.isOpened&&this.mediaSource){var t=this.mediaSource;t.addEventListener("sourceopen",(function i(){var n=oi()-e._st;e._logger.debug("MSE OPEN",n),t.removeEventListener("sourceopen",i),e._openPromise.resolve({costtime:n})})),this._openPromise=ai()}return this._openPromise}},{key:"bindMedia",value:(a=r(i().mark((function e(t){var n,r,s=this;return i().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&&bi){e.next=5;break}throw new Error("Param media or MediaSource does not exist");case 5:return this.media=t,n=this.mediaSource=new bi,this._st=oi(),r=function e(){var i=oi()-s._st;s._logger.debug("MSE OPEN"),n.removeEventListener("sourceopen",e),URL.revokeObjectURL(t.src),s._openPromise.resolve({costtime:i})},n.addEventListener("sourceopen",r),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 a.apply(this,arguments)})},{key:"unbindMedia",value:(n=r(i().mark((function e(){var t,n,r,s=this;return i().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=s._queue[e];t&&t.forEach((function(e){return e.promise.resolve}))})),n=!!this.media&&this.media.readyState>=1,r="open"===t.readyState,n&&r)try{t.endOfStream()}catch(i){}Object.keys(this._sourceBuffer).forEach((function(e){try{t.removeSourceBuffer(s._sourceBuffer[e])}catch(i){}}))}if(this.media){this.media.removeAttribute("src");try{this.media.load()}catch(i){}this.media=null}this.mediaSource=null,this._openPromise=ai(),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 i;try{i=this._sourceBuffer[e]=this.mediaSource.addSourceBuffer(t)}catch(n){throw new vi(fi,_i.MSE_ADD_SB,n)}i.mimeType=t,i.addEventListener("updateend",this._onSBUpdateEnd.bind(this,e)),i.addEventListener("error",this._onSBUpdateError.bind(this,e))}}},{key:"changeType",value:function(e,t){var i=this,n=this._sourceBuffer[e];return this.mediaSource&&n&&n.mimeType!==t&&"function"==typeof n.changeType?this._enqueueOp(e,(function(){n.changeType(t),n.mimeType=t,i._onSBUpdateEnd(e)})):Promise.resolve()}},{key:"createOrChangeSource",value:function(e,t){return this.createSource(e,t),this.changeType(e,t)}},{key:"append",value:function(e,t,i){var n=this;return t&&t.byteLength&&this._sourceBuffer[e]?this._enqueueOp(e,(function(){var r;n.mediaSource&&(n._logger.debug("MSE APPEND START",i),n._opst=oi(),null===(r=n._sourceBuffer[e])||void 0===r||r.appendBuffer(t))}),ki,i):Promise.resolve()}},{key:"remove",value:function(e,t,i,n){var r=this,s=!1;return this._mseFullFlag[e]&&(s=!0),this._enqueueOp(e,(function(){if(r.mediaSource){var s=r._sourceBuffer[e];t>=i||!s?r._onSBUpdateEnd(e):(r._opst=oi(),r._logger.debug("MSE REMOVE START",e,t,i,n),s.remove(t,i))}}),Ei,n,s)}},{key:"clearBuffer",value:function(e,t){var i,n=this;return Object.keys(this._sourceBuffer).forEach((function(r){i=n._enqueueOp(r,(function(){if(n.mediaSource){var i=n._sourceBuffer[r];n._logger.debug("MSE clearBuffer START",r,e,t),i.remove(e,t)}}))})),i}},{key:"clearAllBuffer",value:function(){var e,t=this;return Object.keys(this._sourceBuffer).forEach((function(i){e=t._enqueueOp(i,(function(){if(t.mediaSource){var e=t._sourceBuffer[i];t._logger.debug("MSE clearAllBuffer START",i),e.remove(0,Ai.end(Ai.get(e)))}}))})),e}},{key:"clearOpQueues",value:function(e){var t;this._logger.debug("MSE clearOpQueue START");var i=this._queue[e];if(i&&i[e]&&!(i.length<5)){var n=[];i.forEach((function(e){e.context&&e.context.isinit&&n.push(e)})),this._queue[e]=i.slice(0,2),n.length>0&&(t=this._queue[e]).push.apply(t,n)}}},{key:"endOfStream",value:function(e){var t=this;return this.mediaSource&&"open"===this.mediaSource.readyState?this._enqueueBlockingOp((function(){var i=t.mediaSource;i&&"open"===i.readyState&&(t._logger.debug("MSE endOfStream START"),e?i.endOfStream(e):i.endOfStream())}),"endOfStream"):Promise.resolve()}},{key:"setLiveSeekableRange",value:function(e,t){var i=this.mediaSource;e<0||t<e||null==i||!i.setLiveSeekableRange||"open"!==i.readyState||i.setLiveSeekableRange(e,t)}},{key:"getSourceBuffer",value:function(e){return this._sourceBuffer[e]}},{key:"buffered",value:function(e){return Ai.get(this._sourceBuffer[e])}},{key:"bufferStart",value:function(e){return Ai.start(this.buffered(e))}},{key:"bufferEnd",value:function(e){return Ai.end(this.buffered(e))}},{key:"_enqueueOp",value:function(e,t,i,n,r){var s=this;if(!this.mediaSource)return Promise.resolve();var a=this._queue[e]=this._queue[e]||[],o={exec:t,promise:ai(),opName:i,context:n};return r?(a.splice(0,0,o),this._mseFullFlag[e]=!1,this._startQueue(e)):a.push(o),this.isOpened?1===a.length&&this._startQueue(e):this._openPromise.then((function(){1===a.length&&s._startQueue(e)})),o.promise}},{key:"_enqueueBlockingOp",value:(t=r(i().mark((function e(t,n){var r,s,a=this;return i().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((r=Object.keys(this._sourceBuffer)).length){e.next=5;break}return e.abrupt("return",t());case 5:return s=[],r.forEach((function(e){var t=a._queue[e],i=ai();s.push(i),t.push({exec:function(){return i.resolve()},promise:i,opName:n}),1===t.length&&a._startQueue(e)})),e.abrupt("return",Promise.all(s).then((function(){try{return t()}finally{r.forEach((function(e){var t=a._queue[e],i=a._sourceBuffer[e];null==t||t.shift(),i&&i.updating||a._startQueue(e)}))}})));case 8:case"end":return e.stop()}}),e,this)}))),function(e,i){return t.apply(this,arguments)})},{key:"_startQueue",value:function(e){var t=this._queue[e];if(t){var i=t[0];if(i&&!this._mseFullFlag[e])try{i.exec()}catch(n){n&&n.message&&n.message.indexOf("SourceBuffer is full")>=0?(this._mseFullFlag[e]=!0,this._logger.error("[MSE error], context,",i.context," ,name,",i.opName,",err,SourceBuffer is full"),i.promise.reject(new vi(fi,_i.MSE_FULL,n))):(this._logger.error(n),i.promise.reject(new vi(fi,_i.MSE_OTHER,n)),t.shift(),this._startQueue(e))}}}},{key:"setTimeoffset",value:function(e,t,i){var n=this;return this._enqueueOp(e,(function(){t<0&&(t+=.001),n._sourceBuffer[e].timestampOffset=t,n._onSBUpdateEnd(e)}),"setTimeoffset",i)}},{key:"abort",value:function(e,t){var i=this;return this.isOpened?this._enqueueOp(e,(function(){i._sourceBuffer[e].abort(),i._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(!bi)return!1;try{return bi.isTypeSupported(e)}catch(t){return this._logger.error(e,t),!1}}}]),e}();u(Di,"VIDEO","video"),u(Di,"AUDIO","audio");var Ti={"mp4a.40.5":1,"mp4a.40.2":2},Ri=.05,Si=new(function(){function e(){s(this,e),u(this,"_queue",[]),"undefined"!=typeof document&&(this._tempMedia=document.createElement("video"))}return o(e,[{key:"tempMedia",get:function(){return this._tempMedia}},{key:"hasCached",get:function(){return-1!==this._queue.findIndex((function(e){return 1===e.codec}))&&-1!==this._queue.findIndex((function(e){return 2===e.codec}))}},{key:"getCachedMedia",value:function(e){var t=this._queue.findIndex((function(t){return t.codec===e}));return-1!==t?this._queue.splice(t,1)[0]:null}},{key:"cacheMedia",value:function(e){var t=e.codec,i=e.media,n=e.mse,r=Ti[t];if(this._queue=this._queue.filter((function(e){var t;return e.mse&&!e.mse.isOpened&&e.mse.unbindMedia(),null===(t=e.mse)||void 0===t?void 0:t.isOpened})),!t||this._queue.filter((function(e){return e.codec===r})).length>2)return null==n||n.endOfStream(),void(null==n||n.unbindMedia());this._queue.push({codec:r,media:i,mse:n})}}]),e}()),wi=function(e){A(l,e);var n,a,c,h=p(l);function l(e,n){var a;return s(this,l),u(m(a=h.call(this,e,n)),"_media",void 0),u(m(a),"_isTempMedia",!1),u(m(a),"_mse",void 0),u(m(a),"_remuxer",null),u(m(a),"_codec",""),u(m(a),"_sourceCreated",!1),u(m(a),"_needInitSegment",!0),u(m(a),"_seekNoSideEffect",!1),u(m(a),"_startRendered",!1),u(m(a),"_firstTimeAppendedBuffer",!1),u(m(a),"_sampleQueue",[]),u(m(a),"_inProcessing",!1),u(m(a),"_duration",0),u(m(a),"_mediaCache",Si),u(m(a),"_resetDts",(function(){})),u(m(a),"_onCanplay",(function(){a._ready||(a._ready=!0,a.emit(ee.AUDIO_READY))})),u(m(a),"_onPlaying",(function(){a._parent.ready&&(a._audioCanAutoplay=!0,a._emitTimelineEvents(ie.PLAY_EVENT,q.PLAYING))})),u(m(a),"_onWaiting",(function(){if(!a._seekNoSideEffect){try{for(var e,t=a._media.buffered,i=a._media.currentTime,n=0,r=0,s=t.length;r<s;r++)t.start(r)<i&&t.end(r)>i&&(n=t.end(r)-i);if(Math.abs(n)>.5)return;if(Math.abs(a._media.duration-a._media.currentTime)<.3)return a._reuseMse||a._mse.endOfStream(),void(null===(e=m(a))||void 0===e||e._emitTimelineEvents(ie.PLAY_EVENT,q.ENDED))}catch(vn){}a._ready=!1,a.emit(ee.AUDIO_WAITING)}})),u(m(a),"_onSeeked",(function(){a._seekNoSideEffect||a._isLive?a._seekNoSideEffect=!1:(V.log(a.TAG,"seeked"),a._ready||(a._media.pause(),a._ready=!0,a.emit(ee.AUDIO_READY)))})),u(m(a),"_onProgress",(function(){if(a._media.readyState<=1){var e=a._getBufferGap();e>0&&e<1&&(a._media.currentTime+=e+Ri,V.warn(a.TAG,"progress, gap=",e))}a._emitTimelineEvents(ie.PLAY_EVENT,q.PROGRESS),a._emitTimelineEvents(ie.PLAY_EVENT,q.DURATION_CHANGE)})),u(m(a),"_onEnded",(function(){var e;V.log(a.TAG,"ended!"),null===(e=m(a))||void 0===e||e._emitTimelineEvents(ie.PLAY_EVENT,q.ENDED)})),u(m(a),"_onOnceProgress",(function(){if(a._media.buffered.length){var e=a._media.buffered.start(0);e&&(a._media.currentTime=e+Ri,V.log(a.TAG,"start gap:",e)),a._media.removeEventListener("progress",a._onOnceProgress)}})),u(m(a),"_onError",(function(){var e;a._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,a._assembleErr("audio error: ".concat(null===(e=a._media.error)||void 0===e?void 0:e.message),3))})),u(m(a),"_appendChunk",(function(e,i){if(!a.noAudio&&i.samples.length){if(a._codec||(2!==i.objectType&&5!==i.objectType?a._codec="mp4a.40.5":a._codec=i.codec,a._isTempMedia&&a._switchMedia(a._codec)),i.samples.forEach((function(e){e.baseMediaDecodeTime=i.baseMediaDecodeTime,a._sampleQueue.push(e)})),i.samples=[],!a._meta)return a._meta=t(t({},i),{},{exist:function(){return!0},hasSample:function(){return!0},samples:[]}),V.warn(a.TAG,"audio set metadata",a._meta),void a._doAppendWrapper();a._meta.sampleRate!==i.sampleRate&&(V.warn(a.TAG,"discontinue: ".concat(a._meta.sampleRate," -> ").concat(i.sampleRate)),a._needInitSegment=!0,Object.keys(i).forEach((function(e){a._meta[e]=i[e]}))),!a._inProcessing&&a._sampleQueue.length&&a._doAppendWrapper()}})),u(m(a),"_doAppend",function(){var e=r(i().mark((function e(t){var n,r,s;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a._remuxer||(a._remuxer=new ot({samples:[],exist:function(){return!1}},t)),n=t.samples,a._sourceCreated){e.next=12;break}return a.analyse.addAudioMseOpenStart(),e.next=6,a._mse.open();case 6:a._sourceCreated=!0,V.log(a.TAG,"video/mp4;codecs=".concat(a._codec)),a._mse.createSource(t.type,"video/mp4;codecs=".concat(a._codec)),a.analyse.addAudioMseOpend(),V.log(a.TAG,"sb created!"),a._checkAutoPlay();case 12:if(r=a._remuxer.remux(a._needInitSegment),!a._needInitSegment||r.audioInitSegment){e.next=15;break}return e.abrupt("return");case 15:return a._needInitSegment=!1,s=[],r.audioInitSegment&&s.push(a._mse.append(t.type,r.audioInitSegment)),r.audioSegment&&s.push(a._mse.append(t.type,r.audioSegment)),e.abrupt("return",Promise.all(s).then((function(){return n[n.length-1].dts/1e3})).then((function(){a._firstTimeAppendedBuffer||(a._firstTimeAppendedBuffer=!0,a.analyse.addAudioFirstTimeAppended())})));case 20:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),u(m(a),"_doPlay",(function(){a._media.play().catch((function(){}))})),u(m(a),"_doPause",(function(){a._media.pause()})),u(m(a),"_doSeek",(function(e){a._ready=!1,a._media.currentTime=e})),u(m(a),"_doChaseFrame",(function(e){var t=e.position;a._seekNoSideEffect=!0,a._media.currentTime=t})),u(m(a),"_startRender",(function(){V.log(a.TAG,"start render"),a._startRendered=!0,a._media.play().catch((function(){}))})),a.TAG="AudioMseRender",a._reuseMse=x().reuseMseForAudio,a._initMedia(),a}return o(l,[{key:"isMse",get:function(){return!0}},{key:"media",get:function(){return this._media}},{key:"currentTime",get:function(){return this._media.currentTime}},{key:"buffered",get:function(){return this._media.buffered}},{key:"duration",get:function(){return Number.isNaN(this._media.duration)?1/0:this._media.duration},set:function(e){this._duration=e,this._updateDuration(e)}},{key:"audioCanAutoplay",get:function(){return this._audioCanAutoplay||this.noAudio}},{key:"_initMedia",value:function(){if(!this._reuseMse||!Si.hasCached)return V.log(this.TAG,"init media and mse directly"),this._media=document.createElement("video"),this._media.autoplay=!0,this._mse=new Di,this._bindEvents(),this._bindMediaEvents(),void this._mse.bindMedia(this._media);V.log(this.TAG,"bind media temporary"),this._media=Si.tempMedia,this._bindEvents(),this._isTempMedia=!0}},{key:"_switchMedia",value:function(e){var t=this._media,i=Si.getCachedMedia(Ti[e]);i?(V.warn(this.TAG,"switch to cached media for audio play! codec=".concat(e)),this._media=i.media,this._mse=i.mse,this._bindMediaEvents(),this._updateDuration(this._duration),this._media.currentTime=Ri,this._sourceCreated=!0,this._audioCanAutoplay=!0,this.analyse.addAudioMseOpend()):this._initMedia(),this._media.volume=t.volume,this._media.playbackRate=t.playbackRate,this._isTempMedia=!1}},{key:"_getBufferGap",value:function(){for(var e=this.buffered,t=0,i=e.length;t<i;t++)if(!(e.end(t)<this.currentTime))return e.start(t)-this.currentTime;return 0}},{key:"canSeek",value:function(){return!0}},{key:"resume",value:function(){return this._media.play()}},{key:"pause",value:function(){return this._media.pause()}},{key:"seekNoSideEffect",value:function(e){this._doChaseFrame(e)}},{key:"dump",value:function(){}},{key:"_emitTimelineEvents",value:function(e,t,i){var n,r;null===(n=this._parent)||void 0===n||null===(r=n.emit)||void 0===r||r.call(n,e,t,i)}},{key:"_assembleErr",value:function(e,t){var i=new Error(e);return i.code=3,i.subCode=t,i}},{key:"_bindEvents",value:function(){var e=this;y(d(l.prototype),"_bindEvents",this).call(this),this._parent.on(ne.CHASE_AUDIO_FRAME,this._doChaseFrame),this._parent.on(ie.UPDATE_VOLUME,(function(t){e._media.volume=t,e._emitTimelineEvents(ie.PLAY_EVENT,q.VOLUME_CHANGE)})),this._parent.on(ie.END_OF_STREAM,(function(){var t;e.reuseMseForAudio||(null===(t=e._mse)||void 0===t||t.endOfStream())})),this._parent.on(ie.SET_PLAYBACKRATE,(function(t){V.log(e.TAG,"change playbackrate, ",t),e._media.playbackRate=t}))}},{key:"_bindMediaEvents",value:function(){this._media.addEventListener("canplay",this._onCanplay),this._media.addEventListener("playing",this._onPlaying),this._media.addEventListener("waiting",this._onWaiting),this._media.addEventListener("seeked",this._onSeeked),this._media.addEventListener("progress",this._onProgress),this._media.addEventListener("ended",this._onEnded),this._media.addEventListener("progress",this._onOnceProgress),this._media.addEventListener("error",this._onError)}},{key:"_updateDuration",value:(c=r(i().mark((function e(t){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._mse){e.next=7;break}if(this._mse.isOpened){e.next=4;break}return e.next=4,this._mse.open();case 4:return e.next=6,this._mse.updateDuration(t);case 6:V.log(this.TAG,"update duration",t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"_doAppendWrapper",value:(a=r(i().mark((function e(){var t;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._meta.samples=this._sampleQueue.slice(),this._meta.baseMediaDecodeTime=this._meta.samples[0].baseMediaDecodeTime,this._sampleQueue=[],e.prev=3,this._inProcessing=!0,e.next=7,this._doAppend(this._meta);case 7:if(t=e.sent,this.isLive&&this._emitTimelineEvents(ie.UPDATE_SEGMENT_END,t),this._inProcessing=!1,!this._sampleQueue.length){e.next=13;break}return e.next=13,this._doAppendWrapper();case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(3),this._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,this._assembleErr("audio error: ".concat(null===e.t0||void 0===e.t0?void 0:e.t0.message),3));case 18:case"end":return e.stop()}}),e,this,[[3,15]])}))),function(){return a.apply(this,arguments)})},{key:"_checkAutoPlay",value:function(){var e=this;this._media.addEventListener("canplay",(function t(){var i=e._media.volume;e._media.volume=Math.min(i,.1);var n=e._media.play();(n=n.then?n:Promise.reject()).then((function(){V.log(e.TAG,"auto play by checkAutoPlay!"),e._audioCanAutoplay=!0})).catch((function(){V.warn(e.TAG,"can’t auto play!"),e._audioCanAutoplay=!1,e.emit(ee.AUDIO_NOT_ALLOWED_AUTOPLAY)})).finally((function(){e._media.volume=i,e._startRendered||(e._media.pause(),V.log(e.TAG,"auto paused by checkAutoPlay!")),e._media.removeEventListener("canplay",t)}))}))}},{key:"_destroy",value:(n=r(i().mark((function e(){var t,n,r;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(V.log(this.TAG,"destroy audio render"),this._remuxer=null,this.removeAllListeners(),this._media.removeEventListener("canplay",this._onCanplay),this._media.removeEventListener("playing",this._onPlaying),this._media.removeEventListener("waiting",this._onWaiting),this._media.removeEventListener("seeked",this._onSeeked),this._media.removeEventListener("progress",this._onProgress),this._media.removeEventListener("ended",this._onEnded),this._media.removeEventListener("progress",this._onOnceProgress),this._media.removeEventListener("error",this._onError),this._reuseMse){e.next=17;break}return null===(t=this._mse)||void 0===t||t.endOfStream(),e.next=15,null===(n=this._mse)||void 0===n?void 0:n.unbindMedia();case 15:e.next=20;break;case 17:null===(r=this._mse)||void 0===r||r.clearAllBuffer(),Si.cacheMedia({codec:this._codec,media:this._media,mse:this._mse}),V.log(this.TAG,"cache media for audio play, codec=",this._codec);case 20:this._meta&&(this._meta.duration=0),this._mse=null,this._media=null;case 23:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})}],[{key:"isSupported",value:function(){return x().audioWithMse&&!!window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="mp4a.40.5"')}}]),l}(re),Ci=.1,Vi=function(){function e(t){s(this,e),this.TAG="VideoTimeRange",this._parent=t,this._baseDts=0,this._lastDuration=0,this._duration=0,this._bitrate=0,this._totalSize=0,this._buffers=[],this._currentFrameQueue=[],this._frameIndexInQueue=0,this._delayEstimateList=[],this._keyframeQueue=[]}return o(e,[{key:"isLive",get:function(){return this._parent.isLive}},{key:"baseDts",get:function(){return this._baseDts}},{key:"duration",get:function(){return this._duration},set:function(e){this._duration=e}},{key:"buffered",get:function(){var e=this;if(this.isLive)return{length:this._duration?1:0,start:function(){return 0},end:function(){return e._duration}};var t=this._mergeBufferRanges();return{length:t.length,start:function(e){var i=t[e];return i?i.start:0},end:function(e){var i=t[e];return i?i.end:1/0}}}},{key:"bufferStart",get:function(){var e;return(null===(e=this._buffers[0])||void 0===e?void 0:e.start)||0}},{key:"frameLength",get:function(){return this._currentFrameQueue.length}},{key:"keyFrameLength",get:function(){return this._keyframeQueue.length}},{key:"totalSize",get:function(){return this._totalSize}},{key:"bitrate",get:function(){return this._bitrate},set:function(e){this._bitrate=e}},{key:"lastDuration",get:function(){return this._lastDuration}},{key:"frames",get:function(){return this._currentFrameQueue}},{key:"getCurrentTime",value:function(e){return this._lastDuration+(e-this._baseDts)/1e3}},{key:"resetDts",value:function(e){this._baseDts=e}},{key:"_mergeBufferRanges",value:function(){var e=this._buffers.sort((function(e,t){return e.start>t.start?1:-1})),t=e.length,i=[];if(!t)return i;for(var n={start:e[0].start,end:e[0].end},r=1;r<t;r++){var s=e[r];Math.abs(n.end-s.start)<Ci?n.end=s.end:(i.push(n),n={start:s.start,end:s.end})}return i.push(n),i}},{key:"_caclBaseDts",value:function(e){-1===this._baseDts&&e&&(this._baseDts=e.dts,V.log(this.TAG,"set baseDts: ",this._baseDts,"frame len:",this._currentFrameQueue.length))}},{key:"_updateDuration",value:function(e){for(var t=e.length,i=e[t-1],n=0;n<t;n++){var r=e[n];if(r&&r.options&&r.options.meta){var s=e[n-1]||this._currentFrameQueue[this._currentFrameQueue.length-1];s?this._lastDuration+=(s.dts-this._baseDts)/1e3:this._lastDuration=this._duration,V.log(this.TAG,"updateBaseDts,record lastDuration:",this._lastDuration),this._baseDts=r.dts;break}}i&&(this._duration=(i.dts-this._baseDts)/1e3+this._lastDuration)}},{key:"_estimateBitRate",value:function(e){var t=e.length;if(t<=2){if(this._delayEstimateList=this._delayEstimateList.concat(e),(t=this._delayEstimateList.length)<=30)return;e=this._delayEstimateList,this._delayEstimateList=[]}for(var i=0,n=0;n<t;n++){var r=e[n];i+=r.data?r.data.length:r.units.reduce((function(e,t){return e+t.byteLength}),0)}this._totalSize+=i;var s=i/(e[t-1].dts-e[0].dts);this._bitrate=parseInt(8e3*s)}},{key:"_beforeAppendVodBuffer",value:function(e){var t=this;if(e.length){for(var i=[],n=[],r=0,s=e.length;r<s;r++)e[r].keyframe&&(i.push(n),n=[]),n.push(e[r]);n.length&&i.push(n),i.forEach((function(e){return t._appendVodBuffer(e)}))}}},{key:"_appendVodBuffer",value:function(e){if(e.length){var t=e[0],i=e[e.length-1],n=(t.dts-this._baseDts)/1e3,r=(i.dts-this._baseDts)/1e3;V.enable&&V.log(this.TAG,"add new buffer range [".concat(n," , ").concat(r,"]")),this._buffers.filter((function(e){return n>=e.start&&r<=e.end})).length||(this._buffers.push({start:n,end:r,duartion:r-n,frames:e.slice()}),this._buffers.sort((function(e,t){return e.start>t.start?1:-1})),this._afterAppendVodBuffer())}}},{key:"_afterAppendVodBuffer",value:function(){if(this._buffers.filter((function(e){var t;return!(null!==(t=e.frames[0])&&void 0!==t&&t.keyframe)})).length){for(var e=this._buffers,t=this._buffers.length,i=[],n=this._buffers[0],r=1;r<t;r++){var s;null!==(s=e[r].frames[0])&&void 0!==s&&s.keyframe?(i.push(n),n=e[r]):(n.frames=n.frames.concat(e[r].frames),n.end=e[r].end,n.duartion=n.end-n.start)}i.push(n),this._buffers=i}}},{key:"_recordKeyframes",value:function(e){var t=this;e.forEach((function(e){if(e.keyframe){var i=(e.dts-t._baseDts)/1e3;t._keyframeQueue.push({position:i,frame:e})}})),this._keyframeQueue=this._keyframeQueue.sort((function(e,t){return e.position>t.position?1:-1})),this.isLive&&this._keyframeQueue.length>40&&this._keyframeQueue.splice(0,20)}},{key:"toAnnexBNalu",value:function(e){e.forEach((function(e){var t=e.units;if(t){var i=t.reduce((function(e,t){return e+4+t.byteLength}),0),n=new Uint8Array(i),r=0;t.forEach((function(e){n.set([0,0,0,1],r),r+=4,n.set(e,r),r+=e.byteLength})),e.units=null,e.data=n}}))}},{key:"append",value:function(e,t,i){i&&this.toAnnexBNalu(e),this._caclBaseDts(e[0]),t&&this._updateDuration(e),this._estimateBitRate(e),this._recordKeyframes(e),this.isLive?this._currentFrameQueue=this._currentFrameQueue.concat(e):this._beforeAppendVodBuffer(e)}},{key:"updateSegmentEnd",value:function(e){var t=this._buffers[this._buffers.length-1];t&&(Math.abs(t.end-e)<.5||(t.end=e,t.duartion=e-t.start,V.log(this.TAG,"video data lack, reset end:",e)))}},{key:"getFrame",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this.isLive)return this._currentFrameQueue.shift();if(!(e=this._currentFrameQueue[this._frameIndexInQueue])){if(!(e=this._currentFrameQueue[--this._frameIndexInQueue]))return;var i=this.switchBuffer((e.dts-this._baseDts)/1e3,this._frameIndexInQueue++,t);if(!i)return;return this.getFrame(++t)}return this._frameIndexInQueue++,e}},{key:"getFramesForPreciseSeek",value:function(e){return this._currentFrameQueue.filter((function(t){return t.dts<=e}))}},{key:"updateFrameIndexForPreciseSeek",value:function(e){this._frameIndexInQueue=e}},{key:"switchBuffer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!(i>=20)){e=e||this.bufferStart;var n=this._buffers.filter((function(t){return t.start<e+Ci&&t.end>=e+Ci}))[0];if(!n){var r=this._buffers.find((function(t){return t.start>=e}));return r&&r.start-e<1?(this._currentFrameQueue=r.frames.slice(0),this._frameIndexInQueue=0,r):void 0}return n.frames[0].dts>=e?(this._currentFrameQueue=n.frames.slice(0),this._frameIndexInQueue=0,V.log(this.TAG,"switch video buffer, time:".concat(e," , buffer:[").concat(n.start," , ").concat(n.end,"], index=0")),n):n.frames.length>t?(this._currentFrameQueue=n.frames.slice(0),V.log(this.TAG,"switch video buffer, in the same gop and more frame got, time:".concat(e," , buffer:[").concat(n.start," , ").concat(n.end,"], index=").concat(t)),n):void V.log(this.TAG,"switch video buffer, in the same gop and no more frame got, time:".concat(e," , buffer:[").concat(n.start," , ").concat(n.end,"], index=").concat(t))}}},{key:"getSeekStartPosition",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(this._keyframeQueue.forEach((function(i){i.position<=e&&(t=i)})),t)return e-t.position<i?t:void 0}},{key:"nextFrame",value:function(){return this._currentFrameQueue[0]}},{key:"deletePassed",value:function(e){this._currentFrameQueue=this._currentFrameQueue.filter((function(t){return t.dts>=e}))}},{key:"getDtsOfTime",value:function(e){var t=e-this._lastDuration;return this._baseDts+1e3*t}},{key:"clean",value:function(){this._currentFrameQueue=[]}},{key:"destroy",value:function(){this._currentFrameQueue=[],this._buffers=[]}}]),e}();function Ii(e){var t;(null===(t=e.buffer)||void 0===t?void 0:t.close)&&e.buffer.close()}var Gi=function(){function e(t){s(this,e),this.TAG="FrameQueue",this._parent=t,this._lastGopId=0,this._frames=[]}return o(e,[{key:"currentTimeDts",get:function(){return this._parent.preciseVideoDts}},{key:"length",get:function(){return this._frames.length}},{key:"frames",get:function(){return this._frames}},{key:"append",value:function(e){e.info?this._frames.push(e):Ii(e)}},{key:"appendVodFrame",value:function(e){this._frames.push(e)}},{key:"nextFrame",value:function(){var e=this._frames.length;return 1===this._parent.noAudio&&e>3&&(this._frames=this._frames.slice(e-2)),this._frames[0]}},{key:"shift",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this._frames.shift();return this.deletePassed(e),t}},{key:"deletePassed",value:function(e){this._frames=this._frames.filter((function(t){return!!(t.info&&t.info.dts>e)||(Ii(t),!1)}))}},{key:"empty",value:function(){this._frames.forEach((function(e){return Ii(e)})),this._frames=[]}},{key:"destroy",value:function(){this.empty(),this._lastGopId=0}}]),e}(),Li=new(function(){function e(){s(this,e),u(this,"_queue",[]),u(this,"TAG","FrameRenderCache")}return o(e,[{key:"cacheCvs",value:function(e){this._queue.push(e),V.log(this.TAG,"cache canvas!")}},{key:"getCachedCvs",value:function(){var e=this._queue.pop();return e&&V.log(this.TAG,"get cached canvas!"),e}}]),e}()),Zi=function(){function e(t,i){s(this,e),this.TAG="FrameRender",this.configs=Object.assign({},t),this.parent=i,this.canvas=this.configs.canvas,this.canvas.glInstance=this,this.meta=Object.assign({},this.configs.meta),this.frameRenderCache=Li,this._initMeta(),this._initContextGL(),this.contextGL&&(this._initProgram(),this._initBuffers(),this._initTextures())}return o(e,[{key:"_initMeta",value:function(){this.chroma=this.meta.chromaFormat,this.height=this.meta.height,this.width=this.meta.width,this.canvas.width===this.meta.width&&this.canvas.height===this.meta.height||(this.canvas.width=this.meta.width,this.canvas.height=this.meta.height,this.parent.emitResizeEvent())}},{key:"_initContextGL",value:function(){if("2d"!==this.configs.type){for(var e=this.canvas,t=null,i=["webgl","experimental-webgl","moz-webgl","webkit-3d"],n=0;!t&&n<i.length;){var r=i[n];try{t=e.getContext(r,this.configs.glCtxOptions),V.log("FrameRender","use=",r,this.configs.glCtxOptions);break}catch(vn){t=null}t&&"function"==typeof t.getParameter||(t=null),++n}this.contextGL=t}else this.ctx=this.canvas.getContext("2d")}},{key:"_initProgram",value:function(){var e=this.contextGL,t=["attribute vec4 vertexPos;","attribute vec4 texturePos;","attribute vec4 uTexturePos;","attribute vec4 vTexturePos;","varying vec2 textureCoord;","varying vec2 uTextureCoord;","varying vec2 vTextureCoord;","void main()","{"," gl_Position = vertexPos;"," textureCoord = texturePos.xy;"," uTextureCoord = uTexturePos.xy;"," vTextureCoord = vTexturePos.xy;","}"].join("\n"),i=["precision highp float;","varying highp vec2 textureCoord;","varying highp vec2 uTextureCoord;","varying highp vec2 vTextureCoord;","uniform sampler2D ySampler;","uniform sampler2D uSampler;","uniform sampler2D vSampler;","uniform mat4 YUV2RGB;","void main(void) {"," highp float y = texture2D(ySampler, textureCoord).r;"," highp float u = texture2D(uSampler, uTextureCoord).r;"," highp float v = texture2D(vSampler, vTextureCoord).r;"," gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;","}"].join("\n"),n=e.createShader(e.VERTEX_SHADER);e.shaderSource(n,t),e.compileShader(n),e.getShaderParameter(n,e.COMPILE_STATUS)||console.log("Vertex shader failed to compile: "+e.getShaderInfoLog(n));var r=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(r,i),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)||console.log("Fragment shader failed to compile: "+e.getShaderInfoLog(r));var s=e.createProgram();e.attachShader(s,n),e.attachShader(s,r),e.linkProgram(s),e.getProgramParameter(s,e.LINK_STATUS)||console.log("Program failed to compile: "+e.getProgramInfoLog(s)),e.useProgram(s);var a=e.getUniformLocation(s,"YUV2RGB");e.uniformMatrix4fv(a,!1,[1.16438,0,1.59603,-.87079,1.16438,-.39176,-.81297,.52959,1.16438,2.01723,0,-1.08139,0,0,0,1]),this.shaderProgram=s}},{key:"_initBuffers",value:function(){var e=this.contextGL,t=this.shaderProgram,i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array([1,1,-1,1,1,-1,-1,-1]),e.STATIC_DRAW);var n=e.getAttribLocation(t,"vertexPos");e.enableVertexAttribArray(n),e.vertexAttribPointer(n,2,e.FLOAT,!1,0,0);var r=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1]),e.STATIC_DRAW);var s=e.getAttribLocation(t,"texturePos");e.enableVertexAttribArray(s),e.vertexAttribPointer(s,2,e.FLOAT,!1,0,0),this.texturePosBuffer=r;var a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1]),e.STATIC_DRAW);var o=e.getAttribLocation(t,"uTexturePos");e.enableVertexAttribArray(o),e.vertexAttribPointer(o,2,e.FLOAT,!1,0,0),this.uTexturePosBuffer=a;var u=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,new Float32Array([1,0,0,0,1,1,0,1]),e.STATIC_DRAW);var A=e.getAttribLocation(t,"vTexturePos");e.enableVertexAttribArray(A),e.vertexAttribPointer(A,2,e.FLOAT,!1,0,0),this.vTexturePosBuffer=u}},{key:"_initTextures",value:function(){var e=this.contextGL,t=this.shaderProgram,i=this._initTexture(),n=e.getUniformLocation(t,"ySampler");e.uniform1i(n,0),this.yTextureRef=i;var r=this._initTexture(),s=e.getUniformLocation(t,"uSampler");e.uniform1i(s,1),this.uTextureRef=r;var a=this._initTexture(),o=e.getUniformLocation(t,"vSampler");e.uniform1i(o,2),this.vTextureRef=a,e.pixelStorei(e.UNPACK_ALIGNMENT,1)}},{key:"_initTexture",value:function(){var e=this.contextGL,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),t}},{key:"_drawPictureGL",value:function(e,t,i,n,r){var s=n*i,a=r*i/2;444!==this.chroma&&422!==this.chroma||(a*=2);var o={yData:(e=new Uint8Array(e)).subarray(0,s),uData:e.subarray(s,s+a),vData:e.subarray(s+a,s+a+a)};this._drawPictureGL420(o,t,i,n,r)}},{key:"_drawPictureGL420",value:function(e,t,i,n,r){var s=this.contextGL,a=this.texturePosBuffer,o=this.uTexturePosBuffer,u=this.vTexturePosBuffer,A=this.yTextureRef,d=this.uTextureRef,c=this.vTextureRef,h=e.yData,l=e.uData,f=e.vData,m=n,_=i,p=r,v=i/2;422!==this.chroma&&444!==this.chroma||(v=i);var y=r,g=v,b=this.canvas.width/this.width,k=this.canvas.height/this.height,E=0,D=0,T=this.canvas.width,R=this.canvas.height;b<k?(R=this.height*this.canvas.width/this.width,D=parseInt((this.canvas.height-this.height*this.canvas.width/this.width)/2)):(T=this.width*this.canvas.height/this.height,E=parseInt((this.canvas.width-this.width*this.canvas.height/this.height)/2)),s.viewport(E,D,T,R);var S=new Float32Array([1,0,0,0,1,1,0,1]);s.bindBuffer(s.ARRAY_BUFFER,a),s.bufferData(s.ARRAY_BUFFER,S,s.DYNAMIC_DRAW);var w=new Float32Array([1,0,0,0,1,1,0,1]);s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,w,s.DYNAMIC_DRAW);var C=new Float32Array([1,0,0,0,1,1,0,1]);s.bindBuffer(s.ARRAY_BUFFER,u),s.bufferData(s.ARRAY_BUFFER,C,s.DYNAMIC_DRAW),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,A),s.texImage2D(s.TEXTURE_2D,0,s.LUMINANCE,m,_,0,s.LUMINANCE,s.UNSIGNED_BYTE,h),s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,d),s.texImage2D(s.TEXTURE_2D,0,s.LUMINANCE,p,v,0,s.LUMINANCE,s.UNSIGNED_BYTE,l),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,c),s.texImage2D(s.TEXTURE_2D,0,s.LUMINANCE,y,g,0,s.LUMINANCE,s.UNSIGNED_BYTE,f),s.drawArrays(s.TRIANGLE_STRIP,0,4)}},{key:"_drawPicture2d",value:function(e){if(e&&this.canvas){this.ctx||(this.ctx=this.canvas.getContext("2d"));var t=e.displayWidth||e.width,i=e.displayHeight||e.height;this.canvas.height===i&&this.canvas.width===t||(this.canvas.height=i,this.canvas.width=t);try{this.ctx.drawImage(e.dom||e,0,0,t,i)}catch(n){console.error(this.TAG,"_drawPicture2d",e,e.dom,n,n.message)}}}},{key:"_resize",value:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.canvas.width=e,this.canvas.height=t,this.parent.emitResizeEvent())}},{key:"render",value:function(e,t,i,n,r){this._resize(t,i),this.contextGL?this._drawPictureGL(e,t,i,n,r):this._drawPicture2d(e)}},{key:"resetMeta",value:function(e){this.meta=Object.assign({},e)}},{key:"updateBind",value:function(e,t){this.parent=e,this.resetMeta(t)}},{key:"destroy",value:function(e){this.parent=null,this.canvas.style.display="none",e&&(this.contextGL&&this.contextGL.clear(this.contextGL.DEPTH_BUFFER_BIT|this.contextGL.COLOR_BUFFER_BIT),Li.cacheCvs(this.canvas))}}]),e}(),Fi=function(){function e(t){s(this,e),u(this,"_lowDecodeThreshold",x().lowDecodeThreshold/5),this.TAG="DecodeEstimate",this._needEstimate=!0,this._parent=t,this._lastDecodeDot=0,this._lastDecodeCost=0,this._lastFrameDts=0,this._dtsDeltas=[],this._decodeCosts=[],this._lowDecodeQueue=[],this._fps=0,this._decodeFps=0,this._gopLength=0,this._webcodec=!1}return o(e,[{key:"fps",get:function(){return this._fps}},{key:"decodeFps",get:function(){return this._decodeFps}},{key:"decodeCost",get:function(){return this._lastDecodeCost}},{key:"gopLength",get:function(){return this._gopLength}},{key:"webcodec",set:function(e){this._webcodec=e}},{key:"updateGopCount",value:function(){this._gopLength++}},{key:"needEstimateFps",value:function(){this._needEstimate=!0}},{key:"addDecodeInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{dts:0};this._estimateDecodeFps(e),this._estimateFps(e)}},{key:"resetDecodeDot",value:function(e){this._lastDecodeDot=e||0}},{key:"reset",value:function(){this._decodeCosts=[],this._lowDecodeQueue=[]}},{key:"_estimateFps",value:function(e){if(this._needEstimate)if(this._lastFrameDts){var t=e.dts-this._lastFrameDts;if(this._lastFrameDts=e.dts,!(Math.abs(t)>200)){this._dtsDeltas.push(t);var i=this._dtsDeltas.length;i<5||(this._fps=Math.ceil(1e3/this._avg(this._dtsDeltas,i)),V.log(this.TAG,"estimate fps:",this._fps),this._needEstimate=!1)}}else this._lastFrameDts=e.dts}},{key:"_estimateDecodeFps",value:function(e){if(this._lastDecodeDot){var t=performance.now(),i=t-this._lastDecodeDot;this._lastDecodeDot=t,e.cost=i,this._lastDecodeCost=i,this._decodeCosts.push(i);var n=this._decodeCosts.length;if(!(n<5)){var r=this._avg(this._decodeCosts,n);this._decodeFps=Math.floor(1e3/r),this._decodeCosts=[],this._lowDecodeDetect()}}else this._lastDecodeDot=performance.now()}},{key:"_avg",value:function(e,t){var i=e.reduce((function(e,t){return e+=t}),0);return Math.floor(i/t)||1}},{key:"_lowDecodeDetect",value:function(){this._decodeFps?(this._decodeFps<this._fps*this._parent.playbackRate+(this.webcodec?0:3)?this._lowDecodeQueue.push(this._decodeFps):this._lowDecodeQueue.pop(),this._lowDecodeQueue.length>this._lowDecodeThreshold&&(this._lowDecodeQueue=[],V.log(this.TAG,"解码效率过低,应该降级"),this._parent.emit(te.DECODE_LOW_FPS))):this._parent.emit(te.DECODE_LOW_FPS)}}]),e}(),xi=[],Bi=function(){function e(t){var i=this;s(this,e),u(this,"_doTask",(function(){var e;null===(e=i._task)||void 0===e||e.call(i)})),this._task=t;var n=new Blob(["\n var timer;\n\n function initTimer (interval) {\n destroy()\n clearInterval(timer);\n timer = setInterval(() => {\n self.postMessage({type: 'NEXT_TICK'});\n }, interval)\n }\n\n function destroy () {\n clearInterval(timer);\n }\n\n self.onmessage = function (e) {\n var {type,interval} = e.data;\n switch (type) {\n case 'START':\n initTimer(interval);\n break;\n case 'DESTROY':\n destroy();\n break;\n }\n }\n"],{type:"application/javascript"});this._worker=xi.pop()||new Worker(URL.createObjectURL(n)),this._bindEvent()}return o(e,[{key:"_bindEvent",value:function(){this._worker.addEventListener("message",this._doTask)}},{key:"start",value:function(e){(e=parseInt(e))<10&&(e=10),e>60?e=60:e>25&&(e=25),this._worker.postMessage({type:"START",interval:e})}},{key:"stop",value:function(){this._worker.postMessage({type:"DESTROY"})}},{key:"destroy",value:function(){this._worker&&(this._worker.postMessage({type:"DESTROY"}),this._worker.removeEventListener("message",this._doTask),xi.push(this._worker),V.log("TickTimer","unbind timer event"),this._worker=null,this._task=null)}}]),e}(),Ui=function(e){A(i,e);var t=p(i);function i(e,n){var r;return s(this,i),(r=t.call(this,e,n))._timeRange=new Vi(m(r)),r._decodeEstimate=new Fi(m(r)),r._frameQueue=new Gi(m(r)),r._lastTimeupdate=0,r._renderCost=0,r._canAutoPlay=!0,r._videoDecode=!1,r._inSeeking=!1,r._frameRender=null,r._configuration=null,r._render=r._render.bind(m(r)),r._tickTimer=new Bi(r._render),r._initCanvas(e),r._bindEvents(),r}return o(i,[{key:"canAutoPlay",get:function(){return this._canAutoPlay}},{key:"canvas",get:function(){return this._canvas}},{key:"timescale",get:function(){return 1e3}},{key:"fps",get:function(){return this._decodeEstimate.fps||this._meta&&this._meta.fpsNum/this._meta.fpsDen||24}},{key:"decodeFps",get:function(){return this._decodeEstimate.decodeFps}},{key:"decodeCost",get:function(){return this._decodeEstimate.decodeCost}},{key:"renderCost",get:function(){return this._renderCost}},{key:"totalSize",get:function(){return this._timeRange.totalSize}},{key:"bitrate",get:function(){return this._timeRange.bitrate},set:function(e){this._timeRange.bitrate=e}},{key:"gopLength",get:function(){return this._decodeEstimate.gopLength}},{key:"is540p",get:function(){return this._canvas.height<720}},{key:"buffered",get:function(){return this._timeRange.buffered}},{key:"inSeeking",get:function(){return this._inSeeking}},{key:"interval",get:function(){return Math.floor(1e3/this.fps/this.playbackRate)}},{key:"playbackRate",get:function(){return this._playbackRate||1}},{key:"baseDts",get:function(){return this._timeRange.baseDts}},{key:"currentTime",get:function(){return this._timeRange.getCurrentTime(this.preciseVideoDts)}},{key:"timelinePosition",get:function(){return this._parent.timelinePosition}},{key:"lastTimelinePosition",get:function(){return this._lastTimelinePosition||0},set:function(e){this._lastTimelinePosition=e}},{key:"audioSyncDts",get:function(){return this._audioDts||this.baseDts},set:function(e){this._audioDts=e}},{key:"preciseVideoDts",get:function(){return this.audioSyncDts+Math.floor(1e3*(this.timelinePosition-this.lastTimelinePosition))}},{key:"readyState",get:function(){var e=this._frameQueue.length||(this.currentTime?1:0);return e?e>=8?4:e>=4?3:e>=2?2:1:0}},{key:"isHevc",get:function(){return!("hev1.1.6.L93.B0"!==(this._meta||{}).codec)}},{key:"videoDecode",get:function(){return this._videoDecode}},{key:"decoderMode",get:function(){var e;return null===(e=this._decodeController)||void 0===e?void 0:e.decoderMode}},{key:"configuration",get:function(){var e,t;return this._configuration||(this._configuration=this._meta.configuration||I(null===(e=this._meta)||void 0===e?void 0:e.sps[0],null===(t=this._meta)||void 0===t?void 0:t.pps[0])),this._configuration},set:function(e){this._configuration=e.configuration||I(e.sps[0],e.pps[0])}},{key:"setSeekingStatus",value:function(e){this._inSeeking=e}},{key:"getDtsOfTime",value:function(e){return this._timeRange.getDtsOfTime(e)}},{key:"updateReady",value:function(){this._whenReady()}},{key:"forceRender",value:function(){this._render(!0)}},{key:"getSeekStartPosition",value:function(e,t){return this._timeRange.getSeekStartPosition(e,t)}},{key:"canSeek",value:function(){throw new Error("need override by children")}},{key:"emitResizeEvent",value:function(){null==this||this._emitTimelineEvents(ie.PLAY_EVENT,q.RESIZE)}},{key:"_assembleErr",value:function(e,t){var i=new Error(e);return i.code=3,i.subCode=t,i}},{key:"_emitTimelineEvents",value:function(e,t,i){var n;null===(n=this._parent)||void 0===n||n.emit(e,t,i)}},{key:"_initCanvas",value:function(e){e.canvas?this._canvas=e.canvas:this._canvas=Li.getCachedCvs()||document.createElement("canvas"),this._canvas.style.margin="auto",this._canvas.style.position="absolute",this._canvas.style.pointerEvents="none"}},{key:"_bindEvents",value:function(){var e=this;y(d(i.prototype),"_bindEvents",this).call(this);var t=function(t){var i=t.width,n=t.height,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=e._canvas,o=a.width,u=a.height,A=n*o/u,d=i*u/o,c=i-A,h=n-d,l=c*r+"px",f=h*s+"px";e._canvas.style.left=l,e._canvas.style.top=f,V.warn(e.TAG,"cvsWidth=".concat(o,", cvsHeight=").concat(u,", scaleCvsWidth=").concat(A,", scaleCvsHeight=").concat(d)),V.warn(e.TAG,"cover position: deltaX=".concat(c,", deltaY=").concat(h,", width=").concat(i,", height=").concat(n,", pX=").concat(l,", pY=").concat(f))};this._parent.on(te.UPDATE_VIDEO_FILLTYPE,(function(i,n){var r=n.width,s=n.height,a=e._canvas,o=a.width,u=a.height,A=!r||r/s>o/u;if(V.warn(e.TAG,"UPDATE_VIDEO_FILLTYPE isGapX =",A,"type =",i,o,u,r,s),e._canvas.style.maxWidth="initial",e._canvas.style.maxHeight="initial","cover"===i)return A?(e._canvas.style.left=0,e._canvas.style.top=0,e._canvas.style.height="auto",e._canvas.style.width="100%",void t({width:r,height:s},0,.5)):(e._canvas.style.left=0,e._canvas.style.top=0,e._canvas.style.width="auto",e._canvas.style.height="100%",void t({width:r,height:s},.5,0));if("fill"===i)return e._canvas.style.width="100%",void(e._canvas.style.height="100%");(e._canvas.style.top=0,e._canvas.style.bottom=0,e._canvas.style.left=0,e._canvas.style.right=0,e._canvas.style.maxWidth="100%",e._canvas.style.maxHeight="100%",e._canvas.style.width="initial",e._canvas.style.height="initial",o<r&&u<s)&&(o/r>u/s?e._canvas.style.width="100%":e._canvas.style.height="100%")})),this._parent.on(te.UPDATE_VIDEO_COVER_POSITION,t),this._parent.on(ie.SYNC_DTS,(function(t){var i,n=e._frameQueue.nextFrame(),r=n&&n.info&&n.info.dts;if(e.lastTimelinePosition=e.timelinePosition,e.noAudio){var s=e._timeRange.nextFrame();t=t||r||s&&s.dts||0}if(e.audioSyncDts=t,r&&r-t>500&&e._emitTimelineEvents(ie.PLAY_EVENT,q.LARGE_AV_GAP,{aDts:t,vDts:r,frameLength:e._frameQueue.length,currentTime:e._parent.currentTime,duration:e._parent.duration}),V.log(e.TAG,"audio current buffer play finish, next buffer dts=",t,"currentTime:",e._parent.currentTime,"preciseVideoDts:",e.preciseVideoDts,"next video frame dts:",r,"frame length:",e._frameQueue.length),!(e._isLive||null!==(i=e._parent)&&void 0!==i&&i.seeking)){var a=e._timeRange.nextFrame();if(a){var o=(a.dts-a.baseDts)/1e3;e._parent.currentTime-o>1&&(V.warn(e.TAG,"丢帧!"),e.ajustSeekTime(e._parent.currentTime))}}})),this._parent.on(ie.UPDATE_GL_OPTIONS,(function(t){e._config.glCtxOptions=t})),this._parent.on(ie.UPDATE_SEGMENT_END,this._updateSegmentEnd.bind(this)),this.on(te.AUTO_RUN,this._startRender.bind(this)),this._parent.on(ie.SET_PLAYBACKRATE,(function(t){e._playbackRate=t,e._startRender()}))}},{key:"ajustSeekTime",value:function(){throw new Error("need override by children")}},{key:"_resetDts",value:function(e,t){"audio"!==t&&this._timeRange.resetDts(e)}},{key:"_setMetadata",value:function(e,t){if("audio"!==e){V.warn(this.TAG,"video set metadata"),this._meta=t;var i=t&&t.frameRate&&t.frameRate.fps;i?V.log(this.TAG,"detect fps:",i):V.warn(this.TAG,"no detect fps,start estimate"),this._initDecoder()}}},{key:"_initDecoder",value:function(){throw new Error("need override by children")}},{key:"_whenDecoderReady",value:function(){throw new Error("need override by children")}},{key:"_appendChunk",value:function(){throw new Error("need override by children")}},{key:"_startDecode",value:function(){throw new Error("need override by children")}},{key:"_receiveFrame",value:function(e,t){if(this._parent&&this._timeRange){var i=e.info||{};if(this._decodeEstimate.addDecodeInfo(i),!this._isLive&&((i.output||i.keyframe)&&(this.setSeekingStatus(!1),V.warn(this.TAG,"set seeking status=",!1)),this.inSeeking))return V.log(this.TAG,"drop frame"),void Ii(e);this._isLive?this._frameQueue.append(e):this._frameQueue.appendVodFrame(e),t&&t(),this._ready||this.readyState>=1&&this._whenReady()}}},{key:"_startRender",value:function(){V.log(this.TAG,"start render"),this._tickTimer.start(this.interval)}},{key:"_render",value:function(){throw new Error("need override by children")}},{key:"_updateSegmentEnd",value:function(){throw new Error("need override by children")}},{key:"_whenReady",value:function(){this._ready=!0,this.emit(te.VIDEO_READY),this.noAudio&&this._emitTimelineEvents(ie.PLAY_EVENT,q.PLAYING)}},{key:"_doPlay",value:function(){this._tickTimer.start()}},{key:"_doPause",value:function(){this._tickTimer.stop()}},{key:"_doSeek",value:function(){this._ready=!1,this._frameQueue.destroy()}},{key:"_doChaseFrame",value:function(){throw new Error("need override by children")}},{key:"destroy",value:function(e){var t,i,n,r;null===(t=this._tickTimer)||void 0===t||t.destroy(),null===(i=this._timeRange)||void 0===i||i.destroy(),null===(n=this._frameQueue)||void 0===n||n.destroy(),null===(r=this._frameRender)||void 0===r||r.destroy(e),this._tickTimer=null,this._canvas=null,this._timeRange=null,this._frameQueue=null,this._frameRender=null,this._decodeEstimate=null,this._parent=null,this.removeAllListeners()}}]),i}(re),Ni=function(e){A(i,e);var t=p(i);function i(e){var n;return s(this,i),(n=t.call(this)).TAG="VideoDecoder",n._video=n._createVideo(),n._IsInDecoding=!1,n._fps=0,n._framId=null,n._screenShotNum=0,n._allPicNum=0,n._currentBlob=null,n._basePTS=0,n._totleTime=0,n._isVideoONRun=!0,n.firstEmit=!1,n.ptsArray=[],n._currentCanvasHeight=0,n._canvasList=[],n._realFrameDuration=25,n._maxVideoHeight=e.maxVideoHeight||720,n._minFPSTime=0,n._maxFPSTime=0,n._playFailed=!1,n._isPhoneSafari=!1,n._createCanvasList(),n._bindEvents(),n}return o(i,[{key:"_createCanvasList",value:function(){this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d",{alpha:!1});for(var e=0;e<45;e++){var t=this._createCanvas(),i=t.dom,n=t.ctx;this._canvasList.push({dom:i,ctx:n})}}},{key:"_createCanvas",value:function(){var e=document.createElement("canvas"),t=e.getContext("2d");return{dom:e,ctx:t}}},{key:"_createVideo",value:function(){var e=document.createElement("video");return e.setAttribute("muted",!0),e.setAttribute("autoplay",!0),e.setAttribute("controls",!0),e.setAttribute("webkit-playsinline",!0),e.setAttribute("playsinline",!0),e.setAttribute("x5-video-player-type","h5"),e.setAttribute("x5-video-player-type","h5-page"),e.style.position="absolute",e}},{key:"_initVideo",value:function(e,t){if(e.blobUrl&&void 0!==e.dts){var i=e.blobUrl;this._currentBlob=i,this._basePTS=e.dts,this._currentDuration=e.duration;try{V.log(this.TAG,"_initVideo, basePTS:",e.dts),this._setVideoSrc(i,t),this._video.paused&&this._videoPlay("_initVideo")}catch(vn){console.error(this.TAG,"_initVideo, load error",vn)}}else console.error(this.TAG,"_initVideo","input info is error, blobUrl:",e.blobUrl,"dts:",e.dts)}},{key:"_setVideoSrc",value:function(e,t){try{var i=this._video;i.src=e,i.load(),i.playbackRate=2}catch(vn){console.error(this.TAG,"_setVideoSrc",vn)}}},{key:"_videoPlay",value:function(e){var t=this,i=this._video;if(V.log(this.TAG,"_videoPlay, video is pause:",i.paused,e),i&&i.paused){var n=i.play();void 0!==n&&n.then((function(){t._playFailed=!1,V.log(t.TAG,"_videoPlay success")})).catch((function(e){console.error(t.TAG,"_videoPlay failed,",e.message),t._playFailed=!0,t.emit(ne.PLAY_FAILED,t.firstEmit)}))}}},{key:"_removeEvents",value:function(){var e=this._video;e.removeEventListener("playing",this._onPlaying.bind(this)),e.removeEventListener("ended",this._onEnded.bind(this)),e.removeEventListener("error",this._onError.bind(this)),e.removeEventListener("loadeddata",this._onLoadeddata.bind(this)),e.removeEventListener("timeupdate",this._onTimeUpdate.bind(this))}},{key:"_bindEvents",value:function(){var e=this,t=this._video;t?(document.addEventListener("visibilitychange",this._onVisibilityChange.bind(this)),t.addEventListener("playing",this._onPlaying.bind(this)),t.addEventListener("ended",this._onEnded.bind(this)),t.addEventListener("error",this._onError.bind(this)),t.addEventListener("loadeddata",this._onLoadeddata.bind(this)),t.addEventListener("timeupdate",this._onTimeUpdate.bind(this)),t.addEventListener("pause",(function(){V.log("on pause, currentTime, duration:",e._vCurrentTime,e._vDuration)})),this.on("outputresolutionchange",this._onChange.bind(this)),this.on("fpsreduce",(function(t){e._adaptFrameDuration(t)}))):console.error(this.TAG,"_bindEvents")}},{key:"_onTimeUpdate",value:function(){this._lastCurrentTime=this._vCurrentTime}},{key:"_onVisibilityChange",value:function(){this._isVideoONRun="visible"===document.visibilityState}},{key:"_onChange",value:function(e,t){this._width=e,this._height=t}},{key:"_onPlaying",value:function(){this._IsInDecoding&&(console.warn(this.TAG,"_onPlaying","last video not correct end"),this._framId&&(window.cancelAnimationFrame(this._framId),this._framId=null)),V.log(this.TAG,"_onPlaying, video duration:",this._vDuration,"currentTime:",this._vCurrentTime,"_lastPts:",this._lastPts),this._isInDecoding=!0,this._lastCurrentTime=this._vCurrentTime,this.ptsArray=[],this.playingTime||(this.playingTime=!0),this._getFrame()}},{key:"_onEnded",value:function(e,t){V.log(this.TAG,"_onEnded","current fmp4 duration is:",this._vDuration,"_isInDecoding:",this._isInDecoding,"_lastPts:",this._lastPts,"_realFrameDuration:",this._realFrameDuration,"from:",t),this._isInDecoding&&(this._isInDecoding=!1,this._lastMp4Duration=Math.min(this._vDuration,this._vCurrentTime),this._framId&&(V.log(this.TAG,"_onEnded","cancelAnimationFrame"),window.cancelAnimationFrame(this._framId),this._framId=null),this._decodeFPS=parseInt(this._screenShotNum/(this._vDuration/1e3)),this.emit("fps",this._screenShotNum,this._totleTime,this._vDuration,this._metaFPS,{height:this._currentCanvasHeight,relHeight:this._video.videoHeight}),V.log("_timePerFrame",this._totleTime/this._screenShotNum),this._timePerFrame=this._totleTime/this._screenShotNum,this._screenShotNum=0,this._allPicNum=0,this._totleTime=0,this._currentBlob&&(URL.revokeObjectURL(this._currentBlob),this._currentBlob=null,this._basePTS=0),this.emit(ne.FRAGMENT_END,this._decodeFPS,this._video.duration))}},{key:"_onError",value:function(){this._isInDecoding=!1;var e=this._video;console.error("video error:",e.error.code,e.error.message),this.emit("error",e.error,this.firstEmit)}},{key:"_onLoadeddata",value:function(){var e=this,t=this._video;t.currentTime=.001,this.firstEmit||(this._playFailed?(t.style.visibility="hidden",this.emit(ne.APPEND_VIDEO,t),setTimeout((function(){V.log(e.TAG,"onloadeddata, setTimeout firstEmit:",e.firstEmit),e._getFirstFrame()}),40)):(V.log(this.TAG,"onloadeddata, firstEmit:",this.firstEmit),this._getFirstFrame()))}},{key:"_getFirstFrame",value:function(){this.firstTime=Date.now();var e=this._vCurrentTime,t=this._basePTS+e,i=this._getImageData(t).imageData;this.firstEmit=!0,this.emit(ne.FIRST_FRAME,i,t)}},{key:"_getFrame",value:function(){var e=this._video,t=e.videoWidth,i=e.videoHeight;if(this._allPicNum++,this._isInDecoding){if(t||i){var n=this._vCurrentTime,r=this._basePTS+n;if(this.ptsArray.push(r),this._lastCurrentTime&&this._lastCurrentTime===this._vDuration&&(V.log(this.TAG,"_getFrame, video ended, lastCurrentTime",this._lastCurrentTime,"duration:",this._vDuration,"isInDecoding:",this._isInDecoding),this._onEnded(null,"getFrame")),this._lastPts&&r<=this._lastPts)return void(this._framId=window.requestAnimationFrame(this._getFrame.bind(this)));if(this._lastPts&&r-this._lastPts<this._realFrameDuration)return void(this._framId=window.requestAnimationFrame(this._getFrame.bind(this)));this._screenShotNum++;var s,a=null,o=Date.now();try{a=(s=this._getImageData(r)).imageData}catch(vn){console.error(vn,s,this._canvasList.length)}this._lastPts=r;var u=Date.now()-o;return this._totleTime+=u,this.emit(ne.DECODED,a,r),void(this._framId=window.requestAnimationFrame(this._getFrame.bind(this)))}this._framId=window.requestAnimationFrame(this._getFrame.bind(this))}else this._framId&&(window.cancelAnimationFrame(this._framId),this._framId=null)}},{key:"_getImageData",value:function(){var e,t=this._video,i=t.videoWidth,n=t.videoHeight,r=i,s=n;this._width&&this._height&&(r=this._width,s=this._height),s>this._maxVideoHeight&&(s=this._maxVideoHeight,r=parseInt(s*(i/n))),(e=this._canvasList.shift())||(console.warn(this.TAG,"_getImageData, _canvansList length is 0"),e=this._createCanvas()),e.width=r,e.height=s;var a=e.dom,o=e.ctx;if(this._currentCanvasHeight=s,!a)return{imageData:e};a.width!==r&&(a.width=r,a.height=s);try{n&&i&&r&&s&&o.drawImage(t,0,0,i,n,0,0,r,s)}catch(vn){console.error(this.TAG,"_getImageData, drawImage:",vn)}return{imageData:e}}},{key:"_adaptFrameDuration",value:function(e){e<15?this._minFPSTime++:this._minFPSTime=0,e>30?this._maxFPSTime++:this._maxFPSTime=0,this._minFPSTime>0&&this._decodeFPS<15&&(this._realFrameDuration-=this._timePerFrame,this._realFrameDuration<15&&(this._realFrameDuration=15),this._minFPSTime=0),this._maxFPSTime>0&&this._decodeFPS>30&&(this._realFrameDuration+=this._timePerFrame,this._maxFPSTime=0)}},{key:"_vDuration",get:function(){return parseInt(1e3*this._video.duration)}},{key:"_vCurrentTime",get:function(){return parseInt(1e3*this._video.currentTime)}},{key:"_reset",value:function(){this._isInDecoding=!1,this._lastPts=0,this._screenShotNum=0,this._allPicNum=0,this._totleTime=0}},{key:"reStartDecode",value:function(){this._video.pause(),this._reset();var e=this._currentBlob,t=this._basePTS;this._framId&&(window.cancelAnimationFrame(this._framId),this._framId=null),this._initVideo({blobUrl:e,dts:t})}},{key:"doSeek",value:function(e){if(this._isInDecoding){if(e<=0)return;var t=this._vCurrentTime/1e3+e>=this._vDuration/1e3?this._vDuration/1e3:this._vCurrentTime/1e3+1;console.error("doSeek",t),this._video.currentTime=t}}},{key:"pause",value:function(){this._isInDecoding&&this._video.pause()}},{key:"play",value:function(){if(this._isInDecoding&&this._video.paused)return V.log("video play",this._vCurrentTime),this._video.play()}},{key:"startDecode",value:function(e,t,i){this._initVideo(e,i),this._metaFPS=t}},{key:"stopDecode",value:function(){this._video.paused||(this._video.pause(),this._reset())}},{key:"canPlayType",value:function(e){return this._video.canPlayType(e)}},{key:"destroy",value:function(){this._isInDecoding=!1,window.cancelAnimationFrame(this._framId),this._video.pause(),this._removeEvents()}},{key:"videoWidth",get:function(){return this._video?this._video.videoWidth:0}},{key:"videoHeight",get:function(){return this._video?this._video.videoHeight:0}}]),i}(z),Pi=[{base:720,level:1},{base:540,level:2},{base:360,level:3},{base:280,level:4}],Oi=function(e){A(i,e);var t=p(i);function i(e,n){var r;return s(this,i),(r=t.call(this)).TAG="VideoDecoderController",r._decoder=new Ni(e),r._remux=new si,r._bindEvents(),r._isInit=!1,r._isDataReady=!1,r._ready=!1,r._blobURLList=[],r._isInDecoding=!1,r._mediaSegmentReady=!1,r._parent=n,r._isDecodePause=!1,r._playSuccess=!0,r._isVideoOnRun=!0,r._startDts=0,r._fDuration=0,r._minFPSTime=0,r._lastPts=0,r._frameLengthPerFragment=0,r._gopBufferLength=0,r._maxGopDuration=0,r._minGopDuration=0,r._currentLevel=-1,r._endLevel=e.endLevel||2,r.currentFragmentDuration=0,r._handleKeyFrameVideo=r._handleKeyFrameVideo.bind(m(r)),r}return o(i,[{key:"_bindEvents",value:function(){var e=this;document.addEventListener("visibilitychange",this._onVisibilityChange.bind(this)),this._decoder.on(ne.APPEND_VIDEO,this._onAppendVideo.bind(this)),this._decoder.on(ne.PLAY_FAILED,this._onPlayFailed.bind(this)),this._decoder.on("error",this._onError.bind(this)),this._decoder.on(ne.DECODED,this._onDecoded.bind(this)),this._decoder.on(ne.FIRST_FRAME,this._onFirstFrame.bind(this)),this._decoder.on(ne.FRAGMENT_END,this._onFragmentEnd.bind(this)),this._decoder.on("fps",(function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var r=[e._metaFPS].concat(i,[e._frameLengthPerFragment]);e.emit.apply(e,["fps"].concat(b(r)))})),this.on("keyFrame",this._handleKeyFrameVideo)}},{key:"_onRemuxed",value:function(e){var t={blobUrl:this._createBlobURL(e),dts:this.currentFragmentDts,duration:this.currentFragmentDuration,frameDuration:Math.floor(1e3/this._metaFPS)};this._recordGopDuration(this.currentFragmentDuration),this._pushBlob(t),V.log(this.TAG,"_onRemuxed","maxgopduration:",this._maxGopDuration,"_gopBufferLength:",this._gopBufferLength),!this._isDataReady&&this._gopBufferLength>=this._maxGopDuration&&this._checkDataReady()}},{key:"_onPlayFailed",value:function(e){this._isInDecoding=!1,this._parent.emit(ne.PLAY_FAILED,e)}},{key:"_onAppendVideo",value:function(e){this._parent.emit(ne.APPEND_VIDEO,e)}},{key:"_onVisibilityChange",value:function(){this._isVideoOnRun="visible"===document.visibilityState}},{key:"_onDecoded",value:function(e,t){this._frameLengthPerFragment++;var i=this._buildFrameInfo(e,t);this._parent.emit(ne.DECODED,i),this._lastPts=t}},{key:"_onFirstFrame",value:function(e,t){var i=this._buildFrameInfo(e,t);this._parent.emit(ne.FIRST_FRAME,i)}},{key:"_onFragmentEnd",value:function(e,t){var i=this;V.log(this.TAG,"_onFragmentEnd ,_isDecodePause:",this._isDecodePause,"decodeFPS:",e),e&&this._reduceResolution(e),this._isInDecoding=!1,this._inDecodeId=-1,this._currentInfo=null,this._frameLengthPerFragment=0,this._getBlobLength()&&!this._isDecodePause?this.startDecode():this.loadNextHandle=setInterval((function(){i._getBlobLength()&&!i._isDecodePause&&i._isVideoOnRun&&!i._isInDecoding&&(V.log(i.TAG,"_onFragmentEnd, setInterval start next mp4 decode"),i.startDecode(),clearInterval(i.loadNextHandle))}))}},{key:"_onError",value:function(e,t){this._isInDecoding=!1,this._parent.emit("error",e,t)}},{key:"_checkReady",value:function(){this._isDataReady&&this._isInit&&(this.ready=!0,V.log(this.TAG,"checkReady trigger ready"),this._parent.emit(ne.READY))}},{key:"_checkDataReady",value:function(){this._isDataReady=!0,this._checkReady()}},{key:"_reduceResolution",value:function(e){if(V.log(this.TAG,"_reduceResolution","currentLevel:",this._currentLevel,"endLevel:",this._endLevel),this._videoHeight>720&&(V.log(this.TAG,"_reduceResolution","trigger DECODE_LOW_FPS"),this._parent.emit(te.DECODE_LOW_FPS)),e&&e<20?(this._minFPSTime++,this._decoder.emit("fpsreduce",e)):this._minFPSTime=0,this._currentLevel>=this._endLevel)return V.log(this.TAG,"_reduceResolution","trigger DECODE_LOW_FPS",this._currentLevel,this._endLevel),void this._parent.emit(te.DECODE_LOW_FPS);if(this._minFPSTime>2){var t,i=this._videoWidth,n=this._videoHeight;if(t=this._findLevel(n,this._currentLevel)){if(this._currentLevel=t.level,4===this._currentLevel)return V.log(this.TAG,"_reduceResolution","trigger DECODE_LOW_FPS, _currentLevel: ",this._currentLevel),void this._parent.emit(te.DECODE_LOW_FPS);this.width=t.base*(i/n),this.height=t.base,this._decoder.emit("outputresolutionchange",this.width,this.height)}this._minFPSTime=0}}},{key:"_findLevel",value:function(e,t){return Pi.find((function(i){return i.base<e&&i.level>t}))}},{key:"_buildFrameInfo",value:function(e,t){try{var i=e.width,n=e.height;return{msg:"DECODED",width:i,height:n,buffer:e,yLinesize:i,uvLinesize:i/2,info:{baseDts:void 0,dts:t,gopId:0,isGop:void 0,key:!1,pts:t},type:"rgb"}}catch(vn){V.log(this.TAG,vn)}}},{key:"_pushBlob",value:function(e){V.log("push blob",e.dts,e.duration),e&&e.duration&&(this._gopBufferLength+=e.duration),this._blobURLList.push(e)}},{key:"_shiftBlob",value:function(){var e=this._blobURLList.shift();return e&&e.duration&&(this._gopBufferLength-=e.duration),e}},{key:"_filterBlob",value:function(e){var t=this;this._blobURLList=this._blobURLList.filter((function(i){return i.dts<e&&(URL.revokeObjectURL(i.blobUrl),i.duration&&(t._gopBufferLength-=i.duration)),i.dts>=e}))}},{key:"_emptyBlobList",value:function(){this._blobURLList=[],this._gopBufferLength=0}},{key:"_getBlobLength",value:function(){return this._blobURLList.length}},{key:"_handleKeyFrameVideo",value:function(e){try{var t=this._parent._timeRange.frames||[];if(this._parent._timeRange.clean(),!t.length)return;var i=t[0].dts,n=t[t.length-1].dts,r=i-this.endDts;V.log(this.TAG,"_handleKeyFrameVideo","startDts:",i,"endDts:",n,"samples length:",t.length),this.endDts&&r>Math.floor(1e3/this._metaFPS)+1&&V.log(this.TAG,"_handleKeyFrame, keyFrame dts:",i,"sample length:",t.length,"endDts:",n,"delay:",r);var s=n-i;if(this._fDuration||(this._fDuration=s),s<1500)return void V.log(this.TAG,"_handleKeyFrame gopDuration :",s,"sample length:",t.length,"gopStartDts:",i,"gopEndDts:",n);if(this.firstDts||(this.firstDts=t[0].dts),this.currentFragmentDts=t[0].dts,this.currentFragmentDuration=this._getFragmentDuration(t),this.endDts=n,this.currentFragmentDts<this._startDts)return console.warn(this.TAG,"_handleKeyFrameVideo","currentFragmentDts < this._startDts",this.currentFragmentDts,this._startDts),void(t=[]);this.startRemux(t),t=[]}catch(vn){console.error(this.TAG,"_handleKeyFrameVideo",vn)}}},{key:"_getFragmentDuration",value:function(e){var t=0,i=0;return e[0].keyframe||console.error(this.TAG,"_getFragmentDuration","gop firstFrame is not keyframe"),e.forEach((function(n,r){n.keyframe&&r&&(t+=e[r-1].dts-e[i].dts,i=r)})),t+=e[e.length-1].dts-e[i].dts}},{key:"_createBlobURL",value:function(e){if(e){var t=new window.Blob([e.buffer],{type:"video/mp4"});return window.URL.createObjectURL(t)}}},{key:"_recordGopDuration",value:function(e){var t=e;this._minGopDuration||(this._minGopDuration=t),t>this._maxGopDuration&&(this._maxGopDuration=t),t<this._minGopDuration&&(this._minGopDuration=t)}},{key:"checkMaxFrames",value:function(e){"number"==typeof e&&(this._isDecodePause=e>40,this._playSuccess&&this._isDecodePause&&this._decoder.pause())}},{key:"checkMinFrames",value:function(e){var t=this;if("number"==typeof e&&(this._isDecodePause=!(e<25),!this._isDecodePause)){var i=this._decoder.play();void 0!==i?i.then((function(){t._playSuccess=!0})).catch((function(){t._playSuccess=!1})):setTimeout((function(){t._playSuccess=!0}),20)}}},{key:"frameRendend",value:function(e){if(e.dom){if(e.dom.width=0,e.dom.height=0,this._decoder._canvasList.length>40)return;this._decoder._canvasList.push(e)}else V.error(this.TAG,"_onRendend","imageObj. is error",e)}},{key:"checkValidBlob",value:function(e){this._filterBlob(e)}},{key:"chaseVideoFrame",value:function(e){V.log(this.TAG,e,e.frame.dts,this.currentFragmentDts);var t=e.frame.dts;if(this._startDts=t,t===this.currentFragmentDts){if(V.log(this.TAG,"_onChaseFrame","_inDecodeId:",this._inDecodeId,"currentFragmentDts:",this.currentFragmentDts),this._inDecodeId>0&&this._inDecodeId<t)return V.log(this.TAG,"_onChaseFrame, _inDecodeId > 0 && _inDecodeId < startDts, _inDecodeId:",this._inDecodeId,"startDts:",t),this.stopDecode(),this._filterBlob(t),void this.startDecode();if(this._inDecodeId===t)return V.log(this.TAG,"_onChaseFrame, _inDecodeId === startDts, startDts:",t),this.stopDecode(),void this.reStrartDecode(this._currentInfo);-1===this._inDecodeId&&(V.log(this.TAG,"_onChaseFrame","_inDecodeId==-1"),this.startDecode())}t>this.currentFragmentDts&&(V.log(this.TAG,"_onChaseFrame, startDts > currentFragmentDts, startDts:",t,"currentFragmentDts:",this.currentFragmentDts),this.stopDecode(),this._emptyBlobList()),t<this.currentFragmentDts&&(V.log(this.TAG,"_onChaseFrame, startDts < currentFragmentDts, startDts:",t,"currentFragmentDts:",this.currentFragmentDts),t>this._inDecodeId&&(this._filterBlob(t),this.stopDecode(),this.startDecode()))}},{key:"init",value:function(e){this._isInit||(this._metaFPS=e.fpsNum/e.fpsDen||25,this._videoWidth=e.width,this._videoHeight=e.height,this._width=this._videoWidth,this._height=this._videoHeight,this._frameDuration=parseInt(1e3/this._metaFPS),this._isInit=!0,V.log("".concat(this.TAG," has inited")),this._isInit=!0,this._checkReady())}},{key:"reStrartDecode",value:function(e){if(e)try{V.log(this.TAG,"reStrartDecode"),this._isInDecoding=!0,this._inDecodeId=e.dts,this._currentInfo=e,this._decoder.startDecode(e,this._metaFPS,this._startTime),this._startTime=0}catch(vn){console.error("load error",vn)}}},{key:"stopDecode",value:function(){this._isInDecoding=!1,this._inDecodeId=-1,this._currentInfo=null,this._frameLengthPerFragment=0,this._decoder.stopDecode()}},{key:"startDecode",value:function(){if(this._isInDecoding)V.log(this.TAG,"startDecode","this decoder is in decoding");else{var e=this._getBlobLength();if(this._decoder&&e){V.log(this.TAG,"startDecode","blob url length:",e);var t=this._shiftBlob()||{};try{V.log(this.TAG,"startDecode",t.dts,t.duration),this._isInDecoding=!0,this._inDecodeId=t.dts,this._currentInfo=t,this._decoder.startDecode(t,this._metaFPS)}catch(vn){console.error(this.TAG,"startDecode","load error",vn)}}}}},{key:"canSeek",value:function(e){var t=e.frame.dts;return!!(this.currentFragmentDts>=t&&this._isInDecoding)&&(this._inDecodeId!==t&&this._inDecodeId<t)}},{key:"startRemux",value:function(e){if(V.log("startRemux samples length:",e.length),e.length){var t=this._parent._meta;t.samples=e;var i=this._remux.remux(t).videoSegment;this._onRemuxed(i)}else console.error("frame length is 0")}},{key:"canPlayType",value:function(e){if(this._decoder)try{return this._decoder.canPlayType('video/mp4;codecs="'+e.codec+'"')}catch(vn){console.error(vn)}}},{key:"destroy",value:function(){this._blobURLList=[],this._decoder.destroy()}},{key:"empty",value:function(){if(V.log("empty"),this._decoder){var e=this._decoder._canvasList;return V.log(this.TAG,"empty >>>>>>>>>>>>>>>>>>length:",e.length),e.forEach((function(e){e.dom&&(V.log("clear >>>>>>>>>>>>>>>>>>"),e.dom.width=0,e.dom.height=0,e.dom=null)})),e.length}}},{key:"isIDLE",get:function(){return V.log(this.TAG,"isIDEL","blob length:",this._getBlobLength(),"_isInDecoding:",this._isInDecoding,"isVideoOnRun:",this._isVideoOnRun,"_isDecodePause",this._isDecodePause),!this._getBlobLength()&&!this._isInDecoding&&this._isVideoOnRun}},{key:"ready",get:function(){return this._ready},set:function(e){this._ready=e}},{key:"remux",get:function(){return this._remux}},{key:"isInit",get:function(){return this._isInit}}]),i}(z),Wi=function(e){A(i,e);var t=p(i);function i(e,n){var r;return s(this,i),(r=t.call(this,e,n)).TAG="VideoRenderFromVideo",r._videoDecodeController=new Oi(e,m(r)),r._canAutoPlay=!0,r._videoDecode=e.videoDecode,r._chaseToFrame=null,r}return o(i,[{key:"videoDecode",get:function(){return this._videoDecode},set:function(e){this._videoDecode=e}},{key:"_bindEvents",value:function(){var e=this;y(d(i.prototype),"_bindEvents",this).call(this),this.on("keyFrame",this._onKeyFrame.bind(this)),this.on(ne.READY,this._onReady.bind(this)),this.on(ne.DECODED,this._onDecoded.bind(this)),this.on(ne.PLAY_FAILED,this._onPlayFailed.bind(this)),this.on("error",this._onError.bind(this)),this.on(ne.APPEND_VIDEO,this._onAppendVideo.bind(this)),this.on(ne.FIRST_FRAME,this._onFirstFrame.bind(this)),this._parent.on(ne.CHASE_VIDEO_FRAME,this._onChaseVideoFrame.bind(this)),this._parent.on(ie.SYNC_DTS,this._onTimeLineSyncDTS.bind(this)),window.addEventListener("unload",(function(){e._empty()}))}},{key:"_onTimeLineSyncDTS",value:function(e){this._videoDecodeController.checkValidBlob(e)}},{key:"_onChaseVideoFrame",value:function(e){this._doChaseVideoFrame(e)}},{key:"_onAppendVideo",value:function(e){try{this._parent._parent.appendChild(e)}catch(vn){cosole.error(this.TAG,"onAppendVideo",vn)}}},{key:"_onKeyFrame",value:function(){V.log(this.TAG,"_onKeyFrame, keyframe"),this._videoDecodeController.emit("keyFrame")}},{key:"_onError",value:function(e,t){console.error(this.TAG,"decoder error",e,t),t||this._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,this._assembleErr(e&&e.message))}},{key:"_onReady",value:function(){if(!this._frameRender){var e=Object.assign(this._config,{meta:this._meta,canvas:this._canvas,type:"2d"});try{this._frameRender=new Zi(e,this)}catch(vn){this._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,this._assembleErr(vn&&vn.message))}}this._startDecode()}},{key:"_onFirstFrame",value:function(e){V.log(this.TAG,"onFirstFrame"),this._receiveFrame(e),this._firstFrame=!0}},{key:"_onDecoded",value:function(e){var t=this;if(this._inChaseFrame){if(this.chaseFrameAfter++,1===this.chaseFrameAfter&&this._chaseToFrame){if(this._parent.emit(ne.CHASE_VIDEO_FRAME_END,this._chaseToFrame),this._frameQueue.length)this._frameQueue.frames.forEach((function(e){t._videoDecodeController.frameRendend(e.buffer)}));this._frameQueue.empty(),this._videoDecodeController.checkMinFrames(this._frameQueue.length),this._timeRange.deletePassed(this._chaseToFrame.frame.dts),this._inChaseFrame=!1,this._chaseToFrame=null,console.warn(this.TAG,"onDecoded","_inChaseFrame end")}}else this.chaseFrameAfter=0;this._receiveFrame(e)}},{key:"_onPlayFailed",value:function(e){console.warn(this.TAG,"onPlayFailed, this._ready:",this._ready,",firstEmit:",e,",frame length:",this._frameQueue.length),this._ready||e||this._whenReady(),this._canAutoPlay=!1}},{key:"canSeek",value:function(e){return this._videoDecodeController.canSeek(e)}},{key:"_initDecoder",value:function(){this._isInit||(V.log(this.TAG,"_initDecoder"),this._videoDecodeController.isInit||this._videoDecodeController.init(this._meta),this._isInit=!0)}},{key:"_receiveFrame",value:function(e){y(d(i.prototype),"_receiveFrame",this).call(this,e),this._videoDecodeController.checkMaxFrames(this._frameQueue._frames.length)}},{key:"_setMetadata",value:function(e){V.warn(this.TAG,"video set metadata",e),this._meta=e;var t=e.fpsNum/e.fpsDen;t?V.log(this.TAG,"detect fps:",t):V.warn(this.TAG,"no detect fps,start estimate"),this._initDecoder(e)}},{key:"_doChaseVideoFrame",value:function(e){this._inChaseFrame=!0,this._chaseToFrame=e,this._videoDecodeController.chaseVideoFrame(e)}},{key:"_appendChunk",value:function(e){this._meta||this._setMetadata(e);for(var t=e.samples.slice(),i=t.length,n=0;n<i;n++){var r=t.shift();r.keyframe&&this.emit("keyFrame"),this._timeRange.append([r],this.noAudio,!1)}}},{key:"_startDecode",value:function(){this._videoDecodeController.startDecode()}},{key:"_checkToDecode",value:function(){this._startDecode()}},{key:"_startRender",value:function(){V.log(this.TAG,"_startRender interval",this.interval),this._tickTimer.start(this.interval)}},{key:"_render",value:function(e){var t=this,i=this._frameQueue.nextFrame(),n=this.preciseVideoDts;if(i&&this._timeRange){var r=i.info;if(!r)return this._frameQueue.shift(),void console.error("not info");this._renderDts=r.dts;var s=r.dts-n;if(s<-150){this.lastPrecise;var a=this._frameQueue.frames,o=this._getDeleteFrames(a,n),u=o.deleteFrames,A=o.useFrames;return a.splice(0),A.forEach((function(e){a.push(e)})),u.forEach((function(e){t._videoDecodeController.frameRendend(e.buffer)})),this._videoDecodeController.emit("renderDelay",s,this._frameQueue._frames.length),void this._videoDecodeController.checkMinFrames(this._frameQueue.length)}if(!(!e&&s>30&&s<6e4)){Math.abs(this._lastTimeupdate-r.dts)>250&&(this._emitTimelineEvents(ie.PLAY_EVENT,q.TIMEUPDATE),this._lastTimeupdate=r.dts),V.long&&V.log(this.TAG,"render delay:".concat(s," , timelinePosition:").concat(n," , dts:").concat(r.dts," , cost:").concat(r.cost," , gopID:").concat(r.gopId," , rest:").concat(this._frameQueue.length,", buffer frame:").concat(this._timeRange.frameLength));var d=performance.now();this._frameRender.render(i.buffer,i.width,i.height,i.yLinesize,i.uvLinesize),this.hasFirstFrame||e||(this.hasFirstFrame=!0,this._parent.emit(ie.PLAY_EVENT,"firstframe")),this._videoDecodeController.frameRendend(i.buffer),this._frameQueue.shift(),this._videoDecodeController.checkMinFrames(this._frameQueue.length),this._videoDecodeController.emit("renderDelay",s,this._frameQueue._frames.length),this._renderCost=performance.now()-d,e||(this.lastTime&&(this.lastPrecise,Date.now(),this.lastTime),this.lastFrameinfo=r.dts,this.lastPrecise=n,this.lastTime=Date.now(),this.lastAudioTime=this._parent.audioRender.currentTime)}}else{if(this._videoDecodeController.checkMinFrames(this._frameQueue._frames.length),this._parent._paused)return;if(!this._firstFrame)return void V.log(this.TAG,"_render","not first frame return");var c=this._videoDecodeController;if(V.log(this.TAG,",lack frame, _inDecoding:",this._videoDecodeController._isInDecoding,this._videoDecodeController._isDecodePause,",_frameQueue.length:",this._frameQueue.length),!this._frameQueue.length&&c.isIDLE){this._ready=!1;var h=this._parent.audioRender;console.warn(this.TAG,"trigger video waiting vdecode, preciseVideoDts:",n,h.currentTime,h.duration,h.buffered.end(0),h.baseDts),this.emit(te.VIDEO_WAITING)}this._checkToDecode()}}},{key:"_updateSegmentEnd",value:function(){}},{key:"_destroy",value:function(e){this._empty(),y(d(i.prototype),"destroy",this).call(this,e),this._videoDecodeController.destroy()}},{key:"_doPause",value:function(){V.log(this.TAG,">>>>>>>>doPause"),this._tickTimer.stop()}},{key:"_getDeleteFrames",value:function(e,t){var i=[],n=[];return e.forEach((function(e){e.info&&e.info.dts>t?n.push(e):e.info&&e.info.dts<=t&&i.push(e)})),{deleteFrames:i,useFrames:n}}},{key:"_empty",value:function(){this._videoDecodeController&&(this._videoDecodeController.empty(),this._frameQueue.frames.forEach((function(e){e.buffer&&e.buffer.dom&&(e.buffer.dom.width=0,e.buffer.dom.height=0,e.buffer.dom=null)})))}}]),i}(Ui),ji=function(e){A(i,e);var t=p(i);function i(e){var n;return s(this,i),u(m(n=t.call(this)),"_parent",null),u(m(n),"_decoderReady",!1),u(m(n),"_inDecoding",!1),u(m(n),"_toDecodeFirstframe",!0),u(m(n),"_id",(new Date).getMilliseconds()),u(m(n),"_workerErrorCallback",null),u(m(n),"_workerMessageCallback",null),u(m(n),"_decoderWorker",null),n._parent=e,n}return o(i,[{key:"analyse",get:function(){return this._parent.analyse}},{key:"inDecoding",get:function(){return this._inDecoding}},{key:"decoderMode",get:function(){return this._decoderMode}},{key:"decoderReady",get:function(){return this._decoderReady}},{key:"needToDecode",get:function(){return this._inDecoding?0:this._continueDecodeThreshold}},{key:"maxDecodeOnce",get:function(){return this._maxDecodeOnce}},{key:"meta",get:function(){var e;return null===(e=this._parent)||void 0===e?void 0:e._meta},set:function(e){this._parent&&(this._parent._meta=e)}},{key:"init",value:function(e,t){this._workerMessageCallback=e,this._workerErrorCallback=t,this._initWorker()}},{key:"_initWorker",value:function(){throw new Error("need override by children")}},{key:"checkToDecode",value:function(e){this.webcodec?e<=this.needToDecode&&this.doDecode():!this._inDecoding&&e<=this.needToDecode&&this.doDecode()}},{key:"doDecode",value:function(){var e=this,t=this._getFramesToDecode();t&&t.length&&this.meta&&(this._toDecodeFirstframe&&(this._toDecodeFirstframe=!1,this.analyse.addFirstFrameToDecode()),this._avccpushed||this._initDecoderWithConfiguration(this._decoderWorker,this.meta),V.enable&&V.log(this.TAG,"doDecode ".concat(t.length," frames")),t.forEach((function(t){e._doDecodeInternal(t)})),this._inDecoding=!0,this._decoderWorker.postMessage({msg:"finish_flag"}))}},{key:"preciseSeek",value:function(e){var t,i,n,r,s=this,a=1e3*e,o=null===(t=this._parent)||void 0===t||null===(i=t._timeRange)||void 0===i?void 0:i.getFramesForPreciseSeek(a),u=o.length;u<this.maxDecodeOnce?this.doDecode():(null===(n=this._parent)||void 0===n||null===(r=n._timeRange)||void 0===r||r.updateFrameIndexForPreciseSeek(u),V.enable&&V.log(this.TAG,"doDecode ".concat(o.length," frames for precise seek")),o.forEach((function(e,t){s._doDecodeInternal(e,!0,t>=u-6)})),this._inDecoding=!0,this._decoderWorker.postMessage({msg:"finish_flag"}))}},{key:"_getFramesToDecode",value:function(){var e=this._parent,t=e._timeRange,i=e._decodeEstimate;if(this._decoderReady&&t){var n=t.frameLength;if(n){var r=this._toDecodeFirstframe?x().maxDecodeOnceFirstTime:this.maxDecodeOnce;1===n&&i.resetDecodeDot(performance.now());for(var s=[];r>0;){var a=t&&t.getFrame();if(!a)break;s.push(a),a.gopId&&a.gopId-1==0&&i.updateGopCount(),r--}return s}}}},{key:"_doDecodeInternal",value:function(e,t,i){null!=e&&e.meta&&(this.meta=e.meta,V.warn(this.TAG,"detect metadata! flush decoder"),this._initDecoderWithConfiguration(this.__decoderWorker,e.meta));var n={dts:e.dts,pts:e.pts||e.dts+e.cts,keyframe:e.keyframe,gopId:e.gopId,id:this._id};t&&(n.preciseSeek=!0,n.output=i);var r=e.data.slice();this._decoderWorker.postMessage({msg:"decode",data:r,info:n},[r.buffer])}},{key:"_initDecoderWithConfiguration",value:function(){throw new Error("need override by children")}},{key:"flushDecoder",value:function(){this._decoderWorker.postMessage({msg:"flush"})}},{key:"destroy",value:function(){throw new Error("need override by children")}}]),i}(z),Yi="IWZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBlPW51bGwsdD1bXSxzPTAsYT0hMTtzZWxmLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLChmdW5jdGlvbihvKXtzd2l0Y2goby5kYXRhLm1zZyl7Y2FzZSJjb25maWd1cmF0aW9uIjplPW5ldyBzZWxmLlZpZGVvRGVjb2Rlcih7b3V0cHV0OmZ1bmN0aW9uKG8pe2E9ITAscyYmY2xlYXJUaW1lb3V0KHMpO3ZhciBuPXQuc2hpZnQoKTtuP3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6IkRFQ09ERUQiLHdpZHRoOm8uZGlzcGxheVdpZHRoLGhlaWdodDpvLmRpc3BsYXlIZWlnaHQsaW5mbzpuLGJ1ZmZlcjpvfSxbb10pOm8uY2xvc2UoKSxlLmRlY29kZVF1ZXVlU2l6ZT09PXQubGVuZ3RoJiZzZWxmLnBvc3RNZXNzYWdlKHt0eXBlOiJCQVRDSF9GSU5JU0hfRkxBRyJ9KX0sZXJyb3I6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PyJrZXkiOiJkZWx0YSIsdGltZXN0YW1wOmkucHRzLGRhdGE6bn0pO2UuZGVjb2RlKHIpO2JyZWFrO2Nhc2UiZGVzdHJveSI6ZSYmKGUuZmx1c2goKSxlLmNsb3NlKCkpLGNsZWFyVGltZW91dChzKTticmVhaztjYXNlImNoZWNrRGVjb2RlIjpzZWxmLnBvc3RNZXNzYWdlKHt0eXBlOiJDSEVDS19UT19ERUNPREUiLGRhdGE6MD09PU1hdGguYWJzKGUuZGVjb2RlUXVldWVTaXplLXQubGVuZ3RoKX0pfX0pKX0oKTsK",Mi="undefined"!=typeof window&&window.Blob&&new Blob([atob(Yi)],{type:"text/javascript;charset=utf-8"});function Xi(){var e=Mi&&(window.URL||window.webkitURL).createObjectURL(Mi);try{return e?new Worker(e,{}):new Worker("data:application/javascript;base64,"+Yi,{type:"module"})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}var Qi=x().maxDecodeOnceWebcodec,Ji=function(e){A(i,e);var t=p(i);function i(){var e;s(this,i);for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return u(m(e=t.call.apply(t,[this].concat(r))),"TAG","WebCodecController"),u(m(e),"_decoderMode",5),u(m(e),"_maxDecodeOnce",Qi),u(m(e),"_continueDecodeThreshold",Qi/2),u(m(e),"_avccpushed",!1),e}return o(i,[{key:"webcodec",get:function(){return!0}},{key:"needToDecode",get:function(){return this._inDecoding?(this._checkToDecode(),0):this._continueDecodeThreshold}},{key:"_initWorker",value:function(){var e=this;V.log(this.TAG,"start init webcodec worker");var t=new Xi;t.onMessage=function(t){var i,n;switch(t.data.type){case"DECODER_READY":V.log(e.TAG,"webcodec worker ready "),e._decoderReady=!0,e._workerMessageCallback({type:"DECODER_READY"});break;case"DECODED":if(e._inDecoding=!0,(null===(i=t.data)||void 0===i||null===(n=i.info)||void 0===n?void 0:n.id)!==e._id)return;e._workerMessageCallback({type:"RECEIVE_FRAME",data:t.data});break;case"BATCH_FINISH_FLAG":if(e._inDecoding=!1,!e._workerMessageCallback)return;e._workerMessageCallback({type:"BATCH_FINISH"});break;case"CHECK_TO_DECODE":e._inDecoding=t.data.data;break;case"FAILED":e._whenError(t.data.message)}},t.onError=function(t){var i,n,r=null===(i=e._parent)||void 0===i||null===(n=i._parent)||void 0===n?void 0:n._parent;r&&r.removeChild(r.querySelector("canvas")),e._whenError(t.message)},t.addEventListener("message",t.onMessage),t.addEventListener("error",t.onError),this._decoderWorker=t,this._initDecoderWithConfiguration(t,this._parent.configuration)}},{key:"_whenError",value:function(e){i.canUse=!1,this._workerErrorCallback(e)}},{key:"_initDecoderWithConfiguration",value:function(e,t){e.postMessage({msg:"configuration",data:{codec:this._parent._meta.codec,codedHeight:this._parent._meta.height,codedWidth:this._parent._meta.width,description:t}}),this._avccpushed=!0}},{key:"_checkToDecode",value:function(){this._decoderWorker.postMessage({msg:"checkDecode"})}},{key:"destroy",value:function(){var e=this._decoderWorker;e.removeEventListener("message",e.onMessage),e.removeEventListener("error",e.onError),e.postMessage({msg:"destroy"}),e.terminate(),this._decoderWorker=null}}],[{key:"isSupported",value:function(){return x().h264WithWebcodec&&!!window.VideoDecoder&&!1!==i.canUse}}]),i}(ji),Hi="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHNoaW1JbXBvcnRTY3JpcHRzKHNyYyl7cmV0dXJuIGZldGNoKHNyYykudGhlbigoZnVuY3Rpb24oZSl7cmV0dXJuIGUudGV4dCgpfSkpLnRoZW4oKGZ1bmN0aW9uKHRleHQpe3NlbGYuZXhwb3J0cz17fSxldmFsKHRleHQpLHNlbGYubT1leHBvcnRzLm19KSl9dmFyIE1BWF9TVFJFQU1fQlVGRkVSX0xFTkdUSD0zMTQ1NzI4LGluaXRUcz0wLERlY29kZXI9ZnVuY3Rpb24oZSl7dGhpcy5pbml0ZWQ9ITEsdGhpcy5pbmZvSWQ9MCx0aGlzLnNlbGY9ZSx0aGlzLm1ldGE9dGhpcy5zZWxmLm1ld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ZyI6c2VsZi5wb3N0TWVzc2FnZSh7bXNnOiJCQVRDSF9GSU5JU0hfRkxBRyJ9KTticmVhaztjYXNlImRlc3RvcnkiOmRlY29kZXIuZGVzdHJveSgpfX1lbHNlIHNlbGYucG9zdE1lc3NhZ2Uoe21zZzoiRVJST1I6aW52YWxpZCBtZXNzYWdlIn0pfX0pKCk7Cg==",Ki="undefined"!=typeof window&&window.Blob&&new Blob([atob(Hi)],{type:"text/javascript;charset=utf-8"});function zi(){var e=Ki&&(window.URL||window.webkitURL).createObjectURL(Ki);try{return e?new Worker(e,{}):new Worker("data:application/javascript;base64,"+Hi,{type:"module"})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}var qi="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHNoaW1JbXBvcnRTY3JpcHRzKHNyYyl7cmV0dXJuIGZldGNoKHNyYykudGhlbigoZnVuY3Rpb24oZSl7cmV0dXJuIGUudGV4dCgpfSkpLnRoZW4oKGZ1bmN0aW9uKHRleHQpe3NlbGYuZXhwb3J0cz17fSxldmFsKHRleHQpLHNlbGYubT1leHBvcnRzLm19KSl9dmFyIE1BWF9TVFJFQU1fQlVGRkVSX0xFTkdUSD01MjQyODgwLEJBVENIX0RFQ09ERV9TSVpFPTgsaW5pdFRzPTAsRGVjb2Rlcj1mdW5jdGlvbihlKXt0aGlzLmluaXRlZD0hMSx0aGlzLmluZm9JZD0wLHRoaXMuc2VsZj1lLHRoaXMubWV0YT1lLm1ldGEsdGhpcy50cz0wLHRoaXMuaW5mb2xpc3Q9W10sZS5wYXJfYnJvYWR3YXlPbkJyb2Fkd2F5SW5pdGVkPXRoaXMuYnJvYWR3YXlPbkJyb2Fkd2F5SW5pdGVkLmJpbmQodGhpcyksZS5wYXJfYnJvYWR3YXlPblBpY3R1cmVEZWNvZGVkPXRoaXMuYnJvYWR3YXlPblBpY3R1cmVEZWNvZGVkLmJpbmQodGhpcyl9LGRlY29kZXI7ZnVuY3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YnJlYWs7Y2FzZSJpbml0IjpzZWxmLm1ldGE9dC5tZXRhLEJBVENIX0RFQ09ERV9TSVpFPXQuYmF0Y2hEZWNvZGVDb3VudCxpbml0KHQudXJsKTticmVhaztjYXNlInVwZGF0ZW1ldGEiOnNlbGYubWV0YT10Lm1ldGEsZGVjb2Rlci51cGRhdGVNZXRhKHQubWV0YSk7YnJlYWs7Y2FzZSJpbml0RGVjb2RlciI6ZGVjb2Rlci5mcmFtZUxlbnNPZmZzZXQmJmRlY29kZXIuYmF0Y2hEZWNvZGUoITApLGRlY29kZXIuZmx1c2goKSxkZWNvZGVyLmRlY29kZSh0LmRhdGEpO2JyZWFrO2Nhc2UiZGVjb2RlIjpkZWNvZGVyLnN0b3JlQnVmZmVyKHQuZGF0YSx0LmluZm8pO2JyZWFrO2Nhc2UiZmx1c2giOmRlY29kZXIuZmx1c2goKTticmVhaztjYXNlImZpbmlzaF9mbGFnIjpzZWxmLnBvc3RNZXNzYWdlKHttc2c6IkJBVENIX0ZJTklTSF9GTEFHIn0pO2JyZWFrO2Nhc2UiZGVzdG9yeSI6ZGVjb2Rlci5kZXN0cm95KCl9fX0pKCk7Cg==",$i="undefined"!=typeof window&&window.Blob&&new Blob([atob(qi)],{type:"text/javascript;charset=utf-8"});function en(){var e=$i&&(window.URL||window.webkitURL).createObjectURL($i);try{return e?new Worker(e,{}):new Worker("data:application/javascript;base64,"+qi,{type:"module"})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}var tn="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIHNoaW1JbXBvcnRTY3JpcHRzKHNyYyl7cmV0dXJuIGZldGNoKHNyYykudGhlbigoZnVuY3Rpb24oZSl7cmV0dXJuIGUudGV4dCgpfSkpLnRoZW4oKGZ1bmN0aW9uKHRleHQpe3NlbGYuZXhwb3J0cz17fSxldmFsKHRleHQpLHNlbGYubT1leHBvcnRzLm19KSl9dmFyIE1BWF9TVFJFQU1fQlVGRk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2VsZil9KSl9KSkuY2F0Y2goKGZ1bmN0aW9uKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe21zZzoiSU5JVF9GQUlMRUQiLGxvZzplLm1lc3NhZ2V9KX0pKX1zZWxmLm9ubWVzc2FnZT1mdW5jdGlvbihlKXt2YXIgdD1lLmRhdGE7aWYoImluaXQiPT09dC5tc2d8fCJwcmVsb2FkIj09PXQubXNnfHxkZWNvZGVyKXN3aXRjaCh0Lm1zZyl7Y2FzZSJwcmVsb2FkIjppbml0KHQudXJsKTticmVhaztjYXNlImluaXQiOnNlbGYubWV0YT10Lm1ldGEsc2VsZi5wb3N0TWVzc2FnZSh7bXNnOiJMT0ciLGxvZzoid29ya2VyIGluaXRlZCJ9KSxpbml0KHQudXJsKTticmVhaztjYXNlInVwZGF0ZW1ldGEiOnNlbGYubWV0YT10Lm1ldGEsZGVjb2Rlci51cGRhdGVNZXRhKHQubWV0YSk7YnJlYWs7Y2FzZSJpbml0RGVjb2RlciI6ZGVjb2Rlci5kZWNvZGUodC5kYXRhKTticmVhaztjYXNlImRlY29kZSI6ZGVjb2Rlci5kZWNvZGUodC5kYXRhLHQuaW5mbyk7YnJlYWs7Y2FzZSJmaW5pc2hfZmxhZyI6c2VsZi5wb3N0TWVzc2FnZSh7bXNnOiJCQVRDSF9GSU5JU0hfRkxBRyJ9KTticmVhaztjYXNlImRlc3RvcnkiOmRlY29kZXIuZGVzdHJveSgpfX19KSgpOwo=",nn="undefined"!=typeof window&&window.Blob&&new Blob([atob(tn)],{type:"text/javascript;charset=utf-8"});function rn(){var e=nn&&(window.URL||window.webkitURL).createObjectURL(nn);try{return e?new Worker(e,{}):new Worker("data:application/javascript;base64,"+tn,{type:"module"})}finally{e&&(window.URL||window.webkitURL).revokeObjectURL(e)}}var sn=new(function(){function e(){s(this,e),u(this,"_queue",[]),u(this,"_pendingDecoder",null),u(this,"TAG","DecoderCache")}return o(e,[{key:"genDecoder",value:function(e){return this._initDecoder(e)}},{key:"_initDecoder",value:function(e){var t=this,i=x(),n=i.preloadDecoder,r=i.maxDecodeOnceWasm;e=e||n;var s,a,o=B(),u=o.H264_DECODER_URL,A=o.H265_SIMD_DECODER_URL,d=o.H265_DECODER_URL,c=o.H265_THREAD_DECODER_URL,h=1;if("h265"===e&&(U()?(s=new zi,a=A,h=2):N()&&x().canUseThreadMode?(s=new en,a=c,h=1):(s=new zi,a=d,h=3)),"h264"===e&&(s=new rn,a=u,h=3),!s)return Promise.resolve();var l,f,m,_=((m=new Promise((function(e,t){l=e,f=t}))).resolve=l,m.reject=f,m);s.postMessage({msg:"preload",batchDecodeCount:r,url:a}),this._pendingDecoder=s,s.id=Date.now()+parseInt(1e3*Math.random()),s.isHevc="h265"===e,s.using=!1,s.ready=!1,V.log(this.TAG,"start init decoder worker, id=",s.id,"hevc=",s.isHevc,"mode=",h);var p=function e(i){t._pendingDecoder=null;var n=i.data.msg;switch("DECODER_READY"!==n&&"INIT_FAILED"!==n||(s.removeEventListener("message",e),s.removeEventListener("error",v)),n){case"DECODER_READY":V.log(t.TAG,"decoder worker inited!, id=",s.id,"cost:",i.data.cost),s.ready=!0,s.using||t._queue.push(s),_.resolve();break;case"INIT_FAILED":V.log(t.TAG,"decoder worker init failed!",i.data.log),_.reject(i.data.log)}},v=function e(t){s.removeEventListener("message",p),s.removeEventListener("error",e),_.reject(null==t?void 0:t.message)};return s.addEventListener("message",p),s.addEventListener("error",v),_}},{key:"cacheDecoder",value:function(e){e.using=!1,e.ready=!0,e.id||(e.id=Date.now()+parseInt(1e3*Math.random())),this._queue.push(e),V.log(this.TAG,"cache decoder, id=",e.id),"h265"===x().preloadDecoder&&1===this._queue.filter((function(e){return!e.using&&e.isHevc})).length&&this.genDecoder("h265")}},{key:"getCachedDecoder",value:function(e){var t,i=this._queue.findIndex((function(t){return!t.using&&t.isHevc===e}));if(-1!==i&&(t=this._queue.splice(i,1)[0]),!t&&this._pendingDecoder&&(t=this._pendingDecoder,this._pendingDecoder=null),t)return t.using=!0,V.warn(this.TAG,"get cached decoder, id=".concat(t.id,", ready=").concat(t.ready)),t}}]),e}()),an=x().maxDecodeOnceWasm,on=function(e){A(i,e);var t=p(i);function i(){var e;s(this,i);for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return u(m(e=t.call.apply(t,[this].concat(r))),"TAG","WasmController"),u(m(e),"_avccpushed",!1),u(m(e),"_maxDecodeOnce",an),u(m(e),"_continueDecodeThreshold",an/2),u(m(e),"_wasmInitCost",0),u(m(e),"_threadSupported",N()&&x().canUseThreadMode),u(m(e),"_simdSuppported",U()),u(m(e),"_decoderMode",window.WebAssembly?3:4),e}return o(i,[{key:"wasmInitCost",get:function(){var e;return null===(e=this._decoderWorker)||void 0===e?void 0:e._wasmInitCost}},{key:"isHevc",get:function(){var e;return null===(e=this._parent)||void 0===e?void 0:e.isHevc}},{key:"_selectDecodeWorker",value:function(){this.analyse.addWasmInit();var e,t=B(),i=t.H264_DECODER_URL,n=t.H265_DECODER_URL,r=t.H265_THREAD_DECODER_URL,s=t.H265_SIMD_DECODER_URL,a=t.ASM_H264_DECODER_URL,o=t.ASM_H265_DECODER_URL;return V.log(this.TAG,"start init wasm worker:",performance.now(),"hevc:",this.isHevc,"decoderMode:",this._decoderMode),this.isHevc?(e=1===this._decoderMode?r:2===this._decoderMode?s:3===this._decoderMode?n:o)?{decoder:1===this._decoderMode?new en:new zi,url:e}:void this._workerErrorCallback("no found decoder url, decodeMode:".concat(this._decoderMode)):(e=4===this._decoderMode?a:i)?{decoder:new rn,url:e}:void this._workerErrorCallback("no found decoder url, decodeMode:".concat(this._decoderMode))}},{key:"_initWorker",value:function(){this.isHevc&&(this._threadSupported&&(this._decoderMode=1),this._simdSuppported&&(this._decoderMode=2)),this._initDecodeWorkerInternal()}},{key:"_initDecodeWorkerInternal",value:function(){var e=sn.getCachedDecoder(this.isHevc);if(e)return V.warn(this.TAG,"select decoder from cache"),this.analyse.addWasmInit(),this._avccpushed=!1,this._bindWorkerEvent(e),this._decoderWorker=e,void(e.ready&&(this._decoderReady=!0,this._initDecoderWithConfiguration(e,this.meta),this._workerMessageCallback({type:"DECODER_READY",data:e}),V.log(this.TAG,"decoder ready!")));var t=this._selectDecodeWorker()||{},i=t.decoder,n=t.url;i&&(this._avccpushed=!1,this._bindWorkerEvent(i),i.isHevc=this.isHevc,i.postMessage({msg:"init",meta:this.meta,batchDecodeCount:an,url:n}),this._decoderWorker=i)}},{key:"_bindWorkerEvent",value:function(e){var t=this,i=function(i,n){V.log(t.TAG,"worker failed: ",i,n),t._terminateWorker(e),t._decoderWorker=null,!1===x().wasmFallbackToAsm||4===t._decoderMode?t._workerErrorCallback(i):(t._decoderMode=1===t._decoderMode||2===t._decoderMode?3:4,t._initDecodeWorkerInternal())};e._onMessage=function(n){var r,s;switch(n.data.msg){case"DECODER_READY":if(V.log(t.TAG,"wasm worker ready!","cost:",n.data.cost),t._decoderReady=!0,e._wasmInitCost=parseInt(n.data.cost),!t.meta)return;t._avccpushed||t._initDecoderWithConfiguration(e,t.meta),t.emit(te.VIDEO_DECODER_INIT,e),t._workerMessageCallback({type:"DECODER_READY",data:e});break;case"DECODED":if(t._inDecoding=!0,(null===(r=n.data)||void 0===r||null===(s=r.info)||void 0===s?void 0:s.id)!==t._id)return;t._workerMessageCallback({type:"RECEIVE_FRAME",data:n.data});break;case"BATCH_FINISH_FLAG":if(t._inDecoding=!1,!t._workerMessageCallback)return;t._workerMessageCallback({type:"BATCH_FINISH"});break;case"INIT_FAILED":i(n.data.log,1)}},e._onError=function(e){i(e.message,2)},e.addEventListener("message",e._onMessage),e.addEventListener("error",e._onError)}},{key:"_initDecoderWithConfiguration",value:function(e,t){V.log(this.TAG,"init decoder with configuration"),this._avccpushed=!0,e.postMessage({msg:"updatemeta",meta:t});var i=[t.rawVps||t.vps[0],t.rawSps||t.sps[0],t.rawPps||t.pps[0]].filter(Boolean),n=i.reduce((function(e,t){return e+(t.byteLength+4)}),0),r=new Uint8Array(n),s=0;i.forEach((function(e){r.set([0,0,0,1],s),s+=4,r.set(e,s),s+=e.byteLength})),e.postMessage({msg:"initDecoder",data:r})}},{key:"destroy",value:function(){if(this._decoderWorker)return x().reuseWasmDecoder?(this._offWorkerBind(this._decoderWorker),void sn.cacheDecoder(this._decoderWorker)):void this._terminateWorker(this._decoderWorker)}},{key:"_offWorkerBind",value:function(e){e.removeEventListener("message",e._onMessage),e.removeEventListener("error",e._onError),e.postMessage({msg:"flush"}),e._onMessage=null,e._onError=null,V.log(this.TAG,"flush decoder and unbind worker event")}},{key:"_terminateWorker",value:function(e){this._offWorkerBind(e),e.postMessage({msg:"destroy"}),e.terminate(),V.log(this.TAG,"destroy decoder worker")}}]),i}(ji),un=function(e){A(i,e);var t=p(i);function i(){var e;s(this,i);for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return u(m(e=t.call.apply(t,[this].concat(r))),"TAG","VideoRenderWithDecoder"),u(m(e),"_hideRenderFlag",0),u(m(e),"_recentMeta",null),u(m(e),"_inChaseFrame",!1),u(m(e),"_decoderErrorCallback",(function(t){e._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,e._assembleErr(t,1))})),u(m(e),"_decoderMessageCallback",(function(t){var i,n,r,s=t.type,a=t.data;switch(s){case"DECODER_READY":if(e.analyse.addWasmReady(),!e._frameRender){var o=Object.assign(e._config,{meta:e._meta,canvas:e._canvas,type:e._decodeController.webcodec?"2d":""});try{e._canvas.glInstance?(e._frameRender=e._canvas.glInstance,e._frameRender.updateBind(m(e),e._meta),V.warn(e.TAG,"reuse canvas and context")):(e._frameRender=new Zi(o,m(e)),V.log(e.TAG,"create frameRender with config",o))}catch(vn){e._emitTimelineEvents(ie.PLAY_EVENT,q.ERROR,e._assembleErr(vn&&vn.message,2))}}e._startDecode();break;case"RECEIVE_FRAME":if(e._inChaseFrame&&(null===(i=e._decodeController)||void 0===i||!i.webcodec))return;e._receiveFrame(a);break;case"BATCH_FINISH":null===(n=m(e))||void 0===n||n._decodeEstimate.resetDecodeDot(),e._inChaseFrame&&(e._inChaseFrame=!1,e._frameQueue.empty()),e._ready||e.inSeeking||null===(r=e._decodeController)||void 0===r||!r.decoderReady||e._startDecode()}})),e}return o(i,[{key:"wasmInitCost",get:function(){var e;return null===(e=this._decodeController)||void 0===e?void 0:e.wasmInitCost}},{key:"hevcThread",get:function(){return 1===this.decodeMode}},{key:"lowlatency",get:function(){return this._parent.lowlatency}},{key:"nextFrameTime",get:function(){var e=this._frameQueue.nextFrame();return(e&&e.info&&e.info.dts||0)/1e3}},{key:"ajustSeekTime",value:function(e,t){var i;V.log(this.TAG,"ajust seek time: ",e),this._frameQueue.empty(),null===(i=this._decodeController)||void 0===i||i.flushDecoder(),this._switchVideoBuffer(e,t)}},{key:"canSeek",value:function(){return!0}},{key:"_appendChunk",value:function(e){var t;if(!this.noVideo&&this._timeRange){if(this._meta){if(this._recentMeta.width!==e.width||this._recentMeta.height!==e.height){V.warn(this.TAG,"metadata changed! width: ".concat(this._recentMeta.width," -> ").concat(e.width,", height: ").concat(this._recentMeta.height," -> ").concat(e.height));var i=e.samples[0];i&&(this._recentMeta=i.meta=Object.assign({},e,{samples:null}))}}else{this._emitTimelineEvents(ie.PLAY_EVENT,q.LOADEDMETADATA),this._recentMeta=this._meta=Object.assign({},e,{samples:null}),V.warn(this.TAG,"video set metadata",this._meta,"configuration:",this.configuration);var n=e.fpsNum/e.fpsDen;n?V.log(this.TAG,"detect fps:",n):V.warn(this.TAG,"no detect fps,start estimate"),this._selectDecoder(),this._initDecoder()}if(this._timeRange.append(e.samples,this._isLive&&this.noAudio,!this.videoDecode),e.samples=[],!this.inSeeking){var r;if(this.isLive||this._timeRange.frameLength||this._switchVideoBuffer(this._parent.currentTime),!this._ready&&null!==(t=this._decodeController)&&void 0!==t&&t.decoderReady)!this.noAudio&&null!==(r=this._decodeController)&&void 0!==r&&r.inDecoding||this._startDecode();this.noAudio&&this._emitTimelineEvents(ie.PLAY_EVENT,q.DURATION_CHANGE)}}}},{key:"_selectDecoder",value:function(){if(!this.isHevc&&Ji.isSupported())return this._decodeController=new Ji(this),void(this._decodeEstimate.webcodec=!0);this._decodeController=new on(this)}},{key:"_initDecoder",value:function(){var e;null===(e=this._decodeController)||void 0===e||e.init(this._decoderMessageCallback,this._decoderErrorCallback)}},{key:"_startDecode",value:function(){var e;null===(e=this._decodeController)||void 0===e||e.doDecode()}},{key:"_switchVideoBuffer",value:function(e,t){var i=this._timeRange.switchBuffer(e);if(i){var n;if(this.noAudio&&this._parent.emit(ie.SYNC_DTS,this.getDtsOfTime(i.start)),t)return void(null===(n=this._decodeController)||void 0===n||n.preciseSeek(e));this._startDecode(t)}}},{key:"_checkToDecode",value:function(){var e;this.inSeeking||null===(e=this._decodeController)||void 0===e||e.checkToDecode(this._frameQueue.length)}},{key:"_render",value:function(e){var t;if(!this.noVideo){var i=this._frameQueue&&this._frameQueue.nextFrame();if(i){var n=i.info;if(!n)return this._frameQueue.shift(),void console.error("not info");this._renderDts=n.dts;var r=n.dts-this.preciseVideoDts;if(!(!e&&r>0&&r<6e4)){this._frameQueue.shift(this.preciseVideoDts),Math.abs(this._lastTimeupdate-n.dts)>250&&(this._emitTimelineEvents(ie.PLAY_EVENT,q.TIMEUPDATE,{pts:n.originPts/90}),this._lastTimeupdate=n.dts),V.long&&V.log(this.TAG,"render delay:".concat(r," , timelinePosition:").concat(this.preciseVideoDts," , dts:").concat(n.dts," , cost:").concat(n.cost," , gopID:").concat(n.gopId," , rest:").concat(this._frameQueue.length,", buffer frame:").concat(this._timeRange.frameLength));var s=performance.now();this._hideRenderFlag++,("visible"===document.visibilityState||this._hideRenderFlag%15)&&this._frameRender.render(i.buffer,i.width,i.height,i.yLinesize,i.uvLinesize),null!==(t=this._decodeController)&&void 0!==t&&t.webcodec&&i.buffer.close(),this._renderCost=performance.now()-s,this._checkToDecode()}}else{var a;if(V.log(this.TAG,"lack frame, ","inDecoding:",null===(a=this._decodeController)||void 0===a?void 0:a.inDecoding),this._checkToDecode(),this.noAudio){var o;if(!this.isLive&&Math.abs(this.currentTime-this.duration)<.5)return null==this||this._emitTimelineEvents(ie.PLAY_EVENT,q.TIMEUPDATE),null==this||this._emitTimelineEvents(ie.PLAY_EVENT,q.ENDED),void(null===(o=this._timeRange)||void 0===o||o.clean());this._timeRange.frameLength||(this._ready=!1,this.emit(te.VIDEO_WAITING))}}}}},{key:"_updateSegmentEnd",value:function(e){var t;null===(t=this._timeRange)||void 0===t||t.updateSegmentEnd(e)}},{key:"_doChaseFrame",value:function(e){var t=e.frame;this._inChaseFrame=!0,this._timeRange.deletePassed(t.dts),this._frameQueue.empty(),this.noAudio&&this._parent.emit(ie.SYNC_DTS,t.dts)}},{key:"_destroy",value:function(e){var t;V.log(this.TAG,"destroy video render"),y(d(i.prototype),"destroy",this).call(this,e),null===(t=this._decodeController)||void 0===t||t.destroy(),this._decodeController=null}}]),i}(Ui),An=.1,dn=function(e){A(i,e);var t=p(i);function i(e,n){var r;return s(this,i),(r=t.call(this)).TAG="TimeLine",r._parent=n,r._seeking=!1,r.audioRender=wi.isSupported()?new wi(e,m(r)):new ce(e,m(r)),r.videoRender=new un(e,m(r)),r._readyStatus={audio:!1,video:!1},r._paused=!0,r._switchToMultiWorker=!1,r._lowdecodeEmited=!1,r._startPlayed=!1,r._emitReady=!1,r._lastSeekTime=1e-4,r._singleTrack=-1,r._bindEvent(),r._decodeVideo=e.video,r}return o(i,[{key:"analyse",get:function(){return this._parent.analyse}},{key:"ready",get:function(){return this._readyStatus.video&&this._readyStatus.audio}},{key:"played",get:function(){var e=this;return{length:this.currentTime?1:0,start:function(){return 0},end:function(){return e.currentTime}}}},{key:"noAudio",get:function(){return 1===this._singleTrack||2===this._singleTrack}},{key:"isLive",get:function(){return this._parent.live}},{key:"seeking",get:function(){return this._seeking}},{key:"decodeFps",get:function(){return this.videoRender.decodeFps}},{key:"decodeCost",get:function(){return this.videoRender.decodeCost}},{key:"renderCost",get:function(){return this.videoRender.renderCost}},{key:"wasmInitCost",get:function(){return this.videoRender.wasmInitCost}},{key:"fps",get:function(){return this.videoRender.fps}},{key:"totalSize",get:function(){return this.videoRender.totalSize}},{key:"bitrate",get:function(){return this.videoRender.bitrate}},{key:"gopLength",get:function(){return this.videoRender.gopLength}},{key:"currentTime",get:function(){return this.noAudio?this.paused?this.videoRender.nextFrameTime:this.videoRender.currentTime:this.audioRender.currentTime}},{key:"timelinePosition",get:function(){return this.noAudio?performance.now()/1e3:this.audioRender.currentTime}},{key:"canvas",get:function(){return this.videoRender.canvas}},{key:"readyState",get:function(){return this.videoRender.readyState}},{key:"buffered",get:function(){var e=this;return this.noAudio?this.videoRender.buffered:this.isLive?this.audioRender.buffered:{length:this.audioRender.buffered.length,start:function(t){return Math.max(e.audioRender.buffered.start(t),e.videoRender.buffered.start(t))},end:function(t){return Math.min(e.audioRender.buffered.end(t),e.videoRender.buffered.end(t))}}}},{key:"duration",get:function(){return this.noAudio?this.videoRender.duration:this.isLive?this.audioRender.duration:Math.min(this.audioRender.duration,this.videoRender.duration)}},{key:"paused",get:function(){return this._paused},set:function(e){this._paused=e}},{key:"lowlatency",get:function(){return this._parent.lowlatency}},{key:"decoderMode",get:function(){return this.videoRender.decoderMode}},{key:"currentAudioCanAutoplay",get:function(){return this.audioRender.audioCanAutoplay}},{key:"_getController",value:function(e,t){return e?new Wi(t,this):new un(t,this)}},{key:"_checkInBuffer",value:function(){for(var e=this.buffered,t=0,i=e.length;t<i;t++)if(e.start(t)<=this.currentTime+An&&e.end(t)>=this.currentTime)return!0;return!1}},{key:"_resetReadyStatus",value:function(){this._readyStatus.audio=!1,this._readyStatus.video=!1}},{key:"_bindEvent",value:function(){var e=this;this.on(ne.REMUX,(function(t){e.videoRender.setRemux(t)})),this.on(ne.CHASE_VIDEO_FRAME_END,(function(t){e.emit(ne.CHASE_AUDIO_FRAME,t)})),this.audioRender.on(ee.AUDIO_READY,(function(){V.log(e.TAG,"audio ready! seeking=",e._seeking),e._seeking&&setTimeout((function(){try{var t=e.videoRender.getSeekStartPosition(e.currentTime,1/0);if(e.audioRender.isMse&&t)return x().preciseSeek>e.duration&&e.currentTime>An?(e.audioRender.seekNoSideEffect({position:e.currentTime+An}),void e.videoRender.ajustSeekTime(e.currentTime,!0)):(e.audioRender.seekNoSideEffect({position:t.position+An}),void e.videoRender.ajustSeekTime(t.position));e.videoRender.ajustSeekTime(e.currentTime)}catch(vn){}}),10),e._readyStatus.video&&e._startRender(),e._readyStatus.audio=!0,e._startPlayed||e.analyse.addAudioReady()})),this.audioRender.on(ee.AUDIO_NOT_ALLOWED_AUTOPLAY,(function(){e._emitReady&&e.pause()})),this.audioRender.on(ee.AUDIO_WAITING,(function(){!e.noAudio&&e.currentTime&&(V.warn(e.TAG,"lack data, audio waiting,currentTime:",e.currentTime),e.emit(ie.PLAY_EVENT,q.TIMEUPDATE),e.emit(ie.PLAY_EVENT,q.WAITING),e.emit(ie.DO_PAUSE),e._readyStatus.audio=!1)})),this.videoRender.on(te.VIDEO_WAITING,(function(){V.warn(e.TAG,"lack data, video waiting"),e.emit(ie.PLAY_EVENT,q.WAITING),e.emit(ie.DO_PAUSE),e._readyStatus.video=!1})),this.videoRender.on(te.VIDEO_READY,(function(){V.log(e.TAG,"video ready!"),e._startPlayed||e.analyse.addVideoReady(),e._readyStatus.audio&&e._startRender("video"),e._readyStatus.video=!0})),this.videoRender.on(te.DECODE_LOW_FPS,(function(){e.currentTime<2||(e.analyse.increaseLowDecodeCount(),e._lowdecodeEmited||(Y++,e._lowdecodeEmited=!0),e.emit(ie.PLAY_EVENT,q.LOW_DECODE))})),this.on(ie.SINGLE_TRACK,(function(t){e._singleTrack=t,1!==t&&2!==t||(e._readyStatus.audio=!0),3===t&&(e._readyStatus.video=!0),e.emit(ie.SYNC_DTS,0)})),this.on(ie.DESTROY,(function(){e.removeAllListeners(),e.videoRender=null,e.audioRender=null})),this.on(ie.DO_PLAY,(function(){e.emit(ie.START_RENDER),e._paused=!1,e._lastSeekTime=1e-4,e.noAudio&&e.emit(ie.SYNC_DTS,0)}))}},{key:"_startRender",value:function(e){if(!this._parent.error&&this.videoRender){if(this.noAudio&&this.emit(ie.SYNC_DTS,0),this.videoRender.forceRender(),!this.isLive&&this._paused&&this.seeking&&this._checkInBuffer())return V.log(this.TAG,"set seeking = false"),this._seeking=!1,this.emit(ie.PLAY_EVENT,q.SEEKED),void V.groupEnd();this._startPlayed||(this.analyse.addFirstframe(),this.emit(ie.PLAY_EVENT,q.LOADEDDATA),this.emit(ie.PLAY_EVENT,q.FIRST_FRAME),this._startPlayed=!0),V.log(this.TAG,"emit canplay"),this.emit(ie.PLAY_EVENT,q.CANPLAY),this._parent.autoplay?(V.warn(this.TAG,"startRender: time=",this.currentTime,"paused:",this.paused,"seeking:",this.seeking),this.emit(ie.START_RENDER,e)):(this._parent.autoplay=!0,this.emit(ie.PLAY_EVENT,q.PAUSE)),this.emit(ie.READY),this._emitReady=!0,this._seeking&&this._checkInBuffer()&&(V.log(this.TAG,"set seeking = false"),this._seeking=!1,this.emit(ie.PLAY_EVENT,q.SEEKED),V.groupEnd())}}},{key:"_checkHlsTracks",value:function(e){if(!(null==e?void 0:e.samples[0])){if(!this.buffered.length){var t=new Error("lack video sample");t.code=3,this.emit(ie.PLAY_EVENT,q.ERROR,t)}return!1}return!0}},{key:"appendBuffer",value:function(e,t){this.emit(ie.APPEND_CHUNKS,e,t),this.noAudio&&this._seeking&&this.videoRender.ajustSeekTime(this.currentTime)}},{key:"play",value:function(){var e=this;return new Promise((function(t,i){var n=e.currentAudioCanAutoplay;e.noAudio?n=!0:e.audioRender&&e.audioRender.resume().then((function(){if(V.log(e.TAG,"audio render resumed, pause status: ".concat(e._paused,", audioCanAutoplay:").concat(e.currentAudioCanAutoplay)),e._paused||!e.currentAudioCanAutoplay)return n=!1,void e.emit(ie.DO_PAUSE);n=!0})).catch((function(){})),setTimeout((function(){return V.log(e.TAG,"play() timer done, resumed=".concat(n,", paused=").concat(e.paused)),n?e.videoRender&&!e.videoRender.canAutoPlay?(console.warn("video render an't autoplay"),e.pause(),void t()):(e._paused=!1,void t()):e.paused?void 0:(V.log(e.TAG,"audioCtx can't autoplay"),e.pause(),void i({name:"NotAllowedError"}))}),e.audioRender.isMse?10:60)}))}},{key:"pause",value:function(){this._paused||!this.ready&&!this._seeking||(this.emit(ie.DO_PAUSE),this._paused=!0,this.emit(ie.PLAY_EVENT,q.PAUSE))}},{key:"seek",value:function(e){var t=this;if(this._seeking&&V.groupEnd(),this.isLive){if(this.currentTime<An||!this.currentAudioCanAutoplay||this.paused)return;var i=this.videoRender.getSeekStartPosition(e,this._parent.preloadTime+1);if(i){if(i.position<this.currentTime)return;var n=this.audioRender.canSeek(i.position),r=this.videoRender.canSeek(i);if(!n||!r)return void V.log(this.TAG,"seek, !!!!!!!!!can not seek, audioCanSeek:",n,"videoCanSeek:",r);V.warn(this.TAG,"seek, chase frame to time: ",i.position,"currentTime:",this.currentTime,"duration:",this.duration),this.videoRender.videoDecode?(this.audioRender.doPause(),i.position=i.position-1.5,this.emit(ne.CHASE_VIDEO_FRAME,i)):this.emit(ie.CHASE_FRAME,i)}}else this._lastSeekTime!==e&&(e&&Math.abs(this._lastSeekTime-e)<=.2||(this._lastSeekTime=e,e>=this.duration&&(e=this.duration-1),e<0&&(e=0),V.group(this.TAG,"start seek to:".concat(e,", set seeking status=true")),this._seeking=!0,this.videoRender.setSeekingStatus(!0),this.noAudio?(this.emit(ie.SYNC_DTS,this.videoRender.getDtsOfTime(e)),this.videoRender.ajustSeekTime(e)):this._resetReadyStatus(),this.emit(ie.DO_SEEK,e),new Promise((function(e){t.emit(ie.PLAY_EVENT,q.SEEKING),e()}))))}}]),i}(z),cn={FIRST_DATA:1,AUDIO_MSE_OPEN_START:2,AUDIO_MSE_OPEND:3,AUDIO_FIRSTTIME_APPENDED:4,AUDIO_READY:5,WASM_WORKER_INIT:6,WASM_WORKER_READY:7,FIRST_FRAME_TODECODE:8,VIDEO_READY:9,FIRST_FRAME:10,WAITIGN:11,SEEKING:12,SEEKED:13},hn=Object.entries(cn),ln=function(){function e(){s(this,e),u(this,"_dot",[]),u(this,"_currentLowDecodeCount",0)}return o(e,[{key:"getBootStats",value:function(){var e,t=(null===(e=this._dot[0])||void 0===e?void 0:e.dot)||0;return this._dot.map((function(e){return{action:hn.filter((function(t){return t[1]===e.action}))[0][1],dot:parseInt(e.dot-t)}}))}},{key:"getStats",value:function(e){var t,i=this.getBootStats();return{bootStats:i,bitrate:Math.abs(e.bitrate/1e3),decodeFps:e.decodeFps,fps:e.fps,playbackRate:e.playbackRate,firstframe:null===(t=i.filter((function(e){return 10===e.action}))[0])||void 0===t?void 0:t.dot,width:e.videoWidth,height:e.videoHeight,decoderMode:e.decoderMode,vv:j,lowdecodeVV:Y,h265FailureRate:Number((100*M).toFixed(2)),currentLowDecodeCount:this._currentLowDecodeCount}}},{key:"seekElapses",value:function(){for(var e=this.getBootStats(),t=[],i=0,n=0,r=e.length;n<r;n++){var s=e[n];s.action===cn.SEEKING&&(i=s.dot),s.action===cn.SEEKED&&t.push(s.dot-i)}return t}},{key:"addFirstData",value:function(){this._dot.push({action:cn.FIRST_DATA,dot:this._getTimestap()})}},{key:"addAudioBoundMedia",value:function(){this._dot.push({action:cn.AUDIO_BOUND_MEDIA,dot:this._getTimestap()})}},{key:"addAudioMseOpenStart",value:function(){this._dot.push({action:cn.AUDIO_MSE_OPEN_START,dot:this._getTimestap()})}},{key:"addAudioMseOpend",value:function(){this._dot.push({action:cn.AUDIO_MSE_OPEND,dot:this._getTimestap()})}},{key:"addAudioFirstTimeAppended",value:function(){this._dot.push({action:cn.AUDIO_FIRSTTIME_APPENDED,dot:this._getTimestap()})}},{key:"addAudioReady",value:function(){this._dot.push({action:cn.AUDIO_READY,dot:this._getTimestap()})}},{key:"addWasmInit",value:function(){this._dot.push({action:cn.WASM_WORKER_INIT,dot:this._getTimestap()})}},{key:"addWasmReady",value:function(){this._dot.push({action:cn.WASM_WORKER_READY,dot:this._getTimestap()})}},{key:"addFirstFrameToDecode",value:function(){this._dot.push({action:cn.FIRST_FRAME_TODECODE,dot:this._getTimestap()})}},{key:"addVideoReady",value:function(){this._dot.push({action:cn.VIDEO_READY,dot:this._getTimestap()})}},{key:"addFirstframe",value:function(){this._dot.push({action:cn.FIRST_FRAME,dot:this._getTimestap()})}},{key:"addWaiting",value:function(){this._dot.push({action:cn.WAITIGN,dot:this._getTimestap()})}},{key:"addSeeking",value:function(){this._dot.push({action:cn.SEEKING,dot:this._getTimestap()})}},{key:"addSeeked",value:function(){this._dot.push({action:cn.SEEKED,dot:this._getTimestap()})}},{key:"_getTimestap",value:function(){return performance.now()}},{key:"increaseLowDecodeCount",value:function(){this._currentLowDecodeCount++}},{key:"reset",value:function(){this._currentLowDecodeCount=0,this._dot=[]}}]),e}(),fn=1,mn=2,_n=3,pn=function(e){A(i,e);var t=p(i);function i(){var e,n,r,a,o,u;return s(this,i),(e=t.call(this)).TAG="XGVideo",e._proxyProps(),e._isLive=!0,e._vMeta=null,e._aMeta=null,e._resizeObserver=null,e._eventsBackup=[],e._hevc="h265"===x().preloadDecoder,e._hevc||(e._degradeVideo=document.createElement("video")),e._debounceSeek=(n=e._seek.bind(m(e)),r=300,a=Date.now(),o=null,u=!0,function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];var s=Date.now();u&&(a=Date.now(),u=!1,n.apply(void 0,t)),s-a>r?(a=s,n.apply(void 0,t)):(o&&window.clearTimeout(o),o=setTimeout((function(){n.apply(void 0,t)}),r))}),e._onTouchEnd=e._onTouchEnd.bind(m(e)),e.analyse=new ln,e}return o(i,[{key:"_proxyProps",value:function(){var e=this;Object.getOwnPropertyNames(i.prototype).forEach((function(t){if(/^__/.test(t)){var i=t.replace("__","");Object.defineProperty(e,i,{get:function(){try{return this[t]}catch(vn){}return 0},set:function(e){try{this[t]=e}catch(vn){}}})}}))}},{key:"addEventListener",value:function(e,t,n){y(d(i.prototype),"addEventListener",this).call(this,e,t,n),this._degradeVideo&&this._eventsBackup.push([e,t,n])}},{key:"removeEventListener",value:function(e,t,n){y(d(i.prototype),"removeEventListener",this).call(this,e,t,n),this._degradeVideo&&(this._eventsBackup=this._eventsBackup.filter((function(i){return!(i.eventName===e&&i.handler===t&&i.capture===n)})))}},{key:"setAttribute",value:function(e,t){var n;y(d(i.prototype),"setAttribute",this).call(this,e,t),"src"!==e&&(null===(n=this._degradeVideo)||void 0===n||n.setAttribute(e,t))}},{key:"_init",value:function(){this.analyse.reset(),this.timeline=new dn({volume:this.volume,canvas:this.querySelector("canvas"),videoContext:this.videoContext,videoDecode:this.videoDecode,maxVideoHeight:this.getAttribute("maxVideoHeight"),endLevel:parseInt(this.getAttribute("endLevel"))},this),V.log(this.TAG,"timeline init"),this._noSleep=new S,this._logFirstFrame=!1,this._playRequest=null,this._degradeVideoUserGestured=!1,this._bindEvents(),this._vMeta&&!this.videoDecode&&this.setVideoMeta(this._vMeta),this._glCtxOptions&&(this.glCtxOptions=this._glCtxOptions),this.timeline&&(this.innerDegrade&&this.timeline.emit(ie.INNER_DEGRADE),this.timeline.emit(ie.SET_PLAY_MODE,this._isLive?"LIVE":"VOD"),this.timeline.emit(ie.SET_PLAYBACKRATE,this.playbackRate),this.muted=this.muted)}},{key:"_bindEvents",value:function(){var e=this;this.timeline.on(ie.PLAY_EVENT,(function(t,i){var n;t===q.LOADEDDATA&&(e.querySelector("canvas")||(V.log(e.TAG,"_bindEvents, appendChild canvas"),e.appendChild(e.canvas)),e.canvas.style.display="block",null===(n=e.timeline)||void 0===n||n.emit(ie.SET_PLAYBACKRATE,e.playbackRate));if(t!==q.LOADEDMETADATA&&t!==q.RESIZE||Promise.resolve().then((function(){e.updateVideoPostion()})),t===q.ERROR){if(V.warn(e.TAG,"detect error:",null==i?void 0:i.message),e.pause(),e._disabled(!0),e.innerDegrade||5===e.decoderMode)return e.degradeInfo={decodeFps:e.decodeFps,bitrate:e.bitrate,wasmInitCost:e.wasmInitCost,fps:e.fps,url:e.src,msg:null==i?void 0:i.message,decoderMode:e.decoderMode},void e._innerDispatchEvent("lowdecode");e._err=i}if(t===q.LOW_DECODE)return e._disabled(),e.degradeInfo={decodeFps:e.decodeFps,bitrate:e.bitrate,wasmInitCost:e.wasmInitCost,fps:e.fps,url:e.src,decoderMode:e.decoderMode},void e._innerDispatchEvent($[t],e.degradeInfo);if(t===q.LARGE_AV_GAP&&(e.unsyncInfo=i),t===q.ENDED){if(e.paused)return;e.pause()}t===q.PROGRESS&&e._noSleep.toPlay(),t===q.WAITING&&e.analyse.addWaiting(),t===q.SEEKING&&e.analyse.addSeeking(),t===q.SEEKED&&e.analyse.addSeeked(),e._innerDispatchEvent($[t],i)}))}},{key:"_disabled",value:function(e){(this.innerDegrade||e)&&(e?x().disabledWhenErrorOccur&&Q(1):x().evaluateVVCount||(this.decodeFps/this.fps<=.6&&this.bitrate<2e6?Q(1):Q(2)))}},{key:"degrade",value:function(e){var t=this;!!this.querySelector("canvas")?this.replaceChild(this._degradeVideo,this.canvas):this.appendChild(this._degradeVideo),this.destroy(),this._eventsBackup.forEach((function(e){var n,r=g(e,3),s=r[0],a=r[1],o=r[2];y(d(i.prototype),"removeEventListener",t).call(t,s,a,o),null===(n=t._degradeVideo)||void 0===n||n.addEventListener(s,a,o)})),this._eventsBackup=[],e&&(this._degradeVideo.muted=!1,this._degradeVideo.src=e,this._degradeVideo.load())}},{key:"disconnectedCallback",value:function(){V.log(this.TAG,"video disconnected"),document.removeEventListener("touchend",this._onTouchEnd,!0),this.destroy(!0),this._resizeObserver&&this._resizeObserver.disconnect(this)}},{key:"connectedCallback",value:function(){var e=this;V.log(this.TAG,"video connected to document",performance.now()),this.timeline||this._init(),this.style.width="100%",this.style.height="100%",this.style.position="absolute",this.style.left="0px",this.style.top="0px",document.addEventListener("touchend",this._onTouchEnd,!0),ResizeObserver&&(this._resizeObserver=new ResizeObserver((function(t){var i;null!==(i=e.timeline)&&void 0!==i&&i.ready&&e.updateVideoPostion()})),this._resizeObserver.observe(this))}},{key:"_onTouchEnd",value:function(){C(),this._degradeVideoInteract(),this._noSleep&&this._noSleep.enable()}},{key:"_degradeVideoInteract",value:function(){var e=this;if(this._degradeVideo&&(1===this.innerDegrade||3===this.innerDegrade)){if(this._degradeVideoUserGestured)return;var t=this._degradeVideo.play();t&&t.then((function(){e._degradeVideo.pause(),e._degradeVideoUserGestured=!0})).catch((function(e){console.log("degrade video: ",e.message)}))}}},{key:"play",value:function(e){var t=this;if(this.timeline){V.log(this.TAG,"play() called, ready:".concat(this.timeline.ready,", paused:").concat(this.timeline.paused,", force:").concat(e)),this._degradeVideoInteract();var i=0;if(this.timeline.ready&&this.timeline.paused||e){if(e=e||this._isLive,this._playRequest=null,!e)return this.timeline.emit(ie.DO_PLAY),this._innerDispatchEvent("play"),Promise.resolve();this.destroy(),this._init(),i=setTimeout((function(){try{t._innerDispatchEvent("waiting")}catch(vn){}}),300)}return this._playRequest||!this.timeline.ready||this.timeline.paused?(V.log(this.TAG,"request play!"),this._playRequest=this._playRequest||new Promise((function(e,n){t.timeline._paused=!1,t._innerDispatchEvent("play"),t._noSleep.enable(),t.timeline.once("ready",(function(){V.log(t.TAG,"timeline emit ready"),clearTimeout(i),t.timeline.play().then(e).catch(n).finally((function(){t._playRequest=null}))}))})),this.autoplay=!0,this._playRequest):Promise.resolve()}}},{key:"pause",value:function(){this._playRequest=null,this.timeline&&this.timeline.pause();try{this._noSleep.disable(),(e=D||(D=document.querySelector("#hackAudioPP")))&&e.pause()}catch(vn){}var e}},{key:"load",value:function(){}},{key:"appendBuffer",value:function(e,t){if(this.timeline&&!this._err){if(!this._logFirstFrame){var i=e&&e.samples[0],n=t&&t.samples[0];if(!i&&!n)return;if(i||n){var r=(null==e?void 0:e.duration)/((null==e?void 0:e.formatTimescale)||1/0),s=(null==t?void 0:t.duration)/((null==t?void 0:t.formatTimescale)||1/0);V.warn(this.TAG,"video firstDts:".concat(i&&i.dts," , audio firstDts:").concat(n&&n.dts," videoTrack.duration=").concat(r,", audioTrack.duration=").concat(s)),this._logFirstFrame=!0,(r||s)&&(this.setPlayMode("VOD"),this.timeline.emit(ie.SET_PLAY_MODE,this._isLive?"LIVE":"VOD"),this.duration=Math.min(r||s,s||r)),this.analyse.addFirstData()}this.lowlatency&&(V.warn(this.TAG,"single track! type=",fn),this.timeline.emit(ie.SINGLE_TRACK,fn)),t.exist()||(V.warn(this.TAG,"single track! type=",mn),this.timeline.emit(ie.SINGLE_TRACK,mn)),e.exist()||(V.warn(this.TAG,"single track! type=",_n),this.timeline.emit(ie.SINGLE_TRACK,_n))}e.formatTimescale&&e.samples.forEach((function(t){t.dts=Math.floor(t.dts/e.formatTimescale*1e3),t.pts=Math.floor(t.pts/e.formatTimescale*1e3)})),t.formatTimescale&&t.samples.forEach((function(e){e.dts=Math.floor(e.dts/t.formatTimescale*1e3),e.pts=Math.floor(e.pts/t.formatTimescale*1e3)})),this.timeline.appendBuffer(e,t)}}},{key:"setAudioMeta",value:function(e){this._aMeta=e,this.timeline.emit(ie.SET_METADATA,"audio",e)}},{key:"setVideoMeta",value:function(e){!this._isLive&&this._vMeta||(this.timeline.emit(ie.SET_METADATA,"video",e),this._vMeta=e)}},{key:"setDecodeMode",value:function(e){this.setAttribute("decodeMode",e)}},{key:"setPlayMode",value:function(e){this._isLive="LIVE"===e}},{key:"endOfStream",value:function(){var e;this.currentTime&&(null===(e=this.timeline)||void 0===e||e.emit(ie.END_OF_STREAM))}},{key:"updateVideoPostion",value:function(){var e;null===(e=this.timeline)||void 0===e||e.emit(te.UPDATE_VIDEO_FILLTYPE,this.xgfillType,this.containerLayout)}},{key:"_innerDispatchEvent",value:function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))}},{key:"destroy",value:function(e){this.timeline&&(this._noSleep.destroy(),V.log(this.TAG,"call destroy"),this.timeline.emit(ie.DESTROY,e),this.querySelector("video")&&this.removeChild(this.querySelector("video")),this.timeline=null,this._err=null,this._noSleep=null,this._eventsBackup=null)}},{key:"updateObjectPosition",value:function(e,t){this.timeline.emit(te.UPDATE_VIDEO_COVER_POSITION,this.containerLayout,e,t),this._degradeVideo&&(this._degradeVideo.style.objectPosition="".concat(100*e,"% ").concat(100*t,"%"))}},{key:"setVideoDecode",value:function(){V.log(this.TAG,"set videoDecode",this.videoDecode),this.videoDecode&&this.timeline&&this.timeline.videoRender&&(this.timeline.videoRender.videoDecode=this.videoDecode)}},{key:"live",get:function(){return this._isLive}},{key:"lowlatency",get:function(){return"true"===this.getAttribute("lowlatency")},set:function(e){this.setAttribute("lowlatency",e)}},{key:"autoplay",get:function(){return"true"===this.getAttribute("autoplay")},set:function(e){this.setAttribute("autoplay",e)}},{key:"__canvas",get:function(){return this.timeline.canvas}},{key:"__ended",get:function(){return Math.abs(this.currentTime-this.duration)<.5}},{key:"__width",get:function(){return this.getAttribute("width")||this.videoWidth},set:function(e){var t="number"==typeof e?"".concat(e,"px"):e;this.setAttribute("width",t),this.canvas.width=e}},{key:"__height",get:function(){return this.getAttribute("height")},set:function(e){var t="number"==typeof e?"".concat(e,"px"):e;this.setAttribute("height",t),this.canvas.height=e}},{key:"__videoWidth",get:function(){return this.canvas.width}},{key:"__videoHeight",get:function(){return this.canvas.height}},{key:"__volume",get:function(){return Number(this.getAttribute("volume"))},set:function(e){e<=0&&(e=0),e>=1&&(e=1),this.setAttribute("volume",e),this.muted||this.timeline.emit(ie.UPDATE_VOLUME,e)}},{key:"__muted",get:function(){return"true"===this.getAttribute("muted")},set:function(e){this.setAttribute("muted",e),this._degradeVideoInteract(),this._noSleep.enable(),this.timeline.emit(ie.UPDATE_VOLUME,e?0:this.volume)}},{key:"__currentTime",get:function(){if(!this.timeline)return 0;var e=this.timeline.currentTime,t=this.timeline.duration;return Math.min(e,t)},set:function(e){this._debounceSeek(e)}},{key:"_seek",value:function(e){this.timeline&&(this.buffered.length||this.play(),this.paused&&!this._isLive&&0===e&&this.play(),this.timeline.seek(Number(e)))}},{key:"__duration",get:function(){return this._isLive?1/0:this.timeline.duration},set:function(e){this.timeline.emit(ie.SET_VIDEO_DURATION,e),this._innerDispatchEvent("durationchange")}},{key:"__seeking",get:function(){return this.timeline.seeking}},{key:"__paused",get:function(){return this.timeline.paused}},{key:"__fps",get:function(){return this.timeline.fps}},{key:"__decodeFps",get:function(){return this.timeline.decodeFps}},{key:"__decodeCost",get:function(){return parseInt(this.timeline.decodeCost)}},{key:"__renderCost",get:function(){return this.timeline.renderCost}},{key:"__wasmInitCost",get:function(){return this.timeline.wasmInitCost}},{key:"__totalSize",get:function(){return this.timeline.totalSize}},{key:"__bitrate",get:function(){return this.timeline.bitrate}},{key:"__gopLength",get:function(){return this.timeline.gopLength}},{key:"__readyState",get:function(){return this.timeline.readyState}},{key:"__buffered",get:function(){return this.timeline.buffered}},{key:"__decoderMode",get:function(){return this.timeline.decoderMode}},{key:"src",get:function(){return this.getAttribute("src")||""},set:function(e){V.log(this.TAG,"set src ",e),this.setAttribute("src",e),this._vMeta=null,this.play(!0),this.timeline||this._init(),this._innerDispatchEvent("loadstart"),j++}},{key:"currentSrc",get:function(){return this.getAttribute("src")||""}},{key:"playbackRate",get:function(){return parseFloat(this.getAttribute("playbackrate")||1)},set:function(e){var t;this.setAttribute("playbackrate",e),null===(t=this.timeline)||void 0===t||t.emit(ie.SET_PLAYBACKRATE,e)}},{key:"networkState",get:function(){return 1}},{key:"preloadTime",get:function(){var e=this.getAttribute("preloadtime");if(e){var t=Number.parseFloat(e);if(t>0&&!Number.isNaN(t))return t}return 1/0},set:function(e){e&&Number(e)>0&&this.setAttribute("preloadtime",e)}},{key:"innerDegrade",get:function(){var e=this.getAttribute("innerdegrade");return parseInt(e)}},{key:"__glCtxOptions",set:function(e){this._glCtxOptions=e,this.timeline.emit(ie.UPDATE_GL_OPTIONS,e)}},{key:"__error",get:function(){return this._err},set:function(e){this.timeline.emit(ie.PLAY_EVENT,q.ERROR,e)}},{key:"degradeVideo",get:function(){return this._degradeVideo}},{key:"degradeInfo",get:function(){return this._deradeInfo},set:function(e){this._deradeInfo=e}},{key:"unsyncInfo",get:function(){return this._unsyncInfo},set:function(e){this._unsyncInfo=e}},{key:"xgfillType",get:function(){return this.parentNode.getAttribute("data-xgfill")}},{key:"containerLayout",get:function(){var e=this.parentNode;return{width:e.clientWidth,height:e.clientHeight}}},{key:"videoDecode",get:function(){return"7"===this.getAttribute("decodeMode")}},{key:"audioMedia",get:function(){var e,t;return null===(e=this.timeline)||void 0===e||null===(t=e.audioRender)||void 0===t?void 0:t.media}},{key:"getStats",value:function(){return this.analyse.getStats(this)}},{key:"getSeekElapses",value:function(){return this.analyse.seekElapses()}},{key:"dump",value:function(){var e=this.buffered;return console.log(e),new Array(e.length).fill(0).map((function(t,i){return[e.start(i),e.end(i)]}))}}],[{key:"version",get:function(){return"0.1.16"}},{key:"init",value:function(e){var t=e.h264Url,n=e.h264AsmUrl,r=e.h265AsmUrl,s=e.h265Url,a=e.h265ThreadUrl,o=e.h265SimdUrl;i.h264Url=t,i.h265Url=s,i.h265AsmUrl=r,i.h264AsmUrl=n,i.h265ThreadUrl=a,i.h265SimdUrl=o}},{key:"getDecodeCapacity",value:function(){return x()}},{key:"getDeviceCapacity",value:function(){return{simd:L,thread:N(),nbCpu:navigator.hardwareConcurrency}}},{key:"setDecodeCapacity",value:function(e){var t;t=e,Z=Object.assign({},Z,t),e.preloadDecoder&&sn.genDecoder().catch((function(){}))}},{key:"genDecoder",value:function(e){return sn.genDecoder(e)}},{key:"cleanDisabled",value:function(){H()}},{key:"isSupported",value:function(){return!!function(){if("undefined"==typeof customElements)return!1;if(P)return!0;var e=!1,t=!1;try{var i=new(window.AudioContext||window.webkitAudioContext);i.close(),i=null,e=!0}catch(vn){}try{for(var n=document.createElement("canvas"),r=["webgl","experimental-webgl","moz-webgl","webkit-3d"],s=0;s<r.length;s++){var a=n.getContext(r[s]);if(a){a=null,n=null,t=!0;break}}P=e&&t&&!!WebAssembly,localStorage.setItem("_sds",P?1:0)}catch(vn){}return P}()&&!1===J()}}]),i}("undefined"!=typeof HTMLElement?HTMLElement:function(){});u(pn,"decoderCache",sn);pn.init({h264Url:"https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/decoder/1.1.1/h264/decoder.js",h264AsmUrl:"https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/decoder/1.1.1/h264/decoder_asm.js",h265Url:"https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/codec/base/decoder.js",h265SimdUrl:"https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/codec/high/decoder_1656041798666.js",h265ThreadUrl:"https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/codec/main/decoder.js",h265AsmUrl:"https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/codec/high/decoder_asm.js"}),pn.setEleName=function(e){!function(e){G=e}(e);var t=function(e){A(i,e);var t=p(i);function i(){return s(this,i),t.apply(this,arguments)}return o(i)}(pn);customElements.get(F())||customElements.define(F(),t)};try{customElements.get(F())||customElements.define(F(),pn)}catch(vn){}return pn}));
|
|
2
|
+
//# sourceMappingURL=index.min.js.map
|