1 line
285 KiB
JavaScript
1 line
285 KiB
JavaScript
window.HlsJsPlayer=function(e){var t={};function r(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(a,i,function(t){return e[t]}.bind(null,i));return a},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=31)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.logger=t.enableLogs=void 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=r(5);function n(){}var o={trace:n,debug:n,log:n,warn:n,info:n,error:n},s=o;function l(e,t){return t="["+e+"] > "+t}var u=(0,i.getSelfScope)();function d(e){var t=u.console[e];return t?function(){for(var r=arguments.length,a=Array(r),i=0;i<r;i++)a[i]=arguments[i];a[0]&&(a[0]=l(e,a[0])),t.apply(u.console,a)}:n}t.enableLogs=function(e){if(!0===e||"object"===(void 0===e?"undefined":a(e))){!function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];r.forEach((function(t){s[t]=e[t]?e[t].bind(e):d(t)}))}(e,"debug","log","info","warn","error");try{s.log()}catch(e){s=o}}else s=o},t.logger=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={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_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",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"},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ErrorTypes={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",KEY_SYSTEM_ERROR:"keySystemError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},t.ErrorDetails={KEY_SYSTEM_NO_KEYS:"keySystemNoKeys",KEY_SYSTEM_NO_ACCESS:"keySystemNoAccess",KEY_SYSTEM_NO_SESSION:"keySystemNoSession",KEY_SYSTEM_LICENSE_REQUEST_FAILED:"keySystemLicenseRequestFailed",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_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"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i="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},n=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),o=r(0),s=r(2),l=r(1),u=(a=l)&&a.__esModule?a:{default:a};function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var f={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},c=function(){function e(t){d(this,e),this.hls=t,this.onEvent=this.onEvent.bind(this);for(var r=arguments.length,a=Array(r>1?r-1:0),i=1;i<r;i++)a[i-1]=arguments[i];this.handledEvents=a,this.useGenericHandler=!0,this.registerListeners()}return n(e,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.unregisterListeners(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){}},{key:"onHandlerDestroyed",value:function(){}},{key:"isEventHandler",value:function(){return"object"===i(this.handledEvents)&&this.handledEvents.length&&"function"==typeof this.onEvent}},{key:"registerListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach((function(e){if(f[e])throw new Error("Forbidden event-name: "+e);this.hls.on(e,this.onEvent)}),this)}},{key:"unregisterListeners",value:function(){this.isEventHandler()&&this.handledEvents.forEach((function(e){this.hls.off(e,this.onEvent)}),this)}},{key:"onEvent",value:function(e,t){this.onEventGeneric(e,t)}},{key:"onEventGeneric",value:function(e,t){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,e,t).call()}catch(t){o.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,err:t})}}}]),e}();t.default=c,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();t.BufferHelper=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return a(e,null,[{key:"isBuffered",value:function(e,t){try{if(e)for(var r=e.buffered,a=0;a<r.length;a++)if(t>=r.start(a)&&t<=r.end(a))return!0}catch(e){}return!1}},{key:"bufferInfo",value:function(e,t,r){try{if(e){var a=e.buffered,i=[],n=void 0;for(n=0;n<a.length;n++)i.push({start:a.start(n),end:a.end(n)});return this.bufferedInfo(i,t,r)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}}},{key:"bufferedInfo",value:function(e,t,r){var a=[],i=void 0,n=void 0,o=void 0,s=void 0,l=void 0;for(e.sort((function(e,t){var r=e.start-t.start;return r||t.end-e.end})),l=0;l<e.length;l++){var u=a.length;if(u){var d=a[u-1].end;e[l].start-d<r?e[l].end>d&&(a[u-1].end=e[l].end):a.push(e[l])}else a.push(e[l])}for(l=0,i=0,n=o=t;l<a.length;l++){var f=a[l].start,c=a[l].end;if(t+r>=f&&t<c)n=f,i=(o=c)-t;else if(t+r<f){s=f;break}}return{len:i,start:n,end:o,nextStart:s}}}]),e}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getSelfScope=function(){return"undefined"==typeof window?self:window}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FragmentTracker=t.FragmentState=void 0;var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=o(r(3)),n=o(r(1));function o(e){return e&&e.__esModule?e:{default:e}}var s=t.FragmentState={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};t.FragmentTracker=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n.default.BUFFER_APPENDED,n.default.FRAG_BUFFERED,n.default.FRAG_LOADED));return r.bufferPadding=.2,r.fragments=Object.create(null),r.timeRanges=Object.create(null),r.config=e.config,r}return 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)}(t,e),a(t,[{key:"destroy",value:function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,i.default.prototype.destroy.call(this),function e(t,r,a){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,a)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(a):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"getBufferedFrag",value:function(e,t){var r=this.fragments,a=Object.keys(r).filter((function(a){var i=r[a];if(i.body.type!==t)return!1;if(!i.buffered)return!1;var n=i.body;return n.startPTS<=e&&e<=n.endPTS}));if(0===a.length)return null;var i=a.pop();return r[i].body}},{key:"detectEvictedFragments",value:function(e,t){var r=this,a=void 0,i=void 0;Object.keys(this.fragments).forEach((function(n){var o=r.fragments[n];if(!0===o.buffered){var s=o.range[e];if(s){a=s.time;for(var l=0;l<a.length;l++)if(i=a[l],!1===r.isTimeBuffered(i.startPTS,i.endPTS,t)){r.removeFragment(o.body);break}}}}))}},{key:"detectPartialFragments",value:function(e){var t=this,r=this.getFragmentKey(e),a=this.fragments[r];a&&(a.buffered=!0,Object.keys(this.timeRanges).forEach((function(r){if(e.hasElementaryStream(r)){var i=t.timeRanges[r];a.range[r]=t.getBufferedTimes(e.startPTS,e.endPTS,i)}})))}},{key:"getBufferedTimes",value:function(e,t,r){for(var a=[],i=void 0,n=void 0,o=!1,s=0;s<r.length;s++){if(i=r.start(s)-this.bufferPadding,n=r.end(s)+this.bufferPadding,e>=i&&t<=n){a.push({startPTS:Math.max(e,r.start(s)),endPTS:Math.min(t,r.end(s))});break}if(e<n&&t>i)a.push({startPTS:Math.max(e,r.start(s)),endPTS:Math.min(t,r.end(s))}),o=!0;else if(t<=i)break}return{time:a,partial:o}}},{key:"getFragmentKey",value:function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},{key:"getPartialFragment",value:function(e){var t=this,r=void 0,a=void 0,i=void 0,n=null,o=0;return Object.keys(this.fragments).forEach((function(s){var l=t.fragments[s];t.isPartial(l)&&(a=l.body.startPTS-t.bufferPadding,i=l.body.endPTS+t.bufferPadding,e>=a&&e<=i&&(r=Math.min(e-a,i-e),o<=r&&(n=l.body,o=r)))})),n}},{key:"getState",value:function(e){var t=this.getFragmentKey(e),r=this.fragments[t],a=s.NOT_LOADED;return void 0!==r&&(a=r.buffered?!0===this.isPartial(r)?s.PARTIAL:s.OK:s.APPENDING),a}},{key:"isPartial",value:function(e){return!0===e.buffered&&(void 0!==e.range.video&&!0===e.range.video.partial||void 0!==e.range.audio&&!0===e.range.audio.partial)}},{key:"isTimeBuffered",value:function(e,t,r){for(var a=void 0,i=void 0,n=0;n<r.length;n++){if(a=r.start(n)-this.bufferPadding,i=r.end(n)+this.bufferPadding,e>=a&&t<=i)return!0;if(t<=a)return!1}return!1}},{key:"onFragLoaded",value:function(e){var t=e.frag;Number.isFinite(t.sn)&&!t.bitrateTest&&(this.fragments[this.getFragmentKey(t)]={body:t,range:Object.create(null),buffered:!1})}},{key:"onBufferAppended",value:function(e){var t=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach((function(e){var r=t.timeRanges[e];t.detectEvictedFragments(e,r)}))}},{key:"onFragBuffered",value:function(e){this.detectPartialFragments(e.frag)}},{key:"hasFragment",value:function(e){var t=this.getFragmentKey(e);return void 0!==this.fragments[t]}},{key:"removeFragment",value:function(e){var t=this.getFragmentKey(e);delete this.fragments[t]}},{key:"removeAllFragments",value:function(){this.fragments=Object.create(null)}}]),t}(i.default)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addGroupId=function(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}},t.updatePTS=i,t.updateFragPTSDTS=n,t.mergeDetails=function(e,t){t.initSegment&&e.initSegment&&(t.initSegment=e.initSegment);var r=0,i=void 0;if(o(e,t,(function(e,a){r=e.cc-a.cc,Number.isFinite(e.startPTS)&&(a.start=a.startPTS=e.startPTS,a.endPTS=e.endPTS,a.duration=e.duration,a.backtracked=e.backtracked,a.dropped=e.dropped,i=a),t.PTSKnown=!0})),!t.PTSKnown)return;if(r){a.logger.log("discontinuity sliding from playlist, take drift into account");for(var l=t.fragments,u=0;u<l.length;u++)l[u].cc+=r}i?n(t,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS):s(e,t);t.PTSKnown=e.PTSKnown},t.mergeSubtitlePlaylists=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=-1;o(e,t,(function(e,t,r){t.start=e.start,a=r}));var i=t.fragments;if(a<0)return void i.forEach((function(e){e.start+=r}));for(var n=a+1;n<i.length;n++)i[n].start=i[n-1].start+i[n-1].duration},t.mapFragmentIntersection=o,t.adjustSliding=s,t.computeReloadInterval=function(e,t,r){var a=1e3*(t.averagetargetduration?t.averagetargetduration:t.targetduration),i=a/2;e&&t.endSN===e.endSN&&(a=i);r&&(a=Math.max(i,a-(window.performance.now()-r)));return Math.round(a)};var a=r(0);function i(e,t,r){var i=e[t],n=e[r],o=n.startPTS;Number.isFinite(o)?r>t?(i.duration=o-i.start,i.duration<0&&a.logger.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(n.duration=i.start-o,n.duration<0&&a.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!")):n.start=r>t?i.start+i.duration:Math.max(i.start-n.duration,0)}function n(e,t,r,a,n,o){var s=r;if(Number.isFinite(t.startPTS)){var l=Math.abs(t.startPTS-r);Number.isFinite(t.deltaPTS)?t.deltaPTS=Math.max(l,t.deltaPTS):t.deltaPTS=l,s=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),a=Math.max(a,t.endPTS),n=Math.min(n,t.startDTS),o=Math.max(o,t.endDTS)}var u=r-t.start;t.start=t.startPTS=r,t.maxStartPTS=s,t.endPTS=a,t.startDTS=n,t.endDTS=o,t.duration=a-r;var d=t.sn;if(!e||d<e.startSN||d>e.endSN)return 0;var f,c=void 0,h=void 0;for(f=d-e.startSN,(c=e.fragments)[f]=t,h=f;h>0;h--)i(c,h,h-1);for(h=f;h<c.length-1;h++)i(c,h,h+1);return e.PTSKnown=!0,u}function o(e,t,r){if(e&&t)for(var a=Math.max(e.startSN,t.startSN)-t.startSN,i=Math.min(e.endSN,t.endSN)-t.startSN,n=t.startSN-e.startSN,o=a;o<=i;o++){var s=e.fragments[n+o],l=t.fragments[o];if(!s||!l)break;r(s,l,o)}}function s(e,t){var r=t.startSN-e.startSN,a=e.fragments,i=t.fragments;if(!(r<0||r>a.length))for(var n=0;n<i.length;n++)i[n].start+=a[r].start}},function(e,t,r){var a,i,n,o,s;a=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,i=/^([^\/?#]*)(.*)$/,n=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,s={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=s.normalizePath(a.path),s.buildURLFromParts(a)}var n=s.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=s.normalizePath(n.path),s.buildURLFromParts(n)):t;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(u.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var d=o.path,f=d.substring(0,d.lastIndexOf("/")+1)+n.path;u.path=s.normalizePath(f)}else u.path=o.path,n.params||(u.params=o.params,n.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(n.path):n.path),s.buildURLFromParts(u)},parseURL:function(e){var t=a.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[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}},e.exports=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={search:function(e,t){for(var r=0,a=e.length-1,i=null,n=null;r<=a;){var o=t(n=e[i=(r+a)/2|0]);if(o>0)r=i+1;else{if(!(o<0))return n;a=i-1}}return null}},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return a(e,null,[{key:"isHeader",value:function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}},{key:"isFooter",value:function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}},{key:"getID3Data",value:function(t,r){for(var a=r,i=0;e.isHeader(t,r);){i+=10,i+=e._readSize(t,r+6),e.isFooter(t,r+10)&&(i+=10),r+=i}if(i>0)return t.subarray(a,a+i)}},{key:"_readSize",value:function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]}},{key:"getTimeStamp",value:function(t){for(var r=e.getID3Frames(t),a=0;a<r.length;a++){var i=r[a];if(e.isTimeStampFrame(i))return e._readTimeStamp(i)}}},{key:"isTimeStampFrame",value:function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}},{key:"_getFrameData",value:function(t){var r=String.fromCharCode(t[0],t[1],t[2],t[3]),a=e._readSize(t,4);return{type:r,size:a,data:t.subarray(10,10+a)}}},{key:"getID3Frames",value:function(t){for(var r=0,a=[];e.isHeader(t,r);){for(var i=e._readSize(t,r+6),n=(r+=10)+i;r+8<n;){var o=e._getFrameData(t.subarray(r)),s=e._decodeFrame(o);s&&a.push(s),r+=o.size+10}e.isFooter(t,r)&&(r+=10)}return a}},{key:"_decodeFrame",value:function(t){return"PRIV"===t.type?e._decodePrivFrame(t):"T"===t.type[0]?e._decodeTextFrame(t):"W"===t.type[0]?e._decodeURLFrame(t):void 0}},{key:"_readTimeStamp",value:function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],a=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return a/=45,r&&(a+=47721858.84),Math.round(a)}}},{key:"_decodePrivFrame",value:function(t){if(!(t.size<2)){var r=e._utf8ArrayToStr(t.data,!0),a=new Uint8Array(t.data.subarray(r.length+1));return{key:t.type,info:r,data:a.buffer}}}},{key:"_decodeTextFrame",value:function(t){if(!(t.size<2)){if("TXXX"===t.type){var r=1,a=e._utf8ArrayToStr(t.data.subarray(r));r+=a.length+1;var i=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:a,data:i}}var n=e._utf8ArrayToStr(t.data.subarray(1));return{key:t.type,data:n}}}},{key:"_decodeURLFrame",value:function(t){if("WXXX"===t.type){if(t.size<2)return;var r=1,a=e._utf8ArrayToStr(t.data.subarray(r));r+=a.length+1;var i=e._utf8ArrayToStr(t.data.subarray(r));return{key:t.type,info:a,data:i}}var n=e._utf8ArrayToStr(t.data);return{key:t.type,data:n}}},{key:"_utf8ArrayToStr",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.length,a=void 0,i=void 0,n=void 0,o="",s=0;s<r;){if(0===(a=e[s++])&&t)return o;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(a);break;case 12:case 13:i=e[s++],o+=String.fromCharCode((31&a)<<6|63&i);break;case 14:i=e[s++],n=e[s++],o+=String.fromCharCode((15&a)<<12|(63&i)<<6|(63&n)<<0)}}return o}}]),e}(),n=i._utf8ArrayToStr;t.default=i,t.utf8ArrayToStr=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(8)),o=r(17),s=(a=o)&&a.__esModule?a:{default:a};function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var u=function(){function e(){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._url=null,this._byteRange=null,this._decryptdata=null,this.tagList=[],this.programDateTime=null,this.rawProgramDateTime=null,this._elementaryStreams=(l(t={},e.ElementaryStreamTypes.AUDIO,!1),l(t,e.ElementaryStreamTypes.VIDEO,!1),t)}return i(e,[{key:"addElementaryStream",value:function(e){this._elementaryStreams[e]=!0}},{key:"hasElementaryStream",value:function(e){return!0===this._elementaryStreams[e]}},{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.default).method=e.method,r.baseuri=e.baseuri,r.reluri=e.reluri,r.iv=this.createInitializationVector(t)),r}},{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=n.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){if(!this._byteRange&&!this.rawByteRange)return[];if(this._byteRange)return this._byteRange;var e=[];if(this.rawByteRange){var t=this.rawByteRange.split("@",2);if(1===t.length){var r=this.lastByteRangeEndOffset;e[0]=r||0}else e[0]=parseInt(t[1]);e[1]=parseInt(t[0])+e[0],this._byteRange=e}return e}},{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}},{key:"endProgramDateTime",get:function(){if(!Number.isFinite(this.programDateTime))return null;var e=Number.isFinite(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}],[{key:"ElementaryStreamTypes",get:function(){return{AUDIO:"audio",VIDEO:"video"}}}]),e}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=d(r(42)),n=d(r(43)),o=d(r(44)),s=r(2),l=r(0),u=d(r(1));function d(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var c=(0,r(5).getSelfScope)(),h=function(){function e(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=a.removePKCS7Padding,n=void 0===i||i;if(f(this,e),this.logEnabled=!0,this.observer=t,this.config=r,this.removePKCS7Padding=n,n)try{var o=c.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch(e){}this.disableWebCrypto=!this.subtle}return a(e,[{key:"isSync",value:function(){return this.disableWebCrypto&&this.config.enableSoftwareAES}},{key:"decrypt",value:function(e,t,r,a){var s=this;if(this.disableWebCrypto&&this.config.enableSoftwareAES){this.logEnabled&&(l.logger.log("JS AES decrypt"),this.logEnabled=!1);var u=this.decryptor;u||(this.decryptor=u=new o.default),u.expandKey(t),a(u.decrypt(e,0,r,this.removePKCS7Padding))}else{this.logEnabled&&(l.logger.log("WebCrypto AES decrypt"),this.logEnabled=!1);var d=this.subtle;this.key!==t&&(this.key=t,this.fastAesKey=new n.default(d,t)),this.fastAesKey.expandKey().then((function(n){new i.default(d,r).decrypt(e,n).catch((function(i){s.onWebCryptoError(i,e,t,r,a)})).then((function(e){a(e)}))})).catch((function(i){s.onWebCryptoError(i,e,t,r,a)}))}}},{key:"onWebCryptoError",value:function(e,t,r,a,i){this.config.enableSoftwareAES?(l.logger.log("WebCrypto Error, disable WebCrypto API"),this.disableWebCrypto=!0,this.logEnabled=!0,this.decrypt(t,r,a,i)):(l.logger.error("decrypting error : "+e.message),this.observer.trigger(u.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_DECRYPT_ERROR,fatal:!0,reason:e.message}))}},{key:"destroy",value:function(){var e=this.decryptor;e&&(e.destroy(),this.decryptor=void 0)}}]),e}();t.default=h,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getMediaSource=function(){if("undefined"!=typeof window)return window.MediaSource||window.WebKitMediaSource}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.State=void 0;var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=r(28),o=(a=n)&&a.__esModule?a:{default:a},s=r(6),l=r(4),u=r(0);function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(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}var c=t.State={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",WAITING_LEVEL:"WAITING_LEVEL"},h=function(e){function t(){return d(this,t),f(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return 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)}(t,e),i(t,[{key:"doTick",value:function(){}},{key:"startLoad",value:function(){}},{key:"stopLoad",value:function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragmentTracker.removeFragment(e)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED}},{key:"_streamEnded",value:function(e,t){var r=this.fragCurrent,a=this.fragmentTracker;if(!t.live&&r&&!r.backtracked&&r.sn===t.endSN&&!e.nextStart){var i=a.getState(r);return i===s.FragmentState.PARTIAL||i===s.FragmentState.OK}return!1}},{key:"onMediaSeeking",value:function(){var e=this.config,t=this.media,r=this.mediaBuffer,a=this.state,i=t?t.currentTime:null,n=l.BufferHelper.bufferInfo(r||t,i,this.config.maxBufferHole);if(Number.isFinite(i)&&u.logger.log("media seeking to "+i.toFixed(3)),a===c.FRAG_LOADING){var o=this.fragCurrent;if(0===n.len&&o){var s=e.maxFragLookUpTolerance,d=o.start-s,f=o.start+o.duration+s;i<d||i>f?(o.loader&&(u.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),o.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE):u.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else a===c.ENDED&&(0===n.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=c.IDLE);t&&(this.lastCurrentTime=i),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=i),this.tick()}},{key:"onMediaEnded",value:function(){this.startPosition=this.lastCurrentTime=0}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),function e(t,r,a){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,a)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(a):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"onHandlerDestroying",this).call(this)}},{key:"onHandlerDestroyed",value:function(){this.state=c.STOPPED,this.fragmentTracker=null}}]),t}(o.default);t.default=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=d(r(1)),n=d(r(3)),o=r(2),s=r(0),l=d(r(16)),u=d(r(35));function d(e){return e&&e.__esModule?e:{default:e}}var f=window.performance,c={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},h={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"},v=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.MANIFEST_LOADING,i.default.LEVEL_LOADING,i.default.AUDIO_TRACK_LOADING,i.default.SUBTITLE_TRACK_LOADING));return r.loaders={},r}return 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)}(t,e),a(t,[{key:"createInternalLoader",value:function(e){var t=this.hls.config,r=t.pLoader,a=t.loader,i=new(r||a)(t);return e.loader=i,this.loaders[e.type]=i,i}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.destroyInternalLoaders(),function e(t,r,a){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,a)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(a):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"onManifestLoading",value:function(e){this.load(e.url,{type:c.MANIFEST,level:0,id:null})}},{key:"onLevelLoading",value:function(e){this.load(e.url,{type:c.LEVEL,level:e.level,id:e.id})}},{key:"onAudioTrackLoading",value:function(e){this.load(e.url,{type:c.AUDIO_TRACK,level:null,id:e.id})}},{key:"onSubtitleTrackLoading",value:function(e){this.load(e.url,{type:c.SUBTITLE_TRACK,level:null,id:e.id})}},{key:"load",value:function(e,t){var r=this.hls.config;s.logger.debug("Loading playlist of type "+t.type+", level: "+t.level+", id: "+t.id);var a=this.getInternalLoader(t);if(a){var i=a.context;if(i&&i.url===e)return s.logger.trace("playlist request ongoing"),!1;s.logger.warn("aborting previous loader for type: "+t.type),a.abort()}var n=void 0,o=void 0,l=void 0,u=void 0;switch(t.type){case c.MANIFEST:n=r.manifestLoadingMaxRetry,o=r.manifestLoadingTimeOut,l=r.manifestLoadingRetryDelay,u=r.manifestLoadingMaxRetryTimeout;break;case c.LEVEL:n=0,o=r.levelLoadingTimeOut;break;default:n=r.levelLoadingMaxRetry,o=r.levelLoadingTimeOut,l=r.levelLoadingRetryDelay,u=r.levelLoadingMaxRetryTimeout}a=this.createInternalLoader(t),t.url=e,t.responseType=t.responseType||"";var d={timeout:o,maxRetry:n,retryDelay:l,maxRetryDelay:u},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return s.logger.debug("Calling internal loader delegate for URL: "+e),a.load(t,d,f),!0}},{key:"loadsuccess",value:function(e,t,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(r.isSidxRequest)return this._handleSidxRequest(e,r),void this._handlePlaylistLoaded(e,t,r,a);this.resetInternalLoader(r.type);var i=e.data;t.tload=f.now(),0===i.indexOf("#EXTM3U")?i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(e,t,r,a):this._handleMasterPlaylist(e,t,r,a):this._handleManifestParsingError(e,r,"no EXTM3U delimiter",a)}},{key:"loaderror",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this._handleNetworkError(t,r,!1,e)}},{key:"loadtimeout",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this._handleNetworkError(t,r,!0)}},{key:"_handleMasterPlaylist",value:function(e,r,a,n){var o=this.hls,l=e.data,d=t.getResponseUrl(e,a),f=u.default.parseMasterPlaylist(l,d);if(f.length){var c=f.map((function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}})),h=u.default.parseMasterPlaylistMedia(l,d,"AUDIO",c),v=u.default.parseMasterPlaylistMedia(l,d,"SUBTITLES");if(h.length){var g=!1;h.forEach((function(e){e.url||(g=!0)})),!1===g&&f[0].audioCodec&&!f[0].attrs.AUDIO&&(s.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),h.unshift({type:"main",name:"main"}))}o.trigger(i.default.MANIFEST_LOADED,{levels:f,audioTracks:h,subtitles:v,url:d,stats:r,networkDetails:n})}else this._handleManifestParsingError(e,a,"no level found in manifest",n)}},{key:"_handleTrackOrLevelPlaylist",value:function(e,r,a,n){var o=this.hls,s=a.id,l=a.level,d=a.type,h=t.getResponseUrl(e,a),v=Number.isFinite(s)?s:0,g=Number.isFinite(l)?l:v,p=t.mapContextToLevelType(a),y=u.default.parseLevelPlaylist(e.data,h,g,p,v);if(y.tload=r.tload,d===c.MANIFEST){var m={url:h,details:y};o.trigger(i.default.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:h,stats:r,networkDetails:n})}if(r.tparsed=f.now(),y.needSidxRanges){var b=y.initSegment.url;this.load(b,{isSidxRequest:!0,type:d,level:l,levelDetails:y,id:s,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}else a.levelDetails=y,this._handlePlaylistLoaded(e,r,a,n)}},{key:"_handleSidxRequest",value:function(e,t){var r=l.default.parseSegmentIndex(new Uint8Array(e.data));if(r){var a=r.references,i=t.levelDetails;a.forEach((function(e,t){var r=e.info,a=i.fragments[t];0===a.byteRange.length&&(a.rawByteRange=String(1+r.end-r.start)+"@"+String(r.start))})),i.initSegment.rawByteRange=String(r.moovEndOffset)+"@0"}}},{key:"_handleManifestParsingError",value:function(e,t,r,a){this.hls.trigger(i.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:r,networkDetails:a})}},{key:"_handleNetworkError",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;s.logger.info("A network error occured while loading a "+e.type+"-type playlist");var n=void 0,l=void 0,u=this.getInternalLoader(e);switch(e.type){case c.MANIFEST:n=r?o.ErrorDetails.MANIFEST_LOAD_TIMEOUT:o.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case c.LEVEL:n=r?o.ErrorDetails.LEVEL_LOAD_TIMEOUT:o.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case c.AUDIO_TRACK:n=r?o.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:o.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;default:l=!1}u&&(u.abort(),this.resetInternalLoader(e.type));var d={type:o.ErrorTypes.NETWORK_ERROR,details:n,fatal:l,url:u.url,loader:u,context:e,networkDetails:t};a&&(d.response=a),this.hls.trigger(i.default.ERROR,d)}},{key:"_handlePlaylistLoaded",value:function(e,r,a,n){var o=a.type,s=a.level,l=a.id,u=a.levelDetails;if(u.targetduration)if(t.canHaveQualityLevels(a.type))this.hls.trigger(i.default.LEVEL_LOADED,{details:u,level:s||0,id:l||0,stats:r,networkDetails:n});else switch(o){case c.AUDIO_TRACK:this.hls.trigger(i.default.AUDIO_TRACK_LOADED,{details:u,id:l,stats:r,networkDetails:n});break;case c.SUBTITLE_TRACK:this.hls.trigger(i.default.SUBTITLE_TRACK_LOADED,{details:u,id:l,stats:r,networkDetails:n})}else this._handleManifestParsingError(e,a,"invalid target duration",n)}}],[{key:"canHaveQualityLevels",value:function(e){return e!==c.AUDIO_TRACK&&e!==c.SUBTITLE_TRACK}},{key:"mapContextToLevelType",value:function(e){switch(e.type){case c.AUDIO_TRACK:return h.AUDIO;case c.SUBTITLE_TRACK:return h.SUBTITLE;default:return h.MAIN}}},{key:"getResponseUrl",value:function(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}},{key:"ContextType",get:function(){return c}},{key:"LevelType",get:function(){return h}}]),t}(n.default);t.default=v,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=r(0),o=r(1),s=(a=o)&&a.__esModule?a:{default:a};var l=Math.pow(2,32)-1,u=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.remuxer=r}return i(e,[{key:"resetTimeStamp",value:function(e){this.initPTS=e}},{key:"resetInitSegment",value:function(t,r,a,i){if(t&&t.byteLength){var n=this.initData=e.parseInitSegment(t);null==r&&(r="mp4a.40.5"),null==a&&(a="avc1.42e01e");var o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:r+","+a,initSegment:i?t:null}:(n.audio&&(o.audio={container:"audio/mp4",codec:r,initSegment:i?t:null}),n.video&&(o.video={container:"video/mp4",codec:a,initSegment:i?t:null})),this.observer.trigger(s.default.FRAG_PARSING_INIT_SEGMENT,{tracks:o})}else r&&(this.audioCodec=r),a&&(this.videoCodec=a)}},{key:"append",value:function(t,r,a,i){var n=this.initData;n||(this.resetInitSegment(t,this.audioCodec,this.videoCodec,!1),n=this.initData);var o,l=this.initPTS;if(void 0===l){var u=e.getStartDTS(n,t);this.initPTS=l=u-r,this.observer.trigger(s.default.INIT_PTS_FOUND,{initPTS:l})}e.offsetStartDTS(n,t,l),o=e.getStartDTS(n,t),this.remuxer.remux(n.audio,n.video,null,null,o,a,i,t)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(t){return e.findBox({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0}},{key:"bin2str",value:function(e){return String.fromCharCode.apply(null,e)}},{key:"readUint16",value:function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r}},{key:"readUint32",value:function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r}},{key:"writeUint32",value:function(e,t,r){e.data&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}},{key:"findBox",value:function(t,r){var a=[],i=void 0,n=void 0,o=void 0,s=void 0,l=void 0,u=void 0;if(t.data?(l=t.start,o=t.end,t=t.data):(l=0,o=t.byteLength),!r.length)return null;for(i=l;i<o;)u=(n=e.readUint32(t,i))>1?i+n:o,e.bin2str(t.subarray(i+4,i+8))===r[0]&&(1===r.length?a.push({data:t,start:i+8,end:u}):(s=e.findBox({data:t,start:i+8,end:u},r.slice(1))).length&&(a=a.concat(s))),i=u;return a}},{key:"parseSegmentIndex",value:function(t){var r=e.findBox(t,["moov"])[0],a=r?r.end:null,i=0,n=e.findBox(t,["sidx"]),o=void 0;if(!n||!n[0])return null;o=[];var s=(n=n[0]).data[0];i=0===s?8:16;var l=e.readUint32(n,i);i+=4;i+=0===s?8:16,i+=2;var u=n.end+0,d=e.readUint16(n,i);i+=2;for(var f=0;f<d;f++){var c=i,h=e.readUint32(n,c);c+=4;var v=2147483647&h;if(1===(2147483648&h)>>>31)return void console.warn("SIDX has hierarchical references (not supported)");var g=e.readUint32(n,c);c+=4,o.push({referenceSize:v,subsegmentDuration:g,info:{duration:g/l,start:u,end:u+v-1}}),u+=v,i=c+=4}return{earliestPresentationTime:0,timescale:l,version:s,referencesCount:d,references:o,moovEndOffset:a}}},{key:"parseInitSegment",value:function(t){var r=[];return e.findBox(t,["moov","trak"]).forEach((function(t){var a=e.findBox(t,["tkhd"])[0];if(a){var i=a.data[a.start],o=0===i?12:20,s=e.readUint32(a,o),l=e.findBox(t,["mdia","mdhd"])[0];if(l){o=0===(i=l.data[l.start])?12:20;var u=e.readUint32(l,o),d=e.findBox(t,["mdia","hdlr"])[0];if(d){var f={soun:"audio",vide:"video"}[e.bin2str(d.data.subarray(d.start+8,d.start+12))];if(f){var c=e.findBox(t,["mdia","minf","stbl","stsd"]);if(c.length){c=c[0];var h=e.bin2str(c.data.subarray(c.start+12,c.start+16));n.logger.log("MP4Demuxer:"+f+":"+h+" found")}r[s]={timescale:u,type:f},r[f]={timescale:u,id:s}}}}}})),r}},{key:"getStartDTS",value:function(t,r){var a,i,n=void 0;return n=e.findBox(r,["moof","traf"]),a=[].concat.apply([],n.map((function(r){return e.findBox(r,["tfhd"]).map((function(a){var i,n;return i=e.readUint32(a,4),n=t[i].timescale||9e4,e.findBox(r,["tfdt"]).map((function(t){var r,a=void 0;return r=t.data[t.start],a=e.readUint32(t,4),1===r&&(a*=Math.pow(2,32),a+=e.readUint32(t,8)),a}))[0]/n}))}))),i=Math.min.apply(null,a),isFinite(i)?i:0}},{key:"offsetStartDTS",value:function(t,r,a){e.findBox(r,["moof","traf"]).map((function(r){return e.findBox(r,["tfhd"]).map((function(i){var n=e.readUint32(i,4),o=t[n].timescale||9e4;e.findBox(r,["tfdt"]).map((function(t){var r=t.data[t.start],i=e.readUint32(t,4);if(0===r)e.writeUint32(t,4,i-a*o);else{i*=Math.pow(2,32),i+=e.readUint32(t,8),i-=a*o,i=Math.max(i,0);var n=Math.floor(i/(l+1)),s=Math.floor(i%(l+1));e.writeUint32(t,4,n),e.writeUint32(t,8,s)}}))}))}))}}]),e}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(8));var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.method=null,this.key=null,this.iv=null,this._uri=null}return a(e,[{key:"uri",get:function(){return!this._uri&&this.reluri&&(this._uri=i.buildAbsoluteURL(this.baseuri,this.reluri,{alwaysNormalize:!0})),this._uri}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}};t.isCodecType=function(e,t){var r=a[t];return!!r&&!0===r[e.slice(0,4)]},t.isCodecSupportedInMp4=function(e,t){return window.MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=(r(20),function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(41))),n=c(r(1)),o=c(r(21)),s=r(0),l=r(2),u=r(13),d=r(5),f=r(24);function c(e){return e&&e.__esModule?e:{default:e}}var h=(0,d.getSelfScope)(),v=(0,u.getMediaSource)(),g=function(){function e(t,r){var a=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hls=t,this.id=r;var u=this.observer=new f.Observer,d=t.config,c=function(e,r){(r=r||{}).frag=a.frag,r.id=a.id,t.trigger(e,r)};u.on(n.default.FRAG_DECRYPTED,c),u.on(n.default.FRAG_PARSING_INIT_SEGMENT,c),u.on(n.default.FRAG_PARSING_DATA,c),u.on(n.default.FRAG_PARSED,c),u.on(n.default.ERROR,c),u.on(n.default.FRAG_PARSING_METADATA,c),u.on(n.default.FRAG_PARSING_USERDATA,c),u.on(n.default.INIT_PTS_FOUND,c);var g={mp4:v.isTypeSupported("video/mp4"),mpeg:v.isTypeSupported("audio/mpeg"),mp3:v.isTypeSupported('audio/mp4; codecs="mp3"')},p=navigator.vendor;if(d.enableWorker&&"undefined"!=typeof Worker){s.logger.log("demuxing in webworker");var y=void 0;try{y=this.w=i(55),this.onwmsg=this.onWorkerMessage.bind(this),y.addEventListener("message",this.onwmsg),y.onerror=function(e){t.trigger(n.default.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",err:{message:e.message+" ("+e.filename+":"+e.lineno+")"}})},y.postMessage({cmd:"init",typeSupported:g,vendor:p,id:r,config:JSON.stringify(d)})}catch(e){s.logger.warn("Error in worker:",e),s.logger.error("Error while initializing DemuxerWorker, fallback on DemuxerInline"),y&&h.URL.revokeObjectURL(y.objectURL),this.demuxer=new o.default(u,g,d,p),this.w=void 0}}else this.demuxer=new o.default(u,g,d,p)}return a(e,[{key:"destroy",value:function(){var e=this.w;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.w=null;else{var t=this.demuxer;t&&(t.destroy(),this.demuxer=null)}var r=this.observer;r&&(r.removeAllListeners(),this.observer=null)}},{key:"push",value:function(e,t,r,a,i,n,o,l){var u=this.w,d=Number.isFinite(i.startPTS)?i.startPTS:i.start,f=i.decryptdata,c=this.frag,h=!(c&&i.cc===c.cc),v=!(c&&i.level===c.level),g=c&&i.sn===c.sn+1,p=!v&&g;if(h&&s.logger.log(this.id+":discontinuity detected"),v&&s.logger.log(this.id+":switch detected"),this.frag=i,u)u.postMessage({cmd:"demux",data:e,decryptdata:f,initSegment:t,audioCodec:r,videoCodec:a,timeOffset:d,discontinuity:h,trackSwitch:v,contiguous:p,duration:n,accurateTimeOffset:o,defaultInitPTS:l},e instanceof ArrayBuffer?[e]:[]);else{var y=this.demuxer;y&&y.push(e,f,t,r,a,d,h,v,p,n,o,l)}}},{key:"onWorkerMessage",value:function(e){var t=e.data,r=this.hls;switch(t.event){case"init":h.URL.revokeObjectURL(this.w.objectURL);break;case n.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)}}}]),e}();t.default=g,e.exports=t.default},function(e,t,r){"use strict";var a,i="object"==typeof Reflect?Reflect:null,n=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};a=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var l=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function d(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function f(e,t,r,a){var i,n,o,s;if(u(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),o=n[t]),void 0===o)o=n[t]=r,++e._eventsCount;else if("function"==typeof o?o=n[t]=a?[r,o]:[o,r]:a?o.unshift(r):o.push(r),(i=d(e))>0&&o.length>i&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,s=l,console&&console.warn&&console.warn(s)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var a={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=c.bind(a);return i.listener=r,a.wrapFn=i,i}function v(e,t,r){var a=e._events;if(void 0===a)return[];var i=a[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function g(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),a=0;a<t;++a)r[a]=e[a];return r}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");l=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return d(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var a="error"===e,i=this._events;if(void 0!==i)a=a&&void 0===i.error;else if(!a)return!1;if(a){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var l=i[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var u=l.length,d=p(l,u);for(r=0;r<u;++r)n(d[r],this,t)}return!0},s.prototype.addListener=function(e,t){return f(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return f(this,e,t,!0)},s.prototype.once=function(e,t){return u(t),this.on(e,h(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,h(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,a,i,n,o;if(u(t),void 0===(a=this._events))return this;if(void 0===(r=a[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete a[e],a.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){o=r[n].listener,i=n;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(a[e]=r[0]),void 0!==a.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,a;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,n=Object.keys(r);for(a=0;a<n.length;++a)"removeListener"!==(i=n[a])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(a=t.length-1;a>=0;a--)this.removeListener(e,t[a]);return this},s.prototype.listeners=function(e){return v(this,e,!0)},s.prototype.rawListeners=function(e){return v(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},s.prototype.listenerCount=g,s.prototype.eventNames=function(){return this._eventsCount>0?a(this._events):[]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=g(r(1)),n=r(2),o=g(r(12)),s=g(r(45)),l=g(r(16)),u=g(r(46)),d=g(r(49)),f=g(r(50)),c=g(r(53)),h=r(5),v=r(0);function g(e){return e&&e.__esModule?e:{default:e}}var p=(0,h.getSelfScope)(),y=void 0;try{y=p.performance.now.bind(p.performance)}catch(e){v.logger.debug("Unable to use Performance API on this environment"),y=p.Date.now}var m=function(){function e(t,r,a,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.typeSupported=r,this.config=a,this.vendor=i}return a(e,[{key:"destroy",value:function(){var e=this.demuxer;e&&e.destroy()}},{key:"push",value:function(e,t,r,a,n,s,l,u,d,f,c,h){var v=this;if(e.byteLength>0&&null!=t&&null!=t.key&&"AES-128"===t.method){var g=this.decrypter;null==g&&(g=this.decrypter=new o.default(this.observer,this.config));var p=y();g.decrypt(e,t.key.buffer,t.iv.buffer,(function(e){var o=y();v.observer.trigger(i.default.FRAG_DECRYPTED,{stats:{tstart:p,tdecrypt:o}}),v.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),a,n,s,l,u,d,f,c,h)}))}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),a,n,s,l,u,d,f,c,h)}},{key:"pushDecrypted",value:function(e,t,r,a,o,h,v,g,p,y,m,b){var E=this.demuxer;if(!E||(v||g)&&!this.probe(e)){for(var _=this.observer,T=this.typeSupported,S=this.config,k=[{demux:u.default,remux:f.default},{demux:l.default,remux:c.default},{demux:s.default,remux:f.default},{demux:d.default,remux:f.default}],R=0,A=k.length;R<A;R++){var w=k[R],O=w.demux.probe;if(O(e)){var L=this.remuxer=new w.remux(_,S,T,this.vendor);E=new w.demux(_,L,S,T),this.probe=O;break}}if(!E)return void _.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"});this.demuxer=E}var D=this.remuxer;(v||g)&&(E.resetInitSegment(r,a,o,y),D.resetInitSegment()),v&&(E.resetTimeStamp(b),D.resetTimeStamp(b)),"function"==typeof E.setDecryptData&&E.setDecryptData(t),E.append(e,h,p,m)}}]),e}();t.default=m,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAudioConfig=l,t.isHeaderPattern=u,t.getHeaderLength=d,t.getFullFrameLength=f,t.isHeader=function(e,t){if(t+1<e.length&&u(e,t))return!0;return!1},t.probe=function(e,t){if(t+1<e.length&&u(e,t)){var r=d(e,t);t+5<e.length&&(r=f(e,t));var a=t+r;if(a===e.length||a+1<e.length&&u(e,a))return!0}return!1},t.initTrackConfig=function(e,t,r,a,n){if(!e.samplerate){var o=l(t,r,a,n);e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,i.logger.log("parsed codec:"+e.codec+",rate:"+o.samplerate+",nb channel:"+o.channelCount)}},t.getFrameDuration=c,t.parseFrameHeader=h,t.appendFrame=function(e,t,r,a,i){var n=c(e.samplerate),o=h(t,r,a,i,n);if(o){var s=o.stamp,l=o.headerLength,u=o.frameLength,d={unit:t.subarray(r+l,r+l+u),pts:s,dts:s};return e.samples.push(d),e.len+=u,{sample:d,length:u+l}}return};var a,i=r(0),n=r(2),o=r(1),s=(a=o)&&a.__esModule?a:{default:a};r(5);function l(e,t,r,a){var o,l=void 0,u=void 0,d=void 0,f=void 0,c=navigator.userAgent.toLowerCase(),h=a,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];if(l=1+((192&t[r+2])>>>6),!((o=(60&t[r+2])>>>2)>v.length-1))return d=(1&t[r+2])<<2,d|=(192&t[r+3])>>>6,i.logger.log("manifest codec:"+a+",ADTS data:type:"+l+",sampleingIndex:"+o+"["+v[o]+"Hz],channelConfig:"+d),/firefox/i.test(c)?o>=6?(l=5,f=new Array(4),u=o-3):(l=2,f=new Array(2),u=o):-1!==c.indexOf("android")?(l=2,f=new Array(2),u=o):(l=5,f=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&o>=6?u=o-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(o>=6&&1===d||/vivaldi/i.test(c))||!a&&1===d)&&(l=2,f=new Array(2)),u=o)),f[0]=l<<3,f[0]|=(14&o)>>1,f[1]|=(1&o)<<7,f[1]|=d<<3,5===l&&(f[1]|=(14&u)>>1,f[2]=(1&u)<<7,f[2]|=8,f[3]=0),{config:f,samplerate:v[o],channelCount:d,codec:"mp4a.40."+l,manifestCodec:h};e.trigger(s.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+o})}function u(e,t){return 255===e[t]&&240==(246&e[t+1])}function d(e,t){return 1&e[t+1]?7:9}function f(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function c(e){return 9216e4/e}function h(e,t,r,a,i){var n,o=void 0,s=e.length;if(n=d(e,t),o=f(e,t),(o-=n)>0&&t+n+o<=s)return{headerLength:n,frameLength:o,stamp:r+a*i}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a={BitratesMap:[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],SamplingRateMap:[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],SamplesCoefficients:[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],BytesInSlot:[0,1,1,4],appendFrame:function(e,t,r,a,i){if(!(r+24>t.length)){var n=this.parseHeader(t,r);if(n&&r+n.frameLength<=t.length){var o=a+i*(9e4*n.samplesPerFrame/n.sampleRate),s={unit:t.subarray(r,r+n.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(s),e.len+=n.frameLength,{sample:s,length:n.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,o=e[t+2]>>2&3,s=e[t+2]>>1&1;if(1!==r&&0!==n&&15!==n&&3!==o){var l=3===r?3-i:3===i?3:4,u=1e3*a.BitratesMap[14*l+n-1],d=3===r?0:2===r?1:2,f=a.SamplingRateMap[3*d+o],c=e[t+3]>>6==3?1:2,h=a.SamplesCoefficients[r][i],v=a.BytesInSlot[i],g=8*h*v;return{sampleRate:f,channelCount:c,frameLength:parseInt(h*u/f+s,10)*v,samplesPerFrame:g}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1<e.length&&this.isHeaderPattern(e,t))},probe:function(e,t){if(t+1<e.length&&this.isHeaderPattern(e,t)){var r=this.parseHeader(e,t),a=4;r&&r.frameLength&&(a=r.frameLength);var i=t+a;if(i===e.length||i+1<e.length&&this.isHeaderPattern(e,i))return!0}return!1}};t.default=a,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Observer=void 0;var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=r(54);function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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}t.Observer=function(e){function t(){return n(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return 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)}(t,e),a(t,[{key:"trigger",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];this.emit.apply(this,[e,e].concat(r))}}]),t}(i.EventEmitter)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={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}},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findFirstFragWithCC=s,t.findFragWithCC=function(e,t){return n.default.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))},t.shouldAlignOnDiscontinuities=l,t.findDiscontinuousReferenceFrag=u,t.adjustPts=d,t.alignStream=function(e,t,r){f(e,r,t),!r.PTSKnown&&t&&c(r,t.details)},t.alignDiscontinuities=f,t.alignPDT=c;var a,i=r(9),n=(a=i)&&a.__esModule?a:{default:a},o=r(0);function s(e,t){for(var r=null,a=0;a<e.length;a+=1){var i=e[a];if(i&&i.cc===t){r=i;break}}return r}function l(e,t,r){var a=!1;return t&&t.details&&r&&(r.endCC>r.startCC||e&&e.cc<r.startCC)&&(a=!0),a}function u(e,t){var r=e.fragments,a=t.fragments;if(a.length&&r.length){var i=s(r,a[0].cc);if(i&&(!i||i.startPTS))return i;o.logger.log("No frag in previous level to align on")}else o.logger.log("No fragments to align")}function d(e,t){t.fragments.forEach((function(t){if(t){var r=t.start+e;t.start=t.startPTS=r,t.endPTS=r+t.duration}})),t.PTSKnown=!0}function f(e,t,r){if(l(e,r,t)){var a=u(r.details,t);a&&(o.logger.log("Adjusting PTS using last level due to CC increase within current level"),d(a.start,t))}}function c(e,t){if(t&&t.fragments.length){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;var r=t.fragments[0].programDateTime,a=(e.fragments[0].programDateTime-r)/1e3+t.fragments[0].start;Number.isFinite(a)&&(o.logger.log("adjusting PTS using programDateTime delta, sliding:"+a.toFixed(3)),d(a,e))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findFragmentByPDT=function(e,t,r){if(!Array.isArray(e)||!e.length||!Number.isFinite(t))return null;if(t<e[0].programDateTime)return null;if(t>=e[e.length-1].endProgramDateTime)return null;r=r||0;for(var a=0;a<e.length;++a){var i=e[a];if(s(t,r,i))return i}return null},t.findFragmentByPTS=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=e?t[e.sn-t[0].sn+1]:null;if(i&&!o(r,a,i))return i;return n.default.search(t,o.bind(null,r,a))},t.fragmentWithinToleranceTest=o,t.pdtWithinToleranceTest=s;var a,i=r(9),n=(a=i)&&a.__esModule?a:{default:a};function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments[2],a=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-a<=e?1:r.start-a>e&&r.start?-1:0}function s(e,t,r){var a=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.endProgramDateTime-a>e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=r(3);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(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}var l=function(e){function t(e){var r;o(this,t);for(var a=arguments.length,i=Array(a>1?a-1:0),n=1;n<a;n++)i[n-1]=arguments[n];var l=s(this,(r=t.__proto__||Object.getPrototypeOf(t)).call.apply(r,[this,e].concat(i)));return l._tickInterval=null,l._tickTimer=null,l._tickCallCount=0,l._boundTick=l.tick.bind(l),l}return 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)}(t,e),i(t,[{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return!this._tickInterval&&(this._tickInterval=setInterval(this._boundTick,e),!0)}))},{key:"clearInterval",value:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(){return!!this._tickInterval&&(clearInterval(this._tickInterval),this._tickInterval=null,!0)}))},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&(this.clearNextTick(),this._tickTimer=setTimeout(this._boundTick,0)),this._tickCallCount=0)}},{key:"doTick",value:function(){}}]),t}(((a=n)&&a.__esModule?a:{default:a}).default);t.default=l,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendAddTrackEvent=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.clearCurrentCues=function(e){if(e&&e.cues)for(;e.cues.length>0;)e.removeCue(e.cues[0])}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fixLineBreaks=void 0;var a,i=r(71),n=(a=i)&&a.__esModule?a:{default:a};var o=function(){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 o,this.regionList=[]}function l(){this.values=Object.create(null)}function u(e,t,r,a){var i=a?e.split(a):[e];for(var n in i)if("string"==typeof i[n]){var o=i[n].split(r);if(2===o.length)t(o[0],o[1])}}l.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]*)?%$/)&&(t=parseFloat(t))>=0&&t<=100)&&(this.set(e,t),!0)}};var d=new n.default(0,0,0),f="middle"===d.align?"middle":"center";function c(e,t,r){var a=e;function i(){var t=function(e){function t(e,t,r,a){return 3600*(0|e)+60*(0|t)+(0|r)+(0|a)/1e3}var r=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?t(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?t(r[1],r[2],0,r[4]):t(0,r[1],r[2],r[4]):null}(e);if(null===t)throw new Error("Malformed timestamp: "+a);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function n(){e=e.replace(/^\s+/,"")}if(n(),t.startTime=i(),n(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+a);e=e.substr(3),n(),t.endTime=i(),n(),function(e,t){var a=new l;u(e,(function(e,t){switch(e){case"region":for(var i=r.length-1;i>=0;i--)if(r[i].id===t){a.set(e,r[i].region);break}break;case"vertical":a.alt(e,t,["rl","lr"]);break;case"line":var n=t.split(","),o=n[0];a.integer(e,o),a.percent(e,o)&&a.set("snapToLines",!1),a.alt(e,o,["auto"]),2===n.length&&a.alt("lineAlign",n[1],["start",f,"end"]);break;case"position":n=t.split(","),a.percent(e,n[0]),2===n.length&&a.alt("positionAlign",n[1],["start",f,"end","line-left","line-right","auto"]);break;case"size":a.percent(e,t);break;case"align":a.alt(e,t,["start",f,"end","left","right"])}}),/:/,/\s/),t.region=a.get("region",null),t.vertical=a.get("vertical","");var i=a.get("line","auto");"auto"===i&&-1===d.line&&(i=-1),t.line=i,t.lineAlign=a.get("lineAlign","start"),t.snapToLines=a.get("snapToLines",!0),t.size=a.get("size",100),t.align=a.get("align",f);var n=a.get("position","auto");"auto"===n&&50===d.position&&(n="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=n}(e,t)}function h(e){return e.replace(/<br(?: \/)?>/gi,"\n")}s.prototype={parse:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=h(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var a=e.substr(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.substr(r),a}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var a=void 0;if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var i=(a=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:a=r(),t.state){case"HEADER":/:/.test(a)?u(a,(function(e,t){}),/:/):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new n.default(0,0,""),t.state="CUE",-1===a.indexOf("--\x3e")){t.cue.id=a;continue}case"CUE":try{c(a,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==a.indexOf("--\x3e");if(!a||s&&(o=!0)){t.oncue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}t.cue.text&&(t.cue.text+="\n"),t.cue.text+=a;continue;case"BADCUE":a||(t.state="ID");continue}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.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}},t.fixLineBreaks=h,t.default=s},function(e,t,r){e.exports=r(32)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=s(r(33)),n=s(r(34)),o=s(r(80));function s(e){return e&&e.__esModule?e:{default:e}}function l(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}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=l(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));r.hlsOpts=e.hlsOpts||{};var a=i.default.util,s=r;if(s.once("complete",(function(){if(s.config.isLive&&(a.addClass(s.root,"xgplayer-is-live"),!a.findDom(s.controls,".xgplayer-live"))){var e=a.createDom("xg-live","æ£åœ¨ç›´æ’",{},"xgplayer-live");s.controls.appendChild(e)}})),r.browser=o.default.getBrowserVersion(),void 0===s.config.useHls){if("mobile"===i.default.sniffer.device&&"MacIntel"!==navigator.platform&&"Win32"!==navigator.platform||r.browser.indexOf("Safari")>-1)return l(r)}else if(!s.config.useHls)return l(r);Number.isFinite=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)};var u=void 0;return u=new n.default(r.hlsOpts),r.hls=u,Object.defineProperty(s,"src",{get:function(){return s.currentSrc},set:function(e){a.removeClass(s.root,"xgplayer-is-live");var t=document.querySelector(".xgplayer-live");t&&t.parentNode.removeChild(t);var r=s.paused;s.hls.stopLoad(),s.hls.detachMedia(),s.hls.destroy(),s.hls=new n.default(s.hlsOpts),s.register(e),r?s.hls.loadSource(e):(s.pause(),s.once("pause",(function(){s.hls.loadSource(e)})),s.once("canplay",(function(){s.play().catch((function(e){}))}))),s.hls.attachMedia(s.video),s.once("canplay",(function(){s.currentTime=0}))},configurable:!0}),r.register(r.config.url),r.once("complete",(function(){u.attachMedia(s.video),s.once("canplay",(function(){s.config.autoplay&&s.play().catch((function(e){}))}))})),r.once("destroy",(function(){u.stopLoad()})),r}return 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)}(t,e),a(t,[{key:"register",value:function(e){var t=this.hls,r=i.default.util,a=this;t.on(n.default.Events.MEDIA_ATTACHED,(function(){t.loadSource(e)})),t.on(n.default.Events.LEVEL_LOADED,(function(e,i){if(!t.inited&&(t.inited=!0,i&&i.details&&i.details.live&&(r.addClass(a.root,"xgplayer-is-live"),!r.findDom(a.root,".xgplayer-live")))){var n=r.createDom("xg-live","æ£åœ¨ç›´æ’",{},"xgplayer-live");a.controls.appendChild(n)}})),t.on(n.default.Events.ERROR,(function(e,r){if(a.emit("HLS_ERROR",{errorType:r.type,errorDetails:r.details,errorFatal:r.fatal}),r.fatal)switch(r.type){case n.default.ErrorTypes.NETWORK_ERROR:t.startLoad();break;case n.default.ErrorTypes.MEDIA_ERROR:t.recoverMediaError();break;default:a.emit("error",r)}})),this._statistics()}},{key:"_statistics",value:function(){var e={speed:0,playerType:"HlsPlayer"},t={videoDataRate:0,audioDataRate:0},r=this.hls,a=this;r.on(n.default.Events.FRAG_LOAD_PROGRESS,(function(t,r){e.speed=r.stats.loaded/1e3})),r.on(n.default.Events.FRAG_PARSING_DATA,(function(e,r){"video"===r.type&&(t.fps=parseInt(r.nb/(r.endPTS-r.startPTS)))})),r.on(n.default.Events.FRAG_PARSING_INIT_SEGMENT,(function(e,r){if(t.hasAudio=!(!r.tracks||!r.tracks.audio),t.hasVideo=!(!r.tracks||!r.tracks.audio),t.hasAudio){var i=r.tracks.audio;t.audioChannelCount=i.metadata&&i.metadata.channelCount?i.metadata.channelCount:0,t.audioCodec=i.codec}if(t.hasVideo){var n=r.tracks.video;t.videoCodec=n.codec,t.width=n.metadata&&n.metadata.width?n.metadata.width:0,t.height=n.metadata&&n.metadata.height?n.metadata.height:0}t.duration=r.frag&&r.frag.duration?r.frag.duration:0,t.level=r.frag&&r.frag.level?r.frag.level:0,(t.videoCodec||t.audioCodec)&&(t.mimeType='video/hls; codecs="'+t.videoCodec+";"+t.audioCodec+'"'),a.mediainfo=t,a.emit("media_info",t)})),this._statisticsTimmer=setInterval((function(){a.emit("statistics_info",e),e.speed=0}),1e3)}},{key:"destroy",value:function(){(function e(t,r,a){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,a)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(a):void 0})(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this),clearInterval(this._statisticsTimmer)}}]),t}(i.default);u.isSupported=n.default.isSupported,t.default=u,e.exports=t.default},function(e,t){e.exports=window.Player},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(8)),n=r(2),o=y(r(15)),s=y(r(38)),l=y(r(39)),u=r(6),d=y(r(40)),f=y(r(57)),c=y(r(58)),h=r(59),v=r(0),g=r(60),p=y(r(1));function y(e){return e&&e.__esModule?e:{default:e}}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(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}var E=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m(this,t);var r=b(this,(t.__proto__||Object.getPrototypeOf(t)).call(this)),a=t.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(var i in a)i in e||(e[i]=a[i]);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,v.enableLogs)(e.debug),r.config=e,r._autoLevelCapping=-1;var n=r.abrController=new e.abrController(r),h=new e.bufferController(r),g=new e.capLevelController(r),p=new e.fpsController(r),y=new o.default(r),E=new s.default(r),_=new l.default(r),T=new c.default(r),S=r.levelController=new f.default(r),k=new u.FragmentTracker(r),R=r.streamController=new d.default(r,k),A=[S,R],w=e.audioStreamController;w&&A.push(new w(r,k)),r.networkControllers=A;var O=[y,E,_,n,h,g,p,T,k];if(w=e.audioTrackController){var L=new w(r);r.audioTrackController=L,O.push(L)}if(w=e.subtitleTrackController){var D=new w(r);r.subtitleTrackController=D,A.push(D)}if(w=e.emeController){var P=new w(r);r.emeController=P,O.push(P)}return(w=e.subtitleStreamController)&&A.push(new w(r,k)),(w=e.timelineController)&&O.push(new w(r)),r.coreComponents=O,r}return 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)}(t,e),a(t,null,[{key:"isSupported",value:function(){return(0,h.isSupported)()}},{key:"version",get:function(){return __VERSION__}},{key:"Events",get:function(){return p.default}},{key:"ErrorTypes",get:function(){return n.ErrorTypes}},{key:"ErrorDetails",get:function(){return n.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:g.hlsDefaultConfig},set:function(e){t.defaultConfig=e}}]),a(t,[{key:"destroy",value:function(){v.logger.log("destroy"),this.trigger(p.default.DESTROYING),this.detachMedia(),this.coreComponents.concat(this.networkControllers).forEach((function(e){e.destroy()})),this.url=null,this.removeAllListeners(),this._autoLevelCapping=-1}},{key:"attachMedia",value:function(e){v.logger.log("attachMedia"),this.media=e,this.trigger(p.default.MEDIA_ATTACHING,{media:e})}},{key:"detachMedia",value:function(){v.logger.log("detachMedia"),this.trigger(p.default.MEDIA_DETACHING),this.media=null}},{key:"loadSource",value:function(e){e=i.buildAbsoluteURL(window.location.href,e,{alwaysNormalize:!0}),v.logger.log("loadSource:"+e),this.url=e,this.trigger(p.default.MANIFEST_LOADING,{url:e})}},{key:"startLoad",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1;v.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))}},{key:"stopLoad",value:function(){v.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))}},{key:"swapAudioCodec",value:function(){v.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){v.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){v.logger.log("set currentLevel:"+e),this.loadLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){v.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){v.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){v.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){v.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){v.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((e[a].realBitrate?Math.max(e[a].realBitrate,e[a].bitrate):e[a].bitrate)>t)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)}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}}]),t}(r(24).Observer);t.default=E,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(8)),n=f(r(11)),o=f(r(36)),s=f(r(17)),l=f(r(37)),u=r(0),d=r(18);function f(e){return e&&e.__esModule?e:{default:e}}var c=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,h=/#EXT-X-MEDIA:(.*)/g,v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),g=/(?:(?:#(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?/,p=/\.(mp4|m4s|m4v|m4a)$/i,y=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return a(e,null,[{key:"findGroup",value:function(e,t){if(!e)return null;for(var r=null,a=0;a<e.length;a++){var i=e[a];i.id===t&&(r=i)}return r}},{key:"convertAVC1ToAVCOTI",value:function(e){var t=void 0,r=e.split(".");return r.length>2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t}},{key:"resolve",value:function(e,t){return i.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"parseMasterPlaylist",value:function(t,r){var a=[],i=void 0;function n(e,t){["video","audio"].forEach((function(r){var a=e.filter((function(e){return(0,d.isCodecType)(e,r)}));if(a.length){var i=a.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=i.length>0?i[0]:a[0],e=e.filter((function(e){return-1===a.indexOf(e)}))}})),t.unknownCodecs=e}for(c.lastIndex=0;null!=(i=c.exec(t));){var o={},s=o.attrs=new l.default(i[1]);o.url=e.resolve(i[2],r);var u=s.decimalResolution("RESOLUTION");u&&(o.width=u.width,o.height=u.height),o.bitrate=s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),o.name=s.NAME,n([].concat((s.CODECS||"").split(/[ ,]+/)),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=e.convertAVC1ToAVCOTI(o.videoCodec)),a.push(o)}return a}},{key:"parseMasterPlaylistMedia",value:function(t,r,a){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],n=void 0,o=[],s=0;for(h.lastIndex=0;null!==(n=h.exec(t));){var u={},d=new l.default(n[1]);if(d.TYPE===a){if(u.groupId=d["GROUP-ID"],u.name=d.NAME,u.type=a,u.default="YES"===d.DEFAULT,u.autoselect="YES"===d.AUTOSELECT,u.forced="YES"===d.FORCED,d.URI&&(u.url=e.resolve(d.URI,r)),u.lang=d.LANGUAGE,u.name||(u.name=u.lang),i.length){var f=e.findGroup(i,u.groupId);u.audioCodec=f?f.codec:i[0].codec}u.id=s++,o.push(u)}}return o}},{key:"parseLevelPlaylist",value:function(e,t,r,a,i){var d=0,f=0,c=new o.default(t),h=new s.default,y=0,b=null,E=new n.default,_=void 0,T=void 0,S=null;for(v.lastIndex=0;null!==(_=v.exec(e));){var k=_[1];if(k){E.duration=parseFloat(k);var R=(" "+_[2]).slice(1);E.title=R||null,E.tagList.push(R?["INF",k,R]:["INF",k])}else if(_[3]){if(Number.isFinite(E.duration)){var A=d++;E.type=a,E.start=f,E.levelkey=h,E.sn=A,E.level=r,E.cc=y,E.urlId=i,E.baseurl=t,E.relurl=(" "+_[3]).slice(1),m(E,b),c.fragments.push(E),b=E,f+=E.duration,E=new n.default}}else if(_[4]){if(E.rawByteRange=(" "+_[4]).slice(1),b){var w=b.byteRangeEndOffset;w&&(E.lastByteRangeEndOffset=w)}}else if(_[5])E.rawProgramDateTime=(" "+_[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),null===S&&(S=c.fragments.length);else{for(_=_[0].match(g),T=1;T<_.length&&void 0===_[T];T++);var O=(" "+_[T+1]).slice(1),L=(" "+_[T+2]).slice(1);switch(_[T]){case"#":E.tagList.push(L?[O,L]:[O]);break;case"PLAYLIST-TYPE":c.type=O.toUpperCase();break;case"MEDIA-SEQUENCE":d=c.startSN=parseInt(O);break;case"TARGETDURATION":c.targetduration=parseFloat(O);break;case"VERSION":c.version=parseInt(O);break;case"EXTM3U":break;case"ENDLIST":c.live=!1;break;case"DIS":y++,E.tagList.push(["DIS"]);break;case"DISCONTINUITY-SEQ":y=parseInt(O);break;case"KEY":var D=O,P=new l.default(D),I=P.enumeratedString("METHOD"),C=P.URI,x=P.hexadecimalInteger("IV");I&&(h=new s.default,C&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(I)>=0&&(h.method=I,h.baseuri=t,h.reluri=C,h.key=null,h.iv=x));break;case"START":var M=O,F=new l.default(M).decimalFloatingPoint("TIME-OFFSET");Number.isFinite(F)&&(c.startTimeOffset=F);break;case"MAP":var N=new l.default(O);E.relurl=N.URI,E.rawByteRange=N.BYTERANGE,E.baseurl=t,E.level=r,E.type=a,E.sn="initSegment",c.initSegment=E,(E=new n.default).rawProgramDateTime=c.initSegment.rawProgramDateTime;break;default:u.logger.warn("line parsed but not handled: "+_)}}}return(E=b)&&!E.relurl&&(c.fragments.pop(),f-=E.duration),c.totalduration=f,c.averagetargetduration=f/c.fragments.length,c.endSN=d-1,c.startCC=c.fragments[0]?c.fragments[0].cc:0,c.endCC=y,!c.initSegment&&c.fragments.length&&c.fragments.every((function(e){return p.test(e.relurl)}))&&(u.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(E=new n.default).relurl=c.fragments[0].relurl,E.baseurl=t,E.level=r,E.type=a,E.sn="initSegment",c.initSegment=E,c.needSidxRanges=!0),S&&function(e,t){for(var r=e[t],a=t-1;a>=0;a--){var i=e[a];i.programDateTime=r.programDateTime-1e3*i.duration,r=i}}(c.fragments,S),c}}]),e}();function m(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Number.isFinite(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}t.default=y,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.endCC=0,this.endSN=0,this.fragments=[],this.initSegment=null,this.live=!0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=t,this.version=null}return a(e,[{key:"hasProgramDateTime",get:function(){return!(!this.fragments[0]||!Number.isFinite(this.fragments[0].programDateTime))}}]),e}();t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,o=function(){function e(t){for(var r in function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}return a(e,[{key:"decimalInteger",value:function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var 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){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"decimalResolution",value:function(e){var t=i.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e){var t=void 0,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}}]),e}();t.default=o,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=l(r(1)),n=l(r(3)),o=r(2),s=r(0);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.FRAG_LOADING));return r.loaders={},r}return 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)}(t,e),a(t,[{key:"destroy",value:function(){var e=this.loaders;for(var r in e){var a=e[r];a&&a.destroy()}this.loaders={},function e(t,r,a){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,a)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(a):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this)}},{key:"onFragLoading",value:function(e){var t=e.frag,r=t.type,a=this.loaders,i=this.hls.config,n=i.fLoader,o=i.loader;t.loaded=0;var l=a[r];l&&(s.logger.warn("abort previous fragment loader for type: "+r),l.abort()),l=a[r]=t.loader=i.fLoader?new n(i):new o(i);var u,d,f=void 0;f={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var c=t.byteRangeStartOffset,h=t.byteRangeEndOffset;Number.isFinite(c)&&Number.isFinite(h)&&(f.rangeStart=c,f.rangeEnd=h),u={timeout:i.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:i.fragLoadingMaxRetryTimeout},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},l.load(f,u,d)}},{key:"loadsuccess",value:function(e,t,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=e.data,o=r.frag;o.loader=void 0,this.loaders[o.type]=void 0,this.hls.trigger(i.default.FRAG_LOADED,{payload:n,frag:o,stats:t,networkDetails:a})}},{key:"loaderror",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=t.frag,n=a.loader;n&&n.abort(),this.loaders[a.type]=void 0,this.hls.trigger(i.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})}},{key:"loadtimeout",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=t.frag,n=a.loader;n&&n.abort(),this.loaders[a.type]=void 0,this.hls.trigger(i.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})}},{key:"loadprogress",value:function(e,t,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,n=t.frag;n.loaded=e.loaded,this.hls.trigger(i.default.FRAG_LOAD_PROGRESS,{frag:n,stats:e,networkDetails:a})}}]),t}(n.default);t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=l(r(1)),n=l(r(3)),o=r(2),s=r(0);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.KEY_LOADING));return r.loaders={},r.decryptkey=null,r.decrypturl=null,r}return 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)}(t,e),a(t,[{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=e.frag,r=t.type,a=this.loaders[r],n=t.decryptdata,o=n.uri;if(o!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;a&&(s.logger.warn("abort previous key loader for type:"+r),a.abort()),t.loader=this.loaders[r]=new l.loader(l),this.decrypturl=o,this.decryptkey=null;var u,d,f;u={url:o,frag:t,responseType:"arraybuffer"},d={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)},t.loader.load(u,d,f)}else this.decryptkey&&(n.key=this.decryptkey,this.hls.trigger(i.default.KEY_LOADED,{frag:t}))}},{key:"loadsuccess",value:function(e,t,r){var a=r.frag;this.decryptkey=a.decryptdata.key=new Uint8Array(e.data),a.loader=void 0,this.loaders[a.type]=void 0,this.hls.trigger(i.default.KEY_LOADED,{frag:a})}},{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(i.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.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(i.default.ERROR,{type:o.ErrorTypes.NETWORK_ERROR,details:o.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})}}]),t}(n.default);t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=E(r(9)),n=r(4),o=E(r(19)),s=E(r(1)),l=r(6),u=E(r(11)),d=E(r(15)),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(7)),c=E(r(25)),h=r(2),v=r(0),g=r(26),p=r(27),y=E(r(56)),m=r(14),b=E(m);function E(e){return e&&e.__esModule?e:{default:e}}var _=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var a=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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,s.default.MEDIA_ATTACHED,s.default.MEDIA_DETACHING,s.default.MANIFEST_LOADING,s.default.MANIFEST_PARSED,s.default.LEVEL_LOADED,s.default.KEY_LOADED,s.default.FRAG_LOADED,s.default.FRAG_LOAD_EMERGENCY_ABORTED,s.default.FRAG_PARSING_INIT_SEGMENT,s.default.FRAG_PARSING_DATA,s.default.FRAG_PARSED,s.default.ERROR,s.default.AUDIO_TRACK_SWITCHING,s.default.AUDIO_TRACK_SWITCHED,s.default.BUFFER_CREATED,s.default.BUFFER_APPENDED,s.default.BUFFER_FLUSHED));return a.fragmentTracker=r,a.config=e.config,a.audioCodecSwap=!1,a._state=m.State.STOPPED,a.stallReported=!1,a.gapController=null,a}return 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)}(t,e),a(t,[{key:"startLoad",value:function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var a=r.startLevel;-1===a&&(a=0,this.bitrateTest=!0),this.level=r.nextLoadLevel=a,this.loadedmetadata=!1}t>0&&-1===e&&(v.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=m.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=m.State.STOPPED}},{key:"stopLoad",value:function(){this.forceStartLoad=!1,function e(t,r,a){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,a)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(a):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"stopLoad",this).call(this)}},{key:"doTick",value:function(){switch(this.state){case m.State.BUFFER_FLUSHING:this.fragLoadError=0;break;case m.State.IDLE:this._doTickIdle();break;case m.State.WAITING_LEVEL:var e=this.levels[this.level];e&&e.details&&(this.state=m.State.IDLE);break;case m.State.FRAG_LOADING_WAITING_RETRY:var t=window.performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(v.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=m.State.IDLE);break;case m.State.ERROR:case m.State.STOPPED:case m.State.FRAG_LOADING:case m.State.PARSING:case m.State.PARSED:case m.State.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;var i=e.nextLoadLevel,o=this.levels[i];if(o){var l=o.bitrate,u=void 0;u=l?Math.max(8*t.maxBufferSize/l,t.maxBufferLength):t.maxBufferLength,u=Math.min(u,t.maxMaxBufferLength);var d=n.BufferHelper.bufferInfo(this.mediaBuffer?this.mediaBuffer:r,a,t.maxBufferHole),f=d.len;if(!(f>=u)){v.logger.trace("buffer length of "+f.toFixed(3)+" is below max of "+u.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=i;var c=o.details;if(!c||c.live&&this.levelLastLoaded!==i)this.state=m.State.WAITING_LEVEL;else{if(this._streamEnded(d,c)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(s.default.BUFFER_EOS,h),void(this.state=m.State.ENDED)}this._fetchPayloadOrEos(a,d,c)}}}}}},{key:"_fetchPayloadOrEos",value:function(e,t,r){var a=this.fragPrevious,i=this.level,n=r.fragments,o=n.length;if(0!==o){var s=n[0].start,l=n[o-1].start+n[o-1].duration,u=t.end,d=void 0;if(r.initSegment&&!r.initSegment.data)d=r.initSegment;else if(r.live){var f=this.config.initialLiveManifestSize;if(o<f)return void v.logger.warn("Can not start playback of a level, reason: not enough fragments "+o+" < "+f);if(null===(d=this._ensureFragmentAtLivePoint(r,u,s,l,a,n,o)))return}else u<s&&(d=n[0]);d||(d=this._findFragment(s,a,o,n,u,l,r)),d&&(d.encrypted?(v.logger.log("Loading key for "+d.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+i),this._loadKey(d)):(v.logger.log("Loading "+d.sn+" of ["+r.startSN+" ,"+r.endSN+"],level "+i+", currentTime:"+e.toFixed(3)+",bufferEnd:"+u.toFixed(3)),this._loadFragment(d)))}}},{key:"_ensureFragmentAtLivePoint",value:function(e,t,r,a,n,o,s){var l=this.hls.config,u=this.media,d=void 0,f=void 0!==l.liveMaxLatencyDuration?l.liveMaxLatencyDuration:l.liveMaxLatencyDurationCount*e.targetduration;if(t<Math.max(r-l.maxFragLookUpTolerance,a-f)){var c=this.liveSyncPosition=this.computeLivePosition(r,e);v.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+c.toFixed(3)),t=c,u&&u.readyState&&u.duration>c&&(u.currentTime=c),this.nextLoadPosition=c}if(e.PTSKnown&&t>a&&u&&u.readyState)return null;if(this.startFragRequested&&!e.PTSKnown){if(n)if(e.hasProgramDateTime)v.logger.log("live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),d=(0,p.findFragmentByPDT)(o,n.endProgramDateTime,l.maxFragLookUpTolerance);else{var h=n.sn+1;if(h>=e.startSN&&h<=e.endSN){var g=o[h-e.startSN];n.cc===g.cc&&(d=g,v.logger.log("live playlist, switching playlist, load frag with next SN: "+d.sn))}d||(d=i.default.search(o,(function(e){return n.cc-e.cc})))&&v.logger.log("live playlist, switching playlist, load frag with same CC: "+d.sn)}d||(d=o[Math.min(s-1,Math.round(s/2))],v.logger.log("live playlist, switching playlist, unknown, load middle frag : "+d.sn))}return d}},{key:"_findFragment",value:function(e,t,r,a,i,n,o){var s=this.hls.config,l=void 0;if(i<n){var u=i>n-s.maxFragLookUpTolerance?0:s.maxFragLookUpTolerance;l=(0,p.findFragmentByPTS)(t,a,i,u)}else l=a[r-1];if(l){var d=l.sn-o.startSN,f=t&&l.level===t.level,c=a[d-1],h=a[d+1];if(t&&l.sn===t.sn)if(f&&!l.backtracked)if(l.sn<o.endSN){var g=t.deltaPTS;g&&g>s.maxBufferHole&&t.dropped&&d?(l=c,v.logger.warn("SN just loaded, with large PTS gap between audio and video, maybe frag is not starting with a keyframe ? load previous one to try to overcome this")):(l=h,v.logger.log("SN just loaded, load next one: "+l.sn,l))}else l=null;else l.backtracked&&(h&&h.backtracked?(v.logger.warn("Already backtracked from fragment "+h.sn+", will not backtrack to fragment "+l.sn+". Loading fragment "+h.sn),l=h):(v.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),l.dropped=0,c?(l=c).backtracked=!0:d&&(l=null)))}return l}},{key:"_loadKey",value:function(e){this.state=m.State.KEY_LOADING,this.hls.trigger(s.default.KEY_LOADING,{frag:e})}},{key:"_loadFragment",value:function(e){var t=this.fragmentTracker.getState(e);this.fragCurrent=e,this.startFragRequested=!0,Number.isFinite(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===l.FragmentState.NOT_LOADED||t===l.FragmentState.PARTIAL?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(s.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new o.default(this.hls,"main")),this.state=m.State.FRAG_LOADING):t===l.FragmentState.APPENDING&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,d.default.LevelType.MAIN)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.endPTS+.5):null}},{key:"_checkFragmentChanged",value:function(){var e=void 0,t=void 0,r=this.media;if(r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),n.BufferHelper.isBuffered(r,t)?e=this.getBufferedFrag(t):n.BufferHelper.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var a=e;if(a!==this.fragPlaying){this.hls.trigger(s.default.FRAG_CHANGED,{frag:a});var i=a.level;this.fragPlaying&&this.fragPlaying.level===i||this.hls.trigger(s.default.LEVEL_SWITCHED,{level:i}),this.fragPlaying=a}}}},{key:"immediateLevelSwitch",value:function(){if(v.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e=this.media,t=void 0;e?(t=e.paused,e.pause()):t=!0,this.previouslyPaused=t}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}},{key:"immediateLevelSwitchEnd",value:function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,n.BufferHelper.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())}},{key:"nextLevelSwitch",value:function(){var e=this.media;if(e&&e.readyState){var t,r=void 0,a=void 0;if((t=this.getBufferedFrag(e.currentTime))&&t.startPTS>1&&this.flushMainBuffer(0,t.startPTS-1),e.paused)r=0;else{var i=this.hls.nextLoadLevel,n=this.levels[i],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*o)+1:0}if((a=this.getBufferedFrag(e.currentTime+r))&&(a=this.followingBufferedFrag(a))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(a.maxStartPTS,Number.POSITIVE_INFINITY)}}}},{key:"flushMainBuffer",value:function(e,t){this.state=m.State.BUFFER_FLUSHING;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(s.default.BUFFER_FLUSHING,r)}},{key:"onMediaAttached",value:function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition),this.gapController=new y.default(r,t,this.fragmentTracker,this.hls)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(v.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.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:"onMediaSeeked",value:function(){var e=this.media,t=e?e.currentTime:void 0;Number.isFinite(t)&&v.logger.log("media seeked to "+t.toFixed(3)),this.tick()}},{key:"onManifestLoading",value:function(){v.logger.log("trigger BUFFER_RESET"),this.hls.trigger(s.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0}},{key:"onManifestParsed",value:function(e){var t=!1,r=!1,a=void 0;e.levels.forEach((function(e){(a=e.audioCodec)&&(-1!==a.indexOf("mp4a.40.2")&&(t=!0),-1!==a.indexOf("mp4a.40.5")&&(r=!0))})),this.audioCodecSwitch=t&&r,this.audioCodecSwitch&&v.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1;var i=this.config;(i.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(i.startPosition)}},{key:"onLevelLoaded",value:function(e){var t=e.details,r=e.level,a=this.levels[this.levelLastLoaded],i=this.levels[r],n=t.totalduration,o=0;if(v.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+n),t.live){var l=i.details;l&&t.fragments.length>0?(f.mergeDetails(l,t),o=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(o,l),t.PTSKnown&&Number.isFinite(o)?v.logger.log("live playlist sliding:"+o.toFixed(3)):(v.logger.log("live playlist - outdated PTS, unknown sliding"),(0,g.alignStream)(this.fragPrevious,a,t))):(v.logger.log("live playlist - first load, unknown sliding"),t.PTSKnown=!1,(0,g.alignStream)(this.fragPrevious,a,t))}else t.PTSKnown=!1;if(i.details=t,this.levelLastLoaded=r,this.hls.trigger(s.default.LEVEL_UPDATED,{details:t,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var u=t.startTimeOffset;Number.isFinite(u)?(u<0&&(v.logger.log("negative start time offset "+u+", count from end of last fragment"),u=o+n+u),v.logger.log("start time offset found in playlist, adjust startPosition to "+u),this.startPosition=u):t.live?(this.startPosition=this.computeLivePosition(o,t),v.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===m.State.WAITING_LEVEL&&(this.state=m.State.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===m.State.KEY_LOADING&&(this.state=m.State.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=this.hls,a=this.levels,i=this.media,n=e.frag;if(this.state===m.State.FRAG_LOADING&&t&&"main"===n.type&&n.level===t.level&&n.sn===t.sn){var l=e.stats,u=a[t.level],d=u.details;if(this.bitrateTest=!1,this.stats=l,v.logger.log("Loaded "+t.sn+" of ["+d.startSN+" ,"+d.endSN+"],level "+t.level),n.bitrateTest&&r.nextLoadLevel)this.state=m.State.IDLE,this.startFragRequested=!1,l.tparsed=l.tbuffered=window.performance.now(),r.trigger(s.default.FRAG_BUFFERED,{stats:l,frag:t,id:"main"}),this.tick();else if("initSegment"===n.sn)this.state=m.State.IDLE,l.tparsed=l.tbuffered=window.performance.now(),d.initSegment.data=e.payload,r.trigger(s.default.FRAG_BUFFERED,{stats:l,frag:t,id:"main"}),this.tick();else{v.logger.log("Parsing "+t.sn+" of ["+d.startSN+" ,"+d.endSN+"],level "+t.level+", cc "+t.cc),this.state=m.State.PARSING,this.pendingBuffering=!0,this.appended=!1,n.bitrateTest&&(n.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:n}));var f=!(i&&i.seeking)&&(d.PTSKnown||!d.live),c=d.initSegment?d.initSegment.data:[],h=this._getAudioCodec(u);(this.demuxer=this.demuxer||new o.default(this.hls,"main")).push(e.payload,c,h,u.videoCodec,t,d.totalduration,f)}}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===m.State.PARSING){var a=e.tracks,i=void 0,n=void 0;if(a.audio&&this.altAudio&&delete a.audio,n=a.audio){var o=this.levels[this.level].audioCodec,l=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(v.logger.log("swapping playlist audio codec"),o=-1!==o.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==n.metadata.channelCount&&-1===l.indexOf("firefox")&&(o="mp4a.40.5"),-1!==l.indexOf("android")&&"audio/mpeg"!==n.container&&(o="mp4a.40.2",v.logger.log("Android: force audio codec to "+o)),n.levelCodec=o,n.id=e.id}for(i in(n=a.video)&&(n.levelCodec=this.levels[this.level].videoCodec,n.id=e.id),this.hls.trigger(s.default.BUFFER_CODECS,a),a){n=a[i],v.logger.log("main track:"+i+",container:"+n.container+",codecs[level/parsed]=["+n.levelCodec+"/"+n.codec+"]");var u=n.initSegment;u&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(s.default.BUFFER_APPENDING,{type:i,data:u,parent:"main",content:"initSegment"}))}this.tick()}}},{key:"onFragParsingData",value:function(e){var t=this,r=this.fragCurrent,a=e.frag;if(r&&"main"===e.id&&a.sn===r.sn&&a.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===m.State.PARSING){var i=this.levels[this.level],n=r;if(Number.isFinite(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),!0===e.hasAudio&&n.addElementaryStream(u.default.ElementaryStreamTypes.AUDIO),!0===e.hasVideo&&n.addElementaryStream(u.default.ElementaryStreamTypes.VIDEO),v.logger.log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0)),"video"===e.type)if(n.dropped=e.dropped,n.dropped)if(n.backtracked)v.logger.warn("Already backtracked on this fragment, appending with the gap",n.sn);else{var o=i.details;if(!o||n.sn!==o.startSN)return v.logger.warn("missing video frame(s), backtracking fragment",n.sn),this.fragmentTracker.removeFragment(n),n.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=m.State.IDLE,this.fragPrevious=n,void this.tick();v.logger.warn("missing video frame(s) on first frag, appending with gap",n.sn)}else n.backtracked=!1;var l=f.updateFragPTSDTS(i.details,n,e.startPTS,e.endPTS,e.startDTS,e.endDTS),d=this.hls;d.trigger(s.default.LEVEL_PTS_UPDATED,{details:i.details,level:this.level,drift:l,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach((function(r){r&&r.length&&t.state===m.State.PARSING&&(t.appended=!0,t.pendingBuffering=!0,d.trigger(s.default.BUFFER_APPENDING,{type:e.type,data:r,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===m.State.PARSING&&(this.stats.tparsed=window.performance.now(),this.state=m.State.PARSED,this._checkAppendedParsed())}},{key:"onAudioTrackSwitching",value:function(e){var t=!!e.url,r=e.id;if(!t){if(this.mediaBuffer!==this.media){v.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a.loader&&(v.logger.log("switching to main audio track, cancel main fragment load"),a.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=m.State.IDLE}var i=this.hls;i.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),i.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:r}),this.altAudio=!1}}},{key:"onAudioTrackSwitched",value:function(e){var t=e.id,r=!!this.hls.audioTracks[t].url;if(r){var a=this.videoBuffer;a&&this.mediaBuffer!==a&&(v.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=r,this.tick()}},{key:"onBufferCreated",value:function(e){var t=e.tracks,r=void 0,a=void 0,i=!1;for(var n in t){var o=t[n];"main"===o.id?(a=n,r=o,"video"===n&&(this.videoBuffer=t[n].buffer)):i=!0}i&&r?(v.logger.log("alternate track found, use "+a+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}},{key:"onBufferAppended",value:function(e){if("main"===e.parent){var t=this.state;t!==m.State.PARSING&&t!==m.State.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}}},{key:"_checkAppendedParsed",value:function(){if(!(this.state!==m.State.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;v.logger.log("main buffered : "+c.default.toString(t.buffered)),this.fragPrevious=e;var r=this.stats;r.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*r.total/(r.tbuffered-r.tfirst)),this.hls.trigger(s.default.FRAG_BUFFERED,{stats:r,frag:e,id:"main"}),this.state=m.State.IDLE}this.tick()}}},{key:"onError",value:function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=!!this.media&&n.BufferHelper.isBuffered(this.media,this.media.currentTime)&&n.BufferHelper.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:if(!e.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var a=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);v.logger.warn("mediaController: frag loading failed, retry in "+a+" ms"),this.retryDate=window.performance.now()+a,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=m.State.FRAG_LOADING_WAITING_RETRY}else v.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=m.State.ERROR;break;case h.ErrorDetails.LEVEL_LOAD_ERROR:case h.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==m.State.ERROR&&(e.fatal?(this.state=m.State.ERROR,v.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==m.State.WAITING_LEVEL||(this.state=m.State.IDLE));break;case h.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==m.State.PARSING&&this.state!==m.State.PARSED||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=m.State.IDLE):(v.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;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,v.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)}},{key:"_checkBuffer",value:function(){var e=this.media;if(e&&0!==e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,t)}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=m.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()}},{key:"onBufferFlushed",value:function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;e&&this.fragmentTracker.detectEvictedFragments(u.default.ElementaryStreamTypes.VIDEO,e.buffered),this.state=m.State.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:"_seekToStartPos",value:function(){var e=this.media,t=e.currentTime,r=e.seeking?t:this.startPosition;t!==r&&(v.logger.log("target start position not buffered, seek to buffered.start(0) "+r+" from current time "+t+" "),e.currentTime=r)}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(v.logger.log("swapping playlist audio codec"),t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t}},{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,v.logger.log("main stream:"+t+"->"+e),this.hls.trigger(s.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.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}}]),t}(b.default);t.default=_,e.exports=t.default},function(e,t,r){function a(e){var t={};function r(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.i=function(e){return e},r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:a})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r.oe=function(e){throw console.error(e),e};var a=r(r.s=ENTRY_MODULE);return a.default||a}function i(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function n(e,t,a){var n={};n[a]=[];var o=t.toString(),s=o.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!s)return n;for(var l,u=s[1],d=new RegExp("(\\\\n|\\W)"+i(u)+"\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");l=d.exec(o);)"dll-reference"!==l[3]&&n[a].push(l[3]);for(d=new RegExp("\\("+i(u)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)',"g");l=d.exec(o);)e[l[2]]||(n[a].push(l[1]),e[l[2]]=r(l[1]).m),n[l[2]]=n[l[2]]||[],n[l[2]].push(l[4]);for(var f,c=Object.keys(n),h=0;h<c.length;h++)for(var v=0;v<n[c[h]].length;v++)f=n[c[h]][v],isNaN(1*f)||(n[c[h]][v]=1*n[c[h]][v]);return n}function o(e){return Object.keys(e).reduce((function(t,r){return t||e[r].length>0}),!1)}e.exports=function(e,t){t=t||{};var i={main:r.m},s=t.all?{main:Object.keys(i.main)}:function(e,t){for(var r={main:[t]},a={main:[]},i={main:{}};o(r);)for(var s=Object.keys(r),l=0;l<s.length;l++){var u=s[l],d=r[u].pop();if(i[u]=i[u]||{},!i[u][d]&&e[u][d]){i[u][d]=!0,a[u]=a[u]||[],a[u].push(d);for(var f=n(e,e[u][d],u),c=Object.keys(f),h=0;h<c.length;h++)r[c[h]]=r[c[h]]||[],r[c[h]]=r[c[h]].concat(f[c[h]])}}return a}(i,e),l="";Object.keys(s).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;s[e][t];)t++;s[e].push(t),i[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",l=l+"var "+e+" = ("+a.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+s[e].map((function(t){return JSON.stringify(t)+": "+i[e][t].toString()})).join(",")+"});\n"})),l=l+"new (("+a.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+s.main.map((function(e){return JSON.stringify(e)+": "+i.main[e].toString()})).join(",")+"}))(self);";var u=new window.Blob([l],{type:"text/javascript"});if(t.bare)return u;var d=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(u),f=new window.Worker(d);return f.objectURL=d,f}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.subtle=t,this.aesIV=r}return a(e,[{key:"decrypt",value:function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}]),e}();t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.subtle=t,this.key=r}return a(e,[{key:"expandKey",value:function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}]),e}();t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();function i(e){var t=e.byteLength,r=t&&new DataView(e).getUint8(t-1);return r?e.slice(0,t-r):e}t.removePadding=i;var n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.initTable()}return a(e,[{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(){var e=this.sBox,t=this.invSBox,r=this.subMix,a=r[0],i=r[1],n=r[2],o=r[3],s=this.invSubMix,l=s[0],u=s[1],d=s[2],f=s[3],c=new Uint32Array(256),h=0,v=0,g=0;for(g=0;g<256;g++)c[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var p=v^v<<1^v<<2^v<<3^v<<4;p=p>>>8^255&p^99,e[h]=p,t[p]=h;var y=c[h],m=c[y],b=c[m],E=257*c[p]^16843008*p;a[h]=E<<24|E>>>8,i[h]=E<<16|E>>>16,n[h]=E<<8|E>>>24,o[h]=E,E=16843009*b^65537*m^257*y^16843008*h,l[p]=E<<24|E>>>8,u[p]=E<<16|E>>>16,d[p]=E<<8|E>>>24,f[p]=E,h?(h=y^c[c[c[b^y]]],v^=c[c[v]]):h=v=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);var n=this.ksRows=4*(i+6+1),o=void 0,s=void 0,l=this.keySchedule=new Uint32Array(n),u=this.invKeySchedule=new Uint32Array(n),d=this.sBox,f=this.rcon,c=this.invSubMix,h=c[0],v=c[1],g=c[2],p=c[3],y=void 0,m=void 0;for(o=0;o<n;o++)o<i?y=l[o]=t[o]:(m=y,o%i==0?(m=d[(m=m<<8|m>>>24)>>>24]<<24|d[m>>>16&255]<<16|d[m>>>8&255]<<8|d[255&m],m^=f[o/i|0]<<24):i>6&&o%i==4&&(m=d[m>>>24]<<24|d[m>>>16&255]<<16|d[m>>>8&255]<<8|d[255&m]),l[o]=y=(l[o-i]^m)>>>0);for(s=0;s<n;s++)o=n-s,m=3&s?l[o]:l[o-4],u[s]=s<4||o<=4?m:h[d[m>>>24]]^v[d[m>>>16&255]]^g[d[m>>>8&255]]^p[d[255&m]],u[s]=u[s]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,r,a){for(var n=this.keySize+6,o=this.invKeySchedule,s=this.invSBox,l=this.invSubMix,u=l[0],d=l[1],f=l[2],c=l[3],h=this.uint8ArrayToUint32Array_(r),v=h[0],g=h[1],p=h[2],y=h[3],m=new Int32Array(e),b=new Int32Array(m.length),E=void 0,_=void 0,T=void 0,S=void 0,k=void 0,R=void 0,A=void 0,w=void 0,O=void 0,L=void 0,D=void 0,P=void 0,I=void 0,C=void 0,x=this.networkToHostOrderSwap;t<m.length;){for(O=x(m[t]),L=x(m[t+1]),D=x(m[t+2]),P=x(m[t+3]),k=O^o[0],R=P^o[1],A=D^o[2],w=L^o[3],I=4,C=1;C<n;C++)E=u[k>>>24]^d[R>>16&255]^f[A>>8&255]^c[255&w]^o[I],_=u[R>>>24]^d[A>>16&255]^f[w>>8&255]^c[255&k]^o[I+1],T=u[A>>>24]^d[w>>16&255]^f[k>>8&255]^c[255&R]^o[I+2],S=u[w>>>24]^d[k>>16&255]^f[R>>8&255]^c[255&A]^o[I+3],k=E,R=_,A=T,w=S,I+=4;E=s[k>>>24]<<24^s[R>>16&255]<<16^s[A>>8&255]<<8^s[255&w]^o[I],_=s[R>>>24]<<24^s[A>>16&255]<<16^s[w>>8&255]<<8^s[255&k]^o[I+1],T=s[A>>>24]<<24^s[w>>16&255]<<16^s[k>>8&255]<<8^s[255&R]^o[I+2],S=s[w>>>24]<<24^s[k>>16&255]<<16^s[R>>8&255]<<8^s[255&A]^o[I+3],I+=3,b[t]=x(E^v),b[t+1]=x(S^g),b[t+2]=x(T^p),b[t+3]=x(_^y),v=O,g=L,p=D,y=P,t+=4}return a?i(b.buffer):b.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}}]),e}();t.default=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(22)),o=r(0),s=r(10),l=(a=s)&&a.__esModule?a:{default:a};var u=function(){function e(t,r,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=a,this.remuxer=r}return i(e,[{key:"resetInitSegment",value:function(e,t,r,a){this._audioTrack={container:"audio/adts",type:"audio",id:0,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=this._audioTrack,s=l.default.getID3Data(e,0)||[],u=l.default.getTimeStamp(s),d=Number.isFinite(u)?90*u:9e4*t,f=0,c=d,h=e.length,v=s.length,g=[{pts:c,dts:c,data:s}];v<h-1;)if(n.isHeader(e,v)&&v+5<h){n.initTrackConfig(i,this.observer,e,v,i.manifestCodec);var p=n.appendFrame(i,e,v,d,f);if(!p){o.logger.log("Unable to parse AAC frame");break}v+=p.length,c=p.sample.pts,f++}else l.default.isHeader(e,v)?(s=l.default.getID3Data(e,v),g.push({pts:c,dts:c,data:s}),v+=s.length):v++;this.remuxer.remux(i,{samples:[]},{samples:g,inputTimeScale:9e4},{samples:[]},t,r,a)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(e){if(!e)return!1;for(var t=(l.default.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(n.probe(e,t))return o.logger.log("ADTS sync word found !"),!0;return!1}}]),e}();t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(22)),n=f(r(23)),o=f(r(1)),s=f(r(47)),l=f(r(48)),u=r(0),d=r(2);function f(e){return e&&e.__esModule?e:{default:e}}var c={video:1,audio:2,id3:3,text:4},h=function(){function e(t,r,a,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=a,this.typeSupported=i,this.remuxer=r,this.sampleAes=null}return a(e,[{key:"setDecryptData",value:function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new l.default(this.observer,this.config,e,this.discardEPB):this.sampleAes=null}},{key:"resetInitSegment",value:function(t,r,a,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video",i),this._audioTrack=e.createTrack("audio",i),this._id3Track=e.createTrack("id3",i),this._txtTrack=e.createTrack("text",i),this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=r,this.videoCodec=a,this._duration=i}},{key:"resetTimeStamp",value:function(){}},{key:"append",value:function(t,r,a,i){var n=void 0,s=t.length,l=void 0,f=void 0,c=void 0,h=void 0,v=!1;this.contiguous=a;var g=this.pmtParsed,p=this._avcTrack,y=this._audioTrack,m=this._id3Track,b=p.pid,E=y.pid,_=m.pid,T=this._pmtId,S=p.pesData,k=y.pesData,R=m.pesData,A=this._parsePAT,w=this._parsePMT,O=this._parsePES,L=this._parseAVCPES.bind(this),D=this._parseAACPES.bind(this),P=this._parseMPEGPES.bind(this),I=this._parseID3PES.bind(this),C=e._syncOffset(t);for(s-=(s+C)%188,n=C;n<s;n+=188)if(71===t[n]){if(l=!!(64&t[n+1]),f=((31&t[n+1])<<8)+t[n+2],(48&t[n+3])>>4>1){if((c=n+5+t[n+4])===n+188)continue}else c=n+4;switch(f){case b:l&&(S&&(h=O(S))&&void 0!==h.pts&&L(h,!1),S={data:[],size:0}),S&&(S.data.push(t.subarray(c,n+188)),S.size+=n+188-c);break;case E:l&&(k&&(h=O(k))&&void 0!==h.pts&&(y.isAAC?D(h):P(h)),k={data:[],size:0}),k&&(k.data.push(t.subarray(c,n+188)),k.size+=n+188-c);break;case _:l&&(R&&(h=O(R))&&void 0!==h.pts&&I(h),R={data:[],size:0}),R&&(R.data.push(t.subarray(c,n+188)),R.size+=n+188-c);break;case 0:l&&(c+=t[c]+1),T=this._pmtId=A(t,c);break;case T:l&&(c+=t[c]+1);var x=w(t,c,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(b=x.avc)>0&&(p.pid=b),(E=x.audio)>0&&(y.pid=E,y.isAAC=x.isAAC),(_=x.id3)>0&&(m.pid=_),v&&!g&&(u.logger.log("reparse from beginning"),v=!1,n=C-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:v=!0}}else this.observer.trigger(o.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});S&&(h=O(S))&&void 0!==h.pts?(L(h,!0),p.pesData=null):p.pesData=S,k&&(h=O(k))&&void 0!==h.pts?(y.isAAC?D(h):P(h),y.pesData=null):(k&&k.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),y.pesData=k),R&&(h=O(R))&&void 0!==h.pts?(I(h),m.pesData=null):m.pesData=R,null==this.sampleAes?this.remuxer.remux(y,p,m,this._txtTrack,r,a,i):this.decryptAndRemux(y,p,m,this._txtTrack,r,a,i)}},{key:"decryptAndRemux",value:function(e,t,r,a,i,n,o){if(e.samples&&e.isAAC){var s=this;this.sampleAes.decryptAacSamples(e.samples,0,(function(){s.decryptAndRemuxAvc(e,t,r,a,i,n,o)}))}else this.decryptAndRemuxAvc(e,t,r,a,i,n,o)}},{key:"decryptAndRemuxAvc",value:function(e,t,r,a,i,n,o){if(t.samples){var s=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,(function(){s.remuxer.remux(e,t,r,a,i,n,o)}))}else this.remuxer.remux(e,t,r,a,i,n,o)}},{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=void 0,o={audio:-1,avc:-1,id3:-1,isAAC:!0};for(i=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t<i;){switch(n=(31&e[t+1])<<8|e[t+2],e[t]){case 207:if(!a){u.logger.log("unkown stream type:"+e[t]);break}case 15:-1===o.audio&&(o.audio=n);break;case 21:-1===o.id3&&(o.id3=n);break;case 219:if(!a){u.logger.log("unkown stream type:"+e[t]);break}case 27:-1===o.avc&&(o.avc=n);break;case 3:case 4:r?-1===o.audio&&(o.audio=n,o.isAAC=!1):u.logger.log("MPEG audio found, not supported in this browser for now");break;case 36:u.logger.warn("HEVC stream type found, not supported for now");break;default:u.logger.log("unkown stream type:"+e[t])}t+=5+((15&e[t+3])<<8|e[t+4])}return o}},{key:"_parsePES",value:function(e){var t=0,r=void 0,a=void 0,i=void 0,n=void 0,o=void 0,s=void 0,l=void 0,d=void 0,f=e.data;if(!e||0===e.size)return null;for(;f[0].length<19&&f.length>1;){var c=new Uint8Array(f[0].length+f[1].length);c.set(f[0]),c.set(f[1],f[0].length),f[0]=c,f.splice(1,1)}if(1===((r=f[0])[0]<<16)+(r[1]<<8)+r[2]){if((i=(r[4]<<8)+r[5])&&i>e.size-6)return null;192&(a=r[7])&&((s=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2)>4294967295&&(s-=8589934592),64&a?((l=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>4294967295&&(l-=8589934592),s-l>54e5&&(u.logger.warn(Math.round((s-l)/9e4)+"s delta between PTS and DTS, align them"),s=l)):l=s),d=(n=r[8])+9,e.size-=d,o=new Uint8Array(e.size);for(var h=0,v=f.length;h<v;h++){var g=(r=f[h]).byteLength;if(d){if(d>g){d-=g;continue}r=r.subarray(d),g-=d,d=0}o.set(r,t),t+=g}return i&&(i-=n+3),{data:o,pts:s,dts:l,len:i}}return null}},{key:"pushAccesUnit",value:function(e,t){if(e.units.length&&e.frame){var r=t.samples,a=r.length;!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(a||this.contiguous)?(e.id=a,r.push(e)):t.dropped++}e.debug.length&&u.logger.log(e.pts+"/"+e.dts+":"+e.debug)}},{key:"_parseAVCPES",value:function(e,t){var r=this,a=this._avcTrack,i=this._parseAVCNALu(e.data),n=void 0,o=this.avcSample,l=void 0,u=!1,d=void 0,f=this.pushAccesUnit.bind(this),c=function(e,t,r,a){return{key:e,pts:t,dts:r,units:[],debug:a}};e.data=null,o&&i.length&&!a.audFound&&(f(o,a),o=this.avcSample=c(!1,e.pts,e.dts,"")),i.forEach((function(t){switch(t.type){case 1:l=!0,o||(o=r.avcSample=c(!0,e.pts,e.dts,"")),o.frame=!0;var i=t.data;if(u&&i.length>4){var h=new s.default(i).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(o.key=!0)}break;case 5:l=!0,o||(o=r.avcSample=c(!0,e.pts,e.dts,"")),o.key=!0,o.frame=!0;break;case 6:l=!0,(n=new s.default(r.discardEPB(t.data))).readUByte();for(var v=0,g=0,p=!1,y=0;!p&&n.bytesAvailable>1;){v=0;do{v+=y=n.readUByte()}while(255===y);g=0;do{g+=y=n.readUByte()}while(255===y);if(4===v&&0!==n.bytesAvailable){if(p=!0,181===n.readUByte())if(49===n.readUShort())if(1195456820===n.readUInt())if(3===n.readUByte()){var m=n.readUByte(),b=31&m,E=[m,n.readUByte()];for(d=0;d<b;d++)E.push(n.readUByte()),E.push(n.readUByte()),E.push(n.readUByte());r._insertSampleInOrder(r._txtTrack.samples,{type:3,pts:e.pts,bytes:E})}}else if(g<n.bytesAvailable)for(d=0;d<g;d++)n.readUByte()}break;case 7:if(l=!0,u=!0,!a.sps){var _=(n=new s.default(t.data)).readSPS();a.width=_.width,a.height=_.height,a.pixelRatio=_.pixelRatio,a.sps=[t.data],a.duration=r._duration;var T=t.data.subarray(1,4),S="avc1.";for(d=0;d<3;d++){var k=T[d].toString(16);k.length<2&&(k="0"+k),S+=k}a.codec=S}break;case 8:l=!0,a.pps||(a.pps=[t.data]);break;case 9:l=!1,a.audFound=!0,o&&f(o,a),o=r.avcSample=c(!1,e.pts,e.dts,"");break;case 12:l=!1;break;default:l=!1,o&&(o.debug+="unknown NAL "+t.type+" ")}o&&l&&o.units.push(t)})),t&&o&&(f(o,a),this.avcSample=null)}},{key:"_insertSampleInOrder",value:function(e,t){var r=e.length;if(r>0){if(t.pts>=e[r-1].pts)e.push(t);else for(var a=r-1;a>=0;a--)if(t.pts<e[a].pts){e.splice(a,0,t);break}}else e.push(t)}},{key:"_getLastNalUnit",value:function(){var e=this.avcSample,t=void 0;if(!e||0===e.units.length){var r=this._avcTrack.samples;e=r[r.length-1]}if(e){var a=e.units;t=a[a.length-1]}return t}},{key:"_parseAVCNALu",value:function(e){var t=0,r=e.byteLength,a=void 0,i=void 0,n=this._avcTrack,o=n.naluState||0,s=o,l=[],u=void 0,d=-1,f=void 0;for(-1===o&&(d=0,f=31&e[0],o=0,t=1);t<r;)if(a=e[t++],o)if(1!==o)if(a)if(1===a){if(d>=0)u={data:e.subarray(d,t-o-1),type:f},l.push(u);else{var c=this._getLastNalUnit();if(c&&(s&&t<=4-s&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-s)),(i=t-o-1)>0)){var h=new Uint8Array(c.data.byteLength+i);h.set(c.data,0),h.set(e.subarray(0,i),c.data.byteLength),c.data=h}}t<r?(d=t,f=31&e[t],o=0):o=-1}else o=0;else o=3;else o=a?0:2;else o=a?0:1;if(d>=0&&o>=0&&(u={data:e.subarray(d,r),type:f,state:o},l.push(u)),0===l.length){var v=this._getLastNalUnit();if(v){var g=new Uint8Array(v.data.byteLength+e.byteLength);g.set(v.data,0),g.set(e,v.data.byteLength),v.data=g}}return n.naluState=o,l}},{key:"discardEPB",value:function(e){for(var t,r=e.byteLength,a=[],i=1,n=void 0;i<r-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(a.push(i+2),i+=2):i++;if(0===a.length)return e;t=r-a.length,n=new Uint8Array(t);var o=0;for(i=0;i<t;o++,i++)o===a[0]&&(o++,a.shift()),n[i]=e[o];return n}},{key:"_parseAACPES",value:function(e){var t,r,a=this._audioTrack,n=e.data,s=e.pts,l=this.aacOverFlow,f=this.aacLastPTS,c=void 0,h=void 0,v=void 0;if(l){var g=new Uint8Array(l.byteLength+n.byteLength);g.set(l,0),g.set(n,l.byteLength),n=g}for(h=0,r=n.length;h<r-1&&!i.isHeader(n,h);h++);if(h){var p=void 0,y=void 0;if(h<r-1?(p="AAC PES did not start with ADTS header,offset:"+h,y=!1):(p="no ADTS header found in AAC PES",y=!0),u.logger.warn("parsing error:"+p),this.observer.trigger(o.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:d.ErrorDetails.FRAG_PARSING_ERROR,fatal:y,reason:p}),y)return}if(i.initTrackConfig(a,this.observer,n,h,this.audioCodec),c=0,t=i.getFrameDuration(a.samplerate),l&&f){var m=f+t;Math.abs(m-s)>1&&(u.logger.log("AAC: align PTS for overlapping frames by "+Math.round((m-s)/90)),s=m)}for(;h<r;)if(i.isHeader(n,h)&&h+5<r){var b=i.appendFrame(a,n,h,s,c);if(!b)break;h+=b.length,v=b.sample.pts,c++}else h++;l=h<r?n.subarray(h,r):null,this.aacOverFlow=l,this.aacLastPTS=v}},{key:"_parseMPEGPES",value:function(e){for(var t=e.data,r=t.length,a=0,i=0,o=e.pts;i<r;)if(n.default.isHeader(t,i)){var s=n.default.appendFrame(this._audioTrack,t,i,o,a);if(!s)break;i+=s.length,a++}else i++}},{key:"_parseID3PES",value:function(e){this._id3Track.samples.push(e)}}],[{key:"probe",value:function(t){var r=e._syncOffset(t);return!(r<0)&&(r&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),!0)}},{key:"_syncOffset",value:function(e){for(var t=Math.min(1e3,e.length-564),r=0;r<t;){if(71===e[r]&&71===e[r+188]&&71===e[r+376])return r;r++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:c[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],len:0,dropped:"video"===e?0:void 0,isAAC:"audio"===e||void 0,duration:"audio"===e?t:void 0}}}]),e}();t.default=h,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=r(0);var n=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}return a(e,[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,a=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");a.set(e.subarray(r,r+i)),this.word=new DataView(a.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i}},{key:"skipBits",value:function(e){var t=void 0;this.bitsAvailable>e?(this.word<<=e,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 e>32&&i.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r}},{key:"skipLZ",value:function(){var e=void 0;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}},{key:"skipScalingList",value:function(e){var t=8,r=8,a=void 0;for(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,o=0,s=0,l=void 0,u=void 0,d=void 0,f=this.readUByte.bind(this),c=this.readBits.bind(this),h=this.readUEG.bind(this),v=this.readBoolean.bind(this),g=this.skipBits.bind(this),p=this.skipEG.bind(this),y=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);if(f(),e=f(),c(5),g(3),f(),y(),100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e){var b=h();if(3===b&&g(1),y(),y(),g(1),v())for(u=3!==b?8:12,d=0;d<u;d++)v()&&m(d<6?16:64)}y();var E=h();if(0===E)h();else if(1===E)for(g(1),p(),p(),l=h(),d=0;d<l;d++)p();y(),g(1),t=h(),r=h(),0===(a=c(1))&&g(1),g(1),v()&&(i=h(),n=h(),o=h(),s=h());var _=[1,1];if(v()&&v())switch(f()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:_=[f()<<8|f(),f()<<8|f()]}return{width:Math.ceil(16*(t+1)-2*i-2*n),height:(2-a)*(r+1)*16-(a?2:4)*(o+s),pixelRatio:_}}},{key:"readSliceType",value:function(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=r(12),o=(a=n)&&a.__esModule?a:{default:a};var s=function(){function e(t,r,a,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.decryptdata=a,this.discardEPB=i,this.decrypter=new o.default(t,r,{removePKCS7Padding:!1})}return i(e,[{key:"decryptBuffer",value:function(e,t){this.decrypter.decrypt(e,this.decryptdata.key.buffer,this.decryptdata.iv.buffer,t)}},{key:"decryptAacSample",value:function(e,t,r,a){var i=e[t].unit,n=i.subarray(16,i.length-i.length%16),o=n.buffer.slice(n.byteOffset,n.byteOffset+n.length),s=this;this.decryptBuffer(o,(function(n){n=new Uint8Array(n),i.set(n,16),a||s.decryptAacSamples(e,t+1,r)}))}},{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(e,t,r,a,i,n){var o=this.discardEPB(i.data),s=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(s.buffer,(function(s){i.data=l.getAvcDecryptedUnit(o,s),n||l.decryptAvcSamples(e,t,r+1,a)}))}},{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 o=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,a,n,o),!o)return}}}}}]),e}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=s(r(10)),n=r(0),o=s(r(23));function s(e){return e&&e.__esModule?e:{default:e}}var l=function(){function e(t,r,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=a,this.remuxer=r}return a(e,[{key:"resetInitSegment",value:function(e,t,r,a){this._audioTrack={container:"audio/mpeg",type:"audio",id:-1,sequenceNumber:0,isAAC:!1,samples:[],len:0,manifestCodec:t,duration:a,inputTimeScale:9e4}}},{key:"resetTimeStamp",value:function(){}},{key:"append",value:function(e,t,r,a){for(var n=i.default.getID3Data(e,0),s=i.default.getTimeStamp(n),l=s?90*s:9e4*t,u=n.length,d=e.length,f=0,c=0,h=this._audioTrack,v=[{pts:l,dts:l,data:n}];u<d;)if(o.default.isHeader(e,u)){var g=o.default.appendFrame(h,e,u,l,f);if(!g)break;u+=g.length,c=g.sample.pts,f++}else i.default.isHeader(e,u)?(n=i.default.getID3Data(e,u),v.push({pts:c,dts:c,data:n}),u+=n.length):u++;this.remuxer.remux(h,{samples:[]},{samples:v,inputTimeScale:9e4},{samples:[]},t,r,a)}},{key:"destroy",value:function(){}}],[{key:"probe",value:function(e){var t=void 0,r=void 0,a=i.default.getID3Data(e,0);if(a&&void 0!==i.default.getTimeStamp(a))for(t=a.length,r=Math.min(e.length-1,t+100);t<r;t++)if(o.default.probe(e,t))return n.logger.log("MPEG Audio sync word found !"),!0;return!1}}]),e}();t.default=l,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=u(r(51)),n=u(r(52)),o=u(r(1)),s=r(2),l=r(0);function u(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(t,r,a,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t,this.config=r,this.typeSupported=a;var n=navigator.userAgent;this.isSafari=i&&i.indexOf("Apple")>-1&&n&&!n.match("CriOS"),this.ISGenerated=!1}return a(e,[{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){if(this.ISGenerated||this.generateIS(e,t,i),this.ISGenerated){var u=e.samples.length,d=t.samples.length,f=i,c=i;if(u&&d){var h=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale;f+=Math.max(0,h),c+=Math.max(0,-h)}if(u){e.timescale||(l.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,i));var v=this.remuxAudio(e,f,n,s);if(d){var g=void 0;v&&(g=v.endPTS-v.startPTS),t.timescale||(l.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,i)),this.remuxVideo(t,c,n,g,s)}}else if(d){var p=this.remuxVideo(t,c,n,0,s);p&&e.codec&&this.remuxEmptyAudio(e,f,n,p)}}r.samples.length&&this.remuxID3(r,i),a.samples.length&&this.remuxText(a,i),this.observer.trigger(o.default.FRAG_PARSED)}},{key:"generateIS",value:function(e,t,r){var a=this.observer,i=e.samples,u=t.samples,d=this.typeSupported,f="audio/mp4",c={},h={tracks:c},v=void 0===this._initPTS,g=void 0,p=void 0;if(v&&(g=p=1/0),e.config&&i.length&&(e.timescale=e.samplerate,l.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(d.mpeg?(f="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3")),c.audio={container:f,codec:e.codec,initSegment:!e.isAAC&&d.mpeg?new Uint8Array:n.default.initSegment([e]),metadata:{channelCount:e.channelCount}},v&&(g=p=i[0].pts-e.inputTimeScale*r)),t.sps&&t.pps&&u.length){var y=t.inputTimeScale;t.timescale=y,c.video={container:"video/mp4",codec:t.codec,initSegment:n.default.initSegment([t]),metadata:{width:t.width,height:t.height}},v&&(g=Math.min(g,u[0].pts-y*r),p=Math.min(p,u[0].dts-y*r),this.observer.trigger(o.default.INIT_PTS_FOUND,{initPTS:g}))}Object.keys(c).length?(a.trigger(o.default.FRAG_PARSING_INIT_SEGMENT,h),this.ISGenerated=!0,v&&(this._initPTS=g,this._initDTS=p)):a.trigger(o.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})}},{key:"remuxVideo",value:function(e,t,r,a,i){var u,d,f,c=8,h=void 0,v=void 0,g=void 0,p=void 0,y=e.timescale,m=e.samples,b=[],E=m.length,_=this._PTSNormalize,T=this._initPTS,S=this.nextAvcDts,k=this.isSafari;if(0!==E){k&&(r|=m.length&&S&&(i&&Math.abs(t-S/y)<.1||Math.abs(m[0].pts-S-T)<y/5)),r||(S=t*y),m.forEach((function(e){e.pts=_(e.pts-T,S),e.dts=_(e.dts-T,S)})),m.sort((function(e,t){var r=e.dts-t.dts,a=e.pts-t.pts;return r||a||e.id-t.id}));var R=m.reduce((function(e,t){return Math.max(Math.min(e,t.pts-t.dts),-18e3)}),0);if(R<0){l.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Math.round(R/90)+" ms to overcome this issue");for(var A=0;A<m.length;A++)m[A].dts+=R}var w=m[0];p=Math.max(w.dts,0),g=Math.max(w.pts,0);var O=Math.round((p-S)/90);r&&O&&(O>1?l.logger.log("AVC:"+O+" ms hole between fragments detected,filling it"):O<-1&&l.logger.log("AVC:"+-O+" ms overlapping between fragments detected"),p=S,m[0].dts=p,g=Math.max(g-O,S),m[0].pts=g,l.logger.log("Video/PTS/DTS adjusted: "+Math.round(g/90)+"/"+Math.round(p/90)+",delta:"+O+" ms")),w=m[m.length-1],f=Math.max(w.dts,0),d=Math.max(w.pts,0,f),k&&(h=Math.round((f-p)/(m.length-1)));for(var L=0,D=0,P=0;P<E;P++){for(var I=m[P],C=I.units,x=C.length,M=0,F=0;F<x;F++)M+=C[F].data.length;D+=M,L+=x,I.length=M,I.dts=k?p+P*h:Math.max(I.dts,p),I.pts=Math.max(I.pts,I.dts)}var N=D+4*L+8;try{v=new Uint8Array(N)}catch(e){return void this.observer.trigger(o.default.ERROR,{type:s.ErrorTypes.MUX_ERROR,details:s.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:N,reason:"fail allocating video mdat "+N})}var U=new DataView(v.buffer);U.setUint32(0,N),v.set(n.default.types.mdat,4);for(var B=0;B<E;B++){for(var G=m[B],j=G.units,K=0,H=void 0,V=0,W=j.length;V<W;V++){var Y=j[V],q=Y.data,X=Y.data.byteLength;U.setUint32(c,X),c+=4,v.set(q,c),c+=X,K+=4+X}if(k)H=Math.max(0,h*Math.round((G.pts-G.dts)/h));else{if(B<E-1)h=m[B+1].dts-G.dts;else{var z=this.config,Q=G.dts-m[B>0?B-1:B].dts;if(z.stretchShortVideoTrack){var J=z.maxBufferHole,$=Math.floor(J*y),Z=(a?g+a*y:this.nextAudioPts)-G.pts;Z>$?((h=Z-Q)<0&&(h=Q),l.logger.log("It is approximately "+Z/90+" ms to the next segment; using duration "+h/90+" ms for the last video frame.")):h=Q}else h=Q}H=Math.round(G.pts-G.dts)}b.push({size:K,duration:h,cts:H,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:G.key?2:1,isNonSync:G.key?0:1}})}this.nextAvcDts=f+h;var ee=e.dropped;if(e.len=0,e.nbNalu=0,e.dropped=0,b.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var te=b[0].flags;te.dependsOn=2,te.isNonSync=0}e.samples=b,u=n.default.moof(e.sequenceNumber++,p,e),e.samples=[];var re={data1:u,data2:v,startPTS:g/y,endPTS:(d+h)/y,startDTS:p/y,endDTS:this.nextAvcDts/y,type:"video",hasAudio:!1,hasVideo:!0,nb:b.length,dropped:ee};return this.observer.trigger(o.default.FRAG_PARSING_DATA,re),re}}},{key:"remuxAudio",value:function(e,t,r,a){var u=e.inputTimeScale,d=e.timescale,f=u/d,c=(e.isAAC?1024:1152)*f,h=this._PTSNormalize,v=this._initPTS,g=!e.isAAC&&this.typeSupported.mpeg,p=void 0,y=void 0,m=void 0,b=void 0,E=void 0,_=void 0,T=void 0,S=e.samples,k=[],R=this.nextAudioPts;if(r|=S.length&&R&&(a&&Math.abs(t-R/u)<.1||Math.abs(S[0].pts-R-v)<20*c),S.forEach((function(e){e.pts=e.dts=h(e.pts-v,t*u)})),0!==(S=S.filter((function(e){return e.pts>=0}))).length){if(r||(R=a?t*u:S[0].pts),e.isAAC)for(var A=this.config.maxAudioFramesDrift,w=0,O=R;w<S.length;){var L,D=S[w];L=D.pts-O;var P=Math.abs(1e3*L/u);if(L<=-A*c)l.logger.warn("Dropping 1 audio frame @ "+(O/u).toFixed(3)+"s due to "+Math.round(P)+" ms overlap."),S.splice(w,1),e.len-=D.unit.length;else if(L>=A*c&&P<1e4&&O){var I=Math.round(L/c);l.logger.warn("Injecting "+I+" audio frame @ "+(O/u).toFixed(3)+"s due to "+Math.round(1e3*L/u)+" ms gap.");for(var C=0;C<I;C++){var x=Math.max(O,0);(m=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l.logger.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),m=D.unit.subarray()),S.splice(w,0,{unit:m,pts:x,dts:x}),e.len+=m.length,O+=c,w++}D.pts=D.dts=O,O+=c,w++}else Math.abs(L),D.pts=D.dts=O,O+=c,w++}for(var M=0,F=S.length;M<F;M++){var N=S[M],U=N.unit,B=N.pts;if(void 0!==T)y.duration=Math.round((B-T)/f);else{var G=Math.round(1e3*(B-R)/u),j=0;if(r&&e.isAAC&&G){if(G>0&&G<1e4)j=Math.round((B-R)/c),l.logger.log(G+" ms hole between AAC samples detected,filling it"),j>0&&((m=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(m=U.subarray()),e.len+=j*m.length);else if(G<-12){l.logger.log("drop overlapping AAC sample, expected/parsed/delta:"+(R/u).toFixed(3)+"s/"+(B/u).toFixed(3)+"s/"+-G+"ms"),e.len-=U.byteLength;continue}B=R}if(_=B,!(e.len>0))return;var K=g?e.len:e.len+8;p=g?0:8;try{b=new Uint8Array(K)}catch(e){return void this.observer.trigger(o.default.ERROR,{type:s.ErrorTypes.MUX_ERROR,details:s.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:K,reason:"fail allocating audio mdat "+K})}g||(new DataView(b.buffer).setUint32(0,K),b.set(n.default.types.mdat,4));for(var H=0;H<j;H++)(m=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l.logger.log("Unable to get silent frame for given audio codec; duplicating this frame instead."),m=U.subarray()),b.set(m,p),p+=m.byteLength,y={size:m.byteLength,cts:0,duration:1024,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},k.push(y)}b.set(U,p);var V=U.byteLength;p+=V,y={size:V,cts:0,duration:0,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:1}},k.push(y),T=B}var W=0,Y=k.length;if(Y>=2&&(W=k[Y-2].duration,y.duration=W),Y){this.nextAudioPts=R=T+f*W,e.len=0,e.samples=k,E=g?new Uint8Array:n.default.moof(e.sequenceNumber++,_/f,e),e.samples=[];var q=_/u,X=R/u,z={data1:E,data2:b,startPTS:q,endPTS:X,startDTS:q,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:Y};return this.observer.trigger(o.default.FRAG_PARSING_DATA,z),z}return null}}},{key:"remuxEmptyAudio",value:function(e,t,r,a){var n=e.inputTimeScale,o=n/(e.samplerate?e.samplerate:n),s=this.nextAudioPts,u=(void 0!==s?s:a.startDTS*n)+this._initDTS,d=a.endDTS*n+this._initDTS,f=1024*o,c=Math.ceil((d-u)/f),h=i.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("remux empty Audio"),h){for(var v=[],g=0;g<c;g++){var p=u+g*f;v.push({unit:h,pts:p,dts:p}),e.len+=h.length}e.samples=v,this.remuxAudio(e,t,r)}else l.logger.trace("Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec!")}},{key:"remuxID3",value:function(e){var t=e.samples.length,r=void 0,a=e.inputTimeScale,i=this._initPTS,n=this._initDTS;if(t){for(var s=0;s<t;s++)(r=e.samples[s]).pts=(r.pts-i)/a,r.dts=(r.dts-n)/a;this.observer.trigger(o.default.FRAG_PARSING_METADATA,{samples:e.samples})}e.samples=[]}},{key:"remuxText",value:function(e){e.samples.sort((function(e,t){return e.pts-t.pts}));var t=e.samples.length,r=void 0,a=e.inputTimeScale,i=this._initPTS;if(t){for(var n=0;n<t;n++)(r=e.samples[n]).pts=(r.pts-i)/a;this.observer.trigger(o.default.FRAG_PARSING_USERDATA,{samples:e.samples})}e.samples=[]}},{key:"_PTSNormalize",value:function(e,t){var r=void 0;if(void 0===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}}]),e}();t.default=d,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return a(e,null,[{key:"getSilentFrame",value:function(e,t){switch(e){case"mp4a.40.2":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]);break;default: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}}]),e}();t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=Math.pow(2,32)-1,n=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return a(e,null,[{key:"init",value:function(){e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var t=void 0;for(t in e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),a=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);e.HDLR_TYPES={video:r,audio:a};var i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=n,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,o,l,o,s),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,i))}},{key:"box",value:function(e){for(var t=Array.prototype.slice.call(arguments,1),r=8,a=t.length,i=a,n=void 0;a--;)r+=t[a].byteLength;for((n=new Uint8Array(r))[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=255&r,n.set(e,4),a=0,r=8;a<i;a++)n.set(t[a],r),r+=t[a].byteLength;return n}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,r){r*=t;var a=Math.floor(r/(i+1)),n=Math.floor(r%(i+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,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,a>>24,a>>16&255,a>>8&255,255&a,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,r,a){return e.box(e.types.moof,e.mfhd(t),e.traf(a,r))}},{key:"moov",value:function(t){for(var r=t.length,a=[];r--;)a[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(a).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var r=t.length,a=[];r--;)a[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(a))}},{key:"mvhd",value:function(t,r){r*=t;var a=Math.floor(r/(i+1)),n=Math.floor(r%(i+1)),o=new Uint8Array([1,0,0,0,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,a>>24,a>>16&255,a>>8&255,255&a,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,o)}},{key:"sdtp",value:function(t){var r=t.samples||[],a=new Uint8Array(4+r.length),i=void 0,n=void 0;for(n=0;n<r.length;n++)i=r[n].flags,a[n+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var r=[],a=[],i=void 0,n=void 0,o=void 0;for(i=0;i<t.sps.length;i++)o=(n=t.sps[i]).byteLength,r.push(o>>>8&255),r.push(255&o),r=r.concat(Array.prototype.slice.call(n));for(i=0;i<t.pps.length;i++)o=(n=t.pps[i]).byteLength,a.push(o>>>8&255),a.push(255&o),a=a.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(a))),l=t.width,u=t.height,d=t.pixelRatio[0],f=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,f>>24,f>>16&255,f>>8&255,255&f])))}},{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(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))}},{key:"stsd",value:function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))}},{key:"tkhd",value:function(t){var r=t.id,a=t.duration*t.timescale,n=t.width,o=t.height,s=Math.floor(a/(i+1)),l=Math.floor(a%(i+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,l>>24,l>>16&255,l>>8&255,255&l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,o>>8&255,255&o,0,0]))}},{key:"traf",value:function(t,r){var a=e.sdtp(t),n=t.id,o=Math.floor(r/(i+1)),s=Math.floor(r%(i+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,a.length+16+20+8+16+8+8),a)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,r){var a=t.samples||[],i=a.length,n=12+16*i,o=new Uint8Array(n),s=void 0,l=void 0,u=void 0,d=void 0,f=void 0,c=void 0;for(r+=8+n,o.set([0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),s=0;s<i;s++)u=(l=a[s]).duration,d=l.size,f=l.flags,c=l.cts,o.set([u>>>24&255,u>>>16&255,u>>>8&255,255&u,d>>>24&255,d>>>16&255,d>>>8&255,255&d,f.isLeading<<2|f.dependsOn,f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|f.isNonSync,61440&f.degradPrio,15&f.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*s);return e.box(e.types.trun,o)}},{key:"initSegment",value:function(t){e.types||e.init();var r=e.moov(t),a=void 0;return(a=new Uint8Array(e.FTYP.byteLength+r.byteLength)).set(e.FTYP),a.set(r,e.FTYP.byteLength),a}}]),e}();t.default=n,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=r(1),o=(a=n)&&a.__esModule?a:{default:a};var s=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.observer=t}return i(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(){}},{key:"remux",value:function(e,t,r,a,i,n,s,l){var u=this.observer,d="";e&&(d+="audio"),t&&(d+="video"),u.trigger(o.default.FRAG_PARSING_DATA,{data1:l,startPTS:i,startDTS:i,type:d,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),u.trigger(o.default.FRAG_PARSED)}}]),e}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";var a=Object.prototype.hasOwnProperty,i="~";function n(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,r,a,n){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new o(r,a||e,n),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function u(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)a.call(e,t)&&r.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var a=0,n=r.length,o=new Array(n);a<n;a++)o[a]=r[a].fn;return o},u.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},u.prototype.emit=function(e,t,r,a,n,o){var s=i?i+e:e;if(!this._events[s])return!1;var l,u,d=this._events[s],f=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),f){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,r),!0;case 4:return d.fn.call(d.context,t,r,a),!0;case 5:return d.fn.call(d.context,t,r,a,n),!0;case 6:return d.fn.call(d.context,t,r,a,n,o),!0}for(u=1,l=new Array(f-1);u<f;u++)l[u-1]=arguments[u];d.fn.apply(d.context,l)}else{var c,h=d.length;for(u=0;u<h;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),f){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,r);break;case 4:d[u].fn.call(d[u].context,t,r,a);break;default:if(!l)for(c=1,l=new Array(f-1);c<f;c++)l[c-1]=arguments[c];d[u].fn.apply(d[u].context,l)}}return!0},u.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},u.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},u.prototype.removeListener=function(e,t,r,a){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return l(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||a&&!o.once||r&&o.context!==r||l(this,n);else{for(var s=0,u=[],d=o.length;s<d;s++)(o[s].fn!==t||a&&!o[s].once||r&&o[s].context!==r)&&u.push(o[s]);u.length?this._events[n]=1===u.length?u[0]:u:l(this,n)}return this},u.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&l(this,t)):(this._events=new n,this._eventsCount=0),this},u.prototype.off=u.prototype.removeListener,u.prototype.addListener=u.prototype.on,u.prefixed=i,u.EventEmitter=u,e.exports=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=s(r(21)),i=s(r(1)),n=r(0),o=r(20);function s(e){return e&&e.__esModule?e:{default:e}}t.default=function(e){var t=new o.EventEmitter;t.trigger=function(e){for(var r=arguments.length,a=Array(r>1?r-1:0),i=1;i<r;i++)a[i-1]=arguments[i];t.emit.apply(t,[e,e].concat(a))},t.off=function(e){for(var r=arguments.length,a=Array(r>1?r-1:0),i=1;i<r;i++)a[i-1]=arguments[i];t.removeListener.apply(t,[e].concat(a))};var r=function(t,r){e.postMessage({event:t,data:r})};e.addEventListener("message",(function(i){var o=i.data;switch(o.cmd){case"init":var s=JSON.parse(o.config);e.demuxer=new a.default(t,o.typeSupported,s,o.vendor),(0,n.enableLogs)(s.debug),r("init",null);break;case"demux":e.demuxer.push(o.data,o.decryptdata,o.initSegment,o.audioCodec,o.videoCodec,o.timeOffset,o.discontinuity,o.trackSwitch,o.contiguous,o.duration,o.accurateTimeOffset,o.defaultInitPTS)}})),t.on(i.default.FRAG_DECRYPTED,r),t.on(i.default.FRAG_PARSING_INIT_SEGMENT,r),t.on(i.default.FRAG_PARSED,r),t.on(i.default.ERROR,r),t.on(i.default.FRAG_PARSING_METADATA,r),t.on(i.default.FRAG_PARSING_USERDATA,r),t.on(i.default.INIT_PTS_FOUND,r),t.on(i.default.FRAG_PARSING_DATA,(function(t,r){var a=[],i={event:t,data:r};r.data1&&(i.data1=r.data1.buffer,a.push(r.data1.buffer),delete r.data1),r.data2&&(i.data2=r.data2.buffer,a.push(r.data2.buffer),delete r.data2),e.postMessage(i,a)}))},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=r(4),o=r(2),s=r(1),l=(a=s)&&a.__esModule?a:{default:a},u=r(0);var d=function(){function e(t,r,a,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.config=t,this.media=r,this.fragmentTracker=a,this.hls=i,this.stallReported=!1}return i(e,[{key:"poll",value:function(e,t){var r=this.config,a=this.media,i=a.currentTime,o=window.performance.now();if(i!==e)return this.stallReported&&(u.logger.warn("playback not stuck anymore @"+i+", after "+Math.round(o-this.stalled)+"ms"),this.stallReported=!1),this.stalled=null,void(this.nudgeRetry=0);if(!(a.ended||!a.buffered.length||a.readyState>2||a.seeking&&n.BufferHelper.isBuffered(a,i))){var s=o-this.stalled,l=n.BufferHelper.bufferInfo(a,i,r.maxBufferHole);this.stalled?(s>=1e3&&this._reportStall(l.len),this._tryFixBufferStall(l,s)):this.stalled=o}}},{key:"_tryFixBufferStall",value:function(e,t){var r=this.config,a=this.fragmentTracker,i=this.media.currentTime,n=a.getPartialFragment(i);n&&this._trySkipBufferHole(n),e.len>.5&&t>1e3*r.highBufferWatchdogPeriod&&(this.stalled=null,this._tryNudgeBuffer())}},{key:"_reportStall",value:function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,u.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer"),t.trigger(l.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))}},{key:"_trySkipBufferHole",value:function(e){for(var t=this.hls,r=this.media,a=r.currentTime,i=0,n=0;n<r.buffered.length;n++){var s=r.buffered.start(n);if(a>=i&&a<s)return r.currentTime=Math.max(s,r.currentTime+.1),u.logger.warn("skipping hole, adjusting currentTime from "+a+" to "+r.currentTime),this.stalled=null,void t.trigger(l.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+a+" to "+r.currentTime,frag:e});i=r.buffered.end(n)}}},{key:"_tryNudgeBuffer",value:function(){var e=this.config,t=this.hls,r=this.media,a=r.currentTime,i=(this.nudgeRetry||0)+1;if(this.nudgeRetry=i,i<e.nudgeMaxRetry){var n=a+i*e.nudgeOffset;u.logger.log("adjust currentTime from "+a+" to "+n),r.currentTime=n,t.trigger(l.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else u.logger.error("still stuck in high buffer @"+a+" after "+e.nudgeMaxRetry+", raise fatal error"),t.trigger(l.default.ERROR,{type:o.ErrorTypes.MEDIA_ERROR,details:o.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}}]),e}();t.default=d,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__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(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=f(r(1)),o=f(r(3)),s=r(0),l=r(2),u=r(18),d=r(7);function f(e){return e&&e.__esModule?e:{default:e}}window.performance;var c=void 0,h=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n.default.MANIFEST_LOADED,n.default.LEVEL_LOADED,n.default.AUDIO_TRACK_SWITCHED,n.default.FRAG_LOADED,n.default.ERROR));return r.canload=!1,r.currentLevelIndex=null,r.manualLevelIndex=-1,r.timer=null,c=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),r}return 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)}(t,e),i(t,[{key:"onHandlerDestroying",value:function(){this.clearTimer(),this.manualLevelIndex=-1}},{key:"clearTimer",value:function(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)}},{key:"startLoad",value:function(){var e=this._levels;this.canload=!0,this.levelRetryCount=0,e&&e.forEach((function(e){e.loadError=0;var t=e.details;t&&t.live&&(e.details=void 0)})),null!==this.timer&&this.loadLevel()}},{key:"stopLoad",value:function(){this.canload=!1}},{key:"onManifestLoaded",value:function(e){var t=[],r=[],a=void 0,i={},o=null,f=!1,h=!1;if(e.levels.forEach((function(e){var r=e.attrs;e.loadError=0,e.fragmentError=!1,f=f||!!e.videoCodec,h=h||!!e.audioCodec,c&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0),(o=i[e.bitrate])?o.url.push(e.url):(e.url=[e.url],e.urlId=0,i[e.bitrate]=e,t.push(e)),r&&(r.AUDIO&&(h=!0,(0,d.addGroupId)(o||e,"audio",r.AUDIO)),r.SUBTITLES&&(0,d.addGroupId)(o||e,"text",r.SUBTITLES))})),f&&h&&(t=t.filter((function(e){return!!e.videoCodec}))),t=t.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||(0,u.isCodecSupportedInMp4)(t,"audio"))&&(!r||(0,u.isCodecSupportedInMp4)(r,"video"))})),e.audioTracks&&(r=e.audioTracks.filter((function(e){return!e.audioCodec||(0,u.isCodecSupportedInMp4)(e.audioCodec,"audio")}))).forEach((function(e,t){e.id=t})),t.length>0){a=t[0].bitrate,t.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=t;for(var v=0;v<t.length;v++)if(t[v].bitrate===a){this._firstLevel=v,s.logger.log("manifest loaded,"+t.length+" level(s) found, first bitrate:"+a);break}this.hls.trigger(n.default.MANIFEST_PARSED,{levels:t,audioTracks:r,firstLevel:this._firstLevel,stats:e.stats,audio:h,video:f,altAudio:r.some((function(e){return!!e.url}))})}else this.hls.trigger(n.default.ERROR,{type:l.ErrorTypes.MEDIA_ERROR,details:l.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:this.hls.url,reason:"no level with compatible codecs found in manifest"})}},{key:"setLevelInternal",value:function(e){var t=this._levels,r=this.hls;if(e>=0&&e<t.length){if(this.clearTimer(),this.currentLevelIndex!==e){s.logger.log("switching to level "+e),this.currentLevelIndex=e;var a=t[e];a.level=e,r.trigger(n.default.LEVEL_SWITCHING,a)}var i=t[e],o=i.details;if(!o||o.live){var u=i.urlId;r.trigger(n.default.LEVEL_LOADING,{url:i.url[u],level:e,id:u})}}else r.trigger(n.default.ERROR,{type:l.ErrorTypes.OTHER_ERROR,details:l.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:!1,reason:"invalid level idx"})}},{key:"onError",value:function(e){if(e.fatal)e.type===l.ErrorTypes.NETWORK_ERROR&&this.clearTimer();else{var t=!1,r=!1,a=void 0;switch(e.details){case l.ErrorDetails.FRAG_LOAD_ERROR:case l.ErrorDetails.FRAG_LOAD_TIMEOUT:case l.ErrorDetails.KEY_LOAD_ERROR:case l.ErrorDetails.KEY_LOAD_TIMEOUT:a=e.frag.level,r=!0;break;case l.ErrorDetails.LEVEL_LOAD_ERROR:case l.ErrorDetails.LEVEL_LOAD_TIMEOUT:a=e.context.level,t=!0;break;case l.ErrorDetails.REMUX_ALLOC_ERROR:a=e.level,t=!0}void 0!==a&&this.recoverLevel(e,a,t,r)}}},{key:"recoverLevel",value:function(e,t,r,a){var i=this,n=this.hls.config,o=e.details,l=this._levels[t],u=void 0,d=void 0,f=void 0;if(l.loadError++,l.fragmentError=a,r){if(!(this.levelRetryCount+1<=n.levelLoadingMaxRetry))return s.logger.error("level controller, cannot recover from "+o+" error"),this.currentLevelIndex=null,this.clearTimer(),void(e.fatal=!0);d=Math.min(Math.pow(2,this.levelRetryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout),this.timer=setTimeout((function(){return i.loadLevel()}),d),e.levelRetry=!0,this.levelRetryCount++,s.logger.warn("level controller, "+o+", retry in "+d+" ms, current retry count is "+this.levelRetryCount)}(r||a)&&((u=l.url.length)>1&&l.loadError<u?(l.urlId=(l.urlId+1)%u,l.details=void 0,s.logger.warn("level controller, "+o+" for level "+t+": switching to redundant URL-id "+l.urlId)):-1===this.manualLevelIndex?(f=0===t?this._levels.length-1:t-1,s.logger.warn("level controller, "+o+": switch to "+f),this.hls.nextAutoLevel=this.currentLevelIndex=f):a&&(s.logger.warn("level controller, "+o+": reload a fragment"),this.currentLevelIndex=null))}},{key:"onFragLoaded",value:function(e){var t=e.frag;if(void 0!==t&&"main"===t.type){var r=this._levels[t.level];void 0!==r&&(r.fragmentError=!1,r.loadError=0,this.levelRetryCount=0)}}},{key:"onLevelLoaded",value:function(e){var t=this,r=e.level,a=e.details;if(r===this.currentLevelIndex){var i=this._levels[r];if(i.fragmentError||(i.loadError=0,this.levelRetryCount=0),a.live){var n=(0,d.computeReloadInterval)(i.details,a,e.stats.trequest);s.logger.log("live playlist, reload in "+Math.round(n)+" ms"),this.timer=setTimeout((function(){return t.loadLevel()}),n)}else this.clearTimer()}}},{key:"onAudioTrackSwitched",value:function(e){var t=this.hls.audioTracks[e.id].groupId,r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var a=-1,i=0;i<r.audioGroupIds.length;i++)if(r.audioGroupIds[i]===t){a=i;break}a!==r.urlId&&(r.urlId=a,this.startLoad())}}},{key:"loadLevel",value:function(){if(s.logger.debug("call to loadLevel"),null!==this.currentLevelIndex&&this.canload){var e=this._levels[this.currentLevelIndex];if("object"===(void 0===e?"undefined":a(e))&&e.url.length>0){var t=this.currentLevelIndex,r=e.urlId,i=e.url[r];s.logger.log("Attempt loading level index "+t+" with URL-id "+r),this.hls.trigger(n.default.LEVEL_LOADING,{url:i,level:t,id:r})}}}},{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;t&&(e=Math.min(e,t.length-1),this.currentLevelIndex===e&&t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=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){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}]),t}(o.default);t.default=h,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=l(r(1)),n=l(r(3)),o=l(r(10)),s=r(29);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.MEDIA_ATTACHED,i.default.MEDIA_DETACHING,i.default.FRAG_PARSING_METADATA));return r.id3Track=void 0,r.media=void 0,r}return 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)}(t,e),a(t,[{key:"destroy",value:function(){n.default.prototype.destroy.call(this)}},{key:"onMediaAttached",value:function(e){this.media=e.media,this.media}},{key:"onMediaDetaching",value:function(){(0,s.clearCurrentCues)(this.id3Track),this.id3Track=void 0,this.media=void 0}},{key:"getID3Track",value:function(e){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return(0,s.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},{key:"onFragParsingMetadata",value:function(e){var t=e.frag,r=e.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var a=window.WebKitDataCue||window.VTTCue||window.TextTrackCue,i=0;i<r.length;i++){var n=o.default.getID3Frames(r[i].data);if(n){var s=r[i].pts,l=i<r.length-1?r[i+1].pts:t.endPTS;s===l&&(l+=1e-4);for(var u=0;u<n.length;u++){var d=n[u];if(!o.default.isTimeStampFrame(d)){var f=new a(s,l,"");f.value=d,this.id3Track.addCue(f)}}}}}}]),t}(n.default);t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSupported=function(){var e=(0,a.getMediaSource)(),t=window.SourceBuffer||window.WebKitSourceBuffer,r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!i};var a=r(13)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hlsDefaultConfig=void 0;var a=p(r(61)),i=p(r(64)),n=p(r(65)),o=p(r(66)),s=p(r(67)),l=p(r(68)),u=p(r(69)),d=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(70)),f=p(r(72)),c=p(r(76)),h=r(77),v=p(r(78)),g=r(79);function p(e){return e&&e.__esModule?e:{default:e}}var y=t.hlsDefaultConfig={autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,maxBufferSize:6e7,maxBufferHole:.5,lowBufferWatchdogPeriod:.5,highBufferWatchdogPeriod:3,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,liveDurationInfinity:!1,liveBackBufferLength:1/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,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:s.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,abrController:a.default,bufferController:i.default,capLevelController:n.default,fpsController:o.default,stretchShortVideoTrack:!1,maxAudioFramesDrift: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,emeEnabled:!1,widevineLicenseUrl:void 0,requestMediaKeySystemAccessFunc:g.requestMediaKeySystemAccess};y.subtitleStreamController=h.SubtitleStreamController,y.subtitleTrackController=c.default,y.timelineController=f.default,y.cueHandler=d,y.enableCEA708Captions=!0,y.enableWebVTT=!0,y.captionsTextTrack1Label="English",y.captionsTextTrack1LanguageCode="en",y.captionsTextTrack2Label="Spanish",y.captionsTextTrack2LanguageCode="es",y.audioStreamController=u.default,y.audioTrackController=l.default,y.emeController=v.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=d(r(1)),n=d(r(3)),o=r(4),s=r(2),l=r(0),u=d(r(62));function d(e){return e&&e.__esModule?e:{default:e}}var f=window.performance,c=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.FRAG_LOADING,i.default.FRAG_LOADED,i.default.FRAG_BUFFERED,i.default.ERROR));return r.lastLoadedFragLevel=0,r._nextAutoLevel=-1,r.hls=e,r.timer=null,r._bwEstimator=null,r.onCheck=r._abandonRulesCheck.bind(r),r}return 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)}(t,e),a(t,[{key:"destroy",value:function(){this.clearTimer(),n.default.prototype.destroy.call(this)}},{key:"onFragLoading",value:function(e){var t=e.frag;if("main"===t.type&&(this.timer||(this.fragCurrent=t,this.timer=setInterval(this.onCheck,100)),!this._bwEstimator)){var r=this.hls,a=r.config,i=t.level,n=void 0,o=void 0;r.levels[i].details.live?(n=a.abrEwmaFastLive,o=a.abrEwmaSlowLive):(n=a.abrEwmaFastVoD,o=a.abrEwmaSlowVoD),this._bwEstimator=new u.default(r,o,n,a.abrEwmaDefaultEstimate)}}},{key:"_abandonRulesCheck",value:function(){var e=this.hls,t=e.media,r=this.fragCurrent;if(r){var a=r.loader,n=e.minAutoLevel;if(!a||a.stats&&a.stats.aborted)return l.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);var s=a.stats;if(t&&s&&(!t.paused&&0!==t.playbackRate||!t.readyState)&&r.autoLevel&&r.level){var u=f.now()-s.trequest,d=Math.abs(t.playbackRate);if(u>500*r.duration/d){var c=e.levels,h=Math.max(1,s.bw?s.bw/8:1e3*s.loaded/u),v=c[r.level],g=v.realBitrate?Math.max(v.realBitrate,v.bitrate):v.bitrate,p=s.total?s.total:Math.max(s.loaded,Math.round(r.duration*g/8)),y=t.currentTime,m=(p-s.loaded)/h,b=(o.BufferHelper.bufferInfo(t,y,e.config.maxBufferHole).end-y)/d;if(b<2*r.duration/d&&m>b){var E=void 0,_=void 0;for(_=r.level-1;_>n;_--){var T=c[_].realBitrate?Math.max(c[_].realBitrate,c[_].bitrate):c[_].bitrate;if((E=r.duration*T/(6.4*h))<b)break}E<m&&(l.logger.warn("loading too slow, abort fragment loading and switch to level "+_+":fragLoadedDelay["+_+"]<fragLoadedDelay["+(r.level-1)+"];bufferStarvationDelay:"+E.toFixed(1)+"<"+m.toFixed(1)+":"+b.toFixed(1)),e.nextLoadLevel=_,this._bwEstimator.sample(u,s.loaded),a.abort(),this.clearTimer(),e.trigger(i.default.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,stats:s}))}}}}}},{key:"onFragLoaded",value:function(e){var t=e.frag;if("main"===t.type&&Number.isFinite(t.sn)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var r=this.hls.levels[t.level],a=(r.loaded?r.loaded.bytes:0)+e.stats.loaded,i=(r.loaded?r.loaded.duration:0)+e.frag.duration;r.loaded={bytes:a,duration:i},r.realBitrate=Math.round(8*a/i)}if(e.frag.bitrateTest){var n=e.stats;n.tparsed=n.tbuffered=n.tload,this.onFragBuffered(e)}}}},{key:"onFragBuffered",value:function(e){var t=e.stats,r=e.frag;if(!0!==t.aborted&&"main"===r.type&&Number.isFinite(r.sn)&&(!r.bitrateTest||t.tload===t.tbuffered)){var a=t.tparsed-t.trequest;l.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(a,t.loaded),t.bwEstimate=this._bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/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(){clearInterval(this.timer),this.timer=null}},{key:"_findBestLevel",value:function(e,t,r,a,i,n,o,s,u){for(var d=i;d>=a;d--){var f=u[d];if(f){var c=f.details,h=c?c.totalduration/c.fragments.length:t,v=!!c&&c.live,g=void 0;g=d<=e?o*r:s*r;var p=u[d].realBitrate?Math.max(u[d].realBitrate,u[d].bitrate):u[d].bitrate,y=p*h/g;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+d+"/"+Math.round(g)+"/"+p+"/"+h+"/"+n+"/"+y),g>p&&(!y||v&&!this.bitrateTestDelay||y<n))return d}}return-1}},{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this._bwEstimator;if(!(-1===e||t&&t.canEstimate()))return e;var r=this._nextABRAutoLevel;return-1!==e&&(r=Math.min(e,r)),r},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,u=this.fragCurrent?this.fragCurrent.duration:0,d=n?n.currentTime:0,f=n&&0!==n.playbackRate?Math.abs(n.playbackRate):1,c=this._bwEstimator?this._bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,h=(o.BufferHelper.bufferInfo(n,d,a.maxBufferHole).end-d)/f,v=this._findBestLevel(s,u,c,i,t,h,a.abrBandWidthFactor,a.abrBandWidthUpFactor,r);if(v>=0)return v;l.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var g=u?Math.min(u,a.maxStarvationDelay):a.maxStarvationDelay,p=a.abrBandWidthFactor,y=a.abrBandWidthUpFactor;if(0===h){var m=this.bitrateTestDelay;if(m)g=(u?Math.min(u,a.maxLoadingDelay):a.maxLoadingDelay)-m,l.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*g)+" ms"),p=y=1}return v=this._findBestLevel(s,u,c,i,t,h+g,p,y,r),Math.max(v,0)}}]),t}(n.default);t.default=c,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),n=r(63),o=(a=n)&&a.__esModule?a:{default:a};var s=function(){function e(t,r,a,i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hls=t,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new o.default(r),this.fast_=new o.default(a)}return i(e,[{key:"sample",value:function(e,t){var r=8e3*t/(e=Math.max(e,this.minDelayMs_)),a=e/1e3;this.fast_.sample(a,r),this.slow_.sample(a,r)}},{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(){}}]),e}();t.default=s,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=0,this.totalWeight_=0}return a(e,[{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_}}]),e}();t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=l(r(1)),n=l(r(3)),o=r(0),s=r(2);function l(e){return e&&e.__esModule?e:{default:e}}var u=(0,r(13).getMediaSource)(),d=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.MEDIA_ATTACHING,i.default.MEDIA_DETACHING,i.default.MANIFEST_PARSED,i.default.BUFFER_RESET,i.default.BUFFER_APPENDING,i.default.BUFFER_CODECS,i.default.BUFFER_EOS,i.default.BUFFER_FLUSHING,i.default.LEVEL_PTS_UPDATED,i.default.LEVEL_UPDATED));return r._msDuration=null,r._levelDuration=null,r._levelTargetDuration=10,r._live=null,r._objectUrl=null,r.bufferCodecEventsExpected=0,r.onsbue=r.onSBUpdateEnd.bind(r),r.onsbe=r.onSBUpdateError.bind(r),r.pendingTracks={},r.tracks={},r}return 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)}(t,e),a(t,[{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(Math.abs(a.timestampOffset-e.start)>.1){var i=a.updating;try{a.abort()}catch(e){o.logger.warn("can not abort audio buffer: "+e)}i?this.audioTimestampOffset=e.start:(o.logger.warn("change mpeg audio timestamp offset from "+a.timestampOffset+" to "+e.start),a.timestampOffset=e.start)}}}},{key:"onManifestParsed",value:function(e){this.bufferCodecEventsExpected=e.altAudio?2:1,o.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")}},{key:"onMediaAttaching",value:function(e){var t=this.media=e.media;if(t){var r=this.mediaSource=new u;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this),r.addEventListener("sourceopen",this.onmso),r.addEventListener("sourceended",this.onmse),r.addEventListener("sourceclose",this.onmsc),t.src=window.URL.createObjectURL(r),this._objectUrl=t.src}}},{key:"onMediaDetaching",value:function(){o.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){o.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&&(window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):o.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.onmso=this.onmse=this.onmsc=null,this.hls.trigger(i.default.MEDIA_DETACHED)}},{key:"onMediaSourceOpen",value:function(){o.logger.log("media source opened"),this.hls.trigger(i.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.bufferCodecEventsExpected,t=this.pendingTracks,r=Object.keys(t).length;(r&&!e||2===r)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())}},{key:"onMediaSourceClose",value:function(){o.logger.log("media source closed")}},{key:"onMediaSourceEnded",value:function(){o.logger.log("media source ended")}},{key:"onSBUpdateEnd",value:function(){if(this.audioTimestampOffset){var e=this.sourceBuffer.audio;o.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 t=this.parent,r=this.segments.reduce((function(e,r){return r.parent===t?e+1:e}),0),a={},n=this.sourceBuffer;for(var s in n)a[s]=n[s].buffered;if(!1===this._paused&&a.video&&a.video.length>0&&a.audio&&a.audio.length>0)if(a.video.end(0)-a.video.start(0)>1&&a.audio.end(0)-a.audio.start(0)>1){var l=Math.max(a.video.start(0),a.audio.start(0));this.media.currentTime=l,this.media.play(),delete this._paused}else{var u=Math.max(a.video.end(0),a.audio.end(0));this.media.currentTime=u,this.media.play()}this.hls.trigger(i.default.BUFFER_APPENDED,{parent:t,pending:r,timeRanges:a}),this._needsFlush||this.doAppending(),this.updateMediaElementDuration(),0===r&&this.flushLiveBackBuffer()}},{key:"onSBUpdateError",value:function(e){o.logger.error("sourceBuffer error:",e),this.hls.trigger(i.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})}},{key:"onBufferReset",value:function(){var e=this.sourceBuffer;for(var t in e){var r=e[t];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){var t=this;Object.keys(e).forEach((function(r){t.pendingTracks[r]=e[r]}));var r=this.mediaSource;this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),r&&"open"===r.readyState&&this.checkPendingTracks()}},{key:"createSourceBuffers",value:function(e){var t=this.sourceBuffer,r=this.mediaSource;for(var a in e)if(!t[a]){var n=e[a],l=n.levelCodec||n.codec,d=n.container+";codecs="+l;o.logger.log("creating sourceBuffer("+d+")");try{var f=t[a]=r.addSourceBuffer(d);f.addEventListener("updateend",this.onsbue),f.addEventListener("error",this.onsbe),this.tracks[a]={codec:l,container:n.container},n.buffer=f}catch(e){if(22==e.code){o.logger.log("Found new track, try to rebuild"),this._paused=!1;var c=this.mediaSource=new u;this.onmso=this.onMediaSourceOpen.bind(this),this.onmse=this.onMediaSourceEnded.bind(this),this.onmsc=this.onMediaSourceClose.bind(this);for(var h=0;h<Object.keys(this.tracks).length;h++){var v=this.tracks[Object.keys(this.tracks)[h]];this.pendingTracks[Object.keys(this.tracks)[h]]=v}this.tracks={},this.sourceBuffer={},c.addEventListener("sourceopen",this.onmso),c.addEventListener("sourceended",this.onmse),c.addEventListener("sourceclose",this.onmsc),this.media.src=window.URL.createObjectURL(c),this._objectUrl=media.src}else o.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(i.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:d})}}this.hls.trigger(i.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){o.logger.error("sourceBuffer error:",e.event),this.hls.trigger(i.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})}},{key:"onBufferEos",value:function(e){var t=this.sourceBuffer,r=e.type;for(var a in t)r&&a!==r||t[a].ended||(t[a].ended=!0,o.logger.log(a+" 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)}o.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){o.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:"flushLiveBackBuffer",value:function(){if(this._live){var e=this.hls.config.liveBackBufferLength;if(isFinite(e)&&!(e<0))for(var t=this.media.currentTime,r=this.sourceBuffer,a=Object.keys(r),i=t-Math.max(e,this._levelTargetDuration),n=a.length-1;n>=0;n--){var o=a[n],s=r[o].buffered;s.length>0&&i>s.start(0)&&this.removeBufferRange(o,r[o],0,i)}}}},{key:"onLevelUpdated",value:function(e){var t=e.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())}},{key:"updateMediaElementDuration",value:function(){var e,t=this.hls.config;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var r in this.sourceBuffer)if(!0===this.sourceBuffer[r].updating)return;e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(o.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Number.isFinite(e))&&(o.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}}},{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){o.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(i.default.BUFFER_FLUSHED)}}},{key:"doAppending",value:function(){var e=this.hls,t=this.segments,r=this.sourceBuffer;if(Object.keys(r).length){if(this.media.error)return this.segments=[],void o.logger.error("trying to append although a media error occured, flush segment and abort");if(this.appending)return;if(t&&t.length){var a=t.shift();try{var n=r[a.type];n?n.updating?t.unshift(a):(n.ended=!1,this.parent=a.parent,n.appendBuffer(a.data),this.appendError=0,this.appended++,this.appending=!0):this.onSBUpdateEnd()}catch(r){o.logger.error("error while trying to append buffer:"+r.message),t.unshift(a);var l={type:s.ErrorTypes.MEDIA_ERROR,parent:a.parent};22!==r.code?(this.appendError?this.appendError++:this.appendError=1,l.details=s.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>e.config.appendErrorMaxRetry?(o.logger.log("fail "+e.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],l.fatal=!0,e.trigger(i.default.ERROR,l)):(l.fatal=!1,e.trigger(i.default.ERROR,l))):(this.segments=[],l.details=s.ErrorDetails.BUFFER_FULL_ERROR,l.fatal=!1,e.trigger(i.default.ERROR,l))}}}}},{key:"flushBuffer",value:function(e,t,r){var a=void 0,i=this.sourceBuffer;if(Object.keys(i).length){if(o.logger.log("flushBuffer,pos/start/end: "+this.media.currentTime.toFixed(3)+"/"+e+"/"+t),this.flushBufferCounter<this.appended){for(var n in i)if(!r||n===r){if((a=i[n]).ended=!1,a.updating)return o.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(n,a,e,t))return this.flushBufferCounter++,!1}}else o.logger.warn("abort flushing too many retries");o.logger.log("buffer flushed")}return!0}},{key:"removeBufferRange",value:function(e,t,r,a){try{for(var i=0;i<t.buffered.length;i++){var n=t.buffered.start(i),s=t.buffered.end(i),l=Math.max(n,r),u=Math.min(s,a);if(Math.min(u,s)-l>.5)return o.logger.log("sb remove "+e+" ["+l+","+u+"], of ["+n+","+s+"], pos:"+this.media.currentTime),t.remove(l,u),!0}}catch(e){o.logger.warn("removeBufferRange failed",e)}return!1}}]),t}(n.default);t.default=d,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=n(r(1));function n(e){return e&&e.__esModule?e:{default:e}}var o=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.FPS_DROP_LEVEL_CAPPING,i.default.MEDIA_ATTACHING,i.default.MANIFEST_PARSED,i.default.BUFFER_CODECS,i.default.MEDIA_DETACHING));return r.autoLevelCapping=Number.POSITIVE_INFINITY,r.firstLevel=null,r.levels=[],r.media=null,r.restrictedLevels=[],r.timer=null,r}return 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)}(t,e),a(t,[{key:"destroy",value:function(){this.hls.config.capLevelToPlayerSize&&(this.media=null,this._stopCapping())}},{key:"onFpsDropLevelCapping",value:function(e){t.isLevelAllowed(e.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(e.droppedLevel)}},{key:"onMediaAttaching",value:function(e){this.media=e.media instanceof window.HTMLVideoElement?e.media:null}},{key:"onManifestParsed",value:function(e){var t=this.hls;this.restrictedLevels=[],this.levels=e.levels,this.firstLevel=e.firstLevel,t.config.capLevelToPlayerSize&&e.video&&this._startCapping()}},{key:"onBufferCodecs",value:function(e){this.hls.config.capLevelToPlayerSize&&e.video&&this._startCapping()}},{key:"onLevelsUpdated",value:function(e){this.levels=e.levels}},{key:"onMediaDetaching",value:function(){this._stopCapping()}},{key:"detectPlayerSize",value:function(){if(this.media){var e=this.levels?this.levels.length:0;if(e){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e-1),t.autoLevelCapping>this.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}},{key:"getMaxLevel",value:function(e){var r=this;if(!this.levels)return-1;var a=this.levels.filter((function(a,i){return t.isLevelAllowed(i,r.restrictedLevels)&&i<=e}));return t.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)}},{key:"_startCapping",value:function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{key:"_stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)}},{key:"mediaWidth",get:function(){var e=void 0,r=this.media;return r&&(e=r.width||r.clientWidth||r.offsetWidth,e*=t.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e=void 0,r=this.media;return r&&(e=r.height||r.clientHeight||r.offsetHeight,e*=t.contentScaleFactor),e}}],[{key:"isLevelAllowed",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return-1===t.indexOf(e)}},{key:"getMaxLevelByMediaSize",value:function(e,t,r){if(!e||e&&!e.length)return-1;for(var a,i,n=e.length-1,o=0;o<e.length;o+=1){var s=e[o];if((s.width>=t||s.height>=r)&&(a=s,!(i=e[o+1])||a.width!==i.width||a.height!==i.height)){n=o;break}}return n}},{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}]),t}(n(r(3)).default);t.default=o,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=s(r(1)),n=s(r(3)),o=r(0);function s(e){return e&&e.__esModule?e:{default:e}}var l=window.performance,u=function(e){function t(e){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.MEDIA_ATTACHING))}return 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)}(t,e),a(t,[{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 window.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=l.now();if(t){if(this.lastTime){var n=a-this.lastTime,s=r-this.lastDroppedFrames,u=t-this.lastDecodedFrames,d=1e3*s/n,f=this.hls;if(f.trigger(i.default.FPS_DROP,{currentDropped:s,currentDecoded:u,totalDroppedFrames:r}),d>0&&s>f.config.fpsDroppedMonitoringThreshold*u){var c=f.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===f.autoLevelCapping||f.autoLevelCapping>=c)&&(c-=1,f.trigger(i.default.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:f.currentLevel}),f.autoLevelCapping=c,f.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.video;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}]),t}(n.default);t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=r(0);var n=window,o=n.performance,s=n.XMLHttpRequest,l=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t&&t.xhrSetup&&(this.xhrSetup=t.xhrSetup)}return a(e,[{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:o.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()}},{key:"loadInternal",value:function(){var e=void 0,t=this.context;e=this.loader=new s;var r=this.stats;r.tfirst=0,r.loaded=0;var a=this.xhrSetup;try{if(a)try{a(e,t.url)}catch(r){e.open("GET",t.url,!0),a(e,t.url)}e.readyState||e.open("GET",t.url,!0)}catch(r){return void this.callbacks.onError({code:e.status,text:r.message},t,e)}t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),e.send()}},{key:"readystatechange",value:function(e){var t=e.currentTarget,r=t.readyState,a=this.stats,n=this.context,s=this.config;if(!a.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===a.tfirst&&(a.tfirst=Math.max(o.now(),a.trequest)),4===r){var l=t.status;if(l>=200&&l<300){a.tload=Math.max(a.tfirst,o.now());var u=void 0,d=void 0;d="arraybuffer"===n.responseType?(u=t.response).byteLength:(u=t.responseText).length,a.loaded=a.total=d;var f={url:t.responseURL,data:u};this.callbacks.onSuccess(f,a,n,t)}else a.retry>=s.maxRetry||l>=400&&l<499?(i.logger.error(l+" while loading "+n.url),this.callbacks.onError({code:l,text:t.statusText},n,t)):(i.logger.warn(l+" 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),a.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.timeout)}},{key:"loadtimeout",value:function(){i.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)}},{key:"loadprogress",value:function(e){var t=e.currentTarget,r=this.stats;r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total);var a=this.callbacks.onProgress;a&&a(r,this.context,null,t)}}]),e}();t.default=l,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=l(r(1)),n=l(r(28)),o=r(0),s=r(2);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.MANIFEST_LOADING,i.default.MANIFEST_PARSED,i.default.AUDIO_TRACK_LOADED,i.default.AUDIO_TRACK_SWITCHED,i.default.LEVEL_LOADED,i.default.ERROR));return r._trackId=-1,r._selectDefaultTrack=!0,r.tracks=[],r.trackIdBlacklist=Object.create(null),r.audioGroupId=null,r}return 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)}(t,e),a(t,[{key:"onManifestLoading",value:function(){this.tracks=[],this._trackId=-1,this._selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e){var t=this.tracks=e.audioTracks||[];this.hls.trigger(i.default.AUDIO_TRACKS_UPDATED,{audioTracks:t})}},{key:"onAudioTrackLoaded",value:function(e){if(e.id>=this.tracks.length)o.logger.warn("Invalid audio track id:",e.id);else{if(o.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()){var t=1e3*e.details.targetduration;this.setInterval(t)}!e.details.live&&this.hasInterval()&&this.clearInterval()}}},{key:"onAudioTrackSwitched",value:function(e){var t=this.tracks[e.id].groupId;t&&this.audioGroupId!==t&&(this.audioGroupId=t)}},{key:"onLevelLoaded",value:function(e){var t=this.hls.levels[e.level];if(t.audioGroupIds){var r=t.audioGroupIds[t.urlId];this.audioGroupId!==r&&(this.audioGroupId=r,this._selectInitialAudioTrack())}}},{key:"onError",value:function(e){e.type===s.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(o.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))}},{key:"_setAudioTrack",value:function(e){if(this._trackId===e&&this.tracks[this._trackId].details)o.logger.debug("Same id as current audio-track passed, and track details available -> no-op");else if(e<0||e>=this.tracks.length)o.logger.warn("Invalid id passed to audio-track controller");else{var t=this.tracks[e];o.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e;var r=t.url,a=t.type,n=t.id;this.hls.trigger(i.default.AUDIO_TRACK_SWITCHING,{id:n,type:a,url:r}),this._loadTrackDetailsIfNeeded(t)}}},{key:"doTick",value:function(){this._updateTrack(this._trackId)}},{key:"_selectInitialAudioTrack",value:function(){var e=this,t=this.tracks;if(t.length){var r=this.tracks[this._trackId],a=null;if(r&&(a=r.name),this._selectDefaultTrack){var n=t.filter((function(e){return e.default}));n.length?t=n:o.logger.warn("No default audio tracks defined")}var l=!1,u=function(){t.forEach((function(t){l||e.audioGroupId&&t.groupId!==e.audioGroupId||a&&a!==t.name||(e._setAudioTrack(t.id),l=!0)}))};u(),l||(a=null,u()),l||(o.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(i.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}}},{key:"_needsTrackLoading",value:function(e){var t=e.details,r=e.url;return!(t&&!t.live)&&!!r}},{key:"_loadTrackDetailsIfNeeded",value:function(e){if(this._needsTrackLoading(e)){var t=e.url,r=e.id;o.logger.log("loading audio-track playlist for id: "+r),this.hls.trigger(i.default.AUDIO_TRACK_LOADING,{url:t,id:r})}}},{key:"_updateTrack",value:function(e){if(!(e<0||e>=this.tracks.length)){this.clearInterval(),this._trackId=e,o.logger.log("trying to update audio-track "+e);var t=this.tracks[e];this._loadTrackDetailsIfNeeded(t)}}},{key:"_handleLoadError",value:function(){this.trackIdBlacklist[this._trackId]=!0;var e=this._trackId,t=this.tracks[e],r=t.name,a=t.language,i=t.groupId;o.logger.warn("Loading failed on audio track id: "+e+", group-id: "+i+', name/language: "'+r+'" / "'+a+'"');for(var n=e,s=0;s<this.tracks.length;s++){if(!this.trackIdBlacklist[s])if(this.tracks[s].name===r){n=s;break}}n!==e?(o.logger.log("Attempting audio-track fallback id:",n,"group-id:",this.tracks[n].groupId),this._setAudioTrack(n)):o.logger.warn('No fallback audio-track found for name/language: "'+r+'" / "'+a+'"')}},{key:"audioTracks",get:function(){return this.tracks}},{key:"audioTrack",get:function(){return this._trackId},set:function(e){this._setAudioTrack(e),this._selectDefaultTrack=!1}}]),t}(n.default);t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=y(r(9)),n=r(4),o=y(r(19)),s=y(r(1)),l=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(r(7)),u=y(r(25)),d=r(2),f=r(0),c=r(26),h=r(6),v=y(r(11)),g=r(14),p=y(g);function y(e){return e&&e.__esModule?e:{default:e}}var m=window.performance,b=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var a=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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,s.default.MEDIA_ATTACHED,s.default.MEDIA_DETACHING,s.default.AUDIO_TRACKS_UPDATED,s.default.AUDIO_TRACK_SWITCHING,s.default.AUDIO_TRACK_LOADED,s.default.KEY_LOADED,s.default.FRAG_LOADED,s.default.FRAG_PARSING_INIT_SEGMENT,s.default.FRAG_PARSING_DATA,s.default.FRAG_PARSED,s.default.ERROR,s.default.BUFFER_RESET,s.default.BUFFER_CREATED,s.default.BUFFER_APPENDED,s.default.BUFFER_FLUSHED,s.default.INIT_PTS_FOUND));return a.fragmentTracker=r,a.config=e.config,a.audioCodecSwap=!1,a._state=g.State.STOPPED,a.initPTS=[],a.waitingFragment=null,a.videoTrackCC=null,a}return 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)}(t,e),a(t,[{key:"onInitPtsFound",value:function(e){var t=e.id,r=e.frag.cc,a=e.initPTS;"main"===t&&(this.initPTS[r]=a,this.videoTrackCC=r,f.logger.log("InitPTS for cc: "+r+" found from video track: "+a),this.state===g.State.WAITING_INIT_PTS&&this.tick())}},{key:"startLoad",value:function(e){if(this.tracks){var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,t>0&&-1===e?(f.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=g.State.IDLE):(this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=g.State.STARTING),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=e,this.state=g.State.STOPPED}},{key:"doTick",value:function(){var e=void 0,t=void 0,r=void 0,a=this.hls,o=a.config;switch(this.state){case g.State.ERROR:case g.State.PAUSED:case g.State.BUFFER_FLUSHING:break;case g.State.STARTING:this.state=g.State.WAITING_TRACK,this.loadedmetadata=!1;break;case g.State.IDLE:var l=this.tracks;if(!l)break;if(!this.media&&(this.startFragRequested||!o.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var u=this.mediaBuffer?this.mediaBuffer:this.media,d=this.videoBuffer?this.videoBuffer:this.media,v=n.BufferHelper.bufferInfo(u,e,o.maxBufferHole),p=n.BufferHelper.bufferInfo(d,e,o.maxBufferHole),y=v.len,b=v.end,E=this.fragPrevious,_=Math.min(o.maxBufferLength,o.maxMaxBufferLength),T=Math.max(_,p.len),S=this.audioSwitch,k=this.trackId;if((y<T||S)&&k<l.length){if(void 0===(r=l[k].details)){this.state=g.State.WAITING_TRACK;break}if(!S&&this._streamEnded(v,r))return this.hls.trigger(s.default.BUFFER_EOS,{type:"audio"}),void(this.state=g.State.ENDED);var R=r.fragments,A=R.length,w=R[0].start,O=R[A-1].start+R[A-1].duration,L=void 0;if(S)if(r.live&&!r.PTSKnown)f.logger.log("switching audiotrack, live stream, unknown PTS,load first fragment"),b=0;else if(b=e,r.PTSKnown&&e<w){if(!(v.end>w||v.nextStart))return;f.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=w+.05}if(r.initSegment&&!r.initSegment.data)L=r.initSegment;else if(b<=w){if(L=R[0],null!==this.videoTrackCC&&L.cc!==this.videoTrackCC&&(L=(0,c.findFragWithCC)(R,this.videoTrackCC)),r.live&&L.loadIdx&&L.loadIdx===this.fragLoadIdx){var D=v.nextStart?v.nextStart:w;return f.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(D+.05)),void(this.media.currentTime=D+.05)}}else{var P=void 0,I=o.maxFragLookUpTolerance,C=E?R[E.sn-R[0].sn+1]:void 0,x=function(e){var t=Math.min(I,e.duration);return e.start+e.duration-t<=b?1:e.start-t>b&&e.start?-1:0};b<O?(b>O-I&&(I=0),P=C&&!x(C)?C:i.default.search(R,x)):P=R[A-1],P&&(L=P,w=P.start,E&&L.level===E.level&&L.sn===E.sn&&(L.sn<r.endSN?(L=R[L.sn+1-r.startSN],f.logger.log("SN just loaded, load next one: "+L.sn)):L=null))}L&&(L.encrypted?(f.logger.log("Loading key for "+L.sn+" of ["+r.startSN+" ,"+r.endSN+"],track "+k),this.state=g.State.KEY_LOADING,a.trigger(s.default.KEY_LOADING,{frag:L})):(f.logger.log("Loading "+L.sn+", cc: "+L.cc+" of ["+r.startSN+" ,"+r.endSN+"],track "+k+", currentTime:"+e+",bufferEnd:"+b.toFixed(3)),this.fragCurrent=L,(S||this.fragmentTracker.getState(L)===h.FragmentState.NOT_LOADED)&&(this.startFragRequested=!0,Number.isFinite(L.sn)&&(this.nextLoadPosition=L.start+L.duration),a.trigger(s.default.FRAG_LOADING,{frag:L}),this.state=g.State.FRAG_LOADING)))}break;case g.State.WAITING_TRACK:(t=this.tracks[this.trackId])&&t.details&&(this.state=g.State.IDLE);break;case g.State.FRAG_LOADING_WAITING_RETRY:var M=m.now(),F=this.retryDate,N=(u=this.media)&&u.seeking;(!F||M>=F||N)&&(f.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=g.State.IDLE);break;case g.State.WAITING_INIT_PTS:var U=this.videoTrackCC;if(void 0===this.initPTS[U])break;var B=this.waitingFragment;if(B){var G=B.frag.cc;U!==G?(t=this.tracks[this.trackId]).details&&t.details.live&&(f.logger.warn("Waiting fragment CC ("+G+") does not match video track CC ("+U+")"),this.waitingFragment=null,this.state=g.State.IDLE):(this.state=g.State.FRAG_LOADING,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=g.State.IDLE;break;case g.State.STOPPED:case g.State.FRAG_LOADING:case g.State.PARSING:case g.State.PARSED:case g.State.ENDED:}}},{key:"onMediaAttached",value:function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)}},{key:"onMediaDetaching",value:function(){var e=this.media;e&&e.ended&&(f.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.stopLoad()}},{key:"onAudioTracksUpdated",value:function(e){f.logger.log("audio tracks updated"),this.tracks=e.audioTracks}},{key:"onAudioTrackSwitching",value:function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.state=g.State.PAUSED,this.waitingFragment=null,t?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=g.State.IDLE),this.tick()}},{key:"onAudioTrackLoaded",value:function(e){var t=e.details,r=e.id,a=this.tracks[r],i=t.totalduration,n=0;if(f.logger.log("track "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+i),t.live){var o=a.details;o&&t.fragments.length>0?(l.mergeDetails(o,t),n=t.fragments[0].start,t.PTSKnown?f.logger.log("live audio playlist sliding:"+n.toFixed(3)):f.logger.log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,f.logger.log("live audio playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(a.details=t,!this.startFragRequested){if(-1===this.startPosition){var s=t.startTimeOffset;Number.isFinite(s)?(f.logger.log("start time offset found in playlist, adjust startPosition to "+s),this.startPosition=s):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===g.State.WAITING_TRACK&&(this.state=g.State.IDLE),this.tick()}},{key:"onKeyLoaded",value:function(){this.state===g.State.KEY_LOADING&&(this.state=g.State.IDLE,this.tick())}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag;if(this.state===g.State.FRAG_LOADING&&t&&"audio"===r.type&&r.level===t.level&&r.sn===t.sn){var a=this.tracks[this.trackId],i=a.details,n=i.totalduration,l=t.level,u=t.sn,d=t.cc,c=this.config.defaultAudioCodec||a.audioCodec||"mp4a.40.2",h=this.stats=e.stats;if("initSegment"===u)this.state=g.State.IDLE,h.tparsed=h.tbuffered=m.now(),i.initSegment.data=e.payload,this.hls.trigger(s.default.FRAG_BUFFERED,{stats:h,frag:t,id:"audio"}),this.tick();else{this.state=g.State.PARSING,this.appended=!1,this.demuxer||(this.demuxer=new o.default(this.hls,"audio"));var v=this.initPTS[d],p=i.initSegment?i.initSegment.data:[];if(i.initSegment||void 0!==v){this.pendingBuffering=!0,f.logger.log("Demuxing "+u+" of ["+i.startSN+" ,"+i.endSN+"],track "+l);this.demuxer.push(e.payload,p,c,null,t,n,!1,v)}else f.logger.log("unknown video PTS for continuity counter "+d+", waiting for video PTS before demuxing audio frag "+u+" of ["+i.startSN+" ,"+i.endSN+"],track "+l),this.waitingFragment=e,this.state=g.State.WAITING_INIT_PTS}}this.fragLoadError=0}},{key:"onFragParsingInitSegment",value:function(e){var t=this.fragCurrent,r=e.frag;if(t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===g.State.PARSING){var a=e.tracks,i=void 0;if(a.video&&delete a.video,i=a.audio){i.levelCodec=i.codec,i.id=e.id,this.hls.trigger(s.default.BUFFER_CODECS,a),f.logger.log("audio track:audio,container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var n=i.initSegment;if(n){var o={type:"audio",data:n,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[o]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(s.default.BUFFER_APPENDING,o))}this.tick()}}}},{key:"onFragParsingData",value:function(e){var t=this,r=this.fragCurrent,a=e.frag;if(r&&"audio"===e.id&&"audio"===e.type&&a.sn===r.sn&&a.level===r.level&&this.state===g.State.PARSING){var i=this.trackId,n=this.tracks[i],o=this.hls;Number.isFinite(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),r.addElementaryStream(v.default.ElementaryStreamTypes.AUDIO),f.logger.log("parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb),l.updateFragPTSDTS(n.details,r,e.startPTS,e.endPTS);var u=this.audioSwitch,c=this.media,h=!1;if(u&&c)if(c.readyState){var p=c.currentTime;f.logger.log("switching audio track : currentTime:"+p),p>=e.startPTS&&(f.logger.log("switching audio track : flushing all audio"),this.state=g.State.BUFFER_FLUSHING,o.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),h=!0,this.audioSwitch=!1,o.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:i}))}else this.audioSwitch=!1,o.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:i});var y=this.pendingData;if(!y)return f.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void o.trigger(s.default.ERROR,{type:d.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([e.data1,e.data2].forEach((function(t){t&&t.length&&y.push({type:e.type,data:t,parent:"audio",content:"data"})})),!h&&y.length&&(y.forEach((function(e){t.state===g.State.PARSING&&(t.pendingBuffering=!0,t.hls.trigger(s.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===g.State.PARSING&&(this.stats.tparsed=m.now(),this.state=g.State.PARSED,this._checkAppendedParsed())}},{key:"onBufferReset",value:function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}},{key:"onBufferCreated",value:function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)}},{key:"onBufferAppended",value:function(e){if("audio"===e.parent){var t=this.state;t!==g.State.PARSING&&t!==g.State.PARSED||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}}},{key:"_checkAppendedParsed",value:function(){if(!(this.state!==g.State.PARSED||this.appended&&this.pendingBuffering)){var e=this.fragCurrent,t=this.stats,r=this.hls;if(e){this.fragPrevious=e,t.tbuffered=m.now(),r.trigger(s.default.FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var a=this.mediaBuffer?this.mediaBuffer:this.media;f.logger.log("audio buffered : "+u.default.toString(a.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(s.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=g.State.IDLE}this.tick()}}},{key:"onError",value:function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:var r=e.frag;if(r&&"audio"!==r.type)break;if(!e.fatal){var a=this.fragLoadError;a?a++:a=1;var i=this.config;if(a<=i.fragLoadingMaxRetry){this.fragLoadError=a;var o=Math.min(Math.pow(2,a-1)*i.fragLoadingRetryDelay,i.fragLoadingMaxRetryTimeout);f.logger.warn("AudioStreamController: frag loading failed, retry in "+o+" ms"),this.retryDate=m.now()+o,this.state=g.State.FRAG_LOADING_WAITING_RETRY}else f.logger.error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=g.State.ERROR}break;case d.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case d.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==g.State.ERROR&&(this.state=e.fatal?g.State.ERROR:g.State.IDLE,f.logger.warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===e.parent&&(this.state===g.State.PARSING||this.state===g.State.PARSED)){var l=this.mediaBuffer,u=this.media.currentTime;if(l&&n.BufferHelper.isBuffered(l,u)&&n.BufferHelper.isBuffered(l,u+.5)){var c=this.config;c.maxMaxBufferLength>=c.maxBufferLength&&(c.maxMaxBufferLength/=2,f.logger.warn("AudioStreamController: reduce max buffer length to "+c.maxMaxBufferLength+"s")),this.state=g.State.IDLE}else f.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=g.State.BUFFER_FLUSHING,this.hls.trigger(s.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}}},{key:"onBufferFlushed",value:function(){var e=this,t=this.pendingData;t&&t.length?(f.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),t.forEach((function(t){e.hls.trigger(s.default.BUFFER_APPENDING,t)})),this.appended=!0,this.pendingData=[],this.state=g.State.PARSED):(this.state=g.State.IDLE,this.fragPrevious=null,this.tick())}},{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,f.logger.log("audio stream:"+t+"->"+e)}},get:function(){return this._state}}]),t}(p.default);t.default=b,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.newCue=function(e,t,r,i){for(var n=void 0,o=void 0,s=void 0,l=void 0,u=void 0,d=window.VTTCue||window.TextTrackCue,f=0;f<i.rows.length;f++)if(n=i.rows[f],s=!0,l=0,u="",!n.isEmpty()){for(var c=0;c<n.chars.length;c++)n.chars[c].uchar.match(/\s/)&&s?l++:(u+=n.chars[c].uchar,s=!1);n.cueStartTime=t,t===r&&(r+=1e-4),o=new d(t,r,(0,a.fixLineBreaks)(u.trim())),l>=16?l--:l++,navigator.userAgent.match(/Firefox\//)?o.line=f+1:o.line=f>7?f-2:f+1,o.align="left",o.position=Math.max(0,Math.min(100,l/32*100+(navigator.userAgent.match(/Firefox\//)?50:0))),e.addCue(o)}};var a=r(30)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var e={"":!0,lr:!0,rl:!0},t={start:!0,middle:!0,end:!0,left:!0,right:!0};function r(e){return"string"==typeof e&&(!!t[e.toLowerCase()]&&e.toLowerCase())}function a(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)e[a]=r[a]}return e}function i(t,i,n){var o=this,s=function(){if("undefined"!=typeof navigator)return/MSIE\s8\.0/.test(navigator.userAgent)}(),l={};s?o=document.createElement("custom"):l.enumerable=!0,o.hasBeenReset=!1;var u="",d=!1,f=t,c=i,h=n,v=null,g="",p=!0,y="auto",m="start",b=50,E="middle",_=50,T="middle";if(Object.defineProperty(o,"id",a({},l,{get:function(){return u},set:function(e){u=""+e}})),Object.defineProperty(o,"pauseOnExit",a({},l,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(o,"startTime",a({},l,{get:function(){return f},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");f=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",a({},l,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",a({},l,{get:function(){return h},set:function(e){h=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",a({},l,{get:function(){return v},set:function(e){v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",a({},l,{get:function(){return g},set:function(t){var r=function(t){return"string"==typeof t&&(!!e[t.toLowerCase()]&&t.toLowerCase())}(t);if(!1===r)throw new SyntaxError("An invalid or illegal string was specified.");g=r,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",a({},l,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",a({},l,{get:function(){return y},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",a({},l,{get:function(){return m},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");m=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",a({},l,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",a({},l,{get:function(){return E},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",a({},l,{get:function(){return _},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");_=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",a({},l,{get:function(){return T},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");T=t,this.hasBeenReset=!0}})),o.displayState=void 0,s)return o}return i.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},i}(),e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=f(r(1)),n=f(r(3)),o=f(r(73)),s=f(r(74)),l=f(r(75)),u=r(0),d=r(29);function f(e){return e&&e.__esModule?e:{default:e}}function c(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}var h=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.MEDIA_ATTACHING,i.default.MEDIA_DETACHING,i.default.FRAG_PARSING_USERDATA,i.default.FRAG_DECRYPTED,i.default.MANIFEST_LOADING,i.default.MANIFEST_LOADED,i.default.FRAG_LOADED,i.default.LEVEL_SWITCHING,i.default.INIT_PTS_FOUND));if(r.hls=e,r.config=e.config,r.enabled=!0,r.Cues=e.config.cueHandler,r.textTracks=[],r.tracks=[],r.unparsedVttFrags=[],r.initPTS=[],r.cueRanges=[],r.captionsTracks={},r.captionsProperties={textTrack1:{label:r.config.captionsTextTrack1Label,languageCode:r.config.captionsTextTrack1LanguageCode},textTrack2:{label:r.config.captionsTextTrack2Label,languageCode:r.config.captionsTextTrack2LanguageCode}},r.config.enableCEA708Captions){var a=new s.default(r,"textTrack1"),n=new s.default(r,"textTrack2");r.cea608Parser=new o.default(0,a,n)}return r}return 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)}(t,e),a(t,[{key:"addCues",value:function(e,t,r,a){for(var i,n,o,s,l=this.cueRanges,u=!1,d=l.length;d--;){var f=l[d],c=(i=f[0],n=f[1],o=t,s=r,Math.min(n,s)-Math.max(i,o));if(c>=0&&(f[0]=Math.min(f[0],t),f[1]=Math.max(f[1],r),u=!0,c/(r-t)>.5))return}u||l.push([t,r]),this.Cues.newCue(this.captionsTracks[e],t,r,a)}},{key:"onInitPtsFound",value:function(e){var t=this;if("main"===e.id&&(this.initPTS[e.frag.cc]=e.initPTS),this.unparsedVttFrags.length){var r=this.unparsedVttFrags;this.unparsedVttFrags=[],r.forEach((function(e){t.onFragLoaded(e)}))}}},{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(a[e])return a}return null}},{key:"createCaptionsTrack",value:function(e){var t=this.captionsProperties[e],r=t.label,a=t.languageCode,i=this.captionsTracks;if(!i[e]){var n=this.getExistingTrack(e);if(n)i[e]=n,(0,d.clearCurrentCues)(i[e]),(0,d.sendAddTrackEvent)(i[e],this.media);else{var o=this.createTextTrack("captions",r,a);o&&(o[e]=!0,i[e]=o)}}}},{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,this._cleanTracks()}},{key:"onMediaDetaching",value:function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){(0,d.clearCurrentCues)(e[t]),delete e[t]}))}},{key:"onManifestLoading",value:function(){this.lastSn=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks()}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)(0,d.clearCurrentCues)(t[r])}}},{key:"onManifestLoaded",value:function(e){var t=this;if(this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.cueRanges=[],this.config.enableWebVTT){this.tracks=e.subtitles||[];var r=this.media?this.media.textTracks:[];this.tracks.forEach((function(e,a){var i=void 0;if(a<r.length){for(var n=null,o=0;o<r.length;o++)if(c(r[o],e)){n=r[o];break}n&&(i=n)}i||(i=t.createTextTrack("subtitles",e.name,e.lang)),e.default?i.mode=t.hls.subtitleDisplay?"showing":"hidden":i.mode="disabled",t.textTracks.push(i)}))}}},{key:"onLevelSwitching",value:function(){this.enabled="NONE"!==this.hls.currentLevel.closedCaptions}},{key:"onFragLoaded",value:function(e){var t=e.frag,r=e.payload;if("main"===t.type){var a=t.sn;if(a!==this.lastSn+1){var n=this.cea608Parser;n&&n.reset()}this.lastSn=a}else if("subtitle"===t.type)if(r.byteLength){if(!Number.isFinite(this.initPTS[t.cc]))return this.unparsedVttFrags.push(e),void(this.initPTS.length&&this.hls.trigger(i.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t}));var o=t.decryptdata;null!=o&&null!=o.key&&"AES-128"===o.method||this._parseVTTs(t,r)}else this.hls.trigger(i.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t})}},{key:"_parseVTTs",value:function(e,t){var r=this.vttCCs;r[e.cc]||(r[e.cc]={start:e.start,prevCC:this.prevCC,new:!0},this.prevCC=e.cc);var a=this.textTracks,n=this.hls;l.default.parse(t,this.initPTS[e.cc],r,e.cc,(function(t){var r=a[e.level];"disabled"!==r.mode?(t.forEach((function(e){if(!r.cues.getCueById(e.id))try{r.addCue(e)}catch(a){var t=new window.TextTrackCue(e.startTime,e.endTime,e.text);t.id=e.id,r.addCue(t)}})),n.trigger(i.default.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})):n.trigger(i.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})}),(function(t){u.logger.log("Failed to parse VTT cue: "+t),n.trigger(i.default.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e})}))}},{key:"onFragDecrypted",value:function(e){var t=e.payload,r=e.frag;if("subtitle"===r.type){if(!Number.isFinite(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(e);this._parseVTTs(r,t)}}},{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=31&e[0],r=2,a=void 0,i=void 0,n=void 0,o=[],s=0;s<t;s++)a=e[r++],i=127&e[r++],n=127&e[r++],0===i&&0===n||0!=(4&a)&&0===(3&a)&&(o.push(i),o.push(n));return o}}]),t}(n.default);t.default=h,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}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},o=function(e){var t=e;return n.hasOwnProperty(e)&&(t=n[e]),String.fromCharCode(t)},s={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},l={17:2,18:4,21:6,22:8,23:10,19:13,20:15},u={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},d={25:2,26:4,29:6,30:8,31:10,27:13,28:15},f=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],c={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){this.verboseFilter[e];this.verboseLevel}},h=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},v=function(){function e(t,r,a,n,o){i(this,e),this.foreground=t||"white",this.underline=r||!1,this.italics=a||!1,this.background=n||"black",this.flash=o||!1}return a(e,[{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}}]),e}(),g=function(){function e(t,r,a,n,o,s){i(this,e),this.uchar=t||" ",this.penState=new v(r,a,n,o,s)}return a(e,[{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()}}]),e}(),p=function(){function e(){i(this,e),this.chars=[];for(var t=0;t<100;t++)this.chars.push(new g);this.pos=0,this.currPenState=new v}return a(e,[{key:"equals",value:function(e){for(var t=!0,r=0;r<100;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<100;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<100;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?(c.log("ERROR","Negative cursor position "+this.pos),this.pos=0):this.pos>100&&(c.log("ERROR","Too large cursor position "+this.pos),this.pos=100)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)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){e>=144&&this.backSpace();var t=o(e);this.pos>=100?c.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){var t=void 0;for(t=e;t<100;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<100;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)}}]),e}(),y=function(){function e(){i(this,e),this.rows=[];for(var t=0;t<15;t++)this.rows.push(new p);this.currRow=14,this.nrRollUpRows=null,this.reset()}return a(e,[{key:"reset",value:function(){for(var e=0;e<15;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,r=0;r<15;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<15;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<15;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){c.log("INFO","setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){c.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<15;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<c.time)for(var o=0;o<this.nrRollUpRows;o++)this.rows[t-this.nrRollUpRows+o+1].copy(i.rows[a+o])}}this.currRow=t;var s=this.rows[this.currRow];if(null!==e.indent){var l=e.indent,u=Math.max(l-1,0);s.setCursor(e.indent),e.color=s.chars[u].penState.foreground}var d={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(d)}},{key:"setBkgData",value:function(e){c.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(){if(null!==this.nrRollUpRows){c.log("TEXT",this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),c.log("INFO","Rolling up")}else c.log("DEBUG","roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],r="",a=-1,i=0;i<15;i++){var n=this.rows[i].getTextString();n&&(a=i+1,e?t.push("Row "+a+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}},{key:"getTextAndFormat",value:function(){return this.rows}}]),e}(),m=function(){function e(t,r){i(this,e),this.chNr=t,this.outputFilter=r,this.mode=null,this.verbose=0,this.displayedMemory=new y,this.nonDisplayedMemory=new y,this.lastOutputScreen=new y,this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}return a(e,[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.currRollUpRow=this.displayedMemory.rows[14],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,c.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";c.log("INFO",r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(c.log("TEXT","DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}},{key:"ccRCL",value:function(){c.log("INFO","RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){c.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(){c.log("INFO","DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){c.log("INFO","RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){c.log("INFO","FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){c.log("INFO","RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){c.log("INFO","TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){c.log("INFO","RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){c.log("INFO","EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){c.log("CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){c.log("INFO","ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){if(c.log("INFO","EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,c.log("TEXT","DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){c.log("INFO","TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}c.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=c.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue&&(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),!0===e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue()),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,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))}}]),e}(),b=function(){function e(t,r,a){i(this,e),this.field=t||1,this.outputs=[r,a],this.channels=[new m(1,r),new m(2,a)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.bufferedData=[],this.startTime=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}return a(e,[{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=void 0,a=void 0,i=void 0,n=!1;this.lastTime=e,c.setTime(e);for(var o=0;o<t.length;o+=2)if(a=127&t[o],i=127&t[o+1],0!==a||0!==i){if(c.log("DATA","["+h([t[o],t[o+1]])+"] -> ("+h([a,i])+")"),(r=this.parseCmd(a,i))||(r=this.parseMidrow(a,i)),r||(r=this.parsePAC(a,i)),r||(r=this.parseBackgroundAttributes(a,i)),!r)if(n=this.parseChars(a,i))if(this.currChNr&&this.currChNr>=0)this.channels[this.currChNr-1].insertChars(n);else c.log("WARNING","No channel found yet. TEXT-MODE?");r?this.dataCounters.cmd+=2:n?this.dataCounters.char+=2:(this.dataCounters.other+=2,c.log("WARNING","Couldn't parse cleaned data "+h([a,i])+" orig: "+h([t[o],t[o+1]])))}else this.dataCounters.padding+=2}},{key:"parseCmd",value:function(e,t){var r=null;if(!((20===e||28===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,c.log("DEBUG","Repeated command ("+h([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)&&t>=32&&t<=47&&((r=17===e?1:2)!==this.currChNr?(c.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[r-1].ccMIDROW(t),c.log("DEBUG","MIDROW ("+h([e,t])+")"),!0))}},{key:"parsePAC",value:function(e,t){var r,a=null;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;r=e<=23?1:2,a=t>=64&&t<=95?1===r?s[e]:u[e]:1===r?l[e]:d[e];var i=this.interpretPAC(a,t);return this.channels[r-1].setPAC(i),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=r,!0}},{key:"interpretPAC",value:function(e,t){var r=t,a={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,a.underline=1==(1&r),r<=13?a.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(a.italics=!0,a.color="white"):a.indent=4*Math.floor((r-16)/2),a}},{key:"parseChars",value:function(e,t){var r=null,a=null,i=null;if(e>=25?(r=2,i=e-8):(r=1,i=e),i>=17&&i<=19){var n=t;n=17===i?t+80:18===i?t+112:t+144,c.log("INFO","Special char '"+o(n)+"' in channel "+r),a=[n]}else e>=32&&e<=127&&(a=0===t?[e]:[e,t]);if(a){var s=h(a);c.log("DEBUG","Char codes = "+s.join(",")),this.lastCmdA=null,this.lastCmdB=null}return a}},{key:"parseBackgroundAttributes",value:function(e,t){var r,a=void 0,i=void 0;return((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47)&&(a={},16===e||24===e?(i=Math.floor((t-32)/2),a.background=f[i],t%2==1&&(a.background=a.background+"_semi")):45===t?a.background="transparent":(a.foreground="black",47===t&&(a.underline=!0)),r=e<24?1:2,this.channels[r-1].setBkgData(a),this.lastCmdA=null,this.lastCmdB=null,!0)}},{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)}}]),e}();t.default=b,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}();var i=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.timelineController=t,this.trackName=r,this.startTime=null,this.endTime=null,this.screen=null}return a(e,[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen),this.startTime=null)}},{key:"newCue",value:function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}}]),e}();t.default=i,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a,i=r(30),n=(a=i)&&a.__esModule?a:{default:a},o=r(10);var s=function(e,t,r){return e.substr(r||0,t.length)===t},l=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()},u={parse:function(e,t,r,a,i,u){var d=(0,o.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),f="00:00.000",c=0,h=0,v=0,g=[],p=void 0,y=!0,m=new n.default;m.oncue=function(e){var t=r[a],i=r.ccOffset;t&&t.new&&(void 0!==h?i=r.ccOffset=t.start:function(e,t,r){var a=e[t],i=e[a.prevCC];if(!i||!i.new&&a.new)return e.ccOffset=e.presentationOffset=a.start,void(a.new=!1);for(;i&&i.new;)e.ccOffset+=a.start-i.start,a.new=!1,i=e[(a=i).prevCC];e.presentationOffset=r}(r,a,v)),v&&(i=v-r.presentationOffset),e.startTime+=i-h,e.endTime+=i-h,e.id=l(e.startTime.toString())+l(e.endTime.toString())+l(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),e.endTime>0&&g.push(e)},m.onparsingerror=function(e){p=e},m.onflush=function(){p&&u?u(p):i(g)},d.forEach((function(e){if(y){if(s(e,"X-TIMESTAMP-MAP=")){y=!1,e.substr(16).split(",").forEach((function(e){s(e,"LOCAL:")?f=e.substr(6):s(e,"MPEGTS:")&&(c=parseInt(e.substr(7)))}));try{t+(9e4*r[a].start||0)<0&&(t+=8589934592),c-=t,i=f,n=parseInt(i.substr(-3)),o=parseInt(i.substr(-6,2)),l=parseInt(i.substr(-9,2)),u=i.length>9?parseInt(i.substr(0,i.indexOf(":"))):0,h=(Number.isFinite(n)&&Number.isFinite(o)&&Number.isFinite(l)&&Number.isFinite(u)?(n+=1e3*o,n+=6e4*l,n+=36e5*u):-1)/1e3,v=c/9e4,-1===h&&(p=new Error("Malformed X-TIMESTAMP-MAP: "+e))}catch(t){p=new Error("Malformed X-TIMESTAMP-MAP: "+e)}return}""===e&&(y=!1)}var i,n,o,l,u;m.parse(e+"\n")})),m.flush()}};t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=l(r(1)),n=l(r(3)),o=r(0),s=r(7);function l(e){return e&&e.__esModule?e:{default:e}}var u=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.MEDIA_ATTACHED,i.default.MEDIA_DETACHING,i.default.MANIFEST_LOADED,i.default.SUBTITLE_TRACK_LOADED));return r.tracks=[],r.trackId=-1,r.media=null,r.stopped=!0,r.subtitleDisplay=!0,r}return 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)}(t,e),a(t,[{key:"destroy",value:function(){n.default.prototype.destroy.call(this)}},{key:"onMediaAttached",value:function(e){var t=this;this.media=e.media,this.media&&(this.queuedDefaultTrack&&(this.subtitleTrack=this.queuedDefaultTrack,delete this.queuedDefaultTrack),this.trackChangeListener=this._onTextTracksChanged.bind(this),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.subtitlePollingInterval=setInterval((function(){t.trackChangeListener()}),500):this.media.textTracks.addEventListener("change",this.trackChangeListener))}},{key:"onMediaDetaching",value:function(){this.media&&(this.useTextTrackPolling?clearInterval(this.subtitlePollingInterval):this.media.textTracks.removeEventListener("change",this.trackChangeListener),this.media=null)}},{key:"onManifestLoaded",value:function(e){var t=this,r=e.subtitles||[];this.tracks=r,this.hls.trigger(i.default.SUBTITLE_TRACKS_UPDATED,{subtitleTracks:r}),r.forEach((function(e){e.default&&(t.media?t.subtitleTrack=e.id:t.queuedDefaultTrack=e.id)}))}},{key:"onSubtitleTrackLoaded",value:function(e){var t=this,r=e.id,a=e.details,i=this.trackId,n=this.tracks,l=n[i];if(r>=n.length||r!==i||!l||this.stopped)this._clearReloadTimer();else if(o.logger.log("subtitle track "+r+" loaded"),a.live){var u=(0,s.computeReloadInterval)(l.details,a,e.stats.trequest);o.logger.log("Reloading live subtitle playlist in "+u+"ms"),this.timer=setTimeout((function(){t._loadCurrentTrack()}),u)}else this._clearReloadTimer()}},{key:"startLoad",value:function(){this.stopped=!1,this._loadCurrentTrack()}},{key:"stopLoad",value:function(){this.stopped=!0,this._clearReloadTimer()}},{key:"_clearReloadTimer",value:function(){this.timer&&(clearTimeout(this.timer),this.timer=null)}},{key:"_loadCurrentTrack",value:function(){var e=this.trackId,t=this.tracks,r=this.hls,a=t[e];e<0||!a||a.details&&!a.details.live||(o.logger.log("Loading subtitle track "+e),r.trigger(i.default.SUBTITLE_TRACK_LOADING,{url:a.url,id:e}))}},{key:"_toggleTrackModes",value:function(e){var t=this.media,r=this.subtitleDisplay,a=this.trackId;if(t){var i=d(t.textTracks);if(-1===e)[].slice.call(i).forEach((function(e){e.mode="disabled"}));else{var n=i[a];n&&(n.mode="disabled")}var o=i[e];o&&(o.mode=r?"showing":"hidden")}}},{key:"_setSubtitleTrackInternal",value:function(e){var t=this.hls,r=this.tracks;!Number.isFinite(e)||e<-1||e>=r.length||(this.trackId=e,o.logger.log("Switching to subtitle track "+e),t.trigger(i.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())}},{key:"_onTextTracksChanged",value:function(){if(this.media){for(var e=-1,t=d(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack=e}}},{key:"subtitleTracks",get:function(){return this.tracks}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.trackId!==e&&(this._toggleTrackModes(e),this._setSubtitleTrackInternal(e))}}]),t}(n.default);function d(e){for(var t=[],r=0;r<e.length;r++){var a=e[r];"subtitles"===a.kind&&a.label&&t.push(e[r])}return t}t.default=u,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubtitleStreamController=void 0;var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=h(r(1)),n=r(0),o=h(r(12)),s=r(4),l=r(27),u=r(6),d=r(14),f=h(d),c=r(7);function h(e){return e&&e.__esModule?e:{default:e}}var v=window.performance;t.SubtitleStreamController=function(e){function t(e,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var a=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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i.default.MEDIA_ATTACHED,i.default.MEDIA_DETACHING,i.default.ERROR,i.default.KEY_LOADED,i.default.FRAG_LOADED,i.default.SUBTITLE_TRACKS_UPDATED,i.default.SUBTITLE_TRACK_SWITCH,i.default.SUBTITLE_TRACK_LOADED,i.default.SUBTITLE_FRAG_PROCESSED,i.default.LEVEL_UPDATED));return a.fragmentTracker=r,a.config=e.config,a.state=d.State.STOPPED,a.tracks=[],a.tracksBuffered=[],a.currentTrackId=-1,a.decrypter=new o.default(e,e.config),a.lastAVStart=0,a._onMediaSeeking=a.onMediaSeeking.bind(a),a}return 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)}(t,e),a(t,[{key:"onSubtitleFragProcessed",value:function(e){var t=e.frag,r=e.success;if(this.fragPrevious=t,this.state=d.State.IDLE,r){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var i=void 0,n=t.start,o=0;o<a.length;o++)if(n>=a[o].start&&n<=a[o].end){i=a[o];break}var s=t.start+t.duration;i?i.end=s:(i={start:n,end:s},a.push(i))}}}},{key:"onMediaAttached",value:function(e){var t=e.media;this.media=t,t.addEventListener("seeking",this._onMediaSeeking),this.state=d.State.IDLE}},{key:"onMediaDetaching",value:function(){this.media.removeEventListener("seeking",this._onMediaSeeking),this.media=null,this.state=d.State.STOPPED}},{key:"onError",value:function(e){var t=e.frag;t&&"subtitle"===t.type&&(this.state=d.State.IDLE)}},{key:"onSubtitleTracksUpdated",value:function(e){var t=this;n.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach((function(e){t.tracksBuffered[e.id]=[]}))}},{key:"onSubtitleTrackSwitch",value:function(e){if(this.currentTrackId=e.id,this.tracks&&-1!==this.currentTrackId){var t=this.tracks[this.currentTrackId];t&&t.details&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e){var t=e.id,r=e.details,a=this.currentTrackId,i=this.tracks,n=i[a];t>=i.length||t!==a||!n||(r.live&&(0,c.mergeSubtitlePlaylists)(n.details,r,this.lastAVStart),n.details=r,this.setInterval(500))}},{key:"onKeyLoaded",value:function(){this.state===d.State.KEY_LOADING&&(this.state=d.State.IDLE)}},{key:"onFragLoaded",value:function(e){var t=this.fragCurrent,r=e.frag.decryptdata,a=e.frag,n=this.hls;if(this.state===d.State.FRAG_LOADING&&t&&"subtitle"===e.frag.type&&t.sn===e.frag.sn&&e.payload.byteLength>0&&r&&r.key&&"AES-128"===r.method){var o=v.now();this.decrypter.decrypt(e.payload,r.key.buffer,r.iv.buffer,(function(e){var t=v.now();n.trigger(i.default.FRAG_DECRYPTED,{frag:a,payload:e,stats:{tstart:o,tdecrypt:t}})}))}}},{key:"onLevelUpdated",value:function(e){var t=e.details.fragments;this.lastAVStart=t.length?t[0].start:0}},{key:"doTick",value:function(){if(this.media)switch(this.state){case d.State.IDLE:var e=this.config,t=this.currentTrackId,r=this.fragmentTracker,a=this.media,o=this.tracks;if(!o||!o[t]||!o[t].details)break;var f=e.maxBufferHole,c=e.maxFragLookUpTolerance,h=Math.min(e.maxBufferLength,e.maxMaxBufferLength),v=s.BufferHelper.bufferedInfo(this._getBuffered(),a.currentTime,f),g=v.end,p=v.len,y=o[t].details,m=y.fragments,b=m.length,E=m[b-1].start+m[b-1].duration;if(p>h)return;var _=void 0,T=this.fragPrevious;g<E?(T&&y.hasProgramDateTime&&(_=(0,l.findFragmentByPDT)(m,T.endProgramDateTime,c)),_||(_=(0,l.findFragmentByPTS)(T,m,g,c))):_=m[b-1],_&&_.encrypted?(n.logger.log("Loading key for "+_.sn),this.state=d.State.KEY_LOADING,this.hls.trigger(i.default.KEY_LOADING,{frag:_})):_&&r.getState(_)===u.FragmentState.NOT_LOADED&&(this.fragCurrent=_,this.state=d.State.FRAG_LOADING,this.hls.trigger(i.default.FRAG_LOADING,{frag:_}))}else this.state=d.State.IDLE}},{key:"stopLoad",value:function(){this.lastAVStart=0,function e(t,r,a){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var n=Object.getPrototypeOf(t);return null===n?void 0:e(n,r,a)}if("value"in i)return i.value;var o=i.get;return void 0!==o?o.call(a):void 0}(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"stopLoad",this).call(this)}},{key:"_getBuffered",value:function(){return this.tracksBuffered[this.currentTrackId]||[]}},{key:"onMediaSeeking",value:function(){this.fragPrevious=null}}]),t}(f.default)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,r,a){return r&&e(t.prototype,r),a&&e(t,a),t}}(),i=l(r(3)),n=l(r(1)),o=r(2),s=r(0);function l(e){return e&&e.__esModule?e:{default:e}}var u=window.XMLHttpRequest,d="com.widevine.alpha",f="com.microsoft.playready",c=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var 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,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n.default.MEDIA_ATTACHED,n.default.MANIFEST_PARSED));return r._widevineLicenseUrl=e.config.widevineLicenseUrl,r._licenseXhrSetup=e.config.licenseXhrSetup,r._emeEnabled=e.config.emeEnabled,r._requestMediaKeySystemAccess=e.config.requestMediaKeySystemAccessFunc,r._mediaKeysList=[],r._media=null,r._hasSetMediaKeys=!1,r._isMediaEncrypted=!1,r._requestLicenseFailureCount=0,r}return 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)}(t,e),a(t,[{key:"getLicenseServerUrl",value:function(e){var t=void 0;switch(e){case d:t=this._widevineLicenseUrl;break;default:t=null}return t||(s.logger.error('No license server URL configured for key-system "'+e+'"'),this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})),t}},{key:"_attemptKeySystemAccess",value:function(e,t,r){var a=this,i=function(e,t,r){switch(e){case d:return function(e,t,r){var a={videoCapabilities:[]};return t.forEach((function(e){a.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"'})})),[a]}(0,r);default:throw Error("Unknown key-system: "+e)}}(e,0,r);i?(s.logger.log("Requesting encrypted media key-system access"),this.requestMediaKeySystemAccess(e,i).then((function(t){a._onMediaKeySystemAccessObtained(e,t)})).catch((function(t){s.logger.error('Failed to obtain key-system "'+e+'" access:',t)}))):s.logger.warn("Can not create config for key-system (maybe because platform is not supported):",e)}},{key:"_onMediaKeySystemAccessObtained",value:function(e,t){var r=this;s.logger.log('Access for key-system "'+e+'" obtained');var a={mediaKeys:null,mediaKeysSession:null,mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:e};this._mediaKeysList.push(a),t.createMediaKeys().then((function(t){a.mediaKeys=t,s.logger.log('Media-keys created for key-system "'+e+'"'),r._onMediaKeysCreated()})).catch((function(e){s.logger.error("Failed to create media-keys:",e)}))}},{key:"_onMediaKeysCreated",value:function(){var e=this;this._mediaKeysList.forEach((function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),e._onNewMediaKeySession(t.mediaKeysSession))}))}},{key:"_onNewMediaKeySession",value:function(e){var t=this;s.logger.log("New key-system session "+e.sessionId),e.addEventListener("message",(function(r){t._onKeySessionMessage(e,r.message)}),!1)}},{key:"_onKeySessionMessage",value:function(e,t){s.logger.log("Got EME message event, creating license request"),this._requestLicense(t,(function(t){s.logger.log("Received license data, updating key-session"),e.update(t)}))}},{key:"_onMediaEncrypted",value:function(e,t){s.logger.log('Media is encrypted using "'+e+'" init data type'),this._isMediaEncrypted=!0,this._mediaEncryptionInitDataType=e,this._mediaEncryptionInitData=t,this._attemptSetMediaKeys(),this._generateRequestWithPreferredKeySession()}},{key:"_attemptSetMediaKeys",value:function(){if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});s.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}}},{key:"_generateRequestWithPreferredKeySession",value:function(){var e=this,t=this._mediaKeysList[0];if(!t)return s.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(t.mediaKeysSessionInitialized)s.logger.warn("Key-Session already initialized but requested again");else{var r=t.mediaKeysSession;r||(s.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0}));var a=this._mediaEncryptionInitDataType,i=this._mediaEncryptionInitData;s.logger.log('Generating key-session request for "'+a+'" init data type'),t.mediaKeysSessionInitialized=!0,r.generateRequest(a,i).then((function(){s.logger.debug("Key-session generation succeeded")})).catch((function(t){s.logger.error("Error generating key-session request:",t),e.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}}},{key:"_createLicenseXhr",value:function(e,t,r){var a=new u,i=this._licenseXhrSetup;try{if(i)try{i(a,e)}catch(t){a.open("POST",e,!0),i(a,e)}a.readyState||a.open("POST",e,!0)}catch(e){return s.logger.error("Error setting up key-system license XHR",e),void this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}return a.responseType="arraybuffer",a.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,a,e,t,r),a}},{key:"_onLicenseRequestReadyStageChange",value:function(e,t,r,a){switch(e.readyState){case 4:if(200===e.status)this._requestLicenseFailureCount=0,s.logger.log("License request succeeded"),a(e.response);else{if(s.logger.error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount<=3){var i=3-this._requestLicenseFailureCount+1;return s.logger.warn("Retrying license request, "+i+" attempts left"),void this._requestLicense(r,a)}this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}}}},{key:"_generateLicenseRequestChallenge",value:function(e,t){var r=void 0;return e.mediaKeySystemDomain===f?s.logger.error("PlayReady is not supported (yet)"):e.mediaKeySystemDomain===d?r=t:s.logger.error("Unsupported key-system:",e.mediaKeySystemDomain),r}},{key:"_requestLicense",value:function(e,t){s.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return s.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(n.default.ERROR,{type:o.ErrorTypes.KEY_SYSTEM_ERROR,details:o.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});var a=this.getLicenseServerUrl(r.mediaKeySystemDomain),i=this._createLicenseXhr(a,e,t);s.logger.log("Sending license request to URL: "+a),i.send(this._generateLicenseRequestChallenge(r,e))}},{key:"onMediaAttached",value:function(e){var t=this;if(this._emeEnabled){var r=e.media;this._media=r,r.addEventListener("encrypted",(function(e){t._onMediaEncrypted(e.initDataType,e.initData)}))}}},{key:"onManifestParsed",value:function(e){if(this._emeEnabled){var t=e.levels.map((function(e){return e.audioCodec})),r=e.levels.map((function(e){return e.videoCodec}));this._attemptKeySystemAccess(d,t,r)}}},{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),t}(i.default);t.default=c,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a="undefined"!=typeof window&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null;t.requestMediaKeySystemAccess=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a={getBrowserVersion:function(){var e=navigator.userAgent;if(e.toLowerCase().indexOf("mobile")>-1)return"Unknown";if(e.indexOf("Firefox")>-1)return"Firefox "+e.match(/firefox\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("Edge")>-1)return"Edge "+e.match(/edge\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("rv:11")>-1)return"IE 11";if(e.indexOf("Opera")>-1||e.indexOf("OPR")>-1){if(e.indexOf("Opera")>-1)return"Opera "+e.match(/opera\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("OPR")>-1)return"Opera "+e.match(/opr\/[\d.]+/gi)[0].match(/[\d]+/)[0]}else{if(e.indexOf("Chrome")>-1)return"Chrome "+e.match(/chrome\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("Safari")>-1)return"Safari "+e.match(/safari\/[\d.]+/gi)[0].match(/[\d]+/)[0];if(!(e.indexOf("MSIE")>-1||e.indexOf("Trident")>-1))return"Unknown";if(e.indexOf("MSIE")>-1)return"IE "+e.match(/msie [\d.]+/gi)[0].match(/[\d]+/)[0];if(e.indexOf("Trident")>-1){var t=e.match(/trident\/[\d.]+/gi)[0].match(/[\d]+/)[0];return"IE "+(parseInt(t)+4)}}}};t.default=a,e.exports=t.default}]); |