UNPKG

@swarmcloud/hls

Version:

Let your viewers become your unlimitedly scalable CDN.

1 lines 618 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Hls=t():e.Hls=t()}(this,(()=>(()=>{var e={415:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function n(){n.init.call(this)}e.exports=n,e.exports.once=function(e,t){return new Promise((function(r,i){function s(r){e.removeListener(t,n),i(r)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}p(e,t,n,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&p(e,"error",t,r)}(e,s,{once:!0})}))},n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var a=10;function o(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function h(e,t,r,i){var s,n,a,h;if(o(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),a=n[t]),void 0===a)a=n[t]=r,++e._eventsCount;else if("function"==typeof a?a=n[t]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),(s=l(e))>0&&a.length>s&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,h=u,console&&console.warn&&console.warn(h)}return e}function u(){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 d(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=u.bind(i);return s.listener=r,i.wrapFn=s,s}function c(e,t,r){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]: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}(s):g(s,s.length)}function f(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 g(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function p(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function s(n){i.once&&e.removeEventListener(t,s),r(n)}))}}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),n.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},n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(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},n.prototype.getMaxListeners=function(){return l(this)},n.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,n=this._events;if(void 0!==n)s=s&&void 0===n.error;else if(!s)return!1;if(s){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var l=n[e];if(void 0===l)return!1;if("function"==typeof l)i(l,this,t);else{var h=l.length,u=g(l,h);for(r=0;r<h;++r)i(u[r],this,t)}return!0},n.prototype.addListener=function(e,t){return h(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return h(this,e,t,!0)},n.prototype.once=function(e,t){return o(t),this.on(e,d(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){return o(t),this.prependListener(e,d(this,e,t)),this},n.prototype.removeListener=function(e,t){var r,i,s,n,a;if(o(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){a=r[n].listener,s=n;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,a||t)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(e){var t,r,i;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 s,n=Object.keys(r);for(i=0;i<n.length;++i)"removeListener"!==(s=n[i])&&this.removeAllListeners(s);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(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},n.prototype.listeners=function(e){return c(this,e,!0)},n.prototype.rawListeners=function(e){return c(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},n.prototype.listenerCount=f,n.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},558:function(e){!function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var s=a.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return s.path=a.normalizePath(s.path),a.buildURLFromParts(s)}var n=a.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=a.normalizePath(n.path),a.buildURLFromParts(n)):t;var o=a.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 h={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(h.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var u=o.path,d=u.substring(0,u.lastIndexOf("/")+1)+n.path;h.path=a.normalizePath(d)}else h.path=o.path,n.params||(h.params=o.params,n.query||(h.query=o.query));return null===h.path&&(h.path=r.alwaysNormalize?a.normalizePath(n.path):n.path),a.buildURLFromParts(h)},parseURL:function(e){var t=r.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(s,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=a}()},251:e=>{!function t(r){var i;i=function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function i(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){var r,n,a;r=t,n=e,a=i[e],(n=s(n))in r?Object.defineProperty(r,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[n]=a})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function s(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,s(i.key),i)}}function a(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},o.apply(this,arguments)}function l(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,u(e,t)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function d(e,t,r){return d=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var s=new(Function.bind.apply(e,i));return r&&u(s,r.prototype),s},d.apply(null,arguments)}function c(e){var t="function"==typeof Map?new Map:void 0;return c=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return d(e,arguments,h(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)},c(e)}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}var g={exports:{}};!function(e,t){var r,i,s,n,a;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,s=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var s=a.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");return s.path=a.normalizePath(s.path),a.buildURLFromParts(s)}var n=a.parseURL(t);if(!n)throw new Error("Error trying to parse relative URL.");if(n.scheme)return r.alwaysNormalize?(n.path=a.normalizePath(n.path),a.buildURLFromParts(n)):t;var o=a.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 h={scheme:o.scheme,netLoc:n.netLoc,path:null,params:n.params,query:n.query,fragment:n.fragment};if(!n.netLoc&&(h.netLoc=o.netLoc,"/"!==n.path[0]))if(n.path){var u=o.path,d=u.substring(0,u.lastIndexOf("/")+1)+n.path;h.path=a.normalizePath(d)}else h.path=o.path,n.params||(h.params=o.params,n.query||(h.query=o.query));return null===h.path&&(h.path=r.alwaysNormalize?a.normalizePath(n.path):n.path),a.buildURLFromParts(h)},parseURL:function(e){var t=r.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(s,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=a}(g);var p=g.exports,m=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},v=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=y},y=Number.MAX_SAFE_INTEGER||9007199254740991,E=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e}({}),S=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),T=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({}),_=function(){},b={trace:_,debug:_,log:_,warn:_,info:_,error:_},L=b;function R(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach((function(t){L[t]=e[t]?e[t].bind(e):function(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):_}(t)}))}(e,"debug","log","info","warn","error");try{L.log('Debug logs enabled for "'+t+'" in hls.js version 1.5.20')}catch(e){L=b}}else L=b}var A=L,w=/^(\d+)x(\d+)$/,P=/(.+?)=(".*?"|.*?)(?:,|$)/g,I=function(){function e(t){"string"==typeof t&&(t=e.parseAttrList(t)),o(this,t)}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=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),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=w.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(P.lastIndex=0;null!==(t=P.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1].trim()]=i}return r},a(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}]),e}();function k(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}var C=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(e,i)&&e[i]!==r[i]){A.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=i;break}e=o(new I({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var s=new Date(this.attr["END-DATE"]);m(s.getTime())&&(this._endDate=s)}}return a(e,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(m(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&m(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),e}(),D=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},M="audio",x="video",O="audiovideo",F=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[M]=null,t[x]=null,t[O]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r,i=e.split("@",2);r=1===i.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]},a(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=p.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),N=function(e){function t(t,r){var i;return(i=e.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new D,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.urlId=0,i.type=t,i}l(t,e);var r=t.prototype;return r.setKeyFormat=function(e){if(this.levelkeys){var t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}},r.abortRequests=function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()},r.setElementaryStreamInfo=function(e,t,r,i,s,n){void 0===n&&(n=!1);var a=this.elementaryStreams,o=a[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,s)):a[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:s,partial:n}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[M]=null,e[x]=null,e[O]=null},a(t,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{var t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!m(this.programDateTime))return null;var e=m(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),r=t.length;if(r>1||1===r&&this.levelkeys[t[0]].encrypted)return!0}return!1}}]),t}(F),B=function(e){function t(t,r,i,s,n){var a;(a=e.call(this,i)||this).fragOffset=0,a.duration=0,a.gap=!1,a.independent=!1,a.relurl=void 0,a.fragment=void 0,a.index=void 0,a.stats=new D,a.duration=t.decimalFloatingPoint("DURATION"),a.gap=t.bool("GAP"),a.independent=t.bool("INDEPENDENT"),a.relurl=t.enumeratedString("URI"),a.fragment=r,a.index=s;var o=t.enumeratedString("BYTERANGE");return o&&a.setByteRange(o,n),n&&(a.fragOffset=n.fragOffset+n.duration),a}return l(t,e),a(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(F),U=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},a(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&m(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),e}();function G(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function H(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}var $="undefined"!=typeof self?self:void 0,K={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},W="org.w3.clearkey",q="com.apple.streamingkeydelivery",V="com.microsoft.playready",j="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function z(e){switch(e){case q:return K.FAIRPLAY;case V:return K.PLAYREADY;case j:return K.WIDEVINE;case W:return K.CLEARKEY}}function Y(e){return"edef8ba979d64acea3c827dcd51d21ed"===e?K.WIDEVINE:"9a04f07998404286ab92e65be0885f95"===e?K.PLAYREADY:"1077efecc0b24d02ace33c1e52e2fb4b"===e||"e2719d58a985b3c9781ab030af78d30e"===e?K.CLEARKEY:void 0}function X(e){switch(e){case K.FAIRPLAY:return q;case K.PLAYREADY:return V;case K.WIDEVINE:return j;case K.CLEARKEY:return W}}function Q(e){var t=e.drmSystems,r=e.widevineLicenseUrl,i=t?[K.FAIRPLAY,K.WIDEVINE,K.PLAYREADY,K.CLEARKEY].filter((function(e){return!!t[e]})):[];return!i[K.WIDEVINE]&&r&&i.push(K.WIDEVINE),i}var J,Z=null!=$&&null!=(J=$.navigator)&&J.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function ee(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),r=String.fromCharCode.apply(null,Array.from(t)),i=r.substring(r.indexOf("<"),r.length),s=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(s){var n=s.childNodes[0]?s.childNodes[0].nodeValue:s.getAttribute("VALUE");if(n){var a=G(n).subarray(0,16);return function(e){var t=function(e,t,r){var i=e[t];e[t]=e[r],e[r]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(a),a}}return null}function te(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}var re,ie=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},se=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},ne=function(e,t){for(var r=t,i=0;ie(e,t);)i+=10,i+=ae(e,t+6),se(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},ae=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,(r|=(127&e[t+2])<<7)|127&e[t+3]},oe=function(e,t){return ie(e,t)&&ae(e,t+6)+10<=e.length-t},le=function(e){for(var t=de(e),r=0;r<t.length;r++){var i=t[r];if(he(i))return me(i)}},he=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},ue=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=ae(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},de=function(e){for(var t=0,r=[];ie(e,t);){for(var i=ae(e,t+6),s=(t+=10)+i;t+8<s;){var n=ue(e.subarray(t)),a=ce(n);a&&r.push(a),t+=n.size+10}se(e,t)&&(t+=10)}return r},ce=function(e){return"PRIV"===e.type?fe(e):"W"===e.type[0]?pe(e):ge(e)},fe=function(e){if(!(e.size<2)){var t=ve(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},ge=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=ve(e.data.subarray(t),!0);t+=r.length+1;var i=ve(e.data.subarray(t));return{key:e.type,info:r,data:i}}var s=ve(e.data.subarray(1));return{key:e.type,data:s}}},pe=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=ve(e.data.subarray(t),!0);t+=r.length+1;var i=ve(e.data.subarray(t));return{key:e.type,info:r,data:i}}var s=ve(e.data);return{key:e.type,data:s}},me=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},ve=function(e,t){void 0===t&&(t=!1);var r=function(){if(!navigator.userAgent.includes("PlayStation 4"))return re||void 0===self.TextDecoder||(re=new self.TextDecoder("utf-8")),re}();if(r){var i=r.decode(e);if(t){var s=i.indexOf("\0");return-1!==s?i.substring(0,s):i}return i.replace(/\0/g,"")}for(var n,a,o,l=e.length,h="",u=0;u<l;){if(0===(n=e[u++])&&t)return h;if(0!==n&&3!==n)switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:h+=String.fromCharCode(n);break;case 12:case 13:a=e[u++],h+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[u++],o=e[u++],h+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&o)}}return h};var ye=function(e){for(var t="",r=0;r<e.length;r++){var i=e[r].toString(16);i.length<2&&(i="0"+i),t+=i}return t},Ee=Math.pow(2,32)-1,Se=[].push,Te={video:1,audio:2,id3:3,text:4};function _e(e){return String.fromCharCode.apply(null,e)}function be(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function Le(e,t){var r=Ae(e,t);return r<0?4294967296+r:r}function Re(e,t){var r=Le(e,t);return(r*=Math.pow(2,32))+Le(e,t+4)}function Ae(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function we(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function Pe(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,s=0;s<i;){var n=Le(e,s),a=n>1?s+n:i;if(_e(e.subarray(s+4,s+8))===t[0])if(1===t.length)r.push(e.subarray(s+8,a));else{var o=Pe(e.subarray(s+8,a),t.slice(1));o.length&&Se.apply(r,o)}s=a}return r}function Ie(e){var t=[],r=e[0],i=8,s=Le(e,i);i+=4;var n=0,a=0;0===r?(n=Le(e,i),a=Le(e,i+4),i+=8):(n=Re(e,i),a=Re(e,i+8),i+=16),i+=2;var o=e.length+a,l=be(e,i);i+=2;for(var h=0;h<l;h++){var u=i,d=Le(e,u);u+=4;var c=2147483647&d;if(1==(2147483648&d)>>>31)return A.warn("SIDX has hierarchical references (not supported)"),null;var f=Le(e,u);u+=4,t.push({referenceSize:c,subsegmentDuration:f,info:{duration:f/s,start:o,end:o+c-1}}),o+=c,i=u+=4}return{earliestPresentationTime:n,timescale:s,version:r,referencesCount:l,references:t}}function ke(e){for(var t=[],r=Pe(e,["moov","trak"]),s=0;s<r.length;s++){var n=r[s],a=Pe(n,["tkhd"])[0];if(a){var o=a[0],l=Le(a,0===o?12:20),h=Pe(n,["mdia","mdhd"])[0];if(h){var u=Le(h,0===(o=h[0])?12:20),d=Pe(n,["mdia","hdlr"])[0];if(d){var c=_e(d.subarray(8,12)),f={soun:M,vide:x}[c];if(f){var g=Ce(Pe(n,["mdia","minf","stbl","stsd"])[0]);t[l]={timescale:u,type:f},t[f]=i({timescale:u,id:l},g)}}}}}return Pe(e,["moov","mvex","trex"]).forEach((function(e){var r=Le(e,4),i=t[r];i&&(i.default={duration:Le(e,12),flags:Le(e,20)})})),t}function Ce(e){var t=e.subarray(8),r=t.subarray(86),i=_e(t.subarray(4,8)),s=i,n="enca"===i||"encv"===i;if(n){var a=Pe(t,[i])[0];Pe(a.subarray("enca"===i?28:78),["sinf"]).forEach((function(e){var t=Pe(e,["schm"])[0];if(t){var r=_e(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=Pe(e,["frma"])[0];i&&(s=_e(i))}}}))}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":var o=Pe(r,["avcC"])[0];s+="."+Me(o[1])+Me(o[2])+Me(o[3]);break;case"mp4a":var l=Pe(t,[i])[0],h=Pe(l.subarray(28),["esds"])[0];if(h&&h.length>12){var u=4;if(3!==h[u++])break;u=De(h,u),u+=2;var d=h[u++];if(128&d&&(u+=2),64&d&&(u+=h[u++]),4!==h[u++])break;u=De(h,u);var c=h[u++];if(64!==c)break;if(s+="."+Me(c),u+=12,5!==h[u++])break;u=De(h,u);var f=h[u++],g=(248&f)>>3;31===g&&(g+=1+((7&f)<<3)+((224&h[u])>>5)),s+="."+g}break;case"hvc1":case"hev1":var p=Pe(r,["hvcC"])[0],m=p[1],v=["","A","B","C"][m>>6],y=31&m,E=Le(p,2),S=(32&m)>>5?"H":"L",T=p[12],_=p.subarray(6,12);s+="."+v+y,s+="."+E.toString(16).toUpperCase(),s+="."+S+T;for(var b="",L=_.length;L--;){var R=_[L];(R||b)&&(b="."+R.toString(16).toUpperCase()+b)}s+=b;break;case"dvh1":case"dvhe":var A=Pe(r,["dvcC"])[0],w=A[2]>>1&127,P=A[2]<<5&32|A[3]>>3&31;s+="."+xe(w)+"."+xe(P);break;case"vp09":var I=Pe(r,["vpcC"])[0],k=I[4],C=I[5],D=I[6]>>4&15;s+="."+xe(k)+"."+xe(C)+"."+xe(D);break;case"av01":var M=Pe(r,["av1C"])[0],x=M[1]>>>5,O=31&M[1],F=M[2]>>>7?"H":"M",N=(64&M[2])>>6,B=(32&M[2])>>5,U=2===x&&N?B?12:10:N?10:8,G=(16&M[2])>>4,H=(8&M[2])>>3,$=(4&M[2])>>2,K=3&M[2];s+="."+x+"."+xe(O)+F+"."+xe(U)+"."+G+"."+H+$+K+"."+xe(1)+"."+xe(1)+"."+xe(1)+".0"}return{codec:s,encrypted:n}}function De(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function Me(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function xe(e){return(e<10?"0":"")+e}function Oe(e){var t=Pe(e,["schm"])[0];if(t){var r=_e(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return Pe(e,["schi","tenc"])[0]}return null}function Fe(e){var t=Le(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,s=Le(e,4),n=0;n<s;n++)256&t&&(i+=Le(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function Ne(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function Be(e,t){var r=[],i=t.samples,s=t.timescale,n=t.id,a=!1;return Pe(i,["moof"]).map((function(o){var l=o.byteOffset-8;Pe(o,["traf"]).map((function(o){var h=Pe(o,["tfdt"]).map((function(e){var t=e[0],r=Le(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Le(e,8)),r/s}))[0];return void 0!==h&&(e=h),Pe(o,["tfhd"]).map((function(h){var u=Le(h,4),d=16777215&Le(h,0),c=0,f=!!(16&d),g=0,p=!!(32&d),m=8;u===n&&(!!(1&d)&&(m+=8),!!(2&d)&&(m+=4),!!(8&d)&&(c=Le(h,m),m+=4),f&&(g=Le(h,m),m+=4),p&&(m+=4),"video"===t.type&&(a=function(e){if(!e)return!1;var t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),Pe(o,["trun"]).map((function(n){var o=n[0],h=16777215&Le(n,0),u=!!(1&h),d=0,f=!!(4&h),p=!!(256&h),m=0,v=!!(512&h),y=0,E=!!(1024&h),S=!!(2048&h),T=0,_=Le(n,4),b=8;u&&(d=Le(n,b),b+=4),f&&(b+=4);for(var L=d+l,R=0;R<_;R++){if(p?(m=Le(n,b),b+=4):m=c,v?(y=Le(n,b),b+=4):y=g,E&&(b+=4),S&&(T=0===o?Le(n,b):Ae(n,b),b+=4),t.type===x)for(var A=0;A<y;){var w=Le(i,L);Ue(a,i[L+=4])&&Ge(i.subarray(L,L+w),a?2:1,e+T/s,r),L+=w,A+=w+4}e+=m/s}})))}))}))})),r}function Ue(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function Ge(e,t,r,i){var s=He(e),n=0;n+=t;for(var a=0,o=0,l=0;n<s.length;){a=0;do{if(n>=s.length)break;a+=l=s[n++]}while(255===l);o=0;do{if(n>=s.length)break;o+=l=s[n++]}while(255===l);var h=s.length-n,u=n;if(o<h)n+=o;else if(o>h){A.error("Malformed SEI payload. "+o+" is too small, only "+h+" bytes left to parse.");break}if(4===a){if(181===s[u++]){var d=be(s,u);if(u+=2,49===d){var c=Le(s,u);if(u+=4,1195456820===c){var f=s[u++];if(3===f){var g=s[u++],p=64&g,m=p?2+3*(31&g):0,v=new Uint8Array(m);if(p){v[0]=g;for(var y=1;y<m;y++)v[y]=s[u++]}i.push({type:f,payloadType:a,pts:r,bytes:v})}}}}}else if(5===a&&o>16){for(var E=[],S=0;S<16;S++){var T=s[u++].toString(16);E.push(1==T.length?"0"+T:T),3!==S&&5!==S&&7!==S&&9!==S||E.push("-")}for(var _=o-16,b=new Uint8Array(_),L=0;L<_;L++)b[L]=s[u++];i.push({payloadType:a,pts:r,uuid:E.join(""),userData:ve(b),userDataBytes:b})}}}function He(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var s=t-r.length,n=new Uint8Array(s),a=0;for(i=0;i<s;a++,i++)a===r[0]&&(a++,r.shift()),n[i]=e[a];return n}function $e(e){var t=e.getUint32(0),r=e.byteOffset,i=e.byteLength;if(i<t)return{offset:r,size:i};if(1886614376!==e.getUint32(4))return{offset:r,size:t};var s=e.getUint32(8)>>>24;if(0!==s&&1!==s)return{offset:r,size:t};var n=e.buffer,a=ye(new Uint8Array(n,r+12,16)),o=e.getUint32(28),l=null,h=null;if(0===s){if(t-32<o||o<22)return{offset:r,size:t};h=new Uint8Array(n,r+32,o)}else if(1===s){if(!o||i<r+32+16*o+16)return{offset:r,size:t};l=[];for(var u=0;u<o;u++)l.push(new Uint8Array(n,r+32+16*u,16))}return{version:s,systemId:a,kids:l,data:h,offset:r,size:t}}var Ke={},We=function(){function e(e,t,r,i,s){void 0===i&&(i=[1]),void 0===s&&(s=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=s,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}e.clearKeyUriToKeyIdMap=function(){Ke={}};var t=e.prototype;return t.isSupported=function(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case q:case j:case V:case W:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof t&&("AES-128"!==this.method||this.iv||A.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var r=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,r)}var i=function(e){var t,r,i=e.split(":"),s=null;if("data"===i[0]&&2===i.length){var n=i[1].split(";"),a=n[n.length-1].split(",");if(2===a.length){var o="base64"===a[0],l=a[1];o?(n.splice(-1,1),s=G(l)):(t=H(l).subarray(0,16),(r=new Uint8Array(16)).set(t,16-t.length),s=r)}}return s}(this.uri);if(i)switch(this.keyFormat){case j:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case V:var s=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");var i,s,n;if(t){i=1,s=new Uint8Array(16*t.length);for(var a=0;a<t.length;a++){var o=t[a];if(16!==o.byteLength)throw new RangeError("Invalid key");s.set(o,16*a)}}else i=0,s=new Uint8Array;i>0?(n=new Uint8Array(4),t.length>0&&new DataView(n.buffer).setUint32(0,t.length,!1)):n=new Uint8Array;var l=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(l.buffer).setUint32(0,r.byteLength,!1),function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var s=r.length,n=8,a=s;a--;)n+=r[a].byteLength;var o=new Uint8Array(n);for(o[0]=n>>24&255,o[1]=n>>16&255,o[2]=n>>8&255,o[3]=255&n,o.set(e,4),a=0,n=8;a<s;a++)o.set(r[a],n),n+=r[a].byteLength;return o}([112,115,115,104],new Uint8Array([i,0,0,0]),e,n,s,l,r||new Uint8Array)}(s,null,i),this.keyId=ee(i);break;default:var n=i.subarray(0,16);if(16!==n.length){var a=new Uint8Array(16);a.set(n,16-n.length),n=a}this.keyId=n}if(!this.keyId||16!==this.keyId.byteLength){var o=Ke[this.uri];if(!o){var l=Object.keys(Ke).length%Number.MAX_SAFE_INTEGER;o=new Uint8Array(16),new DataView(o.buffer,12,4).setUint32(0,l),Ke[this.uri]=o}this.keyId=o}return this},e}(),qe=/\{\$([a-zA-Z0-9-_]+)\}/g;function Ve(e){return qe.test(e)}function je(e,t,r){if(null!==e.variableList||e.hasVariableRefs)for(var i=r.length;i--;){var s=r[i],n=t[s];n&&(t[s]=ze(e,n))}}function ze(e,t){if(null!==e.variableList||e.hasVariableRefs){var r=e.variableList;return t.replace(qe,(function(t){var i=t.substring(2,t.length-1),s=null==r?void 0:r[i];return void 0===s?(e.playlistParsingError||(e.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+i+'"')),t):s}))}return t}function Ye(e,t,r){var i,s,n=e.variableList;if(n||(e.variableList=n={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{var a=new self.URL(r).searchParams;if(!a.has(i))throw new Error('"'+i+'" does not match any query parameter in URI: "'+r+'"');s=a.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+t.message))}}else i=t.NAME,s=t.VALUE;i in n?e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+i+'"')):n[i]=s||""}function Xe(e,t,r){var i=t.IMPORT;if(r&&i in r){var s=e.variableList;s||(e.variableList=s={}),s[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+i+'"'))}function Qe(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var Je={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function Ze(e,t,r){return void 0===r&&(r=!0),!e.split(",").some((function(e){return!et(e,t,r)}))}function et(e,t,r){var i;void 0===r&&(r=!0);var s=Qe(r);return null!=(i=null==s?void 0:s.isTypeSupported(tt(e,t)))&&i}function tt(e,t){return t+'/mp4;codecs="'+e+'"'}function rt(e){if(e){var t=e.substring(0,4);return Je.video[t]}return 2}function it(e){return e.split(",").reduce((function(e,t){var r=Je.video[t];return r?(2*r+e)/(e?3:2):(Je.audio[t]+e)/(e?2:1)}),0)}var st={},nt=/flac|opus/i;function at(e,t){return void 0===t&&(t=!0),e.replace(nt,(function(e){return function(e,t){if(void 0===t&&(t=!0),st[e])return st[e];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e],i=0;i<r.length;i++)if(et(r[i],"audio",t))return st[e]=r[i],r[i];return e}(e.toLowerCase(),t)}))}function ot(e,t){return e&&"mp4a"!==e?e:t?t.split(",")[0]:t}var lt=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,ht=/#EXT-X-MEDIA:(.*)/g,ut=/^#EXT(?:INF|-X-TARGETDURATION):/m,dt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ct=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ft=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.resolve=function(e,t){return p.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.isMediaPlaylist=function(e){return ut.test(e)},e.parseMasterPlaylist=function(t,r){var i,s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Ve(t)},n=[];for(lt.lastIndex=0;null!=(i=lt.exec(t));)if(i[1]){var a,o=new I(i[1]);je(s,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=ze(s,i[2]),h={attrs:o,bitrate:o.decimalInteger("BANDWIDTH")||o.decimalInteger("AVERAGE-BANDWIDTH"),name:o.NAME,url:e.resolve(l,r)},u=o.decimalResolution("RESOLUTION");u&&(h.width=u.width,h.height=u.height),mt(o.CODECS,h),null!=(a=h.unknownCodecs)&&a.length||n.push(h),s.levels.push(h)}else if(i[3]){var d=i[3],c=i[4];switch(d){case"SESSION-DATA":var f=new I(c);je(s,f,["DATA-ID","LANGUAGE","VALUE","URI"]);var g=f["DATA-ID"];g&&(null===s.sessionData&&(s.sessionData={}),s.sessionData[g]=f);break;case"SESSION-KEY":var p=gt(c,r,s);p.encrypted&&p.isSupported()?(null===s.sessionKeys&&(s.sessionKeys=[]),s.sessionKeys.push(p)):A.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+c+'"');break;case"DEFINE":var m=new I(c);je(s,m,["NAME","VALUE","QUERYPARAM"]),Ye(s,m,r);break;case"CONTENT-STEERING":var v=new I(c);je(s,v,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:e.resolve(v["SERVER-URI"],r),pathwayId:v["PATHWAY-ID"]||"."};break;case"START":s.startTimeOffset=pt(c)}}var y=n.length>0&&n.length<s.levels.length;return s.levels=y?n:s.levels,0===s.levels.length&&(s.playlistParsingError=new Error("no levels found in manifest")),s},e.parseMasterPlaylistMedia=function(t,r,i){var s,n={},a=i.levels,o={AUDIO:a.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),SUBTITLES:a.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),"CLOSED-CAPTIONS":[]},l=0;for(ht.lastIndex=0;null!==(s=ht.exec(t));){var h=new I(s[1]),u=h.TYPE;if(u){var d=o[u],c=n[u]||[];n[u]=c,je(i,h,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var f=h.LANGUAGE,g=h["ASSOC-LANGUAGE"],p=h.CHANNELS,m=h.CHARACTERISTICS,v=h["INSTREAM-ID"],y={attrs:h,bitrate:0,id:l++,groupId:h["GROUP-ID"]||"",name:h.NAME||f||"",type:u,default:h.bool("DEFAULT"),autoselect:h.bool("AUTOSELECT"),forced:h.bool("FORCED"),lang:f,url:h.URI?e.resolve(h.URI,r):""};if(g&&(y.assocLang=g),p&&(y.channels=p),m&&(y.characteristics=m),v&&(y.instreamId=v),null!=d&&d.length){var E=e.findGroup(d,y.groupId)||d[0];vt(y,E,"audioCodec"),vt(y,E,"textCodec")}c.push(y)}}return n},e.parseLevelPlaylist=function(e,t,r,i,s,n){var a,l,h,u=new U(t),d=u.fragments,c=null,f=0,g=0,p=0,v=0,y=null,E=new N(i,t),S=-1,T=!1,_=null;for(dt.lastIndex=0,u.m3u8=e,u.hasVariableRefs=Ve(e);null!==(a=dt.exec(e));){T&&(T=!1,(E=new N(i,t)).start=p,E.sn=f,E.cc=v,E.level=r,c&&(E.initSegment=c,E.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,_&&(E.setByteRange(_),_=null)));var b=a[1];if(b){E.duration=parseFloat(b);var L=(" "+a[2]).slice(1);E.title=L||null,E.tagList.push(L?["INF",b,L]:["INF",b])}else if(a[3]){if(m(E.duration)){E.start=p,h&&St(E,h,u),E.sn=f,E.level=r,E.cc=v,d.push(E);var R=(" "+a[3]).slice(1);E.relurl=ze(u,R),yt(E,y),y=E,p+=E.duration,f++,g=0,T=!0}}else if(a[4]){var w=(" "+a[4]).slice(1);y?E.setByteRange(w,y):E.setByteRange(w)}else if(a[5])E.rawProgramDateTime=(" "+a[5]).slice(1),E.tagList.push(["PROGRAM-DATE-TIME",E.rawProgramDateTime]),-1===S&&(S=d.length);else{if(!(a=a[0].match(ct))){A.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<a.length&&void 0===a[l];l++);var P=(" "+a[l]).slice(1),k=(" "+a[l+1]).slice(1),D=a[l+2]?(" "+a[l+2]).slice(1):"";switch(P){case"PLAYLIST-TYPE":u.type=k.toUpperCase();break;case"MEDIA-SEQUENCE":f=u.startSN=parseInt(k);break;case"SKIP":var M=new I(k);je(u,M,["RECENTLY-REMOVED-DATERANGES"]);var x=M.decimalInteger("SKIPPED-SEGMENTS");if(m(x)){u.skippedSegments=x;for(var O=x;O--;)d.unshift(null);f+=x}var F=M.enumeratedString("RECENTLY-REMOVED-DATERANGES");F&&(u.recentlyRemovedDateranges=F.split("\t"));break;case"TARGETDURATION":u.targetduration=Math.max(parseInt(k),1);break;case"VERSION":u.version=parseInt(k);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"#":(k||D)&&E.tagList.push(D?[k,D]:[k]);break;case"DISCONTINUITY":v++,E.tagList.push(["DIS"]);break;case"GAP":E.gap=!0,E.tagList.push([P]);break;case"BITRATE":E.tagList.push([P,k]);break;case"DATERANGE":var G=new I(k);je(u,G,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),je(u,G,G.clientAttrs);var H=new C(G,u.dateRanges[G.ID]);H.isValid||u.skippedSegments?u.dateRanges[H.id]=H:A.warn('Ignoring invalid DATERANGE tag: "'+k+'"'),E.tagList.push(["EXT-X-DATERANGE",k]);break;case"DEFINE":var $=new I(k);je(u,$,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in $?Xe(u,$,n):Ye(u,$,t);break;case"DISCONTINUITY-SEQUENCE":v=parseInt(k);break;case"KEY":var K=gt(k,t,u);if(K.isSupported()