forked from video-dev/hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hls.min.js
1 lines (1 loc) · 216 KB
/
hls.min.js
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Hls=e():t.Hls=e()}(this,function(){return function(t){function e(i){if(r[i])return r[i].exports;var a=r[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,i){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/hls.js/dist/",e(e.s=42)}([function(t,e,r){"use strict";function i(){}function a(t,e){return e="["+t+"] > "+e}function n(t){var e=self.console[t];return e?function(){for(var r=arguments.length,i=Array(r),n=0;n<r;n++)i[n]=arguments[n];i[0]&&(i[0]=a(t,i[0])),e.apply(self.console,i)}:i}function o(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];r.forEach(function(e){u[e]=t[e]?t[e].bind(t):n(e)})}Object.defineProperty(e,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l={trace:i,debug:i,log:i,warn:i,info:i,error:i},u=l;e.enableLogs=function(t){if(!0===t||"object"===(void 0===t?"undefined":s(t))){o(t,"debug","log","info","warn","error");try{u.log()}catch(t){u=l}}else u=l},e.logger=u},function(t,e,r){"use strict";t.exports={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCH:"hlsLevelSwitch",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCH:"hlsAudioTrackSwitch",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition"}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},e.ErrorDetails={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",MANIFEST_PARSING_ERROR:"manifestParsingError",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"manifestIncompatibleCodecsError",LEVEL_LOAD_ERROR:"levelLoadError",LEVEL_LOAD_TIMEOUT:"levelLoadTimeOut",LEVEL_SWITCH_ERROR:"levelSwitchError",AUDIO_TRACK_LOAD_ERROR:"audioTrackLoadError",AUDIO_TRACK_LOAD_TIMEOUT:"audioTrackLoadTimeOut",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOOP_LOADING_ERROR:"fragLoopLoadingError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",REMUX_ALLOC_ERROR:"remuxAllocError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_ADD_CODEC_ERROR:"bufferAddCodecError",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole",BUFFER_NUDGE_ON_STALL:"bufferNudgeOnStall",INTERNAL_EXCEPTION:"internalException",WEBVTT_EXCEPTION:"webVTTException"}},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=r(0),o=r(2),s=r(1),l=function(t){return t&&t.__esModule?t:{default:t}}(s),u=function(){function t(e){i(this,t),this.hls=e,this.onEvent=this.onEvent.bind(this);for(var r=arguments.length,a=Array(r>1?r-1:0),n=1;n<r;n++)a[n-1]=arguments[n];this.handledEvents=a,this.useGenericHandler=!0,this.registerListeners()}return t.prototype.destroy=function(){this.unregisterListeners()},t.prototype.isEventHandler=function(){return"object"===a(this.handledEvents)&&this.handledEvents.length&&"function"==typeof this.onEvent},t.prototype.registerListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(t){if("hlsEventGeneric"===t)throw new Error("Forbidden event name: "+t);this.hls.on(t,this.onEvent)},this)},t.prototype.unregisterListeners=function(){this.isEventHandler()&&this.handledEvents.forEach(function(t){this.hls.off(t,this.onEvent)},this)},t.prototype.onEvent=function(t,e){this.onEventGeneric(t,e)},t.prototype.onEventGeneric=function(t,e){var r=function(t,e){var r="on"+t.replace("hls","");if("function"!=typeof this[r])throw new Error("Event "+t+" has no generic handler in this "+this.constructor.name+" class (tried "+r+")");return this[r].bind(this,e)};try{r.call(this,t,e).call()}catch(e){n.logger.error("internal error happened while processing "+t+":"+e.message),this.hls.trigger(l.default.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,err:e})}},t}();e.default=u},function(t,e,r){"use strict";var i={isBuffered:function(t,e){if(t)for(var r=t.buffered,i=0;i<r.length;i++)if(e>=r.start(i)&&e<=r.end(i))return!0;return!1},bufferInfo:function(t,e,r){if(t){var i,a=t.buffered,n=[];for(i=0;i<a.length;i++)n.push({start:a.start(i),end:a.end(i)});return this.bufferedInfo(n,e,r)}return{len:0,start:e,end:e,nextStart:void 0}},bufferedInfo:function(t,e,r){var i,a,n,o,s,l=[];for(t.sort(function(t,e){var r=t.start-e.start;return r||e.end-t.end}),s=0;s<t.length;s++){var u=l.length;if(u){var d=l[u-1].end;t[s].start-d<r?t[s].end>d&&(l[u-1].end=t[s].end):l.push(t[s])}else l.push(t[s])}for(s=0,i=0,a=n=e;s<l.length;s++){var f=l[s].start,c=l[s].end;if(e+r>=f&&e<c)a=f,n=c,i=n-e;else if(e+r<f){o=f;break}}return{len:i,start:a,end:n,nextStart:o}}};t.exports=i},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){i(this,t)}return t.isHeader=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},t.isFooter=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},t.getID3Data=function(e,r){for(var i=r,a=0;t.isHeader(e,r);){a+=10;a+=t._readSize(e,r+6),t.isFooter(e,r+10)&&(a+=10),r+=a}if(a>0)return e.subarray(i,i+a)},t._readSize=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},t.getTimeStamp=function(e){for(var r=t.getID3Frames(e),i=0;i<r.length;i++){var a=r[i];if(t.isTimeStampFrame(a))return t._readTimeStamp(a)}},t.isTimeStampFrame=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},t._getFrameData=function(e){var r=String.fromCharCode(e[0],e[1],e[2],e[3]),i=t._readSize(e,4);return{type:r,size:i,data:e.subarray(10,10+i)}},t.getID3Frames=function(e){for(var r=0,i=[];t.isHeader(e,r);){var a=t._readSize(e,r+6);r+=10;for(var n=r+a;r+8<n;){var o=t._getFrameData(e.subarray(r)),s=t._decodeFrame(o);s&&i.push(s),r+=o.size+10}t.isFooter(e,r)&&(r+=10)}return i},t._decodeFrame=function(e){return"PRIV"===e.type?t._decodePrivFrame(e):"T"===e.type[0]?t._decodeTextFrame(e):"W"===e.type[0]?t._decodeURLFrame(e):void 0},t._readTimeStamp=function(t){if(8===t.data.byteLength){var e=new Uint8Array(t.data),r=1&e[3],i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},t._decodePrivFrame=function(e){if(!(e.size<2)){var r=t._utf8ArrayToStr(e.data),i=new Uint8Array(e.data.subarray(r.length+1));return{key:e.type,info:r,data:i.buffer}}},t._decodeTextFrame=function(e){if(!(e.size<2)){if("TXXX"===e.type){var r=1,i=t._utf8ArrayToStr(e.data.subarray(r));r+=i.length+1;var a=t._utf8ArrayToStr(e.data.subarray(r));return{key:e.type,info:i,data:a}}var n=t._utf8ArrayToStr(e.data.subarray(1));return{key:e.type,data:n}}},t._decodeURLFrame=function(e){if("WXXX"===e.type){if(e.size<2)return;var r=1,i=t._utf8ArrayToStr(e.data.subarray(r));r+=i.length+1;var a=t._utf8ArrayToStr(e.data.subarray(r));return{key:e.type,info:i,data:a}}var n=t._utf8ArrayToStr(e.data);return{key:e.type,data:n}},t._utf8ArrayToStr=function(t){for(var e=void 0,r=void 0,i="",a=0,n=t.length;a<n;){var o=t[a++];switch(o>>4){case 0:return i;case 1:case 2:case 3:case 4:case 5:case 6:case 7:i+=String.fromCharCode(o);break;case 12:case 13:e=t[a++],i+=String.fromCharCode((31&o)<<6|63&e);break;case 14:e=t[a++],r=t[a++],i+=String.fromCharCode((15&o)<<12|(63&e)<<6|(63&r)<<0)}}return i},t}();e.default=a},function(t,e,r){"use strict";var i={search:function(t,e){for(var r=0,i=t.length-1,a=null,n=null;r<=i;){a=(r+i)/2|0,n=t[a];var o=e(n);if(o>0)r=a+1;else{if(!(o<0))return n;i=a-1}}return null}};t.exports=i},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function a(t){return"number"==typeof t}function n(t){return"object"==typeof t&&null!==t}function o(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!a(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,a,s,l,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||n(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var d=new Error('Uncaught, unspecified "error" event. ('+e+")");throw d.context=e,d}if(r=this._events[t],o(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),r.apply(this,s)}else if(n(r))for(s=Array.prototype.slice.call(arguments,1),u=r.slice(),a=u.length,l=0;l<a;l++)u[l].apply(this,s);return!0},r.prototype.addListener=function(t,e){var a;if(!i(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?n(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,n(this._events[t])&&!this._events[t].warned&&(a=o(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&a>0&&this._events[t].length>a&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),a||(a=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var a=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,a,o,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],o=r.length,a=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(n(r)){for(s=o;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){a=s;break}if(a<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(a,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=r(31),o=i(n),s=r(33),l=i(s),u=r(32),d=i(u),f=r(2),c=r(0),h=function(){function t(e,r){a(this,t),this.observer=e,this.config=r,this.logEnabled=!0;try{var i=crypto||self.crypto;this.subtle=i.subtle||i.webkitSubtle}catch(t){}this.disableWebCrypto=!this.subtle}return t.prototype.isSync=function(){return this.disableWebCrypto&&this.config.enableSoftwareAES},t.prototype.decrypt=function(t,e,r,i){var a=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(c.logger.log("JS AES decrypt"),this.logEnabled=!1);var n=this.decryptor;n||(this.decryptor=n=new d.default),n.expandKey(e),i(n.decrypt(t,0,r))}else{this.logEnabled&&(c.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var s=this.subtle;this.key!==e&&(this.key=e,this.fastAesKey=new l.default(s,e)),this.fastAesKey.expandKey().then(function(n){new o.default(s,r).decrypt(t,n).catch(function(n){a.onWebCryptoError(n,t,e,r,i)}).then(function(t){i(t)})}).catch(function(n){a.onWebCryptoError(n,t,e,r,i)})}},t.prototype.onWebCryptoError=function(t,e,r,i,a){this.config.enableSoftwareAES?(c.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(e,r,i,a)):(c.logger.error("decrypting error : "+t.message),this.observer.trigger(Event.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:t.message}))},t.prototype.destroy=function(){var t=this.decryptor;t&&(t.destroy(),this.decryptor=void 0)},t}();e.default=h},function(t,e,r){"use strict";var i=r(0),a=r(2),n={getAudioConfig:function(t,e,r,n){var o,s,l,u,d,f=navigator.userAgent.toLowerCase(),c=n,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];return o=1+((192&e[r+2])>>>6),(s=(60&e[r+2])>>>2)>h.length-1?void t.trigger(Event.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+s}):(u=(1&e[r+2])<<2,u|=(192&e[r+3])>>>6,i.logger.log("manifest codec:"+n+",ADTS data:type:"+o+",sampleingIndex:"+s+"["+h[s]+"Hz],channelConfig:"+u),/firefox/i.test(f)?s>=6?(o=5,d=new Array(4),l=s-3):(o=2,d=new Array(2),l=s):-1!==f.indexOf("android")?(o=2,d=new Array(2),l=s):(o=5,d=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&s>=6?l=s-3:((n&&-1!==n.indexOf("mp4a.40.2")&&s>=6&&1===u||!n&&1===u)&&(o=2,d=new Array(2)),l=s)),d[0]=o<<3,d[0]|=(14&s)>>1,d[1]|=(1&s)<<7,d[1]|=u<<3,5===o&&(d[1]|=(14&l)>>1,d[2]=(1&l)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:h[s],channelCount:u,codec:"mp4a.40."+o,manifestCodec:c})},isHeaderPattern:function(t,e){return 255===t[e]&&240==(246&t[e+1])},getHeaderLength:function(t,e){return 1&t[e+1]?7:9},getFullFrameLength:function(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5},isHeader:function(t,e){return!!(e+1<t.length&&this.isHeaderPattern(t,e))},probe:function(t,e){if(e+1<t.length&&this.isHeaderPattern(t,e)){var r=this.getHeaderLength(t,e),i=r;e+5<t.length&&(i=this.getFullFrameLength(t,e));var a=e+i;if(a===t.length||a+1<t.length&&this.isHeaderPattern(t,a))return!0}return!1},initTrackConfig:function(t,e,r,a,n){if(!t.samplerate){var o=this.getAudioConfig(e,r,a,n);t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,i.logger.log("parsed codec:"+t.codec+",rate:"+o.samplerate+",nb channel:"+o.channelCount)}},getFrameDuration:function(t){return 9216e4/t},appendFrame:function(t,e,r,i,a){var n=this.getFrameDuration(t.samplerate),o=this.parseFrameHeader(e,r,i,a,n);if(o){var s=o.stamp,l=o.headerLength,u=o.frameLength,d={unit:e.subarray(r+l,r+l+u),pts:s,dts:s};return t.samples.push(d),t.len+=u,{sample:d,length:u+l}}},parseFrameHeader:function(t,e,r,i,a){var n,o,s,l=t.length;if(n=this.getHeaderLength(t,e),o=this.getFullFrameLength(t,e),(o-=n)>0&&e+n+o<=l)return s=r+i*a,{headerLength:n,frameLength:o,stamp:s}}};t.exports=n},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=r(1),o=i(n),s=r(2),l=r(8),u=i(l),d=r(34),f=i(d),c=r(38),h=i(c),p=r(40),g=i(p),v=r(37),y=i(v),m=r(47),E=i(m),T=r(48),b=i(T),R=function(){function t(e,r,i,n){a(this,t),this.observer=e,this.typeSupported=r,this.config=i,this.vendor=n}return t.prototype.destroy=function(){var t=this.demuxer;t&&t.destroy()},t.prototype.push=function(t,e,r,i,a,n,s,l,d,f,c,h){if(t.byteLength>0&&null!=e&&null!=e.key&&"AES-128"===e.method){var p=this.decrypter;null==p&&(p=this.decrypter=new u.default(this.observer,this.config));var g,v=this;try{g=performance.now()}catch(t){g=Date.now()}p.decrypt(t,e.key.buffer,e.iv.buffer,function(t){var u;try{u=performance.now()}catch(t){u=Date.now()}v.observer.trigger(o.default.FRAG_DECRYPTED,{stats:{tstart:g,tdecrypt:u}}),v.pushDecrypted(new Uint8Array(t),e,new Uint8Array(r),i,a,n,s,l,d,f,c,h)})}else this.pushDecrypted(new Uint8Array(t),e,new Uint8Array(r),i,a,n,s,l,d,f,c,h)},t.prototype.pushDecrypted=function(t,e,r,i,a,n,l,u,d,c,p,v){var m=this.demuxer;if(!m||l&&!this.probe(t)){for(var T=this.observer,R=this.typeSupported,_=this.config,S=[{demux:f.default,remux:E.default},{demux:y.default,remux:E.default},{demux:g.default,remux:E.default},{demux:h.default,remux:b.default}],A=0,L=S.length;A<L;A++){var w=S[A],D=w.demux.probe;if(D(t)){var O=this.remuxer=new w.remux(T,_,R,this.vendor);m=new w.demux(T,O,_,R),this.probe=D;break}}if(!m)return void T.trigger(o.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});this.demuxer=m}var I=this.remuxer;(l||u)&&(m.resetInitSegment(r,i,a,c),I.resetInitSegment()),l&&(m.resetTimeStamp(v),I.resetTimeStamp(v)),"function"==typeof m.setDecryptData&&m.setDecryptData(e),m.append(t,n,d,p)},t}();e.default=R},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=r(1),o=i(n),s=r(10),l=i(s),u=r(0),d=r(2),f=r(7),c=i(f),h=r(58),p=i(h),g=function(){function t(e,r){a(this,t),this.hls=e,this.id=r;var i=this.observer=new c.default,n=e.config;i.trigger=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),a=1;a<e;a++)r[a-1]=arguments[a];i.emit.apply(i,[t,t].concat(r))},i.off=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),a=1;a<e;a++)r[a-1]=arguments[a];i.removeListener.apply(i,[t].concat(r))};var s=function(t,r){r=r||{},r.frag=this.frag,r.id=this.id,e.trigger(t,r)}.bind(this);i.on(o.default.FRAG_DECRYPTED,s),i.on(o.default.FRAG_PARSING_INIT_SEGMENT,s),i.on(o.default.FRAG_PARSING_DATA,s),i.on(o.default.FRAG_PARSED,s),i.on(o.default.ERROR,s),i.on(o.default.FRAG_PARSING_METADATA,s),i.on(o.default.FRAG_PARSING_USERDATA,s),i.on(o.default.INIT_PTS_FOUND,s);var f={mp4:MediaSource.isTypeSupported("video/mp4"),mpeg:MediaSource.isTypeSupported("audio/mpeg"),mp3:MediaSource.isTypeSupported('audio/mp4; codecs="mp3"')},h=navigator.vendor;if(n.enableWorker&&"undefined"!=typeof Worker){u.logger.log("demuxing in webworker");var g=void 0;try{g=this.w=(0,p.default)(35),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(t){e.trigger(o.default.ERROR,{type:d.ErrorTypes.OTHER_ERROR,details:d.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:t.message+" ("+t.filename+":"+t.lineno+")"}})},g.postMessage({cmd:"init",typeSupported:f,vendor:h,id:r,config:JSON.stringify(n)})}catch(t){u.logger.error("error while initializing DemuxerWorker, fallback on DemuxerInline"),g&&URL.revokeObjectURL(g.objectURL),this.demuxer=new l.default(i,f,n,h),this.w=void 0}}else this.demuxer=new l.default(i,f,n,h)}return t.prototype.destroy=function(){var t=this.w;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.w=null;else{var e=this.demuxer;e&&(e.destroy(),this.demuxer=null)}var r=this.observer;r&&(r.removeAllListeners(),this.observer=null)},t.prototype.push=function(t,e,r,i,a,n,o,s){var l=this.w,d=isNaN(a.startDTS)?a.start:a.startDTS,f=a.decryptdata,c=this.frag,h=!(c&&a.cc===c.cc),p=!(c&&a.level===c.level),g=c&&a.sn===c.sn+1,v=!p&&g;if(h&&u.logger.log(this.id+":discontinuity detected"),p&&u.logger.log(this.id+":switch detected"),this.frag=a,l)l.postMessage({cmd:"demux",data:t,decryptdata:f,initSegment:e,audioCodec:r,videoCodec:i,timeOffset:d,discontinuity:h,trackSwitch:p,contiguous:v,duration:n,accurateTimeOffset:o,defaultInitPTS:s},[t]);else{var y=this.demuxer;y&&y.push(t,f,e,r,i,d,h,p,v,n,o,s)}},t.prototype.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":URL.revokeObjectURL(this.w.objectURL);break;case o.default.FRAG_PARSING_DATA:e.data.data1=new Uint8Array(e.data1),e.data2&&(e.data.data2=new Uint8Array(e.data2));default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},t}();e.default=g},function(t,e,r){"use strict";var i={BitratesMap:[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],appendFrame:function(t,e,r,i,a){if(!(r+24>e.length)){var n=this.parseHeader(e,r);if(n&&r+n.frameLength<=e.length){var o=10368e4/n.sampleRate,s=i+a*o,l={unit:e.subarray(r,r+n.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=n.channelCount,t.samplerate=n.sampleRate,t.samples.push(l),t.len+=n.frameLength,{sample:l,length:n.frameLength}}}},parseHeader:function(t,e){var r=t[e+1]>>3&3,a=t[e+1]>>1&3,n=t[e+2]>>4&15,o=t[e+2]>>2&3,s=!!(2&t[e+2]);if(1!==r&&0!==n&&15!==n&&3!==o){var l=3===r?3-a:3===a?3:4,u=1e3*i.BitratesMap[14*l+n-1],d=3===r?0:2===r?1:2,f=i.SamplingRateMap[3*d+o],c=s?1:0;return{sampleRate:f,channelCount:t[e+3]>>6==3?1:2,frameLength:3===a?(3===r?12:6)*u/f+c<<2:(3===r?144:72)*u/f+c|0}}},isHeaderPattern:function(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])},isHeader:function(t,e){return!!(e+1<t.length&&this.isHeaderPattern(t,e))},probe:function(t,e){if(e+1<t.length&&this.isHeaderPattern(t,e)){var r=this.parseHeader(t,e),i=4;r&&r.frameLength&&(i=r.frameLength);var a=e+i;if(a===t.length||a+1<t.length&&this.isHeaderPattern(t,a))return!0}return!1}};t.exports=i},function(t,e,r){"use strict";var i=r(0),a={mergeDetails:function(t,e){var r,n=Math.max(t.startSN,e.startSN)-e.startSN,o=Math.min(t.endSN,e.endSN)-e.startSN,s=e.startSN-t.startSN,l=t.fragments,u=e.fragments,d=0;if(o<n)return void(e.PTSKnown=!1);for(var f=n;f<=o;f++){var c=l[s+f],h=u[f];h&&c&&(d=c.cc-h.cc,isNaN(c.startPTS)||(h.start=h.startPTS=c.startPTS,h.endPTS=c.endPTS,h.duration=c.duration,h.backtracked=c.backtracked,h.dropped=c.dropped,r=h))}if(d)for(i.logger.log("discontinuity sliding from playlist, take drift into account"),f=0;f<u.length;f++)u[f].cc+=d;if(r)a.updateFragPTSDTS(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS);else if(s>=0&&s<l.length){var p=l[s].start;for(f=0;f<u.length;f++)u[f].start+=p}e.PTSKnown=t.PTSKnown},updateFragPTSDTS:function(t,e,r,i,n,o){var s=r;if(!isNaN(e.startPTS)){var l=Math.abs(e.startPTS-r);isNaN(e.deltaPTS)?e.deltaPTS=l:e.deltaPTS=Math.max(l,e.deltaPTS),s=Math.max(r,e.startPTS),r=Math.min(r,e.startPTS),i=Math.max(i,e.endPTS),n=Math.min(n,e.startDTS),o=Math.max(o,e.endDTS)}var u=r-e.start;e.start=e.startPTS=r,e.maxStartPTS=s,e.endPTS=i,e.startDTS=n,e.endDTS=o,e.duration=i-r;var d=e.sn;if(!t||d<t.startSN||d>t.endSN)return 0;var f,c,h;for(f=d-t.startSN,c=t.fragments,e=c[f],h=f;h>0;h--)a.updatePTS(c,h,h-1);for(h=f;h<c.length-1;h++)a.updatePTS(c,h,h+1);return t.PTSKnown=!0,u},updatePTS:function(t,e,r){var a=t[e],n=t[r],o=n.startPTS;isNaN(o)?n.start=r>e?a.start+a.duration:Math.max(a.start-n.duration,0):r>e?(a.duration=o-a.start,a.duration<0&&i.logger.warn("negative duration computed for frag "+a.sn+",level "+a.level+", there should be some duration drift between playlist and fragment!")):(n.duration=a.start-o,n.duration<0&&i.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!"))}};t.exports=a},function(t,e,r){"use strict";var i={toString:function(t){for(var e="",r=t.length,i=0;i<r;i++)e+="["+t.start(i).toFixed(3)+","+t.end(i).toFixed(3)+"]";return e}};t.exports=i},function(t,e,r){"use strict";function i(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new f,this.regionList=[]}function a(t){function e(t,e,r,i){return 3600*(0|t)+60*(0|e)+(0|r)+(0|i)/1e3}var r=t.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?e(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?e(r[1],r[2],0,r[4]):e(0,r[1],r[2],r[4]):null}function n(){this.values=Object.create(null)}function o(t,e,r,i){var a=i?t.split(i):[t];for(var n in a)if("string"==typeof a[n]){var o=a[n].split(r);if(2===o.length){var s=o[0],l=o[1];e(s,l)}}}function s(t,e,r){function i(){var e=a(t);if(null===e)throw new Error("Malformed timestamp: "+l);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function s(){t=t.replace(/^\s+/,"")}var l=t;if(s(),e.startTime=i(),s(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+l);t=t.substr(3),s(),e.endTime=i(),s(),function(t,e){var i=new n;o(t,function(t,e){switch(t){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===e){i.set(t,r[a].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":var n=e.split(","),o=n[0];i.integer(t,o),i.percent(t,o)&&i.set("snapToLines",!1),i.alt(t,o,["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",h,"end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",h,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",h,"end","left","right"])}},/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var a=i.get("line","auto");"auto"===a&&-1===c.line&&(a=-1),e.line=a,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",h);var s=i.get("position","auto");"auto"===s&&50===c.position&&(s="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=s}(t,e)}function l(t){return t.replace(/<br(?: \/)?>/gi,"\n")}Object.defineProperty(e,"__esModule",{value:!0}),e.fixLineBreaks=void 0;var u=r(55),d=function(t){return t&&t.__esModule?t:{default:t}}(u),f=function(){return{decode:function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}};n.prototype={set:function(t,e){this.get(t)||""===e||(this.values[t]=e)},get:function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,r){for(var i=0;i<r.length;++i)if(e===r[i]){this.set(t,e);break}},integer:function(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))},percent:function(t,e){return!!(e.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(e=parseFloat(e))>=0&&e<=100)&&(this.set(t,e),!0)}};var c=new d.default(0,0,0),h="middle"===c.align?"middle":"center";i.prototype={parse:function(t){function e(){var t=r.buffer,e=0;for(t=l(t);e<t.length&&"\r"!==t[e]&&"\n"!==t[e];)++e;var i=t.substr(0,e);return"\r"===t[e]&&++e,"\n"===t[e]&&++e,r.buffer=t.substr(e),i}var r=this;t&&(r.buffer+=r.decoder.decode(t,{stream:!0}));try{var i;if("INITIAL"===r.state){if(!/\r\n|\n/.test(r.buffer))return this;i=e();var a=i.match(/^WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");r.state="HEADER"}for(var n=!1;r.buffer;){if(!/\r\n|\n/.test(r.buffer))return this;switch(n?n=!1:i=e(),r.state){case"HEADER":/:/.test(i)?function(t){o(t,function(t,e){switch(t){case"Region":console.log("parse region",e)}},/:/)}(i):i||(r.state="ID");continue;case"NOTE":i||(r.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){r.state="NOTE";break}if(!i)continue;if(r.cue=new d.default(0,0,""),r.state="CUE",-1===i.indexOf("--\x3e")){r.cue.id=i;continue}case"CUE":try{s(i,r.cue,r.regionList)}catch(t){r.cue=null,r.state="BADCUE";continue}r.state="CUETEXT";continue;case"CUETEXT":var u=-1!==i.indexOf("--\x3e");if(!i||u&&(n=!0)){r.oncue&&r.oncue(r.cue),r.cue=null,r.state="ID";continue}r.cue.text&&(r.cue.text+="\n"),r.cue.text+=i;continue;case"BADCUE":i||(r.state="ID");continue}}}catch(t){"CUETEXT"===r.state&&r.cue&&r.oncue&&r.oncue(r.cue),r.cue=null,r.state="INITIAL"===r.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var t=this;try{if(t.buffer+=t.decoder.decode(),(t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state)throw new Error("Malformed WebVTT signature.")}catch(t){throw t}return t.onflush&&t.onflush(),this}},e.fixLineBreaks=l,e.default=i},function(t,e,r){!function(e){var r=/^((?:[^\/;?#]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,i=/^([^\/;?#]*)(.*)$/,a=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,o={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var a=this.parseURL(t);if(!s)throw new Error("Error trying to parse base URL.");return a.path=o.normalizePath(a.path),o.buildURLFromParts(a)}var n=this.parseURL(e);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=o.normalizePath(n.path),o.buildURLFromParts(n)):e;var s=this.parseURL(t);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var l=i.exec(s.path);s.netLoc=l[1],s.path=l[2]}s.netLoc&&!s.path&&(s.path="/");var u={scheme:s.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=s.netLoc,"/"!==n.path[0]))if(n.path){var d=s.path,f=d.substring(0,d.lastIndexOf("/")+1)+n.path;u.path=o.normalizePath(f)}else u.path=s.path,n.params||(u.params=s.params,n.query||(u.query=s.query));return null===u.path&&(u.path=r.alwaysNormalize?o.normalizePath(n.path):n.path),o.buildURLFromParts(u)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};t.exports=o}()},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),o=r(16),s=i(o),l=r(1),u=i(l),d=r(2),f=r(45),c=i(f),h=r(43),p=i(h),g=r(44),v=i(g),y=r(27),m=i(y),E=r(26),T=i(E),b=r(25),R=i(b),_=r(0),S=r(7),A=i(S),L=r(18),w=function(){function t(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,t);var i=t.DefaultConfig;if((r.liveSyncDurationCount||r.liveMaxLatencyDurationCount)&&(r.liveSyncDuration||r.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");for(var n in i)n in r||(r[n]=i[n]);if(void 0!==r.liveMaxLatencyDurationCount&&r.liveMaxLatencyDurationCount<=r.liveSyncDurationCount)throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be gt "liveSyncDurationCount"');if(void 0!==r.liveMaxLatencyDuration&&(r.liveMaxLatencyDuration<=r.liveSyncDuration||void 0===r.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be gt "liveSyncDuration"');(0,_.enableLogs)(r.debug),this.config=r,this._autoLevelCapping=-1;var o=this.observer=new A.default;o.trigger=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];o.emit.apply(o,[t,t].concat(r))},o.off=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];o.removeListener.apply(o,[t].concat(r))},this.on=o.on.bind(o),this.off=o.off.bind(o),this.trigger=o.trigger.bind(o);var s=this.abrController=new r.abrController(this),l=new r.bufferController(this),u=new r.capLevelController(this),d=new r.fpsController(this),f=new c.default(this),h=new p.default(this),g=new v.default(this),y=new R.default(this),E=this.levelController=new T.default(this),b=this.streamController=new m.default(this),S=[E,b],L=r.audioStreamController;L&&S.push(new L(this)),this.networkControllers=S;var w=[f,h,g,s,l,u,d,y];if(L=r.audioTrackController){var D=new L(this);this.audioTrackController=D,w.push(D)}if(L=r.subtitleTrackController){var O=new L(this);this.subtitleTrackController=O,w.push(O)}[r.subtitleStreamController,r.timelineController].forEach(function(t){t&&w.push(new t(e))}),this.coreComponents=w}return t.isSupported=function(){var t=window.MediaSource=window.MediaSource||window.WebKitMediaSource,e=window.SourceBuffer=window.SourceBuffer||window.WebKitSourceBuffer,r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return r&&i},n(t,null,[{key:"version",get:function(){return"0.7.10"}},{key:"Events",get:function(){return u.default}},{key:"ErrorTypes",get:function(){return d.ErrorTypes}},{key:"ErrorDetails",get:function(){return d.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:L.hlsDefaultConfig},set:function(e){t.defaultConfig=e}}]),t.prototype.destroy=function(){_.logger.log("destroy"),this.trigger(u.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach(function(t){t.destroy()}),this.url=null,this.observer.removeAllListeners(),this._autoLevelCapping=-1},t.prototype.attachMedia=function(t){_.logger.log("attachMedia"),this.media=t,this.trigger(u.default.MEDIA_ATTACHING,{media:t})},t.prototype.detachMedia=function(){_.logger.log("detachMedia"),this.trigger(u.default.MEDIA_DETACHING),this.media=null},t.prototype.loadSource=function(t){t=s.default.buildAbsoluteURL(window.location.href,t,{alwaysNormalize:!0}),_.logger.log("loadSource:"+t),this.url=t,this.trigger(u.default.MANIFEST_LOADING,{url:t})},t.prototype.startLoad=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;_.logger.log("startLoad("+t+")"),this.networkControllers.forEach(function(e){e.startLoad(t)})},t.prototype.stopLoad=function(){_.logger.log("stopLoad"),this.networkControllers.forEach(function(t){t.stopLoad()})},t.prototype.swapAudioCodec=function(){_.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},t.prototype.recoverMediaError=function(){_.logger.log("recoverMediaError");var t=this.media;this.detachMedia(),this.attachMedia(t)},n(t,[{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){_.logger.log("set currentLevel:"+t),this.loadLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){_.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){_.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){_.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){_.logger.log("set startLevel:"+t);var e=this;-1!==t&&(t=Math.max(t,e.minAutoLevel)),e.levelController.startLevel=t}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){_.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){for(var t=this,e=t.levels,r=t.config.minAutoBitrate,i=e?e.length:0,a=0;a<i;a++){if((e[a].realBitrate?Math.max(e[a].realBitrate,e[a].bitrate):e[a].bitrate)>r)return a}return 0}},{key:"maxAutoLevel",get:function(){var t=this,e=t.levels,r=t.autoLevelCapping;return-1===r&&e&&e.length?e.length-1:r}},{key:"nextAutoLevel",get:function(){var t=this;return Math.min(Math.max(t.abrController.nextAutoLevel,t.minAutoLevel),t.maxAutoLevel)},set:function(t){var e=this;e.abrController.nextAutoLevel=Math.max(e.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}}]),t}();e.default=w},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.hlsDefaultConfig=void 0;var a=r(19),n=i(a),o=r(22),s=i(o),l=r(23),u=i(l),d=r(24),f=i(d),c=r(57),h=i(c),p=r(21),g=i(p),v=r(20),y=i(v),m=r(51),E=i(m),T=r(30),b=i(T),R=r(29),_=i(R),S=r(28),A=i(S),L=e.hlsDefaultConfig={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,maxSeekHole:2,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.2,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,fragLoadingLoopThreshold:3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:h.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,fetchSetup:void 0,abrController:n.default,bufferController:s.default,capLevelController:u.default,fpsController:f.default,stretchShortVideoTrack:!1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0};L.audioStreamController=y.default,L.audioTrackController=g.default,L.subtitleStreamController=A.default,L.subtitleTrackController=_.default,L.timelineController=b.default,L.cueHandler=E.default,L.enableCEA708Captions=!0,L.enableWebVTT=!0,L.captionsTextTrack1Label="English",L.captionsTextTrack1LanguageCode="en",L.captionsTextTrack2Label="Spanish",L.captionsTextTrack2LanguageCode="es"},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),l=r(1),u=i(l),d=r(3),f=i(d),c=r(4),h=i(c),p=r(2),g=r(0),v=r(53),y=i(v),m=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,u.default.FRAG_LOADING,u.default.FRAG_LOADED,u.default.FRAG_BUFFERED,u.default.ERROR));return i.lastLoadedFragLevel=0,i._nextAutoLevel=-1,i.hls=r,i.timer=null,i._bwEstimator=null,i.onCheck=i._abandonRulesCheck.bind(i),i}return o(e,t),e.prototype.destroy=function(){this.clearTimer(),f.default.prototype.destroy.call(this)},e.prototype.onFragLoading=function(t){var e=t.frag;if("main"===e.type){if(this.timer||(this.timer=setInterval(this.onCheck,100)),!this._bwEstimator){var r=this.hls,i=t.frag.level,a=r.levels[i].details.live,n=r.config,o=void 0,s=void 0;a?(o=n.abrEwmaFastLive,s=n.abrEwmaSlowLive):(o=n.abrEwmaFastVoD,s=n.abrEwmaSlowVoD),this._bwEstimator=new y.default(r,s,o,n.abrEwmaDefaultEstimate)}this.fragCurrent=e}},e.prototype._abandonRulesCheck=function(){var t=this.hls,e=t.media,r=this.fragCurrent,i=r.loader,a=t.minAutoLevel;if(!i||i.stats&&i.stats.aborted)return g.logger.warn("frag loader destroy or aborted, disarm abandonRules"),void this.clearTimer();var n=i.stats;if(e&&(!e.paused&&0!==e.playbackRate||!e.readyState)&&r.autoLevel&&r.level){var o=performance.now()-n.trequest,s=Math.abs(e.playbackRate);if(o>500*r.duration/s){var l=t.levels,d=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/o),f=l[r.level],c=f.realBitrate?Math.max(f.realBitrate,f.bitrate):f.bitrate,p=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*c/8)),v=e.currentTime,y=(p-n.loaded)/d,m=(h.default.bufferInfo(e,v,t.config.maxBufferHole).end-v)/s;if(m<2*r.duration/s&&y>m){var E=void 0,T=void 0;for(T=r.level-1;T>a;T--){var b=l[T].realBitrate?Math.max(l[T].realBitrate,l[T].bitrate):l[T].bitrate;if((E=r.duration*b/(6.4*d))<m)break}E<y&&(g.logger.warn("loading too slow, abort fragment loading and switch to level "+T+":fragLoadedDelay["+T+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+E.toFixed(1)+"<"+y.toFixed(1)+":"+m.toFixed(1)),t.nextLoadLevel=T,this._bwEstimator.sample(o,n.loaded),i.abort(),this.clearTimer(),t.trigger(u.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:n}))}}}},e.prototype.onFragLoaded=function(t){var e=t.frag;if("main"===e.type&&!isNaN(e.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[e.level],i=(r.loaded?r.loaded.bytes:0)+t.stats.loaded,a=(r.loaded?r.loaded.duration:0)+t.frag.duration;r.loaded={bytes:i,duration:a},r.realBitrate=Math.round(8*i/a)}if(t.frag.bitrateTest){var n=t.stats;n.tparsed=n.tbuffered=n.tload,this.onFragBuffered(t)}}},e.prototype.onFragBuffered=function(t){var e=t.stats,r=t.frag;if(!(!0===e.aborted||1!==r.loadCounter||"main"!==r.type||isNaN(r.sn)||r.bitrateTest&&e.tload!==e.tbuffered)){var i=e.tparsed-e.trequest;g.logger.log("latency/loading/parsing/append/kbps:"+Math.round(e.tfirst-e.trequest)+"/"+Math.round(e.tload-e.tfirst)+"/"+Math.round(e.tparsed-e.tload)+"/"+Math.round(e.tbuffered-e.tparsed)+"/"+Math.round(8*e.loaded/(e.tbuffered-e.trequest))),this._bwEstimator.sample(i,e.loaded),e.bwEstimate=this._bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},e.prototype.onError=function(t){switch(t.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},e.prototype.clearTimer=function(){clearInterval(this.timer),this.timer=null},e.prototype._findBestLevel=function(t,e,r,i,a,n,o,s,l){for(var u=a;u>=i;u--){var d=l[u],f=d.details,c=f?f.totalduration/f.fragments.length:e,h=!!f&&f.live,p=void 0;p=u<=t?o*r:s*r;var v=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,y=v*c/p;if(g.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(p)+"/"+v+"/"+c+"/"+n+"/"+y),p>v&&(!y||h&&!this.bitrateTestDelay||y<n))return u}return-1},s(e,[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,e=this._bwEstimator;if(!(-1===t||e&&e.canEstimate()))return t;var r=this._nextABRAutoLevel;return-1!==t&&(r=Math.min(t,r)),r},set:function(t){this._nextAutoLevel=t}},{key:"_nextABRAutoLevel",get:function(){var t=this.hls,e=t.maxAutoLevel,r=t.levels,i=t.config,a=t.minAutoLevel,n=t.media,o=this.lastLoadedFragLevel,s=this.fragCurrent?this.fragCurrent.duration:0,l=n?n.currentTime:0,u=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,d=this._bwEstimator?this._bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,f=(h.default.bufferInfo(n,l,i.maxBufferHole).end-l)/u,c=this._findBestLevel(o,s,d,a,e,f,i.abrBandWidthFactor,i.abrBandWidthUpFactor,r);if(c>=0)return c;g.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var p=s?Math.min(s,i.maxStarvationDelay):i.maxStarvationDelay,v=i.abrBandWidthFactor,y=i.abrBandWidthUpFactor;if(0===f){var m=this.bitrateTestDelay;if(m){p=(s?Math.min(s,i.maxLoadingDelay):i.maxLoadingDelay)-m,g.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms"),v=y=1}}return c=this._findBestLevel(o,s,d,a,e,f+p,v,y,r),Math.max(c,0)}}]),e}(f.default);e.default=m},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),l=r(6),u=i(l),d=r(4),f=i(d),c=r(11),h=i(c),p=r(1),g=i(p),v=r(3),y=i(v),m=r(13),E=i(m),T=r(14),b=i(T),R=r(2),_=r(0),S=r(52),A={STOPPED:"STOPPED",STARTING:"STARTING",IDLE:"IDLE",PAUSED:"PAUSED",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS"},L=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,g.default.MEDIA_ATTACHED,g.default.MEDIA_DETACHING,g.default.AUDIO_TRACKS_UPDATED,g.default.AUDIO_TRACK_SWITCHING,g.default.AUDIO_TRACK_LOADED,g.default.KEY_LOADED,g.default.FRAG_LOADED,g.default.FRAG_PARSING_INIT_SEGMENT,g.default.FRAG_PARSING_DATA,g.default.FRAG_PARSED,g.default.ERROR,g.default.BUFFER_CREATED,g.default.BUFFER_APPENDED,g.default.BUFFER_FLUSHED,g.default.INIT_PTS_FOUND));return i.config=r.config,i.audioCodecSwap=!1,i.ticks=0,i._state=A.STOPPED,i.ontick=i.tick.bind(i),i.initPTS=[],i.waitingFragment=null,i.videoTrackCC=null,i}return o(e,t),e.prototype.destroy=function(){this.stopLoad(),this.timer&&(clearInterval(this.timer),this.timer=null),y.default.prototype.destroy.call(this),this.state=A.STOPPED},e.prototype.onInitPtsFound=function(t){var e=t.id,r=t.frag.cc,i=t.initPTS;"main"===e&&(this.initPTS[r]=i,this.videoTrackCC=r,_.logger.log("InitPTS for cc:"+r+" found from video track:"+i),this.state===A.WAITING_INIT_PTS&&this.tick())},e.prototype.startLoad=function(t){if(this.tracks){var e=this.lastCurrentTime;this.stopLoad(),this.timer||(this.timer=setInterval(this.ontick,100)),this.fragLoadError=0,e>0&&-1===t?(_.logger.log("audio:override startPosition with lastCurrentTime @"+e.toFixed(3)),this.state=A.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:t,this.state=A.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=t,this.state=A.STOPPED},e.prototype.stopLoad=function(){var t=this.fragCurrent;t&&(t.loader&&t.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=A.STOPPED},e.prototype.tick=function(){1===++this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){var t,e,r,i=this.hls,a=i.config;switch(this.state){case A.ERROR:case A.PAUSED:case A.BUFFER_FLUSHING:break;case A.STARTING:this.state=A.WAITING_TRACK,this.loadedmetadata=!1;break;case A.IDLE:var n=this.tracks;if(!n)break;if(!this.media&&(this.startFragRequested||!a.startFragPrefetch))break;if(this.loadedmetadata)t=this.media.currentTime;else if(void 0===(t=this.nextLoadPosition))break;var o=this.mediaBuffer?this.mediaBuffer:this.media,s=f.default.bufferInfo(o,t,a.maxBufferHole),l=s.len,d=s.end,c=this.fragPrevious,h=a.maxMaxBufferLength,p=this.audioSwitch,v=this.trackId;if((l<h||p)&&v<n.length){if(void 0===(r=n[v].details)){this.state=A.WAITING_TRACK;break}if(!p&&!r.live&&c&&c.sn===r.endSN&&(!this.media.seeking||this.media.duration-d<c.duration/2)){this.hls.trigger(g.default.BUFFER_EOS,{type:"audio"}),this.state=A.ENDED;break}var y=r.fragments,m=y.length,E=y[0].start,T=y[m-1].start+y[m-1].duration,b=void 0;if(p)if(r.live&&!r.PTSKnown)_.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),d=0;else if(d=t,r.PTSKnown&&t<E){if(!(s.end>E||s.nextStart))return;_.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=E+.05}if(r.initSegment&&!r.initSegment.data)b=r.initSegment;else if(d<=E){if(b=y[0],null!==this.videoTrackCC&&b.cc!==this.videoTrackCC&&(b=(0,S.findFragWithCC)(y,this.videoTrackCC)),r.live&&b.loadIdx&&b.loadIdx===this.fragLoadIdx){var L=s.nextStart?s.nextStart:E;return _.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(L+.05)),void(this.media.currentTime=L+.05)}}else{var w=void 0,D=a.maxFragLookUpTolerance,O=c?y[c.sn-y[0].sn+1]:void 0,I=function(t){var e=Math.min(D,t.duration);return t.start+t.duration-e<=d?1:t.start-e>d&&t.start?-1:0};d<T?(d>T-D&&(D=0),w=O&&!I(O)?O:u.default.search(y,I)):w=y[m-1],w&&(b=w,E=w.start,c&&b.level===c.level&&b.sn===c.sn&&(b.sn<r.endSN?(b=y[b.sn+1-r.startSN],_.logger.log("SN just loaded, load next one: "+b.sn)):b=null))}if(b)if(b.decryptdata&&null!=b.decryptdata.uri&&null==b.decryptdata.key)_.logger.log("Loading key for "+b.sn+" of ["+r.startSN+" ,"+r.endSN+"],track "+v),this.state=A.KEY_LOADING,i.trigger(g.default.KEY_LOADING,{frag:b});else{if(_.logger.log("Loading "+b.sn+", cc: "+b.cc+" of ["+r.startSN+" ,"+r.endSN+"],track "+v+", currentTime:"+t+",bufferEnd:"+d.toFixed(3)),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,b.loadCounter){b.loadCounter++;var k=a.fragLoadingLoopThreshold;if(b.loadCounter>k&&Math.abs(this.fragLoadIdx-b.loadIdx)<k)return void i.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.FRAG_LOOP_LOADING_ERROR,fatal:!1,frag:b})}else b.loadCounter=1;b.loadIdx=this.fragLoadIdx,this.fragCurrent=b,this.startFragRequested=!0,isNaN(b.sn)||(this.nextLoadPosition=b.start+b.duration),i.trigger(g.default.FRAG_LOADING,{frag:b}),this.state=A.FRAG_LOADING}}break;case A.WAITING_TRACK:e=this.tracks[this.trackId],e&&e.details&&(this.state=A.IDLE);break;case A.FRAG_LOADING_WAITING_RETRY:var P=performance.now(),C=this.retryDate;o=this.media;var x=o&&o.seeking;(!C||P>=C||x)&&(_.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=A.IDLE);break;case A.WAITING_INIT_PTS:if(void 0===this.initPTS[this.videoTrackCC])break;var F=this.waitingFragment;if(F){var M=F.frag.cc;this.videoTrackCC!==M?(_.logger.warn("Waiting fragment CC ("+M+") does not match video track CC ("+this.videoTrackCC+")"),this.waitingFragment=null,this.state=A.IDLE):(this.state=A.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=A.IDLE;break;case A.STOPPED:case A.FRAG_LOADING:case A.PARSING:case A.PARSED:case A.ENDED:}},e.prototype.onMediaAttached=function(t){var e=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)},e.prototype.onMediaDetaching=function(){var t=this.media;t&&t.ended&&(_.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var e=this.tracks;e&&e.forEach(function(t){t.details&&t.details.fragments.forEach(function(t){t.loadCounter=void 0})}),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},e.prototype.onMediaSeeking=function(){this.state===A.ENDED&&(this.state=A.IDLE),this.media&&(this.lastCurrentTime=this.media.currentTime),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()},e.prototype.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.prototype.onAudioTracksUpdated=function(t){_.logger.log("audio tracks updated"),this.tracks=t.audioTracks},e.prototype.onAudioTrackSwitching=function(t){var e=!!t.url;this.trackId=t.id,this.fragCurrent=null,this.state=A.PAUSED,this.waitingFragment=null,e?this.timer||(this.timer=setInterval(this.ontick,100)):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),e&&(this.audioSwitch=!0,this.state=A.IDLE,void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold)),this.tick()},e.prototype.onAudioTrackLoaded=function(t){var e=t.details,r=t.id,i=this.tracks[r],a=e.totalduration,n=0;if(_.logger.log("track "+r+" loaded ["+e.startSN+","+e.endSN+"],duration:"+a),e.live){var o=i.details;o&&e.fragments.length>0?(E.default.mergeDetails(o,e),n=e.fragments[0].start,e.PTSKnown?_.logger.log("live audio playlist sliding:"+n.toFixed(3)):_.logger.log("live audio playlist - outdated PTS, unknown sliding")):(e.PTSKnown=!1,_.logger.log("live audio playlist - first load, unknown sliding"))}else e.PTSKnown=!1;if(i.details=e,!this.startFragRequested){if(-1===this.startPosition){var s=e.startTimeOffset;isNaN(s)?this.startPosition=0:(_.logger.log("start time offset found in playlist, adjust startPosition to "+s),this.startPosition=s)}this.nextLoadPosition=this.startPosition}this.state===A.WAITING_TRACK&&(this.state=A.IDLE),this.tick()},e.prototype.onKeyLoaded=function(){this.state===A.KEY_LOADING&&(this.state=A.IDLE,this.tick())},e.prototype.onFragLoaded=function(t){var e=this.fragCurrent,r=t.frag;if(this.state===A.FRAG_LOADING&&e&&"audio"===r.type&&r.level===e.level&&r.sn===e.sn){var i=this.tracks[this.trackId],a=i.details,n=a.totalduration,o=e.level,s=e.sn,l=e.cc,u=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",d=this.stats=t.stats;if("initSegment"===s)this.state=A.IDLE,d.tparsed=d.tbuffered=performance.now(),a.initSegment.data=t.payload,this.hls.trigger(g.default.FRAG_BUFFERED,{stats:d,frag:e,id:"audio"}),this.tick();else{this.state=A.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new h.default(this.hls,"audio"));var f=this.initPTS[l],c=a.initSegment?a.initSegment.data:[];if(a.initSegment||void 0!==f){this.pendingBuffering=!0,_.logger.log("Demuxing "+s+" of ["+a.startSN+" ,"+a.endSN+"],track "+o);this.demuxer.push(t.payload,c,u,null,e,n,!1,f)}else _.logger.log("unknown video PTS for continuity counter "+l+", waiting for video PTS before demuxing audio frag "+s+" of ["+a.startSN+" ,"+a.endSN+"],track "+o),this.waitingFragment=t,this.state=A.WAITING_INIT_PTS}}this.fragLoadError=0},e.prototype.onFragParsingInitSegment=function(t){var e=this.fragCurrent,r=t.frag;if(e&&"audio"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===A.PARSING){var i=t.tracks,a=void 0;if(i.video&&delete i.video,a=i.audio){a.levelCodec=a.codec,a.id=t.id,this.hls.trigger(g.default.BUFFER_CODECS,i),_.logger.log("audio track:audio,container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var n=a.initSegment;if(n){var o={type:"audio",data:n,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[o]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(g.default.BUFFER_APPENDING,o))}this.tick()}}},e.prototype.onFragParsingData=function(t){var e=this,r=this.fragCurrent,i=t.frag;if(r&&"audio"===t.id&&"audio"===t.type&&i.sn===r.sn&&i.level===r.level&&this.state===A.PARSING){var a=this.trackId,n=this.tracks[a],o=this.hls;isNaN(t.endPTS)&&(t.endPTS=t.startPTS+r.duration,t.endDTS=t.startDTS+r.duration),_.logger.log("parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb),E.default.updateFragPTSDTS(n.details,r,t.startPTS,t.endPTS);var s=this.audioSwitch,l=this.media,u=!1;if(s&&l)if(l.readyState){var d=l.currentTime;_.logger.log("switching audio track : currentTime:"+d),d>=t.startPTS&&(_.logger.log("switching audio track : flushing all audio"),this.state=A.BUFFER_FLUSHING,o.trigger(g.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),u=!0,this.audioSwitch=!1,o.trigger(g.default.AUDIO_TRACK_SWITCHED,{id:a}))}else this.audioSwitch=!1,o.trigger(g.default.AUDIO_TRACK_SWITCHED,{id:a});var f=this.pendingData;this.audioSwitch||([t.data1,t.data2].forEach(function(e){e&&e.length&&f.push({type:t.type,data:e,parent:"audio",content:"data"})}),!u&&f.length&&(f.forEach(function(t){e.state===A.PARSING&&(e.pendingBuffering=!0,e.hls.trigger(g.default.BUFFER_APPENDING,t))}),this.pendingData=[],this.appended=!0)),this.tick()}},e.prototype.onFragParsed=function(t){var e=this.fragCurrent,r=t.frag;e&&"audio"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===A.PARSING&&(this.stats.tparsed=performance.now(),this.state=A.PARSED,this._checkAppendedParsed())},e.prototype.onBufferCreated=function(t){var e=t.tracks.audio;e&&(this.mediaBuffer=e.buffer,this.loadedmetadata=!0)},e.prototype.onBufferAppended=function(t){if("audio"===t.parent){var e=this.state;e!==A.PARSING&&e!==A.PARSED||(this.pendingBuffering=t.pending>0,this._checkAppendedParsed())}},e.prototype._checkAppendedParsed=function(){if(!(this.state!==A.PARSED||this.appended&&this.pendingBuffering)){var t=this.fragCurrent,e=this.stats,r=this.hls;if(t){this.fragPrevious=t,e.tbuffered=performance.now(),r.trigger(g.default.FRAG_BUFFERED,{stats:e,frag:t,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;_.logger.log("audio buffered : "+b.default.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(g.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=A.IDLE}this.tick()}},e.prototype.onError=function(t){var e=t.frag;if(!e||"audio"===e.type)switch(t.details){case R.ErrorDetails.FRAG_LOAD_ERROR:case R.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!t.fatal){var r=this.fragLoadError;r?r++:r=1;var i=this.config;if(r<=i.fragLoadingMaxRetry){this.fragLoadError=r,e.loadCounter=0;var a=Math.min(Math.pow(2,r-1)*i.fragLoadingRetryDelay,i.fragLoadingMaxRetryTimeout);_.logger.warn("audioStreamController: frag loading failed, retry in "+a+" ms"),this.retryDate=performance.now()+a,this.state=A.FRAG_LOADING_WAITING_RETRY}else _.logger.error("audioStreamController: "+t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.state=A.ERROR}break;case R.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case R.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case R.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case R.ErrorDetails.KEY_LOAD_ERROR:case R.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==A.ERROR&&(this.state=t.fatal?A.ERROR:A.IDLE,_.logger.warn("audioStreamController: "+t.details+" while loading frag,switch to "+this.state+" state ..."));break;case R.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===t.parent&&(this.state===A.PARSING||this.state===A.PARSED)){var n=this.mediaBuffer,o=this.media.currentTime;if(n&&f.default.isBuffered(n,o)&&f.default.isBuffered(n,o+.5)){var s=this.config;s.maxMaxBufferLength>=s.maxBufferLength&&(s.maxMaxBufferLength/=2,_.logger.warn("audio:reduce max buffer length to "+s.maxMaxBufferLength+"s"),this.fragLoadIdx+=2*s.fragLoadingLoopThreshold),this.state=A.IDLE}else _.logger.warn("buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=A.BUFFER_FLUSHING,this.hls.trigger(g.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}},e.prototype.onBufferFlushed=function(){var t=this,e=this.pendingData;e&&e.length?(_.logger.log("appending pending audio data on Buffer Flushed"),e.forEach(function(e){t.hls.trigger(g.default.BUFFER_APPENDING,e)}),this.appended=!0,this.pendingData=[],this.state=A.PARSED):(this.state=A.IDLE,this.fragPrevious=null,this.tick())},s(e,[{key:"state",set:function(t){if(this.state!==t){var e=this.state;this._state=t,_.logger.log("audio stream:"+e+"->"+t)}},get:function(){return this._state}}]),e}(y.default);e.default=L},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),l=r(1),u=i(l),d=r(3),f=i(d),c=r(0),h=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,u.default.MANIFEST_LOADING,u.default.MANIFEST_LOADED,u.default.AUDIO_TRACK_LOADED));return i.ticks=0,i.ontick=i.tick.bind(i),i}return o(e,t),e.prototype.destroy=function(){f.default.prototype.destroy.call(this)},e.prototype.tick=function(){1===++this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){this.updateTrack(this.trackId)},e.prototype.onManifestLoading=function(){this.tracks=[],this.trackId=-1},e.prototype.onManifestLoaded=function(t){var e=this,r=t.audioTracks||[],i=!1;this.tracks=r,this.hls.trigger(u.default.AUDIO_TRACKS_UPDATED,{audioTracks:r});var a=0;r.forEach(function(t){if(t.default)return e.audioTrack=a,void(i=!0);a++}),!1===i&&r.length&&(c.logger.log("no default audio track defined, use first audio track as default"),this.audioTrack=0)},e.prototype.onAudioTrackLoaded=function(t){t.id<this.tracks.length&&(c.logger.log("audioTrack "+t.id+" loaded"),this.tracks[t.id].details=t.details,t.details.live&&!this.timer&&(this.timer=setInterval(this.ontick,1e3*t.details.targetduration)),!t.details.live&&this.timer&&(clearInterval(this.timer),this.timer=null))},e.prototype.setAudioTrackInternal=function(t){if(t>=0&&t<this.tracks.length){this.timer&&(clearInterval(this.timer),this.timer=null),this.trackId=t,c.logger.log("switching to audioTrack "+t);var e=this.tracks[t],r=this.hls,i=e.type,a=e.url,n={id:t,type:i,url:a};r.trigger(u.default.AUDIO_TRACK_SWITCH,n),r.trigger(u.default.AUDIO_TRACK_SWITCHING,n);var o=e.details;!a||void 0!==o&&!0!==o.live||(c.logger.log("(re)loading playlist for audioTrack "+t),r.trigger(u.default.AUDIO_TRACK_LOADING,{url:a,id:t}))}},e.prototype.updateTrack=function(t){if(t>=0&&t<this.tracks.length){this.timer&&(clearInterval(this.timer),this.timer=null),this.trackId=t,c.logger.log("updating audioTrack "+t);var e=this.tracks[t],r=e.url,i=e.details;!r||void 0!==i&&!0!==i.live||(c.logger.log("(re)loading playlist for audioTrack "+t),this.hls.trigger(u.default.AUDIO_TRACK_LOADING,{url:r,id:t}))}},s(e,[{key:"audioTracks",get:function(){return this.tracks}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.trackId===t&&void 0!==this.tracks[t].details||this.setAudioTrackInternal(t)}}]),e}(f.default);e.default=h},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=r(1),l=i(s),u=r(3),d=i(u),f=r(0),c=r(2),h=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,l.default.MEDIA_ATTACHING,l.default.MEDIA_DETACHING,l.default.MANIFEST_PARSED,l.default.BUFFER_RESET,l.default.BUFFER_APPENDING,l.default.BUFFER_CODECS,l.default.BUFFER_EOS,l.default.BUFFER_FLUSHING,l.default.LEVEL_PTS_UPDATED,l.default.LEVEL_UPDATED));return i._msDuration=null,i._levelDuration=null,i.onsbue=i.onSBUpdateEnd.bind(i),i.onsbe=i.onSBUpdateError.bind(i),i.pendingTracks={},i.tracks={},i}return o(e,t),e.prototype.destroy=function(){d.default.prototype.destroy.call(this)},e.prototype.onLevelPtsUpdated=function(t){var e=t.type,r=this.tracks.audio;if("audio"===e&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio;if(Math.abs(i.timestampOffset-t.start)>.1){var a=i.updating;try{i.abort()}catch(t){a=!0,f.logger.warn("can not abort audio buffer: "+t)}a?this.audioTimestampOffset=t.start:(f.logger.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+t.start),i.timestampOffset=t.start)}}},e.prototype.onManifestParsed=function(t){var e=t.audio,r=t.video||t.levels.length&&t.audio,i=0;t.altAudio&&(e||r)&&(i=(e?1:0)+(r?1:0),f.logger.log(i+" sourceBuffer(s) expected")),this.sourceBufferNb=i},e.prototype.onMediaAttaching=function(t){var e=this.media=t.media;if(e){var r=this.mediaSource=new MediaSource;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),r.addEventListener("sourceopen",this.onmso),r.addEventListener("sourceended",this.onmse),r.addEventListener("sourceclose",this.onmsc),e.src=URL.createObjectURL(r)}},e.prototype.onMediaDetaching=function(){f.logger.log("media source detaching");var t=this.mediaSource;if(t){if("open"===t.readyState)try{t.endOfStream()}catch(t){f.logger.warn("onMediaDetaching:"+t.message+" while calling endOfStream")}t.removeEventListener("sourceopen",this.onmso),t.removeEventListener("sourceended",this.onmse),t.removeEventListener("sourceclose",this.onmsc),this.media&&(URL.revokeObjectURL(this.media.src),this.media.removeAttribute("src"),this.media.load()),this.mediaSource=null,this.media=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(l.default.MEDIA_DETACHED)},e.prototype.onMediaSourceOpen=function(){f.logger.log("media source opened"),this.hls.trigger(l.default.MEDIA_ATTACHED,{media:this.media});var t=this.mediaSource;t&&t.removeEventListener("sourceopen",this.onmso),this.checkPendingTracks()},e.prototype.checkPendingTracks=function(){var t=this.pendingTracks,e=Object.keys(t).length;e&&(this.sourceBufferNb<=e||0===this.sourceBufferNb)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},e.prototype.onMediaSourceClose=function(){f.logger.log("media source closed")},e.prototype.onMediaSourceEnded=function(){f.logger.log("media source ended")},e.prototype.onSBUpdateEnd=function(){if(this.audioTimestampOffset){var t=this.sourceBuffer.audio;f.logger.warn("change mpeg audio timestamp offset from "+t.timestampOffset+" to "+this.audioTimestampOffset),t.timestampOffset=this.audioTimestampOffset,delete this.audioTimestampOffset}this._needsFlush&&this.doFlush(),this._needsEos&&this.checkEos(),this.appending=!1;var e=this.parent,r=this.segments.reduce(function(t,r){return r.parent===e?t+1:t},0);this.hls.trigger(l.default.BUFFER_APPENDED,{parent:e,pending:r}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration()},e.prototype.onSBUpdateError=function(t){f.logger.error("sourceBuffer error:",t),this.hls.trigger(l.default.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},e.prototype.onBufferReset=function(){var t=this.sourceBuffer;for(var e in t){var r=t[e];try{this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this.onsbue),r.removeEventListener("error",this.onsbe)}catch(t){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},e.prototype.onBufferCodecs=function(t){if(0===Object.keys(this.sourceBuffer).length){for(var e in t)this.pendingTracks[e]=t[e];var r=this.mediaSource;r&&"open"===r.readyState&&this.checkPendingTracks()}},e.prototype.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;for(var i in t)if(!e[i]){var a=t[i],n=a.levelCodec||a.codec,o=a.container+";codecs="+n;f.logger.log("creating sourceBuffer("+o+")");try{var s=e[i]=r.addSourceBuffer(o);s.addEventListener("updateend",this.onsbue),s.addEventListener("error",this.onsbe),this.tracks[i]={codec:n,container:a.container},a.buffer=s}catch(t){f.logger.error("error while trying to add sourceBuffer:"+t.message),this.hls.trigger(l.default.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:t,mimeType:o})}}this.hls.trigger(l.default.BUFFER_CREATED,{tracks:t})},e.prototype.onBufferAppending=function(t){this._needsFlush||(this.segments?this.segments.push(t):this.segments=[t],this.doAppending())},e.prototype.onBufferAppendFail=function(t){f.logger.error("sourceBuffer error:",t.event),this.hls.trigger(l.default.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},e.prototype.onBufferEos=function(t){var e=this.sourceBuffer,r=t.type;for(var i in e)r&&i!==r||e[i].ended||(e[i].ended=!0,f.logger.log(i+" sourceBuffer now EOS"));this.checkEos()},e.prototype.checkEos=function(){var t=this.sourceBuffer,e=this.mediaSource;if(!e||"open"!==e.readyState)return void(this._needsEos=!1);for(var r in t){var i=t[r];if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}f.logger.log("all media data available, signal endOfStream() to MediaSource and stop loading fragment");try{e.endOfStream()}catch(t){f.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1},e.prototype.onBufferFlushing=function(t){this.flushRange.push({start:t.startOffset,end:t.endOffset,type:t.type}),this.flushBufferCounter=0,this.doFlush()},e.prototype.onLevelUpdated=function(t){var e=t.details;0!==e.fragments.length&&(this._levelDuration=e.totalduration+e.fragments[0].start,this.updateMediaElementDuration())},e.prototype.updateMediaElementDuration=function(){var t=this.media,e=this.mediaSource,r=this.sourceBuffer,i=this._levelDuration;if(null!==i&&t&&e&&r&&0!==t.readyState&&"open"===e.readyState){for(var a in r)if(r[a].updating)return;null===this._msDuration&&(this._msDuration=e.duration);var n=t.duration;(i>this._msDuration&&i>n||n===1/0||isNaN(n))&&(f.logger.log("Updating mediasource duration to "+i.toFixed(3)),this._msDuration=e.duration=i)}},e.prototype.doFlush=function(){for(;this.flushRange.length;){var t=this.flushRange[0];if(!this.flushBuffer(t.start,t.end,t.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var e=0,r=this.sourceBuffer;try{for(var i in r)e+=r[i].buffered.length}catch(t){f.logger.error("error while accessing sourceBuffer.buffered")}this.appended=e,this.hls.trigger(l.default.BUFFER_FLUSHED)}},e.prototype.doAppending=function(){var t=this.hls,e=this.sourceBuffer,r=this.segments;if(Object.keys(e).length){if(this.media.error)return this.segments=[],void f.logger.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(r&&r.length){var i=r.shift();try{var a=i.type,n=e[a];n?n.updating?r.unshift(i):(n.ended=!1,this.parent=i.parent,n.appendBuffer(i.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(e){f.logger.error("error while trying to append buffer:"+e.message),r.unshift(i);var o={type:c.ErrorTypes.MEDIA_ERROR,parent:i.parent};if(22===e.code)return this.segments=[],o.details=c.ErrorDetails.BUFFER_FULL_ERROR,o.fatal=!1,void t.trigger(l.default.ERROR,o);if(this.appendError?this.appendError++:this.appendError=1,o.details=c.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>t.config.appendErrorMaxRetry)return f.logger.log("fail "+t.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),r=[],o.fatal=!0,void t.trigger(l.default.ERROR,o);o.fatal=!1,t.trigger(l.default.ERROR,o)}}}},e.prototype.flushBuffer=function(t,e,r){var i,a,n,o,s,l,u=this.sourceBuffer;if(Object.keys(u).length){if(f.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+t+"/"+e),this.flushBufferCounter<this.appended){for(var d in u)if(!r||d===r){if(i=u[d],i.ended=!1,i.updating)return f.logger.warn("cannot flush, sb updating in progress"),!1;try{for(a=0;a<i.buffered.length;a++)if(n=i.buffered.start(a),o=i.buffered.end(a),-1!==navigator.userAgent.toLowerCase().indexOf("firefox")&&e===Number.POSITIVE_INFINITY?(s=t,l=e):(s=Math.max(n,t),l=Math.min(o,e)),Math.min(l,o)-s>.5)return this.flushBufferCounter++,f.logger.log("flush "+d+" ["+s+","+l+"], of ["+n+","+o+"], pos:"+this.media.currentTime),i.remove(s,l),!1}catch(t){f.logger.warn("exception while accessing sourcebuffer, it might have been removed from MediaSource")}}}else f.logger.warn("abort flushing too many retries");f.logger.log("buffer flushed")}return!0},e}(d.default);e.default=h},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),l=r(1),u=i(l),d=r(3),f=i(d),c=function(t){function e(r){return a(this,e),n(this,t.call(this,r,u.default.FPS_DROP_LEVEL_CAPPING,u.default.MEDIA_ATTACHING,u.default.MANIFEST_PARSED))}return o(e,t),e.prototype.destroy=function(){this.hls.config.capLevelToPlayerSize&&(this.media=this.restrictedLevels=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer)))},e.prototype.onFpsDropLevelCapping=function(t){e.isLevelAllowed(t.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(t.droppedLevel)},e.prototype.onMediaAttaching=function(t){this.media=t.media instanceof HTMLVideoElement?t.media:null},e.prototype.onManifestParsed=function(t){var e=this.hls;this.restrictedLevels=[],e.config.capLevelToPlayerSize&&(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.levels=t.levels,e.firstLevel=this.getMaxLevel(t.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},e.prototype.detectPlayerSize=function(){if(this.media){var t=this.levels?this.levels.length:0;if(t){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t-1),e.autoLevelCapping>this.autoLevelCapping&&e.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},e.prototype.getMaxLevel=function(t){var r=this;if(!this.levels)return-1;var i=this.levels.filter(function(i,a){return e.isLevelAllowed(a,r.restrictedLevels)&&a<=t});return e.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},e.isLevelAllowed=function(t){return-1===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).indexOf(t)},e.getMaxLevelByMediaSize=function(t,e,r){if(!t||t&&!t.length)return-1;for(var i=t.length-1,a=0;a<t.length;a+=1){var n=t[a];if((n.width>=e||n.height>=r)&&function(t,e){return!e||(t.width!==e.width||t.height!==e.height)}(n,t[a+1])){i=a;break}}return i},s(e,[{key:"mediaWidth",get:function(){var t=void 0,r=this.media;return r&&(t=r.width||r.clientWidth||r.offsetWidth,t*=e.contentScaleFactor),t}},{key:"mediaHeight",get:function(){var t=void 0,r=this.media;return r&&(t=r.height||r.clientHeight||r.offsetHeight,t*=e.contentScaleFactor),t}}],[{key:"contentScaleFactor",get:function(){var t=1;try{t=window.devicePixelRatio}catch(t){}return t}}]),e}(f.default);e.default=c},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=r(1),l=i(s),u=r(3),d=i(u),f=r(0),c=function(t){function e(r){return a(this,e),n(this,t.call(this,r,l.default.MEDIA_ATTACHING))}return o(e,t),e.prototype.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},e.prototype.onMediaAttaching=function(t){var e=this.hls.config;if(e.capLevelOnFPSDrop){"function"==typeof(this.video=t.media instanceof HTMLVideoElement?t.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),e.fpsDroppedMonitoringPeriod)}},e.prototype.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var a=i-this.lastTime,n=r-this.lastDroppedFrames,o=e-this.lastDecodedFrames,s=1e3*n/a,u=this.hls;if(u.trigger(l.default.FPS_DROP,{currentDropped:n,currentDecoded:o,totalDroppedFrames:r}),s>0&&n>u.config.fpsDroppedMonitoringThreshold*o){var d=u.currentLevel;f.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=d)&&(d-=1,u.trigger(l.default.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:u.currentLevel}),u.autoLevelCapping=d,u.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.prototype.checkFPSInterval=function(){var t=this.video;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},e}(d.default);e.default=c},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=r(1),l=i(s),u=r(3),d=i(u),f=r(5),c=i(f),h=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,l.default.MEDIA_ATTACHED,l.default.MEDIA_DETACHING,l.default.FRAG_PARSING_METADATA));return i.id3Track=void 0,i.media=void 0,i}return o(e,t),e.prototype.destroy=function(){d.default.prototype.destroy.call(this)},e.prototype.onMediaAttached=function(t){this.media=t.media,this.media&&(this.id3Track=this.media.addTextTrack("metadata","id3"),this.id3Track.mode="hidden")},e.prototype.onMediaDetaching=function(){this.media=void 0},e.prototype.onFragParsingMetadata=function(t){for(var e=t.frag,r=t.samples,i=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,a=0;a<r.length;a++){var n=c.default.getID3Frames(r[a].data);if(n){var o=r[a].pts,s=a<r.length-1?r[a+1].pts:e.endPTS;o===s&&(s+=1e-4);for(var l=0;l<n.length;l++){var u=n[l];if(!c.default.isTimeStampFrame(u)){var d=new i(o,s,"");d.value=u,this.id3Track.addCue(d)}}}}},e}(d.default);e.default=h},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),l=r(1),u=i(l),d=r(3),f=i(d),c=r(0),h=r(2),p=r(4),g=i(p),v=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,u.default.MANIFEST_LOADED,u.default.LEVEL_LOADED,u.default.FRAG_LOADED,u.default.ERROR));return i.ontick=i.tick.bind(i),i._manualLevel=-1,i}return o(e,t),e.prototype.destroy=function(){this.timer&&(clearTimeout(this.timer),this.timer=null),this._manualLevel=-1},e.prototype.startLoad=function(){this.canload=!0;var t=this._levels;t&&t.forEach(function(t){t.loadError=0;var e=t.details;e&&e.live&&(t.details=void 0)}),this.timer&&this.tick()},e.prototype.stopLoad=function(){this.canload=!1},e.prototype.onManifestLoaded=function(t){var e,r=[],i=[],a={},n=!1,o=!1,s=this.hls,l=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(t,e){return MediaSource.isTypeSupported(t+"/mp4;codecs="+e)};if(t.levels.forEach(function(t){t.videoCodec&&(n=!0),l&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0),(t.audioCodec||t.attrs&&t.attrs.AUDIO)&&(o=!0);var e=a[t.bitrate];void 0===e?(a[t.bitrate]=r.length,t.url=[t.url],t.urlId=0,r.push(t)):r[e].url.push(t.url)}),n&&o?r.forEach(function(t){t.videoCodec&&i.push(t)}):i=r,i=i.filter(function(t){var e=t.audioCodec,r=t.videoCodec;return(!e||d("audio",e))&&(!r||d("video",r))}),i.length){e=i[0].bitrate,i.sort(function(t,e){return t.bitrate-e.bitrate}),this._levels=i;for(var f=0;f<i.length;f++)if(i[f].bitrate===e){this._firstLevel=f,c.logger.log("manifest loaded,"+i.length+" level(s) found, first bitrate:"+e);break}s.trigger(u.default.MANIFEST_PARSED,{levels:i,firstLevel:this._firstLevel,stats:t.stats,audio:o,video:n,altAudio:t.audioTracks.length>0})}else s.trigger(u.default.ERROR,{type:h.ErrorTypes.MEDIA_ERROR,details:h.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:s.url,reason:"no level with compatible codecs found in manifest"})},e.prototype.setLevelInternal=function(t){var e=this._levels,r=this.hls;if(t>=0&&t<e.length){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this._level!==t){c.logger.log("switching to level "+t),this._level=t;var i=e[t];i.level=t,r.trigger(u.default.LEVEL_SWITCH,i),r.trigger(u.default.LEVEL_SWITCHING,i)}var a=e[t],n=a.details;if(!n||!0===n.live){var o=a.urlId;r.trigger(u.default.LEVEL_LOADING,{url:a.url[o],level:t,id:o})}}else r.trigger(u.default.ERROR,{type:h.ErrorTypes.OTHER_ERROR,details:h.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:!1,reason:"invalid level idx"})},e.prototype.onError=function(t){if(!t.fatal){var e=t.details,r=this.hls,i=void 0,a=void 0,n=!1;switch(e){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:i=t.frag.level;break;case h.ErrorDetails.LEVEL_LOAD_ERROR:case h.ErrorDetails.LEVEL_LOAD_TIMEOUT:i=t.context.level,n=!0;break;case h.ErrorDetails.REMUX_ALLOC_ERROR:i=t.level}if(void 0!==i){a=this._levels[i],a.loadError?a.loadError++:a.loadError=1;var o=a.url.length;if(o>1&&a.loadError<o)a.urlId=(a.urlId+1)%o,a.details=void 0,c.logger.warn("level controller,"+e+" for level "+i+": switching to redundant stream id "+a.urlId);else{if(-1===this._manualLevel&&i)c.logger.warn("level controller,"+e+": switch-down for next fragment"),r.nextAutoLevel=Math.max(0,i-1);else if(a&&a.details&&a.details.live)c.logger.warn("level controller,"+e+" on live stream, discard"),n&&(this._level=void 0);else if(e===h.ErrorDetails.LEVEL_LOAD_ERROR||e===h.ErrorDetails.LEVEL_LOAD_TIMEOUT){var s=r.media,l=s&&g.default.isBuffered(s,s.currentTime)&&g.default.isBuffered(s,s.currentTime+.5);if(l){var u=r.config.levelLoadingRetryDelay;c.logger.warn("level controller,"+e+", but media buffered, retry in "+u+"ms"),this.timer=setTimeout(this.ontick,u),t.levelRetry=!0}else c.logger.error("cannot recover "+e+" error"),this._level=void 0,this.timer&&(clearTimeout(this.timer),this.timer=null),t.fatal=!0}}}}},e.prototype.onFragLoaded=function(t){var e=t.frag;if(e&&"main"===e.type){var r=this._levels[e.level];r&&(r.loadError=0)}},e.prototype.onLevelLoaded=function(t){var e=t.level;if(e===this._level){var r=this._levels[e];r.loadError=0;var i=t.details;if(i.live){var a=1e3*(i.averagetargetduration?i.averagetargetduration:i.targetduration),n=r.details;n&&i.endSN===n.endSN&&(a/=2,c.logger.log("same live playlist, reload twice faster")),a-=performance.now()-t.stats.trequest,a=Math.max(1e3,Math.round(a)),c.logger.log("live playlist, reload in "+a+" ms"),this.timer=setTimeout(this.ontick,a)}else this.timer=null}},e.prototype.tick=function(){var t=this._level;if(void 0!==t&&this.canload){var e=this._levels[t];if(e&&e.url){var r=e.urlId;this.hls.trigger(u.default.LEVEL_LOADING,{url:e.url[r],level:t,id:r})}}},s(e,[{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this._level},set:function(t){var e=this._levels;e&&e.length>t&&(this._level===t&&void 0!==e[t].details||this.setLevelInternal(t))}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(t){this._manualLevel=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this._manualLevel?this._manualLevel:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this._manualLevel&&(this.hls.nextAutoLevel=t)}}]),e}(f.default);e.default=v},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),l=r(6),u=i(l),d=r(4),f=i(d),c=r(11),h=i(c),p=r(1),g=i(p),v=r(3),y=i(v),m=r(13),E=i(m),T=r(14),b=i(T),R=r(2),_=r(0),S={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_LEVEL:"WAITING_LEVEL",PARSING:"PARSING",PARSED:"PARSED",BUFFER_FLUSHING:"BUFFER_FLUSHING",ENDED:"ENDED",ERROR:"ERROR"},A=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,g.default.MEDIA_ATTACHED,g.default.MEDIA_DETACHING,g.default.MANIFEST_LOADING,g.default.MANIFEST_PARSED,g.default.LEVEL_LOADED,g.default.KEY_LOADED,g.default.FRAG_LOADED,g.default.FRAG_LOAD_EMERGENCY_ABORTED,g.default.FRAG_PARSING_INIT_SEGMENT,g.default.FRAG_PARSING_DATA,g.default.FRAG_PARSED,g.default.ERROR,g.default.AUDIO_TRACK_SWITCHING,g.default.AUDIO_TRACK_SWITCHED,g.default.BUFFER_CREATED,g.default.BUFFER_APPENDED,g.default.BUFFER_FLUSHED));return i.config=r.config,i.audioCodecSwap=!1,i.ticks=0,i._state=S.STOPPED,i.ontick=i.tick.bind(i),i}return o(e,t),e.prototype.destroy=function(){this.stopLoad(),this.timer&&(clearInterval(this.timer),this.timer=null),y.default.prototype.destroy.call(this),this.state=S.STOPPED},e.prototype.startLoad=function(t){if(this.levels){var e=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.timer||(this.timer=setInterval(this.ontick,100)),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(i=0,this.bitrateTest=!0),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}e>0&&-1===t&&(_.logger.log("override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=S.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this.forceStartLoad=!0,this.state=S.STOPPED},e.prototype.stopLoad=function(){var t=this.fragCurrent;t&&(t.loader&&t.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=S.STOPPED,this.forceStartLoad=!1},e.prototype.tick=function(){1===++this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)},e.prototype.doTick=function(){switch(this.state){case S.ERROR:break;case S.BUFFER_FLUSHING:this.fragLoadError=0;break;case S.IDLE:this._doTickIdle();break;case S.WAITING_LEVEL:var t=this.levels[this.level];t&&t.details&&(this.state=S.IDLE);break;case S.FRAG_LOADING_WAITING_RETRY:var e=performance.now(),r=this.retryDate;(!r||e>=r||this.media&&this.media.seeking)&&(_.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=S.IDLE);break;case S.ERROR:case S.STOPPED:case S.FRAG_LOADING:case S.PARSING:case S.PARSED:case S.ENDED:}this._checkBuffer(),this._checkFragmentChanged()},e.prototype._doTickIdle=function(){var t=this.hls,e=t.config,r=this.media;if(void 0===this.levelLastLoaded||r||!this.startFragRequested&&e.startFragPrefetch){var i=void 0;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var a=t.nextLoadLevel,n=this.levels[a];if(n){var o=n.bitrate,s=void 0;s=o?Math.max(8*e.maxBufferSize/o,e.maxBufferLength):e.maxBufferLength,s=Math.min(s,e.maxMaxBufferLength);var l=f.default.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,i,e.maxBufferHole),u=l.len;if(!(u>=s)){_.logger.trace("buffer length of "+u.toFixed(3)+" is below max of "+s.toFixed(3)+". checking for more payload ..."),this.level=t.nextLoadLevel=a;var d=n.details;if(void 0===d||d.live&&this.levelLastLoaded!==a)return void(this.state=S.WAITING_LEVEL);var c=this.fragPrevious;if(!d.live&&c&&c.sn===d.endSN&&u&&!l.nextStart){if(Math.min(r.duration,c.start+c.duration)-Math.max(l.end,c.start)<=Math.max(.2,c.duration)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(g.default.BUFFER_EOS,h),void(this.state=S.ENDED)}}this._fetchPayloadOrEos(i,l,d)}}}},e.prototype._fetchPayloadOrEos=function(t,e,r){var i=this.fragPrevious,a=this.level,n=r.fragments,o=n.length;if(0!==o){var s=n[0].start,l=n[o-1].start+n[o-1].duration,u=e.end,d=void 0;if(r.initSegment&&!r.initSegment.data)d=r.initSegment;else if(r.live){var f=this.config.initialLiveManifestSize;if(o<f)return void _.logger.warn("Can not start playback of a level, reason: not enough fragments "+o+" < "+f);if(null===(d=this._ensureFragmentAtLivePoint(r,u,s,l,i,n,o)))return}else u<s&&(d=n[0]);d||(d=this._findFragment(s,i,o,n,u,l,r)),d&&this._loadFragmentOrKey(d,a,r,t,u)}},e.prototype._ensureFragmentAtLivePoint=function(t,e,r,i,a,n,o){var s=this.hls.config,l=this.media,u=void 0,d=void 0!==s.liveMaxLatencyDuration?s.liveMaxLatencyDuration:s.liveMaxLatencyDurationCount*t.targetduration;if(e<Math.max(r-s.maxFragLookUpTolerance,i-d)){var f=this.liveSyncPosition=this.computeLivePosition(r,t);_.logger.log("buffer end: "+e.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+f.toFixed(3)),e=f,l&&l.readyState&&l.duration>f&&(l.currentTime=f),this.nextLoadPosition=f}if(t.PTSKnown&&e>i&&l&&l.readyState)return null;if(this.startFragRequested&&!t.PTSKnown){if(a){var c=a.sn+1;c>=t.startSN&&c<=t.endSN&&(u=n[c-t.startSN],_.logger.log("live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=n[Math.min(o-1,Math.round(o/2))],_.logger.log("live playlist, switching playlist, unknown, load middle frag : "+u.sn))}return u},e.prototype._findFragment=function(t,e,r,i,a,n,o){var s=this.hls.config,l=void 0,d=void 0,f=s.maxFragLookUpTolerance,c=e?i[e.sn-i[0].sn+1]:void 0,h=function(t){var e=Math.min(f,t.duration);return t.start+t.duration-e<=a?1:t.start-e>a&&t.start?-1:0};if(a<n?(a>n-f&&(f=0),d=c&&!h(c)?c:u.default.search(i,h)):d=i[r-1],d){l=d;var p=l.sn-o.startSN,g=e&&l.level===e.level,v=i[p-1],y=i[p+1];if(e&&l.sn===e.sn)if(g&&!l.backtracked)if(l.sn<o.endSN){var m=e.deltaPTS;m&&m>s.maxBufferHole&&e.dropped&&p?(l=v,_.logger.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this"),e.loadCounter--):(l=y,_.logger.log("SN just loaded, load next one: "+l.sn))}else l=null;else l.backtracked&&(y&&y.backtracked?(_.logger.warn("Already backtracked from fragment "+y.sn+", will not backtrack to fragment "+l.sn+". Loading fragment "+y.sn),l=y):(_.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),l.dropped=0,v?(v.loadCounter&&v.loadCounter--,l=v,l.backtracked=!0):p&&(l=null)))}return l},e.prototype._loadFragmentOrKey=function(t,e,r,i,a){var n=this.hls,o=n.config;if(!t.decryptdata||null==t.decryptdata.uri||null!=t.decryptdata.key){if(_.logger.log("Loading "+t.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+e+", currentTime:"+i.toFixed(3)+",bufferEnd:"+a.toFixed(3)),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,t.loadCounter){t.loadCounter++;var s=o.fragLoadingLoopThreshold;if(t.loadCounter>s&&Math.abs(this.fragLoadIdx-t.loadIdx)<s)return void n.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.FRAG_LOOP_LOADING_ERROR,fatal:!1,frag:t})}else t.loadCounter=1;return t.loadIdx=this.fragLoadIdx,this.fragCurrent=t,this.startFragRequested=!0,isNaN(t.sn)||(this.nextLoadPosition=t.start+t.duration),t.autoLevel=n.autoLevelEnabled,t.bitrateTest=this.bitrateTest,n.trigger(g.default.FRAG_LOADING,{frag:t}),this.demuxer||(this.demuxer=new h.default(n,"main")),void(this.state=S.FRAG_LOADING)}_.logger.log("Loading key for "+t.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+e),this.state=S.KEY_LOADING,n.trigger(g.default.KEY_LOADING,{frag:t})},e.prototype.getBufferedFrag=function(t){return u.default.search(this._bufferedFrags,function(e){return t<e.startPTS?-1:t>e.endPTS?1:0})},e.prototype.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.endPTS+.5):null},e.prototype._checkFragmentChanged=function(){var t,e,r=this.media;if(r&&r.readyState&&!1===r.seeking&&(e=r.currentTime,e>r.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=e),f.default.isBuffered(r,e)?t=this.getBufferedFrag(e):f.default.isBuffered(r,e+.1)&&(t=this.getBufferedFrag(e+.1)),t)){var i=t;if(i!==this.fragPlaying){this.hls.trigger(g.default.FRAG_CHANGED,{frag:i});var a=i.level;this.fragPlaying&&this.fragPlaying.level===a||this.hls.trigger(g.default.LEVEL_SWITCHED,{level:a}),this.fragPlaying=i}}},e.prototype.immediateLevelSwitch=function(){if(_.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var t=this.media,e=void 0;t?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},e.prototype.immediateLevelSwitchEnd=function(){var t=this.media;t&&t.buffered.length&&(this.immediateSwitch=!1,f.default.isBuffered(t,t.currentTime)&&(t.currentTime-=1e-4),this.previouslyPaused||t.play())},e.prototype.nextLevelSwitch=function(){var t=this.media;if(t&&t.readyState){var e=void 0,r=void 0,i=void 0;if(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,r=this.getBufferedFrag(t.currentTime),r&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),t.paused)e=0;else{var a=this.hls.nextLoadLevel,n=this.levels[a],o=this.fragLastKbps;e=o&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*o)+1:0}if((i=this.getBufferedFrag(t.currentTime+e))&&(i=this.followingBufferedFrag(i))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(i.maxStartPTS,Number.POSITIVE_INFINITY)}}},e.prototype.flushMainBuffer=function(t,e){this.state=S.BUFFER_FLUSHING;var r={startOffset:t,endOffset:e};this.altAudio&&(r.type="video"),this.hls.trigger(g.default.BUFFER_FLUSHING,r)},e.prototype.onMediaAttached=function(t){var e=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),e.addEventListener("seeking",this.onvseeking),e.addEventListener("seeked",this.onvseeked),e.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition)},e.prototype.onMediaDetaching=function(){var t=this.media;t&&t.ended&&(_.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var e=this.levels;e&&e.forEach(function(t){t.details&&t.details.fragments.forEach(function(t){t.loadCounter=void 0,t.backtracked=void 0})}),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("seeked",this.onvseeked),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},e.prototype.onMediaSeeking=function(){var t=this.media,e=t?t.currentTime:void 0,r=this.config;isNaN(e)||_.logger.log("media seeking to "+e.toFixed(3));var i=this.mediaBuffer?this.mediaBuffer:t,a=f.default.bufferInfo(i,e,this.config.maxBufferHole);if(this.state===S.FRAG_LOADING){var n=this.fragCurrent;if(0===a.len&&n){var o=r.maxFragLookUpTolerance,s=n.start-o,l=n.start+n.duration+o;e<s||e>l?(n.loader&&(_.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),n.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=S.IDLE):_.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else this.state===S.ENDED&&(0===a.len&&(this.fragPrevious=0),this.state=S.IDLE);t&&(this.lastCurrentTime=e),this.state!==S.FRAG_LOADING&&void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*r.fragLoadingLoopThreshold),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=e),this.tick()},e.prototype.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:void 0;isNaN(e)||_.logger.log("media seeked to "+e.toFixed(3)),this.tick()},e.prototype.onMediaEnded=function(){_.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0},e.prototype.onManifestLoading=function(){_.logger.log("trigger BUFFER_RESET"),this.hls.trigger(g.default.BUFFER_RESET),this._bufferedFrags=[],this.stalled=!1,this.startPosition=this.lastCurrentTime=0},e.prototype.onManifestParsed=function(t){var e,r=!1,i=!1;t.levels.forEach(function(t){(e=t.audioCodec)&&(-1!==e.indexOf("mp4a.40.2")&&(r=!0),-1!==e.indexOf("mp4a.40.5")&&(i=!0))}),this.audioCodecSwitch=r&&i,this.audioCodecSwitch&&_.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startLevelLoaded=!1,this.startFragRequested=!1;var a=this.config;(a.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(a.startPosition)},e.prototype.onLevelLoaded=function(t){var e=t.details,r=t.level,i=this.levels[r],a=e.totalduration,n=0;if(_.logger.log("level "+r+" loaded ["+e.startSN+","+e.endSN+"],duration:"+a),this.levelLastLoaded=r,e.live){var o=i.details;o&&e.fragments.length>0?(E.default.mergeDetails(o,e),n=e.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(n,o),e.PTSKnown?_.logger.log("live playlist sliding:"+n.toFixed(3)):_.logger.log("live playlist - outdated PTS, unknown sliding")):(e.PTSKnown=!1,_.logger.log("live playlist - first load, unknown sliding"))}else e.PTSKnown=!1;if(i.details=e,this.hls.trigger(g.default.LEVEL_UPDATED,{details:e,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var s=e.startTimeOffset;isNaN(s)?e.live?(this.startPosition=this.computeLivePosition(n,e),_.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0:(s<0&&(_.logger.log("negative start time offset "+s+", count from end of last fragment"),s=n+a+s),_.logger.log("start time offset found in playlist, adjust startPosition to "+s),this.startPosition=s),this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===S.WAITING_LEVEL&&(this.state=S.IDLE),this.tick()},e.prototype.onKeyLoaded=function(){this.state===S.KEY_LOADING&&(this.state=S.IDLE,this.tick())},e.prototype.onFragLoaded=function(t){var e=this.fragCurrent,r=t.frag;if(this.state===S.FRAG_LOADING&&e&&"main"===r.type&&r.level===e.level&&r.sn===e.sn){var i=t.stats,a=this.levels[e.level],n=a.details;if(_.logger.log("Loaded "+e.sn+" of ["+n.startSN+" ,"+n.endSN+"],level "+e.level),this.bitrateTest=!1,this.stats=i,!0===r.bitrateTest&&this.hls.nextLoadLevel)this.state=S.IDLE,this.startFragRequested=!1,i.tparsed=i.tbuffered=performance.now(),this.hls.trigger(g.default.FRAG_BUFFERED,{stats:i,frag:e,id:"main"}),this.tick();else if("initSegment"===r.sn)this.state=S.IDLE,i.tparsed=i.tbuffered=performance.now(),n.initSegment.data=t.payload,this.hls.trigger(g.default.FRAG_BUFFERED,{stats:i,frag:e,id:"main"}),this.tick();else{this.state=S.PARSING;var o=n.totalduration,s=e.level,l=e.sn,u=this.config.defaultAudioCodec||a.audioCodec;this.audioCodecSwap&&(_.logger.log("swapping playlist audio codec"),void 0===u&&(u=this.lastAudioCodec),u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),this.pendingBuffering=!0,this.appended=!1,_.logger.log("Parsing "+l+" of ["+n.startSN+" ,"+n.endSN+"],level "+s+", cc "+e.cc);var d=this.demuxer;d||(d=this.demuxer=new h.default(this.hls,"main"));var f=this.media,c=f&&f.seeking,p=!c&&(n.PTSKnown||!n.live),v=n.initSegment?n.initSegment.data:[];d.push(t.payload,v,u,a.videoCodec,e,o,p,void 0)}}this.fragLoadError=0},e.prototype.onFragParsingInitSegment=function(t){var e=this.fragCurrent,r=t.frag;if(e&&"main"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===S.PARSING){var i,a,n=t.tracks;if(n.audio&&this.altAudio&&delete n.audio,a=n.audio){var o=this.levels[this.level].audioCodec,s=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(_.logger.log("swapping playlist audio codec"),o=-1!==o.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&-1===s.indexOf("firefox")&&(o="mp4a.40.5"),-1!==s.indexOf("android")&&"audio/mpeg"!==a.container&&(o="mp4a.40.2",_.logger.log("Android: force audio codec to "+o)),a.levelCodec=o,a.id=t.id}a=n.video,a&&(a.levelCodec=this.levels[this.level].videoCodec,a.id=t.id),this.hls.trigger(g.default.BUFFER_CODECS,n);for(i in n){a=n[i],_.logger.log("main track:"+i+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var l=a.initSegment;l&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(g.default.BUFFER_APPENDING,{type:i,data:l,parent:"main",content:"initSegment"}))}this.tick()}},e.prototype.onFragParsingData=function(t){var e=this,r=this.fragCurrent,i=t.frag;if(r&&"main"===t.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==t.type||!this.altAudio)&&this.state===S.PARSING){var a=this.levels[this.level],n=r;if(isNaN(t.endPTS)&&(t.endPTS=t.startPTS+r.duration,t.endDTS=t.startDTS+r.duration),_.logger.log("Parsed "+t.type+",PTS:["+t.startPTS.toFixed(3)+","+t.endPTS.toFixed(3)+"],DTS:["+t.startDTS.toFixed(3)+"/"+t.endDTS.toFixed(3)+"],nb:"+t.nb+",dropped:"+(t.dropped||0)),"video"===t.type)if(n.dropped=t.dropped,n.dropped){if(!n.backtracked)return _.logger.warn("missing video frame(s), backtracking fragment"),n.backtracked=!0,this.nextLoadPosition=t.startPTS,this.state=S.IDLE,this.fragPrevious=n,void this.tick();_.logger.warn("Already backtracked on this fragment, appending with the gap")}else n.backtracked=!1;var o=E.default.updateFragPTSDTS(a.details,n,t.startPTS,t.endPTS,t.startDTS,t.endDTS),s=this.hls;s.trigger(g.default.LEVEL_PTS_UPDATED,{details:a.details,level:this.level,drift:o,type:t.type,start:t.startPTS,end:t.endPTS}),[t.data1,t.data2].forEach(function(r){r&&r.length&&e.state===S.PARSING&&(e.appended=!0,e.pendingBuffering=!0,s.trigger(g.default.BUFFER_APPENDING,{type:t.type,data:r,parent:"main",content:"data"}))}),this.tick()}},e.prototype.onFragParsed=function(t){var e=this.fragCurrent,r=t.frag;e&&"main"===t.id&&r.sn===e.sn&&r.level===e.level&&this.state===S.PARSING&&(this.stats.tparsed=performance.now(),this.state=S.PARSED,this._checkAppendedParsed())},e.prototype.onAudioTrackSwitching=function(t){var e=!!t.url,r=t.id;if(!e){if(this.mediaBuffer!==this.media){_.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i.loader&&(_.logger.log("switching to main audio track, cancel main fragment load"),i.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=S.IDLE}var a=this.hls;a.trigger(g.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),a.trigger(g.default.AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}},e.prototype.onAudioTrackSwitched=function(t){var e=t.id,r=!!this.hls.audioTracks[e].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(_.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()},e.prototype.onBufferCreated=function(t){var e=t.tracks,r=void 0,i=void 0,a=!1;for(var n in e){var o=e[n];"main"===o.id?(i=n,r=o,"video"===n&&(this.videoBuffer=e[n].buffer)):a=!0}a&&r?(_.logger.log("alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},e.prototype.onBufferAppended=function(t){if("main"===t.parent){var e=this.state;e!==S.PARSING&&e!==S.PARSED||(this.pendingBuffering=t.pending>0,this._checkAppendedParsed())}},e.prototype._checkAppendedParsed=function(){if(!(this.state!==S.PARSED||this.appended&&this.pendingBuffering)){var t=this.fragCurrent;if(t){var e=this.mediaBuffer?this.mediaBuffer:this.media;_.logger.log("main buffered : "+b.default.toString(e.buffered));var r=this._bufferedFrags.filter(function(t){return f.default.isBuffered(e,(t.startPTS+t.endPTS)/2)});r.push(t),this._bufferedFrags=r.sort(function(t,e){return t.startPTS-e.startPTS}),this.fragPrevious=t;var i=this.stats;i.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*i.total/(i.tbuffered-i.tfirst)),this.hls.trigger(g.default.FRAG_BUFFERED,{stats:i,frag:t,id:"main"}),this.state=S.IDLE}this.tick()}},e.prototype.onError=function(t){var e=t.frag||this.fragCurrent;if(!e||"main"===e.type){var r=this.media,i=r&&f.default.isBuffered(r,r.currentTime)&&f.default.isBuffered(r,r.currentTime+.5);switch(t.details){case R.ErrorDetails.FRAG_LOAD_ERROR:case R.ErrorDetails.FRAG_LOAD_TIMEOUT:case R.ErrorDetails.KEY_LOAD_ERROR:case R.ErrorDetails.KEY_LOAD_TIMEOUT:if(!t.fatal){var a=this.fragLoadError;a?a++:a=1;var n=this.config;if(a<=n.fragLoadingMaxRetry||i||e.autoLevel&&e.level){this.fragLoadError=a,e.loadCounter=0;var o=Math.min(Math.pow(2,a-1)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);_.logger.warn("mediaController: frag loading failed, retry in "+o+" ms"),this.retryDate=performance.now()+o,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.state=S.FRAG_LOADING_WAITING_RETRY}else _.logger.error("mediaController: "+t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.state=S.ERROR}break;case R.ErrorDetails.FRAG_LOOP_LOADING_ERROR:t.fatal||(i?(this._reduceMaxBufferLength(e.duration),this.state=S.IDLE):e.autoLevel&&0!==e.level||(t.fatal=!0,this.state=S.ERROR));break;case R.ErrorDetails.LEVEL_LOAD_ERROR:case R.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==S.ERROR&&(t.fatal?(this.state=S.ERROR,_.logger.warn("streamController: "+t.details+",switch to "+this.state+" state ...")):t.levelRetry||this.state!==S.WAITING_LEVEL||(this.state=S.IDLE));break;case R.ErrorDetails.BUFFER_FULL_ERROR:"main"!==t.parent||this.state!==S.PARSING&&this.state!==S.PARSED||(i?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=S.IDLE):(_.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},e.prototype._reduceMaxBufferLength=function(t){var e=this.config;e.maxMaxBufferLength>=t&&(e.maxMaxBufferLength/=2,_.logger.warn("main:reduce max buffer length to "+e.maxMaxBufferLength+"s"),this.fragLoadIdx+=2*e.fragLoadingLoopThreshold)},e.prototype._checkBuffer=function(){var t=this.media,e=this.config;if(t&&t.readyState){var r=t.currentTime,i=this.mediaBuffer?this.mediaBuffer:t,a=i.buffered;if(!this.loadedmetadata&&a.length){this.loadedmetadata=!0;var n=t.seeking?r:this.startPosition,o=f.default.isBuffered(i,n),s=a.start(0);(r!==n||!o&&Math.abs(n-s)<e.maxSeekHole)&&(_.logger.log("target start position:"+n),o||(n=s,_.logger.log("target start position not buffered, seek to buffered.start(0) "+n)),_.logger.log("adjust currentTime from "+r+" to "+n),t.currentTime=n)}else if(this.immediateSwitch)this.immediateLevelSwitchEnd();else{var l=f.default.bufferInfo(t,r,0),u=!(t.paused||t.ended||0===t.buffered.length),d=r!==this.lastCurrentTime;if(d)this.stallReported&&(_.logger.warn("playback not stuck anymore @"+r+", after "+Math.round(performance.now()-this.stalled)+"ms"),this.stallReported=!1),this.stalled=void 0,this.nudgeRetry=0;else if(u){var c=performance.now(),h=this.hls;if(this.stalled){var p=c-this.stalled,v=l.len,y=this.nudgeRetry||0;if(v<=.5&&p>1e3*e.lowBufferWatchdogPeriod){this.stallReported||(this.stallReported=!0,_.logger.warn("playback stalling in low buffer @"+r),h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:v}));var m=l.nextStart,E=m-r;if(m&&E<e.maxSeekHole&&E>0){this.nudgeRetry=++y;var T=y*e.nudgeOffset;_.logger.log("adjust currentTime from "+t.currentTime+" to next buffered @ "+m+" + nudge "+T),t.currentTime=m+T,this.stalled=void 0,h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,hole:m+T-r})}}else if(v>.5&&p>1e3*e.highBufferWatchdogPeriod)if(this.stallReported||(this.stallReported=!0,_.logger.warn("playback stalling in high buffer @"+r),h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:v})),this.stalled=void 0,this.nudgeRetry=++y,y<e.nudgeMaxRetry){var b=t.currentTime,S=b+y*e.nudgeOffset;_.logger.log("adjust currentTime from "+b+" to "+S),t.currentTime=S,h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else _.logger.error("still stuck in high buffer @"+r+" after "+e.nudgeMaxRetry+", raise fatal error"),h.trigger(g.default.ERROR,{type:R.ErrorTypes.MEDIA_ERROR,details:R.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}else this.stalled=c,this.stallReported=!1}}}},e.prototype.onFragLoadEmergencyAborted=function(){this.state=S.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},e.prototype.onBufferFlushed=function(){var t=this.mediaBuffer?this.mediaBuffer:this.media;this._bufferedFrags=this._bufferedFrags.filter(function(e){return f.default.isBuffered(t,(e.startPTS+e.endPTS)/2)}),this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.state=S.IDLE,this.fragPrevious=null},e.prototype.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},e.prototype.computeLivePosition=function(t,e){var r=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*e.targetduration;return t+Math.max(0,e.totalduration-r)},s(e,[{key:"state",set:function(t){if(this.state!==t){var e=this.state;this._state=t,_.logger.log("main stream:"+e+"->"+t),this.hls.trigger(g.default.STREAM_STATE_TRANSITION,{previousState:e,nextState:t})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var t=this.media;if(t){var e=this.getBufferedFrag(t.currentTime);if(e)return e.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;return t?this.followingBufferedFrag(this.getBufferedFrag(t.currentTime)):null}},{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(t){this._liveSyncPosition=t}}]),e}(y.default);e.default=A},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=r(1),l=i(s),u=r(3),d=i(u),f=r(0),c=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,l.default.ERROR,l.default.SUBTITLE_TRACKS_UPDATED,l.default.SUBTITLE_TRACK_SWITCH,l.default.SUBTITLE_TRACK_LOADED,l.default.SUBTITLE_FRAG_PROCESSED));return i.config=r.config,i.vttFragSNsProcessed={},i.vttFragQueues=void 0,i.currentlyProcessing=null,i.currentTrackId=-1,i}return o(e,t),e.prototype.destroy=function(){d.default.prototype.destroy.call(this)},e.prototype.clearVttFragQueues=function(){var t=this;this.vttFragQueues={},this.tracks.forEach(function(e){t.vttFragQueues[e.id]=[]})},e.prototype.nextFrag=function(){if(null===this.currentlyProcessing&&this.currentTrackId>-1&&this.vttFragQueues[this.currentTrackId].length){var t=this.currentlyProcessing=this.vttFragQueues[this.currentTrackId].shift();this.hls.trigger(l.default.FRAG_LOADING,{frag:t})}},e.prototype.onSubtitleFragProcessed=function(t){t.success&&this.vttFragSNsProcessed[t.frag.trackId].push(t.frag.sn),this.currentlyProcessing=null,this.nextFrag()},e.prototype.onError=function(t){var e=t.frag;e&&"subtitle"!==e.type||this.currentlyProcessing&&(this.currentlyProcessing=null,this.nextFrag())},e.prototype.onSubtitleTracksUpdated=function(t){var e=this;f.logger.log("subtitle tracks updated"),this.tracks=t.subtitleTracks,this.clearVttFragQueues(),this.vttFragSNsProcessed={},this.tracks.forEach(function(t){e.vttFragSNsProcessed[t.id]=[]})},e.prototype.onSubtitleTrackSwitch=function(t){this.currentTrackId=t.id,this.clearVttFragQueues()},e.prototype.onSubtitleTrackLoaded=function(t){var e=this.vttFragSNsProcessed[t.id],r=this.vttFragQueues[t.id],i=this.currentlyProcessing?this.currentlyProcessing.sn:-1,a=function(t){return e.indexOf(t.sn)>-1},n=function(t){return r.some(function(e){return e.sn===t.sn})};t.details.fragments.forEach(function(e){a(e)||e.sn===i||n(e)||(e.trackId=t.id,r.push(e))}),this.nextFrag()},e}(d.default);e.default=c},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t){for(var e=[],r=0;r<t.length;r++)"subtitles"===t[r].kind&&e.push(t[r]);return e}Object.defineProperty(e,"__esModule",{value:!0});var l=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),u=r(1),d=i(u),f=r(3),c=i(f),h=r(0),p=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,d.default.MEDIA_ATTACHED,d.default.MEDIA_DETACHING,d.default.MANIFEST_LOADING,d.default.MANIFEST_LOADED,d.default.SUBTITLE_TRACK_LOADED));return i.tracks=[],i.trackId=-1,i.media=void 0,i}return o(e,t),e.prototype._onTextTracksChanged=function(){if(this.media){for(var t=-1,e=s(this.media.textTracks),r=0;r<e.length;r++)"showing"===e[r].mode&&(t=r);this.subtitleTrack=t}},e.prototype.destroy=function(){c.default.prototype.destroy.call(this)},e.prototype.onMediaAttached=function(t){this.media=t.media,this.media&&(this.trackChangeListener=this._onTextTracksChanged.bind(this),this.media.textTracks.addEventListener("change",this.trackChangeListener))},e.prototype.onMediaDetaching=function(){this.media&&(this.media.textTracks.removeEventListener("change",this.trackChangeListener),this.media=void 0)},e.prototype.onManifestLoading=function(){this.tracks=[],this.trackId=-1},e.prototype.onManifestLoaded=function(t){var e=this,r=t.subtitles||[],i=!1;this.tracks=r,this.trackId=-1,this.hls.trigger(d.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:r}),r.forEach(function(t){t.default&&(e.subtitleTrack=t.id,i=!0)})},e.prototype.onTick=function(){var t=this.trackId,e=this.tracks[t];if(e){var r=e.details;void 0!==r&&!0!==r.live||(h.logger.log("(re)loading playlist for subtitle track "+t),this.hls.trigger(d.default.SUBTITLE_TRACK_LOADING,{url:e.url,id:t}))}},e.prototype.onSubtitleTrackLoaded=function(t){var e=this;t.id<this.tracks.length&&(h.logger.log("subtitle track "+t.id+" loaded"),this.tracks[t.id].details=t.details,t.details.live&&!this.timer&&(this.timer=setInterval(function(){e.onTick()},1e3*t.details.targetduration,this)),!t.details.live&&this.timer&&(clearInterval(this.timer),this.timer=null))},e.prototype.setSubtitleTrackInternal=function(t){if(t>=0&&t<this.tracks.length){this.timer&&(clearInterval(this.timer),this.timer=null),this.trackId=t,h.logger.log("switching to subtitle track "+t);var e=this.tracks[t];this.hls.trigger(d.default.SUBTITLE_TRACK_SWITCH,{id:t});var r=e.details;void 0!==r&&!0!==r.live||(h.logger.log("(re)loading playlist for subtitle track "+t),this.hls.trigger(d.default.SUBTITLE_TRACK_LOADING,{url:e.url,id:t}))}},l(e,[{key:"subtitleTracks",get:function(){return this.tracks}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.trackId!==t&&this.setSubtitleTrackInternal(t)}}]),e}(c.default);e.default=p},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t){if(t&&t.cues)for(;t.cues.length>0;)t.removeCue(t.cues[0])}function l(t,e){return t&&t.label===e.name&&!(t.textTrack1||t.textTrack2)}function u(t,e,r,i){return Math.min(e,i)-Math.max(t,r)}Object.defineProperty(e,"__esModule",{value:!0});var d=r(1),f=i(d),c=r(3),h=i(c),p=r(50),g=i(p),v=r(56),y=i(v),m=r(0),E=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,f.default.MEDIA_ATTACHING,f.default.MEDIA_DETACHING,f.default.FRAG_PARSING_USERDATA,f.default.MANIFEST_LOADING,f.default.MANIFEST_LOADED,f.default.FRAG_LOADED,f.default.LEVEL_SWITCHING,f.default.INIT_PTS_FOUND));if(i.hls=r,i.config=r.config,i.enabled=!0,i.Cues=r.config.cueHandler,i.textTracks=[],i.tracks=[],i.unparsedVttFrags=[],i.initPTS=void 0,i.cueRanges=[],i.config.enableCEA708Captions){var o=i,l=function(t,e){var r=null;try{r=new window.Event("addtrack")}catch(t){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)},u={newCue:function(t,e,r){if(!o.textTrack1){var i=o.getExistingTrack("1");if(i)o.textTrack1=i,s(o.textTrack1),l(o.textTrack1,o.media);else{var a=o.createTextTrack("captions",o.config.captionsTextTrack1Label,o.config.captionsTextTrack1LanguageCode);a&&(a.textTrack1=!0,o.textTrack1=a)}}o.addCues("textTrack1",t,e,r)}},d={newCue:function(t,e,r){if(!o.textTrack2){var i=o.getExistingTrack("2");if(i)o.textTrack2=i,s(o.textTrack2),l(o.textTrack2,o.media);else{var a=o.createTextTrack("captions",o.config.captionsTextTrack2Label,o.config.captionsTextTrack1LanguageCode);a&&(a.textTrack2=!0,o.textTrack2=a)}}o.addCues("textTrack2",t,e,r)}};i.cea608Parser=new g.default(0,u,d)}return i}return o(e,t),e.prototype.addCues=function(t,e,r,i){for(var a=this.cueRanges,n=!1,o=a.length;o--;){var s=a[o],l=u(s[0],s[1],e,r);if(l>=0&&(s[0]=Math.min(s[0],e),s[1]=Math.max(s[1],r),n=!0,l/(r-e)>.5))return}n||a.push([e,r]),this.Cues.newCue(this[t],e,r,i)},e.prototype.onInitPtsFound=function(t){var e=this;void 0===this.initPTS&&(this.initPTS=t.initPTS),this.unparsedVttFrags.length&&(this.unparsedVttFrags.forEach(function(t){e.onFragLoaded(t)}),this.unparsedVttFrags=[])},e.prototype.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;r<e.textTracks.length;r++){var i=e.textTracks[r],a="textTrack"+t;if(!0===i[a])return i}return null},e.prototype.createTextTrack=function(t,e,r){var i=this.media;if(i)return i.addTextTrack(t,e,r)},e.prototype.destroy=function(){h.default.prototype.destroy.call(this)},e.prototype.onMediaAttaching=function(t){this.media=t.media},e.prototype.onMediaDetaching=function(){s(this.textTrack1),s(this.textTrack2)},e.prototype.onManifestLoading=function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0};var t=this.media;if(t){var e=t.textTracks;if(e)for(var r=0;r<e.length;r++)s(e[r])}},e.prototype.onManifestLoaded=function(t){var e=this;if(this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=void 0,this.cueRanges=[],this.config.enableWebVTT){this.tracks=t.subtitles||[];var r=this.media?this.media.textTracks:[];this.tracks.forEach(function(t,i){var a=void 0;if(i<r.length){var n=r[i];l(n,t)&&(a=n)}a||(a=e.createTextTrack("subtitles",t.name,t.lang)),a.mode=t.default?"showing":"hidden",e.textTracks.push(a)})}},e.prototype.onLevelSwitching=function(){this.enabled="NONE"!==this.hls.currentLevel.closedCaptions},e.prototype.onFragLoaded=function(t){var e=t.frag,r=t.payload;if("main"===e.type){var i=e.sn;if(i!==this.lastSn+1){var a=this.cea608Parser;a&&a.reset()}this.lastSn=i}else if("subtitle"===e.type)if(r.byteLength){if(void 0===this.initPTS)return void this.unparsedVttFrags.push(t);var n=this.vttCCs;n[e.cc]||(n[e.cc]={start:e.start,prevCC:this.prevCC,new:!0},this.prevCC=e.cc);var o=this.textTracks,s=this.hls;y.default.parse(r,this.initPTS,n,e.cc,function(t){var r=o[e.trackId];t.forEach(function(t){r.cues.getCueById(t.id)||r.addCue(t)}),s.trigger(f.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(t){m.logger.log("Failed to parse VTT cue: "+t),s.trigger(f.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})})}else this.hls.trigger(f.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})},e.prototype.onFragParsingUserdata=function(t){if(this.enabled&&this.config.enableCEA708Captions)for(var e=0;e<t.samples.length;e++){var r=this.extractCea608Data(t.samples[e].bytes);this.cea608Parser.addData(t.samples[e].pts,r)}},e.prototype.extractCea608Data=function(t){for(var e,r,i,a,n,o=31&t[0],s=2,l=[],u=0;u<o;u++)e=t[s++],r=127&t[s++],i=127&t[s++],a=0!=(4&e),n=3&e,0===r&&0===i||a&&0===n&&(l.push(r),l.push(i));return l},e}(h.default);e.default=E},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(e,r){i(this,t),this.subtle=e,this.aesIV=r}return t.prototype.decrypt=function(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)},t}();e.default=a},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){i(this,t),this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}return t.prototype.uint8ArrayToUint32Array_=function(t){for(var e=new DataView(t),r=new Uint32Array(4),i=0;i<4;i++)r[i]=e.getUint32(4*i);return r},t.prototype.initTable=function(){var t=this.sBox,e=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],o=r[3],s=this.invSubMix,l=s[0],u=s[1],d=s[2],f=s[3],c=new Uint32Array(256),h=0,p=0,g=0;for(g=0;g<256;g++)c[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^255&v^99,t[h]=v,e[v]=h;var y=c[h],m=c[y],E=c[m],T=257*c[v]^16843008*v;i[h]=T<<24|T>>>8,a[h]=T<<16|T>>>16,n[h]=T<<8|T>>>24,o[h]=T,T=16843009*E^65537*m^257*y^16843008*h,l[v]=T<<24|T>>>8,u[v]=T<<16|T>>>16,d[v]=T<<8|T>>>24,f[v]=T,h?(h=y^c[c[c[E^y]]],p^=c[c[p]]):h=p=1}},t.prototype.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;i<e.length&&r;)r=e[i]===this.key[i],i++;if(!r){this.key=e;var a=this.keySize=e.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var n=this.ksRows=4*(a+6+1),o=void 0,s=void 0,l=this.keySchedule=new Uint32Array(n),u=this.invKeySchedule=new Uint32Array(n),d=this.sBox,f=this.rcon,c=this.invSubMix,h=c[0],p=c[1],g=c[2],v=c[3],y=void 0,m=void 0;for(o=0;o<n;o++)o<a?y=l[o]=e[o]:(m=y,o%a==0?(m=m<<8|m>>>24,m=d[m>>>24]<<24|d[m>>>16&255]<<16|d[m>>>8&255]<<8|d[255&m],m^=f[o/a|0]<<24):a>6&&o%a==4&&(m=d[m>>>24]<<24|d[m>>>16&255]<<16|d[m>>>8&255]<<8|d[255&m]),l[o]=y=(l[o-a]^m)>>>0);for(s=0;s<n;s++)o=n-s,m=3&s?l[o]:l[o-4],u[s]=s<4||o<=4?m:h[d[m>>>24]]^p[d[m>>>16&255]]^g[d[m>>>8&255]]^v[d[255&m]],u[s]=u[s]>>>0}},t.prototype.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},t.prototype.decrypt=function(t,e,r){for(var i,a,n=this.keySize+6,o=this.invKeySchedule,s=this.invSBox,l=this.invSubMix,u=l[0],d=l[1],f=l[2],c=l[3],h=this.uint8ArrayToUint32Array_(r),p=h[0],g=h[1],v=h[2],y=h[3],m=new Int32Array(t),E=new Int32Array(m.length),T=void 0,b=void 0,R=void 0,_=void 0,S=void 0,A=void 0,L=void 0,w=void 0,D=void 0,O=void 0,I=void 0,k=void 0,P=this.networkToHostOrderSwap;e<m.length;){for(D=P(m[e]),O=P(m[e+1]),I=P(m[e+2]),k=P(m[e+3]),S=D^o[0],A=k^o[1],L=I^o[2],w=O^o[3],i=4,a=1;a<n;a++)T=u[S>>>24]^d[A>>16&255]^f[L>>8&255]^c[255&w]^o[i],b=u[A>>>24]^d[L>>16&255]^f[w>>8&255]^c[255&S]^o[i+1],R=u[L>>>24]^d[w>>16&255]^f[S>>8&255]^c[255&A]^o[i+2],_=u[w>>>24]^d[S>>16&255]^f[A>>8&255]^c[255&L]^o[i+3],S=T,A=b,L=R,w=_,i+=4;T=s[S>>>24]<<24^s[A>>16&255]<<16^s[L>>8&255]<<8^s[255&w]^o[i],b=s[A>>>24]<<24^s[L>>16&255]<<16^s[w>>8&255]<<8^s[255&S]^o[i+1],R=s[L>>>24]<<24^s[w>>16&255]<<16^s[S>>8&255]<<8^s[255&A]^o[i+2],_=s[w>>>24]<<24^s[S>>16&255]<<16^s[A>>8&255]<<8^s[255&L]^o[i+3],i+=3,E[e]=P(T^p),E[e+1]=P(_^g),E[e+2]=P(R^v),E[e+3]=P(b^y),p=D,g=O,v=I,y=k,e+=4}return E.buffer},t.prototype.destroy=function(){this.key=void 0,this.keySize=void 0,this.ksRows=void 0,this.sBox=void 0,this.invSBox=void 0,this.subMix=void 0,this.invSubMix=void 0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.rcon=void 0},t}();e.default=a},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(e,r){i(this,t),this.subtle=e,this.key=r}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}();e.default=a},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=r(9),o=i(n),s=r(0),l=r(5),u=i(l),d=function(){function t(e,r,i){a(this,t),this.observer=e,this.config=i,this.remuxer=r}return t.prototype.resetInitSegment=function(t,e,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:-1,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:e,duration:i,inputTimeScale:9e4}},t.prototype.resetTimeStamp=function(){},t.probe=function(t){var e,r,i=u.default.getID3Data(t,0);if(i&&void 0!==u.default.getTimeStamp(i))for(e=i.length,r=Math.min(t.length-1,e+100);e<r;e++)if(o.default.probe(t,e))return s.logger.log("ADTS sync word found !"),!0;return!1},t.prototype.append=function(t,e,r,i){for(var a=this._audioTrack,n=u.default.getID3Data(t,0),l=90*u.default.getTimeStamp(n),d=0,f=l,c=t.length,h=n.length,p=[{pts:f,dts:f,data:n}];h<c-1;)if(o.default.isHeader(t,h)&&h+5<c){o.default.initTrackConfig(a,this.observer,t,h,a.manifestCodec);var g=o.default.appendFrame(a,t,h,l,d);if(!g){s.logger.log("Unable to parse AAC frame");break}h+=g.length,f=g.sample.pts,d++}else u.default.isHeader(t,h)?(n=u.default.getID3Data(t,h),p.push({pts:f,dts:f,data:n}),h+=n.length):h++;this.remuxer.remux(a,{samples:[]},{samples:p,inputTimeScale:9e4},{samples:[]},e,r,i)},t.prototype.destroy=function(){},t}();e.default=d},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var a=r(10),n=i(a),o=r(1),s=i(o),l=r(0),u=r(7),d=i(u),f=function(t){var e=new d.default;e.trigger=function(t){for(var r=arguments.length,i=Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];e.emit.apply(e,[t,t].concat(i))},e.off=function(t){for(var r=arguments.length,i=Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];e.removeListener.apply(e,[t].concat(i))};var r=function(e,r){t.postMessage({event:e,data:r})};t.addEventListener("message",function(i){var a=i.data;switch(a.cmd){case"init":var o=JSON.parse(a.config);t.demuxer=new n.default(e,a.typeSupported,o,a.vendor);try{(0,l.enableLogs)(!0===o.debug)}catch(t){console.warn("demuxerWorker: unable to enable logs")}r("init",null);break;case"demux":t.demuxer.push(a.data,a.decryptdata,a.initSegment,a.audioCodec,a.videoCodec,a.timeOffset,a.discontinuity,a.trackSwitch,a.contiguous,a.duration,a.accurateTimeOffset,a.defaultInitPTS)}}),e.on(s.default.FRAG_DECRYPTED,r),e.on(s.default.FRAG_PARSING_INIT_SEGMENT,r),e.on(s.default.FRAG_PARSED,r),e.on(s.default.ERROR,r),e.on(s.default.FRAG_PARSING_METADATA,r),e.on(s.default.FRAG_PARSING_USERDATA,r),e.on(s.default.INIT_PTS_FOUND,r),e.on(s.default.FRAG_PARSING_DATA,function(e,r){var i=[],a={event:e,data:r};r.data1&&(a.data1=r.data1.buffer,i.push(r.data1.buffer),delete r.data1),r.data2&&(a.data2=r.data2.buffer,i.push(r.data2.buffer),delete r.data2),t.postMessage(a,i)})};e.default=f},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=r(0),n=function(){function t(e){i(this,t),this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}return t.prototype.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),a=Math.min(4,e);if(0===a)throw new Error("no bytes available");i.set(t.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},t.prototype.skipBits=function(t){var e;this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e>>3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},t.prototype.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),e=t-e,e>0&&this.bitsAvailable?r<<e|this.readBits(e):r},t.prototype.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},t.prototype.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.prototype.skipEG=function(){this.skipBits(1+this.skipLZ())},t.prototype.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},t.prototype.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},t.prototype.readBoolean=function(){return 1===this.readBits(1)},t.prototype.readUByte=function(){return this.readBits(8)},t.prototype.readUShort=function(){return this.readBits(16)},t.prototype.readUInt=function(){return this.readBits(32)},t.prototype.skipScalingList=function(t){var e,r,i=8,a=8;for(e=0;e<t;e++)0!==a&&(r=this.readEG(),a=(i+r+256)%256),i=0===a?i:a},t.prototype.readSPS=function(){var t,e,r,i,a,n,o,s=0,l=0,u=0,d=0,f=this.readUByte.bind(this),c=this.readBits.bind(this),h=this.readUEG.bind(this),p=this.readBoolean.bind(this),g=this.skipBits.bind(this),v=this.skipEG.bind(this),y=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);if(f(),t=f(),c(5),g(3),f(),y(),100===t||110===t||122===t||244===t||44===t||83===t||86===t||118===t||128===t){var E=h();if(3===E&&g(1),y(),y(),g(1),p())for(n=3!==E?8:12,o=0;o<n;o++)p()&&m(o<6?16:64)}y();var T=h();if(0===T)h();else if(1===T)for(g(1),v(),v(),e=h(),o=0;o<e;o++)v();y(),g(1),r=h(),i=h(),a=c(1),0===a&&g(1),g(1),p()&&(s=h(),l=h(),u=h(),d=h());var b=[1,1];if(p()&&p()){switch(f()){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:b=[f()<<8|f(),f()<<8|f()]}}return{width:Math.ceil(16*(r+1)-2*s-2*l),height:(2-a)*(i+1)*16-(a?2:4)*(u+d),pixelRatio:b}},t.prototype.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}();e.default=n},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=r(5),o=i(n),s=r(0),l=r(12),u=i(l),d=function(){function t(e,r,i){a(this,t),this.observer=e,this.config=i,this.remuxer=r}return t.prototype.resetInitSegment=function(t,e,r,i){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:e,duration:i,inputTimeScale:9e4}},t.prototype.resetTimeStamp=function(){},t.probe=function(t){var e,r,i=o.default.getID3Data(t,0);if(i&&void 0!==o.default.getTimeStamp(i))for(e=i.length,r=Math.min(t.length-1,e+100);e<r;e++)if(u.default.probe(t,e))return s.logger.log("MPEG Audio sync word found !"),!0;return!1},t.prototype.append=function(t,e,r,i){for(var a=o.default.getID3Data(t,0),n=90*o.default.getTimeStamp(a),s=a.length,l=t.length,d=0,f=0,c=this._audioTrack,h=[{pts:n,dts:n,data:a}];s<l;)if(u.default.isHeader(t,s)){var p=u.default.appendFrame(c,t,s,n,d);if(!p)break;s+=p.length,f=p.sample.pts,d++}else o.default.isHeader(t,s)?(a=o.default.getID3Data(t,s),h.push({pts:f,dts:f,data:a}),s+=a.length):s++;this.remuxer.remux(c,{samples:[]},{samples:h,inputTimeScale:9e4},{samples:[]},e,r,i)},t.prototype.destroy=function(){},t}();e.default=d},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=r(1),n=function(t){return t&&t.__esModule?t:{default:t}}(a),o=Math.pow(2,32)-1,s=function(){function t(e,r){i(this,t),this.observer=e,this.remuxer=r}return t.prototype.resetTimeStamp=function(t){this.initPTS=t},t.prototype.resetInitSegment=function(e,r,i,a){if(e&&e.byteLength){var o=this.initData=t.parseInitSegment(e),s={};o.audio&&(s.audio={container:"audio/mp4",codec:r,initSegment:a?e:null}),o.video&&(s.video={container:"video/mp4",codec:i,initSegment:a?e:null}),this.observer.trigger(n.default.FRAG_PARSING_INIT_SEGMENT,{tracks:s})}else r&&(this.audioCodec=r),i&&(this.videoCodec=i)},t.probe=function(e){if(e.length>=8){return["moof","ftyp","styp"].indexOf(t.bin2str(e.subarray(4,8)))>=0}return!1},t.bin2str=function(t){return String.fromCharCode.apply(null,t)},t.readUint32=function(t,e){t.data&&(e+=t.start,t=t.data);var r=t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3];return r<0?4294967296+r:r},t.writeUint32=function(t,e,r){t.data&&(e+=t.start,t=t.data),t[e]=r>>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r},t.findBox=function(e,r){var i,a,n,o,s,l,u,d=[];if(e.data?(l=e.start,o=e.end,e=e.data):(l=0,o=e.byteLength),!r.length)return null;for(i=l;i<o;)a=t.readUint32(e,i),n=t.bin2str(e.subarray(i+4,i+8)),u=a>1?i+a:o,n===r[0]&&(1===r.length?d.push({data:e,start:i+8,end:u}):(s=t.findBox({data:e,start:i+8,end:u},r.slice(1)),s.length&&(d=d.concat(s)))),i=u;return d},t.parseInitSegment=function(e){var r=[];return t.findBox(e,["moov","trak"]).forEach(function(e){var i=t.findBox(e,["tkhd"])[0];if(i){var a=i.data[i.start],n=0===a?12:20,o=t.readUint32(i,n),s=t.findBox(e,["mdia","mdhd"])[0];if(s){a=s.data[s.start],n=0===a?12:20;var l=t.readUint32(s,n),u=t.findBox(e,["mdia","hdlr"])[0];if(u){var d=t.bin2str(u.data.subarray(u.start+8,u.start+12)),f={soun:"audio",vide:"video"}[d];f&&(r[o]={timescale:l,type:f},r[f]={timescale:l,id:o})}}}}),r},t.getStartDTS=function(e,r){var i,a,n;return i=t.findBox(r,["moof","traf"]),a=[].concat.apply([],i.map(function(r){return t.findBox(r,["tfhd"]).map(function(i){var a,n,o;return a=t.readUint32(i,4),n=e[a].timescale||9e4,o=t.findBox(r,["tfdt"]).map(function(e){var r,i;return r=e.data[e.start],i=t.readUint32(e,4),1===r&&(i*=Math.pow(2,32),i+=t.readUint32(e,8)),i})[0],(o=o||1/0)/n})})),n=Math.min.apply(null,a),isFinite(n)?n:0},t.offsetStartDTS=function(e,r,i){t.findBox(r,["moof","traf"]).map(function(r){return t.findBox(r,["tfhd"]).map(function(a){var n=t.readUint32(a,4),s=e[n].timescale||9e4;t.findBox(r,["tfdt"]).map(function(e){var r=e.data[e.start],a=t.readUint32(e,4);if(0===r)t.writeUint32(e,4,a-i*s);else{a*=Math.pow(2,32),a+=t.readUint32(e,8),a-=i*s;var n=Math.floor(a/(o+1)),l=Math.floor(a%(o+1));t.writeUint32(e,4,n),t.writeUint32(e,8,l)}})})})},t.prototype.append=function(e,r,i,a){var o=this.initData;o||(this.resetInitSegment(e,this.audioCodec,this.videoCodec),o=this.initData);var s=void 0,l=this.initPTS;if(void 0===l){var u=t.getStartDTS(o,e);this.initPTS=l=u-r,this.observer.trigger(n.default.INIT_PTS_FOUND,{initPTS:l})}t.offsetStartDTS(o,e,l),s=t.getStartDTS(o,e),this.remuxer.remux(o.audio,o.video,null,null,s,i,a,e)},t.prototype.destroy=function(){},t}();e.default=s},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=r(8),n=function(t){return t&&t.__esModule?t:{default:t}}(a),o=function(){function t(e,r,a,o){i(this,t),this.decryptdata=a,this.discardEPB=o,this.decrypter=new n.default(e,r)}return t.prototype.decryptBuffer=function(t,e){this.decrypter.decrypt(t,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,e)},t.prototype.decryptAacSample=function(t,e,r,i){var a=t[e].unit,n=a.subarray(16,a.length-a.length%16),o=n.buffer.slice(n.byteOffset,n.byteOffset+n.length),s=this;this.decryptBuffer(o,function(n){n=new Uint8Array(n),a.set(n,16),i||s.decryptAacSamples(t,e+1,r)})},t.prototype.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(t,e,r,i),!i)return}}},t.prototype.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,a=32;a<=t.length-16;a+=160,i+=16)r.set(t.subarray(a,a+16),i);return r},t.prototype.getAvcDecryptedUnit=function(t,e){e=new Uint8Array(e);for(var r=0,i=32;i<=t.length-16;i+=160,r+=16)t.set(e.subarray(r,r+16),i);return t},t.prototype.decryptAvcSample=function(t,e,r,i,a,n){var o=this.discardEPB(a.data),s=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(s.buffer,function(s){a.data=l.getAvcDecryptedUnit(o,s),n||l.decryptAvcSamples(t,e,r+1,i)})},t.prototype.decryptAvcSamples=function(t,e,r,i){for(;;e++,r=0){if(e>=t.length)return void i();for(var a=t[e].units;!(r>=a.length);r++){var n=a[r];if(!(n.length<=48||1!==n.type&&5!==n.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(t,e,r,i,n,o),!o)return}}}},t}();e.default=o},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=r(9),o=i(n),s=r(12),l=i(s),u=r(1),d=i(u),f=r(36),c=i(f),h=r(39),p=i(h),g=r(0),v=r(2),y=function(){function t(e,r,i,n){a(this,t),this.observer=e,this.config=i,this.typeSupported=n,this.remuxer=r,this.sampleAes=null}return t.prototype.setDecryptData=function(t){null!=t&&null!=t.key&&"SAMPLE-AES"===t.method?this.sampleAes=new p.default(this.observer,this.config,t,this.discardEPB):this.sampleAes=null},t.probe=function(t){return t.length>=564&&71===t[0]&&71===t[188]&&71===t[376]},t.prototype.resetInitSegment=function(t,e,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack={container:"video/mp2t",type:"video",id:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0,dropped:0},this._audioTrack={container:"video/mp2t",type:"audio",id:-1,inputTimeScale:9e4,duration:i,sequenceNumber:0,samples:[],len:0,isAAC:!0},this._id3Track={type:"id3",id:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0},this._txtTrack={type:"text",id:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0},this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=e,this.videoCodec=r,this._duration=i},t.prototype.resetTimeStamp=function(){},t.prototype.append=function(t,e,r,i){var a,n,o,s,l,u=t.length,f=!1;this.contiguous=r;var c=this.pmtParsed,h=this._avcTrack,p=this._audioTrack,y=this._id3Track,m=h.id,E=p.id,T=y.id,b=this._pmtId,R=h.pesData,_=p.pesData,S=y.pesData,A=this._parsePAT,L=this._parsePMT,w=this._parsePES,D=this._parseAVCPES.bind(this),O=this._parseAACPES.bind(this),I=this._parseMPEGPES.bind(this),k=this._parseID3PES.bind(this);for(u-=u%188,a=0;a<u;a+=188)if(71===t[a]){if(n=!!(64&t[a+1]),o=((31&t[a+1])<<8)+t[a+2],(48&t[a+3])>>4>1){if((s=a+5+t[a+4])===a+188)continue}else s=a+4;switch(o){case m:n&&(R&&(l=w(R))&&D(l,!1),R={data:[],size:0}),R&&(R.data.push(t.subarray(s,a+188)),R.size+=a+188-s);break;case E:n&&(_&&(l=w(_))&&(p.isAAC?O(l):I(l)),_={data:[],size:0}),_&&(_.data.push(t.subarray(s,a+188)),_.size+=a+188-s);break;case T:n&&(S&&(l=w(S))&&k(l),S={data:[],size:0}),S&&(S.data.push(t.subarray(s,a+188)),S.size+=a+188-s);break;case 0:n&&(s+=t[s]+1),b=this._pmtId=A(t,s);break;case b:n&&(s+=t[s]+1);var P=L(t,s,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);m=P.avc,m>0&&(h.id=m),E=P.audio,E>0&&(p.id=E,p.isAAC=P.isAAC),T=P.id3,T>0&&(y.id=T),f&&!c&&(g.logger.log("reparse from beginning"),f=!1,a=-188),c=this.pmtParsed=!0;break;case 17:case 8191:break;default:f=!0}}else this.observer.trigger(d.default.ERROR,{type:v.ErrorTypes.MEDIA_ERROR,details:v.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});R&&(l=w(R))?(D(l,!0),h.pesData=null):h.pesData=R,_&&(l=w(_))?(p.isAAC?O(l):I(l),p.pesData=null):(_&&_.size&&g.logger.log("last AAC PES packet truncated,might overlap between fragments"),p.pesData=_),S&&(l=w(S))?(k(l),y.pesData=null):y.pesData=S,null==this.sampleAes?this.remuxer.remux(p,h,y,this._txtTrack,e,r,i):this.decryptAndRemux(p,h,y,this._txtTrack,e,r,i)},t.prototype.decryptAndRemux=function(t,e,r,i,a,n,o){if(t.samples&&t.isAAC){var s=this;this.sampleAes.decryptAacSamples(t.samples,0,function(){s.decryptAndRemuxAvc(t,e,r,i,a,n,o)})}else this.decryptAndRemuxAvc(t,e,r,i,a,n,o)},t.prototype.decryptAndRemuxAvc=function(t,e,r,i,a,n,o){if(e.samples){var s=this;this.sampleAes.decryptAvcSamples(e.samples,0,0,function(){s.remuxer.remux(t,e,r,i,a,n,o)})}else this.remuxer.remux(t,e,r,i,a,n,o)},t.prototype.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},t.prototype._parsePAT=function(t,e){return(31&t[e+10])<<8|t[e+11]},t.prototype._parsePMT=function(t,e,r,i){var a,n,o,s,l={audio:-1,avc:-1,id3:-1,isAAC:!0};for(a=(15&t[e+1])<<8|t[e+2],n=e+3+a-4,o=(15&t[e+10])<<8|t[e+11],e+=12+o;e<n;){switch(s=(31&t[e+1])<<8|t[e+2],t[e]){case 207:if(!i){g.logger.log("unkown stream type:"+t[e]);break}case 15:-1===l.audio&&(l.audio=s);break;case 21:-1===l.id3&&(l.id3=s);break;case 219:if(!i){g.logger.log("unkown stream type:"+t[e]);break}case 27:-1===l.avc&&(l.avc=s);break;case 3:case 4:r?-1===l.audio&&(l.audio=s,l.isAAC=!1):g.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:g.logger.warn("HEVC stream type found, not supported for now");break;default:g.logger.log("unkown stream type:"+t[e])}e+=5+((15&t[e+3])<<8|t[e+4])}return l},t.prototype._parsePES=function(t){var e,r,i,a,n,o,s,l,u=0,d=t.data;if(!t||0===t.size)return null;for(;d[0].length<19&&d.length>1;){var f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(e=d[0],1===(e[0]<<16)+(e[1]<<8)+e[2]){if((i=(e[4]<<8)+e[5])&&i>t.size-6)return null;r=e[7],192&r&&(o=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,o>4294967295&&(o-=8589934592),64&r?(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,s>4294967295&&(s-=8589934592),o-s>54e5&&(g.logger.warn(Math.round((o-s)/9e4)+"s delta between PTS and DTS, align them"),o=s)):s=o),a=e[8],l=a+9,t.size-=l,n=new Uint8Array(t.size);for(var c=0,h=d.length;c<h;c++){e=d[c];var p=e.byteLength;if(l){if(l>p){l-=p;continue}e=e.subarray(l),p-=l,l=0}n.set(e,u),u+=p}return i&&(i-=a+3),{data:n,pts:o,dts:s,len:i}}return null},t.prototype.pushAccesUnit=function(t,e){if(t.units.length&&t.frame){var r=e.samples,i=r.length;!this.config.forceKeyFrameOnDiscontinuity||!0===t.key||e.sps&&(i||this.contiguous)?(t.id=i,r.push(t)):e.dropped++}t.debug.length&&g.logger.log(t.pts+"/"+t.dts+":"+t.debug)},t.prototype._parseAVCPES=function(t,e){var r,i,a,n=this,o=this._avcTrack,s=this._parseAVCNALu(t.data),l=this.avcSample,u=!1;t.data=null,s.forEach(function(e){switch(e.type){case 1:i=!0,l.frame=!0;var s=e.data;if(u&&s.length>4){var d=new c.default(s).readSliceType();2!==d&&4!==d&&7!==d&&9!==d||(l.key=!0)}break;case 5:i=!0,l||(l=n.avcSample=n._createAVCSample(!0,t.pts,t.dts,"")),l.key=!0,l.frame=!0;break;case 6:i=!0,r=new c.default(n.discardEPB(e.data)),r.readUByte();for(var f=0,h=0,p=!1,g=0;!p&&r.bytesAvailable>1;){f=0;do{g=r.readUByte(),f+=g}while(255===g);h=0;do{g=r.readUByte(),h+=g}while(255===g);if(4===f&&0!==r.bytesAvailable){p=!0;if(181===r.readUByte()){if(49===r.readUShort()){if(1195456820===r.readUInt()){if(3===r.readUByte()){var v=r.readUByte(),y=r.readUByte(),m=31&v,E=[v,y];for(a=0;a<m;a++)E.push(r.readUByte()),E.push(r.readUByte()),E.push(r.readUByte());n._insertSampleInOrder(n._txtTrack.samples,{type:3,pts:t.pts,bytes:E})}}}}}else if(h<r.bytesAvailable)for(a=0;a<h;a++)r.readUByte()}break;case 7:if(i=!0,u=!0,!o.sps){r=new c.default(e.data);var T=r.readSPS();o.width=T.width,o.height=T.height,o.pixelRatio=T.pixelRatio,o.sps=[e.data],o.duration=n._duration;var b=e.data.subarray(1,4),R="avc1.";for(a=0;a<3;a++){var _=b[a].toString(16);_.length<2&&(_="0"+_),R+=_}o.codec=R}break;case 8:i=!0,o.pps||(o.pps=[e.data]);break;case 9:i=!1,l&&n.pushAccesUnit(l,o),l=n.avcSample=n._createAVCSample(!1,t.pts,t.dts,"");break;case 12:i=!1;break;default:i=!1,l&&(l.debug+="unknown NAL "+e.type+" ")}if(l&&i){l.units.push(e)}}),e&&l&&(this.pushAccesUnit(l,o),this.avcSample=null)},t.prototype._createAVCSample=function(t,e,r,i){return{key:t,pts:e,dts:r,units:[],debug:i}},t.prototype._insertSampleInOrder=function(t,e){var r=t.length;if(r>0){if(e.pts>=t[r-1].pts)t.push(e);else for(var i=r-1;i>=0;i--)if(e.pts<t[i].pts){t.splice(i,0,e);break}}else t.push(e)},t.prototype._getLastNalUnit=function(){var t=this.avcSample,e=void 0;if(!t||0===t.units.length){var r=this._avcTrack,i=r.samples;t=i[i.length-1]}if(t){var a=t.units;e=a[a.length-1]}return e},t.prototype._parseAVCNALu=function(t){var e,r,i,a,n,o=0,s=t.byteLength,l=this._avcTrack,u=l.naluState||0,d=u,f=[],c=-1;for(-1===u&&(c=0,n=31&t[0],u=0,o=1);o<s;)if(e=t[o++],u)if(1!==u)if(e)if(1===e){if(c>=0)i={data:t.subarray(c,o-u-1),type:n},f.push(i);else{var h=this._getLastNalUnit();if(h&&(d&&o<=4-d&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-d)),(r=o-u-1)>0)){var p=new Uint8Array(h.data.byteLength+r);p.set(h.data,0),p.set(t.subarray(0,r),h.data.byteLength),h.data=p}}o<s?(a=31&t[o],c=o,n=a,u=0):u=-1}else u=0;else u=3;else u=e?0:2;else u=e?0:1;if(c>=0&&u>=0&&(i={data:t.subarray(c,s),type:n,state:u},f.push(i)),0===f.length){var g=this._getLastNalUnit();if(g){var v=new Uint8Array(g.data.byteLength+t.byteLength);v.set(g.data,0),v.set(t,g.data.byteLength),g.data=v}}return l.naluState=u,f},t.prototype.discardEPB=function(t){for(var e,r,i=t.byteLength,a=[],n=1;n<i-2;)0===t[n]&&0===t[n+1]&&3===t[n+2]?(a.push(n+2),n+=2):n++;if(0===a.length)return t;e=i-a.length,r=new Uint8Array(e);var o=0;for(n=0;n<e;o++,n++)o===a[0]&&(o++,a.shift()),r[n]=t[o];return r},t.prototype._parseAACPES=function(t){var e,r,i,a,n,s=this._audioTrack,l=t.data,u=t.pts,f=this.aacOverFlow,c=this.aacLastPTS;if(f){var h=new Uint8Array(f.byteLength+l.byteLength);h.set(f,0),h.set(l,f.byteLength),l=h}for(i=0,n=l.length;i<n-1&&!o.default.isHeader(l,i);i++);if(i){var p,y;if(i<n-1?(p="AAC PES did not start with ADTS header,offset:"+i,y=!1):(p="no ADTS header found in AAC PES",y=!0),g.logger.warn("parsing error:"+p),this.observer.trigger(d.default.ERROR,{type:v.ErrorTypes.MEDIA_ERROR,details:v.ErrorDetails.FRAG_PARSING_ERROR,fatal:y,reason:p}),y)return}if(o.default.initTrackConfig(s,this.observer,l,i,this.audioCodec),r=0,e=o.default.getFrameDuration(s.samplerate),f&&c){var m=c+e;Math.abs(m-u)>1&&(g.logger.log("AAC: align PTS for overlapping frames by "+Math.round((m-u)/90)),u=m)}for(;i<n;)if(o.default.isHeader(l,i)&&i+5<n){var E=o.default.appendFrame(s,l,i,u,r);if(!E)break;i+=E.length,a=E.sample.pts,r++}else i++;f=i<n?l.subarray(i,n):null,this.aacOverFlow=f,this.aacLastPTS=a},t.prototype._parseMPEGPES=function(t){for(var e=t.data,r=e.length,i=0,a=0,n=t.pts;a<r;)if(l.default.isHeader(e,a)){var o=l.default.appendFrame(this._audioTrack,e,a,n,i);if(!o)break;a+=o.length,i++}else a++},t.prototype._parseID3PES=function(t){this._id3Track.samples.push(t)},t}();e.default=y},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(){i(this,t)}return t.getSilentFrame=function(t,e){switch(t){case"mp4a.40.2":if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)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===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(1===e)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===e)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===e)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])}return null},t}();e.default=a},function(t,e,r){"use strict";t.exports=r(17).default},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=r(1),l=i(s),u=r(3),d=i(u),f=r(2),c=r(0),h=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,l.default.FRAG_LOADING));return i.loaders={},i}return o(e,t),e.prototype.destroy=function(){var t=this.loaders;for(var e in t){var r=t[e];r&&r.destroy()}this.loaders={},d.default.prototype.destroy.call(this)},e.prototype.onFragLoading=function(t){var e=t.frag,r=e.type,i=this.loaders[r],a=this.hls.config;e.loaded=0,i&&(c.logger.warn("abort previous fragment loader for type:"+r),i.abort()),i=this.loaders[r]=e.loader=void 0!==a.fLoader?new a.fLoader(a):new a.loader(a);var n=void 0,o=void 0,s=void 0;n={url:e.url,frag:e,responseType:"arraybuffer",progressData:!1};var l=e.byteRangeStartOffset,u=e.byteRangeEndOffset;isNaN(l)||isNaN(u)||(n.rangeStart=l,n.rangeEnd=u),o={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},i.load(n,o,s)},e.prototype.loadsuccess=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=t.data,n=r.frag;n.loader=void 0,this.loaders[n.type]=void 0,this.hls.trigger(l.default.FRAG_LOADED,{payload:a,frag:n,stats:e,networkDetails:i})},e.prototype.loaderror=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e.frag,response:t,networkDetails:r})},e.prototype.loadtimeout=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e.frag,networkDetails:r})},e.prototype.loadprogress=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=e.frag;a.loaded=t.loaded,this.hls.trigger(l.default.FRAG_LOAD_PROGRESS,{frag:a,stats:t,networkDetails:i})},e}(d.default);e.default=h},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var s=r(1),l=i(s),u=r(3),d=i(u),f=r(2),c=r(0),h=function(t){function e(r){a(this,e);var i=n(this,t.call(this,r,l.default.KEY_LOADING));return i.loaders={},i.decryptkey=null,i.decrypturl=null,i}return o(e,t),e.prototype.destroy=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={},d.default.prototype.destroy.call(this)},e.prototype.onKeyLoading=function(t){var e=t.frag,r=e.type,i=this.loaders[r],a=e.decryptdata,n=a.uri;if(n!==this.decrypturl||null===this.decryptkey){var o=this.hls.config;i&&(c.logger.warn("abort previous key loader for type:"+r),i.abort()),e.loader=this.loaders[r]=new o.loader(o),this.decrypturl=n,this.decryptkey=null;var s=void 0,u=void 0,d=void 0;s={url:n,frag:e,responseType:"arraybuffer"},u={timeout:o.fragLoadingTimeOut,maxRetry:o.fragLoadingMaxRetry,retryDelay:o.fragLoadingRetryDelay,maxRetryDelay:o.fragLoadingMaxRetryTimeout},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},e.loader.load(s,u,d)}else this.decryptkey&&(a.key=this.decryptkey,this.hls.trigger(l.default.KEY_LOADED,{frag:e}))},e.prototype.loadsuccess=function(t,e,r){var i=r.frag;this.decryptkey=i.decryptdata.key=new Uint8Array(t.data),i.loader=void 0,this.loaders[i.type]=void 0,this.hls.trigger(l.default.KEY_LOADED,{frag:i})},e.prototype.loaderror=function(t,e){var r=e.frag,i=r.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:t})},e.prototype.loadtimeout=function(t,e){var r=e.frag,i=r.loader;i&&i.abort(),this.loaders[e.type]=void 0,this.hls.trigger(l.default.ERROR,{type:f.ErrorTypes.NETWORK_ERROR,details:f.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},e}(d.default);e.default=h},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,r,i){return r&&t(e.prototype,r),i&&t(e,i),e}}(),l=r(16),u=i(l),d=r(1),f=i(d),c=r(3),h=i(c),p=r(2),g=r(49),v=i(g),y=r(0),m=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,E=/#EXT-X-MEDIA:(.*)/g,T=new RegExp([/#EXTINF:(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)(\S+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),b=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)(.*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,R=function(){function t(){o(this,t),this.method=null,this.key=null,this.iv=null,this._uri=null}return s(t,[{key:"uri",get:function(){return!this._uri&&this.reluri&&(this._uri=u.default.buildAbsoluteURL(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}]),t}(),_=function(){function t(){o(this,t),this._url=null,this._byteRange=null,this._decryptdata=null,this.tagList=[]}return t.prototype.createInitializationVector=function(t){for(var e=new Uint8Array(16),r=12;r<16;r++)e[r]=t>>8*(15-r)&255;return e},t.prototype.fragmentDecryptdataFromLevelkey=function(t,e){var r=t;return t&&t.method&&t.uri&&!t.iv&&(r=new R,r.method=t.method,r.baseuri=t.baseuri,r.reluri=t.reluri,r.iv=this.createInitializationVector(e)),r},t.prototype.cloneObj=function(t){return JSON.parse(JSON.stringify(t))},s(t,[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=u.default.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(t){this._url=t}},{key:"programDateTime",get:function(){return!this._programDateTime&&this.rawProgramDateTime&&(this._programDateTime=new Date(Date.parse(this.rawProgramDateTime))),this._programDateTime}},{key:"byteRange",get:function(){if(!this._byteRange){var t=this._byteRange=[];if(this.rawByteRange){var e=this.rawByteRange.split("@",2);if(1===e.length){var r=this.lastByteRangeEndOffset;t[0]=r||0}else t[0]=parseInt(e[1]);t[1]=parseInt(e[0])+t[0]}}return this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){return this._decryptdata||(this._decryptdata=this.fragmentDecryptdataFromLevelkey(this.levelkey,this.sn)),this._decryptdata}}]),t}(),S=function(t){function e(r){o(this,e);var i=a(this,t.call(this,r,f.default.MANIFEST_LOADING,f.default.LEVEL_LOADING,f.default.AUDIO_TRACK_LOADING,f.default.SUBTITLE_TRACK_LOADING));return i.loaders={},i}return n(e,t),e.prototype.destroy=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy()}this.loaders={},h.default.prototype.destroy.call(this)},e.prototype.onManifestLoading=function(t){this.load(t.url,{type:"manifest"})},e.prototype.onLevelLoading=function(t){this.load(t.url,{type:"level",level:t.level,id:t.id})},e.prototype.onAudioTrackLoading=function(t){this.load(t.url,{type:"audioTrack",id:t.id})},e.prototype.onSubtitleTrackLoading=function(t){this.load(t.url,{type:"subtitleTrack",id:t.id})},e.prototype.load=function(t,e){var r=this.loaders[e.type];if(r){var i=r.context;if(i&&i.url===t)return void y.logger.trace("playlist request ongoing");y.logger.warn("abort previous loader for type:"+e.type),r.abort()}var a=this.hls.config,n=void 0,o=void 0,s=void 0,l=void 0;"manifest"===e.type?(n=a.manifestLoadingMaxRetry,o=a.manifestLoadingTimeOut,s=a.manifestLoadingRetryDelay,l=a.manifestLoadingMaxRetryTimeout):(n=a.levelLoadingMaxRetry,o=a.levelLoadingTimeOut,s=a.levelLoadingRetryDelay,l=a.levelLoadingMaxRetryTimeout,y.logger.log("loading playlist for "+e.type+" "+(e.level||e.id))),r=this.loaders[e.type]=e.loader=void 0!==a.pLoader?new a.pLoader(a):new a.loader(a),e.url=t,e.responseType="";var u=void 0,d=void 0;u={timeout:o,maxRetry:n,retryDelay:s,maxRetryDelay:l},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},r.load(e,u,d)},e.prototype.resolve=function(t,e){return u.default.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},e.prototype.parseMasterPlaylist=function(t,e){var r=[],i=void 0;for(m.lastIndex=0;null!=(i=m.exec(t));){var a={},n=a.attrs=new v.default(i[1]);a.url=this.resolve(i[2],e);var o=n.decimalResolution("RESOLUTION");o&&(a.width=o.width,a.height=o.height),a.bitrate=n.decimalInteger("AVERAGE-BANDWIDTH")||n.decimalInteger("BANDWIDTH"),a.name=n.NAME;var s=n.CODECS;if(s){s=s.split(/[ ,]+/);for(var l=0;l<s.length;l++){var u=s[l];-1!==u.indexOf("avc1")?a.videoCodec=this.avc1toavcoti(u):-1!==u.indexOf("hvc1")?a.videoCodec=u:a.audioCodec=u}}r.push(a)}return r},e.prototype.parseMasterPlaylistMedia=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=void 0,n=[],o=0;for(E.lastIndex=0;null!=(a=E.exec(t));){var s={},l=new v.default(a[1]);l.TYPE===r&&(s.groupId=l["GROUP-ID"],s.name=l.NAME,s.type=r,s.default="YES"===l.DEFAULT,s.autoselect="YES"===l.AUTOSELECT,s.forced="YES"===l.FORCED,l.URI&&(s.url=this.resolve(l.URI,e)),s.lang=l.LANGUAGE,s.name||(s.name=s.lang),i&&(s.audioCodec=i),s.id=o++,n.push(s))}return n},e.prototype.avc1toavcoti=function(t){var e,r=t.split(".");return r.length>2?(e=r.shift()+".",e+=parseInt(r.shift()).toString(16),e+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):e=t,e},e.prototype.parseLevelPlaylist=function(t,e,r,i){var a,n,o=0,s=0,l={type:null,version:null,url:e,fragments:[],live:!0,startSN:0},u=new R,d=0,f=null,c=new _;for(T.lastIndex=0;null!==(a=T.exec(t));){var h=a[1];if(h){c.duration=parseFloat(h);var p=(" "+a[2]).slice(1);c.title=p||null,c.tagList.push(p?["INF",h,p]:["INF",h])}else if(a[3]){if(!isNaN(c.duration)){var g=o++;c.type=i,c.start=s,c.levelkey=u,c.sn=g,c.level=r,c.cc=d,c.baseurl=e,c.relurl=(" "+a[3]).slice(1),l.fragments.push(c),f=c,s+=c.duration,c=new _}}else if(a[4]){if(c.rawByteRange=(" "+a[4]).slice(1),f){var m=f.byteRangeEndOffset;m&&(c.lastByteRangeEndOffset=m)}}else if(a[5])c.rawProgramDateTime=(" "+a[5]).slice(1),c.tagList.push(["PROGRAM-DATE-TIME",c.rawProgramDateTime]);else{for(a=a[0].match(b),n=1;n<a.length&&void 0===a[n];n++);var E=(" "+a[n+1]).slice(1),S=(" "+a[n+2]).slice(1);switch(a[n]){case"#":c.tagList.push(S?[E,S]:[E]);break;case"PLAYLIST-TYPE":l.type=E.toUpperCase();break;case"MEDIA-SEQUENCE":o=l.startSN=parseInt(E);break;case"TARGETDURATION":l.targetduration=parseFloat(E);break;case"VERSION":l.version=parseInt(E);break;case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"DIS":d++,c.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":d=parseInt(E);break;case"KEY":var A=E,L=new v.default(A),w=L.enumeratedString("METHOD"),D=L.URI,O=L.hexadecimalInteger("IV");w&&(u=new R,D&&["AES-128","SAMPLE-AES"].indexOf(w)>=0&&(u.method=w,u.baseuri=e,u.reluri=D,u.key=null,u.iv=O));break;case"START":var I=E,k=new v.default(I),P=k.decimalFloatingPoint("TIME-OFFSET");isNaN(P)||(l.startTimeOffset=P);break;case"MAP":var C=new v.default(E);c.relurl=C.URI,c.rawByteRange=C.BYTERANGE,c.baseurl=e,c.level=r,c.type=i,c.sn="initSegment",l.initSegment=c,c=new _;break;default:y.logger.warn("line parsed but not handled: "+a)}}}return c=f,c&&!c.relurl&&(l.fragments.pop(),s-=c.duration),l.totalduration=s,l.averagetargetduration=s/l.fragments.length,l.endSN=o-1,l},e.prototype.loadsuccess=function(t,e,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=t.data,n=t.url,o=r.type,s=r.id,l=r.level,u=this.hls;if(this.loaders[o]=void 0,void 0!==n&&0!==n.indexOf("data:")||(n=r.url),e.tload=performance.now(),0===a.indexOf("#EXTM3U"))if(a.indexOf("#EXTINF:")>0){var d="audioTrack"!==o&&"subtitleTrack"!==o,c=isNaN(l)?isNaN(s)?0:s:l,h=this.parseLevelPlaylist(a,n,c,"audioTrack"===o?"audio":"subtitleTrack"===o?"subtitle":"main");h.tload=e.tload,"manifest"===o&&u.trigger(f.default.MANIFEST_LOADED,{levels:[{url:n,details:h}],audioTracks:[],url:n,stats:e,networkDetails:i}),e.tparsed=performance.now(),h.targetduration?d?u.trigger(f.default.LEVEL_LOADED,{details:h,level:l||0,id:s||0,stats:e,networkDetails:i}):"audioTrack"===o?u.trigger(f.default.AUDIO_TRACK_LOADED,{details:h,id:s,stats:e,networkDetails:i}):"subtitleTrack"===o&&u.trigger(f.default.SUBTITLE_TRACK_LOADED,{details:h,id:s,stats:e,networkDetails:i}):u.trigger(f.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"invalid targetduration",networkDetails:i})}else{var g=this.parseMasterPlaylist(a,n);if(g.length){var v=this.parseMasterPlaylistMedia(a,n,"AUDIO",g[0].audioCodec),m=this.parseMasterPlaylistMedia(a,n,"SUBTITLES");if(v.length){var E=!1;v.forEach(function(t){t.url||(E=!0)}),!1===E&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(y.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main"}))}u.trigger(f.default.MANIFEST_LOADED,{levels:g,audioTracks:v,subtitles:m,url:n,stats:e,networkDetails:i})}else u.trigger(f.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no level found in manifest",networkDetails:i})}else u.trigger(f.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:n,reason:"no EXTM3U delimiter",networkDetails:i})},e.prototype.loaderror=function(t,e){var r,i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e.loader;switch(e.type){case"manifest":r=p.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0;break;case"level":r=p.ErrorDetails.LEVEL_LOAD_ERROR,i=!1;break;case"audioTrack":r=p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,i=!1}n&&(n.abort(),this.loaders[e.type]=void 0),this.hls.trigger(f.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:r,fatal:i,url:n.url,loader:n,response:t,context:e,networkDetails:a})},e.prototype.loadtimeout=function(t,e){var r,i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=e.loader;switch(e.type){case"manifest":r=p.ErrorDetails.MANIFEST_LOAD_TIMEOUT,i=!0;break;case"level":r=p.ErrorDetails.LEVEL_LOAD_TIMEOUT,i=!1;break;case"audioTrack":r=p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT,i=!1}n&&(n.abort(),this.loaders[e.type]=void 0),this.hls.trigger(f.default.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:r,fatal:i,url:n.url,loader:n,context:e,networkDetails:a})},e}(h.default);e.default=S},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=Math.pow(2,32)-1,n=function(){function t(){i(this,t)}return t.init=function(){t.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var e;for(e in t.types)t.types.hasOwnProperty(e)&&(t.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);t.HDLR_TYPES={video:r,audio:i};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=n,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,o,l,o,s),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,a))},t.box=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),i=8,a=r.length,n=a;a--;)i+=r[a].byteLength;for(e=new Uint8Array(i),e[0]=i>>24&255,e[1]=i>>16&255,e[2]=i>>8&255,e[3]=255&i,e.set(t,4),a=0,i=8;a<n;a++)e.set(r[a],i),i+=r[a].byteLength;return e},t.hdlr=function(e){return t.box(t.types.hdlr,t.HDLR_TYPES[e])},t.mdat=function(e){return t.box(t.types.mdat,e)},t.mdhd=function(e,r){r*=e;var i=Math.floor(r/(a+1)),n=Math.floor(r%(a+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var i=Math.floor(r/(a+1)),n=Math.floor(r%(a+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,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 t.box(t.types.mvhd,o)},t.sdtp=function(e){var r,i,a=e.samples||[],n=new Uint8Array(4+a.length);for(i=0;i<a.length;i++)r=a[i].flags,n[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return t.box(t.types.sdtp,n)},t.stbl=function(e){return t.box(t.types.stbl,t.stsd(e),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(e){var r,i,a,n=[],o=[];for(r=0;r<e.sps.length;r++)i=e.sps[r],a=i.byteLength,n.push(a>>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r<e.pps.length;r++)i=e.pps[r],a=i.byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(i));var s=t.box(t.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(o))),l=e.width,u=e.height,d=e.pixelRatio[0],f=e.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,f>>24,f>>16&255,f>>8&255,255&f])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"===e.type?e.isAAC||"mp3"!==e.codec?t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,i=e.duration*e.timescale,n=e.width,o=e.height,s=Math.floor(i/(a+1)),l=Math.floor(i%(a+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,l>>24,l>>16&255,l>>8&255,255&l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,o>>8&255,255&o,0,0]))},t.traf=function(e,r){var i=t.sdtp(e),n=e.id,o=Math.floor(r/(a+1)),s=Math.floor(r%(a+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s])),t.trun(e,i.length+16+20+8+16+8+8),i)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,r){var i,a,n,o,s,l,u=e.samples||[],d=u.length,f=12+16*d,c=new Uint8Array(f);for(r+=8+f,c.set([0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<d;i++)a=u[i],n=a.duration,o=a.size,s=a.flags,l=a.cts,c.set([n>>>24&255,n>>>16&255,n>>>8&255,255&n,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return t.box(t.types.trun,c)},t.initSegment=function(e){t.types||t.init();var r,i=t.moov(e);return r=new Uint8Array(t.FTYP.byteLength+i.byteLength),r.set(t.FTYP),r.set(i,t.FTYP.byteLength),r},t}();e.default=n},function(t,e,r){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var n=r(41),o=i(n),s=r(1),l=i(s),u=r(0),d=r(46),f=i(d),c=r(2),h=function(){function t(e,r,i,n){a(this,t),this.observer=e,this.config=r,this.typeSupported=i;var o=navigator.userAgent;this.isSafari=n&&n.indexOf("Apple")>-1&&o&&!o.match("CriOS"),this.ISGenerated=!1}return t.prototype.destroy=function(){},t.prototype.resetTimeStamp=function(t){this._initPTS=this._initDTS=t},t.prototype.resetInitSegment=function(){this.ISGenerated=!1},t.prototype.remux=function(t,e,r,i,a,n,o){if(this.ISGenerated){if(o){var s=this._initPTS,d=this._PTSNormalize,f=t.inputTimeScale||e.inputTimeScale,c=1/0,h=1/0,p=t.samples;if(p.length&&(c=h=d(p[0].pts-f*a,s)),p=e.samples,p.length){var g=p[0];c=Math.min(c,d(g.pts-f*a,s)),h=Math.min(h,d(g.dts-f*a,s))}if(c!==1/0){var v=s-c;Math.abs(v)>10*f&&(u.logger.warn("timestamp inconsistency, "+(v/f).toFixed(3)+"s delta against expected value: missing discontinuity ? reset initPTS/initDTS"),this._initPTS=c,this._initDTS=h,this.observer.trigger(l.default.INIT_PTS_FOUND,{initPTS:c}))}}}else this.generateIS(t,e,a);if(this.ISGenerated)if(t.samples.length){t.timescale||(u.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(t,e,a));var y=this.remuxAudio(t,a,n,o);if(e.samples.length){var m=void 0;y&&(m=y.endPTS-y.startPTS),e.timescale||(u.logger.warn("regenerate InitSegment as video detected"),this.generateIS(t,e,a)),this.remuxVideo(e,a,n,m,o)}}else{var E=void 0;e.samples.length&&(E=this.remuxVideo(e,a,n,o)),E&&t.codec&&this.remuxEmptyAudio(t,a,n,E)}r.samples.length&&this.remuxID3(r,a),i.samples.length&&this.remuxText(i,a),this.observer.trigger(l.default.FRAG_PARSED)},t.prototype.generateIS=function(t,e,r){var i,a,n=this.observer,o=t.samples,s=e.samples,d=this.typeSupported,h="audio/mp4",p={},g={tracks:p},v=void 0===this._initPTS;if(v&&(i=a=1/0),t.config&&o.length&&(t.timescale=t.samplerate,u.logger.log("audio sampling rate : "+t.samplerate),t.isAAC||(d.mpeg?(h="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3")),p.audio={container:h,codec:t.codec,initSegment:!t.isAAC&&d.mpeg?new Uint8Array:f.default.initSegment([t]),metadata:{channelCount:t.channelCount}},v&&(i=a=o[0].pts-t.inputTimeScale*r)),e.sps&&e.pps&&s.length){var y=e.inputTimeScale;e.timescale=y,p.video={container:"video/mp4",codec:e.codec,initSegment:f.default.initSegment([e]),metadata:{width:e.width,height:e.height}},v&&(i=Math.min(i,s[0].pts-y*r),a=Math.min(a,s[0].dts-y*r),this.observer.trigger(l.default.INIT_PTS_FOUND,{initPTS:i}))}Object.keys(p).length?(n.trigger(l.default.FRAG_PARSING_INIT_SEGMENT,g),this.ISGenerated=!0,v&&(this._initPTS=i,this._initDTS=a)):n.trigger(l.default.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.prototype.remuxVideo=function(t,e,r,i,a){var n,o,s,d,h,p,g,v=8,y=t.timescale,m=t.samples,E=[],T=m.length,b=this._PTSNormalize,R=this._initDTS,_=this.nextAvcDts,S=this.isSafari;S&&(r|=m.length&&_&&(a&&Math.abs(e-_/y)<.1||Math.abs(m[0].pts-_-R)<y/5)),r||(_=e*y),m.forEach(function(t){t.pts=b(t.pts-R,_),t.dts=b(t.dts-R,_)}),m.sort(function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||(i||t.id-e.id)});var A=m.reduce(function(t,e){return Math.max(Math.min(t,e.pts-e.dts),-18e3)},0);if(A<0){u.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(A/90)+" ms to overcome this issue");for(var L=0;L<m.length;L++)m[L].dts+=A}var w=m[0];h=Math.max(w.dts,0),d=Math.max(w.pts,0);var D=Math.round((h-_)/90);r&&D&&(D>1?u.logger.log("AVC:"+D+" ms hole between fragments detected,filling it"):D<-1&&u.logger.log("AVC:"+-D+" ms overlapping between fragments detected"),h=_,m[0].dts=h,d=Math.max(d-D,_),m[0].pts=d,u.logger.log("Video/PTS/DTS adjusted: "+Math.round(d/90)+"/"+Math.round(h/90)+",delta:"+D+" ms")),w=m[m.length-1],g=Math.max(w.dts,0),p=Math.max(w.pts,0,g),S&&(n=Math.round((g-h)/(m.length-1)));for(var O=0,I=0,k=0;k<T;k++){for(var P=m[k],C=P.units,x=C.length,F=0,M=0;M<x;M++)F+=C[M].data.length;I+=F,O+=x,P.length=F,P.dts=S?h+k*n:Math.max(P.dts,h),P.pts=Math.max(P.pts,P.dts)}var N=I+4*O+8;try{o=new Uint8Array(N)}catch(t){return void this.observer.trigger(l.default.ERROR,{type:c.ErrorTypes.MUX_ERROR,details:c.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:N,reason:"fail allocating video mdat "+N})}var U=new DataView(o.buffer);U.setUint32(0,N),o.set(f.default.types.mdat,4);for(var B=0;B<T;B++){for(var G=m[B],j=G.units,H=0,W=void 0,K=0,V=j.length;K<V;K++){var Y=j[K],z=Y.data,X=Y.data.byteLength;U.setUint32(v,X),v+=4,o.set(z,v),v+=X,H+=4+X}if(S)W=Math.max(0,n*Math.round((G.pts-G.dts)/n));else{if(B<T-1)n=m[B+1].dts-G.dts;else{var q=this.config,Q=G.dts-m[B>0?B-1:B].dts;if(q.stretchShortVideoTrack){var J=q.maxBufferHole,$=q.maxSeekHole,Z=Math.floor(Math.min(J,$)*y),tt=(i?d+i*y:this.nextAudioPts)-G.pts;tt>Z?(n=tt-Q,n<0&&(n=Q),u.logger.log("It is approximately "+tt/90+" ms to the next segment; using duration "+n/90+" ms for the last video frame.")):n=Q}else n=Q}W=Math.round(G.pts-G.dts)}E.push({size:H,duration:n,cts:W,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:G.key?2:1,isNonSync:G.key?0:1}})}this.nextAvcDts=g+n;var et=t.dropped;if(t.len=0,t.nbNalu=0,t.dropped=0,E.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var rt=E[0].flags;rt.dependsOn=2,rt.isNonSync=0}t.samples=E,s=f.default.moof(t.sequenceNumber++,h,t),t.samples=[];var it={data1:s,data2:o,startPTS:d/y,endPTS:(p+n)/y,startDTS:h/y,endDTS:this.nextAvcDts/y,type:"video",nb:E.length,dropped:et};return this.observer.trigger(l.default.FRAG_PARSING_DATA,it),it},t.prototype.remuxAudio=function(t,e,r,i){var a,n,s,d,h,p,g,v=t.inputTimeScale,y=t.timescale,m=v/y,E=t.isAAC?1024:1152,T=E*m,b=this._PTSNormalize,R=this._initDTS,_=!t.isAAC&&this.typeSupported.mpeg,S=t.samples,A=[],L=this.nextAudioPts;if(r|=S.length&&L&&(i&&Math.abs(e-L/v)<.1||Math.abs(S[0].pts-L-R)<20*T),r||(L=e*v),S.forEach(function(t){t.pts=t.dts=b(t.pts-R,L)}),S.sort(function(t,e){return t.pts-e.pts}),i&&t.isAAC)for(var w=0,D=L;w<S.length;){var O,I=S[w],k=I.pts;O=k-D;var P=Math.abs(1e3*O/v);if(O<=-T)u.logger.warn("Dropping 1 audio frame @ "+(D/v).toFixed(3)+"s due to "+P+" ms overlap."),S.splice(w,1),t.len-=I.unit.length;else if(O>=T&&P<1e4&&D){var C=Math.round(O/T);u.logger.warn("Injecting "+C+" audio frame @ "+(D/v).toFixed(3)+"s due to "+Math.round(1e3*O/v)+" ms gap.");for(var x=0;x<C;x++){var F=Math.max(D,0);s=o.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount),s||(u.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),s=I.unit.subarray()),S.splice(w,0,{unit:s,pts:F,dts:F}),t.len+=s.length,D+=T,w++}I.pts=I.dts=D,D+=T,w++}else Math.abs(O),I.pts=I.dts=D,D+=T,w++}for(var M=0,N=S.length;M<N;M++){var U=S[M],B=U.unit,G=U.pts;if(void 0!==g)n.duration=Math.round((G-g)/m);else{var j=Math.round(1e3*(G-L)/v),H=0;if(r&&t.isAAC&&j){if(j>0&&j<1e4)H=Math.round((G-L)/T),u.logger.log(j+" ms hole between AAC samples detected,filling it"),H>0&&(s=o.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount),s||(s=B.subarray()),t.len+=H*s.length);else if(j<-12){u.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(L/v).toFixed(3)+"s/"+(G/v).toFixed(3)+"s/"+-j+"ms"),t.len-=B.byteLength;continue}G=L}if(p=Math.max(0,G),!(t.len>0))return;var W=_?t.len:t.len+8;a=_?0:8;try{d=new Uint8Array(W)}catch(t){return void this.observer.trigger(l.default.ERROR,{type:c.ErrorTypes.MUX_ERROR,details:c.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:W,reason:"fail allocating audio mdat "+W})}if(!_){new DataView(d.buffer).setUint32(0,W),d.set(f.default.types.mdat,4)}for(var K=0;K<H;K++)s=o.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount),s||(u.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),s=B.subarray()),d.set(s,a),a+=s.byteLength,n={size:s.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},A.push(n)}d.set(B,a);var V=B.byteLength;a+=V,n={size:V,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},A.push(n),g=G}var Y=0,z=A.length;if(z>=2&&(Y=A[z-2].duration,n.duration=Y),z){this.nextAudioPts=L=g+m*Y,t.len=0,t.samples=A,h=_?new Uint8Array:f.default.moof(t.sequenceNumber++,p/m,t),t.samples=[];var X=p/v,q=L/v,Q={data1:h,data2:d,startPTS:X,endPTS:q,startDTS:X,endDTS:q,type:"audio",nb:z};return this.observer.trigger(l.default.FRAG_PARSING_DATA,Q),Q}return null},t.prototype.remuxEmptyAudio=function(t,e,r,i){var a=t.inputTimeScale,n=t.samplerate?t.samplerate:a,s=a/n,l=this.nextAudioPts,d=(void 0!==l?l:i.startDTS*a)+this._initDTS,f=i.endDTS*a+this._initDTS,c=1024*s,h=Math.ceil((f-d)/c),p=o.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(u.logger.warn("remux empty Audio"),!p)return void u.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!");for(var g=[],v=0;v<h;v++){var y=d+v*c;g.push({unit:p,pts:y,dts:y}),t.len+=p.length}t.samples=g,this.remuxAudio(t,e,r)},t.prototype.remuxID3=function(t,e){var r,i=t.samples.length,a=t.inputTimeScale,n=this._initPTS,o=this._initDTS;if(i){for(var s=0;s<i;s++)r=t.samples[s],r.pts=(r.pts-n)/a,r.dts=(r.dts-o)/a;this.observer.trigger(l.default.FRAG_PARSING_METADATA,{samples:t.samples})}t.samples=[],e=e},t.prototype.remuxText=function(t,e){t.samples.sort(function(t,e){return t.pts-e.pts});var r,i=t.samples.length,a=t.inputTimeScale,n=this._initPTS;if(i){for(var o=0;o<i;o++)r=t.samples[o],r.pts=(r.pts-n)/a;this.observer.trigger(l.default.FRAG_PARSING_USERDATA,{samples:t.samples})}t.samples=[],e=e},t.prototype._PTSNormalize=function(t,e){var r;if(void 0===e)return t;for(r=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=r;return t},t}();e.default=h},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=r(1),n=function(t){return t&&t.__esModule?t:{default:t}}(a),o=function(){function t(e){i(this,t),this.observer=e}return t.prototype.destroy=function(){},t.prototype.resetTimeStamp=function(){},t.prototype.resetInitSegment=function(){},t.prototype.remux=function(t,e,r,i,a,o,s,l){var u=this.observer,d="";t&&(d+="audio"),e&&(d+="video"),u.trigger(n.default.FRAG_PARSING_DATA,{data1:l,startPTS:a,startDTS:a,type:d,nb:1,dropped:0}),u.trigger(n.default.FRAG_PARSED)},t}();e.default=o},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,o=function(){function t(e){i(this,t),"string"==typeof e&&(e=t.parseAttrList(e));for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r])}return t.prototype.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},t.prototype.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;i<e.length/2;i++)r[i]=parseInt(e.slice(2*i,2*i+2),16);return r}return null},t.prototype.hexadecimalIntegerAsNumber=function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e},t.prototype.decimalFloatingPoint=function(t){return parseFloat(this[t])},t.prototype.enumeratedString=function(t){return this[t]},t.prototype.decimalResolution=function(t){var e=a.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(n.lastIndex=0;null!==(e=n.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1]]=i}return r},t}();e.default=o},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},n=function(t){var e=t;return a.hasOwnProperty(t)&&(e=a[t]),String.fromCharCode(e)},o=15,s=100,l={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},u={17:2,18:4,21:6,22:8,23:10,19:13,20:15},d={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},f={25:2,26:4,29:6,30:8,31:10,27:13,28:15},c=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],h={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(t){this.time=t},log:function(t,e){var r=this.verboseFilter[t];this.verboseLevel>=r&&console.log(this.time+" ["+t+"] "+e)}},p=function(t){for(var e=[],r=0;r<t.length;r++)e.push(t[r].toString(16));return e},g=function(){function t(e,r,a,n,o){i(this,t),this.foreground=e||"white",this.underline=r||!1,this.italics=a||!1,this.background=n||"black",this.flash=o||!1}return t.prototype.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.prototype.setStyles=function(t){for(var e=["foreground","underline","italics","background","flash"],r=0;r<e.length;r++){var i=e[r];t.hasOwnProperty(i)&&(this[i]=t[i])}},t.prototype.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.prototype.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},t.prototype.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},t.prototype.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),v=function(){function t(e,r,a,n,o,s){i(this,t),this.uchar=e||" ",this.penState=new g(r,a,n,o,s)}return t.prototype.reset=function(){this.uchar=" ",this.penState.reset()},t.prototype.setChar=function(t,e){this.uchar=t,this.penState.copy(e)},t.prototype.setPenState=function(t){this.penState.copy(t)},t.prototype.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},t.prototype.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},t.prototype.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},t}(),y=function(){function t(){i(this,t),this.chars=[];for(var e=0;e<s;e++)this.chars.push(new v);this.pos=0,this.currPenState=new g}return t.prototype.equals=function(t){for(var e=!0,r=0;r<s;r++)if(!this.chars[r].equals(t.chars[r])){e=!1;break}return e},t.prototype.copy=function(t){for(var e=0;e<s;e++)this.chars[e].copy(t.chars[e])},t.prototype.isEmpty=function(){for(var t=!0,e=0;e<s;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t},t.prototype.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(h.log("ERROR","Negative cursor position "+this.pos),this.pos=0):this.pos>s&&(h.log("ERROR","Too large cursor position "+this.pos),this.pos=s)},t.prototype.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r<e+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(e)},t.prototype.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.prototype.insertChar=function(t){t>=144&&this.backSpace();var e=n(t);if(this.pos>=s)return void h.log("ERROR","Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)},t.prototype.clearFromPos=function(t){var e;for(e=t;e<s;e++)this.chars[e].reset()},t.prototype.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.prototype.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.prototype.getTextString=function(){for(var t=[],e=!0,r=0;r<s;r++){var i=this.chars[r].uchar;" "!==i&&(e=!1),t.push(i)}return e?"":t.join("")},t.prototype.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),m=function(){function t(){i(this,t),this.rows=[];for(var e=0;e<o;e++)this.rows.push(new y);this.currRow=o-1,this.nrRollUpRows=null,this.reset()}return t.prototype.reset=function(){for(var t=0;t<o;t++)this.rows[t].clear();this.currRow=o-1},t.prototype.equals=function(t){for(var e=!0,r=0;r<o;r++)if(!this.rows[r].equals(t.rows[r])){e=!1;break}return e},t.prototype.copy=function(t){for(var e=0;e<o;e++)this.rows[e].copy(t.rows[e])},t.prototype.isEmpty=function(){for(var t=!0,e=0;e<o;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t},t.prototype.backSpace=function(){this.rows[this.currRow].backSpace()},t.prototype.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.prototype.insertChar=function(t){this.rows[this.currRow].insertChar(t)},t.prototype.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},t.prototype.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},t.prototype.setCursor=function(t){h.log("INFO","setCursor: "+t),this.rows[this.currRow].setCursor(t)},t.prototype.setPAC=function(t){h.log("INFO","pacData = "+JSON.stringify(t));var e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(var r=0;r<o;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var n=a.rows[i].cueStartTime;if(n&&n<h.time)for(var s=0;s<this.nrRollUpRows;s++)this.rows[e-this.nrRollUpRows+s+1].copy(a.rows[i+s])}}this.currRow=e;var l=this.rows[this.currRow];if(null!==t.indent){var u=t.indent,d=Math.max(u-1,0);l.setCursor(t.indent),t.color=l.chars[d].penState.foreground}var f={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(f)},t.prototype.setBkgData=function(t){h.log("INFO","bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)},t.prototype.setRollUpRows=function(t){this.nrRollUpRows=t},t.prototype.rollUp=function(){if(null===this.nrRollUpRows)return void h.log("DEBUG","roll_up but nrRollUpRows not set yet");h.log("TEXT",this.getDisplayText());var t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),h.log("INFO","Rolling up")},t.prototype.getDisplayText=function(t){t=t||!1;for(var e=[],r="",i=-1,a=0;a<o;a++){var n=this.rows[a].getTextString();n&&(i=a+1,t?e.push("Row "+i+": '"+n+"'"):e.push(n.trim()))}return e.length>0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},t.prototype.getTextAndFormat=function(){return this.rows},t}(),E=function(){function t(e,r){i(this,t),this.chNr=e,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new m,this.nonDisplayedMemory=new m,this.lastOutputScreen=new m,this.currRollUpRow=this.displayedMemory.rows[o-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return t.prototype.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[o-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.lastCueEndTime=null},t.prototype.getHandler=function(){return this.outputFilter},t.prototype.setHandler=function(t){this.outputFilter=t},t.prototype.setPAC=function(t){this.writeScreen.setPAC(t)},t.prototype.setBkgData=function(t){this.writeScreen.setBkgData(t)},t.prototype.setMode=function(t){t!==this.mode&&(this.mode=t,h.log("INFO","MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},t.prototype.insertChars=function(t){for(var e=0;e<t.length;e++)this.writeScreen.insertChar(t[e]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";h.log("INFO",r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(h.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.prototype.ccRCL=function(){h.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.prototype.ccBS=function(){h.log("INFO","BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.prototype.ccAOF=function(){},t.prototype.ccAON=function(){},t.prototype.ccDER=function(){h.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.prototype.ccRU=function(t){h.log("INFO","RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},t.prototype.ccFON=function(){h.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.prototype.ccRDC=function(){h.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.prototype.ccTR=function(){h.log("INFO","TR"),this.setMode("MODE_TEXT")},t.prototype.ccRTD=function(){h.log("INFO","RTD"),this.setMode("MODE_TEXT")},t.prototype.ccEDM=function(){h.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate()},t.prototype.ccCR=function(){h.log("CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate()},t.prototype.ccENM=function(){h.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.prototype.ccEOC=function(){if(h.log("INFO","EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,h.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate()},t.prototype.ccTO=function(t){h.log("INFO","TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},t.prototype.ccMIDROW=function(t){var e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=i[r]}h.log("INFO","MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},t.prototype.outputDataUpdate=function(){var t=h.time;null!==t&&this.outputFilter&&(this.outputFilter.updateData&&this.outputFilter.updateData(t,this.displayedMemory),null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.prototype.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),T=function(){function t(e,r,a){i(this,t),this.field=e||1,this.outputs=[r,a],this.channels=[new E(1,r),new E(2,a)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return t.prototype.getHandler=function(t){return this.channels[t].getHandler()},t.prototype.setHandler=function(t,e){this.channels[t].setHandler(e)},t.prototype.addData=function(t,e){var r,i,a,n=!1;this.lastTime=t,h.setTime(t);for(var o=0;o<e.length;o+=2)if(i=127&e[o],a=127&e[o+1],0!==i||0!==a){if(h.log("DATA","["+p([e[o],e[o+1]])+"] -> ("+p([i,a])+")"),r=this.parseCmd(i,a),r||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(n=this.parseChars(i,a)))if(this.currChNr&&this.currChNr>=0){var s=this.channels[this.currChNr-1];s.insertChars(n)}else h.log("WARNING","No channel found yet. TEXT-MODE?");r?this.dataCounters.cmd+=2:n?this.dataCounters.char+=2:(this.dataCounters.other+=2,h.log("WARNING","Couldn't parse cleaned data "+p([i,a])+" orig: "+p([e[o],e[o+1]])))}else this.dataCounters.padding+=2},t.prototype.parseCmd=function(t,e){var r=null,i=(20===t||28===t)&&32<=e&&e<=47,a=(23===t||31===t)&&33<=e&&e<=35;if(!i&&!a)return!1;if(t===this.lastCmdA&&e===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,h.log("DEBUG","Repeated command ("+p([t,e])+") is dropped"),!0;r=20===t||23===t?1:2;var n=this.channels[r-1];return 20===t||28===t?32===e?n.ccRCL():33===e?n.ccBS():34===e?n.ccAOF():35===e?n.ccAON():36===e?n.ccDER():37===e?n.ccRU(2):38===e?n.ccRU(3):39===e?n.ccRU(4):40===e?n.ccFON():41===e?n.ccRDC():42===e?n.ccTR():43===e?n.ccRTD():44===e?n.ccEDM():45===e?n.ccCR():46===e?n.ccENM():47===e&&n.ccEOC():n.ccTO(e-32),this.lastCmdA=t,this.lastCmdB=e,this.currChNr=r,!0},t.prototype.parseMidrow=function(t,e){var r=null;if((17===t||25===t)&&32<=e&&e<=47){if((r=17===t?1:2)!==this.currChNr)return h.log("ERROR","Mismatch channel in midrow parsing"),!1;return this.channels[r-1].ccMIDROW(e),h.log("DEBUG","MIDROW ("+p([t,e])+")"),!0}return!1},t.prototype.parsePAC=function(t,e){var r=null,i=null,a=(17<=t&&t<=23||25<=t&&t<=31)&&64<=e&&e<=127,n=(16===t||24===t)&&64<=e&&e<=95;if(!a&&!n)return!1;if(t===this.lastCmdA&&e===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=t<=23?1:2,i=64<=e&&e<=95?1===r?l[t]:d[t]:1===r?u[t]:f[t];var o=this.interpretPAC(i,e);return this.channels[r-1].setPAC(o),this.lastCmdA=t,this.lastCmdB=e,this.currChNr=r,!0},t.prototype.interpretPAC=function(t,e){var r=e,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.prototype.parseChars=function(t,e){var r=null,i=null,a=null;if(t>=25?(r=2,a=t-8):(r=1,a=t),17<=a&&a<=19){var o=e;o=17===a?e+80:18===a?e+112:e+144,h.log("INFO","Special char '"+n(o)+"' in channel "+r),i=[o]}else 32<=t&&t<=127&&(i=0===e?[t]:[t,e]);if(i){var s=p(i);h.log("DEBUG","Char codes = "+s.join(",")),this.lastCmdA=null,this.lastCmdB=null}return i},t.prototype.parseBackgroundAttributes=function(t,e){var r,i,a,n,o=(16===t||24===t)&&32<=e&&e<=47,s=(23===t||31===t)&&45<=e&&e<=47;return!(!o&&!s)&&(r={},16===t||24===t?(i=Math.floor((e-32)/2),r.background=c[i],e%2==1&&(r.background=r.background+"_semi")):45===e?r.background="transparent":(r.foreground="black",47===e&&(r.underline=!0)),a=t<24?1:2,n=this.channels[a-1],n.setBkgData(r),this.lastCmdA=null,this.lastCmdB=null,!0)},t.prototype.reset=function(){for(var t=0;t<this.channels.length;t++)this.channels[t]&&this.channels[t].reset();this.lastCmdA=null,this.lastCmdB=null},t.prototype.cueSplitAtTime=function(t){for(var e=0;e<this.channels.length;e++)this.channels[e]&&this.channels[e].cueSplitAtTime(t)},t}();e.default=T},function(t,e,r){"use strict";var i=r(15),a={newCue:function(t,e,r,a){for(var n,o,s,l,u,d=window.VTTCue||window.TextTrackCue,f=0;f<a.rows.length;f++)if(n=a.rows[f],s=!0,l=0,u="",!n.isEmpty()){for(var c=0;c<n.chars.length;c++)n.chars[c].uchar.match(/\s/)&&s?l++:(u+=n.chars[c].uchar,s=!1);n.cueStartTime=e,e===r&&(r+=1e-4),o=new d(e,r,(0,i.fixLineBreaks)(u.trim())),l>=16?l--:l++,navigator.userAgent.match(/Firefox\//)?o.line=f+1:o.line=f>7?f-2:f+1,o.align="left",o.position=Math.max(0,Math.min(100,l/32*100+(navigator.userAgent.match(/Firefox\//)?50:0))),t.addCue(o)}}};t.exports=a},function(t,e,r){"use strict";function i(t,e){return n.default.search(t,function(t){return t.cc<e?1:t.cc>e?-1:0})}Object.defineProperty(e,"__esModule",{value:!0}),e.findFragWithCC=i;var a=r(6),n=function(t){return t&&t.__esModule?t:{default:t}}(a)},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=r(54),n=function(t){return t&&t.__esModule?t:{default:t}}(a),o=function(){function t(e,r,a,o){i(this,t),this.hls=e,this.defaultEstimate_=o,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new n.default(r),this.fast_=new n.default(a)}return t.prototype.sample=function(t,e){t=Math.max(t,this.minDelayMs_);var r=8e3*e/t,i=t/1e3;this.fast_.sample(i,r),this.slow_.sample(i,r)},t.prototype.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},t.prototype.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.prototype.destroy=function(){},t}();e.default=o},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(e){i(this,t),this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=0,this.totalWeight_=0}return t.prototype.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},t.prototype.getTotalWeight=function(){return this.totalWeight_},t.prototype.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);return this.estimate_/t}return this.estimate_},t}();e.default=a},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){function t(t){return"string"==typeof t&&(!!n[t.toLowerCase()]&&t.toLowerCase())}function e(t){return"string"==typeof t&&(!!o[t.toLowerCase()]&&t.toLowerCase())}function r(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)t[i]=r[i]}return t}function i(i,n,o){var s=this,l=function(){if("undefined"!=typeof navigator)return/MSIE\s8\.0/.test(navigator.userAgent)}(),u={};l?s=document.createElement("custom"):u.enumerable=!0,s.hasBeenReset=!1;var d="",f=!1,c=i,h=n,p=o,g=null,v="",y=!0,m="auto",E="start",T=50,b="middle",R=50,_="middle";if(Object.defineProperty(s,"id",r({},u,{get:function(){return d},set:function(t){d=""+t}})),Object.defineProperty(s,"pauseOnExit",r({},u,{get:function(){return f},set:function(t){f=!!t}})),Object.defineProperty(s,"startTime",r({},u,{get:function(){return c},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");c=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",r({},u,{get:function(){return h},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");h=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",r({},u,{get:function(){return p},set:function(t){p=""+t,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",r({},u,{get:function(){return g},set:function(t){g=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",r({},u,{get:function(){return v},set:function(e){var r=t(e);if(!1===r)throw new SyntaxError("An invalid or illegal string was specified.");v=r,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",r({},u,{get:function(){return y},set:function(t){y=!!t,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",r({},u,{get:function(){return m},set:function(t){if("number"!=typeof t&&t!==a)throw new SyntaxError("An invalid number or illegal string was specified.");m=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",r({},u,{get:function(){return E},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");E=r,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",r({},u,{get:function(){return T},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");T=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",r({},u,{get:function(){return b},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");b=r,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",r({},u,{get:function(){return R},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");R=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",r({},u,{get:function(){return _},set:function(t){var r=e(t);if(!r)throw new SyntaxError("An invalid or illegal string was specified.");_=r,this.hasBeenReset=!0}})),s.displayState=void 0,l)return s}if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var a="auto",n={"":!0,lr:!0,rl:!0},o={start:!0,middle:!0,end:!0,left:!0,right:!0};return i.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},i}()},function(t,e,r){"use strict";var i=r(15),a=function(t){return t&&t.__esModule?t:{default:t}}(i),n=function(t,e,r){return t.substr(r||0,e.length)===e},o=function(t){var e=parseInt(t.substr(-3)),r=parseInt(t.substr(-6,2)),i=parseInt(t.substr(-9,2)),a=t.length>9?parseInt(t.substr(0,t.indexOf(":"))):0;return isNaN(e)||isNaN(r)||isNaN(i)||isNaN(a)?-1:(e+=1e3*r,e+=6e4*i,e+=36e5*a)},s=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return(e>>>0).toString()},l=function(t,e,r){var i=t[e],a=t[i.prevCC];if(!a||!a.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;a&&a.new;)t.ccOffset+=i.start-a.start,i.new=!1,i=a,a=t[i.prevCC];t.presentationOffset=r},u={parse:function(t,e,r,i,u,d){var f=/\r\n|\n\r|\n|\r/g,c=String.fromCharCode.apply(null,new Uint8Array(t)).trim().replace(f,"\n").split("\n"),h="00:00.000",p=0,g=0,v=0,y=[],m=void 0,E=!0,T=new a.default;T.oncue=function(t){var e=r[i],a=r.ccOffset;e&&e.new&&(void 0!==g?a=r.ccOffset=e.start:l(r,i,v)),v&&(a=v+r.ccOffset-r.presentationOffset),t.startTime+=a-g,t.endTime+=a-g,t.id=s(t.startTime)+s(t.endTime)+s(t.text),t.text=decodeURIComponent(escape(t.text)),t.endTime>0&&y.push(t)},T.onparsingerror=function(t){m=t},T.onflush=function(){if(m&&d)return void d(m);u(y)},c.forEach(function(t){if(E){if(n(t,"X-TIMESTAMP-MAP=")){E=!1,t.substr(16).split(",").forEach(function(t){n(t,"LOCAL:")?h=t.substr(6):n(t,"MPEGTS:")&&(p=parseInt(t.substr(7)))});try{e=e<0?e+8589934592:e,p-=e,g=o(h)/1e3,v=p/9e4,-1===g&&(m=new Error("Malformed X-TIMESTAMP-MAP: "+t))}catch(e){m=new Error("Malformed X-TIMESTAMP-MAP: "+t)}return}""===t&&(E=!1)}T.parse(t+"\n")}),T.flush()}};t.exports=u},function(t,e,r){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var a=r(0),n=function(){function t(e){i(this,t),e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}return t.prototype.destroy=function(){this.abort(),this.loader=null},t.prototype.abort=function(){var t=this.loader;t&&4!==t.readyState&&(this.stats.aborted=!0,t.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.prototype.load=function(t,e,r){this.context=t,this.config=e,this.callbacks=r,this.stats={trequest:performance.now(),retry:0},this.retryDelay=e.retryDelay,this.loadInternal()},t.prototype.loadInternal=function(){var t,e=this.context;t="undefined"!=typeof XDomainRequest?this.loader=new XDomainRequest:this.loader=new XMLHttpRequest;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(t,e.url)}catch(r){t.open("GET",e.url,!0),i(t,e.url)}t.readyState||t.open("GET",e.url,!0)}catch(r){return void this.callbacks.onError({code:t.status,text:r.message},e,t)}e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),t.send()},t.prototype.readystatechange=function(t){var e=t.currentTarget,r=e.readyState,i=this.stats,n=this.context,o=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(performance.now(),i.trequest)),4===r){var s=e.status;if(s>=200&&s<300){i.tload=Math.max(i.tfirst,performance.now());var l=void 0,u=void 0;"arraybuffer"===n.responseType?(l=e.response,u=l.byteLength):(l=e.responseText,u=l.length),i.loaded=i.total=u;var d={url:e.responseURL,data:l};this.callbacks.onSuccess(d,i,n,e)}else i.retry>=o.maxRetry||s>=400&&s<499?(a.logger.error(s+" while loading "+n.url),this.callbacks.onError({code:s,text:e.statusText},n,e)):(a.logger.warn(s+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,o.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),o.timeout)},t.prototype.loadtimeout=function(){a.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.prototype.loadprogress=function(t){var e=t.currentTarget,r=this.stats;r.loaded=t.loaded,t.lengthComputable&&(r.total=t.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,e)},t}();e.default=n},function(t,e,r){function i(t){function e(i){if(r[i])return r[i].exports;var a=r[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var r={};e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,i){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e.oe=function(t){throw console.error(t),t};var i=e(e.s=ENTRY_MODULE);return i.default||i}function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function n(t){var e=[],r=t.toString(),i=r.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!i)return e;for(var n,o=i[1],s=new RegExp("(\\\\n|\\W)"+a(o)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\w|/|@]+).*?\\)","g");n=s.exec(r);)e.push(n[3]);return e}function o(t,e){for(var r=[e],i=[],a={};r.length;){var o=r.pop();if(!a[o]&&t[o]){a[o]=!0,i.push(o);var s=n(t[o]);r=r.concat(s)}}return i}t.exports=function(t,e){e=e||{};var a=r.m,n=e.all?Object.keys(a):o(a,t),s="("+i.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+n.map(function(t){return JSON.stringify(t)+": "+a[t].toString()}).join(",")+"})(self);",l=new window.Blob([s],{type:"text/javascript"});if(e.bare)return l;var u=window.URL||window.webkitURL||window.mozURL||window.msURL,d=u.createObjectURL(l),f=new window.Worker(d);return f.objectURL=d,f}}])});