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