jellyfin-web/dashboard-ui/bower_components/hls.js/dist/hls.min.js
2016-03-18 13:28:45 -04:00

5 lines
117 KiB
JavaScript

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Hls=e()}}(function(){return function s(e,t,r){function a(n,d){if(!t[n]){if(!e[n]){var l="function"==typeof require&&require;if(!d&&l)return l(n,!0);if(i)return i(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var o=t[n]={exports:{}};e[n][0].call(o.exports,function(t){var r=e[n][1][t];return a(r?r:t)},o,o.exports,s,e,t,r)}return t[n].exports}for(var i="function"==typeof require&&require,n=0;n<r.length;n++)a(r[n]);return a}({1:[function(s,n,o){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function t(e){return"function"==typeof e}function i(e){return"number"==typeof e}function r(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}n.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},e.prototype.emit=function(l){var s,e,u,n,i,o;if(this._events||(this._events={}),"error"===l&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if(s=arguments[1],s instanceof Error)throw s;throw TypeError('Uncaught, unspecified "error" event.')}if(e=this._events[l],a(e))return!1;if(t(e))switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:n=Array.prototype.slice.call(arguments,1),e.apply(this,n)}else if(r(e))for(n=Array.prototype.slice.call(arguments,1),o=e.slice(),u=o.length,i=0;u>i;i++)o[i].apply(this,n);return!0},e.prototype.addListener=function(n,i){var s;if(!t(i))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",n,t(i.listener)?i.listener:i),this._events[n]?r(this._events[n])?this._events[n].push(i):this._events[n]=[this._events[n],i]:this._events[n]=i,r(this._events[n])&&!this._events[n].warned&&(s=a(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[n].length>s&&(this._events[n].warned=!0,"function"==typeof console.trace)),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(a,e){function r(){this.removeListener(a,r),n||(n=!0,e.apply(this,arguments))}if(!t(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(a,r),this},e.prototype.removeListener=function(n,a){var e,s,o,i;if(!t(a))throw TypeError("listener must be a function");if(!this._events||!this._events[n])return this;if(e=this._events[n],o=e.length,s=-1,e===a||t(e.listener)&&e.listener===a)delete this._events[n],this._events.removeListener&&this.emit("removeListener",n,a);else if(r(e)){for(i=o;i-- >0;)if(e[i]===a||e[i].listener&&e[i].listener===a){s=i;break}if(0>s)return this;1===e.length?(e.length=0,delete this._events[n]):e.splice(s,1),this._events.removeListener&&this.emit("removeListener",n,a)}return this},e.prototype.removeAllListeners=function(r){var a,e;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[r]&&delete this._events[r],this;if(0===arguments.length){for(a in this._events)"removeListener"!==a&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events={},this}if(e=this._events[r],t(e))this.removeListener(r,e);else if(e)for(;e.length;)this.removeListener(r,e[e.length-1]);return delete this._events[r],this},e.prototype.listeners=function(e){var r;return r=this._events&&this._events[e]?t(this._events[e])?[this._events[e]]:this._events[e].slice():[]},e.prototype.listenerCount=function(r){if(this._events){var e=this._events[r];if(t(e))return 1;if(e)return e.length}return 0},e.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(i,a,s){var n=arguments[3],e=arguments[4],r=arguments[5],t=JSON.stringify;a.exports=function(l){for(var a,s=Object.keys(r),i=0,d=s.length;d>i;i++){var o=s[i],u=r[o].exports;if(u===l||u.default===l){a=o;break}}if(!a){a=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var f={},i=0,d=s.length;d>i;i++){var o=s[i];f[o]=o}e[a]=[Function(["require","module","exports"],"("+l+")(self)"),f]}var h=Math.floor(Math.pow(16,8)*Math.random()).toString(16),c={};c[a]=a,e[h]=[Function(["require"],"var f = require("+t(a)+");(f.default ? f.default : f)(self);"),c];var g="("+n+")({"+Object.keys(e).map(function(r){return t(r)+":["+e[r][0]+","+t(e[r][1])+"]"}).join(",")+"},{},["+t(h)+"])",v=window.URL||window.webkitURL||window.mozURL||window.msURL;return new Worker(v.createObjectURL(new Blob([g],{type:"text/javascript"})))}},{}],3:[function(e,h,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 f(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)}var o=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(t,"__esModule",{value:!0});var l=e("../events"),u=r(l),d=e("../event-handler"),a=r(d),s=function(t){function e(r){n(this,e);var t=i(this,Object.getPrototypeOf(e).call(this,r,u.default.FRAG_LOAD_PROGRESS));return t.lastfetchlevel=0,t._autoLevelCapping=-1,t._nextAutoLevel=-1,t}return f(e,t),o(e,[{key:"destroy",value:function(){a.default.prototype.destroy.call(this)}},{key:"onFragLoadProgress",value:function(e){var t=e.stats;void 0===t.aborted&&1===e.frag.loadCounter&&(this.lastfetchduration=(performance.now()-t.trequest)/1e3,this.lastfetchlevel=e.frag.level,this.lastbw=8*t.loaded/this.lastfetchduration)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping=e}},{key:"nextAutoLevel",get:function(){var r,e,t,a=this.lastbw,n=this.hls;if(t=-1===this._autoLevelCapping?n.levels.length-1:this._autoLevelCapping,-1!==this._nextAutoLevel){var i=Math.min(this._nextAutoLevel,t);if(i!==this.lastfetchlevel)return i;this._nextAutoLevel=-1}for(e=0;t>=e;e++)if(r=e<=this.lastfetchlevel?.8*a:.7*a,r<n.levels[e].bitrate)return Math.max(0,e-1);return e-1},set:function(e){this._nextAutoLevel=e}}]),e}(a.default);t.default=s},{"../event-handler":20,"../events":21}],4:[function(a,g,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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 h(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)}var c=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(n,"__esModule",{value:!0});var l=a("../events"),e=i(l),d=a("../event-handler"),s=i(d),t=a("../utils/logger"),r=a("../errors"),o=function(n){function a(r){u(this,a);var t=f(this,Object.getPrototypeOf(a).call(this,r,e.default.MEDIA_ATTACHING,e.default.MEDIA_DETACHING,e.default.BUFFER_RESET,e.default.BUFFER_APPENDING,e.default.BUFFER_CODECS,e.default.BUFFER_EOS,e.default.BUFFER_FLUSHING));return t.onsbue=t.onSBUpdateEnd.bind(t),t.onsbe=t.onSBUpdateError.bind(t),t}return h(a,n),c(a,[{key:"destroy",value:function(){s.default.prototype.destroy.call(this)}},{key:"onMediaAttaching",value:function(t){var r=this.media=t.media,e=this.mediaSource=new MediaSource;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),e.addEventListener("sourceopen",this.onmso),e.addEventListener("sourceended",this.onmse),e.addEventListener("sourceclose",this.onmsc),r.src=URL.createObjectURL(e)}},{key:"onMediaDetaching",value:function(){var r=this.mediaSource;if(r){if("open"===r.readyState)try{r.endOfStream()}catch(e){t.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}r.removeEventListener("sourceopen",this.onmso),r.removeEventListener("sourceended",this.onmse),r.removeEventListener("sourceclose",this.onmsc),this.media.src="",this.media.removeAttribute("src"),this.mediaSource=null,this.media=null,this.pendingTracks=null,this.sourceBuffer=null}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(e.default.MEDIA_DETACHED)}},{key:"onMediaSourceOpen",value:function(){t.logger.log("media source opened"),this.hls.trigger(e.default.MEDIA_ATTACHED,{media:this.media}),this.mediaSource.removeEventListener("sourceopen",this.onmso);var r=this.pendingTracks;r&&(this.onBufferCodecs(r),this.pendingTracks=null,this.doAppending())}},{key:"onMediaSourceClose",value:function(){t.logger.log("media source closed")}},{key:"onMediaSourceEnded",value:function(){t.logger.log("media source ended")}},{key:"onSBUpdateEnd",value:function(){this._needsFlush&&this.doFlush(),this._needsEos&&this.onBufferEos(),this.hls.trigger(e.default.BUFFER_APPENDED),this.doAppending()}},{key:"onSBUpdateError",value:function(a){t.logger.error("sourceBuffer error:"+a),this.hls.trigger(e.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})}},{key:"onBufferReset",value:function(){var e=this.sourceBuffer;if(e){for(var r in e){var t=e[r];try{this.mediaSource.removeSourceBuffer(t),t.removeEventListener("updateend",this.onsbue),t.removeEventListener("error",this.onsbe)}catch(e){}}this.sourceBuffer=null}this.flushRange=[],this.appended=0}},{key:"onBufferCodecs",value:function(r){var a,n,e,s,i;if(!this.media)return void(this.pendingTracks=r);if(!this.sourceBuffer){var o={},l=this.mediaSource;for(n in r)e=r[n],s=e.levelCodec||e.codec,i=e.container+";codecs="+s,t.logger.log("creating sourceBuffer with mimeType:"+i),a=o[n]=l.addSourceBuffer(i),a.addEventListener("updateend",this.onsbue),a.addEventListener("error",this.onsbe);this.sourceBuffer=o}}},{key:"onBufferAppending",value:function(e){this.segments?this.segments.push(e):this.segments=[e],this.doAppending()}},{key:"onBufferAppendFail",value:function(a){t.logger.error("sourceBuffer error:"+a.event),this.hls.trigger(e.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1,frag:this.fragCurrent})}},{key:"onBufferEos",value:function(){var e=this.sourceBuffer,r=this.mediaSource;r&&"open"===r.readyState&&(e.audio&&e.audio.updating||e.video&&e.video.updating?this._needsEos=!0:(t.logger.log("all media data available, signal endOfStream() to MediaSource and stop loading fragment"),r.endOfStream(),this._needsEos=!1))}},{key:"onBufferFlushing",value:function(e){this.flushRange.push({start:e.startOffset,end:e.endOffset}),this.flushBufferCounter=0,this.doFlush()}},{key:"doFlush",value:function(){for(;this.flushRange.length;){var r=this.flushRange[0];if(!this.flushBuffer(r.start,r.end))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var a=0,t=this.sourceBuffer;if(t)for(var n in t)a+=t[n].buffered.length;this.appended=a,this.hls.trigger(e.default.BUFFER_FLUSHED)}}},{key:"doAppending",value:function(){var i=this.hls,s=this.sourceBuffer,n=this.segments;if(s){if(this.media.error)return n=[],void t.logger.error("trying to append although a media error occured, flush segment and abort");for(var l in s)if(s[l].updating)return;if(n.length){var o=n.shift();try{s[o.type].appendBuffer(o.data),this.appendError=0,this.appended++}catch(s){t.logger.error("error while trying to append buffer:"+s.message),n.unshift(o);var a={type:r.ErrorTypes.MEDIA_ERROR};if(22!==s.code){if(this.appendError?this.appendError++:this.appendError=1,a.details=r.ErrorDetails.BUFFER_APPEND_ERROR,a.frag=this.fragCurrent,this.appendError>i.config.appendErrorMaxRetry)return t.logger.log("fail "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),n=[],a.fatal=!0,void i.trigger(e.default.ERROR,a);a.fatal=!1,i.trigger(e.default.ERROR,a)}else n=[],a.details=r.ErrorDetails.BUFFER_FULL_ERROR,i.trigger(e.default.ERROR,a)}}}}},{key:"flushBuffer",value:function(l,s){var e,r,o,i,a,n;if(this.flushBufferCounter<this.appended&&this.sourceBuffer)for(var u in this.sourceBuffer){if(e=this.sourceBuffer[u],e.updating)return t.logger.warn("cannot flush, sb updating in progress"),!1;for(r=0;r<e.buffered.length;r++)if(o=e.buffered.start(r),i=e.buffered.end(r),-1!==navigator.userAgent.toLowerCase().indexOf("firefox")&&s===Number.POSITIVE_INFINITY?(a=l,n=s):(a=Math.max(o,l),n=Math.min(i,s)),Math.min(n,i)-a>.5)return this.flushBufferCounter++,t.logger.log("flush "+u+" ["+a+","+n+"], of ["+o+","+i+"], pos:"+this.media.currentTime),e.remove(a,n),!1}else t.logger.warn("abort flushing too many retries");return t.logger.log("buffer flushed"),!0}}]),a}(s.default);n.default=o},{"../errors":19,"../event-handler":20,"../events":21,"../utils/logger":34}],5:[function(a,g,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(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 s(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)}var c=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(n,"__esModule",{value:!0});var l=a("../events"),t=i(l),d=a("../event-handler"),f=i(d),r=a("../utils/logger"),e=a("../errors"),o=function(n){function a(r){u(this,a);var e=h(this,Object.getPrototypeOf(a).call(this,r,t.default.MANIFEST_LOADED,t.default.LEVEL_LOADED,t.default.ERROR));return e.ontick=e.tick.bind(e),e._manualLevel=e._autoLevelCapping=-1,e}return s(a,n),c(a,[{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this._manualLevel=-1}},{key:"startLoad",value:function(){this.canload=!0,this.timer&&this.tick()}},{key:"stopLoad",value:function(){this.canload=!1}},{key:"onManifestLoaded",value:function(l){var s,n,i=[],a=[],u={},d=!1,f=!1,o=this.hls;if(l.levels.forEach(function(e){e.videoCodec&&(d=!0),e.audioCodec&&(f=!0);var t=u[e.bitrate];void 0===t?(u[e.bitrate]=i.length,e.url=[e.url],e.urlId=0,i.push(e)):i[t].url.push(e.url)}),d&&f?i.forEach(function(e){e.videoCodec&&a.push(e)}):a=i,a=a.filter(function(e){var a=function(e){return MediaSource.isTypeSupported("audio/mp4;codecs="+e)},n=function(e){return MediaSource.isTypeSupported("video/mp4;codecs="+e)},t=e.audioCodec,r=e.videoCodec;return(!t||a(t))&&(!r||n(r))}),a.length){for(s=a[0].bitrate,a.sort(function(e,t){return e.bitrate-t.bitrate}),this._levels=a,n=0;n<a.length;n++)if(a[n].bitrate===s){this._firstLevel=n,r.logger.log("manifest loaded,"+a.length+" level(s) found, first bitrate:"+s);break}o.trigger(t.default.MANIFEST_PARSED,{levels:this._levels,firstLevel:this._firstLevel,stats:l.stats})}else o.trigger(t.default.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:o.url,reason:"no level with compatible codecs found in manifest"})}},{key:"setLevelInternal",value:function(a){if(a>=0&&a<this._levels.length){this.timer&&(clearInterval(this.timer),this.timer=null),this._level=a,r.logger.log("switching to level "+a),this.hls.trigger(t.default.LEVEL_SWITCH,{level:a});var n=this._levels[a];if(void 0===n.details||n.details.live===!0){r.logger.log("(re)loading playlist for level "+a);var i=n.urlId;this.hls.trigger(t.default.LEVEL_LOADING,{url:n.url[i],level:a,id:i})}}else this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.OTHER_ERROR,details:e.ErrorDetails.LEVEL_SWITCH_ERROR,level:a,fatal:!1,reason:"invalid level idx"})}},{key:"onError",value:function(n){if(!n.fatal){var i,t,a=n.details,s=this.hls;switch(a){case e.ErrorDetails.FRAG_LOAD_ERROR:case e.ErrorDetails.FRAG_LOAD_TIMEOUT:case e.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case e.ErrorDetails.KEY_LOAD_ERROR:case e.ErrorDetails.KEY_LOAD_TIMEOUT:i=n.frag.level;break;case e.ErrorDetails.LEVEL_LOAD_ERROR:case e.ErrorDetails.LEVEL_LOAD_TIMEOUT:i=n.level}if(void 0!==i)if(t=this._levels[i],t.urlId<t.url.length-1)t.urlId++,t.details=void 0,r.logger.warn("level controller,"+a+" for level "+i+": switching to redundant stream id "+t.urlId);else{var o=-1===this._manualLevel&&i;o?(r.logger.warn("level controller,"+a+": emergency switch-down for next fragment"),s.abrController.nextAutoLevel=0):t&&t.details&&t.details.live?r.logger.warn("level controller,"+a+" on live stream, discard"):a!==e.ErrorDetails.FRAG_LOAD_ERROR&&a!==e.ErrorDetails.FRAG_LOAD_TIMEOUT&&(r.logger.error("cannot recover "+a+" error"),this._level=void 0,this.timer&&(clearInterval(this.timer),this.timer=null),n.fatal=!0,s.trigger(event,n))}}}},{key:"onLevelLoaded",value:function(e){e.details.live&&!this.timer&&(this.timer=setInterval(this.ontick,1e3*e.details.targetduration)),!e.details.live&&this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"tick",value:function(){var e=this._level;if(void 0!==e&&this.canload){var r=this._levels[e],a=r.urlId;this.hls.trigger(t.default.LEVEL_LOADING,{url:r.url[a],level:e,id:a})}}},{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this._level},set:function(e){(this._level!==e||void 0===this._levels[e].details)&&this.setLevelInternal(e)}},{key:"manualLevel",get:function(){return this._manualLevel},set:function(e){this._manualLevel=e,-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){return void 0===this._startLevel?this._firstLevel:this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this._manualLevel?this._manualLevel:this.hls.abrController.nextAutoLevel},set:function(e){this.level=e,-1===this._manualLevel&&(this.hls.abrController.nextAutoLevel=e)}}]),a}(f.default);n.default=o},{"../errors":19,"../event-handler":20,"../events":21,"../utils/logger":34}],6:[function(n,_,o){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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 c(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)}var m=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(o,"__esModule",{value:!0});var E=n("../demux/demuxer"),u=i(E),d=n("../events"),r=i(d),h=n("../event-handler"),s=i(h),t=n("../utils/logger"),v=n("../utils/binary-search"),p=i(v),y=n("../helper/level-helper"),l=i(y),a=n("../errors"),e={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_LEVEL:"WAITING_LEVEL",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR"},b=function(i){function n(t){g(this,n);var e=f(this,Object.getPrototypeOf(n).call(this,t,r.default.MEDIA_ATTACHED,r.default.MEDIA_DETACHING,r.default.MANIFEST_LOADING,r.default.MANIFEST_PARSED,r.default.LEVEL_LOADED,r.default.KEY_LOADED,r.default.FRAG_LOADED,r.default.FRAG_PARSING_INIT_SEGMENT,r.default.FRAG_PARSING_DATA,r.default.FRAG_PARSED,r.default.ERROR,r.default.BUFFER_APPENDED,r.default.BUFFER_FLUSHED));return e.config=t.config,e.audioCodecSwap=!1,e.ticks=0,e.ontick=e.tick.bind(e),e}return c(n,i),m(n,[{key:"destroy",value:function(){this.stopLoad(),this.timer&&(clearInterval(this.timer),this.timer=null),s.default.prototype.destroy.call(this),this.state=e.STOPPED}},{key:"startLoad",value:function(){var n=arguments.length<=0||void 0===arguments[0]?0:arguments[0];if(this.levels){var r=this.media,a=this.lastCurrentTime;this.stopLoad(),this.demuxer=new u.default(this.hls),this.timer||(this.timer=setInterval(this.ontick,100)),this.level=-1,this.fragLoadError=0,r&&a?(t.logger.log("configure startPosition @"+a),this.lastPaused||(t.logger.log("resuming video"),r.play()),this.state=e.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:n,this.state=e.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else t.logger.warn("cannot start loading as manifest not parsed yet"),this.state=e.STOPPED}},{key:"stopLoad",value: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=e.STOPPED}},{key:"tick",value:function(){this.ticks++,1===this.ticks&&(this.doTick(),this.ticks>1&&setTimeout(this.tick,1),this.ticks=0)}},{key:"doTick",value:function(){var c,l,i,D=this,u=this.hls,s=u.config;switch(this.state){case e.ERROR:case e.PAUSED:break;case e.STARTING:this.startLevel=u.startLevel,-1===this.startLevel&&(this.startLevel=0,this.fragBitrateTest=!0),this.level=u.nextLoadLevel=this.startLevel,this.state=e.WAITING_LEVEL,this.loadedmetadata=!1;break;case e.IDLE:if(!this.media&&(this.startFragRequested||!s.startFragPrefetch))break;c=this.loadedmetadata?this.media.currentTime:this.nextLoadPosition,l=this.startFragRequested===!1?this.startLevel:u.nextLoadLevel;var g,k=this.bufferInfo(c,s.maxBufferHole),C=k.len,h=k.end,y=this.fragPrevious;if(this.levels[l].hasOwnProperty("bitrate")?(g=Math.max(8*s.maxBufferSize/this.levels[l].bitrate,s.maxBufferLength),g=Math.min(g,s.maxMaxBufferLength)):g=s.maxBufferLength,g>C){if(u.nextLoadLevel=l,this.level=l,i=this.levels[l].details,"undefined"==typeof i||i.live&&this.levelLastLoaded!==l){this.state=e.WAITING_LEVEL;break}var d=i.fragments,v=d.length,m=d[0].start,_=d[v-1].start+d[v-1].duration,n=void 0;if(i.live){var N=void 0!==s.liveMaxLatencyDuration?s.liveMaxLatencyDuration:s.liveMaxLatencyDurationCount*i.targetduration;if(h<Math.max(m,_-N)){var M=void 0!==s.liveSyncDuration?s.liveSyncDuration:s.liveSyncDurationCount*i.targetduration;this.seekAfterBuffered=m+Math.max(0,i.totalduration-M),t.logger.log("buffer end: "+h+" is located too far from the end of live sliding playlist, media position will be reseted to: "+this.seekAfterBuffered.toFixed(3)),h=this.seekAfterBuffered}if(this.startFragRequested&&!i.PTSKnown){if(y){var R=y.sn+1;R>=i.startSN&&R<=i.endSN&&(n=d[R-i.startSN],t.logger.log("live playlist, switching playlist, load frag with next SN: "+n.sn))}n||(n=d[Math.min(v-1,Math.round(v/2))],t.logger.log("live playlist, switching playlist, unknown, load middle frag : "+n.sn))}}else m>h&&(n=d[0]);if(n||!function(){var a=void 0,o=s.maxFragLookUpTolerance;_>h?(h>_-o&&(o=0),a=p.default.search(d,function(e){return e.start+e.duration-o<=h?1:e.start-o>h?-1:0})):a=d[v-1],a&&(n=a,m=a.start,y&&n.level===y.level&&n.sn===y.sn&&(n.sn<i.endSN?(n=d[n.sn+1-i.startSN],t.logger.log("SN just loaded, load next one: "+n.sn)):(i.live||(D.hls.trigger(r.default.BUFFER_EOS),D.state=e.ENDED),n=null)))}(),n)if(null!=n.decryptdata.uri&&null==n.decryptdata.key)t.logger.log("Loading key for "+n.sn+" of ["+i.startSN+" ,"+i.endSN+"],level "+l),this.state=e.KEY_LOADING,u.trigger(r.default.KEY_LOADING,{frag:n});else{if(t.logger.log("Loading "+n.sn+" of ["+i.startSN+" ,"+i.endSN+"],level "+l+", currentTime:"+c+",bufferEnd:"+h.toFixed(3)),n.autoLevel=u.autoLevelEnabled,this.levels.length>1&&(n.expectedLen=Math.round(n.duration*this.levels[l].bitrate/8),n.trequest=performance.now()),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,n.loadCounter){n.loadCounter++;var T=s.fragLoadingLoopThreshold;if(n.loadCounter>T&&Math.abs(this.fragLoadIdx-n.loadIdx)<T)return void u.trigger(r.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_LOOP_LOADING_ERROR,fatal:!1,frag:n})}else n.loadCounter=1;n.loadIdx=this.fragLoadIdx,this.fragCurrent=n,this.startFragRequested=!0,u.trigger(r.default.FRAG_LOADING,{frag:n}),this.state=e.FRAG_LOADING}}break;case e.WAITING_LEVEL:l=this.levels[this.level],l&&l.details&&(this.state=e.IDLE);break;case e.FRAG_LOADING:var A=this.media,o=this.fragCurrent;if(A&&(!A.paused||this.loadedmetadata===!1)&&o.autoLevel&&this.level&&this.levels.length>1){var w=performance.now()-o.trequest;if(w>500*o.duration){var P=Math.max(1,1e3*o.loaded/w);o.expectedLen<o.loaded&&(o.expectedLen=o.loaded),c=A.currentTime;var L=(o.expectedLen-o.loaded)/P,E=this.bufferInfo(c,s.maxBufferHole).end-c;if(E<2*o.duration&&L>E){var b=void 0,f=void 0;for(f=this.level-1;f>=0&&(b=o.duration*this.levels[f].bitrate/(6.4*P),t.logger.log("fragLoadedDelay/bufferStarvationDelay/fragLevelNextLoadedDelay["+f+"] :"+L.toFixed(1)+"/"+E.toFixed(1)+"/"+b.toFixed(1)),!(E>b));f--);L>b&&(f=Math.max(0,f),u.nextLoadLevel=f,t.logger.warn("loading too slow, abort fragment loading and switch to level "+f),o.loader.abort(),u.trigger(r.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:o}),this.state=e.IDLE)}}}break;case e.FRAG_LOADING_WAITING_RETRY:var I=performance.now(),O=this.retryDate,S=this.media,x=S&&S.seeking;(!O||I>=O||x)&&(t.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=e.IDLE);break;case e.PARSING:break;case e.PARSED:break;case e.ENDED:}this._checkBuffer(),this._checkFragmentChanged()}},{key:"bufferInfo",value:function(n,i){var r=this.media;if(r){var e,t=r.buffered,a=[];for(e=0;e<t.length;e++)a.push({start:t.start(e),end:t.end(e)});return this.bufferedInfo(a,n,i)}return{len:0,start:0,end:0,nextStart:void 0}}},{key:"bufferedInfo",value:function(r,a,s){var o,l,n,h,e,t=[];for(r.sort(function(e,t){var r=e.start-t.start;return r?r:t.end-e.end}),e=0;e<r.length;e++){var u=t.length;if(u){var d=t[u-1].end;r[e].start-d<s?r[e].end>d&&(t[u-1].end=r[e].end):t.push(r[e])}else t.push(r[e])}for(e=0,o=0,l=n=a;e<t.length;e++){var i=t[e].start,f=t[e].end;if(a+s>=i&&f>a)l=i,n=f,o=n-a;else if(i>a+s){h=i;break}}return{len:o,start:l,end:n,nextStart:h}}},{key:"getBufferRange",value:function(a){var e,t,r=this.bufferRange;if(r)for(e=r.length-1;e>=0;e--)if(t=r[e],a>=t.start&&a<=t.end)return t;return null}},{key:"followingBufferRange",value:function(e){return e?this.getBufferRange(e.end+.5):null}},{key:"isBuffered",value:function(r){for(var a=this.media,t=a.buffered,e=0;e<t.length;e++)if(r>=t.start(e)&&r<=t.end(e))return!0;return!1}},{key:"_checkFragmentChanged",value:function(){var t,e,a=this.media;if(a&&a.seeking===!1&&(e=a.currentTime,e>a.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=e),this.isBuffered(e)?t=this.getBufferRange(e):this.isBuffered(e+.1)&&(t=this.getBufferRange(e+.1)),t)){var n=t.frag;n!==this.fragPlaying&&(this.fragPlaying=n,this.hls.trigger(r.default.FRAG_CHANGED,{frag:n}))}}},{key:"immediateLevelSwitch",value:function(){t.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,this.previouslyPaused=this.media.paused,this.media.pause());var a=this.fragCurrent;a&&a.loader&&a.loader.abort(),this.fragCurrent=null,this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY}),this.state=e.PAUSED,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.tick()}},{key:"immediateLevelSwitchEnd",value:function(){this.immediateSwitch=!1,this.media.currentTime-=1e-4,this.previouslyPaused||this.media.play()}},{key:"nextLevelSwitch",value:function(){var n,a,t;if(a=this.getBufferRange(this.media.currentTime),a&&a.start>1&&(this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:0,endOffset:a.start-1}),this.state=e.PAUSED),this.media.paused)n=0;else{var o=this.hls.nextLoadLevel,l=this.levels[o],s=this.fragLastKbps;n=s&&this.fragCurrent?this.fragCurrent.duration*l.bitrate/(1e3*s)+1:0}if(t=this.getBufferRange(this.media.currentTime+n),t&&(t=this.followingBufferRange(t))){this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:t.start,endOffset:Number.POSITIVE_INFINITY}),this.state=e.PAUSED;var i=this.fragCurrent;i&&i.loader&&i.loader.abort(),this.fragCurrent=null,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold}}},{key:"onMediaAttached",value:function(t){var e=this.media=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),this.levels&&this.config.autoStartLoad&&this.hls.startLoad()}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(t.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var r=this.levels;r&&r.forEach(function(e){e.details&&e.details.fragments.forEach(function(e){e.loadCounter=void 0})}),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=null,this.loadedmetadata=!1,this.stopLoad()}},{key:"onMediaSeeking",value:function(){if(this.state===e.FRAG_LOADING){if(0===this.bufferInfo(this.media.currentTime,this.config.maxBufferHole).len){t.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load");var r=this.fragCurrent;r&&(r.loader&&r.loader.abort(),this.fragCurrent=null),this.fragPrevious=null,this.state=e.IDLE}}else this.state===e.ENDED&&(this.state=e.IDLE);this.media&&(this.lastCurrentTime=this.media.currentTime),void 0!==this.fragLoadIdx&&(this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold),this.tick()}},{key:"onMediaSeeked",value:function(){this.tick()}},{key:"onMediaEnded",value:function(){t.logger.log("media ended"),this.startPosition=this.lastCurrentTime=0}},{key:"onManifestLoading",value:function(){t.logger.log("trigger BUFFER_RESET"),this.hls.trigger(r.default.BUFFER_RESET),this.bufferRange=[],this.stalled=!1}},{key:"onManifestParsed",value:function(r){var e,a=!1,n=!1;r.levels.forEach(function(t){e=t.audioCodec,e&&(-1!==e.indexOf("mp4a.40.2")&&(a=!0),-1!==e.indexOf("mp4a.40.5")&&(n=!0))}),this.audioCodecSwitch=a&&n,this.audioCodecSwitch&&t.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),
this.levels=r.levels,this.startLevelLoaded=!1,this.startFragRequested=!1,this.config.autoStartLoad&&this.hls.startLoad()}},{key:"onLevelLoaded",value:function(s){var a=s.details,n=s.level,o=this.levels[n],u=a.totalduration,i=0;if(t.logger.log("level "+n+" loaded ["+a.startSN+","+a.endSN+"],duration:"+u),this.levelLastLoaded=n,a.live){var d=o.details;d?(l.default.mergeDetails(d,a),i=a.fragments[0].start,a.PTSKnown?t.logger.log("live playlist sliding:"+i.toFixed(3)):t.logger.log("live playlist - outdated PTS, unknown sliding")):(a.PTSKnown=!1,t.logger.log("live playlist - first load, unknown sliding"))}else a.PTSKnown=!1;if(o.details=a,this.hls.trigger(r.default.LEVEL_UPDATED,{details:a,level:n}),this.startFragRequested===!1){if(a.live){var f=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*a.targetduration;this.startPosition=Math.max(0,i+u-f)}this.nextLoadPosition=this.startPosition}this.state===e.WAITING_LEVEL&&(this.state=e.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===e.KEY_LOADING&&(this.state=e.IDLE,this.tick())}},{key:"onFragLoaded",value:function(n){var a=this.fragCurrent;if(this.state===e.FRAG_LOADING&&a&&n.frag.level===a.level&&n.frag.sn===a.sn)if(this.fragBitrateTest===!0)this.state=e.IDLE,this.fragBitrateTest=!1,n.stats.tparsed=n.stats.tbuffered=performance.now(),this.hls.trigger(r.default.FRAG_BUFFERED,{stats:n.stats,frag:a});else{this.state=e.PARSING,this.stats=n.stats;var s=this.levels[this.level],o=s.details,d=o.totalduration,f=a.start,l=a.level,u=a.sn,i=s.audioCodec||this.config.defaultAudioCodec;this.audioCodecSwap&&(t.logger.log("swapping playlist audio codec"),void 0===i&&(i=this.lastAudioCodec),i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),this.pendingAppending=0,t.logger.log("Demuxing "+u+" of ["+o.startSN+" ,"+o.endSN+"],level "+l),this.demuxer.push(n.payload,i,s.videoCodec,f,a.cc,l,u,d,a.decryptdata)}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(l){if(this.state===e.PARSING){var o,a,n=l.tracks;if(a=n.audio){var i=this.levels[this.level].audioCodec,u=navigator.userAgent.toLowerCase();i&&this.audioCodecSwap&&(t.logger.log("swapping playlist audio codec"),i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==a.metadata.channelCount&&-1===u.indexOf("firefox")&&(i="mp4a.40.5"),-1!==u.indexOf("android")&&(i="mp4a.40.2",t.logger.log("Android: force audio codec to"+i)),a.levelCodec=i}if(a=n.video,a&&(a.levelCodec=this.levels[this.level].videoCodec),l.unique){var s={codec:"",levelCodec:""};for(o in l.tracks)a=n[o],s.container=a.container,s.codec&&(s.codec+=",",s.levelCodec+=","),a.codec&&(s.codec+=a.codec),a.levelCodec&&(s.levelCodec+=a.levelCodec);n={audiovideo:s}}this.hls.trigger(r.default.BUFFER_CODECS,n);for(o in n){a=n[o],t.logger.log("track:"+o+",container:"+a.container+",codecs[level/parsed]=["+a.levelCodec+"/"+a.codec+"]");var d=a.initSegment;d&&(this.pendingAppending++,this.hls.trigger(r.default.BUFFER_APPENDING,{type:o,data:d}))}this.tick()}}},{key:"onFragParsingData",value:function(a){var o=this;if(this.state===e.PARSING){this.tparse2=Date.now();var n=this.levels[this.level],i=this.fragCurrent;t.logger.log("parsed "+a.type+",PTS:["+a.startPTS.toFixed(3)+","+a.endPTS.toFixed(3)+"],DTS:["+a.startDTS.toFixed(3)+"/"+a.endDTS.toFixed(3)+"],nb:"+a.nb);var u=l.default.updateFragPTS(n.details,i.sn,a.startPTS,a.endPTS),s=this.hls;s.trigger(r.default.LEVEL_PTS_UPDATED,{details:n.details,level:this.level,drift:u}),[a.data1,a.data2].forEach(function(e){e&&(o.pendingAppending++,s.trigger(r.default.BUFFER_APPENDING,{type:a.type,data:e}))}),this.nextLoadPosition=a.endPTS,this.bufferRange.push({type:a.type,start:a.startPTS,end:a.endPTS,frag:i}),this.tick()}else t.logger.warn("not in PARSING state but "+this.state+", ignoring FRAG_PARSING_DATA event")}},{key:"onFragParsed",value:function(){this.state===e.PARSING&&(this.stats.tparsed=performance.now(),this.state=e.PARSED,this._checkAppendedParsed())}},{key:"onBufferAppended",value:function(){switch(this.state){case e.PARSING:case e.PARSED:this.pendingAppending--,this._checkAppendedParsed()}}},{key:"_checkAppendedParsed",value:function(){if(this.state===e.PARSED&&0===this.pendingAppending){var n=this.fragCurrent,a=this.stats;n&&(this.fragPrevious=n,a.tbuffered=performance.now(),this.fragLastKbps=Math.round(8*a.length/(a.tbuffered-a.tfirst)),this.hls.trigger(r.default.FRAG_BUFFERED,{stats:a,frag:n}),t.logger.log("media buffered : "+this.timeRangesToString(this.media.buffered)),this.state=e.IDLE),this.tick()}}},{key:"onError",value:function(n){switch(n.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:if(!n.fatal){var i=this.fragLoadError;if(i?i++:i=1,i<=this.config.fragLoadingMaxRetry){this.fragLoadError=i,n.frag.loadCounter=0;var s=Math.min(Math.pow(2,i-1)*this.config.fragLoadingRetryDelay,64e3);t.logger.warn("mediaController: frag loading failed, retry in "+s+" ms"),this.retryDate=performance.now()+s,this.state=e.FRAG_LOADING_WAITING_RETRY}else t.logger.error("mediaController: "+n.details+" reaches max retry, redispatch as fatal ..."),n.fatal=!0,this.hls.trigger(r.default.ERROR,n),this.state=e.ERROR}break;case a.ErrorDetails.FRAG_LOOP_LOADING_ERROR:case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:t.logger.warn("mediaController: "+n.details+" while loading frag,switch to "+(n.fatal?"ERROR":"IDLE")+" state ..."),this.state=n.fatal?e.ERROR:e.IDLE;break;case a.ErrorDetails.BUFFER_FULL_ERROR:this.config.maxMaxBufferLength/=2,t.logger.warn("reduce max buffer length to "+this.config.maxMaxBufferLength+"s and trigger a nextLevelSwitch to flush old buffer and fix QuotaExceededError"),this.nextLevelSwitch()}}},{key:"_checkBuffer",value:function(){var e=this.media;if(e){var d=e.readyState;if(d){var n,i,o=this.seekAfterBuffered;if(o)e.duration>=o&&(n=o,this.seekAfterBuffered=void 0);else{i=e.currentTime;var g=this.loadedmetadata;!g&&e.buffered.length&&(this.loadedmetadata=!0,i||i===this.startPosition||(n=this.startPosition))}n&&(i=n,t.logger.log("target seek position:"+n));var l=this.bufferInfo(i,0),c=!(e.paused||e.ended||e.seeking||2>d),u=.4,f=i>e.playbackRate*this.lastCurrentTime;if(this.stalled&&f&&(this.stalled=!1,t.logger.log("playback not stuck anymore @"+i)),l.len<=u){if(f||!c?u=0:this.stalled||(t.logger.log("playback seems stuck @"+i),this.hls.trigger(r.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1}),this.stalled=!0),l.len<=u){var s=l.nextStart,h=s-i;s&&h<this.config.maxSeekHole&&h>0&&!e.seeking&&(t.logger.log("adjust currentTime from "+e.currentTime+" to next buffered @ "+s),e.currentTime=s,this.hls.trigger(r.default.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1}))}}else n&&e.currentTime!==n&&(t.logger.log("adjust currentTime from "+e.currentTime+" to "+n),e.currentTime=n)}}}},{key:"onBufferFlushed",value:function(){var t,r,a=[];for(r=0;r<this.bufferRange.length;r++)t=this.bufferRange[r],this.isBuffered((t.start+t.end)/2)&&a.push(t);this.bufferRange=a,this.immediateSwitch&&this.immediateLevelSwitchEnd(),this.state=e.IDLE,this.fragPrevious=null}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"timeRangesToString",value:function(t){for(var r="",a=t.length,e=0;a>e;e++)r+="["+t.start(e)+","+t.end(e)+"]";return r}},{key:"currentLevel",get:function(){if(this.media){var e=this.getBufferRange(this.media.currentTime);if(e)return e.frag.level}return-1}},{key:"nextBufferRange",get:function(){return this.media?this.followingBufferRange(this.getBufferRange(this.media.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferRange;return e?e.frag.level:-1}}]),n}(s.default);o.default=b},{"../demux/demuxer":15,"../errors":19,"../event-handler":20,"../events":21,"../helper/level-helper":22,"../utils/binary-search":32,"../utils/logger":34}],7:[function(t,g,a){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(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 s(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)}var c=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(a,"__esModule",{value:!0});var l=t("../events"),e=r(l),d=t("../event-handler"),n=r(d),h=t("../utils/cea-708-interpreter"),o=r(h),u=function(r){function t(a){f(this,t);var r=i(this,Object.getPrototypeOf(t).call(this,a,e.default.MEDIA_ATTACHING,e.default.MEDIA_DETACHING,e.default.FRAG_PARSING_USERDATA,e.default.MANIFEST_LOADING,e.default.FRAG_LOADED));return r.hls=a,r.config=a.config,r.config.enableCEA708Captions&&(r.cea708Interpreter=new o.default),r}return s(t,r),c(t,[{key:"destroy",value:function(){n.default.prototype.destroy.call(this)}},{key:"onMediaAttaching",value:function(e){var t=this.media=e.media;this.cea708Interpreter.attach(t)}},{key:"onMediaDetaching",value:function(){this.cea708Interpreter.detach()}},{key:"onManifestLoading",value:function(){this.lastPts=Number.POSITIVE_INFINITY}},{key:"onFragLoaded",value:function(t){var e=t.frag.start;e<=this.lastPts&&this.cea708Interpreter.clear(),this.lastPts=e}},{key:"onFragParsingUserdata",value:function(t){for(var e=0;e<t.samples.length;e++)this.cea708Interpreter.push(t.samples[e].pts,t.samples[e].bytes)}}]),t}(n.default);a.default=u},{"../event-handler":20,"../events":21,"../utils/cea-708-interpreter":33}],8:[function(n,i,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function e(f){t(this,e),this._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],this._precompute();var a,s,r,o,l,i=this._tables[0][4],u=this._tables[1],n=f.length,d=1;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);for(o=f.slice(0),l=[],this._key=[o,l],a=n;4*n+28>a;a++)r=o[a-1],(a%n===0||8===n&&a%n===4)&&(r=i[r>>>24]<<24^i[r>>16&255]<<16^i[r>>8&255]<<8^i[255&r],a%n===0&&(r=r<<8^r>>>24^d<<24,d=d<<1^283*(d>>7))),o[a]=o[a-n]^r;for(s=0;a;s++,a--)r=o[3&s?a:a-4],4>=a||4>s?l[s]=r:l[s]=u[0][i[r>>>24]]^u[1][i[r>>16&255]]^u[2][i[r>>8&255]]^u[3][i[255&r]]}return r(e,[{key:"_precompute",value:function(){var e,a,r,u,f,d,t,s,l,i=this._tables[0],o=this._tables[1],h=i[4],g=o[4],n=[],c=[];for(e=0;256>e;e++)c[(n[e]=e<<1^283*(e>>7))^e]=e;for(a=r=0;!h[a];a^=u||1,r=c[r]||1)for(t=r^r<<1^r<<2^r<<3^r<<4,t=t>>8^255&t^99,h[a]=t,g[t]=a,d=n[f=n[u=n[a]]],l=16843009*d^65537*f^257*u^16843008*a,s=257*n[t]^16843008*t,e=0;4>e;e++)i[e][a]=s=s<<24^s>>>8,o[e][t]=l=l<<24^l>>>8;for(e=0;5>e;e++)i[e]=i[e].slice(0),o[e]=o[e].slice(0)}},{key:"decrypt",value:function(R,p,_,b,E,m){var h,v,g,i,e=this._key[1],t=R^e[0],a=b^e[1],n=_^e[2],r=p^e[3],y=e.length/4-2,s=4,o=this._tables[1],f=o[0],d=o[1],u=o[2],l=o[3],c=o[4];for(i=0;y>i;i++)h=f[t>>>24]^d[a>>16&255]^u[n>>8&255]^l[255&r]^e[s],v=f[a>>>24]^d[n>>16&255]^u[r>>8&255]^l[255&t]^e[s+1],g=f[n>>>24]^d[r>>16&255]^u[t>>8&255]^l[255&a]^e[s+2],r=f[r>>>24]^d[t>>16&255]^u[a>>8&255]^l[255&n]^e[s+3],s+=4,t=h,a=v,n=g;for(i=0;4>i;i++)E[(3&-i)+m]=c[t>>>24]<<24^c[a>>16&255]<<16^c[n>>8&255]<<8^c[255&r]^e[s++],h=t,t=a,a=n,n=r,r=h}}]),e}();e.default=a},{}],9:[function(t,l,e){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(e,"__esModule",{value:!0});var i=t("./aes"),s=r(i),o=function(){function e(t,r){a(this,e),this.key=t,this.iv=r}return n(e,[{key:"ntoh",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"doDecrypt",value:function(a,v,n){var u,h,o,f,l,c,d,i,e,r=new Int32Array(a.buffer,a.byteOffset,a.byteLength>>2),p=new s.default(Array.prototype.slice.call(v)),g=new Uint8Array(a.byteLength),t=new Int32Array(g.buffer);for(u=~~n[0],h=~~n[1],o=~~n[2],f=~~n[3],e=0;e<r.length;e+=4)l=~~this.ntoh(r[e]),c=~~this.ntoh(r[e+1]),d=~~this.ntoh(r[e+2]),i=~~this.ntoh(r[e+3]),p.decrypt(l,c,d,i,t,e),t[e]=this.ntoh(t[e]^u),t[e+1]=this.ntoh(t[e+1]^h),t[e+2]=this.ntoh(t[e+2]^o),t[e+3]=this.ntoh(t[e+3]^f),u=l,h=c,o=d,f=i;return g}},{key:"localDecrypt",value:function(e,t,r,a){var n=this.doDecrypt(e,t,r);a.set(n,e.byteOffset)}},{key:"decrypt",value:function(i){var r=32e3,t=new Int32Array(i),a=new Uint8Array(i.byteLength),e=0,s=this.key,n=this.iv;for(this.localDecrypt(t.subarray(e,e+r),s,n,a),e=r;e<t.length;e+=r)n=new Uint32Array([this.ntoh(t[e-4]),this.ntoh(t[e-3]),this.ntoh(t[e-2]),this.ntoh(t[e-1])]),this.localDecrypt(t.subarray(e,e+r),s,n,a);return a}}]),e}();e.default=o},{"./aes":8}],10:[function(t,d,r){"use strict";function l(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var u=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(r,"__esModule",{value:!0});var s=t("./aes128-decrypter"),o=l(s),a=t("../errors"),e=t("../utils/logger"),i=function(){function t(r){n(this,t),this.hls=r;try{var e=window?window.crypto:crypto;this.subtle=e.subtle||e.webkitSubtle,this.disableWebCrypto=!this.subtle}catch(e){this.disableWebCrypto=!0}}return u(t,[{key:"destroy",value:function(){}},{key:"decrypt",value:function(e,t,r,a){this.disableWebCrypto&&this.hls.config.enableSoftwareAES?this.decryptBySoftware(e,t,r,a):this.decryptByWebCrypto(e,t,r,a)}},{key:"decryptByWebCrypto",value:function(t,r,a,n){var i=this;e.logger.log("decrypting by WebCrypto API"),this.subtle.importKey("raw",r,{name:"AES-CBC",length:128},!1,["decrypt"]).then(function(e){i.subtle.decrypt({name:"AES-CBC",iv:a.buffer},e,t).then(n).catch(function(e){i.onWebCryptoError(e,t,r,a,n)})}).catch(function(e){i.onWebCryptoError(e,t,r,a,n)})}},{key:"decryptBySoftware",value:function(r,a,n,i){e.logger.log("decrypting by JavaScript Implementation");var t=new DataView(a.buffer),s=new Uint32Array([t.getUint32(0),t.getUint32(4),t.getUint32(8),t.getUint32(12)]);t=new DataView(n.buffer);var l=new Uint32Array([t.getUint32(0),t.getUint32(4),t.getUint32(8),t.getUint32(12)]),u=new o.default(s,l);i(u.decrypt(r).buffer)}},{key:"onWebCryptoError",value:function(t,r,n,i,s){this.hls.config.enableSoftwareAES?(e.logger.log("disabling to use WebCrypto API"),this.disableWebCrypto=!0,this.decryptBySoftware(r,n,i,s)):(e.logger.error("decrypting error : "+t.message),this.hls.trigger(Event.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:t.message}))}}]),t}();r.default=i},{"../errors":19,"../utils/logger":34,"./aes128-decrypter":9}],11:[function(e,f,t){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(t,"__esModule",{value:!0});var d=e("./adts"),o=r(d),l=e("../utils/logger"),u=e("../demux/id3"),a=r(u),s=function(){function e(t,r){n(this,e),this.observer=t,this.remuxerClass=r,this.remuxer=new this.remuxerClass(t),this._aacTrack={container:"audio/adts",type:"audio",id:-1,sequenceNumber:0,samples:[],len:0}}return i(e,[{key:"push",value:function(t,p,R,m,_,b,E,y){var n,i,v,c,e,s,f,u,g,r=this._aacTrack,d=new a.default(t),h=90*d.timeStamp;for(e=d.length,u=t.length;u-1>e&&(255!==t[e]||240!==(240&t[e+1]));e++);for(r.audiosamplerate||(n=o.default.getAudioConfig(this.observer,t,e,p),r.config=n.config,r.audiosamplerate=n.samplerate,r.channelCount=n.channelCount,r.codec=n.codec,r.duration=y,l.logger.log("parsed codec:"+r.codec+",rate:"+n.samplerate+",nb channel:"+n.channelCount)),c=0,v=9216e4/r.audiosamplerate;u>e+5&&(s=1&t[e+1]?7:9,i=(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5,i-=s,i>0&&u>=e+s+i);)for(f=h+c*v,g={unit:t.subarray(e+s,e+s+i),pts:f,dts:f},r.samples.push(g),r.len+=i,e+=i+s,c++;u-1>e&&(255!==t[e]||240!==(240&t[e+1]));e++);this.remuxer.remux(this._aacTrack,{samples:[]},{samples:[{pts:h,dts:h,unit:d.payload}]},{samples:[]},m)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(t){var e,r,n=new a.default(t);if(n.hasTimeStamp)for(e=n.length,r=t.length;r-1>e;e++)if(255===t[e]&&240===(240&t[e+1]))return!0;return!1}}]),e}();t.default=s},{"../demux/id3":17,"../utils/logger":34,"./adts":12}],12:[function(e,o,t){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(t,"__esModule",{value:!0});var i=e("../utils/logger"),r=e("../errors"),s=function(){function e(){a(this,e)}return n(e,null,[{key:"getAudioConfig",value:function(h,u,l,n){var a,e,s,o,t,f=navigator.userAgent.toLowerCase(),d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];return a=((192&u[l+2])>>>6)+1,e=(60&u[l+2])>>>2,e>d.length-1?void h.trigger(Event.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+e}):(o=(1&u[l+2])<<2,o|=(192&u[l+3])>>>6,i.logger.log("manifest codec:"+n+",ADTS data:type:"+a+",sampleingIndex:"+e+"["+d[e]+"Hz],channelConfig:"+o),-1!==f.indexOf("firefox")?e>=6?(a=5,t=new Array(4),s=e-3):(a=2,t=new Array(2),s=e):-1!==f.indexOf("android")?(a=2,t=new Array(2),s=e):(a=5,t=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&e>=6?s=e-3:((n&&-1!==n.indexOf("mp4a.40.2")&&e>=6&&1===o||!n&&1===o)&&(a=2,t=new Array(2)),s=e)),t[0]=a<<3,t[0]|=(14&e)>>1,t[1]|=(1&e)<<7,t[1]|=o<<3,5===a&&(t[1]|=(14&s)>>1,t[2]=(1&s)<<7,t[2]|=8,t[3]=0),{config:t,samplerate:d[e],channelCount:o,codec:"mp4a.40."+a})}}]),e}();t.default=s},{"../errors":19,"../utils/logger":34}],13:[function(e,y,a){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var h=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(a,"__esModule",{value:!0});var g=e("../events"),o=t(g),n=e("../errors"),p=e("../demux/aacdemuxer"),i=t(p),f=e("../demux/tsdemuxer"),r=t(f),c=e("../remux/mp4-remuxer"),s=t(c),v=e("../remux/passthrough-remuxer"),u=t(v),l=function(){function e(t,r){d(this,e),this.hls=t,this.typeSupported=r}return h(e,[{key:"destroy",value:function(){var e=this.demuxer;e&&e.destroy()}},{key:"push",value:function(a,l,d,f,h,c,g,v){var e=this.demuxer;if(!e){var t=this.hls;if(r.default.probe(a))e=this.typeSupported.mp2t===!0?new r.default(t,u.default):new r.default(t,s.default);else{if(!i.default.probe(a))return void t.trigger(o.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});e=new i.default(t,s.default)}this.demuxer=e}e.push(a,l,d,f,h,c,g,v)}}]),e}();a.default=l},{"../demux/aacdemuxer":11,"../demux/tsdemuxer":18,"../errors":19,"../events":21,"../remux/mp4-remuxer":29,"../remux/passthrough-remuxer":30}],14:[function(t,d,a){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(a,"__esModule",{value:!0});var n=t("../demux/demuxer-inline"),u=r(n),s=t("../events"),e=r(s),l=t("events"),i=r(l),o=function(r){var t=new i.default;t.trigger=function(a){for(var r=arguments.length,n=Array(r>1?r-1:0),e=1;r>e;e++)n[e-1]=arguments[e];t.emit.apply(t,[a,a].concat(n))},t.off=function(n){for(var r=arguments.length,a=Array(r>1?r-1:0),e=1;r>e;e++)a[e-1]=arguments[e];t.removeListener.apply(t,[n].concat(a))},r.addEventListener("message",function(a){var e=a.data;switch(e.cmd){case"init":r.demuxer=new u.default(t,e.typeSupported);break;case"demux":r.demuxer.push(new Uint8Array(e.data),e.audioCodec,e.videoCodec,e.timeOffset,e.cc,e.level,e.sn,e.duration)}}),t.on(e.default.FRAG_PARSING_INIT_SEGMENT,function(t,e){r.postMessage({event:t,tracks:e.tracks,unique:e.unique})}),t.on(e.default.FRAG_PARSING_DATA,function(a,e){var t={event:a,type:e.type,startPTS:e.startPTS,endPTS:e.endPTS,startDTS:e.startDTS,endDTS:e.endDTS,data1:e.data1.buffer,data2:e.data2.buffer,nb:e.nb};r.postMessage(t,[t.data1,t.data2])}),t.on(e.default.FRAG_PARSED,function(e){r.postMessage({event:e})}),t.on(e.default.ERROR,function(e,t){r.postMessage({event:e,data:t})}),t.on(e.default.FRAG_PARSING_METADATA,function(e,t){var a={event:e,samples:t.samples};r.postMessage(a)}),t.on(e.default.FRAG_PARSING_USERDATA,function(e,t){var a={event:e,samples:t.samples};r.postMessage(a)})};a.default=o},{"../demux/demuxer-inline":13,"../events":21,events:1}],15:[function(t,v,a){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var h=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(a,"__esModule",{value:!0});var s=t("../events"),e=r(s),g=t("../demux/demuxer-inline"),n=r(g),d=t("../demux/demuxer-worker"),f=r(d),i=t("../utils/logger"),c=t("../crypt/decrypter"),l=r(c),o=function(){function r(e){u(this,r),this.hls=e;var a={mp4:MediaSource.isTypeSupported("video/mp4"),mp2t:e.config.enableMP2TPassThrough&&MediaSource.isTypeSupported("video/mp2t")};if(e.config.enableWorker&&"undefined"!=typeof Worker){i.logger.log("demuxing in webworker");try{var s=t("webworkify");this.w=s(f.default),this.onwmsg=this.onWorkerMessage.bind(this),this.w.addEventListener("message",this.onwmsg),this.w.postMessage({cmd:"init",typeSupported:a})}catch(t){i.logger.error("error while initializing DemuxerWorker, fallback on DemuxerInline"),this.demuxer=new n.default(e,a)}}else this.demuxer=new n.default(e,a);this.demuxInitialized=!0}return h(r,[{key:"destroy",value:function(){this.w?(this.w.removeEventListener("message",this.onwmsg),this.w.terminate(),this.w=null):(this.demuxer.destroy(),this.demuxer=null),this.decrypter&&(this.decrypter.destroy(),this.decrypter=null)}},{key:"pushDecrypted",value:function(e,t,r,a,n,i,s,o){this.w?this.w.postMessage({cmd:"demux",data:e,audioCodec:t,videoCodec:r,timeOffset:a,cc:n,level:i,sn:s,duration:o},[e]):this.demuxer.push(new Uint8Array(e),t,r,a,n,i,s,o)}},{key:"push",value:function(t,r,a,n,i,s,o,u,e){if(t.byteLength>0&&null!=e&&null!=e.key&&"AES-128"===e.method){null==this.decrypter&&(this.decrypter=new l.default(this.hls));var d=this;this.decrypter.decrypt(t,e.key,e.iv,function(e){d.pushDecrypted(e,r,a,n,i,s,o,u)})}else this.pushDecrypted(t,r,a,n,i,s,o,u)}},{key:"onWorkerMessage",value:function(a){var t=a.data;switch(t.event){case e.default.FRAG_PARSING_INIT_SEGMENT:var r={};r.tracks=t.tracks,r.unique=t.unique,this.hls.trigger(e.default.FRAG_PARSING_INIT_SEGMENT,r);break;case e.default.FRAG_PARSING_DATA:this.hls.trigger(e.default.FRAG_PARSING_DATA,{data1:new Uint8Array(t.data1),data2:new Uint8Array(t.data2),startPTS:t.startPTS,endPTS:t.endPTS,startDTS:t.startDTS,endDTS:t.endDTS,type:t.type,nb:t.nb});break;case e.default.FRAG_PARSING_METADATA:this.hls.trigger(e.default.FRAG_PARSING_METADATA,{samples:t.samples});break;case e.default.FRAG_PARSING_USERDATA:this.hls.trigger(e.default.FRAG_PARSING_USERDATA,{samples:t.samples});break;default:this.hls.trigger(t.event,t.data)}}}]),r}();a.default=o},{"../crypt/decrypter":10,"../demux/demuxer-inline":13,"../demux/demuxer-worker":14,"../events":21,"../utils/logger":34,webworkify:2}],16:[function(t,s,e){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(e,"__esModule",{value:!0});var n=t("../utils/logger"),i=function(){function e(t){r(this,e),this.data=t,this.bytesAvailable=this.data.byteLength,this.word=0,this.bitsAvailable=0}return a(e,[{key:"loadWord",value:function(){var t=this.data.byteLength-this.bytesAvailable,r=new Uint8Array(4),e=Math.min(4,this.bytesAvailable);if(0===e)throw new Error("no bytes available");r.set(this.data.subarray(t,t+e)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e}},{key:"skipBits",value:function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&n.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?r<<e|this.readBits(e):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!==(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}},{key:"skipScalingList",value:function(n){var t,a,r=8,e=8;for(t=0;n>t;t++)0!==e&&(a=this.readEG(),e=(r+a+256)%256),r=0===e?r:e}},{key:"readSPS",value:function(){var t,v,p,l,n,i,a,o,r,s=0,d=0,f=0,h=0,c=1;if(this.readUByte(),t=this.readUByte(),v=this.readBits(5),this.skipBits(3),p=this.readUByte(),this.skipUEG(),100===t||110===t||122===t||244===t||44===t||83===t||86===t||118===t||128===t){var g=this.readUEG();if(3===g&&this.skipBits(1),this.skipUEG(),this.skipUEG(),this.skipBits(1),this.readBoolean())for(o=3!==g?8:12,r=0;o>r;r++)this.readBoolean()&&(6>r?this.skipScalingList(16):this.skipScalingList(64))}this.skipUEG();var u=this.readUEG();if(0===u)this.readUEG();else if(1===u)for(this.skipBits(1),this.skipEG(),this.skipEG(),l=this.readUEG(),r=0;l>r;r++)this.skipEG();if(this.skipUEG(),this.skipBits(1),n=this.readUEG(),i=this.readUEG(),a=this.readBits(1),0===a&&this.skipBits(1),this.skipBits(1),this.readBoolean()&&(s=this.readUEG(),d=this.readUEG(),f=this.readUEG(),h=this.readUEG()),this.readBoolean()&&this.readBoolean()){var e=void 0,y=this.readUByte();switch(y){case 1:e=[1,1];break;case 2:e=[12,11];break;case 3:e=[10,11];break;case 4:e=[16,11];break;case 5:e=[40,33];break;case 6:e=[24,11];break;case 7:e=[20,11];break;case 8:e=[32,11];break;case 9:e=[80,33];break;case 10:e=[18,11];break;case 11:e=[15,11];break;case 12:e=[64,33];break;case 13:e=[160,99];break;case 14:e=[4,3];break;case 15:e=[3,2];break;case 16:e=[2,1];break;case 255:e=[this.readUByte()<<8|this.readUByte(),this.readUByte()<<8|this.readUByte()]}e&&(c=e[0]/e[1])}return{width:Math.ceil((16*(n+1)-2*s-2*d)*c),height:(2-a)*(i+1)*16-(a?2:4)*(f+h)}}},{key:"readSliceType",value:function(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),e}();e.default=i},{"../utils/logger":34}],17:[function(r,s,t){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(t,"__esModule",{value:!0});var e=r("../utils/logger"),i=function(){function t(n){a(this,t),this._hasTimeStamp=!1;for(var l,u,d,f,h,s,o,i,r=0;;)if(o=this.readUTF(n,r,3),r+=3,"ID3"===o)r+=3,l=127&n[r++],u=127&n[r++],d=127&n[r++],f=127&n[r++],h=(l<<21)+(u<<14)+(d<<7)+f,s=r+h,this._parseID3Frames(n,r,s),r=s;else{if("3DI"!==o)return r-=3,i=r,void(i&&(this.hasTimeStamp||e.logger.warn("ID3 tag found, but no timestamp"),this._length=i,this._payload=n.subarray(0,i)));r+=7,e.logger.log("3DI footer found, end: "+r)}}return n(t,[{key:"readUTF",value:function(a,e,n){var t="",r=e,i=e+n;do t+=String.fromCharCode(a[r++]);while(i>r);return t}},{key:"_parseID3Frames",value:function(r,t,i){for(var n,s,o,l,a;i>=t+8;)switch(n=this.readUTF(r,t,4),t+=4,s=r[t++]<<24+r[t++]<<16+r[t++]<<8+r[t++],l=r[t++]<<8+r[t++],o=t,n){case"PRIV":if("com.apple.streaming.transportStreamTimestamp"===this.readUTF(r,t,44)){t+=44,t+=4;var u=1&r[t++];this._hasTimeStamp=!0,a=((r[t++]<<23)+(r[t++]<<15)+(r[t++]<<7)+r[t++])/45,u&&(a+=47721858.84),a=Math.round(a),e.logger.trace("ID3 timestamp found: "+a),this._timeStamp=a}}}},{key:"hasTimeStamp",get:function(){return this._hasTimeStamp}},{key:"timeStamp",get:function(){return this._timeStamp}},{key:"length",get:function(){return this._length}},{key:"payload",get:function(){return this._payload}}]),t}();t.default=i},{"../utils/logger":34}],18:[function(t,g,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var f=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(n,"__esModule",{value:!0});var h=t("./adts"),c=a(h),l=t("../events"),i=a(l),d=t("./exp-golomb"),s=a(d),e=t("../utils/logger"),r=t("../errors"),o=function(){function t(e,r){u(this,t),this.observer=e,this.remuxerClass=r,this.lastCC=0,this.remuxer=new this.remuxerClass(e)}return f(t,[{key:"switchLevel",value:function(){this.pmtParsed=!1,this._pmtId=-1,this.lastAacPTS=null,this.aacOverFlow=null,this._avcTrack={container:"video/mp2t",type:"video",id:-1,sequenceNumber:0,samples:[],len:0,nbNalu:0},this._aacTrack={container:"video/mp2t",type:"audio",id:-1,sequenceNumber:0,
samples:[],len:0},this._id3Track={type:"id3",id:-1,sequenceNumber:0,samples:[],len:0},this._txtTrack={type:"text",id:-1,sequenceNumber:0,samples:[],len:0},this.remuxer.switchLevel()}},{key:"insertDiscontinuity",value:function(){this.switchLevel(),this.remuxer.insertDiscontinuity()}},{key:"push",value:function(a,R,L,_,p,m,E,A){var s,o,l,t,d,u,y,n,c=a.length,b=this.remuxer.passthrough;this.audioCodec=R,this.videoCodec=L,this.timeOffset=_,this._duration=A,this.contiguous=!1,p!==this.lastCC?(e.logger.log("discontinuity detected"),this.insertDiscontinuity(),this.lastCC=p):m!==this.lastLevel?(e.logger.log("level switch detected"),this.switchLevel(),this.lastLevel=m):E===this.lastSN+1&&(this.contiguous=!0),this.lastSN=E,this.contiguous||(this.aacOverFlow=null);var v=this.pmtParsed,h=this._avcTrack.id,f=this._aacTrack.id,g=this._id3Track.id;for(c-=c%188,t=0;c>t;t+=188)if(71===a[t]){if(d=!!(64&a[t+1]),u=((31&a[t+1])<<8)+a[t+2],y=(48&a[t+3])>>4,y>1){if(n=t+5+a[t+4],n===t+188)continue}else n=t+4;if(v)if(u===h){if(d){if(s&&(this._parseAVCPES(this._parsePES(s)),b&&this._avcTrack.codec&&(-1===f||this._aacTrack.codec)))return void this.remux(a);s={data:[],size:0}}s&&(s.data.push(a.subarray(n,t+188)),s.size+=t+188-n)}else if(u===f){if(d){if(o&&(this._parseAACPES(this._parsePES(o)),b&&this._aacTrack.codec&&(-1===h||this._avcTrack.codec)))return void this.remux(a);o={data:[],size:0}}o&&(o.data.push(a.subarray(n,t+188)),o.size+=t+188-n)}else u===g&&(d&&(l&&this._parseID3PES(this._parsePES(l)),l={data:[],size:0}),l&&(l.data.push(a.subarray(n,t+188)),l.size+=t+188-n));else d&&(n+=a[n]+1),0===u?this._parsePAT(a,n):u===this._pmtId&&(this._parsePMT(a,n),v=this.pmtParsed=!0,h=this._avcTrack.id,f=this._aacTrack.id,g=this._id3Track.id)}else this.observer.trigger(i.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});s&&this._parseAVCPES(this._parsePES(s)),o&&this._parseAACPES(this._parsePES(o)),l&&this._parseID3PES(this._parsePES(l)),this.remux(null)}},{key:"remux",value:function(e){this.remuxer.remux(this._aacTrack,this._avcTrack,this._id3Track,this._txtTrack,this.timeOffset,this.contiguous,e)}},{key:"destroy",value:function(){this.switchLevel(),this._initPTS=this._initDTS=void 0,this._duration=0}},{key:"_parsePAT",value:function(e,t){this._pmtId=(31&e[t+10])<<8|e[t+11]}},{key:"_parsePMT",value:function(r,t){var n,i,s,a;for(n=(15&r[t+1])<<8|r[t+2],i=t+3+n-4,s=(15&r[t+10])<<8|r[t+11],t+=12+s;i>t;){switch(a=(31&r[t+1])<<8|r[t+2],r[t]){case 15:this._aacTrack.id=a;break;case 21:this._id3Track.id=a;break;case 27:this._avcTrack.id=a;break;default:e.logger.log("unkown stream type:"+r[t])}t+=((15&r[t+3])<<8|r[t+4])+5}}},{key:"_parsePES",value:function(o){var e,i,h,d,u,l,a,r,t,f=0,s=o.data;if(e=s[0],h=(e[0]<<16)+(e[1]<<8)+e[2],1===h){for(d=(e[4]<<8)+e[5],i=e[7],192&i&&(a=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,a>4294967295&&(a-=8589934592),64&i?(r=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,r>4294967295&&(r-=8589934592)):r=a),u=e[8],t=u+9,o.size-=t,l=new Uint8Array(o.size);s.length;){e=s.shift();var n=e.byteLength;if(t){if(t>n){t-=n;continue}e=e.subarray(t),n-=t,t=0}l.set(e,f),f+=n}return{data:l,pts:a,dts:r,len:d}}return null}},{key:"_parseAVCPES",value:function(a){var t,p,i,l,y=this,r=this._avcTrack,u=r.samples,m=this._parseAVCNALu(a.data),d=[],o=!1,h=!1,c=0;if(0===m.length&&u.length>0){var g=u[u.length-1],f=g.units.units[g.units.units.length-1],v=new Uint8Array(f.data.byteLength+a.data.byteLength);v.set(f.data,0),v.set(a.data,f.data.byteLength),f.data=v,g.units.length+=a.data.byteLength,r.len+=a.data.byteLength}a.data=null;var n="";m.forEach(function(e){switch(e.type){case 1:i=!0,o&&(n+="NDR ");break;case 5:i=!0,o&&(n+="IDR "),h=!0;break;case 6:i=!0,o&&(n+="SEI "),t=new s.default(e.data),t.readUByte();var E=t.readUByte();if(4===E){var v=0;do v=t.readUByte();while(255===v);var R=t.readUByte();if(181===R){var _=t.readUShort();if(49===_){var A=t.readUInt();if(1195456820===A){var k=t.readUByte();if(3===k){var g=t.readUByte(),b=t.readUByte(),S=31&g,f=[g,b];for(l=0;S>l;l++)f.push(t.readUByte()),f.push(t.readUByte()),f.push(t.readUByte());y._txtTrack.samples.push({type:3,pts:a.pts,bytes:f})}}}}}break;case 7:if(i=!0,o&&(n+="SPS "),!r.sps){t=new s.default(e.data);var p=t.readSPS();r.width=p.width,r.height=p.height,r.sps=[e.data],r.duration=y._duration;var L=e.data.subarray(1,4),m="avc1.";for(l=0;3>l;l++){var u=L[l].toString(16);u.length<2&&(u="0"+u),m+=u}r.codec=m}break;case 8:i=!0,o&&(n+="PPS "),r.pps||(r.pps=[e.data]);break;case 9:i=!1,o&&(n+="AUD ");break;default:i=!1,n+="unknown NAL "+e.type+" "}i&&(d.push(e),c+=e.data.byteLength)}),(o||n.length)&&e.logger.log(n),d.length&&(h===!0||r.sps)&&(p={units:{units:d,length:c},pts:a.pts,dts:a.dts,key:h},u.push(p),r.len+=c,r.nbNalu+=d.length)}},{key:"_parseAVCNALu",value:function(r){for(var i,a,s,p,n,l,t=0,h=r.byteLength,e=0,d=[];h>t;)switch(i=r[t++],e){case 0:0===i&&(e=1);break;case 1:e=0===i?2:0;break;case 2:case 3:if(0===i)e=3;else if(1===i&&h>t){if(p=31&r[t],n)s={data:r.subarray(n,t-e-1),type:l},d.push(s);else if(a=t-e-1){var c=this._avcTrack,f=c.samples;if(f.length){var g=f[f.length-1],v=g.units.units,o=v[v.length-1],u=new Uint8Array(o.data.byteLength+a);u.set(o.data,0),u.set(r.subarray(0,a),o.data.byteLength),o.data=u,g.units.length+=a,c.len+=a}}n=t,l=p,e=0}else e=0}return n&&(s={data:r.subarray(n,h),type:l},d.push(s)),d}},{key:"_parseAACPES",value:function(R){var l,o,p,E,t,d,f,s,_,n=this._aacTrack,a=R.data,g=R.pts,k=0,L=this._duration,A=this.audioCodec,u=this.aacOverFlow,b=this.lastAacPTS;if(u){var m=new Uint8Array(u.byteLength+a.byteLength);m.set(u,0),m.set(a,u.byteLength),a=m}for(t=k,s=a.length;s-1>t&&(255!==a[t]||240!==(240&a[t+1]));t++);if(t){var y,h;if(s-1>t?(y="AAC PES did not start with ADTS header,offset:"+t,h=!1):(y="no ADTS header found in AAC PES",h=!0),this.observer.trigger(i.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:h,reason:y}),h)return}if(n.audiosamplerate||(l=c.default.getAudioConfig(this.observer,a,t,A),n.config=l.config,n.audiosamplerate=l.samplerate,n.channelCount=l.channelCount,n.codec=l.codec,n.duration=L,e.logger.log("parsed codec:"+n.codec+",rate:"+l.samplerate+",nb channel:"+l.channelCount)),E=0,p=9216e4/n.audiosamplerate,u&&b){var v=b+p;Math.abs(v-g)>1&&(e.logger.log("AAC: align PTS for overlapping frames by "+Math.round((v-g)/90)),g=v)}for(;s>t+5&&(d=1&a[t+1]?7:9,o=(3&a[t+3])<<11|a[t+4]<<3|(224&a[t+5])>>>5,o-=d,o>0&&s>=t+d+o);)for(f=g+E*p,_={unit:a.subarray(t+d,t+d+o),pts:f,dts:f},n.samples.push(_),n.len+=o,t+=o+d,E++;s-1>t&&(255!==a[t]||240!==(240&a[t+1]));t++);u=s>t?a.subarray(t,s):null,this.aacOverFlow=u,this.lastAacPTS=f}},{key:"_parseID3PES",value:function(e){this._id3Track.samples.push(e)}}],[{key:"probe",value:function(e){return e.length>=564&&71===e[0]&&71===e[188]&&71===e[376]?!0:!1}}]),t}();n.default=o},{"../errors":19,"../events":21,"../utils/logger":34,"./adts":12,"./exp-golomb":16}],19:[function(t,r,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",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",FRAG_LOAD_ERROR:"fragLoadError",FRAG_LOOP_LOADING_ERROR:"fragLoopLoadingError",FRAG_LOAD_TIMEOUT:"fragLoadTimeOut",FRAG_DECRYPT_ERROR:"fragDecryptError",FRAG_PARSING_ERROR:"fragParsingError",KEY_LOAD_ERROR:"keyLoadError",KEY_LOAD_TIMEOUT:"keyLoadTimeOut",BUFFER_APPEND_ERROR:"bufferAppendError",BUFFER_APPENDING_ERROR:"bufferAppendingError",BUFFER_STALLED_ERROR:"bufferStalledError",BUFFER_FULL_ERROR:"bufferFullError",BUFFER_SEEK_OVER_HOLE:"bufferSeekOverHole"}},{}],20:[function(i,s,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},a=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function e(i){t(this,e),this.hls=i,this.onEvent=this.onEvent.bind(this);for(var a=arguments.length,n=Array(a>1?a-1:0),r=1;a>r;r++)n[r-1]=arguments[r];this.handledEvents=n,this.useGenericHandler=!0,this.registerListeners()}return a(e,[{key:"destroy",value:function(){this.unregisterListeners()}},{key:"isEventHandler",value:function(){return"object"===r(this.handledEvents)&&this.handledEvents.length&&"function"==typeof this.onEvent}},{key:"registerListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){if("hlsEventGeneric"===e)throw new Error("Forbidden event name: "+e);this.hls.on(e,this.onEvent)}.bind(this))}},{key:"unregisterListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach(function(e){this.hls.off(e,this.onEvent)}.bind(this))}},{key:"onEvent",value:function(e,t){this.onEventGeneric(e,t)}},{key:"onEventGeneric",value:function(e,t){var r=function(t,r){var e="on"+t.replace("hls","");if("function"!=typeof this[e])throw new Error("Event "+t+" has no generic handler in this "+this.constructor.name+" class (tried "+e+")");return this[e].bind(this,r)};r.call(this,e,t).call()}}]),e}();e.default=n},{}],21:[function(t,e,r){"use strict";e.exports={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",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_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVEL_SWITCH:"hlsLevelSwitch",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",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",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded"}},{}],22:[function(r,s,t){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(t,"__esModule",{value:!0});var e=r("../utils/logger"),i=function(){function t(){a(this,t)}return n(t,null,[{key:"mergeDetails",value:function(i,a){var s,c=Math.max(i.startSN,a.startSN)-a.startSN,d=Math.min(i.endSN,a.endSN)-a.startSN,f=a.startSN-i.startSN,h=i.fragments,o=a.fragments,u=0;if(c>d)return void(a.PTSKnown=!1);for(var r=c;d>=r;r++){var l=h[f+r],n=o[r];u=l.cc-n.cc,isNaN(l.startPTS)||(n.start=n.startPTS=l.startPTS,n.endPTS=l.endPTS,n.duration=l.duration,s=n)}if(u)for(e.logger.log("discontinuity sliding from playlist, take drift into account"),r=0;r<o.length;r++)o[r].cc+=u;if(s)t.updateFragPTS(a,s.sn,s.startPTS,s.endPTS);else{var g=h[f].start;for(r=0;r<o.length;r++)o[r].start+=g}a.PTSKnown=i.PTSKnown}},{key:"updateFragPTS",value:function(a,l,n,s){var o,i,r,e;if(l<a.startSN||l>a.endSN)return 0;o=l-a.startSN,i=a.fragments,r=i[o],isNaN(r.startPTS)||(n=Math.min(n,r.startPTS),s=Math.max(s,r.endPTS));var u=n-r.start;for(r.start=r.startPTS=n,r.endPTS=s,r.duration=s-n,e=o;e>0;e--)t.updatePTS(i,e,e-1);for(e=o;e<i.length-1;e++)t.updatePTS(i,e,e+1);return a.PTSKnown=!0,u}},{key:"updatePTS",value:function(s,a,n){var t=s[a],r=s[n],i=r.startPTS;isNaN(i)?n>a?r.start=t.start+t.duration:r.start=t.start-r.duration:n>a?(t.duration=i-t.start,t.duration<0&&e.logger.error("negative duration computed for frag "+t.sn+",level "+t.level+", there should be some duration drift between playlist and fragment!")):(r.duration=t.start-i,r.duration<0&&e.logger.error("negative duration computed for frag "+r.sn+",level "+r.level+", there should be some duration drift between playlist and fragment!"))}}]),t}();t.default=i},{"../utils/logger":34}],23:[function(t,O,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(n,"__esModule",{value:!0});var A=t("./events"),a=r(A),s=t("./errors"),u=t("./loader/playlist-loader"),d=r(u),f=t("./loader/fragment-loader"),h=r(f),c=t("./controller/abr-controller"),g=r(c),D=t("./controller/buffer-controller"),p=r(D),y=t("./controller/stream-controller"),m=r(y),E=t("./controller/level-controller"),b=r(E),_=t("./controller/timeline-controller"),R=r(_),e=t("./utils/logger"),L=t("./utils/xhr-loader"),k=r(L),S=t("events"),T=r(S),w=t("./loader/key-loader"),v=r(w),l=function(){function t(){var r=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];o(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,e.enableLogs)(r.debug),this.config=r;var a=this.observer=new T.default;a.trigger=function(r){for(var t=arguments.length,n=Array(t>1?t-1:0),e=1;t>e;e++)n[e-1]=arguments[e];a.emit.apply(a,[r,r].concat(n))},a.off=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];a.removeListener.apply(a,[n].concat(r))},this.on=a.on.bind(a),this.off=a.off.bind(a),this.trigger=a.trigger.bind(a),this.playlistLoader=new d.default(this),this.fragmentLoader=new h.default(this),this.levelController=new b.default(this),this.abrController=new r.abrController(this),this.bufferController=new r.bufferController(this),this.streamController=new r.streamController(this),this.timelineController=new r.timelineController(this),this.keyLoader=new v.default(this)}return i(t,null,[{key:"isSupported",value:function(){return window.MediaSource&&window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')}},{key:"Events",get:function(){return a.default}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig||(t.defaultConfig={autoStartLoad:!0,debug:!1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,maxSeekHole:2,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,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingLoopThreshold:3,startFragPrefetch:!1,appendErrorMaxRetry:3,loader:k.default,fLoader:void 0,pLoader:void 0,abrController:g.default,bufferController:p.default,streamController:m.default,timelineController:R.default,enableCEA708Captions:!0,enableMP2TPassThrough:!1}),t.defaultConfig},set:function(e){t.defaultConfig=e}}]),i(t,[{key:"destroy",value:function(){e.logger.log("destroy"),this.trigger(a.default.DESTROYING),this.detachMedia(),this.playlistLoader.destroy(),this.fragmentLoader.destroy(),this.levelController.destroy(),this.bufferController.destroy(),this.streamController.destroy(),this.timelineController.destroy(),this.keyLoader.destroy(),this.url=null,this.observer.removeAllListeners()}},{key:"attachMedia",value:function(t){e.logger.log("attachMedia"),this.media=t,this.trigger(a.default.MEDIA_ATTACHING,{media:t})}},{key:"detachMedia",value:function(){e.logger.log("detachMedia"),this.trigger(a.default.MEDIA_DETACHING),this.media=null}},{key:"loadSource",value:function(t){e.logger.log("loadSource:"+t),this.url=t,this.trigger(a.default.MANIFEST_LOADING,{url:t})}},{key:"startLoad",value:function(){var t=arguments.length<=0||void 0===arguments[0]?0:arguments[0];e.logger.log("startLoad"),this.levelController.startLoad(),this.streamController.startLoad(t)}},{key:"stopLoad",value:function(){e.logger.log("stopLoad"),this.levelController.stopLoad(),this.streamController.stopLoad()}},{key:"swapAudioCodec",value:function(){e.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){e.logger.log("recoverMediaError");var t=this.media;this.detachMedia(),this.attachMedia(t)}},{key:"levels",get:function(){return this.levelController.levels}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){e.logger.log("set currentLevel:"+t),this.loadLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){e.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){e.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return this.levelController.firstLevel},set:function(t){e.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){e.logger.log("set startLevel:"+t),this.levelController.startLevel=t}},{key:"autoLevelCapping",get:function(){return this.abrController.autoLevelCapping},set:function(t){e.logger.log("set autoLevelCapping:"+t),this.abrController.autoLevelCapping=t}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}}]),t}();n.default=l},{"./controller/abr-controller":3,"./controller/buffer-controller":4,"./controller/level-controller":5,"./controller/stream-controller":6,"./controller/timeline-controller":7,"./errors":19,"./events":21,"./loader/fragment-loader":25,"./loader/key-loader":26,"./loader/playlist-loader":27,"./utils/logger":34,"./utils/xhr-loader":36,events:1}],24:[function(e,t,r){"use strict";t.exports=e("./hls.js").default},{"./hls.js":23}],25:[function(r,c,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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 s(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)}var h=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(a,"__esModule",{value:!0});var l=r("../events"),e=n(l),d=r("../event-handler"),i=n(d),t=r("../errors"),o=function(a){function r(t){return u(this,r),f(this,Object.getPrototypeOf(r).call(this,t,e.default.FRAG_LOADING))}return s(r,a),h(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),i.default.prototype.destroy.call(this)}},{key:"onFragLoading",value:function(r){var t=r.frag;this.frag=t,this.frag.loaded=0;var e=this.hls.config;t.loader=this.loader="undefined"!=typeof e.fLoader?new e.fLoader(e):new e.loader(e),this.loader.load(t.url,"arraybuffer",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),e.fragLoadingTimeOut,1,0,this.loadprogress.bind(this),t)}},{key:"loadsuccess",value:function(a,t){var r=a.currentTarget.response;t.length=r.byteLength,this.frag.loader=void 0,this.hls.trigger(e.default.FRAG_LOADED,{payload:r,frag:this.frag,stats:t})}},{key:"loaderror",value:function(r){this.loader&&this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:this.frag,response:r})}},{key:"loadtimeout",value:function(){this.loader&&this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:this.frag})}},{key:"loadprogress",value:function(r,t){this.frag.loaded=t.loaded,this.hls.trigger(e.default.FRAG_LOAD_PROGRESS,{frag:this.frag,stats:t})}}]),r}(i.default);a.default=o},{"../errors":19,"../event-handler":20,"../events":21}],26:[function(r,c,a){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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 s(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)}var h=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(a,"__esModule",{value:!0});var l=r("../events"),e=n(l),d=r("../event-handler"),i=n(d),t=r("../errors"),o=function(a){function r(a){u(this,r);var t=f(this,Object.getPrototypeOf(r).call(this,a,e.default.KEY_LOADING));return t.decryptkey=null,t.decrypturl=null,t}return s(r,a),h(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),i.default.prototype.destroy.call(this)}},{key:"onKeyLoading",value:function(i){var t=this.frag=i.frag,n=t.decryptdata,a=n.uri;if(a!==this.decrypturl||null===this.decryptkey){var r=this.hls.config;t.loader=this.loader=new r.loader(r),this.decrypturl=a,this.decryptkey=null,t.loader.load(a,"arraybuffer",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r.fragLoadingTimeOut,r.fragLoadingMaxRetry,r.fragLoadingRetryDelay,this.loadprogress.bind(this),t)}else this.decryptkey&&(n.key=this.decryptkey,this.hls.trigger(e.default.KEY_LOADED,{frag:t}))}},{key:"loadsuccess",value:function(r){var t=this.frag;this.decryptkey=t.decryptdata.key=new Uint8Array(r.currentTarget.response),t.loader=void 0,this.hls.trigger(e.default.KEY_LOADED,{frag:t})}},{key:"loaderror",value:function(r){this.loader&&this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:this.frag,response:r})}},{key:"loadtimeout",value:function(){this.loader&&this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:this.frag})}},{key:"loadprogress",value:function(){}}]),r}(i.default);a.default=o},{"../errors":19,"../event-handler":20,"../events":21}],27:[function(r,y,s){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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 h(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)}var o=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(s,"__esModule",{value:!0});var l=r("../events"),t=a(l),p=r("../event-handler"),i=a(p),e=r("../errors"),c=r("../utils/url"),g=a(c),v=r("../utils/attr-list"),n=a(v),u=function(a){function r(e){return d(this,r),f(this,Object.getPrototypeOf(r).call(this,e,t.default.MANIFEST_LOADING,t.default.LEVEL_LOADING))}return h(r,a),o(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),this.url=this.id=null,i.default.prototype.destroy.call(this)}},{key:"onManifestLoading",value:function(e){this.load(e.url,null)}},{key:"onLevelLoading",value:function(e){this.load(e.url,e.level,e.id)}},{key:"load",value:function(n,i,s){var t,r,a,e=this.hls.config;this.url=n,this.id=i,this.id2=s,null===this.id?(t=e.manifestLoadingMaxRetry,r=e.manifestLoadingTimeOut,a=e.manifestLoadingRetryDelay):(t=e.levelLoadingMaxRetry,r=e.levelLoadingTimeOut,a=e.levelLoadingRetryDelay),this.loader="undefined"!=typeof e.pLoader?new e.pLoader(e):new e.loader(e),this.loader.load(n,"",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r,t,a)}},{key:"resolve",value:function(e,t){return g.default.buildAbsoluteURL(t,e)}},{key:"parseMasterPlaylist",value:function(f,u){for(var l=[],a=void 0,d=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g;null!=(a=d.exec(f));){var e={},r=e.attrs=new n.default(a[1]);e.url=this.resolve(a[2],u);var s=r.decimalResolution("RESOLUTION");s&&(e.width=s.width,e.height=s.height),e.bitrate=r.decimalInteger("BANDWIDTH"),e.name=r.NAME;var t=r.CODECS;if(t){t=t.split(",");for(var o=0;o<t.length;o++){var i=t[o];-1!==i.indexOf("avc1")?e.videoCodec=this.avc1toavcoti(i):e.audioCodec=i}}l.push(e)}return l}},{key:"avc1toavcoti",value:function(r){var e,t=r.split(".");return t.length>2?(e=t.shift()+".",e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).substr(-4)):e=r,e}},{key:"cloneObj",value:function(e){return JSON.parse(JSON.stringify(e))}},{key:"parseLevelPlaylist",value:function(L,l,A){var e,b,s,i,v=0,o=0,a={url:l,fragments:[],live:!0,startSN:0},r={method:null,key:null,iv:null,uri:null},E=0,f=null,t=null;for(b=/(?:#EXT-X-(MEDIA-SEQUENCE):(\d+))|(?:#EXT-X-(TARGETDURATION):(\d+))|(?:#EXT-X-(KEY):(.*))|(?:#EXT(INF):([\d\.]+)[^\r\n]*([\r\n]+[^#|\r\n]+)?)|(?:#EXT-X-(BYTERANGE):([\d]+[@[\d]*)]*[\r\n]+([^#|\r\n]+)?|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(PROGRAM-DATE-TIME):(.*))/g;null!==(e=b.exec(L));)switch(e.shift(),e=e.filter(function(e){return void 0!==e}),e[0]){case"MEDIA-SEQUENCE":v=a.startSN=parseInt(e[1]);break;case"TARGETDURATION":a.targetduration=parseFloat(e[1]);break;case"ENDLIST":a.live=!1;break;case"DIS":E++;break;case"BYTERANGE":var c=e[1].split("@");i=1===c.length?s:parseInt(c[1]),s=parseInt(c[0])+i,t&&!t.url&&(t.byteRangeStartOffset=i,t.byteRangeEndOffset=s,t.url=this.resolve(e[2],l));break;case"INF":var g=parseFloat(e[1]);if(!isNaN(g)){var u,m=v++;if(r.method&&r.uri&&!r.iv){u=this.cloneObj(r);for(var y=new Uint8Array(16),d=12;16>d;d++)y[d]=m>>8*(15-d)&255;u.iv=y}else u=r;var k=e[2]?this.resolve(e[2],l):null;t={url:k,duration:g,start:o,sn:m,level:A,cc:E,byteRangeStartOffset:i,byteRangeEndOffset:s,decryptdata:u,programDateTime:f},a.fragments.push(t),o+=g,i=null,f=null}break;case"KEY":var R=e[1],p=new n.default(R),h=p.enumeratedString("METHOD"),_=p.URI,S=p.hexadecimalInteger("IV");h&&(r={method:null,key:null,iv:null,uri:null},_&&"AES-128"===h&&(r.method=h,r.uri=this.resolve(_,l),r.key=null,r.iv=S));break;case"PROGRAM-DATE-TIME":f=new Date(Date.parse(e[1]))}return t&&!t.url&&(a.fragments.pop(),o-=t.duration),a.totalduration=o,a.endSN=v-1,a}},{key:"loadsuccess",value:function(u,a){var s,o=u.currentTarget,i=o.responseText,r=o.responseURL,l=this.id,d=this.id2,n=this.hls;if(void 0===r&&(r=this.url),a.tload=performance.now(),a.mtime=new Date(o.getResponseHeader("Last-Modified")),0===i.indexOf("#EXTM3U"))if(i.indexOf("#EXTINF:")>0)if(null===this.id)n.trigger(t.default.MANIFEST_LOADED,{levels:[{url:r}],url:r,stats:a});else{var f=this.parseLevelPlaylist(i,r,l);a.tparsed=performance.now(),n.trigger(t.default.LEVEL_LOADED,{details:f,level:l,id:d,stats:a})}else s=this.parseMasterPlaylist(i,r),s.length?n.trigger(t.default.MANIFEST_LOADED,{levels:s,url:r,stats:a}):n.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:r,reason:"no level found in manifest"});else n.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:r,reason:"no EXTM3U delimiter"})}},{key:"loaderror",value:function(n){var r,a;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_ERROR,a=!0):(r=e.ErrorDetails.LEVEL_LOAD_ERROR,a=!1),this.loader&&this.loader.abort(),this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:r,fatal:a,url:this.url,loader:this.loader,response:n.currentTarget,level:this.id,id:this.id2})}},{key:"loadtimeout",value:function(){var r,a;null===this.id?(r=e.ErrorDetails.MANIFEST_LOAD_TIMEOUT,a=!0):(r=e.ErrorDetails.LEVEL_LOAD_TIMEOUT,a=!1),this.loader&&this.loader.abort(),this.hls.trigger(t.default.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:r,fatal:a,url:this.url,loader:this.loader,level:this.id,id:this.id2})}}]),r}(i.default);s.default=u},{"../errors":19,"../event-handler":20,"../events":21,"../utils/attr-list":31,"../utils/url":35}],28:[function(n,i,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function e(){t(this,e)}return r(e,null,[{key:"init",value:function(){e.types={avc1:[],avcC:[],btrt:[],
dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var t;for(t in e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var a=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]),n=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:a,audio:n};var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=s,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var r=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,r,l,r,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,i))}},{key:"box",value:function(n){for(var t,a=Array.prototype.slice.call(arguments,1),e=8,r=a.length,i=r;r--;)e+=a[r].byteLength;for(t=new Uint8Array(e),t[0]=e>>24&255,t[1]=e>>16&255,t[2]=e>>8&255,t[3]=255&e,t.set(n,4),r=0,e=8;i>r;r++)t.set(a[r],e),e+=a[r].byteLength;return t}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){return r*=t,e.box(e.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,a){return e.box(e.types.moof,e.mfhd(t),e.traf(a,r))}},{key:"moov",value:function(t){for(var r=t.length,a=[];r--;)a[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(a).concat(e.mvex(t)))}},{key:"mvex",value:function(r){for(var t=r.length,a=[];t--;)a[t]=e.trex(r[t]);return e.box.apply(null,[e.types.mvex].concat(a))}},{key:"mvhd",value:function(t,r){r*=t;var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24&255,r>>16&255,r>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,a)}},{key:"sdtp",value:function(i){var r,t,a=i.samples||[],n=new Uint8Array(4+a.length);for(t=0;t<a.length;t++)r=a[t].flags,n[t+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return e.box(e.types.sdtp,n)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r,n,i,a=[],s=[];for(r=0;r<t.sps.length;r++)n=t.sps[r],i=n.byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(n));for(r=0;r<t.pps.length;r++)n=t.pps[r],i=n.byteLength,s.push(i>>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(n));var u=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),o=t.width,l=t.height;return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,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]),u,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])))}},{key:"esds",value: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]))}},{key:"mp4a",value:function(t){var r=t.audiosamplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))}},{key:"stsd",value:function(t){return"audio"===t.type?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))}},{key:"tkhd",value:function(t){var r=t.id,a=t.duration*t.timescale,n=t.width,i=t.height;return e.box(e.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,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,i>>8&255,255&i,0,0]))}},{key:"traf",value:function(a,t){var n=e.sdtp(a),r=a.id;return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),e.box(e.types.tfdt,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t])),e.trun(a,n.length+16+16+8+16+8+8),n)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(r){var t=r.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(h,o){var a,n,i,s,t,l,d=h.samples||[],r=d.length,f=12+16*r,u=new Uint8Array(f);for(o+=8+f,u.set([0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,255&r,o>>>24&255,o>>>16&255,o>>>8&255,255&o],0),a=0;r>a;a++)n=d[a],i=n.duration,s=n.size,t=n.flags,l=n.cts,u.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,s>>>24&255,s>>>16&255,s>>>8&255,255&s,t.isLeading<<2|t.dependsOn,t.isDependedOn<<6|t.hasRedundancy<<4|t.paddingValue<<1|t.isNonSync,61440&t.degradPrio,15&t.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*a);return e.box(e.types.trun,u)}},{key:"initSegment",value:function(a){e.types||e.init();var t,r=e.moov(a);return t=new Uint8Array(e.FTYP.byteLength+r.byteLength),t.set(e.FTYP),t.set(r,e.FTYP.byteLength),t}}]),e}();e.default=a},{}],29:[function(a,h,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var l=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(n,"__esModule",{value:!0});var f=a("../events"),t=i(f),e=a("../utils/logger"),u=a("../remux/mp4-generator"),r=i(u),s=a("../errors"),d=function(){function a(e){o(this,a),this.observer=e,this.ISGenerated=!1,this.PES2MP4SCALEFACTOR=4,this.PES_TIMESCALE=9e4,this.MP4_TIMESCALE=this.PES_TIMESCALE/this.PES2MP4SCALEFACTOR}return l(a,[{key:"destroy",value:function(){}},{key:"insertDiscontinuity",value:function(){this._initPTS=this._initDTS=this.nextAacPts=this.nextAvcDts=void 0}},{key:"switchLevel",value:function(){this.ISGenerated=!1}},{key:"remux",value:function(r,a,n,i,e,s){this.ISGenerated||this.generateIS(r,a,e),a.samples.length&&this.remuxVideo(a,e,s),r.samples.length&&this.remuxAudio(r,e,s),n.samples.length&&this.remuxID3(n,e),i.samples.length&&this.remuxText(i,e),this.observer.trigger(t.default.FRAG_PARSED)}},{key:"generateIS",value:function(a,n,h){var i,o,c=this.observer,g=a.samples,d=n.samples,f=this.PES_TIMESCALE,l={},v={tracks:l,unique:!1},u=void 0===this._initPTS;u&&(i=o=1/0),a.config&&g.length&&(a.timescale=a.audiosamplerate,a.timescale*a.duration>Math.pow(2,32)&&!function(){var e=function r(t,e){return e?r(e,t%e):t};a.timescale=a.audiosamplerate/e(a.audiosamplerate,1024)}(),e.logger.log("audio mp4 timescale :"+a.timescale),l.audio={container:"audio/mp4",codec:a.codec,initSegment:r.default.initSegment([a]),metadata:{channelCount:a.channelCount}},u&&(i=o=g[0].pts-f*h)),n.sps&&n.pps&&d.length&&(n.timescale=this.MP4_TIMESCALE,l.video={container:"video/mp4",codec:n.codec,initSegment:r.default.initSegment([n]),metadata:{width:n.width,height:n.height}},u&&(i=Math.min(i,d[0].pts-f*h),o=Math.min(o,d[0].dts-f*h))),Object.keys(l)?(c.trigger(t.default.FRAG_PARSING_INIT_SEGMENT,v),this.ISGenerated=!0,u&&(this._initPTS=i,this._initDTS=o)):c.trigger(t.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(n,w,T){var L,s,p,A,f,d,S,k,R,g,_,v,o,a,l,E=8,c=this.PES_TIMESCALE,h=this.PES2MP4SCALEFACTOR,u=[];for(d=new Uint8Array(n.len+4*n.nbNalu+8),L=new DataView(d.buffer),L.setUint32(0,d.byteLength),d.set(r.default.types.mdat,4);n.samples.length;){for(s=n.samples.shift(),A=0;s.units.units.length;)f=s.units.units.shift(),L.setUint32(E,f.data.byteLength),E+=4,d.set(f.data,E),E+=f.data.byteLength,A+=4+f.data.byteLength;if(_=s.pts-this._initDTS,v=s.dts-this._initDTS,v=Math.min(_,v),void 0!==g){o=this._PTSNormalize(_,g),a=this._PTSNormalize(v,g);var m=(a-g)/h;0>=m&&(e.logger.log("invalid sample duration at PTS/DTS: "+s.pts+"/"+s.dts+":"+m),m=1),p.duration=m}else{var y=void 0,i=void 0;y=T?this.nextAvcDts:w*c,o=this._PTSNormalize(_,y),a=this._PTSNormalize(v,y),i=Math.round((a-y)/90),(T||Math.abs(i)<600)&&i&&(i>1?e.logger.log("AVC:"+i+" ms hole between fragments detected,filling it"):-1>i&&e.logger.log("AVC:"+-i+" ms overlapping between fragments detected"),a=y,o=Math.max(o-i,a),e.logger.log("Video/PTS/DTS adjusted: "+o+"/"+a+",delta:"+i)),k=Math.max(0,o),R=Math.max(0,a)}p={size:A,duration:0,cts:(o-a)/h,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0}},l=p.flags,s.key===!0?(l.dependsOn=2,l.isNonSync=0):(l.dependsOn=1,l.isNonSync=1),u.push(p),g=a}var b=0;u.length>=2&&(b=u[u.length-2].duration,p.duration=b),this.nextAvcDts=a+b*h,n.len=0,n.nbNalu=0,u.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1&&(l=u[0].flags,l.dependsOn=2,l.isNonSync=0),n.samples=u,S=r.default.moof(n.sequenceNumber++,R/h,n),n.samples=[],this.observer.trigger(t.default.FRAG_PARSING_DATA,{data1:S,data2:d,startPTS:k/c,endPTS:(o+h*b)/c,startDTS:R/c,endDTS:this.nextAvcDts/c,type:"video",nb:u.length})}},{key:"remuxAudio",value:function(a,D,T){var S,p,i,h,l,k,L,b,u,v,R,d,n,A=8,s=this.PES_TIMESCALE,w=a.timescale,f=s/w,E=1024*a.timescale/a.audiosamplerate,m=[],_=[];for(a.samples.sort(function(e,t){return e.pts-t.pts}),_=a.samples;_.length;){if(p=_.shift(),h=p.unit,v=p.pts-this._initDTS,R=p.dts-this._initDTS,void 0!==u)d=this._PTSNormalize(v,u),n=this._PTSNormalize(R,u),i.duration=(n-u)/f,Math.abs(i.duration-E)>E/10&&e.logger.log("invalid AAC sample duration at PTS "+Math.round(v/90)+",should be 1024,found :"+Math.round(i.duration*a.audiosamplerate/a.timescale)),i.duration=E,n=E*f+u;else{var c=void 0,o=void 0;if(c=T?this.nextAacPts:D*s,d=this._PTSNormalize(v,c),n=this._PTSNormalize(R,c),o=Math.round(1e3*(d-c)/s),(T||Math.abs(o)<600)&&o){if(o>0)e.logger.log(o+" ms hole between AAC samples detected,filling it");else if(-12>o){e.logger.log(-o+" ms overlapping between AAC samples detected, drop frame"),a.len-=h.byteLength;continue}d=n=c}if(L=Math.max(0,d),b=Math.max(0,n),!(a.len>0))return;l=new Uint8Array(a.len+8),S=new DataView(l.buffer),S.setUint32(0,l.byteLength),l.set(r.default.types.mdat,4)}l.set(h,A),A+=h.byteLength,i={size:h.byteLength,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},m.push(i),u=n}var y=0,g=m.length;g>=2&&(y=m[g-2].duration,i.duration=y),g&&(this.nextAacPts=d+f*y,a.len=0,a.samples=m,k=r.default.moof(a.sequenceNumber++,b/f,a),a.samples=[],this.observer.trigger(t.default.FRAG_PARSING_DATA,{data1:k,data2:l,startPTS:L/s,endPTS:this.nextAacPts/s,startDTS:b/s,endDTS:(n+f*y)/s,type:"audio",nb:g}))}},{key:"remuxID3",value:function(r,n){var e,i=r.samples.length;if(i){for(var a=0;i>a;a++)e=r.samples[a],e.pts=(e.pts-this._initPTS)/this.PES_TIMESCALE,e.dts=(e.dts-this._initDTS)/this.PES_TIMESCALE;this.observer.trigger(t.default.FRAG_PARSING_METADATA,{samples:r.samples})}r.samples=[],n=n}},{key:"remuxText",value:function(e,n){e.samples.sort(function(e,t){return e.pts-t.pts});var r,i=e.samples.length;if(i){for(var a=0;i>a;a++)r=e.samples[a],r.pts=(r.pts-this._initPTS)/this.PES_TIMESCALE;this.observer.trigger(t.default.FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[],n=n}},{key:"_PTSNormalize",value:function(e,t){var r;if(void 0===t)return e;for(r=e>t?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}},{key:"passthrough",get:function(){return!1}}]),a}();n.default=d},{"../errors":19,"../events":21,"../remux/mp4-generator":28,"../utils/logger":34}],30:[function(r,l,e){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(e,"__esModule",{value:!0});var s=r("../events"),t=a(s),o=function(){function e(t){n(this,e),this.observer=t,this.ISGenerated=!1}return i(e,[{key:"destroy",value:function(){}},{key:"insertDiscontinuity",value:function(){}},{key:"switchLevel",value:function(){this.ISGenerated=!1}},{key:"remux",value:function(o,s,f,d,n,u){var i=this.observer;if(!this.ISGenerated){var l={},a={tracks:l,unique:!0},e=s,r=e.codec;r&&(a.tracks.video={container:e.container,codec:r,metadata:{width:e.width,height:e.height}}),e=o,r=e.codec,r&&(a.tracks.audio={container:e.container,codec:r,metadata:{channelCount:e.channelCount}}),this.ISGenerated=!0,i.trigger(t.default.FRAG_PARSING_INIT_SEGMENT,a)}i.trigger(t.default.FRAG_PARSING_DATA,{data1:u,startPTS:n,startDTS:n,type:"audiovideo",nb:1})}},{key:"passthrough",get:function(){return!0}}]),e}();e.default=o},{"../events":21}],31:[function(n,i,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function e(r){t(this,e),"string"==typeof r&&(r=e.parseAttrList(r));for(var a in r)r.hasOwnProperty(a)&&(this[a]=r[a])}return r(e,[{key:"decimalInteger",value:function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}},{key:"hexadecimalInteger",value:function(r){if(this[r]){var e=(this[r]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var a=new Uint8Array(e.length/2),t=0;t<e.length/2;t++)a[t]=parseInt(e.slice(2*t,2*t+2),16);return a}return null}},{key:"hexadecimalIntegerAsNumber",value:function(t){var e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"decimalResolution",value:function(t){var e=/^(\d+)x(\d+)$/.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}}],[{key:"parseAttrList",value:function(n){for(var t,i=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,r={};null!==(t=i.exec(n));){var e=t[2],a='"';0===e.indexOf(a)&&e.lastIndexOf(a)===e.length-1&&(e=e.slice(1,-1)),r[t[1]]=e}return r}}]),e}();e.default=a},{}],32:[function(r,e,a){"use strict";var t={search:function(n,s){for(var t=0,r=n.length-1,e=null,a=null;r>=t;){e=(t+r)/2|0,a=n[e];var i=s(a);if(i>0)t=e+1;else{if(!(0>i))return a;r=e-1}}return null}};e.exports=t},{}],33:[function(n,i,e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function e(){t(this,e)}return r(e,[{key:"attach",value:function(e){this.media=e,this.display=[],this.memory=[]}},{key:"detach",value:function(){this.clear()}},{key:"destroy",value:function(){}},{key:"_createCue",value:function(){var t=window.VTTCue||window.TextTrackCue,e=this.cue=new t(-1,-1,"");e.text="",e.pauseOnExit=!1,e.startTime=Number.MAX_VALUE,e.endTime=Number.MAX_VALUE,this.memory.push(e)}},{key:"clear",value:function(){var e=this._textTrack;if(e&&e.cues)for(;e.cues.length>0;)e.removeCue(e.cues[0])}},{key:"push",value:function(r,a){this.cue||this._createCue();for(var n,t,e,s,o,u=31&a[0],i=2,l=0;u>l;l++)if(n=a[i++],t=127&a[i++],e=127&a[i++],s=0===(4&n)?!1:!0,o=3&n,(0!==t||0!==e)&&s&&0===o){if(32&t||64&t)this.cue.text+=this._fromCharCode(t)+this._fromCharCode(e);else if((17===t||25===t)&&e>=48&&63>=e)switch(e){case 48:this.cue.text+="®";break;case 49:this.cue.text+="°";break;case 50:this.cue.text+="½";break;case 51:this.cue.text+="¿";break;case 52:this.cue.text+="™";break;case 53:this.cue.text+="¢";break;case 54:this.cue.text+="";break;case 55:this.cue.text+="£";break;case 56:this.cue.text+="♪";break;case 57:this.cue.text+=" ";break;case 58:this.cue.text+="è";break;case 59:this.cue.text+="â";break;case 60:this.cue.text+="ê";break;case 61:this.cue.text+="î";break;case 62:this.cue.text+="ô";break;case 63:this.cue.text+="û"}if((17===t||25===t)&&e>=32&&47>=e)switch(e){case 32:break;case 33:break;case 34:break;case 35:break;case 36:break;case 37:break;case 38:break;case 39:break;case 40:break;case 41:break;case 42:break;case 43:break;case 44:break;case 45:break;case 46:break;case 47:}if((20===t||28===t)&&e>=32&&47>=e)switch(e){case 32:this._clearActiveCues(r);break;case 33:this.cue.text=this.cue.text.substr(0,this.cue.text.length-1);break;case 34:break;case 35:break;case 36:break;case 37:break;case 38:break;case 39:break;case 40:break;case 41:this._clearActiveCues(r);break;case 42:break;case 43:break;case 44:this._clearActiveCues(r);break;case 45:break;case 46:this._text="";break;case 47:this._flipMemory(r)}if((23===t||31===t)&&e>=33&&35>=e)switch(e){case 33:break;case 34:break;case 35:}}}},{key:"_fromCharCode",value:function(e){switch(e){case 42:return"á";case 2:return"á";case 2:return"é";case 4:return"í";case 5:return"ó";case 6:return"ú";case 3:return"ç";case 4:return"÷";case 5:return"Ñ";case 6:return"ñ";case 7:return"█";default:return String.fromCharCode(e)}}},{key:"_flipMemory",value:function(e){this._clearActiveCues(e),this._flushCaptions(e)}},{key:"_flushCaptions",value:function(s){this._has708||(this._textTrack=this.media.addTextTrack("captions","English","en"),this._has708=!0);var e=!0,a=!1,n=void 0;try{for(var i,t=this.memory[Symbol.iterator]();!(e=(i=t.next()).done);e=!0){var r=i.value;r.startTime=s,this._textTrack.addCue(r),this.display.push(r)}}catch(e){a=!0,n=e}finally{try{!e&&t.return&&t.return()}finally{if(a)throw n}}this.memory=[],this.cue=null}},{key:"_clearActiveCues",value:function(i){var e=!0,r=!1,a=void 0;try{for(var n,t=this.display[Symbol.iterator]();!(e=(n=t.next()).done);e=!0){var s=n.value;s.endTime=i}}catch(e){r=!0,a=e}finally{try{!e&&t.return&&t.return()}finally{if(r)throw a}}this.display=[]}},{key:"_clearBufferedCues",value:function(){}}]),e}();e.default=a},{}],34:[function(l,u,r){"use strict";function e(){}function n(t,e){return e="["+t+"] > "+e}function i(t){var r=window.console[t];return r?function(){for(var i=arguments.length,e=Array(i),a=0;i>a;a++)e[a]=arguments[a];e[0]&&(e[0]=n(t,e[0])),r.apply(window.console,e)}:e}function s(r){for(var a=arguments.length,n=Array(a>1?a-1:0),e=1;a>e;e++)n[e-1]=arguments[e];n.forEach(function(e){t[e]=r[e]?r[e].bind(r):i(e)})}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};Object.defineProperty(r,"__esModule",{value:!0});var a={trace:e,debug:e,log:e,warn:e,info:e,error:e},t=a;r.enableLogs=function(e){if(e===!0||"object"===("undefined"==typeof e?"undefined":o(e))){s(e,"debug","log","info","warn","error");try{t.log()}catch(e){t=a}}else t=a},r.logger=t},{}],35:[function(r,t,a){"use strict";var e={buildAbsoluteURL:function(r,t){if(t=t.trim(),/^[a-z]+:/i.test(t))return t;var o=null,n=null,i=/^([^#]*)(.*)$/.exec(t);i&&(n=i[2],t=i[1]);var s=/^([^\?]*)(.*)$/.exec(t);s&&(o=s[2],t=s[1]);var f=/^([^#]*)(.*)$/.exec(r);f&&(r=f[1]);var u=/^([^\?]*)(.*)$/.exec(r);u&&(r=u[1]);var l=/^((([a-z]+):)?\/\/[a-z0-9\.\-_~]+(:[0-9]+)?\/)(.*)$/i.exec(r),h=l[3],d=l[1],c=l[5],a=null;return a=/^\/\//.test(t)?h+"://"+e.buildAbsolutePath("",t.substring(2)):/^\//.test(t)?d+e.buildAbsolutePath("",t.substring(1)):e.buildAbsolutePath(d+c,t),o&&(a+=o),n&&(a+=n),a},buildAbsolutePath:function(i,s){for(var a,e,o=s,n="",t=i.replace(/[^\/]*$/,o.replace(/(\/|^)(?:\.?\/+)+/g,"$1")),r=0;e=t.indexOf("/../",r),e>-1;r=e+a)a=/^\/(?:\.\.\/)*/.exec(t.slice(e))[0].length,n=(n+t.substring(r,e)).replace(new RegExp("(?:\\/+[^\\/]*){0,"+(a-1)/3+"}$"),"/");return n+t.substr(r)}};t.exports=e},{}],36:[function(r,s,t){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(a,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(a,e.key,e)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();Object.defineProperty(t,"__esModule",{value:!0});var e=r("../utils/logger"),i=function(){function t(e){a(this,t),e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}return n(t,[{key:"destroy",value:function(){this.abort(),this.loader=null}},{key:"abort",value:function(){var e=this.loader,t=this.timeoutHandle;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),t&&window.clearTimeout(t)}},{key:"load",value:function(t,r,a,n,i,s,o,l){var u=arguments.length<=8||void 0===arguments[8]?null:arguments[8],e=arguments.length<=9||void 0===arguments[9]?null:arguments[9];this.url=t,!e||isNaN(e.byteRangeStartOffset)||isNaN(e.byteRangeEndOffset)||(this.byteRange=e.byteRangeStartOffset+"-"+(e.byteRangeEndOffset-1)),this.responseType=r,this.onSuccess=a,this.onProgress=u,this.onTimeout=i,this.onError=n,this.stats={trequest:performance.now(),retry:0},this.timeout=s,this.maxRetry=o,this.retryDelay=l,this.loadInternal()}},{key:"loadInternal",value:function(){var e;e="undefined"!=typeof XDomainRequest?this.loader=new XDomainRequest:this.loader=new XMLHttpRequest,e.onloadend=this.loadend.bind(this),e.onprogress=this.loadprogress.bind(this),e.open("GET",this.url,!0),this.byteRange&&e.setRequestHeader("Range","bytes="+this.byteRange),e.responseType=this.responseType,this.stats.tfirst=null,this.stats.loaded=0,this.xhrSetup&&this.xhrSetup(e,this.url),this.timeoutHandle=window.setTimeout(this.loadtimeout.bind(this),this.timeout),e.send()}},{key:"loadend",value:function(a){var n=a.currentTarget,r=n.status,t=this.stats;t.aborted||(r>=200&&300>r?(window.clearTimeout(this.timeoutHandle),t.tload=performance.now(),this.onSuccess(a,t)):t.retry<this.maxRetry?(e.logger.warn(r+" while loading "+this.url+", retrying in "+this.retryDelay+"..."),this.destroy(),window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,64e3),t.retry++):(window.clearTimeout(this.timeoutHandle),e.logger.error(r+" while loading "+this.url),this.onError(a)))}},{key:"loadtimeout",value:function(t){e.logger.warn("timeout while loading "+this.url),this.onTimeout(t,this.stats)}},{key:"loadprogress",value:function(t){var e=this.stats;null===e.tfirst&&(e.tfirst=performance.now()),e.loaded=t.loaded,this.onProgress&&this.onProgress(t,e)}}]),t}();t.default=i},{"../utils/logger":34}]},{},[24])(24)});